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 <formula/grammar.hxx>
25 #include <tools/color.hxx>
26 #include "tabbgcolor.hxx"
36 class ScPrintRangeSaver
;
38 class ScDocProtection
;
39 class ScTableProtection
;
42 class ScUndoInsertTab
: public ScSimpleUndo
46 ScDocShell
* pNewDocShell
,
49 const OUString
& rNewName
);
50 virtual ~ScUndoInsertTab();
52 virtual void Undo() override
;
53 virtual void Redo() override
;
54 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
55 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
57 virtual OUString
GetComment() const override
;
61 SdrUndoAction
* pDrawUndo
;
62 sal_uLong nEndChangeAction
;
66 void SetChangeTrack();
69 class ScUndoInsertTables
: public ScSimpleUndo
73 ScDocShell
* pNewDocShell
,
75 std::vector
<OUString
>& newNameList
);
76 virtual ~ScUndoInsertTables();
78 virtual void Undo() override
;
79 virtual void Redo() override
;
80 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
81 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
83 virtual OUString
GetComment() const override
;
87 SdrUndoAction
* pDrawUndo
;
88 std::vector
<OUString
> aNameList
;
89 sal_uLong nStartChangeAction
;
90 sal_uLong nEndChangeAction
;
93 void SetChangeTrack();
96 class ScUndoDeleteTab
: public ScMoveUndo
100 ScDocShell
* pNewDocShell
,
101 const std::vector
<SCTAB
> &theTabs
, //SCTAB nNewTab,
102 ScDocument
* pUndoDocument
,
103 ScRefUndoData
* pRefData
);
104 virtual ~ScUndoDeleteTab();
106 virtual void Undo() override
;
107 virtual void Redo() override
;
108 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
109 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
111 virtual OUString
GetComment() const override
;
114 std::vector
<SCTAB
> theTabs
;
115 sal_uLong nStartChangeAction
;
116 sal_uLong nEndChangeAction
;
118 void SetChangeTrack();
121 class ScUndoRenameTab
: public ScSimpleUndo
125 ScDocShell
* pNewDocShell
,
127 const OUString
& rOldName
,
128 const OUString
& rNewName
);
129 virtual ~ScUndoRenameTab();
131 virtual void Undo() override
;
132 virtual void Redo() override
;
133 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
134 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
136 virtual OUString
GetComment() const override
;
143 void DoChange( SCTAB nTab
, const OUString
& rName
) const;
146 class ScUndoMoveTab
: public ScSimpleUndo
150 ScDocShell
* pNewDocShell
,
151 ::std::vector
<SCTAB
>* pOldTabs
,
152 ::std::vector
<SCTAB
>* pNewTabs
,
153 ::std::vector
< OUString
>* pOldNames
= nullptr,
154 ::std::vector
< OUString
>* pNewNames
= nullptr );
156 virtual ~ScUndoMoveTab();
158 virtual void Undo() override
;
159 virtual void Redo() override
;
160 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
161 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
163 virtual OUString
GetComment() const override
;
166 std::shared_ptr
< ::std::vector
<SCTAB
> > mpOldTabs
;
167 std::shared_ptr
< ::std::vector
<SCTAB
> > mpNewTabs
;
168 std::shared_ptr
< ::std::vector
< OUString
> > mpOldNames
;
169 std::shared_ptr
< ::std::vector
< OUString
> > mpNewNames
;
171 void DoChange( bool bUndo
) const;
174 class ScUndoCopyTab
: public ScSimpleUndo
178 ScDocShell
* pNewDocShell
,
179 ::std::vector
<SCTAB
>* pOldTabs
,
180 ::std::vector
<SCTAB
>* pNewTabs
,
181 ::std::vector
< OUString
>* pNewNames
= nullptr );
183 virtual ~ScUndoCopyTab();
185 virtual void Undo() override
;
186 virtual void Redo() override
;
187 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
188 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
190 virtual OUString
GetComment() const override
;
193 std::shared_ptr
< ::std::vector
<SCTAB
> > mpOldTabs
;
194 std::shared_ptr
< ::std::vector
<SCTAB
> > mpNewTabs
;
195 std::shared_ptr
< ::std::vector
< OUString
> > mpNewNames
;
196 SdrUndoAction
* pDrawUndo
;
198 void DoChange() const;
201 class ScUndoTabColor
: public ScSimpleUndo
205 ScDocShell
* pNewDocShell
,
207 const Color
& aOTabBgColor
,
208 const Color
& aNTabBgColor
);
210 ScDocShell
* pNewDocShell
,
211 const ScUndoTabColorInfo::List
& rUndoTabColorList
);
212 virtual ~ScUndoTabColor();
214 virtual void Undo() override
;
215 virtual void Redo() override
;
216 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
217 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
219 virtual OUString
GetComment() const override
;
222 ScUndoTabColorInfo::List aTabColorList
;
224 void DoChange(bool bUndoType
) const;
227 class ScUndoMakeScenario
: public ScSimpleUndo
231 ScDocShell
* pNewDocShell
,
232 SCTAB nSrc
, SCTAB nDest
,
233 const OUString
& rN
, const OUString
& rC
,
234 const Color
& rCol
, sal_uInt16 nF
,
235 const ScMarkData
& rMark
);
236 virtual ~ScUndoMakeScenario();
238 virtual void Undo() override
;
239 virtual void Redo() override
;
240 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
241 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
243 virtual OUString
GetComment() const override
;
246 std::unique_ptr
<ScMarkData
> mpMarkData
;
253 SdrUndoAction
* pDrawUndo
;
256 class ScUndoImportTab
: public ScSimpleUndo
261 SCTAB nNewTab
, SCTAB nNewCount
);
262 virtual ~ScUndoImportTab();
264 virtual void Undo() override
;
265 virtual void Redo() override
;
266 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
267 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
269 virtual OUString
GetComment() const override
;
274 ScDocument
* pRedoDoc
;
275 SdrUndoAction
* pDrawUndo
;
277 void DoChange() const;
280 class ScUndoRemoveLink
: public ScSimpleUndo
283 ScUndoRemoveLink( // Call before delete!
285 const OUString
& rDoc
);
286 virtual ~ScUndoRemoveLink();
288 virtual void Undo() override
;
289 virtual void Redo() override
;
290 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
291 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
293 virtual OUString
GetComment() const override
;
299 sal_uLong nRefreshDelay
;
305 void DoChange( bool bLink
) const;
308 class ScUndoShowHideTab
: public ScSimpleUndo
313 const std::vector
<SCTAB
>& newUndoTabs
,
315 virtual ~ScUndoShowHideTab();
317 virtual void Undo() override
;
318 virtual void Redo() override
;
319 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
320 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
322 virtual OUString
GetComment() const override
;
325 std::vector
<SCTAB
> undoTabs
;
328 void DoChange( bool bShow
) const;
331 /** This class implements undo & redo of document protect & unprotect
333 class ScUndoDocProtect
: public ScSimpleUndo
336 ScUndoDocProtect(ScDocShell
* pShell
, ::std::unique_ptr
<ScDocProtection
> && pProtectSettings
);
337 virtual ~ScUndoDocProtect();
339 virtual void Undo() override
;
340 virtual void Redo() override
;
341 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
342 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
344 virtual OUString
GetComment() const override
;
347 ::std::unique_ptr
<ScDocProtection
> mpProtectSettings
;
349 void DoProtect(bool bProtect
);
352 /** This class implements undo & redo of both protect and unprotect of
354 class ScUndoTabProtect
: public ScSimpleUndo
357 ScUndoTabProtect(ScDocShell
* pShell
, SCTAB nTab
,
358 std::unique_ptr
<ScTableProtection
> && pProtectSettings
);
359 virtual ~ScUndoTabProtect();
361 virtual void Undo() override
;
362 virtual void Redo() override
;
363 virtual void Repeat(SfxRepeatTarget
& rTarget
) override
;
364 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const override
;
366 virtual OUString
GetComment() const override
;
370 ::std::unique_ptr
<ScTableProtection
> mpProtectSettings
;
372 void DoProtect(bool bProtect
);
375 class ScUndoPrintRange
: public ScSimpleUndo
378 ScUndoPrintRange( ScDocShell
* pShell
, SCTAB nNewTab
,
379 ScPrintRangeSaver
* pOld
, ScPrintRangeSaver
* pNew
);
380 virtual ~ScUndoPrintRange();
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 ScPrintRangeSaver
* pOldRanges
;
392 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 sal_uInt16 nOF
, sal_uInt16 nNF
);
407 virtual ~ScUndoScenarioFlags();
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 sal_uInt16 nOldFlags
;
425 sal_uInt16 nNewFlags
;
428 class ScUndoRenameObject
: public ScSimpleUndo
432 ScDocShell
* pNewDocShell
, const OUString
& rPN
,
433 const OUString
& rON
, const OUString
& rNN
);
435 virtual ~ScUndoRenameObject();
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();
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: */