[Libreoffice-commits] core.git: sc/source sc/uiconfig

Manfred Blume manfred.blume at cib.de
Fri Apr 7 10:43:19 UTC 2017


 sc/source/ui/condformat/condformatdlg.cxx       |   79 +++++++++++++++++++++++-
 sc/source/ui/inc/condformatdlg.hxx              |    5 +
 sc/uiconfig/scalc/ui/conditionalformatdialog.ui |   34 +++++++++-
 3 files changed, 113 insertions(+), 5 deletions(-)

New commits:
commit 1a95e2a2bbdd1b95d97d3e79b1ef0bc5da95a110
Author: Manfred Blume <manfred.blume at cib.de>
Date:   Wed Apr 5 13:31:25 2017 +0200

    tdf#74074 Ability to rearrange order of conditions
    
    applied most comments from Katarina
    
    Change-Id: I8da44b234ce37747b52fb32c4c13607c06767257
    Reviewed-on: https://gerrit.libreoffice.org/36140
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Katarina Behrens <Katarina.Behrens at cib.de>

diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx
index 8689c0be7115..a39a9cea2e55 100644
--- a/sc/source/ui/condformat/condformatdlg.cxx
+++ b/sc/source/ui/condformat/condformatdlg.cxx
@@ -144,7 +144,10 @@ void ScCondFormatList::init(ScDocument* pDoc, ScCondFormatDlg* pDialogParent,
     Thaw();
     RecalcAll();
     if (!maEntries.empty())
+    {
         (*maEntries.begin())->SetActive();
+        mpDialogParent->OnSelectionChange(0, maEntries.size());
+    }
 
     RecalcAll();
 }
@@ -392,6 +395,7 @@ IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl, Button*, void )
     }
     mpDialogParent->InvalidateRefData();
     pNewEntry->SetActive();
+    mpDialogParent->OnSelectionChange(maEntries.size() - 1, maEntries.size());
     Thaw();
     RecalcAll();
 }
@@ -410,6 +414,51 @@ IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl, Button*, void )
         }
     }
     mpDialogParent->InvalidateRefData();
+    mpDialogParent->OnSelectionChange(0, maEntries.size(), false);
+    Thaw();
+    RecalcAll();
+}
+
+IMPL_LINK_NOARG(ScCondFormatList, UpBtnHdl, Button*, void)
+{
+    Freeze();
+    size_t index = 0;
+    for (size_t i = 0; i < maEntries.size(); i++)
+    {
+        auto widget = maEntries[i];
+        if (widget->IsSelected() && i > 0)
+        {
+            std::swap(maEntries[i], maEntries[i - 1]);
+            index = i - 1;
+            break;
+        }
+    }
+    mpDialogParent->InvalidateRefData();
+    mpDialogParent->OnSelectionChange(index, maEntries.size());
+    Thaw();
+    RecalcAll();
+}
+
+IMPL_LINK_NOARG(ScCondFormatList, DownBtnHdl, Button*, void)
+{
+    Freeze();
+    size_t index = 0;
+    for (size_t i = 0; i < maEntries.size(); i++)
+    {
+        auto widget = maEntries[i];
+        if (widget->IsSelected())
+        {
+            index = i;
+            if (i < maEntries.size()-1)
+            {
+                std::swap(maEntries[i], maEntries[i + 1]);
+                index = i + 1;
+                break;
+            }
+        }
+    }
+    mpDialogParent->InvalidateRefData();
+    mpDialogParent->OnSelectionChange(index, maEntries.size());
     Thaw();
     RecalcAll();
 }
@@ -423,11 +472,17 @@ IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry&, rEntry, void )
     //A child has focus, but we will hide that, so regrab to whatever new thing gets
     //shown instead of leaving it stuck in the inaccessible hidden element
     bool bReGrabFocus = HasChildPathFocus();
-    for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
+    size_t index = 0;
+    for(size_t i = 0; i < maEntries.size(); i++)
     {
-        (*itr)->SetInactive();
+        if (maEntries[i] == &rEntry)
+        {
+            index = i;
+        }
+        maEntries[i]->SetInactive();
     }
     mpDialogParent->InvalidateRefData();
+    mpDialogParent->OnSelectionChange(index, maEntries.size());
     rEntry.SetActive();
     Thaw();
     RecalcAll();
@@ -451,6 +506,8 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW,
 {
     get(mpBtnOk, "ok");
     get(mpBtnAdd, "add");
+    get(mpBtnUp, "up");
+    get(mpBtnDown, "down");
     get(mpBtnRemove, "delete");
     get(mpBtnCancel, "cancel");
 
@@ -498,6 +555,8 @@ ScCondFormatDlg::ScCondFormatDlg(SfxBindings* pB, SfxChildWindow* pCW,
     mpBtnOk->SetClickHdl(LINK(this, ScCondFormatDlg, BtnPressedHdl ) );
     mpBtnAdd->SetClickHdl( LINK( mpCondFormList, ScCondFormatList, AddBtnHdl ) );
     mpBtnRemove->SetClickHdl( LINK( mpCondFormList, ScCondFormatList, RemoveBtnHdl ) );
+    mpBtnUp->SetClickHdl(LINK(mpCondFormList, ScCondFormatList, UpBtnHdl));
+    mpBtnDown->SetClickHdl(LINK(mpCondFormList, ScCondFormatList, DownBtnHdl));
     mpBtnCancel->SetClickHdl( LINK(this, ScCondFormatDlg, BtnPressedHdl ) );
     mpEdRange->SetModifyHdl( LINK( this, ScCondFormatDlg, EdRangeModifyHdl ) );
     mpEdRange->SetGetFocusHdl( LINK( this, ScCondFormatDlg, RangeGetFocusHdl ) );
@@ -528,6 +587,8 @@ void ScCondFormatDlg::dispose()
     mpBtnOk.clear();
     mpBtnAdd.clear();
     mpBtnRemove.clear();
+    mpBtnUp.clear();
+    mpBtnDown.clear();
     mpBtnCancel.clear();
     mpFtRange.clear();
     mpEdRange.clear();
@@ -690,6 +751,20 @@ void ScCondFormatDlg::CancelPressed()
     Close();
 }
 
+void ScCondFormatDlg::OnSelectionChange(size_t nIndex, size_t nSize, bool bSelected)
+{
+    if (nSize <= 1 || !bSelected)
+    {
+        mpBtnUp->Enable(false);
+        mpBtnDown->Enable(false);
+    }
+    else
+    {
+        mpBtnUp->Enable(nIndex != 0);
+        mpBtnDown->Enable(nIndex < nSize - 1);
+    }
+}
+
 IMPL_LINK( ScCondFormatDlg, EdRangeModifyHdl, Edit&, rEdit, void )
 {
     OUString aRangeStr = rEdit.GetText();
diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx
index 40ca3db13522..021e21908185 100644
--- a/sc/source/ui/inc/condformatdlg.hxx
+++ b/sc/source/ui/inc/condformatdlg.hxx
@@ -77,6 +77,8 @@ public:
 
     DECL_LINK( AddBtnHdl, Button*, void );
     DECL_LINK( RemoveBtnHdl, Button*, void );
+    DECL_LINK( UpBtnHdl, Button*, void );
+    DECL_LINK( DownBtnHdl, Button*, void );
     DECL_LINK( ScrollHdl, ScrollBar*, void );
     DECL_LINK( EntrySelectHdl, ScCondFrmtEntry&, void );
 
@@ -91,6 +93,8 @@ private:
     VclPtr<PushButton> mpBtnOk;
     VclPtr<PushButton> mpBtnAdd;
     VclPtr<PushButton> mpBtnRemove;
+    VclPtr<PushButton> mpBtnUp;
+    VclPtr<PushButton> mpBtnDown;
     VclPtr<PushButton> mpBtnCancel;
     VclPtr<FixedText> mpFtRange;
     VclPtr<formula::RefEdit> mpEdRange;
@@ -131,6 +135,7 @@ public:
     virtual bool Close() override;
 
     void InvalidateRefData();
+    void OnSelectionChange(size_t nIndex, size_t nSize, bool bSelected = true);
 
     DECL_LINK( BtnPressedHdl, Button*, void );
     DECL_LINK( RangeGetFocusHdl, Control&, void );
diff --git a/sc/uiconfig/scalc/ui/conditionalformatdialog.ui b/sc/uiconfig/scalc/ui/conditionalformatdialog.ui
index 8b93610886d1..c7797cb0542c 100644
--- a/sc/uiconfig/scalc/ui/conditionalformatdialog.ui
+++ b/sc/uiconfig/scalc/ui/conditionalformatdialog.ui
@@ -1,8 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
 <interface>
-  <requires lib="gtk+" version="3.0"/>
-  <requires lib="LibreOffice" version="1.0"/>
+  <!-- interface-requires gtk+ 3.0 -->
+  <!-- interface-requires LibreOffice 1.0 -->
   <object class="GtkDialog" id="ConditionalFormatDialog">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
@@ -83,6 +82,34 @@
                             <property name="position">1</property>
                           </packing>
                         </child>
+                        <child>
+                          <object class="GtkButton" id="up">
+                            <property name="label">gtk-go-up</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="down">
+                            <property name="label">gtk-go-down</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
                       </object>
                       <packing>
                         <property name="expand">False</property>
@@ -256,6 +283,7 @@
     <action-widgets>
       <action-widget response="0">ok</action-widget>
       <action-widget response="0">cancel</action-widget>
+      <action-widget response="0">help</action-widget>
     </action-widgets>
   </object>
 </interface>


More information about the Libreoffice-commits mailing list