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 SwUndoId StartUndo(SwUndoId const eUndoId, 61 SwRewriter const*const pRewriter); 62 virtual SwUndoId EndUndo(SwUndoId const eUndoId, 63 SwRewriter const*const pRewriter); 64 virtual void DelAllUndoObj(); 65 virtual bool GetLastUndoInfo(::rtl::OUString *const o_pStr, 66 SwUndoId *const o_pId) const; 67 virtual SwUndoComments_t GetUndoComments() const; 68 virtual bool GetFirstRedoInfo(::rtl::OUString *const o_pStr, 69 SwUndoId *const o_pId = 0) const; 70 virtual SwUndoComments_t GetRedoComments() const; 71 virtual bool Repeat(::sw::RepeatContext & rContext, 72 sal_uInt16 const nRepeatCnt); 73 virtual SwUndoId GetRepeatInfo(::rtl::OUString *const o_pStr) const; 74 virtual void AppendUndo(SwUndo *const pUndo); 75 virtual void ClearRedo(); 76 virtual bool IsUndoNodes(SwNodes const& rNodes) const; 77 78 // ::svl::IUndoManager 79 virtual void AddUndoAction(SfxUndoAction *pAction, 80 sal_Bool bTryMerg = sal_False); 81 virtual sal_Bool Undo(); 82 virtual sal_Bool Redo(); 83 virtual void EnableUndo(bool bEnable); 84 85 SwUndo * RemoveLastUndo(); 86 SwUndo * GetLastUndo(); 87 88 SwNodes const& GetUndoNodes() const; 89 SwNodes & GetUndoNodes(); 90 91 private: 92 IDocumentDrawModelAccess & m_rDrawModelAccess; 93 IDocumentRedlineAccess & m_rRedlineAccess; 94 IDocumentState & m_rState; 95 96 /// Undo nodes array: content not currently in document 97 ::std::auto_ptr<SwNodes> m_pUndoNodes; 98 99 bool m_bGroupUndo : 1; // TRUE: Undo grouping enabled 100 bool m_bDrawUndo : 1; // TRUE: Draw Undo enabled 101 bool m_bLockUndoNoModifiedPosition : 1; 102 /// position in Undo-Array at which Doc was saved (and is not modified) 103 UndoStackMark m_UndoSaveMark; 104 105 typedef enum { UNDO = true, REDO = false } UndoOrRedo_t; 106 bool impl_DoUndoRedo(UndoOrRedo_t const undoOrRedo); 107 108 // UGLY: should not be called 109 using SdrUndoManager::Repeat; 110 }; 111 112 } // namespace sw 113 114 #endif // SW_UNDO_MANAGER_HXX 115 116