nss: upgrade to release 3.73
[LibreOffice.git] / sc / source / ui / inc / undotab.hxx
blobd9e50709a47063860954ccdafebdb10e271d46b9
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 <tools/color.hxx>
25 #include <tabbgcolor.hxx>
27 #include <memory>
28 #include <vector>
30 class ScDocShell;
31 class SdrUndoAction;
32 class ScPrintRangeSaver;
33 class SdrObject;
34 class ScDocProtection;
35 class ScTableProtection;
36 class ScMarkData;
38 class ScUndoInsertTab : public ScSimpleUndo
40 public:
41 ScUndoInsertTab(
42 ScDocShell* pNewDocShell,
43 SCTAB nTabNum,
44 bool bApp,
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;
55 private:
56 OUString sNewName;
57 std::unique_ptr<SdrUndoAction> pDrawUndo;
58 sal_uLong nEndChangeAction;
59 SCTAB nTab;
60 bool bAppend;
62 void SetChangeTrack();
65 class ScUndoInsertTables : public ScSimpleUndo
67 public:
68 ScUndoInsertTables(
69 ScDocShell* pNewDocShell,
70 SCTAB nTabNum,
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;
81 private:
83 std::unique_ptr<SdrUndoAction> pDrawUndo;
84 std::vector<OUString> aNameList;
85 sal_uLong nStartChangeAction;
86 sal_uLong nEndChangeAction;
87 SCTAB nTab;
89 void SetChangeTrack();
92 class ScUndoDeleteTab: public ScMoveUndo
94 public:
95 ScUndoDeleteTab(
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;
109 private:
110 std::vector<SCTAB> theTabs;
111 sal_uLong nStartChangeAction;
112 sal_uLong nEndChangeAction;
114 void SetChangeTrack();
117 class ScUndoRenameTab: public ScSimpleUndo
119 public:
120 ScUndoRenameTab(
121 ScDocShell* pNewDocShell,
122 SCTAB nT,
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;
134 private:
135 SCTAB nTab;
136 OUString sOldName;
137 OUString sNewName;
139 void DoChange( SCTAB nTab, const OUString& rName ) const;
142 class ScUndoMoveTab: public ScSimpleUndo
144 public:
145 ScUndoMoveTab(
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;
161 private:
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
172 public:
173 ScUndoCopyTab(
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;
188 private:
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
199 public:
200 ScUndoTabColor(
201 ScDocShell* pNewDocShell,
202 SCTAB nT,
203 const Color& aOTabBgColor,
204 const Color& aNTabBgColor);
205 ScUndoTabColor(
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;
217 private:
218 ScUndoTabColorInfo::List aTabColorList;
220 void DoChange(bool bUndoType) const;
223 class ScUndoMakeScenario: public ScSimpleUndo
225 public:
226 ScUndoMakeScenario(
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;
241 private:
242 std::unique_ptr<ScMarkData> mpMarkData;
243 SCTAB nSrcTab;
244 SCTAB nDestTab;
245 OUString aName;
246 OUString aComment;
247 Color aColor;
248 ScScenarioFlags nFlags;
249 std::unique_ptr<SdrUndoAction> pDrawUndo;
252 class ScUndoImportTab : public ScSimpleUndo
254 public:
255 ScUndoImportTab(
256 ScDocShell* pShell,
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;
267 private:
268 SCTAB nTab;
269 SCTAB nCount;
270 ScDocumentUniquePtr xRedoDoc;
271 std::unique_ptr<SdrUndoAction> pDrawUndo;
273 void DoChange() const;
276 class ScUndoRemoveLink : public ScSimpleUndo
278 public:
279 ScUndoRemoveLink( // Call before delete!
280 ScDocShell* pShell,
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;
291 private:
292 OUString aDocName;
293 OUString aFltName;
294 OUString aOptions;
295 sal_uLong nRefreshDelay;
296 sal_uInt16 nCount;
297 std::unique_ptr<SCTAB[]>
298 pTabs;
299 std::unique_ptr<ScLinkMode[]>
300 pModes;
301 std::unique_ptr<OUString[]>
302 pTabNames;
304 void DoChange( bool bLink ) const;
307 class ScUndoShowHideTab : public ScSimpleUndo
309 public:
310 ScUndoShowHideTab(
311 ScDocShell* pShell,
312 const std::vector<SCTAB>& newUndoTabs,
313 bool bNewShow );
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;
323 private:
324 std::vector<SCTAB> undoTabs;
325 bool bShow;
327 void DoChange( bool bShow ) const;
330 /** This class implements undo & redo of document protect & unprotect
331 operations. */
332 class ScUndoDocProtect : public ScSimpleUndo
334 public:
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;
345 private:
346 ::std::unique_ptr<ScDocProtection> mpProtectSettings;
348 void DoProtect(bool bProtect);
351 /** This class implements undo & redo of both protect and unprotect of
352 sheet. */
353 class ScUndoTabProtect : public ScSimpleUndo
355 public:
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;
367 private:
368 SCTAB mnTab;
369 ::std::unique_ptr<ScTableProtection> mpProtectSettings;
371 void DoProtect(bool bProtect);
374 class ScUndoPrintRange : public ScSimpleUndo
376 public:
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;
389 private:
390 SCTAB nTab;
391 std::unique_ptr<ScPrintRangeSaver> pOldRanges;
392 std::unique_ptr<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 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;
416 private:
417 SCTAB nTab;
418 OUString aOldName;
419 OUString aNewName;
420 OUString aOldComment;
421 OUString aNewComment;
422 Color aOldColor;
423 Color aNewColor;
424 ScScenarioFlags nOldFlags;
425 ScScenarioFlags 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() 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;
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() 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;
465 private:
466 SCTAB nTab;
467 bool bRTL;
469 void DoChange( bool bNew );
472 #endif
474 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */