[Libreoffice-commits] core.git: sc/source

Thomas Arnhold thomas at arnhold.org
Mon Apr 15 13:45:52 PDT 2013


 sc/source/ui/dbgui/sortkeydlg.cxx |    9 ++++-----
 sc/source/ui/dbgui/tpsort.cxx     |   25 ++++++++++++-------------
 sc/source/ui/inc/sortkeydlg.hxx   |    2 +-
 sc/source/ui/inc/tpsort.hxx       |    1 -
 4 files changed, 17 insertions(+), 20 deletions(-)

New commits:
commit 0d3a130511fcd28d3d24d5b56275de73d8fbfc1a
Author: Thomas Arnhold <thomas at arnhold.org>
Date:   Mon Apr 15 22:41:17 2013 +0200

    Revert "Calc Sort: Introducing new method AddKeyItem to avoid code duplication"
    
    This reverts commit 42726853bb90eab11bf4fde8b0358ca3c3354529.
    
    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...

diff --git a/sc/source/ui/dbgui/sortkeydlg.cxx b/sc/source/ui/dbgui/sortkeydlg.cxx
index 3e09076..006dad5 100644
--- a/sc/source/ui/dbgui/sortkeydlg.cxx
+++ b/sc/source/ui/dbgui/sortkeydlg.cxx
@@ -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( nItemIndex );
-    m_rVertScroll.DoScroll( nItemIndex );
-    m_aSortWin.AddSortKey( nItemIndex );
+    m_rVertScroll.SetRangeMax( nItem );
+    m_rVertScroll.DoScroll( nItem );
+    m_aSortWin.AddSortKey( nItem );
     checkAutoVScroll();
 }
 
diff --git a/sc/source/ui/dbgui/tpsort.cxx b/sc/source/ui/dbgui/tpsort.cxx
index f153cf7..6731e71 100644
--- a/sc/source/ui/dbgui/tpsort.cxx
+++ b/sc/source/ui/dbgui/tpsort.cxx
@@ -141,7 +141,10 @@ void ScTabPageSortFields::Init()
 
     // Create three sort key dialogs by default
     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
         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();
         FillFieldLists(0);
 
@@ -437,15 +443,6 @@ 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:
 //---------
@@ -466,7 +463,9 @@ IMPL_LINK( ScTabPageSortFields, SelectHdl, ListBox *, pLb )
 
             // Add Sort Key Item
             ++nSortKeyCount;
-            AddSortKeyItem( nSortKeyIndex );
+            maSortKeyCtrl.AddSortKey( nSortKeyCount );
+            maSortKeyItems[nSortKeyIndex].m_pLbSort->SetSelectHdl( LINK( this, ScTabPageSortFields, SelectHdl ) );
+
             FillFieldLists( nSortKeyIndex );
 
             // Set Status
diff --git a/sc/source/ui/inc/sortkeydlg.hxx b/sc/source/ui/inc/sortkeydlg.hxx
index 7718663..060e8ad 100644
--- a/sc/source/ui/inc/sortkeydlg.hxx
+++ b/sc/source/ui/inc/sortkeydlg.hxx
@@ -99,7 +99,7 @@ private:
 public:
     ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& mrSortKeyItems);
     void setScrollRange();
-    void AddSortKey( sal_uInt16 nItemIndex );
+    void AddSortKey( sal_uInt16 nItem );
 };
 
 #endif // SC_SORTKEYDLG_HXX
diff --git a/sc/source/ui/inc/tpsort.hxx b/sc/source/ui/inc/tpsort.hxx
index e4d82c6..8ce4a42 100644
--- a/sc/source/ui/inc/tpsort.hxx
+++ b/sc/source/ui/inc/tpsort.hxx
@@ -95,7 +95,6 @@ private:
     void    Init            ();
     void    FillFieldLists  ( sal_uInt16 nStartField );
     sal_uInt16  GetFieldSelPos  ( SCCOLROW nField );
-    void    AddSortKeyItem( sal_uInt16 nItemIndex );
 
     // Handler ------------------------
     DECL_LINK( SelectHdl, ListBox * );


More information about the Libreoffice-commits mailing list