Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3801

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/01/3801/1

fdo#51828 - UI: Sort: can use more than 3 criteria once only - additional fix

Change-Id: I220b3755d3ea30bd9aa25b175f7f3eea7590ebdb
---
M sc/source/ui/dbgui/tpsort.cxx
M sc/source/ui/inc/tpsort.hxx
2 files changed, 25 insertions(+), 16 deletions(-)



diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 6731e71..fd62073 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -184,7 +184,6 @@
             {
                 maSortKeyItems[i].m_pLbSort->SelectEntryPos( GetFieldSelPos(
                                     aSortData.maKeyState[i].nField ) );
-
                 (aSortData.maKeyState[i].bAscending)
                     ? maSortKeyItems[i].m_pBtnUp->Check()
                     : maSortKeyItems[i].m_pBtnDown->Check();
@@ -234,6 +233,10 @@
         pDlg->SetByRows ( bSortByRows );
         pDlg->SetHeaders( bHasHeader );
     }
+
+    // Make sure that there is always a last undefined sort key
+    if ( maSortKeyItems[nSortKeyCount - 1].m_pLbSort->GetSelectEntryPos() > 0 )
+        SetLastSortKey( nSortKeyCount );
 }
 
 // -----------------------------------------------------------------------
@@ -443,6 +446,25 @@
     return nFieldPos;
 }
 
+void ScTabPageSortFields::SetLastSortKey( sal_uInt16 nItem )
+{
+    // Extend local SortParam copy
+    const ScSortKeyState atempKeyState = { false, 0, true };
+    aSortData.maKeyState.push_back( atempKeyState );
+
+    // Add Sort Key Item
+    ++nSortKeyCount;
+    maSortKeyCtrl.AddSortKey( nSortKeyCount );
+    maSortKeyItems[nItem].m_pLbSort->SetSelectHdl(
+                     LINK( this, ScTabPageSortFields, SelectHdl ) );
+
+    FillFieldLists( nItem );
+
+    // Set Status
+    maSortKeyItems[nItem].m_pBtnUp->Check();
+    maSortKeyItems[nItem].m_pLbSort->SelectEntryPos( 0 );
+}
+
 // -----------------------------------------------------------------------
 // Handler:
 //---------
@@ -451,26 +473,12 @@
 {
     OUString aSelEntry = pLb->GetSelectEntry();
     ScSortKeyItems::iterator pIter;
-    sal_uInt16 nSortKeyIndex = nSortKeyCount;
 
     // If last listbox is enabled add one item
     if ( maSortKeyItems.back().m_pLbSort == pLb )
         if ( aSelEntry != aStrUndefined )
         {
-            // Extend local SortParam copy
-            const ScSortKeyState atempKeyState = { false, 0, true };
-            aSortData.maKeyState.push_back( atempKeyState );
-
-            // Add Sort Key Item
-            ++nSortKeyCount;
-            maSortKeyCtrl.AddSortKey( nSortKeyCount );
-            maSortKeyItems[nSortKeyIndex].m_pLbSort->SetSelectHdl( LINK( this, 
ScTabPageSortFields, SelectHdl ) );
-
-            FillFieldLists( nSortKeyIndex );
-
-            // Set Status
-            maSortKeyItems[nSortKeyIndex].m_pBtnUp->Check();
-            maSortKeyItems[nSortKeyIndex].m_pLbSort->SelectEntryPos( 0 );
+            SetLastSortKey( nSortKeyCount );
             return 0;
         }
 
diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx
index 8ce4a42..b230581 100644
--- a/sc/source/ui/inc/tpsort.hxx
+++ b/sc/source/ui/inc/tpsort.hxx
@@ -95,6 +95,7 @@
     void    Init            ();
     void    FillFieldLists  ( sal_uInt16 nStartField );
     sal_uInt16  GetFieldSelPos  ( SCCOLROW nField );
+    void    SetLastSortKey( sal_uInt16 nItem );
 
     // Handler ------------------------
     DECL_LINK( SelectHdl, ListBox * );

-- 
To view, visit https://gerrit.libreoffice.org/3801
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I220b3755d3ea30bd9aa25b175f7f3eea7590ebdb
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Albert Thuswaldner <albert.thuswaldner@gmail.com>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.