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: undodat.cxx,v $
10 * $Revision: 1.12.128.2 $
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"
34 // INCLUDE ---------------------------------------------------------------
36 #include <sfx2/app.hxx>
38 #include "undodat.hxx"
39 #include "undoutil.hxx"
40 #include "undoolk.hxx"
41 #include "document.hxx"
43 #include "tabvwsh.hxx"
44 #include "olinetab.hxx"
45 #include "dbcolect.hxx"
46 #include "rangenam.hxx"
48 #include "globstr.hrc"
51 #include "chartarr.hxx"
52 #include "dbdocfun.hxx"
53 #include "olinefun.hxx"
54 #include "dpobject.hxx"
57 #include "chgtrack.hxx" // Amelia Wang
58 #include "refundo.hxx" // Amelia Wang
60 // -----------------------------------------------------------------------
62 TYPEINIT1(ScUndoDoOutline
, ScSimpleUndo
);
63 TYPEINIT1(ScUndoMakeOutline
, ScSimpleUndo
);
64 TYPEINIT1(ScUndoOutlineLevel
, ScSimpleUndo
);
65 TYPEINIT1(ScUndoOutlineBlock
, ScSimpleUndo
);
66 TYPEINIT1(ScUndoRemoveAllOutlines
, ScSimpleUndo
);
67 TYPEINIT1(ScUndoAutoOutline
, ScSimpleUndo
);
68 TYPEINIT1(ScUndoSubTotals
, ScDBFuncUndo
);
69 TYPEINIT1(ScUndoSort
, ScDBFuncUndo
);
70 TYPEINIT1(ScUndoQuery
, ScDBFuncUndo
);
71 TYPEINIT1(ScUndoAutoFilter
, ScDBFuncUndo
);
72 TYPEINIT1(ScUndoDBData
, ScSimpleUndo
);
73 TYPEINIT1(ScUndoImportData
, ScSimpleUndo
);
74 TYPEINIT1(ScUndoRepeatDB
, ScSimpleUndo
);
75 //UNUSED2008-05 TYPEINIT1(ScUndoPivot, ScSimpleUndo);
76 TYPEINIT1(ScUndoDataPilot
, ScSimpleUndo
);
77 TYPEINIT1(ScUndoConsolidate
, ScSimpleUndo
);
78 TYPEINIT1(ScUndoChartData
, ScSimpleUndo
);
79 TYPEINIT1(ScUndoDataForm
, SfxUndoAction
); // amelia
81 // -----------------------------------------------------------------------
85 // Outline-Gruppen ein- oder ausblenden
88 ScUndoDoOutline::ScUndoDoOutline( ScDocShell
* pNewDocShell
,
89 SCCOLROW nNewStart
, SCCOLROW nNewEnd
, SCTAB nNewTab
,
90 ScDocument
* pNewUndoDoc
, BOOL bNewColumns
,
91 USHORT nNewLevel
, USHORT nNewEntry
, BOOL bNewShow
) :
92 ScSimpleUndo( pNewDocShell
),
96 pUndoDoc( pNewUndoDoc
),
97 bColumns( bNewColumns
),
104 __EXPORT
ScUndoDoOutline::~ScUndoDoOutline()
109 String __EXPORT
ScUndoDoOutline::GetComment() const
110 { // Detail einblenden" "Detail ausblenden"
112 ScGlobal::GetRscString( STR_UNDO_DOOUTLINE
) :
113 ScGlobal::GetRscString( STR_UNDO_REDOOUTLINE
);
116 void __EXPORT
ScUndoDoOutline::Undo()
120 ScDocument
* pDoc
= pDocShell
->GetDocument();
121 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
123 // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
125 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
126 if ( nVisTab
!= nTab
)
127 pViewShell
->SetTabNo( nTab
);
129 // inverse Funktion ausfuehren
132 pViewShell
->HideOutline( bColumns
, nLevel
, nEntry
, FALSE
, FALSE
);
134 pViewShell
->ShowOutline( bColumns
, nLevel
, nEntry
, FALSE
, FALSE
);
136 // Original Spalten-/Zeilenstatus
139 pUndoDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
140 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, FALSE
, pDoc
);
142 pUndoDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, FALSE
, pDoc
);
144 pViewShell
->UpdateScrollBars();
146 pDocShell
->PostPaint(0,0,nTab
,MAXCOL
,MAXROW
,nTab
,PAINT_GRID
|PAINT_LEFT
|PAINT_TOP
);
151 void __EXPORT
ScUndoDoOutline::Redo()
155 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
157 // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
159 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
160 if ( nVisTab
!= nTab
)
161 pViewShell
->SetTabNo( nTab
);
164 pViewShell
->ShowOutline( bColumns
, nLevel
, nEntry
, FALSE
);
166 pViewShell
->HideOutline( bColumns
, nLevel
, nEntry
, FALSE
);
171 void __EXPORT
ScUndoDoOutline::Repeat(SfxRepeatTarget
& /* rTarget */)
175 BOOL __EXPORT
ScUndoDoOutline::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
177 return FALSE
; // geht nicht
181 // Outline-Gruppen erzeugen oder loeschen
184 ScUndoMakeOutline::ScUndoMakeOutline( ScDocShell
* pNewDocShell
,
185 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
186 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
187 ScOutlineTable
* pNewUndoTab
, BOOL bNewColumns
, BOOL bNewMake
) :
188 ScSimpleUndo( pNewDocShell
),
189 aBlockStart( nStartX
, nStartY
, nStartZ
),
190 aBlockEnd( nEndX
, nEndY
, nEndZ
),
191 pUndoTable( pNewUndoTab
),
192 bColumns( bNewColumns
),
197 __EXPORT
ScUndoMakeOutline::~ScUndoMakeOutline()
202 String __EXPORT
ScUndoMakeOutline::GetComment() const
203 { // "Gruppierung" "Gruppierung aufheben"
205 ScGlobal::GetRscString( STR_UNDO_MAKEOUTLINE
) :
206 ScGlobal::GetRscString( STR_UNDO_REMAKEOUTLINE
);
209 void __EXPORT
ScUndoMakeOutline::Undo()
213 ScDocument
* pDoc
= pDocShell
->GetDocument();
214 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
215 SCTAB nTab
= aBlockStart
.Tab();
217 ScUndoUtil::MarkSimpleBlock( pDocShell
, aBlockStart
, aBlockEnd
);
219 pDoc
->SetOutlineTable( nTab
, pUndoTable
);
221 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
222 if ( nVisTab
!= nTab
)
223 pViewShell
->SetTabNo( nTab
);
225 pDocShell
->PostPaint(0,0,nTab
,MAXCOL
,MAXROW
,nTab
,PAINT_GRID
|PAINT_LEFT
|PAINT_TOP
|PAINT_SIZE
);
230 void __EXPORT
ScUndoMakeOutline::Redo()
234 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
236 ScUndoUtil::MarkSimpleBlock( pDocShell
, aBlockStart
, aBlockEnd
);
239 pViewShell
->MakeOutline( bColumns
, FALSE
);
241 pViewShell
->RemoveOutline( bColumns
, FALSE
);
243 pDocShell
->PostPaint(0,0,aBlockStart
.Tab(),MAXCOL
,MAXROW
,aBlockEnd
.Tab(),PAINT_GRID
);
248 void __EXPORT
ScUndoMakeOutline::Repeat(SfxRepeatTarget
& rTarget
)
250 if (rTarget
.ISA(ScTabViewTarget
))
252 ScTabViewShell
& rViewShell
= *((ScTabViewTarget
&)rTarget
).GetViewShell();
255 rViewShell
.MakeOutline( bColumns
, TRUE
);
257 rViewShell
.RemoveOutline( bColumns
, TRUE
);
261 BOOL __EXPORT
ScUndoMakeOutline::CanRepeat(SfxRepeatTarget
& rTarget
) const
263 return (rTarget
.ISA(ScTabViewTarget
));
267 // Outline-Ebene auswaehlen
270 ScUndoOutlineLevel::ScUndoOutlineLevel( ScDocShell
* pNewDocShell
,
271 SCCOLROW nNewStart
, SCCOLROW nNewEnd
, SCTAB nNewTab
,
272 ScDocument
* pNewUndoDoc
, ScOutlineTable
* pNewUndoTab
,
273 BOOL bNewColumns
, USHORT nNewLevel
) :
274 ScSimpleUndo( pNewDocShell
),
278 pUndoDoc( pNewUndoDoc
),
279 pUndoTable( pNewUndoTab
),
280 bColumns( bNewColumns
),
285 __EXPORT
ScUndoOutlineLevel::~ScUndoOutlineLevel()
291 String __EXPORT
ScUndoOutlineLevel::GetComment() const
292 { // "Gliederungsebene auswaehlen";
293 return ScGlobal::GetRscString( STR_UNDO_OUTLINELEVEL
);
296 void __EXPORT
ScUndoOutlineLevel::Undo()
300 ScDocument
* pDoc
= pDocShell
->GetDocument();
301 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
303 // Original Outline-Table
305 pDoc
->SetOutlineTable( nTab
, pUndoTable
);
307 // Original Spalten-/Zeilenstatus
310 pUndoDoc
->CopyToDocument( static_cast<SCCOL
>(nStart
), 0, nTab
,
311 static_cast<SCCOL
>(nEnd
), MAXROW
, nTab
, IDF_NONE
, FALSE
, pDoc
);
313 pUndoDoc
->CopyToDocument( 0, nStart
, nTab
, MAXCOL
, nEnd
, nTab
, IDF_NONE
, FALSE
, pDoc
);
315 pDoc
->UpdatePageBreaks( nTab
);
317 pViewShell
->UpdateScrollBars();
319 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
320 if ( nVisTab
!= nTab
)
321 pViewShell
->SetTabNo( nTab
);
323 pDocShell
->PostPaint(0,0,nTab
,MAXCOL
,MAXROW
,nTab
,PAINT_GRID
|PAINT_LEFT
|PAINT_TOP
);
328 void __EXPORT
ScUndoOutlineLevel::Redo()
332 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
334 // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
336 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
337 if ( nVisTab
!= nTab
)
338 pViewShell
->SetTabNo( nTab
);
340 pViewShell
->SelectLevel( bColumns
, nLevel
, FALSE
);
345 void __EXPORT
ScUndoOutlineLevel::Repeat(SfxRepeatTarget
& rTarget
)
347 if (rTarget
.ISA(ScTabViewTarget
))
348 ((ScTabViewTarget
&)rTarget
).GetViewShell()->SelectLevel( bColumns
, nLevel
, TRUE
);
351 BOOL __EXPORT
ScUndoOutlineLevel::CanRepeat(SfxRepeatTarget
& rTarget
) const
353 return (rTarget
.ISA(ScTabViewTarget
));
357 // Outline ueber Blockmarken ein- oder ausblenden
360 ScUndoOutlineBlock::ScUndoOutlineBlock( ScDocShell
* pNewDocShell
,
361 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
362 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
363 ScDocument
* pNewUndoDoc
, ScOutlineTable
* pNewUndoTab
, BOOL bNewShow
) :
364 ScSimpleUndo( pNewDocShell
),
365 aBlockStart( nStartX
, nStartY
, nStartZ
),
366 aBlockEnd( nEndX
, nEndY
, nEndZ
),
367 pUndoDoc( pNewUndoDoc
),
368 pUndoTable( pNewUndoTab
),
373 __EXPORT
ScUndoOutlineBlock::~ScUndoOutlineBlock()
379 String __EXPORT
ScUndoOutlineBlock::GetComment() const
380 { // "Detail einblenden" "Detail ausblenden"
382 ScGlobal::GetRscString( STR_UNDO_DOOUTLINEBLK
) :
383 ScGlobal::GetRscString( STR_UNDO_REDOOUTLINEBLK
);
386 void __EXPORT
ScUndoOutlineBlock::Undo()
390 ScDocument
* pDoc
= pDocShell
->GetDocument();
391 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
392 SCTAB nTab
= aBlockStart
.Tab();
394 // Original Outline-Table
396 pDoc
->SetOutlineTable( nTab
, pUndoTable
);
398 // Original Spalten-/Zeilenstatus
400 SCCOLROW nStartCol
= aBlockStart
.Col();
401 SCCOLROW nEndCol
= aBlockEnd
.Col();
402 SCCOLROW nStartRow
= aBlockStart
.Row();
403 SCCOLROW nEndRow
= aBlockEnd
.Row();
406 { // Groesse des ausgeblendeten Blocks
408 pUndoTable
->GetColArray()->FindTouchedLevel( nStartCol
, nEndCol
, nLevel
);
409 pUndoTable
->GetColArray()->ExtendBlock( nLevel
, nStartCol
, nEndCol
);
410 pUndoTable
->GetRowArray()->FindTouchedLevel( nStartRow
, nEndRow
, nLevel
);
411 pUndoTable
->GetRowArray()->ExtendBlock( nLevel
, nStartRow
, nEndRow
);
414 pUndoDoc
->CopyToDocument( static_cast<SCCOL
>(nStartCol
), 0, nTab
,
415 static_cast<SCCOL
>(nEndCol
), MAXROW
, nTab
, IDF_NONE
, FALSE
, pDoc
);
416 pUndoDoc
->CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, IDF_NONE
, FALSE
, pDoc
);
418 pDoc
->UpdatePageBreaks( nTab
);
420 pViewShell
->UpdateScrollBars();
422 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
423 if ( nVisTab
!= nTab
)
424 pViewShell
->SetTabNo( nTab
);
426 pDocShell
->PostPaint(0,0,nTab
,MAXCOL
,MAXROW
,nTab
,PAINT_GRID
|PAINT_LEFT
|PAINT_TOP
);
431 void __EXPORT
ScUndoOutlineBlock::Redo()
435 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
437 ScUndoUtil::MarkSimpleBlock( pDocShell
, aBlockStart
, aBlockEnd
);
439 pViewShell
->ShowMarkedOutlines( FALSE
);
441 pViewShell
->HideMarkedOutlines( FALSE
);
446 void __EXPORT
ScUndoOutlineBlock::Repeat(SfxRepeatTarget
& rTarget
)
448 if (rTarget
.ISA(ScTabViewTarget
))
450 ScTabViewShell
& rViewShell
= *((ScTabViewTarget
&)rTarget
).GetViewShell();
453 rViewShell
.ShowMarkedOutlines( TRUE
);
455 rViewShell
.HideMarkedOutlines( TRUE
);
459 BOOL __EXPORT
ScUndoOutlineBlock::CanRepeat(SfxRepeatTarget
& rTarget
) const
461 return (rTarget
.ISA(ScTabViewTarget
));
465 // alle Outlines loeschen
468 ScUndoRemoveAllOutlines::ScUndoRemoveAllOutlines( ScDocShell
* pNewDocShell
,
469 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
470 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
471 ScDocument
* pNewUndoDoc
, ScOutlineTable
* pNewUndoTab
) :
472 ScSimpleUndo( pNewDocShell
),
473 aBlockStart( nStartX
, nStartY
, nStartZ
),
474 aBlockEnd( nEndX
, nEndY
, nEndZ
),
475 pUndoDoc( pNewUndoDoc
),
476 pUndoTable( pNewUndoTab
)
480 __EXPORT
ScUndoRemoveAllOutlines::~ScUndoRemoveAllOutlines()
486 String __EXPORT
ScUndoRemoveAllOutlines::GetComment() const
487 { // "Gliederung entfernen"
488 return ScGlobal::GetRscString( STR_UNDO_REMOVEALLOTLNS
);
491 void __EXPORT
ScUndoRemoveAllOutlines::Undo()
495 ScDocument
* pDoc
= pDocShell
->GetDocument();
496 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
497 SCTAB nTab
= aBlockStart
.Tab();
499 // Original Outline-Table
501 pDoc
->SetOutlineTable( nTab
, pUndoTable
);
503 // Original Spalten-/Zeilenstatus
505 SCCOL nStartCol
= aBlockStart
.Col();
506 SCCOL nEndCol
= aBlockEnd
.Col();
507 SCROW nStartRow
= aBlockStart
.Row();
508 SCROW nEndRow
= aBlockEnd
.Row();
510 pUndoDoc
->CopyToDocument( nStartCol
, 0, nTab
, nEndCol
, MAXROW
, nTab
, IDF_NONE
, FALSE
, pDoc
);
511 pUndoDoc
->CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, IDF_NONE
, FALSE
, pDoc
);
513 pDoc
->UpdatePageBreaks( nTab
);
515 pViewShell
->UpdateScrollBars();
517 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
518 if ( nVisTab
!= nTab
)
519 pViewShell
->SetTabNo( nTab
);
521 pDocShell
->PostPaint(0,0,nTab
,MAXCOL
,MAXROW
,nTab
,PAINT_GRID
|PAINT_LEFT
|PAINT_TOP
|PAINT_SIZE
);
526 void __EXPORT
ScUndoRemoveAllOutlines::Redo()
530 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
532 // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
534 SCTAB nTab
= aBlockStart
.Tab();
535 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
536 if ( nVisTab
!= nTab
)
537 pViewShell
->SetTabNo( nTab
);
539 pViewShell
->RemoveAllOutlines( FALSE
);
544 void __EXPORT
ScUndoRemoveAllOutlines::Repeat(SfxRepeatTarget
& rTarget
)
546 if (rTarget
.ISA(ScTabViewTarget
))
547 ((ScTabViewTarget
&)rTarget
).GetViewShell()->RemoveAllOutlines( TRUE
);
550 BOOL __EXPORT
ScUndoRemoveAllOutlines::CanRepeat(SfxRepeatTarget
& rTarget
) const
552 return (rTarget
.ISA(ScTabViewTarget
));
559 ScUndoAutoOutline::ScUndoAutoOutline( ScDocShell
* pNewDocShell
,
560 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
561 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
562 ScDocument
* pNewUndoDoc
, ScOutlineTable
* pNewUndoTab
) :
563 ScSimpleUndo( pNewDocShell
),
564 aBlockStart( nStartX
, nStartY
, nStartZ
),
565 aBlockEnd( nEndX
, nEndY
, nEndZ
),
566 pUndoDoc( pNewUndoDoc
),
567 pUndoTable( pNewUndoTab
)
571 __EXPORT
ScUndoAutoOutline::~ScUndoAutoOutline()
577 String __EXPORT
ScUndoAutoOutline::GetComment() const
578 { // "Auto-Gliederung"
579 return ScGlobal::GetRscString( STR_UNDO_AUTOOUTLINE
);
582 void __EXPORT
ScUndoAutoOutline::Undo()
586 ScDocument
* pDoc
= pDocShell
->GetDocument();
587 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
588 SCTAB nTab
= aBlockStart
.Tab();
590 // Original Outline-Table
592 pDoc
->SetOutlineTable( nTab
, pUndoTable
);
594 // Original Spalten-/Zeilenstatus
596 if (pUndoDoc
&& pUndoTable
)
602 pUndoTable
->GetColArray()->GetRange( nStartCol
, nEndCol
);
603 pUndoTable
->GetRowArray()->GetRange( nStartRow
, nEndRow
);
605 pUndoDoc
->CopyToDocument( static_cast<SCCOL
>(nStartCol
), 0, nTab
,
606 static_cast<SCCOL
>(nEndCol
), MAXROW
, nTab
, IDF_NONE
, FALSE
,
608 pUndoDoc
->CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, IDF_NONE
, FALSE
, pDoc
);
610 pViewShell
->UpdateScrollBars();
613 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
614 if ( nVisTab
!= nTab
)
615 pViewShell
->SetTabNo( nTab
);
617 pDocShell
->PostPaint(0,0,nTab
,MAXCOL
,MAXROW
,nTab
,PAINT_GRID
|PAINT_LEFT
|PAINT_TOP
|PAINT_SIZE
);
622 void __EXPORT
ScUndoAutoOutline::Redo()
626 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
628 SCTAB nTab
= aBlockStart
.Tab();
631 // Tabelle muss vorher umgeschaltet sein (#46952#) !!!
633 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
634 if ( nVisTab
!= nTab
)
635 pViewShell
->SetTabNo( nTab
);
638 ScRange
aRange( aBlockStart
.Col(), aBlockStart
.Row(), nTab
,
639 aBlockEnd
.Col(), aBlockEnd
.Row(), nTab
);
640 ScOutlineDocFunc
aFunc( *pDocShell
);
641 aFunc
.AutoOutline( aRange
, FALSE
, FALSE
);
643 // auf der View markieren
644 // Wenn's beim Aufruf eine Mehrfachselektion war, ist es jetzt der
645 // umschliessende Bereich...
648 pViewShell
->MarkRange( aRange
);
653 void __EXPORT
ScUndoAutoOutline::Repeat(SfxRepeatTarget
& rTarget
)
655 if (rTarget
.ISA(ScTabViewTarget
))
656 ((ScTabViewTarget
&)rTarget
).GetViewShell()->AutoOutline( TRUE
);
659 BOOL __EXPORT
ScUndoAutoOutline::CanRepeat(SfxRepeatTarget
& rTarget
) const
661 return (rTarget
.ISA(ScTabViewTarget
));
665 // Zwischenergebnisse
668 ScUndoSubTotals::ScUndoSubTotals( ScDocShell
* pNewDocShell
, SCTAB nNewTab
,
669 const ScSubTotalParam
& rNewParam
, SCROW nNewEndY
,
670 ScDocument
* pNewUndoDoc
, ScOutlineTable
* pNewUndoTab
,
671 ScRangeName
* pNewUndoRange
, ScDBCollection
* pNewUndoDB
) :
672 ScDBFuncUndo( pNewDocShell
, ScRange( rNewParam
.nCol1
, rNewParam
.nRow1
, nNewTab
,
673 rNewParam
.nCol2
, rNewParam
.nRow2
, nNewTab
) ),
676 nNewEndRow( nNewEndY
),
677 pUndoDoc( pNewUndoDoc
),
678 pUndoTable( pNewUndoTab
),
679 pUndoRange( pNewUndoRange
),
680 pUndoDB( pNewUndoDB
)
684 __EXPORT
ScUndoSubTotals::~ScUndoSubTotals()
692 String __EXPORT
ScUndoSubTotals::GetComment() const
693 { // "Teilergebnisse"
694 return ScGlobal::GetRscString( STR_UNDO_SUBTOTALS
);
697 void __EXPORT
ScUndoSubTotals::Undo()
701 ScDocument
* pDoc
= pDocShell
->GetDocument();
702 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
704 // um einzelnen DB-Bereich anzupassen
705 /* ScDBData* pOldDBData = ScUndoUtil::GetOldDBData( pUndoDBData, pDoc, nTab,
706 aParam.nCol1, aParam.nRow1, aParam.nCol2, nNewEndRow );
709 if (nNewEndRow
> aParam
.nRow2
)
711 pDoc
->DeleteRow( 0,nTab
, MAXCOL
,nTab
, aParam
.nRow2
+1, static_cast<SCSIZE
>(nNewEndRow
-aParam
.nRow2
) );
713 else if (nNewEndRow
< aParam
.nRow2
)
715 pDoc
->InsertRow( 0,nTab
, MAXCOL
,nTab
, nNewEndRow
+1, static_cast<SCSIZE
>(aParam
.nRow2
-nNewEndRow
) );
719 // Original Outline-Table
721 pDoc
->SetOutlineTable( nTab
, pUndoTable
);
723 // Original Spalten-/Zeilenstatus
725 if (pUndoDoc
&& pUndoTable
)
731 pUndoTable
->GetColArray()->GetRange( nStartCol
, nEndCol
);
732 pUndoTable
->GetRowArray()->GetRange( nStartRow
, nEndRow
);
734 pUndoDoc
->CopyToDocument( static_cast<SCCOL
>(nStartCol
), 0, nTab
,
735 static_cast<SCCOL
>(nEndCol
), MAXROW
, nTab
, IDF_NONE
, FALSE
,
737 pUndoDoc
->CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, IDF_NONE
, FALSE
, pDoc
);
739 pViewShell
->UpdateScrollBars();
742 // Original-Daten & Referenzen
744 ScUndoUtil::MarkSimpleBlock( pDocShell
, 0, aParam
.nRow1
+1, nTab
,
745 MAXCOL
, aParam
.nRow2
, nTab
);
747 pDoc
->DeleteAreaTab( 0,aParam
.nRow1
+1, MAXCOL
,aParam
.nRow2
, nTab
, IDF_ALL
);
749 pUndoDoc
->CopyToDocument( 0, aParam
.nRow1
+1, nTab
, MAXCOL
, aParam
.nRow2
, nTab
,
750 IDF_NONE
, FALSE
, pDoc
); // Flags
751 pUndoDoc
->UndoToDocument( 0, aParam
.nRow1
+1, nTab
, MAXCOL
, aParam
.nRow2
, nTab
,
752 IDF_ALL
, FALSE
, pDoc
);
754 ScUndoUtil::MarkSimpleBlock( pDocShell
, aParam
.nCol1
,aParam
.nRow1
,nTab
,
755 aParam
.nCol2
,aParam
.nRow2
,nTab
);
758 *pOldDBData = *pUndoDBData;
761 pDoc
->SetRangeName( new ScRangeName( *pUndoRange
) );
763 pDoc
->SetDBCollection( new ScDBCollection( *pUndoDB
), TRUE
);
765 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
766 if ( nVisTab
!= nTab
)
767 pViewShell
->SetTabNo( nTab
);
769 pDocShell
->PostPaint(0,0,nTab
,MAXCOL
,MAXROW
,nTab
,PAINT_GRID
|PAINT_LEFT
|PAINT_TOP
|PAINT_SIZE
);
770 pDocShell
->PostDataChanged();
775 void __EXPORT
ScUndoSubTotals::Redo()
779 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
781 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
782 if ( nVisTab
!= nTab
)
783 pViewShell
->SetTabNo( nTab
);
785 ScUndoUtil::MarkSimpleBlock( pDocShell
, aParam
.nCol1
,aParam
.nRow1
,nTab
,
786 aParam
.nCol2
,aParam
.nRow2
,nTab
);
787 pViewShell
->DoSubTotals( aParam
, FALSE
);
792 void __EXPORT
ScUndoSubTotals::Repeat(SfxRepeatTarget
& /* rTarget */)
796 BOOL __EXPORT
ScUndoSubTotals::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
798 return FALSE
; // geht nicht wegen Spaltennummern
805 ScUndoSort::ScUndoSort( ScDocShell
* pNewDocShell
,
806 SCTAB nNewTab
, const ScSortParam
& rParam
,
807 BOOL bQuery
, ScDocument
* pNewUndoDoc
, ScDBCollection
* pNewUndoDB
,
808 const ScRange
* pDest
) :
809 ScDBFuncUndo( pNewDocShell
, ScRange( rParam
.nCol1
, rParam
.nRow1
, nNewTab
,
810 rParam
.nCol2
, rParam
.nRow2
, nNewTab
) ),
812 aSortParam( rParam
),
813 bRepeatQuery( bQuery
),
814 pUndoDoc( pNewUndoDoc
),
815 pUndoDB( pNewUndoDB
),
825 __EXPORT
ScUndoSort::~ScUndoSort()
831 String __EXPORT
ScUndoSort::GetComment() const
833 return ScGlobal::GetRscString( STR_UNDO_SORT
);
836 void __EXPORT
ScUndoSort::Undo()
840 ScDocument
* pDoc
= pDocShell
->GetDocument();
841 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
843 SCCOL nStartCol
= aSortParam
.nCol1
;
844 SCROW nStartRow
= aSortParam
.nRow1
;
845 SCCOL nEndCol
= aSortParam
.nCol2
;
846 SCROW nEndRow
= aSortParam
.nRow2
;
847 SCTAB nSortTab
= nTab
;
848 if ( !aSortParam
.bInplace
)
850 nStartCol
= aSortParam
.nDestCol
;
851 nStartRow
= aSortParam
.nDestRow
;
852 nEndCol
= nStartCol
+ ( aSortParam
.nCol2
- aSortParam
.nCol1
);
853 nEndRow
= nStartRow
+ ( aSortParam
.nRow2
- aSortParam
.nRow1
);
854 nSortTab
= aSortParam
.nDestTab
;
857 ScUndoUtil::MarkSimpleBlock( pDocShell
, nStartCol
, nStartRow
, nSortTab
,
858 nEndCol
, nEndRow
, nSortTab
);
860 // do not delete/copy note captions, they are handled in drawing undo (ScDBFuncUndo::mpDrawUndo)
861 pDoc
->DeleteAreaTab( nStartCol
,nStartRow
, nEndCol
,nEndRow
, nSortTab
, IDF_ALL
|IDF_NOCAPTIONS
);
862 pUndoDoc
->CopyToDocument( nStartCol
, nStartRow
, nSortTab
, nEndCol
, nEndRow
, nSortTab
,
863 IDF_ALL
|IDF_NOCAPTIONS
, FALSE
, pDoc
);
867 // do not delete/copy note captions, they are handled in drawing undo (ScDBFuncUndo::mpDrawUndo)
868 pDoc
->DeleteAreaTab( aDestRange
, IDF_ALL
|IDF_NOCAPTIONS
);
869 pUndoDoc
->CopyToDocument( aDestRange
, IDF_ALL
|IDF_NOCAPTIONS
, FALSE
, pDoc
);
872 // Zeilenhoehen immer (wegen automatischer Anpassung)
873 //! auf ScBlockUndo umstellen
875 pUndoDoc
->CopyToDocument( 0, nStartRow
, nSortTab
, MAXCOL
, nEndRow
, nSortTab
,
876 IDF_NONE
, FALSE
, pDoc
);
879 pDoc
->SetDBCollection( new ScDBCollection( *pUndoDB
), TRUE
);
881 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
882 if ( nVisTab
!= nSortTab
)
883 pViewShell
->SetTabNo( nSortTab
);
885 pDocShell
->PostPaint(0,0,nTab
,MAXCOL
,MAXROW
,nTab
,PAINT_GRID
|PAINT_LEFT
|PAINT_TOP
|PAINT_SIZE
);
886 pDocShell
->PostDataChanged();
891 void __EXPORT
ScUndoSort::Redo()
895 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
897 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
898 if ( nVisTab
!= nTab
)
899 pViewShell
->SetTabNo( nTab
);
901 // pViewShell->DoneBlockMode();
902 // pViewShell->InitOwnBlockMode();
903 // pViewShell->GetViewData()->GetMarkData() = aMarkData; // CopyMarksTo
905 pViewShell
->MarkRange( ScRange( aSortParam
.nCol1
, aSortParam
.nRow1
, nTab
,
906 aSortParam
.nCol2
, aSortParam
.nRow2
, nTab
) );
908 pViewShell
->Sort( aSortParam
, FALSE
);
910 // Quellbereich painten wegen Markierung
911 if ( !aSortParam
.bInplace
)
912 pDocShell
->PostPaint( aSortParam
.nCol1
, aSortParam
.nRow1
, nTab
,
913 aSortParam
.nCol2
, aSortParam
.nRow2
, nTab
, PAINT_GRID
);
918 void __EXPORT
ScUndoSort::Repeat(SfxRepeatTarget
& /* rTarget */)
922 BOOL __EXPORT
ScUndoSort::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
924 return FALSE
; // geht nicht wegen Spaltennummern
931 ScUndoQuery::ScUndoQuery( ScDocShell
* pNewDocShell
, SCTAB nNewTab
, const ScQueryParam
& rParam
,
932 ScDocument
* pNewUndoDoc
, ScDBCollection
* pNewUndoDB
,
933 const ScRange
* pOld
, BOOL bSize
, const ScRange
* pAdvSrc
) :
934 ScDBFuncUndo( pNewDocShell
, ScRange( rParam
.nCol1
, rParam
.nRow1
, nNewTab
,
935 rParam
.nCol2
, rParam
.nRow2
, nNewTab
) ),
938 aQueryParam( rParam
),
939 pUndoDoc( pNewUndoDoc
),
940 // pUndoDBData( pNewData )
941 pUndoDB( pNewUndoDB
),
942 bIsAdvanced( FALSE
),
954 aAdvSource
= *pAdvSrc
;
957 pDrawUndo
= GetSdrUndoAction( pDocShell
->GetDocument() );
960 __EXPORT
ScUndoQuery::~ScUndoQuery()
963 // delete pUndoDBData;
965 DeleteSdrUndoAction( pDrawUndo
);
968 String __EXPORT
ScUndoQuery::GetComment() const
970 return ScGlobal::GetRscString( STR_UNDO_QUERY
);
973 void __EXPORT
ScUndoQuery::Undo()
977 ScDocument
* pDoc
= pDocShell
->GetDocument();
978 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
980 BOOL bCopy
= !aQueryParam
.bInplace
;
981 SCCOL nDestEndCol
= 0;
982 SCROW nDestEndRow
= 0;
985 nDestEndCol
= aQueryParam
.nDestCol
+ ( aQueryParam
.nCol2
-aQueryParam
.nCol1
);
986 nDestEndRow
= aQueryParam
.nDestRow
+ ( aQueryParam
.nRow2
-aQueryParam
.nRow1
);
988 ScDBData
* pData
= pDoc
->GetDBAtCursor( aQueryParam
.nDestCol
, aQueryParam
.nDestRow
,
989 aQueryParam
.nDestTab
, TRUE
);
993 pData
->GetArea( aNewDest
);
994 nDestEndCol
= aNewDest
.aEnd
.Col();
995 nDestEndRow
= aNewDest
.aEnd
.Row();
998 if ( bDoSize
&& bDestArea
)
1000 // aDestRange ist der alte Bereich
1001 pDoc
->FitBlock( ScRange(
1002 aQueryParam
.nDestCol
, aQueryParam
.nDestRow
, aQueryParam
.nDestTab
,
1003 nDestEndCol
, nDestEndRow
, aQueryParam
.nDestTab
),
1007 ScUndoUtil::MarkSimpleBlock( pDocShell
,
1008 aQueryParam
.nDestCol
, aQueryParam
.nDestRow
, aQueryParam
.nDestTab
,
1009 nDestEndCol
, nDestEndRow
, aQueryParam
.nDestTab
);
1010 pDoc
->DeleteAreaTab( aQueryParam
.nDestCol
, aQueryParam
.nDestRow
,
1011 nDestEndCol
, nDestEndRow
, aQueryParam
.nDestTab
, IDF_ALL
);
1013 pViewShell
->DoneBlockMode();
1015 pUndoDoc
->CopyToDocument( aQueryParam
.nDestCol
, aQueryParam
.nDestRow
, aQueryParam
.nDestTab
,
1016 nDestEndCol
, nDestEndRow
, aQueryParam
.nDestTab
,
1017 IDF_ALL
, FALSE
, pDoc
);
1018 // Attribute werden immer mitkopiert (#49287#)
1020 // Rest von altem Bereich
1021 if ( bDestArea
&& !bDoSize
)
1023 pDoc
->DeleteAreaTab( aOldDest
, IDF_ALL
);
1024 pUndoDoc
->CopyToDocument( aOldDest
, IDF_ALL
, FALSE
, pDoc
);
1028 pUndoDoc
->CopyToDocument( 0, aQueryParam
.nRow1
, nTab
, MAXCOL
, aQueryParam
.nRow2
, nTab
,
1029 IDF_NONE
, FALSE
, pDoc
);
1032 pDoc
->SetDBCollection( new ScDBCollection( *pUndoDB
), TRUE
);
1036 pDoc
->InvalidatePageBreaks(nTab
);
1037 pDoc
->UpdatePageBreaks( nTab
);
1040 ScRange
aDirtyRange( 0 , aQueryParam
.nRow1
, nTab
,
1041 MAXCOL
, aQueryParam
.nRow2
, nTab
);
1042 pDoc
->SetDirty( aDirtyRange
);
1044 DoSdrUndoAction( pDrawUndo
, pDoc
);
1046 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
1047 if ( nVisTab
!= nTab
)
1048 pViewShell
->SetTabNo( nTab
);
1054 SCCOL nEndX
= nDestEndCol
;
1055 SCROW nEndY
= nDestEndRow
;
1058 if ( aOldDest
.aEnd
.Col() > nEndX
)
1059 nEndX
= aOldDest
.aEnd
.Col();
1060 if ( aOldDest
.aEnd
.Row() > nEndY
)
1061 nEndY
= aOldDest
.aEnd
.Row();
1065 pDocShell
->PostPaint( aQueryParam
.nDestCol
, aQueryParam
.nDestRow
, aQueryParam
.nDestTab
,
1066 nEndX
, nEndY
, aQueryParam
.nDestTab
, PAINT_GRID
);
1069 pDocShell
->PostPaint( 0, aQueryParam
.nRow1
, nTab
, MAXCOL
, MAXROW
, nTab
,
1070 PAINT_GRID
| PAINT_LEFT
);
1071 pDocShell
->PostDataChanged();
1076 void __EXPORT
ScUndoQuery::Redo()
1080 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1082 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
1083 if ( nVisTab
!= nTab
)
1084 pViewShell
->SetTabNo( nTab
);
1087 pViewShell
->Query( aQueryParam
, &aAdvSource
, FALSE
);
1089 pViewShell
->Query( aQueryParam
, NULL
, FALSE
);
1094 void __EXPORT
ScUndoQuery::Repeat(SfxRepeatTarget
& /* rTarget */)
1098 BOOL __EXPORT
ScUndoQuery::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1100 return FALSE
; // geht nicht wegen Spaltennummern
1104 // Show or hide AutoFilter buttons (doesn't include filter settings)
1107 ScUndoAutoFilter::ScUndoAutoFilter( ScDocShell
* pNewDocShell
, const ScRange
& rRange
,
1108 const String
& rName
, BOOL bSet
) :
1109 ScDBFuncUndo( pNewDocShell
, rRange
),
1115 ScUndoAutoFilter::~ScUndoAutoFilter()
1119 String
ScUndoAutoFilter::GetComment() const
1121 return ScGlobal::GetRscString( STR_UNDO_QUERY
); // same as ScUndoQuery
1124 void ScUndoAutoFilter::DoChange( BOOL bUndo
)
1126 BOOL bNewFilter
= bUndo
? !bFilterSet
: bFilterSet
;
1129 ScDocument
* pDoc
= pDocShell
->GetDocument();
1130 ScDBCollection
* pColl
= pDoc
->GetDBCollection();
1131 if ( pColl
->SearchName( aDBName
, nIndex
) )
1133 ScDBData
* pDBData
= (*pColl
)[nIndex
];
1134 pDBData
->SetAutoFilter( bNewFilter
);
1141 pDBData
->GetArea( nRangeTab
, nRangeX1
, nRangeY1
, nRangeX2
, nRangeY2
);
1144 pDoc
->ApplyFlagsTab( nRangeX1
, nRangeY1
, nRangeX2
, nRangeY1
, nRangeTab
, SC_MF_AUTO
);
1146 pDoc
->RemoveFlagsTab( nRangeX1
, nRangeY1
, nRangeX2
, nRangeY1
, nRangeTab
, SC_MF_AUTO
);
1148 pDocShell
->PostPaint( nRangeX1
, nRangeY1
, nRangeTab
, nRangeX2
, nRangeY1
, nRangeTab
, PAINT_GRID
);
1152 void ScUndoAutoFilter::Undo()
1159 void ScUndoAutoFilter::Redo()
1166 void ScUndoAutoFilter::Repeat(SfxRepeatTarget
& /* rTarget */)
1170 BOOL
ScUndoAutoFilter::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1176 // Datenbankbereiche aendern (Dialog)
1179 ScUndoDBData::ScUndoDBData( ScDocShell
* pNewDocShell
,
1180 ScDBCollection
* pNewUndoColl
, ScDBCollection
* pNewRedoColl
) :
1181 ScSimpleUndo( pNewDocShell
),
1182 pUndoColl( pNewUndoColl
),
1183 pRedoColl( pNewRedoColl
)
1187 __EXPORT
ScUndoDBData::~ScUndoDBData()
1193 String __EXPORT
ScUndoDBData::GetComment() const
1194 { // "Datenbankbereiche aendern";
1195 return ScGlobal::GetRscString( STR_UNDO_DBDATA
);
1198 void __EXPORT
ScUndoDBData::Undo()
1202 ScDocument
* pDoc
= pDocShell
->GetDocument();
1204 BOOL bOldAutoCalc
= pDoc
->GetAutoCalc();
1205 pDoc
->SetAutoCalc( FALSE
); // unnoetige Berechnungen vermeiden
1206 pDoc
->CompileDBFormula( TRUE
); // CreateFormulaString
1207 pDoc
->SetDBCollection( new ScDBCollection(*pUndoColl
), TRUE
);
1208 pDoc
->CompileDBFormula( FALSE
); // CompileFormulaString
1209 pDoc
->SetAutoCalc( bOldAutoCalc
);
1211 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED
) );
1216 void __EXPORT
ScUndoDBData::Redo()
1220 ScDocument
* pDoc
= pDocShell
->GetDocument();
1222 BOOL bOldAutoCalc
= pDoc
->GetAutoCalc();
1223 pDoc
->SetAutoCalc( FALSE
); // unnoetige Berechnungen vermeiden
1224 pDoc
->CompileDBFormula( TRUE
); // CreateFormulaString
1225 pDoc
->SetDBCollection( new ScDBCollection(*pRedoColl
), TRUE
);
1226 pDoc
->CompileDBFormula( FALSE
); // CompileFormulaString
1227 pDoc
->SetAutoCalc( bOldAutoCalc
);
1229 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED
) );
1234 void __EXPORT
ScUndoDBData::Repeat(SfxRepeatTarget
& /* rTarget */)
1238 BOOL __EXPORT
ScUndoDBData::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1240 return FALSE
; // geht nicht
1247 ScUndoImportData::ScUndoImportData( ScDocShell
* pNewDocShell
, SCTAB nNewTab
,
1248 const ScImportParam
& rParam
, SCCOL nNewEndX
, SCROW nNewEndY
,
1250 ScDocument
* pNewUndoDoc
, ScDocument
* pNewRedoDoc
,
1251 ScDBData
* pNewUndoData
, ScDBData
* pNewRedoData
) :
1252 ScSimpleUndo( pNewDocShell
),
1254 aImportParam( rParam
),
1255 nEndCol( nNewEndX
),
1256 nEndRow( nNewEndY
),
1257 pUndoDoc( pNewUndoDoc
),
1258 pRedoDoc( pNewRedoDoc
),
1259 pUndoDBData( pNewUndoData
),
1260 pRedoDBData( pNewRedoData
),
1261 nFormulaCols( nNewFormula
),
1262 bRedoFilled( FALSE
)
1264 // redo doc doesn't contain imported data (but everything else)
1267 __EXPORT
ScUndoImportData::~ScUndoImportData()
1275 String __EXPORT
ScUndoImportData::GetComment() const
1277 return ScGlobal::GetRscString( STR_UNDO_IMPORTDATA
);
1280 void __EXPORT
ScUndoImportData::Undo()
1284 ScDocument
* pDoc
= pDocShell
->GetDocument();
1285 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1287 ScUndoUtil::MarkSimpleBlock( pDocShell
, aImportParam
.nCol1
,aImportParam
.nRow1
,nTab
,
1288 nEndCol
,nEndRow
,nTab
);
1293 ScDBData
* pCurrentData
= NULL
;
1294 if (pUndoDBData
&& pRedoDBData
)
1296 pRedoDBData
->GetArea( nTable
, nCol1
, nRow1
, nCol2
, nRow2
);
1297 pCurrentData
= ScUndoUtil::GetOldDBData( pRedoDBData
, pDoc
, nTab
,
1298 nCol1
, nRow1
, nCol2
, nRow2
);
1302 // read redo data from document at first undo
1303 // imported data is deleted later anyway,
1304 // so now delete each column after copying to save memory (#41216#)
1306 BOOL bOldAutoCalc
= pDoc
->GetAutoCalc();
1307 pDoc
->SetAutoCalc( FALSE
); // outside of the loop
1308 for (SCCOL nCopyCol
= nCol1
; nCopyCol
<= nCol2
; nCopyCol
++)
1310 pDoc
->CopyToDocument( nCopyCol
,nRow1
,nTab
, nCopyCol
,nRow2
,nTab
,
1311 IDF_CONTENTS
, FALSE
, pRedoDoc
);
1312 pDoc
->DeleteAreaTab( nCopyCol
,nRow1
, nCopyCol
,nRow2
, nTab
, IDF_CONTENTS
);
1313 pDoc
->DoColResize( nTab
, nCopyCol
, nCopyCol
, 0 );
1315 pDoc
->SetAutoCalc( bOldAutoCalc
);
1319 BOOL bMoveCells
= pUndoDBData
&& pRedoDBData
&&
1320 pRedoDBData
->IsDoSize(); // in alt und neu gleich
1323 // Undo: erst die neuen Daten loeschen, dann FitBlock rueckwaerts
1326 pUndoDBData
->GetArea( aOld
);
1327 pRedoDBData
->GetArea( aNew
);
1329 pDoc
->DeleteAreaTab( aNew
.aStart
.Col(), aNew
.aStart
.Row(),
1330 aNew
.aEnd
.Col(), aNew
.aEnd
.Row(), nTab
, IDF_ALL
);
1332 aOld
.aEnd
.SetCol( aOld
.aEnd
.Col() + nFormulaCols
); // FitBlock auch fuer Formeln
1333 aNew
.aEnd
.SetCol( aNew
.aEnd
.Col() + nFormulaCols
);
1334 pDoc
->FitBlock( aNew
, aOld
, FALSE
); // rueckwaerts
1337 pDoc
->DeleteAreaTab( aImportParam
.nCol1
,aImportParam
.nRow1
,
1338 nEndCol
,nEndRow
, nTab
, IDF_ALL
);
1340 pUndoDoc
->CopyToDocument( aImportParam
.nCol1
,aImportParam
.nRow1
,nTab
,
1341 nEndCol
+nFormulaCols
,nEndRow
,nTab
,
1342 IDF_ALL
, FALSE
, pDoc
);
1346 *pCurrentData
= *pUndoDBData
;
1348 pUndoDBData
->GetArea( nTable
, nCol1
, nRow1
, nCol2
, nRow2
);
1349 ScUndoUtil::MarkSimpleBlock( pDocShell
, nCol1
, nRow1
, nTable
, nCol2
, nRow2
, nTable
);
1352 // erack! it's broadcasted
1353 // pDoc->SetDirty();
1355 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
1356 if ( nVisTab
!= nTab
)
1357 pViewShell
->SetTabNo( nTab
);
1360 pDocShell
->PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
);
1362 pDocShell
->PostPaint( aImportParam
.nCol1
,aImportParam
.nRow1
,nTab
,
1363 nEndCol
,nEndRow
,nTab
, PAINT_GRID
);
1364 pDocShell
->PostDataChanged();
1369 void __EXPORT
ScUndoImportData::Redo()
1373 ScDocument
* pDoc
= pDocShell
->GetDocument();
1374 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1376 ScUndoUtil::MarkSimpleBlock( pDocShell
, aImportParam
.nCol1
,aImportParam
.nRow1
,nTab
,
1377 nEndCol
,nEndRow
,nTab
);
1382 ScDBData
* pCurrentData
= NULL
;
1383 if (pUndoDBData
&& pRedoDBData
)
1385 pUndoDBData
->GetArea( nTable
, nCol1
, nRow1
, nCol2
, nRow2
);
1386 pCurrentData
= ScUndoUtil::GetOldDBData( pUndoDBData
, pDoc
, nTab
,
1387 nCol1
, nRow1
, nCol2
, nRow2
);
1389 BOOL bMoveCells
= pUndoDBData
&& pRedoDBData
&&
1390 pRedoDBData
->IsDoSize(); // in alt und neu gleich
1393 // Redo: FitBlock, dann Daten loeschen (noetig fuer CopyToDocument)
1396 pUndoDBData
->GetArea( aOld
);
1397 pRedoDBData
->GetArea( aNew
);
1399 aOld
.aEnd
.SetCol( aOld
.aEnd
.Col() + nFormulaCols
); // FitBlock auch fuer Formeln
1400 aNew
.aEnd
.SetCol( aNew
.aEnd
.Col() + nFormulaCols
);
1401 pDoc
->FitBlock( aOld
, aNew
);
1403 pDoc
->DeleteAreaTab( aNew
.aStart
.Col(), aNew
.aStart
.Row(),
1404 aNew
.aEnd
.Col(), aNew
.aEnd
.Row(), nTab
, IDF_ALL
);
1406 pRedoDoc
->CopyToDocument( aNew
, IDF_ALL
, FALSE
, pDoc
); // incl. Formeln
1410 pDoc
->DeleteAreaTab( aImportParam
.nCol1
,aImportParam
.nRow1
,
1411 nEndCol
,nEndRow
, nTab
, IDF_ALL
);
1412 pRedoDoc
->CopyToDocument( aImportParam
.nCol1
,aImportParam
.nRow1
,nTab
,
1413 nEndCol
,nEndRow
,nTab
, IDF_ALL
, FALSE
, pDoc
);
1418 *pCurrentData
= *pRedoDBData
;
1420 pRedoDBData
->GetArea( nTable
, nCol1
, nRow1
, nCol2
, nRow2
);
1421 ScUndoUtil::MarkSimpleBlock( pDocShell
, nCol1
, nRow1
, nTable
, nCol2
, nRow2
, nTable
);
1424 // erack! it's broadcasted
1425 // pDoc->SetDirty();
1427 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
1428 if ( nVisTab
!= nTab
)
1429 pViewShell
->SetTabNo( nTab
);
1432 pDocShell
->PostPaint( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, PAINT_GRID
);
1434 pDocShell
->PostPaint( aImportParam
.nCol1
,aImportParam
.nRow1
,nTab
,
1435 nEndCol
,nEndRow
,nTab
, PAINT_GRID
);
1436 pDocShell
->PostDataChanged();
1441 void __EXPORT
ScUndoImportData::Repeat(SfxRepeatTarget
& rTarget
)
1443 if (rTarget
.ISA(ScTabViewTarget
))
1445 ScTabViewShell
& rViewShell
= *((ScTabViewTarget
&)rTarget
).GetViewShell();
1448 ScImportParam
aNewParam(aImportParam
);
1449 ScDBData
* pDBData
= rViewShell
.GetDBData();
1450 pDBData
->GetArea( nDummy
, aNewParam
.nCol1
,aNewParam
.nRow1
, aNewParam
.nCol2
,aNewParam
.nRow2
);
1452 rViewShell
.ImportData( aNewParam
);
1456 BOOL __EXPORT
ScUndoImportData::CanRepeat(SfxRepeatTarget
& rTarget
) const
1458 // Repeat nur fuer Import per DB-Bereich, dann ist pUndoDBData gesetzt
1461 return (rTarget
.ISA(ScTabViewTarget
));
1463 return FALSE
; // Adressbuch
1467 // Operationen wiederholen
1470 ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell
* pNewDocShell
, SCTAB nNewTab
,
1471 SCCOL nStartX
, SCROW nStartY
, SCCOL nEndX
, SCROW nEndY
,
1472 SCROW nResultEndRow
, SCCOL nCurX
, SCROW nCurY
,
1473 ScDocument
* pNewUndoDoc
, ScOutlineTable
* pNewUndoTab
,
1474 ScRangeName
* pNewUndoRange
, ScDBCollection
* pNewUndoDB
,
1475 const ScRange
* pOldQ
, const ScRange
* pNewQ
) :
1476 ScSimpleUndo( pNewDocShell
),
1477 aBlockStart( nStartX
,nStartY
,nNewTab
),
1478 aBlockEnd( nEndX
,nEndY
,nNewTab
),
1479 nNewEndRow( nResultEndRow
),
1480 aCursorPos( nCurX
,nCurY
,nNewTab
),
1481 pUndoDoc( pNewUndoDoc
),
1482 pUndoTable( pNewUndoTab
),
1483 pUndoRange( pNewUndoRange
),
1484 pUndoDB( pNewUndoDB
),
1487 if ( pOldQ
&& pNewQ
)
1495 __EXPORT
ScUndoRepeatDB::~ScUndoRepeatDB()
1503 String __EXPORT
ScUndoRepeatDB::GetComment() const
1504 { // "Wiederholen"; //! bessere Beschreibung!
1505 return ScGlobal::GetRscString( STR_UNDO_REPEATDB
);
1508 void __EXPORT
ScUndoRepeatDB::Undo()
1512 ScDocument
* pDoc
= pDocShell
->GetDocument();
1513 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1514 SCTAB nTab
= aBlockStart
.Tab();
1518 pDoc
->FitBlock( aNewQuery
, aOldQuery
, FALSE
);
1520 if ( aNewQuery
.aEnd
.Col() == aOldQuery
.aEnd
.Col() )
1522 SCCOL nFormulaCols
= 0;
1523 SCCOL nCol
= aOldQuery
.aEnd
.Col() + 1;
1524 SCROW nRow
= aOldQuery
.aStart
.Row() + 1; //! Header testen
1525 while ( nCol
<= MAXCOL
&&
1526 pDoc
->GetCellType(ScAddress( nCol
, nRow
, nTab
)) == CELLTYPE_FORMULA
)
1527 ++nCol
, ++nFormulaCols
;
1529 if ( nFormulaCols
> 0 )
1531 ScRange aOldForm
= aOldQuery
;
1532 aOldForm
.aStart
.SetCol( aOldQuery
.aEnd
.Col() + 1 );
1533 aOldForm
.aEnd
.SetCol( aOldQuery
.aEnd
.Col() + nFormulaCols
);
1534 ScRange aNewForm
= aOldForm
;
1535 aNewForm
.aEnd
.SetRow( aNewQuery
.aEnd
.Row() );
1536 pDoc
->FitBlock( aNewForm
, aOldForm
, FALSE
);
1541 //! Daten von Filter in anderen Bereich fehlen noch !!!!!!!!!!!!!!!!!
1543 if (nNewEndRow
> aBlockEnd
.Row())
1545 pDoc
->DeleteRow( 0,nTab
, MAXCOL
,nTab
, aBlockEnd
.Row()+1, static_cast<SCSIZE
>(nNewEndRow
-aBlockEnd
.Row()) );
1547 else if (nNewEndRow
< aBlockEnd
.Row())
1549 pDoc
->InsertRow( 0,nTab
, MAXCOL
,nTab
, nNewEndRow
+1, static_cast<SCSIZE
>(nNewEndRow
-aBlockEnd
.Row()) );
1552 // Original Outline-Table
1554 pDoc
->SetOutlineTable( nTab
, pUndoTable
);
1556 // Original Spalten-/Zeilenstatus
1558 if (pUndoDoc
&& pUndoTable
)
1564 pUndoTable
->GetColArray()->GetRange( nStartCol
, nEndCol
);
1565 pUndoTable
->GetRowArray()->GetRange( nStartRow
, nEndRow
);
1567 pUndoDoc
->CopyToDocument( static_cast<SCCOL
>(nStartCol
), 0, nTab
,
1568 static_cast<SCCOL
>(nEndCol
), MAXROW
, nTab
, IDF_NONE
, FALSE
,
1570 pUndoDoc
->CopyToDocument( 0, nStartRow
, nTab
, MAXCOL
, nEndRow
, nTab
, IDF_NONE
, FALSE
, pDoc
);
1572 pViewShell
->UpdateScrollBars();
1575 // Original-Daten & Referenzen
1577 ScUndoUtil::MarkSimpleBlock( pDocShell
, 0, aBlockStart
.Row(), nTab
,
1578 MAXCOL
, aBlockEnd
.Row(), nTab
);
1579 pDoc
->DeleteAreaTab( 0, aBlockStart
.Row(),
1580 MAXCOL
, aBlockEnd
.Row(), nTab
, IDF_ALL
);
1582 pUndoDoc
->CopyToDocument( 0, aBlockStart
.Row(), nTab
, MAXCOL
, aBlockEnd
.Row(), nTab
,
1583 IDF_NONE
, FALSE
, pDoc
); // Flags
1584 pUndoDoc
->UndoToDocument( 0, aBlockStart
.Row(), nTab
, MAXCOL
, aBlockEnd
.Row(), nTab
,
1585 IDF_ALL
, FALSE
, pDoc
);
1587 ScUndoUtil::MarkSimpleBlock( pDocShell
, aBlockStart
.Col(),aBlockStart
.Row(),nTab
,
1588 aBlockEnd
.Col(),aBlockEnd
.Row(),nTab
);
1591 pDoc
->SetRangeName( new ScRangeName( *pUndoRange
) );
1593 pDoc
->SetDBCollection( new ScDBCollection( *pUndoDB
), TRUE
);
1595 // erack! it's broadcasted
1596 // pDoc->SetDirty();
1598 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
1599 if ( nVisTab
!= nTab
)
1600 pViewShell
->SetTabNo( nTab
);
1602 pDocShell
->PostPaint(0,0,nTab
,MAXCOL
,MAXROW
,nTab
,PAINT_GRID
|PAINT_LEFT
|PAINT_TOP
|PAINT_SIZE
);
1603 pDocShell
->PostDataChanged();
1608 void __EXPORT
ScUndoRepeatDB::Redo()
1612 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1613 SCTAB nTab
= aBlockStart
.Tab();
1615 SCTAB nVisTab
= pViewShell
->GetViewData()->GetTabNo();
1616 if ( nVisTab
!= nTab
)
1617 pViewShell
->SetTabNo( nTab
);
1619 ScUndoUtil::MarkSimpleBlock( pDocShell
, aBlockStart
.Col(),aBlockStart
.Row(),nTab
,
1620 aBlockEnd
.Col(),aBlockEnd
.Row(),nTab
);
1621 pViewShell
->SetCursor( aCursorPos
.Col(), aCursorPos
.Row() );
1623 pViewShell
->RepeatDB( FALSE
);
1628 void __EXPORT
ScUndoRepeatDB::Repeat(SfxRepeatTarget
& rTarget
)
1630 if (rTarget
.ISA(ScTabViewTarget
))
1631 ((ScTabViewTarget
&)rTarget
).GetViewShell()->RepeatDB( TRUE
);
1634 BOOL __EXPORT
ScUndoRepeatDB::CanRepeat(SfxRepeatTarget
& rTarget
) const
1636 return (rTarget
.ISA(ScTabViewTarget
));
1640 //UNUSED2008-05 // Pivot-Tabellen
1643 //UNUSED2008-05 ScUndoPivot::ScUndoPivot( ScDocShell* pNewDocShell,
1644 //UNUSED2008-05 const ScArea& rOld, const ScArea& rNew,
1645 //UNUSED2008-05 ScDocument* pOldDoc, ScDocument* pNewDoc,
1646 //UNUSED2008-05 const ScPivot* pOldPivot, const ScPivot* pNewPivot ) :
1647 //UNUSED2008-05 ScSimpleUndo( pNewDocShell ),
1648 //UNUSED2008-05 aOldArea( rOld ),
1649 //UNUSED2008-05 aNewArea( rNew ),
1650 //UNUSED2008-05 pOldUndoDoc( pOldDoc ),
1651 //UNUSED2008-05 pNewUndoDoc( pNewDoc )
1653 //UNUSED2008-05 if (pNewPivot)
1655 //UNUSED2008-05 pNewPivot->GetParam( aNewParam, aNewQuery, aNewSrc );
1656 //UNUSED2008-05 aNewName = pNewPivot->GetName();
1657 //UNUSED2008-05 aNewTag = pNewPivot->GetTag();
1659 //UNUSED2008-05 if (pOldPivot)
1661 //UNUSED2008-05 pOldPivot->GetParam( aOldParam, aOldQuery, aOldSrc );
1662 //UNUSED2008-05 aOldName = pOldPivot->GetName();
1663 //UNUSED2008-05 aOldTag = pOldPivot->GetTag();
1667 //UNUSED2008-05 __EXPORT ScUndoPivot::~ScUndoPivot()
1669 //UNUSED2008-05 delete pOldUndoDoc;
1670 //UNUSED2008-05 delete pNewUndoDoc;
1673 //UNUSED2008-05 String __EXPORT ScUndoPivot::GetComment() const
1675 //UNUSED2008-05 USHORT nIndex;
1676 //UNUSED2008-05 if ( pOldUndoDoc && pNewUndoDoc )
1677 //UNUSED2008-05 nIndex = STR_UNDO_PIVOT_MODIFY;
1678 //UNUSED2008-05 else if ( pNewUndoDoc )
1679 //UNUSED2008-05 nIndex = STR_UNDO_PIVOT_NEW;
1680 //UNUSED2008-05 else
1681 //UNUSED2008-05 nIndex = STR_UNDO_PIVOT_DELETE;
1683 //UNUSED2008-05 return ScGlobal::GetRscString( nIndex );
1686 //UNUSED2008-05 void __EXPORT ScUndoPivot::Undo()
1688 //UNUSED2008-05 BeginUndo();
1690 //UNUSED2008-05 ScDocument* pDoc = pDocShell->GetDocument();
1692 //UNUSED2008-05 if (pNewUndoDoc)
1694 //UNUSED2008-05 pDoc->DeleteAreaTab( aNewArea.nColStart,aNewArea.nRowStart,
1695 //UNUSED2008-05 aNewArea.nColEnd,aNewArea.nRowEnd, aNewArea.nTab, IDF_ALL );
1696 //UNUSED2008-05 pNewUndoDoc->CopyToDocument( aNewArea.nColStart, aNewArea.nRowStart, aNewArea.nTab,
1697 //UNUSED2008-05 aNewArea.nColEnd, aNewArea.nRowEnd, aNewArea.nTab,
1698 //UNUSED2008-05 IDF_ALL, FALSE, pDoc );
1700 //UNUSED2008-05 if (pOldUndoDoc)
1702 //UNUSED2008-05 pDoc->DeleteAreaTab( aOldArea.nColStart,aOldArea.nRowStart,
1703 //UNUSED2008-05 aOldArea.nColEnd,aOldArea.nRowEnd, aOldArea.nTab, IDF_ALL );
1704 //UNUSED2008-05 pOldUndoDoc->CopyToDocument( aOldArea.nColStart, aOldArea.nRowStart, aOldArea.nTab,
1705 //UNUSED2008-05 aOldArea.nColEnd, aOldArea.nRowEnd, aOldArea.nTab,
1706 //UNUSED2008-05 IDF_ALL, FALSE, pDoc );
1709 //UNUSED2008-05 ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection();
1710 //UNUSED2008-05 if ( pNewUndoDoc )
1712 //UNUSED2008-05 ScPivot* pNewPivot = pPivotCollection->GetPivotAtCursor(
1713 //UNUSED2008-05 aNewParam.nCol, aNewParam.nRow, aNewParam.nTab );
1714 //UNUSED2008-05 if (pNewPivot)
1715 //UNUSED2008-05 pPivotCollection->Free( pNewPivot );
1717 //UNUSED2008-05 if ( pOldUndoDoc )
1719 //UNUSED2008-05 ScPivot* pOldPivot = new ScPivot( pDoc );
1720 //UNUSED2008-05 pOldPivot->SetParam( aOldParam, aOldQuery, aOldSrc );
1721 //UNUSED2008-05 pOldPivot->SetName( aOldName );
1722 //UNUSED2008-05 pOldPivot->SetTag( aOldTag );
1723 //UNUSED2008-05 if (pOldPivot->CreateData()) // Felder berechnen
1724 //UNUSED2008-05 pOldPivot->ReleaseData();
1725 //UNUSED2008-05 pPivotCollection->Insert( pOldPivot );
1728 //UNUSED2008-05 // erack! it's broadcasted
1729 //UNUSED2008-05 // pDoc->SetDirty();
1730 //UNUSED2008-05 if (pNewUndoDoc)
1731 //UNUSED2008-05 pDocShell->PostPaint( aNewArea.nColStart, aNewArea.nRowStart, aNewArea.nTab,
1732 //UNUSED2008-05 aNewArea.nColEnd, aNewArea.nRowEnd, aNewArea.nTab,
1733 //UNUSED2008-05 PAINT_GRID, SC_PF_LINES );
1734 //UNUSED2008-05 if (pOldUndoDoc)
1735 //UNUSED2008-05 pDocShell->PostPaint( aOldArea.nColStart, aOldArea.nRowStart, aOldArea.nTab,
1736 //UNUSED2008-05 aOldArea.nColEnd, aOldArea.nRowEnd, aOldArea.nTab,
1737 //UNUSED2008-05 PAINT_GRID, SC_PF_LINES );
1738 //UNUSED2008-05 pDocShell->PostDataChanged();
1740 //UNUSED2008-05 ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1741 //UNUSED2008-05 if (pViewShell)
1743 //UNUSED2008-05 SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
1744 //UNUSED2008-05 if ( pOldUndoDoc )
1746 //UNUSED2008-05 if ( nTab != aOldArea.nTab )
1747 //UNUSED2008-05 pViewShell->SetTabNo( aOldArea.nTab );
1749 //UNUSED2008-05 else if ( pNewUndoDoc )
1751 //UNUSED2008-05 if ( nTab != aNewArea.nTab )
1752 //UNUSED2008-05 pViewShell->SetTabNo( aNewArea.nTab );
1756 //UNUSED2008-05 EndUndo();
1759 //UNUSED2008-05 void __EXPORT ScUndoPivot::Redo()
1761 //UNUSED2008-05 BeginRedo();
1763 //UNUSED2008-05 ScDocument* pDoc = pDocShell->GetDocument();
1764 //UNUSED2008-05 ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection();
1765 //UNUSED2008-05 ScPivot* pOldPivot = pPivotCollection->GetPivotAtCursor(
1766 //UNUSED2008-05 aOldParam.nCol, aOldParam.nRow, aOldParam.nTab );
1768 //UNUSED2008-05 ScPivot* pNewPivot = NULL;
1769 //UNUSED2008-05 if (pNewUndoDoc)
1771 //UNUSED2008-05 pNewPivot = new ScPivot( pDoc );
1772 //UNUSED2008-05 pNewPivot->SetParam( aNewParam, aNewQuery, aNewSrc );
1773 //UNUSED2008-05 pNewPivot->SetName( aNewName );
1774 //UNUSED2008-05 pNewPivot->SetTag( aNewTag );
1777 //UNUSED2008-05 pDocShell->PivotUpdate( pOldPivot, pNewPivot, FALSE );
1779 //UNUSED2008-05 EndRedo();
1782 //UNUSED2008-05 void __EXPORT ScUndoPivot::Repeat(SfxRepeatTarget& rTarget)
1784 //UNUSED2008-05 // Wiederholen: nur loeschen
1786 //UNUSED2008-05 if ( pOldUndoDoc && !pNewUndoDoc && rTarget.ISA(ScTabViewTarget) )
1787 //UNUSED2008-05 ((ScTabViewTarget&)rTarget).GetViewShell()->DeletePivotTable();
1790 //UNUSED2008-05 BOOL __EXPORT ScUndoPivot::CanRepeat(SfxRepeatTarget& rTarget) const
1792 //UNUSED2008-05 // Wiederholen: nur loeschen
1794 //UNUSED2008-05 return ( pOldUndoDoc && !pNewUndoDoc && rTarget.ISA(ScTabViewTarget) );
1801 ScUndoDataPilot::ScUndoDataPilot( ScDocShell
* pNewDocShell
,
1802 ScDocument
* pOldDoc
, ScDocument
* pNewDoc
,
1803 const ScDPObject
* pOldObj
, const ScDPObject
* pNewObj
, BOOL bMove
) :
1804 ScSimpleUndo( pNewDocShell
),
1805 pOldUndoDoc( pOldDoc
),
1806 pNewUndoDoc( pNewDoc
),
1807 pOldDPObject( NULL
),
1808 pNewDPObject( NULL
),
1812 pOldDPObject
= new ScDPObject( *pOldObj
);
1814 pNewDPObject
= new ScDPObject( *pNewObj
);
1817 __EXPORT
ScUndoDataPilot::~ScUndoDataPilot()
1819 delete pOldDPObject
;
1820 delete pNewDPObject
;
1825 String __EXPORT
ScUndoDataPilot::GetComment() const
1828 if ( pOldUndoDoc
&& pNewUndoDoc
)
1829 nIndex
= STR_UNDO_PIVOT_MODIFY
;
1830 else if ( pNewUndoDoc
)
1831 nIndex
= STR_UNDO_PIVOT_NEW
;
1833 nIndex
= STR_UNDO_PIVOT_DELETE
;
1835 return ScGlobal::GetRscString( nIndex
);
1838 void __EXPORT
ScUndoDataPilot::Undo()
1842 ScDocument
* pDoc
= pDocShell
->GetDocument();
1847 if ( pNewDPObject
&& pNewUndoDoc
)
1849 aNewRange
= pNewDPObject
->GetOutRange();
1850 pDoc
->DeleteAreaTab( aNewRange
, IDF_ALL
);
1851 pNewUndoDoc
->CopyToDocument( aNewRange
, IDF_ALL
, FALSE
, pDoc
);
1853 if ( pOldDPObject
&& pOldUndoDoc
)
1855 aOldRange
= pOldDPObject
->GetOutRange();
1856 pDoc
->DeleteAreaTab( aOldRange
, IDF_ALL
);
1857 pOldUndoDoc
->CopyToDocument( aOldRange
, IDF_ALL
, FALSE
, pDoc
);
1860 // update objects in collection
1864 // find updated object
1867 ScDPObject
* pDocObj
= pDoc
->GetDPAtCursor(
1868 aNewRange
.aStart
.Col(), aNewRange
.aStart
.Row(), aNewRange
.aStart
.Tab() );
1869 DBG_ASSERT(pDocObj
, "DPObject not found");
1874 // restore old settings
1875 pOldDPObject
->WriteSourceDataTo( *pDocObj
);
1876 ScDPSaveData
* pData
= pOldDPObject
->GetSaveData();
1878 pDocObj
->SetSaveData(*pData
);
1879 pDocObj
->SetOutRange( pOldDPObject
->GetOutRange() );
1880 pOldDPObject
->WriteTempDataTo( *pDocObj
);
1884 // delete inserted object
1885 pDoc
->GetDPCollection()->FreeTable(pDocObj
);
1889 else if ( pOldDPObject
)
1891 // re-insert deleted object
1893 ScDPObject
* pDestObj
= new ScDPObject( *pOldDPObject
);
1894 pDestObj
->SetAlive(TRUE
);
1895 if ( !pDoc
->GetDPCollection()->InsertNewTable(pDestObj
) )
1897 DBG_ERROR("cannot insert DPObject");
1898 DELETEZ( pDestObj
);
1903 pDocShell
->PostPaint( aNewRange
, PAINT_GRID
, SC_PF_LINES
);
1905 pDocShell
->PostPaint( aOldRange
, PAINT_GRID
, SC_PF_LINES
);
1906 pDocShell
->PostDataChanged();
1908 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
1911 //! set current sheet
1917 void __EXPORT
ScUndoDataPilot::Redo()
1921 //! copy output data instead of repeating the change,
1922 //! in case external data have changed!
1924 ScDocument
* pDoc
= pDocShell
->GetDocument();
1926 ScDPObject
* pSourceObj
= NULL
;
1929 // find object to modify
1932 ScRange aOldRange
= pOldDPObject
->GetOutRange();
1933 pSourceObj
= pDoc
->GetDPAtCursor(
1934 aOldRange
.aStart
.Col(), aOldRange
.aStart
.Row(), aOldRange
.aStart
.Tab() );
1935 DBG_ASSERT(pSourceObj
, "DPObject not found");
1938 ScDBDocFunc
aFunc( *pDocShell
);
1939 aFunc
.DataPilotUpdate( pSourceObj
, pNewDPObject
, FALSE
, FALSE
, bAllowMove
); // no new undo action
1944 void __EXPORT
ScUndoDataPilot::Repeat(SfxRepeatTarget
& /* rTarget */)
1949 BOOL __EXPORT
ScUndoDataPilot::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
1960 ScUndoConsolidate::ScUndoConsolidate( ScDocShell
* pNewDocShell
, const ScArea
& rArea
,
1961 const ScConsolidateParam
& rPar
, ScDocument
* pNewUndoDoc
,
1962 BOOL bReference
, SCROW nInsCount
, ScOutlineTable
* pTab
,
1964 ScSimpleUndo( pNewDocShell
),
1966 pUndoDoc( pNewUndoDoc
),
1968 bInsRef( bReference
),
1969 nInsertCount( nInsCount
),
1975 __EXPORT
ScUndoConsolidate::~ScUndoConsolidate()
1982 String __EXPORT
ScUndoConsolidate::GetComment() const
1984 return ScGlobal::GetRscString( STR_UNDO_CONSOLIDATE
);
1987 void __EXPORT
ScUndoConsolidate::Undo()
1991 ScDocument
* pDoc
= pDocShell
->GetDocument();
1992 SCTAB nTab
= aDestArea
.nTab
;
1996 pUndoData
->GetArea(aOldRange
);
2001 pDoc
->DeleteRow( 0,nTab
, MAXCOL
,nTab
, aDestArea
.nRowStart
, nInsertCount
);
2004 pDoc
->SetOutlineTable( nTab
, pUndoTab
);
2007 pUndoDoc
->CopyToDocument( 0,0,nTab
, MAXCOL
,MAXROW
,nTab
, IDF_NONE
, FALSE
, pDoc
);
2009 // Daten & Referenzen
2010 pDoc
->DeleteAreaTab( 0,aDestArea
.nRowStart
, MAXCOL
,aDestArea
.nRowEnd
, nTab
, IDF_ALL
);
2011 pUndoDoc
->UndoToDocument( 0, aDestArea
.nRowStart
, nTab
,
2012 MAXCOL
, aDestArea
.nRowEnd
, nTab
,
2013 IDF_ALL
, FALSE
, pDoc
);
2018 pDoc
->DeleteAreaTab(aOldRange
, IDF_ALL
);
2019 pUndoDoc
->CopyToDocument(aOldRange
, IDF_ALL
, FALSE
, pDoc
);
2022 pDocShell
->PostPaint( 0,aDestArea
.nRowStart
,nTab
, MAXCOL
,MAXROW
,nTab
,
2023 PAINT_GRID
| PAINT_LEFT
| PAINT_SIZE
);
2027 pDoc
->DeleteAreaTab( aDestArea
.nColStart
,aDestArea
.nRowStart
,
2028 aDestArea
.nColEnd
,aDestArea
.nRowEnd
, nTab
, IDF_ALL
);
2029 pUndoDoc
->CopyToDocument( aDestArea
.nColStart
, aDestArea
.nRowStart
, nTab
,
2030 aDestArea
.nColEnd
, aDestArea
.nRowEnd
, nTab
,
2031 IDF_ALL
, FALSE
, pDoc
);
2036 pDoc
->DeleteAreaTab(aOldRange
, IDF_ALL
);
2037 pUndoDoc
->CopyToDocument(aOldRange
, IDF_ALL
, FALSE
, pDoc
);
2040 SCCOL nEndX
= aDestArea
.nColEnd
;
2041 SCROW nEndY
= aDestArea
.nRowEnd
;
2044 if ( aOldRange
.aEnd
.Col() > nEndX
)
2045 nEndX
= aOldRange
.aEnd
.Col();
2046 if ( aOldRange
.aEnd
.Row() > nEndY
)
2047 nEndY
= aOldRange
.aEnd
.Row();
2049 pDocShell
->PostPaint( aDestArea
.nColStart
, aDestArea
.nRowStart
, nTab
,
2050 nEndX
, nEndY
, nTab
, PAINT_GRID
);
2053 // DB-Bereich wieder anpassen
2056 ScDBCollection
* pColl
= pDoc
->GetDBCollection();
2060 if (pColl
->SearchName( pUndoData
->GetName(), nIndex
))
2062 ScDBData
* pDocData
= (*pColl
)[nIndex
];
2064 *pDocData
= *pUndoData
;
2068 DBG_ERROR("alte DB-Daten nicht gefunden");
2073 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
2076 SCTAB nViewTab
= pViewShell
->GetViewData()->GetTabNo();
2077 if ( nViewTab
!= nTab
)
2078 pViewShell
->SetTabNo( nTab
);
2084 void __EXPORT
ScUndoConsolidate::Redo()
2088 pDocShell
->DoConsolidate( aParam
, FALSE
);
2090 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
2093 SCTAB nViewTab
= pViewShell
->GetViewData()->GetTabNo();
2094 if ( nViewTab
!= aParam
.nTab
)
2095 pViewShell
->SetTabNo( aParam
.nTab
);
2101 void __EXPORT
ScUndoConsolidate::Repeat(SfxRepeatTarget
& /* rTarget */)
2105 BOOL __EXPORT
ScUndoConsolidate::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
2112 // Quell-Daten von Chart aendern
2115 void ScUndoChartData::Init()
2117 ScDocument
* pDoc
= pDocShell
->GetDocument();
2118 aOldRangeListRef
= new ScRangeList
;
2119 pDoc
->GetOldChartParameters( aChartName
, *aOldRangeListRef
, bOldColHeaders
, bOldRowHeaders
);
2122 ScUndoChartData::ScUndoChartData( ScDocShell
* pNewDocShell
, const String
& rName
,
2123 const ScRange
& rNew
, BOOL bColHdr
, BOOL bRowHdr
,
2125 ScSimpleUndo( pNewDocShell
),
2126 aChartName( rName
),
2127 bNewColHeaders( bColHdr
),
2128 bNewRowHeaders( bRowHdr
),
2131 aNewRangeListRef
= new ScRangeList
;
2132 aNewRangeListRef
->Append( rNew
);
2137 ScUndoChartData::ScUndoChartData( ScDocShell
* pNewDocShell
, const String
& rName
,
2138 const ScRangeListRef
& rNew
, BOOL bColHdr
, BOOL bRowHdr
,
2140 ScSimpleUndo( pNewDocShell
),
2141 aChartName( rName
),
2142 aNewRangeListRef( rNew
),
2143 bNewColHeaders( bColHdr
),
2144 bNewRowHeaders( bRowHdr
),
2150 __EXPORT
ScUndoChartData::~ScUndoChartData()
2154 String __EXPORT
ScUndoChartData::GetComment() const
2156 return ScGlobal::GetRscString( STR_UNDO_CHARTDATA
);
2159 void __EXPORT
ScUndoChartData::Undo()
2163 pDocShell
->GetDocument()->UpdateChartArea( aChartName
, aOldRangeListRef
,
2164 bOldColHeaders
, bOldRowHeaders
, FALSE
);
2169 void __EXPORT
ScUndoChartData::Redo()
2173 pDocShell
->GetDocument()->UpdateChartArea( aChartName
, aNewRangeListRef
,
2174 bNewColHeaders
, bNewRowHeaders
, bAddRange
);
2179 void __EXPORT
ScUndoChartData::Repeat(SfxRepeatTarget
& /* rTarget */)
2183 BOOL __EXPORT
ScUndoChartData::CanRepeat(SfxRepeatTarget
& /* rTarget */) const
2189 ScUndoDataForm::ScUndoDataForm( ScDocShell
* pNewDocShell
,
2190 SCCOL nStartX
, SCROW nStartY
, SCTAB nStartZ
,
2191 SCCOL nEndX
, SCROW nEndY
, SCTAB nEndZ
,
2192 const ScMarkData
& rMark
,
2193 ScDocument
* pNewUndoDoc
, ScDocument
* pNewRedoDoc
,
2195 ScRefUndoData
* pRefData
,
2196 void* /*pFill1*/, void* /*pFill2*/, void* /*pFill3*/,
2197 BOOL bRedoIsFilled
) :
2198 ScBlockUndo( pNewDocShell
, ScRange( nStartX
, nStartY
, nStartZ
, nEndX
, nEndY
, nEndZ
), SC_UNDO_SIMPLE
),
2200 pUndoDoc( pNewUndoDoc
),
2201 pRedoDoc( pNewRedoDoc
),
2202 nFlags( nNewFlags
),
2203 pRefUndoData( pRefData
),
2204 pRefRedoData( NULL
),
2205 bRedoFilled( bRedoIsFilled
)
2207 // pFill1,pFill2,pFill3 are there so the ctor calls for simple paste (without cutting)
2208 // don't have to be changed and branched for 641.
2209 // They can be removed later.
2211 if ( !aMarkData
.IsMarked() ) // no cell marked:
2212 aMarkData
.SetMarkArea( aBlockRange
); // mark paste block
2215 pRefUndoData
->DeleteUnchanged( pDocShell
->GetDocument() );
2220 ScUndoDataForm::~ScUndoDataForm()
2224 delete pRefUndoData
;
2225 delete pRefRedoData
;
2228 String
ScUndoDataForm::GetComment() const
2230 return ScGlobal::GetRscString( STR_UNDO_PASTE
);
2233 void ScUndoDataForm::SetChangeTrack()
2235 ScChangeTrack
* pChangeTrack
= pDocShell
->GetDocument()->GetChangeTrack();
2236 if ( pChangeTrack
&& (nFlags
& IDF_CONTENTS
) )
2237 pChangeTrack
->AppendContentRange( aBlockRange
, pUndoDoc
,
2238 nStartChangeAction
, nEndChangeAction
, SC_CACM_PASTE
);
2240 nStartChangeAction
= nEndChangeAction
= 0;
2244 void ScUndoDataForm::Undo()
2248 ShowTable( aBlockRange
);
2250 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED
) );
2253 void ScUndoDataForm::Redo()
2256 ScDocument
* pDoc
= pDocShell
->GetDocument();
2257 EnableDrawAdjust( pDoc
, FALSE
); //! include in ScBlockUndo?
2259 EnableDrawAdjust( pDoc
, TRUE
); //! include in ScBlockUndo?
2261 SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREALINKS_CHANGED
) );
2264 void ScUndoDataForm::Repeat(SfxRepeatTarget
& /*rTarget*/)
2268 BOOL
ScUndoDataForm::CanRepeat(SfxRepeatTarget
& rTarget
) const
2270 return (rTarget
.ISA(ScTabViewTarget
));
2273 void ScUndoDataForm::DoChange( const BOOL bUndo
)
2275 ScDocument
* pDoc
= pDocShell
->GetDocument();
2277 // RefUndoData for redo is created before first undo
2278 // (with DeleteUnchanged after the DoUndo call)
2279 BOOL bCreateRedoData
= ( bUndo
&& pRefUndoData
&& !pRefRedoData
);
2280 if ( bCreateRedoData
)
2281 pRefRedoData
= new ScRefUndoData( pDoc
);
2283 ScRefUndoData
* pWorkRefData
= bUndo
? pRefUndoData
: pRefRedoData
;
2285 // fuer Undo immer alle oder keine Inhalte sichern
2286 USHORT nUndoFlags
= IDF_NONE
;
2287 if (nFlags
& IDF_CONTENTS
)
2288 nUndoFlags
|= IDF_CONTENTS
;
2289 if (nFlags
& IDF_ATTRIB
)
2290 nUndoFlags
|= IDF_ATTRIB
;
2292 BOOL bPaintAll
= FALSE
;
2294 ScTabViewShell
* pViewShell
= ScTabViewShell::GetActiveViewShell();
2296 // marking is in ScBlockUndo...
2297 //ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockRange );
2299 SCTAB nTabCount
= pDoc
->GetTableCount();
2300 if ( bUndo
&& !bRedoFilled
)
2304 BOOL bColInfo
= ( aBlockRange
.aStart
.Row()==0 && aBlockRange
.aEnd
.Row()==MAXROW
);
2305 BOOL bRowInfo
= ( aBlockRange
.aStart
.Col()==0 && aBlockRange
.aEnd
.Col()==MAXCOL
);
2307 pRedoDoc
= new ScDocument( SCDOCMODE_UNDO
);
2308 pRedoDoc
->InitUndoSelected( pDoc
, aMarkData
, bColInfo
, bRowInfo
);
2310 // read "redo" data from the document in the first undo
2311 // all sheets - CopyToDocument skips those that don't exist in pRedoDoc
2312 ScRange aCopyRange
= aBlockRange
;
2313 aCopyRange
.aStart
.SetTab(0);
2314 aCopyRange
.aEnd
.SetTab(nTabCount
-1);
2315 pDoc
->CopyToDocument( aCopyRange
, 1, FALSE
, pRedoDoc
);
2319 USHORT nExtFlags
= 0;
2320 pDocShell
->UpdatePaintExt( nExtFlags
, aBlockRange
);
2322 for ( sal_uInt16 i
=0; i
<= ( aBlockRange
.aEnd
.Col() - aBlockRange
.aStart
.Col() ); i
++ )
2325 pUndoDoc
->GetString( aBlockRange
.aStart
.Col()+i
, aBlockRange
.aStart
.Row() , aBlockRange
.aStart
.Tab() , aOldString
);
2326 pDoc
->SetString( aBlockRange
.aStart
.Col()+i
, aBlockRange
.aStart
.Row() , aBlockRange
.aStart
.Tab() , aOldString
);
2329 //ScRange aTabSelectRange = aBlockRange;
2333 pWorkRefData
->DoUndo( pDoc
, TRUE
); // TRUE = bSetChartRangeLists for SetChartListenerCollection
2334 if ( pDoc
->RefreshAutoFilter( 0,0, MAXCOL
,MAXROW
, aBlockRange
.aStart
.Tab() ) )
2338 if ( bCreateRedoData
&& pRefRedoData
)
2339 pRefRedoData
->DeleteUnchanged( pDoc
);
2343 ScChangeTrack
* pChangeTrack
= pDoc
->GetChangeTrack();
2345 pChangeTrack
->Undo( nStartChangeAction
, nEndChangeAction
);
2350 ScRange
aDrawRange( aBlockRange
);
2351 pDoc
->ExtendMerge( aDrawRange
, TRUE
); // only needed for single sheet (text/rtf etc.)
2352 USHORT nPaint
= PAINT_GRID
;
2355 aDrawRange
.aStart
.SetCol(0);
2356 aDrawRange
.aStart
.SetRow(0);
2357 aDrawRange
.aEnd
.SetCol(MAXCOL
);
2358 aDrawRange
.aEnd
.SetRow(MAXROW
);
2359 nPaint
|= PAINT_TOP
| PAINT_LEFT
;
2360 /*A*/ if (pViewShell
)
2361 pViewShell
->AdjustBlockHeight(FALSE
);
2365 if ( aBlockRange
.aStart
.Row() == 0 && aBlockRange
.aEnd
.Row() == MAXROW
) // ganze Spalte
2367 nPaint
|= PAINT_TOP
;
2368 aDrawRange
.aEnd
.SetCol(MAXCOL
);
2370 if ( aBlockRange
.aStart
.Col() == 0 && aBlockRange
.aEnd
.Col() == MAXCOL
) // ganze Zeile
2372 nPaint
|= PAINT_LEFT
;
2373 aDrawRange
.aEnd
.SetRow(MAXROW
);
2375 /*A*/ if ((pViewShell
) && pViewShell
->AdjustBlockHeight(FALSE
))
2377 aDrawRange
.aStart
.SetCol(0);
2378 aDrawRange
.aStart
.SetRow(0);
2379 aDrawRange
.aEnd
.SetCol(MAXCOL
);
2380 aDrawRange
.aEnd
.SetRow(MAXROW
);
2381 nPaint
|= PAINT_LEFT
;
2383 pDocShell
->UpdatePaintExt( nExtFlags
, aDrawRange
);
2386 if ( !bUndo
) // draw redo after updating row heights
2387 RedoSdrUndoAction( pDrawUndo
); //! include in ScBlockUndo?
2389 pDocShell
->PostPaint( aDrawRange
, nPaint
, nExtFlags
);
2391 pDocShell
->PostDataChanged();
2393 pViewShell
->CellContentChanged();