Kaydet (Commit) 42726853 authored tarafından Albert Thuswaldner's avatar Albert Thuswaldner Kaydeden (comit) Caolán McNamara

Calc Sort: Introducing new method AddKeyItem to avoid code duplication

Change-Id: Ic34b5958472a7d2c19ff686914309b6699e237c4
Reviewed-on: https://gerrit.libreoffice.org/3370Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 4f4ab917
......@@ -156,11 +156,12 @@ IMPL_LINK( ScSortKeyCtrl, ScrollHdl, ScrollBar*, pScrollBar )
// -----------------------------------------------------------------------
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();
}
......
......@@ -141,10 +141,7 @@ void ScTabPageSortFields::Init()
// 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 @@ void ScTabPageSortFields::Reset( const SfxItemSet& /* rArgSet */ )
{
// 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 @@ sal_uInt16 ScTabPageSortFields::GetFieldSelPos( SCCOLROW nField )
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 @@ IMPL_LINK( ScTabPageSortFields, SelectHdl, ListBox *, pLb )
// Add Sort Key Item
++nSortKeyCount;
maSortKeyCtrl.AddSortKey( nSortKeyCount );
maSortKeyItems[nSortKeyIndex].m_pLbSort->SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
AddSortKeyItem( nSortKeyIndex );
FillFieldLists( nSortKeyIndex );
// Set Status
......
......@@ -99,7 +99,7 @@ private:
public:
ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& mrSortKeyItems);
void setScrollRange();
void AddSortKey( sal_uInt16 nItem );
void AddSortKey( sal_uInt16 nItemIndex );
};
#endif // SC_SORTKEYDLG_HXX
......
......@@ -95,6 +95,7 @@ private:
void Init ();
void FillFieldLists ( sal_uInt16 nStartField );
sal_uInt16 GetFieldSelPos ( SCCOLROW nField );
void AddSortKeyItem( sal_uInt16 nItemIndex );
// Handler ------------------------
DECL_LINK( SelectHdl, ListBox * );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment