LibreOffice Module sc (master) 1
undobase.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <svl/undo.hxx>
23#include <address.hxx>
24#include "docsh.hxx"
25
26#include <memory>
27#include <map>
28#include <optional>
29
30class SdrUndoAction;
31class ScRefUndoData;
32class ScDBData;
33
35{
36 ScSimpleUndo(const ScSimpleUndo&) = delete;
37
38public:
39 typedef std::map<SCTAB, std::unique_ptr<sc::ColumnSpanSet>> DataSpansType;
40
41 ScSimpleUndo( ScDocShell* pDocSh );
42
43 virtual bool Merge( SfxUndoAction *pNextAction ) override;
45 ViewShellId GetViewShellId() const override;
46
47 virtual std::optional<ScRange> getAffectedRange() const { return std::nullopt; }
48
49protected:
51 std::unique_ptr<SfxUndoAction>
54
55 bool IsPaintLocked() const { return pDocShell->IsPaintLocked(); }
56
57 bool SetViewMarkData( const ScMarkData& rMarkData );
58
59 void BeginUndo();
60 void EndUndo();
61 void BeginRedo();
62 void EndRedo();
63
64 void BroadcastChanges( const ScRange& rRange );
65
72 void BroadcastChanges( const DataSpansType& rSpans );
73
74 static void ShowTable( SCTAB nTab );
75 static void ShowTable( const ScRange& rRange );
76};
77
79
81{
82public:
83 ScBlockUndo( ScDocShell* pDocSh, const ScRange& rRange,
84 ScBlockUndoMode eBlockMode );
85 virtual ~ScBlockUndo() override;
86
87 virtual std::optional<ScRange> getAffectedRange() const override { return aBlockRange; }
88
89protected:
91 std::unique_ptr<SdrUndoAction> pDrawUndo;
93
94 void BeginUndo();
95 void EndUndo();
96// void BeginRedo();
97 void EndRedo();
98
99 bool AdjustHeight();
100 void ShowBlock();
101};
102
104{
105public:
106 ScMultiBlockUndo(ScDocShell* pDocSh, ScRangeList aRanges);
107 virtual ~ScMultiBlockUndo() override;
108
109protected:
111 std::unique_ptr<SdrUndoAction> mpDrawUndo;
112
113 void BeginUndo();
114 void EndUndo();
115 void EndRedo();
116
117 void ShowBlock();
118};
119
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.)
122
124{
125protected:
126 std::unique_ptr<ScDBData> pAutoDBRange;
128
129public:
130 ScDBFuncUndo( ScDocShell* pDocSh, const ScRange& rOriginal );
131 virtual ~ScDBFuncUndo() override;
132
133 void BeginUndo();
134 void EndUndo();
135 void BeginRedo();
136 void EndRedo();
137};
138
139class ScMoveUndo: public ScSimpleUndo // with references
140{
141public:
142 ScMoveUndo( ScDocShell* pDocSh,
143 ScDocumentUniquePtr pRefDoc, std::unique_ptr<ScRefUndoData> pRefData );
144 virtual ~ScMoveUndo() override;
145
146protected:
147 std::unique_ptr<SdrUndoAction> pDrawUndo;
149 std::unique_ptr<ScRefUndoData> pRefUndoData;
150
151 void BeginUndo();
152 void EndUndo();
153// void BeginRedo();
154// void EndRedo();
155
156private:
157 void UndoRef();
158};
159
160class ScUndoWrapper: public SfxUndoAction // for manual merging of actions
161{
162 std::unique_ptr<SfxUndoAction> pWrappedUndo;
164
165public:
166 ScUndoWrapper( std::unique_ptr<SfxUndoAction> pUndo );
167 virtual ~ScUndoWrapper() override;
168
170 void ForgetWrappedUndo();
171
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;
180 ViewShellId GetViewShellId() const override;
181};
182
183/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScRange aBlockRange
Definition: undobase.hxx:90
bool AdjustHeight()
Definition: undobase.cxx:285
void ShowBlock()
Definition: undobase.cxx:325
void EndRedo()
Definition: undobase.cxx:276
virtual ~ScBlockUndo() override
Definition: undobase.cxx:253
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undobase.hxx:91
void BeginUndo()
Definition: undobase.cxx:258
virtual std::optional< ScRange > getAffectedRange() const override
Definition: undobase.hxx:87
ScBlockUndoMode eMode
Definition: undobase.hxx:92
void EndUndo()
Definition: undobase.cxx:264
ScBlockUndo(ScDocShell *pDocSh, const ScRange &rRange, ScBlockUndoMode eBlockMode)
Definition: undobase.cxx:244
std::unique_ptr< ScDBData > pAutoDBRange
Definition: undobase.hxx:126
ScDBFuncUndo(ScDocShell *pDocSh, const ScRange &rOriginal)
Definition: undobase.cxx:457
void EndUndo()
Definition: undobase.cxx:475
virtual ~ScDBFuncUndo() override
Definition: undobase.cxx:464
void EndRedo()
Definition: undobase.cxx:544
void BeginUndo()
Definition: undobase.cxx:469
ScRange aOriginalRange
Definition: undobase.hxx:127
void BeginRedo()
Definition: undobase.cxx:507
bool IsPaintLocked() const
Definition: docsh.hxx:326
todo: It should be possible to have MarkArrays for each table, in order to enable "search all" across...
Definition: markdata.hxx:43
std::unique_ptr< SdrUndoAction > pDrawUndo
Definition: undobase.hxx:147
void BeginUndo()
Definition: undobase.cxx:438
virtual ~ScMoveUndo() override
Definition: undobase.cxx:422
ScDocumentUniquePtr pRefUndoDoc
Definition: undobase.hxx:148
void EndUndo()
Definition: undobase.cxx:445
void UndoRef()
Definition: undobase.cxx:429
std::unique_ptr< ScRefUndoData > pRefUndoData
Definition: undobase.hxx:149
ScMoveUndo(ScDocShell *pDocSh, ScDocumentUniquePtr pRefDoc, std::unique_ptr< ScRefUndoData > pRefData)
Definition: undobase.cxx:411
ScRangeList maBlockRanges
Definition: undobase.hxx:110
std::unique_ptr< SdrUndoAction > mpDrawUndo
Definition: undobase.hxx:111
ScSimpleUndo(const ScSimpleUndo &)=delete
std::map< SCTAB, std::unique_ptr< sc::ColumnSpanSet > > DataSpansType
Definition: undobase.hxx:39
std::unique_ptr< SfxUndoAction > pDetectiveUndo
Definition: undobase.hxx:52
ViewShellId mnViewShellId
Definition: undobase.hxx:53
virtual std::optional< ScRange > getAffectedRange() const
Definition: undobase.hxx:47
bool IsPaintLocked() const
Definition: undobase.hxx:55
ScDocShell * pDocShell
Definition: undobase.hxx:50
ViewShellId mnViewShellId
Definition: undobase.hxx:163
virtual bool CanRepeat(SfxRepeatTarget &rTarget) const override
Definition: undobase.cxx:611
virtual OUString GetRepeatComment(SfxRepeatTarget &) const override
Definition: undobase.cxx:578
std::unique_ptr< SfxUndoAction > pWrappedUndo
Definition: undobase.hxx:162
virtual OUString GetComment() const override
Definition: undobase.cxx:566
void ForgetWrappedUndo()
Definition: undobase.cxx:561
virtual void Redo() override
Definition: undobase.cxx:599
ViewShellId GetViewShellId() const override
See SfxUndoAction::GetViewShellId().
Definition: undobase.cxx:573
virtual void Repeat(SfxRepeatTarget &rTarget) override
Definition: undobase.cxx:605
virtual bool Merge(SfxUndoAction *pNextAction) override
Definition: undobase.cxx:585
SfxUndoAction * GetWrappedUndo()
Definition: undobase.hxx:169
virtual void Undo() override
Definition: undobase.cxx:593
ScUndoWrapper(std::unique_ptr< SfxUndoAction > pUndo)
Definition: undobase.cxx:549
virtual ~ScUndoWrapper() override
Definition: undobase.cxx:557
virtual ViewShellId GetViewShellId() const
virtual bool Merge(SfxUndoAction *pNextAction)
std::unique_ptr< ScDocument, o3tl::default_delete< ScDocument > > ScDocumentUniquePtr
Definition: document.hxx:2720
#define SC_DLLPUBLIC
Definition: scdllapi.h:27
sal_Int16 SCTAB
Definition: types.hxx:22
ScBlockUndoMode
Definition: undobase.hxx:78
@ SC_UNDO_SIMPLE
Definition: undobase.hxx:78
@ SC_UNDO_AUTOHEIGHT
Definition: undobase.hxx:78
@ SC_UNDO_MANUALHEIGHT
Definition: undobase.hxx:78