diff options
Diffstat (limited to 'cui/source/options/cfgchart.cxx')
-rw-r--r-- | cui/source/options/cfgchart.cxx | 103 |
1 files changed, 30 insertions, 73 deletions
diff --git a/cui/source/options/cfgchart.cxx b/cui/source/options/cfgchart.cxx index 063ecc0fb184..8d1bd5e4130e 100644 --- a/cui/source/options/cfgchart.cxx +++ b/cui/source/options/cfgchart.cxx @@ -23,6 +23,8 @@ #include "cfgchart.hxx" #include <dialmgr.hxx> #include <strings.hrc> +#include <utility> +#include <officecfg/Office/Chart.hxx> #define ROW_COLOR_COUNT 12 @@ -115,14 +117,14 @@ OUString SvxChartColorTable::getDefaultName( size_t _nIndex ) { OUString aName; - OUString sDefaultNamePrefix; - OUString sDefaultNamePostfix; + std::u16string_view sDefaultNamePrefix; + std::u16string_view sDefaultNamePostfix; OUString aResName( CuiResId( RID_CUISTR_DIAGRAM_ROW ) ); sal_Int32 nPos = aResName.indexOf( "$(ROW)" ); if( nPos != -1 ) { - sDefaultNamePrefix = aResName.copy( 0, nPos ); - sDefaultNamePostfix = aResName.copy( nPos + sizeof( "$(ROW)" ) - 1 ); + sDefaultNamePrefix = aResName.subView( 0, nPos ); + sDefaultNamePostfix = aResName.subView( nPos + sizeof( "$(ROW)" ) - 1 ); } else { @@ -158,108 +160,63 @@ bool SvxChartColorTable::operator==( const SvxChartColorTable & _rOther ) const -SvxChartOptions::SvxChartOptions() : - ::utl::ConfigItem( "Office.Chart" ), - mbIsInitialized( false ), - maPropertyNames{ "DefaultColor/Series" } +SvxChartColorTable SvxChartOptions::GetDefaultColors() { -} - -SvxChartOptions::~SvxChartOptions() -{ -} - -const SvxChartColorTable& SvxChartOptions::GetDefaultColors() -{ - if ( !mbIsInitialized ) - mbIsInitialized = RetrieveOptions(); - return maDefColors; -} - -void SvxChartOptions::SetDefaultColors( const SvxChartColorTable& aCol ) -{ - maDefColors = aCol; - SetModified(); -} - -bool SvxChartOptions::RetrieveOptions() -{ - // get sequence containing all properties - - uno::Sequence< OUString > aNames = GetPropertyNames(); - uno::Sequence< uno::Any > aProperties( aNames.getLength()); - aProperties = GetProperties( aNames ); - - if( aProperties.getLength() != aNames.getLength()) - return false; - // 1. default colors for series - maDefColors.clear(); - uno::Sequence< sal_Int64 > aColorSeq; - aProperties[ 0 ] >>= aColorSeq; + uno::Sequence< sal_Int64 > aColorSeq = officecfg::Office::Chart::DefaultColor::Series::get(); sal_Int32 nCount = aColorSeq.getLength(); Color aCol; // create strings for entry names OUString aResName( CuiResId( RID_CUISTR_DIAGRAM_ROW ) ); - OUString aPrefix, aPostfix, aName; + std::u16string_view aPrefix, aPostfix; + OUString aName; sal_Int32 nPos = aResName.indexOf( "$(ROW)" ); if( nPos != -1 ) { - aPrefix = aResName.copy( 0, nPos ); + aPrefix = aResName.subView( 0, nPos ); sal_Int32 idx = nPos + sizeof( "$(ROW)" ) - 1; - aPostfix = aResName.copy( idx ); + aPostfix = aResName.subView( idx ); } else aPrefix = aResName; // set color values + SvxChartColorTable aDefColors; for( sal_Int32 i=0; i < nCount; i++ ) { aCol = Color(ColorTransparency, aColorSeq[ i ]); aName = aPrefix + OUString::number(i + 1) + aPostfix; - maDefColors.append( XColorEntry( aCol, aName )); + aDefColors.append( XColorEntry( aCol, aName )); } - return true; + + return aDefColors; } -void SvxChartOptions::ImplCommit() +void SvxChartOptions::SetDefaultColors( const SvxChartColorTable& rDefColors ) { - uno::Sequence< OUString > aNames = GetPropertyNames(); - uno::Sequence< uno::Any > aValues( aNames.getLength()); - - if( aValues.hasElements() ) + // 1. default colors for series + // convert list to sequence + const size_t nCount = rDefColors.size(); + uno::Sequence< sal_Int64 > aColors( nCount ); + auto aColorsRange = asNonConstRange(aColors); + for( size_t i=0; i < nCount; i++ ) { - // 1. default colors for series - // convert list to sequence - const size_t nCount = maDefColors.size(); - uno::Sequence< sal_Int64 > aColors( nCount ); - auto aColorsRange = asNonConstRange(aColors); - for( size_t i=0; i < nCount; i++ ) - { - Color aData = maDefColors.getColor( i ); - aColorsRange[ i ] = sal_uInt32(aData); - } - - aValues.getArray()[0] <<= aColors; + Color aData = rDefColors.getColor( i ); + aColorsRange[ i ] = sal_uInt32(aData); } - - PutProperties( aNames, aValues ); + std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create()); + officecfg::Office::Chart::DefaultColor::Series::set(aColors, batch); + batch->commit(); } -void SvxChartOptions::Notify( const css::uno::Sequence< OUString >& ) -{ -} - - - -SvxChartColorTableItem::SvxChartColorTableItem( sal_uInt16 nWhich_, const SvxChartColorTable& aTable ) : +SvxChartColorTableItem::SvxChartColorTableItem( sal_uInt16 nWhich_, SvxChartColorTable aTable ) : SfxPoolItem( nWhich_ ), - m_aColorTable( aTable ) + m_aColorTable(std::move( aTable )) { } |