summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Snelders <programming@ertai.nl>2011-04-04 12:07:23 +0300
committerTor Lillqvist <tlillqvist@novell.com>2011-04-04 12:07:23 +0300
commitd57dfa29c2ba47293eb12a853cdccf4196565ef7 (patch)
tree49473dd0cc84c983afc0ccd6b759af681e6bcf9e
parenta561fc7f6538c9e3271f0a2e9847577adeb25842 (diff)
Improvement of adding and removing color charts
-rw-r--r--cui/source/inc/cuires.hrc2
-rw-r--r--cui/source/options/cfgchart.cxx11
-rw-r--r--cui/source/options/cfgchart.hxx2
-rw-r--r--cui/source/options/optchart.cxx32
-rw-r--r--cui/source/options/optchart.hxx3
-rw-r--r--cui/source/options/optchart.src10
6 files changed, 49 insertions, 11 deletions
diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc
index efde05284e3e..5f80b1ef8a76 100644
--- a/cui/source/inc/cuires.hrc
+++ b/cui/source/inc/cuires.hrc
@@ -157,6 +157,8 @@
#define RID_SVXPAGE_ACCESSIBILITYCONFIG (RID_SVX_START + 250)
#define RID_SVXPAGE_ASIAN_LAYOUT (RID_SVX_START + 246)
#define RID_OPTPAGE_CHART_DEFCOLORS (RID_SVX_START + 299)
+#define RID_OPTQB_COLOR_CHART_DELETE (RID_SVX_START + 296)
+#define RID_OPTSTR_COLOR_CHART_DELETE (RID_SVX_START + 289)
#define RID_SVXPAGE_COLORCONFIG (RID_SVX_START + 249)
#define RID_SVXQB_DELETE_COLOR_CONFIG (RID_SVX_START + 324)
#define RID_SVXSTR_COLOR_CONFIG_SAVE1 (RID_SVX_START + 853)
diff --git a/cui/source/options/cfgchart.cxx b/cui/source/options/cfgchart.cxx
index 0d406cd9156f..969eae062fb2 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 dede79ebc299..95e038557779 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 b30d933ee9aa..177db9a414c3 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 933a72e0ab03..1b457dd64385 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 0b9cf2df1cb6..425fbcf11689 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" ;
+};