2010-10-12 15:59:00 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-18 23:16:46 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 18:31:08 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:31:08 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:31:08 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:31:08 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:31:08 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
2008-04-10 18:31:08 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 23:16:46 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
#include "olinetab.hxx"
|
|
|
|
#include "global.hxx"
|
|
|
|
#include "rechead.hxx"
|
2004-06-04 09:26:59 +00:00
|
|
|
#include "address.hxx"
|
2010-06-23 13:38:34 +02:00
|
|
|
#include "table.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2010-06-23 13:38:34 +02:00
|
|
|
ScOutlineEntry::ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNewHidden ) :
|
2000-09-18 23:16:46 +00:00
|
|
|
nStart ( nNewStart ),
|
|
|
|
nSize ( nNewSize ),
|
|
|
|
bHidden ( bNewHidden ),
|
2012-02-03 23:35:49 -05:00
|
|
|
bVisible( true )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineEntry::ScOutlineEntry( const ScOutlineEntry& rEntry ) :
|
|
|
|
nStart ( rEntry.nStart ),
|
|
|
|
nSize ( rEntry.nSize ),
|
|
|
|
bHidden ( rEntry.bHidden ),
|
|
|
|
bVisible( rEntry.bVisible )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-02-03 14:58:56 -05:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineEntry::Move( SCsCOLROW nDelta )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nNewPos = nStart + nDelta;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nNewPos<0)
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("OutlineEntry < 0");
|
2000-09-18 23:16:46 +00:00
|
|
|
nNewPos = 0;
|
|
|
|
}
|
2004-06-04 09:26:59 +00:00
|
|
|
nStart = nNewPos;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineEntry::SetSize( SCSIZE nNewSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:26:59 +00:00
|
|
|
if (nNewSize>0)
|
2000-09-18 23:16:46 +00:00
|
|
|
nSize = nNewSize;
|
|
|
|
else
|
2008-01-29 14:19:37 +00:00
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("ScOutlineEntry Size == 0");
|
2008-01-29 14:19:37 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineEntry::SetPosSize( SCCOLROW nNewPos, SCSIZE nNewSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
nStart = nNewPos;
|
|
|
|
SetSize( nNewSize );
|
|
|
|
}
|
|
|
|
|
2010-06-23 13:38:34 +02:00
|
|
|
void ScOutlineEntry::SetHidden( bool bNewHidden )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
bHidden = bNewHidden;
|
|
|
|
}
|
|
|
|
|
2010-06-23 13:38:34 +02:00
|
|
|
void ScOutlineEntry::SetVisible( bool bNewVisible )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
bVisible = bNewVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection::ScOutlineCollection() {}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
inline short IntCompare( SCCOLROW nX, SCCOLROW nY )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if ( nX==nY ) return 0;
|
|
|
|
else if ( nX<nY ) return -1;
|
|
|
|
else return 1;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
size_t ScOutlineCollection::size() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
return maEntries.size();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
void ScOutlineCollection::clear()
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
maEntries.clear();
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
void ScOutlineCollection::insert(ScOutlineEntry* pEntry)
|
|
|
|
{
|
|
|
|
SCCOLROW nStart = pEntry->GetStart();
|
|
|
|
maEntries.insert(nStart, pEntry);
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection::iterator ScOutlineCollection::begin()
|
|
|
|
{
|
|
|
|
return maEntries.begin();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection::iterator ScOutlineCollection::end()
|
|
|
|
{
|
|
|
|
return maEntries.end();
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection::const_iterator ScOutlineCollection::begin() const
|
|
|
|
{
|
|
|
|
return maEntries.begin();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineCollection::const_iterator ScOutlineCollection::end() const
|
|
|
|
{
|
|
|
|
return maEntries.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScOutlineCollection::erase(iterator pos)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
maEntries.erase(pos);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
bool ScOutlineCollection::empty() const
|
|
|
|
{
|
|
|
|
return maEntries.empty();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineCollection::iterator ScOutlineCollection::FindStart(SCCOLROW nMinStart)
|
|
|
|
{
|
|
|
|
return maEntries.lower_bound(nMinStart);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScOutlineArray::ScOutlineArray() :
|
|
|
|
nDepth(0) {}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
ScOutlineArray::ScOutlineArray( const ScOutlineArray& rArray ) :
|
|
|
|
nDepth( rArray.nDepth )
|
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
for (size_t nLevel = 0; nLevel < nDepth; ++nLevel)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineCollection& rColl = rArray.aCollections[nLevel];
|
|
|
|
ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
|
|
|
|
for (; it != itEnd; ++it)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineEntry* pEntry = it->second;
|
|
|
|
aCollections[nLevel].insert(new ScOutlineEntry(*pEntry));
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
void ScOutlineArray::FindEntry(
|
2012-02-04 00:18:23 -05:00
|
|
|
SCCOLROW nSearchPos, size_t& rFindLevel, size_t& rFindIndex,
|
2012-02-03 23:35:49 -05:00
|
|
|
size_t nMaxLevel )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-04 00:18:23 -05:00
|
|
|
rFindLevel = rFindIndex = 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (nMaxLevel > nDepth)
|
|
|
|
nMaxLevel = nDepth;
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
for (size_t nLevel = 0; nLevel < nMaxLevel; ++nLevel) //! rueckwaerts suchen ?
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ScOutlineCollection* pCollect = &aCollections[nLevel];
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection::iterator it = pCollect->begin(), itEnd = pCollect->end();
|
|
|
|
for (; it != itEnd; ++it)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineEntry* pEntry = it->second;
|
|
|
|
if (pEntry->GetStart() <= nSearchPos && pEntry->GetEnd() >= nSearchPos)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
rFindLevel = nLevel + 1; // naechster Level (zum Einfuegen)
|
2012-02-04 00:18:23 -05:00
|
|
|
rFindIndex = std::distance(pCollect->begin(), it);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
bool ScOutlineArray::Insert(
|
|
|
|
SCCOLROW nStartCol, SCCOLROW nEndCol, bool& rSizeChanged, bool bHidden, bool bVisible )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
rSizeChanged = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-04 00:18:23 -05:00
|
|
|
size_t nStartLevel, nEndLevel, nStartIndex, nEndIndex;
|
2011-08-25 11:33:20 +02:00
|
|
|
bool bFound = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-08-25 11:33:20 +02:00
|
|
|
bool bCont;
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_uInt16 nFindMax;
|
2012-02-04 00:18:23 -05:00
|
|
|
FindEntry( nStartCol, nStartLevel, nStartIndex ); // nLevel = neuer Level (alter+1) !!!
|
|
|
|
FindEntry( nEndCol, nEndLevel, nEndIndex );
|
2000-09-18 23:16:46 +00:00
|
|
|
nFindMax = Max(nStartLevel,nEndLevel);
|
|
|
|
do
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
bCont = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-04 00:18:23 -05:00
|
|
|
if (nStartLevel == nEndLevel && nStartIndex == nEndIndex && nStartLevel < SC_OL_MAXDEPTH)
|
2011-08-25 11:33:20 +02:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (!bFound)
|
|
|
|
{
|
|
|
|
if (nFindMax>0)
|
|
|
|
{
|
|
|
|
--nFindMax;
|
|
|
|
if (nStartLevel)
|
2012-02-03 23:35:49 -05:00
|
|
|
{
|
2012-02-04 00:18:23 -05:00
|
|
|
ScOutlineCollection::const_iterator it = aCollections[nStartLevel-1].begin();
|
|
|
|
std::advance(it, nStartIndex);
|
|
|
|
if (it->second->GetStart() == nStartCol)
|
|
|
|
FindEntry(nStartCol, nStartLevel, nStartIndex, nFindMax);
|
2012-02-03 23:35:49 -05:00
|
|
|
}
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nEndLevel)
|
2012-02-03 23:35:49 -05:00
|
|
|
{
|
2012-02-04 00:18:23 -05:00
|
|
|
ScOutlineCollection::const_iterator it = aCollections[nEndLevel-1].begin();
|
|
|
|
std::advance(it, nEndIndex);
|
|
|
|
if (it->second->GetEnd() == nEndCol)
|
|
|
|
FindEntry(nEndCol, nEndLevel, nEndIndex, nFindMax);
|
2012-02-03 23:35:49 -05:00
|
|
|
}
|
2011-08-25 11:33:20 +02:00
|
|
|
bCont = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ( !bFound && bCont );
|
|
|
|
|
|
|
|
if (!bFound)
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
size_t nLevel = nStartLevel;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
// untere verschieben
|
|
|
|
|
2011-08-25 11:33:20 +02:00
|
|
|
bool bNeedSize = false;
|
2012-02-03 23:53:12 -05:00
|
|
|
if (nDepth > 0)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:53:12 -05:00
|
|
|
for (size_t nMoveLevel = nDepth-1; nMoveLevel >= nLevel; --nMoveLevel)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:53:12 -05:00
|
|
|
ScOutlineCollection& rColl = aCollections[nMoveLevel];
|
|
|
|
ScOutlineCollection::iterator it = rColl.begin(), itEnd = rColl.end();
|
|
|
|
while (it != itEnd)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:53:12 -05:00
|
|
|
ScOutlineEntry* pEntry = it->second;
|
|
|
|
SCCOLROW nEntryStart = pEntry->GetStart();
|
|
|
|
if (nEntryStart >= nStartCol && nEntryStart <= nEndCol)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:53:12 -05:00
|
|
|
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;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2012-02-03 23:53:12 -05:00
|
|
|
else
|
|
|
|
++it;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2012-02-03 23:53:12 -05:00
|
|
|
if (nMoveLevel == 0)
|
|
|
|
break;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bNeedSize)
|
|
|
|
{
|
|
|
|
++nDepth;
|
2011-08-25 11:33:20 +02:00
|
|
|
rSizeChanged = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (nDepth <= nLevel)
|
|
|
|
{
|
|
|
|
nDepth = nLevel+1;
|
2011-08-25 11:33:20 +02:00
|
|
|
rSizeChanged = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineEntry* pNewEntry = new ScOutlineEntry( nStartCol, nEndCol+1-nStartCol, bHidden );
|
|
|
|
pNewEntry->SetVisible( bVisible );
|
2012-02-03 23:35:49 -05:00
|
|
|
aCollections[nLevel].insert(pNewEntry);
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2011-08-25 11:33:20 +02:00
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
size_t ScOutlineArray::GetDepth() const
|
|
|
|
{
|
|
|
|
return nDepth;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ScOutlineArray::FindTouchedLevel(
|
|
|
|
SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rFindLevel) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
bool bFound = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
rFindLevel = 0;
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
for (size_t nLevel = 0; nLevel < nDepth; ++nLevel)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-09-18 13:00:19 +00:00
|
|
|
const ScOutlineCollection* pCollect = &aCollections[nLevel];
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection::const_iterator it = pCollect->begin(), itEnd = pCollect->end();
|
|
|
|
for (; it != itEnd; ++it)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineEntry* pEntry = it->second;
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nStart = pEntry->GetStart();
|
|
|
|
SCCOLROW nEnd = pEntry->GetEnd();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( ( nBlockStart>=nStart && nBlockStart<=nEnd ) ||
|
|
|
|
( nBlockEnd >=nStart && nBlockEnd <=nEnd ) )
|
|
|
|
{
|
|
|
|
rFindLevel = nLevel; // wirklicher Level
|
2012-02-03 23:35:49 -05:00
|
|
|
bFound = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
void ScOutlineArray::RemoveSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nLevel)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-09-18 13:00:19 +00:00
|
|
|
if ( nLevel >= nDepth )
|
|
|
|
return;
|
2012-02-03 23:35:49 -05:00
|
|
|
|
|
|
|
ScOutlineCollection& rColl = aCollections[nLevel];
|
|
|
|
|
|
|
|
ScOutlineCollection::iterator it = rColl.begin(), itEnd = rColl.end();
|
|
|
|
while (it != itEnd)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineEntry* pEntry = it->second;
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nStart = pEntry->GetStart();
|
|
|
|
SCCOLROW nEnd = pEntry->GetEnd();
|
2012-02-03 23:35:49 -05:00
|
|
|
if (nStart >= nStartPos && nEnd <= nEndPos)
|
|
|
|
{
|
|
|
|
// Overlaps.
|
|
|
|
RemoveSub( nStart, nEnd, nLevel+1 );
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
// 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)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
RemoveSub( nStart, nEnd, nLevel+1 );
|
2012-02-03 23:35:49 -05:00
|
|
|
|
|
|
|
// 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();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2012-02-03 23:35:49 -05:00
|
|
|
else
|
|
|
|
++it;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
void ScOutlineArray::PromoteSub(SCCOLROW nStartPos, SCCOLROW nEndPos, size_t nStartLevel)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (nStartLevel==0)
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("PromoteSub mit Level 0");
|
2000-09-18 23:16:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
for (size_t nLevel = nStartLevel; nLevel < nDepth; ++nLevel)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection& rColl = aCollections[nLevel];
|
|
|
|
ScOutlineCollection::iterator it = rColl.begin(), itEnd = rColl.end();
|
|
|
|
while (it != itEnd)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineEntry* pEntry = it->second;
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nStart = pEntry->GetStart();
|
|
|
|
SCCOLROW nEnd = pEntry->GetEnd();
|
2012-02-03 23:35:49 -05:00
|
|
|
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();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
while (it != itEnd)
|
|
|
|
{
|
|
|
|
ScOutlineEntry* pEntry = it->second;
|
|
|
|
SCCOLROW nStart = pEntry->GetStart();
|
|
|
|
SCCOLROW nEnd = pEntry->GetEnd();
|
|
|
|
if (nStart >= nStartPos && nEnd <= nEndPos)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
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();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2012-02-03 23:35:49 -05:00
|
|
|
else
|
|
|
|
++it;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
bool ScOutlineArray::DecDepth() // nDepth auf leere Levels anpassen
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
bool bChanged = false;
|
|
|
|
bool bCont;
|
2000-09-18 23:16:46 +00:00
|
|
|
do
|
|
|
|
{
|
2011-03-10 16:55:21 -05:00
|
|
|
bCont = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
if (nDepth)
|
2012-02-03 23:35:49 -05:00
|
|
|
{
|
|
|
|
if (aCollections[nDepth-1].empty())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
--nDepth;
|
2012-02-03 23:35:49 -05:00
|
|
|
bChanged = true;
|
|
|
|
bCont = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2012-02-03 23:35:49 -05:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
while (bCont);
|
2012-02-03 23:35:49 -05:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
bool ScOutlineArray::Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, bool& rSizeChanged )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
size_t nLevel;
|
2000-09-18 23:16:46 +00:00
|
|
|
FindTouchedLevel( nBlockStart, nBlockEnd, nLevel );
|
|
|
|
|
|
|
|
ScOutlineCollection* pCollect = &aCollections[nLevel];
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection::iterator it = pCollect->begin(), itEnd = pCollect->end();
|
|
|
|
bool bAny = false;
|
|
|
|
while (it != itEnd)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineEntry* pEntry = it->second;
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nStart = pEntry->GetStart();
|
|
|
|
SCCOLROW nEnd = pEntry->GetEnd();
|
2012-02-03 23:35:49 -05:00
|
|
|
if (nBlockStart <= nEnd && nBlockEnd >= nStart)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
// Overlaps.
|
|
|
|
pCollect->erase(it);
|
2000-09-18 23:16:46 +00:00
|
|
|
PromoteSub( nStart, nEnd, nLevel+1 );
|
2012-02-03 23:35:49 -05:00
|
|
|
itEnd = pCollect->end();
|
|
|
|
it = pCollect->FindStart( nEnd+1 );
|
|
|
|
bAny = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
2012-02-03 23:35:49 -05:00
|
|
|
else
|
|
|
|
++it;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (bAny) // Depth anpassen
|
|
|
|
if (DecDepth())
|
2012-02-03 23:35:49 -05:00
|
|
|
rSizeChanged = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
return bAny;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
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
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
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;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
size_t ScOutlineArray::GetCount(size_t nLevel) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
if (nLevel >= nDepth)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
return aCollections[nLevel].size();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineEntry* ScOutlineArray::GetEntryByPos(size_t nLevel, SCCOLROW nPos) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
if (nLevel >= nDepth)
|
|
|
|
return NULL;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineCollection& rColl = aCollections[nLevel];
|
|
|
|
ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
|
|
|
|
for (; it != itEnd; ++it)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineEntry* pEntry = it->second;
|
|
|
|
if (pEntry->GetStart() <= nPos && nPos <= pEntry->GetEnd())
|
2000-09-18 23:16:46 +00:00
|
|
|
return pEntry;
|
|
|
|
}
|
2012-02-03 23:35:49 -05:00
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
bool ScOutlineArray::GetEntryIndex(size_t nLevel, SCCOLROW nPos, size_t& rnIndex) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
if (nLevel >= nDepth)
|
|
|
|
return false;
|
|
|
|
|
2002-09-18 13:00:19 +00:00
|
|
|
// found entry contains passed position
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineCollection& rColl = aCollections[nLevel];
|
|
|
|
ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
|
|
|
|
for (; it != itEnd; ++it)
|
2002-09-18 13:00:19 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineEntry* p = it->second;
|
|
|
|
if (p->GetStart() <= nPos && nPos <= p->GetEnd())
|
|
|
|
{
|
|
|
|
rnIndex = std::distance(rColl.begin(), it);
|
|
|
|
return true;
|
|
|
|
}
|
2002-09-18 13:00:19 +00:00
|
|
|
}
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2002-09-18 13:00:19 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
bool ScOutlineArray::GetEntryIndexInRange(
|
|
|
|
size_t nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, size_t& rnIndex) const
|
2002-09-18 13:00:19 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
if (nLevel >= nDepth)
|
|
|
|
return false;
|
|
|
|
|
2002-09-18 13:00:19 +00:00
|
|
|
// found entry will be completely inside of passed range
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineCollection& rColl = aCollections[nLevel];
|
|
|
|
ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
|
|
|
|
for (; it != itEnd; ++it)
|
2002-09-18 13:00:19 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineEntry* p = it->second;
|
|
|
|
if (nBlockStart <= p->GetStart() && p->GetEnd() <= nBlockEnd)
|
|
|
|
{
|
|
|
|
rnIndex = std::distance(rColl.begin(), it);
|
|
|
|
return true;
|
|
|
|
}
|
2002-09-18 13:00:19 +00:00
|
|
|
}
|
2011-03-10 16:55:21 -05:00
|
|
|
return false;
|
2002-09-18 13:00:19 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
void ScOutlineArray::SetVisibleBelow(
|
|
|
|
size_t nLevel, size_t nEntry, bool bValue, bool bSkipHidden)
|
2002-09-18 13:00:19 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineEntry* pEntry = GetEntry( nLevel, nEntry );
|
|
|
|
if (!pEntry)
|
|
|
|
return;
|
2002-09-18 13:00:19 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
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)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineEntry* p = it->second;
|
|
|
|
if (p->GetStart() >= nStart && p->GetEnd() <= nEnd)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
p->SetVisible(bValue);
|
|
|
|
if (bSkipHidden && !p->IsHidden())
|
2002-09-18 13:00:19 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
size_t nPos = std::distance(rColl.begin(), it);
|
|
|
|
SetVisibleBelow(nSubLevel, nPos, bValue, true);
|
2002-09-18 13:00:19 +00:00
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
2012-02-03 23:35:49 -05:00
|
|
|
|
|
|
|
if (bSkipHidden)
|
|
|
|
nSubLevel = nDepth; // Abbruch
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
void ScOutlineArray::GetRange(SCCOLROW& rStart, SCCOLROW& rEnd) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineCollection& rColl = aCollections[0];
|
|
|
|
if (!rColl.empty())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection::const_iterator it = rColl.begin();
|
|
|
|
rStart = it->second->GetStart();
|
|
|
|
std::advance(it, rColl.size()-1);
|
|
|
|
rEnd = it->second->GetEnd();
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
rStart = rEnd = 0;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
void ScOutlineArray::ExtendBlock(size_t nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
if (nLevel >= nDepth)
|
|
|
|
return;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineCollection& rColl = aCollections[nLevel];
|
|
|
|
ScOutlineCollection::const_iterator it = rColl.begin(), itEnd = rColl.end();
|
|
|
|
for (; it != itEnd; ++it)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineEntry* pEntry = it->second;
|
|
|
|
SCCOLROW nStart = pEntry->GetStart();
|
|
|
|
SCCOLROW nEnd = pEntry->GetEnd();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
if (rBlkStart <= nEnd && rBlkEnd >= nStart)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
if (nStart < rBlkStart)
|
|
|
|
rBlkStart = nStart;
|
|
|
|
if (nEnd > rBlkEnd)
|
|
|
|
rBlkEnd = nEnd;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
bool ScOutlineArray::TestInsertSpace(SCSIZE nSize, SCCOLROW nMaxVal) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineCollection& rColl = aCollections[0];
|
|
|
|
if (rColl.empty())
|
|
|
|
return true;
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
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;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
void ScOutlineArray::InsertSpace(SCCOLROW nStartPos, SCSIZE nSize)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ScSubOutlineIterator aIter( this );
|
|
|
|
ScOutlineEntry* pEntry;
|
2012-02-03 23:35:49 -05:00
|
|
|
while ((pEntry = aIter.GetNext()) != NULL)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if ( pEntry->GetStart() >= nStartPos )
|
2004-06-04 09:26:59 +00:00
|
|
|
pEntry->Move(static_cast<SCsCOLROW>(nSize));
|
2000-09-18 23:16:46 +00:00
|
|
|
else
|
|
|
|
{
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nEnd = pEntry->GetEnd();
|
2000-09-18 23:16:46 +00:00
|
|
|
// immer erweitern, wenn innerhalb der Gruppe eingefuegt
|
|
|
|
// beim Einfuegen am Ende nur, wenn die Gruppe nicht ausgeblendet ist
|
|
|
|
if ( nEnd >= nStartPos || ( nEnd+1 >= nStartPos && !pEntry->IsHidden() ) )
|
|
|
|
{
|
2004-06-04 09:26:59 +00:00
|
|
|
SCSIZE nEntrySize = pEntry->GetSize();
|
2000-09-18 23:16:46 +00:00
|
|
|
nEntrySize += nSize;
|
|
|
|
pEntry->SetSize( nEntrySize );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
bool ScOutlineArray::DeleteSpace(SCCOLROW nStartPos, SCSIZE nSize)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nEndPos = nStartPos + nSize - 1;
|
2011-03-10 16:55:21 -05:00
|
|
|
sal_Bool bNeedSave = false; // Original fuer Undo benoetigt?
|
|
|
|
sal_Bool bChanged = false; // fuer Test auf Level
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
ScSubOutlineIterator aIter( this );
|
|
|
|
ScOutlineEntry* pEntry;
|
|
|
|
while((pEntry=aIter.GetNext())!=NULL)
|
|
|
|
{
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nEntryStart = pEntry->GetStart();
|
|
|
|
SCCOLROW nEntryEnd = pEntry->GetEnd();
|
|
|
|
SCSIZE nEntrySize = pEntry->GetSize();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if ( nEntryEnd >= nStartPos )
|
|
|
|
{
|
|
|
|
if ( nEntryStart > nEndPos ) // rechts
|
2004-06-04 09:26:59 +00:00
|
|
|
pEntry->Move(-(static_cast<SCsCOLROW>(nSize)));
|
2000-09-18 23:16:46 +00:00
|
|
|
else if ( nEntryStart < nStartPos && nEntryEnd >= nEndPos ) // aussen
|
|
|
|
pEntry->SetSize( nEntrySize-nSize );
|
|
|
|
else
|
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
bNeedSave = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
if ( nEntryStart >= nStartPos && nEntryEnd <= nEndPos ) // innen
|
|
|
|
{
|
|
|
|
aIter.DeleteLast();
|
2012-02-03 23:35:49 -05:00
|
|
|
bChanged = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else if ( nEntryStart >= nStartPos ) // rechts ueber
|
2004-06-04 09:26:59 +00:00
|
|
|
pEntry->SetPosSize( nStartPos, static_cast<SCSIZE>(nEntryEnd-nEndPos) );
|
2000-09-18 23:16:46 +00:00
|
|
|
else // links ueber
|
2004-06-04 09:26:59 +00:00
|
|
|
pEntry->SetSize( static_cast<SCSIZE>(nStartPos-nEntryStart) );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bChanged)
|
|
|
|
DecDepth();
|
|
|
|
|
|
|
|
return bNeedSave;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
bool ScOutlineArray::ManualAction(
|
|
|
|
SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, const ScTable& rTable, bool bCol)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2010-06-23 13:38:34 +02:00
|
|
|
bool bModified = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
ScSubOutlineIterator aIter( this );
|
|
|
|
ScOutlineEntry* pEntry;
|
|
|
|
while((pEntry=aIter.GetNext())!=NULL)
|
|
|
|
{
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nEntryStart = pEntry->GetStart();
|
|
|
|
SCCOLROW nEntryEnd = pEntry->GetEnd();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
if (nEntryEnd>=nStartPos && nEntryStart<=nEndPos)
|
|
|
|
{
|
|
|
|
if ( pEntry->IsHidden() == bShow )
|
|
|
|
{
|
2003-04-08 15:19:29 +00:00
|
|
|
// #i12341# hide if all columns/rows are hidden, show if at least one
|
|
|
|
// is visible
|
2010-06-23 13:38:34 +02:00
|
|
|
SCCOLROW nEnd = rTable.LastHiddenColRow(nEntryStart, bCol);
|
|
|
|
bool bAllHidden = (nEntryEnd <= nEnd && nEnd <
|
2004-08-20 08:10:38 +00:00
|
|
|
::std::numeric_limits<SCCOLROW>::max());
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2010-06-23 13:38:34 +02:00
|
|
|
bool bToggle = ( bShow != bAllHidden );
|
2003-04-08 15:19:29 +00:00
|
|
|
if ( bToggle )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
pEntry->SetHidden( !bShow );
|
|
|
|
SetVisibleBelow( aIter.LastLevel(), aIter.LastEntry(), bShow, bShow );
|
2010-06-23 13:38:34 +02:00
|
|
|
bModified = true;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bModified;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScOutlineArray::RemoveAll()
|
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
for (size_t nLevel = 0; nLevel < nDepth; ++nLevel)
|
|
|
|
aCollections[nLevel].clear();
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
nDepth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScOutlineTable::ScOutlineTable()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineTable::ScOutlineTable( const ScOutlineTable& rOutline ) :
|
|
|
|
aColOutline( rOutline.aColOutline ),
|
|
|
|
aRowOutline( rOutline.aRowOutline )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool ScOutlineTable::TestInsertCol( SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return aColOutline.TestInsertSpace( nSize, MAXCOL );
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineTable::InsertCol( SCCOL nStartCol, SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
aColOutline.InsertSpace( nStartCol, nSize );
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool ScOutlineTable::DeleteCol( SCCOL nStartCol, SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return aColOutline.DeleteSpace( nStartCol, nSize );
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool ScOutlineTable::TestInsertRow( SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return aRowOutline.TestInsertSpace( nSize, MAXROW );
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineTable::InsertRow( SCROW nStartRow, SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
aRowOutline.InsertSpace( nStartRow, nSize );
|
|
|
|
}
|
|
|
|
|
2011-01-17 13:20:22 +01:00
|
|
|
sal_Bool ScOutlineTable::DeleteRow( SCROW nStartRow, SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return aRowOutline.DeleteSpace( nStartRow, nSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScSubOutlineIterator::ScSubOutlineIterator( ScOutlineArray* pOutlineArray ) :
|
|
|
|
pArray( pOutlineArray ),
|
|
|
|
nStart( 0 ),
|
2004-06-04 09:26:59 +00:00
|
|
|
nEnd( SCCOLROW_MAX ), // alle durchgehen
|
2000-09-18 23:16:46 +00:00
|
|
|
nSubLevel( 0 ),
|
|
|
|
nSubEntry( 0 )
|
|
|
|
{
|
|
|
|
nDepth = pArray->nDepth;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
ScSubOutlineIterator::ScSubOutlineIterator(
|
|
|
|
ScOutlineArray* pOutlineArray, size_t nLevel, size_t nEntry ) :
|
2000-09-18 23:16:46 +00:00
|
|
|
pArray( pOutlineArray )
|
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
const ScOutlineCollection& rColl = pArray->aCollections[nLevel];
|
|
|
|
ScOutlineCollection::const_iterator it = rColl.begin();
|
|
|
|
std::advance(it, nEntry);
|
|
|
|
const ScOutlineEntry* pEntry = it->second;
|
2000-09-18 23:16:46 +00:00
|
|
|
nStart = pEntry->GetStart();
|
|
|
|
nEnd = pEntry->GetEnd();
|
|
|
|
nSubLevel = nLevel + 1;
|
|
|
|
nSubEntry = 0;
|
|
|
|
nDepth = pArray->nDepth;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineEntry* ScSubOutlineIterator::GetNext()
|
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineEntry* pEntry = NULL;
|
|
|
|
bool bFound = false;
|
2000-09-18 23:16:46 +00:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (nSubLevel >= nDepth)
|
|
|
|
return NULL;
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection& rColl = pArray->aCollections[nSubLevel];
|
|
|
|
if (nSubEntry < rColl.size())
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection::iterator it = rColl.begin();
|
|
|
|
std::advance(it, nSubEntry);
|
|
|
|
pEntry = it->second;
|
|
|
|
|
|
|
|
if (pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd)
|
|
|
|
bFound = true;
|
|
|
|
|
|
|
|
++nSubEntry;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-02-03 23:35:49 -05:00
|
|
|
// Go to the next sub-level.
|
|
|
|
nSubEntry = 0;
|
|
|
|
++nSubLevel;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!bFound);
|
|
|
|
return pEntry; // nSubLevel gueltig, wenn pEntry != 0
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
size_t ScSubOutlineIterator::LastLevel() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return nSubLevel;
|
|
|
|
}
|
|
|
|
|
2012-02-03 23:35:49 -05:00
|
|
|
size_t ScSubOutlineIterator::LastEntry() const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (nSubEntry == 0)
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("ScSubOutlineIterator::LastEntry vor GetNext");
|
2000-09-18 23:16:46 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return nSubEntry-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScSubOutlineIterator::DeleteLast()
|
|
|
|
{
|
|
|
|
if (nSubLevel >= nDepth)
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("ScSubOutlineIterator::DeleteLast nach Ende");
|
2000-09-18 23:16:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (nSubEntry == 0)
|
|
|
|
{
|
2011-03-01 19:05:02 +01:00
|
|
|
OSL_FAIL("ScSubOutlineIterator::DeleteLast vor GetNext");
|
2000-09-18 23:16:46 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
--nSubEntry;
|
2012-02-03 23:35:49 -05:00
|
|
|
ScOutlineCollection& rColl = pArray->aCollections[nSubLevel];
|
|
|
|
OSL_ASSERT(nSubEntry < rColl.size());
|
|
|
|
ScOutlineCollection::iterator it = rColl.begin();
|
|
|
|
std::advance(it, nSubEntry);
|
|
|
|
rColl.erase(it);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-12 15:59:00 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|