LibreOffice Module sw (master) 1
IDocumentUndoRedo.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#ifndef INCLUDED_SW_INC_IDOCUMENTUNDOREDO_HXX
21#define INCLUDED_SW_INC_IDOCUMENTUNDOREDO_HXX
22
23#include <sal/types.h>
24
25#include "swundo.hxx"
26#include <memory>
27
28class SwRewriter;
29class SwNodes;
30class SwUndo;
31class SwView;
32
33namespace sw {
34 class RepeatContext;
35}
36
37class SAL_LOPLUGIN_ANNOTATE("crosscast") IDocumentUndoRedo
38{
39public:
40
43 virtual void DoUndo(bool const bDoUndo) = 0;
44
47 virtual bool DoesUndo() const = 0;
48
53 virtual void DoGroupUndo(bool const bDoUndo) = 0;
54
57 virtual bool DoesGroupUndo() const = 0;
58
61 virtual void DoDrawUndo(bool const bDoUndo) = 0;
62
66 virtual bool DoesDrawUndo() const = 0;
67
69 virtual void DoRepair(bool bRepair) = 0;
71 virtual bool DoesRepair() const = 0;
72
76 virtual void SetUndoNoModifiedPosition() = 0;
77
81 virtual void LockUndoNoModifiedPosition() = 0;
82
86 virtual void UnLockUndoNoModifiedPosition() = 0;
87
90 virtual void SetUndoNoResetModified() = 0;
91
94 virtual bool IsUndoNoResetModified() const = 0;
95
100 virtual bool Undo() = 0;
101
114 virtual SwUndoId StartUndo(SwUndoId const eUndoId,
115 SwRewriter const*const pRewriter) = 0;
116
133 virtual SwUndoId EndUndo(SwUndoId const eUndoId,
134 SwRewriter const*const pRewriter) = 0;
135
140 virtual void DelAllUndoObj() = 0;
141
148 virtual bool GetLastUndoInfo(OUString *const o_pStr,
149 SwUndoId *const o_pId,
150 const SwView* pView = nullptr) const = 0;
151
155 virtual SwUndoComments_t GetUndoComments() const = 0;
156
161 virtual bool Redo() = 0;
162
169 virtual bool GetFirstRedoInfo(OUString *const o_pStr,
170 SwUndoId *const o_pId,
171 const SwView* pView = nullptr) const = 0;
172
176 virtual SwUndoComments_t GetRedoComments() const = 0;
177
181 virtual bool Repeat(::sw::RepeatContext & rContext,
182 sal_uInt16 const nRepeatCnt) = 0;
183
190 virtual SwUndoId GetRepeatInfo(OUString *const o_pStr) const = 0;
191
197 virtual void AppendUndo(std::unique_ptr<SwUndo> pUndo) = 0;
198
201 virtual void ClearRedo() = 0;
202
203 /* Is the given nodes array the Undo nodes array?
204 */
205 virtual bool IsUndoNodes(SwNodes const& rNodes) const = 0;
206
209 virtual size_t GetUndoActionCount(const bool bCurrentLevel = true) const = 0;
210
213 virtual void SetView(SwView* pView) = 0;
214
216 virtual bool UndoWithOffset(size_t nUndoOffset) = 0;
217
218protected:
219 virtual ~IDocumentUndoRedo() {};
220};
221
222namespace sw {
223
225{
226public:
227
228 UndoGuard(IDocumentUndoRedo & rUndoRedo)
229 : m_rUndoRedo(rUndoRedo)
230 , m_bUndoWasEnabled(rUndoRedo.DoesUndo())
231 {
232 m_rUndoRedo.DoUndo(false);
233 }
235 {
237 }
238
239 bool UndoWasEnabled() const
240 {
241 return m_bUndoWasEnabled;
242 }
243
244private:
245 IDocumentUndoRedo & m_rUndoRedo;
247};
248
251{
252public:
253
254 GroupUndoGuard(IDocumentUndoRedo & rUndoRedo)
255 : m_rUndoRedo(rUndoRedo)
256 , m_bGroupUndoWasEnabled(rUndoRedo.DoesGroupUndo())
257 {
258 m_rUndoRedo.DoGroupUndo(false);
259 }
261 {
263 }
264
265private:
266 IDocumentUndoRedo & m_rUndoRedo;
268};
269
271{
272public:
273
274 DrawUndoGuard(IDocumentUndoRedo & rUndoRedo)
275 : m_rUndoRedo(rUndoRedo)
276 , m_bDrawUndoWasEnabled(rUndoRedo.DoesDrawUndo())
277 {
278 m_rUndoRedo.DoDrawUndo(false);
279 }
281 {
283 }
284
285private:
286 IDocumentUndoRedo & m_rUndoRedo;
288};
289
290} // namespace sw
291
292#endif
293
294/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
class SAL_LOPLUGIN_ANNOTATE("crosscast") IDocumentUndoRedo
static void EndUndo(SwWrtShell &rSh)
Definition: basesh.cxx:3088
Definition: view.hxx:146
IDocumentUndoRedo & m_rUndoRedo
DrawUndoGuard(IDocumentUndoRedo &rUndoRedo)
bool const m_bDrawUndoWasEnabled
Blocks grouping undo actions together into an SfxListUndoAction.
GroupUndoGuard(IDocumentUndoRedo &rUndoRedo)
bool const m_bGroupUndoWasEnabled
IDocumentUndoRedo & m_rUndoRedo
IDocumentUndoRedo & m_rUndoRedo
UndoGuard(IDocumentUndoRedo &rUndoRedo)
bool UndoWasEnabled() const
bool const m_bUndoWasEnabled
Dialog to specify the properties of date form field.
SwUndoId
Definition: swundo.hxx:30
std::vector< OUString > SwUndoComments_t
Definition: swundo.hxx:26