summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamás Zolnai <tamas.zolnai@collabora.com>2019-01-02 18:06:37 +0100
committerTamás Zolnai <tamas.zolnai@collabora.com>2019-01-04 04:33:51 +0100
commit9a115beac9a13ae320a9abf578be25bfbff1e02d (patch)
treee6f576e0e56fb285fa5713e33fb0e73e9a28eedd
parentdcf70bb4188e019154d6201936bf1ee2e16149a3 (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
-rw-r--r--sw/source/uibase/docvw/FloatingTableButton.cxx17
1 files changed, 15 insertions, 2 deletions
diff --git a/sw/source/uibase/docvw/FloatingTableButton.cxx b/sw/source/uibase/docvw/FloatingTableButton.cxx
index eccdef644227..949934d5908d 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->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&)