Revert "Calc Sort: Introducing new method AddKeyItem to avoid code duplication"

This reverts commit 42726853bb.

In tpsort.cxx this is used in another way than the other two cases:

++nSortKeyCount;
maSortKeyCtrl.AddSortKey( nSortKeyCount );
maSortKeyItems[nSortKeyIndex].m_pLbSort->SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );

So both are using the same index. In contrast the other two cases use (i+1)
and (i). So this can't be handled with one method or needs some more work...
This commit is contained in:
Thomas Arnhold
2013-04-15 22:41:17 +02:00
parent 935ccf0fb5
commit 0d3a130511
4 changed files with 17 additions and 20 deletions

View File

@@ -156,12 +156,11 @@ IMPL_LINK( ScSortKeyCtrl, ScrollHdl, ScrollBar*, pScrollBar )
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void ScSortKeyCtrl::AddSortKey( sal_uInt16 nItemIndex ) void ScSortKeyCtrl::AddSortKey( sal_uInt16 nItem )
{ {
++nItemIndex; m_rVertScroll.SetRangeMax( nItem );
m_rVertScroll.SetRangeMax( nItemIndex ); m_rVertScroll.DoScroll( nItem );
m_rVertScroll.DoScroll( nItemIndex ); m_aSortWin.AddSortKey( nItem );
m_aSortWin.AddSortKey( nItemIndex );
checkAutoVScroll(); checkAutoVScroll();
} }

View File

@@ -141,7 +141,10 @@ void ScTabPageSortFields::Init()
// Create three sort key dialogs by default // Create three sort key dialogs by default
for ( sal_uInt16 i=0; i<nSortKeyCount; i++ ) for ( sal_uInt16 i=0; i<nSortKeyCount; i++ )
AddSortKeyItem(i); {
maSortKeyCtrl.AddSortKey(i+1);
maSortKeyItems[i].m_pLbSort->SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@@ -167,8 +170,11 @@ void ScTabPageSortFields::Reset( const SfxItemSet& /* rArgSet */ )
{ {
// Make sure that the all sort keys are reset // Make sure that the all sort keys are reset
for ( sal_uInt16 i=nSortKeyCount; i<aSortData.maKeyState.size(); i++ ) for ( sal_uInt16 i=nSortKeyCount; i<aSortData.maKeyState.size(); i++ )
AddSortKeyItem(i); {
maSortKeyCtrl.AddSortKey(i+1);
maSortKeyItems[i].m_pLbSort->SetSelectHdl( LINK( this,
ScTabPageSortFields, SelectHdl ) );
}
nSortKeyCount = aSortData.maKeyState.size(); nSortKeyCount = aSortData.maKeyState.size();
FillFieldLists(0); FillFieldLists(0);
@@ -437,15 +443,6 @@ sal_uInt16 ScTabPageSortFields::GetFieldSelPos( SCCOLROW nField )
return nFieldPos; return nFieldPos;
} }
//------------------------------------------------------------------------
void ScTabPageSortFields::AddSortKeyItem( sal_uInt16 nItemIndex )
{
maSortKeyCtrl.AddSortKey( nItemIndex );
maSortKeyItems[nItemIndex].m_pLbSort->SetSelectHdl(
LINK( this, ScTabPageSortFields, SelectHdl ) );
}
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Handler: // Handler:
//--------- //---------
@@ -466,7 +463,9 @@ IMPL_LINK( ScTabPageSortFields, SelectHdl, ListBox *, pLb )
// Add Sort Key Item // Add Sort Key Item
++nSortKeyCount; ++nSortKeyCount;
AddSortKeyItem( nSortKeyIndex ); maSortKeyCtrl.AddSortKey( nSortKeyCount );
maSortKeyItems[nSortKeyIndex].m_pLbSort->SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
FillFieldLists( nSortKeyIndex ); FillFieldLists( nSortKeyIndex );
// Set Status // Set Status

View File

@@ -99,7 +99,7 @@ private:
public: public:
ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& mrSortKeyItems); ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& mrSortKeyItems);
void setScrollRange(); void setScrollRange();
void AddSortKey( sal_uInt16 nItemIndex ); void AddSortKey( sal_uInt16 nItem );
}; };
#endif // SC_SORTKEYDLG_HXX #endif // SC_SORTKEYDLG_HXX

View File

@@ -95,7 +95,6 @@ private:
void Init (); void Init ();
void FillFieldLists ( sal_uInt16 nStartField ); void FillFieldLists ( sal_uInt16 nStartField );
sal_uInt16 GetFieldSelPos ( SCCOLROW nField ); sal_uInt16 GetFieldSelPos ( SCCOLROW nField );
void AddSortKeyItem( sal_uInt16 nItemIndex );
// Handler ------------------------ // Handler ------------------------
DECL_LINK( SelectHdl, ListBox * ); DECL_LINK( SelectHdl, ListBox * );