diff options
Diffstat (limited to 'chart2/source/tools/ConfigColorScheme.cxx')
-rw-r--r-- | chart2/source/tools/ConfigColorScheme.cxx | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/chart2/source/tools/ConfigColorScheme.cxx b/chart2/source/tools/ConfigColorScheme.cxx index 5645fb22b68f..b4bbd8dfa369 100644 --- a/chart2/source/tools/ConfigColorScheme.cxx +++ b/chart2/source/tools/ConfigColorScheme.cxx @@ -20,11 +20,7 @@ #include <ConfigColorScheme.hxx> #include <unotools/configitem.hxx> -#include <sal/macros.h> #include <cppuhelper/supportsservice.hxx> -#include <comphelper/sequence.hxx> - -#include <set> using namespace ::com::sun::star; @@ -34,7 +30,7 @@ using ::com::sun::star::uno::Sequence; namespace { -const char aSeriesPropName[] = "Series"; +constexpr OUString aSeriesPropName = u"Series"_ustr; } // anonymous namespace @@ -53,7 +49,6 @@ class ChartConfigItem : public ::utl::ConfigItem public: explicit ChartConfigItem( ConfigColorScheme & rListener ); - void addPropertyNotification( const OUString & rPropertyName ); uno::Any getProperty( const OUString & aPropertyName ); protected: @@ -63,32 +58,27 @@ protected: private: ConfigColorScheme & m_rListener; - std::set< OUString > m_aPropertiesToNotify; }; ChartConfigItem::ChartConfigItem( ConfigColorScheme & rListener ) : - ::utl::ConfigItem( "Office.Chart/DefaultColor" ), + ::utl::ConfigItem( u"Office.Chart/DefaultColor"_ustr ), m_rListener( rListener ) -{} +{ + EnableNotification( { aSeriesPropName } ); +} void ChartConfigItem::Notify( const Sequence< OUString > & aPropertyNames ) { for( OUString const & s : aPropertyNames ) { - if( m_aPropertiesToNotify.find( s ) != m_aPropertiesToNotify.end()) - m_rListener.notify( s ); + if( s == aSeriesPropName ) + m_rListener.notify(); } } void ChartConfigItem::ImplCommit() {} -void ChartConfigItem::addPropertyNotification( const OUString & rPropertyName ) -{ - m_aPropertiesToNotify.insert( rPropertyName ); - EnableNotification( comphelper::containerToSequence( m_aPropertiesToNotify )); -} - uno::Any ChartConfigItem::getProperty( const OUString & aPropertyName ) { Sequence< uno::Any > aValues( @@ -103,8 +93,8 @@ uno::Any ChartConfigItem::getProperty( const OUString & aPropertyName ) // explicit ConfigColorScheme::ConfigColorScheme( const Reference< uno::XComponentContext > & xContext ) : + BaseColorScheme(), m_xContext( xContext ), - m_nNumberOfColors( 0 ), m_bNeedsUpdate( true ) { } @@ -122,11 +112,8 @@ void ConfigColorScheme::retrieveConfigColors() { m_apChartConfigItem.reset( new impl::ChartConfigItem( *this )); - m_apChartConfigItem->addPropertyNotification( aSeriesPropName ); } - OSL_ASSERT(m_apChartConfigItem); - if (!m_apChartConfigItem) - return; + assert(m_apChartConfigItem && "this can only be set at this point"); // retrieve colors uno::Any aValue( @@ -153,29 +140,18 @@ void ConfigColorScheme::retrieveConfigColors() 0xff00ff, 0x00ffff, 0xffff00 }; - static const sal_Int32 nMaxDefaultColors = SAL_N_ELEMENTS( nDefaultColors ); + static const sal_Int32 nMaxDefaultColors = std::size( nDefaultColors ); return nDefaultColors[ nIndex % nMaxDefaultColors ]; } -void ConfigColorScheme::notify( const OUString & rPropertyName ) +void ConfigColorScheme::notify() { - if( rPropertyName == aSeriesPropName ) - m_bNeedsUpdate = true; + m_bNeedsUpdate = true; } OUString SAL_CALL ConfigColorScheme::getImplementationName() { - return "com.sun.star.comp.chart2.ConfigDefaultColorScheme" ; -} - -sal_Bool SAL_CALL ConfigColorScheme::supportsService( const OUString& rServiceName ) -{ - return cppu::supportsService(this, rServiceName); -} - -css::uno::Sequence< OUString > SAL_CALL ConfigColorScheme::getSupportedServiceNames() -{ - return { "com.sun.star.chart2.ColorScheme" }; + return u"com.sun.star.comp.chart2.ConfigDefaultColorScheme"_ustr ; } } // namespace chart |