diff options
Diffstat (limited to 'chart2/source/model/template/ColumnChartType.cxx')
-rw-r--r-- | chart2/source/model/template/ColumnChartType.cxx | 93 |
1 files changed, 30 insertions, 63 deletions
diff --git a/chart2/source/model/template/ColumnChartType.cxx b/chart2/source/model/template/ColumnChartType.cxx index 3553e289985e..cc351e77512b 100644 --- a/chart2/source/model/template/ColumnChartType.cxx +++ b/chart2/source/model/template/ColumnChartType.cxx @@ -54,67 +54,19 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticColumnChartTypeDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - Sequence< sal_Int32 > aSeq{ 0, 0 }; - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq ); - - aSeq = { 100, 100 }; - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq ); - } -}; - -struct StaticColumnChartTypeDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticColumnChartTypeDefaults_Initializer > -{ -}; - -struct StaticColumnChartTypeInfoHelper_Initializer +::cppu::OPropertyArrayHelper & StaticColumnChartTypeInfoHelper() { - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } - -}; - -struct StaticColumnChartTypeInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticColumnChartTypeInfoHelper_Initializer > -{ -}; - -struct StaticColumnChartTypeInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticColumnChartTypeInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; - -struct StaticColumnChartTypeInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticColumnChartTypeInfo_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -139,6 +91,11 @@ uno::Reference< util::XCloneable > SAL_CALL ColumnChartType::createClone() return uno::Reference< util::XCloneable >( new ColumnChartType( *this )); } +rtl::Reference< ChartType > ColumnChartType::cloneChartType() const +{ + return new ColumnChartType( *this ); +} + // ____ XChartType ____ OUString SAL_CALL ColumnChartType::getChartType() { @@ -153,9 +110,17 @@ uno::Sequence< OUString > ColumnChartType::getSupportedPropertyRoles() // ____ OPropertySet ____ void ColumnChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticColumnChartTypeDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); - if( aFound == rStaticDefaults.end() ) + static const ::chart::tPropertyValueMap aStaticDefaults = []() + { + ::chart::tPropertyValueMap aTmp; + Sequence< sal_Int32 > aSeq{ 0, 0 }; + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_OVERLAP_SEQUENCE, aSeq ); + aSeq = { 100, 100 }; + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_BARCHARTTYPE_GAPWIDTH_SEQUENCE, aSeq ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( nHandle ) ); + if( aFound == aStaticDefaults.end() ) rAny.clear(); else rAny = (*aFound).second; @@ -163,13 +128,15 @@ void ColumnChartType::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const ::cppu::IPropertyArrayHelper & SAL_CALL ColumnChartType::getInfoHelper() { - return *StaticColumnChartTypeInfoHelper::get(); + return StaticColumnChartTypeInfoHelper(); } // ____ XPropertySet ____ uno::Reference< beans::XPropertySetInfo > SAL_CALL ColumnChartType::getPropertySetInfo() { - return *StaticColumnChartTypeInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticColumnChartTypeInfoHelper() ) ); + return xPropertySetInfo; } OUString SAL_CALL ColumnChartType::getImplementationName() |