tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / inc / undotab.hxx
blobf0269b317708ec4240232ce9365bfb59951094df
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 #pragma once
22 #include "undobase.hxx"
23 #include <tools/color.hxx>
24 #include <tabbgcolor.hxx>
26 #include <memory>
27 #include <vector>
29 class ScDocShell;
30 class SdrUndoAction;
31 class ScPrintRangeSaver;
32 class SdrObject;
33 class ScDocProtection;
34 class ScTableProtection;
35 class ScMarkData;
37 class ScUndoInsertTab : public ScSimpleUndo
39 public:
40 ScUndoInsertTab(
41 ScDocShell* pNewDocShell,
42 SCTAB nTabNum,
43 bool bApp,
44 OUString aNewName);
45 virtual ~ScUndoInsertTab() override;
47 virtual void Undo() override;
48 virtual void Redo() override;
49 virtual void Repeat(SfxRepeatTarget& rTarget) override;
50 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
52 virtual OUString GetComment() const override;
54 private:
55 OUString sNewName;
56 std::unique_ptr<SdrUndoAction> pDrawUndo;
57 sal_uLong nEndChangeAction;
58 SCTAB nTab;
59 bool bAppend;
61 void SetChangeTrack();
64 class ScUndoInsertTables : public ScSimpleUndo
66 public:
67 ScUndoInsertTables(
68 ScDocShell* pNewDocShell,
69 SCTAB nTabNum,
70 std::vector<OUString>&& newNameList);
71 virtual ~ScUndoInsertTables() override;
73 virtual void Undo() override;
74 virtual void Redo() override;
75 virtual void Repeat(SfxRepeatTarget& rTarget) override;
76 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
78 virtual OUString GetComment() const override;
80 private:
82 std::unique_ptr<SdrUndoAction> pDrawUndo;
83 std::vector<OUString> aNameList;
84 sal_uLong nStartChangeAction;
85 sal_uLong nEndChangeAction;
86 SCTAB nTab;
88 void SetChangeTrack();
91 class ScUndoDeleteTab: public ScMoveUndo
93 public:
94 ScUndoDeleteTab(
95 ScDocShell* pNewDocShell,
96 const std::vector<SCTAB> &theTabs, //SCTAB nNewTab,
97 ScDocumentUniquePtr pUndoDocument,
98 std::unique_ptr<ScRefUndoData> pRefData );
99 virtual ~ScUndoDeleteTab() override;
101 virtual void Undo() override;
102 virtual void Redo() override;
103 virtual void Repeat(SfxRepeatTarget& rTarget) override;
104 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
106 virtual OUString GetComment() const override;
108 private:
109 std::vector<SCTAB> theTabs;
110 sal_uLong nStartChangeAction;
111 sal_uLong nEndChangeAction;
113 void SetChangeTrack();
116 class ScUndoRenameTab: public ScSimpleUndo
118 public:
119 ScUndoRenameTab(
120 ScDocShell* pNewDocShell,
121 SCTAB nT,
122 const OUString& rOldName,
123 const OUString& rNewName);
124 virtual ~ScUndoRenameTab() override;
126 virtual void Undo() override;
127 virtual void Redo() override;
128 virtual void Repeat(SfxRepeatTarget& rTarget) override;
129 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
131 virtual OUString GetComment() const override;
133 private:
134 SCTAB nTab;
135 OUString sOldName;
136 OUString sNewName;
138 void DoChange( SCTAB nTab, const OUString& rName ) const;
141 class ScUndoMoveTab: public ScSimpleUndo
143 public:
144 ScUndoMoveTab(
145 ScDocShell* pNewDocShell,
146 std::unique_ptr<std::vector<SCTAB>> pOldTabs,
147 std::unique_ptr<std::vector<SCTAB>> pNewTabs,
148 std::unique_ptr<std::vector< OUString>> pOldNames = nullptr,
149 std::unique_ptr<std::vector< OUString>> pNewNames = nullptr );
151 virtual ~ScUndoMoveTab() override;
153 virtual void Undo() override;
154 virtual void Redo() override;
155 virtual void Repeat(SfxRepeatTarget& rTarget) override;
156 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
158 virtual OUString GetComment() const override;
160 private:
161 std::unique_ptr< ::std::vector<SCTAB> > mpOldTabs;
162 std::unique_ptr< ::std::vector<SCTAB> > mpNewTabs;
163 std::unique_ptr< ::std::vector< OUString> > mpOldNames;
164 std::unique_ptr< ::std::vector< OUString> > mpNewNames;
166 void DoChange( bool bUndo ) const;
169 class ScUndoCopyTab: public ScSimpleUndo
171 public:
172 ScUndoCopyTab(
173 ScDocShell* pNewDocShell,
174 std::unique_ptr<std::vector<SCTAB>> pOldTabs,
175 std::unique_ptr<std::vector<SCTAB>> pNewTabs,
176 std::unique_ptr<std::vector< OUString>> pNewNames = nullptr );
178 virtual ~ScUndoCopyTab() override;
180 virtual void Undo() override;
181 virtual void Redo() override;
182 virtual void Repeat(SfxRepeatTarget& rTarget) override;
183 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
185 virtual OUString GetComment() const override;
187 private:
188 std::unique_ptr< ::std::vector<SCTAB> > mpOldTabs;
189 std::unique_ptr< ::std::vector<SCTAB> > mpNewTabs;
190 std::unique_ptr< ::std::vector< OUString> > mpNewNames;
191 std::unique_ptr<SdrUndoAction> pDrawUndo;
193 void DoChange() const;
196 class ScUndoTabColor: public ScSimpleUndo
198 public:
199 ScUndoTabColor(
200 ScDocShell* pNewDocShell,
201 SCTAB nT,
202 const Color& aOTabBgColor,
203 const Color& aNTabBgColor);
204 ScUndoTabColor(
205 ScDocShell* pNewDocShell,
206 ScUndoTabColorInfo::List&& rUndoTabColorList);
207 virtual ~ScUndoTabColor() override;
209 virtual void Undo() override;
210 virtual void Redo() override;
211 virtual void Repeat(SfxRepeatTarget& rTarget) override;
212 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
214 virtual OUString GetComment() const override;
216 private:
217 ScUndoTabColorInfo::List aTabColorList;
219 void DoChange(bool bUndoType) const;
222 class ScUndoMakeScenario: public ScSimpleUndo
224 public:
225 ScUndoMakeScenario(
226 ScDocShell* pNewDocShell,
227 SCTAB nSrc, SCTAB nDest,
228 OUString aN, OUString aC,
229 const Color& rCol, ScScenarioFlags nF,
230 const ScMarkData& rMark );
231 virtual ~ScUndoMakeScenario() override;
233 virtual void Undo() override;
234 virtual void Redo() override;
235 virtual void Repeat(SfxRepeatTarget& rTarget) override;
236 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
238 virtual OUString GetComment() const override;
240 private:
241 std::unique_ptr<ScMarkData> mpMarkData;
242 SCTAB nSrcTab;
243 SCTAB nDestTab;
244 OUString aName;
245 OUString aComment;
246 Color aColor;
247 ScScenarioFlags nFlags;
248 std::unique_ptr<SdrUndoAction> pDrawUndo;
251 class ScUndoImportTab : public ScSimpleUndo
253 public:
254 ScUndoImportTab(
255 ScDocShell* pShell,
256 SCTAB nNewTab, SCTAB nNewCount );
257 virtual ~ScUndoImportTab() override;
259 virtual void Undo() override;
260 virtual void Redo() override;
261 virtual void Repeat(SfxRepeatTarget& rTarget) override;
262 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
264 virtual OUString GetComment() const override;
266 private:
267 SCTAB nTab;
268 SCTAB nCount;
269 ScDocumentUniquePtr xRedoDoc;
270 std::unique_ptr<SdrUndoAction> pDrawUndo;
272 void DoChange() const;
275 class ScUndoRemoveLink : public ScSimpleUndo
277 public:
278 ScUndoRemoveLink( // Call before delete!
279 ScDocShell* pShell,
280 OUString aDoc );
281 virtual ~ScUndoRemoveLink() override;
283 virtual void Undo() override;
284 virtual void Redo() override;
285 virtual void Repeat(SfxRepeatTarget& rTarget) override;
286 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
288 virtual OUString GetComment() const override;
290 private:
291 OUString aDocName;
292 OUString aFltName;
293 OUString aOptions;
294 sal_Int32 nRefreshDelay;
295 sal_uInt16 nCount;
296 std::unique_ptr<SCTAB[]>
297 pTabs;
298 std::unique_ptr<ScLinkMode[]>
299 pModes;
300 std::unique_ptr<OUString[]>
301 pTabNames;
303 void DoChange( bool bLink ) const;
306 class ScUndoShowHideTab : public ScSimpleUndo
308 public:
309 ScUndoShowHideTab(
310 ScDocShell* pShell,
311 std::vector<SCTAB>&& newUndoTabs,
312 bool bNewShow );
313 virtual ~ScUndoShowHideTab() override;
315 virtual void Undo() override;
316 virtual void Redo() override;
317 virtual void Repeat(SfxRepeatTarget& rTarget) override;
318 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
320 virtual OUString GetComment() const override;
322 private:
323 std::vector<SCTAB> undoTabs;
324 bool bShow;
326 void DoChange( bool bShow ) const;
329 /** This class implements undo & redo of document protect & unprotect
330 operations. */
331 class ScUndoDocProtect : public ScSimpleUndo
333 public:
334 ScUndoDocProtect(ScDocShell* pShell, ::std::unique_ptr<ScDocProtection> && pProtectSettings);
335 virtual ~ScUndoDocProtect() override;
337 virtual void Undo() override;
338 virtual void Redo() override;
339 virtual void Repeat(SfxRepeatTarget& rTarget) override;
340 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
342 virtual OUString GetComment() const override;
344 private:
345 ::std::unique_ptr<ScDocProtection> mpProtectSettings;
347 void DoProtect(bool bProtect);
350 /** This class implements undo & redo of both protect and unprotect of
351 sheet. */
352 class ScUndoTabProtect : public ScSimpleUndo
354 public:
355 ScUndoTabProtect(ScDocShell* pShell, SCTAB nTab,
356 std::unique_ptr<ScTableProtection> && pProtectSettings);
357 virtual ~ScUndoTabProtect() override;
359 virtual void Undo() override;
360 virtual void Redo() override;
361 virtual void Repeat(SfxRepeatTarget& rTarget) override;
362 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
364 virtual OUString GetComment() const override;
366 private:
367 SCTAB mnTab;
368 ::std::unique_ptr<ScTableProtection> mpProtectSettings;
370 void DoProtect(bool bProtect);
373 class ScUndoPrintRange : public ScSimpleUndo
375 public:
376 ScUndoPrintRange( ScDocShell* pShell, SCTAB nNewTab,
377 std::unique_ptr<ScPrintRangeSaver> pOld,
378 std::unique_ptr<ScPrintRangeSaver> pNew );
379 virtual ~ScUndoPrintRange() override;
381 virtual void Undo() override;
382 virtual void Redo() override;
383 virtual void Repeat(SfxRepeatTarget& rTarget) override;
384 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
386 virtual OUString GetComment() const override;
388 private:
389 SCTAB nTab;
390 std::unique_ptr<ScPrintRangeSaver> pOldRanges;
391 std::unique_ptr<ScPrintRangeSaver> pNewRanges;
393 void DoChange( bool bUndo );
396 class ScUndoScenarioFlags: public ScSimpleUndo
398 public:
399 ScUndoScenarioFlags(
400 ScDocShell* pNewDocShell, SCTAB nT,
401 OUString aON, OUString aNN,
402 OUString aOC, OUString aNC,
403 const Color& rOCol, const Color& rNCol,
404 ScScenarioFlags nOF, ScScenarioFlags nNF);
406 virtual ~ScUndoScenarioFlags() override;
408 virtual void Undo() override;
409 virtual void Redo() override;
410 virtual void Repeat(SfxRepeatTarget& rTarget) override;
411 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
413 virtual OUString GetComment() const override;
415 private:
416 SCTAB nTab;
417 OUString aOldName;
418 OUString aNewName;
419 OUString aOldComment;
420 OUString aNewComment;
421 Color aOldColor;
422 Color aNewColor;
423 ScScenarioFlags nOldFlags;
424 ScScenarioFlags nNewFlags;
427 class ScUndoRenameObject: public ScSimpleUndo
429 public:
430 ScUndoRenameObject(
431 ScDocShell* pNewDocShell, OUString aPN,
432 OUString aON, OUString aNN );
434 virtual ~ScUndoRenameObject() override;
436 virtual void Undo() override;
437 virtual void Redo() override;
438 virtual void Repeat(SfxRepeatTarget& rTarget) override;
439 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
441 virtual OUString GetComment() const override;
443 private:
444 OUString aPersistName; // to find object (works only for OLE objects)
445 OUString aOldName;
446 OUString aNewName;
448 SdrObject* GetObject();
451 class ScUndoLayoutRTL : public ScSimpleUndo
453 public:
454 ScUndoLayoutRTL( ScDocShell* pShell, SCTAB nNewTab, bool bNewRTL );
455 virtual ~ScUndoLayoutRTL() override;
457 virtual void Undo() override;
458 virtual void Redo() override;
459 virtual void Repeat(SfxRepeatTarget& rTarget) override;
460 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
462 virtual OUString GetComment() const override;
464 private:
465 SCTAB nTab;
466 bool bRTL;
468 void DoChange( bool bNew );
471 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */