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

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Thu Jun 14 21:44:16 PDT 2012


 sc/source/ui/condformat/colorformat.cxx   |   21 +++++++----
 sc/source/ui/condformat/condformatdlg.cxx |   53 ++++++++++++++++++++++++------
 sc/source/ui/inc/colorformat.hxx          |    2 +
 sc/source/ui/inc/condformatdlg.hxx        |    4 ++
 4 files changed, 63 insertions(+), 17 deletions(-)

New commits:
commit 31058ad8f22480730651e7379fb0d7b9654739a0
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jun 15 06:43:32 2012 +0200

    disable two ui elements for 3.6
    
    Change-Id: I55c8932fb5561704626f73e044091fe7b5240229

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index d230692..25ff9a5 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -548,7 +548,8 @@ void ScCondFrmtEntry::SetColorScaleType()
     {
         maEdMiddle.Hide();
         maLbEntryTypeMiddle.Hide();
-        maLbColScale2.Show();
+        // TODO: enale for 3.7 again with good presets
+        //maLbColScale2.Show();
         maLbColScale3.Hide();
         maLbColMiddle.Hide();
     }
@@ -557,7 +558,8 @@ void ScCondFrmtEntry::SetColorScaleType()
         maEdMiddle.Show();
         maLbEntryTypeMiddle.Show();
         maLbColScale2.Hide();
-        maLbColScale3.Show();
+        // TODO: enale for 3.7 again with good presets
+        // maLbColScale3.Show();
         maLbColMiddle.Show();
     }
     maLbEntryTypeMin.Show();
commit 146cc7a3ad8b07889dff64cf6d3db21e2d6d2147
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Jun 15 06:32:33 2012 +0200

    use correct localization aware string to double
    
    Change-Id: Ied254ef0dc8f7dcf444738da193122a733089b5a

diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx
index 2483364..ba54db2 100644
--- a/sc/source/ui/condformat/colorformat.cxx
+++ b/sc/source/ui/condformat/colorformat.cxx
@@ -83,9 +83,10 @@ void SetType(const ScColorScaleEntry* pEntry, ListBox& aLstBox)
         aLstBox.SelectEntryPos(4);
 }
 
-void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry )
+void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry, SvNumberFormatter* pNumberFormatter )
 {
     double nVal = 0;
+    sal_uInt32 nIndex = 0;
     switch(rLstBox.GetSelectEntryPos())
     {
         case 0:
@@ -96,16 +97,16 @@ void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry
             break;
         case 2:
             pEntry->SetPercentile(true);
-            nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
+            pNumberFormatter->IsNumberFormat( rEd.GetText(), nIndex, nVal );
             pEntry->SetValue(nVal);
             break;
         case 3:
-            nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
             pEntry->SetPercent(true);
+            pNumberFormatter->IsNumberFormat( rEd.GetText(), nIndex, nVal );
             pEntry->SetValue(nVal);
             break;
         case 4:
-            nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ',');
+            pNumberFormatter->IsNumberFormat( rEd.GetText(), nIndex, nVal );
             pEntry->SetHasValue();
             pEntry->SetValue(nVal);
             break;
@@ -305,8 +306,8 @@ ScDataBarFormatData* ScDataBarSettingsDlg::GetData()
     pData->mpUpperLimit.reset(new ScColorScaleEntry());
     pData->mpLowerLimit.reset(new ScColorScaleEntry());
 
-    ::GetType(maLbTypeMin, maEdMin, pData->mpLowerLimit.get());
-    ::GetType(maLbTypeMax, maEdMax, pData->mpUpperLimit.get());
+    ::GetType(maLbTypeMin, maEdMin, pData->mpLowerLimit.get(), mpNumberFormatter);
+    ::GetType(maLbTypeMax, maEdMax, pData->mpUpperLimit.get(), mpNumberFormatter);
     GetAxesPosition(pData, maLbAxisPos);
 
     return pData;
@@ -327,8 +328,12 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
         {
             rtl::OUString aMinString = maEdMin.GetText();
             rtl::OUString aMaxString = maEdMax.GetText();
-            double nMinValue = rtl::math::stringToDouble(aMinString, '.', ',');
-            double nMaxValue = rtl::math::stringToDouble(aMaxString, '.', ',');
+            double nMinValue = 0;
+            sal_uInt32 nIndex = 0;
+            mpNumberFormatter->IsNumberFormat(aMinString, nIndex, nMinValue);
+            nIndex = 0;
+            double nMaxValue = 0;
+            mpNumberFormatter->IsNumberFormat(aMaxString, nIndex, nMinValue);
             if(rtl::math::approxEqual(nMinValue, nMaxValue) || nMinValue > nMaxValue)
                 bWarn = true;
         }
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 51e68c2..d230692 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -47,8 +47,6 @@
 #include "colorscale.hxx"
 #include "colorformat.hxx"
 
-#include <rtl/math.hxx>
-
 #include "globstr.hrc"
 
 #include <cassert>
@@ -685,7 +683,10 @@ namespace {
 
 void SetColorScaleEntry( ScColorScaleEntry* pEntry, const ListBox& rType, const Edit& rValue, ScDocument* pDoc, const ScAddress& rPos )
 {
-    double nVal = rtl::math::stringToDouble(rValue.GetText(), '.', ',');
+    sal_uInt32 nIndex = 0;
+    double nVal = 0;
+    SvNumberFormatter* pNumberFormatter = pDoc->GetFormatTable();
+    pNumberFormatter->IsNumberFormat(rValue.GetText(), nIndex, nVal);
     switch(rType.GetSelectEntryPos())
     {
         case 0:
@@ -1054,7 +1055,9 @@ ScConditionalFormat* ScCondFormatDlg::GetConditionalFormat() const
 
 IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
 {
-    maEntries.push_back( new ScCondFrmtEntry(this, mpDoc) );
+    ScCondFrmtEntry* pNewEntry = new ScCondFrmtEntry(this, mpDoc);
+    maEntries.push_back( pNewEntry );
+    pNewEntry->Select();
     RecalcAll();
     return 0;
 }
diff --git a/sc/source/ui/inc/colorformat.hxx b/sc/source/ui/inc/colorformat.hxx
index c85eec5..fffbb34 100644
--- a/sc/source/ui/inc/colorformat.hxx
+++ b/sc/source/ui/inc/colorformat.hxx
@@ -30,6 +30,7 @@
 #include <vcl/dialog.hxx>
 #include <vcl/fixed.hxx>
 #include <svtools/ctrlbox.hxx>
+#include <svl/zforlist.hxx>
 #include "anyrefdg.hxx"
 
 class ScDataBarFormat;
@@ -63,6 +64,7 @@ private:
     Edit maEdMax;
 
     rtl::OUString maStrWarnSameValue;
+    SvNumberFormatter* mpNumberFormatter;
 
     DECL_LINK(OkBtnHdl, void*);
     DECL_LINK(TypeSelectHdl, void*);
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 2794cfd..8b03c29 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -123,6 +123,7 @@ private:
 
     ScDocument* mpDoc;
     ScAddress maPos;
+    SvNumberFormatter* mpNumberFormatter;
 
     DECL_LINK( TypeListHdl, void*);
     DECL_LINK( ColFormatTypeHdl, void*);
commit fb4302d489d542ce9afd54a377b3399e1c4cad00
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Thu Jun 14 09:03:22 2012 +0200

    handle formula is in new conditional format dlg
    
    Change-Id: Ia492b8fb9ad1406800ba855370daafb40f254093

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 8434d53..51e68c2 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -219,6 +219,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
         ScConditionMode eMode = pEntry->GetOperation();
         maLbType.SelectEntryPos(1);
         maEdVal1.SetText(pEntry->GetExpression(maPos, 0));
+        SetCondType();
         switch(eMode)
         {
             case SC_COND_EQUAL:
@@ -255,12 +256,11 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
                 break;
             case SC_COND_DIRECT:
                 maLbType.SelectEntryPos(2);
+                SwitchToType(FORMULA);
                 break;
             case SC_COND_NONE:
                 break;
         }
-        SwitchToType(CONDITION);
-        SetCondType();
     }
     else if( pFormatEntry && pFormatEntry->GetType() == condformat::COLORSCALE )
     {
@@ -400,6 +400,8 @@ rtl::OUString getTextForType(ScCondFormatEntryType eType)
             return rtl::OUString("Color scale");
         case DATABAR:
             return rtl::OUString("Data Bar");
+        case FORMULA:
+            return rtl::OUString("Formula is");
         default:
             break;
     }
@@ -517,6 +519,7 @@ void ScCondFrmtEntry::SetHeight()
         switch (meType)
         {
             case CONDITION:
+            case FORMULA:
                 aSize.Height() = 120;
                 break;
             case COLORSCALE:
@@ -591,6 +594,18 @@ void ScCondFrmtEntry::SetDataBarType()
     maBtOptions.Show();
 }
 
+void ScCondFrmtEntry::SetFormulaType()
+{
+    SwitchToType(FORMULA);
+    HideColorScaleElements();
+    HideDataBarElements();
+    maEdVal1.Show();
+    maEdVal2.Hide();
+    maLbCondType.Hide();
+    maLbStyle.Show();
+    maWdPreview.Show();
+}
+
 void ScCondFrmtEntry::Select()
 {
     SetControlForeground(Color(COL_RED));
@@ -730,6 +745,18 @@ ScFormatEntry* ScCondFrmtEntry::createDatabarEntry() const
     return pDataBar;
 }
 
+ScFormatEntry* ScCondFrmtEntry::createFormulaEntry() const
+{
+    ScConditionMode eMode = SC_COND_DIRECT;
+    rtl::OUString aFormula = maEdVal1.GetText();
+    if(aFormula.isEmpty())
+        return NULL;
+
+    rtl::OUString aExpr2;
+    ScFormatEntry* pEntry = new ScCondFormatEntry(eMode, aFormula, aExpr2, mpDoc, maPos, maLbStyle.GetSelectEntry());
+    return pEntry;
+}
+
 ScFormatEntry* ScCondFrmtEntry::GetEntry() const
 {
     switch(meType)
@@ -743,6 +770,9 @@ ScFormatEntry* ScCondFrmtEntry::GetEntry() const
         case DATABAR:
             return createDatabarEntry();
             break;
+        case FORMULA:
+            return createFormulaEntry();
+            break;
         default:
             break;
     }
@@ -764,7 +794,7 @@ IMPL_LINK_NOARG(ScCondFrmtEntry, TypeListHdl)
                 SetDataBarType();
             break;
         case 2:
-            SetCondType();
+            SetFormulaType();
             break;
         default:
             break;
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index e66c090..2794cfd 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -51,6 +51,7 @@ enum ScCondFormatEntryType
     CONDITION,
     COLORSCALE,
     DATABAR,
+    FORMULA,
     COLLAPSED
 };
 
@@ -107,6 +108,7 @@ private:
     void SetCondType();
     void SetColorScaleType();
     void SetDataBarType();
+    void SetFormulaType();
     void HideCondElements();
     void HideColorScaleElements();
     void HideDataBarElements();
@@ -117,6 +119,7 @@ private:
     ScFormatEntry* createConditionEntry() const;
     ScFormatEntry* createColorscaleEntry() const;
     ScFormatEntry* createDatabarEntry() const;
+    ScFormatEntry* createFormulaEntry() const;
 
     ScDocument* mpDoc;
     ScAddress maPos;


More information about the Libreoffice-commits mailing list