/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/** adds a fill gradient, fill hatch, fill bitmap, fill transparency gradient, line dash or line marker to the corresponding name container with a unique name.
@param rPrefix The prefix used for automated name generation.
@param rPreferredName If this string is not empty it is used as name if it is unique in the table. Otherwise a new name is generated using pPrefix.
@return the new name under which the property was stored in the table
*/
OUString lcl_addNamedPropertyUniqueNameToTable( const Any & rValue, const Reference< container::XNameContainer > & xNameContainer, const OUString & rPrefix, const OUString & rPreferredName )
{ if( ! xNameContainer.is() ||
! rValue.hasValue() ) return rPreferredName;
Any aValue(rValue);
if ( rValue.has<css::awt::Gradient>())
{ // tdf#158421 the lists for Gradients needs awt::Gradient2 // as type, convert input data if needed (and warn about it, // the caller should be changed to offer the needed type)
SAL_WARN("chart2","input value needs to be awt::Gradient2"); const basegfx::BGradient aTemp(model::gradient::getFromAny(rValue));
aValue <<= model::gradient::createUnoGradient2(aTemp);
}
if ( aValue.getValueType() != xNameContainer->getElementType()) return rPreferredName;
// element found => return name if( it != aElementNames.end()) return *it;
// element not found in container
OUString aUniqueName;
// check if preferred name is already used if( !rPreferredName.isEmpty())
{ auto aIt = std::find( aElementNames.begin(), aElementNames.end(), rPreferredName ); if( aIt == aElementNames.end())
aUniqueName = rPreferredName;
}
if( aUniqueName.isEmpty())
{ auto aNames( comphelper::sequenceToContainer<std::vector< OUString >>( aElementNames )); // create a unique id using the prefix plus a number
std::vector< sal_Int32 > aNumbers;
std::vector< OUString >::iterator aNonConstIt(
std::partition( aNames.begin(), aNames.end(), lcl_StringMatches( rPrefix )));
std::transform( aNames.begin(), aNonConstIt,
back_inserter( aNumbers ),
lcl_OUStringRestToInt32( rPrefix.getLength() ));
std::vector< sal_Int32 >::const_iterator aMaxIt(
std::max_element( aNumbers.begin(), aNumbers.end()));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.