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 
28 class SwRewriter;
29 class SwNodes;
30 class SwUndo;
31 class SwView;
32 
33 namespace sw {
34  class RepeatContext;
35 }
36 
38 {
39 public:
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 
215 protected:
216  virtual ~IDocumentUndoRedo() {};
217 };
218 
219 namespace sw {
220 
222 {
223 public:
224 
226  : m_rUndoRedo(rUndoRedo)
227  , m_bUndoWasEnabled(rUndoRedo.DoesUndo())
228  {
229  m_rUndoRedo.DoUndo(false);
230  }
232  {
234  }
235 
236  bool UndoWasEnabled() const
237  {
238  return m_bUndoWasEnabled;
239  }
240 
241 private:
243  bool const m_bUndoWasEnabled;
244 };
245 
247 {
248 public:
249 
251  : m_rUndoRedo(rUndoRedo)
252  , m_bGroupUndoWasEnabled(rUndoRedo.DoesGroupUndo())
253  {
254  m_rUndoRedo.DoGroupUndo(false);
255  }
257  {
259  }
260 
261 private:
264 };
265 
267 {
268 public:
269 
271  : m_rUndoRedo(rUndoRedo)
272  , m_bDrawUndoWasEnabled(rUndoRedo.DoesDrawUndo())
273  {
274  m_rUndoRedo.DoDrawUndo(false);
275  }
277  {
279  }
280 
281 private:
284 };
285 
286 } // namespace sw
287 
288 #endif
289 
290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool UndoWasEnabled() const
bool const m_bUndoWasEnabled
virtual void DoRepair(bool bRepair)=0
Enable repair mode.
SwUndoId
Definition: swundo.hxx:29
virtual void LockUndoNoModifiedPosition()=0
Prevent updates to the "unmodified" state position via SetUndoNoResetModified().
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
virtual bool Redo()=0
Execute Redo.
DrawUndoGuard(IDocumentUndoRedo &rUndoRedo)
virtual SwUndoComments_t GetUndoComments() const =0
Get comments of Undo actions.
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
virtual SwUndoComments_t GetRedoComments() const =0
Get comments of Redo actions.
GroupUndoGuard(IDocumentUndoRedo &rUndoRedo)
virtual bool GetFirstRedoInfo(OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const =0
Get Id and comment of first Redo action.
virtual void DelAllUndoObj()=0
Delete all Undo actions.
virtual bool IsUndoNodes(SwNodes const &rNodes) const =0
virtual void DoUndo(bool const bDoUndo)=0
Enable/Disable Undo.
virtual bool Undo()=0
Execute Undo.
std::vector< OUString > SwUndoComments_t
Definition: swundo.hxx:26
virtual bool DoesUndo() const =0
Is Undo enabled?
bool const m_bGroupUndoWasEnabled
virtual SwUndoId GetRepeatInfo(OUString *const o_pStr) const =0
Get Id and comment of last Undo action, if it is Repeat capable.
virtual bool Repeat(::sw::RepeatContext &rContext, sal_uInt16 const nRepeatCnt)=0
Repeat the last Undo action.
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
virtual void ClearRedo()=0
Delete all Redo actions.
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
virtual void SetUndoNoResetModified()=0
Disable (re)setting the document modified flag on Undo/Redo.
virtual bool DoesDrawUndo() const =0
Is Undo for Drawing objects enabled? for Draw-Undo: writer wants to handle actions on Flys on its own...
virtual bool DoesGroupUndo() const =0
Is Group Undo enabled?
virtual bool IsUndoNoResetModified() const =0
Is setting the document modified flag on Undo/Redo disabled?
IDocumentUndoRedo & m_rUndoRedo
IDocumentUndoRedo & m_rUndoRedo
virtual void UnLockUndoNoModifiedPosition()=0
Allow updates to the "unmodified" state position via SetUndoNoResetModified().
virtual void DoGroupUndo(bool const bDoUndo)=0
Enable/Disable Group Undo.
virtual void DoDrawUndo(bool const bDoUndo)=0
Enable/Disable Undo for Drawing objects.
bool const m_bDrawUndoWasEnabled
virtual size_t GetUndoActionCount(const bool bCurrentLevel=true) const =0
Get the number of Undo actions.
IDocumentUndoRedo & m_rUndoRedo
virtual bool GetLastUndoInfo(OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const =0
Get Id and comment of last Undo action.
virtual void SetUndoNoModifiedPosition()=0
Set the position at which the document is in the "unmodified" state to the current position in the Un...
virtual bool DoesRepair() const =0
Is repair mode active?
virtual void SetView(SwView *pView)=0
Return undo/redo info for this view.
UndoGuard(IDocumentUndoRedo &rUndoRedo)
Definition: view.hxx:146