diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2023-03-20 20:19:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2023-03-23 06:11:52 +0000 |
commit | 4e8f36fcd43c6ccc9d07211ebc8e7ee53d2e33d1 (patch) | |
tree | ec3b109d99e8a7f7a944b53f9b52c65bc2b95533 /chart2 | |
parent | edb2c2a9f128273486163e22f7a44117ac47ae84 (diff) |
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.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
11 files changed, 193 insertions, 390 deletions
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() |