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"
30 static void lcl_InvalidateOutliner( SfxBindings
* 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
;
53 SCCOL nEndCol
= MAXCOL
; // fuer Test auf Merge
54 SCROW nEndRow
= MAXROW
;
58 nStartCol
= static_cast<SCCOL
>(nStart
);
59 nEndCol
= static_cast<SCCOL
>(nEnd
);
67 if (rDoc
.HasAttrib( nStartCol
,nStartRow
,nTab
, nEndCol
,nEndRow
,nTab
,
68 HASATTR_MERGED
| HASATTR_OVERLAPPED
))
73 rDocShell
.PostPaint( nStartCol
,nStartRow
,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
76 void ScOutlineDocFunc::MakeOutline( const ScRange
& rRange
, bool bColumns
, bool bRecord
, bool bApi
)
78 SCCOL nStartCol
= rRange
.aStart
.Col();
79 SCROW nStartRow
= rRange
.aStart
.Row();
80 SCCOL nEndCol
= rRange
.aEnd
.Col();
81 SCROW nEndRow
= rRange
.aEnd
.Row();
82 SCTAB nTab
= rRange
.aStart
.Tab();
84 ScDocument
& rDoc
= rDocShell
.GetDocument();
85 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
, true );
86 ScOutlineTable
* pUndoTab
= nullptr;
88 if (bRecord
&& !rDoc
.IsUndoEnabled())
92 pUndoTab
= new ScOutlineTable( *pTable
);
94 ScOutlineArray
& rArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
99 bRes
= rArray
.Insert( nStartCol
, nEndCol
, bSize
);
101 bRes
= rArray
.Insert( nStartRow
, nEndRow
, bSize
);
107 rDocShell
.GetUndoManager()->AddUndoAction(
108 new ScUndoMakeOutline( &rDocShell
,
109 nStartCol
,nStartRow
,nTab
,nEndCol
,nEndRow
,nTab
,
110 pUndoTab
, bColumns
, true ) );
113 if (rDoc
.IsStreamValid(nTab
))
114 rDoc
.SetStreamValid(nTab
, false);
116 sal_uInt16 nParts
= 0; // Datenbereich nicht geaendert
120 nParts
|= PAINT_LEFT
;
122 nParts
|= PAINT_SIZE
;
124 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
125 rDocShell
.SetDocumentModified();
126 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
131 rDocShell
.ErrorMessage(STR_MSSG_MAKEOUTLINE_0
); // "Gruppierung nicht moeglich"
136 void ScOutlineDocFunc::RemoveOutline( const ScRange
& rRange
, bool bColumns
, bool bRecord
, bool bApi
)
140 SCCOL nStartCol
= rRange
.aStart
.Col();
141 SCROW nStartRow
= rRange
.aStart
.Row();
142 SCCOL nEndCol
= rRange
.aEnd
.Col();
143 SCROW nEndRow
= rRange
.aEnd
.Row();
144 SCTAB nTab
= rRange
.aStart
.Tab();
146 ScDocument
& rDoc
= rDocShell
.GetDocument();
148 if (bRecord
&& !rDoc
.IsUndoEnabled())
150 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
153 ScOutlineTable
* pUndoTab
= nullptr;
155 pUndoTab
= new ScOutlineTable( *pTable
);
157 ScOutlineArray
& rArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
162 bRes
= rArray
.Remove( nStartCol
, nEndCol
, bSize
);
164 bRes
= rArray
.Remove( nStartRow
, nEndRow
, bSize
);
170 rDocShell
.GetUndoManager()->AddUndoAction(
171 new ScUndoMakeOutline( &rDocShell
,
172 nStartCol
,nStartRow
,nTab
, nEndCol
,nEndRow
,nTab
,
173 pUndoTab
, bColumns
, false ) );
176 if (rDoc
.IsStreamValid(nTab
))
177 rDoc
.SetStreamValid(nTab
, false);
179 sal_uInt16 nParts
= 0; // Datenbereich nicht geaendert
183 nParts
|= PAINT_LEFT
;
185 nParts
|= PAINT_SIZE
;
187 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
188 rDocShell
.SetDocumentModified();
190 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
192 // es wird nicht wieder eingeblendet -> kein UpdatePageBreaks
199 rDocShell
.ErrorMessage(STR_MSSG_REMOVEOUTLINE_0
); // "Aufheben nicht moeglich"
202 bool ScOutlineDocFunc::RemoveAllOutlines( SCTAB nTab
, bool bRecord
)
204 bool bSuccess
= false;
205 ScDocument
& rDoc
= rDocShell
.GetDocument();
207 if (bRecord
&& !rDoc
.IsUndoEnabled())
209 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
214 SCCOLROW nCol1
, nCol2
, nRow1
, nRow2
;
215 pTable
->GetColArray().GetRange( nCol1
, nCol2
);
216 pTable
->GetRowArray().GetRange( nRow1
, nRow2
);
217 SCCOL nStartCol
= static_cast<SCCOL
>(nCol1
);
218 SCROW nStartRow
= nRow1
;
219 SCCOL nEndCol
= static_cast<SCCOL
>(nCol2
);
220 SCROW nEndRow
= nRow2
;
222 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
223 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, true, true );
224 rDoc
.CopyToDocument( nStartCol
, 0, nTab
, nEndCol
, MAXROW
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
225 rDoc
.CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
227 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
229 rDocShell
.GetUndoManager()->AddUndoAction(
230 new ScUndoRemoveAllOutlines( &rDocShell
,
231 nStartCol
, nStartRow
, nTab
,
232 nEndCol
, nEndRow
, nTab
,
233 pUndoDoc
, pUndoTab
) );
236 SelectLevel( nTab
, true, pTable
->GetColArray().GetDepth(), false, false );
237 SelectLevel( nTab
, false, pTable
->GetRowArray().GetDepth(), false, false );
238 rDoc
.SetOutlineTable( nTab
, nullptr );
240 rDoc
.UpdatePageBreaks( nTab
);
242 if (rDoc
.IsStreamValid(nTab
))
243 rDoc
.SetStreamValid(nTab
, false);
245 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
,
246 PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
| PAINT_SIZE
);
247 rDocShell
.SetDocumentModified();
248 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
255 void ScOutlineDocFunc::AutoOutline( const ScRange
& rRange
, bool bRecord
)
257 SCCOL nStartCol
= rRange
.aStart
.Col();
258 SCROW nStartRow
= rRange
.aStart
.Row();
259 SCCOL nEndCol
= rRange
.aEnd
.Col();
260 SCROW nEndRow
= rRange
.aEnd
.Row();
261 SCTAB nTab
= rRange
.aStart
.Tab();
263 ScDocument
& rDoc
= rDocShell
.GetDocument();
265 if (bRecord
&& !rDoc
.IsUndoEnabled())
267 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
269 ScDocument
* pUndoDoc
= nullptr;
270 ScOutlineTable
* pUndoTab
= nullptr;
276 pUndoTab
= new ScOutlineTable( *pTable
);
278 SCCOLROW nCol1
, nCol2
, nRow1
, nRow2
;
279 pTable
->GetColArray().GetRange( nCol1
, nCol2
);
280 pTable
->GetRowArray().GetRange( nRow1
, nRow2
);
281 SCCOL nOutStartCol
= static_cast<SCCOL
>(nCol1
);
282 SCROW nOutStartRow
= nRow1
;
283 SCCOL nOutEndCol
= static_cast<SCCOL
>(nCol2
);
284 SCROW nOutEndRow
= nRow2
;
286 pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
287 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, true, true );
288 rDoc
.CopyToDocument( nOutStartCol
, 0, nTab
, nOutEndCol
, MAXROW
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
289 rDoc
.CopyToDocument( 0, nOutStartRow
, nTab
, MAXCOL
, nOutEndRow
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
293 SelectLevel( nTab
, true, pTable
->GetColArray().GetDepth(), false, false );
294 SelectLevel( nTab
, false, pTable
->GetRowArray().GetDepth(), false, false );
295 rDoc
.SetOutlineTable( nTab
, nullptr );
298 rDoc
.DoAutoOutline( nStartCol
,nStartRow
, nEndCol
,nEndRow
, nTab
);
302 rDocShell
.GetUndoManager()->AddUndoAction(
303 new ScUndoAutoOutline( &rDocShell
,
304 nStartCol
, nStartRow
, nTab
,
305 nEndCol
, nEndRow
, nTab
,
306 pUndoDoc
, pUndoTab
) );
309 if (rDoc
.IsStreamValid(nTab
))
310 rDoc
.SetStreamValid(nTab
, false);
312 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_LEFT
| PAINT_TOP
| PAINT_SIZE
);
313 rDocShell
.SetDocumentModified();
314 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
317 bool ScOutlineDocFunc::SelectLevel( SCTAB nTab
, bool bColumns
, sal_uInt16 nLevel
,
318 bool bRecord
, bool bPaint
)
320 ScDocument
& rDoc
= rDocShell
.GetDocument();
322 if (bRecord
&& !rDoc
.IsUndoEnabled())
324 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
); // ist schon da
327 ScOutlineArray
& rArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
329 SCCOLROW nStart
, nEnd
;
330 rArray
.GetRange( nStart
, nEnd
);
334 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
335 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
338 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, true );
339 rDoc
.CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
340 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, InsertDeleteFlags::NONE
, false,
345 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, false, true );
346 rDoc
.CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
349 rDocShell
.GetUndoManager()->AddUndoAction(
350 new ScUndoOutlineLevel( &rDocShell
,
351 nStart
, nEnd
, nTab
, //! start und end berechnen
353 bColumns
, nLevel
) );
356 ScSubOutlineIterator
aIter( &rArray
); // alle Eintraege
357 ScOutlineEntry
* pEntry
;
358 while ((pEntry
=aIter
.GetNext()) != nullptr)
360 sal_uInt16 nThisLevel
= aIter
.LastLevel();
361 bool bShow
= (nThisLevel
< nLevel
);
362 if (bShow
) // einblenden
364 pEntry
->SetHidden( false );
365 pEntry
->SetVisible( true );
367 else if ( nThisLevel
== nLevel
) // ausblenden
369 pEntry
->SetHidden( true );
370 pEntry
->SetVisible( true );
374 pEntry
->SetVisible( false );
377 SCCOLROW nThisStart
= pEntry
->GetStart();
378 SCCOLROW nThisEnd
= pEntry
->GetEnd();
379 for (SCCOLROW i
=nThisStart
; i
<=nThisEnd
; i
++)
382 rDoc
.ShowCol( static_cast<SCCOL
>(i
), nTab
, bShow
);
385 // show several rows together, don't show filtered rows
386 SCROW nFilterEnd
= i
;
387 bool bFiltered
= rDoc
.RowFiltered( i
, nTab
, nullptr, &nFilterEnd
);
388 nFilterEnd
= std::min( nThisEnd
, nFilterEnd
);
389 if ( !bShow
|| !bFiltered
)
390 rDoc
.ShowRows( i
, nFilterEnd
, nTab
, bShow
);
396 rDoc
.SetDrawPageSize(nTab
);
397 rDoc
.UpdatePageBreaks( nTab
);
400 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
402 rDocShell
.SetDocumentModified();
403 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
408 bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange
& rRange
, bool bRecord
)
412 SCCOL nStartCol
= rRange
.aStart
.Col();
413 SCROW nStartRow
= rRange
.aStart
.Row();
414 SCCOL nEndCol
= rRange
.aEnd
.Col();
415 SCROW nEndRow
= rRange
.aEnd
.Row();
416 SCTAB nTab
= rRange
.aStart
.Tab();
418 ScDocument
& rDoc
= rDocShell
.GetDocument();
420 if (bRecord
&& !rDoc
.IsUndoEnabled())
422 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
426 ScOutlineEntry
* pEntry
;
435 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
436 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
437 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, true, true );
438 rDoc
.CopyToDocument( nStartCol
, 0, nTab
, nEndCol
, MAXROW
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
439 rDoc
.CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
441 rDocShell
.GetUndoManager()->AddUndoAction(
442 new ScUndoOutlineBlock( &rDocShell
,
443 nStartCol
, nStartRow
, nTab
, nEndCol
, nEndRow
, nTab
,
444 pUndoDoc
, pUndoTab
, true ) );
451 ScOutlineArray
& rColArray
= pTable
->GetColArray();
452 ScSubOutlineIterator
aColIter( &rColArray
);
453 while ((pEntry
=aColIter
.GetNext()) != nullptr)
455 nStart
= pEntry
->GetStart();
456 nEnd
= pEntry
->GetEnd();
457 if ( nStart
>=nStartCol
&& nEnd
<=nEndCol
)
459 pEntry
->SetHidden( false );
460 pEntry
->SetVisible( true );
461 if (nStart
<nMin
) nMin
=nStart
;
462 if (nEnd
>nMax
) nMax
=nEnd
;
465 for ( i
=nMin
; i
<=nMax
; i
++ )
466 rDoc
.ShowCol( static_cast<SCCOL
>(i
), nTab
, true );
472 ScOutlineArray
& rRowArray
= pTable
->GetRowArray();
473 ScSubOutlineIterator
aRowIter( &rRowArray
);
474 while ((pEntry
=aRowIter
.GetNext()) != nullptr)
476 nStart
= pEntry
->GetStart();
477 nEnd
= pEntry
->GetEnd();
478 if ( nStart
>=nStartRow
&& nEnd
<=nEndRow
)
480 pEntry
->SetHidden( false );
481 pEntry
->SetVisible( true );
482 if (nStart
<nMin
) nMin
=nStart
;
483 if (nEnd
>nMax
) nMax
=nEnd
;
486 for ( i
=nMin
; i
<=nMax
; i
++ )
488 // show several rows together, don't show filtered rows
489 SCROW nFilterEnd
= i
;
490 bool bFiltered
= rDoc
.RowFiltered( i
, nTab
, nullptr, &nFilterEnd
);
491 nFilterEnd
= std::min( nMax
, nFilterEnd
);
493 rDoc
.ShowRows( i
, nFilterEnd
, nTab
, true );
497 rDoc
.SetDrawPageSize(nTab
);
498 rDoc
.UpdatePageBreaks( nTab
);
500 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
);
501 rDocShell
.SetDocumentModified();
504 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
510 bool ScOutlineDocFunc::HideMarkedOutlines( const ScRange
& rRange
, bool bRecord
)
514 SCCOL nStartCol
= rRange
.aStart
.Col();
515 SCROW nStartRow
= rRange
.aStart
.Row();
516 SCCOL nEndCol
= rRange
.aEnd
.Col();
517 SCROW nEndRow
= rRange
.aEnd
.Row();
518 SCTAB nTab
= rRange
.aStart
.Tab();
520 ScDocument
& rDoc
= rDocShell
.GetDocument();
522 if (bRecord
&& !rDoc
.IsUndoEnabled())
524 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
528 const ScOutlineEntry
* pEntry
;
536 SCCOLROW nEffStartCol
= nStartCol
;
537 SCCOLROW nEffEndCol
= nEndCol
;
538 ScOutlineArray
& rColArray
= pTable
->GetColArray();
539 rColArray
.FindTouchedLevel( nStartCol
, nEndCol
, nColLevel
);
540 rColArray
.ExtendBlock( nColLevel
, nEffStartCol
, nEffEndCol
);
541 SCCOLROW nEffStartRow
= nStartRow
;
542 SCCOLROW nEffEndRow
= nEndRow
;
543 ScOutlineArray
& rRowArray
= pTable
->GetRowArray();
544 rRowArray
.FindTouchedLevel( nStartRow
, nEndRow
, nRowLevel
);
545 rRowArray
.ExtendBlock( nRowLevel
, nEffStartRow
, nEffEndRow
);
549 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
550 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
551 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, true, true );
552 rDoc
.CopyToDocument( static_cast<SCCOL
>(nEffStartCol
), 0, nTab
,
553 static_cast<SCCOL
>(nEffEndCol
), MAXROW
, nTab
, InsertDeleteFlags::NONE
,
555 rDoc
.CopyToDocument( 0, nEffStartRow
, nTab
, MAXCOL
, nEffEndRow
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
557 rDocShell
.GetUndoManager()->AddUndoAction(
558 new ScUndoOutlineBlock( &rDocShell
,
559 nStartCol
, nStartRow
, nTab
, nEndCol
, nEndRow
, nTab
,
560 pUndoDoc
, pUndoTab
, false ) );
565 nCount
= rColArray
.GetCount(nColLevel
);
566 for ( i
=0; i
<nCount
; i
++ )
568 pEntry
= rColArray
.GetEntry(nColLevel
,i
);
569 nStart
= pEntry
->GetStart();
570 nEnd
= pEntry
->GetEnd();
572 if ( static_cast<SCCOLROW
>(nStartCol
)<=nEnd
&& static_cast<SCCOLROW
>(nEndCol
)>=nStart
)
573 HideOutline( nTab
, true, nColLevel
, i
, false, false );
578 nCount
= rRowArray
.GetCount(nRowLevel
);
579 for ( i
=0; i
<nCount
; i
++ )
581 pEntry
= rRowArray
.GetEntry(nRowLevel
,i
);
582 nStart
= pEntry
->GetStart();
583 nEnd
= pEntry
->GetEnd();
585 if ( nStartRow
<=nEnd
&& nEndRow
>=nStart
)
586 HideOutline( nTab
, false, nRowLevel
, i
, false, false );
589 rDoc
.SetDrawPageSize(nTab
);
590 rDoc
.UpdatePageBreaks( nTab
);
592 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
);
594 rDocShell
.SetDocumentModified();
597 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
603 bool ScOutlineDocFunc::ShowOutline( SCTAB nTab
, bool bColumns
, sal_uInt16 nLevel
, sal_uInt16 nEntry
,
604 bool bRecord
, bool bPaint
)
606 ScDocument
& rDoc
= rDocShell
.GetDocument();
607 if (bRecord
&& !rDoc
.IsUndoEnabled())
610 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
611 ScOutlineArray
& rArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
612 ScOutlineEntry
* pEntry
= rArray
.GetEntry( nLevel
, nEntry
);
613 SCCOLROW nStart
= pEntry
->GetStart();
614 SCCOLROW nEnd
= pEntry
->GetEnd();
618 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
621 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, true );
622 rDoc
.CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
623 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, InsertDeleteFlags::NONE
, false,
628 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, false, true );
629 rDoc
.CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
632 rDocShell
.GetUndoManager()->AddUndoAction(
633 new ScUndoDoOutline( &rDocShell
,
634 nStart
, nEnd
, nTab
, pUndoDoc
, //! start und end berechnen
635 bColumns
, nLevel
, nEntry
, true ) );
638 pEntry
->SetHidden(false);
640 for ( i
= nStart
; i
<= nEnd
; i
++ )
643 rDoc
.ShowCol( static_cast<SCCOL
>(i
), nTab
, true );
646 // show several rows together, don't show filtered rows
647 SCROW nFilterEnd
= i
;
648 bool bFiltered
= rDoc
.RowFiltered( i
, nTab
, nullptr, &nFilterEnd
);
649 nFilterEnd
= std::min( nEnd
, nFilterEnd
);
651 rDoc
.ShowRows( i
, nFilterEnd
, nTab
, true );
656 ScSubOutlineIterator
aIter( &rArray
, nLevel
, nEntry
);
657 while ((pEntry
=aIter
.GetNext()) != nullptr)
659 if ( pEntry
->IsHidden() )
661 SCCOLROW nSubStart
= pEntry
->GetStart();
662 SCCOLROW nSubEnd
= pEntry
->GetEnd();
664 for ( i
= nSubStart
; i
<= nSubEnd
; i
++ )
665 rDoc
.ShowCol( static_cast<SCCOL
>(i
), nTab
, false );
667 rDoc
.ShowRows( nSubStart
, nSubEnd
, nTab
, false );
671 rArray
.SetVisibleBelow( nLevel
, nEntry
, true, true );
673 rDoc
.SetDrawPageSize(nTab
);
674 rDoc
.InvalidatePageBreaks(nTab
);
675 rDoc
.UpdatePageBreaks( nTab
);
678 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
680 rDocShell
.SetDocumentModified();
682 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
684 return true; //! immer ???
687 bool ScOutlineDocFunc::HideOutline( SCTAB nTab
, bool bColumns
, sal_uInt16 nLevel
, sal_uInt16 nEntry
,
688 bool bRecord
, bool bPaint
)
690 ScDocument
& rDoc
= rDocShell
.GetDocument();
691 if (bRecord
&& !rDoc
.IsUndoEnabled())
694 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
695 ScOutlineArray
& rArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
696 ScOutlineEntry
* pEntry
= rArray
.GetEntry( nLevel
, nEntry
);
697 SCCOLROW nStart
= pEntry
->GetStart();
698 SCCOLROW nEnd
= pEntry
->GetEnd();
702 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
705 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, true );
706 rDoc
.CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
707 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, InsertDeleteFlags::NONE
, false,
712 pUndoDoc
->InitUndo( &rDoc
, nTab
, nTab
, false, true );
713 rDoc
.CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, InsertDeleteFlags::NONE
, false, pUndoDoc
);
716 rDocShell
.GetUndoManager()->AddUndoAction(
717 new ScUndoDoOutline( &rDocShell
,
718 nStart
, nEnd
, nTab
, pUndoDoc
,
719 bColumns
, nLevel
, nEntry
, false ) );
722 pEntry
->SetHidden(true);
725 for ( i
= nStart
; i
<= nEnd
; i
++ )
726 rDoc
.ShowCol( static_cast<SCCOL
>(i
), nTab
, false );
728 rDoc
.ShowRows( nStart
, nEnd
, nTab
, false );
730 rArray
.SetVisibleBelow( nLevel
, nEntry
, false );
732 rDoc
.SetDrawPageSize(nTab
);
733 rDoc
.InvalidatePageBreaks(nTab
);
734 rDoc
.UpdatePageBreaks( nTab
);
737 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
739 rDocShell
.SetDocumentModified();
741 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
743 return true; //! immer ???
746 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */