1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
25 #include "olinetab.hxx"
26 #include "undodat.hxx"
27 #include "globstr.hrc"
31 //========================================================================
33 static void lcl_InvalidateOutliner( SfxBindings
* pBindings
)
37 pBindings
->Invalidate( SID_OUTLINE_SHOW
);
38 pBindings
->Invalidate( SID_OUTLINE_HIDE
);
39 pBindings
->Invalidate( SID_OUTLINE_REMOVE
);
41 pBindings
->Invalidate( SID_STATUS_SUM
); // wegen ein-/ausblenden
42 pBindings
->Invalidate( SID_ATTR_SIZE
);
46 //------------------------------------------------------------------------
48 //! PaintWidthHeight zur DocShell verschieben?
50 static void lcl_PaintWidthHeight( ScDocShell
& rDocShell
, SCTAB nTab
,
51 sal_Bool bColumns
, SCCOLROW nStart
, SCCOLROW nEnd
)
53 ScDocument
* pDoc
= rDocShell
.GetDocument();
55 sal_uInt16 nParts
= PAINT_GRID
;
58 SCCOL nEndCol
= MAXCOL
; // fuer Test auf Merge
59 SCROW nEndRow
= MAXROW
;
63 nStartCol
= static_cast<SCCOL
>(nStart
);
64 nEndCol
= static_cast<SCCOL
>(nEnd
);
72 if (pDoc
->HasAttrib( nStartCol
,nStartRow
,nTab
, nEndCol
,nEndRow
,nTab
,
73 HASATTR_MERGED
| HASATTR_OVERLAPPED
))
78 rDocShell
.PostPaint( nStartCol
,nStartRow
,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
81 //------------------------------------------------------------------------
83 sal_Bool
ScOutlineDocFunc::MakeOutline( const ScRange
& rRange
, sal_Bool bColumns
, sal_Bool bRecord
, sal_Bool bApi
)
85 sal_Bool bSuccess
= false;
86 SCCOL nStartCol
= rRange
.aStart
.Col();
87 SCROW nStartRow
= rRange
.aStart
.Row();
88 SCCOL nEndCol
= rRange
.aEnd
.Col();
89 SCROW nEndRow
= rRange
.aEnd
.Row();
90 SCTAB nTab
= rRange
.aStart
.Tab();
92 ScDocument
* pDoc
= rDocShell
.GetDocument();
93 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
, sal_True
);
94 ScOutlineTable
* pUndoTab
= NULL
;
96 if (bRecord
&& !pDoc
->IsUndoEnabled())
100 pUndoTab
= new ScOutlineTable( *pTable
);
102 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
107 bRes
= pArray
->Insert( nStartCol
, nEndCol
, bSize
);
109 bRes
= pArray
->Insert( nStartRow
, nEndRow
, bSize
);
115 rDocShell
.GetUndoManager()->AddUndoAction(
116 new ScUndoMakeOutline( &rDocShell
,
117 nStartCol
,nStartRow
,nTab
,nEndCol
,nEndRow
,nTab
,
118 pUndoTab
, bColumns
, sal_True
) );
121 if (pDoc
->IsStreamValid(nTab
))
122 pDoc
->SetStreamValid(nTab
, false);
124 sal_uInt16 nParts
= 0; // Datenbereich nicht geaendert
128 nParts
|= PAINT_LEFT
;
130 nParts
|= PAINT_SIZE
;
132 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
133 rDocShell
.SetDocumentModified();
134 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
140 rDocShell
.ErrorMessage(STR_MSSG_MAKEOUTLINE_0
); // "Gruppierung nicht moeglich"
147 sal_Bool
ScOutlineDocFunc::RemoveOutline( const ScRange
& rRange
, sal_Bool bColumns
, sal_Bool bRecord
, sal_Bool bApi
)
149 sal_Bool bDone
= false;
151 SCCOL nStartCol
= rRange
.aStart
.Col();
152 SCROW nStartRow
= rRange
.aStart
.Row();
153 SCCOL nEndCol
= rRange
.aEnd
.Col();
154 SCROW nEndRow
= rRange
.aEnd
.Row();
155 SCTAB nTab
= rRange
.aStart
.Tab();
157 ScDocument
* pDoc
= rDocShell
.GetDocument();
159 if (bRecord
&& !pDoc
->IsUndoEnabled())
161 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
164 ScOutlineTable
* pUndoTab
= NULL
;
166 pUndoTab
= new ScOutlineTable( *pTable
);
168 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
173 bRes
= pArray
->Remove( nStartCol
, nEndCol
, bSize
);
175 bRes
= pArray
->Remove( nStartRow
, nEndRow
, bSize
);
181 rDocShell
.GetUndoManager()->AddUndoAction(
182 new ScUndoMakeOutline( &rDocShell
,
183 nStartCol
,nStartRow
,nTab
, nEndCol
,nEndRow
,nTab
,
184 pUndoTab
, bColumns
, false ) );
187 if (pDoc
->IsStreamValid(nTab
))
188 pDoc
->SetStreamValid(nTab
, false);
190 sal_uInt16 nParts
= 0; // Datenbereich nicht geaendert
194 nParts
|= PAINT_LEFT
;
196 nParts
|= PAINT_SIZE
;
198 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
199 rDocShell
.SetDocumentModified();
201 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
203 // es wird nicht wieder eingeblendet -> kein UpdatePageBreaks
210 rDocShell
.ErrorMessage(STR_MSSG_REMOVEOUTLINE_0
); // "Aufheben nicht moeglich"
215 sal_Bool
ScOutlineDocFunc::RemoveAllOutlines( SCTAB nTab
, sal_Bool bRecord
, sal_Bool bApi
)
217 sal_Bool bSuccess
= false;
218 ScDocument
* pDoc
= rDocShell
.GetDocument();
220 if (bRecord
&& !pDoc
->IsUndoEnabled())
222 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
227 SCCOLROW nCol1
, nCol2
, nRow1
, nRow2
;
228 pTable
->GetColArray()->GetRange( nCol1
, nCol2
);
229 pTable
->GetRowArray()->GetRange( nRow1
, nRow2
);
230 SCCOL nStartCol
= static_cast<SCCOL
>(nCol1
);
231 SCROW nStartRow
= nRow1
;
232 SCCOL nEndCol
= static_cast<SCCOL
>(nCol2
);
233 SCROW nEndRow
= nRow2
;
235 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
236 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, sal_True
);
237 pDoc
->CopyToDocument( nStartCol
, 0, nTab
, nEndCol
, MAXROW
, nTab
, IDF_NONE
, false, pUndoDoc
);
238 pDoc
->CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, IDF_NONE
, false, pUndoDoc
);
240 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
242 rDocShell
.GetUndoManager()->AddUndoAction(
243 new ScUndoRemoveAllOutlines( &rDocShell
,
244 nStartCol
, nStartRow
, nTab
,
245 nEndCol
, nEndRow
, nTab
,
246 pUndoDoc
, pUndoTab
) );
249 SelectLevel( nTab
, sal_True
, pTable
->GetColArray()->GetDepth(), false, false, bApi
);
250 SelectLevel( nTab
, false, pTable
->GetRowArray()->GetDepth(), false, false, bApi
);
251 pDoc
->SetOutlineTable( nTab
, NULL
);
253 pDoc
->UpdatePageBreaks( nTab
);
255 if (pDoc
->IsStreamValid(nTab
))
256 pDoc
->SetStreamValid(nTab
, false);
258 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
,
259 PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
| PAINT_SIZE
);
260 rDocShell
.SetDocumentModified();
261 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
268 //------------------------------------------------------------------------
270 sal_Bool
ScOutlineDocFunc::AutoOutline( const ScRange
& rRange
, sal_Bool bRecord
, sal_Bool bApi
)
272 SCCOL nStartCol
= rRange
.aStart
.Col();
273 SCROW nStartRow
= rRange
.aStart
.Row();
274 SCCOL nEndCol
= rRange
.aEnd
.Col();
275 SCROW nEndRow
= rRange
.aEnd
.Row();
276 SCTAB nTab
= rRange
.aStart
.Tab();
278 ScDocument
* pDoc
= rDocShell
.GetDocument();
280 if (bRecord
&& !pDoc
->IsUndoEnabled())
282 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
284 ScDocument
* pUndoDoc
= NULL
;
285 ScOutlineTable
* pUndoTab
= NULL
;
291 pUndoTab
= new ScOutlineTable( *pTable
);
293 SCCOLROW nCol1
, nCol2
, nRow1
, nRow2
;
294 pTable
->GetColArray()->GetRange( nCol1
, nCol2
);
295 pTable
->GetRowArray()->GetRange( nRow1
, nRow2
);
296 SCCOL nOutStartCol
= static_cast<SCCOL
>(nCol1
);
297 SCROW nOutStartRow
= nRow1
;
298 SCCOL nOutEndCol
= static_cast<SCCOL
>(nCol2
);
299 SCROW nOutEndRow
= nRow2
;
301 pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
302 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, sal_True
);
303 pDoc
->CopyToDocument( nOutStartCol
, 0, nTab
, nOutEndCol
, MAXROW
, nTab
, IDF_NONE
, false, pUndoDoc
);
304 pDoc
->CopyToDocument( 0, nOutStartRow
, nTab
, MAXCOL
, nOutEndRow
, nTab
, IDF_NONE
, false, pUndoDoc
);
308 SelectLevel( nTab
, sal_True
, pTable
->GetColArray()->GetDepth(), false, false, bApi
);
309 SelectLevel( nTab
, false, pTable
->GetRowArray()->GetDepth(), false, false, bApi
);
310 pDoc
->SetOutlineTable( nTab
, NULL
);
313 pDoc
->DoAutoOutline( nStartCol
,nStartRow
, nEndCol
,nEndRow
, nTab
);
317 rDocShell
.GetUndoManager()->AddUndoAction(
318 new ScUndoAutoOutline( &rDocShell
,
319 nStartCol
, nStartRow
, nTab
,
320 nEndCol
, nEndRow
, nTab
,
321 pUndoDoc
, pUndoTab
) );
324 if (pDoc
->IsStreamValid(nTab
))
325 pDoc
->SetStreamValid(nTab
, false);
327 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_LEFT
| PAINT_TOP
| PAINT_SIZE
);
328 rDocShell
.SetDocumentModified();
329 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
334 //------------------------------------------------------------------------
336 sal_Bool
ScOutlineDocFunc::SelectLevel( SCTAB nTab
, sal_Bool bColumns
, sal_uInt16 nLevel
,
337 sal_Bool bRecord
, sal_Bool bPaint
, sal_Bool
/* bApi */ )
339 ScDocument
* pDoc
= rDocShell
.GetDocument();
341 if (bRecord
&& !pDoc
->IsUndoEnabled())
343 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
); // ist schon da
346 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
350 SCCOLROW nStart
, nEnd
;
351 pArray
->GetRange( nStart
, nEnd
);
355 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
356 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
359 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, false );
360 pDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
361 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, false,
366 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, false, sal_True
);
367 pDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, false, pUndoDoc
);
370 rDocShell
.GetUndoManager()->AddUndoAction(
371 new ScUndoOutlineLevel( &rDocShell
,
372 nStart
, nEnd
, nTab
, //! start und end berechnen
374 bColumns
, nLevel
) );
377 ScSubOutlineIterator
aIter( pArray
); // alle Eintraege
378 ScOutlineEntry
* pEntry
;
379 while ((pEntry
=aIter
.GetNext()) != NULL
)
381 sal_uInt16 nThisLevel
= aIter
.LastLevel();
382 sal_Bool bShow
= (nThisLevel
< nLevel
);
383 if (bShow
) // einblenden
385 pEntry
->SetHidden( false );
386 pEntry
->SetVisible( sal_True
);
388 else if ( nThisLevel
== nLevel
) // ausblenden
390 pEntry
->SetHidden( sal_True
);
391 pEntry
->SetVisible( sal_True
);
395 pEntry
->SetVisible( false );
398 SCCOLROW nThisStart
= pEntry
->GetStart();
399 SCCOLROW nThisEnd
= pEntry
->GetEnd();
400 for (SCCOLROW i
=nThisStart
; i
<=nThisEnd
; i
++)
403 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, bShow
);
406 // show several rows together, don't show filtered rows
407 SCROW nFilterEnd
= i
;
408 bool bFiltered
= pDoc
->RowFiltered( i
, nTab
, NULL
, &nFilterEnd
);
409 nFilterEnd
= std::min( nThisEnd
, nFilterEnd
);
410 if ( !bShow
|| !bFiltered
)
411 pDoc
->ShowRows( i
, nFilterEnd
, nTab
, bShow
);
417 pDoc
->SetDrawPageSize(nTab
);
418 pDoc
->UpdatePageBreaks( nTab
);
421 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
423 rDocShell
.SetDocumentModified();
424 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
429 //------------------------------------------------------------------------
431 sal_Bool
ScOutlineDocFunc::ShowMarkedOutlines( const ScRange
& rRange
, sal_Bool bRecord
)
433 sal_Bool bDone
= false;
435 SCCOL nStartCol
= rRange
.aStart
.Col();
436 SCROW nStartRow
= rRange
.aStart
.Row();
437 SCCOL nEndCol
= rRange
.aEnd
.Col();
438 SCROW nEndRow
= rRange
.aEnd
.Row();
439 SCTAB nTab
= rRange
.aStart
.Tab();
441 ScDocument
* pDoc
= rDocShell
.GetDocument();
443 if (bRecord
&& !pDoc
->IsUndoEnabled())
445 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
449 ScOutlineArray
* pArray
;
450 ScOutlineEntry
* pEntry
;
459 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
460 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
461 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, sal_True
);
462 pDoc
->CopyToDocument( nStartCol
, 0, nTab
, nEndCol
, MAXROW
, nTab
, IDF_NONE
, false, pUndoDoc
);
463 pDoc
->CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, IDF_NONE
, false, pUndoDoc
);
465 rDocShell
.GetUndoManager()->AddUndoAction(
466 new ScUndoOutlineBlock( &rDocShell
,
467 nStartCol
, nStartRow
, nTab
, nEndCol
, nEndRow
, nTab
,
468 pUndoDoc
, pUndoTab
, sal_True
) );
475 pArray
= pTable
->GetColArray();
476 ScSubOutlineIterator
aColIter( pArray
);
477 while ((pEntry
=aColIter
.GetNext()) != NULL
)
479 nStart
= pEntry
->GetStart();
480 nEnd
= pEntry
->GetEnd();
481 if ( nStart
>=nStartCol
&& nEnd
<=nEndCol
)
483 pEntry
->SetHidden( false );
484 pEntry
->SetVisible( sal_True
);
485 if (nStart
<nMin
) nMin
=nStart
;
486 if (nEnd
>nMax
) nMax
=nEnd
;
489 for ( i
=nMin
; i
<=nMax
; i
++ )
490 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, sal_True
);
496 pArray
= pTable
->GetRowArray();
497 ScSubOutlineIterator
aRowIter( pArray
);
498 while ((pEntry
=aRowIter
.GetNext()) != NULL
)
500 nStart
= pEntry
->GetStart();
501 nEnd
= pEntry
->GetEnd();
502 if ( nStart
>=nStartRow
&& nEnd
<=nEndRow
)
504 pEntry
->SetHidden( false );
505 pEntry
->SetVisible( sal_True
);
506 if (nStart
<nMin
) nMin
=nStart
;
507 if (nEnd
>nMax
) nMax
=nEnd
;
510 for ( i
=nMin
; i
<=nMax
; i
++ )
512 // show several rows together, don't show filtered rows
513 SCROW nFilterEnd
= i
;
514 bool bFiltered
= pDoc
->RowFiltered( i
, nTab
, NULL
, &nFilterEnd
);
515 nFilterEnd
= std::min( nMax
, nFilterEnd
);
517 pDoc
->ShowRows( i
, nFilterEnd
, nTab
, sal_True
);
521 pDoc
->SetDrawPageSize(nTab
);
522 pDoc
->UpdatePageBreaks( nTab
);
524 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
);
525 rDocShell
.SetDocumentModified();
528 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
534 sal_Bool
ScOutlineDocFunc::HideMarkedOutlines( const ScRange
& rRange
, sal_Bool bRecord
, sal_Bool bApi
)
536 sal_Bool bDone
= false;
538 SCCOL nStartCol
= rRange
.aStart
.Col();
539 SCROW nStartRow
= rRange
.aStart
.Row();
540 SCCOL nEndCol
= rRange
.aEnd
.Col();
541 SCROW nEndRow
= rRange
.aEnd
.Row();
542 SCTAB nTab
= rRange
.aStart
.Tab();
544 ScDocument
* pDoc
= rDocShell
.GetDocument();
546 if (bRecord
&& !pDoc
->IsUndoEnabled())
548 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
552 const ScOutlineEntry
* pEntry
;
560 SCCOLROW nEffStartCol
= nStartCol
;
561 SCCOLROW nEffEndCol
= nEndCol
;
562 ScOutlineArray
* pColArray
= pTable
->GetColArray();
563 pColArray
->FindTouchedLevel( nStartCol
, nEndCol
, nColLevel
);
564 pColArray
->ExtendBlock( nColLevel
, nEffStartCol
, nEffEndCol
);
565 SCCOLROW nEffStartRow
= nStartRow
;
566 SCCOLROW nEffEndRow
= nEndRow
;
567 ScOutlineArray
* pRowArray
= pTable
->GetRowArray();
568 pRowArray
->FindTouchedLevel( nStartRow
, nEndRow
, nRowLevel
);
569 pRowArray
->ExtendBlock( nRowLevel
, nEffStartRow
, nEffEndRow
);
573 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
574 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
575 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, sal_True
);
576 pDoc
->CopyToDocument( static_cast<SCCOL
>(nEffStartCol
), 0, nTab
,
577 static_cast<SCCOL
>(nEffEndCol
), MAXROW
, nTab
, IDF_NONE
,
579 pDoc
->CopyToDocument( 0, nEffStartRow
, nTab
, MAXCOL
, nEffEndRow
, nTab
, IDF_NONE
, false, pUndoDoc
);
581 rDocShell
.GetUndoManager()->AddUndoAction(
582 new ScUndoOutlineBlock( &rDocShell
,
583 nStartCol
, nStartRow
, nTab
, nEndCol
, nEndRow
, nTab
,
584 pUndoDoc
, pUndoTab
, false ) );
589 nCount
= pColArray
->GetCount(nColLevel
);
590 for ( i
=0; i
<nCount
; i
++ )
592 pEntry
= pColArray
->GetEntry(nColLevel
,i
);
593 nStart
= pEntry
->GetStart();
594 nEnd
= pEntry
->GetEnd();
596 if ( static_cast<SCCOLROW
>(nStartCol
)<=nEnd
&& static_cast<SCCOLROW
>(nEndCol
)>=nStart
)
597 HideOutline( nTab
, sal_True
, nColLevel
, i
, false, false, bApi
);
602 nCount
= pRowArray
->GetCount(nRowLevel
);
603 for ( i
=0; i
<nCount
; i
++ )
605 pEntry
= pRowArray
->GetEntry(nRowLevel
,i
);
606 nStart
= pEntry
->GetStart();
607 nEnd
= pEntry
->GetEnd();
609 if ( nStartRow
<=nEnd
&& nEndRow
>=nStart
)
610 HideOutline( nTab
, false, nRowLevel
, i
, false, false, bApi
);
613 pDoc
->SetDrawPageSize(nTab
);
614 pDoc
->UpdatePageBreaks( nTab
);
616 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
);
618 rDocShell
.SetDocumentModified();
621 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
627 //------------------------------------------------------------------------
629 sal_Bool
ScOutlineDocFunc::ShowOutline( SCTAB nTab
, sal_Bool bColumns
, sal_uInt16 nLevel
, sal_uInt16 nEntry
,
630 sal_Bool bRecord
, sal_Bool bPaint
, sal_Bool
/* bApi */ )
632 ScDocument
* pDoc
= rDocShell
.GetDocument();
633 if (bRecord
&& !pDoc
->IsUndoEnabled())
636 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
637 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
638 ScOutlineEntry
* pEntry
= pArray
->GetEntry( nLevel
, nEntry
);
639 SCCOLROW nStart
= pEntry
->GetStart();
640 SCCOLROW nEnd
= pEntry
->GetEnd();
644 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
647 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, false );
648 pDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
649 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, false,
654 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, false, sal_True
);
655 pDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, false, pUndoDoc
);
658 rDocShell
.GetUndoManager()->AddUndoAction(
659 new ScUndoDoOutline( &rDocShell
,
660 nStart
, nEnd
, nTab
, pUndoDoc
, //! start und end berechnen
661 bColumns
, nLevel
, nEntry
, sal_True
) );
664 pEntry
->SetHidden(false);
666 for ( i
= nStart
; i
<= nEnd
; i
++ )
669 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, sal_True
);
672 // show several rows together, don't show filtered rows
673 SCROW nFilterEnd
= i
;
674 bool bFiltered
= pDoc
->RowFiltered( i
, nTab
, NULL
, &nFilterEnd
);
675 nFilterEnd
= std::min( nEnd
, nFilterEnd
);
677 pDoc
->ShowRows( i
, nFilterEnd
, nTab
, sal_True
);
682 ScSubOutlineIterator
aIter( pArray
, nLevel
, nEntry
);
683 while ((pEntry
=aIter
.GetNext()) != NULL
)
685 if ( pEntry
->IsHidden() )
687 SCCOLROW nSubStart
= pEntry
->GetStart();
688 SCCOLROW nSubEnd
= pEntry
->GetEnd();
690 for ( i
= nSubStart
; i
<= nSubEnd
; i
++ )
691 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, false );
693 pDoc
->ShowRows( nSubStart
, nSubEnd
, nTab
, sal_False
);
697 pArray
->SetVisibleBelow( nLevel
, nEntry
, sal_True
, sal_True
);
699 pDoc
->SetDrawPageSize(nTab
);
700 pDoc
->InvalidatePageBreaks(nTab
);
701 pDoc
->UpdatePageBreaks( nTab
);
704 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
706 rDocShell
.SetDocumentModified();
708 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
710 return sal_True
; //! immer ???
713 sal_Bool
ScOutlineDocFunc::HideOutline( SCTAB nTab
, sal_Bool bColumns
, sal_uInt16 nLevel
, sal_uInt16 nEntry
,
714 sal_Bool bRecord
, sal_Bool bPaint
, sal_Bool
/* bApi */ )
716 ScDocument
* pDoc
= rDocShell
.GetDocument();
717 if (bRecord
&& !pDoc
->IsUndoEnabled())
720 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
721 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
722 ScOutlineEntry
* pEntry
= pArray
->GetEntry( nLevel
, nEntry
);
723 SCCOLROW nStart
= pEntry
->GetStart();
724 SCCOLROW nEnd
= pEntry
->GetEnd();
728 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
731 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, false );
732 pDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
733 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, false,
738 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, false, sal_True
);
739 pDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, false, pUndoDoc
);
742 rDocShell
.GetUndoManager()->AddUndoAction(
743 new ScUndoDoOutline( &rDocShell
,
744 nStart
, nEnd
, nTab
, pUndoDoc
,
745 bColumns
, nLevel
, nEntry
, false ) );
748 pEntry
->SetHidden(true);
751 for ( i
= nStart
; i
<= nEnd
; i
++ )
752 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, sal_False
);
754 pDoc
->ShowRows( nStart
, nEnd
, nTab
, sal_False
);
756 pArray
->SetVisibleBelow( nLevel
, nEntry
, false );
758 pDoc
->SetDrawPageSize(nTab
);
759 pDoc
->InvalidatePageBreaks(nTab
);
760 pDoc
->UpdatePageBreaks( nTab
);
763 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
765 rDocShell
.SetDocumentModified();
767 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
769 return sal_True
; //! immer ???
776 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */