summaryrefslogtreecommitdiff
path: root/chart2/source/model/main/StockBar.cxx
diff options
context:
space:
mode:
authorIngrid Halama <iha@openoffice.org>2010-10-07 16:21:04 +0200
committerIngrid Halama <iha@openoffice.org>2010-10-07 16:21:04 +0200
commitee8bb91da8d56fe194aa58a8d78e0c64d0f8dea9 (patch)
treec9ee39b672eaf5868b2fb21c177a637599d9c838 /chart2/source/model/main/StockBar.cxx
parent9f5af964256e4e6a98fc85b18e9dd477e012995e (diff)
chart49: #i113103# use corrected double-checked locking pattern for default properties
Diffstat (limited to 'chart2/source/model/main/StockBar.cxx')
-rwxr-xr-xchart2/source/model/main/StockBar.cxx49
1 files changed, 24 insertions, 25 deletions
diff --git a/chart2/source/model/main/StockBar.cxx b/chart2/source/model/main/StockBar.cxx
index 098bbdd18f96..e812ba3c39dd 100755
--- a/chart2/source/model/main/StockBar.cxx
+++ b/chart2/source/model/main/StockBar.cxx
@@ -99,12 +99,28 @@ struct StaticStockBarInfo : public rtl::StaticAggregate< uno::Reference< beans::
{
};
-void lcl_AddDefaultsToMap(
- ::chart::tPropertyValueMap & rOutMap )
+struct StaticStockBarDefaults_Initializer
{
- // override other defaults
- ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white
-}
+ ::chart::tPropertyValueMap* operator()()
+ {
+ static ::chart::tPropertyValueMap aStaticDefaults;
+ lcl_AddDefaultsToMap( aStaticDefaults );
+ return &aStaticDefaults;
+ }
+private:
+ void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap )
+ {
+ ::chart::LineProperties::AddDefaultsToMap( rOutMap );
+ ::chart::FillProperties::AddDefaultsToMap( rOutMap );
+
+ // override other defaults
+ ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); // white
+ }
+};
+
+struct StaticStockBarDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticStockBarDefaults_Initializer >
+{
+};
} // anonymous namespace
@@ -152,28 +168,11 @@ uno::Reference< util::XCloneable > SAL_CALL StockBar::createClone()
uno::Any StockBar::GetDefaultValue( sal_Int32 nHandle ) const
throw(beans::UnknownPropertyException)
{
- static tPropertyValueMap aStaticDefaults;
-
- // /--
- ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
- if( 0 == aStaticDefaults.size() )
- {
- // initialize defaults
- LineProperties::AddDefaultsToMap( aStaticDefaults );
- FillProperties::AddDefaultsToMap( aStaticDefaults );
-
- // overrides a line property
- lcl_AddDefaultsToMap( aStaticDefaults );
- }
-
- tPropertyValueMap::const_iterator aFound(
- aStaticDefaults.find( nHandle ));
-
- if( aFound == aStaticDefaults.end())
+ const tPropertyValueMap& rStaticDefaults = *StaticStockBarDefaults::get();
+ tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) );
+ if( aFound == rStaticDefaults.end() )
return uno::Any();
-
return (*aFound).second;
- // \--
}
::cppu::IPropertyArrayHelper & SAL_CALL StockBar::getInfoHelper()