1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include "undobase.hxx"
23 #include <tools/color.hxx>
24 #include <tabbgcolor.hxx>
31 class ScPrintRangeSaver
;
33 class ScDocProtection
;
34 class ScTableProtection
;
37 class ScUndoInsertTab
: public ScSimpleUndo
41 ScDocShell
* pNewDocShell
,
45 virtual ~ScUndoInsertTab() override
;
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
;
52 virtual OUString
GetComment() const override
;
56 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
57 sal_uLong nEndChangeAction
;
61 void SetChangeTrack();
64 class ScUndoInsertTables
: public ScSimpleUndo
68 ScDocShell
* pNewDocShell
,
70 std::vector
<OUString
>&& newNameList
);
71 virtual ~ScUndoInsertTables() override
;
73 virtual void Undo() override
;
74 virtual void Redo() override
;
75 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
76 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
78 virtual OUString
GetComment() const override
;
82 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
83 std::vector
<OUString
> aNameList
;
84 sal_uLong nStartChangeAction
;
85 sal_uLong nEndChangeAction
;
88 void SetChangeTrack();
91 class ScUndoDeleteTab
: public ScMoveUndo
95 ScDocShell
* pNewDocShell
,
96 const std::vector
<SCTAB
> &theTabs
, //SCTAB nNewTab,
97 ScDocumentUniquePtr pUndoDocument
,
98 std::unique_ptr
<ScRefUndoData
> pRefData
);
99 virtual ~ScUndoDeleteTab() override
;
101 virtual void Undo() override
;
102 virtual void Redo() override
;
103 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
104 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
106 virtual OUString
GetComment() const override
;
109 std::vector
<SCTAB
> theTabs
;
110 sal_uLong nStartChangeAction
;
111 sal_uLong nEndChangeAction
;
113 void SetChangeTrack();
116 class ScUndoRenameTab
: public ScSimpleUndo
120 ScDocShell
* pNewDocShell
,
122 const OUString
& rOldName
,
123 const OUString
& rNewName
);
124 virtual ~ScUndoRenameTab() override
;
126 virtual void Undo() override
;
127 virtual void Redo() override
;
128 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
129 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
131 virtual OUString
GetComment() const override
;
138 void DoChange( SCTAB nTab
, const OUString
& rName
) const;
141 class ScUndoMoveTab
: public ScSimpleUndo
145 ScDocShell
* pNewDocShell
,
146 std::unique_ptr
<std::vector
<SCTAB
>> pOldTabs
,
147 std::unique_ptr
<std::vector
<SCTAB
>> pNewTabs
,
148 std::unique_ptr
<std::vector
< OUString
>> pOldNames
= nullptr,
149 std::unique_ptr
<std::vector
< OUString
>> pNewNames
= nullptr );
151 virtual ~ScUndoMoveTab() override
;
153 virtual void Undo() override
;
154 virtual void Redo() override
;
155 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
156 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
158 virtual OUString
GetComment() const override
;
161 std::unique_ptr
< ::std::vector
<SCTAB
> > mpOldTabs
;
162 std::unique_ptr
< ::std::vector
<SCTAB
> > mpNewTabs
;
163 std::unique_ptr
< ::std::vector
< OUString
> > mpOldNames
;
164 std::unique_ptr
< ::std::vector
< OUString
> > mpNewNames
;
166 void DoChange( bool bUndo
) const;
169 class ScUndoCopyTab
: public ScSimpleUndo
173 ScDocShell
* pNewDocShell
,
174 std::unique_ptr
<std::vector
<SCTAB
>> pOldTabs
,
175 std::unique_ptr
<std::vector
<SCTAB
>> pNewTabs
,
176 std::unique_ptr
<std::vector
< OUString
>> pNewNames
= nullptr );
178 virtual ~ScUndoCopyTab() override
;
180 virtual void Undo() override
;
181 virtual void Redo() override
;
182 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
183 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
185 virtual OUString
GetComment() const override
;
188 std::unique_ptr
< ::std::vector
<SCTAB
> > mpOldTabs
;
189 std::unique_ptr
< ::std::vector
<SCTAB
> > mpNewTabs
;
190 std::unique_ptr
< ::std::vector
< OUString
> > mpNewNames
;
191 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
193 void DoChange() const;
196 class ScUndoTabColor
: public ScSimpleUndo
200 ScDocShell
* pNewDocShell
,
202 const Color
& aOTabBgColor
,
203 const Color
& aNTabBgColor
);
205 ScDocShell
* pNewDocShell
,
206 ScUndoTabColorInfo::List
&& rUndoTabColorList
);
207 virtual ~ScUndoTabColor() override
;
209 virtual void Undo() override
;
210 virtual void Redo() override
;
211 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
212 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
214 virtual OUString
GetComment() const override
;
217 ScUndoTabColorInfo::List aTabColorList
;
219 void DoChange(bool bUndoType
) const;
222 class ScUndoMakeScenario
: public ScSimpleUndo
226 ScDocShell
* pNewDocShell
,
227 SCTAB nSrc
, SCTAB nDest
,
228 OUString aN
, OUString aC
,
229 const Color
& rCol
, ScScenarioFlags nF
,
230 const ScMarkData
& rMark
);
231 virtual ~ScUndoMakeScenario() override
;
233 virtual void Undo() override
;
234 virtual void Redo() override
;
235 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
236 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
238 virtual OUString
GetComment() const override
;
241 std::unique_ptr
<ScMarkData
> mpMarkData
;
247 ScScenarioFlags nFlags
;
248 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
251 class ScUndoImportTab
: public ScSimpleUndo
256 SCTAB nNewTab
, SCTAB nNewCount
);
257 virtual ~ScUndoImportTab() override
;
259 virtual void Undo() override
;
260 virtual void Redo() override
;
261 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
262 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
264 virtual OUString
GetComment() const override
;
269 ScDocumentUniquePtr xRedoDoc
;
270 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
272 void DoChange() const;
275 class ScUndoRemoveLink
: public ScSimpleUndo
278 ScUndoRemoveLink( // Call before delete!
281 virtual ~ScUndoRemoveLink() override
;
283 virtual void Undo() override
;
284 virtual void Redo() override
;
285 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
286 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
288 virtual OUString
GetComment() const override
;
294 sal_Int32 nRefreshDelay
;
296 std::unique_ptr
<SCTAB
[]>
298 std::unique_ptr
<ScLinkMode
[]>
300 std::unique_ptr
<OUString
[]>
303 void DoChange( bool bLink
) const;
306 class ScUndoShowHideTab
: public ScSimpleUndo
311 std::vector
<SCTAB
>&& newUndoTabs
,
313 virtual ~ScUndoShowHideTab() override
;
315 virtual void Undo() override
;
316 virtual void Redo() override
;
317 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
318 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
320 virtual OUString
GetComment() const override
;
323 std::vector
<SCTAB
> undoTabs
;
326 void DoChange( bool bShow
) const;
329 /** This class implements undo & redo of document protect & unprotect
331 class ScUndoDocProtect
: public ScSimpleUndo
334 ScUndoDocProtect(ScDocShell
* pShell
, ::std::unique_ptr
<ScDocProtection
> && pProtectSettings
);
335 virtual ~ScUndoDocProtect() override
;
337 virtual void Undo() override
;
338 virtual void Redo() override
;
339 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
340 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
342 virtual OUString
GetComment() const override
;
345 ::std::unique_ptr
<ScDocProtection
> mpProtectSettings
;
347 void DoProtect(bool bProtect
);
350 /** This class implements undo & redo of both protect and unprotect of
352 class ScUndoTabProtect
: public ScSimpleUndo
355 ScUndoTabProtect(ScDocShell
* pShell
, SCTAB nTab
,
356 std::unique_ptr
<ScTableProtection
> && pProtectSettings
);
357 virtual ~ScUndoTabProtect() override
;
359 virtual void Undo() override
;
360 virtual void Redo() override
;
361 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
362 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
364 virtual OUString
GetComment() const override
;
368 ::std::unique_ptr
<ScTableProtection
> mpProtectSettings
;
370 void DoProtect(bool bProtect
);
373 class ScUndoPrintRange
: public ScSimpleUndo
376 ScUndoPrintRange( ScDocShell
* pShell
, SCTAB nNewTab
,
377 std::unique_ptr
<ScPrintRangeSaver
> pOld
,
378 std::unique_ptr
<ScPrintRangeSaver
> pNew
);
379 virtual ~ScUndoPrintRange() override
;
381 virtual void Undo() override
;
382 virtual void Redo() override
;
383 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
384 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
386 virtual OUString
GetComment() const override
;
390 std::unique_ptr
<ScPrintRangeSaver
> pOldRanges
;
391 std::unique_ptr
<ScPrintRangeSaver
> pNewRanges
;
393 void DoChange( bool bUndo
);
396 class ScUndoScenarioFlags
: public ScSimpleUndo
400 ScDocShell
* pNewDocShell
, SCTAB nT
,
401 OUString aON
, OUString aNN
,
402 OUString aOC
, OUString aNC
,
403 const Color
& rOCol
, const Color
& rNCol
,
404 ScScenarioFlags nOF
, ScScenarioFlags nNF
);
406 virtual ~ScUndoScenarioFlags() override
;
408 virtual void Undo() override
;
409 virtual void Redo() override
;
410 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
411 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
413 virtual OUString
GetComment() const override
;
419 OUString aOldComment
;
420 OUString aNewComment
;
423 ScScenarioFlags nOldFlags
;
424 ScScenarioFlags nNewFlags
;
427 class ScUndoRenameObject
: public ScSimpleUndo
431 ScDocShell
* pNewDocShell
, OUString aPN
,
432 OUString aON
, OUString aNN
);
434 virtual ~ScUndoRenameObject() override
;
436 virtual void Undo() override
;
437 virtual void Redo() override
;
438 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
439 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
441 virtual OUString
GetComment() const override
;
444 OUString aPersistName
; // to find object (works only for OLE objects)
448 SdrObject
* GetObject();
451 class ScUndoLayoutRTL
: public ScSimpleUndo
454 ScUndoLayoutRTL( ScDocShell
* pShell
, SCTAB nNewTab
, bool bNewRTL
);
455 virtual ~ScUndoLayoutRTL() override
;
457 virtual void Undo() override
;
458 virtual void Redo() override
;
459 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
460 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
462 virtual OUString
GetComment() const override
;
468 void DoChange( bool bNew
);
471 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */