Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / sc / source / ui / inc / undotab.hxx
blob455689fb6e3095f99f8d02f59509e60ed6e860e6
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 <memory>
30 #include <memory>
31 #include <vector>
33 class ScDocShell;
34 class ScDocument;
35 class SdrUndoAction;
36 class ScPrintRangeSaver;
37 class SdrObject;
38 class ScDocProtection;
39 class ScTableProtection;
40 class ScMarkData;
42 class ScUndoInsertTab : public ScSimpleUndo
44 public:
45 ScUndoInsertTab(
46 ScDocShell* pNewDocShell,
47 SCTAB nTabNum,
48 bool bApp,
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;
59 private:
60 OUString sNewName;
61 SdrUndoAction* pDrawUndo;
62 sal_uLong nEndChangeAction;
63 SCTAB nTab;
64 bool bAppend;
66 void SetChangeTrack();
69 class ScUndoInsertTables : public ScSimpleUndo
71 public:
72 ScUndoInsertTables(
73 ScDocShell* pNewDocShell,
74 SCTAB nTabNum,
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;
85 private:
87 SdrUndoAction* pDrawUndo;
88 std::vector<OUString> aNameList;
89 sal_uLong nStartChangeAction;
90 sal_uLong nEndChangeAction;
91 SCTAB nTab;
93 void SetChangeTrack();
96 class ScUndoDeleteTab: public ScMoveUndo
98 public:
99 ScUndoDeleteTab(
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;
113 private:
114 std::vector<SCTAB> theTabs;
115 sal_uLong nStartChangeAction;
116 sal_uLong nEndChangeAction;
118 void SetChangeTrack();
121 class ScUndoRenameTab: public ScSimpleUndo
123 public:
124 ScUndoRenameTab(
125 ScDocShell* pNewDocShell,
126 SCTAB nT,
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;
138 private:
139 SCTAB nTab;
140 OUString sOldName;
141 OUString sNewName;
143 void DoChange( SCTAB nTab, const OUString& rName ) const;
146 class ScUndoMoveTab: public ScSimpleUndo
148 public:
149 ScUndoMoveTab(
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;
165 private:
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
176 public:
177 ScUndoCopyTab(
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;
192 private:
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
203 public:
204 ScUndoTabColor(
205 ScDocShell* pNewDocShell,
206 SCTAB nT,
207 const Color& aOTabBgColor,
208 const Color& aNTabBgColor);
209 ScUndoTabColor(
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;
221 private:
222 ScUndoTabColorInfo::List aTabColorList;
224 void DoChange(bool bUndoType) const;
227 class ScUndoMakeScenario: public ScSimpleUndo
229 public:
230 ScUndoMakeScenario(
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;
245 private:
246 std::unique_ptr<ScMarkData> mpMarkData;
247 SCTAB nSrcTab;
248 SCTAB nDestTab;
249 OUString aName;
250 OUString aComment;
251 Color aColor;
252 sal_uInt16 nFlags;
253 SdrUndoAction* pDrawUndo;
256 class ScUndoImportTab : public ScSimpleUndo
258 public:
259 ScUndoImportTab(
260 ScDocShell* pShell,
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;
271 private:
272 SCTAB nTab;
273 SCTAB nCount;
274 ScDocument* pRedoDoc;
275 SdrUndoAction* pDrawUndo;
277 void DoChange() const;
280 class ScUndoRemoveLink : public ScSimpleUndo
282 public:
283 ScUndoRemoveLink( // Call before delete!
284 ScDocShell* pShell,
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;
295 private:
296 OUString aDocName;
297 OUString aFltName;
298 OUString aOptions;
299 sal_uLong nRefreshDelay;
300 sal_uInt16 nCount;
301 SCTAB* pTabs;
302 ScLinkMode* pModes;
303 OUString* pTabNames;
305 void DoChange( bool bLink ) const;
308 class ScUndoShowHideTab : public ScSimpleUndo
310 public:
311 ScUndoShowHideTab(
312 ScDocShell* pShell,
313 const std::vector<SCTAB>& newUndoTabs,
314 bool bNewShow );
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;
324 private:
325 std::vector<SCTAB> undoTabs;
326 bool bShow;
328 void DoChange( bool bShow ) const;
331 /** This class implements undo & redo of document protect & unprotect
332 operations. */
333 class ScUndoDocProtect : public ScSimpleUndo
335 public:
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;
346 private:
347 ::std::unique_ptr<ScDocProtection> mpProtectSettings;
349 void DoProtect(bool bProtect);
352 /** This class implements undo & redo of both protect and unprotect of
353 sheet. */
354 class ScUndoTabProtect : public ScSimpleUndo
356 public:
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;
368 private:
369 SCTAB mnTab;
370 ::std::unique_ptr<ScTableProtection> mpProtectSettings;
372 void DoProtect(bool bProtect);
375 class ScUndoPrintRange : public ScSimpleUndo
377 public:
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;
389 private:
390 SCTAB nTab;
391 ScPrintRangeSaver* pOldRanges;
392 ScPrintRangeSaver* pNewRanges;
394 void DoChange( bool bUndo );
397 class ScUndoScenarioFlags: public ScSimpleUndo
399 public:
400 ScUndoScenarioFlags(
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;
416 private:
417 SCTAB nTab;
418 OUString aOldName;
419 OUString aNewName;
420 OUString aOldComment;
421 OUString aNewComment;
422 Color aOldColor;
423 Color aNewColor;
424 sal_uInt16 nOldFlags;
425 sal_uInt16 nNewFlags;
428 class ScUndoRenameObject: public ScSimpleUndo
430 public:
431 ScUndoRenameObject(
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;
444 private:
445 OUString aPersistName; // to find object (works only for OLE objects)
446 OUString aOldName;
447 OUString aNewName;
449 SdrObject* GetObject();
452 class ScUndoLayoutRTL : public ScSimpleUndo
454 public:
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;
465 private:
466 SCTAB nTab;
467 bool bRTL;
469 void DoChange( bool bNew );
472 #endif
474 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */