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#pragma once
21
22#include <sal/types.h>
23
24#include "swundo.hxx"
25#include <memory>
26
27class SwRewriter;
28class SwNodes;
29class SwUndo;
30class SwView;
31
32namespace sw {
33 class RepeatContext;
34}
35
36class SAL_LOPLUGIN_ANNOTATE("crosscast") IDocumentUndoRedo
37{
38public:
39
42 virtual void DoUndo(bool const bDoUndo) = 0;
43
46 virtual bool DoesUndo() const = 0;
47
52 virtual void DoGroupUndo(bool const bDoUndo) = 0;
53
56 virtual bool DoesGroupUndo() const = 0;
57
60 virtual void DoDrawUndo(bool const bDoUndo) = 0;
61
65 virtual bool DoesDrawUndo() const = 0;
66
68 virtual void DoRepair(bool bRepair) = 0;
70 virtual bool DoesRepair() const = 0;
71
75 virtual void SetUndoNoModifiedPosition() = 0;
76
80 virtual void LockUndoNoModifiedPosition() = 0;
81
85 virtual void UnLockUndoNoModifiedPosition() = 0;
86
89 virtual void SetUndoNoResetModified() = 0;
90
93 virtual bool IsUndoNoResetModified() const = 0;
94
99 virtual bool Undo() = 0;
100
113 virtual SwUndoId StartUndo(SwUndoId const eUndoId,
114 SwRewriter const*const pRewriter) = 0;
115
132 virtual SwUndoId EndUndo(SwUndoId const eUndoId,
133 SwRewriter const*const pRewriter) = 0;
134
139 virtual void DelAllUndoObj() = 0;
140
147 virtual bool GetLastUndoInfo(OUString *const o_pStr,
148 SwUndoId *const o_pId,
149 const SwView* pView = nullptr) const = 0;
150
154 virtual SwUndoComments_t GetUndoComments() const = 0;
155
160 virtual bool Redo() = 0;
161
168 virtual bool GetFirstRedoInfo(OUString *const o_pStr,
169 SwUndoId *const o_pId,
170 const SwView* pView = nullptr) const = 0;
171
175 virtual SwUndoComments_t GetRedoComments() const = 0;
176
180 virtual bool Repeat(::sw::RepeatContext & rContext,
181 sal_uInt16 const nRepeatCnt) = 0;
182
189 virtual SwUndoId GetRepeatInfo(OUString *const o_pStr) const = 0;
190
196 virtual void AppendUndo(std::unique_ptr<SwUndo> pUndo) = 0;
197
200 virtual void ClearRedo() = 0;
201
202 /* Is the given nodes array the Undo nodes array?
203 */
204 virtual bool IsUndoNodes(SwNodes const& rNodes) const = 0;
205
208 virtual size_t GetUndoActionCount(const bool bCurrentLevel = true) const = 0;
209
212 virtual void SetView(SwView* pView) = 0;
213
215 virtual bool UndoWithOffset(size_t nUndoOffset) = 0;
216
217protected:
218 virtual ~IDocumentUndoRedo() {};
219};
220
221namespace sw {
222
224{
225public:
226
227 UndoGuard(IDocumentUndoRedo & rUndoRedo)
228 : m_rUndoRedo(rUndoRedo)
229 , m_bUndoWasEnabled(rUndoRedo.DoesUndo())
230 {
231 m_rUndoRedo.DoUndo(false);
232 }
234 {
236 }
237
238 bool UndoWasEnabled() const
239 {
240 return m_bUndoWasEnabled;
241 }
242
243private:
244 IDocumentUndoRedo & m_rUndoRedo;
246};
247
250{
251public:
252
253 GroupUndoGuard(IDocumentUndoRedo & rUndoRedo)
254 : m_rUndoRedo(rUndoRedo)
255 , m_bGroupUndoWasEnabled(rUndoRedo.DoesGroupUndo())
256 {
257 m_rUndoRedo.DoGroupUndo(false);
258 }
260 {
262 }
263
264private:
265 IDocumentUndoRedo & m_rUndoRedo;
267};
268
270{
271public:
272
273 DrawUndoGuard(IDocumentUndoRedo & rUndoRedo)
274 : m_rUndoRedo(rUndoRedo)
275 , m_bDrawUndoWasEnabled(rUndoRedo.DoesDrawUndo())
276 {
277 m_rUndoRedo.DoDrawUndo(false);
278 }
280 {
282 }
283
284private:
285 IDocumentUndoRedo & m_rUndoRedo;
287};
288
289} // namespace sw
290
291/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
class SAL_LOPLUGIN_ANNOTATE("crosscast") IDocumentUndoRedo
static void EndUndo(SwWrtShell &rSh)
Definition: basesh.cxx:3011
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