[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.0' - sw/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Jan 7 09:30:45 UTC 2019


 sw/source/uibase/docvw/FloatingTableButton.cxx |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

New commits:
commit 82d9796a674672d7ad141dd19bb266e8e4f0b846
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Wed Jan 2 18:06:37 2019 +0100
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Mon Jan 7 10:30:25 2019 +0100

    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 at collabora.com>
    Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    Tested-by: Jenkins
    (cherry picked from commit 9a115beac9a13ae320a9abf578be25bfbff1e02d)
    Reviewed-on: https://gerrit.libreoffice.org/65873
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
    Tested-by: Miklos Vajna <vmiklos at collabora.com>

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&)


More information about the Libreoffice-commits mailing list