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