summaryrefslogtreecommitdiff
path: root/chart2
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-11-08 21:01:19 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-11-09 08:28:56 +0100
commitb3c6b3a274b4c89d3572010794897c65b26571aa (patch)
tree87493b0306663ac6c818a71df9f83831914e296b /chart2
parent926ac3c5e4b8eb425bc2db0366594acc0cf2c1ed (diff)
rtl::Static to thread-safe static
Change-Id: I35e2a252708228bdbeaee557ef35763c64608653 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124884 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2')
-rw-r--r--chart2/source/controller/main/ConfigurationAccess.cxx11
-rw-r--r--chart2/source/model/main/Diagram.cxx86
-rw-r--r--chart2/source/view/charttypes/ConfigAccess.cxx13
3 files changed, 36 insertions, 74 deletions
diff --git a/chart2/source/controller/main/ConfigurationAccess.cxx b/chart2/source/controller/main/ConfigurationAccess.cxx
index 54a94adfa083..f6dfecc60113 100644
--- a/chart2/source/controller/main/ConfigurationAccess.cxx
+++ b/chart2/source/controller/main/ConfigurationAccess.cxx
@@ -22,7 +22,6 @@
#include <unotools/syslocale.hxx>
#include <unotools/configitem.hxx>
#include <unotools/localedatawrapper.hxx>
-#include <rtl/instance.hxx>
namespace chart
{
@@ -78,17 +77,13 @@ FieldUnit CalcConfigItem::getFieldUnit()
return eResult;
}
-namespace
-{
- //a CalcConfigItem Singleton
- struct theCalcConfigItem : public rtl::Static< CalcConfigItem, theCalcConfigItem > {};
-}
-
namespace ConfigurationAccess
{
FieldUnit getFieldUnit()
{
- FieldUnit aUnit( theCalcConfigItem::get().getFieldUnit() );
+ //a CalcConfigItem Singleton
+ static CalcConfigItem SINGLETON;
+ FieldUnit aUnit( SINGLETON.getFieldUnit() );
return aUnit;
}
} //namespace ConfigurationAccess
diff --git a/chart2/source/model/main/Diagram.cxx b/chart2/source/model/main/Diagram.cxx
index f5d8afc5b172..8255115bead1 100644
--- a/chart2/source/model/main/Diagram.cxx
+++ b/chart2/source/model/main/Diagram.cxx
@@ -30,7 +30,6 @@
#include <unonames.hxx>
#include <basegfx/numeric/ftools.hxx>
-#include <rtl/instance.hxx>
#include <com/sun/star/beans/PropertyAttribute.hpp>
#include <com/sun/star/chart2/RelativePosition.hpp>
#include <com/sun/star/chart2/RelativeSize.hpp>
@@ -179,46 +178,31 @@ void lcl_AddPropertiesToVector(
beans::PropertyAttribute::MAYBEVOID );
}
-struct StaticDiagramDefaults_Initializer
+const ::chart::tPropertyValueMap& StaticDiagramDefaults()
{
- ::chart::tPropertyValueMap* operator()()
+ static ::chart::tPropertyValueMap aStaticDefaults = []()
{
- static ::chart::tPropertyValueMap aStaticDefaults;
- lcl_AddDefaultsToMap( aStaticDefaults );
- return &aStaticDefaults;
- }
-private:
- static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
- {
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_CONNECT_BARS, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEHBORDER, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEVBORDER, false );
- ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_DIAGRAM_DATATABLEOUTLINE, false );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
- ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( rOutMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 );
- ::chart::SceneProperties::AddDefaultsToMap( rOutMap );
- }
+ ::chart::tPropertyValueMap aMap;
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_POSSIZE_EXCLUDE_LABELS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_SORT_BY_X_VALUES, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_CONNECT_BARS, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_GROUP_BARS_PER_AXIS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, true );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_RIGHT_ANGLED_AXES, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEHBORDER, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEVBORDER, false );
+ ::chart::PropertyHelper::setPropertyValueDefault( aMap, PROP_DIAGRAM_DATATABLEOUTLINE, false );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_STARTING_ANGLE, 90 );
+ ::chart::PropertyHelper::setPropertyValueDefault< sal_Int32 >( aMap, PROP_DIAGRAM_3DRELATIVEHEIGHT, 100 );
+ ::chart::SceneProperties::AddDefaultsToMap( aMap );
+ return aMap;
+ }();
+ return aStaticDefaults;
};
-struct StaticDiagramDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticDiagramDefaults_Initializer >
+::cppu::OPropertyArrayHelper& StaticDiagramInfoHelper()
{
-};
-
-struct StaticDiagramInfoHelper_Initializer
-{
- ::cppu::OPropertyArrayHelper* operator()()
- {
- static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() );
- return &aPropHelper;
- }
-
-private:
- static Sequence< Property > lcl_GetPropertySequence()
+ static ::cppu::OPropertyArrayHelper aPropHelper = []()
{
std::vector< css::beans::Property > aProperties;
lcl_AddPropertiesToVector( aProperties );
@@ -228,26 +212,16 @@ private:
std::sort( aProperties.begin(), aProperties.end(),
::chart::PropertyNameLess() );
- return comphelper::containerToSequence( aProperties );
- }
-};
-
-struct StaticDiagramInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticDiagramInfoHelper_Initializer >
-{
-};
-
-struct StaticDiagramInfo_Initializer
-{
- uno::Reference< beans::XPropertySetInfo >* operator()()
- {
- static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
- ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticDiagramInfoHelper::get() ) );
- return &xPropertySetInfo;
- }
+ return ::cppu::OPropertyArrayHelper( aProperties.data(), aProperties.size() );
+ }();
+ return aPropHelper;
};
-struct StaticDiagramInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticDiagramInfo_Initializer >
+const uno::Reference< beans::XPropertySetInfo >& StaticDiagramInfo()
{
+ static const uno::Reference< beans::XPropertySetInfo > xPropertySetInfo(
+ ::cppu::OPropertySetHelper::createPropertySetInfo(StaticDiagramInfoHelper() ) );
+ return xPropertySetInfo;
};
/// clones a UNO-sequence of UNO-References
@@ -595,7 +569,7 @@ void Diagram::fireModifyEvent()
// ____ OPropertySet ____
uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
{
- const tPropertyValueMap& rStaticDefaults = *StaticDiagramDefaults::get();
+ const tPropertyValueMap& rStaticDefaults = StaticDiagramDefaults();
tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
if( aFound == rStaticDefaults.end() )
return uno::Any();
@@ -605,13 +579,13 @@ uno::Any Diagram::GetDefaultValue( sal_Int32 nHandle ) const
// ____ OPropertySet ____
::cppu::IPropertyArrayHelper & SAL_CALL Diagram::getInfoHelper()
{
- return *StaticDiagramInfoHelper::get();
+ return StaticDiagramInfoHelper();
}
// ____ XPropertySet ____
uno::Reference< beans::XPropertySetInfo > SAL_CALL Diagram::getPropertySetInfo()
{
- return *StaticDiagramInfo::get();
+ return StaticDiagramInfo();
}
// ____ XFastPropertySet ____
diff --git a/chart2/source/view/charttypes/ConfigAccess.cxx b/chart2/source/view/charttypes/ConfigAccess.cxx
index e83385fb63d1..ce02c4817e0a 100644
--- a/chart2/source/view/charttypes/ConfigAccess.cxx
+++ b/chart2/source/view/charttypes/ConfigAccess.cxx
@@ -21,7 +21,6 @@
#include <unotools/configitem.hxx>
#include <o3tl/any.hxx>
-#include <rtl/instance.hxx>
#include <com/sun/star/uno/Sequence.hxx>
namespace chart
@@ -59,19 +58,13 @@ bool ChartConfigItem::getUseErrorRectangle()
return b && *b;
}
-namespace
-{
-//a ChartConfigItem Singleton
-struct theChartConfigItem : public rtl::Static<ChartConfigItem, theChartConfigItem>
-{
-};
-}
-
namespace ConfigAccess
{
bool getUseErrorRectangle()
{
- bool bResult(theChartConfigItem::get().getUseErrorRectangle());
+ //a ChartConfigItem Singleton
+ static ChartConfigItem SINGLETON;
+ bool bResult(SINGLETON.getUseErrorRectangle());
return bResult;
}
} //namespace ConfigAccess