diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-01-02 18:06:37 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2019-01-07 10:30:25 +0100 |
commit | 82d9796a674672d7ad141dd19bb266e8e4f0b846 (patch) | |
tree | e25a563186d27e34f84e68f382f8c054f4cd8af9 | |
parent | d2f6818130cef0926c8e3ead6dc6f03fd005fefc (diff) |
Unfloat: Disable undoing of unfloat operation
I tested to use undo events for unfloat operations:
moving a table outside of the text frame and removing the
text frame, but sometimes it just crashed. So now we handle
unfloating similar to the reverse operation (table is moved
into a text frame(MakeFlyAndMove).
Change-Id: I4eaeda550ccc51252abd4abde6cee45c76a8483e
Reviewed-on: https://gerrit.libreoffice.org/65822
Reviewed-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai@collabora.com>
Tested-by: Jenkins
(cherry picked from commit 9a115beac9a13ae320a9abf578be25bfbff1e02d)
Reviewed-on: https://gerrit.libreoffice.org/65873
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Miklos Vajna <vmiklos@collabora.com>
-rw-r--r-- | sw/source/uibase/docvw/FloatingTableButton.cxx | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/sw/source/uibase/docvw/FloatingTableButton.cxx b/sw/source/uibase/docvw/FloatingTableButton.cxx index 982af73c0367..ba0f0fcfbcc8 100644 --- a/sw/source/uibase/docvw/FloatingTableButton.cxx +++ b/sw/source/uibase/docvw/FloatingTableButton.cxx @@ -20,6 +20,8 @@ #include <txtfrm.hxx> #include <ndindex.hxx> #include <swtable.hxx> +#include <IDocumentState.hxx> +#include <IDocumentUndoRedo.hxx> #include <drawinglayer/primitive2d/textprimitive2d.hxx> #include <drawinglayer/processor2d/baseprocessor2d.hxx> #include <drawinglayer/attribute/fontattribute.hxx> @@ -100,12 +102,23 @@ void FloatingTableButton::MouseButtonDown(const MouseEvent& /*rMEvt*/) if (pTableNode == nullptr) return; + SwDoc& rDoc = *pTextFrame->GetTextNode()->GetDoc(); + + // Move the table outside of the text frame SwNodeRange aRange(*pTableNode, 0, *pTableNode->EndOfSectionNode(), 1); - pTableNode->getIDocumentContentOperations().MoveNodeRange(aRange, aInsertPos, - SwMoveFlags::DEFAULT); + rDoc.getIDocumentContentOperations().MoveNodeRange(aRange, aInsertPos, SwMoveFlags::DEFAULT); // Remove the floating table's frame SwFrame::DestroyFrame(pFlyFrame); + + rDoc.getIDocumentState().SetModified(); + + // Undoing MoveNodeRange() is not working correctly in case of tables, it crashes some times + // So don't allow to undo after unfloating (similar to MakeFlyAndMove() method) + if (rDoc.GetIDocumentUndoRedo().DoesUndo()) + { + rDoc.GetIDocumentUndoRedo().DelAllUndoObj(); + } } void FloatingTableButton::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) |