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"
28 #include <com/sun/star/uno/Sequence.hxx>
30 #include <boost/shared_ptr.hpp>
31 #include <boost/scoped_ptr.hpp>
39 class ScPrintRangeSaver
;
41 class ScDocProtection
;
42 class ScTableProtection
;
45 class ScUndoInsertTab
: public ScSimpleUndo
50 ScDocShell
* pNewDocShell
,
53 const OUString
& rNewName
);
54 virtual ~ScUndoInsertTab();
56 virtual void Undo() SAL_OVERRIDE
;
57 virtual void Redo() SAL_OVERRIDE
;
58 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
59 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
61 virtual OUString
GetComment() const SAL_OVERRIDE
;
65 SdrUndoAction
* pDrawUndo
;
66 sal_uLong nEndChangeAction
;
70 void SetChangeTrack();
73 class ScUndoInsertTables
: public ScSimpleUndo
78 ScDocShell
* pNewDocShell
,
80 std::vector
<OUString
>& newNameList
);
81 virtual ~ScUndoInsertTables();
83 virtual void Undo() SAL_OVERRIDE
;
84 virtual void Redo() SAL_OVERRIDE
;
85 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
86 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
88 virtual OUString
GetComment() const SAL_OVERRIDE
;
92 SdrUndoAction
* pDrawUndo
;
93 std::vector
<OUString
> aNameList
;
94 sal_uLong nStartChangeAction
;
95 sal_uLong nEndChangeAction
;
98 void SetChangeTrack();
101 class ScUndoDeleteTab
: public ScMoveUndo
106 ScDocShell
* pNewDocShell
,
107 const std::vector
<SCTAB
> &theTabs
, //SCTAB nNewTab,
108 ScDocument
* pUndoDocument
,
109 ScRefUndoData
* pRefData
);
110 virtual ~ScUndoDeleteTab();
112 virtual void Undo() SAL_OVERRIDE
;
113 virtual void Redo() SAL_OVERRIDE
;
114 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
115 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
117 virtual OUString
GetComment() const SAL_OVERRIDE
;
120 std::vector
<SCTAB
> theTabs
;
121 sal_uLong nStartChangeAction
;
122 sal_uLong nEndChangeAction
;
124 void SetChangeTrack();
127 class ScUndoRenameTab
: public ScSimpleUndo
132 ScDocShell
* pNewDocShell
,
134 const OUString
& rOldName
,
135 const OUString
& rNewName
);
136 virtual ~ScUndoRenameTab();
138 virtual void Undo() SAL_OVERRIDE
;
139 virtual void Redo() SAL_OVERRIDE
;
140 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
141 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
143 virtual OUString
GetComment() const SAL_OVERRIDE
;
150 void DoChange( SCTAB nTab
, const OUString
& rName
) const;
153 class ScUndoMoveTab
: public ScSimpleUndo
158 ScDocShell
* pNewDocShell
,
159 ::std::vector
<SCTAB
>* pOldTabs
,
160 ::std::vector
<SCTAB
>* pNewTabs
,
161 ::std::vector
< OUString
>* pOldNames
= NULL
,
162 ::std::vector
< OUString
>* pNewNames
= NULL
);
164 virtual ~ScUndoMoveTab();
166 virtual void Undo() SAL_OVERRIDE
;
167 virtual void Redo() SAL_OVERRIDE
;
168 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
169 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
171 virtual OUString
GetComment() const SAL_OVERRIDE
;
174 ::boost::shared_ptr
< ::std::vector
<SCTAB
> > mpOldTabs
;
175 ::boost::shared_ptr
< ::std::vector
<SCTAB
> > mpNewTabs
;
176 ::boost::shared_ptr
< ::std::vector
< OUString
> > mpOldNames
;
177 ::boost::shared_ptr
< ::std::vector
< OUString
> > mpNewNames
;
179 void DoChange( bool bUndo
) const;
182 class ScUndoCopyTab
: public ScSimpleUndo
187 ScDocShell
* pNewDocShell
,
188 ::std::vector
<SCTAB
>* pOldTabs
,
189 ::std::vector
<SCTAB
>* pNewTabs
,
190 ::std::vector
< OUString
>* pNewNames
= NULL
);
192 virtual ~ScUndoCopyTab();
194 virtual void Undo() SAL_OVERRIDE
;
195 virtual void Redo() SAL_OVERRIDE
;
196 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
197 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
199 virtual OUString
GetComment() const SAL_OVERRIDE
;
202 ::boost::shared_ptr
< ::std::vector
<SCTAB
> > mpOldTabs
;
203 ::boost::shared_ptr
< ::std::vector
<SCTAB
> > mpNewTabs
;
204 ::boost::shared_ptr
< ::std::vector
< OUString
> > mpNewNames
;
205 SdrUndoAction
* pDrawUndo
;
207 void DoChange() const;
210 class ScUndoTabColor
: public ScSimpleUndo
215 ScDocShell
* pNewDocShell
,
217 const Color
& aOTabBgColor
,
218 const Color
& aNTabBgColor
);
220 ScDocShell
* pNewDocShell
,
221 const ScUndoTabColorInfo::List
& rUndoTabColorList
);
222 virtual ~ScUndoTabColor();
224 virtual void Undo() SAL_OVERRIDE
;
225 virtual void Redo() SAL_OVERRIDE
;
226 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
227 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
229 virtual OUString
GetComment() const SAL_OVERRIDE
;
232 ScUndoTabColorInfo::List aTabColorList
;
234 void DoChange(bool bUndoType
) const;
237 class ScUndoMakeScenario
: public ScSimpleUndo
242 ScDocShell
* pNewDocShell
,
243 SCTAB nSrc
, SCTAB nDest
,
244 const OUString
& rN
, const OUString
& rC
,
245 const Color
& rCol
, sal_uInt16 nF
,
246 const ScMarkData
& rMark
);
247 virtual ~ScUndoMakeScenario();
249 virtual void Undo() SAL_OVERRIDE
;
250 virtual void Redo() SAL_OVERRIDE
;
251 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
252 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
254 virtual OUString
GetComment() const SAL_OVERRIDE
;
257 boost::scoped_ptr
<ScMarkData
> mpMarkData
;
264 SdrUndoAction
* pDrawUndo
;
267 class ScUndoImportTab
: public ScSimpleUndo
273 SCTAB nNewTab
, SCTAB nNewCount
);
274 virtual ~ScUndoImportTab();
276 virtual void Undo() SAL_OVERRIDE
;
277 virtual void Redo() SAL_OVERRIDE
;
278 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
279 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
281 virtual OUString
GetComment() const SAL_OVERRIDE
;
286 ScDocument
* pRedoDoc
;
287 SdrUndoAction
* pDrawUndo
;
289 void DoChange() const;
292 class ScUndoRemoveLink
: public ScSimpleUndo
296 ScUndoRemoveLink( // Call before delete!
298 const OUString
& rDoc
);
299 virtual ~ScUndoRemoveLink();
301 virtual void Undo() SAL_OVERRIDE
;
302 virtual void Redo() SAL_OVERRIDE
;
303 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
304 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
306 virtual OUString
GetComment() const SAL_OVERRIDE
;
312 sal_uLong nRefreshDelay
;
318 void DoChange( bool bLink
) const;
321 class ScUndoShowHideTab
: public ScSimpleUndo
327 const std::vector
<SCTAB
>& newUndoTabs
,
329 virtual ~ScUndoShowHideTab();
331 virtual void Undo() SAL_OVERRIDE
;
332 virtual void Redo() SAL_OVERRIDE
;
333 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
334 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
336 virtual OUString
GetComment() const SAL_OVERRIDE
;
339 std::vector
<SCTAB
> undoTabs
;
342 void DoChange( bool bShow
) const;
345 /** This class implements undo & redo of document protect & unprotect
347 class ScUndoDocProtect
: public ScSimpleUndo
350 ScUndoDocProtect(ScDocShell
* pShell
, ::std::unique_ptr
<ScDocProtection
> && pProtectSettings
);
351 virtual ~ScUndoDocProtect();
353 virtual void Undo() SAL_OVERRIDE
;
354 virtual void Redo() SAL_OVERRIDE
;
355 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
356 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
358 virtual OUString
GetComment() const SAL_OVERRIDE
;
361 ::std::unique_ptr
<ScDocProtection
> mpProtectSettings
;
363 void DoProtect(bool bProtect
);
366 /** This class implements undo & redo of both protect and unprotect of
368 class ScUndoTabProtect
: public ScSimpleUndo
371 ScUndoTabProtect(ScDocShell
* pShell
, SCTAB nTab
,
372 std::unique_ptr
<ScTableProtection
> && pProtectSettings
);
373 virtual ~ScUndoTabProtect();
375 virtual void Undo() SAL_OVERRIDE
;
376 virtual void Redo() SAL_OVERRIDE
;
377 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
378 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
380 virtual OUString
GetComment() const SAL_OVERRIDE
;
384 ::std::unique_ptr
<ScTableProtection
> mpProtectSettings
;
386 void DoProtect(bool bProtect
);
389 class ScUndoPrintRange
: public ScSimpleUndo
393 ScUndoPrintRange( ScDocShell
* pShell
, SCTAB nNewTab
,
394 ScPrintRangeSaver
* pOld
, ScPrintRangeSaver
* pNew
);
395 virtual ~ScUndoPrintRange();
397 virtual void Undo() SAL_OVERRIDE
;
398 virtual void Redo() SAL_OVERRIDE
;
399 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
400 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
402 virtual OUString
GetComment() const SAL_OVERRIDE
;
406 ScPrintRangeSaver
* pOldRanges
;
407 ScPrintRangeSaver
* pNewRanges
;
409 void DoChange( bool bUndo
);
412 class ScUndoScenarioFlags
: public ScSimpleUndo
417 ScDocShell
* pNewDocShell
, SCTAB nT
,
418 const OUString
& rON
, const OUString
& rNN
,
419 const OUString
& rOC
, const OUString
& rNC
,
420 const Color
& rOCol
, const Color
& rNCol
,
421 sal_uInt16 nOF
, sal_uInt16 nNF
);
423 virtual ~ScUndoScenarioFlags();
425 virtual void Undo() SAL_OVERRIDE
;
426 virtual void Redo() SAL_OVERRIDE
;
427 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
428 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
430 virtual OUString
GetComment() const SAL_OVERRIDE
;
436 OUString aOldComment
;
437 OUString aNewComment
;
440 sal_uInt16 nOldFlags
;
441 sal_uInt16 nNewFlags
;
444 class ScUndoRenameObject
: public ScSimpleUndo
449 ScDocShell
* pNewDocShell
, const OUString
& rPN
,
450 const OUString
& rON
, const OUString
& rNN
);
452 virtual ~ScUndoRenameObject();
454 virtual void Undo() SAL_OVERRIDE
;
455 virtual void Redo() SAL_OVERRIDE
;
456 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
457 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
459 virtual OUString
GetComment() const SAL_OVERRIDE
;
462 OUString aPersistName
; // to find object (works only for OLE objects)
466 SdrObject
* GetObject();
469 class ScUndoLayoutRTL
: public ScSimpleUndo
473 ScUndoLayoutRTL( ScDocShell
* pShell
, SCTAB nNewTab
, bool bNewRTL
);
474 virtual ~ScUndoLayoutRTL();
476 virtual void Undo() SAL_OVERRIDE
;
477 virtual void Redo() SAL_OVERRIDE
;
478 virtual void Repeat(SfxRepeatTarget
& rTarget
) SAL_OVERRIDE
;
479 virtual bool CanRepeat(SfxRepeatTarget
& rTarget
) const SAL_OVERRIDE
;
481 virtual OUString
GetComment() const SAL_OVERRIDE
;
487 void DoChange( bool bNew
);
492 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */