tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / sc / source / ui / inc / undobase.hxx
blob4ca471d5f1bc1ebec51fd78760bf556066fda7a8
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 <svl/undo.hxx>
23 #include <address.hxx>
24 #include "docsh.hxx"
26 #include <memory>
27 #include <map>
28 #include <optional>
30 class SdrUndoAction;
31 class ScRefUndoData;
32 class ScDBData;
34 class SAL_DLLPUBLIC_RTTI ScSimpleUndo: public SfxUndoAction
36 ScSimpleUndo(const ScSimpleUndo&) = delete;
38 public:
39 typedef std::map<SCTAB, std::unique_ptr<sc::ColumnSpanSet>> DataSpansType;
41 ScSimpleUndo( ScDocShell* pDocSh );
43 virtual bool Merge( SfxUndoAction *pNextAction ) override;
44 /// See SfxUndoAction::GetViewShellId().
45 ViewShellId GetViewShellId() const override;
47 virtual std::optional<ScRange> getAffectedRange() const { return std::nullopt; }
49 protected:
50 ScDocShell* pDocShell;
51 std::unique_ptr<SfxUndoAction>
52 pDetectiveUndo;
53 ViewShellId mnViewShellId;
55 bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
57 bool SetViewMarkData( const ScMarkData& rMarkData );
59 void BeginUndo();
60 void EndUndo();
61 void BeginRedo();
62 void EndRedo();
64 void BroadcastChanges( const ScRange& rRange );
66 /**
67 * Broadcast changes on specified spans.
69 * @param rSpans container that specifies all spans whose changes need to
70 * be broadcasted.
72 void BroadcastChanges( const DataSpansType& rSpans );
74 static void ShowTable( SCTAB nTab );
75 static void ShowTable( const ScRange& rRange );
78 enum ScBlockUndoMode { SC_UNDO_SIMPLE, SC_UNDO_MANUALHEIGHT, SC_UNDO_AUTOHEIGHT };
80 class ScBlockUndo: public ScSimpleUndo
82 public:
83 ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
84 ScBlockUndoMode eBlockMode );
85 virtual ~ScBlockUndo() override;
87 virtual std::optional<ScRange> getAffectedRange() const override { return aBlockRange; }
89 protected:
90 ScRange aBlockRange;
91 std::unique_ptr<SdrUndoAction> pDrawUndo;
92 ScBlockUndoMode eMode;
94 void BeginUndo();
95 void EndUndo();
96 // void BeginRedo();
97 void EndRedo();
99 bool AdjustHeight();
100 void ShowBlock();
103 class SC_DLLPUBLIC ScMultiBlockUndo: public ScSimpleUndo
105 public:
106 ScMultiBlockUndo(ScDocShell* pDocSh, ScRangeList aRanges);
107 virtual ~ScMultiBlockUndo() override;
109 protected:
110 ScRangeList maBlockRanges;
111 std::unique_ptr<SdrUndoAction> mpDrawUndo;
113 void BeginUndo();
114 void EndUndo();
115 void EndRedo();
117 void ShowBlock();
120 // for functions that act on a database range - takes care of the unnamed database range
121 // (collected separately, before the undo action, for showing dialogs etc.)
123 class ScDBFuncUndo: public ScSimpleUndo
125 protected:
126 std::unique_ptr<ScDBData> pAutoDBRange;
127 ScRange aOriginalRange;
129 public:
130 ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal );
131 virtual ~ScDBFuncUndo() override;
133 void BeginUndo();
134 void EndUndo();
135 void BeginRedo();
136 void EndRedo();
139 class ScMoveUndo: public ScSimpleUndo // with references
141 public:
142 ScMoveUndo( ScDocShell* pDocSh,
143 ScDocumentUniquePtr pRefDoc, std::unique_ptr<ScRefUndoData> pRefData );
144 virtual ~ScMoveUndo() override;
146 protected:
147 std::unique_ptr<SdrUndoAction> pDrawUndo;
148 ScDocumentUniquePtr pRefUndoDoc;
149 std::unique_ptr<ScRefUndoData> pRefUndoData;
151 void BeginUndo();
152 void EndUndo();
153 // void BeginRedo();
154 // void EndRedo();
156 private:
157 void UndoRef();
160 class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
162 std::unique_ptr<SfxUndoAction> pWrappedUndo;
163 ViewShellId mnViewShellId;
165 public:
166 ScUndoWrapper( std::unique_ptr<SfxUndoAction> pUndo );
167 virtual ~ScUndoWrapper() override;
169 SfxUndoAction* GetWrappedUndo() { return pWrappedUndo.get(); }
170 std::unique_ptr<SfxUndoAction> ReleaseWrappedUndo() { return std::move(pWrappedUndo); }
172 virtual void Undo() override;
173 virtual void Redo() override;
174 virtual void Repeat(SfxRepeatTarget& rTarget) override;
175 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
176 virtual bool Merge( SfxUndoAction *pNextAction ) override;
177 virtual OUString GetComment() const override;
178 virtual OUString GetRepeatComment(SfxRepeatTarget&) const override;
179 /// See SfxUndoAction::GetViewShellId().
180 ViewShellId GetViewShellId() const override;
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */