24#include <osl/diagnose.h>
29 bHidden ( bNewHidden ),
35 nStart ( rEntry.nStart ),
36 nSize ( rEntry.nSize ),
37 bHidden ( rEntry.bHidden ),
52 OSL_FAIL(
"OutlineEntry < 0");
64 OSL_FAIL(
"ScOutlineEntry Size == 0");
86 const char*
const pSep =
":";
87 return OString::number(
nStart) + pSep + OString::number(
nSize) +
106 m_Entries.insert(std::make_pair(nStart, rEntry));
147 const char*
const pGroupEntrySep =
",";
148 for (
const auto& rKeyValuePair :
m_Entries)
149 aOutput += rKeyValuePair.second.dumpAsString() + pGroupEntrySep;
158 nDepth( rArray.nDepth )
160 for (
size_t nLevel = 0; nLevel <
nDepth; ++nLevel)
163 for (
const auto& rEntry : rColl)
172 SCCOLROW nSearchPos,
size_t& rFindLevel,
size_t& rFindIndex,
175 rFindLevel = rFindIndex = 0;
180 for (
size_t nLevel = 0; nLevel < nMaxLevel; ++nLevel)
184 for (
auto& rEntry : *pCollect)
187 if (pEntry->
GetStart() <= nSearchPos && pEntry->
GetEnd() >= nSearchPos)
189 rFindLevel = nLevel + 1;
200 rSizeChanged =
false;
202 size_t nStartLevel, nEndLevel, nStartIndex, nEndIndex;
207 FindEntry( nStartCol, nStartLevel, nStartIndex );
208 FindEntry( nEndCol, nEndLevel, nEndIndex );
209 nFindMax = std::max(nStartLevel,nEndLevel);
214 if (nStartLevel == nEndLevel && nStartIndex == nEndIndex && nStartLevel <
SC_OL_MAXDEPTH)
217 if (!bFound && nFindMax>0)
223 std::advance(it, nStartIndex);
224 if (it->second.GetStart() == nStartCol)
225 FindEntry(nStartCol, nStartLevel, nStartIndex, nFindMax);
231 std::advance(it, nEndIndex);
232 if (it->second.GetEnd() == nEndCol)
233 FindEntry(nEndCol, nEndLevel, nEndIndex, nFindMax);
238 while ( !bFound && bCont );
243 size_t nLevel = nStartLevel;
246 bool bNeedSize =
false;
249 for (
size_t nMoveLevel =
nDepth-1; nMoveLevel >= nLevel; --nMoveLevel)
257 if (nEntryStart >= nStartCol && nEntryStart <= nEndCol)
261 rSizeChanged =
false;
265 it = rColl.
erase(it);
266 if (nMoveLevel ==
nDepth - 1)
289 ScOutlineEntry aNewEntry(nStartCol, nEndCol+1-nStartCol, bHidden);
302 for (
size_t nLevel = 0; nLevel <
nDepth; ++nLevel)
305 for (
const auto& rEntry : *pCollect)
311 if ( ( nBlockStart>=nStart && nBlockStart<=nEnd ) ||
312 ( nBlockEnd >=nStart && nBlockEnd <=nEnd ) )
327 OSL_FAIL(
"PromoteSub with Level 0");
331 for (
size_t nLevel = nStartLevel; nLevel <
nDepth; ++nLevel)
340 if (nStart >= nStartPos && nEnd <= nEndPos)
344 it = rColl.
erase(it);
358 if (nStart >= nStartPos && nEnd <= nEndPos)
362 it = rColl.
erase(it);
375 bool bChanged =
false;
408 if (nBlockStart <= nEnd && nBlockEnd >= nStart)
413 itEnd = pCollect->
end();
471 [&
nPos](
const auto& rEntry) {
472 const ScOutlineEntry *const pEntry = &rEntry.second;
473 return pEntry->GetStart() <= nPos && nPos <= pEntry->GetEnd();
475 if (it != rColl.
end())
489 [&
nPos](
const auto& rEntry) {
490 const ScOutlineEntry *const p = &rEntry.second;
491 return p->GetStart() <= nPos && nPos <= p->GetEnd();
493 if (it != rColl.
end())
495 rnIndex = std::distance(rColl.
begin(), it);
502 size_t nLevel,
SCCOLROW nBlockStart,
SCCOLROW nBlockEnd,
size_t& rnIndex)
const
510 [&nBlockStart, &nBlockEnd](
const auto& rEntry) {
511 const ScOutlineEntry *const p = &rEntry.second;
512 return nBlockStart <= p->GetStart() && p->GetEnd() <= nBlockEnd;
514 if (it != rColl.
end())
516 rnIndex = std::distance(rColl.
begin(), it);
523 size_t nLevel,
size_t nEntry,
bool bValue,
bool bSkipHidden)
532 for (
size_t nSubLevel = nLevel+1; nSubLevel <
nDepth; ++nSubLevel)
536 for (
auto& rEntry : rColl)
539 if (
p->GetStart() >= nStart &&
p->GetEnd() <= nEnd)
541 p->SetVisible(bValue);
542 if (bSkipHidden && !
p->IsHidden())
561 rStart = it->second.GetStart();
562 std::advance(it, rColl.
size()-1);
563 rEnd = it->second.GetEnd();
575 for (
const auto& rEntry : rColl)
581 if (rBlkStart <= nEnd && rBlkEnd >= nStart)
583 if (nStart < rBlkStart)
598 std::advance(it, rColl.
size()-1);
599 SCCOLROW nEnd = it->second.GetEnd();
600 return sal::static_int_cast<SCCOLROW>(nEnd+nSize) <= nMaxVal;
607 while ((pEntry = aIter.
GetNext()) !=
nullptr)
609 if ( pEntry->
GetStart() >= nStartPos )
616 if ( nEnd >= nStartPos || ( nEnd+1 >= nStartPos && !pEntry->
IsHidden() ) )
628 SCCOLROW nEndPos = nStartPos + nSize - 1;
629 bool bNeedSave =
false;
630 bool bChanged =
false;
634 while((pEntry=aIter.
GetNext())!=
nullptr)
640 if ( nEntryEnd >= nStartPos )
642 if ( nEntryStart > nEndPos )
644 else if ( nEntryStart < nStartPos && nEntryEnd >= nEndPos )
645 pEntry->
SetSize( nEntrySize-nSize );
649 if ( nEntryStart >= nStartPos && nEntryEnd <= nEndPos )
654 else if ( nEntryStart >= nStartPos )
657 pEntry->
SetSize(
static_cast<SCSIZE>(nStartPos-nEntryStart) );
671 bool bModified =
false;
674 while((pEntry=aIter.
GetNext())!=
nullptr)
679 if (nEntryEnd>=nStartPos && nEntryStart<=nEndPos)
686 bool bAllHidden = (nEntryEnd <= nEnd && nEnd <
687 ::std::numeric_limits<SCCOLROW>::max());
689 bool bToggle = ( bShow != bAllHidden );
704 for (
size_t nLevel = 0; nLevel <
nDepth; ++nLevel)
714 while((pEntry=aIter.
GetNext())!=
nullptr)
723 bool bAllHidden = (nEntryEnd <= nEnd && nEnd <
724 ::std::numeric_limits<SCCOLROW>::max());
734 const char*
const pLevelSep =
" ";
737 if (rCollection.empty())
739 aOutput += rCollection.dumpAsString() + pLevelSep;
750 aColOutline( rOutline.aColOutline ),
751 aRowOutline( rOutline.aRowOutline )
786 pArray( pOutlineArray ),
797 pArray( pOutlineArray )
801 std::advance(it, nEntry);
824 pEntry = &it->second;
846 OSL_FAIL(
"ScSubOutlineIterator::LastEntry before GetNext");
856 OSL_FAIL(
"ScSubOutlineIterator::DeleteLast after End");
861 OSL_FAIL(
"ScSubOutlineIterator::DeleteLast before GetNext");
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
const SCCOLROW SCCOLROW_MAX
size_t GetCount(size_t nLevel) const
void GetRange(SCCOLROW &rStart, SCCOLROW &rEnd) const
bool TestInsertSpace(SCSIZE nSize, SCCOLROW nMaxVal) const
ScOutlineEntry * GetEntry(size_t nLevel, size_t nIndex)
void InsertSpace(SCCOLROW nStartPos, SCSIZE nSize)
bool FindTouchedLevel(SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t &rFindLevel) const
bool GetEntryIndex(size_t nLevel, SCCOLROW nPos, size_t &rnIndex) const
void finalizeImport(const ScTable &rTable)
bool Remove(SCCOLROW nBlockStart, SCCOLROW nBlockEnd, bool &rSizeChanged)
OString dumpAsString() const
const ScOutlineEntry * GetEntryByPos(size_t nLevel, SCCOLROW nPos) const
void SetVisibleBelow(size_t nLevel, size_t nEntry, bool bValue, bool bSkipHidden=false)
void FindEntry(SCCOLROW nSearchPos, size_t &rFindLevel, size_t &rFindIndex, size_t nMaxLevel=SC_OL_MAXDEPTH)
bool ManualAction(SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, const ScTable &rTable, bool bCol)
bool Insert(SCCOLROW nStartPos, SCCOLROW nEndPos, bool &rSizeChanged, bool bHidden=false)
bool GetEntryIndexInRange(size_t nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t &rnIndex) const
void PromoteSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nStartLevel)
bool DeleteSpace(SCCOLROW nStartPos, SCSIZE nSize)
bool DecDepth()
Adapt nDepth for empty Levels.
ScOutlineCollection aCollections[SC_OL_MAXDEPTH]
void ExtendBlock(size_t nLevel, SCCOLROW &rBlkStart, SCCOLROW &rBlkEnd)
MapType::iterator iterator
MapType::const_iterator const_iterator
OString dumpAsString() const
void insert(ScOutlineEntry const &rEntry)
iterator erase(const iterator &pos)
iterator FindStart(SCCOLROW nMinStart)
SC_DLLPUBLIC SCCOLROW GetStart() const
SC_DLLPUBLIC bool IsHidden() const
void SetPosSize(SCCOLROW nNewPos, SCSIZE nNewSize)
void SetSize(SCSIZE nNewSize)
void Move(SCCOLROW nDelta)
SC_DLLPUBLIC SCCOLROW GetEnd() const
void SetVisible(bool bNewVisible)
OString dumpAsString() const
void SetHidden(bool bNewHidden)
ScOutlineEntry(SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNewHidden)
void InsertCol(SCCOL nStartCol, SCSIZE nSize)
bool TestInsertRow(SCSIZE nSize)
bool TestInsertCol(SCSIZE nSize)
bool DeleteRow(SCROW nStartRow, SCSIZE nSize)
ScOutlineArray aRowOutline
bool DeleteCol(SCCOL nStartCol, SCSIZE nSize)
void InsertRow(SCROW nStartRow, SCSIZE nSize)
ScOutlineArray aColOutline
ScOutlineEntry * GetNext()
ScSubOutlineIterator(ScOutlineArray *pOutlineArray)
SCCOLROW LastHiddenColRow(SCCOLROW nPos, bool bCol) const
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW