chart2/source/controller/chartapiwrapper/AreaWrapper.cxx | 46 +--- chart2/source/controller/chartapiwrapper/AxisWrapper.cxx | 44 +--- chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx | 34 +-- chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx | 30 --- chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx | 56 ++--- chart2/source/controller/chartapiwrapper/GridWrapper.cxx | 43 +--- chart2/source/controller/chartapiwrapper/LegendWrapper.cxx | 48 +--- chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx | 89 ++------ chart2/source/controller/chartapiwrapper/TitleWrapper.cxx | 47 +--- chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx | 100 ++-------- chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx | 46 +--- chart2/source/model/template/AreaChartTypeTemplate.cxx | 76 ++----- chart2/source/model/template/BarChartTypeTemplate.cxx | 83 ++------ chart2/source/model/template/BubbleChartType.cxx | 69 +----- chart2/source/model/template/BubbleChartTypeTemplate.cxx | 72 +------ chart2/source/model/template/CandleStickChartType.cxx | 89 ++------ chart2/source/model/template/ChartType.cxx | 33 --- chart2/source/model/template/ColumnChartType.cxx | 88 ++------ 18 files changed, 328 insertions(+), 765 deletions(-)
New commits: commit 1131b090ed9b68300c0b08366e6cb7d7fee453e5 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Tue Mar 21 16:56:14 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Mar 23 06:12:00 2023 +0000 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.gran...@collabora.co.uk> 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() commit 4e8f36fcd43c6ccc9d07211ebc8e7ee53d2e33d1 Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Mon Mar 20 20:19:34 2023 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Thu Mar 23 06:11:52 2023 +0000 rtl::Static-> thread-safe-static in chart2 Change-Id: Ie629e4e2d4e3a56894bc964b8bb50dac5823cf4c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149337 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx index 5c384c3ce134..4d5abf1e229c 100644 --- a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx @@ -36,38 +36,6 @@ using ::osl::MutexGuard; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -namespace -{ - -struct StaticAreaWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer > -{ -}; - -} // anonymous namespace - namespace chart::wrapper { @@ -142,7 +110,19 @@ Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet() const Sequence< beans::Property >& AreaWrapper::getPropertySequence() { - return *StaticAreaWrapperPropertyArray::get(); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; } std::vector< std::unique_ptr<WrappedProperty> > AreaWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index e49d674732a4..ea50320e506e 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -335,33 +335,23 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID ); } -struct StaticAxisWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticAxisWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAxisWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticAxisWrapperPropertyArray() { + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; } // anonymous namespace @@ -607,7 +597,7 @@ Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet() const Sequence< beans::Property >& AxisWrapper::getPropertySequence() { - return *StaticAxisWrapperPropertyArray::get(); + return StaticAxisWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > AxisWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index fbb12b5d4a51..a2385ba897b7 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -221,30 +221,20 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticChartDocumentWrapperPropertyArray_Initializer +const Sequence< Property > & StaticChartDocumentWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static uno::Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticChartDocumentWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticChartDocumentWrapperPropertyArray_Initializer > -{ -}; + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; +} } // anonymous namespace @@ -1384,7 +1374,7 @@ Reference< beans::XPropertySet > ChartDocumentWrapper::getInnerPropertySet() } const Sequence< beans::Property >& ChartDocumentWrapper::getPropertySequence() { - return *StaticChartDocumentWrapperPropertyArray::get(); + return StaticChartDocumentWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > ChartDocumentWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index 6c0dbe7bce25..12449763df19 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -247,30 +247,16 @@ uno::Sequence< Property > lcl_GetPropertySequence( DataSeriesPointWrapper::eType return comphelper::containerToSequence( aProperties ); } -struct StaticSeriesWrapperPropertyArray_Initializer +const Sequence< Property >& StaticSeriesWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES ) ); - return &aPropSeq; - } -}; - -struct StaticSeriesWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticSeriesWrapperPropertyArray_Initializer > -{ -}; - -struct StaticPointWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT ) ); - return &aPropSeq; - } + static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES ) ); + return aPropSeq; }; -struct StaticPointWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticPointWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticPointWrapperPropertyArray() { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT ) ); + return aPropSeq; }; //PROP_SERIES_ATTACHED_AXIS @@ -720,9 +706,9 @@ Reference< beans::XPropertySet > DataSeriesPointWrapper::getInnerPropertySet() const Sequence< beans::Property >& DataSeriesPointWrapper::getPropertySequence() { if( m_eType == DATA_SERIES ) - return *StaticSeriesWrapperPropertyArray::get(); + return StaticSeriesWrapperPropertyArray(); else - return *StaticPointWrapperPropertyArray::get(); + return StaticPointWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > DataSeriesPointWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 8ef1429d7565..8d71463263af 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -386,39 +386,29 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID ); } -struct StaticDiagramWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static uno::Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::SceneProperties::AddPropertiesToVector( aProperties ); - WrappedStatisticProperties::addProperties( aProperties ); - WrappedSymbolProperties::addProperties( aProperties ); - WrappedDataCaptionProperties::addProperties( aProperties ); - WrappedSplineProperties::addProperties( aProperties ); - WrappedStockProperties::addProperties( aProperties ); - WrappedAutomaticPositionProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticDiagramWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticDiagramWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticDiagramWrapperPropertyArray() { + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::SceneProperties::AddPropertiesToVector( aProperties ); + WrappedStatisticProperties::addProperties( aProperties ); + WrappedSymbolProperties::addProperties( aProperties ); + WrappedDataCaptionProperties::addProperties( aProperties ); + WrappedSplineProperties::addProperties( aProperties ); + WrappedStockProperties::addProperties( aProperties ); + WrappedAutomaticPositionProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; bool lcl_isXYChart( const rtl::Reference< ::chart::Diagram >& xDiagram ) @@ -1842,7 +1832,7 @@ Reference< beans::XPropertySet > DiagramWrapper::getInnerPropertySet() const Sequence< beans::Property >& DiagramWrapper::getPropertySequence() { - return *StaticDiagramWrapperPropertyArray::get(); + return StaticDiagramWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > DiagramWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx index 87653f67f1b7..cae43580d4b9 100644 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx @@ -40,36 +40,6 @@ using ::com::sun::star::beans::Property; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -namespace -{ - -struct StaticGridWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticGridWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticGridWrapperPropertyArray_Initializer > -{ -}; - -} // anonymous namespace - namespace chart::wrapper { @@ -154,7 +124,18 @@ Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet() const Sequence< beans::Property >& GridWrapper::getPropertySequence() { - return *StaticGridWrapperPropertyArray::get(); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; } std::vector< std::unique_ptr<WrappedProperty> > GridWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx index 1cea91eb5eea..edf955b43f7f 100644 --- a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx @@ -225,35 +225,25 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticLegendWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticLegendWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticLegendWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticLegendWrapperPropertyArray() { + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; } // anonymous namespace @@ -380,7 +370,7 @@ Reference< beans::XPropertySet > LegendWrapper::getInnerPropertySet() const Sequence< beans::Property >& LegendWrapper::getPropertySequence() { - return *StaticLegendWrapperPropertyArray::get(); + return StaticLegendWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > LegendWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx index 65be4793f01c..3b40bcb5a0f7 100644 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx @@ -43,72 +43,34 @@ using ::com::sun::star::uno::Any; namespace { -struct StaticMinMaxLineWrapperDefaults_Initializer +Sequence< Property >& StaticMinMaxLineWrapperPropertyArray() { - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - ::chart::LinePropertiesHelper::AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -}; - -struct StaticMinMaxLineWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticMinMaxLineWrapperDefaults_Initializer > -{ -}; - -struct StaticMinMaxLineWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; - return comphelper::containerToSequence( aProperties ); - } -}; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); -struct StaticMinMaxLineWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticMinMaxLineWrapperPropertyArray_Initializer > -{ -}; - -struct StaticMinMaxLineWrapperInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( *StaticMinMaxLineWrapperPropertyArray::get() ); - return &aPropHelper; - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticMinMaxLineWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticMinMaxLineWrapperInfoHelper_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -struct StaticMinMaxLineWrapperInfo_Initializer +::cppu::OPropertyArrayHelper& StaticMinMaxLineWrapperInfoHelper() { - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticMinMaxLineWrapperInfoHelper::get() ) ); - return &xPropertySetInfo; - } + static ::cppu::OPropertyArrayHelper aPropHelper( StaticMinMaxLineWrapperPropertyArray() ); + return aPropHelper; }; -struct StaticMinMaxLineWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticMinMaxLineWrapperInfo_Initializer > +uno::Reference< beans::XPropertySetInfo >& StaticMinMaxLineWrapperInfo() { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( StaticMinMaxLineWrapperInfoHelper() ) ); + return xPropertySetInfo; }; } // anonymous namespace @@ -151,7 +113,7 @@ void SAL_CALL MinMaxLineWrapper::removeEventListener( //XPropertySet uno::Reference< beans::XPropertySetInfo > SAL_CALL MinMaxLineWrapper::getPropertySetInfo() { - return *StaticMinMaxLineWrapperInfo::get(); + return StaticMinMaxLineWrapperInfo(); } void SAL_CALL MinMaxLineWrapper::setPropertyValue( const OUString& rPropertyName, const uno::Any& rValue ) @@ -321,9 +283,14 @@ void SAL_CALL MinMaxLineWrapper::setPropertyToDefault( const OUString& rProperty uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const OUString& rPropertyName ) { - const tPropertyValueMap& rStaticDefaults = *StaticMinMaxLineWrapperDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( StaticMinMaxLineWrapperInfoHelper::get()->getHandleByName( rPropertyName ) ) ); - if( aFound == rStaticDefaults.end() ) + static const ::chart::tPropertyValueMap aStaticDefaults = [] + { + ::chart::tPropertyValueMap aTmp; + ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( StaticMinMaxLineWrapperInfoHelper().getHandleByName( rPropertyName ) ) ); + if( aFound == aStaticDefaults.end() ) return uno::Any(); return (*aFound).second; } @@ -332,7 +299,7 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const OUString& rProper //getPropertyStates() already declared in XPropertyState void SAL_CALL MinMaxLineWrapper::setAllPropertiesToDefault( ) { - const Sequence< beans::Property >& rPropSeq = *StaticMinMaxLineWrapperPropertyArray::get(); + const Sequence< beans::Property >& rPropSeq = StaticMinMaxLineWrapperPropertyArray(); for(beans::Property const & prop : rPropSeq) { setPropertyToDefault( prop.Name ); diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx index 594209d4fbf3..edd88fc96393 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -153,36 +153,27 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticTitleWrapperPropertyArray_Initializer +const Sequence< Property > & StaticTitleWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } + static Sequence< Property > aPropSeq = []() + { + std::vector< beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -struct StaticTitleWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticTitleWrapperPropertyArray_Initializer > -{ -}; } // anonymous namespace @@ -470,7 +461,7 @@ Reference< beans::XPropertySet > TitleWrapper::getInnerPropertySet() const Sequence< beans::Property >& TitleWrapper::getPropertySequence() { - return *StaticTitleWrapperPropertyArray::get(); + return StaticTitleWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > TitleWrapper::createWrappedProperties() diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx index 143d0123ee63..721fa266821c 100644 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx @@ -43,79 +43,28 @@ using ::com::sun::star::uno::Any; namespace { -struct StaticUpDownBarWrapperPropertyArray_Initializer +const Sequence< Property > & StaticUpDownBarWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticUpDownBarWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticUpDownBarWrapperPropertyArray_Initializer > -{ -}; - -struct StaticUpDownBarWrapperInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( *StaticUpDownBarWrapperPropertyArray::get() ); - return &aPropHelper; - } -}; + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; -struct StaticUpDownBarWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticUpDownBarWrapperInfoHelper_Initializer > -{ -}; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); -struct StaticUpDownBarWrapperInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticUpDownBarWrapperInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticUpDownBarWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticUpDownBarWrapperInfo_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -struct StaticUpDownBarWrapperDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap ); - ::chart::FillProperties::AddDefaultsToMap( rOutMap ); - } -}; - -struct StaticUpDownBarWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticUpDownBarWrapperDefaults_Initializer > +::cppu::OPropertyArrayHelper& StaticUpDownBarWrapperInfoHelper() { + static ::cppu::OPropertyArrayHelper aPropHelper( StaticUpDownBarWrapperPropertyArray() ); + return aPropHelper; }; } // anonymous namespace @@ -159,8 +108,11 @@ void SAL_CALL UpDownBarWrapper::removeEventListener( //XPropertySet uno::Reference< beans::XPropertySetInfo > SAL_CALL UpDownBarWrapper::getPropertySetInfo() { - return *StaticUpDownBarWrapperInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticUpDownBarWrapperInfoHelper() ) ); + return xPropertySetInfo; } + void SAL_CALL UpDownBarWrapper::setPropertyValue( const OUString& rPropertyName, const uno::Any& rValue ) { Reference< beans::XPropertySet > xPropSet; @@ -294,9 +246,15 @@ void SAL_CALL UpDownBarWrapper::setPropertyToDefault( const OUString& rPropertyN uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const OUString& rPropertyName ) { - const tPropertyValueMap& rStaticDefaults = *StaticUpDownBarWrapperDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( StaticUpDownBarWrapperInfoHelper::get()->getHandleByName( rPropertyName ) ) ); - if( aFound == rStaticDefaults.end() ) + static const ::chart::tPropertyValueMap aStaticDefaults = []() + { + ::chart::tPropertyValueMap aTmp; + ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp ); + ::chart::FillProperties::AddDefaultsToMap( aTmp ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( StaticUpDownBarWrapperInfoHelper().getHandleByName( rPropertyName ) ) ); + if( aFound == aStaticDefaults.end() ) return uno::Any(); return (*aFound).second; } @@ -305,7 +263,7 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const OUString& rPropert //getPropertyStates() already declared in XPropertyState void SAL_CALL UpDownBarWrapper::setAllPropertiesToDefault( ) { - const Sequence< beans::Property >& rPropSeq = *StaticUpDownBarWrapperPropertyArray::get(); + const Sequence< beans::Property >& rPropSeq = StaticUpDownBarWrapperPropertyArray(); for(beans::Property const & prop : rPropSeq) { setPropertyToDefault( prop.Name ); diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx index c50edb623070..bc6f15505471 100644 --- a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx @@ -38,38 +38,6 @@ using ::osl::MutexGuard; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -namespace -{ - -struct StaticWallFloorWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer > -{ -}; - -} // anonymous namespace - namespace chart::wrapper { @@ -128,7 +96,19 @@ Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet() const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence() { - return *StaticWallFloorWrapperPropertyArray::get(); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; } std::vector< std::unique_ptr<WrappedProperty> > WallFloorWrapper::createWrappedProperties()