[Libreoffice-commits] .: Branch 'feature/cond-format-rework' - sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Oct 5 20:22:29 PDT 2012


 sc/source/ui/attrdlg/scdlgfact.cxx        |   13 ++++++++--
 sc/source/ui/condformat/condformatdlg.cxx |   39 ++++++++++++++++++++++++++----
 sc/source/ui/condformat/condformatmgr.cxx |    2 -
 sc/source/ui/inc/condformatdlg.hxx        |   25 ++++++++++++++++---
 sc/source/ui/view/cellsh1.cxx             |    6 ++--
 5 files changed, 71 insertions(+), 14 deletions(-)

New commits:
commit efd0b1ef03ea231b77a509fc01b5919d80682226
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Oct 6 05:19:19 2012 +0200

    selecting the correct entry will also show it in the dialog
    
    Change-Id: I6bbeb2d1cb5af724ac0743d13f3e36cb8b613a88

diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 7962c6d..9200eba 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -787,8 +787,17 @@ AbstractScCondFormatDlg* ScAbstractDialogFactory_Impl::CreateScCondFormatDlg(Win
     ScCondFormatDlg* pDlg = NULL;
     switch( nId )
     {
-        case RID_SCDLG_CONDFORMAT:
-            pDlg = new ScCondFormatDlg( pParent, pDoc, pFormat, rRange, rPos );
+        case 0:
+            pDlg = new ScCondFormatDlg( pParent, pDoc, pFormat, rRange, rPos, condformat::dialog::NONE );
+            break;
+        case SID_OPENDLG_CONDFRMT:
+            pDlg = new ScCondFormatDlg( pParent, pDoc, pFormat, rRange, rPos, condformat::dialog::CONDITION );
+            break;
+        case SID_OPENDLG_COLORSCALE:
+            pDlg = new ScCondFormatDlg( pParent, pDoc, pFormat, rRange, rPos, condformat::dialog::COLORSCALE );
+            break;
+        case SID_OPENDLG_DATABAR:
+            pDlg = new ScCondFormatDlg( pParent, pDoc, pFormat, rRange, rPos, condformat::dialog::DATABAR );
             break;
         default:
             break;
diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index e2f8d67..9dc6350 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -633,6 +633,14 @@ void ScCondFrmtEntry::Select()
     SetHeight();
 }
 
+void ScCondFrmtEntry::SetType( ScCondFormatEntryType eType )
+{
+    meType = eType;
+    if(eType == DATABAR)
+        maLbColorFormat.SelectEntryPos(2);
+    Select();
+}
+
 void ScCondFrmtEntry::Deselect()
 {
     SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
@@ -987,7 +995,8 @@ IMPL_LINK_NOARG( ScCondFrmtEntry, ConditionTypeSelectHdl )
     return 0;
 }
 
-ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRanges, const ScAddress& rPos):
+ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc, const ScConditionalFormat* pFormat,
+                                const ScRangeList& rRanges, const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType):
     Control(pParent, rResId),
     mbHasScrollBar(false),
     mpScrollBar(new ScrollBar(this, WB_VERT )),
@@ -1005,9 +1014,28 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocum
         {
             maEntries.push_back(new ScCondFrmtEntry( this, mpDoc, pFormat->GetEntry(nIndex), maPos ));
         }
-        if (nCount > 0)
-            maEntries.begin()->Select();
     }
+    else
+    {
+        switch(eType)
+        {
+            case condformat::dialog::CONDITION:
+                maEntries.push_back(new ScCondFrmtEntry( this, mpDoc, maPos ));
+                break;
+            case condformat::dialog::COLORSCALE:
+                maEntries.push_back(new ScCondFrmtEntry( this, mpDoc, maPos ));
+                maEntries[0].SetType(COLORSCALE);
+                break;
+            case condformat::dialog::DATABAR:
+                maEntries.push_back(new ScCondFrmtEntry( this, mpDoc, maPos ));
+                maEntries[0].SetType(DATABAR);
+                break;
+            default:
+                break;
+        }
+    }
+    if (!maEntries.empty())
+        maEntries.begin()->Select();
 
     RecalcAll();
     FreeResource();
@@ -1083,7 +1111,8 @@ void ScCondFormatList::DoScroll(long nDelta)
     mpScrollBar->SetPosPixel(aNewPoint);
 }
 
-ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange, const ScAddress& rPos):
+ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange,
+                                    const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType):
     ModalDialog(pParent, ScResId( RID_SCDLG_CONDFORMAT )),
     maBtnAdd( this, ScResId( BTN_ADD ) ),
     maBtnRemove( this, ScResId( BTN_REMOVE ) ),
@@ -1091,7 +1120,7 @@ ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, const ScCond
     maBtnCancel( this, ScResId( BTN_CANCEL ) ),
     maFtRange( this, ScResId( FT_RANGE ) ),
     maEdRange( this, ScResId( ED_RANGE ) ),
-    maCondFormList( this, ScResId( CTRL_LIST ), pDoc, pFormat, rRange, rPos ),
+    maCondFormList( this, ScResId( CTRL_LIST ), pDoc, pFormat, rRange, rPos, eType ),
     maPos(rPos),
     mpDoc(pDoc)
 {
diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index 0931899..6eeecd1 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -217,7 +217,7 @@ IMPL_LINK_NOARG(ScCondFormatManagerDlg, EditBtnHdl)
         return 0;
 
     boost::scoped_ptr<ScCondFormatDlg> pDlg(new ScCondFormatDlg(this, mpDoc, pFormat, pFormat->GetRange(),
-                                                pFormat->GetRange().GetTopLeftCorner()));
+                                                pFormat->GetRange().GetTopLeftCorner(), condformat::dialog::NONE));
     if(pDlg->Execute() == RET_OK)
     {
         sal_Int32 nKey = pFormat->GetKey();
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 4b3e780..c7a247c 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -47,6 +47,22 @@ class ScFormatEntry;
 class ScConditionalFormat;
 struct ScDataBarFormatData;
 
+namespace condformat {
+
+namespace dialog {
+
+enum ScCondFormatDialogType
+{
+    NONE,
+    CONDITION,
+    COLORSCALE,
+    DATABAR
+};
+
+}
+
+}
+
 class ScCondFrmtEntry : public Control
 {
 private:
@@ -96,7 +112,6 @@ private:
     boost::scoped_ptr<ScDataBarFormatData> mpDataBarData;
 
     //
-    void SwitchToType(ScCondFormatEntryType eType);
     void SetCondType();
     void SetColorScaleType();
     void SetDataBarType();
@@ -104,6 +119,7 @@ private:
     void HideCondElements();
     void HideColorScaleElements();
     void HideDataBarElements();
+    void SwitchToType(ScCondFormatEntryType eType);
 
     void SetHeight();
     void Init();
@@ -134,6 +150,8 @@ public:
 
     virtual long Notify( NotifyEvent& rNEvt );
 
+    void SetType( ScCondFormatEntryType eType );
+
     void Select();
     void Deselect();
 
@@ -159,7 +177,8 @@ private:
     void RecalcAll();
     void DoScroll(long nDiff);
 public:
-    ScCondFormatList( Window* pParent, const ResId& rResId, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRanges, const ScAddress& rPos);
+    ScCondFormatList( Window* pParent, const ResId& rResId, ScDocument* pDoc, const ScConditionalFormat* pFormat,
+            const ScRangeList& rRanges, const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType);
 
     ScConditionalFormat* GetConditionalFormat() const;
 
@@ -188,7 +207,7 @@ private:
     DECL_LINK( EdRangeModifyHdl, Edit* );
 
 public:
-    ScCondFormatDlg(Window* pWindow, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange, const ScAddress& rPos);
+    ScCondFormatDlg(Window* pWindow, ScDocument* pDoc, const ScConditionalFormat* pFormat, const ScRangeList& rRange, const ScAddress& rPos, condformat::dialog::ScCondFormatDialogType eType);
 
     ScConditionalFormat* GetConditionalFormat() const;
 };
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index c4b21f3..1f970b6 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -2065,15 +2065,15 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                 {
                     const ScRangeList& rCondFormatRange = pCondFormat->GetRange();
                     if(rCondFormatRange == aRangeList)
-                        pDlg.reset(pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, pCondFormat->GetRange(), aPos, RID_SCDLG_CONDFORMAT ));
+                        pDlg.reset(pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, pCondFormat, pCondFormat->GetRange(), aPos, 0 ));
                 }
 
                 if(!pDlg)
                 {
-                    pDlg.reset(pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aRangeList.GetTopLeftCorner(), RID_SCDLG_CONDFORMAT ));
+                    pDlg.reset(pFact->CreateScCondFormatDlg( pTabViewShell->GetDialogParent(), pDoc, NULL, aRangeList, aRangeList.GetTopLeftCorner(), nSlot ));
                 }
 
-                if(pDlg->Execute() == RET_OK)
+                if(pDlg && pDlg->Execute() == RET_OK)
                 {
                     ScConditionalFormat* pFormat = pDlg->GetConditionalFormat();
                     sal_uLong nOldIndex = 0;


More information about the Libreoffice-commits mailing list