Hi, I have submitted a patch for review:
https://gerrit.libreoffice.org/3370 To pull it, you can do: git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/70/3370/1 Calc Sort: Introducing new method AddKeyItem to avoid code duplication Change-Id: Ic34b5958472a7d2c19ff686914309b6699e237c4 --- M sc/source/ui/dbgui/sortkeydlg.cxx M sc/source/ui/dbgui/tpsort.cxx M sc/source/ui/inc/sortkeydlg.hxx M sc/source/ui/inc/tpsort.hxx 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/sc/source/ui/dbgui/sortkeydlg.cxx b/sc/source/ui/dbgui/sortkeydlg.cxx index 006dad5..3e09076 100644 --- a/sc/source/ui/dbgui/sortkeydlg.cxx +++ b/sc/source/ui/dbgui/sortkeydlg.cxx @@ -156,11 +156,12 @@ // ----------------------------------------------------------------------- -void ScSortKeyCtrl::AddSortKey( sal_uInt16 nItem ) +void ScSortKeyCtrl::AddSortKey( sal_uInt16 nItemIndex ) { - m_rVertScroll.SetRangeMax( nItem ); - m_rVertScroll.DoScroll( nItem ); - m_aSortWin.AddSortKey( nItem ); + ++nItemIndex; + m_rVertScroll.SetRangeMax( nItemIndex ); + m_rVertScroll.DoScroll( nItemIndex ); + m_aSortWin.AddSortKey( nItemIndex ); checkAutoVScroll(); } diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx index 6731e71..f153cf7 100644 --- a/sc/source/ui/dbgui/tpsort.cxx +++ b/sc/source/ui/dbgui/tpsort.cxx @@ -141,10 +141,7 @@ // Create three sort key dialogs by default for ( sal_uInt16 i=0; i<nSortKeyCount; i++ ) - { - maSortKeyCtrl.AddSortKey(i+1); - maSortKeyItems[i].m_pLbSort->SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) ); - } + AddSortKeyItem(i); } // ----------------------------------------------------------------------- @@ -170,11 +167,8 @@ { // Make sure that the all sort keys are reset for ( sal_uInt16 i=nSortKeyCount; i<aSortData.maKeyState.size(); i++ ) - { - maSortKeyCtrl.AddSortKey(i+1); - maSortKeyItems[i].m_pLbSort->SetSelectHdl( LINK( this, - ScTabPageSortFields, SelectHdl ) ); - } + AddSortKeyItem(i); + nSortKeyCount = aSortData.maKeyState.size(); FillFieldLists(0); @@ -443,6 +437,15 @@ return nFieldPos; } +//------------------------------------------------------------------------ + +void ScTabPageSortFields::AddSortKeyItem( sal_uInt16 nItemIndex ) +{ + maSortKeyCtrl.AddSortKey( nItemIndex ); + maSortKeyItems[nItemIndex].m_pLbSort->SetSelectHdl( + LINK( this, ScTabPageSortFields, SelectHdl ) ); +} + // ----------------------------------------------------------------------- // Handler: //--------- @@ -463,9 +466,7 @@ // Add Sort Key Item ++nSortKeyCount; - maSortKeyCtrl.AddSortKey( nSortKeyCount ); - maSortKeyItems[nSortKeyIndex].m_pLbSort->SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) ); - + AddSortKeyItem( nSortKeyIndex ); FillFieldLists( nSortKeyIndex ); // Set Status diff --git a/sc/source/ui/inc/sortkeydlg.hxx b/sc/source/ui/inc/sortkeydlg.hxx index 060e8ad..7718663 100644 --- a/sc/source/ui/inc/sortkeydlg.hxx +++ b/sc/source/ui/inc/sortkeydlg.hxx @@ -99,7 +99,7 @@ public: ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& mrSortKeyItems); void setScrollRange(); - void AddSortKey( sal_uInt16 nItem ); + void AddSortKey( sal_uInt16 nItemIndex ); }; #endif // SC_SORTKEYDLG_HXX diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx index 8ce4a42..e4d82c6 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 AddSortKeyItem( sal_uInt16 nItemIndex ); // Handler ------------------------ DECL_LINK( SelectHdl, ListBox * ); -- To view, visit https://gerrit.libreoffice.org/3370 To unsubscribe, visit https://gerrit.libreoffice.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic34b5958472a7d2c19ff686914309b6699e237c4 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