Revert "reduce symbol visibility in sw"
[LibreOffice.git] / sw / source / core / inc / UndoManager.hxx
blob0993cdf5c6564acb41e97971b61576815c4c4667
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 /**
37 * Stores the undo/redo information, implementing the IDocumentUndoRedo interface.
38 * It contains a stack of SwUndo actions, each of which represents one user-visible
39 * undo / redo step.
41 class SAL_DLLPUBLIC_RTTI UndoManager final
42 : public IDocumentUndoRedo
43 , public SdrUndoManager
45 public:
46 UndoManager(std::shared_ptr<SwNodes> pUndoNodes,
47 IDocumentDrawModelAccess & rDrawModelAccess,
48 IDocumentRedlineAccess & rRedlineAccess,
49 IDocumentState & rState);
51 /** IDocumentUndoRedo */
52 virtual void DoUndo(bool const bDoUndo) override;
53 virtual bool DoesUndo() const override;
54 virtual void DoGroupUndo(bool const bDoUndo) override;
55 virtual bool DoesGroupUndo() const override;
56 virtual void DoDrawUndo(bool const bDoUndo) override;
57 virtual bool DoesDrawUndo() const override;
58 void DoRepair(bool bRepair) override;
59 bool DoesRepair() const override;
60 virtual void SetUndoNoModifiedPosition() override;
61 virtual void LockUndoNoModifiedPosition() override;
62 virtual void UnLockUndoNoModifiedPosition() override;
63 virtual void SetUndoNoResetModified() override;
64 virtual bool IsUndoNoResetModified() const override;
66 SW_DLLPUBLIC virtual SwUndoId StartUndo(SwUndoId const eUndoId,
67 SwRewriter const*const pRewriter) override;
68 SW_DLLPUBLIC virtual SwUndoId EndUndo(SwUndoId const eUndoId,
69 SwRewriter const*const pRewriter) override;
70 virtual void DelAllUndoObj() override;
71 virtual bool GetLastUndoInfo(OUString *const o_pStr,
72 SwUndoId *const o_pId,
73 const SwView* pView = nullptr) const override;
74 virtual SwUndoComments_t GetUndoComments() const override;
75 virtual bool GetFirstRedoInfo(OUString *const o_pStr,
76 SwUndoId *const o_pId,
77 const SwView* pView = nullptr) const override;
78 virtual SwUndoComments_t GetRedoComments() const override;
79 virtual bool Repeat(::sw::RepeatContext & rContext,
80 sal_uInt16 const nRepeatCnt) override;
81 virtual SwUndoId GetRepeatInfo(OUString *const o_pStr) const override;
82 virtual void AppendUndo(std::unique_ptr<SwUndo> pUndo) override;
83 virtual void ClearRedo() override;
84 virtual bool IsUndoNodes(SwNodes const& rNodes) const override;
85 SW_DLLPUBLIC virtual size_t GetUndoActionCount(const bool bCurrentLevel = true) const override;
86 size_t GetRedoActionCount(const bool bCurrentLevel = true) const override;
87 SW_DLLPUBLIC void SetView(SwView* pView) override;
88 bool UndoWithOffset(size_t nUndoOffset) override;
90 // SfxUndoManager
91 virtual void AddUndoAction(std::unique_ptr<SfxUndoAction> pAction,
92 bool bTryMerg = false) override;
93 SW_DLLPUBLIC virtual bool Undo() override;
94 SW_DLLPUBLIC virtual bool Redo() override;
95 void dumpAsXml(xmlTextWriterPtr pWriter) const;
97 SwUndo * RemoveLastUndo();
98 SwUndo * GetLastUndo();
100 SwNodes const& GetUndoNodes() const;
101 SwNodes & GetUndoNodes();
102 void SetDocShell(SwDocShell* pDocShell);
105 * Checks if the topmost undo action owned by pView is independent from the topmost action undo
106 * action. Sets rOffset to the offset of that independent undo action on success.
108 bool IsViewUndoActionIndependent(const SwView* pView, sal_uInt16& rOffset) const;
110 private:
111 virtual void EmptyActionsChanged() override;
113 IDocumentDrawModelAccess & m_rDrawModelAccess;
114 IDocumentRedlineAccess & m_rRedlineAccess;
115 IDocumentState & m_rState;
117 /// Undo nodes array: content not currently in document, but required for undo/redo.
118 std::shared_ptr<SwNodes> m_xUndoNodes;
120 bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled
121 bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled
122 /// If true, then repair mode is enabled.
123 bool m_bRepair;
124 bool m_bLockUndoNoModifiedPosition : 1;
125 /// set the IgnoreRepeat flag on every added action
126 bool m_isAddWithIgnoreRepeat;
127 /// position in Undo-Array at which Doc was saved (and is not modified)
128 UndoStackMark m_UndoSaveMark;
129 SwDocShell* m_pDocShell;
130 SwView* m_pView;
132 enum class UndoOrRedoType { Undo, Redo };
133 bool impl_DoUndoRedo(UndoOrRedoType undoOrRedo, size_t nUndoOffset);
135 // UGLY: should not be called
136 using SdrUndoManager::Repeat;
139 } // namespace sw
141 #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */