fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / ui / docshell / olinefun.cxx
blob9def268ed97ae8ae1a10da6d7a01e60ef3d768e7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sfx2/bindings.hxx>
22 #include "olinefun.hxx"
24 #include "docsh.hxx"
25 #include "olinetab.hxx"
26 #include "undodat.hxx"
27 #include "globstr.hrc"
28 #include "sc.hrc"
30 static void lcl_InvalidateOutliner( SfxBindings* pBindings )
32 if ( pBindings )
34 pBindings->Invalidate( SID_OUTLINE_SHOW );
35 pBindings->Invalidate( SID_OUTLINE_HIDE );
36 pBindings->Invalidate( SID_OUTLINE_REMOVE );
38 pBindings->Invalidate( SID_STATUS_SUM ); // wegen ein-/ausblenden
39 pBindings->Invalidate( SID_ATTR_SIZE );
43 //! PaintWidthHeight zur DocShell verschieben?
45 static void lcl_PaintWidthHeight( ScDocShell& rDocShell, SCTAB nTab,
46 bool bColumns, SCCOLROW nStart, SCCOLROW nEnd )
48 ScDocument& rDoc = rDocShell.GetDocument();
50 sal_uInt16 nParts = PAINT_GRID;
51 SCCOL nStartCol = 0;
52 SCROW nStartRow = 0;
53 SCCOL nEndCol = MAXCOL; // fuer Test auf Merge
54 SCROW nEndRow = MAXROW;
55 if ( bColumns )
57 nParts |= PAINT_TOP;
58 nStartCol = static_cast<SCCOL>(nStart);
59 nEndCol = static_cast<SCCOL>(nEnd);
61 else
63 nParts |= PAINT_LEFT;
64 nStartRow = nStart;
65 nEndRow = nEnd;
67 if (rDoc.HasAttrib( nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
68 HASATTR_MERGED | HASATTR_OVERLAPPED ))
70 nStartCol = 0;
71 nStartRow = 0;
73 rDocShell.PostPaint( nStartCol,nStartRow,nTab, MAXCOL,MAXROW,nTab, nParts );
76 bool ScOutlineDocFunc::MakeOutline( const ScRange& rRange, bool bColumns, bool bRecord, bool bApi )
78 bool bSuccess = false;
79 SCCOL nStartCol = rRange.aStart.Col();
80 SCROW nStartRow = rRange.aStart.Row();
81 SCCOL nEndCol = rRange.aEnd.Col();
82 SCROW nEndRow = rRange.aEnd.Row();
83 SCTAB nTab = rRange.aStart.Tab();
85 ScDocument& rDoc = rDocShell.GetDocument();
86 ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab, true );
87 ScOutlineTable* pUndoTab = NULL;
89 if (bRecord && !rDoc.IsUndoEnabled())
90 bRecord = false;
92 if (bRecord)
93 pUndoTab = new ScOutlineTable( *pTable );
95 ScOutlineArray& rArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
97 bool bRes;
98 bool bSize = false;
99 if ( bColumns )
100 bRes = rArray.Insert( nStartCol, nEndCol, bSize );
101 else
102 bRes = rArray.Insert( nStartRow, nEndRow, bSize );
104 if ( bRes )
106 if (bRecord)
108 rDocShell.GetUndoManager()->AddUndoAction(
109 new ScUndoMakeOutline( &rDocShell,
110 nStartCol,nStartRow,nTab,nEndCol,nEndRow,nTab,
111 pUndoTab, bColumns, true ) );
114 if (rDoc.IsStreamValid(nTab))
115 rDoc.SetStreamValid(nTab, false);
117 sal_uInt16 nParts = 0; // Datenbereich nicht geaendert
118 if ( bColumns )
119 nParts |= PAINT_TOP;
120 else
121 nParts |= PAINT_LEFT;
122 if ( bSize )
123 nParts |= PAINT_SIZE;
125 rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, nParts );
126 rDocShell.SetDocumentModified();
127 lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
128 bSuccess = true;
130 else
132 if (!bApi)
133 rDocShell.ErrorMessage(STR_MSSG_MAKEOUTLINE_0); // "Gruppierung nicht moeglich"
134 delete pUndoTab;
137 return bSuccess;
140 bool ScOutlineDocFunc::RemoveOutline( const ScRange& rRange, bool bColumns, bool bRecord, bool bApi )
142 bool bDone = false;
144 SCCOL nStartCol = rRange.aStart.Col();
145 SCROW nStartRow = rRange.aStart.Row();
146 SCCOL nEndCol = rRange.aEnd.Col();
147 SCROW nEndRow = rRange.aEnd.Row();
148 SCTAB nTab = rRange.aStart.Tab();
150 ScDocument& rDoc = rDocShell.GetDocument();
152 if (bRecord && !rDoc.IsUndoEnabled())
153 bRecord = false;
154 ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab );
155 if (pTable)
157 ScOutlineTable* pUndoTab = NULL;
158 if (bRecord)
159 pUndoTab = new ScOutlineTable( *pTable );
161 ScOutlineArray& rArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
163 bool bRes;
164 bool bSize = false;
165 if ( bColumns )
166 bRes = rArray.Remove( nStartCol, nEndCol, bSize );
167 else
168 bRes = rArray.Remove( nStartRow, nEndRow, bSize );
170 if ( bRes )
172 if (bRecord)
174 rDocShell.GetUndoManager()->AddUndoAction(
175 new ScUndoMakeOutline( &rDocShell,
176 nStartCol,nStartRow,nTab, nEndCol,nEndRow,nTab,
177 pUndoTab, bColumns, false ) );
180 if (rDoc.IsStreamValid(nTab))
181 rDoc.SetStreamValid(nTab, false);
183 sal_uInt16 nParts = 0; // Datenbereich nicht geaendert
184 if ( bColumns )
185 nParts |= PAINT_TOP;
186 else
187 nParts |= PAINT_LEFT;
188 if ( bSize )
189 nParts |= PAINT_SIZE;
191 rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, nParts );
192 rDocShell.SetDocumentModified();
193 bDone = true;
194 lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
196 // es wird nicht wieder eingeblendet -> kein UpdatePageBreaks
198 else
199 delete pUndoTab;
202 if (!bDone && !bApi)
203 rDocShell.ErrorMessage(STR_MSSG_REMOVEOUTLINE_0); // "Aufheben nicht moeglich"
205 return bDone;
208 bool ScOutlineDocFunc::RemoveAllOutlines( SCTAB nTab, bool bRecord )
210 bool bSuccess = false;
211 ScDocument& rDoc = rDocShell.GetDocument();
213 if (bRecord && !rDoc.IsUndoEnabled())
214 bRecord = false;
215 ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab );
216 if (pTable)
218 if (bRecord)
220 SCCOLROW nCol1, nCol2, nRow1, nRow2;
221 pTable->GetColArray().GetRange( nCol1, nCol2 );
222 pTable->GetRowArray().GetRange( nRow1, nRow2 );
223 SCCOL nStartCol = static_cast<SCCOL>(nCol1);
224 SCROW nStartRow = nRow1;
225 SCCOL nEndCol = static_cast<SCCOL>(nCol2);
226 SCROW nEndRow = nRow2;
228 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
229 pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true );
230 rDoc.CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, false, pUndoDoc );
231 rDoc.CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, false, pUndoDoc );
233 ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
235 rDocShell.GetUndoManager()->AddUndoAction(
236 new ScUndoRemoveAllOutlines( &rDocShell,
237 nStartCol, nStartRow, nTab,
238 nEndCol, nEndRow, nTab,
239 pUndoDoc, pUndoTab ) );
242 SelectLevel( nTab, true, pTable->GetColArray().GetDepth(), false, false );
243 SelectLevel( nTab, false, pTable->GetRowArray().GetDepth(), false, false );
244 rDoc.SetOutlineTable( nTab, NULL );
246 rDoc.UpdatePageBreaks( nTab );
248 if (rDoc.IsStreamValid(nTab))
249 rDoc.SetStreamValid(nTab, false);
251 rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab,
252 PAINT_GRID | PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
253 rDocShell.SetDocumentModified();
254 lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
255 bSuccess = true;
258 return bSuccess;
261 bool ScOutlineDocFunc::AutoOutline( const ScRange& rRange, bool bRecord )
263 SCCOL nStartCol = rRange.aStart.Col();
264 SCROW nStartRow = rRange.aStart.Row();
265 SCCOL nEndCol = rRange.aEnd.Col();
266 SCROW nEndRow = rRange.aEnd.Row();
267 SCTAB nTab = rRange.aStart.Tab();
269 ScDocument& rDoc = rDocShell.GetDocument();
271 if (bRecord && !rDoc.IsUndoEnabled())
272 bRecord = false;
273 ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab );
275 ScDocument* pUndoDoc = NULL;
276 ScOutlineTable* pUndoTab = NULL;
278 if ( pTable )
280 if ( bRecord )
282 pUndoTab = new ScOutlineTable( *pTable );
284 SCCOLROW nCol1, nCol2, nRow1, nRow2;
285 pTable->GetColArray().GetRange( nCol1, nCol2 );
286 pTable->GetRowArray().GetRange( nRow1, nRow2 );
287 SCCOL nOutStartCol = static_cast<SCCOL>(nCol1);
288 SCROW nOutStartRow = nRow1;
289 SCCOL nOutEndCol = static_cast<SCCOL>(nCol2);
290 SCROW nOutEndRow = nRow2;
292 pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
293 pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true );
294 rDoc.CopyToDocument( nOutStartCol, 0, nTab, nOutEndCol, MAXROW, nTab, IDF_NONE, false, pUndoDoc );
295 rDoc.CopyToDocument( 0, nOutStartRow, nTab, MAXCOL, nOutEndRow, nTab, IDF_NONE, false, pUndoDoc );
298 // einblenden
299 SelectLevel( nTab, true, pTable->GetColArray().GetDepth(), false, false );
300 SelectLevel( nTab, false, pTable->GetRowArray().GetDepth(), false, false );
301 rDoc.SetOutlineTable( nTab, NULL );
304 rDoc.DoAutoOutline( nStartCol,nStartRow, nEndCol,nEndRow, nTab );
306 if (bRecord)
308 rDocShell.GetUndoManager()->AddUndoAction(
309 new ScUndoAutoOutline( &rDocShell,
310 nStartCol, nStartRow, nTab,
311 nEndCol, nEndRow, nTab,
312 pUndoDoc, pUndoTab ) );
315 if (rDoc.IsStreamValid(nTab))
316 rDoc.SetStreamValid(nTab, false);
318 rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_LEFT | PAINT_TOP | PAINT_SIZE );
319 rDocShell.SetDocumentModified();
320 lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
322 return true;
325 bool ScOutlineDocFunc::SelectLevel( SCTAB nTab, bool bColumns, sal_uInt16 nLevel,
326 bool bRecord, bool bPaint )
328 ScDocument& rDoc = rDocShell.GetDocument();
330 if (bRecord && !rDoc.IsUndoEnabled())
331 bRecord = false;
332 ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab ); // ist schon da
333 if (!pTable)
334 return false;
335 ScOutlineArray& rArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
337 SCCOLROW nStart, nEnd;
338 rArray.GetRange( nStart, nEnd );
340 if ( bRecord )
342 ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
343 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
344 if (bColumns)
346 pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, false );
347 rDoc.CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
348 static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, false,
349 pUndoDoc );
351 else
353 pUndoDoc->InitUndo( &rDoc, nTab, nTab, false, true );
354 rDoc.CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, false, pUndoDoc );
357 rDocShell.GetUndoManager()->AddUndoAction(
358 new ScUndoOutlineLevel( &rDocShell,
359 nStart, nEnd, nTab, //! start und end berechnen
360 pUndoDoc, pUndoTab,
361 bColumns, nLevel ) );
364 ScSubOutlineIterator aIter( &rArray ); // alle Eintraege
365 ScOutlineEntry* pEntry;
366 while ((pEntry=aIter.GetNext()) != NULL)
368 sal_uInt16 nThisLevel = aIter.LastLevel();
369 bool bShow = (nThisLevel < nLevel);
370 if (bShow) // einblenden
372 pEntry->SetHidden( false );
373 pEntry->SetVisible( true );
375 else if ( nThisLevel == nLevel ) // ausblenden
377 pEntry->SetHidden( true );
378 pEntry->SetVisible( true );
380 else // verdeckt
382 pEntry->SetVisible( false );
385 SCCOLROW nThisStart = pEntry->GetStart();
386 SCCOLROW nThisEnd = pEntry->GetEnd();
387 for (SCCOLROW i=nThisStart; i<=nThisEnd; i++)
389 if ( bColumns )
390 rDoc.ShowCol( static_cast<SCCOL>(i), nTab, bShow );
391 else
393 // show several rows together, don't show filtered rows
394 SCROW nFilterEnd = i;
395 bool bFiltered = rDoc.RowFiltered( i, nTab, NULL, &nFilterEnd );
396 nFilterEnd = std::min( nThisEnd, nFilterEnd );
397 if ( !bShow || !bFiltered )
398 rDoc.ShowRows( i, nFilterEnd, nTab, bShow );
399 i = nFilterEnd;
404 rDoc.SetDrawPageSize(nTab);
405 rDoc.UpdatePageBreaks( nTab );
407 if (bPaint)
408 lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
410 rDocShell.SetDocumentModified();
411 lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
413 return true;
416 bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange& rRange, bool bRecord )
418 bool bDone = false;
420 SCCOL nStartCol = rRange.aStart.Col();
421 SCROW nStartRow = rRange.aStart.Row();
422 SCCOL nEndCol = rRange.aEnd.Col();
423 SCROW nEndRow = rRange.aEnd.Row();
424 SCTAB nTab = rRange.aStart.Tab();
426 ScDocument& rDoc = rDocShell.GetDocument();
428 if (bRecord && !rDoc.IsUndoEnabled())
429 bRecord = false;
430 ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab );
432 if (pTable)
434 ScOutlineEntry* pEntry;
435 SCCOLROW nStart;
436 SCCOLROW nEnd;
437 SCCOLROW nMin;
438 SCCOLROW nMax;
439 SCCOLROW i;
441 if ( bRecord )
443 ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
444 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
445 pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true );
446 rDoc.CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, false, pUndoDoc );
447 rDoc.CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, false, pUndoDoc );
449 rDocShell.GetUndoManager()->AddUndoAction(
450 new ScUndoOutlineBlock( &rDocShell,
451 nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
452 pUndoDoc, pUndoTab, true ) );
455 // Spalten
457 nMin=MAXCOL;
458 nMax=0;
459 ScOutlineArray& rColArray = pTable->GetColArray();
460 ScSubOutlineIterator aColIter( &rColArray );
461 while ((pEntry=aColIter.GetNext()) != NULL)
463 nStart = pEntry->GetStart();
464 nEnd = pEntry->GetEnd();
465 if ( nStart>=nStartCol && nEnd<=nEndCol )
467 pEntry->SetHidden( false );
468 pEntry->SetVisible( true );
469 if (nStart<nMin) nMin=nStart;
470 if (nEnd>nMax) nMax=nEnd;
473 for ( i=nMin; i<=nMax; i++ )
474 rDoc.ShowCol( static_cast<SCCOL>(i), nTab, true );
476 // Zeilen
478 nMin=MAXROW;
479 nMax=0;
480 ScOutlineArray& rRowArray = pTable->GetRowArray();
481 ScSubOutlineIterator aRowIter( &rRowArray );
482 while ((pEntry=aRowIter.GetNext()) != NULL)
484 nStart = pEntry->GetStart();
485 nEnd = pEntry->GetEnd();
486 if ( nStart>=nStartRow && nEnd<=nEndRow )
488 pEntry->SetHidden( false );
489 pEntry->SetVisible( true );
490 if (nStart<nMin) nMin=nStart;
491 if (nEnd>nMax) nMax=nEnd;
494 for ( i=nMin; i<=nMax; i++ )
496 // show several rows together, don't show filtered rows
497 SCROW nFilterEnd = i;
498 bool bFiltered = rDoc.RowFiltered( i, nTab, NULL, &nFilterEnd );
499 nFilterEnd = std::min( nMax, nFilterEnd );
500 if ( !bFiltered )
501 rDoc.ShowRows( i, nFilterEnd, nTab, true );
502 i = nFilterEnd;
505 rDoc.SetDrawPageSize(nTab);
506 rDoc.UpdatePageBreaks( nTab );
508 rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT | PAINT_TOP );
509 rDocShell.SetDocumentModified();
510 bDone = true;
512 lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
515 return bDone;
518 bool ScOutlineDocFunc::HideMarkedOutlines( const ScRange& rRange, bool bRecord )
520 bool bDone = false;
522 SCCOL nStartCol = rRange.aStart.Col();
523 SCROW nStartRow = rRange.aStart.Row();
524 SCCOL nEndCol = rRange.aEnd.Col();
525 SCROW nEndRow = rRange.aEnd.Row();
526 SCTAB nTab = rRange.aStart.Tab();
528 ScDocument& rDoc = rDocShell.GetDocument();
530 if (bRecord && !rDoc.IsUndoEnabled())
531 bRecord = false;
532 ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab );
534 if (pTable)
536 const ScOutlineEntry* pEntry;
537 size_t nColLevel;
538 size_t nRowLevel;
539 sal_uInt16 nCount;
540 SCCOLROW nStart;
541 SCCOLROW nEnd;
542 sal_uInt16 i;
544 SCCOLROW nEffStartCol = nStartCol;
545 SCCOLROW nEffEndCol = nEndCol;
546 ScOutlineArray& rColArray = pTable->GetColArray();
547 rColArray.FindTouchedLevel( nStartCol, nEndCol, nColLevel );
548 rColArray.ExtendBlock( nColLevel, nEffStartCol, nEffEndCol );
549 SCCOLROW nEffStartRow = nStartRow;
550 SCCOLROW nEffEndRow = nEndRow;
551 ScOutlineArray& rRowArray = pTable->GetRowArray();
552 rRowArray.FindTouchedLevel( nStartRow, nEndRow, nRowLevel );
553 rRowArray.ExtendBlock( nRowLevel, nEffStartRow, nEffEndRow );
555 if ( bRecord )
557 ScOutlineTable* pUndoTab = new ScOutlineTable( *pTable );
558 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
559 pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, true );
560 rDoc.CopyToDocument( static_cast<SCCOL>(nEffStartCol), 0, nTab,
561 static_cast<SCCOL>(nEffEndCol), MAXROW, nTab, IDF_NONE,
562 false, pUndoDoc );
563 rDoc.CopyToDocument( 0, nEffStartRow, nTab, MAXCOL, nEffEndRow, nTab, IDF_NONE, false, pUndoDoc );
565 rDocShell.GetUndoManager()->AddUndoAction(
566 new ScUndoOutlineBlock( &rDocShell,
567 nStartCol, nStartRow, nTab, nEndCol, nEndRow, nTab,
568 pUndoDoc, pUndoTab, false ) );
571 // Spalten
573 nCount = rColArray.GetCount(nColLevel);
574 for ( i=0; i<nCount; i++ )
576 pEntry = rColArray.GetEntry(nColLevel,i);
577 nStart = pEntry->GetStart();
578 nEnd = pEntry->GetEnd();
580 if ( static_cast<SCCOLROW>(nStartCol)<=nEnd && static_cast<SCCOLROW>(nEndCol)>=nStart )
581 HideOutline( nTab, true, nColLevel, i, false, false );
584 // Zeilen
586 nCount = rRowArray.GetCount(nRowLevel);
587 for ( i=0; i<nCount; i++ )
589 pEntry = rRowArray.GetEntry(nRowLevel,i);
590 nStart = pEntry->GetStart();
591 nEnd = pEntry->GetEnd();
593 if ( nStartRow<=nEnd && nEndRow>=nStart )
594 HideOutline( nTab, false, nRowLevel, i, false, false );
597 rDoc.SetDrawPageSize(nTab);
598 rDoc.UpdatePageBreaks( nTab );
600 rDocShell.PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID | PAINT_LEFT | PAINT_TOP );
602 rDocShell.SetDocumentModified();
603 bDone = true;
605 lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
608 return bDone;
611 bool ScOutlineDocFunc::ShowOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry,
612 bool bRecord, bool bPaint )
614 ScDocument& rDoc = rDocShell.GetDocument();
615 if (bRecord && !rDoc.IsUndoEnabled())
616 bRecord = false;
618 ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab );
619 ScOutlineArray& rArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
620 ScOutlineEntry* pEntry = rArray.GetEntry( nLevel, nEntry );
621 SCCOLROW nStart = pEntry->GetStart();
622 SCCOLROW nEnd = pEntry->GetEnd();
624 if ( bRecord )
626 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
627 if (bColumns)
629 pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, false );
630 rDoc.CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
631 static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, false,
632 pUndoDoc );
634 else
636 pUndoDoc->InitUndo( &rDoc, nTab, nTab, false, true );
637 rDoc.CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, false, pUndoDoc );
640 rDocShell.GetUndoManager()->AddUndoAction(
641 new ScUndoDoOutline( &rDocShell,
642 nStart, nEnd, nTab, pUndoDoc, //! start und end berechnen
643 bColumns, nLevel, nEntry, true ) );
646 pEntry->SetHidden(false);
647 SCCOLROW i;
648 for ( i = nStart; i <= nEnd; i++ )
650 if ( bColumns )
651 rDoc.ShowCol( static_cast<SCCOL>(i), nTab, true );
652 else
654 // show several rows together, don't show filtered rows
655 SCROW nFilterEnd = i;
656 bool bFiltered = rDoc.RowFiltered( i, nTab, NULL, &nFilterEnd );
657 nFilterEnd = std::min( nEnd, nFilterEnd );
658 if ( !bFiltered )
659 rDoc.ShowRows( i, nFilterEnd, nTab, true );
660 i = nFilterEnd;
664 ScSubOutlineIterator aIter( &rArray, nLevel, nEntry );
665 while ((pEntry=aIter.GetNext()) != NULL)
667 if ( pEntry->IsHidden() )
669 SCCOLROW nSubStart = pEntry->GetStart();
670 SCCOLROW nSubEnd = pEntry->GetEnd();
671 if ( bColumns )
672 for ( i = nSubStart; i <= nSubEnd; i++ )
673 rDoc.ShowCol( static_cast<SCCOL>(i), nTab, false );
674 else
675 rDoc.ShowRows( nSubStart, nSubEnd, nTab, false );
679 rArray.SetVisibleBelow( nLevel, nEntry, true, true );
681 rDoc.SetDrawPageSize(nTab);
682 rDoc.InvalidatePageBreaks(nTab);
683 rDoc.UpdatePageBreaks( nTab );
685 if (bPaint)
686 lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
688 rDocShell.SetDocumentModified();
690 lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
692 return true; //! immer ???
695 bool ScOutlineDocFunc::HideOutline( SCTAB nTab, bool bColumns, sal_uInt16 nLevel, sal_uInt16 nEntry,
696 bool bRecord, bool bPaint )
698 ScDocument& rDoc = rDocShell.GetDocument();
699 if (bRecord && !rDoc.IsUndoEnabled())
700 bRecord = false;
702 ScOutlineTable* pTable = rDoc.GetOutlineTable( nTab );
703 ScOutlineArray& rArray = bColumns ? pTable->GetColArray() : pTable->GetRowArray();
704 ScOutlineEntry* pEntry = rArray.GetEntry( nLevel, nEntry );
705 SCCOLROW nStart = pEntry->GetStart();
706 SCCOLROW nEnd = pEntry->GetEnd();
708 if ( bRecord )
710 ScDocument* pUndoDoc = new ScDocument( SCDOCMODE_UNDO );
711 if (bColumns)
713 pUndoDoc->InitUndo( &rDoc, nTab, nTab, true, false );
714 rDoc.CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
715 static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, false,
716 pUndoDoc );
718 else
720 pUndoDoc->InitUndo( &rDoc, nTab, nTab, false, true );
721 rDoc.CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, false, pUndoDoc );
724 rDocShell.GetUndoManager()->AddUndoAction(
725 new ScUndoDoOutline( &rDocShell,
726 nStart, nEnd, nTab, pUndoDoc,
727 bColumns, nLevel, nEntry, false ) );
730 pEntry->SetHidden(true);
731 SCCOLROW i;
732 if ( bColumns )
733 for ( i = nStart; i <= nEnd; i++ )
734 rDoc.ShowCol( static_cast<SCCOL>(i), nTab, false );
735 else
736 rDoc.ShowRows( nStart, nEnd, nTab, false );
738 rArray.SetVisibleBelow( nLevel, nEntry, false );
740 rDoc.SetDrawPageSize(nTab);
741 rDoc.InvalidatePageBreaks(nTab);
742 rDoc.UpdatePageBreaks( nTab );
744 if (bPaint)
745 lcl_PaintWidthHeight( rDocShell, nTab, bColumns, nStart, nEnd );
747 rDocShell.SetDocumentModified();
749 lcl_InvalidateOutliner( rDocShell.GetViewBindings() );
751 return true; //! immer ???
754 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */