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