1*b3f79822SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b3f79822SAndrew Rist * distributed with this work for additional information
6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance
9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b3f79822SAndrew Rist * software distributed under the License is distributed on an
15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the
17*b3f79822SAndrew Rist * specific language governing permissions and limitations
18*b3f79822SAndrew Rist * under the License.
19cdf0e10cSrcweir *
20*b3f79822SAndrew Rist *************************************************************/
21*b3f79822SAndrew Rist
22*b3f79822SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sc.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir // System - Includes -----------------------------------------------------
28cdf0e10cSrcweir
29cdf0e10cSrcweir
30cdf0e10cSrcweir
31cdf0e10cSrcweir #include <tools/debug.hxx>
32cdf0e10cSrcweir #include <limits.h>
33cdf0e10cSrcweir
34cdf0e10cSrcweir // INCLUDE ---------------------------------------------------------------
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include "olinetab.hxx"
37cdf0e10cSrcweir #include "global.hxx"
38cdf0e10cSrcweir #include "rechead.hxx"
39cdf0e10cSrcweir #include "address.hxx"
40cdf0e10cSrcweir #include "table.hxx"
41cdf0e10cSrcweir
42cdf0e10cSrcweir //------------------------------------------------------------------------
43cdf0e10cSrcweir
ScOutlineEntry(SCCOLROW nNewStart,SCCOLROW nNewSize,bool bNewHidden)44cdf0e10cSrcweir ScOutlineEntry::ScOutlineEntry( SCCOLROW nNewStart, SCCOLROW nNewSize, bool bNewHidden ) :
45cdf0e10cSrcweir nStart ( nNewStart ),
46cdf0e10cSrcweir nSize ( nNewSize ),
47cdf0e10cSrcweir bHidden ( bNewHidden ),
48cdf0e10cSrcweir bVisible( sal_True )
49cdf0e10cSrcweir {
50cdf0e10cSrcweir }
51cdf0e10cSrcweir
ScOutlineEntry(const ScOutlineEntry & rEntry)52cdf0e10cSrcweir ScOutlineEntry::ScOutlineEntry( const ScOutlineEntry& rEntry ) :
53cdf0e10cSrcweir ScDataObject(),
54cdf0e10cSrcweir nStart ( rEntry.nStart ),
55cdf0e10cSrcweir nSize ( rEntry.nSize ),
56cdf0e10cSrcweir bHidden ( rEntry.bHidden ),
57cdf0e10cSrcweir bVisible( rEntry.bVisible )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir }
60cdf0e10cSrcweir
Clone() const61cdf0e10cSrcweir ScDataObject* ScOutlineEntry::Clone() const
62cdf0e10cSrcweir {
63cdf0e10cSrcweir return new ScOutlineEntry( *this );
64cdf0e10cSrcweir }
65cdf0e10cSrcweir
Move(SCsCOLROW nDelta)66cdf0e10cSrcweir void ScOutlineEntry::Move( SCsCOLROW nDelta )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir SCCOLROW nNewPos = nStart + nDelta;
69cdf0e10cSrcweir if (nNewPos<0)
70cdf0e10cSrcweir {
71cdf0e10cSrcweir DBG_ERROR("OutlineEntry < 0");
72cdf0e10cSrcweir nNewPos = 0;
73cdf0e10cSrcweir }
74cdf0e10cSrcweir nStart = nNewPos;
75cdf0e10cSrcweir }
76cdf0e10cSrcweir
SetSize(SCSIZE nNewSize)77cdf0e10cSrcweir void ScOutlineEntry::SetSize( SCSIZE nNewSize )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir if (nNewSize>0)
80cdf0e10cSrcweir nSize = nNewSize;
81cdf0e10cSrcweir else
82cdf0e10cSrcweir {
83cdf0e10cSrcweir DBG_ERROR("ScOutlineEntry Size == 0");
84cdf0e10cSrcweir }
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
SetPosSize(SCCOLROW nNewPos,SCSIZE nNewSize)87cdf0e10cSrcweir void ScOutlineEntry::SetPosSize( SCCOLROW nNewPos, SCSIZE nNewSize )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir nStart = nNewPos;
90cdf0e10cSrcweir SetSize( nNewSize );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir
SetHidden(bool bNewHidden)93cdf0e10cSrcweir void ScOutlineEntry::SetHidden( bool bNewHidden )
94cdf0e10cSrcweir {
95cdf0e10cSrcweir bHidden = bNewHidden;
96cdf0e10cSrcweir }
97cdf0e10cSrcweir
SetVisible(bool bNewVisible)98cdf0e10cSrcweir void ScOutlineEntry::SetVisible( bool bNewVisible )
99cdf0e10cSrcweir {
100cdf0e10cSrcweir bVisible = bNewVisible;
101cdf0e10cSrcweir }
102cdf0e10cSrcweir
103cdf0e10cSrcweir //------------------------------------------------------------------------
104cdf0e10cSrcweir
ScOutlineCollection()105cdf0e10cSrcweir ScOutlineCollection::ScOutlineCollection() :
106cdf0e10cSrcweir ScSortedCollection( 4,4,sal_False )
107cdf0e10cSrcweir {
108cdf0e10cSrcweir }
109cdf0e10cSrcweir
IntCompare(SCCOLROW nX,SCCOLROW nY)110cdf0e10cSrcweir inline short IntCompare( SCCOLROW nX, SCCOLROW nY )
111cdf0e10cSrcweir {
112cdf0e10cSrcweir if ( nX==nY ) return 0;
113cdf0e10cSrcweir else if ( nX<nY ) return -1;
114cdf0e10cSrcweir else return 1;
115cdf0e10cSrcweir }
116cdf0e10cSrcweir
Compare(ScDataObject * pKey1,ScDataObject * pKey2) const117cdf0e10cSrcweir short ScOutlineCollection::Compare(ScDataObject* pKey1, ScDataObject* pKey2) const
118cdf0e10cSrcweir {
119cdf0e10cSrcweir return IntCompare( ((ScOutlineEntry*)pKey1)->GetStart(),
120cdf0e10cSrcweir ((ScOutlineEntry*)pKey2)->GetStart() );
121cdf0e10cSrcweir }
122cdf0e10cSrcweir
FindStart(SCCOLROW nMinStart)123cdf0e10cSrcweir sal_uInt16 ScOutlineCollection::FindStart( SCCOLROW nMinStart )
124cdf0e10cSrcweir {
125cdf0e10cSrcweir //! binaer suchen ?
126cdf0e10cSrcweir
127cdf0e10cSrcweir sal_uInt16 nPos = 0;
128cdf0e10cSrcweir sal_uInt16 nLocalCount = GetCount();
129cdf0e10cSrcweir while ( (nPos<nLocalCount) ? (((ScOutlineEntry*)At(nPos))->GetStart() < nMinStart) : sal_False )
130cdf0e10cSrcweir ++nPos;
131cdf0e10cSrcweir
132cdf0e10cSrcweir return nPos;
133cdf0e10cSrcweir }
134cdf0e10cSrcweir
135cdf0e10cSrcweir //------------------------------------------------------------------------
136cdf0e10cSrcweir
ScOutlineArray()137cdf0e10cSrcweir ScOutlineArray::ScOutlineArray() :
138cdf0e10cSrcweir nDepth( 0 )
139cdf0e10cSrcweir {
140cdf0e10cSrcweir }
141cdf0e10cSrcweir
ScOutlineArray(const ScOutlineArray & rArray)142cdf0e10cSrcweir ScOutlineArray::ScOutlineArray( const ScOutlineArray& rArray ) :
143cdf0e10cSrcweir nDepth( rArray.nDepth )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir for (sal_uInt16 nLevel=0; nLevel<nDepth; nLevel++)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir sal_uInt16 nCount = rArray.aCollections[nLevel].GetCount();
148cdf0e10cSrcweir for (sal_uInt16 nEntry=0; nEntry<nCount; nEntry++)
149cdf0e10cSrcweir {
150cdf0e10cSrcweir ScOutlineEntry* pEntry = (ScOutlineEntry*) rArray.aCollections[nLevel].At(nEntry);
151cdf0e10cSrcweir aCollections[nLevel].Insert( new ScOutlineEntry( *pEntry ) );
152cdf0e10cSrcweir }
153cdf0e10cSrcweir }
154cdf0e10cSrcweir }
155cdf0e10cSrcweir
FindEntry(SCCOLROW nSearchPos,sal_uInt16 & rFindLevel,sal_uInt16 & rFindIndex,sal_uInt16 nMaxLevel)156cdf0e10cSrcweir void ScOutlineArray::FindEntry( SCCOLROW nSearchPos, sal_uInt16& rFindLevel, sal_uInt16& rFindIndex,
157cdf0e10cSrcweir sal_uInt16 nMaxLevel )
158cdf0e10cSrcweir {
159cdf0e10cSrcweir rFindLevel = rFindIndex = 0;
160cdf0e10cSrcweir
161cdf0e10cSrcweir if (nMaxLevel > nDepth)
162cdf0e10cSrcweir nMaxLevel = nDepth;
163cdf0e10cSrcweir
164cdf0e10cSrcweir for (sal_uInt16 nLevel=0; nLevel<nMaxLevel; nLevel++) //! rueckwaerts suchen ?
165cdf0e10cSrcweir {
166cdf0e10cSrcweir ScOutlineCollection* pCollect = &aCollections[nLevel];
167cdf0e10cSrcweir sal_uInt16 nCount = pCollect->GetCount();
168cdf0e10cSrcweir for (sal_uInt16 i=0; i<nCount; i++)
169cdf0e10cSrcweir {
170cdf0e10cSrcweir ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
171cdf0e10cSrcweir if ( pEntry->GetStart() <= nSearchPos && pEntry->GetEnd() >= nSearchPos )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir rFindLevel = nLevel + 1; // naechster Level (zum Einfuegen)
174cdf0e10cSrcweir rFindIndex = i;
175cdf0e10cSrcweir }
176cdf0e10cSrcweir }
177cdf0e10cSrcweir }
178cdf0e10cSrcweir }
179cdf0e10cSrcweir
Insert(SCCOLROW nStartCol,SCCOLROW nEndCol,sal_Bool & rSizeChanged,sal_Bool bHidden,sal_Bool bVisible)180cdf0e10cSrcweir sal_Bool ScOutlineArray::Insert( SCCOLROW nStartCol, SCCOLROW nEndCol, sal_Bool& rSizeChanged,
181cdf0e10cSrcweir sal_Bool bHidden, sal_Bool bVisible )
182cdf0e10cSrcweir {
183cdf0e10cSrcweir rSizeChanged = sal_False;
184cdf0e10cSrcweir
185cdf0e10cSrcweir sal_uInt16 nStartLevel;
186cdf0e10cSrcweir sal_uInt16 nStartIndex;
187cdf0e10cSrcweir sal_uInt16 nEndLevel;
188cdf0e10cSrcweir sal_uInt16 nEndIndex;
189cdf0e10cSrcweir sal_Bool bFound = sal_False;
190cdf0e10cSrcweir
191cdf0e10cSrcweir sal_Bool bCont;
192cdf0e10cSrcweir sal_uInt16 nFindMax;
193cdf0e10cSrcweir FindEntry( nStartCol, nStartLevel, nStartIndex ); // nLevel = neuer Level (alter+1) !!!
194cdf0e10cSrcweir FindEntry( nEndCol, nEndLevel, nEndIndex );
195cdf0e10cSrcweir nFindMax = Max(nStartLevel,nEndLevel);
196cdf0e10cSrcweir do
197cdf0e10cSrcweir {
198cdf0e10cSrcweir bCont = sal_False;
199cdf0e10cSrcweir
200cdf0e10cSrcweir if ( nStartLevel == nEndLevel && nStartIndex == nEndIndex && nStartLevel < SC_OL_MAXDEPTH )
201cdf0e10cSrcweir bFound = sal_True;
202cdf0e10cSrcweir
203cdf0e10cSrcweir if (!bFound)
204cdf0e10cSrcweir {
205cdf0e10cSrcweir if (nFindMax>0)
206cdf0e10cSrcweir {
207cdf0e10cSrcweir --nFindMax;
208cdf0e10cSrcweir if (nStartLevel)
209cdf0e10cSrcweir if ( ((ScOutlineEntry*)aCollections[nStartLevel-1].At(nStartIndex))->
210cdf0e10cSrcweir GetStart() == nStartCol )
211cdf0e10cSrcweir FindEntry( nStartCol, nStartLevel, nStartIndex, nFindMax );
212cdf0e10cSrcweir if (nEndLevel)
213cdf0e10cSrcweir if ( ((ScOutlineEntry*)aCollections[nEndLevel-1].At(nEndIndex))->
214cdf0e10cSrcweir GetEnd() == nEndCol )
215cdf0e10cSrcweir FindEntry( nEndCol, nEndLevel, nEndIndex, nFindMax );
216cdf0e10cSrcweir bCont = sal_True;
217cdf0e10cSrcweir }
218cdf0e10cSrcweir }
219cdf0e10cSrcweir }
220cdf0e10cSrcweir while ( !bFound && bCont );
221cdf0e10cSrcweir
222cdf0e10cSrcweir if (!bFound)
223cdf0e10cSrcweir return sal_False;
224cdf0e10cSrcweir
225cdf0e10cSrcweir sal_uInt16 nLevel = nStartLevel;
226cdf0e10cSrcweir
227cdf0e10cSrcweir // untere verschieben
228cdf0e10cSrcweir
229cdf0e10cSrcweir sal_Bool bNeedSize = sal_False;
230cdf0e10cSrcweir for ( short nMoveLevel = nDepth-1; nMoveLevel >= (short) nLevel; nMoveLevel-- )
231cdf0e10cSrcweir {
232cdf0e10cSrcweir sal_uInt16 nCount = aCollections[nMoveLevel].GetCount();
233cdf0e10cSrcweir sal_Bool bMoved = sal_False;
234cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nCount; i += bMoved ? 0 : 1 )
235cdf0e10cSrcweir {
236cdf0e10cSrcweir ScOutlineEntry* pEntry = (ScOutlineEntry*) aCollections[nMoveLevel].At(i);
237cdf0e10cSrcweir SCCOLROW nEntryStart = pEntry->GetStart();
238cdf0e10cSrcweir if ( nEntryStart >= nStartCol && nEntryStart <= nEndCol )
239cdf0e10cSrcweir {
240cdf0e10cSrcweir if (nMoveLevel >= SC_OL_MAXDEPTH - 1)
241cdf0e10cSrcweir {
242cdf0e10cSrcweir rSizeChanged = sal_False; // kein Platz
243cdf0e10cSrcweir return sal_False;
244cdf0e10cSrcweir }
245cdf0e10cSrcweir aCollections[nMoveLevel+1].Insert( new ScOutlineEntry( *pEntry ) );
246cdf0e10cSrcweir aCollections[nMoveLevel].AtFree( i );
247cdf0e10cSrcweir nCount = aCollections[nMoveLevel].GetCount();
248cdf0e10cSrcweir bMoved = sal_True;
249cdf0e10cSrcweir if (nMoveLevel == (short) nDepth - 1)
250cdf0e10cSrcweir bNeedSize = sal_True;
251cdf0e10cSrcweir }
252cdf0e10cSrcweir else
253cdf0e10cSrcweir bMoved = sal_False;
254cdf0e10cSrcweir }
255cdf0e10cSrcweir }
256cdf0e10cSrcweir
257cdf0e10cSrcweir if (bNeedSize)
258cdf0e10cSrcweir {
259cdf0e10cSrcweir ++nDepth;
260cdf0e10cSrcweir rSizeChanged = sal_True;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir
263cdf0e10cSrcweir if (nDepth <= nLevel)
264cdf0e10cSrcweir {
265cdf0e10cSrcweir nDepth = nLevel+1;
266cdf0e10cSrcweir rSizeChanged = sal_True;
267cdf0e10cSrcweir }
268cdf0e10cSrcweir
269cdf0e10cSrcweir /* nicht zusammenfassen!
270cdf0e10cSrcweir
271cdf0e10cSrcweir // zusammenfassen
272cdf0e10cSrcweir
273cdf0e10cSrcweir sal_uInt16 nCount = aCollections[nLevel].GetCount();
274cdf0e10cSrcweir sal_uInt16 nIndex;
275cdf0e10cSrcweir bFound = sal_False;
276cdf0e10cSrcweir for ( nIndex=0; nIndex<nCount && !bFound; nIndex++ )
277cdf0e10cSrcweir {
278cdf0e10cSrcweir if ( ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetEnd() + 1 == nStartCol )
279cdf0e10cSrcweir {
280cdf0e10cSrcweir nStartCol = ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetStart();
281cdf0e10cSrcweir aCollections[nLevel].AtFree(nIndex);
282cdf0e10cSrcweir nCount = aCollections[nLevel].GetCount(); // Daten geaendert
283cdf0e10cSrcweir bFound = sal_True;
284cdf0e10cSrcweir }
285cdf0e10cSrcweir }
286cdf0e10cSrcweir
287cdf0e10cSrcweir bFound = sal_False;
288cdf0e10cSrcweir for ( nIndex=0; nIndex<nCount && !bFound; nIndex++ )
289cdf0e10cSrcweir {
290cdf0e10cSrcweir if ( ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetStart() == nEndCol + 1 )
291cdf0e10cSrcweir {
292cdf0e10cSrcweir nEndCol = ((ScOutlineEntry*) aCollections[nLevel].At(nIndex))->GetEnd();
293cdf0e10cSrcweir aCollections[nLevel].AtFree(nIndex);
294cdf0e10cSrcweir bFound = sal_True;
295cdf0e10cSrcweir }
296cdf0e10cSrcweir }
297cdf0e10cSrcweir */
298cdf0e10cSrcweir ScOutlineEntry* pNewEntry = new ScOutlineEntry( nStartCol, nEndCol+1-nStartCol, bHidden );
299cdf0e10cSrcweir pNewEntry->SetVisible( bVisible );
300cdf0e10cSrcweir aCollections[nLevel].Insert( pNewEntry );
301cdf0e10cSrcweir
302cdf0e10cSrcweir return sal_True;
303cdf0e10cSrcweir }
304cdf0e10cSrcweir
FindTouchedLevel(SCCOLROW nBlockStart,SCCOLROW nBlockEnd,sal_uInt16 & rFindLevel) const305cdf0e10cSrcweir sal_Bool ScOutlineArray::FindTouchedLevel( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, sal_uInt16& rFindLevel ) const
306cdf0e10cSrcweir {
307cdf0e10cSrcweir sal_Bool bFound = sal_False;
308cdf0e10cSrcweir rFindLevel = 0;
309cdf0e10cSrcweir
310cdf0e10cSrcweir for (sal_uInt16 nLevel=0; nLevel<nDepth; nLevel++)
311cdf0e10cSrcweir {
312cdf0e10cSrcweir const ScOutlineCollection* pCollect = &aCollections[nLevel];
313cdf0e10cSrcweir sal_uInt16 nCount = pCollect->GetCount();
314cdf0e10cSrcweir for (sal_uInt16 i=0; i<nCount; i++)
315cdf0e10cSrcweir {
316cdf0e10cSrcweir ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
317cdf0e10cSrcweir SCCOLROW nStart = pEntry->GetStart();
318cdf0e10cSrcweir SCCOLROW nEnd = pEntry->GetEnd();
319cdf0e10cSrcweir
320cdf0e10cSrcweir if ( ( nBlockStart>=nStart && nBlockStart<=nEnd ) ||
321cdf0e10cSrcweir ( nBlockEnd >=nStart && nBlockEnd <=nEnd ) )
322cdf0e10cSrcweir {
323cdf0e10cSrcweir rFindLevel = nLevel; // wirklicher Level
324cdf0e10cSrcweir bFound = sal_True;
325cdf0e10cSrcweir }
326cdf0e10cSrcweir }
327cdf0e10cSrcweir }
328cdf0e10cSrcweir
329cdf0e10cSrcweir return bFound;
330cdf0e10cSrcweir }
331cdf0e10cSrcweir
RemoveSub(SCCOLROW nStartPos,SCCOLROW nEndPos,sal_uInt16 nLevel)332cdf0e10cSrcweir void ScOutlineArray::RemoveSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nLevel )
333cdf0e10cSrcweir {
334cdf0e10cSrcweir if ( nLevel >= nDepth )
335cdf0e10cSrcweir return;
336cdf0e10cSrcweir ScOutlineCollection* pCollect = &aCollections[nLevel];
337cdf0e10cSrcweir sal_uInt16 nCount = pCollect->GetCount();
338cdf0e10cSrcweir sal_Bool bFound = sal_False;
339cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nCount; i += ( bFound ? 0 : 1 ) )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir bFound = sal_False;
342cdf0e10cSrcweir ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
343cdf0e10cSrcweir SCCOLROW nStart = pEntry->GetStart();
344cdf0e10cSrcweir SCCOLROW nEnd = pEntry->GetEnd();
345cdf0e10cSrcweir
346cdf0e10cSrcweir if ( nStart>=nStartPos && nEnd<=nEndPos )
347cdf0e10cSrcweir {
348cdf0e10cSrcweir RemoveSub( nStart, nEnd, nLevel+1 );
349cdf0e10cSrcweir pCollect->AtFree(i);
350cdf0e10cSrcweir nCount = pCollect->GetCount();
351cdf0e10cSrcweir bFound = sal_True;
352cdf0e10cSrcweir }
353cdf0e10cSrcweir }
354cdf0e10cSrcweir }
355cdf0e10cSrcweir
PromoteSub(SCCOLROW nStartPos,SCCOLROW nEndPos,sal_uInt16 nStartLevel)356cdf0e10cSrcweir void ScOutlineArray::PromoteSub( SCCOLROW nStartPos, SCCOLROW nEndPos, sal_uInt16 nStartLevel )
357cdf0e10cSrcweir {
358cdf0e10cSrcweir if (nStartLevel==0)
359cdf0e10cSrcweir {
360cdf0e10cSrcweir DBG_ERROR("PromoteSub mit Level 0");
361cdf0e10cSrcweir return;
362cdf0e10cSrcweir }
363cdf0e10cSrcweir
364cdf0e10cSrcweir for (sal_uInt16 nLevel = nStartLevel; nLevel < nDepth; nLevel++)
365cdf0e10cSrcweir {
366cdf0e10cSrcweir ScOutlineCollection* pCollect = &aCollections[nLevel];
367cdf0e10cSrcweir sal_uInt16 nCount = pCollect->GetCount();
368cdf0e10cSrcweir sal_Bool bFound = sal_False;
369cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nCount; i += ( bFound ? 0 : 1 ) )
370cdf0e10cSrcweir {
371cdf0e10cSrcweir bFound = sal_False;
372cdf0e10cSrcweir ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
373cdf0e10cSrcweir SCCOLROW nStart = pEntry->GetStart();
374cdf0e10cSrcweir SCCOLROW nEnd = pEntry->GetEnd();
375cdf0e10cSrcweir
376cdf0e10cSrcweir if ( nStart>=nStartPos && nEnd<=nEndPos )
377cdf0e10cSrcweir {
378cdf0e10cSrcweir aCollections[nLevel-1].Insert( new ScOutlineEntry( *pEntry ) );
379cdf0e10cSrcweir pCollect->AtFree(i);
380cdf0e10cSrcweir nCount = pCollect->GetCount();
381cdf0e10cSrcweir bFound = sal_True;
382cdf0e10cSrcweir }
383cdf0e10cSrcweir }
384cdf0e10cSrcweir }
385cdf0e10cSrcweir }
386cdf0e10cSrcweir
DecDepth()387cdf0e10cSrcweir sal_Bool ScOutlineArray::DecDepth() // nDepth auf leere Levels anpassen
388cdf0e10cSrcweir {
389cdf0e10cSrcweir sal_Bool bChanged = sal_False;
390cdf0e10cSrcweir sal_Bool bCont;
391cdf0e10cSrcweir do
392cdf0e10cSrcweir {
393cdf0e10cSrcweir bCont = sal_False;
394cdf0e10cSrcweir if (nDepth)
395cdf0e10cSrcweir if (aCollections[nDepth-1].GetCount() == 0)
396cdf0e10cSrcweir {
397cdf0e10cSrcweir --nDepth;
398cdf0e10cSrcweir bChanged = sal_True;
399cdf0e10cSrcweir bCont = sal_True;
400cdf0e10cSrcweir }
401cdf0e10cSrcweir }
402cdf0e10cSrcweir while (bCont);
403cdf0e10cSrcweir return bChanged;
404cdf0e10cSrcweir }
405cdf0e10cSrcweir
Remove(SCCOLROW nBlockStart,SCCOLROW nBlockEnd,sal_Bool & rSizeChanged)406cdf0e10cSrcweir sal_Bool ScOutlineArray::Remove( SCCOLROW nBlockStart, SCCOLROW nBlockEnd, sal_Bool& rSizeChanged )
407cdf0e10cSrcweir {
408cdf0e10cSrcweir sal_uInt16 nLevel;
409cdf0e10cSrcweir FindTouchedLevel( nBlockStart, nBlockEnd, nLevel );
410cdf0e10cSrcweir
411cdf0e10cSrcweir ScOutlineCollection* pCollect = &aCollections[nLevel];
412cdf0e10cSrcweir sal_uInt16 nCount = pCollect->GetCount();
413cdf0e10cSrcweir sal_Bool bFound = sal_False;
414cdf0e10cSrcweir sal_Bool bAny = sal_False;
415cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nCount; i += ( bFound ? 0 : 1 ) )
416cdf0e10cSrcweir {
417cdf0e10cSrcweir bFound = sal_False;
418cdf0e10cSrcweir ScOutlineEntry* pEntry = (ScOutlineEntry*) pCollect->At(i);
419cdf0e10cSrcweir SCCOLROW nStart = pEntry->GetStart();
420cdf0e10cSrcweir SCCOLROW nEnd = pEntry->GetEnd();
421cdf0e10cSrcweir
422cdf0e10cSrcweir if ( nBlockStart<=nEnd && nBlockEnd>=nStart )
423cdf0e10cSrcweir {
424cdf0e10cSrcweir // RemoveSub( nStart, nEnd, nLevel+1 );
425cdf0e10cSrcweir pCollect->AtFree(i);
426cdf0e10cSrcweir PromoteSub( nStart, nEnd, nLevel+1 );
427cdf0e10cSrcweir nCount = pCollect->GetCount();
428cdf0e10cSrcweir i = pCollect->FindStart( nEnd+1 );
429cdf0e10cSrcweir bFound = sal_True;
430cdf0e10cSrcweir bAny = sal_True;
431cdf0e10cSrcweir }
432cdf0e10cSrcweir }
433cdf0e10cSrcweir
434cdf0e10cSrcweir if (bAny) // Depth anpassen
435cdf0e10cSrcweir if (DecDepth())
436cdf0e10cSrcweir rSizeChanged = sal_True;
437cdf0e10cSrcweir
438cdf0e10cSrcweir return bAny;
439cdf0e10cSrcweir }
440cdf0e10cSrcweir
GetEntry(sal_uInt16 nLevel,sal_uInt16 nIndex) const441cdf0e10cSrcweir ScOutlineEntry* ScOutlineArray::GetEntry( sal_uInt16 nLevel, sal_uInt16 nIndex ) const
442cdf0e10cSrcweir {
443cdf0e10cSrcweir return (ScOutlineEntry*)((nLevel < nDepth) ? aCollections[nLevel].At(nIndex) : NULL);
444cdf0e10cSrcweir }
445cdf0e10cSrcweir
GetCount(sal_uInt16 nLevel) const446cdf0e10cSrcweir sal_uInt16 ScOutlineArray::GetCount( sal_uInt16 nLevel ) const
447cdf0e10cSrcweir {
448cdf0e10cSrcweir return (nLevel < nDepth) ? aCollections[nLevel].GetCount() : 0;
449cdf0e10cSrcweir }
450cdf0e10cSrcweir
GetEntryByPos(sal_uInt16 nLevel,SCCOLROW nPos) const451cdf0e10cSrcweir ScOutlineEntry* ScOutlineArray::GetEntryByPos( sal_uInt16 nLevel, SCCOLROW nPos ) const
452cdf0e10cSrcweir {
453cdf0e10cSrcweir sal_uInt16 nCount = GetCount( nLevel );
454cdf0e10cSrcweir ScOutlineEntry* pEntry;
455cdf0e10cSrcweir
456cdf0e10cSrcweir for (sal_uInt16 nIndex = 0; nIndex < nCount; nIndex++)
457cdf0e10cSrcweir {
458cdf0e10cSrcweir pEntry = GetEntry( nLevel, nIndex );
459cdf0e10cSrcweir if ((pEntry->GetStart() <= nPos) && (nPos <= pEntry->GetEnd()))
460cdf0e10cSrcweir return pEntry;
461cdf0e10cSrcweir }
462cdf0e10cSrcweir return NULL;
463cdf0e10cSrcweir }
464cdf0e10cSrcweir
GetEntryIndex(sal_uInt16 nLevel,SCCOLROW nPos,sal_uInt16 & rnIndex) const465cdf0e10cSrcweir sal_Bool ScOutlineArray::GetEntryIndex( sal_uInt16 nLevel, SCCOLROW nPos, sal_uInt16& rnIndex ) const
466cdf0e10cSrcweir {
467cdf0e10cSrcweir // found entry contains passed position
468cdf0e10cSrcweir sal_uInt16 nCount = GetCount( nLevel );
469cdf0e10cSrcweir for ( rnIndex = 0; rnIndex < nCount; ++rnIndex )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir const ScOutlineEntry* pEntry = GetEntry( nLevel, rnIndex );
472cdf0e10cSrcweir if ( (pEntry->GetStart() <= nPos) && (nPos <= pEntry->GetEnd()) )
473cdf0e10cSrcweir return sal_True;
474cdf0e10cSrcweir }
475cdf0e10cSrcweir return sal_False;
476cdf0e10cSrcweir }
477cdf0e10cSrcweir
GetEntryIndexInRange(sal_uInt16 nLevel,SCCOLROW nBlockStart,SCCOLROW nBlockEnd,sal_uInt16 & rnIndex) const478cdf0e10cSrcweir sal_Bool ScOutlineArray::GetEntryIndexInRange(
479cdf0e10cSrcweir sal_uInt16 nLevel, SCCOLROW nBlockStart, SCCOLROW nBlockEnd, sal_uInt16& rnIndex ) const
480cdf0e10cSrcweir {
481cdf0e10cSrcweir // found entry will be completely inside of passed range
482cdf0e10cSrcweir sal_uInt16 nCount = GetCount( nLevel );
483cdf0e10cSrcweir for ( rnIndex = 0; rnIndex < nCount; ++rnIndex )
484cdf0e10cSrcweir {
485cdf0e10cSrcweir const ScOutlineEntry* pEntry = GetEntry( nLevel, rnIndex );
486cdf0e10cSrcweir if ( (nBlockStart <= pEntry->GetStart()) && (pEntry->GetEnd() <= nBlockEnd) )
487cdf0e10cSrcweir return sal_True;
488cdf0e10cSrcweir }
489cdf0e10cSrcweir return sal_False;
490cdf0e10cSrcweir }
491cdf0e10cSrcweir
SetVisibleBelow(sal_uInt16 nLevel,sal_uInt16 nEntry,sal_Bool bValue,sal_Bool bSkipHidden)492cdf0e10cSrcweir void ScOutlineArray::SetVisibleBelow( sal_uInt16 nLevel, sal_uInt16 nEntry, sal_Bool bValue, sal_Bool bSkipHidden )
493cdf0e10cSrcweir {
494cdf0e10cSrcweir ScOutlineEntry* pEntry = GetEntry( nLevel, nEntry );
495cdf0e10cSrcweir if( pEntry )
496cdf0e10cSrcweir {
497cdf0e10cSrcweir SCCOLROW nStart = pEntry->GetStart();
498cdf0e10cSrcweir SCCOLROW nEnd = pEntry->GetEnd();
499cdf0e10cSrcweir
500cdf0e10cSrcweir for (sal_uInt16 nSubLevel=nLevel+1; nSubLevel<nDepth; nSubLevel++)
501cdf0e10cSrcweir {
502cdf0e10cSrcweir sal_uInt16 i = 0;
503cdf0e10cSrcweir pEntry = (ScOutlineEntry*) aCollections[nSubLevel].At(i);
504cdf0e10cSrcweir while (pEntry)
505cdf0e10cSrcweir {
506cdf0e10cSrcweir if (pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd)
507cdf0e10cSrcweir {
508cdf0e10cSrcweir pEntry->SetVisible(bValue);
509cdf0e10cSrcweir
510cdf0e10cSrcweir if (bSkipHidden)
511cdf0e10cSrcweir if (!pEntry->IsHidden())
512cdf0e10cSrcweir SetVisibleBelow( nSubLevel, i, bValue, sal_True );
513cdf0e10cSrcweir }
514cdf0e10cSrcweir
515cdf0e10cSrcweir ++i;
516cdf0e10cSrcweir pEntry = (ScOutlineEntry*) aCollections[nSubLevel].At(i);
517cdf0e10cSrcweir }
518cdf0e10cSrcweir
519cdf0e10cSrcweir if (bSkipHidden)
520cdf0e10cSrcweir nSubLevel = nDepth; // Abbruch
521cdf0e10cSrcweir }
522cdf0e10cSrcweir }
523cdf0e10cSrcweir }
524cdf0e10cSrcweir
GetRange(SCCOLROW & rStart,SCCOLROW & rEnd) const525cdf0e10cSrcweir void ScOutlineArray::GetRange( SCCOLROW& rStart, SCCOLROW& rEnd ) const
526cdf0e10cSrcweir {
527cdf0e10cSrcweir sal_uInt16 nCount = aCollections[0].GetCount();
528cdf0e10cSrcweir if (nCount)
529cdf0e10cSrcweir {
530cdf0e10cSrcweir rStart = ((ScOutlineEntry*) aCollections[0].At(0))->GetStart();
531cdf0e10cSrcweir rEnd = ((ScOutlineEntry*) aCollections[0].At(nCount-1))->GetEnd();
532cdf0e10cSrcweir }
533cdf0e10cSrcweir else
534cdf0e10cSrcweir rStart = rEnd = 0;
535cdf0e10cSrcweir }
536cdf0e10cSrcweir
ExtendBlock(sal_uInt16 nLevel,SCCOLROW & rBlkStart,SCCOLROW & rBlkEnd)537cdf0e10cSrcweir void ScOutlineArray::ExtendBlock( sal_uInt16 nLevel, SCCOLROW& rBlkStart, SCCOLROW& rBlkEnd )
538cdf0e10cSrcweir {
539cdf0e10cSrcweir sal_uInt16 nCount;
540cdf0e10cSrcweir SCCOLROW nStart;
541cdf0e10cSrcweir SCCOLROW nEnd;
542cdf0e10cSrcweir sal_uInt16 i;
543cdf0e10cSrcweir ScOutlineEntry* pEntry;
544cdf0e10cSrcweir
545cdf0e10cSrcweir nCount = GetCount(nLevel);
546cdf0e10cSrcweir for ( i=0; i<nCount; i++ )
547cdf0e10cSrcweir {
548cdf0e10cSrcweir pEntry = (ScOutlineEntry*) aCollections[nLevel].At(i);
549cdf0e10cSrcweir nStart = pEntry->GetStart();
550cdf0e10cSrcweir nEnd = pEntry->GetEnd();
551cdf0e10cSrcweir
552cdf0e10cSrcweir if ( rBlkStart<=nEnd && rBlkEnd>=nStart )
553cdf0e10cSrcweir {
554cdf0e10cSrcweir if (nStart<rBlkStart) rBlkStart = nStart;
555cdf0e10cSrcweir if (nEnd>rBlkEnd) rBlkEnd = nEnd;
556cdf0e10cSrcweir }
557cdf0e10cSrcweir }
558cdf0e10cSrcweir }
559cdf0e10cSrcweir
TestInsertSpace(SCSIZE nSize,SCCOLROW nMaxVal) const560cdf0e10cSrcweir sal_Bool ScOutlineArray::TestInsertSpace( SCSIZE nSize, SCCOLROW nMaxVal ) const
561cdf0e10cSrcweir {
562cdf0e10cSrcweir sal_uInt16 nCount = aCollections[0].GetCount();
563cdf0e10cSrcweir if (nCount)
564cdf0e10cSrcweir {
565cdf0e10cSrcweir SCCOLROW nEnd = ((ScOutlineEntry*) aCollections[0].At(nCount-1))->GetEnd();
566cdf0e10cSrcweir return ( sal::static_int_cast<SCCOLROW>(nEnd+nSize) <= nMaxVal );
567cdf0e10cSrcweir }
568cdf0e10cSrcweir
569cdf0e10cSrcweir return sal_True;
570cdf0e10cSrcweir }
571cdf0e10cSrcweir
InsertSpace(SCCOLROW nStartPos,SCSIZE nSize)572cdf0e10cSrcweir void ScOutlineArray::InsertSpace( SCCOLROW nStartPos, SCSIZE nSize )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir ScSubOutlineIterator aIter( this );
575cdf0e10cSrcweir ScOutlineEntry* pEntry;
576cdf0e10cSrcweir while((pEntry=aIter.GetNext())!=NULL)
577cdf0e10cSrcweir {
578cdf0e10cSrcweir if ( pEntry->GetStart() >= nStartPos )
579cdf0e10cSrcweir pEntry->Move(static_cast<SCsCOLROW>(nSize));
580cdf0e10cSrcweir else
581cdf0e10cSrcweir {
582cdf0e10cSrcweir SCCOLROW nEnd = pEntry->GetEnd();
583cdf0e10cSrcweir // immer erweitern, wenn innerhalb der Gruppe eingefuegt
584cdf0e10cSrcweir // beim Einfuegen am Ende nur, wenn die Gruppe nicht ausgeblendet ist
585cdf0e10cSrcweir if ( nEnd >= nStartPos || ( nEnd+1 >= nStartPos && !pEntry->IsHidden() ) )
586cdf0e10cSrcweir {
587cdf0e10cSrcweir SCSIZE nEntrySize = pEntry->GetSize();
588cdf0e10cSrcweir nEntrySize += nSize;
589cdf0e10cSrcweir pEntry->SetSize( nEntrySize );
590cdf0e10cSrcweir }
591cdf0e10cSrcweir }
592cdf0e10cSrcweir }
593cdf0e10cSrcweir }
594cdf0e10cSrcweir
DeleteSpace(SCCOLROW nStartPos,SCSIZE nSize)595cdf0e10cSrcweir sal_Bool ScOutlineArray::DeleteSpace( SCCOLROW nStartPos, SCSIZE nSize )
596cdf0e10cSrcweir {
597cdf0e10cSrcweir SCCOLROW nEndPos = nStartPos + nSize - 1;
598cdf0e10cSrcweir sal_Bool bNeedSave = sal_False; // Original fuer Undo benoetigt?
599cdf0e10cSrcweir sal_Bool bChanged = sal_False; // fuer Test auf Level
600cdf0e10cSrcweir
601cdf0e10cSrcweir ScSubOutlineIterator aIter( this );
602cdf0e10cSrcweir ScOutlineEntry* pEntry;
603cdf0e10cSrcweir while((pEntry=aIter.GetNext())!=NULL)
604cdf0e10cSrcweir {
605cdf0e10cSrcweir SCCOLROW nEntryStart = pEntry->GetStart();
606cdf0e10cSrcweir SCCOLROW nEntryEnd = pEntry->GetEnd();
607cdf0e10cSrcweir SCSIZE nEntrySize = pEntry->GetSize();
608cdf0e10cSrcweir
609cdf0e10cSrcweir if ( nEntryEnd >= nStartPos )
610cdf0e10cSrcweir {
611cdf0e10cSrcweir if ( nEntryStart > nEndPos ) // rechts
612cdf0e10cSrcweir pEntry->Move(-(static_cast<SCsCOLROW>(nSize)));
613cdf0e10cSrcweir else if ( nEntryStart < nStartPos && nEntryEnd >= nEndPos ) // aussen
614cdf0e10cSrcweir pEntry->SetSize( nEntrySize-nSize );
615cdf0e10cSrcweir else
616cdf0e10cSrcweir {
617cdf0e10cSrcweir bNeedSave = sal_True;
618cdf0e10cSrcweir if ( nEntryStart >= nStartPos && nEntryEnd <= nEndPos ) // innen
619cdf0e10cSrcweir {
620cdf0e10cSrcweir aIter.DeleteLast();
621cdf0e10cSrcweir bChanged = sal_True;
622cdf0e10cSrcweir }
623cdf0e10cSrcweir else if ( nEntryStart >= nStartPos ) // rechts ueber
624cdf0e10cSrcweir pEntry->SetPosSize( nStartPos, static_cast<SCSIZE>(nEntryEnd-nEndPos) );
625cdf0e10cSrcweir else // links ueber
626cdf0e10cSrcweir pEntry->SetSize( static_cast<SCSIZE>(nStartPos-nEntryStart) );
627cdf0e10cSrcweir }
628cdf0e10cSrcweir }
629cdf0e10cSrcweir }
630cdf0e10cSrcweir
631cdf0e10cSrcweir if (bChanged)
632cdf0e10cSrcweir DecDepth();
633cdf0e10cSrcweir
634cdf0e10cSrcweir return bNeedSave;
635cdf0e10cSrcweir }
636cdf0e10cSrcweir
ManualAction(SCCOLROW nStartPos,SCCOLROW nEndPos,bool bShow,ScTable & rTable,bool bCol)637cdf0e10cSrcweir bool ScOutlineArray::ManualAction( SCCOLROW nStartPos, SCCOLROW nEndPos, bool bShow, ScTable& rTable, bool bCol )
638cdf0e10cSrcweir {
639cdf0e10cSrcweir bool bModified = false;
640cdf0e10cSrcweir ScSubOutlineIterator aIter( this );
641cdf0e10cSrcweir ScOutlineEntry* pEntry;
642cdf0e10cSrcweir while((pEntry=aIter.GetNext())!=NULL)
643cdf0e10cSrcweir {
644cdf0e10cSrcweir SCCOLROW nEntryStart = pEntry->GetStart();
645cdf0e10cSrcweir SCCOLROW nEntryEnd = pEntry->GetEnd();
646cdf0e10cSrcweir
647cdf0e10cSrcweir if (nEntryEnd>=nStartPos && nEntryStart<=nEndPos)
648cdf0e10cSrcweir {
649cdf0e10cSrcweir if ( pEntry->IsHidden() == bShow )
650cdf0e10cSrcweir {
651cdf0e10cSrcweir // #i12341# hide if all columns/rows are hidden, show if at least one
652cdf0e10cSrcweir // is visible
653cdf0e10cSrcweir SCCOLROW nEnd = rTable.LastHiddenColRow(nEntryStart, bCol);
654cdf0e10cSrcweir bool bAllHidden = (nEntryEnd <= nEnd && nEnd <
655cdf0e10cSrcweir ::std::numeric_limits<SCCOLROW>::max());
656cdf0e10cSrcweir
657cdf0e10cSrcweir bool bToggle = ( bShow != bAllHidden );
658cdf0e10cSrcweir if ( bToggle )
659cdf0e10cSrcweir {
660cdf0e10cSrcweir pEntry->SetHidden( !bShow );
661cdf0e10cSrcweir SetVisibleBelow( aIter.LastLevel(), aIter.LastEntry(), bShow, bShow );
662cdf0e10cSrcweir bModified = true;
663cdf0e10cSrcweir }
664cdf0e10cSrcweir }
665cdf0e10cSrcweir }
666cdf0e10cSrcweir }
667cdf0e10cSrcweir return bModified;
668cdf0e10cSrcweir }
669cdf0e10cSrcweir
RemoveAll()670cdf0e10cSrcweir void ScOutlineArray::RemoveAll()
671cdf0e10cSrcweir {
672cdf0e10cSrcweir for (sal_uInt16 nLevel=0; nLevel<nDepth; nLevel++)
673cdf0e10cSrcweir aCollections[nLevel].FreeAll();
674cdf0e10cSrcweir
675cdf0e10cSrcweir nDepth = 0;
676cdf0e10cSrcweir }
677cdf0e10cSrcweir
678cdf0e10cSrcweir //------------------------------------------------------------------------
679cdf0e10cSrcweir
ScOutlineTable()680cdf0e10cSrcweir ScOutlineTable::ScOutlineTable()
681cdf0e10cSrcweir {
682cdf0e10cSrcweir }
683cdf0e10cSrcweir
ScOutlineTable(const ScOutlineTable & rOutline)684cdf0e10cSrcweir ScOutlineTable::ScOutlineTable( const ScOutlineTable& rOutline ) :
685cdf0e10cSrcweir aColOutline( rOutline.aColOutline ),
686cdf0e10cSrcweir aRowOutline( rOutline.aRowOutline )
687cdf0e10cSrcweir {
688cdf0e10cSrcweir }
689cdf0e10cSrcweir
TestInsertCol(SCSIZE nSize)690cdf0e10cSrcweir sal_Bool ScOutlineTable::TestInsertCol( SCSIZE nSize )
691cdf0e10cSrcweir {
692cdf0e10cSrcweir return aColOutline.TestInsertSpace( nSize, MAXCOL );
693cdf0e10cSrcweir }
694cdf0e10cSrcweir
InsertCol(SCCOL nStartCol,SCSIZE nSize)695cdf0e10cSrcweir void ScOutlineTable::InsertCol( SCCOL nStartCol, SCSIZE nSize )
696cdf0e10cSrcweir {
697cdf0e10cSrcweir aColOutline.InsertSpace( nStartCol, nSize );
698cdf0e10cSrcweir }
699cdf0e10cSrcweir
DeleteCol(SCCOL nStartCol,SCSIZE nSize)700cdf0e10cSrcweir sal_Bool ScOutlineTable::DeleteCol( SCCOL nStartCol, SCSIZE nSize )
701cdf0e10cSrcweir {
702cdf0e10cSrcweir return aColOutline.DeleteSpace( nStartCol, nSize );
703cdf0e10cSrcweir }
704cdf0e10cSrcweir
TestInsertRow(SCSIZE nSize)705cdf0e10cSrcweir sal_Bool ScOutlineTable::TestInsertRow( SCSIZE nSize )
706cdf0e10cSrcweir {
707cdf0e10cSrcweir return aRowOutline.TestInsertSpace( nSize, MAXROW );
708cdf0e10cSrcweir }
709cdf0e10cSrcweir
InsertRow(SCROW nStartRow,SCSIZE nSize)710cdf0e10cSrcweir void ScOutlineTable::InsertRow( SCROW nStartRow, SCSIZE nSize )
711cdf0e10cSrcweir {
712cdf0e10cSrcweir aRowOutline.InsertSpace( nStartRow, nSize );
713cdf0e10cSrcweir }
714cdf0e10cSrcweir
DeleteRow(SCROW nStartRow,SCSIZE nSize)715cdf0e10cSrcweir sal_Bool ScOutlineTable::DeleteRow( SCROW nStartRow, SCSIZE nSize )
716cdf0e10cSrcweir {
717cdf0e10cSrcweir return aRowOutline.DeleteSpace( nStartRow, nSize );
718cdf0e10cSrcweir }
719cdf0e10cSrcweir
720cdf0e10cSrcweir //------------------------------------------------------------------------
721cdf0e10cSrcweir
ScSubOutlineIterator(ScOutlineArray * pOutlineArray)722cdf0e10cSrcweir ScSubOutlineIterator::ScSubOutlineIterator( ScOutlineArray* pOutlineArray ) :
723cdf0e10cSrcweir pArray( pOutlineArray ),
724cdf0e10cSrcweir nStart( 0 ),
725cdf0e10cSrcweir nEnd( SCCOLROW_MAX ), // alle durchgehen
726cdf0e10cSrcweir nSubLevel( 0 ),
727cdf0e10cSrcweir nSubEntry( 0 )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir nDepth = pArray->nDepth;
730cdf0e10cSrcweir }
731cdf0e10cSrcweir
ScSubOutlineIterator(ScOutlineArray * pOutlineArray,sal_uInt16 nLevel,sal_uInt16 nEntry)732cdf0e10cSrcweir ScSubOutlineIterator::ScSubOutlineIterator( ScOutlineArray* pOutlineArray,
733cdf0e10cSrcweir sal_uInt16 nLevel, sal_uInt16 nEntry ) :
734cdf0e10cSrcweir pArray( pOutlineArray )
735cdf0e10cSrcweir {
736cdf0e10cSrcweir ScOutlineEntry* pEntry = (ScOutlineEntry*) pArray->aCollections[nLevel].At(nEntry);
737cdf0e10cSrcweir nStart = pEntry->GetStart();
738cdf0e10cSrcweir nEnd = pEntry->GetEnd();
739cdf0e10cSrcweir nSubLevel = nLevel + 1;
740cdf0e10cSrcweir nSubEntry = 0;
741cdf0e10cSrcweir nDepth = pArray->nDepth;
742cdf0e10cSrcweir }
743cdf0e10cSrcweir
GetNext()744cdf0e10cSrcweir ScOutlineEntry* ScSubOutlineIterator::GetNext()
745cdf0e10cSrcweir {
746cdf0e10cSrcweir ScOutlineEntry* pEntry;
747cdf0e10cSrcweir sal_Bool bFound = sal_False;
748cdf0e10cSrcweir do
749cdf0e10cSrcweir {
750cdf0e10cSrcweir if (nSubLevel >= nDepth)
751cdf0e10cSrcweir return NULL;
752cdf0e10cSrcweir
753cdf0e10cSrcweir pEntry = (ScOutlineEntry*) pArray->aCollections[nSubLevel].At(nSubEntry);
754cdf0e10cSrcweir if (!pEntry)
755cdf0e10cSrcweir {
756cdf0e10cSrcweir nSubEntry = 0;
757cdf0e10cSrcweir ++nSubLevel;
758cdf0e10cSrcweir }
759cdf0e10cSrcweir else
760cdf0e10cSrcweir {
761cdf0e10cSrcweir if ( pEntry->GetStart() >= nStart && pEntry->GetEnd() <= nEnd )
762cdf0e10cSrcweir bFound = sal_True;
763cdf0e10cSrcweir ++nSubEntry;
764cdf0e10cSrcweir }
765cdf0e10cSrcweir }
766cdf0e10cSrcweir while (!bFound);
767cdf0e10cSrcweir return pEntry; // nSubLevel gueltig, wenn pEntry != 0
768cdf0e10cSrcweir }
769cdf0e10cSrcweir
LastLevel() const770cdf0e10cSrcweir sal_uInt16 ScSubOutlineIterator::LastLevel() const
771cdf0e10cSrcweir {
772cdf0e10cSrcweir return nSubLevel;
773cdf0e10cSrcweir }
774cdf0e10cSrcweir
LastEntry() const775cdf0e10cSrcweir sal_uInt16 ScSubOutlineIterator::LastEntry() const
776cdf0e10cSrcweir {
777cdf0e10cSrcweir if (nSubEntry == 0)
778cdf0e10cSrcweir {
779cdf0e10cSrcweir DBG_ERROR("ScSubOutlineIterator::LastEntry vor GetNext");
780cdf0e10cSrcweir return 0;
781cdf0e10cSrcweir }
782cdf0e10cSrcweir return nSubEntry-1;
783cdf0e10cSrcweir }
784cdf0e10cSrcweir
DeleteLast()785cdf0e10cSrcweir void ScSubOutlineIterator::DeleteLast()
786cdf0e10cSrcweir {
787cdf0e10cSrcweir if (nSubLevel >= nDepth)
788cdf0e10cSrcweir {
789cdf0e10cSrcweir DBG_ERROR("ScSubOutlineIterator::DeleteLast nach Ende");
790cdf0e10cSrcweir return;
791cdf0e10cSrcweir }
792cdf0e10cSrcweir if (nSubEntry == 0)
793cdf0e10cSrcweir {
794cdf0e10cSrcweir DBG_ERROR("ScSubOutlineIterator::DeleteLast vor GetNext");
795cdf0e10cSrcweir return;
796cdf0e10cSrcweir }
797cdf0e10cSrcweir
798cdf0e10cSrcweir --nSubEntry;
799cdf0e10cSrcweir pArray->aCollections[nSubLevel].AtFree(nSubEntry);
800cdf0e10cSrcweir }
801cdf0e10cSrcweir
802cdf0e10cSrcweir
803