diff options
author | Rob Snelders <programming@ertai.nl> | 2011-04-04 12:07:23 +0300 |
---|---|---|
committer | Tor Lillqvist <tlillqvist@novell.com> | 2011-04-04 12:36:20 +0300 |
commit | 576feba610e92bd31e17573c06fc0242d3465742 (patch) | |
tree | 940c82d299eb85386f5b1818d7bacf30bbcffc27 /cui/source/options | |
parent | 50b65e0e971869854b8da7465ff642f1a886d873 (diff) |
Improvement of adding and removing color charts
(cherry picked from commit b635aad528973bf175aa8a61ad380992448b6f5a)
Diffstat (limited to 'cui/source/options')
-rw-r--r-- | cui/source/options/cfgchart.cxx | 11 | ||||
-rw-r--r-- | cui/source/options/cfgchart.hxx | 2 | ||||
-rw-r--r-- | cui/source/options/optchart.cxx | 32 | ||||
-rw-r--r-- | cui/source/options/optchart.hxx | 3 | ||||
-rw-r--r-- | cui/source/options/optchart.src | 10 |
5 files changed, 47 insertions, 11 deletions
diff --git a/cui/source/options/cfgchart.cxx b/cui/source/options/cfgchart.cxx index 0d406cd91..969eae062 100644 --- a/cui/source/options/cfgchart.cxx +++ b/cui/source/options/cfgchart.cxx @@ -92,6 +92,11 @@ void SvxChartColorTable::remove( size_t _nIndex ) { if (m_aColorEntries.size() > 0) m_aColorEntries.erase( m_aColorEntries.begin() + _nIndex); + + for (size_t i=0 ; i<m_aColorEntries.size(); i++) + { + m_aColorEntries[ i ].SetName( getDefaultName( i ) ); + } } void SvxChartColorTable::replace( size_t _nIndex, const XColorEntry & _rEntry ) @@ -123,11 +128,11 @@ void SvxChartColorTable::useDefault() for( sal_Int32 i=0; i<ROW_COLOR_COUNT; i++ ) { - append( XColorEntry( aColors[ i % sizeof( aColors ) ], getNextDefaultName() )); + append( XColorEntry( aColors[ i % sizeof( aColors ) ], getDefaultName( i ) )); } } -String SvxChartColorTable::getNextDefaultName() +String SvxChartColorTable::getDefaultName( size_t _nIndex ) { String aName; @@ -147,7 +152,7 @@ String SvxChartColorTable::getNextDefaultName() } aName = sDefaultNamePrefix; - aName.Append( String::CreateFromInt32 ( nNextElementNumber ) ); + aName.Append( String::CreateFromInt32 ( _nIndex + 1 ) ); aName.Append( sDefaultNamePostfix ); nNextElementNumber++; diff --git a/cui/source/options/cfgchart.hxx b/cui/source/options/cfgchart.hxx index 918f81a3a..b9adf3900 100644 --- a/cui/source/options/cfgchart.hxx +++ b/cui/source/options/cfgchart.hxx @@ -63,7 +63,7 @@ public: void remove( size_t _nIndex ); void replace( size_t _nIndex, const XColorEntry & _rEntry ); void useDefault(); - String getNextDefaultName(); + String getDefaultName(size_t _nIndex); // comparison bool operator==( const SvxChartColorTable & _rOther ) const; diff --git a/cui/source/options/optchart.cxx b/cui/source/options/optchart.cxx index 51d48d461..f5c25dc47 100644 --- a/cui/source/options/optchart.cxx +++ b/cui/source/options/optchart.cxx @@ -31,6 +31,7 @@ #include "optchart.hxx" #include "optchart.hrc" #include <dialmgr.hxx> +#include <vcl/msgbox.hxx> #include <svx/svxids.hrc> // for SID_SCH_EDITOPTIONS // ==================== @@ -194,6 +195,7 @@ IMPL_LINK( SvxDefaultColorOptPage, ResetToDefaults, void *, EMPTYARG ) aLbChartColors.FillBox( pColorConfig->GetColorTable() ); aLbChartColors.GetFocus(); + aLbChartColors.SelectEntryPos( 0 ); } return 0L; @@ -208,12 +210,13 @@ IMPL_LINK( SvxDefaultColorOptPage, AddChartColor, void *, EMPTYARG ) { ColorData black = RGB_COLORDATA( 0x00, 0x00, 0x00 ); - pColorConfig->GetColorTable().append (XColorEntry ( black, pColorConfig->GetColorTable().getNextDefaultName())); + pColorConfig->GetColorTable().append (XColorEntry ( black, pColorConfig->GetColorTable().getDefaultName(pColorConfig->GetColorTable().size()))); aLbChartColors.Clear(); aLbChartColors.FillBox( pColorConfig->GetColorTable() ); aLbChartColors.GetFocus(); + aLbChartColors.SelectEntryPos( pColorConfig->GetColorTable().size() - 1 ); } return 0L; @@ -222,16 +225,33 @@ IMPL_LINK( SvxDefaultColorOptPage, AddChartColor, void *, EMPTYARG ) // RemoveChartColor // ---------------- -IMPL_LINK( SvxDefaultColorOptPage, RemoveChartColor, void *, EMPTYARG ) +IMPL_LINK( SvxDefaultColorOptPage, RemoveChartColor, PushButton*, pButton ) { + size_t nIndex = aLbChartColors.GetSelectEntryPos(); + + if (aLbChartColors.GetSelectEntryCount() == 0) + return 0L; + if( pColorConfig ) { - pColorConfig->GetColorTable().remove( aLbChartColors.GetSelectEntryPos() ); + DBG_ASSERT(pColorConfig.size() > 1, "don't delete the last chart color"); + QueryBox aQuery(pButton, CUI_RES(RID_OPTQB_COLOR_CHART_DELETE)); + aQuery.SetText(String(CUI_RES(RID_OPTSTR_COLOR_CHART_DELETE))); + if(RET_YES == aQuery.Execute()) + { - aLbChartColors.Clear(); - aLbChartColors.FillBox( pColorConfig->GetColorTable() ); + pColorConfig->GetColorTable().remove( nIndex ); - aLbChartColors.GetFocus(); + aLbChartColors.Clear(); + aLbChartColors.FillBox( pColorConfig->GetColorTable() ); + + aLbChartColors.GetFocus(); + + if (nIndex == aLbChartColors.GetEntryCount() && aLbChartColors.GetEntryCount() > 0) + aLbChartColors.SelectEntryPos( pColorConfig->GetColorTable().size() - 1 ); + else if (aLbChartColors.GetEntryCount() > 0) + aLbChartColors.SelectEntryPos( nIndex ); + } } return 0L; diff --git a/cui/source/options/optchart.hxx b/cui/source/options/optchart.hxx index 71898e9e3..141600890 100644 --- a/cui/source/options/optchart.hxx +++ b/cui/source/options/optchart.hxx @@ -55,6 +55,7 @@ public: class SvxDefaultColorOptPage : public SfxTabPage { + private: FixedLine aGbChartColors; ChartColorLB aLbChartColors; @@ -70,7 +71,7 @@ private: DECL_LINK( ResetToDefaults, void * ); DECL_LINK( AddChartColor, void * ); - DECL_LINK( RemoveChartColor, void * ); + DECL_LINK( RemoveChartColor, PushButton * ); DECL_LINK( ListClickedHdl, ChartColorLB * ); DECL_LINK( BoxClickedHdl, ValueSet * ); diff --git a/cui/source/options/optchart.src b/cui/source/options/optchart.src index 593fafd36..09800aa36 100644 --- a/cui/source/options/optchart.src +++ b/cui/source/options/optchart.src @@ -97,3 +97,13 @@ String RID_SVXSTR_DIAGRAM_ROW Text [ en-US ] = "Data Series $(ROW)" ; }; +QueryBox RID_OPTQB_COLOR_CHART_DELETE +{ + Buttons = WB_YES_NO ; + DefButton = WB_DEF_NO ; + Message [ en-US ] = "Do you really want to delete the chart color?" ; +}; +String RID_OPTSTR_COLOR_CHART_DELETE +{ + Text [ en-US ] = "Chart Color Deletion" ; +}; |