[Libreoffice-commits] .: 13 commits - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Feb 3 21:25:54 PST 2012
sc/inc/chartlis.hxx | 1
sc/inc/chartpos.hxx | 1
sc/inc/chgtrack.hxx | 16
sc/inc/collect.hxx | 32 -
sc/inc/document.hxx | 1
sc/inc/dpcachetable.hxx | 1
sc/inc/dpdimsave.hxx | 4
sc/inc/dpobject.hxx | 5
sc/inc/dpoutput.hxx | 5
sc/inc/dptypes.hxx | 39 ++
sc/inc/olinetab.hxx | 143 ++++----
sc/inc/pivot.hxx | 1
sc/inc/rangenam.hxx | 1
sc/inc/unitconv.hxx | 2
sc/source/core/data/column2.cxx | 1
sc/source/core/data/documen5.cxx | 10
sc/source/core/data/dpdimsave.cxx | 10
sc/source/core/data/dpgroup.cxx | 1
sc/source/core/data/dpobject.cxx | 5
sc/source/core/data/dpoutput.cxx | 9
sc/source/core/data/dpsdbtab.cxx | 1
sc/source/core/data/dpshttab.cxx | 1
sc/source/core/data/dptabsrc.cxx | 1
sc/source/core/data/olinetab.cxx | 612 ++++++++++++++++++++++++-------------
sc/source/core/data/table3.cxx | 28 -
sc/source/core/data/table5.cxx | 1
sc/source/core/data/table6.cxx | 1
sc/source/core/data/validat.cxx | 1
sc/source/core/tool/chgtrack.cxx | 40 +-
sc/source/core/tool/collect.cxx | 27 -
sc/source/filter/excel/xetable.cxx | 8
sc/source/filter/xml/xmlexprt.cxx | 10
sc/source/filter/xml/xmltabi.cxx | 23 -
sc/source/ui/dbgui/pfiltdlg.cxx | 1
sc/source/ui/docshell/docsh.cxx | 7
sc/source/ui/docshell/docsh6.cxx | 85 ++---
sc/source/ui/docshell/docsh8.cxx | 41 +-
sc/source/ui/docshell/olinefun.cxx | 10
sc/source/ui/inc/dbfunc.hxx | 12
sc/source/ui/inc/docsh.hxx | 4
sc/source/ui/inc/filtdlg.hxx | 2
sc/source/ui/miscdlgs/acredlin.cxx | 6
sc/source/ui/undo/undodat.cxx | 2
sc/source/ui/unoobj/dapiuno.cxx | 3
sc/source/ui/unoobj/linkuno.cxx | 116 +++----
sc/source/ui/vba/vbarange.cxx | 2
sc/source/ui/view/cellsh1.cxx | 6
sc/source/ui/view/dbfunc3.cxx | 103 ++----
sc/source/ui/view/olinewin.cxx | 15
49 files changed, 796 insertions(+), 661 deletions(-)
New commits:
commit dc35a3974293cfa01cb5b2563798eeacb29a3f46
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Sat Feb 4 00:18:23 2012 -0500
Fixed incorrect insertion.
diff --git a/sc/inc/olinetab.hxx b/sc/inc/olinetab.hxx
index 6a542f3..c6b95f8 100644
--- a/sc/inc/olinetab.hxx
+++ b/sc/inc/olinetab.hxx
@@ -106,7 +106,7 @@ private:
bool DecDepth();
void FindEntry(
- SCCOLROW nSearchPos, size_t& rFindLevel, ScOutlineCollection::iterator& rFindPos,
+ SCCOLROW nSearchPos, size_t& rFindLevel, size_t& rFindIndex,
size_t nMaxLevel = SC_OL_MAXDEPTH);
void RemoveSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nLevel);
diff --git a/sc/source/core/data/olinetab.cxx b/sc/source/core/data/olinetab.cxx
index 2106925..27b8324 100644
--- a/sc/source/core/data/olinetab.cxx
+++ b/sc/source/core/data/olinetab.cxx
@@ -203,10 +203,10 @@ ScOutlineArray::ScOutlineArray( const ScOutlineArray& rArray ) :
}
void ScOutlineArray::FindEntry(
- SCCOLROW nSearchPos, size_t& rFindLevel, ScOutlineCollection::iterator& rFindPos,
+ SCCOLROW nSearchPos, size_t& rFindLevel, size_t& rFindIndex,
size_t nMaxLevel )
{
- rFindLevel = 0;
+ rFindLevel = rFindIndex = 0;
if (nMaxLevel > nDepth)
nMaxLevel = nDepth;
@@ -215,14 +215,13 @@ void ScOutlineArray::FindEntry(
{
ScOutlineCollection* pCollect = &aCollections[nLevel];
ScOutlineCollection::iterator it = pCollect->begin(), itEnd = pCollect->end();
- rFindPos = itEnd;
for (; it != itEnd; ++it)
{
ScOutlineEntry* pEntry = it->second;
if (pEntry->GetStart() <= nSearchPos && pEntry->GetEnd() >= nSearchPos)
{
rFindLevel = nLevel + 1; // naechster Level (zum Einfuegen)
- rFindPos = it;
+ rFindIndex = std::distance(pCollect->begin(), it);
}
}
}
@@ -233,20 +232,19 @@ bool ScOutlineArray::Insert(
{
rSizeChanged = false;
- size_t nStartLevel, nEndLevel;
- ScOutlineCollection::iterator itStartPos, itEndPos;
+ size_t nStartLevel, nEndLevel, nStartIndex, nEndIndex;
bool bFound = false;
bool bCont;
sal_uInt16 nFindMax;
- FindEntry( nStartCol, nStartLevel, itStartPos ); // nLevel = neuer Level (alter+1) !!!
- FindEntry( nEndCol, nEndLevel, itEndPos );
+ FindEntry( nStartCol, nStartLevel, nStartIndex ); // nLevel = neuer Level (alter+1) !!!
+ FindEntry( nEndCol, nEndLevel, nEndIndex );
nFindMax = Max(nStartLevel,nEndLevel);
do
{
bCont = false;
- if (nStartLevel == nEndLevel && itStartPos == itEndPos && nStartLevel < SC_OL_MAXDEPTH)
+ if (nStartLevel == nEndLevel && nStartIndex == nEndIndex && nStartLevel < SC_OL_MAXDEPTH)
bFound = true;
if (!bFound)
@@ -256,14 +254,18 @@ bool ScOutlineArray::Insert(
--nFindMax;
if (nStartLevel)
{
- if (itStartPos->second->GetStart() == nStartCol)
- FindEntry(nStartCol, nStartLevel, itStartPos, nFindMax);
+ ScOutlineCollection::const_iterator it = aCollections[nStartLevel-1].begin();
+ std::advance(it, nStartIndex);
+ if (it->second->GetStart() == nStartCol)
+ FindEntry(nStartCol, nStartLevel, nStartIndex, nFindMax);
}
if (nEndLevel)
{
- if (itEndPos->second->GetEnd() == nEndCol)
- FindEntry(nEndCol, nEndLevel, itEndPos, nFindMax);
+ ScOutlineCollection::const_iterator it = aCollections[nEndLevel-1].begin();
+ std::advance(it, nEndIndex);
+ if (it->second->GetEnd() == nEndCol)
+ FindEntry(nEndCol, nEndLevel, nEndIndex, nFindMax);
}
bCont = true;
}
commit 42d04ed4e2f50a6d9957eaca61cc2d56023153ef
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 3 23:53:12 2012 -0500
Fixed a crash on the first outline creation.
diff --git a/sc/source/core/data/olinetab.cxx b/sc/source/core/data/olinetab.cxx
index 0dae860..2106925 100644
--- a/sc/source/core/data/olinetab.cxx
+++ b/sc/source/core/data/olinetab.cxx
@@ -279,32 +279,37 @@ bool ScOutlineArray::Insert(
// untere verschieben
bool bNeedSize = false;
- for (size_t nMoveLevel = nDepth-1; nMoveLevel >= nLevel; --nMoveLevel)
+ if (nDepth > 0)
{
- ScOutlineCollection& rColl = aCollections[nMoveLevel];
- ScOutlineCollection::iterator it = rColl.begin(), itEnd = rColl.end();
- while (it != itEnd)
+ for (size_t nMoveLevel = nDepth-1; nMoveLevel >= nLevel; --nMoveLevel)
{
- ScOutlineEntry* pEntry = it->second;
- SCCOLROW nEntryStart = pEntry->GetStart();
- if (nEntryStart >= nStartCol && nEntryStart <= nEndCol)
+ ScOutlineCollection& rColl = aCollections[nMoveLevel];
+ ScOutlineCollection::iterator it = rColl.begin(), itEnd = rColl.end();
+ while (it != itEnd)
{
- if (nMoveLevel >= SC_OL_MAXDEPTH - 1)
+ ScOutlineEntry* pEntry = it->second;
+ SCCOLROW nEntryStart = pEntry->GetStart();
+ if (nEntryStart >= nStartCol && nEntryStart <= nEndCol)
{
- rSizeChanged = false; // kein Platz
- return false;
+ if (nMoveLevel >= SC_OL_MAXDEPTH - 1)
+ {
+ rSizeChanged = false; // kein Platz
+ return false;
+ }
+ aCollections[nMoveLevel+1].insert(new ScOutlineEntry(*pEntry));
+ size_t nPos = std::distance(rColl.begin(), it);
+ rColl.erase(it);
+ it = rColl.begin();
+ std::advance(it, nPos);
+ itEnd = rColl.end();
+ if (nMoveLevel == nDepth - 1)
+ bNeedSize = true;
}
- aCollections[nMoveLevel+1].insert(new ScOutlineEntry(*pEntry));
- size_t nPos = std::distance(rColl.begin(), it);
- rColl.erase(it);
- it = rColl.begin();
- std::advance(it, nPos);
- itEnd = rColl.end();
- if (nMoveLevel == nDepth - 1)
- bNeedSize = true;
+ else
+ ++it;
}
- else
- ++it;
+ if (nMoveLevel == 0)
+ break;
}
}
commit 35692c7370bb35eb66f5485f6033af5de812ad1c
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 3 23:35:49 2012 -0500
ScOutlineCollection and its friends now free of ScSortedCollection.
But it's apparently broken at the moment. I need to fix this...
diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx
index 9707971..c602f24 100644
--- a/sc/inc/chartlis.hxx
+++ b/sc/inc/chartlis.hxx
@@ -32,7 +32,6 @@
#include <vcl/timer.hxx>
#include <svl/listener.hxx>
-#include "collect.hxx"
#include "rangelst.hxx"
#include "token.hxx"
#include "externalrefmgr.hxx"
diff --git a/sc/inc/chartpos.hxx b/sc/inc/chartpos.hxx
index b648043..4d3dccb 100644
--- a/sc/inc/chartpos.hxx
+++ b/sc/inc/chartpos.hxx
@@ -31,7 +31,6 @@
// -----------------------------------------------------------------------
-#include "collect.hxx"
#include "rangelst.hxx"
diff --git a/sc/inc/chgtrack.hxx b/sc/inc/chgtrack.hxx
index 9564e33..16b8698 100644
--- a/sc/inc/chgtrack.hxx
+++ b/sc/inc/chgtrack.hxx
@@ -40,7 +40,6 @@
#include <unotools/options.hxx>
#include "global.hxx"
#include "bigrange.hxx"
-#include "collect.hxx"
#include "scdllapi.h"
#ifdef SC_CHGTRACK_CXX
diff --git a/sc/inc/dpcachetable.hxx b/sc/inc/dpcachetable.hxx
index 695586f..7927b1a 100644
--- a/sc/inc/dpcachetable.hxx
+++ b/sc/inc/dpcachetable.hxx
@@ -32,7 +32,6 @@
#include "sal/types.h"
#include "osl/mutex.hxx"
#include "global.hxx"
-#include "collect.hxx"
#include <vector>
#include <boost/unordered_set.hpp>
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index ca1dd9e..79b5a67 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -32,7 +32,6 @@
#include "scdllapi.h"
#include "global.hxx"
#include "address.hxx"
-#include "collect.hxx"
#include "dpoutput.hxx"
#include "dptypes.hxx"
#include "pivot.hxx"
diff --git a/sc/inc/olinetab.hxx b/sc/inc/olinetab.hxx
index 4759bef..6a542f3 100644
--- a/sc/inc/olinetab.hxx
+++ b/sc/inc/olinetab.hxx
@@ -29,9 +29,10 @@
#ifndef SC_OUTLINETAB_HXX
#define SC_OUTLINETAB_HXX
-
-#include "collect.hxx"
#include "scdllapi.h"
+#include "address.hxx"
+
+#include <boost/ptr_container/ptr_map.hpp>
#define SC_OL_MAXDEPTH 7
@@ -39,7 +40,7 @@ class SvStream;
class ScTable;
-class ScOutlineEntry : public ScDataObject
+class ScOutlineEntry
{
SCCOLROW nStart;
SCSIZE nSize;
@@ -50,8 +51,6 @@ public:
ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNewHidden = false );
ScOutlineEntry( const ScOutlineEntry& rEntry );
- virtual ScDataObject* Clone() const;
-
SCCOLROW GetStart() const;
SCSIZE GetSize() const;
SC_DLLPUBLIC SCCOLROW GetEnd() const;
@@ -73,66 +72,82 @@ public:
void SetVisible( bool bNewVisible );
};
-class ScOutlineCollection : public ScSortedCollection
+class ScOutlineCollection
{
-public:
- ScOutlineCollection();
-
- virtual short Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
+ typedef boost::ptr_map<SCCOLROW, ScOutlineEntry> MapType;
+ MapType maEntries;
- sal_uInt16 FindStart( SCCOLROW nMinStart );
+public:
+ typedef MapType::iterator iterator;
+ typedef MapType::const_iterator const_iterator;
+
+ ScOutlineCollection();
+
+ size_t size() const;
+ void clear();
+ void insert(ScOutlineEntry* pEntry);
+ iterator begin();
+ iterator end();
+ const_iterator begin() const;
+ const_iterator end() const;
+ void erase(iterator pos);
+ bool empty() const;
+
+ iterator FindStart(SCCOLROW nMinStart);
};
-
class SC_DLLPUBLIC ScOutlineArray
{
friend class ScSubOutlineIterator;
private:
- sal_uInt16 nDepth;
+ size_t nDepth;
ScOutlineCollection aCollections[SC_OL_MAXDEPTH];
- sal_Bool DecDepth();
- void FindEntry( SCCOLROW nSearchPos, sal_uInt16& rFindLevel, sal_uInt16& rFindIndex,
- sal_uInt16 nMaxLevel = SC_OL_MAXDEPTH );
- void RemoveSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nLevel );
- void PromoteSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nStartLevel );
+ bool DecDepth();
+ void FindEntry(
+ SCCOLROW nSearchPos, size_t& rFindLevel, ScOutlineCollection::iterator& rFindPos,
+ size_t nMaxLevel = SC_OL_MAXDEPTH);
+
+ void RemoveSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nLevel);
+ void PromoteSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nStartLevel);
public:
- ScOutlineArray();
- ScOutlineArray( const ScOutlineArray& rArray );
+ ScOutlineArray();
+ ScOutlineArray( const ScOutlineArray& rArray );
- sal_uInt16 GetDepth() const { return nDepth; }
+ size_t GetDepth() const;
- sal_Bool FindTouchedLevel( SCCOLROW nBlockStart, SCCOLROW nBlockEnd,
- sal_uInt16& rFindLevel ) const;
+ bool FindTouchedLevel(
+ SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rFindLevel) const;
- bool Insert( SCCOLROW nStartPos, SCCOLROW nEndPos, bool& rSizeChanged,
- bool bHidden = false, bool bVisible = true );
- sal_Bool Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, sal_Bool& rSizeChanged );
+ bool Insert( SCCOLROW nStartPos, SCCOLROW nEndPos, bool& rSizeChanged,
+ bool bHidden = false, bool bVisible = true );
+ bool Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, bool& rSizeChanged );
- ScOutlineEntry* GetEntry( sal_uInt16 nLevel, sal_uInt16 nIndex ) const;
- sal_uInt16 GetCount( sal_uInt16 nLevel ) const;
- ScOutlineEntry* GetEntryByPos( sal_uInt16 nLevel, SCCOLROW nPos ) const;
+ ScOutlineEntry* GetEntry(size_t nLevel, size_t nIndex);
+ const ScOutlineEntry* GetEntry(size_t nLevel, size_t nIndex) const;
+ size_t GetCount(size_t nLevel) const;
+ const ScOutlineEntry* GetEntryByPos(size_t nLevel, SCCOLROW nPos) const;
- sal_Bool GetEntryIndex( sal_uInt16 nLevel, SCCOLROW nPos, sal_uInt16& rnIndex ) const;
- sal_Bool GetEntryIndexInRange(
- sal_uInt16 nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd,
- sal_uInt16& rnIndex ) const;
+ bool GetEntryIndex(size_t nLevel, SCCOLROW nPos, size_t& rnIndex) const;
+ bool GetEntryIndexInRange(
+ size_t nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rnIndex) const;
- void SetVisibleBelow( sal_uInt16 nLevel, sal_uInt16 nEntry, sal_Bool bValue,
- sal_Bool bSkipHidden = false );
+ void SetVisibleBelow(
+ size_t nLevel, size_t nEntry, bool bValue, bool bSkipHidden = false);
- void GetRange( SCCOLROW& rStart, SCCOLROW& rEnd ) const;
- void ExtendBlock( sal_uInt16 nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd );
+ void GetRange(SCCOLROW& rStart, SCCOLROW& rEnd) const;
+ void ExtendBlock(size_t nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd);
- sal_Bool TestInsertSpace( SCSIZE nSize, SCCOLROW nMaxVal ) const;
- void InsertSpace( SCCOLROW nStartPos, SCSIZE nSize );
- sal_Bool DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize );
+ bool TestInsertSpace(SCSIZE nSize, SCCOLROW nMaxVal) const;
+ void InsertSpace(SCCOLROW nStartPos, SCSIZE nSize);
+ bool DeleteSpace(SCCOLROW nStartPos, SCSIZE nSize);
- bool ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, ScTable& rTable, bool bCol );
+ bool ManualAction(
+ SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, const ScTable& rTable, bool bCol);
- void RemoveAll();
+ void RemoveAll();
};
@@ -166,19 +181,19 @@ private:
ScOutlineArray* pArray;
SCCOLROW nStart;
SCCOLROW nEnd;
- sal_uInt16 nSubLevel;
- sal_uInt16 nSubEntry;
- sal_uInt16 nCount;
- sal_uInt16 nDepth;
+ size_t nSubLevel;
+ size_t nSubEntry;
+ size_t nCount;
+ size_t nDepth;
public:
- ScSubOutlineIterator( ScOutlineArray* pOutlineArray );
- ScSubOutlineIterator( ScOutlineArray* pOutlineArray,
- sal_uInt16 nLevel, sal_uInt16 nEntry );
- ScOutlineEntry* GetNext();
- sal_uInt16 LastLevel() const;
- sal_uInt16 LastEntry() const;
- void DeleteLast();
+ ScSubOutlineIterator( ScOutlineArray* pOutlineArray );
+ ScSubOutlineIterator( ScOutlineArray* pOutlineArray, size_t nLevel, size_t nEntry );
+
+ ScOutlineEntry* GetNext();
+ size_t LastLevel() const;
+ size_t LastEntry() const;
+ void DeleteLast();
};
#endif
diff --git a/sc/inc/pivot.hxx b/sc/inc/pivot.hxx
index 705f794..1171737 100644
--- a/sc/inc/pivot.hxx
+++ b/sc/inc/pivot.hxx
@@ -53,7 +53,6 @@
#include <boost/shared_ptr.hpp>
class SubTotal;
-#include "collect.hxx"
#define PIVOT_DATA_FIELD (MAXCOLCOUNT)
#define PIVOT_FUNC_REF (MAXCOLCOUNT)
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 53e9ec8..90edb8d 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -31,7 +31,6 @@
#include "global.hxx" // -> enum UpdateRefMode
#include "address.hxx"
-#include "collect.hxx"
#include "formula/grammar.hxx"
#include "scdllapi.h"
diff --git a/sc/inc/unitconv.hxx b/sc/inc/unitconv.hxx
index 2b000fb..024a303 100644
--- a/sc/inc/unitconv.hxx
+++ b/sc/inc/unitconv.hxx
@@ -29,8 +29,6 @@
#ifndef SC_UNITCONV_HXX
#define SC_UNITCONV_HXX
-#include "collect.hxx"
-
#include <boost/noncopyable.hpp>
#include <boost/ptr_container/ptr_map.hpp>
diff --git a/sc/source/core/data/column2.cxx b/sc/source/core/data/column2.cxx
index b97b0de..865820a 100644
--- a/sc/source/core/data/column2.cxx
+++ b/sc/source/core/data/column2.cxx
@@ -56,7 +56,6 @@
#include "attarray.hxx"
#include "patattr.hxx"
#include "cellform.hxx"
-#include "collect.hxx"
#include "stlsheet.hxx"
#include "rechead.hxx"
#include "brdcst.hxx"
diff --git a/sc/source/core/data/dpgroup.cxx b/sc/source/core/data/dpgroup.cxx
index 3dd8247..7888331 100644
--- a/sc/source/core/data/dpgroup.cxx
+++ b/sc/source/core/data/dpgroup.cxx
@@ -38,7 +38,6 @@
#include <svl/zforlist.hxx>
#include "dpgroup.hxx"
-#include "collect.hxx"
#include "global.hxx"
#include "document.hxx"
#include "dpcachetable.hxx"
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index f827973..7458fca 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -39,6 +39,7 @@
#include "dpgroup.hxx"
#include "document.hxx"
#include "rechead.hxx"
+#include "collect.hxx"
#include "pivot.hxx" // PIVOT_DATA_FIELD
#include "dapiuno.hxx" // ScDataPilotConversion
#include "miscuno.hxx"
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 103fab1..e43d706 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -50,7 +50,6 @@
#include "globstr.hrc"
#include "stlpool.hxx"
#include "stlsheet.hxx"
-#include "collect.hxx"
#include "scresid.hxx"
#include "unonames.hxx"
#include "sc.hrc"
diff --git a/sc/source/core/data/dpsdbtab.cxx b/sc/source/core/data/dpsdbtab.cxx
index 576beb5..c67c3b9 100644
--- a/sc/source/core/data/dpsdbtab.cxx
+++ b/sc/source/core/data/dpsdbtab.cxx
@@ -32,7 +32,6 @@
// INCLUDE --------------------------------------------------------------
#include "dpsdbtab.hxx"
-#include "collect.hxx"
#include "global.hxx"
#include "globstr.hrc"
#include "dpcachetable.hxx"
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index 7891eaa..40a0d43 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -36,7 +36,6 @@
#include "dpshttab.hxx"
#include "dptabres.hxx"
#include "document.hxx"
-#include "collect.hxx"
#include "cell.hxx"
#include "dpcachetable.hxx"
#include "dpobject.hxx"
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 7693197..8b9e4e0 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -53,7 +53,6 @@
#include "dptabres.hxx"
#include "dptabdat.hxx"
#include "global.hxx"
-#include "collect.hxx"
#include "datauno.hxx" // ScDataUnoConversion
#include "miscuno.hxx"
#include "unonames.hxx"
diff --git a/sc/source/core/data/olinetab.cxx b/sc/source/core/data/olinetab.cxx
index 30bf2f3..0dae860 100644
--- a/sc/source/core/data/olinetab.cxx
+++ b/sc/source/core/data/olinetab.cxx
@@ -47,12 +47,11 @@ ScOutlineEntry::ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNew
nStart ( nNewStart ),
nSize ( nNewSize ),
bHidden ( bNewHidden ),
- bVisible( sal_True )
+ bVisible( true )
{
}
ScOutlineEntry::ScOutlineEntry( const ScOutlineEntry& rEntry ) :
- ScDataObject(),
nStart ( rEntry.nStart ),
nSize ( rEntry.nSize ),
bHidden ( rEntry.bHidden ),
@@ -60,11 +59,6 @@ ScOutlineEntry::ScOutlineEntry( const ScOutlineEntry& rEntry ) :
{
}
-ScDataObject* ScOutlineEntry::Clone() const
-{
- return new ScOutlineEntry( *this );
-}
-
SCCOLROW ScOutlineEntry::GetStart() const
{
return nStart;
@@ -128,10 +122,7 @@ void ScOutlineEntry::SetVisible( bool bNewVisible )
//------------------------------------------------------------------------
-ScOutlineCollection::ScOutlineCollection() :
- ScSortedCollection( 4,4,false )
-{
-}
+ScOutlineCollection::ScOutlineCollection() {}
inline short IntCompare( SCCOLROW nX, SCCOLROW nY )
{
@@ -140,90 +131,122 @@ inline short IntCompare( SCCOLROW nX, SCCOLROW nY )
else return 1;
}
-short ScOutlineCollection::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const
+size_t ScOutlineCollection::size() const
{
- return IntCompare( ((ScOutlineEntry*)pKey1)->GetStart(),
- ((ScOutlineEntry*)pKey2)->GetStart() );
+ return maEntries.size();
}
-sal_uInt16 ScOutlineCollection::FindStart( SCCOLROW nMinStart )
+void ScOutlineCollection::clear()
{
- //! binaer suchen ?
+ maEntries.clear();
+}
- sal_uInt16 nPos = 0;
- sal_uInt16 nLocalCount = GetCount();
- while ( (nPos<nLocalCount) ? (((ScOutlineEntry*)At(nPos))->GetStart() < nMinStart) : false )
- ++nPos;
+void ScOutlineCollection::insert(ScOutlineEntry* pEntry)
+{
+ SCCOLROW nStart = pEntry->GetStart();
+ maEntries.insert(nStart, pEntry);
+}
- return nPos;
+ScOutlineCollection::iterator ScOutlineCollection::begin()
+{
+ return maEntries.begin();
}
-//------------------------------------------------------------------------
+ScOutlineCollection::iterator ScOutlineCollection::end()
+{
+ return maEntries.end();
+}
-ScOutlineArray::ScOutlineArray() :
- nDepth( 0 )
+ScOutlineCollection::const_iterator ScOutlineCollection::begin() const
+{
+ return maEntries.begin();
+}
+
+ScOutlineCollection::const_iterator ScOutlineCollection::end() const
+{
+ return maEntries.end();
+}
+
+void ScOutlineCollection::erase(iterator pos)
{
+ maEntries.erase(pos);
}
+bool ScOutlineCollection::empty() const
+{
+ return maEntries.empty();
+}
+
+ScOutlineCollection::iterator ScOutlineCollection::FindStart(SCCOLROW nMinStart)
+{
+ return maEntries.lower_bound(nMinStart);
+}
+
+//------------------------------------------------------------------------
+
+ScOutlineArray::ScOutlineArray() :
+ nDepth(0) {}
+
ScOutlineArray::ScOutlineArray( const ScOutlineArray& rArray ) :
nDepth( rArray.nDepth )
{
- for (sal_uInt16 nLevel=0; nLevel<nDepth; nLevel++)
+ for (size_t nLevel = 0; nLevel < nDepth; ++nLevel)
{
- sal_uInt16 nCount = rArray.aCollections[nLevel].GetCount();
- for (sal_uInt16 nEntry=0; nEntry<nCount; nEntry++)
+ const ScOutlineCollection& rColl = rArray.aCollections[nLevel];
+ ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
+ for (; it != itEnd; ++it)
{
- ScOutlineEntry* pEntry = (ScOutlineEntry*) rArray.aCollections[nLevel].At(nEntry);
- aCollections[nLevel].Insert( new ScOutlineEntry( *pEntry ) );
+ const ScOutlineEntry* pEntry = it->second;
+ aCollections[nLevel].insert(new ScOutlineEntry(*pEntry));
}
}
}
-void ScOutlineArray::FindEntry( SCCOLROW nSearchPos, sal_uInt16& rFindLevel, sal_uInt16& rFindIndex,
- sal_uInt16 nMaxLevel )
+void ScOutlineArray::FindEntry(
+ SCCOLROW nSearchPos, size_t& rFindLevel, ScOutlineCollection::iterator& rFindPos,
+ size_t nMaxLevel )
{
- rFindLevel = rFindIndex = 0;
+ rFindLevel = 0;
if (nMaxLevel > nDepth)
nMaxLevel = nDepth;
- for (sal_uInt16 nLevel=0; nLevel<nMaxLevel; nLevel++) //! rueckwaerts suchen ?
+ for (size_t nLevel = 0; nLevel < nMaxLevel; ++nLevel) //! rueckwaerts suchen ?
{
ScOutlineCollection* pCollect = &aCollections[nLevel];
- sal_uInt16 nCount = pCollect->GetCount();
- for (sal_uInt16 i=0; i<nCount; i++)
+ ScOutlineCollection::iterator it = pCollect->begin(), itEnd = pCollect->end();
+ rFindPos = itEnd;
+ for (; it != itEnd; ++it)
{
- ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
- if ( pEntry->GetStart() <= nSearchPos && pEntry->GetEnd() >= nSearchPos )
+ ScOutlineEntry* pEntry = it->second;
+ if (pEntry->GetStart() <= nSearchPos && pEntry->GetEnd() >= nSearchPos)
{
rFindLevel = nLevel + 1; // naechster Level (zum Einfuegen)
- rFindIndex = i;
+ rFindPos = it;
}
}
}
}
-bool ScOutlineArray::Insert( SCCOLROW nStartCol, SCCOLROW nEndCol, bool& rSizeChanged,
- bool bHidden, bool bVisible )
+bool ScOutlineArray::Insert(
+ SCCOLROW nStartCol, SCCOLROW nEndCol, bool& rSizeChanged, bool bHidden, bool bVisible )
{
rSizeChanged = false;
- sal_uInt16 nStartLevel;
- sal_uInt16 nStartIndex;
- sal_uInt16 nEndLevel;
- sal_uInt16 nEndIndex;
+ size_t nStartLevel, nEndLevel;
+ ScOutlineCollection::iterator itStartPos, itEndPos;
bool bFound = false;
bool bCont;
sal_uInt16 nFindMax;
- FindEntry( nStartCol, nStartLevel, nStartIndex ); // nLevel = neuer Level (alter+1) !!!
- FindEntry( nEndCol, nEndLevel, nEndIndex );
+ FindEntry( nStartCol, nStartLevel, itStartPos ); // nLevel = neuer Level (alter+1) !!!
+ FindEntry( nEndCol, nEndLevel, itEndPos );
nFindMax = Max(nStartLevel,nEndLevel);
do
{
bCont = false;
- if ( nStartLevel == nEndLevel && nStartIndex == nEndIndex && nStartLevel < SC_OL_MAXDEPTH )
+ if (nStartLevel == nEndLevel && itStartPos == itEndPos && nStartLevel < SC_OL_MAXDEPTH)
bFound = true;
if (!bFound)
@@ -232,13 +255,16 @@ bool ScOutlineArray::Insert( SCCOLROW nStartCol, SCCOLROW nEndCol, bool& rSizeCh
{
--nFindMax;
if (nStartLevel)
- if ( ((ScOutlineEntry*)aCollections[nStartLevel-1].At(nStartIndex))->
- GetStart() == nStartCol )
- FindEntry( nStartCol, nStartLevel, nStartIndex, nFindMax );
+ {
+ if (itStartPos->second->GetStart() == nStartCol)
+ FindEntry(nStartCol, nStartLevel, itStartPos, nFindMax);
+ }
+
if (nEndLevel)
- if ( ((ScOutlineEntry*)aCollections[nEndLevel-1].At(nEndIndex))->
- GetEnd() == nEndCol )
- FindEntry( nEndCol, nEndLevel, nEndIndex, nFindMax );
+ {
+ if (itEndPos->second->GetEnd() == nEndCol)
+ FindEntry(nEndCol, nEndLevel, itEndPos, nFindMax);
+ }
bCont = true;
}
}
@@ -248,35 +274,37 @@ bool ScOutlineArray::Insert( SCCOLROW nStartCol, SCCOLROW nEndCol, bool& rSizeCh
if (!bFound)
return false;
- sal_uInt16 nLevel = nStartLevel;
+ size_t nLevel = nStartLevel;
// untere verschieben
bool bNeedSize = false;
- for ( short nMoveLevel = nDepth-1; nMoveLevel >= (short) nLevel; nMoveLevel-- )
+ for (size_t nMoveLevel = nDepth-1; nMoveLevel >= nLevel; --nMoveLevel)
{
- sal_uInt16 nCount = aCollections[nMoveLevel].GetCount();
- bool bMoved = false;
- for ( sal_uInt16 i=0; i<nCount; i += bMoved ? 0 : 1 )
+ ScOutlineCollection& rColl = aCollections[nMoveLevel];
+ ScOutlineCollection::iterator it = rColl.begin(), itEnd = rColl.end();
+ while (it != itEnd)
{
- ScOutlineEntry* pEntry = (ScOutlineEntry*) aCollections[nMoveLevel].At(i);
+ ScOutlineEntry* pEntry = it->second;
SCCOLROW nEntryStart = pEntry->GetStart();
- if ( nEntryStart >= nStartCol && nEntryStart <= nEndCol )
+ if (nEntryStart >= nStartCol && nEntryStart <= nEndCol)
{
if (nMoveLevel >= SC_OL_MAXDEPTH - 1)
{
rSizeChanged = false; // kein Platz
return false;
}
- aCollections[nMoveLevel+1].Insert( new ScOutlineEntry( *pEntry ) );
- aCollections[nMoveLevel].AtFree( i );
- nCount = aCollections[nMoveLevel].GetCount();
- bMoved = true;
- if (nMoveLevel == (short) nDepth - 1)
- bNeedSize = sal_True;
+ aCollections[nMoveLevel+1].insert(new ScOutlineEntry(*pEntry));
+ size_t nPos = std::distance(rColl.begin(), it);
+ rColl.erase(it);
+ it = rColl.begin();
+ std::advance(it, nPos);
+ itEnd = rColl.end();
+ if (nMoveLevel == nDepth - 1)
+ bNeedSize = true;
}
else
- bMoved = false;
+ ++it;
}
}
@@ -294,23 +322,29 @@ bool ScOutlineArray::Insert( SCCOLROW nStartCol, SCCOLROW nEndCol, bool& rSizeCh
ScOutlineEntry* pNewEntry = new ScOutlineEntry( nStartCol, nEndCol+1-nStartCol, bHidden );
pNewEntry->SetVisible( bVisible );
- aCollections[nLevel].Insert( pNewEntry );
+ aCollections[nLevel].insert(pNewEntry);
return true;
}
-sal_Bool ScOutlineArray::FindTouchedLevel( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, sal_uInt16& rFindLevel ) const
+size_t ScOutlineArray::GetDepth() const
+{
+ return nDepth;
+}
+
+bool ScOutlineArray::FindTouchedLevel(
+ SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rFindLevel) const
{
- sal_Bool bFound = false;
+ bool bFound = false;
rFindLevel = 0;
- for (sal_uInt16 nLevel=0; nLevel<nDepth; nLevel++)
+ for (size_t nLevel = 0; nLevel < nDepth; ++nLevel)
{
const ScOutlineCollection* pCollect = &aCollections[nLevel];
- sal_uInt16 nCount = pCollect->GetCount();
- for (sal_uInt16 i=0; i<nCount; i++)
+ ScOutlineCollection::const_iterator it = pCollect->begin(), itEnd = pCollect->end();
+ for (; it != itEnd; ++it)
{
- ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
+ const ScOutlineEntry* pEntry = it->second;
SCCOLROW nStart = pEntry->GetStart();
SCCOLROW nEnd = pEntry->GetEnd();
@@ -318,7 +352,7 @@ sal_Bool ScOutlineArray::FindTouchedLevel( SCCOLROW nBlockStart, SCCOLROW nBlock
( nBlockEnd >=nStart && nBlockEnd <=nEnd ) )
{
rFindLevel = nLevel; // wirklicher Level
- bFound = sal_True;
+ bFound = true;
}
}
}
@@ -326,31 +360,61 @@ sal_Bool ScOutlineArray::FindTouchedLevel( SCCOLROW nBlockStart, SCCOLROW nBlock
return bFound;
}
-void ScOutlineArray::RemoveSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nLevel )
+void ScOutlineArray::RemoveSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nLevel)
{
if ( nLevel >= nDepth )
return;
- ScOutlineCollection* pCollect = &aCollections[nLevel];
- sal_uInt16 nCount = pCollect->GetCount();
- sal_Bool bFound = false;
- for ( sal_uInt16 i=0; i<nCount; i += ( bFound ? 0 : 1 ) )
+
+ ScOutlineCollection& rColl = aCollections[nLevel];
+
+ ScOutlineCollection::iterator it = rColl.begin(), itEnd = rColl.end();
+ while (it != itEnd)
{
- bFound = false;
- ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
+ ScOutlineEntry* pEntry = it->second;
SCCOLROW nStart = pEntry->GetStart();
SCCOLROW nEnd = pEntry->GetEnd();
+ if (nStart >= nStartPos && nEnd <= nEndPos)
+ {
+ // Overlaps.
+ RemoveSub( nStart, nEnd, nLevel+1 );
- if ( nStart>=nStartPos && nEnd<=nEndPos )
+ // Re-calc iterator positions after the tree gets invalidated.
+ size_t nPos = std::distance(rColl.begin(), it);
+ rColl.erase(it);
+ it = rColl.begin();
+ std::advance(it, nPos);
+ itEnd = rColl.end();
+ }
+ else
+ ++it;
+ }
+
+ it = rColl.begin();
+ itEnd = rColl.end();
+
+ while (it != itEnd)
+ {
+ ScOutlineEntry* pEntry = it->second;
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
+
+ if (nStart >= nStartPos && nEnd <= nEndPos)
{
RemoveSub( nStart, nEnd, nLevel+1 );
- pCollect->AtFree(i);
- nCount = pCollect->GetCount();
- bFound = sal_True;
+
+ // Re-calc iterator positions after the tree gets invalidated.
+ size_t nPos = std::distance(rColl.begin(), it);
+ rColl.erase(it);
+ it = rColl.begin();
+ std::advance(it, nPos);
+ itEnd = rColl.end();
}
+ else
+ ++it;
}
}
-void ScOutlineArray::PromoteSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nStartLevel )
+void ScOutlineArray::PromoteSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nStartLevel)
{
if (nStartLevel==0)
{
@@ -358,218 +422,291 @@ void ScOutlineArray::PromoteSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt1
return;
}
- for (sal_uInt16 nLevel = nStartLevel; nLevel < nDepth; nLevel++)
+ for (size_t nLevel = nStartLevel; nLevel < nDepth; ++nLevel)
{
- ScOutlineCollection* pCollect = &aCollections[nLevel];
- sal_uInt16 nCount = pCollect->GetCount();
- sal_Bool bFound = false;
- for ( sal_uInt16 i=0; i<nCount; i += ( bFound ? 0 : 1 ) )
+ ScOutlineCollection& rColl = aCollections[nLevel];
+ ScOutlineCollection::iterator it = rColl.begin(), itEnd = rColl.end();
+ while (it != itEnd)
{
- bFound = false;
- ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
+ ScOutlineEntry* pEntry = it->second;
SCCOLROW nStart = pEntry->GetStart();
SCCOLROW nEnd = pEntry->GetEnd();
+ if (nStart >= nStartPos && nEnd <= nEndPos)
+ {
+ aCollections[nLevel-1].insert(new ScOutlineEntry(*pEntry));
+
+ // Re-calc iterator positions after the tree gets invalidated.
+ size_t nPos = std::distance(rColl.begin(), it);
+ rColl.erase(it);
+ it = rColl.begin();
+ std::advance(it, nPos);
+ itEnd = rColl.end();
+ }
+ else
+ ++it;
+ }
+
+ it = rColl.begin();
+ itEnd = rColl.end();
- if ( nStart>=nStartPos && nEnd<=nEndPos )
+ while (it != itEnd)
+ {
+ ScOutlineEntry* pEntry = it->second;
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
+ if (nStart >= nStartPos && nEnd <= nEndPos)
{
- aCollections[nLevel-1].Insert( new ScOutlineEntry( *pEntry ) );
- pCollect->AtFree(i);
- nCount = pCollect->GetCount();
- bFound = sal_True;
+ aCollections[nLevel-1].insert(new ScOutlineEntry(*pEntry));
+
+ // Re-calc iterator positions after the tree gets invalidated.
+ size_t nPos = std::distance(rColl.begin(), it);
+ rColl.erase(it);
+ it = rColl.begin();
+ std::advance(it, nPos);
+ itEnd = rColl.end();
}
+ else
+ ++it;
}
}
}
-sal_Bool ScOutlineArray::DecDepth() // nDepth auf leere Levels anpassen
+bool ScOutlineArray::DecDepth() // nDepth auf leere Levels anpassen
{
- sal_Bool bChanged = false;
- sal_Bool bCont;
+ bool bChanged = false;
+ bool bCont;
do
{
bCont = false;
if (nDepth)
- if (aCollections[nDepth-1].GetCount() == 0)
+ {
+ if (aCollections[nDepth-1].empty())
{
--nDepth;
- bChanged = sal_True;
- bCont = sal_True;
+ bChanged = true;
+ bCont = true;
}
+ }
}
while (bCont);
+
return bChanged;
}
-sal_Bool ScOutlineArray::Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, sal_Bool& rSizeChanged )
+bool ScOutlineArray::Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, bool& rSizeChanged )
{
- sal_uInt16 nLevel;
+ size_t nLevel;
FindTouchedLevel( nBlockStart, nBlockEnd, nLevel );
ScOutlineCollection* pCollect = &aCollections[nLevel];
- sal_uInt16 nCount = pCollect->GetCount();
- sal_Bool bFound = false;
- sal_Bool bAny = false;
- for ( sal_uInt16 i=0; i<nCount; i += ( bFound ? 0 : 1 ) )
+ ScOutlineCollection::iterator it = pCollect->begin(), itEnd = pCollect->end();
+ bool bAny = false;
+ while (it != itEnd)
{
- bFound = false;
- ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
+ ScOutlineEntry* pEntry = it->second;
SCCOLROW nStart = pEntry->GetStart();
SCCOLROW nEnd = pEntry->GetEnd();
-
- if ( nBlockStart<=nEnd && nBlockEnd>=nStart )
+ if (nBlockStart <= nEnd && nBlockEnd >= nStart)
{
- pCollect->AtFree(i);
+ // Overlaps.
+ pCollect->erase(it);
PromoteSub( nStart, nEnd, nLevel+1 );
- nCount = pCollect->GetCount();
- i = pCollect->FindStart( nEnd+1 );
- bFound = sal_True;
- bAny = sal_True;
+ itEnd = pCollect->end();
+ it = pCollect->FindStart( nEnd+1 );
+ bAny = true;
}
+ else
+ ++it;
}
if (bAny) // Depth anpassen
if (DecDepth())
- rSizeChanged = sal_True;
+ rSizeChanged = true;
return bAny;
}
-ScOutlineEntry* ScOutlineArray::GetEntry( sal_uInt16 nLevel, sal_uInt16 nIndex ) const
+ScOutlineEntry* ScOutlineArray::GetEntry(size_t nLevel, size_t nIndex)
+{
+ if (nLevel >= nDepth)
+ return NULL;
+
+ ScOutlineCollection& rColl = aCollections[nLevel];
+ if (nIndex >= rColl.size())
+ return NULL;
+
+ ScOutlineCollection::iterator it = rColl.begin();
+ std::advance(it, nIndex);
+ return it->second;
+}
+
+const ScOutlineEntry* ScOutlineArray::GetEntry(size_t nLevel, size_t nIndex) const
{
- return (ScOutlineEntry*)((nLevel < nDepth) ? aCollections[nLevel].At(nIndex) : NULL);
+ if (nLevel >= nDepth)
+ return NULL;
+
+ const ScOutlineCollection& rColl = aCollections[nLevel];
+ if (nIndex >= rColl.size())
+ return NULL;
+
+ ScOutlineCollection::const_iterator it = rColl.begin();
+ std::advance(it, nIndex);
+ return it->second;
}
-sal_uInt16 ScOutlineArray::GetCount( sal_uInt16 nLevel ) const
+size_t ScOutlineArray::GetCount(size_t nLevel) const
{
- return (nLevel < nDepth) ? aCollections[nLevel].GetCount() : 0;
+ if (nLevel >= nDepth)
+ return 0;
+
+ return aCollections[nLevel].size();
}
-ScOutlineEntry* ScOutlineArray::GetEntryByPos( sal_uInt16 nLevel, SCCOLROW nPos ) const
+const ScOutlineEntry* ScOutlineArray::GetEntryByPos(size_t nLevel, SCCOLROW nPos) const
{
- sal_uInt16 nCount = GetCount( nLevel );
- ScOutlineEntry* pEntry;
+ if (nLevel >= nDepth)
+ return NULL;
- for (sal_uInt16 nIndex = 0; nIndex < nCount; nIndex++)
+ const ScOutlineCollection& rColl = aCollections[nLevel];
+ ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
+ for (; it != itEnd; ++it)
{
- pEntry = GetEntry( nLevel, nIndex );
- if ((pEntry->GetStart() <= nPos) && (nPos <= pEntry->GetEnd()))
+ const ScOutlineEntry* pEntry = it->second;
+ if (pEntry->GetStart() <= nPos && nPos <= pEntry->GetEnd())
return pEntry;
}
+
return NULL;
}
-sal_Bool ScOutlineArray::GetEntryIndex( sal_uInt16 nLevel, SCCOLROW nPos, sal_uInt16& rnIndex ) const
+bool ScOutlineArray::GetEntryIndex(size_t nLevel, SCCOLROW nPos, size_t& rnIndex) const
{
+ if (nLevel >= nDepth)
+ return false;
+
// found entry contains passed position
- sal_uInt16 nCount = GetCount( nLevel );
- for ( rnIndex = 0; rnIndex < nCount; ++rnIndex )
+ const ScOutlineCollection& rColl = aCollections[nLevel];
+ ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
+ for (; it != itEnd; ++it)
{
- const ScOutlineEntry* pEntry = GetEntry( nLevel, rnIndex );
- if ( (pEntry->GetStart() <= nPos) && (nPos <= pEntry->GetEnd()) )
- return sal_True;
+ const ScOutlineEntry* p = it->second;
+ if (p->GetStart() <= nPos && nPos <= p->GetEnd())
+ {
+ rnIndex = std::distance(rColl.begin(), it);
+ return true;
+ }
}
return false;
}
-sal_Bool ScOutlineArray::GetEntryIndexInRange(
- sal_uInt16 nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, sal_uInt16& rnIndex ) const
+bool ScOutlineArray::GetEntryIndexInRange(
+ size_t nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rnIndex) const
{
+ if (nLevel >= nDepth)
+ return false;
+
// found entry will be completely inside of passed range
- sal_uInt16 nCount = GetCount( nLevel );
- for ( rnIndex = 0; rnIndex < nCount; ++rnIndex )
+ const ScOutlineCollection& rColl = aCollections[nLevel];
+ ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
+ for (; it != itEnd; ++it)
{
- const ScOutlineEntry* pEntry = GetEntry( nLevel, rnIndex );
- if ( (nBlockStart <= pEntry->GetStart()) && (pEntry->GetEnd() <= nBlockEnd) )
- return sal_True;
+ const ScOutlineEntry* p = it->second;
+ if (nBlockStart <= p->GetStart() && p->GetEnd() <= nBlockEnd)
+ {
+ rnIndex = std::distance(rColl.begin(), it);
+ return true;
+ }
}
return false;
}
-void ScOutlineArray::SetVisibleBelow( sal_uInt16 nLevel, sal_uInt16 nEntry, sal_Bool bValue, sal_Bool bSkipHidden )
+void ScOutlineArray::SetVisibleBelow(
+ size_t nLevel, size_t nEntry, bool bValue, bool bSkipHidden)
{
- ScOutlineEntry* pEntry = GetEntry( nLevel, nEntry );
- if( pEntry )
- {
- SCCOLROW nStart = pEntry->GetStart();
- SCCOLROW nEnd = pEntry->GetEnd();
+ const ScOutlineEntry* pEntry = GetEntry( nLevel, nEntry );
+ if (!pEntry)
+ return;
- for (sal_uInt16 nSubLevel=nLevel+1; nSubLevel<nDepth; nSubLevel++)
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
+
+ for (size_t nSubLevel = nLevel+1; nSubLevel < nDepth; ++nSubLevel)
+ {
+ ScOutlineCollection& rColl = aCollections[nSubLevel];
+ ScOutlineCollection::iterator it = rColl.begin(), itEnd = rColl.end();
+ for (; it != itEnd; ++it)
{
- sal_uInt16 i = 0;
- pEntry = (ScOutlineEntry*) aCollections[nSubLevel].At(i);
- while (pEntry)
+ ScOutlineEntry* p = it->second;
+ if (p->GetStart() >= nStart && p->GetEnd() <= nEnd)
{
- if (pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd)
+ p->SetVisible(bValue);
+ if (bSkipHidden && !p->IsHidden())
{
- pEntry->SetVisible(bValue);
-
- if (bSkipHidden)
- if (!pEntry->IsHidden())
- SetVisibleBelow( nSubLevel, i, bValue, sal_True );
+ size_t nPos = std::distance(rColl.begin(), it);
+ SetVisibleBelow(nSubLevel, nPos, bValue, true);
}
-
- ++i;
- pEntry = (ScOutlineEntry*) aCollections[nSubLevel].At(i);
}
-
- if (bSkipHidden)
- nSubLevel = nDepth; // Abbruch
}
+
+ if (bSkipHidden)
+ nSubLevel = nDepth; // Abbruch
}
}
-void ScOutlineArray::GetRange( SCCOLROW& rStart, SCCOLROW& rEnd ) const
+void ScOutlineArray::GetRange(SCCOLROW& rStart, SCCOLROW& rEnd) const
{
- sal_uInt16 nCount = aCollections[0].GetCount();
- if (nCount)
+ const ScOutlineCollection& rColl = aCollections[0];
+ if (!rColl.empty())
{
- rStart = ((ScOutlineEntry*) aCollections[0].At(0))->GetStart();
- rEnd = ((ScOutlineEntry*) aCollections[0].At(nCount-1))->GetEnd();
+ ScOutlineCollection::const_iterator it = rColl.begin();
+ rStart = it->second->GetStart();
+ std::advance(it, rColl.size()-1);
+ rEnd = it->second->GetEnd();
}
else
rStart = rEnd = 0;
}
-void ScOutlineArray::ExtendBlock( sal_uInt16 nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd )
+void ScOutlineArray::ExtendBlock(size_t nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd)
{
- sal_uInt16 nCount;
- SCCOLROW nStart;
- SCCOLROW nEnd;
- sal_uInt16 i;
- ScOutlineEntry* pEntry;
+ if (nLevel >= nDepth)
+ return;
- nCount = GetCount(nLevel);
- for ( i=0; i<nCount; i++ )
+ const ScOutlineCollection& rColl = aCollections[nLevel];
+ ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
+ for (; it != itEnd; ++it)
{
- pEntry = (ScOutlineEntry*) aCollections[nLevel].At(i);
- nStart = pEntry->GetStart();
- nEnd = pEntry->GetEnd();
+ const ScOutlineEntry* pEntry = it->second;
+ SCCOLROW nStart = pEntry->GetStart();
+ SCCOLROW nEnd = pEntry->GetEnd();
- if ( rBlkStart<=nEnd && rBlkEnd>=nStart )
+ if (rBlkStart <= nEnd && rBlkEnd >= nStart)
{
- if (nStart<rBlkStart) rBlkStart = nStart;
- if (nEnd>rBlkEnd) rBlkEnd = nEnd;
+ if (nStart < rBlkStart)
+ rBlkStart = nStart;
+ if (nEnd > rBlkEnd)
+ rBlkEnd = nEnd;
}
}
}
-sal_Bool ScOutlineArray::TestInsertSpace( SCSIZE nSize, SCCOLROW nMaxVal ) const
+bool ScOutlineArray::TestInsertSpace(SCSIZE nSize, SCCOLROW nMaxVal) const
{
- sal_uInt16 nCount = aCollections[0].GetCount();
- if (nCount)
- {
- SCCOLROW nEnd = ((ScOutlineEntry*) aCollections[0].At(nCount-1))->GetEnd();
- return ( sal::static_int_cast<SCCOLROW>(nEnd+nSize) <= nMaxVal );
- }
+ const ScOutlineCollection& rColl = aCollections[0];
+ if (rColl.empty())
+ return true;
- return sal_True;
+ ScOutlineCollection::const_iterator it = rColl.begin();
+ std::advance(it, rColl.size()-1);
+ SCCOLROW nEnd = it->second->GetEnd();
+ return sal::static_int_cast<SCCOLROW>(nEnd+nSize) <= nMaxVal;
}
-void ScOutlineArray::InsertSpace( SCCOLROW nStartPos, SCSIZE nSize )
+void ScOutlineArray::InsertSpace(SCCOLROW nStartPos, SCSIZE nSize)
{
ScSubOutlineIterator aIter( this );
ScOutlineEntry* pEntry;
- while((pEntry=aIter.GetNext())!=NULL)
+ while ((pEntry = aIter.GetNext()) != NULL)
{
if ( pEntry->GetStart() >= nStartPos )
pEntry->Move(static_cast<SCsCOLROW>(nSize));
@@ -588,7 +725,7 @@ void ScOutlineArray::InsertSpace( SCCOLROW nStartPos, SCSIZE nSize )
}
}
-sal_Bool ScOutlineArray::DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize )
+bool ScOutlineArray::DeleteSpace(SCCOLROW nStartPos, SCSIZE nSize)
{
SCCOLROW nEndPos = nStartPos + nSize - 1;
sal_Bool bNeedSave = false; // Original fuer Undo benoetigt?
@@ -610,11 +747,11 @@ sal_Bool ScOutlineArray::DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize )
pEntry->SetSize( nEntrySize-nSize );
else
{
- bNeedSave = sal_True;
+ bNeedSave = true;
if ( nEntryStart >= nStartPos && nEntryEnd <= nEndPos ) // innen
{
aIter.DeleteLast();
- bChanged = sal_True;
+ bChanged = true;
}
else if ( nEntryStart >= nStartPos ) // rechts ueber
pEntry->SetPosSize( nStartPos, static_cast<SCSIZE>(nEntryEnd-nEndPos) );
@@ -630,7 +767,8 @@ sal_Bool ScOutlineArray::DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize )
return bNeedSave;
}
-bool ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, ScTable& rTable, bool bCol )
+bool ScOutlineArray::ManualAction(
+ SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, const ScTable& rTable, bool bCol)
{
bool bModified = false;
ScSubOutlineIterator aIter( this );
@@ -665,8 +803,8 @@ bool ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bS
void ScOutlineArray::RemoveAll()
{
- for (sal_uInt16 nLevel=0; nLevel<nDepth; nLevel++)
- aCollections[nLevel].FreeAll();
+ for (size_t nLevel = 0; nLevel < nDepth; ++nLevel)
+ aCollections[nLevel].clear();
nDepth = 0;
}
@@ -725,11 +863,14 @@ ScSubOutlineIterator::ScSubOutlineIterator( ScOutlineArray* pOutlineArray ) :
nDepth = pArray->nDepth;
}
-ScSubOutlineIterator::ScSubOutlineIterator( ScOutlineArray* pOutlineArray,
- sal_uInt16 nLevel, sal_uInt16 nEntry ) :
+ScSubOutlineIterator::ScSubOutlineIterator(
+ ScOutlineArray* pOutlineArray, size_t nLevel, size_t nEntry ) :
pArray( pOutlineArray )
{
- ScOutlineEntry* pEntry = (ScOutlineEntry*) pArray->aCollections[nLevel].At(nEntry);
+ const ScOutlineCollection& rColl = pArray->aCollections[nLevel];
+ ScOutlineCollection::const_iterator it = rColl.begin();
+ std::advance(it, nEntry);
+ const ScOutlineEntry* pEntry = it->second;
nStart = pEntry->GetStart();
nEnd = pEntry->GetEnd();
nSubLevel = nLevel + 1;
@@ -739,36 +880,42 @@ ScSubOutlineIterator::ScSubOutlineIterator( ScOutlineArray* pOutlineArray,
ScOutlineEntry* ScSubOutlineIterator::GetNext()
{
- ScOutlineEntry* pEntry;
- sal_Bool bFound = false;
+ ScOutlineEntry* pEntry = NULL;
+ bool bFound = false;
do
{
if (nSubLevel >= nDepth)
return NULL;
- pEntry = (ScOutlineEntry*) pArray->aCollections[nSubLevel].At(nSubEntry);
- if (!pEntry)
+ ScOutlineCollection& rColl = pArray->aCollections[nSubLevel];
+ if (nSubEntry < rColl.size())
{
- nSubEntry = 0;
- ++nSubLevel;
+ ScOutlineCollection::iterator it = rColl.begin();
+ std::advance(it, nSubEntry);
+ pEntry = it->second;
+
+ if (pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd)
+ bFound = true;
+
+ ++nSubEntry;
}
else
{
- if ( pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd )
- bFound = sal_True;
- ++nSubEntry;
+ // Go to the next sub-level.
+ nSubEntry = 0;
+ ++nSubLevel;
}
}
while (!bFound);
return pEntry; // nSubLevel gueltig, wenn pEntry != 0
}
-sal_uInt16 ScSubOutlineIterator::LastLevel() const
+size_t ScSubOutlineIterator::LastLevel() const
{
return nSubLevel;
}
-sal_uInt16 ScSubOutlineIterator::LastEntry() const
+size_t ScSubOutlineIterator::LastEntry() const
{
if (nSubEntry == 0)
{
@@ -792,7 +939,11 @@ void ScSubOutlineIterator::DeleteLast()
}
--nSubEntry;
- pArray->aCollections[nSubLevel].AtFree(nSubEntry);
+ ScOutlineCollection& rColl = pArray->aCollections[nSubLevel];
+ OSL_ASSERT(nSubEntry < rColl.size());
+ ScOutlineCollection::iterator it = rColl.begin();
+ std::advance(it, nSubEntry);
+ rColl.erase(it);
}
diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 6b3eeab..a1ed9b9 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -39,7 +39,6 @@
#include "table.hxx"
#include "scitems.hxx"
-#include "collect.hxx"
#include "attrib.hxx"
#include "cell.hxx"
#include "document.hxx"
diff --git a/sc/source/core/data/table5.cxx b/sc/source/core/data/table5.cxx
index fffd42f..020c721 100644
--- a/sc/source/core/data/table5.cxx
+++ b/sc/source/core/data/table5.cxx
@@ -30,7 +30,6 @@
// INCLUDE ---------------------------------------------------------------
#include "scitems.hxx"
-#include "collect.hxx"
#include "attrib.hxx"
#include "patattr.hxx"
#include "docpool.hxx"
diff --git a/sc/source/core/data/table6.cxx b/sc/source/core/data/table6.cxx
index f4cbe46..381ee2d 100644
--- a/sc/source/core/data/table6.cxx
+++ b/sc/source/core/data/table6.cxx
@@ -36,7 +36,6 @@
#include <editeng/editobj.hxx>
#include "table.hxx"
-#include "collect.hxx"
#include "cell.hxx"
#include "document.hxx"
#include "stlpool.hxx"
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index 1f8f85f..c6638e0 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -53,6 +53,7 @@
#include "globstr.hrc"
#include "rangenam.hxx"
#include "dbdata.hxx"
+#include "collect.hxx"
#include <math.h>
#include <memory>
diff --git a/sc/source/filter/excel/xetable.cxx b/sc/source/filter/excel/xetable.cxx
index d356990..ac8c6ca 100644
--- a/sc/source/filter/excel/xetable.cxx
+++ b/sc/source/filter/excel/xetable.cxx
@@ -1302,8 +1302,8 @@ XclExpOutlineBuffer::XclExpOutlineBuffer( const XclExpRoot& rRoot, bool bRows )
mpScOLArray = bRows ? pOutlineTable->GetRowArray() : pOutlineTable->GetColArray();
if( mpScOLArray )
- for( sal_uInt16 nLevel = 0; nLevel < SC_OL_MAXDEPTH; ++nLevel )
- if( ScOutlineEntry* pEntry = mpScOLArray->GetEntryByPos( nLevel, 0 ) )
+ for( size_t nLevel = 0; nLevel < SC_OL_MAXDEPTH; ++nLevel )
+ if( const ScOutlineEntry* pEntry = mpScOLArray->GetEntryByPos( nLevel, 0 ) )
maLevelInfos[ nLevel ].mnScEndPos = pEntry->GetEnd();
}
@@ -1312,7 +1312,7 @@ void XclExpOutlineBuffer::UpdateColRow( SCCOLROW nScPos )
if( mpScOLArray )
{
// find open level index for passed position
- sal_uInt16 nNewOpenScLevel = 0; // new open level (0-based Calc index)
+ size_t nNewOpenScLevel = 0; // new open level (0-based Calc index)
sal_uInt8 nNewLevel = 0; // new open level (1-based Excel index)
if( mpScOLArray->FindTouchedLevel( nScPos, nScPos, nNewOpenScLevel ) )
@@ -1329,7 +1329,7 @@ void XclExpOutlineBuffer::UpdateColRow( SCCOLROW nScPos )
neighbored groups without gap - therefore check ALL levels). */
if( maLevelInfos[ nScLevel ].mnScEndPos < nScPos )
{
- if( ScOutlineEntry* pEntry = mpScOLArray->GetEntryByPos( nScLevel, nScPos ) )
+ if( const ScOutlineEntry* pEntry = mpScOLArray->GetEntryByPos( nScLevel, nScPos ) )
{
maLevelInfos[ nScLevel ].mnScEndPos = pEntry->GetEnd();
maLevelInfos[ nScLevel ].mbHidden = pEntry->IsHidden();
diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx
index 5e92182..8a8dde7 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -1486,14 +1486,14 @@ void ScXMLExport::GetColumnRowHeader(bool& rHasColumnHeader, table::CellRangeAdd
void ScXMLExport::FillFieldGroup(ScOutlineArray* pFields, ScMyOpenCloseColumnRowGroup* pGroups)
{
- sal_Int32 nDepth(pFields->GetDepth());
- for(sal_Int32 i = 0; i < nDepth; ++i)
+ size_t nDepth = pFields->GetDepth();
+ for (size_t i = 0; i < nDepth; ++i)
{
- sal_Int32 nFields = pFields->GetCount(static_cast<sal_uInt16>(i));
- for (sal_Int32 j = 0; j < nFields; ++j)
+ size_t nFields = pFields->GetCount(i);
+ for (size_t j = 0; j < nFields; ++j)
{
ScMyColumnRowGroup aGroup;
- ScOutlineEntry* pEntry(pFields->GetEntry(static_cast<sal_uInt16>(i), static_cast<sal_uInt16>(j)));
+ const ScOutlineEntry* pEntry = pFields->GetEntry(i, j);
aGroup.nField = pEntry->GetStart();
aGroup.nLevel = static_cast<sal_Int16>(i);
aGroup.bDisplay = !(pEntry->IsHidden());
diff --git a/sc/source/filter/xml/xmltabi.cxx b/sc/source/filter/xml/xmltabi.cxx
index c6c43ec..a5ff146 100644
--- a/sc/source/filter/xml/xmltabi.cxx
+++ b/sc/source/filter/xml/xmltabi.cxx
@@ -398,28 +398,27 @@ void ScXMLTableContext::EndElement()
if (pOutlineTable)
{
ScOutlineArray* pColArray(pOutlineTable->GetColArray());
- sal_Int32 nDepth(pColArray->GetDepth());
- sal_Int32 i;
- for (i = 0; i < nDepth; ++i)
+ size_t nDepth = pColArray->GetDepth();
+ for (size_t i = 0; i < nDepth; ++i)
{
- sal_Int32 nCount(pColArray->GetCount(static_cast<sal_uInt16>(i)));
- for (sal_Int32 j = 0; j < nCount; ++j)
+ size_t nCount = pColArray->GetCount(i);
+ for (size_t j = 0; j < nCount; ++j)
{
- ScOutlineEntry* pEntry(pColArray->GetEntry(static_cast<sal_uInt16>(i), static_cast<sal_uInt16>(j)));
+ const ScOutlineEntry* pEntry = pColArray->GetEntry(i, j);
if (pEntry->IsHidden())
- pColArray->SetVisibleBelow(static_cast<sal_uInt16>(i), static_cast<sal_uInt16>(j), false);
+ pColArray->SetVisibleBelow(i, j, false);
}
}
ScOutlineArray* pRowArray(pOutlineTable->GetRowArray());
nDepth = pRowArray->GetDepth();
- for (i = 0; i < nDepth; ++i)
+ for (size_t i = 0; i < nDepth; ++i)
{
- sal_Int32 nCount(pRowArray->GetCount(static_cast<sal_uInt16>(i)));
- for (sal_Int32 j = 0; j < nCount; ++j)
+ size_t nCount = pRowArray->GetCount(i);
+ for (size_t j = 0; j < nCount; ++j)
{
- ScOutlineEntry* pEntry(pRowArray->GetEntry(static_cast<sal_uInt16>(i), static_cast<sal_uInt16>(j)));
+ const ScOutlineEntry* pEntry = pRowArray->GetEntry(i, j);
if (pEntry->IsHidden())
- pRowArray->SetVisibleBelow(static_cast<sal_uInt16>(i), static_cast<sal_uInt16>(j), false);
+ pRowArray->SetVisibleBelow(i, j, false);
}
}
}
diff --git a/sc/source/ui/dbgui/pfiltdlg.cxx b/sc/source/ui/dbgui/pfiltdlg.cxx
index 1b65585..14f1cf2 100644
--- a/sc/source/ui/dbgui/pfiltdlg.cxx
+++ b/sc/source/ui/dbgui/pfiltdlg.cxx
@@ -43,6 +43,7 @@
#include "dbdata.hxx"
#include "scresid.hxx"
#include "queryentry.hxx"
+#include "collect.hxx"
#include "sc.hrc"
#include "filter.hrc"
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index eee108a..d15ca7a 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -104,7 +104,6 @@
#include "docpool.hxx" // LoadCompleted
#include "progress.hxx"
#include "pntlock.hxx"
-#include "collect.hxx"
#include "docuno.hxx"
#include "appoptio.hxx"
#include "detdata.hxx"
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index 9b1146c..afbbf21 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -47,7 +47,6 @@
#include "viewdata.hxx"
#include "tabvwsh.hxx"
#include "tablink.hxx"
-#include "collect.hxx"
#include "docoptio.hxx"
#include "globstr.hrc"
#include "scmod.hxx"
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 747cb71..96e3c63 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -71,7 +71,6 @@
#include "docsh.hxx"
#include "filter.hxx"
#include "progress.hxx"
-#include "collect.hxx"
#include "cell.hxx"
#include "editutil.hxx"
#include "cellform.hxx"
diff --git a/sc/source/ui/docshell/olinefun.cxx b/sc/source/ui/docshell/olinefun.cxx
index e99ff87..6bc1395 100644
--- a/sc/source/ui/docshell/olinefun.cxx
+++ b/sc/source/ui/docshell/olinefun.cxx
@@ -182,8 +182,8 @@ sal_Bool ScOutlineDocFunc::RemoveOutline( const ScRange& rRange, sal_Bool bColum
ScOutlineArray* pArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
- sal_Bool bRes;
- sal_Bool bSize = false;
+ bool bRes;
+ bool bSize = false;
if ( bColumns )
bRes = pArray->Remove( nStartCol, nEndCol, bSize );
else
@@ -577,9 +577,9 @@ sal_Bool ScOutlineDocFunc::HideMarkedOutlines( const ScRange& rRange, sal_Bool b
if (pTable)
{
- ScOutlineEntry* pEntry;
- sal_uInt16 nColLevel;
- sal_uInt16 nRowLevel;
+ const ScOutlineEntry* pEntry;
+ size_t nColLevel;
+ size_t nRowLevel;
sal_uInt16 nCount;
SCCOLROW nStart;
SCCOLROW nEnd;
diff --git a/sc/source/ui/inc/filtdlg.hxx b/sc/source/ui/inc/filtdlg.hxx
index 865fc1b..e62ca41 100644
--- a/sc/source/ui/inc/filtdlg.hxx
+++ b/sc/source/ui/inc/filtdlg.hxx
@@ -37,6 +37,7 @@
#include "address.hxx"
#include "anyrefdg.hxx"
#include "queryparam.hxx"
+#include "collect.hxx"
#include <deque>
#include <vector>
@@ -51,7 +52,6 @@ class ScRangeData;
class ScViewData;
class ScDocument;
class ScQueryItem;
-class TypedScStrCollection;
class ScFilterDlg : public ScAnyRefDlg
{
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index eb692e1..8e0464e 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -402,7 +402,7 @@ void ScUndoOutlineBlock::Undo()
if (!bShow)
{ // Groesse des ausgeblendeten Blocks
- sal_uInt16 nLevel;
+ size_t nLevel;
pUndoTable->GetColArray()->FindTouchedLevel( nStartCol, nEndCol, nLevel );
pUndoTable->GetColArray()->ExtendBlock( nLevel, nStartCol, nEndCol );
pUndoTable->GetRowArray()->FindTouchedLevel( nStartRow, nEndRow, nLevel );
diff --git a/sc/source/ui/unoobj/linkuno.cxx b/sc/source/ui/unoobj/linkuno.cxx
index 6ba1bdd..db8ec46 100644
--- a/sc/source/ui/unoobj/linkuno.cxx
+++ b/sc/source/ui/unoobj/linkuno.cxx
@@ -38,7 +38,6 @@
#include "convuno.hxx"
#include "docsh.hxx"
#include "docfunc.hxx"
-#include "collect.hxx"
#include "tablink.hxx"
#include "arealink.hxx"
#include "hints.hxx"
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 114ac2e..6ae2d08 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -5233,7 +5233,7 @@ uno::Any ScVbaRange::getShowDetail() throw ( css::uno::RuntimeException)
if( pOutlineArray )
{
SCCOLROW nPos = bColumn ? (SCCOLROW)(thisAddress.EndColumn-1):(SCCOLROW)(thisAddress.EndRow-1);
- ScOutlineEntry* pEntry = pOutlineArray->GetEntryByPos( 0, nPos );
+ const ScOutlineEntry* pEntry = pOutlineArray->GetEntryByPos( 0, nPos );
if( pEntry )
{
bShowDetail = !pEntry->IsHidden();
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index a572aa7..45e3126 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -504,7 +504,7 @@ void ScDBFunc::DoSubTotals( const ScSubTotalParam& rParam, sal_Bool bRecord,
sal_uInt16 nDepth = pRowArray->GetDepth();
for (sal_uInt16 i = 0; i < nDepth; ++i)
{
- sal_Bool bSize;
+ bool bSize;
pRowArray->Remove(aNewParam.nRow1, aNewParam.nRow2, bSize);
}
}
diff --git a/sc/source/ui/view/olinewin.cxx b/sc/source/ui/view/olinewin.cxx
index caadf3f..4557e06 100644
--- a/sc/source/ui/view/olinewin.cxx
+++ b/sc/source/ui/view/olinewin.cxx
@@ -810,8 +810,9 @@ bool ScOutlineWindow::ImplMoveFocusByLevel( bool bForward )
}
else
{
- const ScOutlineEntry* pEntry = pArray->GetEntry( sal::static_int_cast<sal_uInt16>(mnFocusLevel),
- sal::static_int_cast<sal_uInt16>(mnFocusEntry) );
+ const ScOutlineEntry* pEntry = pArray->GetEntry(
+ mnFocusLevel, mnFocusEntry);
+
if ( pEntry )
{
SCCOLROW nStart = pEntry->GetStart();
@@ -824,19 +825,13 @@ bool ScOutlineWindow::ImplMoveFocusByLevel( bool bForward )
{
// next level -> find first child entry
nNewLevel = mnFocusLevel + 1;
- // TODO - change ScOutlineArray interface to size_t usage
- sal_uInt16 nTmpEntry = 0;
- bFound = pArray->GetEntryIndexInRange( sal::static_int_cast<sal_uInt16>(nNewLevel), nStart, nEnd, nTmpEntry );
- nNewEntry = nTmpEntry;
+ bFound = pArray->GetEntryIndexInRange(nNewLevel, nStart, nEnd, nNewEntry);
}
else if ( !bForward && (mnFocusLevel > 0) )
{
// previous level -> find parent entry
nNewLevel = mnFocusLevel - 1;
- // TODO - change ScOutlineArray interface to size_t usage
- sal_uInt16 nTmpEntry = 0;
- bFound = pArray->GetEntryIndex( sal::static_int_cast<sal_uInt16>(nNewLevel), nStart, nTmpEntry );
- nNewEntry = nTmpEntry;
+ bFound = pArray->GetEntryIndex(nNewLevel, nStart, nNewEntry);
}
if ( bFound && IsButtonVisible( nNewLevel, nNewEntry ) )
commit 6fae316672b146937a52eeb6447b08177c26c43b
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 3 14:58:56 2012 -0500
No inlined member methods.
diff --git a/sc/inc/olinetab.hxx b/sc/inc/olinetab.hxx
index 9dcdf0c..4759bef 100644
--- a/sc/inc/olinetab.hxx
+++ b/sc/inc/olinetab.hxx
@@ -47,17 +47,24 @@ class ScOutlineEntry : public ScDataObject
bool bVisible;
public:
- ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize,
- bool bNewHidden = false );
- ScOutlineEntry( const ScOutlineEntry& rEntry );
+ ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNewHidden = false );
+ ScOutlineEntry( const ScOutlineEntry& rEntry );
virtual ScDataObject* Clone() const;
- SCCOLROW GetStart() const { return nStart; }
- SCSIZE GetSize() const { return nSize; }
- SCCOLROW GetEnd() const { return nStart+nSize-1; }
- bool IsHidden() const { return bHidden; } // group hidden
- bool IsVisible() const { return bVisible; } // control visible?
+ SCCOLROW GetStart() const;
+ SCSIZE GetSize() const;
+ SC_DLLPUBLIC SCCOLROW GetEnd() const;
+
+ /**
+ * @return true is the group is hidden, false otherwise.
+ */
+ SC_DLLPUBLIC bool IsHidden() const;
+
+ /**
+ * @return true if the control is visible, false otherwise.
+ */
+ bool IsVisible() const;
void Move( SCsCOLROW nDelta );
void SetSize( SCSIZE nNewSize );
@@ -66,7 +73,6 @@ public:
void SetVisible( bool bNewVisible );
};
-
class ScOutlineCollection : public ScSortedCollection
{
public:
diff --git a/sc/source/core/data/olinetab.cxx b/sc/source/core/data/olinetab.cxx
index 2af2a84..30bf2f3 100644
--- a/sc/source/core/data/olinetab.cxx
+++ b/sc/source/core/data/olinetab.cxx
@@ -65,6 +65,30 @@ ScDataObject* ScOutlineEntry::Clone() const
return new ScOutlineEntry( *this );
}
+SCCOLROW ScOutlineEntry::GetStart() const
+{
+ return nStart;
+}
+
+SCSIZE ScOutlineEntry::GetSize() const
+{
+ return nSize;
+}
+
+SCCOLROW ScOutlineEntry::GetEnd() const
+{
+ return nStart+nSize-1;
+}
+bool ScOutlineEntry::IsHidden() const
+{
+ return bHidden;
+}
+
+bool ScOutlineEntry::IsVisible() const
+{
+ return bVisible;
+}
+
void ScOutlineEntry::Move( SCsCOLROW nDelta )
{
SCCOLROW nNewPos = nStart + nDelta;
commit f0002a68c4dcf99d775d9575deabec18c1bd5852
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 3 14:36:01 2012 -0500
Nobody uses StrData and ScStrCollection now.
diff --git a/sc/inc/collect.hxx b/sc/inc/collect.hxx
index bc4144f..e0d4f8f 100644
--- a/sc/inc/collect.hxx
+++ b/sc/inc/collect.hxx
@@ -109,38 +109,6 @@ public:
sal_Bool operator==(const ScSortedCollection& rCmp) const;
};
-
-
-//------------------------------------------------------------------------
-class StrData : public ScDataObject
-{
-friend class ScStrCollection;
- String aStr;
-public:
- StrData(const String& rStr) : aStr(rStr) {}
- StrData(const StrData& rData) : ScDataObject(), aStr(rData.aStr) {}
- virtual ScDataObject* Clone() const;
- const String& GetString() const { return aStr; }
- // SetString only, if StrData is not in ScStrCollection! for example
- // for Searcher
- void SetString( const String& rNew ) { aStr = rNew; }
-};
-
-class SvStream;
-
-class SC_DLLPUBLIC ScStrCollection : public ScSortedCollection
-{
-public:
- ScStrCollection(sal_uInt16 nLim = 4, sal_uInt16 nDel = 4, sal_Bool bDup = false) :
- ScSortedCollection ( nLim, nDel, bDup ) {}
- ScStrCollection(const ScStrCollection& rScStrCollection) :
- ScSortedCollection ( rScStrCollection ) {}
-
- virtual ScDataObject* Clone() const;
- StrData* operator[]( const sal_uInt16 nIndex) const {return (StrData*)At(nIndex);}
- virtual short Compare(ScDataObject* pKey1, ScDataObject* pKey2) const;
-};
-
//------------------------------------------------------------------------
// TypedScStrCollection: wie ScStrCollection, nur, dass Zahlen vor Strings
// sortiert werden
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 86b2feb..b402ac8 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -118,7 +118,6 @@ class ScTokenArray;
class ScValidationData;
class ScValidationDataList;
class ScViewOptions;
-class ScStrCollection;
class TypedScStrCollection;
class ScChangeTrack;
class ScEditEngineDefaulter;
diff --git a/sc/inc/dpdimsave.hxx b/sc/inc/dpdimsave.hxx
index 38c8cb0..7820ce2 100644
--- a/sc/inc/dpdimsave.hxx
+++ b/sc/inc/dpdimsave.hxx
@@ -39,7 +39,6 @@
class ScDPGroupTableData;
class ScDPGroupDimension;
class ScDPObject;
-class ScStrCollection;
class SvNumberFormatter;
class ScDPSaveGroupDimension;
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 251e515..ca1dd9e 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -65,7 +65,6 @@ class ScPivotCollection;
struct ScPivotParam;
struct ScImportSourceDesc;
class ScSheetSourceDesc;
-class ScStrCollection;
class TypedScStrCollection;
struct PivotField;
class ScDPCacheTable;
diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index 56bc61e..97f931e 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -51,7 +51,6 @@ namespace com { namespace sun { namespace star { namespace sheet {
class Rectangle;
class SvStream;
class ScDocument;
-class ScStrCollection;
struct ScDPOutLevelData;
diff --git a/sc/source/core/tool/collect.cxx b/sc/source/core/tool/collect.cxx
index 23b6cca..f0ba178 100644
--- a/sc/source/core/tool/collect.cxx
+++ b/sc/source/core/tool/collect.cxx
@@ -303,33 +303,6 @@ sal_Bool ScSortedCollection::IsEqual(ScDataObject* pKey1, ScDataObject* pKey2) c
}
//------------------------------------------------------------------------
-
-ScDataObject* StrData::Clone() const
-{
- return new StrData(*this);
-}
-
-//------------------------------------------------------------------------
-
-short ScStrCollection::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const
-{
- StringCompare eComp = ((StrData*)pKey1)->aStr.CompareTo(((StrData*)pKey2)->aStr);
- if (eComp == COMPARE_EQUAL)
- return 0;
- else if (eComp == COMPARE_LESS)
- return -1;
- else
- return 1;
-}
-
-//------------------------------------------------------------------------
-
-ScDataObject* ScStrCollection::Clone() const
-{
- return new ScStrCollection(*this);
-}
-
-//------------------------------------------------------------------------
// TypedScStrCollection
//------------------------------------------------------------------------
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index 7c02000..9f201e3 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -42,7 +42,6 @@ class ScDBData;
class ScDBCollection;
class ScDPObject;
class ScDPSaveData;
-class ScStrCollection;
struct ScDPNumGroupInfo;
struct ScSubTotalParam;
commit bd3919c03dc1e5de2eb986321477bfe4a9b93cf4
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 3 14:23:19 2012 -0500
No more ScStrCollection in pivot table code.
diff --git a/sc/inc/dpdimsave.hxx b/sc/inc/dpdimsave.hxx
index 3c377c0..38c8cb0 100644
--- a/sc/inc/dpdimsave.hxx
+++ b/sc/inc/dpdimsave.hxx
@@ -34,6 +34,7 @@
#include <tools/string.hxx>
#include "dpgroup.hxx" // for ScDPNumGroupInfo
#include "scdllapi.h"
+#include "dptypes.hxx"
class ScDPGroupTableData;
class ScDPGroupDimension;
@@ -107,7 +108,7 @@ public:
void RemoveFromGroups( const String& rItemName );
void RemoveGroup( const String& rGroupName );
bool IsEmpty() const;
- bool HasOnlyHidden( const ScStrCollection& rVisible );
+ bool HasOnlyHidden(const ScDPUniqueStringSet& rVisible);
long GetGroupCount() const;
const ScDPSaveGroupItem* GetGroupByIndex( long nIndex ) const;
diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index f7126b1..251e515 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -34,6 +34,7 @@
#include "address.hxx"
#include "collect.hxx"
#include "dpoutput.hxx"
+#include "dptypes.hxx"
#include "pivot.hxx"
#include <com/sun/star/sheet/XDimensionsSupplier.hpp>
@@ -191,7 +192,7 @@ public:
std::vector< ScDPGetPivotDataField >& rFilters,
const ::rtl::OUString& rFilterList );
- void GetMemberResultNames( ScStrCollection& rNames, long nDimension );
+ void GetMemberResultNames(ScDPUniqueStringSet& rNames, long nDimension);
void FillPageList( TypedScStrCollection& rStrings, long nField );
diff --git a/sc/inc/dpoutput.hxx b/sc/inc/dpoutput.hxx
index d1d07e2..56bc61e 100644
--- a/sc/inc/dpoutput.hxx
+++ b/sc/inc/dpoutput.hxx
@@ -39,6 +39,8 @@
#include "address.hxx"
#include "dpcachetable.hxx"
+#include "dptypes.hxx"
+
#include <vector>
namespace com { namespace sun { namespace star { namespace sheet {
@@ -160,7 +162,7 @@ public:
Rectangle& rPosRect, sal_uInt16& rOrient, long& rDimPos );
sal_Bool IsFilterButton( const ScAddress& rPos );
- void GetMemberResultNames( ScStrCollection& rNames, long nDimension );
+ void GetMemberResultNames(ScDPUniqueStringSet& rNames, long nDimension);
void SetHeaderLayout(bool bUseGrid);
bool GetHeaderLayout() const;
diff --git a/sc/inc/dptypes.hxx b/sc/inc/dptypes.hxx
new file mode 100644
index 0000000..da49c9a
--- /dev/null
+++ b/sc/inc/dptypes.hxx
@@ -0,0 +1,39 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Kohei Yoshida <kohei.yoshida at suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef __SC_DPTYPES_HXX__
+#define __SC_DPTYPES_HXX__
+
+#include "rtl/ustring.hxx"
+
+#include <boost/unordered_set.hpp>
+
+typedef boost::unordered_set<rtl::OUString, rtl::OUStringHash> ScDPUniqueStringSet;
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx
index 45bff8f..b6e0cf1 100644
--- a/sc/source/core/data/dpdimsave.cxx
+++ b/sc/source/core/data/dpdimsave.cxx
@@ -247,17 +247,15 @@ bool ScDPSaveGroupDimension::IsEmpty() const
return aGroups.empty();
}
-bool ScDPSaveGroupDimension::HasOnlyHidden( const ScStrCollection& rVisible )
+bool ScDPSaveGroupDimension::HasOnlyHidden(const ScDPUniqueStringSet& rVisible)
{
// check if there are only groups that don't appear in the list of visible names
bool bAllHidden = true;
- for ( ScDPSaveGroupItemVec::const_iterator aIter(aGroups.begin()); aIter != aGroups.end() && bAllHidden; aIter++ )
+ for (ScDPSaveGroupItemVec::const_iterator aIter = aGroups.begin(); aIter != aGroups.end() && bAllHidden; ++aIter)
{
- StrData aSearch( aIter->GetGroupName() );
- sal_uInt16 nCollIndex;
- if ( rVisible.Search( &aSearch, nCollIndex ) )
- bAllHidden = false; // found one that is visible
+ if (rVisible.count(aIter->GetGroupName()) > 0)
+ bAllHidden = false;
}
return bAllHidden;
}
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index d5ac788..f827973 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -1121,11 +1121,11 @@ bool ScDPObject::GetHeaderDrag( const ScAddress& rPos, bool bMouseLeft, bool bMo
return pOutput->GetHeaderDrag( rPos, bMouseLeft, bMouseTop, nDragDim, rPosRect, rOrient, rDimPos );
}
-void ScDPObject::GetMemberResultNames( ScStrCollection& rNames, long nDimension )
+void ScDPObject::GetMemberResultNames(ScDPUniqueStringSet& rNames, long nDimension)
{
CreateOutput(); // create xSource and pOutput if not already done
- pOutput->GetMemberResultNames( rNames, nDimension ); // used only with table data -> level not needed
+ pOutput->GetMemberResultNames(rNames, nDimension); // used only with table data -> level not needed
}
bool lcl_Dequote( const String& rSource, xub_StrLen nStartPos, xub_StrLen& rEndPos, String& rResult )
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 32179e3..103fab1 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -1170,7 +1170,7 @@ long ScDPOutput::GetHeaderRows()
return nPageFieldCount + ( bDoFilter ? 1 : 0 );
}
-void ScDPOutput::GetMemberResultNames( ScStrCollection& rNames, long nDimension )
+void ScDPOutput::GetMemberResultNames(ScDPUniqueStringSet& rNames, long nDimension)
{
// Return the list of all member names in a dimension's MemberResults.
// Only the dimension has to be compared because this is only used with table data,
@@ -1208,11 +1208,7 @@ void ScDPOutput::GetMemberResultNames( ScStrCollection& rNames, long nDimension
for (long nItem=0; nItem<nResultCount; nItem++)
{
if ( pArray[nItem].Flags & sheet::MemberResultFlags::HASMEMBER )
- {
- StrData* pNew = new StrData( pArray[nItem].Name );
- if ( !rNames.Insert( pNew ) )
- delete pNew;
- }
+ rNames.insert(pArray[nItem].Name);
}
}
}
diff --git a/sc/source/ui/inc/dbfunc.hxx b/sc/source/ui/inc/dbfunc.hxx
index 67344c1..7c02000 100644
--- a/sc/source/ui/inc/dbfunc.hxx
+++ b/sc/source/ui/inc/dbfunc.hxx
@@ -30,6 +30,7 @@
#define SC_DBFUNC_HXX
#include "viewfunc.hxx"
+#include "dptypes.hxx"
namespace com { namespace sun { namespace star { namespace sheet {
struct DataPilotFieldFilter;
@@ -50,7 +51,7 @@ struct ScSubTotalParam;
class ScDBFunc : public ScViewFunc
{
private:
- void GetSelectedMemberList( ScStrCollection& rEntries, long& rDimension );
+ void GetSelectedMemberList(ScDPUniqueStringSet& rEntries, long& rDimension);
public:
ScDBFunc( Window* pParent, ScDocShell& rDocSh, ScTabViewShell* pViewShell );
@@ -89,8 +90,8 @@ public:
const ScDPObject& rSource, sal_Bool bApi = false );
void DeletePivotTable();
void RecalcPivotTable();
- sal_Bool HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts );
- sal_Bool HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo );
+ bool HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts );
+ bool HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo );
void GroupDataPilot();
void DateGroupDataPilot( const ScDPNumGroupInfo& rInfo, sal_Int32 nParts );
void NumGroupDataPilot( const ScDPNumGroupInfo& rInfo );
@@ -100,8 +101,8 @@ public:
bool DataPilotSort( const ScAddress& rPos, bool bAscending, sal_uInt16* pUserListId = NULL );
sal_Bool DataPilotMove( const ScRange& rSource, const ScAddress& rDest );
- sal_Bool HasSelectionForDrillDown( sal_uInt16& rOrientation );
- void SetDataPilotDetails( sal_Bool bShow, const String* pNewDimensionName = NULL );
+ bool HasSelectionForDrillDown( sal_uInt16& rOrientation );
+ void SetDataPilotDetails(bool bShow, const rtl::OUString* pNewDimensionName = NULL);
void ShowDataPilotSourceData( ScDPObject& rDPObj,
const ::com::sun::star::uno::Sequence< ::com::sun::star::sheet::DataPilotFieldFilter >& rFilters );
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index f482caa..e9a574f 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -963,8 +963,8 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
OSL_ENSURE(pDlg, "Dialog create fail!");
if ( pDlg->Execute() == RET_OK )
{
- String aNewDimName( pDlg->GetDimensionName() );
- pTabViewShell->SetDataPilotDetails( sal_True, &aNewDimName );
+ rtl::OUString aNewDimName( pDlg->GetDimensionName() );
+ pTabViewShell->SetDataPilotDetails( true, &aNewDimName );
}
}
else if ( !pDPObj->IsServiceData() &&
@@ -973,7 +973,7 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
aFilters ) )
pTabViewShell->ShowDataPilotSourceData( *pDPObj, aFilters );
else
- pTabViewShell->SetDataPilotDetails( sal_True );
+ pTabViewShell->SetDataPilotDetails(true);
}
else
pTabViewShell->ShowMarkedOutlines();
diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx
index 086b4ff..a572aa7 100644
--- a/sc/source/ui/view/dbfunc3.cxx
+++ b/sc/source/ui/view/dbfunc3.cxx
@@ -729,7 +729,7 @@ void ScDBFunc::RecalcPivotTable()
ErrorMessage(STR_PIVOT_NOTFOUND);
}
-void ScDBFunc::GetSelectedMemberList( ScStrCollection& rEntries, long& rDimension )
+void ScDBFunc::GetSelectedMemberList(ScDPUniqueStringSet& rEntries, long& rDimension)
{
ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
@@ -781,25 +781,21 @@ void ScDBFunc::GetSelectedMemberList( ScStrCollection& rEntries, long& rDimensio
// accept any part of a member description, also subtotals,
// but don't stop if empty parts are contained
if ( aData.Flags & sheet::MemberResultFlags::HASMEMBER )
- {
- StrData* pNew = new StrData( aData.MemberName );
- if ( !rEntries.Insert( pNew ) )
- delete pNew;
- }
+ rEntries.insert(aData.MemberName);
}
}
}
rDimension = nStartDimension; // dimension from which the found members came
if (!bContinue)
- rEntries.FreeAll(); // remove all if not valid
+ rEntries.clear(); // remove all if not valid
}
-sal_Bool ScDBFunc::HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts )
+bool ScDBFunc::HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int32& rParts )
{
// determine if the date group dialog has to be shown for the current selection
- sal_Bool bFound = false;
+ bool bFound = false;
SCCOL nCurX = GetViewData()->GetCurX();
SCROW nCurY = GetViewData()->GetCurY();
@@ -809,11 +805,11 @@ sal_Bool ScDBFunc::HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int
ScDPObject* pDPObj = pDoc->GetDPAtCursor( nCurX, nCurY, nTab );
if ( pDPObj )
{
- ScStrCollection aEntries;
+ ScDPUniqueStringSet aEntries;
long nSelectDimension = -1;
GetSelectedMemberList( aEntries, nSelectDimension );
- if ( aEntries.GetCount() > 0 )
+ if (!aEntries.empty())
{
bool bIsDataLayout;
OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
@@ -908,11 +904,11 @@ sal_Bool ScDBFunc::HasSelectionForDateGroup( ScDPNumGroupInfo& rOldInfo, sal_Int
return bFound;
}
-sal_Bool ScDBFunc::HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo )
+bool ScDBFunc::HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo )
{
// determine if the numeric group dialog has to be shown for the current selection
- sal_Bool bFound = false;
+ bool bFound = false;
SCCOL nCurX = GetViewData()->GetCurX();
SCROW nCurY = GetViewData()->GetCurY();
@@ -922,11 +918,11 @@ sal_Bool ScDBFunc::HasSelectionForNumGroup( ScDPNumGroupInfo& rOldInfo )
ScDPObject* pDPObj = pDoc->GetDPAtCursor( nCurX, nCurY, nTab );
if ( pDPObj )
{
- ScStrCollection aEntries;
+ ScDPUniqueStringSet aEntries;
long nSelectDimension = -1;
GetSelectedMemberList( aEntries, nSelectDimension );
- if ( aEntries.GetCount() > 0 )
+ if (!aEntries.empty())
{
bool bIsDataLayout;
OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
@@ -982,11 +978,11 @@ void ScDBFunc::DateGroupDataPilot( const ScDPNumGroupInfo& rInfo, sal_Int32 nPar
GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
if ( pDPObj )
{
- ScStrCollection aEntries;
+ ScDPUniqueStringSet aEntries;
long nSelectDimension = -1;
GetSelectedMemberList( aEntries, nSelectDimension );
- if ( aEntries.GetCount() > 0 )
+ if (!aEntries.empty())
{
bool bIsDataLayout;
OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
@@ -1112,11 +1108,11 @@ void ScDBFunc::NumGroupDataPilot( const ScDPNumGroupInfo& rInfo )
GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
if ( pDPObj )
{
- ScStrCollection aEntries;
+ ScDPUniqueStringSet aEntries;
long nSelectDimension = -1;
GetSelectedMemberList( aEntries, nSelectDimension );
- if ( aEntries.GetCount() > 0 )
+ if (!aEntries.empty())
{
bool bIsDataLayout;
OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
@@ -1156,11 +1152,11 @@ void ScDBFunc::GroupDataPilot()
GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
if ( pDPObj )
{
- ScStrCollection aEntries;
+ ScDPUniqueStringSet aEntries;
long nSelectDimension = -1;
GetSelectedMemberList( aEntries, nSelectDimension );
- if ( aEntries.GetCount() > 0 )
+ if (!aEntries.empty())
{
bool bIsDataLayout;
OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
@@ -1183,13 +1179,12 @@ void ScDBFunc::GroupDataPilot()
// remove the selected items from their groups
// (empty groups are removed, too)
- sal_uInt16 nEntryCount = aEntries.GetCount();
- sal_uInt16 nEntry;
if ( pGroupDimension )
{
- for (nEntry=0; nEntry<nEntryCount; nEntry++)
+ ScDPUniqueStringSet::const_iterator it = aEntries.begin(), itEnd = aEntries.end();
+ for (; it != itEnd; ++it)
{
- String aEntryName = aEntries[nEntry]->GetString();
+ const rtl::OUString& aEntryName = *it;
if ( pBaseGroupDim )
{
// for each selected (intermediate) group, remove all its items
@@ -1228,9 +1223,7 @@ void ScDBFunc::GroupDataPilot()
{
const ScDPSaveGroupItem* pBaseGroup = pBaseGroupDim->GetGroupByIndex( nGroup );
- StrData aStrData( pBaseGroup->GetGroupName() );
- sal_uInt16 nCollIndex;
- if ( !aEntries.Search( &aStrData, nCollIndex ) ) //! ignore case?
+ if (!aEntries.count(pBaseGroup->GetGroupName()))
{
// add an additional group for each item that is not in the selection
ScDPSaveGroupItem aGroup( pBaseGroup->GetGroupName() );
@@ -1245,9 +1238,10 @@ void ScDBFunc::GroupDataPilot()
//! localized prefix string
String aGroupName = pGroupDimension->CreateGroupName( String::CreateFromAscii("Group") );
ScDPSaveGroupItem aGroup( aGroupName );
- for (nEntry=0; nEntry<nEntryCount; nEntry++)
+ ScDPUniqueStringSet::const_iterator it = aEntries.begin(), itEnd = aEntries.end();
+ for (; it != itEnd; ++it)
{
- String aEntryName = aEntries[nEntry]->GetString();
+ const rtl::OUString& aEntryName = *it;
if ( pBaseGroupDim )
{
// for each selected (intermediate) group, add all its items
@@ -1300,11 +1294,11 @@ void ScDBFunc::UngroupDataPilot()
GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
if ( pDPObj )
{
- ScStrCollection aEntries;
+ ScDPUniqueStringSet aEntries;
long nSelectDimension = -1;
GetSelectedMemberList( aEntries, nSelectDimension );
- if ( aEntries.GetCount() > 0 )
+ if (!aEntries.empty())
{
bool bIsDataLayout;
OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
@@ -1329,19 +1323,17 @@ void ScDBFunc::UngroupDataPilot()
}
else if ( pGroupDim )
{
- sal_uInt16 nEntryCount = aEntries.GetCount();
- for (sal_uInt16 nEntry=0; nEntry<nEntryCount; nEntry++)
- {
- String aEntryName = aEntries[nEntry]->GetString();
- pGroupDim->RemoveGroup( aEntryName );
- }
+ ScDPUniqueStringSet::const_iterator it = aEntries.begin(), itEnd = aEntries.end();
+ for (; it != itEnd; ++it)
+ pGroupDim->RemoveGroup(*it);
+
// remove group dimension if empty
bool bEmptyDim = pGroupDim->IsEmpty();
if ( !bEmptyDim )
{
// If all remaining groups in the dimension aren't shown, remove
// the dimension too, as if it was completely empty.
- ScStrCollection aVisibleEntries;
+ ScDPUniqueStringSet aVisibleEntries;
pDPObj->GetMemberResultNames( aVisibleEntries, nSelectDimension );
bEmptyDim = pGroupDim->HasOnlyHidden( aVisibleEntries );
}
@@ -1962,19 +1954,19 @@ sal_Bool ScDBFunc::DataPilotMove( const ScRange& rSource, const ScAddress& rDest
return bRet;
}
-sal_Bool ScDBFunc::HasSelectionForDrillDown( sal_uInt16& rOrientation )
+bool ScDBFunc::HasSelectionForDrillDown( sal_uInt16& rOrientation )
{
- sal_Bool bRet = false;
+ bool bRet = false;
ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
if ( pDPObj )
{
- ScStrCollection aEntries;
+ ScDPUniqueStringSet aEntries;
long nSelectDimension = -1;
GetSelectedMemberList( aEntries, nSelectDimension );
- if ( aEntries.GetCount() > 0 )
+ if (!aEntries.empty())
{
bool bIsDataLayout;
OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
@@ -1989,7 +1981,7 @@ sal_Bool ScDBFunc::HasSelectionForDrillDown( sal_uInt16& rOrientation )
if ( pDim == pInner )
{
rOrientation = nDimOrient;
- bRet = sal_True;
+ bRet = true;
}
}
}
@@ -1999,17 +1991,17 @@ sal_Bool ScDBFunc::HasSelectionForDrillDown( sal_uInt16& rOrientation )
return bRet;
}
-void ScDBFunc::SetDataPilotDetails( sal_Bool bShow, const String* pNewDimensionName )
+void ScDBFunc::SetDataPilotDetails(bool bShow, const rtl::OUString* pNewDimensionName)
{
ScDPObject* pDPObj = GetViewData()->GetDocument()->GetDPAtCursor( GetViewData()->GetCurX(),
GetViewData()->GetCurY(), GetViewData()->GetTabNo() );
if ( pDPObj )
{
- ScStrCollection aEntries;
+ ScDPUniqueStringSet aEntries;
long nSelectDimension = -1;
GetSelectedMemberList( aEntries, nSelectDimension );
- if ( aEntries.GetCount() > 0 )
+ if (!aEntries.empty())
{
bool bIsDataLayout;
OUString aDimName = pDPObj->GetDimName( nSelectDimension, bIsDataLayout );
@@ -2055,23 +2047,22 @@ void ScDBFunc::SetDataPilotDetails( sal_Bool bShow, const String* pNewDimensionN
// Hide details for all visible members (selected are changed below).
//! Use all members from source level instead (including non-visible)?
- ScStrCollection aVisibleEntries;
+ ScDPUniqueStringSet aVisibleEntries;
pDPObj->GetMemberResultNames( aVisibleEntries, nSelectDimension );
- sal_uInt16 nVisCount = aVisibleEntries.GetCount();
- for (sal_uInt16 nVisPos=0; nVisPos<nVisCount; nVisPos++)
+ ScDPUniqueStringSet::const_iterator it = aVisibleEntries.begin(), itEnd = aVisibleEntries.end();
+ for (; it != itEnd; ++it)
{
- String aVisName = aVisibleEntries[nVisPos]->GetString();
+ const rtl::OUString& aVisName = *it;
ScDPSaveMember* pMember = pDim->GetMemberByName( aVisName );
pMember->SetShowDetails( false );
}
}
- sal_uInt16 nEntryCount = aEntries.GetCount();
- for (sal_uInt16 nEntry=0; nEntry<nEntryCount; nEntry++)
+ ScDPUniqueStringSet::const_iterator it = aEntries.begin(), itEnd = aEntries.end();
+ for (; it != itEnd; ++it)
{
- String aEntryName = aEntries[nEntry]->GetString();
- ScDPSaveMember* pMember = pDim->GetMemberByName( aEntryName );
+ ScDPSaveMember* pMember = pDim->GetMemberByName(*it);
pMember->SetShowDetails( bShow );
}
commit 1e27efd970e2d2ec1bb5b5b99717c58b7653616e
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Feb 3 13:45:49 2012 -0500
More on ScStrCollection/StrData elimination.
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 7454882..eee108a 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -2204,10 +2204,10 @@ sal_Bool ScDocShell::ConvertTo( SfxMedium &rMed )
WaitObject aWait( GetActiveDialogParent() );
// HACK damit Sba geoffnetes TempFile ueberschreiben kann
rMed.CloseOutStream();
- sal_Bool bHasMemo = false;
+ bool bHasMemo = false;
- sal_uLong eError = DBaseExport( rMed.GetPhysicalName(),
- ScGlobal::GetCharsetValue(sCharSet), bHasMemo );
+ sal_uLong eError = DBaseExport(
+ rMed.GetPhysicalName(), ScGlobal::GetCharsetValue(sCharSet), bHasMemo);
if ( eError != eERR_OK && (eError & ERRCODE_WARNING_MASK) )
{
diff --git a/sc/source/ui/docshell/docsh8.cxx b/sc/source/ui/docshell/docsh8.cxx
index 4c81cc0..747cb71 100644
--- a/sc/source/ui/docshell/docsh8.cxx
+++ b/sc/source/ui/docshell/docsh8.cxx
@@ -87,6 +87,7 @@
#include "docparam.hxx"
#include <vector>
+#include <boost/unordered_set.hpp>
using namespace com::sun::star;
using ::std::vector;
@@ -480,28 +481,27 @@ sal_uLong ScDocShell::DBaseImport( const String& rFullFileName, CharSet eCharSet
return nErr;
}
-// -----------------------------------------------------------------------
+namespace {
-inline sal_Bool IsAsciiDigit( sal_Unicode c )
+inline bool IsAsciiDigit( sal_Unicode c )
{
return 0x30 <= c && c <= 0x39;
}
-inline sal_Bool IsAsciiAlpha( sal_Unicode c )
+inline bool IsAsciiAlpha( sal_Unicode c )
{
... etc. - the rest is truncated
More information about the Libreoffice-commits
mailing list