1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef SW_UNDO_MANAGER_HXX 25 #define SW_UNDO_MANAGER_HXX 26 27 #include <IDocumentUndoRedo.hxx> 28 29 #include <memory> 30 31 #include <svl/undo.hxx> 32 33 34 class IDocumentDrawModelAccess; 35 class IDocumentRedlineAccess; 36 class IDocumentState; 37 38 39 namespace sw { 40 41 class UndoManager 42 : public IDocumentUndoRedo 43 , public SfxUndoManager 44 { 45 public: 46 47 UndoManager(::std::auto_ptr<SwNodes> pUndoNodes, 48 IDocumentDrawModelAccess & rDrawModelAccess, 49 IDocumentRedlineAccess & rRedlineAccess, 50 IDocumentState & rState); 51 52 /** IDocumentUndoRedo */ 53 virtual void DoUndo(bool const bDoUndo); 54 virtual bool DoesUndo() const; 55 virtual void DoGroupUndo(bool const bDoUndo); 56 virtual bool DoesGroupUndo() const; 57 virtual void DoDrawUndo(bool const bDoUndo); 58 virtual bool DoesDrawUndo() const; 59 virtual void SetUndoNoModifiedPosition(); 60 virtual void LockUndoNoModifiedPosition(); 61 virtual void UnLockUndoNoModifiedPosition(); 62 virtual void SetUndoNoResetModified(); 63 virtual bool IsUndoNoResetModified() const; 64 // virtual bool Undo(); 65 virtual SwUndoId StartUndo(SwUndoId const eUndoId, 66 SwRewriter const*const pRewriter); 67 virtual SwUndoId EndUndo(SwUndoId const eUndoId, 68 SwRewriter const*const pRewriter); 69 virtual void DelAllUndoObj(); 70 virtual bool GetLastUndoInfo(::rtl::OUString *const o_pStr, 71 SwUndoId *const o_pId) const; 72 virtual SwUndoComments_t GetUndoComments() const; 73 // virtual bool Redo(); 74 virtual bool GetFirstRedoInfo(::rtl::OUString *const o_pStr) const; 75 virtual SwUndoComments_t GetRedoComments() const; 76 virtual bool Repeat(::sw::RepeatContext & rContext, 77 sal_uInt16 const nRepeatCnt); 78 virtual SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const; 79 virtual void AppendUndo(SwUndo *const pUndo); 80 virtual void ClearRedo(); 81 virtual bool IsUndoNodes(SwNodes const& rNodes) const; 82 83 // ::svl::IUndoManager 84 virtual void AddUndoAction(SfxUndoAction *pAction, 85 sal_Bool bTryMerg = sal_False); 86 virtual sal_Bool Undo(); 87 virtual sal_Bool Redo(); 88 virtual void EnableUndo(bool bEnable); 89 90 SwUndo * RemoveLastUndo(); 91 SwUndo * GetLastUndo(); 92 93 SwNodes const& GetUndoNodes() const; 94 SwNodes & GetUndoNodes(); 95 96 private: 97 IDocumentDrawModelAccess & m_rDrawModelAccess; 98 IDocumentRedlineAccess & m_rRedlineAccess; 99 IDocumentState & m_rState; 100 101 /// Undo nodes array: content not currently in document 102 ::std::auto_ptr<SwNodes> m_pUndoNodes; 103 104 bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled 105 bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled 106 bool m_bLockUndoNoModifiedPosition : 1; 107 /// position in Undo-Array at which Doc was saved (and is not modified) 108 UndoStackMark m_UndoSaveMark; 109 110 typedef enum { UNDO = true, REDO = false } UndoOrRedo_t; 111 bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo); 112 113 // UGLY: should not be called 114 using SfxUndoManager::Repeat; 115 }; 116 117 } // namespace sw 118 119 #endif // SW_UNDO_MANAGER_HXX 120 121