1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: olinefun.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
36 // INCLUDE ---------------------------------------------------------------
38 #include <vcl/sound.hxx>
39 #include <sfx2/bindings.hxx>
41 #include "olinefun.hxx"
44 #include "olinetab.hxx"
45 #include "undodat.hxx"
46 #include "globstr.hrc"
50 //========================================================================
52 void lcl_InvalidateOutliner( SfxBindings
* pBindings
)
56 pBindings
->Invalidate( SID_OUTLINE_SHOW
);
57 pBindings
->Invalidate( SID_OUTLINE_HIDE
);
58 pBindings
->Invalidate( SID_OUTLINE_REMOVE
);
60 pBindings
->Invalidate( SID_STATUS_SUM
); // wegen ein-/ausblenden
61 pBindings
->Invalidate( SID_ATTR_SIZE
);
65 //------------------------------------------------------------------------
67 //! PaintWidthHeight zur DocShell verschieben?
69 void lcl_PaintWidthHeight( ScDocShell
& rDocShell
, SCTAB nTab
,
70 BOOL bColumns
, SCCOLROW nStart
, SCCOLROW nEnd
)
72 ScDocument
* pDoc
= rDocShell
.GetDocument();
74 USHORT nParts
= PAINT_GRID
;
77 SCCOL nEndCol
= MAXCOL
; // fuer Test auf Merge
78 SCROW nEndRow
= MAXROW
;
82 nStartCol
= static_cast<SCCOL
>(nStart
);
83 nEndCol
= static_cast<SCCOL
>(nEnd
);
91 if (pDoc
->HasAttrib( nStartCol
,nStartRow
,nTab
, nEndCol
,nEndRow
,nTab
,
92 HASATTR_MERGED
| HASATTR_OVERLAPPED
))
97 rDocShell
.PostPaint( nStartCol
,nStartRow
,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
100 //------------------------------------------------------------------------
102 BOOL
ScOutlineDocFunc::MakeOutline( const ScRange
& rRange
, BOOL bColumns
, BOOL bRecord
, BOOL bApi
)
104 BOOL bSuccess
= FALSE
;
105 SCCOL nStartCol
= rRange
.aStart
.Col();
106 SCROW nStartRow
= rRange
.aStart
.Row();
107 SCCOL nEndCol
= rRange
.aEnd
.Col();
108 SCROW nEndRow
= rRange
.aEnd
.Row();
109 SCTAB nTab
= rRange
.aStart
.Tab();
111 ScDocument
* pDoc
= rDocShell
.GetDocument();
112 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
, TRUE
);
113 ScOutlineTable
* pUndoTab
= NULL
;
115 if (bRecord
&& !pDoc
->IsUndoEnabled())
119 pUndoTab
= new ScOutlineTable( *pTable
);
121 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
126 bRes
= pArray
->Insert( nStartCol
, nEndCol
, bSize
);
128 bRes
= pArray
->Insert( nStartRow
, nEndRow
, bSize
);
134 rDocShell
.GetUndoManager()->AddUndoAction(
135 new ScUndoMakeOutline( &rDocShell
,
136 nStartCol
,nStartRow
,nTab
,nEndCol
,nEndRow
,nTab
,
137 pUndoTab
, bColumns
, TRUE
) );
140 USHORT nParts
= 0; // Datenbereich nicht geaendert
144 nParts
|= PAINT_LEFT
;
146 nParts
|= PAINT_SIZE
;
148 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
149 rDocShell
.SetDocumentModified();
150 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
156 rDocShell
.ErrorMessage(STR_MSSG_MAKEOUTLINE_0
); // "Gruppierung nicht moeglich"
163 BOOL
ScOutlineDocFunc::RemoveOutline( const ScRange
& rRange
, BOOL bColumns
, BOOL bRecord
, BOOL bApi
)
167 SCCOL nStartCol
= rRange
.aStart
.Col();
168 SCROW nStartRow
= rRange
.aStart
.Row();
169 SCCOL nEndCol
= rRange
.aEnd
.Col();
170 SCROW nEndRow
= rRange
.aEnd
.Row();
171 SCTAB nTab
= rRange
.aStart
.Tab();
173 ScDocument
* pDoc
= rDocShell
.GetDocument();
175 if (bRecord
&& !pDoc
->IsUndoEnabled())
177 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
180 ScOutlineTable
* pUndoTab
= NULL
;
182 pUndoTab
= new ScOutlineTable( *pTable
);
184 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
189 bRes
= pArray
->Remove( nStartCol
, nEndCol
, bSize
);
191 bRes
= pArray
->Remove( nStartRow
, nEndRow
, bSize
);
197 rDocShell
.GetUndoManager()->AddUndoAction(
198 new ScUndoMakeOutline( &rDocShell
,
199 nStartCol
,nStartRow
,nTab
, nEndCol
,nEndRow
,nTab
,
200 pUndoTab
, bColumns
, FALSE
) );
203 USHORT nParts
= 0; // Datenbereich nicht geaendert
207 nParts
|= PAINT_LEFT
;
209 nParts
|= PAINT_SIZE
;
211 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, nParts
);
212 rDocShell
.SetDocumentModified();
214 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
216 // es wird nicht wieder eingeblendet -> kein UpdatePageBreaks
223 rDocShell
.ErrorMessage(STR_MSSG_REMOVEOUTLINE_0
); // "Aufheben nicht moeglich"
228 BOOL
ScOutlineDocFunc::RemoveAllOutlines( SCTAB nTab
, BOOL bRecord
, BOOL bApi
)
230 BOOL bSuccess
= FALSE
;
231 ScDocument
* pDoc
= rDocShell
.GetDocument();
233 if (bRecord
&& !pDoc
->IsUndoEnabled())
235 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
240 SCCOLROW nCol1
, nCol2
, nRow1
, nRow2
;
241 pTable
->GetColArray()->GetRange( nCol1
, nCol2
);
242 pTable
->GetRowArray()->GetRange( nRow1
, nRow2
);
243 SCCOL nStartCol
= static_cast<SCCOL
>(nCol1
);
244 SCROW nStartRow
= nRow1
;
245 SCCOL nEndCol
= static_cast<SCCOL
>(nCol2
);
246 SCROW nEndRow
= nRow2
;
248 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
249 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, TRUE
, TRUE
);
250 pDoc
->CopyToDocument( nStartCol
, 0, nTab
, nEndCol
, MAXROW
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
251 pDoc
->CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
253 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
255 rDocShell
.GetUndoManager()->AddUndoAction(
256 new ScUndoRemoveAllOutlines( &rDocShell
,
257 nStartCol
, nStartRow
, nTab
,
258 nEndCol
, nEndRow
, nTab
,
259 pUndoDoc
, pUndoTab
) );
262 SelectLevel( nTab
, TRUE
, pTable
->GetColArray()->GetDepth(), FALSE
, FALSE
, bApi
);
263 SelectLevel( nTab
, FALSE
, pTable
->GetRowArray()->GetDepth(), FALSE
, FALSE
, bApi
);
264 pDoc
->SetOutlineTable( nTab
, NULL
);
266 pDoc
->UpdatePageBreaks( nTab
);
268 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
,
269 PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
| PAINT_SIZE
);
270 rDocShell
.SetDocumentModified();
271 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
280 //------------------------------------------------------------------------
282 BOOL
ScOutlineDocFunc::AutoOutline( const ScRange
& rRange
, BOOL bRecord
, BOOL bApi
)
284 SCCOL nStartCol
= rRange
.aStart
.Col();
285 SCROW nStartRow
= rRange
.aStart
.Row();
286 SCCOL nEndCol
= rRange
.aEnd
.Col();
287 SCROW nEndRow
= rRange
.aEnd
.Row();
288 SCTAB nTab
= rRange
.aStart
.Tab();
290 ScDocument
* pDoc
= rDocShell
.GetDocument();
292 if (bRecord
&& !pDoc
->IsUndoEnabled())
294 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
296 ScDocument
* pUndoDoc
= NULL
;
297 ScOutlineTable
* pUndoTab
= NULL
;
303 pUndoTab
= new ScOutlineTable( *pTable
);
305 SCCOLROW nCol1
, nCol2
, nRow1
, nRow2
;
306 pTable
->GetColArray()->GetRange( nCol1
, nCol2
);
307 pTable
->GetRowArray()->GetRange( nRow1
, nRow2
);
308 SCCOL nOutStartCol
= static_cast<SCCOL
>(nCol1
);;
309 SCROW nOutStartRow
= nRow1
;
310 SCCOL nOutEndCol
= static_cast<SCCOL
>(nCol2
);;
311 SCROW nOutEndRow
= nRow2
;
313 pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
314 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, TRUE
, TRUE
);
315 pDoc
->CopyToDocument( nOutStartCol
, 0, nTab
, nOutEndCol
, MAXROW
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
316 pDoc
->CopyToDocument( 0, nOutStartRow
, nTab
, MAXCOL
, nOutEndRow
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
320 SelectLevel( nTab
, TRUE
, pTable
->GetColArray()->GetDepth(), FALSE
, FALSE
, bApi
);
321 SelectLevel( nTab
, FALSE
, pTable
->GetRowArray()->GetDepth(), FALSE
, FALSE
, bApi
);
322 pDoc
->SetOutlineTable( nTab
, NULL
);
325 pDoc
->DoAutoOutline( nStartCol
,nStartRow
, nEndCol
,nEndRow
, nTab
);
329 rDocShell
.GetUndoManager()->AddUndoAction(
330 new ScUndoAutoOutline( &rDocShell
,
331 nStartCol
, nStartRow
, nTab
,
332 nEndCol
, nEndRow
, nTab
,
333 pUndoDoc
, pUndoTab
) );
336 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_LEFT
| PAINT_TOP
| PAINT_SIZE
);
337 rDocShell
.SetDocumentModified();
338 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
343 //------------------------------------------------------------------------
345 BOOL
ScOutlineDocFunc::SelectLevel( SCTAB nTab
, BOOL bColumns
, USHORT nLevel
,
346 BOOL bRecord
, BOOL bPaint
, BOOL
/* bApi */ )
348 ScDocument
* pDoc
= rDocShell
.GetDocument();
350 if (bRecord
&& !pDoc
->IsUndoEnabled())
352 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
); // ist schon da
355 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
359 SCCOLROW nStart
, nEnd
;
360 pArray
->GetRange( nStart
, nEnd
);
364 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
365 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
368 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, TRUE
, FALSE
);
369 pDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
370 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, FALSE
,
375 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, FALSE
, TRUE
);
376 pDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
379 rDocShell
.GetUndoManager()->AddUndoAction(
380 new ScUndoOutlineLevel( &rDocShell
,
381 nStart
, nEnd
, nTab
, //! start und end berechnen
383 bColumns
, nLevel
) );
386 ScSubOutlineIterator
aIter( pArray
); // alle Eintraege
387 ScOutlineEntry
* pEntry
;
388 while ((pEntry
=aIter
.GetNext()) != NULL
)
390 USHORT nThisLevel
= aIter
.LastLevel();
391 BOOL bShow
= (nThisLevel
< nLevel
);
392 if (bShow
) // einblenden
394 pEntry
->SetHidden( FALSE
);
395 pEntry
->SetVisible( TRUE
);
397 else if ( nThisLevel
== nLevel
) // ausblenden
399 pEntry
->SetHidden( TRUE
);
400 pEntry
->SetVisible( TRUE
);
404 pEntry
->SetVisible( FALSE
);
407 SCCOLROW nThisStart
= pEntry
->GetStart();
408 SCCOLROW nThisEnd
= pEntry
->GetEnd();
409 for (SCCOLROW i
=nThisStart
; i
<=nThisEnd
; i
++)
412 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, bShow
);
414 if ( !bShow
|| !pDoc
->RowFiltered( i
,nTab
) )
415 pDoc
->ShowRow( i
, nTab
, bShow
);
419 pDoc
->UpdatePageBreaks( nTab
);
422 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
424 rDocShell
.SetDocumentModified();
425 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
430 //------------------------------------------------------------------------
432 BOOL
ScOutlineDocFunc::ShowMarkedOutlines( const ScRange
& rRange
, BOOL bRecord
, BOOL bApi
)
436 SCCOL nStartCol
= rRange
.aStart
.Col();
437 SCROW nStartRow
= rRange
.aStart
.Row();
438 SCCOL nEndCol
= rRange
.aEnd
.Col();
439 SCROW nEndRow
= rRange
.aEnd
.Row();
440 SCTAB nTab
= rRange
.aStart
.Tab();
442 ScDocument
* pDoc
= rDocShell
.GetDocument();
444 if (bRecord
&& !pDoc
->IsUndoEnabled())
446 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
450 ScOutlineArray
* pArray
;
451 ScOutlineEntry
* pEntry
;
460 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
461 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
462 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, TRUE
, TRUE
);
463 pDoc
->CopyToDocument( nStartCol
, 0, nTab
, nEndCol
, MAXROW
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
464 pDoc
->CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
466 rDocShell
.GetUndoManager()->AddUndoAction(
467 new ScUndoOutlineBlock( &rDocShell
,
468 nStartCol
, nStartRow
, nTab
, nEndCol
, nEndRow
, nTab
,
469 pUndoDoc
, pUndoTab
, TRUE
) );
476 pArray
= pTable
->GetColArray();
477 ScSubOutlineIterator
aColIter( pArray
);
478 while ((pEntry
=aColIter
.GetNext()) != NULL
)
480 nStart
= pEntry
->GetStart();
481 nEnd
= pEntry
->GetEnd();
482 if ( nStart
>=nStartCol
&& nEnd
<=nEndCol
)
484 pEntry
->SetHidden( FALSE
);
485 pEntry
->SetVisible( TRUE
);
486 if (nStart
<nMin
) nMin
=nStart
;
487 if (nEnd
>nMax
) nMax
=nEnd
;
490 for ( i
=nMin
; i
<=nMax
; i
++ )
491 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, TRUE
);
497 pArray
= pTable
->GetRowArray();
498 ScSubOutlineIterator
aRowIter( pArray
);
499 while ((pEntry
=aRowIter
.GetNext()) != NULL
)
501 nStart
= pEntry
->GetStart();
502 nEnd
= pEntry
->GetEnd();
503 if ( nStart
>=nStartRow
&& nEnd
<=nEndRow
)
505 pEntry
->SetHidden( FALSE
);
506 pEntry
->SetVisible( TRUE
);
507 if (nStart
<nMin
) nMin
=nStart
;
508 if (nEnd
>nMax
) nMax
=nEnd
;
511 for ( i
=nMin
; i
<=nMax
; i
++ )
512 if ( !pDoc
->RowFiltered( i
,nTab
) ) // weggefilterte nicht einblenden
513 pDoc
->ShowRow( i
, nTab
, TRUE
);
515 pDoc
->UpdatePageBreaks( nTab
);
517 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
);
519 rDocShell
.SetDocumentModified();
522 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
531 BOOL
ScOutlineDocFunc::HideMarkedOutlines( const ScRange
& rRange
, BOOL bRecord
, BOOL bApi
)
535 SCCOL nStartCol
= rRange
.aStart
.Col();
536 SCROW nStartRow
= rRange
.aStart
.Row();
537 SCCOL nEndCol
= rRange
.aEnd
.Col();
538 SCROW nEndRow
= rRange
.aEnd
.Row();
539 SCTAB nTab
= rRange
.aStart
.Tab();
541 ScDocument
* pDoc
= rDocShell
.GetDocument();
543 if (bRecord
&& !pDoc
->IsUndoEnabled())
545 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
549 ScOutlineEntry
* pEntry
;
557 SCCOLROW nEffStartCol
= nStartCol
;
558 SCCOLROW nEffEndCol
= nEndCol
;
559 ScOutlineArray
* pColArray
= pTable
->GetColArray();
560 pColArray
->FindTouchedLevel( nStartCol
, nEndCol
, nColLevel
);
561 pColArray
->ExtendBlock( nColLevel
, nEffStartCol
, nEffEndCol
);
562 SCCOLROW nEffStartRow
= nStartRow
;
563 SCCOLROW nEffEndRow
= nEndRow
;
564 ScOutlineArray
* pRowArray
= pTable
->GetRowArray();
565 pRowArray
->FindTouchedLevel( nStartRow
, nEndRow
, nRowLevel
);
566 pRowArray
->ExtendBlock( nRowLevel
, nEffStartRow
, nEffEndRow
);
570 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
571 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
572 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, TRUE
, TRUE
);
573 pDoc
->CopyToDocument( static_cast<SCCOL
>(nEffStartCol
), 0, nTab
,
574 static_cast<SCCOL
>(nEffEndCol
), MAXROW
, nTab
, IDF_NONE
,
576 pDoc
->CopyToDocument( 0, nEffStartRow
, nTab
, MAXCOL
, nEffEndRow
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
578 rDocShell
.GetUndoManager()->AddUndoAction(
579 new ScUndoOutlineBlock( &rDocShell
,
580 nStartCol
, nStartRow
, nTab
, nEndCol
, nEndRow
, nTab
,
581 pUndoDoc
, pUndoTab
, FALSE
) );
586 nCount
= pColArray
->GetCount(nColLevel
);
587 for ( i
=0; i
<nCount
; i
++ )
589 pEntry
= pColArray
->GetEntry(nColLevel
,i
);
590 nStart
= pEntry
->GetStart();
591 nEnd
= pEntry
->GetEnd();
593 if ( static_cast<SCCOLROW
>(nStartCol
)<=nEnd
&& static_cast<SCCOLROW
>(nEndCol
)>=nStart
)
594 HideOutline( nTab
, TRUE
, nColLevel
, i
, FALSE
, FALSE
, bApi
);
599 nCount
= pRowArray
->GetCount(nRowLevel
);
600 for ( i
=0; i
<nCount
; i
++ )
602 pEntry
= pRowArray
->GetEntry(nRowLevel
,i
);
603 nStart
= pEntry
->GetStart();
604 nEnd
= pEntry
->GetEnd();
606 if ( nStartRow
<=nEnd
&& nEndRow
>=nStart
)
607 HideOutline( nTab
, FALSE
, nRowLevel
, i
, FALSE
, FALSE
, bApi
);
610 pDoc
->UpdatePageBreaks( nTab
);
612 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
);
614 rDocShell
.SetDocumentModified();
617 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
626 //------------------------------------------------------------------------
628 BOOL
ScOutlineDocFunc::ShowOutline( SCTAB nTab
, BOOL bColumns
, USHORT nLevel
, USHORT nEntry
,
629 BOOL bRecord
, BOOL bPaint
, BOOL
/* bApi */ )
631 ScDocument
* pDoc
= rDocShell
.GetDocument();
632 if (bRecord
&& !pDoc
->IsUndoEnabled())
635 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
636 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
637 ScOutlineEntry
* pEntry
= pArray
->GetEntry( nLevel
, nEntry
);
638 SCCOLROW nStart
= pEntry
->GetStart();
639 SCCOLROW nEnd
= pEntry
->GetEnd();
643 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
646 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, TRUE
, FALSE
);
647 pDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
648 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, FALSE
,
653 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, FALSE
, TRUE
);
654 pDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
657 rDocShell
.GetUndoManager()->AddUndoAction(
658 new ScUndoDoOutline( &rDocShell
,
659 nStart
, nEnd
, nTab
, pUndoDoc
, //! start und end berechnen
660 bColumns
, nLevel
, nEntry
, TRUE
) );
665 pEntry
->SetHidden(FALSE
);
667 for ( i
= nStart
; i
<= nEnd
; i
++ )
670 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, TRUE
);
672 if ( !pDoc
->RowFiltered( i
,nTab
) ) // weggefilterte nicht einblenden
673 pDoc
->ShowRow( i
, nTab
, TRUE
);
676 ScSubOutlineIterator
aIter( pArray
, nLevel
, nEntry
);
677 while ((pEntry
=aIter
.GetNext()) != NULL
)
679 if ( pEntry
->IsHidden() )
681 SCCOLROW nSubStart
= pEntry
->GetStart();
682 SCCOLROW nSubEnd
= pEntry
->GetEnd();
683 for ( i
= nSubStart
; i
<= nSubEnd
; i
++ )
686 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, FALSE
);
688 pDoc
->ShowRow( i
, nTab
, FALSE
);
693 pArray
->SetVisibleBelow( nLevel
, nEntry
, TRUE
, TRUE
);
695 pDoc
->InvalidatePageBreaks(nTab
);
696 pDoc
->UpdatePageBreaks( nTab
);
699 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
702 rDocShell
.SetDocumentModified();
705 //! UpdateScrollBars();
707 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
709 return TRUE
; //! immer ???
712 BOOL
ScOutlineDocFunc::HideOutline( SCTAB nTab
, BOOL bColumns
, USHORT nLevel
, USHORT nEntry
,
713 BOOL bRecord
, BOOL bPaint
, BOOL
/* bApi */ )
715 ScDocument
* pDoc
= rDocShell
.GetDocument();
716 if (bRecord
&& !pDoc
->IsUndoEnabled())
719 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
720 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
721 ScOutlineEntry
* pEntry
= pArray
->GetEntry( nLevel
, nEntry
);
722 SCCOLROW nStart
= pEntry
->GetStart();
723 SCCOLROW nEnd
= pEntry
->GetEnd();
727 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
730 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, TRUE
, FALSE
);
731 pDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
732 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, FALSE
,
737 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, FALSE
, TRUE
);
738 pDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, FALSE
, pUndoDoc
);
741 rDocShell
.GetUndoManager()->AddUndoAction(
742 new ScUndoDoOutline( &rDocShell
,
743 nStart
, nEnd
, nTab
, pUndoDoc
,
744 bColumns
, nLevel
, nEntry
, FALSE
) );
749 pEntry
->SetHidden(TRUE
);
751 for ( i
= nStart
; i
<= nEnd
; i
++ )
754 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, FALSE
);
756 pDoc
->ShowRow( i
, nTab
, FALSE
);
759 pArray
->SetVisibleBelow( nLevel
, nEntry
, FALSE
);
761 pDoc
->InvalidatePageBreaks(nTab
);
762 pDoc
->UpdatePageBreaks( nTab
);
765 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
768 rDocShell
.SetDocumentModified();
771 //! UpdateScrollBars();
773 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
775 return TRUE
; //! immer ???