Line data Source code
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 <boost/shared_ptr.hpp>
25 : #include <svx/sdrundomanager.hxx>
26 : #include <ndarr.hxx>
27 :
28 : class IDocumentDrawModelAccess;
29 : class IDocumentRedlineAccess;
30 : class IDocumentState;
31 :
32 : namespace sw {
33 :
34 10090 : class UndoManager
35 : : public IDocumentUndoRedo
36 : , public SdrUndoManager
37 : {
38 : public:
39 : UndoManager(boost::shared_ptr<SwNodes> pUndoNodes,
40 : IDocumentDrawModelAccess & rDrawModelAccess,
41 : IDocumentRedlineAccess & rRedlineAccess,
42 : IDocumentState & rState);
43 :
44 : /** IDocumentUndoRedo */
45 : virtual void DoUndo(bool const bDoUndo) SAL_OVERRIDE;
46 : virtual bool DoesUndo() const SAL_OVERRIDE;
47 : virtual void DoGroupUndo(bool const bDoUndo) SAL_OVERRIDE;
48 : virtual bool DoesGroupUndo() const SAL_OVERRIDE;
49 : virtual void DoDrawUndo(bool const bDoUndo) SAL_OVERRIDE;
50 : virtual bool DoesDrawUndo() const SAL_OVERRIDE;
51 : virtual void SetUndoNoModifiedPosition() SAL_OVERRIDE;
52 : virtual void LockUndoNoModifiedPosition() SAL_OVERRIDE;
53 : virtual void UnLockUndoNoModifiedPosition() SAL_OVERRIDE;
54 : virtual void SetUndoNoResetModified() SAL_OVERRIDE;
55 : virtual bool IsUndoNoResetModified() const SAL_OVERRIDE;
56 :
57 : virtual SwUndoId StartUndo(SwUndoId const eUndoId,
58 : SwRewriter const*const pRewriter) SAL_OVERRIDE;
59 : virtual SwUndoId EndUndo(SwUndoId const eUndoId,
60 : SwRewriter const*const pRewriter) SAL_OVERRIDE;
61 : virtual void DelAllUndoObj() SAL_OVERRIDE;
62 : virtual bool GetLastUndoInfo(OUString *const o_pStr,
63 : SwUndoId *const o_pId) const SAL_OVERRIDE;
64 : virtual SwUndoComments_t GetUndoComments() const SAL_OVERRIDE;
65 : virtual bool GetFirstRedoInfo(OUString *const o_pStr,
66 : SwUndoId *const o_pId = 0) const SAL_OVERRIDE;
67 : virtual SwUndoComments_t GetRedoComments() const SAL_OVERRIDE;
68 : virtual bool Repeat(::sw::RepeatContext & rContext,
69 : sal_uInt16 const nRepeatCnt) SAL_OVERRIDE;
70 : virtual SwUndoId GetRepeatInfo(OUString *const o_pStr) const SAL_OVERRIDE;
71 : virtual void AppendUndo(SwUndo *const pUndo) SAL_OVERRIDE;
72 : virtual void ClearRedo() SAL_OVERRIDE;
73 : virtual bool IsUndoNodes(SwNodes const& rNodes) const SAL_OVERRIDE;
74 :
75 : // ::svl::IUndoManager
76 : virtual void AddUndoAction(SfxUndoAction *pAction,
77 : bool bTryMerg = false) SAL_OVERRIDE;
78 : virtual bool Undo() SAL_OVERRIDE;
79 : virtual bool Redo() SAL_OVERRIDE;
80 : virtual void EnableUndo(bool bEnable) SAL_OVERRIDE;
81 :
82 : SwUndo * RemoveLastUndo();
83 : SwUndo * GetLastUndo();
84 :
85 : SwNodes const& GetUndoNodes() const;
86 : SwNodes & GetUndoNodes();
87 :
88 : void dumpAsXml(xmlTextWriterPtr w);
89 :
90 : private:
91 : IDocumentDrawModelAccess & m_rDrawModelAccess;
92 : IDocumentRedlineAccess & m_rRedlineAccess;
93 : IDocumentState & m_rState;
94 :
95 : /// Undo nodes array: content not currently in document
96 : boost::shared_ptr<SwNodes> m_xUndoNodes;
97 :
98 : bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled
99 : bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled
100 : bool m_bLockUndoNoModifiedPosition : 1;
101 : /// position in Undo-Array at which Doc was saved (and is not modified)
102 : UndoStackMark m_UndoSaveMark;
103 :
104 : typedef enum { UNDO = int(true), REDO = int(false) } UndoOrRedo_t;
105 : bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo);
106 :
107 : // UGLY: should not be called
108 : using SdrUndoManager::Repeat;
109 : };
110 :
111 : } // namespace sw
112 :
113 : #endif // INCLUDED_SW_SOURCE_CORE_INC_UNDOMANAGER_HXX
114 :
115 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|