diff options
35 files changed, 472 insertions, 331 deletions
diff --git a/sc/inc/chartlis.hxx b/sc/inc/chartlis.hxx index 9707971910c1..c602f242a062 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 b64804374f83..4d3dccbd6bc6 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 9564e338eb51..16b86983f4b7 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 695586f42874..7927b1a91162 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 ca1dd9ea2e57..79b5a67a0345 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 4759bef70990..6a542f3b8c97 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 705f794a1fa7..11717374dc96 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 53e9ec8f0a8a..90edb8d73c6c 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 2b000fb1e63a..024a3039f5aa 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 b97b0dea0cde..865820a1e0f6 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 3dd82476278b..7888331deafa 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 f8279730b080..7458fca8e2ba 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 103fab1ee95a..e43d70632ad0 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 576beb524249..c67c3b9dc258 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 7891eaa74c97..40a0d439e5da 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 769319771889..8b9e4e0bb8af 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 30bf2f32d053..0dae8607a0cb 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 6b3eeab4ae1d..a1ed9b97a852 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 fffd42fa36e5..020c721aa815 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 f4cbe46ecd98..381ee2d64cab 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 1f8f85f539ce..c6638e01479c 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 d35699006140..ac8c6caefa9a 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 5e92182207b9..8a8dde71172f 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 c6c43ec34255..a5ff14610161 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 1b65585df1e8..14f1cf29f499 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 eee108a1c110..d15ca7a867f8 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 9b1146caa8b7..afbbf21b934e 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 747cb71f5f11..96e3c63d44b6 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 e99ff87778e6..6bc139526c7b 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 865fc1b6a31c..e62ca411614a 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 eb692e1f921b..8e0464e3db1c 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 6ba1bddbd21d..db8ec46793ab 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 114ac2e63c5a..6ae2d0820d21 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 a572aa763321..45e312631256 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 caadf3fbb54b..4557e068e2a8 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 ) ) |