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 pDoc
->InitializeNoteCaptions(nTab
);
378 ScSubOutlineIterator
aIter( pArray
); // alle Eintraege
379 ScOutlineEntry
* pEntry
;
380 while ((pEntry
=aIter
.GetNext()) != NULL
)
382 sal_uInt16 nThisLevel
= aIter
.LastLevel();
383 sal_Bool bShow
= (nThisLevel
< nLevel
);
384 if (bShow
) // einblenden
386 pEntry
->SetHidden( false );
387 pEntry
->SetVisible( sal_True
);
389 else if ( nThisLevel
== nLevel
) // ausblenden
391 pEntry
->SetHidden( sal_True
);
392 pEntry
->SetVisible( sal_True
);
396 pEntry
->SetVisible( false );
399 SCCOLROW nThisStart
= pEntry
->GetStart();
400 SCCOLROW nThisEnd
= pEntry
->GetEnd();
401 for (SCCOLROW i
=nThisStart
; i
<=nThisEnd
; i
++)
404 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, bShow
);
407 // show several rows together, don't show filtered rows
408 SCROW nFilterEnd
= i
;
409 bool bFiltered
= pDoc
->RowFiltered( i
, nTab
, NULL
, &nFilterEnd
);
410 nFilterEnd
= std::min( nThisEnd
, nFilterEnd
);
411 if ( !bShow
|| !bFiltered
)
412 pDoc
->ShowRows( i
, nFilterEnd
, nTab
, bShow
);
418 pDoc
->SetDrawPageSize(nTab
);
419 pDoc
->UpdatePageBreaks( nTab
);
422 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
424 rDocShell
.SetDocumentModified();
425 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
430 //------------------------------------------------------------------------
432 sal_Bool
ScOutlineDocFunc::ShowMarkedOutlines( const ScRange
& rRange
, sal_Bool bRecord
)
434 sal_Bool bDone
= false;
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
, sal_True
, sal_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
, sal_True
) );
472 pDoc
->InitializeNoteCaptions(nTab
);
478 pArray
= pTable
->GetColArray();
479 ScSubOutlineIterator
aColIter( pArray
);
480 while ((pEntry
=aColIter
.GetNext()) != NULL
)
482 nStart
= pEntry
->GetStart();
483 nEnd
= pEntry
->GetEnd();
484 if ( nStart
>=nStartCol
&& nEnd
<=nEndCol
)
486 pEntry
->SetHidden( false );
487 pEntry
->SetVisible( sal_True
);
488 if (nStart
<nMin
) nMin
=nStart
;
489 if (nEnd
>nMax
) nMax
=nEnd
;
492 for ( i
=nMin
; i
<=nMax
; i
++ )
493 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, sal_True
);
499 pArray
= pTable
->GetRowArray();
500 ScSubOutlineIterator
aRowIter( pArray
);
501 pDoc
->InitializeNoteCaptions(nTab
);
502 while ((pEntry
=aRowIter
.GetNext()) != NULL
)
504 nStart
= pEntry
->GetStart();
505 nEnd
= pEntry
->GetEnd();
506 if ( nStart
>=nStartRow
&& nEnd
<=nEndRow
)
508 pEntry
->SetHidden( false );
509 pEntry
->SetVisible( sal_True
);
510 if (nStart
<nMin
) nMin
=nStart
;
511 if (nEnd
>nMax
) nMax
=nEnd
;
514 for ( i
=nMin
; i
<=nMax
; i
++ )
516 // show several rows together, don't show filtered rows
517 SCROW nFilterEnd
= i
;
518 bool bFiltered
= pDoc
->RowFiltered( i
, nTab
, NULL
, &nFilterEnd
);
519 nFilterEnd
= std::min( nMax
, nFilterEnd
);
521 pDoc
->ShowRows( i
, nFilterEnd
, nTab
, sal_True
);
525 pDoc
->SetDrawPageSize(nTab
);
526 pDoc
->UpdatePageBreaks( nTab
);
528 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
);
529 rDocShell
.SetDocumentModified();
532 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
538 sal_Bool
ScOutlineDocFunc::HideMarkedOutlines( const ScRange
& rRange
, sal_Bool bRecord
, sal_Bool bApi
)
540 sal_Bool bDone
= false;
542 SCCOL nStartCol
= rRange
.aStart
.Col();
543 SCROW nStartRow
= rRange
.aStart
.Row();
544 SCCOL nEndCol
= rRange
.aEnd
.Col();
545 SCROW nEndRow
= rRange
.aEnd
.Row();
546 SCTAB nTab
= rRange
.aStart
.Tab();
548 ScDocument
* pDoc
= rDocShell
.GetDocument();
550 if (bRecord
&& !pDoc
->IsUndoEnabled())
552 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
556 const ScOutlineEntry
* pEntry
;
564 SCCOLROW nEffStartCol
= nStartCol
;
565 SCCOLROW nEffEndCol
= nEndCol
;
566 ScOutlineArray
* pColArray
= pTable
->GetColArray();
567 pColArray
->FindTouchedLevel( nStartCol
, nEndCol
, nColLevel
);
568 pColArray
->ExtendBlock( nColLevel
, nEffStartCol
, nEffEndCol
);
569 SCCOLROW nEffStartRow
= nStartRow
;
570 SCCOLROW nEffEndRow
= nEndRow
;
571 ScOutlineArray
* pRowArray
= pTable
->GetRowArray();
572 pRowArray
->FindTouchedLevel( nStartRow
, nEndRow
, nRowLevel
);
573 pRowArray
->ExtendBlock( nRowLevel
, nEffStartRow
, nEffEndRow
);
577 ScOutlineTable
* pUndoTab
= new ScOutlineTable( *pTable
);
578 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
579 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, sal_True
);
580 pDoc
->CopyToDocument( static_cast<SCCOL
>(nEffStartCol
), 0, nTab
,
581 static_cast<SCCOL
>(nEffEndCol
), MAXROW
, nTab
, IDF_NONE
,
583 pDoc
->CopyToDocument( 0, nEffStartRow
, nTab
, MAXCOL
, nEffEndRow
, nTab
, IDF_NONE
, false, pUndoDoc
);
585 rDocShell
.GetUndoManager()->AddUndoAction(
586 new ScUndoOutlineBlock( &rDocShell
,
587 nStartCol
, nStartRow
, nTab
, nEndCol
, nEndRow
, nTab
,
588 pUndoDoc
, pUndoTab
, false ) );
591 pDoc
->InitializeNoteCaptions(nTab
);
595 nCount
= pColArray
->GetCount(nColLevel
);
596 for ( i
=0; i
<nCount
; i
++ )
598 pEntry
= pColArray
->GetEntry(nColLevel
,i
);
599 nStart
= pEntry
->GetStart();
600 nEnd
= pEntry
->GetEnd();
602 if ( static_cast<SCCOLROW
>(nStartCol
)<=nEnd
&& static_cast<SCCOLROW
>(nEndCol
)>=nStart
)
603 HideOutline( nTab
, sal_True
, nColLevel
, i
, false, false, bApi
);
608 nCount
= pRowArray
->GetCount(nRowLevel
);
609 for ( i
=0; i
<nCount
; i
++ )
611 pEntry
= pRowArray
->GetEntry(nRowLevel
,i
);
612 nStart
= pEntry
->GetStart();
613 nEnd
= pEntry
->GetEnd();
615 if ( nStartRow
<=nEnd
&& nEndRow
>=nStart
)
616 HideOutline( nTab
, false, nRowLevel
, i
, false, false, bApi
);
619 pDoc
->SetDrawPageSize(nTab
);
620 pDoc
->UpdatePageBreaks( nTab
);
622 rDocShell
.PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
| PAINT_LEFT
| PAINT_TOP
);
624 rDocShell
.SetDocumentModified();
627 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
633 //------------------------------------------------------------------------
635 sal_Bool
ScOutlineDocFunc::ShowOutline( SCTAB nTab
, sal_Bool bColumns
, sal_uInt16 nLevel
, sal_uInt16 nEntry
,
636 sal_Bool bRecord
, sal_Bool bPaint
, sal_Bool
/* bApi */ )
638 ScDocument
* pDoc
= rDocShell
.GetDocument();
639 if (bRecord
&& !pDoc
->IsUndoEnabled())
642 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
643 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
644 ScOutlineEntry
* pEntry
= pArray
->GetEntry( nLevel
, nEntry
);
645 SCCOLROW nStart
= pEntry
->GetStart();
646 SCCOLROW nEnd
= pEntry
->GetEnd();
650 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
653 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, false );
654 pDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
655 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, false,
660 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, false, sal_True
);
661 pDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, false, pUndoDoc
);
664 rDocShell
.GetUndoManager()->AddUndoAction(
665 new ScUndoDoOutline( &rDocShell
,
666 nStart
, nEnd
, nTab
, pUndoDoc
, //! start und end berechnen
667 bColumns
, nLevel
, nEntry
, sal_True
) );
670 pDoc
->InitializeNoteCaptions(nTab
);
671 pEntry
->SetHidden(false);
673 for ( i
= nStart
; i
<= nEnd
; i
++ )
676 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, sal_True
);
679 // show several rows together, don't show filtered rows
680 SCROW nFilterEnd
= i
;
681 bool bFiltered
= pDoc
->RowFiltered( i
, nTab
, NULL
, &nFilterEnd
);
682 nFilterEnd
= std::min( nEnd
, nFilterEnd
);
684 pDoc
->ShowRows( i
, nFilterEnd
, nTab
, sal_True
);
689 ScSubOutlineIterator
aIter( pArray
, nLevel
, nEntry
);
690 while ((pEntry
=aIter
.GetNext()) != NULL
)
692 if ( pEntry
->IsHidden() )
694 SCCOLROW nSubStart
= pEntry
->GetStart();
695 SCCOLROW nSubEnd
= pEntry
->GetEnd();
697 for ( i
= nSubStart
; i
<= nSubEnd
; i
++ )
698 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, false );
700 pDoc
->ShowRows( nSubStart
, nSubEnd
, nTab
, sal_False
);
704 pArray
->SetVisibleBelow( nLevel
, nEntry
, sal_True
, sal_True
);
706 pDoc
->SetDrawPageSize(nTab
);
707 pDoc
->InvalidatePageBreaks(nTab
);
708 pDoc
->UpdatePageBreaks( nTab
);
711 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
713 rDocShell
.SetDocumentModified();
715 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
717 return sal_True
; //! immer ???
720 sal_Bool
ScOutlineDocFunc::HideOutline( SCTAB nTab
, sal_Bool bColumns
, sal_uInt16 nLevel
, sal_uInt16 nEntry
,
721 sal_Bool bRecord
, sal_Bool bPaint
, sal_Bool
/* bApi */ )
723 ScDocument
* pDoc
= rDocShell
.GetDocument();
724 if (bRecord
&& !pDoc
->IsUndoEnabled())
727 ScOutlineTable
* pTable
= pDoc
->GetOutlineTable( nTab
);
728 ScOutlineArray
* pArray
= bColumns
? pTable
->GetColArray() : pTable
->GetRowArray();
729 ScOutlineEntry
* pEntry
= pArray
->GetEntry( nLevel
, nEntry
);
730 SCCOLROW nStart
= pEntry
->GetStart();
731 SCCOLROW nEnd
= pEntry
->GetEnd();
735 ScDocument
* pUndoDoc
= new ScDocument( SCDOCMODE_UNDO
);
738 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, sal_True
, false );
739 pDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
740 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, false,
745 pUndoDoc
->InitUndo( pDoc
, nTab
, nTab
, false, sal_True
);
746 pDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, false, pUndoDoc
);
749 rDocShell
.GetUndoManager()->AddUndoAction(
750 new ScUndoDoOutline( &rDocShell
,
751 nStart
, nEnd
, nTab
, pUndoDoc
,
752 bColumns
, nLevel
, nEntry
, false ) );
755 pDoc
->InitializeNoteCaptions(nTab
);
756 pEntry
->SetHidden(true);
759 for ( i
= nStart
; i
<= nEnd
; i
++ )
760 pDoc
->ShowCol( static_cast<SCCOL
>(i
), nTab
, sal_False
);
762 pDoc
->ShowRows( nStart
, nEnd
, nTab
, sal_False
);
764 pArray
->SetVisibleBelow( nLevel
, nEntry
, false );
766 pDoc
->SetDrawPageSize(nTab
);
767 pDoc
->InvalidatePageBreaks(nTab
);
768 pDoc
->UpdatePageBreaks( nTab
);
771 lcl_PaintWidthHeight( rDocShell
, nTab
, bColumns
, nStart
, nEnd
);
773 rDocShell
.SetDocumentModified();
775 lcl_InvalidateOutliner( rDocShell
.GetViewBindings() );
777 return sal_True
; //! immer ???
784 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */