[Libreoffice-commits] core.git: cui/source include/svtools svtools/source

Palenik Mihály palenik.mihaly at gmail.com
Thu Oct 30 06:04:09 PDT 2014


 cui/source/options/optaboutconfig.cxx |   14 +++----------
 cui/source/options/optjava.cxx        |    1 
 include/svtools/simptabl.hxx          |    3 ++
 include/svtools/treelist.hxx          |    6 ++++-
 svtools/source/contnr/simptabl.cxx    |   35 ++++++++++++++++++----------------
 svtools/source/contnr/treelist.cxx    |   32 +++++++++++++++++++++++++++++++
 6 files changed, 64 insertions(+), 27 deletions(-)

New commits:
commit f92ab4da51647a4353038b1c56b70db3672c49cf
Author: Palenik Mihály <palenik.mihaly at gmail.com>
Date:   Wed Oct 22 19:01:05 2014 +0200

    Improve SvSimpleTable class
    
    It is possible to order columns. This is set in Expert Configuration
    dialog. The header's itembits weren't set correctly therefore mouse
    click handler didn't do anything. The comparsion was slow on big
    table.
    
    Conflicts:
    	include/svtools/treelist.hxx
    	svtools/source/contnr/simptabl.cxx
    
    Change-Id: I7e1301d40433ef45b3d0a3fb300909345ede9d4d
    Reviewed-on: https://gerrit.libreoffice.org/12070
    Reviewed-by: Andras Timar <andras.timar at collabora.com>
    Tested-by: Andras Timar <andras.timar at collabora.com>

diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index d66a369..8732145 100644
--- a/cui/source/options/optaboutconfig.cxx
+++ b/cui/source/options/optaboutconfig.cxx
@@ -38,11 +38,6 @@ using namespace com::sun::star::container;
 #define LONG_LEN_LIMIT      11
 #define HYPER_LEN_LIMIT     20
 
-#define ITEMID_PREFNAME     1
-#define ITEMID_PROPERTY     2
-#define ITEMID_TYPE         3
-#define ITEMID_VALUE        4
-
 struct Prop_Impl
 {
     OUString    Name;
@@ -141,11 +136,10 @@ CuiAboutConfigTabPage::CuiAboutConfigTabPage( vcl::Window* pParent/*, const SfxI
     m_pResetBtn->SetClickHdl( LINK( this, CuiAboutConfigTabPage, ResetBtnHdl_Impl ) );
     m_pPrefBox->SetDoubleClickHdl( LINK(this, CuiAboutConfigTabPage, StandardHdl_Impl) );
 
-    HeaderBar &rBar = m_pPrefBox->GetTheHeaderBar();
-    rBar.InsertItem( ITEMID_PREFNAME, get<FixedText>("preference")->GetText(), 0, HIB_LEFT | HIB_VCENTER );
-    rBar.InsertItem( ITEMID_PROPERTY, get<FixedText>("property")->GetText(), 0,  HIB_LEFT | HIB_VCENTER );
-    rBar.InsertItem( ITEMID_TYPE, get<FixedText>("type")->GetText(), 0,  HIB_LEFT | HIB_VCENTER );
-    rBar.InsertItem( ITEMID_VALUE, get<FixedText>("value")->GetText(), 0,  HIB_LEFT | HIB_VCENTER );
+    m_pPrefBox->InsertHeaderEntry(get<FixedText>("preference")->GetText());
+    m_pPrefBox->InsertHeaderEntry(get<FixedText>("property")->GetText());
+    m_pPrefBox->InsertHeaderEntry(get<FixedText>("type")->GetText());
+    m_pPrefBox->InsertHeaderEntry(get<FixedText>("value")->GetText());
 
     long aTabs[] = {4,0,0,0,0};
 
diff --git a/cui/source/options/optjava.cxx b/cui/source/options/optjava.cxx
index cf3b2b5..10ee781 100644
--- a/cui/source/options/optjava.cxx
+++ b/cui/source/options/optjava.cxx
@@ -430,6 +430,7 @@ IMPL_LINK_NOARG( SvxJavaOptionsPage, ExpertConfigHdl_Impl )
         m_pExpertConfigDlg->FillItemSet();//save changes if there are any
     }
 
+    delete m_pExpertConfigDlg;
     return 0;
 }
 
diff --git a/include/svtools/simptabl.hxx b/include/svtools/simptabl.hxx
index 5ade4fb..821a1d7 100644
--- a/include/svtools/simptabl.hxx
+++ b/include/svtools/simptabl.hxx
@@ -23,6 +23,7 @@
 #include <svtools/svtdllapi.h>
 #include <svtools/headbar.hxx>
 #include <svtools/svtabbx.hxx>
+#include <unotools/intlwrapper.hxx>
 
 class SvSimpleTable;
 class SVT_DLLPUBLIC SvSimpleTableContainer : public Control
@@ -59,6 +60,8 @@ private:
     bool                bSortDirection;
     sal_uInt16          nSortCol;
 
+    const CollatorWrapper aCollator;
+
     DECL_LINK( StartDragHdl, HeaderBar* );
     DECL_LINK( DragHdl, HeaderBar* );
     DECL_LINK( EndDragHdl, HeaderBar* );
diff --git a/include/svtools/treelist.hxx b/include/svtools/treelist.hxx
index cf20872..ae01595 100644
--- a/include/svtools/treelist.hxx
+++ b/include/svtools/treelist.hxx
@@ -44,7 +44,9 @@ enum class SvListAction
     INVALIDATE_ENTRY = 8,
     RESORTING        = 9,
     RESORTED         = 10,
-    CLEARED          = 11
+    CLEARED          = 11,
+    REVERSING        = 12,
+    REVERSED         = 13
 };
 
 class SvTreeListEntry;
@@ -124,6 +126,7 @@ class SVT_DLLPUBLIC SvTreeList
                         );
 
     SVT_DLLPRIVATE void ResortChildren( SvTreeListEntry* pParent );
+    SVT_DLLPRIVATE void ReverseChildren( SvTreeListEntry* pParent );
 
     SvTreeList(const SvTreeList&); // disabled
     SvTreeList& operator= (const SvTreeList&); // disabled
@@ -233,6 +236,7 @@ public:
     void                SetCompareHdl( const Link& rLink ) { aCompareLink = rLink; }
     const Link&         GetCompareHdl() const { return aCompareLink; }
     void                Resort();
+    void                Reverse();
 };
 
 class SVT_DLLPUBLIC SvListView
diff --git a/svtools/source/contnr/simptabl.cxx b/svtools/source/contnr/simptabl.cxx
index f5755bd..2422bba 100644
--- a/svtools/source/contnr/simptabl.cxx
+++ b/svtools/source/contnr/simptabl.cxx
@@ -21,7 +21,6 @@
 #include <svtools/simptabl.hxx>
 #include <svtools/svlbitm.hxx>
 #include <svtools/treelistentry.hxx>
-#include <unotools/intlwrapper.hxx>
 #include <vcl/builder.hxx>
 #include <vcl/svapp.hxx>
 #include <vcl/settings.hxx>
@@ -84,7 +83,8 @@ SvSimpleTable::SvSimpleTable(SvSimpleTableContainer& rParent, WinBits nBits):
         m_rParentTableContainer(rParent),
         aHeaderBar(&rParent,WB_BUTTONSTYLE | WB_BORDER | WB_TABSTOP),
         nHeaderItemId(1),
-        bPaintFlag(true)
+        bPaintFlag(true),
+        aCollator(*(IntlWrapper( Application::GetSettings().GetLanguageTag() ).getCaseCollator()))
 {
     m_rParentTableContainer.SetTable(this);
 
@@ -98,6 +98,8 @@ SvSimpleTable::SvSimpleTable(SvSimpleTableContainer& rParent, WinBits nBits):
     aHeaderBar.SetSelectHdl(LINK( this, SvSimpleTable, HeaderBarClick));
     aHeaderBar.SetDoubleClickHdl(LINK( this, SvSimpleTable, HeaderBarDblClick));
 
+    GetModel()->SetCompareHdl( LINK( this, SvSimpleTable, CompareHdl));
+
     EnableCellFocus();
     DisableTransientChildren();
     InitHeaderBar( &aHeaderBar );
@@ -262,29 +264,38 @@ sal_uInt16 SvSimpleTable::GetSelectedCol()
 
 void SvSimpleTable::SortByCol(sal_uInt16 nCol, bool bDir)
 {
-    bSortDirection=bDir;
     if(nSortCol!=0xFFFF)
         aHeaderBar.SetItemBits(nSortCol+1,HIB_STDSTYLE);
 
     if (nCol != 0xFFFF)
     {
-        if(bDir)
+        if(bDir || nSortCol != nCol)
         {
             aHeaderBar.SetItemBits( nCol+1, HIB_STDSTYLE | HIB_DOWNARROW);
             GetModel()->SetSortMode(SortAscending);
+            bDir = true;
         }
         else
         {
             aHeaderBar.SetItemBits( nCol+1, HIB_STDSTYLE | HIB_UPARROW);
             GetModel()->SetSortMode(SortDescending);
         }
-        nSortCol=nCol;
-        GetModel()->SetCompareHdl( LINK( this, SvSimpleTable, CompareHdl));
-        GetModel()->Resort();
+        if(nSortCol == nCol)
+        {
+            GetModel()->Reverse();
+            Resize();   //update rows
+        }
+        else
+        {
+            nSortCol=nCol;
+            GetModel()->Resort();
+        }
     }
     else
         GetModel()->SetSortMode(SortNone);
     nSortCol=nCol;
+    bSortDirection=bDir;
+    SetAlternatingRowColors( true );
 }
 
 void SvSimpleTable::HBarClick()
@@ -447,16 +458,8 @@ sal_Int32 SvSimpleTable::ColCompare(SvTreeListEntry* pLeft,SvTreeListEntry* pRig
 
         if(nRightKind == SV_ITEM_ID_LBOXSTRING &&
             nLeftKind == SV_ITEM_ID_LBOXSTRING )
-        {
-            IntlWrapper aIntlWrapper( Application::GetSettings().GetLanguageTag() );
-            const CollatorWrapper* pCollator = aIntlWrapper.getCaseCollator();
-
-            nCompare = pCollator->compareString( static_cast<SvLBoxString*>(pLeftItem)->GetText(),
+            nCompare = aCollator.compareString( static_cast<SvLBoxString*>(pLeftItem)->GetText(),
                                     static_cast<SvLBoxString*>(pRightItem)->GetText());
-
-            if (nCompare == 0)
-                nCompare = -1;
-        }
     }
     return nCompare;
 }
diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx
index 27eebd4..60a8d27 100644
--- a/svtools/source/contnr/treelist.cxx
+++ b/svtools/source/contnr/treelist.cxx
@@ -1438,6 +1438,11 @@ void SvListView::ModelNotification( SvListAction nActionId, SvTreeListEntry* pEn
             break;
         case SvListAction::RESORTING:
             break;
+        case SvListAction::REVERSING:
+            break;
+        case SvListAction::REVERSED:
+            bVisPositionsValid = false;
+            break;
         default:
             OSL_FAIL("unknown ActionId");
     }
@@ -1547,6 +1552,33 @@ void SvTreeList::ResortChildren( SvTreeListEntry* pParent )
     SetListPositions(pParent->maChildren); // correct list position in target list
 }
 
+void SvTreeList::Reverse()
+{
+    Broadcast(SvListAction::REVERSING);
+    bAbsPositionsValid = false;
+    ReverseChildren(pRootItem);
+    Broadcast(SvListAction::REVERSED);
+}
+
+void SvTreeList::ReverseChildren( SvTreeListEntry* pParent )
+{
+    DBG_ASSERT(pParent,"Parent not set");
+
+    if (pParent->maChildren.empty())
+        return;
+
+    std::reverse(pParent->maChildren.base().begin(), pParent->maChildren.base().end());
+    // Recursively sort child entries.
+    SvTreeListEntries::iterator it = pParent->maChildren.begin(), itEnd = pParent->maChildren.end();
+    for (; it != itEnd; ++it)
+    {
+        SvTreeListEntry& r = *it;
+        ReverseChildren(&r);
+    }
+
+    SetListPositions(pParent->maChildren); // correct list position in target list
+}
+
 void SvTreeList::GetInsertionPos( SvTreeListEntry* pEntry, SvTreeListEntry* pParent,
     sal_uLong& rPos )
 {


More information about the Libreoffice-commits mailing list