diff options
author | Armin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de> | 2023-12-08 12:42:37 +0100 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@me.com> | 2023-12-11 10:29:32 +0100 |
commit | 6c986c718630ab21e6d9b5d353ddf1534e2dda41 (patch) | |
tree | 80b925219d27576321c0a2a10a4fc0fa05f324f7 /chart2/source/tools/PropertyHelper.cxx | |
parent | ece6c0eef5a6105541d378c09a10b1f0903882de (diff) |
tdf#158421 use correct awt:Gradient2 in Chart lists
Change-Id: I5fa02c2660d59981f540cde8bd6eaaaaddb30e65
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160463
Tested-by: Jenkins
Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'chart2/source/tools/PropertyHelper.cxx')
-rw-r--r-- | chart2/source/tools/PropertyHelper.cxx | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/chart2/source/tools/PropertyHelper.cxx b/chart2/source/tools/PropertyHelper.cxx index 90e0b06cdf59..48e21eccaf25 100644 --- a/chart2/source/tools/PropertyHelper.cxx +++ b/chart2/source/tools/PropertyHelper.cxx @@ -20,6 +20,7 @@ #include <PropertyHelper.hxx> #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <docmodel/uno/UnoGradientTools.hxx> #include <comphelper/sequence.hxx> #include <osl/diagnose.h> #include <comphelper/diagnose_ex.hxx> @@ -113,15 +114,29 @@ OUString lcl_addNamedPropertyUniqueNameToTable( const OUString & rPreferredName ) { if( ! xNameContainer.is() || - ! rValue.hasValue() || - ( rValue.getValueType() != xNameContainer->getElementType())) + ! 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; try { Reference< container::XNameAccess > xNameAccess( xNameContainer, uno::UNO_QUERY_THROW ); const uno::Sequence<OUString> aElementNames = xNameAccess->getElementNames(); - auto it = std::find_if( aElementNames.begin(), aElementNames.end(), lcl_EqualsElement( rValue, xNameAccess )); + auto it = std::find_if( aElementNames.begin(), aElementNames.end(), lcl_EqualsElement( aValue, xNameAccess )); // element found => return name if( it != aElementNames.end()) @@ -159,7 +174,7 @@ OUString lcl_addNamedPropertyUniqueNameToTable( } OSL_ASSERT( !aUniqueName.isEmpty()); - xNameContainer->insertByName( aUniqueName, rValue ); + xNameContainer->insertByName( aUniqueName, aValue ); return aUniqueName; } catch( const uno::Exception & ) |