diff options
author | Ingrid Halama <iha@openoffice.org> | 2010-10-07 16:21:04 +0200 |
---|---|---|
committer | Ingrid Halama <iha@openoffice.org> | 2010-10-07 16:21:04 +0200 |
commit | ee8bb91da8d56fe194aa58a8d78e0c64d0f8dea9 (patch) | |
tree | c9ee39b672eaf5868b2fb21c177a637599d9c838 /chart2/source/model/main/FormattedString.cxx | |
parent | 9f5af964256e4e6a98fc85b18e9dd477e012995e (diff) |
chart49: #i113103# use corrected double-checked locking pattern for default properties
Diffstat (limited to 'chart2/source/model/main/FormattedString.cxx')
-rwxr-xr-x | chart2/source/model/main/FormattedString.cxx | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/chart2/source/model/main/FormattedString.cxx b/chart2/source/model/main/FormattedString.cxx index ab9aa4f8b33d..2d1f937d3e57 100755 --- a/chart2/source/model/main/FormattedString.cxx +++ b/chart2/source/model/main/FormattedString.cxx @@ -47,6 +47,25 @@ using ::osl::MutexGuard; namespace { +struct StaticFormattedStringDefaults_Initializer +{ + ::chart::tPropertyValueMap* operator()() + { + static ::chart::tPropertyValueMap aStaticDefaults; + lcl_AddDefaultsToMap( aStaticDefaults ); + return &aStaticDefaults; + } +private: + void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) + { + ::chart::CharacterProperties::AddDefaultsToMap( rOutMap ); + } +}; + +struct StaticFormattedStringDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticFormattedStringDefaults_Initializer > +{ +}; + struct StaticFormattedStringInfoHelper_Initializer { ::cppu::OPropertyArrayHelper* operator()() @@ -209,24 +228,11 @@ Sequence< OUString > FormattedString::getSupportedServiceNames_Static() uno::Any FormattedString::GetDefaultValue( sal_Int32 nHandle ) const throw(beans::UnknownPropertyException) { - static tPropertyValueMap aStaticDefaults; - - // /-- - ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aStaticDefaults.size() ) - { - // initialize defaults - CharacterProperties::AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) - throw beans::UnknownPropertyException(); - + const tPropertyValueMap& rStaticDefaults = *StaticFormattedStringDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) + return uno::Any(); return (*aFound).second; - // \-- } // ____ OPropertySet ____ |