nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / core / inc / UndoManager.hxx
blob4113d54d8f52351074326f9bbbf049b61b499439
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX
23 #include <IDocumentUndoRedo.hxx>
24 #include <svx/sdrundomanager.hxx>
25 #include <ndarr.hxx>
26 #include <memory>
28 class IDocumentDrawModelAccess;
29 class IDocumentRedlineAccess;
30 class IDocumentState;
31 class SwDocShell;
32 class SwView;
34 namespace sw {
36 class SAL_DLLPUBLIC_RTTI UndoManager
37 : public IDocumentUndoRedo
38 , public SdrUndoManager
40 public:
41 UndoManager(std::shared_ptr<SwNodes> const & pUndoNodes,
42 IDocumentDrawModelAccess & rDrawModelAccess,
43 IDocumentRedlineAccess & rRedlineAccess,
44 IDocumentState & rState);
46 /** IDocumentUndoRedo */
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;
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;
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;
91 SwUndo * RemoveLastUndo();
92 SwUndo * GetLastUndo();
94 SwNodes const& GetUndoNodes() const;
95 SwNodes & GetUndoNodes();
96 void SetDocShell(SwDocShell* pDocShell);
98 protected:
99 virtual void EmptyActionsChanged() override;
101 private:
102 IDocumentDrawModelAccess & m_rDrawModelAccess;
103 IDocumentRedlineAccess & m_rRedlineAccess;
104 IDocumentState & m_rState;
106 /// Undo nodes array: content not currently in document
107 std::shared_ptr<SwNodes> m_xUndoNodes;
109 bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled
110 bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled
111 /// If true, then repair mode is enabled.
112 bool m_bRepair;
113 bool m_bLockUndoNoModifiedPosition : 1;
114 /// set the IgnoreRepeat flag on every added action
115 bool m_isAddWithIgnoreRepeat;
116 /// position in Undo-Array at which Doc was saved (and is not modified)
117 UndoStackMark m_UndoSaveMark;
118 SwDocShell* m_pDocShell;
119 SwView* m_pView;
121 enum class UndoOrRedoType { Undo, Redo };
122 bool impl_DoUndoRedo(UndoOrRedoType undoOrRedo);
124 // UGLY: should not be called
125 using SdrUndoManager::Repeat;
128 } // namespace sw
130 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */