nss: upgrade to release 3.73
[LibreOffice.git] / sc / source / ui / inc / undobase.hxx
blobd497e798ebc08f1449be1440a182e9cd7fa727a0
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_UNDOBASE_HXX
21 #define INCLUDED_SC_SOURCE_UI_INC_UNDOBASE_HXX
23 #include <svl/undo.hxx>
24 #include <address.hxx>
25 #include "docsh.hxx"
27 #include <memory>
28 #include <map>
30 class SdrUndoAction;
31 class ScRefUndoData;
32 class ScDBData;
34 class 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 protected:
48 ScDocShell* pDocShell;
49 std::unique_ptr<SfxUndoAction>
50 pDetectiveUndo;
51 ViewShellId mnViewShellId;
53 bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
55 bool SetViewMarkData( const ScMarkData& rMarkData );
57 void BeginUndo();
58 void EndUndo();
59 void BeginRedo();
60 void EndRedo();
62 void BroadcastChanges( const ScRange& rRange );
64 /**
65 * Broadcast changes on specified spans.
67 * @param rSpans container that specifies all spans whose changes need to
68 * be broadcasted.
70 void BroadcastChanges( const DataSpansType& rSpans );
72 static void ShowTable( SCTAB nTab );
73 static void ShowTable( const ScRange& rRange );
76 enum ScBlockUndoMode { SC_UNDO_SIMPLE, SC_UNDO_MANUALHEIGHT, SC_UNDO_AUTOHEIGHT };
78 class ScBlockUndo: public ScSimpleUndo
80 public:
81 ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
82 ScBlockUndoMode eBlockMode );
83 virtual ~ScBlockUndo() override;
85 protected:
86 ScRange aBlockRange;
87 std::unique_ptr<SdrUndoAction> pDrawUndo;
88 ScBlockUndoMode eMode;
90 void BeginUndo();
91 void EndUndo();
92 // void BeginRedo();
93 void EndRedo();
95 bool AdjustHeight();
96 void ShowBlock();
99 class ScMultiBlockUndo: public ScSimpleUndo
101 public:
102 ScMultiBlockUndo(ScDocShell* pDocSh, const ScRangeList& rRanges);
103 virtual ~ScMultiBlockUndo() override;
105 protected:
106 ScRangeList maBlockRanges;
107 std::unique_ptr<SdrUndoAction> mpDrawUndo;
109 void BeginUndo();
110 void EndUndo();
111 void EndRedo();
113 void ShowBlock();
116 // for functions that act on a database range - takes care of the unnamed database range
117 // (collected separately, before the undo action, for showing dialogs etc.)
119 class ScDBFuncUndo: public ScSimpleUndo
121 protected:
122 std::unique_ptr<ScDBData> pAutoDBRange;
123 ScRange aOriginalRange;
125 public:
126 ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal );
127 virtual ~ScDBFuncUndo() override;
129 void BeginUndo();
130 void EndUndo();
131 void BeginRedo();
132 void EndRedo();
135 class ScMoveUndo: public ScSimpleUndo // with references
137 public:
138 ScMoveUndo( ScDocShell* pDocSh,
139 ScDocumentUniquePtr pRefDoc, std::unique_ptr<ScRefUndoData> pRefData );
140 virtual ~ScMoveUndo() override;
142 protected:
143 std::unique_ptr<SdrUndoAction> pDrawUndo;
144 ScDocumentUniquePtr pRefUndoDoc;
145 std::unique_ptr<ScRefUndoData> pRefUndoData;
147 void BeginUndo();
148 void EndUndo();
149 // void BeginRedo();
150 // void EndRedo();
152 private:
153 void UndoRef();
156 class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
158 std::unique_ptr<SfxUndoAction> pWrappedUndo;
159 ViewShellId mnViewShellId;
161 public:
162 ScUndoWrapper( std::unique_ptr<SfxUndoAction> pUndo );
163 virtual ~ScUndoWrapper() override;
165 SfxUndoAction* GetWrappedUndo() { return pWrappedUndo.get(); }
166 void ForgetWrappedUndo();
168 virtual void Undo() override;
169 virtual void Redo() override;
170 virtual void Repeat(SfxRepeatTarget& rTarget) override;
171 virtual bool CanRepeat(SfxRepeatTarget& rTarget) const override;
172 virtual bool Merge( SfxUndoAction *pNextAction ) override;
173 virtual OUString GetComment() const override;
174 virtual OUString GetRepeatComment(SfxRepeatTarget&) const override;
175 /// See SfxUndoAction::GetViewShellId().
176 ViewShellId GetViewShellId() const override;
179 #endif
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */