1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef SW_UNDO_MANAGER_HXX 29 #define SW_UNDO_MANAGER_HXX 30 31 #include <IDocumentUndoRedo.hxx> 32 33 #include <memory> 34 35 #include <svl/undo.hxx> 36 37 38 class IDocumentDrawModelAccess; 39 class IDocumentRedlineAccess; 40 class IDocumentState; 41 42 43 namespace sw { 44 45 class UndoManager 46 : public IDocumentUndoRedo 47 , public SfxUndoManager 48 { 49 public: 50 51 UndoManager(::std::auto_ptr<SwNodes> pUndoNodes, 52 IDocumentDrawModelAccess & rDrawModelAccess, 53 IDocumentRedlineAccess & rRedlineAccess, 54 IDocumentState & rState); 55 56 /** IDocumentUndoRedo */ 57 virtual void DoUndo(bool const bDoUndo); 58 virtual bool DoesUndo() const; 59 virtual void DoGroupUndo(bool const bDoUndo); 60 virtual bool DoesGroupUndo() const; 61 virtual void DoDrawUndo(bool const bDoUndo); 62 virtual bool DoesDrawUndo() const; 63 virtual void SetUndoNoModifiedPosition(); 64 virtual void LockUndoNoModifiedPosition(); 65 virtual void UnLockUndoNoModifiedPosition(); 66 virtual void SetUndoNoResetModified(); 67 virtual bool IsUndoNoResetModified() const; 68 // virtual bool Undo(); 69 virtual SwUndoId StartUndo(SwUndoId const eUndoId, 70 SwRewriter const*const pRewriter); 71 virtual SwUndoId EndUndo(SwUndoId const eUndoId, 72 SwRewriter const*const pRewriter); 73 virtual void DelAllUndoObj(); 74 virtual bool GetLastUndoInfo(::rtl::OUString *const o_pStr, 75 SwUndoId *const o_pId) const; 76 virtual SwUndoComments_t GetUndoComments() const; 77 // virtual bool Redo(); 78 virtual bool GetFirstRedoInfo(::rtl::OUString *const o_pStr) const; 79 virtual SwUndoComments_t GetRedoComments() const; 80 virtual bool Repeat(::sw::RepeatContext & rContext, 81 sal_uInt16 const nRepeatCnt); 82 virtual SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const; 83 virtual void AppendUndo(SwUndo *const pUndo); 84 virtual void ClearRedo(); 85 virtual bool IsUndoNodes(SwNodes const& rNodes) const; 86 87 // ::svl::IUndoManager 88 virtual void AddUndoAction(SfxUndoAction *pAction, 89 sal_Bool bTryMerg = sal_False); 90 virtual sal_Bool Undo(); 91 virtual sal_Bool Redo(); 92 virtual void EnableUndo(bool bEnable); 93 94 SwUndo * RemoveLastUndo(); 95 SwUndo * GetLastUndo(); 96 97 SwNodes const& GetUndoNodes() const; 98 SwNodes & GetUndoNodes(); 99 100 private: 101 IDocumentDrawModelAccess & m_rDrawModelAccess; 102 IDocumentRedlineAccess & m_rRedlineAccess; 103 IDocumentState & m_rState; 104 105 /// Undo nodes array: content not currently in document 106 ::std::auto_ptr<SwNodes> m_pUndoNodes; 107 108 bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled 109 bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled 110 bool m_bLockUndoNoModifiedPosition : 1; 111 /// position in Undo-Array at which Doc was saved (and is not modified) 112 UndoStackMark m_UndoSaveMark; 113 114 typedef enum { UNDO = true, REDO = false } UndoOrRedo_t; 115 bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo); 116 117 // UGLY: should not be called 118 using SfxUndoManager::Repeat; 119 }; 120 121 } // namespace sw 122 123 #endif // SW_UNDO_MANAGER_HXX 124 125