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 #ifndef _SDR_UNDOMANAGER_HXX 23 #define _SDR_UNDOMANAGER_HXX 24 25 #include "svx/svxdllapi.h" 26 #include <sal/types.h> 27 #include <editeng/editund2.hxx> 28 #include <tools/link.hxx> 29 30 ////////////////////////////////////////////////////////////////////////////// 31 32 class SVX_DLLPUBLIC SdrUndoManager : public EditUndoManager 33 { 34 private: 35 using EditUndoManager::Undo; 36 using EditUndoManager::Redo; 37 38 Link maEndTextEditHdl; 39 SfxUndoAction* mpLastUndoActionBeforeTextEdit; 40 bool mbEndTextEditTriggeredFromUndo; 41 42 protected: 43 // call to check for TextEdit active 44 bool isTextEditActive() const; 45 46 public: 47 SdrUndoManager(sal_uInt16 nMaxUndoActionCount = 20); 48 virtual ~SdrUndoManager(); 49 50 /// react depending on edit mode and if no more undo is possible 51 virtual sal_Bool Undo(); 52 virtual sal_Bool Redo(); 53 54 // ## 55 virtual void Clear(); 56 57 // Call for the view which starts the interactive text edit. Use link to 58 // activate (start text edit) and empty link to reset (end text edit). On 59 // reset all text edit actions will be removed from this undo manager to 60 // restore the state before activation 61 void SetEndTextEditHdl(const Link& rLink); 62 63 // check from outside if we are inside a callback for ending text edit. This 64 // is needed to detect inside end text edit if it is a regular one or triggered 65 // by a last undo during text edit isEndTextEditTriggeredFromUndo()66 bool isEndTextEditTriggeredFromUndo() { return mbEndTextEditTriggeredFromUndo; } 67 }; 68 69 ////////////////////////////////////////////////////////////////////////////// 70 71 #endif //_SDR_UNDOMANAGER_HXX 72 // eof 73