xref: /trunk/main/sc/source/ui/undo/undodat.cxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sc.hxx"
30 
31 // INCLUDE ---------------------------------------------------------------
32 
33 #include <sfx2/app.hxx>
34 
35 #include "undodat.hxx"
36 #include "undoutil.hxx"
37 #include "undoolk.hxx"
38 #include "document.hxx"
39 #include "docsh.hxx"
40 #include "tabvwsh.hxx"
41 #include "olinetab.hxx"
42 #include "dbcolect.hxx"
43 #include "rangenam.hxx"
44 #include "pivot.hxx"
45 #include "globstr.hrc"
46 #include "global.hxx"
47 #include "target.hxx"
48 #include "chartarr.hxx"
49 #include "dbdocfun.hxx"
50 #include "olinefun.hxx"
51 #include "dpobject.hxx"
52 #include "attrib.hxx"
53 #include "hints.hxx"
54 #include "sc.hrc"
55 
56 // -----------------------------------------------------------------------
57 
58 TYPEINIT1(ScUndoDoOutline,          ScSimpleUndo);
59 TYPEINIT1(ScUndoMakeOutline,        ScSimpleUndo);
60 TYPEINIT1(ScUndoOutlineLevel,       ScSimpleUndo);
61 TYPEINIT1(ScUndoOutlineBlock,       ScSimpleUndo);
62 TYPEINIT1(ScUndoRemoveAllOutlines,  ScSimpleUndo);
63 TYPEINIT1(ScUndoAutoOutline,        ScSimpleUndo);
64 TYPEINIT1(ScUndoSubTotals,          ScDBFuncUndo);
65 TYPEINIT1(ScUndoSort,               ScDBFuncUndo);
66 TYPEINIT1(ScUndoQuery,              ScDBFuncUndo);
67 TYPEINIT1(ScUndoAutoFilter,         ScDBFuncUndo);
68 TYPEINIT1(ScUndoDBData,             ScSimpleUndo);
69 TYPEINIT1(ScUndoImportData,         ScSimpleUndo);
70 TYPEINIT1(ScUndoRepeatDB,           ScSimpleUndo);
71 //UNUSED2008-05  TYPEINIT1(ScUndoPivot,              ScSimpleUndo);
72 TYPEINIT1(ScUndoDataPilot,          ScSimpleUndo);
73 TYPEINIT1(ScUndoConsolidate,        ScSimpleUndo);
74 TYPEINIT1(ScUndoChartData,          ScSimpleUndo);
75 
76 // -----------------------------------------------------------------------
77 
78 
79 //
80 //      Outline-Gruppen ein- oder ausblenden
81 //
82 
83 ScUndoDoOutline::ScUndoDoOutline( ScDocShell* pNewDocShell,
84                             SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
85                             ScDocument* pNewUndoDoc, sal_Bool bNewColumns,
86                             sal_uInt16 nNewLevel, sal_uInt16 nNewEntry, sal_Bool bNewShow ) :
87     ScSimpleUndo( pNewDocShell ),
88     nStart( nNewStart ),
89     nEnd( nNewEnd ),
90     nTab( nNewTab ),
91     pUndoDoc( pNewUndoDoc ),
92     bColumns( bNewColumns ),
93     nLevel( nNewLevel ),
94     nEntry( nNewEntry ),
95     bShow( bNewShow )
96 {
97 }
98 
99 __EXPORT ScUndoDoOutline::~ScUndoDoOutline()
100 {
101     delete pUndoDoc;
102 }
103 
104 String __EXPORT ScUndoDoOutline::GetComment() const
105 {   // Detail einblenden" "Detail ausblenden"
106     return bShow ?
107         ScGlobal::GetRscString( STR_UNDO_DOOUTLINE ) :
108         ScGlobal::GetRscString( STR_UNDO_REDOOUTLINE );
109 }
110 
111 void __EXPORT ScUndoDoOutline::Undo()
112 {
113     BeginUndo();
114 
115     ScDocument* pDoc = pDocShell->GetDocument();
116     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
117 
118     //  Tabelle muss vorher umgeschaltet sein (#46952#) !!!
119 
120     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
121     if ( nVisTab != nTab )
122         pViewShell->SetTabNo( nTab );
123 
124     //  inverse Funktion ausfuehren
125 
126     if (bShow)
127         pViewShell->HideOutline( bColumns, nLevel, nEntry, sal_False, sal_False );
128     else
129         pViewShell->ShowOutline( bColumns, nLevel, nEntry, sal_False, sal_False );
130 
131     //  Original Spalten-/Zeilenstatus
132 
133     if (bColumns)
134         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
135                 static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, sal_False, pDoc);
136     else
137         pUndoDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, sal_False, pDoc );
138 
139     pViewShell->UpdateScrollBars();
140 
141     pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP);
142 
143     EndUndo();
144 }
145 
146 void __EXPORT ScUndoDoOutline::Redo()
147 {
148     BeginRedo();
149 
150     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
151 
152     //  Tabelle muss vorher umgeschaltet sein (#46952#) !!!
153 
154     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
155     if ( nVisTab != nTab )
156         pViewShell->SetTabNo( nTab );
157 
158     if (bShow)
159         pViewShell->ShowOutline( bColumns, nLevel, nEntry, sal_False );
160     else
161         pViewShell->HideOutline( bColumns, nLevel, nEntry, sal_False );
162 
163     EndRedo();
164 }
165 
166 void __EXPORT ScUndoDoOutline::Repeat(SfxRepeatTarget& /* rTarget */)
167 {
168 }
169 
170 sal_Bool __EXPORT ScUndoDoOutline::CanRepeat(SfxRepeatTarget& /* rTarget */) const
171 {
172     return sal_False;                       // geht nicht
173 }
174 
175 //
176 //      Outline-Gruppen erzeugen oder loeschen
177 //
178 
179 ScUndoMakeOutline::ScUndoMakeOutline( ScDocShell* pNewDocShell,
180                             SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
181                             SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
182                             ScOutlineTable* pNewUndoTab, sal_Bool bNewColumns, sal_Bool bNewMake ) :
183     ScSimpleUndo( pNewDocShell ),
184     aBlockStart( nStartX, nStartY, nStartZ ),
185     aBlockEnd( nEndX, nEndY, nEndZ ),
186     pUndoTable( pNewUndoTab ),
187     bColumns( bNewColumns ),
188     bMake( bNewMake )
189 {
190 }
191 
192 __EXPORT ScUndoMakeOutline::~ScUndoMakeOutline()
193 {
194     delete pUndoTable;
195 }
196 
197 String __EXPORT ScUndoMakeOutline::GetComment() const
198 {   // "Gruppierung" "Gruppierung aufheben"
199     return bMake ?
200         ScGlobal::GetRscString( STR_UNDO_MAKEOUTLINE ) :
201         ScGlobal::GetRscString( STR_UNDO_REMAKEOUTLINE );
202 }
203 
204 void __EXPORT ScUndoMakeOutline::Undo()
205 {
206     BeginUndo();
207 
208     ScDocument* pDoc = pDocShell->GetDocument();
209     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
210     SCTAB nTab = aBlockStart.Tab();
211 
212     ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
213 
214     pDoc->SetOutlineTable( nTab, pUndoTable );
215 
216     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
217     if ( nVisTab != nTab )
218         pViewShell->SetTabNo( nTab );
219 
220     pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
221 
222     EndUndo();
223 }
224 
225 void __EXPORT ScUndoMakeOutline::Redo()
226 {
227     BeginRedo();
228 
229     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
230 
231     ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
232 
233     if (bMake)
234         pViewShell->MakeOutline( bColumns, sal_False );
235     else
236         pViewShell->RemoveOutline( bColumns, sal_False );
237 
238     pDocShell->PostPaint(0,0,aBlockStart.Tab(),MAXCOL,MAXROW,aBlockEnd.Tab(),PAINT_GRID);
239 
240     EndRedo();
241 }
242 
243 void __EXPORT ScUndoMakeOutline::Repeat(SfxRepeatTarget& rTarget)
244 {
245     if (rTarget.ISA(ScTabViewTarget))
246     {
247         ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
248 
249         if (bMake)
250             rViewShell.MakeOutline( bColumns, sal_True );
251         else
252             rViewShell.RemoveOutline( bColumns, sal_True );
253     }
254 }
255 
256 sal_Bool __EXPORT ScUndoMakeOutline::CanRepeat(SfxRepeatTarget& rTarget) const
257 {
258     return (rTarget.ISA(ScTabViewTarget));
259 }
260 
261 //
262 //      Outline-Ebene auswaehlen
263 //
264 
265 ScUndoOutlineLevel::ScUndoOutlineLevel( ScDocShell* pNewDocShell,
266                         SCCOLROW nNewStart, SCCOLROW nNewEnd, SCTAB nNewTab,
267                         ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
268                         sal_Bool bNewColumns, sal_uInt16 nNewLevel ) :
269     ScSimpleUndo( pNewDocShell ),
270     nStart( nNewStart ),
271     nEnd( nNewEnd ),
272     nTab( nNewTab ),
273     pUndoDoc( pNewUndoDoc ),
274     pUndoTable( pNewUndoTab ),
275     bColumns( bNewColumns ),
276     nLevel( nNewLevel )
277 {
278 }
279 
280 __EXPORT ScUndoOutlineLevel::~ScUndoOutlineLevel()
281 {
282     delete pUndoDoc;
283     delete pUndoTable;
284 }
285 
286 String __EXPORT ScUndoOutlineLevel::GetComment() const
287 {   // "Gliederungsebene auswaehlen";
288     return ScGlobal::GetRscString( STR_UNDO_OUTLINELEVEL );
289 }
290 
291 void __EXPORT ScUndoOutlineLevel::Undo()
292 {
293     BeginUndo();
294 
295     ScDocument* pDoc = pDocShell->GetDocument();
296     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
297 
298     //  Original Outline-Table
299 
300     pDoc->SetOutlineTable( nTab, pUndoTable );
301 
302     //  Original Spalten-/Zeilenstatus
303 
304     if (bColumns)
305         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStart), 0, nTab,
306                 static_cast<SCCOL>(nEnd), MAXROW, nTab, IDF_NONE, sal_False, pDoc);
307     else
308         pUndoDoc->CopyToDocument( 0, nStart, nTab, MAXCOL, nEnd, nTab, IDF_NONE, sal_False, pDoc );
309 
310     pDoc->UpdatePageBreaks( nTab );
311 
312     pViewShell->UpdateScrollBars();
313 
314     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
315     if ( nVisTab != nTab )
316         pViewShell->SetTabNo( nTab );
317 
318     pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP);
319 
320     EndUndo();
321 }
322 
323 void __EXPORT ScUndoOutlineLevel::Redo()
324 {
325     BeginRedo();
326 
327     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
328 
329     //  Tabelle muss vorher umgeschaltet sein (#46952#) !!!
330 
331     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
332     if ( nVisTab != nTab )
333         pViewShell->SetTabNo( nTab );
334 
335     pViewShell->SelectLevel( bColumns, nLevel, sal_False );
336 
337     EndRedo();
338 }
339 
340 void __EXPORT ScUndoOutlineLevel::Repeat(SfxRepeatTarget& rTarget)
341 {
342     if (rTarget.ISA(ScTabViewTarget))
343         ((ScTabViewTarget&)rTarget).GetViewShell()->SelectLevel( bColumns, nLevel, sal_True );
344 }
345 
346 sal_Bool __EXPORT ScUndoOutlineLevel::CanRepeat(SfxRepeatTarget& rTarget) const
347 {
348     return (rTarget.ISA(ScTabViewTarget));
349 }
350 
351 //
352 //      Outline ueber Blockmarken ein- oder ausblenden
353 //
354 
355 ScUndoOutlineBlock::ScUndoOutlineBlock( ScDocShell* pNewDocShell,
356                         SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
357                         SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
358                         ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab, sal_Bool bNewShow ) :
359     ScSimpleUndo( pNewDocShell ),
360     aBlockStart( nStartX, nStartY, nStartZ ),
361     aBlockEnd( nEndX, nEndY, nEndZ ),
362     pUndoDoc( pNewUndoDoc ),
363     pUndoTable( pNewUndoTab ),
364     bShow( bNewShow )
365 {
366 }
367 
368 __EXPORT ScUndoOutlineBlock::~ScUndoOutlineBlock()
369 {
370     delete pUndoDoc;
371     delete pUndoTable;
372 }
373 
374 String __EXPORT ScUndoOutlineBlock::GetComment() const
375 {   // "Detail einblenden" "Detail ausblenden"
376     return bShow ?
377         ScGlobal::GetRscString( STR_UNDO_DOOUTLINEBLK ) :
378         ScGlobal::GetRscString( STR_UNDO_REDOOUTLINEBLK );
379 }
380 
381 void __EXPORT ScUndoOutlineBlock::Undo()
382 {
383     BeginUndo();
384 
385     ScDocument* pDoc = pDocShell->GetDocument();
386     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
387     SCTAB nTab = aBlockStart.Tab();
388 
389     //  Original Outline-Table
390 
391     pDoc->SetOutlineTable( nTab, pUndoTable );
392 
393     //  Original Spalten-/Zeilenstatus
394 
395     SCCOLROW    nStartCol = aBlockStart.Col();
396     SCCOLROW    nEndCol = aBlockEnd.Col();
397     SCCOLROW    nStartRow = aBlockStart.Row();
398     SCCOLROW    nEndRow = aBlockEnd.Row();
399 
400     if (!bShow)
401     {                               //  Groesse des ausgeblendeten Blocks
402         sal_uInt16 nLevel;
403         pUndoTable->GetColArray()->FindTouchedLevel( nStartCol, nEndCol, nLevel );
404         pUndoTable->GetColArray()->ExtendBlock( nLevel, nStartCol, nEndCol );
405         pUndoTable->GetRowArray()->FindTouchedLevel( nStartRow, nEndRow, nLevel );
406         pUndoTable->GetRowArray()->ExtendBlock( nLevel, nStartRow, nEndRow );
407     }
408 
409     pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
410             static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, sal_False, pDoc );
411     pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
412 
413     pDoc->UpdatePageBreaks( nTab );
414 
415     pViewShell->UpdateScrollBars();
416 
417     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
418     if ( nVisTab != nTab )
419         pViewShell->SetTabNo( nTab );
420 
421     pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP);
422 
423     EndUndo();
424 }
425 
426 void __EXPORT ScUndoOutlineBlock::Redo()
427 {
428     BeginRedo();
429 
430     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
431 
432     ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart, aBlockEnd );
433     if (bShow)
434         pViewShell->ShowMarkedOutlines( sal_False );
435     else
436         pViewShell->HideMarkedOutlines( sal_False );
437 
438     EndRedo();
439 }
440 
441 void __EXPORT ScUndoOutlineBlock::Repeat(SfxRepeatTarget& rTarget)
442 {
443     if (rTarget.ISA(ScTabViewTarget))
444     {
445         ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
446 
447         if (bShow)
448             rViewShell.ShowMarkedOutlines( sal_True );
449         else
450             rViewShell.HideMarkedOutlines( sal_True );
451     }
452 }
453 
454 sal_Bool __EXPORT ScUndoOutlineBlock::CanRepeat(SfxRepeatTarget& rTarget) const
455 {
456     return (rTarget.ISA(ScTabViewTarget));
457 }
458 
459 //
460 //      alle Outlines loeschen
461 //
462 
463 ScUndoRemoveAllOutlines::ScUndoRemoveAllOutlines( ScDocShell* pNewDocShell,
464                                     SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
465                                     SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
466                                     ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) :
467     ScSimpleUndo( pNewDocShell ),
468     aBlockStart( nStartX, nStartY, nStartZ ),
469     aBlockEnd( nEndX, nEndY, nEndZ ),
470     pUndoDoc( pNewUndoDoc ),
471     pUndoTable( pNewUndoTab )
472 {
473 }
474 
475 __EXPORT ScUndoRemoveAllOutlines::~ScUndoRemoveAllOutlines()
476 {
477     delete pUndoDoc;
478     delete pUndoTable;
479 }
480 
481 String __EXPORT ScUndoRemoveAllOutlines::GetComment() const
482 {   // "Gliederung entfernen"
483     return ScGlobal::GetRscString( STR_UNDO_REMOVEALLOTLNS );
484 }
485 
486 void __EXPORT ScUndoRemoveAllOutlines::Undo()
487 {
488     BeginUndo();
489 
490     ScDocument* pDoc = pDocShell->GetDocument();
491     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
492     SCTAB nTab = aBlockStart.Tab();
493 
494     //  Original Outline-Table
495 
496     pDoc->SetOutlineTable( nTab, pUndoTable );
497 
498     //  Original Spalten-/Zeilenstatus
499 
500     SCCOL   nStartCol = aBlockStart.Col();
501     SCCOL   nEndCol = aBlockEnd.Col();
502     SCROW   nStartRow = aBlockStart.Row();
503     SCROW   nEndRow = aBlockEnd.Row();
504 
505     pUndoDoc->CopyToDocument( nStartCol, 0, nTab, nEndCol, MAXROW, nTab, IDF_NONE, sal_False, pDoc );
506     pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
507 
508     pDoc->UpdatePageBreaks( nTab );
509 
510     pViewShell->UpdateScrollBars();
511 
512     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
513     if ( nVisTab != nTab )
514         pViewShell->SetTabNo( nTab );
515 
516     pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
517 
518     EndUndo();
519 }
520 
521 void __EXPORT ScUndoRemoveAllOutlines::Redo()
522 {
523     BeginRedo();
524 
525     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
526 
527     //  Tabelle muss vorher umgeschaltet sein (#46952#) !!!
528 
529     SCTAB nTab = aBlockStart.Tab();
530     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
531     if ( nVisTab != nTab )
532         pViewShell->SetTabNo( nTab );
533 
534     pViewShell->RemoveAllOutlines( sal_False );
535 
536     EndRedo();
537 }
538 
539 void __EXPORT ScUndoRemoveAllOutlines::Repeat(SfxRepeatTarget& rTarget)
540 {
541     if (rTarget.ISA(ScTabViewTarget))
542         ((ScTabViewTarget&)rTarget).GetViewShell()->RemoveAllOutlines( sal_True );
543 }
544 
545 sal_Bool __EXPORT ScUndoRemoveAllOutlines::CanRepeat(SfxRepeatTarget& rTarget) const
546 {
547     return (rTarget.ISA(ScTabViewTarget));
548 }
549 
550 //
551 //      Auto-Outline
552 //
553 
554 ScUndoAutoOutline::ScUndoAutoOutline( ScDocShell* pNewDocShell,
555                                     SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
556                                     SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
557                                     ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab ) :
558     ScSimpleUndo( pNewDocShell ),
559     aBlockStart( nStartX, nStartY, nStartZ ),
560     aBlockEnd( nEndX, nEndY, nEndZ ),
561     pUndoDoc( pNewUndoDoc ),
562     pUndoTable( pNewUndoTab )
563 {
564 }
565 
566 __EXPORT ScUndoAutoOutline::~ScUndoAutoOutline()
567 {
568     delete pUndoDoc;
569     delete pUndoTable;
570 }
571 
572 String __EXPORT ScUndoAutoOutline::GetComment() const
573 {   // "Auto-Gliederung"
574     return ScGlobal::GetRscString( STR_UNDO_AUTOOUTLINE );
575 }
576 
577 void __EXPORT ScUndoAutoOutline::Undo()
578 {
579     BeginUndo();
580 
581     ScDocument* pDoc = pDocShell->GetDocument();
582     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
583     SCTAB nTab = aBlockStart.Tab();
584 
585     //  Original Outline-Table
586 
587     pDoc->SetOutlineTable( nTab, pUndoTable );
588 
589     //  Original Spalten-/Zeilenstatus
590 
591     if (pUndoDoc && pUndoTable)
592     {
593         SCCOLROW nStartCol;
594         SCCOLROW nStartRow;
595         SCCOLROW nEndCol;
596         SCCOLROW nEndRow;
597         pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol );
598         pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow );
599 
600         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
601                 static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, sal_False,
602                 pDoc);
603         pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
604 
605         pViewShell->UpdateScrollBars();
606     }
607 
608     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
609     if ( nVisTab != nTab )
610         pViewShell->SetTabNo( nTab );
611 
612     pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
613 
614     EndUndo();
615 }
616 
617 void __EXPORT ScUndoAutoOutline::Redo()
618 {
619     BeginRedo();
620 
621     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
622 
623     SCTAB nTab = aBlockStart.Tab();
624     if (pViewShell)
625     {
626         //  Tabelle muss vorher umgeschaltet sein (#46952#) !!!
627 
628         SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
629         if ( nVisTab != nTab )
630             pViewShell->SetTabNo( nTab );
631     }
632 
633     ScRange aRange( aBlockStart.Col(), aBlockStart.Row(), nTab,
634                     aBlockEnd.Col(),   aBlockEnd.Row(),   nTab );
635     ScOutlineDocFunc aFunc( *pDocShell );
636     aFunc.AutoOutline( aRange, sal_False, sal_False );
637 
638     //  auf der View markieren
639     //  Wenn's beim Aufruf eine Mehrfachselektion war, ist es jetzt der
640     //  umschliessende Bereich...
641 
642     if (pViewShell)
643         pViewShell->MarkRange( aRange );
644 
645     EndRedo();
646 }
647 
648 void __EXPORT ScUndoAutoOutline::Repeat(SfxRepeatTarget& rTarget)
649 {
650     if (rTarget.ISA(ScTabViewTarget))
651         ((ScTabViewTarget&)rTarget).GetViewShell()->AutoOutline( sal_True );
652 }
653 
654 sal_Bool __EXPORT ScUndoAutoOutline::CanRepeat(SfxRepeatTarget& rTarget) const
655 {
656     return (rTarget.ISA(ScTabViewTarget));
657 }
658 
659 //
660 //      Zwischenergebnisse
661 //
662 
663 ScUndoSubTotals::ScUndoSubTotals( ScDocShell* pNewDocShell, SCTAB nNewTab,
664                                 const ScSubTotalParam& rNewParam, SCROW nNewEndY,
665                                 ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
666                                 ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB ) :
667     ScDBFuncUndo( pNewDocShell, ScRange( rNewParam.nCol1, rNewParam.nRow1, nNewTab,
668                                          rNewParam.nCol2, rNewParam.nRow2, nNewTab ) ),
669     nTab( nNewTab ),
670     aParam( rNewParam ),
671     nNewEndRow( nNewEndY ),
672     pUndoDoc( pNewUndoDoc ),
673     pUndoTable( pNewUndoTab ),
674     pUndoRange( pNewUndoRange ),
675     pUndoDB( pNewUndoDB )
676 {
677 }
678 
679 __EXPORT ScUndoSubTotals::~ScUndoSubTotals()
680 {
681     delete pUndoDoc;
682     delete pUndoTable;
683     delete pUndoRange;
684     delete pUndoDB;
685 }
686 
687 String __EXPORT ScUndoSubTotals::GetComment() const
688 {   // "Teilergebnisse"
689     return ScGlobal::GetRscString( STR_UNDO_SUBTOTALS );
690 }
691 
692 void __EXPORT ScUndoSubTotals::Undo()
693 {
694     BeginUndo();
695 
696     ScDocument* pDoc = pDocShell->GetDocument();
697     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
698 
699     //  um einzelnen DB-Bereich anzupassen
700 /*  ScDBData* pOldDBData = ScUndoUtil::GetOldDBData( pUndoDBData, pDoc, nTab,
701                                         aParam.nCol1, aParam.nRow1, aParam.nCol2, nNewEndRow );
702 */
703 
704     if (nNewEndRow > aParam.nRow2)
705     {
706         pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aParam.nRow2+1, static_cast<SCSIZE>(nNewEndRow-aParam.nRow2) );
707     }
708     else if (nNewEndRow < aParam.nRow2)
709     {
710         pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nNewEndRow+1, static_cast<SCSIZE>(aParam.nRow2-nNewEndRow) );
711     }
712 
713 
714     //  Original Outline-Table
715 
716     pDoc->SetOutlineTable( nTab, pUndoTable );
717 
718     //  Original Spalten-/Zeilenstatus
719 
720     if (pUndoDoc && pUndoTable)
721     {
722         SCCOLROW nStartCol;
723         SCCOLROW nStartRow;
724         SCCOLROW nEndCol;
725         SCCOLROW nEndRow;
726         pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol );
727         pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow );
728 
729         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
730                 static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, sal_False,
731                 pDoc);
732         pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
733 
734         pViewShell->UpdateScrollBars();
735     }
736 
737     //  Original-Daten & Referenzen
738 
739     ScUndoUtil::MarkSimpleBlock( pDocShell, 0, aParam.nRow1+1, nTab,
740                                             MAXCOL, aParam.nRow2, nTab );
741 
742     pDoc->DeleteAreaTab( 0,aParam.nRow1+1, MAXCOL,aParam.nRow2, nTab, IDF_ALL );
743 
744     pUndoDoc->CopyToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
745                                                             IDF_NONE, sal_False, pDoc );    // Flags
746     pUndoDoc->UndoToDocument( 0, aParam.nRow1+1, nTab, MAXCOL, aParam.nRow2, nTab,
747                                                             IDF_ALL, sal_False, pDoc );
748 
749     ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab,
750                                             aParam.nCol2,aParam.nRow2,nTab );
751 
752 /*  if (pUndoDBData)
753         *pOldDBData = *pUndoDBData;
754 */
755     if (pUndoRange)
756         pDoc->SetRangeName( new ScRangeName( *pUndoRange ) );
757     if (pUndoDB)
758         pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), sal_True );
759 
760     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
761     if ( nVisTab != nTab )
762         pViewShell->SetTabNo( nTab );
763 
764     pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
765     pDocShell->PostDataChanged();
766 
767     EndUndo();
768 }
769 
770 void __EXPORT ScUndoSubTotals::Redo()
771 {
772     BeginRedo();
773 
774     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
775 
776     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
777     if ( nVisTab != nTab )
778         pViewShell->SetTabNo( nTab );
779 
780     ScUndoUtil::MarkSimpleBlock( pDocShell, aParam.nCol1,aParam.nRow1,nTab,
781                                             aParam.nCol2,aParam.nRow2,nTab );
782     pViewShell->DoSubTotals( aParam, sal_False );
783 
784     EndRedo();
785 }
786 
787 void __EXPORT ScUndoSubTotals::Repeat(SfxRepeatTarget& /* rTarget */)
788 {
789 }
790 
791 sal_Bool __EXPORT ScUndoSubTotals::CanRepeat(SfxRepeatTarget& /* rTarget */) const
792 {
793     return sal_False;                       // geht nicht wegen Spaltennummern
794 }
795 
796 //
797 //      Sortieren
798 //
799 
800 ScUndoSort::ScUndoSort( ScDocShell* pNewDocShell,
801                         SCTAB nNewTab, const ScSortParam& rParam,
802                         sal_Bool bQuery, ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB,
803                         const ScRange* pDest ) :
804     ScDBFuncUndo( pNewDocShell, ScRange( rParam.nCol1, rParam.nRow1, nNewTab,
805                                          rParam.nCol2, rParam.nRow2, nNewTab ) ),
806     nTab( nNewTab ),
807     aSortParam( rParam ),
808     bRepeatQuery( bQuery ),
809     pUndoDoc( pNewUndoDoc ),
810     pUndoDB( pNewUndoDB ),
811     bDestArea( sal_False )
812 {
813     if ( pDest )
814     {
815         bDestArea = sal_True;
816         aDestRange = *pDest;
817     }
818 }
819 
820 __EXPORT ScUndoSort::~ScUndoSort()
821 {
822     delete pUndoDoc;
823     delete pUndoDB;
824 }
825 
826 String __EXPORT ScUndoSort::GetComment() const
827 {
828     return ScGlobal::GetRscString( STR_UNDO_SORT );
829 }
830 
831 void __EXPORT ScUndoSort::Undo()
832 {
833     BeginUndo();
834 
835     ScDocument* pDoc = pDocShell->GetDocument();
836     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
837 
838     SCCOL nStartCol = aSortParam.nCol1;
839     SCROW nStartRow = aSortParam.nRow1;
840     SCCOL nEndCol    = aSortParam.nCol2;
841     SCROW nEndRow    = aSortParam.nRow2;
842     SCTAB nSortTab  = nTab;
843     if ( !aSortParam.bInplace )
844     {
845         nStartCol = aSortParam.nDestCol;
846         nStartRow = aSortParam.nDestRow;
847         nEndCol   = nStartCol + ( aSortParam.nCol2 - aSortParam.nCol1 );
848         nEndRow   = nStartRow + ( aSortParam.nRow2 - aSortParam.nRow1 );
849         nSortTab  = aSortParam.nDestTab;
850     }
851 
852     ScUndoUtil::MarkSimpleBlock( pDocShell, nStartCol, nStartRow, nSortTab,
853                                  nEndCol, nEndRow, nSortTab );
854 
855     // do not delete/copy note captions, they are handled in drawing undo (ScDBFuncUndo::mpDrawUndo)
856     pDoc->DeleteAreaTab( nStartCol,nStartRow, nEndCol,nEndRow, nSortTab, IDF_ALL|IDF_NOCAPTIONS );
857     pUndoDoc->CopyToDocument( nStartCol, nStartRow, nSortTab, nEndCol, nEndRow, nSortTab,
858                                 IDF_ALL|IDF_NOCAPTIONS, sal_False, pDoc );
859 
860     if (bDestArea)
861     {
862         // do not delete/copy note captions, they are handled in drawing undo (ScDBFuncUndo::mpDrawUndo)
863         pDoc->DeleteAreaTab( aDestRange, IDF_ALL|IDF_NOCAPTIONS );
864         pUndoDoc->CopyToDocument( aDestRange, IDF_ALL|IDF_NOCAPTIONS, sal_False, pDoc );
865     }
866 
867     //  Zeilenhoehen immer (wegen automatischer Anpassung)
868     //! auf ScBlockUndo umstellen
869 //  if (bRepeatQuery)
870         pUndoDoc->CopyToDocument( 0, nStartRow, nSortTab, MAXCOL, nEndRow, nSortTab,
871                                 IDF_NONE, sal_False, pDoc );
872 
873     if (pUndoDB)
874         pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), sal_True );
875 
876     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
877     if ( nVisTab != nSortTab )
878         pViewShell->SetTabNo( nSortTab );
879 
880     pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
881     pDocShell->PostDataChanged();
882 
883     EndUndo();
884 }
885 
886 void __EXPORT ScUndoSort::Redo()
887 {
888     BeginRedo();
889 
890     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
891 
892     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
893     if ( nVisTab != nTab )
894         pViewShell->SetTabNo( nTab );
895 
896 //  pViewShell->DoneBlockMode();
897 //  pViewShell->InitOwnBlockMode();
898 //  pViewShell->GetViewData()->GetMarkData() = aMarkData;   // CopyMarksTo
899 
900     pViewShell->MarkRange( ScRange( aSortParam.nCol1, aSortParam.nRow1, nTab,
901                                       aSortParam.nCol2, aSortParam.nRow2, nTab ) );
902 
903     pViewShell->Sort( aSortParam, sal_False );
904 
905     //  Quellbereich painten wegen Markierung
906     if ( !aSortParam.bInplace )
907         pDocShell->PostPaint( aSortParam.nCol1, aSortParam.nRow1, nTab,
908                               aSortParam.nCol2, aSortParam.nRow2, nTab, PAINT_GRID );
909 
910     EndRedo();
911 }
912 
913 void __EXPORT ScUndoSort::Repeat(SfxRepeatTarget& /* rTarget */)
914 {
915 }
916 
917 sal_Bool __EXPORT ScUndoSort::CanRepeat(SfxRepeatTarget& /* rTarget */) const
918 {
919     return sal_False;                       // geht nicht wegen Spaltennummern
920 }
921 
922 //
923 //      Filtern
924 //
925 
926 ScUndoQuery::ScUndoQuery( ScDocShell* pNewDocShell, SCTAB nNewTab, const ScQueryParam& rParam,
927                             ScDocument* pNewUndoDoc, ScDBCollection* pNewUndoDB,
928                             const ScRange* pOld, sal_Bool bSize, const ScRange* pAdvSrc ) :
929     ScDBFuncUndo( pNewDocShell, ScRange( rParam.nCol1, rParam.nRow1, nNewTab,
930                                          rParam.nCol2, rParam.nRow2, nNewTab ) ),
931     pDrawUndo( NULL ),
932     nTab( nNewTab ),
933     aQueryParam( rParam ),
934     pUndoDoc( pNewUndoDoc ),
935 //  pUndoDBData( pNewData )
936     pUndoDB( pNewUndoDB ),
937     bIsAdvanced( sal_False ),
938     bDestArea( sal_False ),
939     bDoSize( bSize )
940 {
941     if ( pOld )
942     {
943         bDestArea = sal_True;
944         aOldDest = *pOld;
945     }
946     if ( pAdvSrc )
947     {
948         bIsAdvanced = sal_True;
949         aAdvSource = *pAdvSrc;
950     }
951 
952     pDrawUndo = GetSdrUndoAction( pDocShell->GetDocument() );
953 }
954 
955 __EXPORT ScUndoQuery::~ScUndoQuery()
956 {
957     delete pUndoDoc;
958 //  delete pUndoDBData;
959     delete pUndoDB;
960     DeleteSdrUndoAction( pDrawUndo );
961 }
962 
963 String __EXPORT ScUndoQuery::GetComment() const
964 {   // "Filtern";
965     return ScGlobal::GetRscString( STR_UNDO_QUERY );
966 }
967 
968 void __EXPORT ScUndoQuery::Undo()
969 {
970     BeginUndo();
971 
972     ScDocument* pDoc = pDocShell->GetDocument();
973     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
974 
975     sal_Bool bCopy = !aQueryParam.bInplace;
976     SCCOL nDestEndCol = 0;
977     SCROW nDestEndRow = 0;
978     if (bCopy)
979     {
980         nDestEndCol = aQueryParam.nDestCol + ( aQueryParam.nCol2-aQueryParam.nCol1 );
981         nDestEndRow = aQueryParam.nDestRow + ( aQueryParam.nRow2-aQueryParam.nRow1 );
982 
983         ScDBData* pData = pDoc->GetDBAtCursor( aQueryParam.nDestCol, aQueryParam.nDestRow,
984                                                 aQueryParam.nDestTab, sal_True );
985         if (pData)
986         {
987             ScRange aNewDest;
988             pData->GetArea( aNewDest );
989             nDestEndCol = aNewDest.aEnd.Col();
990             nDestEndRow = aNewDest.aEnd.Row();
991         }
992 
993         if ( bDoSize && bDestArea )
994         {
995             //  aDestRange ist der alte Bereich
996             pDoc->FitBlock( ScRange(
997                                 aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
998                                 nDestEndCol, nDestEndRow, aQueryParam.nDestTab ),
999                             aOldDest );
1000         }
1001 
1002         ScUndoUtil::MarkSimpleBlock( pDocShell,
1003                                     aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
1004                                     nDestEndCol, nDestEndRow, aQueryParam.nDestTab );
1005         pDoc->DeleteAreaTab( aQueryParam.nDestCol, aQueryParam.nDestRow,
1006                             nDestEndCol, nDestEndRow, aQueryParam.nDestTab, IDF_ALL );
1007 
1008         pViewShell->DoneBlockMode();
1009 
1010         pUndoDoc->CopyToDocument( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
1011                                     nDestEndCol, nDestEndRow, aQueryParam.nDestTab,
1012                                     IDF_ALL, sal_False, pDoc );
1013         //  Attribute werden immer mitkopiert (#49287#)
1014 
1015         //  Rest von altem Bereich
1016         if ( bDestArea && !bDoSize )
1017         {
1018             pDoc->DeleteAreaTab( aOldDest, IDF_ALL );
1019             pUndoDoc->CopyToDocument( aOldDest, IDF_ALL, sal_False, pDoc );
1020         }
1021     }
1022     else
1023         pUndoDoc->CopyToDocument( 0, aQueryParam.nRow1, nTab, MAXCOL, aQueryParam.nRow2, nTab,
1024                                         IDF_NONE, sal_False, pDoc );
1025 
1026     if (pUndoDB)
1027         pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), sal_True );
1028 
1029     if (!bCopy)
1030     {
1031         pDoc->InvalidatePageBreaks(nTab);
1032         pDoc->UpdatePageBreaks( nTab );
1033     }
1034 
1035     ScRange aDirtyRange( 0 , aQueryParam.nRow1, nTab,
1036         MAXCOL, aQueryParam.nRow2, nTab );
1037     pDoc->SetDirty( aDirtyRange );
1038 
1039     DoSdrUndoAction( pDrawUndo, pDoc );
1040 
1041     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1042     if ( nVisTab != nTab )
1043         pViewShell->SetTabNo( nTab );
1044 
1045         //  Paint
1046 
1047     if (bCopy)
1048     {
1049         SCCOL nEndX = nDestEndCol;
1050         SCROW nEndY = nDestEndRow;
1051         if (bDestArea)
1052         {
1053             if ( aOldDest.aEnd.Col() > nEndX )
1054                 nEndX = aOldDest.aEnd.Col();
1055             if ( aOldDest.aEnd.Row() > nEndY )
1056                 nEndY = aOldDest.aEnd.Row();
1057         }
1058         if (bDoSize)
1059             nEndY = MAXROW;
1060         pDocShell->PostPaint( aQueryParam.nDestCol, aQueryParam.nDestRow, aQueryParam.nDestTab,
1061                                     nEndX, nEndY, aQueryParam.nDestTab, PAINT_GRID );
1062     }
1063     else
1064         pDocShell->PostPaint( 0, aQueryParam.nRow1, nTab, MAXCOL, MAXROW, nTab,
1065                                                     PAINT_GRID | PAINT_LEFT );
1066     pDocShell->PostDataChanged();
1067 
1068     EndUndo();
1069 }
1070 
1071 void __EXPORT ScUndoQuery::Redo()
1072 {
1073     BeginRedo();
1074 
1075     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1076 
1077     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1078     if ( nVisTab != nTab )
1079         pViewShell->SetTabNo( nTab );
1080 
1081     if ( bIsAdvanced )
1082         pViewShell->Query( aQueryParam, &aAdvSource, sal_False );
1083     else
1084         pViewShell->Query( aQueryParam, NULL, sal_False );
1085 
1086     EndRedo();
1087 }
1088 
1089 void __EXPORT ScUndoQuery::Repeat(SfxRepeatTarget& /* rTarget */)
1090 {
1091 }
1092 
1093 sal_Bool __EXPORT ScUndoQuery::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1094 {
1095     return sal_False;                       // geht nicht wegen Spaltennummern
1096 }
1097 
1098 //
1099 //      Show or hide AutoFilter buttons (doesn't include filter settings)
1100 //
1101 
1102 ScUndoAutoFilter::ScUndoAutoFilter( ScDocShell* pNewDocShell, const ScRange& rRange,
1103                                     const String& rName, sal_Bool bSet ) :
1104     ScDBFuncUndo( pNewDocShell, rRange ),
1105     aDBName( rName ),
1106     bFilterSet( bSet )
1107 {
1108 }
1109 
1110 ScUndoAutoFilter::~ScUndoAutoFilter()
1111 {
1112 }
1113 
1114 String ScUndoAutoFilter::GetComment() const
1115 {
1116     return ScGlobal::GetRscString( STR_UNDO_QUERY );    // same as ScUndoQuery
1117 }
1118 
1119 void ScUndoAutoFilter::DoChange( sal_Bool bUndo )
1120 {
1121     sal_Bool bNewFilter = bUndo ? !bFilterSet : bFilterSet;
1122 
1123     sal_uInt16 nIndex;
1124     ScDocument* pDoc = pDocShell->GetDocument();
1125     ScDBCollection* pColl = pDoc->GetDBCollection();
1126     if ( pColl->SearchName( aDBName, nIndex ) )
1127     {
1128         ScDBData* pDBData = (*pColl)[nIndex];
1129         pDBData->SetAutoFilter( bNewFilter );
1130 
1131         SCCOL nRangeX1;
1132         SCROW nRangeY1;
1133         SCCOL nRangeX2;
1134         SCROW nRangeY2;
1135         SCTAB nRangeTab;
1136         pDBData->GetArea( nRangeTab, nRangeX1, nRangeY1, nRangeX2, nRangeY2 );
1137 
1138         if ( bNewFilter )
1139             pDoc->ApplyFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO );
1140         else
1141             pDoc->RemoveFlagsTab( nRangeX1, nRangeY1, nRangeX2, nRangeY1, nRangeTab, SC_MF_AUTO );
1142 
1143         pDocShell->PostPaint( nRangeX1, nRangeY1, nRangeTab, nRangeX2, nRangeY1, nRangeTab, PAINT_GRID );
1144     }
1145 }
1146 
1147 void ScUndoAutoFilter::Undo()
1148 {
1149     BeginUndo();
1150     DoChange( sal_True );
1151     EndUndo();
1152 }
1153 
1154 void ScUndoAutoFilter::Redo()
1155 {
1156     BeginRedo();
1157     DoChange( sal_False );
1158     EndRedo();
1159 }
1160 
1161 void ScUndoAutoFilter::Repeat(SfxRepeatTarget& /* rTarget */)
1162 {
1163 }
1164 
1165 sal_Bool ScUndoAutoFilter::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1166 {
1167     return sal_False;
1168 }
1169 
1170 //
1171 //      Datenbankbereiche aendern (Dialog)
1172 //
1173 
1174 ScUndoDBData::ScUndoDBData( ScDocShell* pNewDocShell,
1175                             ScDBCollection* pNewUndoColl, ScDBCollection* pNewRedoColl ) :
1176     ScSimpleUndo( pNewDocShell ),
1177     pUndoColl( pNewUndoColl ),
1178     pRedoColl( pNewRedoColl )
1179 {
1180 }
1181 
1182 __EXPORT ScUndoDBData::~ScUndoDBData()
1183 {
1184     delete pUndoColl;
1185     delete pRedoColl;
1186 }
1187 
1188 String __EXPORT ScUndoDBData::GetComment() const
1189 {   // "Datenbankbereiche aendern";
1190     return ScGlobal::GetRscString( STR_UNDO_DBDATA );
1191 }
1192 
1193 void __EXPORT ScUndoDBData::Undo()
1194 {
1195     BeginUndo();
1196 
1197     ScDocument* pDoc = pDocShell->GetDocument();
1198 
1199     sal_Bool bOldAutoCalc = pDoc->GetAutoCalc();
1200     pDoc->SetAutoCalc( sal_False );         // unnoetige Berechnungen vermeiden
1201     pDoc->CompileDBFormula( sal_True );     // CreateFormulaString
1202     pDoc->SetDBCollection( new ScDBCollection(*pUndoColl), sal_True );
1203     pDoc->CompileDBFormula( sal_False );    // CompileFormulaString
1204     pDoc->SetAutoCalc( bOldAutoCalc );
1205 
1206     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
1207 
1208     EndUndo();
1209 }
1210 
1211 void __EXPORT ScUndoDBData::Redo()
1212 {
1213     BeginRedo();
1214 
1215     ScDocument* pDoc = pDocShell->GetDocument();
1216 
1217     sal_Bool bOldAutoCalc = pDoc->GetAutoCalc();
1218     pDoc->SetAutoCalc( sal_False );         // unnoetige Berechnungen vermeiden
1219     pDoc->CompileDBFormula( sal_True );     // CreateFormulaString
1220     pDoc->SetDBCollection( new ScDBCollection(*pRedoColl), sal_True );
1221     pDoc->CompileDBFormula( sal_False );    // CompileFormulaString
1222     pDoc->SetAutoCalc( bOldAutoCalc );
1223 
1224     SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_DBAREAS_CHANGED ) );
1225 
1226     EndRedo();
1227 }
1228 
1229 void __EXPORT ScUndoDBData::Repeat(SfxRepeatTarget& /* rTarget */)
1230 {
1231 }
1232 
1233 sal_Bool __EXPORT ScUndoDBData::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1234 {
1235     return sal_False;                       // geht nicht
1236 }
1237 
1238 //
1239 //      Import
1240 //
1241 
1242 ScUndoImportData::ScUndoImportData( ScDocShell* pNewDocShell, SCTAB nNewTab,
1243                                 const ScImportParam& rParam, SCCOL nNewEndX, SCROW nNewEndY,
1244                                 SCCOL nNewFormula,
1245                                 ScDocument* pNewUndoDoc, ScDocument* pNewRedoDoc,
1246                                 ScDBData* pNewUndoData, ScDBData* pNewRedoData ) :
1247     ScSimpleUndo( pNewDocShell ),
1248     nTab( nNewTab ),
1249     aImportParam( rParam ),
1250     nEndCol( nNewEndX ),
1251     nEndRow( nNewEndY ),
1252     pUndoDoc( pNewUndoDoc ),
1253     pRedoDoc( pNewRedoDoc ),
1254     pUndoDBData( pNewUndoData ),
1255     pRedoDBData( pNewRedoData ),
1256     nFormulaCols( nNewFormula ),
1257     bRedoFilled( sal_False )
1258 {
1259     // redo doc doesn't contain imported data (but everything else)
1260 }
1261 
1262 __EXPORT ScUndoImportData::~ScUndoImportData()
1263 {
1264     delete pUndoDoc;
1265     delete pRedoDoc;
1266     delete pUndoDBData;
1267     delete pRedoDBData;
1268 }
1269 
1270 String __EXPORT ScUndoImportData::GetComment() const
1271 {   // "Importieren";
1272     return ScGlobal::GetRscString( STR_UNDO_IMPORTDATA );
1273 }
1274 
1275 void __EXPORT ScUndoImportData::Undo()
1276 {
1277     BeginUndo();
1278 
1279     ScDocument* pDoc = pDocShell->GetDocument();
1280     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1281 
1282     ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab,
1283                                                         nEndCol,nEndRow,nTab );
1284 
1285     SCTAB nTable;
1286     SCCOL nCol1, nCol2;
1287     SCROW nRow1, nRow2;
1288     ScDBData* pCurrentData = NULL;
1289     if (pUndoDBData && pRedoDBData)
1290     {
1291         pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
1292         pCurrentData = ScUndoUtil::GetOldDBData( pRedoDBData, pDoc, nTab,
1293                                                     nCol1, nRow1, nCol2, nRow2 );
1294 
1295         if ( !bRedoFilled )
1296         {
1297             //  read redo data from document at first undo
1298             //  imported data is deleted later anyway,
1299             //  so now delete each column after copying to save memory (#41216#)
1300 
1301             sal_Bool bOldAutoCalc = pDoc->GetAutoCalc();
1302             pDoc->SetAutoCalc( sal_False );             // outside of the loop
1303             for (SCCOL nCopyCol = nCol1; nCopyCol <= nCol2; nCopyCol++)
1304             {
1305                 pDoc->CopyToDocument( nCopyCol,nRow1,nTab, nCopyCol,nRow2,nTab,
1306                                         IDF_CONTENTS & ~IDF_NOTE, sal_False, pRedoDoc );
1307                 pDoc->DeleteAreaTab( nCopyCol,nRow1, nCopyCol,nRow2, nTab, IDF_CONTENTS & ~IDF_NOTE );
1308                 pDoc->DoColResize( nTab, nCopyCol, nCopyCol, 0 );
1309             }
1310             pDoc->SetAutoCalc( bOldAutoCalc );
1311             bRedoFilled = sal_True;
1312         }
1313     }
1314     sal_Bool bMoveCells = pUndoDBData && pRedoDBData &&
1315                         pRedoDBData->IsDoSize();        // in alt und neu gleich
1316     if (bMoveCells)
1317     {
1318         //  Undo: erst die neuen Daten loeschen, dann FitBlock rueckwaerts
1319 
1320         ScRange aOld, aNew;
1321         pUndoDBData->GetArea( aOld );
1322         pRedoDBData->GetArea( aNew );
1323 
1324         pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
1325                                 aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL & ~IDF_NOTE );
1326 
1327         aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols );     // FitBlock auch fuer Formeln
1328         aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols );
1329         pDoc->FitBlock( aNew, aOld, sal_False );                    // rueckwaerts
1330     }
1331     else
1332         pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
1333                                 nEndCol,nEndRow, nTab, IDF_ALL & ~IDF_NOTE );
1334 
1335     pUndoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab,
1336                                 nEndCol+nFormulaCols,nEndRow,nTab,
1337                                 IDF_ALL & ~IDF_NOTE, sal_False, pDoc );
1338 
1339     if (pCurrentData)
1340     {
1341         *pCurrentData = *pUndoDBData;
1342 
1343         pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
1344         ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable );
1345     }
1346 
1347 // erack! it's broadcasted
1348 //  pDoc->SetDirty();
1349 
1350     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1351     if ( nVisTab != nTab )
1352         pViewShell->SetTabNo( nTab );
1353 
1354     if (bMoveCells)
1355         pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
1356     else
1357         pDocShell->PostPaint( aImportParam.nCol1,aImportParam.nRow1,nTab,
1358                                 nEndCol,nEndRow,nTab, PAINT_GRID );
1359     pDocShell->PostDataChanged();
1360 
1361     EndUndo();
1362 }
1363 
1364 void __EXPORT ScUndoImportData::Redo()
1365 {
1366     BeginRedo();
1367 
1368     ScDocument* pDoc = pDocShell->GetDocument();
1369     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1370 
1371     ScUndoUtil::MarkSimpleBlock( pDocShell, aImportParam.nCol1,aImportParam.nRow1,nTab,
1372                                                         nEndCol,nEndRow,nTab );
1373 
1374     SCTAB nTable;
1375     SCCOL nCol1, nCol2;
1376     SCROW nRow1, nRow2;
1377     ScDBData* pCurrentData = NULL;
1378     if (pUndoDBData && pRedoDBData)
1379     {
1380         pUndoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
1381         pCurrentData = ScUndoUtil::GetOldDBData( pUndoDBData, pDoc, nTab,
1382                                                     nCol1, nRow1, nCol2, nRow2 );
1383     }
1384     sal_Bool bMoveCells = pUndoDBData && pRedoDBData &&
1385                         pRedoDBData->IsDoSize();        // in alt und neu gleich
1386     if (bMoveCells)
1387     {
1388         //  Redo: FitBlock, dann Daten loeschen (noetig fuer CopyToDocument)
1389 
1390         ScRange aOld, aNew;
1391         pUndoDBData->GetArea( aOld );
1392         pRedoDBData->GetArea( aNew );
1393 
1394         aOld.aEnd.SetCol( aOld.aEnd.Col() + nFormulaCols );     // FitBlock auch fuer Formeln
1395         aNew.aEnd.SetCol( aNew.aEnd.Col() + nFormulaCols );
1396         pDoc->FitBlock( aOld, aNew );
1397 
1398         pDoc->DeleteAreaTab( aNew.aStart.Col(), aNew.aStart.Row(),
1399                                 aNew.aEnd.Col(), aNew.aEnd.Row(), nTab, IDF_ALL & ~IDF_NOTE );
1400 
1401         pRedoDoc->CopyToDocument( aNew, IDF_ALL & ~IDF_NOTE, sal_False, pDoc );        // incl. Formeln
1402     }
1403     else
1404     {
1405         pDoc->DeleteAreaTab( aImportParam.nCol1,aImportParam.nRow1,
1406                                 nEndCol,nEndRow, nTab, IDF_ALL & ~IDF_NOTE );
1407         pRedoDoc->CopyToDocument( aImportParam.nCol1,aImportParam.nRow1,nTab,
1408                                 nEndCol,nEndRow,nTab, IDF_ALL & ~IDF_NOTE, sal_False, pDoc );
1409     }
1410 
1411     if (pCurrentData)
1412     {
1413         *pCurrentData = *pRedoDBData;
1414 
1415         pRedoDBData->GetArea( nTable, nCol1, nRow1, nCol2, nRow2 );
1416         ScUndoUtil::MarkSimpleBlock( pDocShell, nCol1, nRow1, nTable, nCol2, nRow2, nTable );
1417     }
1418 
1419 // erack! it's broadcasted
1420 //  pDoc->SetDirty();
1421 
1422     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1423     if ( nVisTab != nTab )
1424         pViewShell->SetTabNo( nTab );
1425 
1426     if (bMoveCells)
1427         pDocShell->PostPaint( 0,0,nTab, MAXCOL,MAXROW,nTab, PAINT_GRID );
1428     else
1429         pDocShell->PostPaint( aImportParam.nCol1,aImportParam.nRow1,nTab,
1430                                 nEndCol,nEndRow,nTab, PAINT_GRID );
1431     pDocShell->PostDataChanged();
1432 
1433     EndRedo();
1434 }
1435 
1436 void __EXPORT ScUndoImportData::Repeat(SfxRepeatTarget& rTarget)
1437 {
1438     if (rTarget.ISA(ScTabViewTarget))
1439     {
1440         ScTabViewShell& rViewShell = *((ScTabViewTarget&)rTarget).GetViewShell();
1441 
1442         SCTAB nDummy;
1443         ScImportParam aNewParam(aImportParam);
1444         ScDBData* pDBData = rViewShell.GetDBData();
1445         pDBData->GetArea( nDummy, aNewParam.nCol1,aNewParam.nRow1, aNewParam.nCol2,aNewParam.nRow2 );
1446 
1447         rViewShell.ImportData( aNewParam );
1448     }
1449 }
1450 
1451 sal_Bool __EXPORT ScUndoImportData::CanRepeat(SfxRepeatTarget& rTarget) const
1452 {
1453     //  Repeat nur fuer Import per DB-Bereich, dann ist pUndoDBData gesetzt
1454 
1455     if (pUndoDBData)
1456         return (rTarget.ISA(ScTabViewTarget));
1457     else
1458         return sal_False;       // Adressbuch
1459 }
1460 
1461 //
1462 //      Operationen wiederholen
1463 //
1464 
1465 ScUndoRepeatDB::ScUndoRepeatDB( ScDocShell* pNewDocShell, SCTAB nNewTab,
1466                                 SCCOL nStartX, SCROW nStartY, SCCOL nEndX, SCROW nEndY,
1467                                 SCROW nResultEndRow, SCCOL nCurX, SCROW nCurY,
1468                                 ScDocument* pNewUndoDoc, ScOutlineTable* pNewUndoTab,
1469                                 ScRangeName* pNewUndoRange, ScDBCollection* pNewUndoDB,
1470                                 const ScRange* pOldQ, const ScRange* pNewQ ) :
1471     ScSimpleUndo( pNewDocShell ),
1472     aBlockStart( nStartX,nStartY,nNewTab ),
1473     aBlockEnd( nEndX,nEndY,nNewTab ),
1474     nNewEndRow( nResultEndRow ),
1475     aCursorPos( nCurX,nCurY,nNewTab ),
1476     pUndoDoc( pNewUndoDoc ),
1477     pUndoTable( pNewUndoTab ),
1478     pUndoRange( pNewUndoRange ),
1479     pUndoDB( pNewUndoDB ),
1480     bQuerySize( sal_False )
1481 {
1482     if ( pOldQ && pNewQ )
1483     {
1484         aOldQuery = *pOldQ;
1485         aNewQuery = *pNewQ;
1486         bQuerySize = sal_True;;
1487     }
1488 }
1489 
1490 __EXPORT ScUndoRepeatDB::~ScUndoRepeatDB()
1491 {
1492     delete pUndoDoc;
1493     delete pUndoTable;
1494     delete pUndoRange;
1495     delete pUndoDB;
1496 }
1497 
1498 String __EXPORT ScUndoRepeatDB::GetComment() const
1499 {   // "Wiederholen";       //! bessere Beschreibung!
1500     return ScGlobal::GetRscString( STR_UNDO_REPEATDB );
1501 }
1502 
1503 void __EXPORT ScUndoRepeatDB::Undo()
1504 {
1505     BeginUndo();
1506 
1507     ScDocument* pDoc = pDocShell->GetDocument();
1508     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1509     SCTAB nTab = aBlockStart.Tab();
1510 
1511     if (bQuerySize)
1512     {
1513         pDoc->FitBlock( aNewQuery, aOldQuery, sal_False );
1514 
1515         if ( aNewQuery.aEnd.Col() == aOldQuery.aEnd.Col() )
1516         {
1517             SCCOL nFormulaCols = 0;
1518             SCCOL nCol = aOldQuery.aEnd.Col() + 1;
1519             SCROW nRow = aOldQuery.aStart.Row() + 1;        //! Header testen
1520             while ( nCol <= MAXCOL &&
1521                     pDoc->GetCellType(ScAddress( nCol, nRow, nTab )) == CELLTYPE_FORMULA )
1522                 ++nCol, ++nFormulaCols;
1523 
1524             if ( nFormulaCols > 0 )
1525             {
1526                 ScRange aOldForm = aOldQuery;
1527                 aOldForm.aStart.SetCol( aOldQuery.aEnd.Col() + 1 );
1528                 aOldForm.aEnd.SetCol( aOldQuery.aEnd.Col() + nFormulaCols );
1529                 ScRange aNewForm = aOldForm;
1530                 aNewForm.aEnd.SetRow( aNewQuery.aEnd.Row() );
1531                 pDoc->FitBlock( aNewForm, aOldForm, sal_False );
1532             }
1533         }
1534     }
1535 
1536     //!     Daten von Filter in anderen Bereich fehlen noch !!!!!!!!!!!!!!!!!
1537 
1538     if (nNewEndRow > aBlockEnd.Row())
1539     {
1540         pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aBlockEnd.Row()+1, static_cast<SCSIZE>(nNewEndRow-aBlockEnd.Row()) );
1541     }
1542     else if (nNewEndRow < aBlockEnd.Row())
1543     {
1544         pDoc->InsertRow( 0,nTab, MAXCOL,nTab, nNewEndRow+1, static_cast<SCSIZE>(nNewEndRow-aBlockEnd.Row()) );
1545     }
1546 
1547     //  Original Outline-Table
1548 
1549     pDoc->SetOutlineTable( nTab, pUndoTable );
1550 
1551     //  Original Spalten-/Zeilenstatus
1552 
1553     if (pUndoDoc && pUndoTable)
1554     {
1555         SCCOLROW nStartCol;
1556         SCCOLROW nStartRow;
1557         SCCOLROW nEndCol;
1558         SCCOLROW nEndRow;
1559         pUndoTable->GetColArray()->GetRange( nStartCol, nEndCol );
1560         pUndoTable->GetRowArray()->GetRange( nStartRow, nEndRow );
1561 
1562         pUndoDoc->CopyToDocument( static_cast<SCCOL>(nStartCol), 0, nTab,
1563                 static_cast<SCCOL>(nEndCol), MAXROW, nTab, IDF_NONE, sal_False,
1564                 pDoc );
1565         pUndoDoc->CopyToDocument( 0, nStartRow, nTab, MAXCOL, nEndRow, nTab, IDF_NONE, sal_False, pDoc );
1566 
1567         pViewShell->UpdateScrollBars();
1568     }
1569 
1570     //  Original-Daten & Referenzen
1571 
1572     ScUndoUtil::MarkSimpleBlock( pDocShell, 0, aBlockStart.Row(), nTab,
1573                                             MAXCOL, aBlockEnd.Row(), nTab );
1574     pDoc->DeleteAreaTab( 0, aBlockStart.Row(),
1575                             MAXCOL, aBlockEnd.Row(), nTab, IDF_ALL );
1576 
1577     pUndoDoc->CopyToDocument( 0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
1578                                                             IDF_NONE, sal_False, pDoc );            // Flags
1579     pUndoDoc->UndoToDocument( 0, aBlockStart.Row(), nTab, MAXCOL, aBlockEnd.Row(), nTab,
1580                                                             IDF_ALL, sal_False, pDoc );
1581 
1582     ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.Col(),aBlockStart.Row(),nTab,
1583                                             aBlockEnd.Col(),aBlockEnd.Row(),nTab );
1584 
1585     if (pUndoRange)
1586         pDoc->SetRangeName( new ScRangeName( *pUndoRange ) );
1587     if (pUndoDB)
1588         pDoc->SetDBCollection( new ScDBCollection( *pUndoDB ), sal_True );
1589 
1590 // erack! it's broadcasted
1591 //  pDoc->SetDirty();
1592 
1593     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1594     if ( nVisTab != nTab )
1595         pViewShell->SetTabNo( nTab );
1596 
1597     pDocShell->PostPaint(0,0,nTab,MAXCOL,MAXROW,nTab,PAINT_GRID|PAINT_LEFT|PAINT_TOP|PAINT_SIZE);
1598     pDocShell->PostDataChanged();
1599 
1600     EndUndo();
1601 }
1602 
1603 void __EXPORT ScUndoRepeatDB::Redo()
1604 {
1605     BeginRedo();
1606 
1607     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1608     SCTAB nTab = aBlockStart.Tab();
1609 
1610     SCTAB nVisTab = pViewShell->GetViewData()->GetTabNo();
1611     if ( nVisTab != nTab )
1612         pViewShell->SetTabNo( nTab );
1613 
1614     ScUndoUtil::MarkSimpleBlock( pDocShell, aBlockStart.Col(),aBlockStart.Row(),nTab,
1615                                             aBlockEnd.Col(),aBlockEnd.Row(),nTab );
1616     pViewShell->SetCursor( aCursorPos.Col(), aCursorPos.Row() );
1617 
1618     pViewShell->RepeatDB( sal_False );
1619 
1620     EndRedo();
1621 }
1622 
1623 void __EXPORT ScUndoRepeatDB::Repeat(SfxRepeatTarget& rTarget)
1624 {
1625     if (rTarget.ISA(ScTabViewTarget))
1626         ((ScTabViewTarget&)rTarget).GetViewShell()->RepeatDB( sal_True );
1627 }
1628 
1629 sal_Bool __EXPORT ScUndoRepeatDB::CanRepeat(SfxRepeatTarget& rTarget) const
1630 {
1631     return (rTarget.ISA(ScTabViewTarget));
1632 }
1633 
1634 //UNUSED2008-05  //
1635 //UNUSED2008-05  //     Pivot-Tabellen
1636 //UNUSED2008-05  //
1637 //UNUSED2008-05
1638 //UNUSED2008-05  ScUndoPivot::ScUndoPivot( ScDocShell* pNewDocShell,
1639 //UNUSED2008-05                              const ScArea& rOld, const ScArea& rNew,
1640 //UNUSED2008-05                              ScDocument* pOldDoc, ScDocument* pNewDoc,
1641 //UNUSED2008-05                              const ScPivot* pOldPivot, const ScPivot* pNewPivot ) :
1642 //UNUSED2008-05      ScSimpleUndo( pNewDocShell ),
1643 //UNUSED2008-05      aOldArea( rOld ),
1644 //UNUSED2008-05      aNewArea( rNew ),
1645 //UNUSED2008-05      pOldUndoDoc( pOldDoc ),
1646 //UNUSED2008-05      pNewUndoDoc( pNewDoc )
1647 //UNUSED2008-05  {
1648 //UNUSED2008-05      if (pNewPivot)
1649 //UNUSED2008-05      {
1650 //UNUSED2008-05          pNewPivot->GetParam( aNewParam, aNewQuery, aNewSrc );
1651 //UNUSED2008-05          aNewName = pNewPivot->GetName();
1652 //UNUSED2008-05          aNewTag = pNewPivot->GetTag();
1653 //UNUSED2008-05      }
1654 //UNUSED2008-05      if (pOldPivot)
1655 //UNUSED2008-05      {
1656 //UNUSED2008-05          pOldPivot->GetParam( aOldParam, aOldQuery, aOldSrc );
1657 //UNUSED2008-05          aOldName = pOldPivot->GetName();
1658 //UNUSED2008-05          aOldTag = pOldPivot->GetTag();
1659 //UNUSED2008-05      }
1660 //UNUSED2008-05  }
1661 //UNUSED2008-05
1662 //UNUSED2008-05  __EXPORT ScUndoPivot::~ScUndoPivot()
1663 //UNUSED2008-05  {
1664 //UNUSED2008-05      delete pOldUndoDoc;
1665 //UNUSED2008-05      delete pNewUndoDoc;
1666 //UNUSED2008-05  }
1667 //UNUSED2008-05
1668 //UNUSED2008-05  String __EXPORT ScUndoPivot::GetComment() const
1669 //UNUSED2008-05  {
1670 //UNUSED2008-05      sal_uInt16 nIndex;
1671 //UNUSED2008-05      if ( pOldUndoDoc && pNewUndoDoc )
1672 //UNUSED2008-05          nIndex = STR_UNDO_PIVOT_MODIFY;
1673 //UNUSED2008-05      else if ( pNewUndoDoc )
1674 //UNUSED2008-05          nIndex = STR_UNDO_PIVOT_NEW;
1675 //UNUSED2008-05      else
1676 //UNUSED2008-05          nIndex = STR_UNDO_PIVOT_DELETE;
1677 //UNUSED2008-05
1678 //UNUSED2008-05      return ScGlobal::GetRscString( nIndex );
1679 //UNUSED2008-05  }
1680 //UNUSED2008-05
1681 //UNUSED2008-05  void __EXPORT ScUndoPivot::Undo()
1682 //UNUSED2008-05  {
1683 //UNUSED2008-05      BeginUndo();
1684 //UNUSED2008-05
1685 //UNUSED2008-05      ScDocument* pDoc = pDocShell->GetDocument();
1686 //UNUSED2008-05
1687 //UNUSED2008-05      if (pNewUndoDoc)
1688 //UNUSED2008-05      {
1689 //UNUSED2008-05          pDoc->DeleteAreaTab( aNewArea.nColStart,aNewArea.nRowStart,
1690 //UNUSED2008-05                              aNewArea.nColEnd,aNewArea.nRowEnd, aNewArea.nTab, IDF_ALL );
1691 //UNUSED2008-05          pNewUndoDoc->CopyToDocument( aNewArea.nColStart, aNewArea.nRowStart, aNewArea.nTab,
1692 //UNUSED2008-05                                  aNewArea.nColEnd, aNewArea.nRowEnd, aNewArea.nTab,
1693 //UNUSED2008-05                                  IDF_ALL, sal_False, pDoc );
1694 //UNUSED2008-05      }
1695 //UNUSED2008-05      if (pOldUndoDoc)
1696 //UNUSED2008-05      {
1697 //UNUSED2008-05          pDoc->DeleteAreaTab( aOldArea.nColStart,aOldArea.nRowStart,
1698 //UNUSED2008-05                              aOldArea.nColEnd,aOldArea.nRowEnd, aOldArea.nTab, IDF_ALL );
1699 //UNUSED2008-05          pOldUndoDoc->CopyToDocument( aOldArea.nColStart, aOldArea.nRowStart, aOldArea.nTab,
1700 //UNUSED2008-05                                  aOldArea.nColEnd, aOldArea.nRowEnd, aOldArea.nTab,
1701 //UNUSED2008-05                                  IDF_ALL, sal_False, pDoc );
1702 //UNUSED2008-05      }
1703 //UNUSED2008-05
1704 //UNUSED2008-05      ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection();
1705 //UNUSED2008-05      if ( pNewUndoDoc )
1706 //UNUSED2008-05      {
1707 //UNUSED2008-05          ScPivot* pNewPivot = pPivotCollection->GetPivotAtCursor(
1708 //UNUSED2008-05                                  aNewParam.nCol, aNewParam.nRow, aNewParam.nTab );
1709 //UNUSED2008-05          if (pNewPivot)
1710 //UNUSED2008-05              pPivotCollection->Free( pNewPivot );
1711 //UNUSED2008-05      }
1712 //UNUSED2008-05      if ( pOldUndoDoc )
1713 //UNUSED2008-05      {
1714 //UNUSED2008-05          ScPivot* pOldPivot = new ScPivot( pDoc );
1715 //UNUSED2008-05          pOldPivot->SetParam( aOldParam, aOldQuery, aOldSrc );
1716 //UNUSED2008-05          pOldPivot->SetName( aOldName );
1717 //UNUSED2008-05          pOldPivot->SetTag( aOldTag );
1718 //UNUSED2008-05          if (pOldPivot->CreateData())                            // Felder berechnen
1719 //UNUSED2008-05              pOldPivot->ReleaseData();
1720 //UNUSED2008-05          pPivotCollection->Insert( pOldPivot );
1721 //UNUSED2008-05      }
1722 //UNUSED2008-05
1723 //UNUSED2008-05  // erack! it's broadcasted
1724 //UNUSED2008-05  // pDoc->SetDirty();
1725 //UNUSED2008-05      if (pNewUndoDoc)
1726 //UNUSED2008-05          pDocShell->PostPaint( aNewArea.nColStart, aNewArea.nRowStart, aNewArea.nTab,
1727 //UNUSED2008-05                                  aNewArea.nColEnd, aNewArea.nRowEnd, aNewArea.nTab,
1728 //UNUSED2008-05                                  PAINT_GRID, SC_PF_LINES );
1729 //UNUSED2008-05      if (pOldUndoDoc)
1730 //UNUSED2008-05          pDocShell->PostPaint( aOldArea.nColStart, aOldArea.nRowStart, aOldArea.nTab,
1731 //UNUSED2008-05                                  aOldArea.nColEnd, aOldArea.nRowEnd, aOldArea.nTab,
1732 //UNUSED2008-05                                  PAINT_GRID, SC_PF_LINES );
1733 //UNUSED2008-05      pDocShell->PostDataChanged();
1734 //UNUSED2008-05
1735 //UNUSED2008-05      ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1736 //UNUSED2008-05      if (pViewShell)
1737 //UNUSED2008-05      {
1738 //UNUSED2008-05          SCTAB nTab = pViewShell->GetViewData()->GetTabNo();
1739 //UNUSED2008-05          if ( pOldUndoDoc )
1740 //UNUSED2008-05          {
1741 //UNUSED2008-05              if ( nTab != aOldArea.nTab )
1742 //UNUSED2008-05                  pViewShell->SetTabNo( aOldArea.nTab );
1743 //UNUSED2008-05          }
1744 //UNUSED2008-05          else if ( pNewUndoDoc )
1745 //UNUSED2008-05          {
1746 //UNUSED2008-05              if ( nTab != aNewArea.nTab )
1747 //UNUSED2008-05                  pViewShell->SetTabNo( aNewArea.nTab );
1748 //UNUSED2008-05          }
1749 //UNUSED2008-05      }
1750 //UNUSED2008-05
1751 //UNUSED2008-05      EndUndo();
1752 //UNUSED2008-05  }
1753 //UNUSED2008-05
1754 //UNUSED2008-05  void __EXPORT ScUndoPivot::Redo()
1755 //UNUSED2008-05  {
1756 //UNUSED2008-05      BeginRedo();
1757 //UNUSED2008-05
1758 //UNUSED2008-05      ScDocument* pDoc = pDocShell->GetDocument();
1759 //UNUSED2008-05      ScPivotCollection* pPivotCollection = pDoc->GetPivotCollection();
1760 //UNUSED2008-05      ScPivot* pOldPivot = pPivotCollection->GetPivotAtCursor(
1761 //UNUSED2008-05                                              aOldParam.nCol, aOldParam.nRow, aOldParam.nTab );
1762 //UNUSED2008-05
1763 //UNUSED2008-05      ScPivot* pNewPivot = NULL;
1764 //UNUSED2008-05      if (pNewUndoDoc)
1765 //UNUSED2008-05      {
1766 //UNUSED2008-05          pNewPivot = new ScPivot( pDoc );
1767 //UNUSED2008-05          pNewPivot->SetParam( aNewParam, aNewQuery, aNewSrc );
1768 //UNUSED2008-05          pNewPivot->SetName( aNewName );
1769 //UNUSED2008-05          pNewPivot->SetTag( aNewTag );
1770 //UNUSED2008-05      }
1771 //UNUSED2008-05
1772 //UNUSED2008-05      pDocShell->PivotUpdate( pOldPivot, pNewPivot, sal_False );
1773 //UNUSED2008-05
1774 //UNUSED2008-05      EndRedo();
1775 //UNUSED2008-05  }
1776 //UNUSED2008-05
1777 //UNUSED2008-05  void __EXPORT ScUndoPivot::Repeat(SfxRepeatTarget& rTarget)
1778 //UNUSED2008-05  {
1779 //UNUSED2008-05      //  Wiederholen: nur loeschen
1780 //UNUSED2008-05
1781 //UNUSED2008-05      if ( pOldUndoDoc && !pNewUndoDoc && rTarget.ISA(ScTabViewTarget) )
1782 //UNUSED2008-05          ((ScTabViewTarget&)rTarget).GetViewShell()->DeletePivotTable();
1783 //UNUSED2008-05  }
1784 //UNUSED2008-05
1785 //UNUSED2008-05  sal_Bool __EXPORT ScUndoPivot::CanRepeat(SfxRepeatTarget& rTarget) const
1786 //UNUSED2008-05  {
1787 //UNUSED2008-05      //  Wiederholen: nur loeschen
1788 //UNUSED2008-05
1789 //UNUSED2008-05      return ( pOldUndoDoc && !pNewUndoDoc && rTarget.ISA(ScTabViewTarget) );
1790 //UNUSED2008-05  }
1791 
1792 //
1793 //      data pilot
1794 //
1795 
1796 ScUndoDataPilot::ScUndoDataPilot( ScDocShell* pNewDocShell,
1797                             ScDocument* pOldDoc, ScDocument* pNewDoc,
1798                             const ScDPObject* pOldObj, const ScDPObject* pNewObj, sal_Bool bMove ) :
1799     ScSimpleUndo( pNewDocShell ),
1800     pOldUndoDoc( pOldDoc ),
1801     pNewUndoDoc( pNewDoc ),
1802     pOldDPObject( NULL ),
1803     pNewDPObject( NULL ),
1804     bAllowMove( bMove )
1805 {
1806     if (pOldObj)
1807         pOldDPObject = new ScDPObject( *pOldObj );
1808     if (pNewObj)
1809         pNewDPObject = new ScDPObject( *pNewObj );
1810 }
1811 
1812 __EXPORT ScUndoDataPilot::~ScUndoDataPilot()
1813 {
1814     delete pOldDPObject;
1815     delete pNewDPObject;
1816     delete pOldUndoDoc;
1817     delete pNewUndoDoc;
1818 }
1819 
1820 String __EXPORT ScUndoDataPilot::GetComment() const
1821 {
1822     sal_uInt16 nIndex;
1823     if ( pOldUndoDoc && pNewUndoDoc )
1824         nIndex = STR_UNDO_PIVOT_MODIFY;
1825     else if ( pNewUndoDoc )
1826         nIndex = STR_UNDO_PIVOT_NEW;
1827     else
1828         nIndex = STR_UNDO_PIVOT_DELETE;
1829 
1830     return ScGlobal::GetRscString( nIndex );
1831 }
1832 
1833 void __EXPORT ScUndoDataPilot::Undo()
1834 {
1835     BeginUndo();
1836 
1837     ScDocument* pDoc = pDocShell->GetDocument();
1838 
1839     ScRange aOldRange;
1840     ScRange aNewRange;
1841 
1842     if ( pNewDPObject && pNewUndoDoc )
1843     {
1844         aNewRange = pNewDPObject->GetOutRange();
1845         pDoc->DeleteAreaTab( aNewRange, IDF_ALL );
1846         pNewUndoDoc->CopyToDocument( aNewRange, IDF_ALL, sal_False, pDoc );
1847     }
1848     if ( pOldDPObject && pOldUndoDoc )
1849     {
1850         aOldRange = pOldDPObject->GetOutRange();
1851         pDoc->DeleteAreaTab( aOldRange, IDF_ALL );
1852         pOldUndoDoc->CopyToDocument( aOldRange, IDF_ALL, sal_False, pDoc );
1853     }
1854 
1855     //  update objects in collection
1856 
1857     if ( pNewDPObject )
1858     {
1859         //  find updated object
1860         //! find by name!
1861 
1862         ScDPObject* pDocObj = pDoc->GetDPAtCursor(
1863                             aNewRange.aStart.Col(), aNewRange.aStart.Row(), aNewRange.aStart.Tab() );
1864         DBG_ASSERT(pDocObj, "DPObject not found");
1865         if (pDocObj)
1866         {
1867             if ( pOldDPObject )
1868             {
1869                 //  restore old settings
1870                 pOldDPObject->WriteSourceDataTo( *pDocObj );
1871                 ScDPSaveData* pData = pOldDPObject->GetSaveData();
1872                 if (pData)
1873                     pDocObj->SetSaveData(*pData);
1874                 pDocObj->SetOutRange( pOldDPObject->GetOutRange() );
1875                 pOldDPObject->WriteTempDataTo( *pDocObj );
1876             }
1877             else
1878             {
1879                 //  delete inserted object
1880                 pDoc->GetDPCollection()->FreeTable(pDocObj);
1881             }
1882         }
1883     }
1884     else if ( pOldDPObject )
1885     {
1886         //  re-insert deleted object
1887 
1888         ScDPObject* pDestObj = new ScDPObject( *pOldDPObject );
1889         pDestObj->SetAlive(sal_True);
1890         if ( !pDoc->GetDPCollection()->InsertNewTable(pDestObj) )
1891         {
1892             DBG_ERROR("cannot insert DPObject");
1893             DELETEZ( pDestObj );
1894         }
1895     }
1896 
1897     if (pNewUndoDoc)
1898         pDocShell->PostPaint( aNewRange, PAINT_GRID, SC_PF_LINES );
1899     if (pOldUndoDoc)
1900         pDocShell->PostPaint( aOldRange, PAINT_GRID, SC_PF_LINES );
1901     pDocShell->PostDataChanged();
1902 
1903     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
1904     if (pViewShell)
1905     {
1906         //! set current sheet
1907     }
1908 
1909     if (pNewDPObject)
1910     {
1911         // notify API objects
1912         pDoc->BroadcastUno( ScDataPilotModifiedHint( pNewDPObject->GetName() ) );
1913     }
1914 
1915     EndUndo();
1916 }
1917 
1918 void __EXPORT ScUndoDataPilot::Redo()
1919 {
1920     BeginRedo();
1921 
1922     //! copy output data instead of repeating the change,
1923     //! in case external data have changed!
1924 
1925     ScDocument* pDoc = pDocShell->GetDocument();
1926 
1927     ScDPObject* pSourceObj = NULL;
1928     if ( pOldDPObject )
1929     {
1930         //  find object to modify
1931         //! find by name!
1932 
1933         ScRange aOldRange = pOldDPObject->GetOutRange();
1934         pSourceObj = pDoc->GetDPAtCursor(
1935                         aOldRange.aStart.Col(), aOldRange.aStart.Row(), aOldRange.aStart.Tab() );
1936         DBG_ASSERT(pSourceObj, "DPObject not found");
1937     }
1938 
1939     ScDBDocFunc aFunc( *pDocShell );
1940     aFunc.DataPilotUpdate( pSourceObj, pNewDPObject, sal_False, sal_False, bAllowMove );    // no new undo action
1941 
1942     EndRedo();
1943 }
1944 
1945 void __EXPORT ScUndoDataPilot::Repeat(SfxRepeatTarget& /* rTarget */)
1946 {
1947     //! allow deletion
1948 }
1949 
1950 sal_Bool __EXPORT ScUndoDataPilot::CanRepeat(SfxRepeatTarget& /* rTarget */) const
1951 {
1952     //! allow deletion
1953     return sal_False;
1954 }
1955 
1956 
1957 //
1958 //      Konsolidieren
1959 //
1960 
1961 ScUndoConsolidate::ScUndoConsolidate( ScDocShell* pNewDocShell, const ScArea& rArea,
1962                     const ScConsolidateParam& rPar, ScDocument* pNewUndoDoc,
1963                     sal_Bool bReference, SCROW nInsCount, ScOutlineTable* pTab,
1964                     ScDBData* pData ) :
1965     ScSimpleUndo( pNewDocShell ),
1966     aDestArea( rArea ),
1967     pUndoDoc( pNewUndoDoc ),
1968     aParam( rPar ),
1969     bInsRef( bReference ),
1970     nInsertCount( nInsCount ),
1971     pUndoTab( pTab ),
1972     pUndoData( pData )
1973 {
1974 }
1975 
1976 __EXPORT ScUndoConsolidate::~ScUndoConsolidate()
1977 {
1978     delete pUndoDoc;
1979     delete pUndoTab;
1980     delete pUndoData;
1981 }
1982 
1983 String __EXPORT ScUndoConsolidate::GetComment() const
1984 {
1985     return ScGlobal::GetRscString( STR_UNDO_CONSOLIDATE );
1986 }
1987 
1988 void __EXPORT ScUndoConsolidate::Undo()
1989 {
1990     BeginUndo();
1991 
1992     ScDocument* pDoc = pDocShell->GetDocument();
1993     SCTAB nTab = aDestArea.nTab;
1994 
1995     ScRange aOldRange;
1996     if (pUndoData)
1997         pUndoData->GetArea(aOldRange);
1998 
1999     if (bInsRef)
2000     {
2001         //  Zeilen loeschen
2002         pDoc->DeleteRow( 0,nTab, MAXCOL,nTab, aDestArea.nRowStart, nInsertCount );
2003 
2004         //  Outlines
2005         pDoc->SetOutlineTable( nTab, pUndoTab );
2006 
2007         //  Zeilenstatus
2008         pUndoDoc->CopyToDocument( 0,0,nTab, MAXCOL,MAXROW,nTab, IDF_NONE, sal_False, pDoc );
2009 
2010         //  Daten & Referenzen
2011         pDoc->DeleteAreaTab( 0,aDestArea.nRowStart, MAXCOL,aDestArea.nRowEnd, nTab, IDF_ALL );
2012         pUndoDoc->UndoToDocument( 0, aDestArea.nRowStart, nTab,
2013                                     MAXCOL, aDestArea.nRowEnd, nTab,
2014                                     IDF_ALL, sal_False, pDoc );
2015 
2016         //  Original-Bereich
2017         if (pUndoData)
2018         {
2019             pDoc->DeleteAreaTab(aOldRange, IDF_ALL);
2020             pUndoDoc->CopyToDocument(aOldRange, IDF_ALL, sal_False, pDoc);
2021         }
2022 
2023         pDocShell->PostPaint( 0,aDestArea.nRowStart,nTab, MAXCOL,MAXROW,nTab,
2024                                 PAINT_GRID | PAINT_LEFT | PAINT_SIZE );
2025     }
2026     else
2027     {
2028         pDoc->DeleteAreaTab( aDestArea.nColStart,aDestArea.nRowStart,
2029                                 aDestArea.nColEnd,aDestArea.nRowEnd, nTab, IDF_ALL );
2030         pUndoDoc->CopyToDocument( aDestArea.nColStart, aDestArea.nRowStart, nTab,
2031                                     aDestArea.nColEnd, aDestArea.nRowEnd, nTab,
2032                                     IDF_ALL, sal_False, pDoc );
2033 
2034         //  Original-Bereich
2035         if (pUndoData)
2036         {
2037             pDoc->DeleteAreaTab(aOldRange, IDF_ALL);
2038             pUndoDoc->CopyToDocument(aOldRange, IDF_ALL, sal_False, pDoc);
2039         }
2040 
2041         SCCOL nEndX = aDestArea.nColEnd;
2042         SCROW nEndY = aDestArea.nRowEnd;
2043         if ( pUndoData )
2044         {
2045             if ( aOldRange.aEnd.Col() > nEndX )
2046                 nEndX = aOldRange.aEnd.Col();
2047             if ( aOldRange.aEnd.Row() > nEndY )
2048                 nEndY = aOldRange.aEnd.Row();
2049         }
2050         pDocShell->PostPaint( aDestArea.nColStart, aDestArea.nRowStart, nTab,
2051                                     nEndX, nEndY, nTab, PAINT_GRID );
2052     }
2053 
2054     //  DB-Bereich wieder anpassen
2055     if (pUndoData)
2056     {
2057         ScDBCollection* pColl = pDoc->GetDBCollection();
2058         if (pColl)
2059         {
2060             sal_uInt16 nIndex;
2061             if (pColl->SearchName( pUndoData->GetName(), nIndex ))
2062             {
2063                 ScDBData* pDocData = (*pColl)[nIndex];
2064                 if (pDocData)
2065                     *pDocData = *pUndoData;
2066             }
2067             else
2068             {
2069                 DBG_ERROR("alte DB-Daten nicht gefunden");
2070             }
2071         }
2072     }
2073 
2074     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
2075     if (pViewShell)
2076     {
2077         SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo();
2078         if ( nViewTab != nTab )
2079             pViewShell->SetTabNo( nTab );
2080     }
2081 
2082     EndUndo();
2083 }
2084 
2085 void __EXPORT ScUndoConsolidate::Redo()
2086 {
2087     BeginRedo();
2088 
2089     pDocShell->DoConsolidate( aParam, sal_False );
2090 
2091     ScTabViewShell* pViewShell = ScTabViewShell::GetActiveViewShell();
2092     if (pViewShell)
2093     {
2094         SCTAB nViewTab = pViewShell->GetViewData()->GetTabNo();
2095         if ( nViewTab != aParam.nTab )
2096             pViewShell->SetTabNo( aParam.nTab );
2097     }
2098 
2099     EndRedo();
2100 }
2101 
2102 void __EXPORT ScUndoConsolidate::Repeat(SfxRepeatTarget& /* rTarget */)
2103 {
2104 }
2105 
2106 sal_Bool __EXPORT ScUndoConsolidate::CanRepeat(SfxRepeatTarget& /* rTarget */) const
2107 {
2108     return sal_False;
2109 }
2110 
2111 
2112 //
2113 //      Quell-Daten von Chart aendern
2114 //
2115 
2116 void ScUndoChartData::Init()
2117 {
2118     ScDocument* pDoc = pDocShell->GetDocument();
2119     aOldRangeListRef = new ScRangeList;
2120     pDoc->GetOldChartParameters( aChartName, *aOldRangeListRef, bOldColHeaders, bOldRowHeaders );
2121 }
2122 
2123 ScUndoChartData::ScUndoChartData( ScDocShell* pNewDocShell, const String& rName,
2124                                     const ScRange& rNew, sal_Bool bColHdr, sal_Bool bRowHdr,
2125                                     sal_Bool bAdd ) :
2126     ScSimpleUndo( pNewDocShell ),
2127     aChartName( rName ),
2128     bNewColHeaders( bColHdr ),
2129     bNewRowHeaders( bRowHdr ),
2130     bAddRange( bAdd )
2131 {
2132     aNewRangeListRef = new ScRangeList;
2133     aNewRangeListRef->Append( rNew );
2134 
2135     Init();
2136 }
2137 
2138 ScUndoChartData::ScUndoChartData( ScDocShell* pNewDocShell, const String& rName,
2139                                     const ScRangeListRef& rNew, sal_Bool bColHdr, sal_Bool bRowHdr,
2140                                     sal_Bool bAdd ) :
2141     ScSimpleUndo( pNewDocShell ),
2142     aChartName( rName ),
2143     aNewRangeListRef( rNew ),
2144     bNewColHeaders( bColHdr ),
2145     bNewRowHeaders( bRowHdr ),
2146     bAddRange( bAdd )
2147 {
2148     Init();
2149 }
2150 
2151 __EXPORT ScUndoChartData::~ScUndoChartData()
2152 {
2153 }
2154 
2155 String __EXPORT ScUndoChartData::GetComment() const
2156 {
2157     return ScGlobal::GetRscString( STR_UNDO_CHARTDATA );
2158 }
2159 
2160 void __EXPORT ScUndoChartData::Undo()
2161 {
2162     BeginUndo();
2163 
2164     pDocShell->GetDocument()->UpdateChartArea( aChartName, aOldRangeListRef,
2165                                 bOldColHeaders, bOldRowHeaders, sal_False );
2166 
2167     EndUndo();
2168 }
2169 
2170 void __EXPORT ScUndoChartData::Redo()
2171 {
2172     BeginRedo();
2173 
2174     pDocShell->GetDocument()->UpdateChartArea( aChartName, aNewRangeListRef,
2175                                 bNewColHeaders, bNewRowHeaders, bAddRange );
2176 
2177     EndRedo();
2178 }
2179 
2180 void __EXPORT ScUndoChartData::Repeat(SfxRepeatTarget& /* rTarget */)
2181 {
2182 }
2183 
2184 sal_Bool __EXPORT ScUndoChartData::CanRepeat(SfxRepeatTarget& /* rTarget */) const
2185 {
2186     return sal_False;
2187 }
2188 
2189 
2190 
2191 
2192 
2193 
2194