summaryrefslogtreecommitdiff
path: root/svx/source/svdraw/sdrundomanager.cxx
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-08-09 08:42:27 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-05-28 15:55:23 +0100
commit12a4200e8ff7f045efcc7e9d15a24b15b248c437 (patch)
tree00363aedf07713ec9ff931d933b86a6b35e20267 /svx/source/svdraw/sdrundomanager.cxx
parent64b07d99aa0b31b3d04519afe6afe0cdf36bcd6f (diff)
Related: #i120498# Enhanced Undo/Redo and user experience...
when editing texts in graphic objects and/or tables (cherry picked from commit a096725779b210c7a2706e72596fd7c80e049fdd) Conflicts: editeng/inc/editeng/editeng.hxx editeng/inc/editeng/editund2.hxx editeng/inc/editeng/outliner.hxx editeng/source/editeng/editundo.cxx editeng/source/editeng/impedit.hxx editeng/source/outliner/outliner.cxx sd/source/core/undo/undomanager.cxx sd/source/ui/view/drviewse.cxx svx/Library_svxcore.mk svx/Package_inc.mk svx/inc/svx/svdedxv.hxx svx/source/svdraw/svdedxv.cxx Change-Id: I40e3ef2dff681f9b6f2f6b5d35507071f8110533 Comment unused variable pNewEditUndoManager to silence the compiler (cherry picked from commit 568655083af7830e7b9edf56ef862ddf9a99003b) Change-Id: Ib7179ee6c34ce03a75942978831c3a55968f161f Removed unused variable (cherry picked from commit 0bbde4414badfd40234de4a4c9f750194f5d1d5e) Change-Id: I39e7f25426e8e7d1367102d603b0f6c84d96622f
Diffstat (limited to 'svx/source/svdraw/sdrundomanager.cxx')
-rw-r--r--svx/source/svdraw/sdrundomanager.cxx109
1 files changed, 109 insertions, 0 deletions
diff --git a/svx/source/svdraw/sdrundomanager.cxx b/svx/source/svdraw/sdrundomanager.cxx
new file mode 100644
index 000000000000..88e0c6c6c5d0
--- /dev/null
+++ b/svx/source/svdraw/sdrundomanager.cxx
@@ -0,0 +1,109 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+#include <svx/sdrundomanager.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+SdrUndoManager::SdrUndoManager(sal_uInt16 nMaxUndoActionCount)
+: EditUndoManager(nMaxUndoActionCount),
+ maEndTextEditHdl(),
+ mpLastUndoActionBeforeTextEdit(0)
+{
+}
+
+SdrUndoManager::~SdrUndoManager()
+{
+}
+
+sal_Bool SdrUndoManager::Undo()
+{
+ sal_Bool bRetval(sal_False);
+
+ if(maEndTextEditHdl.IsSet())
+ {
+ // we are in text edit mode
+ if(GetUndoActionCount() && mpLastUndoActionBeforeTextEdit != GetUndoAction(0))
+ {
+ // there is an undo action for text edit, trigger it
+ bRetval = EditUndoManager::Undo();
+ }
+ else
+ {
+ // no more text edit undo, end text edit
+ maEndTextEditHdl.Call(this);
+ }
+ }
+
+ if(!bRetval && GetUndoActionCount())
+ {
+ // no undo triggered up to now, trigger local one
+ bRetval = SfxUndoManager::Undo();
+ }
+
+ return bRetval;
+}
+
+sal_Bool SdrUndoManager::Redo()
+{
+ sal_Bool bRetval(sal_False);
+
+ if(maEndTextEditHdl.IsSet())
+ {
+ // we are in text edit mode
+ bRetval = EditUndoManager::Redo();
+ }
+
+ if(!bRetval)
+ {
+ // no redo triggered up to now, trigger local one
+ bRetval = SfxUndoManager::Redo();
+ }
+
+ return bRetval;
+}
+
+void SdrUndoManager::SetEndTextEditHdl(const Link& rLink)
+{
+ maEndTextEditHdl = rLink;
+
+ if(maEndTextEditHdl.IsSet())
+ {
+ // text edit start, remember last non-textedit action for later cleanup
+ mpLastUndoActionBeforeTextEdit = GetUndoActionCount() ? GetUndoAction(0) : 0;
+ }
+ else
+ {
+ // text edit ends, pop all textedit actions up to the remembered non-textedit action from the start
+ // to set back the UndoManager to the state before text edit started. If that action is already gone
+ // (due to being removed from the undo stack in the meantime), all need to be removed anyways
+ while(GetUndoActionCount() && mpLastUndoActionBeforeTextEdit != GetUndoAction(0))
+ {
+ RemoveLastUndoAction();
+ }
+
+ // urgently needed: RemoveLastUndoAction does NOT correct the Redo stack by itself (!)
+ ClearRedo();
+
+ // forget marker again
+ mpLastUndoActionBeforeTextEdit = 0;
+ }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+// eof