[Libreoffice-commits] .: cui/source

Tor Lillqvist tml at kemper.freedesktop.org
Mon Apr 4 02:07:56 PDT 2011


 cui/source/inc/cuires.hrc       |    2 ++
 cui/source/options/cfgchart.cxx |   11 ++++++++---
 cui/source/options/cfgchart.hxx |    2 +-
 cui/source/options/optchart.cxx |   32 ++++++++++++++++++++++++++------
 cui/source/options/optchart.hxx |    3 ++-
 cui/source/options/optchart.src |   10 ++++++++++
 6 files changed, 49 insertions(+), 11 deletions(-)

New commits:
commit b635aad528973bf175aa8a61ad380992448b6f5a
Author: Rob Snelders <programming at ertai.nl>
Date:   Mon Apr 4 12:07:23 2011 +0300

    Improvement of adding and removing color charts

diff --git a/cui/source/inc/cuires.hrc b/cui/source/inc/cuires.hrc
index 24d3ce2..226b8f7 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 0d406cd..969eae0 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 918f81a..b9adf39 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 51d48d4..f5c25dc 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 71898e9..1416008 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 593fafd..09800aa 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" ;
+};


More information about the Libreoffice-commits mailing list