1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SC_SOURCE_UI_INC_UNDOTAB_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_UNDOTAB_HXX
23 #include "undobase.hxx"
24 #include <tools/color.hxx>
25 #include <tabbgcolor.hxx>
32 class ScPrintRangeSaver
;
34 class ScDocProtection
;
35 class ScTableProtection
;
38 class ScUndoInsertTab
: public ScSimpleUndo
42 ScDocShell
* pNewDocShell
,
45 const OUString
& rNewName
);
46 virtual ~ScUndoInsertTab() override
;
48 virtual void Undo() override
;
49 virtual void Redo() override
;
50 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
51 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
53 virtual OUString
GetComment() const override
;
57 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
58 sal_uLong nEndChangeAction
;
62 void SetChangeTrack();
65 class ScUndoInsertTables
: public ScSimpleUndo
69 ScDocShell
* pNewDocShell
,
71 const std::vector
<OUString
>& newNameList
);
72 virtual ~ScUndoInsertTables() override
;
74 virtual void Undo() override
;
75 virtual void Redo() override
;
76 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
77 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
79 virtual OUString
GetComment() const override
;
83 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
84 std::vector
<OUString
> aNameList
;
85 sal_uLong nStartChangeAction
;
86 sal_uLong nEndChangeAction
;
89 void SetChangeTrack();
92 class ScUndoDeleteTab
: public ScMoveUndo
96 ScDocShell
* pNewDocShell
,
97 const std::vector
<SCTAB
> &theTabs
, //SCTAB nNewTab,
98 ScDocumentUniquePtr pUndoDocument
,
99 std::unique_ptr
<ScRefUndoData
> pRefData
);
100 virtual ~ScUndoDeleteTab() override
;
102 virtual void Undo() override
;
103 virtual void Redo() override
;
104 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
105 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
107 virtual OUString
GetComment() const override
;
110 std::vector
<SCTAB
> theTabs
;
111 sal_uLong nStartChangeAction
;
112 sal_uLong nEndChangeAction
;
114 void SetChangeTrack();
117 class ScUndoRenameTab
: public ScSimpleUndo
121 ScDocShell
* pNewDocShell
,
123 const OUString
& rOldName
,
124 const OUString
& rNewName
);
125 virtual ~ScUndoRenameTab() override
;
127 virtual void Undo() override
;
128 virtual void Redo() override
;
129 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
130 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
132 virtual OUString
GetComment() const override
;
139 void DoChange( SCTAB nTab
, const OUString
& rName
) const;
142 class ScUndoMoveTab
: public ScSimpleUndo
146 ScDocShell
* pNewDocShell
,
147 std::unique_ptr
<std::vector
<SCTAB
>> pOldTabs
,
148 std::unique_ptr
<std::vector
<SCTAB
>> pNewTabs
,
149 std::unique_ptr
<std::vector
< OUString
>> pOldNames
= nullptr,
150 std::unique_ptr
<std::vector
< OUString
>> pNewNames
= nullptr );
152 virtual ~ScUndoMoveTab() override
;
154 virtual void Undo() override
;
155 virtual void Redo() override
;
156 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
157 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
159 virtual OUString
GetComment() const override
;
162 std::unique_ptr
< ::std::vector
<SCTAB
> > mpOldTabs
;
163 std::unique_ptr
< ::std::vector
<SCTAB
> > mpNewTabs
;
164 std::unique_ptr
< ::std::vector
< OUString
> > mpOldNames
;
165 std::unique_ptr
< ::std::vector
< OUString
> > mpNewNames
;
167 void DoChange( bool bUndo
) const;
170 class ScUndoCopyTab
: public ScSimpleUndo
174 ScDocShell
* pNewDocShell
,
175 std::unique_ptr
<std::vector
<SCTAB
>> pOldTabs
,
176 std::unique_ptr
<std::vector
<SCTAB
>> pNewTabs
,
177 std::unique_ptr
<std::vector
< OUString
>> pNewNames
= nullptr );
179 virtual ~ScUndoCopyTab() override
;
181 virtual void Undo() override
;
182 virtual void Redo() override
;
183 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
184 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
186 virtual OUString
GetComment() const override
;
189 std::unique_ptr
< ::std::vector
<SCTAB
> > mpOldTabs
;
190 std::unique_ptr
< ::std::vector
<SCTAB
> > mpNewTabs
;
191 std::unique_ptr
< ::std::vector
< OUString
> > mpNewNames
;
192 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
194 void DoChange() const;
197 class ScUndoTabColor
: public ScSimpleUndo
201 ScDocShell
* pNewDocShell
,
203 const Color
& aOTabBgColor
,
204 const Color
& aNTabBgColor
);
206 ScDocShell
* pNewDocShell
,
207 const ScUndoTabColorInfo::List
& rUndoTabColorList
);
208 virtual ~ScUndoTabColor() override
;
210 virtual void Undo() override
;
211 virtual void Redo() override
;
212 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
213 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
215 virtual OUString
GetComment() const override
;
218 ScUndoTabColorInfo::List aTabColorList
;
220 void DoChange(bool bUndoType
) const;
223 class ScUndoMakeScenario
: public ScSimpleUndo
227 ScDocShell
* pNewDocShell
,
228 SCTAB nSrc
, SCTAB nDest
,
229 const OUString
& rN
, const OUString
& rC
,
230 const Color
& rCol
, ScScenarioFlags nF
,
231 const ScMarkData
& rMark
);
232 virtual ~ScUndoMakeScenario() override
;
234 virtual void Undo() override
;
235 virtual void Redo() override
;
236 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
237 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
239 virtual OUString
GetComment() const override
;
242 std::unique_ptr
<ScMarkData
> mpMarkData
;
248 ScScenarioFlags nFlags
;
249 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
252 class ScUndoImportTab
: public ScSimpleUndo
257 SCTAB nNewTab
, SCTAB nNewCount
);
258 virtual ~ScUndoImportTab() override
;
260 virtual void Undo() override
;
261 virtual void Redo() override
;
262 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
263 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
265 virtual OUString
GetComment() const override
;
270 ScDocumentUniquePtr xRedoDoc
;
271 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
273 void DoChange() const;
276 class ScUndoRemoveLink
: public ScSimpleUndo
279 ScUndoRemoveLink( // Call before delete!
281 const OUString
& rDoc
);
282 virtual ~ScUndoRemoveLink() override
;
284 virtual void Undo() override
;
285 virtual void Redo() override
;
286 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
287 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
289 virtual OUString
GetComment() const override
;
295 sal_uLong nRefreshDelay
;
297 std::unique_ptr
<SCTAB
[]>
299 std::unique_ptr
<ScLinkMode
[]>
301 std::unique_ptr
<OUString
[]>
304 void DoChange( bool bLink
) const;
307 class ScUndoShowHideTab
: public ScSimpleUndo
312 const std::vector
<SCTAB
>& newUndoTabs
,
314 virtual ~ScUndoShowHideTab() override
;
316 virtual void Undo() override
;
317 virtual void Redo() override
;
318 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
319 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
321 virtual OUString
GetComment() const override
;
324 std::vector
<SCTAB
> undoTabs
;
327 void DoChange( bool bShow
) const;
330 /** This class implements undo & redo of document protect & unprotect
332 class ScUndoDocProtect
: public ScSimpleUndo
335 ScUndoDocProtect(ScDocShell
* pShell
, ::std::unique_ptr
<ScDocProtection
> && pProtectSettings
);
336 virtual ~ScUndoDocProtect() override
;
338 virtual void Undo() override
;
339 virtual void Redo() override
;
340 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
341 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
343 virtual OUString
GetComment() const override
;
346 ::std::unique_ptr
<ScDocProtection
> mpProtectSettings
;
348 void DoProtect(bool bProtect
);
351 /** This class implements undo & redo of both protect and unprotect of
353 class ScUndoTabProtect
: public ScSimpleUndo
356 ScUndoTabProtect(ScDocShell
* pShell
, SCTAB nTab
,
357 std::unique_ptr
<ScTableProtection
> && pProtectSettings
);
358 virtual ~ScUndoTabProtect() override
;
360 virtual void Undo() override
;
361 virtual void Redo() override
;
362 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
363 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
365 virtual OUString
GetComment() const override
;
369 ::std::unique_ptr
<ScTableProtection
> mpProtectSettings
;
371 void DoProtect(bool bProtect
);
374 class ScUndoPrintRange
: public ScSimpleUndo
377 ScUndoPrintRange( ScDocShell
* pShell
, SCTAB nNewTab
,
378 std::unique_ptr
<ScPrintRangeSaver
> pOld
,
379 std::unique_ptr
<ScPrintRangeSaver
> pNew
);
380 virtual ~ScUndoPrintRange() override
;
382 virtual void Undo() override
;
383 virtual void Redo() override
;
384 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
385 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
387 virtual OUString
GetComment() const override
;
391 std::unique_ptr
<ScPrintRangeSaver
> pOldRanges
;
392 std::unique_ptr
<ScPrintRangeSaver
> pNewRanges
;
394 void DoChange( bool bUndo
);
397 class ScUndoScenarioFlags
: public ScSimpleUndo
401 ScDocShell
* pNewDocShell
, SCTAB nT
,
402 const OUString
& rON
, const OUString
& rNN
,
403 const OUString
& rOC
, const OUString
& rNC
,
404 const Color
& rOCol
, const Color
& rNCol
,
405 ScScenarioFlags nOF
, ScScenarioFlags nNF
);
407 virtual ~ScUndoScenarioFlags() override
;
409 virtual void Undo() override
;
410 virtual void Redo() override
;
411 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
412 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
414 virtual OUString
GetComment() const override
;
420 OUString aOldComment
;
421 OUString aNewComment
;
424 ScScenarioFlags nOldFlags
;
425 ScScenarioFlags nNewFlags
;
428 class ScUndoRenameObject
: public ScSimpleUndo
432 ScDocShell
* pNewDocShell
, const OUString
& rPN
,
433 const OUString
& rON
, const OUString
& rNN
);
435 virtual ~ScUndoRenameObject() override
;
437 virtual void Undo() override
;
438 virtual void Redo() override
;
439 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
440 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
442 virtual OUString
GetComment() const override
;
445 OUString aPersistName
; // to find object (works only for OLE objects)
449 SdrObject
* GetObject();
452 class ScUndoLayoutRTL
: public ScSimpleUndo
455 ScUndoLayoutRTL( ScDocShell
* pShell
, SCTAB nNewTab
, bool bNewRTL
);
456 virtual ~ScUndoLayoutRTL() override
;
458 virtual void Undo() override
;
459 virtual void Redo() override
;
460 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
461 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
463 virtual OUString
GetComment() const override
;
469 void DoChange( bool bNew
);
474 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */