LibreOffice Module sw (master)  1
UndoManager.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_SOURCE_CORE_INC_UNDOMANAGER_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX
22 
23 #include <IDocumentUndoRedo.hxx>
24 #include <svx/sdrundomanager.hxx>
25 #include <ndarr.hxx>
26 #include <memory>
27 
30 class IDocumentState;
31 class SwDocShell;
32 class SwView;
33 
34 namespace sw {
35 
36 class SAL_DLLPUBLIC_RTTI UndoManager
37  : public IDocumentUndoRedo
38  , public SdrUndoManager
39 {
40 public:
41  UndoManager(std::shared_ptr<SwNodes> const & pUndoNodes,
42  IDocumentDrawModelAccess & rDrawModelAccess,
43  IDocumentRedlineAccess & rRedlineAccess,
44  IDocumentState & rState);
45 
47  virtual void DoUndo(bool const bDoUndo) override;
48  virtual bool DoesUndo() const override;
49  virtual void DoGroupUndo(bool const bDoUndo) override;
50  virtual bool DoesGroupUndo() const override;
51  virtual void DoDrawUndo(bool const bDoUndo) override;
52  virtual bool DoesDrawUndo() const override;
53  void DoRepair(bool bRepair) override;
54  bool DoesRepair() const override;
55  virtual void SetUndoNoModifiedPosition() override;
56  virtual void LockUndoNoModifiedPosition() override;
57  virtual void UnLockUndoNoModifiedPosition() override;
58  virtual void SetUndoNoResetModified() override;
59  virtual bool IsUndoNoResetModified() const override;
60 
61  virtual SwUndoId StartUndo(SwUndoId const eUndoId,
62  SwRewriter const*const pRewriter) override;
63  virtual SwUndoId EndUndo(SwUndoId const eUndoId,
64  SwRewriter const*const pRewriter) override;
65  virtual void DelAllUndoObj() override;
66  virtual bool GetLastUndoInfo(OUString *const o_pStr,
67  SwUndoId *const o_pId,
68  const SwView* pView = nullptr) const override;
69  virtual SwUndoComments_t GetUndoComments() const override;
70  virtual bool GetFirstRedoInfo(OUString *const o_pStr,
71  SwUndoId *const o_pId,
72  const SwView* pView = nullptr) const override;
73  virtual SwUndoComments_t GetRedoComments() const override;
74  virtual bool Repeat(::sw::RepeatContext & rContext,
75  sal_uInt16 const nRepeatCnt) override;
76  virtual SwUndoId GetRepeatInfo(OUString *const o_pStr) const override;
77  virtual void AppendUndo(std::unique_ptr<SwUndo> pUndo) override;
78  virtual void ClearRedo() override;
79  virtual bool IsUndoNodes(SwNodes const& rNodes) const override;
80  virtual size_t GetUndoActionCount(const bool bCurrentLevel = true) const override;
81  size_t GetRedoActionCount(const bool bCurrentLevel = true) const override;
82  void SetView(SwView* pView) override;
83 
84  // SfxUndoManager
85  virtual void AddUndoAction(std::unique_ptr<SfxUndoAction> pAction,
86  bool bTryMerg = false) override;
87  virtual bool Undo() override;
88  virtual bool Redo() override;
89  void dumpAsXml(xmlTextWriterPtr pWriter) const;
90 
91  SwUndo * RemoveLastUndo();
92  SwUndo * GetLastUndo();
93 
94  SwNodes const& GetUndoNodes() const;
95  SwNodes & GetUndoNodes();
96  void SetDocShell(SwDocShell* pDocShell);
97 
98 protected:
99  virtual void EmptyActionsChanged() override;
100 
101 private:
105 
107  std::shared_ptr<SwNodes> m_xUndoNodes;
108 
109  bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled
110  bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled
112  bool m_bRepair;
113  bool m_bLockUndoNoModifiedPosition : 1;
120 
121  enum class UndoOrRedoType { Undo, Redo };
122  bool impl_DoUndoRedo(UndoOrRedoType undoOrRedo);
123 
124  // UGLY: should not be called
125  using SdrUndoManager::Repeat;
126 };
127 
128 } // namespace sw
129 
130 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX
131 
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::shared_ptr< SwNodes > m_xUndoNodes
Undo nodes array: content not currently in document.
SwUndoId
Definition: swundo.hxx:29
bool m_isAddWithIgnoreRepeat
set the IgnoreRepeat flag on every added action
Dialog to specify the properties of date form field.
IDocumentState & m_rState
std::vector< OUString > SwUndoComments_t
Definition: swundo.hxx:26
sal_Int32 UndoStackMark
SwDocShell * m_pDocShell
struct _xmlTextWriter * xmlTextWriterPtr
IDocumentRedlineAccess & m_rRedlineAccess
static void EndUndo(SwWrtShell &rSh)
Definition: basesh.cxx:2697
bool m_bRepair
If true, then repair mode is enabled.
UndoStackMark m_UndoSaveMark
position in Undo-Array at which Doc was saved (and is not modified)
Get information about the current document state.
IDocumentDrawModelAccess & m_rDrawModelAccess
Definition: view.hxx:144