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>
25#include <ndarr.hxx>
26#include <memory>
27
30class IDocumentState;
31class SwDocShell;
32class SwView;
33
34namespace sw {
35
42 : public IDocumentUndoRedo
43 , public SdrUndoManager
44{
45public:
46 UndoManager(std::shared_ptr<SwNodes> pUndoNodes,
47 IDocumentDrawModelAccess & rDrawModelAccess,
48 IDocumentRedlineAccess & rRedlineAccess,
49 IDocumentState & rState);
50
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;
65
66 virtual SwUndoId StartUndo(SwUndoId const eUndoId,
67 SwRewriter const*const pRewriter) override;
68 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 virtual size_t GetUndoActionCount(const bool bCurrentLevel = true) const override;
86 size_t GetRedoActionCount(const bool bCurrentLevel = true) const override;
87 void SetView(SwView* pView) override;
88 bool UndoWithOffset(size_t nUndoOffset) override;
89
90 // SfxUndoManager
91 virtual void AddUndoAction(std::unique_ptr<SfxUndoAction> pAction,
92 bool bTryMerg = false) override;
93 virtual bool Undo() override;
94 virtual bool Redo() override;
95 void dumpAsXml(xmlTextWriterPtr pWriter) const;
96
97 SwUndo * RemoveLastUndo();
98 SwUndo * GetLastUndo();
99
100 SwNodes const& GetUndoNodes() const;
101 SwNodes & GetUndoNodes();
102 void SetDocShell(SwDocShell* pDocShell);
103
108 bool IsViewUndoActionIndependent(const SwView* pView, sal_uInt16& rOffset) const;
109
110private:
111 virtual void EmptyActionsChanged() override;
112
116
118 std::shared_ptr<SwNodes> m_xUndoNodes;
119
120 bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled
121 bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled
131
132 enum class UndoOrRedoType { Undo, Redo };
133 bool impl_DoUndoRedo(UndoOrRedoType undoOrRedo, size_t nUndoOffset);
134
135 // UGLY: should not be called
136 using SdrUndoManager::Repeat;
137};
138
139} // namespace sw
140
141#endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX
142
143/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void EndUndo(SwWrtShell &rSh)
Definition: basesh.cxx:3011
Get information about the current document state.
Definition: view.hxx:146
Stores the undo/redo information, implementing the IDocumentUndoRedo interface.
Definition: UndoManager.hxx:44
UndoStackMark m_UndoSaveMark
position in Undo-Array at which Doc was saved (and is not modified)
bool m_bLockUndoNoModifiedPosition
std::shared_ptr< SwNodes > m_xUndoNodes
Undo nodes array: content not currently in document, but required for undo/redo.
bool m_bRepair
If true, then repair mode is enabled.
IDocumentRedlineAccess & m_rRedlineAccess
bool m_isAddWithIgnoreRepeat
set the IgnoreRepeat flag on every added action
IDocumentDrawModelAccess & m_rDrawModelAccess
SwDocShell * m_pDocShell
IDocumentState & m_rState
struct _xmlTextWriter * xmlTextWriterPtr
Dialog to specify the properties of date form field.
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
SwUndoId
Definition: swundo.hxx:30
std::vector< OUString > SwUndoComments_t
Definition: swundo.hxx:26
sal_Int32 UndoStackMark