summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPalenik Mihály <palenik.mihaly@gmail.com>2014-10-22 19:01:05 +0200
committerAndras Timar <andras.timar@collabora.com>2014-10-30 13:03:44 +0000
commitf92ab4da51647a4353038b1c56b70db3672c49cf (patch)
treede37e84439aef3b3cbd08e875a58a0f36dea0697
parent226285b7ccc0c6880ae1005c9f0d9f47aa41fc29 (diff)
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@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--cui/source/options/optaboutconfig.cxx14
-rw-r--r--cui/source/options/optjava.cxx1
-rw-r--r--include/svtools/simptabl.hxx3
-rw-r--r--include/svtools/treelist.hxx6
-rw-r--r--svtools/source/contnr/simptabl.cxx35
-rw-r--r--svtools/source/contnr/treelist.cxx32
6 files changed, 64 insertions, 27 deletions
diff --git a/cui/source/options/optaboutconfig.cxx b/cui/source/options/optaboutconfig.cxx
index d66a3691c978..87321458fff1 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 cf3b2b5bcd8a..10ee78191e37 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 5ade4fbbbe6a..821a1d73753f 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 cf208727deb4..ae0159510d8f 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 f5755bdc7875..2422bba2efb8 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 27eebd488529..60a8d27855c8 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 )
{