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 .
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>
34 class 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
;
48 ScDocShell
* pDocShell
;
49 std::unique_ptr
<SfxUndoAction
>
51 ViewShellId mnViewShellId
;
53 bool IsPaintLocked() const { return pDocShell
->IsPaintLocked(); }
55 bool SetViewMarkData( const ScMarkData
& rMarkData
);
62 void BroadcastChanges( const ScRange
& rRange
);
65 * Broadcast changes on specified spans.
67 * @param rSpans container that specifies all spans whose changes need to
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
81 ScBlockUndo( ScDocShell
* pDocSh
, const ScRange
& rRange
,
82 ScBlockUndoMode eBlockMode
);
83 virtual ~ScBlockUndo() override
;
87 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
88 ScBlockUndoMode eMode
;
99 class ScMultiBlockUndo
: public ScSimpleUndo
102 ScMultiBlockUndo(ScDocShell
* pDocSh
, const ScRangeList
& rRanges
);
103 virtual ~ScMultiBlockUndo() override
;
106 ScRangeList maBlockRanges
;
107 std::unique_ptr
<SdrUndoAction
> mpDrawUndo
;
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
122 std::unique_ptr
<ScDBData
> pAutoDBRange
;
123 ScRange aOriginalRange
;
126 ScDBFuncUndo( ScDocShell
* pDocSh
, const ScRange
& rOriginal
);
127 virtual ~ScDBFuncUndo() override
;
135 class ScMoveUndo
: public ScSimpleUndo
// with references
138 ScMoveUndo( ScDocShell
* pDocSh
,
139 ScDocumentUniquePtr pRefDoc
, std::unique_ptr
<ScRefUndoData
> pRefData
);
140 virtual ~ScMoveUndo() override
;
143 std::unique_ptr
<SdrUndoAction
> pDrawUndo
;
144 ScDocumentUniquePtr pRefUndoDoc
;
145 std::unique_ptr
<ScRefUndoData
> pRefUndoData
;
156 class ScUndoWrapper
: public SfxUndoAction
// for manual merging of actions
158 std::unique_ptr
<SfxUndoAction
> pWrappedUndo
;
159 ViewShellId mnViewShellId
;
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
;
181 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */