diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-03-21 16:56:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-23 06:12:00 +0000 |
commit | 1131b090ed9b68300c0b08366e6cb7d7fee453e5 (patch) | |
tree | be5d673b838d71e59edc12511a278a8108a4b710 /chart2 | |
parent | 4e8f36fcd43c6ccc9d07211ebc8e7ee53d2e33d1 (diff) |
rtl::Static-> thread-safe-static in chart2
Change-Id: I5bd595d5251cd92904750d6e6830f1d95f41b177
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149338
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/model/template/AreaChartTypeTemplate.cxx | 76 | ||||
-rw-r--r-- | chart2/source/model/template/BarChartTypeTemplate.cxx | 83 | ||||
-rw-r--r-- | chart2/source/model/template/BubbleChartType.cxx | 69 | ||||
-rw-r--r-- | chart2/source/model/template/BubbleChartTypeTemplate.cxx | 72 | ||||
-rw-r--r-- | chart2/source/model/template/CandleStickChartType.cxx | 89 | ||||
-rw-r--r-- | chart2/source/model/template/ChartType.cxx | 33 | ||||
-rw-r--r-- | chart2/source/model/template/ColumnChartType.cxx | 88 |
7 files changed, 135 insertions, 375 deletions
diff --git a/chart2/source/model/template/AreaChartTypeTemplate.cxx b/chart2/source/model/template/AreaChartTypeTemplate.cxx index d1f63b2ba866..f2ff81a1e8d1 100644 --- a/chart2/source/model/template/AreaChartTypeTemplate.cxx +++ b/chart2/source/model/template/AreaChartTypeTemplate.cxx @@ -55,58 +55,19 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticAreaChartTypeTemplateDefaults_Initializer +::cppu::OPropertyArrayHelper& StaticAreaChartTypeTemplateInfoHelper() { - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aStaticDefaults, PROP_AREA_TEMPLATE_DIMENSION, 2 ); - return &aStaticDefaults; - } -}; - -struct StaticAreaChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticAreaChartTypeTemplateDefaults_Initializer > -{ -}; - -struct StaticAreaChartTypeTemplateInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static uno::Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticAreaChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticAreaChartTypeTemplateInfoHelper_Initializer > -{ -}; - -struct StaticAreaChartTypeTemplateInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticAreaChartTypeTemplateInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; - -struct StaticAreaChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticAreaChartTypeTemplateInfo_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -132,9 +93,14 @@ AreaChartTypeTemplate::~AreaChartTypeTemplate() // ____ OPropertySet ____ void AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticAreaChartTypeTemplateDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); - if( aFound == rStaticDefaults.end() ) + static ::chart::tPropertyValueMap aStaticDefaults = []() + { + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_AREA_TEMPLATE_DIMENSION, 2 ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) ); + if( aFound == aStaticDefaults.end() ) rAny.clear(); else rAny = (*aFound).second; @@ -142,13 +108,15 @@ void AreaChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) ::cppu::IPropertyArrayHelper & SAL_CALL AreaChartTypeTemplate::getInfoHelper() { - return *StaticAreaChartTypeTemplateInfoHelper::get(); + return StaticAreaChartTypeTemplateInfoHelper(); } // ____ XPropertySet ____ uno::Reference< beans::XPropertySetInfo > SAL_CALL AreaChartTypeTemplate::getPropertySetInfo() { - return *StaticAreaChartTypeTemplateInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticAreaChartTypeTemplateInfoHelper() ) ); + return xPropertySetInfo; } sal_Int32 AreaChartTypeTemplate::getDimension() const diff --git a/chart2/source/model/template/BarChartTypeTemplate.cxx b/chart2/source/model/template/BarChartTypeTemplate.cxx index 54f4f155186b..1381e09cc413 100644 --- a/chart2/source/model/template/BarChartTypeTemplate.cxx +++ b/chart2/source/model/template/BarChartTypeTemplate.cxx @@ -62,64 +62,19 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticBarChartTypeTemplateDefaults_Initializer +::cppu::OPropertyArrayHelper& StaticBarChartTypeTemplateInfoHelper() { - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_BAR_TEMPLATE_DIMENSION, 2 ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BAR_TEMPLATE_GEOMETRY3D, ::chart2::DataPointGeometry3D::CUBOID ); - } -}; - -struct StaticBarChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBarChartTypeTemplateDefaults_Initializer > -{ -}; - -struct StaticBarChartTypeTemplateInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } - -}; - -struct StaticBarChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBarChartTypeTemplateInfoHelper_Initializer > -{ -}; + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); -struct StaticBarChartTypeTemplateInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBarChartTypeTemplateInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticBarChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBarChartTypeTemplateInfo_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -212,9 +167,15 @@ rtl::Reference< ChartType > BarChartTypeTemplate::getChartTypeForNewSeries2( // ____ OPropertySet ____ void BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticBarChartTypeTemplateDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); - if( aFound == rStaticDefaults.end() ) + static ::chart::tPropertyValueMap aStaticDefaults = []() + { + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aTmp, PROP_BAR_TEMPLATE_DIMENSION, 2 ); + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BAR_TEMPLATE_GEOMETRY3D, ::chart2::DataPointGeometry3D::CUBOID ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) ); + if( aFound == aStaticDefaults.end() ) rAny.clear(); else rAny = (*aFound).second; @@ -222,13 +183,15 @@ void BarChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) ::cppu::IPropertyArrayHelper & SAL_CALL BarChartTypeTemplate::getInfoHelper() { - return *StaticBarChartTypeTemplateInfoHelper::get(); + return StaticBarChartTypeTemplateInfoHelper(); } // ____ XPropertySet ____ Reference< beans::XPropertySetInfo > SAL_CALL BarChartTypeTemplate::getPropertySetInfo() { - return *StaticBarChartTypeTemplateInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticBarChartTypeTemplateInfoHelper() ) ); + return xPropertySetInfo; } void BarChartTypeTemplate::applyStyle2( diff --git a/chart2/source/model/template/BubbleChartType.cxx b/chart2/source/model/template/BubbleChartType.cxx index 3521f7909fb7..bd8bf287d96a 100644 --- a/chart2/source/model/template/BubbleChartType.cxx +++ b/chart2/source/model/template/BubbleChartType.cxx @@ -36,55 +36,16 @@ using ::com::sun::star::uno::Reference; namespace { -struct StaticBubbleChartTypeDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - return &aStaticDefaults; - } -}; - -struct StaticBubbleChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeDefaults_Initializer > -{ -}; - -struct StaticBubbleChartTypeInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticBubbleChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeInfoHelper_Initializer > -{ -}; - -struct StaticBubbleChartTypeInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; - -struct StaticBubbleChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeInfo_Initializer > +::cppu::OPropertyArrayHelper& StaticBubbleChartTypeInfoHelper() { + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -169,9 +130,9 @@ OUString SAL_CALL BubbleChartType::getRoleOfSequenceForSeriesLabel() // ____ OPropertySet ____ void BubbleChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); - if( aFound == rStaticDefaults.end() ) + static ::chart::tPropertyValueMap aStaticDefaults; + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) ); + if( aFound == aStaticDefaults.end() ) rAny.clear(); else rAny = (*aFound).second; @@ -180,13 +141,15 @@ void BubbleChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartType::getInfoHelper() { - return *StaticBubbleChartTypeInfoHelper::get(); + return StaticBubbleChartTypeInfoHelper(); } // ____ XPropertySet ____ uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartType::getPropertySetInfo() { - return *StaticBubbleChartTypeInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticBubbleChartTypeInfoHelper() ) ); + return xPropertySetInfo; } OUString SAL_CALL BubbleChartType::getImplementationName() diff --git a/chart2/source/model/template/BubbleChartTypeTemplate.cxx b/chart2/source/model/template/BubbleChartTypeTemplate.cxx index 4f347793f6f6..55f39ef0669b 100644 --- a/chart2/source/model/template/BubbleChartTypeTemplate.cxx +++ b/chart2/source/model/template/BubbleChartTypeTemplate.cxx @@ -38,56 +38,16 @@ using ::com::sun::star::beans::Property; namespace { -struct StaticBubbleChartTypeTemplateDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - return &aStaticDefaults; - } -}; - -struct StaticBubbleChartTypeTemplateDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticBubbleChartTypeTemplateDefaults_Initializer > -{ -}; - -struct StaticBubbleChartTypeTemplateInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } - -}; - -struct StaticBubbleChartTypeTemplateInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticBubbleChartTypeTemplateInfoHelper_Initializer > -{ -}; - -struct StaticBubbleChartTypeTemplateInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticBubbleChartTypeTemplateInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; - -struct StaticBubbleChartTypeTemplateInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticBubbleChartTypeTemplateInfo_Initializer > -{ +::cppu::OPropertyArrayHelper & StaticBubbleChartTypeTemplateInfoHelper() +{ + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -109,9 +69,9 @@ BubbleChartTypeTemplate::~BubbleChartTypeTemplate() // ____ OPropertySet ____ void BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticBubbleChartTypeTemplateDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); - if( aFound == rStaticDefaults.end() ) + static ::chart::tPropertyValueMap aStaticDefaults; + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) ); + if( aFound == aStaticDefaults.end() ) rAny.clear(); else rAny = (*aFound).second; @@ -119,13 +79,15 @@ void BubbleChartTypeTemplate::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ::cppu::IPropertyArrayHelper & SAL_CALL BubbleChartTypeTemplate::getInfoHelper() { - return *StaticBubbleChartTypeTemplateInfoHelper::get(); + return StaticBubbleChartTypeTemplateInfoHelper(); } // ____ XPropertySet ____ uno::Reference< beans::XPropertySetInfo > SAL_CALL BubbleChartTypeTemplate::getPropertySetInfo() { - return *StaticBubbleChartTypeTemplateInfo::get(); + static const uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticBubbleChartTypeTemplateInfoHelper() ) ); + return xPropertySetInfo; } sal_Int32 BubbleChartTypeTemplate::getDimension() const diff --git a/chart2/source/model/template/CandleStickChartType.cxx b/chart2/source/model/template/CandleStickChartType.cxx index a55a3baa3403..247a68406808 100644 --- a/chart2/source/model/template/CandleStickChartType.cxx +++ b/chart2/source/model/template/CandleStickChartType.cxx @@ -79,66 +79,17 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticCandleStickChartTypeDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - // must match default in CTOR! - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true ); - } -}; - -struct StaticCandleStickChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticCandleStickChartTypeDefaults_Initializer > -{ -}; - -struct StaticCandleStickChartTypeInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } - -}; - -struct StaticCandleStickChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticCandleStickChartTypeInfoHelper_Initializer > -{ -}; - -struct StaticCandleStickChartTypeInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticCandleStickChartTypeInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; - -struct StaticCandleStickChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticCandleStickChartTypeInfo_Initializer > +::cppu::OPropertyArrayHelper& StaticCandleStickChartTypeInfoHelper() { + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -270,9 +221,17 @@ OUString SAL_CALL CandleStickChartType::getRoleOfSequenceForSeriesLabel() // ____ OPropertySet ____ void CandleStickChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticCandleStickChartTypeDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); - if( aFound == rStaticDefaults.end() ) + static const ::chart::tPropertyValueMap aStaticDefaults = []() + { + // must match default in CTOR! + ::chart::tPropertyValueMap aTmp; + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_JAPANESE, false ); + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_SHOW_FIRST, false ); + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_CANDLESTICKCHARTTYPE_SHOW_HIGH_LOW, true ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) ); + if( aFound == aStaticDefaults.end() ) rAny.clear(); else rAny = (*aFound).second; @@ -281,13 +240,15 @@ void CandleStickChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL CandleStickChartType::getInfoHelper() { - return *StaticCandleStickChartTypeInfoHelper::get(); + return StaticCandleStickChartTypeInfoHelper(); } // ____ XPropertySet ____ Reference< beans::XPropertySetInfo > SAL_CALL CandleStickChartType::getPropertySetInfo() { - return *StaticCandleStickChartTypeInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticCandleStickChartTypeInfoHelper() ) ); + return xPropertySetInfo; } void SAL_CALL CandleStickChartType::setFastPropertyValue_NoBroadcast( diff --git a/chart2/source/model/template/ChartType.cxx b/chart2/source/model/template/ChartType.cxx index e2af341a99b1..9448a766071c 100644 --- a/chart2/source/model/template/ChartType.cxx +++ b/chart2/source/model/template/ChartType.cxx @@ -227,31 +227,10 @@ void ChartType::GetDefaultValue( sal_Int32 /* nHandle */, uno::Any& rAny ) const namespace { -struct StaticChartTypeInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( Sequence< beans::Property >{} ); - return &aPropHelper; - } -}; - -struct StaticChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticChartTypeInfoHelper_Initializer > -{ -}; - -struct StaticChartTypeInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticChartTypeInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; - -struct StaticChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticChartTypeInfo_Initializer > +::cppu::OPropertyArrayHelper& StaticChartTypeInfoHelper() { + static ::cppu::OPropertyArrayHelper aPropHelper( Sequence< beans::Property >{} ); + return aPropHelper; }; } @@ -259,13 +238,15 @@ struct StaticChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans: // ____ OPropertySet ____ ::cppu::IPropertyArrayHelper & SAL_CALL ChartType::getInfoHelper() { - return *StaticChartTypeInfoHelper::get(); + return StaticChartTypeInfoHelper(); } // ____ XPropertySet ____ uno::Reference< beans::XPropertySetInfo > SAL_CALL ChartType::getPropertySetInfo() { - return *StaticChartTypeInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( StaticChartTypeInfoHelper() ) ); + return xPropertySetInfo; } // ____ XModifyBroadcaster ____ diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx index 50fdca0e1dbc..cc351e77512b 100644 --- a/chart2/source/model/template/ColumnChartType.cxx +++ b/chart2/source/model/template/ColumnChartType.cxx @@ -54,67 +54,19 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticColumnChartTypeDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - Sequence< sal_Int32 > aSeq{ 0, 0 }; - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq ); - - aSeq = { 100, 100 }; - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq ); - } -}; - -struct StaticColumnChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnChartTypeDefaults_Initializer > -{ -}; - -struct StaticColumnChartTypeInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } - -}; - -struct StaticColumnChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnChartTypeInfoHelper_Initializer > +::cppu::OPropertyArrayHelper & StaticColumnChartTypeInfoHelper() { -}; + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); -struct StaticColumnChartTypeInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticColumnChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnChartTypeInfo_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -158,9 +110,17 @@ uno::Sequence< OUString > ColumnChartType::getSupportedPropertyRoles() // ____ OPropertySet ____ void ColumnChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticColumnChartTypeDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); - if( aFound == rStaticDefaults.end() ) + static const ::chart::tPropertyValueMap aStaticDefaults = []() + { + ::chart::tPropertyValueMap aTmp; + Sequence< sal_Int32 > aSeq{ 0, 0 }; + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq ); + aSeq = { 100, 100 }; + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) ); + if( aFound == aStaticDefaults.end() ) rAny.clear(); else rAny = (*aFound).second; @@ -168,13 +128,15 @@ void ColumnChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper() { - return *StaticColumnChartTypeInfoHelper::get(); + return StaticColumnChartTypeInfoHelper(); } // ____ XPropertySet ____ uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo() { - return *StaticColumnChartTypeInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticColumnChartTypeInfoHelper() ) ); + return xPropertySetInfo; } OUString SAL_CALL ColumnChartType::getImplementationName() |