[PATCH] fdo#51828 - UI: Sort: can use more than 3 criteria once only...

2013-05-03 Thread Albert Thuswaldner (via Code Review)
Hi,

I have submitted a patch for review:

https://gerrit.libreoffice.org/3772

To pull it, you can do:

git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/72/3772/1

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

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



diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 6731e71..69551f0 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -178,13 +178,13 @@
 nSortKeyCount = aSortData.maKeyState.size();
 FillFieldLists(0);
 
+
 for ( sal_uInt16 i=0; inSortKeyCount; i++ )
 {
 if (aSortData.maKeyState[i].bDoSort )
 {
 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 +234,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 +447,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 +474,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 @@
 voidInit();
 voidFillFieldLists  ( sal_uInt16 nStartField );
 sal_uInt16  GetFieldSelPos  ( SCCOLROW nField );
+voidSetLastSortKey( sal_uInt16 nItem );
 
 // Handler 
 DECL_LINK( SelectHdl, ListBox * );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I569766945d96eae74479e310d674c9420e9a2b4b
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Albert Thuswaldner albert.thuswald...@gmail.com

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice


[PATCH] fdo#51828 - UI: Sort: can use more than 3 criteria once only

2013-04-06 Thread Albert Thuswaldner (via Code Review)
Hi,

I have submitted a patch for review:

https://gerrit.libreoffice.org/3217

To pull it, you can do:

git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/17/3217/1

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

Change-Id: I7480e8d606e1eafde45635e36dfafa4232f529cb
---
M sc/source/ui/dbgui/tpsort.cxx
1 file changed, 12 insertions(+), 2 deletions(-)



diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index cb69736..75d0113 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -168,9 +168,20 @@
 // ListBox selection:
 if ( aSortData.maKeyState[0].bDoSort )
 {
+// Make sure that the all sort keys are reset
+for ( sal_uInt16 i=nSortKeyCount; iaSortData.maKeyState.size(); i++ )
+{
+maSortKeyCtrl.AddSortKey(i+1);
+maSortKeyItems[i].m_pLbSort-SetSelectHdl( LINK( this,
+ ScTabPageSortFields, SelectHdl ) );
+}
+nSortKeyCount = aSortData.maKeyState.size();
+FillFieldLists(0);
+
+
 for ( sal_uInt16 i=0; inSortKeyCount; i++ )
 {
-if ( i  aSortData.maKeyState.size()  
aSortData.maKeyState[i].bDoSort )
+if (aSortData.maKeyState[i].bDoSort )
 {
 maSortKeyItems[i].m_pLbSort-SelectEntryPos( GetFieldSelPos(
 aSortData.maKeyState[i].nField ) );
@@ -193,7 +204,6 @@
 maSortKeyItems[i].DisableField();
 else
 maSortKeyItems[i].EnableField();
-
 }
 else
 {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7480e8d606e1eafde45635e36dfafa4232f529cb
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: master
Gerrit-Owner: Albert Thuswaldner albert.thuswald...@gmail.com

___
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice