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 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())
93 pUndoTab
= new ScOutlineTable( *pTable
);
95 ScOutlineArray
& rArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
100 bRes
= rArray
.Insert( nStartCol
, nEndCol
, bSize
);
102 bRes
= rArray
.Insert( nStartRow
, nEndRow
, bSize
);
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
121 nParts
|= PAINT_LEFT
;
123 nParts
|= PAINT_SIZE
;
125 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
126 rDocShell
.SetDocumentModified();
127 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
133 rDocShell
.ErrorMessage(STR_MSSG_MAKEOUTLINE_0
); // "Gruppierung nicht moeglich"
140 bool ScOutlineDocFunc::RemoveOutline( const ScRange
& rRange
, bool bColumns
, bool bRecord
, bool bApi
)
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())
154 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
157 ScOutlineTable
* pUndoTab
= NULL
;
159 pUndoTab
= new ScOutlineTable( *pTable
);
161 ScOutlineArray
& rArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
166 bRes
= rArray
.Remove( nStartCol
, nEndCol
, bSize
);
168 bRes
= rArray
.Remove( nStartRow
, nEndRow
, bSize
);
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
187 nParts
|= PAINT_LEFT
;
189 nParts
|= PAINT_SIZE
;
191 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
192 rDocShell
.SetDocumentModified();
194 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
196 // es wird nicht wieder eingeblendet -> kein UpdatePageBreaks
203 rDocShell
.ErrorMessage(STR_MSSG_REMOVEOUTLINE_0
); // "Aufheben nicht moeglich"
208 bool ScOutlineDocFunc::RemoveAllOutlines( SCTAB nTab
, bool bRecord
)
210 bool bSuccess
= false;
211 ScDocument
& rDoc
= rDocShell
.GetDocument();
213 if (bRecord
&& !rDoc
.IsUndoEnabled())
215 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
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() );
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())
273 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
275 ScDocument
* pUndoDoc
= NULL
;
276 ScOutlineTable
* pUndoTab
= NULL
;
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
);
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
);
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() );
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())
332 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
); // ist schon da
335 ScOutlineArray
& rArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
337 SCCOLROW nStart
, nEnd
;
338 rArray
.GetRange( nStart
, nEnd
);
342 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
343 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
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,
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
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 );
382 pEntry
->SetVisible( false );
385 SCCOLROW nThisStart
= pEntry
->GetStart();
386 SCCOLROW nThisEnd
= pEntry
->GetEnd();
387 for (SCCOLROW i
=nThisStart
; i
<=nThisEnd
; i
++)
390 rDoc
.ShowCol( static_cast<SCCOL
>(i
), nTab
, bShow
);
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
);
404 rDoc
.SetDrawPageSize(nTab
);
405 rDoc
.UpdatePageBreaks( nTab
);
408 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
410 rDocShell
.SetDocumentModified();
411 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
416 bool ScOutlineDocFunc::ShowMarkedOutlines( const ScRange
& rRange
, bool bRecord
)
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())
430 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
434 ScOutlineEntry
* pEntry
;
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 ) );
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 );
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
);
501 rDoc
.ShowRows( i
, nFilterEnd
, nTab
, true );
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();
512 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
518 bool ScOutlineDocFunc::HideMarkedOutlines( const ScRange
& rRange
, bool bRecord
)
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())
532 ScOutlineTable
* pTable
= rDoc
.GetOutlineTable( nTab
);
536 const ScOutlineEntry
* pEntry
;
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
);
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
,
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 ) );
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 );
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();
605 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
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())
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();
626 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
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,
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);
648 for ( i
= nStart
; i
<= nEnd
; i
++ )
651 rDoc
.ShowCol( static_cast<SCCOL
>(i
), nTab
, true );
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
);
659 rDoc
.ShowRows( i
, nFilterEnd
, nTab
, true );
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();
672 for ( i
= nSubStart
; i
<= nSubEnd
; i
++ )
673 rDoc
.ShowCol( static_cast<SCCOL
>(i
), nTab
, false );
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
);
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())
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();
710 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
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,
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);
733 for ( i
= nStart
; i
<= nEnd
; i
++ )
734 rDoc
.ShowCol( static_cast<SCCOL
>(i
), nTab
, false );
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
);
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: */