1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <svl/undo.hxx>
23 #include <address.hxx>
34 class SAL_DLLPUBLIC_RTTI ScSimpleUndo
: public SfxUndoAction
36 ScSimpleUndo(const ScSimpleUndo
&) = delete;
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
; }
50 ScDocShell
* pDocShell
;
51 std::unique_ptr
<SfxUndoAction
>
53 ViewShellId mnViewShellId
;
55 bool IsPaintLocked() const { return pDocShell
->IsPaintLocked(); }
57 bool SetViewMarkData( const ScMarkData
& rMarkData
);
64 void BroadcastChanges( const ScRange
& rRange
);
67 * Broadcast changes on specified spans.
69 * @param rSpans container that specifies all spans whose changes need to
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
83 ScBlockUndo( ScDocShell
* pDocSh
, const ScRange
& rRange
,
84 ScBlockUndoMode eBlockMode
);
85 virtual ~ScBlockUndo() override
;
87 virtual std::optional
<ScRange
> getAffectedRange() const override
{ return aBlockRange
; }
91 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
92 ScBlockUndoMode eMode
;
103 class SC_DLLPUBLIC ScMultiBlockUndo
: public ScSimpleUndo
106 ScMultiBlockUndo(ScDocShell
* pDocSh
, ScRangeList aRanges
);
107 virtual ~ScMultiBlockUndo() override
;
110 ScRangeList maBlockRanges
;
111 std::unique_ptr
<SdrUndoAction
> mpDrawUndo
;
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
126 std::unique_ptr
<ScDBData
> pAutoDBRange
;
127 ScRange aOriginalRange
;
130 ScDBFuncUndo( ScDocShell
* pDocSh
, const ScRange
& rOriginal
);
131 virtual ~ScDBFuncUndo() override
;
139 class ScMoveUndo
: public ScSimpleUndo
// with references
142 ScMoveUndo( ScDocShell
* pDocSh
,
143 ScDocumentUniquePtr pRefDoc
, std::unique_ptr
<ScRefUndoData
> pRefData
);
144 virtual ~ScMoveUndo() override
;
147 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
148 ScDocumentUniquePtr pRefUndoDoc
;
149 std::unique_ptr
<ScRefUndoData
> pRefUndoData
;
160 class ScUndoWrapper
: public SfxUndoAction
// for manual merging of actions
162 std::unique_ptr
<SfxUndoAction
> pWrappedUndo
;
163 ViewShellId mnViewShellId
;
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: */