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
|
|
|
*
|
2008-04-10 18:31:08 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
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
|
|
|
* $RCSfile: olinetab.cxx,v $
|
|
|
|
* $Revision: 1.10 $
|
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
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-07-21 10:06:28 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sc.hxx"
|
|
|
|
|
2000-09-18 23:16:46 +00:00
|
|
|
// System - Includes -----------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#include <limits.h>
|
|
|
|
|
|
|
|
// INCLUDE ---------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "olinetab.hxx"
|
|
|
|
#include "global.hxx"
|
|
|
|
#include "rechead.hxx"
|
2004-06-04 09:26:59 +00:00
|
|
|
#include "address.hxx"
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
ScOutlineEntry::ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, BOOL bNewHidden ) :
|
2000-09-18 23:16:46 +00:00
|
|
|
nStart ( nNewStart ),
|
|
|
|
nSize ( nNewSize ),
|
|
|
|
bHidden ( bNewHidden ),
|
|
|
|
bVisible( TRUE )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineEntry::ScOutlineEntry( const ScOutlineEntry& rEntry ) :
|
2007-02-27 11:07:18 +00:00
|
|
|
DataObject(),
|
2000-09-18 23:16:46 +00:00
|
|
|
nStart ( rEntry.nStart ),
|
|
|
|
nSize ( rEntry.nSize ),
|
|
|
|
bHidden ( rEntry.bHidden ),
|
|
|
|
bVisible( rEntry.bVisible )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-02-27 11:07:18 +00:00
|
|
|
ScOutlineEntry::ScOutlineEntry( SvStream& /* rStream */, ScMultipleReadHeader& rHdr )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
rHdr.StartEntry();
|
2004-06-04 09:26:59 +00:00
|
|
|
#if SC_ROWLIMIT_STREAM_ACCESS
|
|
|
|
#error address types changed!
|
2000-09-18 23:16:46 +00:00
|
|
|
|
|
|
|
rStream >> nStart;
|
|
|
|
rStream >> nSize;
|
|
|
|
rStream >> bHidden;
|
|
|
|
rStream >> bVisible;
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
#endif
|
2000-09-18 23:16:46 +00:00
|
|
|
rHdr.EndEntry();
|
|
|
|
}
|
|
|
|
|
2007-02-27 11:07:18 +00:00
|
|
|
void ScOutlineEntry::Store( SvStream& /* rStream */, ScMultipleWriteHeader& rHdr )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
rHdr.StartEntry();
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
#if SC_ROWLIMIT_STREAM_ACCESS
|
|
|
|
#error address types changed!
|
2000-09-18 23:16:46 +00:00
|
|
|
rStream << nStart;
|
|
|
|
rStream << nSize;
|
|
|
|
rStream << bHidden;
|
|
|
|
rStream << bVisible;
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
#endif
|
2000-09-18 23:16:46 +00:00
|
|
|
rHdr.EndEntry();
|
|
|
|
}
|
|
|
|
|
|
|
|
DataObject* ScOutlineEntry::Clone() const
|
|
|
|
{
|
|
|
|
return new ScOutlineEntry( *this );
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
DBG_ERROR("OutlineEntry < 0");
|
|
|
|
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
|
|
|
{
|
2000-09-18 23:16:46 +00:00
|
|
|
DBG_ERROR("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 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScOutlineEntry::SetHidden( BOOL bNewHidden )
|
|
|
|
{
|
|
|
|
bHidden = bNewHidden;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScOutlineEntry::SetVisible( BOOL bNewVisible )
|
|
|
|
{
|
|
|
|
bVisible = bNewVisible;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScOutlineCollection::ScOutlineCollection() :
|
|
|
|
SortedCollection( 4,4,FALSE )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
short ScOutlineCollection::Compare(DataObject* pKey1, DataObject* pKey2) const
|
|
|
|
{
|
|
|
|
return IntCompare( ((ScOutlineEntry*)pKey1)->GetStart(),
|
|
|
|
((ScOutlineEntry*)pKey2)->GetStart() );
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
USHORT ScOutlineCollection::FindStart( SCCOLROW nMinStart )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
//! binaer suchen ?
|
|
|
|
|
|
|
|
USHORT nPos = 0;
|
2007-02-27 11:07:18 +00:00
|
|
|
USHORT nLocalCount = GetCount();
|
|
|
|
while ( (nPos<nLocalCount) ? (((ScOutlineEntry*)At(nPos))->GetStart() < nMinStart) : FALSE )
|
2000-09-18 23:16:46 +00:00
|
|
|
++nPos;
|
|
|
|
|
|
|
|
return nPos;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScOutlineArray::ScOutlineArray() :
|
|
|
|
nDepth( 0 )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineArray::ScOutlineArray( const ScOutlineArray& rArray ) :
|
|
|
|
nDepth( rArray.nDepth )
|
|
|
|
{
|
|
|
|
for (USHORT nLevel=0; nLevel<nDepth; nLevel++)
|
|
|
|
{
|
|
|
|
USHORT nCount = rArray.aCollections[nLevel].GetCount();
|
|
|
|
for (USHORT nEntry=0; nEntry<nCount; nEntry++)
|
|
|
|
{
|
|
|
|
ScOutlineEntry* pEntry = (ScOutlineEntry*) rArray.aCollections[nLevel].At(nEntry);
|
|
|
|
aCollections[nLevel].Insert( new ScOutlineEntry( *pEntry ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineArray::FindEntry( SCCOLROW nSearchPos, USHORT& rFindLevel, USHORT& rFindIndex,
|
2000-09-18 23:16:46 +00:00
|
|
|
USHORT nMaxLevel )
|
|
|
|
{
|
|
|
|
rFindLevel = rFindIndex = 0;
|
|
|
|
|
|
|
|
if (nMaxLevel > nDepth)
|
|
|
|
nMaxLevel = nDepth;
|
|
|
|
|
|
|
|
for (USHORT nLevel=0; nLevel<nMaxLevel; nLevel++) //! rueckwaerts suchen ?
|
|
|
|
{
|
|
|
|
ScOutlineCollection* pCollect = &aCollections[nLevel];
|
|
|
|
USHORT nCount = pCollect->GetCount();
|
|
|
|
for (USHORT i=0; i<nCount; i++)
|
|
|
|
{
|
|
|
|
ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
|
|
|
|
if ( pEntry->GetStart() <= nSearchPos && pEntry->GetEnd() >= nSearchPos )
|
|
|
|
{
|
|
|
|
rFindLevel = nLevel + 1; // naechster Level (zum Einfuegen)
|
|
|
|
rFindIndex = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
BOOL ScOutlineArray::Insert( SCCOLROW nStartCol, SCCOLROW nEndCol, BOOL& rSizeChanged,
|
2000-09-18 23:16:46 +00:00
|
|
|
BOOL bHidden, BOOL bVisible )
|
|
|
|
{
|
|
|
|
rSizeChanged = FALSE;
|
|
|
|
|
|
|
|
USHORT nStartLevel;
|
|
|
|
USHORT nStartIndex;
|
|
|
|
USHORT nEndLevel;
|
|
|
|
USHORT nEndIndex;
|
|
|
|
BOOL bFound = FALSE;
|
|
|
|
|
|
|
|
BOOL bCont;
|
|
|
|
USHORT nFindMax;
|
|
|
|
FindEntry( nStartCol, nStartLevel, nStartIndex ); // nLevel = neuer Level (alter+1) !!!
|
|
|
|
FindEntry( nEndCol, nEndLevel, nEndIndex );
|
|
|
|
nFindMax = Max(nStartLevel,nEndLevel);
|
|
|
|
do
|
|
|
|
{
|
|
|
|
bCont = FALSE;
|
|
|
|
|
|
|
|
if ( nStartLevel == nEndLevel && nStartIndex == nEndIndex && nStartLevel < SC_OL_MAXDEPTH )
|
|
|
|
bFound = TRUE;
|
|
|
|
|
|
|
|
if (!bFound)
|
|
|
|
{
|
|
|
|
if (nFindMax>0)
|
|
|
|
{
|
|
|
|
--nFindMax;
|
|
|
|
if (nStartLevel)
|
|
|
|
if ( ((ScOutlineEntry*)aCollections[nStartLevel-1].At(nStartIndex))->
|
|
|
|
GetStart() == nStartCol )
|
|
|
|
FindEntry( nStartCol, nStartLevel, nStartIndex, nFindMax );
|
|
|
|
if (nEndLevel)
|
|
|
|
if ( ((ScOutlineEntry*)aCollections[nEndLevel-1].At(nEndIndex))->
|
|
|
|
GetEnd() == nEndCol )
|
|
|
|
FindEntry( nEndCol, nEndLevel, nEndIndex, nFindMax );
|
|
|
|
bCont = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while ( !bFound && bCont );
|
|
|
|
|
|
|
|
if (!bFound)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
USHORT nLevel = nStartLevel;
|
|
|
|
|
|
|
|
// untere verschieben
|
|
|
|
|
|
|
|
BOOL bNeedSize = FALSE;
|
|
|
|
for ( short nMoveLevel = nDepth-1; nMoveLevel >= (short) nLevel; nMoveLevel-- )
|
|
|
|
{
|
|
|
|
USHORT nCount = aCollections[nMoveLevel].GetCount();
|
|
|
|
BOOL bMoved = FALSE;
|
|
|
|
for ( USHORT i=0; i<nCount; i += bMoved ? 0 : 1 )
|
|
|
|
{
|
|
|
|
ScOutlineEntry* pEntry = (ScOutlineEntry*) aCollections[nMoveLevel].At(i);
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nEntryStart = pEntry->GetStart();
|
2000-09-18 23:16:46 +00:00
|
|
|
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 = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
bMoved = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bNeedSize)
|
|
|
|
{
|
|
|
|
++nDepth;
|
|
|
|
rSizeChanged = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nDepth <= nLevel)
|
|
|
|
{
|
|
|
|
nDepth = nLevel+1;
|
|
|
|
rSizeChanged = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nicht zusammenfassen!
|
|
|
|
|
|
|
|
// zusammenfassen
|
|
|
|
|
|
|
|
USHORT nCount = aCollections[nLevel].GetCount();
|
|
|
|
USHORT nIndex;
|
|
|
|
bFound = FALSE;
|
|
|
|
for ( nIndex=0; nIndex<nCount && !bFound; nIndex++ )
|
|
|
|
{
|
|
|
|
if ( ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetEnd() + 1 == nStartCol )
|
|
|
|
{
|
|
|
|
nStartCol = ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetStart();
|
|
|
|
aCollections[nLevel].AtFree(nIndex);
|
|
|
|
nCount = aCollections[nLevel].GetCount(); // Daten geaendert
|
|
|
|
bFound = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bFound = FALSE;
|
|
|
|
for ( nIndex=0; nIndex<nCount && !bFound; nIndex++ )
|
|
|
|
{
|
|
|
|
if ( ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetStart() == nEndCol + 1 )
|
|
|
|
{
|
|
|
|
nEndCol = ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetEnd();
|
|
|
|
aCollections[nLevel].AtFree(nIndex);
|
|
|
|
bFound = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
ScOutlineEntry* pNewEntry = new ScOutlineEntry( nStartCol, nEndCol+1-nStartCol, bHidden );
|
|
|
|
pNewEntry->SetVisible( bVisible );
|
|
|
|
aCollections[nLevel].Insert( pNewEntry );
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
BOOL ScOutlineArray::FindTouchedLevel( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, USHORT& rFindLevel ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
BOOL bFound = FALSE;
|
|
|
|
rFindLevel = 0;
|
|
|
|
|
|
|
|
for (USHORT nLevel=0; nLevel<nDepth; nLevel++)
|
|
|
|
{
|
2002-09-18 13:00:19 +00:00
|
|
|
const ScOutlineCollection* pCollect = &aCollections[nLevel];
|
2000-09-18 23:16:46 +00:00
|
|
|
USHORT nCount = pCollect->GetCount();
|
|
|
|
for (USHORT i=0; i<nCount; i++)
|
|
|
|
{
|
|
|
|
ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
|
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
|
|
|
|
bFound = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bFound;
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineArray::RemoveSub( SCCOLROW nStartPos, SCCOLROW nEndPos, USHORT nLevel )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-09-18 13:00:19 +00:00
|
|
|
if ( nLevel >= nDepth )
|
|
|
|
return;
|
2000-09-18 23:16:46 +00:00
|
|
|
ScOutlineCollection* pCollect = &aCollections[nLevel];
|
|
|
|
USHORT nCount = pCollect->GetCount();
|
|
|
|
BOOL bFound = FALSE;
|
|
|
|
for ( USHORT i=0; i<nCount; i += ( bFound ? 0 : 1 ) )
|
|
|
|
{
|
|
|
|
bFound = FALSE;
|
|
|
|
ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
|
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 ( nStart>=nStartPos && nEnd<=nEndPos )
|
|
|
|
{
|
|
|
|
RemoveSub( nStart, nEnd, nLevel+1 );
|
|
|
|
pCollect->AtFree(i);
|
|
|
|
nCount = pCollect->GetCount();
|
|
|
|
bFound = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineArray::PromoteSub( SCCOLROW nStartPos, SCCOLROW nEndPos, USHORT nStartLevel )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
if (nStartLevel==0)
|
|
|
|
{
|
|
|
|
DBG_ERROR("PromoteSub mit Level 0");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (USHORT nLevel = nStartLevel; nLevel < nDepth; nLevel++)
|
|
|
|
{
|
|
|
|
ScOutlineCollection* pCollect = &aCollections[nLevel];
|
|
|
|
USHORT nCount = pCollect->GetCount();
|
|
|
|
BOOL bFound = FALSE;
|
|
|
|
for ( USHORT i=0; i<nCount; i += ( bFound ? 0 : 1 ) )
|
|
|
|
{
|
|
|
|
bFound = FALSE;
|
|
|
|
ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
|
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 ( nStart>=nStartPos && nEnd<=nEndPos )
|
|
|
|
{
|
|
|
|
aCollections[nLevel-1].Insert( new ScOutlineEntry( *pEntry ) );
|
|
|
|
pCollect->AtFree(i);
|
|
|
|
nCount = pCollect->GetCount();
|
|
|
|
bFound = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL ScOutlineArray::DecDepth() // nDepth auf leere Levels anpassen
|
|
|
|
{
|
|
|
|
BOOL bChanged = FALSE;
|
|
|
|
BOOL bCont;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
bCont = FALSE;
|
|
|
|
if (nDepth)
|
|
|
|
if (aCollections[nDepth-1].GetCount() == 0)
|
|
|
|
{
|
|
|
|
--nDepth;
|
|
|
|
bChanged = TRUE;
|
|
|
|
bCont = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (bCont);
|
|
|
|
return bChanged;
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
BOOL ScOutlineArray::Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, BOOL& rSizeChanged )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
USHORT nLevel;
|
|
|
|
FindTouchedLevel( nBlockStart, nBlockEnd, nLevel );
|
|
|
|
|
|
|
|
ScOutlineCollection* pCollect = &aCollections[nLevel];
|
|
|
|
USHORT nCount = pCollect->GetCount();
|
|
|
|
BOOL bFound = FALSE;
|
|
|
|
BOOL bAny = FALSE;
|
|
|
|
for ( USHORT i=0; i<nCount; i += ( bFound ? 0 : 1 ) )
|
|
|
|
{
|
|
|
|
bFound = FALSE;
|
|
|
|
ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
|
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<=nEnd && nBlockEnd>=nStart )
|
|
|
|
{
|
|
|
|
// RemoveSub( nStart, nEnd, nLevel+1 );
|
|
|
|
pCollect->AtFree(i);
|
|
|
|
PromoteSub( nStart, nEnd, nLevel+1 );
|
|
|
|
nCount = pCollect->GetCount();
|
|
|
|
i = pCollect->FindStart( nEnd+1 );
|
|
|
|
bFound = TRUE;
|
|
|
|
bAny = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bAny) // Depth anpassen
|
|
|
|
if (DecDepth())
|
|
|
|
rSizeChanged = TRUE;
|
|
|
|
|
|
|
|
return bAny;
|
|
|
|
}
|
|
|
|
|
2002-09-18 13:00:19 +00:00
|
|
|
ScOutlineEntry* ScOutlineArray::GetEntry( USHORT nLevel, USHORT nIndex ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-09-18 13:00:19 +00:00
|
|
|
return (ScOutlineEntry*)((nLevel < nDepth) ? aCollections[nLevel].At(nIndex) : NULL);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2002-09-18 13:00:19 +00:00
|
|
|
USHORT ScOutlineArray::GetCount( USHORT nLevel ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-09-18 13:00:19 +00:00
|
|
|
return (nLevel < nDepth) ? aCollections[nLevel].GetCount() : 0;
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
ScOutlineEntry* ScOutlineArray::GetEntryByPos( USHORT nLevel, SCCOLROW nPos ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
USHORT nCount = GetCount( nLevel );
|
|
|
|
ScOutlineEntry* pEntry;
|
|
|
|
|
|
|
|
for (USHORT nIndex = 0; nIndex < nCount; nIndex++)
|
|
|
|
{
|
|
|
|
pEntry = GetEntry( nLevel, nIndex );
|
|
|
|
if ((pEntry->GetStart() <= nPos) && (nPos <= pEntry->GetEnd()))
|
|
|
|
return pEntry;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
BOOL ScOutlineArray::GetEntryIndex( USHORT nLevel, SCCOLROW nPos, USHORT& rnIndex ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-09-18 13:00:19 +00:00
|
|
|
// found entry contains passed position
|
|
|
|
USHORT nCount = GetCount( nLevel );
|
|
|
|
for ( rnIndex = 0; rnIndex < nCount; ++rnIndex )
|
|
|
|
{
|
|
|
|
const ScOutlineEntry* pEntry = GetEntry( nLevel, rnIndex );
|
|
|
|
if ( (pEntry->GetStart() <= nPos) && (nPos <= pEntry->GetEnd()) )
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL ScOutlineArray::GetEntryIndexInRange(
|
2004-06-04 09:26:59 +00:00
|
|
|
USHORT nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, USHORT& rnIndex ) const
|
2002-09-18 13:00:19 +00:00
|
|
|
{
|
|
|
|
// found entry will be completely inside of passed range
|
|
|
|
USHORT nCount = GetCount( nLevel );
|
|
|
|
for ( rnIndex = 0; rnIndex < nCount; ++rnIndex )
|
|
|
|
{
|
|
|
|
const ScOutlineEntry* pEntry = GetEntry( nLevel, rnIndex );
|
|
|
|
if ( (nBlockStart <= pEntry->GetStart()) && (pEntry->GetEnd() <= nBlockEnd) )
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2002-09-18 13:00:19 +00:00
|
|
|
void ScOutlineArray::SetVisibleBelow( USHORT nLevel, USHORT nEntry, BOOL bValue, BOOL bSkipHidden )
|
|
|
|
{
|
|
|
|
ScOutlineEntry* pEntry = GetEntry( nLevel, nEntry );
|
|
|
|
if( pEntry )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nStart = pEntry->GetStart();
|
|
|
|
SCCOLROW nEnd = pEntry->GetEnd();
|
2002-09-18 13:00:19 +00:00
|
|
|
|
|
|
|
for (USHORT nSubLevel=nLevel+1; nSubLevel<nDepth; nSubLevel++)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-09-18 13:00:19 +00:00
|
|
|
USHORT i = 0;
|
|
|
|
pEntry = (ScOutlineEntry*) aCollections[nSubLevel].At(i);
|
|
|
|
while (pEntry)
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
2002-09-18 13:00:19 +00:00
|
|
|
if (pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd)
|
|
|
|
{
|
|
|
|
pEntry->SetVisible(bValue);
|
|
|
|
|
|
|
|
if (bSkipHidden)
|
|
|
|
if (!pEntry->IsHidden())
|
|
|
|
SetVisibleBelow( nSubLevel, i, bValue, TRUE );
|
|
|
|
}
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2002-09-18 13:00:19 +00:00
|
|
|
++i;
|
|
|
|
pEntry = (ScOutlineEntry*) aCollections[nSubLevel].At(i);
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
2002-09-18 13:00:19 +00:00
|
|
|
if (bSkipHidden)
|
|
|
|
nSubLevel = nDepth; // Abbruch
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineArray::GetRange( SCCOLROW& rStart, SCCOLROW& rEnd ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
USHORT nCount = aCollections[0].GetCount();
|
|
|
|
if (nCount)
|
|
|
|
{
|
|
|
|
rStart = ((ScOutlineEntry*) aCollections[0].At(0))->GetStart();
|
|
|
|
rEnd = ((ScOutlineEntry*) aCollections[0].At(nCount-1))->GetEnd();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rStart = rEnd = 0;
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineArray::ExtendBlock( USHORT nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
USHORT nCount;
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nStart;
|
|
|
|
SCCOLROW nEnd;
|
2000-09-18 23:16:46 +00:00
|
|
|
USHORT i;
|
|
|
|
ScOutlineEntry* pEntry;
|
|
|
|
|
|
|
|
nCount = GetCount(nLevel);
|
|
|
|
for ( i=0; i<nCount; i++ )
|
|
|
|
{
|
|
|
|
pEntry = (ScOutlineEntry*) aCollections[nLevel].At(i);
|
|
|
|
nStart = pEntry->GetStart();
|
|
|
|
nEnd = pEntry->GetEnd();
|
|
|
|
|
|
|
|
if ( rBlkStart<=nEnd && rBlkEnd>=nStart )
|
|
|
|
{
|
|
|
|
if (nStart<rBlkStart) rBlkStart = nStart;
|
|
|
|
if (nEnd>rBlkEnd) rBlkEnd = nEnd;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
BOOL ScOutlineArray::TestInsertSpace( SCSIZE nSize, SCCOLROW nMaxVal ) const
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
USHORT nCount = aCollections[0].GetCount();
|
|
|
|
if (nCount)
|
|
|
|
{
|
2004-06-04 09:26:59 +00:00
|
|
|
SCCOLROW nEnd = ((ScOutlineEntry*) aCollections[0].At(nCount-1))->GetEnd();
|
2007-02-27 11:07:18 +00:00
|
|
|
return ( sal::static_int_cast<SCCOLROW>(nEnd+nSize) <= nMaxVal );
|
2000-09-18 23:16:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
void ScOutlineArray::InsertSpace( SCCOLROW nStartPos, SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
ScSubOutlineIterator aIter( this );
|
|
|
|
ScOutlineEntry* pEntry;
|
|
|
|
while((pEntry=aIter.GetNext())!=NULL)
|
|
|
|
{
|
|
|
|
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 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00: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;
|
2000-09-18 23:16:46 +00:00
|
|
|
BOOL bNeedSave = FALSE; // Original fuer Undo benoetigt?
|
|
|
|
BOOL bChanged = FALSE; // fuer Test auf Level
|
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
bNeedSave = TRUE;
|
|
|
|
if ( nEntryStart >= nStartPos && nEntryEnd <= nEndPos ) // innen
|
|
|
|
{
|
|
|
|
aIter.DeleteLast();
|
|
|
|
bChanged = TRUE;
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2004-08-20 08:10:38 +00:00
|
|
|
BOOL ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos,
|
|
|
|
BOOL bShow, const ScBitMaskCompressedArray< SCCOLROW, BYTE>& rHiddenFlags )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
BOOL bModified = FALSE;
|
|
|
|
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
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2004-08-20 08:10:38 +00:00
|
|
|
SCCOLROW nEnd = rHiddenFlags.GetBitStateEnd( nEntryStart,
|
|
|
|
CR_HIDDEN, CR_HIDDEN);
|
|
|
|
BOOL bAllHidden = (nEntryEnd <= nEnd && nEnd <
|
|
|
|
::std::numeric_limits<SCCOLROW>::max());
|
2000-09-18 23:16:46 +00:00
|
|
|
|
2003-04-08 15:19:29 +00:00
|
|
|
BOOL bToggle = ( bShow != bAllHidden );
|
|
|
|
if ( bToggle )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
pEntry->SetHidden( !bShow );
|
|
|
|
SetVisibleBelow( aIter.LastLevel(), aIter.LastEntry(), bShow, bShow );
|
|
|
|
bModified = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bModified;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScOutlineArray::RemoveAll()
|
|
|
|
{
|
|
|
|
for (USHORT nLevel=0; nLevel<nDepth; nLevel++)
|
|
|
|
aCollections[nLevel].FreeAll();
|
|
|
|
|
|
|
|
nDepth = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScOutlineArray::Load( SvStream& rStream )
|
|
|
|
{
|
|
|
|
ScMultipleReadHeader aHdr( rStream );
|
|
|
|
|
|
|
|
rStream >> nDepth;
|
|
|
|
for (USHORT nLevel=0; nLevel<nDepth; nLevel++)
|
|
|
|
{
|
|
|
|
USHORT nCount;
|
|
|
|
rStream >> nCount;
|
|
|
|
for (USHORT nIndex=0; nIndex<nCount; nIndex++)
|
|
|
|
{
|
|
|
|
ScOutlineEntry* pEntry = new ScOutlineEntry( rStream, aHdr );
|
|
|
|
aCollections[nLevel].Insert( pEntry );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScOutlineArray::Store( SvStream& rStream )
|
|
|
|
{
|
|
|
|
ScMultipleWriteHeader aHdr( rStream );
|
|
|
|
|
|
|
|
rStream << nDepth;
|
|
|
|
for (USHORT nLevel=0; nLevel<nDepth; nLevel++)
|
|
|
|
{
|
|
|
|
USHORT nCount = aCollections[nLevel].GetCount();
|
|
|
|
rStream << nCount;
|
|
|
|
for (USHORT nIndex=0; nIndex<nCount; nIndex++)
|
|
|
|
((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->Store( rStream, aHdr );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
ScOutlineTable::ScOutlineTable()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineTable::ScOutlineTable( const ScOutlineTable& rOutline ) :
|
|
|
|
aColOutline( rOutline.aColOutline ),
|
|
|
|
aRowOutline( rOutline.aRowOutline )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
BOOL ScOutlineTable::DeleteCol( SCCOL nStartCol, SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return aColOutline.DeleteSpace( nStartCol, nSize );
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
|
2004-06-04 09:26:59 +00:00
|
|
|
BOOL ScOutlineTable::DeleteRow( SCROW nStartRow, SCSIZE nSize )
|
2000-09-18 23:16:46 +00:00
|
|
|
{
|
|
|
|
return aRowOutline.DeleteSpace( nStartRow, nSize );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScOutlineTable::Load( SvStream& rStream )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( aColOutline.GetDepth()==0 && aRowOutline.GetDepth()==0,
|
|
|
|
"Load auf nicht leere ScOutlineTable" );
|
|
|
|
aColOutline.Load( rStream );
|
|
|
|
aRowOutline.Load( rStream );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScOutlineTable::Store( SvStream& rStream )
|
|
|
|
{
|
|
|
|
aColOutline.Store( rStream );
|
|
|
|
aRowOutline.Store( rStream );
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScSubOutlineIterator::ScSubOutlineIterator( ScOutlineArray* pOutlineArray,
|
|
|
|
USHORT nLevel, USHORT nEntry ) :
|
|
|
|
pArray( pOutlineArray )
|
|
|
|
{
|
|
|
|
ScOutlineEntry* pEntry = (ScOutlineEntry*) pArray->aCollections[nLevel].At(nEntry);
|
|
|
|
nStart = pEntry->GetStart();
|
|
|
|
nEnd = pEntry->GetEnd();
|
|
|
|
nSubLevel = nLevel + 1;
|
|
|
|
nSubEntry = 0;
|
|
|
|
nDepth = pArray->nDepth;
|
|
|
|
}
|
|
|
|
|
|
|
|
ScOutlineEntry* ScSubOutlineIterator::GetNext()
|
|
|
|
{
|
|
|
|
ScOutlineEntry* pEntry;
|
|
|
|
BOOL bFound = FALSE;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (nSubLevel >= nDepth)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
pEntry = (ScOutlineEntry*) pArray->aCollections[nSubLevel].At(nSubEntry);
|
|
|
|
if (!pEntry)
|
|
|
|
{
|
|
|
|
nSubEntry = 0;
|
|
|
|
++nSubLevel;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd )
|
|
|
|
bFound = TRUE;
|
|
|
|
++nSubEntry;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
while (!bFound);
|
|
|
|
return pEntry; // nSubLevel gueltig, wenn pEntry != 0
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT ScSubOutlineIterator::LastLevel() const
|
|
|
|
{
|
|
|
|
return nSubLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
USHORT ScSubOutlineIterator::LastEntry() const
|
|
|
|
{
|
|
|
|
if (nSubEntry == 0)
|
|
|
|
{
|
|
|
|
DBG_ERROR("ScSubOutlineIterator::LastEntry vor GetNext");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return nSubEntry-1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ScSubOutlineIterator::DeleteLast()
|
|
|
|
{
|
|
|
|
if (nSubLevel >= nDepth)
|
|
|
|
{
|
|
|
|
DBG_ERROR("ScSubOutlineIterator::DeleteLast nach Ende");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (nSubEntry == 0)
|
|
|
|
{
|
|
|
|
DBG_ERROR("ScSubOutlineIterator::DeleteLast vor GetNext");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
--nSubEntry;
|
|
|
|
pArray->aCollections[nSubLevel].AtFree(nSubEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
|