summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorAlbert Thuswaldner <albert.thuswaldner@gmail.com>2013-05-04 01:39:24 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-05-07 07:12:19 +0000
commit104edfdc77147b49f32df55e8b48a3aef4542c87 (patch)
treea536a627612f1b892f0702773dd52f3369e6cc0d /sc/source/ui
parentea2603200b46f460f34c930770d69db74a164bde (diff)
fdo#51828 - UI: Sort: can use more than 3 criteria once only - additional fix
Change-Id: I220b3755d3ea30bd9aa25b175f7f3eea7590ebdb Reviewed-on: https://gerrit.libreoffice.org/3801 Reviewed-by: Miklos Vajna <vmiklos@suse.cz> Tested-by: Miklos Vajna <vmiklos@suse.cz>
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/dbgui/tpsort.cxx40
-rw-r--r--sc/source/ui/inc/tpsort.hxx1
2 files changed, 25 insertions, 16 deletions
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index 4ee9d1109307..034afec316ad 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -184,7 +184,6 @@ void ScTabPageSortFields::Reset( const SfxItemSet& /* rArgSet */ )
{
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 @@ void ScTabPageSortFields::Reset( const SfxItemSet& /* rArgSet */ )
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 @@ sal_uInt16 ScTabPageSortFields::GetFieldSelPos( SCCOLROW nField )
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 @@ IMPL_LINK( ScTabPageSortFields, SelectHdl, ListBox *, pLb )
{
rtl::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 8ce4a4278a89..b23058136ba6 100644
--- a/sc/source/ui/inc/tpsort.hxx
+++ b/sc/source/ui/inc/tpsort.hxx
@@ -95,6 +95,7 @@ private:
void Init ();
void FillFieldLists ( sal_uInt16 nStartField );
sal_uInt16 GetFieldSelPos ( SCCOLROW nField );
+ void SetLastSortKey( sal_uInt16 nItem );
// Handler ------------------------
DECL_LINK( SelectHdl, ListBox * );