diff options
Diffstat (limited to 'chart2/source/model/main/Legend.cxx')
-rw-r--r-- | chart2/source/model/main/Legend.cxx | 150 |
1 files changed, 55 insertions, 95 deletions
diff --git a/chart2/source/model/main/Legend.cxx b/chart2/source/model/main/Legend.cxx index 4c3b9f0e5167..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,15 +160,14 @@ namespace chart { Legend::Legend() : - ::property::OPropertySet( m_aMutex ), - m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()) + m_xModifyEventForwarder( new ModifyEventForwarder() ) { } Legend::Legend( const Legend & rOther ) : impl::Legend_Base(rOther), - ::property::OPropertySet( rOther, m_aMutex ), - m_xModifyEventForwarder( ModifyListenerHelper::createModifyEventForwarder()) + ::property::OPropertySet( rOther ), + m_xModifyEventForwarder( new ModifyEventForwarder() ) { } @@ -211,28 +184,12 @@ Reference< util::XCloneable > SAL_CALL Legend::createClone() // ____ XModifyBroadcaster ____ void SAL_CALL Legend::addModifyListener( const Reference< util::XModifyListener >& aListener ) { - try - { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW ); - xBroadcaster->addModifyListener( aListener ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + m_xModifyEventForwarder->addModifyListener( aListener ); } void SAL_CALL Legend::removeModifyListener( const Reference< util::XModifyListener >& aListener ) { - try - { - Reference< util::XModifyBroadcaster > xBroadcaster( m_xModifyEventForwarder, uno::UNO_QUERY_THROW ); - xBroadcaster->removeModifyListener( aListener ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + m_xModifyEventForwarder->removeModifyListener( aListener ); } // ____ XModifyListener ____ @@ -254,24 +211,27 @@ void Legend::firePropertyChangeEvent() } // ____ OPropertySet ____ -Any Legend::GetDefaultValue( sal_Int32 nHandle ) const +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() ) - return uno::Any(); - return (*aFound).second; + rAny.clear(); + else + rAny = (*aFound).second; } ::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 |