1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  *   Licensed to the Apache Software Foundation (ASF) under one or more
12  *   contributor license agreements. See the NOTICE file distributed
13  *   with this work for additional information regarding copyright
14  *   ownership. The ASF licenses this file to you under the Apache
15  *   License, Version 2.0 (the "License"); you may not use this file
16  *   except in compliance with the License. You may obtain a copy of
17  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 #pragma once
20 
21 #include "undobase.hxx"
22 #include <markdata.hxx>
23 #include "spellparam.hxx"
24 #include "cellmergeoption.hxx"
25 #include <paramisc.hxx>
26 #include <editeng/boxitem.hxx>
27 
28 #include <memory>
29 
30 class ScDocShell;
31 class ScOutlineTable;
32 class ScPatternAttr;
33 class SvxSearchItem;
34 class SdrUndoAction;
35 class ScEditDataArray;
36 
37 class ScUndoInsertCells: public ScMoveUndo
38 {
39 public:
40                     ScUndoInsertCells( ScDocShell* pNewDocShell,
41                                        const ScRange& rRange,
42                                        SCTAB nNewCount, std::unique_ptr<SCTAB[]> pNewTabs, std::unique_ptr<SCTAB[]> pNewScenarios,
43                                        InsCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData,
44                                        bool bNewPartOfPaste );
45     virtual         ~ScUndoInsertCells() override;
46 
47     virtual void    Undo() override;
48     virtual void    Redo() override;
49     virtual void    Repeat( SfxRepeatTarget& rTarget ) override;
50     virtual bool    CanRepeat( SfxRepeatTarget& rTarget ) const override;
51 
52     virtual OUString GetComment() const override;
53 
54     virtual bool    Merge( SfxUndoAction *pNextAction ) override;
55 
56 private:
57     ScRange         aEffRange;
58     SCTAB           nCount;
59     std::unique_ptr<SCTAB[]>
60                     pTabs;
61     std::unique_ptr<SCTAB[]>
62                     pScenarios;
63     sal_uLong       nEndChangeAction;
64     InsCellCmd      eCmd;
65     bool            bPartOfPaste;
66     std::unique_ptr<SfxUndoAction>
67                     pPasteUndo;
68 
69     void            DoChange ( const bool bUndo );
70     void            SetChangeTrack();
71 };
72 
73 class ScUndoDeleteCells: public ScMoveUndo
74 {
75 public:
76                     ScUndoDeleteCells( ScDocShell* pNewDocShell,
77                                        const ScRange& rRange,
78                                        SCTAB nNewCount, std::unique_ptr<SCTAB[]> pNewTabs, std::unique_ptr<SCTAB[]> pNewScenarios,
79                                        DelCellCmd eNewCmd, ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData );
80     virtual         ~ScUndoDeleteCells() override;
81 
82     virtual void    Undo() override;
83     virtual void    Redo() override;
84     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
85     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
86 
87     virtual OUString GetComment() const override;
88 
89 private:
90     ScRange         aEffRange;
91     SCTAB           nCount;
92     std::unique_ptr<SCTAB[]>
93                     pTabs;
94     std::unique_ptr<SCTAB[]>
95                     pScenarios;
96     sal_uLong       nStartChangeAction;
97     sal_uLong       nEndChangeAction;
98     DelCellCmd      eCmd;
99 
100     void            DoChange ( const bool bUndo );
101     void            SetChangeTrack();
102 };
103 
104 class ScUndoDeleteMulti: public ScMoveUndo
105 {
106 public:
107 
108     ScUndoDeleteMulti( ScDocShell* pNewDocShell,
109                        bool bNewRows, bool bNeedsRefresh, SCTAB nNewTab,
110                        const std::vector<sc::ColRowSpan>& rSpans,
111                        ScDocumentUniquePtr pUndoDocument, std::unique_ptr<ScRefUndoData> pRefData );
112 
113     virtual         ~ScUndoDeleteMulti() override;
114 
115     virtual void    Undo() override;
116     virtual void    Redo() override;
117     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
118     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
119 
120     virtual OUString GetComment() const override;
121 
122 private:
123     bool            mbRows:1;
124     bool            mbRefresh:1;
125     SCTAB           nTab;
126     std::vector<sc::ColRowSpan> maSpans;
127     sal_uLong           nStartChangeAction;
128     sal_uLong           nEndChangeAction;
129 
130     void            DoChange() const;
131     void            SetChangeTrack();
132 };
133 
134 class SC_DLLPUBLIC ScUndoCut: public ScBlockUndo
135 {
136 public:
137     ScUndoCut(ScDocShell* pNewDocShell,
138               const ScRange& aRange, // adjusted for merged cells
139               const ScAddress& aOldEnd, // end position without adjustment
140               const ScMarkData& rMark, // selected sheets
141               ScDocumentUniquePtr pNewUndoDoc);
142     virtual         ~ScUndoCut() override;
143 
144     virtual void    Undo() override;
145     virtual void    Redo() override;
146     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
147     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
148 
149     virtual OUString GetComment() const override;
150 
151 private:
152     ScMarkData          aMarkData;
153     ScDocumentUniquePtr
154                         pUndoDoc;
155     ScRange             aExtendedRange;
156     sal_uLong           nStartChangeAction;
157     sal_uLong           nEndChangeAction;
158 
159     void            DoChange( const bool bUndo );
160     void            SetChangeTrack();
161 };
162 
163 struct ScUndoPasteOptions
164 {
165     ScPasteFunc  nFunction;
166     bool       bSkipEmpty;
167     bool       bTranspose;
168     bool       bAsLink;
169     InsCellCmd eMoveMode;
170 
ScUndoPasteOptionsScUndoPasteOptions171     ScUndoPasteOptions() :
172         nFunction( ScPasteFunc::NONE ),
173         bSkipEmpty( false ),
174         bTranspose( false ),
175         bAsLink( false ),
176         eMoveMode( INS_NONE )
177     {}
178 };
179 
180 class SC_DLLPUBLIC ScUndoPaste: public ScMultiBlockUndo
181 {
182 public:
183     ScUndoPaste(ScDocShell* pNewDocShell, const ScRangeList& rRanges,
184                 const ScMarkData& rMark,
185                 ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc,
186                 InsertDeleteFlags nNewFlags,
187                 std::unique_ptr<ScRefUndoData> pRefData,
188                 bool bRedoIsFilled = true,
189                 const ScUndoPasteOptions* pOptions = nullptr);
190     virtual ~ScUndoPaste() override;
191 
192     virtual void Undo() override;
193     virtual void Redo() override;
194     virtual void Repeat(SfxRepeatTarget& rTarget) override;
195     virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
196 
197     virtual OUString GetComment() const override;
198 
199 private:
200     ScMarkData      aMarkData;
201     ScDocumentUniquePtr pUndoDoc;
202     ScDocumentUniquePtr pRedoDoc;
203     InsertDeleteFlags nFlags;
204     std::unique_ptr<ScRefUndoData> pRefUndoData;
205     std::unique_ptr<ScRefUndoData> pRefRedoData;
206     sal_uLong       nStartChangeAction;
207     sal_uLong       nEndChangeAction;
208     bool            bRedoFilled;
209     ScUndoPasteOptions aPasteOptions;
210 
211     void DoChange(bool bUndo);
212     void SetChangeTrack();
213 };
214 
215 class ScUndoDragDrop: public ScMoveUndo
216 {
217 public:
218                     ScUndoDragDrop( ScDocShell* pNewDocShell,
219                                     const ScRange& rRange, const ScAddress& aNewDestPos, bool bNewCut,
220                                     ScDocumentUniquePtr pUndoDocument,
221                                     bool bScenario );
222     virtual         ~ScUndoDragDrop() override;
223 
224     virtual void    Undo() override;
225     virtual void    Redo() override;
226     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
227     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
228 
229     virtual OUString GetComment() const override;
230 
231 private:
232     sal_uInt16 mnPaintExtFlags;
233     ScRangeList maPaintRanges;
234 
235     ScRange         aSrcRange;
236     ScRange         aDestRange;
237     sal_uLong       nStartChangeAction;
238     sal_uLong       nEndChangeAction;
239     bool            bCut;
240     bool            bKeepScenarioFlags;
241 
242     void            PaintArea( ScRange aRange, sal_uInt16 nExtFlags ) const;
243     void DoUndo( ScRange aRange );
244 
245     void            SetChangeTrack();
246 };
247 
248 class ScUndoDeleteContents: public ScSimpleUndo
249 {
250 public:
251                     ScUndoDeleteContents( ScDocShell* pNewDocShell,
252                                           const ScMarkData& rMark,
253                                           const ScRange& rRange,
254                                           ScDocumentUniquePtr&& pNewUndoDoc, bool bNewMulti,
255                                           InsertDeleteFlags nNewFlags, bool bObjects );
256     virtual         ~ScUndoDeleteContents() override;
257 
258     virtual void    Undo() override;
259     virtual void    Redo() override;
260     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
261     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
262 
263     virtual OUString GetComment() const override;
264 
265     void SetDataSpans( const std::shared_ptr<DataSpansType>& pSpans );
266 
267 private:
268     std::shared_ptr<DataSpansType> mpDataSpans; // Spans of non-empty cells.
269 
270     ScRange         aRange;
271     ScMarkData      aMarkData;
272     ScDocumentUniquePtr pUndoDoc; // Block mark and deleted data
273     std::unique_ptr<SdrUndoAction> pDrawUndo;      // Deleted objects
274     sal_uLong       nStartChangeAction;
275     sal_uLong       nEndChangeAction;
276     InsertDeleteFlags nFlags;
277     bool            bMulti;         // Multi selection
278 
279     void            DoChange( const bool bUndo );
280     void            SetChangeTrack();
281 };
282 
283 class ScUndoFillTable: public ScSimpleUndo
284 {
285 public:
286                     ScUndoFillTable( ScDocShell* pNewDocShell,
287                                      const ScMarkData& rMark,
288                                      SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
289                                      SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
290                                      ScDocumentUniquePtr pNewUndoDoc, bool bNewMulti, SCTAB nSrc,
291                                      InsertDeleteFlags nFlg, ScPasteFunc nFunc, bool bSkip, bool bLink );
292     virtual         ~ScUndoFillTable() override;
293 
294     virtual void    Undo() override;
295     virtual void    Redo() override;
296     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
297     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
298 
299     virtual OUString GetComment() const override;
300 
301 private:
302     ScRange         aRange;
303     ScMarkData      aMarkData;
304     ScDocumentUniquePtr
305                     pUndoDoc;       // Block mark and deleted data
306     sal_uLong       nStartChangeAction;
307     sal_uLong       nEndChangeAction;
308     InsertDeleteFlags nFlags;
309     ScPasteFunc       nFunction;
310     SCTAB           nSrcTab;
311     bool            bMulti;         // Multi selection
312     bool            bSkipEmpty;
313     bool            bAsLink;
314 
315     void            DoChange( const bool bUndo );
316     void            SetChangeTrack();
317 };
318 
319 class ScUndoSelectionAttr: public ScSimpleUndo
320 {
321 public:
322                     ScUndoSelectionAttr( ScDocShell* pNewDocShell,
323                                          const ScMarkData& rMark,
324                                          SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
325                                          SCCOL nEndX, SCROW nEndY, SCTAB nEndZ,
326                                          ScDocumentUniquePtr pNewUndoDoc, bool bNewMulti,
327                                          const ScPatternAttr* pNewApply,
328                                          const SvxBoxItem* pNewOuter = nullptr,
329                                          const SvxBoxInfoItem* pNewInner = nullptr,
330                                          const ScRange* pRangeCover = nullptr );
331     virtual         ~ScUndoSelectionAttr() override;
332 
333     virtual void    Undo() override;
334     virtual void    Redo() override;
335     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
336     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
337 
338     virtual OUString GetComment() const override;
339 
340     ScEditDataArray*    GetDataArray();
341 private:
342     ScMarkData      aMarkData;
343     ScRange         aRange;
344     ScRange         aRangeCover;
345     std::unique_ptr<ScEditDataArray> mpDataArray;
346     ScDocumentUniquePtr pUndoDoc;
347     bool            bMulti;
348     ScPatternAttr*  pApplyPattern;
349     SvxBoxItem*     pLineOuter;
350     SvxBoxInfoItem* pLineInner;
351 
352     void            DoChange( const bool bUndo );
353     void            ChangeEditData( const bool bUndo );
354 };
355 
356 class ScUndoWidthOrHeight: public ScSimpleUndo
357 {
358 public:
359                     ScUndoWidthOrHeight( ScDocShell* pNewDocShell,
360                                          const ScMarkData& rMark,
361                                          SCCOLROW nNewStart, SCTAB nNewStartTab,
362                                          SCCOLROW nNewEnd, SCTAB nNewEndTab,
363                                          ScDocumentUniquePtr pNewUndoDoc,
364                                          const std::vector<sc::ColRowSpan>& rRanges,
365                                          std::unique_ptr<ScOutlineTable> pNewUndoTab,
366                                          ScSizeMode eNewMode, sal_uInt16 nNewSizeTwips,
367                                          bool bNewWidth );
368     virtual         ~ScUndoWidthOrHeight() override;
369 
370     virtual void    Undo() override;
371     virtual void    Redo() override;
372     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
373     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
374 
375     virtual OUString GetComment() const override;
376 
377 private:
378     ScMarkData      aMarkData;
379     SCCOLROW        nStart;
380     SCCOLROW        nEnd;
381     SCTAB           nStartTab;
382     SCTAB           nEndTab;
383     ScDocumentUniquePtr pUndoDoc;
384     std::unique_ptr<ScOutlineTable> pUndoTab;
385     std::vector<sc::ColRowSpan> maRanges;
386     sal_uInt16      nNewSize;
387     bool            bWidth;
388     ScSizeMode      eMode;
389     std::unique_ptr<SdrUndoAction>  pDrawUndo;
390 };
391 
392 class ScUndoAutoFill: public ScBlockUndo
393 {
394 public:
395                     ScUndoAutoFill( ScDocShell* pNewDocShell,
396                                     const ScRange& rRange, const ScRange& rSourceArea,
397                                     ScDocumentUniquePtr pNewUndoDoc, const ScMarkData& rMark,
398                                     FillDir eNewFillDir,
399                                     FillCmd eNewFillCmd, FillDateCmd eNewFillDateCmd,
400                                     double fNewStartValue, double fNewStepValue, double fNewMaxValue );
401     virtual         ~ScUndoAutoFill() override;
402 
403     virtual void    Undo() override;
404     virtual void    Redo() override;
405     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
406     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
407 
408     virtual OUString GetComment() const override;
409 
410 private:
411     ScRange         aSource;
412     ScMarkData      aMarkData;
413     ScDocumentUniquePtr
414                     pUndoDoc;
415     FillDir         eFillDir;
416     FillCmd         eFillCmd;
417     FillDateCmd     eFillDateCmd;
418     double          fStartValue;
419     double          fStepValue;
420     double          fMaxValue;
421     sal_uLong           nStartChangeAction;
422     sal_uLong           nEndChangeAction;
423 
424     void            SetChangeTrack();
425 };
426 
427 class ScUndoMerge: public ScSimpleUndo
428 {
429 public:
430                     ScUndoMerge( ScDocShell* pNewDocShell, const ScCellMergeOption& rOption,
431                                  bool bMergeContents, ScDocumentUniquePtr pUndoDoc,
432                                  std::unique_ptr<SdrUndoAction> pDrawUndo);
433     virtual         ~ScUndoMerge() override;
434 
435     virtual void    Undo() override;
436     virtual void    Redo() override;
437     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
438     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
439 
440     virtual OUString GetComment() const override;
441 
442 private:
443     ScCellMergeOption maOption;
444     bool            mbMergeContents;        // Merge contents in Redo().
445     ScDocumentUniquePtr mxUndoDoc;              // when data is merged
446     std::unique_ptr<SdrUndoAction> mpDrawUndo;
447 
448     void            DoChange( bool bUndo ) const;
449 };
450 
451 class ScUndoAutoFormat: public ScBlockUndo
452 {
453 public:
454                     ScUndoAutoFormat( ScDocShell* pNewDocShell,
455                                       const ScRange& rRange, ScDocumentUniquePtr pNewUndoDoc,
456                                       const ScMarkData& rMark,
457                                       bool bNewSize, sal_uInt16 nNewFormatNo );
458     virtual         ~ScUndoAutoFormat() override;
459 
460     virtual void    Undo() override;
461     virtual void    Redo() override;
462     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
463     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
464 
465     virtual OUString GetComment() const override;
466 
467 private:
468     ScDocumentUniquePtr
469                     pUndoDoc;       // deleted data
470     ScMarkData      aMarkData;
471     bool            bSize;
472     sal_uInt16      nFormatNo;
473 };
474 
475 class ScUndoReplace: public ScSimpleUndo
476 {
477 public:
478                     ScUndoReplace( ScDocShell* pNewDocShell,
479                                    const ScMarkData& rMark,
480                                    SCCOL nCurX, SCROW nCurY, SCTAB nCurZ,
481                                    const OUString& rNewUndoStr, ScDocumentUniquePtr pNewUndoDoc,
482                                    const SvxSearchItem* pItem );
483     virtual         ~ScUndoReplace() override;
484 
485     virtual void    Undo() override;
486     virtual void    Redo() override;
487     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
488     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
489 
490     virtual OUString GetComment() const override;
491 
492 private:
493     ScAddress       aCursorPos;
494     ScMarkData      aMarkData;
495     OUString        aUndoStr;           // Data at single selection
496     ScDocumentUniquePtr pUndoDoc;           // Block mark and deleted data
497     std::unique_ptr<SvxSearchItem> pSearchItem;
498     sal_uLong           nStartChangeAction;
499     sal_uLong           nEndChangeAction;
500 
501             void    SetChangeTrack();
502 };
503 
504 class ScUndoTabOp: public ScSimpleUndo
505 {
506 public:
507                     ScUndoTabOp( ScDocShell* pNewDocShell,
508                                  SCCOL nStartX, SCROW nStartY, SCTAB nStartZ,
509                                  SCCOL nEndX,   SCROW nEndY,   SCTAB nEndZ,
510                                  ScDocumentUniquePtr pNewUndoDoc,
511                                  const ScRefAddress& rFormulaCell,
512                                  const ScRefAddress& rFormulaEnd,
513                                  const ScRefAddress& rRowCell,
514                                  const ScRefAddress& rColCell,
515                                  ScTabOpParam::Mode eMode );
516     virtual         ~ScUndoTabOp() override;
517 
518     virtual void    Undo() override;
519     virtual void    Redo() override;
520     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
521     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
522 
523     virtual OUString GetComment() const override;
524 
525 private:
526     ScRange         aRange;
527     ScDocumentUniquePtr
528                     pUndoDoc;       // Deleted data
529     ScRefAddress    theFormulaCell;
530     ScRefAddress    theFormulaEnd;
531     ScRefAddress    theRowCell;
532     ScRefAddress    theColCell;
533     ScTabOpParam::Mode meMode;
534 };
535 
536 class ScUndoConversion : public ScSimpleUndo
537 {
538 public:
539 
540                     ScUndoConversion( ScDocShell* pNewDocShell, const ScMarkData& rMark,
541                                       SCCOL nCurX, SCROW nCurY, SCTAB nCurZ, ScDocumentUniquePtr pNewUndoDoc,
542                                       SCCOL nNewX, SCROW nNewY, SCTAB nNewZ, ScDocumentUniquePtr pNewRedoDoc,
543                                       const ScConversionParam& rConvParam );
544     virtual         ~ScUndoConversion() override;
545 
546     virtual void    Undo() override;
547     virtual void    Redo() override;
548     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
549     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
550 
551     virtual OUString GetComment() const override;
552 
553 private:
554     ScMarkData      aMarkData;
555     ScAddress       aCursorPos;
556     ScDocumentUniquePtr pUndoDoc;           // Block mark and deleted data
557     ScAddress       aNewCursorPos;
558     ScDocumentUniquePtr pRedoDoc;           // Block mark and new data
559     sal_uLong       nStartChangeAction;
560     sal_uLong       nEndChangeAction;
561     ScConversionParam maConvParam;        /// Conversion type and parameters.
562 
563     void            DoChange( ScDocument* pRefDoc, const ScAddress& rCursorPos );
564     void            SetChangeTrack();
565 };
566 
567 class ScUndoRefConversion: public ScSimpleUndo
568 {
569 public:
570                     ScUndoRefConversion( ScDocShell* pNewDocShell,
571                                          const ScRange& aMarkRange, const ScMarkData& rMark,
572                                          ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc, bool bNewMulti);
573     virtual         ~ScUndoRefConversion() override;
574 
575     virtual void    Undo() override;
576     virtual void    Redo() override;
577     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
578     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
579 
580     virtual OUString GetComment() const override;
581 
582 private:
583     ScMarkData          aMarkData;
584     ScDocumentUniquePtr pUndoDoc;
585     ScDocumentUniquePtr pRedoDoc;
586     ScRange             aRange;
587     bool                bMulti;
588     sal_uLong           nStartChangeAction;
589     sal_uLong           nEndChangeAction;
590 
591     void                DoChange( ScDocument* pRefDoc);
592     void                SetChangeTrack();
593 };
594 
595 class ScUndoListNames: public ScBlockUndo
596 {
597 public:
598     ScUndoListNames(ScDocShell* pNewDocShell,
599                     const ScRange& rRange,
600                     ScDocumentUniquePtr pNewUndoDoc, ScDocumentUniquePtr pNewRedoDoc);
601 
602     virtual void    Undo() override;
603     virtual void    Redo() override;
604     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
605     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
606 
607     virtual OUString GetComment() const override;
608 
609 private:
610     ScDocumentUniquePtr xUndoDoc;
611     ScDocumentUniquePtr xRedoDoc;
612 
613     void            DoChange( ScDocument* pSrcDoc ) const;
614 };
615 
616 class ScUndoConditionalFormat : public ScSimpleUndo
617 {
618 public:
619     ScUndoConditionalFormat( ScDocShell* pNewDocShell,
620             ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, const ScRange& rRange);
621     virtual         ~ScUndoConditionalFormat() override;
622 
623     virtual void    Undo() override;
624     virtual void    Redo() override;
625     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
626     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
627 
628     virtual OUString GetComment() const override;
629 
630 private:
631     void DoChange(ScDocument* pDoc);
632     ScDocumentUniquePtr mpUndoDoc;
633     ScDocumentUniquePtr mpRedoDoc;
634     ScRange maRange;
635 };
636 
637 class ScUndoConditionalFormatList : public ScSimpleUndo
638 {
639 public:
640     ScUndoConditionalFormatList( ScDocShell* pNewDocShell,
641             ScDocumentUniquePtr pUndoDoc, ScDocumentUniquePtr pRedoDoc, SCTAB nTab);
642     virtual         ~ScUndoConditionalFormatList() override;
643 
644     virtual void    Undo() override;
645     virtual void    Redo() override;
646     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
647     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
648 
649     virtual OUString GetComment() const override;
650 
651 private:
652     void DoChange(const ScDocument* pDoc);
653     ScDocumentUniquePtr mpUndoDoc;
654     ScDocumentUniquePtr mpRedoDoc;
655     SCTAB mnTab;
656 };
657 
658 class ScUndoUseScenario: public ScSimpleUndo
659 {
660 public:
661                     ScUndoUseScenario( ScDocShell* pNewDocShell,
662                                        const ScMarkData& rMark,
663                                        const ScArea& rDestArea, ScDocumentUniquePtr pNewUndoDoc,
664                                        const OUString& rNewName );
665     virtual         ~ScUndoUseScenario() override;
666 
667     virtual void    Undo() override;
668     virtual void    Redo() override;
669     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
670     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
671 
672     virtual OUString GetComment() const override;
673 
674 private:
675     ScDocumentUniquePtr
676                     pUndoDoc;
677     ScRange         aRange;
678     ScMarkData      aMarkData;
679     OUString        aName;
680 };
681 
682 class ScUndoSelectionStyle: public ScSimpleUndo
683 {
684 public:
685                     ScUndoSelectionStyle( ScDocShell* pNewDocShell,
686                                           const ScMarkData& rMark,
687                                           const ScRange& rRange,
688                                           const OUString& rName,
689                                           ScDocumentUniquePtr pNewUndoDoc );
690     virtual         ~ScUndoSelectionStyle() override;
691 
692     virtual void    Undo() override;
693     virtual void    Redo() override;
694     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
695     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
696 
697     virtual OUString GetComment() const override;
698 
699 private:
700     ScMarkData      aMarkData;
701     ScDocumentUniquePtr
702                     pUndoDoc;
703     OUString        aStyleName;
704     ScRange         aRange;
705 
706     void            DoChange( const bool bUndo );
707 };
708 
709 class ScUndoRefreshLink: public ScSimpleUndo
710 {
711 public:
712     ScUndoRefreshLink(ScDocShell* pNewDocShell,
713                       ScDocumentUniquePtr pNewUndoDoc);
714 
715     virtual void    Undo() override;
716     virtual void    Redo() override;
717     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
718     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
719 
720     virtual OUString GetComment() const override;
721 
722 private:
723     ScDocumentUniquePtr xUndoDoc;
724     ScDocumentUniquePtr xRedoDoc;
725 };
726 
727 class ScUndoEnterMatrix: public ScBlockUndo
728 {
729 public:
730                     ScUndoEnterMatrix( ScDocShell* pNewDocShell,
731                                        const ScRange& rArea,
732                                        ScDocumentUniquePtr pNewUndoDoc,
733                                        const OUString& rForm );
734     virtual         ~ScUndoEnterMatrix() override;
735 
736     virtual void    Undo() override;
737     virtual void    Redo() override;
738     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
739     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
740 
741     virtual OUString GetComment() const override;
742 
743 private:
744     ScDocumentUniquePtr
745                     pUndoDoc;
746     OUString        aFormula;
747     sal_uLong       nStartChangeAction;
748     sal_uLong       nEndChangeAction;
749 
750     void            SetChangeTrack();
751 };
752 
753 class ScUndoInsertAreaLink : public ScSimpleUndo
754 {
755 public:
756                     ScUndoInsertAreaLink( ScDocShell* pShell,
757                                           const OUString& rDocName,
758                                           const OUString& rFltName, const OUString& rOptions,
759                                           const OUString& rAreaName, const ScRange& rDestRange,
760                                           sal_uLong nRefreshDelay );
761     virtual         ~ScUndoInsertAreaLink() override;
762 
763     virtual void    Undo() override;
764     virtual void    Redo() override;
765     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
766     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
767 
768     virtual OUString GetComment() const override;
769 
770 private:
771     OUString        aDocName;
772     OUString        aFltName;
773     OUString        aOptions;
774     OUString        aAreaName;
775     ScRange         aRange;
776     sal_uLong           nRefreshDelay;
777 };
778 
779 class ScUndoRemoveAreaLink : public ScSimpleUndo
780 {
781 public:
782                     ScUndoRemoveAreaLink( ScDocShell* pShell,
783                                           const OUString& rDocName,
784                                           const OUString& rFltName, const OUString& rOptions,
785                                           const OUString& rAreaName, const ScRange& rDestRange,
786                                           sal_uLong nRefreshDelay );
787     virtual         ~ScUndoRemoveAreaLink() override;
788 
789     virtual void    Undo() override;
790     virtual void    Redo() override;
791     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
792     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
793 
794     virtual OUString GetComment() const override;
795 
796 private:
797     OUString        aDocName;
798     OUString        aFltName;
799     OUString        aOptions;
800     OUString        aAreaName;
801     ScRange         aRange;
802     sal_uLong           nRefreshDelay;
803 };
804 
805 class ScUndoUpdateAreaLink : public ScSimpleUndo        //! also change BlockUndo?
806 {
807 public:
808     ScUndoUpdateAreaLink(ScDocShell* pShell,
809                          const OUString& rOldD,
810                          const OUString& rOldF, const OUString& rOldO,
811                          const OUString& rOldA, const ScRange& rOldR,
812                          sal_uLong nOldRD,
813                          const OUString& rNewD,
814                          const OUString& rNewF, const OUString& rNewO,
815                          const OUString& rNewA, const ScRange& rNewR,
816                          sal_uLong nNewRD,
817                          ScDocumentUniquePtr pUndo, ScDocumentUniquePtr pRedo,
818                          bool bDoInsert);
819 
820     virtual void    Undo() override;
821     virtual void    Redo() override;
822     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
823     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
824 
825     virtual OUString GetComment() const override;
826 
827 private:
828     OUString        aOldDoc;
829     OUString        aOldFlt;
830     OUString        aOldOpt;
831     OUString        aOldArea;
832     ScRange         aOldRange;
833     OUString        aNewDoc;
834     OUString        aNewFlt;
835     OUString        aNewOpt;
836     OUString        aNewArea;
837     ScRange         aNewRange;
838     ScDocumentUniquePtr xUndoDoc;
839     ScDocumentUniquePtr xRedoDoc;
840     sal_uLong       nOldRefresh;
841     sal_uLong       nNewRefresh;
842     bool            bWithInsert;
843 
844     void            DoChange( const bool bUndo ) const;
845 };
846 
847 class ScUndoIndent: public ScBlockUndo
848 {
849 public:
850                     ScUndoIndent( ScDocShell* pNewDocShell, const ScMarkData& rMark,
851                                   ScDocumentUniquePtr pNewUndoDoc, bool bIncrement );
852     virtual         ~ScUndoIndent() override;
853 
854     virtual void    Undo() override;
855     virtual void    Redo() override;
856     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
857     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
858 
859     virtual OUString GetComment() const override;
860 
861 private:
862     ScMarkData      aMarkData;
863     ScDocumentUniquePtr
864                     pUndoDoc;
865     bool            bIsIncrement;
866 };
867 
868 class ScUndoTransliterate: public ScBlockUndo
869 {
870 public:
871                     ScUndoTransliterate( ScDocShell* pNewDocShell, const ScMarkData& rMark,
872                                         ScDocumentUniquePtr pNewUndoDoc, TransliterationFlags nType );
873     virtual         ~ScUndoTransliterate() override;
874 
875     virtual void    Undo() override;
876     virtual void    Redo() override;
877     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
878     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
879 
880     virtual OUString GetComment() const override;
881 
882 private:
883     ScMarkData      aMarkData;
884     ScDocumentUniquePtr
885                     pUndoDoc;
886     TransliterationFlags
887                     nTransliterationType;
888 };
889 
890 class ScUndoClearItems: public ScBlockUndo
891 {
892 public:
893                     ScUndoClearItems( ScDocShell* pNewDocShell, const ScMarkData& rMark,
894                                       ScDocumentUniquePtr pNewUndoDoc, const sal_uInt16* pW );
895     virtual         ~ScUndoClearItems() override;
896 
897     virtual void    Undo() override;
898     virtual void    Redo() override;
899     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
900     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
901 
902     virtual OUString GetComment() const override;
903 
904 private:
905     ScMarkData      aMarkData;
906     ScDocumentUniquePtr
907                     pUndoDoc;
908     std::unique_ptr<sal_uInt16[]>
909                     pWhich;
910 };
911 
912 class ScUndoRemoveBreaks: public ScSimpleUndo
913 {
914 public:
915                     ScUndoRemoveBreaks( ScDocShell* pNewDocShell,
916                                     SCTAB nNewTab, ScDocumentUniquePtr pNewUndoDoc );
917     virtual         ~ScUndoRemoveBreaks() override;
918 
919     virtual void    Undo() override;
920     virtual void    Redo() override;
921     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
922     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
923 
924     virtual OUString GetComment() const override;
925 
926 private:
927     SCTAB           nTab;
928     ScDocumentUniquePtr
929                     pUndoDoc;
930 };
931 
932 class ScUndoRemoveMerge: public ScBlockUndo
933 {
934 public:
935                     ScUndoRemoveMerge( ScDocShell* pNewDocShell,
936                                        const ScCellMergeOption& rOption,
937                                        ScDocumentUniquePtr pNewUndoDoc );
938                     ScUndoRemoveMerge( ScDocShell* pNewDocShell,
939                                        const ScRange& rRange,
940                                        ScDocumentUniquePtr pNewUndoDoc );
941     virtual         ~ScUndoRemoveMerge() override;
942 
943     virtual void    Undo() override;
944     virtual void    Redo() override;
945     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
946     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
947 
948     virtual OUString GetComment() const override;
949 
950     ScDocument*     GetUndoDoc();
951     void            AddCellMergeOption( const ScCellMergeOption& rOption );
952 
953 private:
954     void            SetCurTab();
955 
956     std::vector<ScCellMergeOption> maOptions;
957     ScDocumentUniquePtr    pUndoDoc;
958 };
959 
960 class ScUndoBorder: public ScBlockUndo
961 {
962 public:
963     ScUndoBorder(ScDocShell* pNewDocShell,
964                  const ScRangeList& rRangeList,
965                  ScDocumentUniquePtr pNewUndoDoc,
966                  const SvxBoxItem& rNewOuter,
967                  const SvxBoxInfoItem& rNewInner);
968 
969     virtual void    Undo() override;
970     virtual void    Redo() override;
971     virtual void    Repeat(SfxRepeatTarget& rTarget) override;
972     virtual bool    CanRepeat(SfxRepeatTarget& rTarget) const override;
973 
974     virtual OUString GetComment() const override;
975 
976 private:
977     ScDocumentUniquePtr xUndoDoc;
978     std::unique_ptr<ScRangeList> xRanges;
979     std::unique_ptr<SvxBoxItem> xOuter;
980     std::unique_ptr<SvxBoxInfoItem> xInner;
981 };
982 
983 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
984