diff options
Diffstat (limited to 'chart2/source/model/main/Wall.cxx')
-rwxr-xr-x[-rw-r--r--] | chart2/source/model/main/Wall.cxx | 112 |
1 files changed, 52 insertions, 60 deletions
diff --git a/chart2/source/model/main/Wall.cxx b/chart2/source/model/main/Wall.cxx index 2ad00a4c90ae..404a5e6ff97f 100644..100755 --- a/chart2/source/model/main/Wall.cxx +++ b/chart2/source/model/main/Wall.cxx @@ -59,46 +59,70 @@ namespace static const ::rtl::OUString lcl_aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.Wall" )); -void lcl_AddDefaultsToMap( - ::chart::tPropertyValueMap & rOutMap ) +struct StaticWallDefaults_Initializer { - // override other defaults - ::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( rOutMap, ::chart::LineProperties::PROP_LINE_STYLE, drawing::LineStyle_NONE ); + } +}; + +struct StaticWallDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticWallDefaults_Initializer > +{ +}; -const uno::Sequence< Property > & lcl_GetPropertySequence() +struct StaticWallInfoHelper_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 StaticWallInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticWallInfoHelper_Initializer > { - static ::cppu::OPropertyArrayHelper aArrayHelper( - lcl_GetPropertySequence(), - /* bSorted = */ sal_True ); +}; - return aArrayHelper; -} +struct StaticWallInfo_Initializer +{ + uno::Reference< beans::XPropertySetInfo >* operator()() + { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticWallInfoHelper::get() ) ); + return &xPropertySetInfo; + } +}; + +struct StaticWallInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticWallInfo_Initializer > +{ +}; } // anonymous namespace @@ -135,55 +159,23 @@ uno::Reference< util::XCloneable > SAL_CALL Wall::createClone() uno::Any Wall::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 ); - - // initialize defaults - // Note: this should be last to override defaults of the previously - // added defaults - lcl_AddDefaultsToMap( aStaticDefaults ); - } - - tPropertyValueMap::const_iterator aFound( - aStaticDefaults.find( nHandle )); - - if( aFound == aStaticDefaults.end()) + const tPropertyValueMap& rStaticDefaults = *StaticWallDefaults::get(); + tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); + if( aFound == rStaticDefaults.end() ) return uno::Any(); - return (*aFound).second; - // \-- } ::cppu::IPropertyArrayHelper & SAL_CALL Wall::getInfoHelper() { - return lcl_getInfoHelper(); + return *StaticWallInfoHelper::get(); } - // ____ XPropertySet ____ -uno::Reference< beans::XPropertySetInfo > SAL_CALL - Wall::getPropertySetInfo() +uno::Reference< beans::XPropertySetInfo > SAL_CALL Wall::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 *StaticWallInfo::get(); } // ____ XModifyBroadcaster ____ |