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 
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  bool UndoWithOffset(size_t nUndoOffset) override;
84 
85  // SfxUndoManager
86  virtual void AddUndoAction(std::unique_ptr<SfxUndoAction> pAction,
87  bool bTryMerg = false) override;
88  virtual bool Undo() override;
89  virtual bool Redo() override;
90  void dumpAsXml(xmlTextWriterPtr pWriter) const;
91 
92  SwUndo * RemoveLastUndo();
93  SwUndo * GetLastUndo();
94 
95  SwNodes const& GetUndoNodes() const;
96  SwNodes & GetUndoNodes();
97  void SetDocShell(SwDocShell* pDocShell);
98 
103  bool IsViewUndoActionIndependent(const SwView* pView, sal_uInt16& rOffset) const;
104 
105 private:
106  virtual void EmptyActionsChanged() override;
107 
111 
113  std::shared_ptr<SwNodes> m_xUndoNodes;
114 
115  bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled
116  bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled
118  bool m_bRepair;
119  bool m_bLockUndoNoModifiedPosition : 1;
126 
127  enum class UndoOrRedoType { Undo, Redo };
128  bool impl_DoUndoRedo(UndoOrRedoType undoOrRedo, size_t nUndoOffset);
129 
130  // UGLY: should not be called
131  using SdrUndoManager::Repeat;
132 };
133 
134 } // namespace sw
135 
136 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX
137 
138 /* 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
IDocumentRedlineAccess & m_rRedlineAccess
static void EndUndo(SwWrtShell &rSh)
Definition: basesh.cxx:2830
bool m_bRepair
If true, then repair mode is enabled.
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
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
struct _xmlTextWriter * xmlTextWriterPtr
Definition: view.hxx:144