[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-6.4' - include/svx sd/qa svx/source

Szymon KÅ‚os (via logerrit) logerrit at kemper.freedesktop.org
Tue Mar 30 13:17:30 UTC 2021


 include/svx/svdedtv.hxx                      |    6 +++
 sd/qa/unit/tiledrendering/tiledrendering.cxx |   51 +++++++++++++++++++++++++++
 svx/source/svdraw/svdedtv.cxx                |   21 +++++++++--
 3 files changed, 74 insertions(+), 4 deletions(-)

New commits:
commit 795005f210e74bf04be798609ca1d4d93be74061
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Mar 26 09:30:18 2021 +0100
Commit:     Jan Holesovsky <kendy at collabora.com>
CommitDate: Tue Mar 30 15:16:57 2021 +0200

    Don't end text editing in other views if shape inserted
    
    This is revert of a small piece of
    tdf#126180: EndTextEdit on all views before delete/cut slide
    e6c7a018a0cfee395ce2886d41c908a2447ef5cc
    
    Change needed for online where multiple users work together
    and we need to not disturb other views in editing.
    
    Change-Id: I73c2289a9d950465f020f684e9e736148380f5c5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113148
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/include/svx/svdedtv.hxx b/include/svx/svdedtv.hxx
index 4351ccee2764..51da6124ed88 100644
--- a/include/svx/svdedtv.hxx
+++ b/include/svx/svdedtv.hxx
@@ -185,6 +185,12 @@ public:
     void SetUndoComment(const OUString& rComment, const OUString& rObjDescr) { mpModel->SetUndoComment(rComment,rObjDescr); }
     bool IsUndoEnabled() const;
 
+    /**
+     * Checks if this or other views have an active text edit, in which case object undos are not
+     * created.
+     */
+    bool CanDoSdrUndo() const;
+
     /**
      * Checks if this or other views have an active text edit, if true, end them.
      */
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 61940c1e8c2a..161aed640277 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -114,6 +114,7 @@ public:
     void testCommentChangeDraw();
     void testMultiViewInsertDeletePage();
     void testMultiViewInsertDeletePage2();
+    void testEditingTextBoxAndInsertShapeInterrupt();
     void testDisableUndoRepair();
     void testDocumentRepair();
     void testLanguageStatus();
@@ -167,6 +168,7 @@ public:
     CPPUNIT_TEST(testCommentChangeDraw);
     CPPUNIT_TEST(testMultiViewInsertDeletePage);
     CPPUNIT_TEST(testMultiViewInsertDeletePage2);
+    CPPUNIT_TEST(testEditingTextBoxAndInsertShapeInterrupt);
     CPPUNIT_TEST(testDisableUndoRepair);
     CPPUNIT_TEST(testDocumentRepair);
     CPPUNIT_TEST(testLanguageStatus);
@@ -1986,6 +1988,55 @@ void SdTiledRenderingTest::testMultiViewInsertDeletePage2()
     CPPUNIT_ASSERT(pViewShell->GetView()->IsTextEdit());
 }
 
+void SdTiledRenderingTest::testEditingTextBoxAndInsertShapeInterrupt()
+{
+    // Load the document.
+    SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp");
+    ViewCallback aView1;
+    int nView1 = SfxLokHelper::getView();
+    uno::Sequence<beans::PropertyValue> aArgs;
+
+    // Create second view
+    SfxLokHelper::createView();
+    pXImpressDocument->initializeForTiledRendering(aArgs);
+    ViewCallback aView2;
+    int nView2 = SfxLokHelper::getView();
+
+    // Switch to 5th page in 2nd view
+    pXImpressDocument->setPart(4);
+
+    // Begin text edit on the only object on the slide.
+    sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell();
+    SdPage* pActualPage = pViewShell->GetActualPage();
+    SdrObject* pObject1 = pActualPage->GetObj(0);
+    CPPUNIT_ASSERT(pObject1 != nullptr);
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(OBJ_TITLETEXT), pObject1->GetObjIdentifier());
+    SdrTextObj* pTextObject = static_cast<SdrTextObj*>(pObject1);
+
+    // Double-click outside the text to enter edit mode.
+    const ::tools::Rectangle aRect = pTextObject->GetCurrentBoundRect();
+    const auto cornerX = convertMm100ToTwip(aRect.getX() + (aRect.getWidth() / 4));
+    const auto cornerY = convertMm100ToTwip(aRect.getY() + (aRect.getHeight() / 4));
+    pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN,
+                                      cornerX, cornerY,
+                                      2, MOUSE_LEFT, 0);
+    pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP,
+                                      cornerX, cornerY,
+                                      2, MOUSE_LEFT, 0);
+    Scheduler::ProcessEventsToIdle();
+
+    // We must be in text editing mode and have cursor visible.
+    CPPUNIT_ASSERT(pViewShell->GetView()->IsTextEdit());
+
+    // Insert shape in 1st view
+    SfxLokHelper::setView(nView1);
+    comphelper::dispatchCommand(".uno:BasicShapes.rectangle", aArgs);
+
+    // We must be still in text editing mode and have cursor visible.
+    SfxLokHelper::setView(nView2);
+    CPPUNIT_ASSERT(pViewShell->GetView()->IsTextEdit());
+}
+
 void SdTiledRenderingTest::testDisableUndoRepair()
 {
     // Load the document.
diff --git a/svx/source/svdraw/svdedtv.cxx b/svx/source/svdraw/svdedtv.cxx
index b301d19312d2..b48174ad8b57 100644
--- a/svx/source/svdraw/svdedtv.cxx
+++ b/svx/source/svdraw/svdedtv.cxx
@@ -973,11 +973,8 @@ bool SdrEditView::InsertObjectAtView(SdrObject* pObj, SdrPageView& rPV, SdrInser
     if (!pObj->IsInserted()) {
         rPV.GetObjList()->InsertObject(pObj, SAL_MAX_SIZE);
     }
-    if( IsUndoEnabled())
-    {
-        EndTextEditAllViews();
+    if( IsUndoEnabled() && CanDoSdrUndo())
         AddUndo(GetModel()->GetSdrUndoFactory().CreateUndoNewObject(*pObj));
-    }
 
     if (!(nOptions & SdrInsertFlags::DONTMARK)) {
         if (!(nOptions & SdrInsertFlags::ADDMARK)) UnmarkAllObj();
@@ -1032,6 +1029,22 @@ bool SdrEditView::IsUndoEnabled() const
     return mpModel->IsUndoEnabled();
 }
 
+bool SdrEditView::CanDoSdrUndo() const
+{
+    size_t nViews = mpModel->GetListenerCount();
+    for (size_t nView = 0; nView < nViews; ++nView)
+    {
+        SdrEditView* pView = dynamic_cast<SdrEditView*>(mpModel->GetListener(nView));
+        if (!pView)
+            continue;
+
+        if (pView->IsTextEdit())
+            return false;
+    }
+
+    return true;
+}
+
 void SdrEditView::EndTextEditAllViews() const
 {
     size_t nViews = mpModel->GetListenerCount();


More information about the Libreoffice-commits mailing list