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