sdrundomanager.cxx (69ffbee1) | sdrundomanager.cxx (3d9b0034) |
---|---|
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 --- 14 unchanged lines hidden (view full) --- 23#include "precompiled_svx.hxx" 24#include <svx/sdrundomanager.hxx> 25 26////////////////////////////////////////////////////////////////////////////// 27 28SdrUndoManager::SdrUndoManager(sal_uInt16 nMaxUndoActionCount) 29: EditUndoManager(nMaxUndoActionCount), 30 maEndTextEditHdl(), | 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 --- 14 unchanged lines hidden (view full) --- 23#include "precompiled_svx.hxx" 24#include <svx/sdrundomanager.hxx> 25 26////////////////////////////////////////////////////////////////////////////// 27 28SdrUndoManager::SdrUndoManager(sal_uInt16 nMaxUndoActionCount) 29: EditUndoManager(nMaxUndoActionCount), 30 maEndTextEditHdl(), |
31 mpLastUndoActionBeforeTextEdit(0) | 31 mpLastUndoActionBeforeTextEdit(0), 32 mbEndTextEditTriggeredFromUndo(false) |
32{ 33} 34 35SdrUndoManager::~SdrUndoManager() 36{ 37} 38 39sal_Bool SdrUndoManager::Undo() 40{ | 33{ 34} 35 36SdrUndoManager::~SdrUndoManager() 37{ 38} 39 40sal_Bool SdrUndoManager::Undo() 41{ |
41 sal_Bool bRetval(sal_False); 42 43 if(maEndTextEditHdl.IsSet()) | 42 if(isTextEditActive()) |
44 { | 43 { |
44 sal_Bool bRetval(sal_False); 45 |
|
45 // we are in text edit mode 46 if(GetUndoActionCount() && mpLastUndoActionBeforeTextEdit != GetUndoAction(0)) 47 { 48 // there is an undo action for text edit, trigger it 49 bRetval = EditUndoManager::Undo(); 50 } 51 else 52 { 53 // no more text edit undo, end text edit | 46 // we are in text edit mode 47 if(GetUndoActionCount() && mpLastUndoActionBeforeTextEdit != GetUndoAction(0)) 48 { 49 // there is an undo action for text edit, trigger it 50 bRetval = EditUndoManager::Undo(); 51 } 52 else 53 { 54 // no more text edit undo, end text edit |
55 mbEndTextEditTriggeredFromUndo = true; |
|
54 maEndTextEditHdl.Call(this); | 56 maEndTextEditHdl.Call(this); |
57 mbEndTextEditTriggeredFromUndo = false; |
|
55 } | 58 } |
56 } | |
57 | 59 |
58 if(!bRetval && GetUndoActionCount()) | 60 return bRetval; 61 } 62 else |
59 { 60 // no undo triggered up to now, trigger local one | 63 { 64 // no undo triggered up to now, trigger local one |
61 bRetval = SfxUndoManager::Undo(); | 65 return SfxUndoManager::Undo(); |
62 } | 66 } |
63 64 return bRetval; | |
65} 66 67sal_Bool SdrUndoManager::Redo() 68{ 69 sal_Bool bRetval(sal_False); 70 | 67} 68 69sal_Bool SdrUndoManager::Redo() 70{ 71 sal_Bool bRetval(sal_False); 72 |
71 if(maEndTextEditHdl.IsSet()) | 73 if(isTextEditActive()) |
72 { 73 // we are in text edit mode 74 bRetval = EditUndoManager::Redo(); 75 } 76 77 if(!bRetval) 78 { 79 // no redo triggered up to now, trigger local one 80 bRetval = SfxUndoManager::Redo(); 81 } 82 83 return bRetval; 84} 85 86void SdrUndoManager::SetEndTextEditHdl(const Link& rLink) 87{ 88 maEndTextEditHdl = rLink; 89 | 74 { 75 // we are in text edit mode 76 bRetval = EditUndoManager::Redo(); 77 } 78 79 if(!bRetval) 80 { 81 // no redo triggered up to now, trigger local one 82 bRetval = SfxUndoManager::Redo(); 83 } 84 85 return bRetval; 86} 87 88void SdrUndoManager::SetEndTextEditHdl(const Link& rLink) 89{ 90 maEndTextEditHdl = rLink; 91 |
90 if(maEndTextEditHdl.IsSet()) | 92 if(isTextEditActive()) |
91 { 92 // text edit start, remember last non-textedit action for later cleanup 93 mpLastUndoActionBeforeTextEdit = GetUndoActionCount() ? GetUndoAction(0) : 0; 94 } 95 else 96 { 97 // text edit ends, pop all textedit actions up to the remembered non-textedit action from the start 98 // to set back the UndoManager to the state before text edit started. If that action is already gone --- 6 unchanged lines hidden (view full) --- 105 // urgently needed: RemoveLastUndoAction does NOT correct the Redo stack by itself (!) 106 ClearRedo(); 107 108 // forget marker again 109 mpLastUndoActionBeforeTextEdit = 0; 110 } 111} 112 | 93 { 94 // text edit start, remember last non-textedit action for later cleanup 95 mpLastUndoActionBeforeTextEdit = GetUndoActionCount() ? GetUndoAction(0) : 0; 96 } 97 else 98 { 99 // text edit ends, pop all textedit actions up to the remembered non-textedit action from the start 100 // to set back the UndoManager to the state before text edit started. If that action is already gone --- 6 unchanged lines hidden (view full) --- 107 // urgently needed: RemoveLastUndoAction does NOT correct the Redo stack by itself (!) 108 ClearRedo(); 109 110 // forget marker again 111 mpLastUndoActionBeforeTextEdit = 0; 112 } 113} 114 |
115bool SdrUndoManager::isTextEditActive() const 116{ 117 return maEndTextEditHdl.IsSet(); 118} 119 |
|
113////////////////////////////////////////////////////////////////////////////// 114// eof | 120////////////////////////////////////////////////////////////////////////////// 121// eof |