[Libreoffice-commits] .: sc/inc sc/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Mon Jun 11 23:35:10 PDT 2012


 sc/inc/colorscale.hxx                     |    2 +
 sc/source/core/data/colorscale.cxx        |    9 +++++
 sc/source/ui/condformat/colorformat.cxx   |   54 +++++++++++++++++++++++++++---
 sc/source/ui/condformat/condformatdlg.cxx |   36 ++++++++++++++++++++
 sc/source/ui/inc/colorformat.hrc          |    2 +
 sc/source/ui/inc/colorformat.hxx          |    3 +
 sc/source/ui/src/colorformat.src          |    6 ++-
 7 files changed, 106 insertions(+), 6 deletions(-)

New commits:
commit 56de6cce83701f003416ad91b28c0dbca3a3d67e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Jun 12 07:48:41 2012 +0200

    small improvements to data bar dialog
    
    Change-Id: I7eada5e24047d36c1625aa082ecc9e5d52f785ae

diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx
index 8e9c377..72349dc 100644
--- a/sc/inc/colorscale.hxx
+++ b/sc/inc/colorscale.hxx
@@ -80,6 +80,8 @@ public:
     void SetMax(bool bMax);
     void SetPercent(bool bPercent);
     void SetPercentile(bool bPercentile);
+
+    void SetHasValue();
 };
 
 namespace databar
diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx
index e6a5c8d..c677397 100644
--- a/sc/source/core/data/colorscale.cxx
+++ b/sc/source/core/data/colorscale.cxx
@@ -242,6 +242,15 @@ void ScColorScaleEntry::SetPercentile(bool bPercentile)
     mbPercentile = bPercentile;
 }
 
+void ScColorScaleEntry::SetHasValue()
+{
+    mbPercentile = false;
+    mbPercent = false;
+    mbMin = false;
+    mbMax = false;
+    mpCell.reset();
+}
+
 namespace {
 
 double getMinValue(const ScRange& rRange, ScDocument* pDoc)
diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx
index de45815..2483364 100644
--- a/sc/source/ui/condformat/colorformat.cxx
+++ b/sc/source/ui/condformat/colorformat.cxx
@@ -105,12 +105,12 @@ void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry
             pEntry->SetValue(nVal);
             break;
         case 4:
-            //FIXME
-            break;
-        case 5:
             nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
+            pEntry->SetHasValue();
             pEntry->SetValue(nVal);
             break;
+        case 5:
+            break;
     }
 }
 
@@ -146,7 +146,8 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, const ScDataBarForma
     maLbTypeMax( this, ScResId( LB_TYPE ) ),
     maLbAxisPos( this, ScResId( LB_AXIS_POSITION ) ),
     maEdMin( this, ScResId( ED_MIN ) ),
-    maEdMax( this, ScResId( ED_MAX ) )
+    maEdMax( this, ScResId( ED_MAX ) ),
+    maStrWarnSameValue( SC_RESSTR( STR_WARN_SAME_VALUE ) )
 {
     Init();
     FreeResource();
@@ -171,6 +172,8 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, const ScDataBarForma
     ::SetType(rData.mpUpperLimit.get(), maLbTypeMax);
     SetValue(rData.mpLowerLimit.get(), maEdMin);
     SetValue(rData.mpUpperLimit.get(), maEdMax);
+
+    TypeSelectHdl(NULL);
 }
 
 ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, ScDataBarFormat* pFormat):
@@ -193,7 +196,8 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, ScDataBarFormat* pFo
     maLbTypeMax( this, ScResId( LB_TYPE ) ),
     maLbAxisPos( this, ScResId( LB_AXIS_POSITION ) ),
     maEdMin( this, ScResId( ED_MIN ) ),
-    maEdMax( this, ScResId( ED_MAX ) )
+    maEdMax( this, ScResId( ED_MAX ) ),
+    maStrWarnSameValue( SC_RESSTR( STR_WARN_SAME_VALUE ) )
 {
     Init();
     FreeResource();
@@ -265,6 +269,10 @@ void ScDataBarSettingsDlg::Init()
     Point aPoint = maLbTypeMax.GetPosPixel();
     aPoint.Y() += 50;
     maLbTypeMax.SetPosPixel(aPoint);
+
+    maLbTypeMin.SetSelectHdl( LINK( this, ScDataBarSettingsDlg, TypeSelectHdl ) );
+    maLbTypeMax.SetSelectHdl( LINK( this, ScDataBarSettingsDlg, TypeSelectHdl ) );
+
 }
 
 namespace {
@@ -329,6 +337,8 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
     if(bWarn)
     {
         //show warning message and don't close
+        WarningBox aWarn(this, WB_OK, maStrWarnSameValue );
+        aWarn.Execute();
     }
     else
     {
@@ -337,4 +347,38 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
     return 0;
 }
 
+IMPL_LINK_NOARG( ScDataBarSettingsDlg, TypeSelectHdl )
+{
+    sal_Int32 nSelectMin = maLbTypeMin.GetSelectEntryPos();
+    if( nSelectMin == 0 || nSelectMin == 1)
+        maEdMin.Disable();
+    else
+    {
+        maEdMin.Enable();
+        if(!maEdMin.GetText().Len())
+        {
+            if(nSelectMin == 2 || nSelectMin == 3)
+                maEdMin.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(50)));
+            else
+                maEdMin.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(0)));
+        }
+    }
+
+    sal_Int32 nSelectMax = maLbTypeMax.GetSelectEntryPos();
+    if(nSelectMax == 0 || nSelectMax == 1)
+        maEdMax.Disable();
+    else
+    {
+        maEdMax.Enable();
+        if(!maEdMax.GetText().Len())
+        {
+            if(nSelectMax == 2 || nSelectMax == 3)
+                maEdMax.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(50)));
+            else
+                maEdMax.SetText(rtl::OUString::valueOf(static_cast<sal_Int32>(0)));
+        }
+    }
+    return 0;
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 54d5ba1..81a681b 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -685,6 +685,7 @@ void SetColorScaleEntry( ScColorScaleEntry* pEntry, const ListBox& rType, const
             break;
         case 3:
             pEntry->SetValue(nVal);
+            pEntry->SetHasValue();
             break;
         case 4:
             pEntry->SetPercent(true);
@@ -693,6 +694,8 @@ void SetColorScaleEntry( ScColorScaleEntry* pEntry, const ListBox& rType, const
         case 5:
             pEntry->SetFormula(rValue.GetText(), pDoc, rPos);
             break;
+        default:
+            break;
     }
 }
 
@@ -706,6 +709,36 @@ ScColorScaleEntry* createColorScaleEntry( const ListBox& rType, const ColorListB
     return pEntry;
 }
 
+void GetDataBarType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry )
+{
+    double nVal = 0;
+    switch(rLstBox.GetSelectEntryPos())
+    {
+        case 0:
+            pEntry->SetMin(true);
+            break;
+        case 1:
+            pEntry->SetMax(true);
+            break;
+        case 2:
+            pEntry->SetPercentile(true);
+            nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
+            pEntry->SetValue(nVal);
+            break;
+        case 3:
+            nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
+            pEntry->SetPercent(true);
+            pEntry->SetValue(nVal);
+            break;
+        case 4:
+            nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
+            pEntry->SetValue(nVal);
+            break;
+        case 5:
+            break;
+    }
+}
+
 }
 
 ScFormatEntry* ScCondFrmtEntry::createColorscaleEntry() const
@@ -720,6 +753,8 @@ ScFormatEntry* ScCondFrmtEntry::createColorscaleEntry() const
 
 ScFormatEntry* ScCondFrmtEntry::createDatabarEntry() const
 {
+    SetColorScaleEntry(mpDataBarData->mpLowerLimit.get(), maLbDataBarMinType, maEdDataBarMin, mpDoc, maPos);
+    SetColorScaleEntry(mpDataBarData->mpUpperLimit.get(), maLbDataBarMaxType, maEdDataBarMax, mpDoc, maPos);
     ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc);
     pDataBar->SetDataBarData(new ScDataBarFormatData(*mpDataBarData.get()));
     return pDataBar;
@@ -862,6 +897,7 @@ IMPL_LINK_NOARG( ScCondFrmtEntry, OptionBtnHdl )
         mpDataBarData.reset(pDlg->GetData());
         SetDataBarEntryTypes(*mpDataBarData->mpLowerLimit, maLbDataBarMinType, maEdDataBarMin);
         SetDataBarEntryTypes(*mpDataBarData->mpUpperLimit, maLbDataBarMaxType, maEdDataBarMax);
+        DataBarTypeSelectHdl(NULL);
     }
     return 0;
 }
diff --git a/sc/source/ui/inc/colorformat.hrc b/sc/source/ui/inc/colorformat.hrc
index fc27609..140cd16 100644
--- a/sc/source/ui/inc/colorformat.hrc
+++ b/sc/source/ui/inc/colorformat.hrc
@@ -50,4 +50,6 @@
 #define ED_MIN 24
 #define ED_MAX 25
 
+#define STR_WARN_SAME_VALUE 26
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/colorformat.hxx b/sc/source/ui/inc/colorformat.hxx
index 4fe44f9..c85eec5 100644
--- a/sc/source/ui/inc/colorformat.hxx
+++ b/sc/source/ui/inc/colorformat.hxx
@@ -62,7 +62,10 @@ private:
     Edit maEdMin;
     Edit maEdMax;
 
+    rtl::OUString maStrWarnSameValue;
+
     DECL_LINK(OkBtnHdl, void*);
+    DECL_LINK(TypeSelectHdl, void*);
 
     void Init();
 
diff --git a/sc/source/ui/src/colorformat.src b/sc/source/ui/src/colorformat.src
index 18cd823..66ae20e 100644
--- a/sc/source/ui/src/colorformat.src
+++ b/sc/source/ui/src/colorformat.src
@@ -136,8 +136,8 @@ ModalDialog RID_SCDLG_DATABAR
         {
             "Minimum";
             "Maximum";
-            "Percent";
             "Percentile";
+            "Percent";
             "Value";
             "Formula";
         };
@@ -169,6 +169,10 @@ ModalDialog RID_SCDLG_DATABAR
         TabStop = TRUE;
         Border = TRUE;
     };
+    String STR_WARN_SAME_VALUE
+    {
+        Text [ en-US ] = "Min value must be smaller than max value!";
+    };
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list