diff options
Diffstat (limited to 'chart2/source/model/main/Legend.cxx')
-rw-r--r-- | chart2/source/model/main/Legend.cxx | 119 |
1 files changed, 47 insertions, 72 deletions
diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx index 27eae67764ed..f72868b58cb5 100644 --- a/chart2/source/model/main/Legend.cxx +++ b/chart2/source/model/main/Legend.cxx @@ -17,7 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "Legend.hxx" +#include <Legend.hxx> #include <LinePropertiesHelper.hxx> #include <FillProperties.hxx> #include <CharacterProperties.hxx> @@ -31,7 +31,6 @@ #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> #include <cppuhelper/supportsservice.hxx> -#include <tools/diagnose_ex.h> #include <algorithm> @@ -106,78 +105,53 @@ void lcl_AddPropertiesToVector( } -struct StaticLegendDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap ); - ::chart::FillProperties::AddDefaultsToMap( rOutMap ); - ::chart::CharacterProperties::AddDefaultsToMap( rOutMap ); - - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_EXPANSION, css::chart::ChartLegendExpansion_HIGH ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_SHOW, true ); - ::chart::PropertyHelper::setPropertyValueDefault( rOutMap, PROP_LEGEND_OVERLAY, false ); - - float fDefaultCharHeight = 10.0; - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); - ::chart::PropertyHelper::setPropertyValue( rOutMap, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); - } -}; +} // namespace -struct StaticLegendDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticLegendDefaults_Initializer > +namespace chart { -}; - -struct StaticLegendInfoHelper_Initializer +const ::chart::tPropertyValueMap& StaticLegendDefaults() { - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( lcl_GetPropertySequence() ); - return &aPropHelper; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } + static ::chart::tPropertyValueMap aStaticDefaults = []() + { + ::chart::tPropertyValueMap aTmp; + ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp ); + ::chart::FillProperties::AddDefaultsToMap( aTmp ); + ::chart::CharacterProperties::AddDefaultsToMap( aTmp ); + + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_ANCHOR_POSITION, chart2::LegendPosition_LINE_END ); + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_EXPANSION, css::chart::ChartLegendExpansion_HIGH ); + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_SHOW, true ); + ::chart::PropertyHelper::setPropertyValueDefault( aTmp, PROP_LEGEND_OVERLAY, false ); + + float fDefaultCharHeight = 10.0; + ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::CharacterProperties::PROP_CHAR_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::CharacterProperties::PROP_CHAR_ASIAN_CHAR_HEIGHT, fDefaultCharHeight ); + ::chart::PropertyHelper::setPropertyValue( aTmp, ::chart::CharacterProperties::PROP_CHAR_COMPLEX_CHAR_HEIGHT, fDefaultCharHeight ); + return aTmp; + }(); + return aStaticDefaults; }; +} // namespace chart -struct StaticLegendInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticLegendInfoHelper_Initializer > -{ -}; - -struct StaticLegendInfo_Initializer +namespace { - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticLegendInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; - -struct StaticLegendInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticLegendInfo_Initializer > +::cppu::OPropertyArrayHelper& StaticLegendInfoHelper() { + static ::cppu::OPropertyArrayHelper aPropHelper = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropHelper; }; } // anonymous namespace @@ -186,14 +160,13 @@ namespace chart { Legend::Legend() : - ::property::OPropertySet( m_aMutex ), m_xModifyEventForwarder( new ModifyEventForwarder() ) { } Legend::Legend( const Legend & rOther ) : impl::Legend_Base(rOther), - ::property::OPropertySet( rOther, m_aMutex ), + ::property::OPropertySet( rOther ), m_xModifyEventForwarder( new ModifyEventForwarder() ) { } @@ -240,7 +213,7 @@ void Legend::firePropertyChangeEvent() // ____ OPropertySet ____ void Legend::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const { - const tPropertyValueMap& rStaticDefaults = *StaticLegendDefaults::get(); + const tPropertyValueMap& rStaticDefaults = StaticLegendDefaults(); tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( nHandle ) ); if( aFound == rStaticDefaults.end() ) rAny.clear(); @@ -250,13 +223,15 @@ void Legend::GetDefaultValue( sal_Int32 nHandle, uno::Any& rAny ) const ::cppu::IPropertyArrayHelper & SAL_CALL Legend::getInfoHelper() { - return *StaticLegendInfoHelper::get(); + return StaticLegendInfoHelper(); } // ____ XPropertySet ____ Reference< beans::XPropertySetInfo > SAL_CALL Legend::getPropertySetInfo() { - return *StaticLegendInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticLegendInfoHelper() ) ); + return xPropertySetInfo; } // implement XServiceInfo methods basing upon getSupportedServiceNames_Static |