diff options
Diffstat (limited to 'chart2/source/model/main/PageBackground.cxx')
-rwxr-xr-x[-rw-r--r--] | chart2/source/model/main/PageBackground.cxx | 107 |
1 files changed, 53 insertions, 54 deletions
diff --git a/chart2/source/model/main/PageBackground.cxx b/chart2/source/model/main/PageBackground.cxx index 964529f6aa16..8aa631f724e5 100644..100755 --- a/chart2/source/model/main/PageBackground.cxx +++ b/chart2/source/model/main/PageBackground.cxx @@ -54,46 +54,71 @@ namespace static const ::rtl::OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.PageBackground" )); -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticPageBackgroundDefaults_Initializer { - // override other defaults - ::chart::PropertyHelper::setPropertyValue< sal_Int32 >( rOutMap, ::chart::FillProperties::PROP_FILL_COLOR, 0xffffff ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); -} + ::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 ); + ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); + } +}; + +struct StaticPageBackgroundDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticPageBackgroundDefaults_Initializer > +{ +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticPageBackgroundInfoHelper_Initializer { - static uno::Sequence< Property > aPropSeq; + ::cppu::OPropertyArrayHelper* operator()() + { + static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); + return &aPropHelper; + } - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( 0 == aPropSeq.getLength() ) +private: + uno::Sequence< Property > lcl_GetPropertySequence() { - // get properties ::std::vector< ::com::sun::star::beans::Property > aProperties; ::chart::LineProperties::AddPropertiesToVector( aProperties ); ::chart::FillProperties::AddPropertiesToVector( aProperties ); ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - // and sort them for access via bsearch ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); - // transfer result to static Sequence - aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + return ::chart::ContainerHelper::ContainerToSequence( aProperties ); } - return aPropSeq; -} +}; -::cppu::IPropertyArrayHelper & lcl_getInfoHelper() +struct StaticPageBackgroundInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticPageBackgroundInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticPageBackgroundInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticPageBackgroundInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticPageBackgroundInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticPageBackgroundInfo_Initializer > +{ +}; } // anonymous namespace @@ -132,51 +157,25 @@ uno::Reference< util::XCloneable > SAL_CALL PageBackground::createClone() uno::Any PageBackground::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 defaults of FillProperties - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticPageBackgroundDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; } ::cppu::IPropertyArrayHelper & SAL_CALL PageBackground::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticPageBackgroundInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - PageBackground::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL PageBackground::getPropertySetInfo() throw (uno::RuntimeException) { - static uno::Reference< beans::XPropertySetInfo > xInfo; - - MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); - if( !xInfo.is()) - { - xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( - getInfoHelper()); - } - - return xInfo; + return *StaticPageBackgroundInfo::get(); } - // ____ XModifyBroadcaster ____ void SAL_CALL PageBackground::addModifyListener( const uno::Reference< util::XModifyListener >& aListener ) throw (uno::RuntimeException) |