sd/qa/unit/tiledrendering/data/TextBoxAndRect.odg |binary
 sd/qa/unit/tiledrendering/tiledrendering.cxx      |   38 ++++++++++++++++++++++
 sd/source/ui/view/drviews1.cxx                    |    3 +
 3 files changed, 40 insertions(+), 1 deletion(-)

New commits:
commit 5ea797d83f753787b61c8e7e1278dc517812cf56
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Jan 15 09:39:14 2026 +0000
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue Jan 20 10:38:13 2026 +0100

    kit: Don't exit shape edit mode due to a view-switch
    
    View1 - enters text edit mode in a shape on page A
    View2 - enters text edit mode in a shape on page B
    
    There is a view switch from B to A and back to B, in which case View2
    should remain in shape edit mode and not auto-exit.
    
    Change-Id: I55f492903c80a347cd7f8287d5a60d20628f69b0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197341
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>
    (cherry picked from commit c5d1aaba6c898c87190b0ca64f463dcf6b0c301f)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197366
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sd/qa/unit/tiledrendering/data/TextBoxAndRect.odg 
b/sd/qa/unit/tiledrendering/data/TextBoxAndRect.odg
index aa1a37b83147..d715f8180052 100644
Binary files a/sd/qa/unit/tiledrendering/data/TextBoxAndRect.odg and 
b/sd/qa/unit/tiledrendering/data/TextBoxAndRect.odg differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index caf90b070016..7d7b7dc79055 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -2645,6 +2645,44 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, 
testShapeEditInMultipleViews)
         CPPUNIT_ASSERT_EQUAL(false, pView1->IsTextEdit());
         CPPUNIT_ASSERT_EQUAL(false, pView2->IsTextEdit());
     }
+
+    // Scenario 4
+    // View1 - enters text edit mode in a shape on page A
+    // View2 - enters text edit mode in a shape on page B
+    // there is a view switch from B to A and back to B.
+    // View2 should remain in shape edit mode and not exit
+    // shape edit mode on switching back to view2
+    {
+        CPPUNIT_ASSERT_EQUAL(false, pView1->IsTextEdit());
+        CPPUNIT_ASSERT_EQUAL(false, pView2->IsTextEdit());
+
+        // Switch to view 1
+        SfxLokHelper::setView(nView1);
+        pView1->SdrBeginTextEdit(pTextBoxObject);
+
+        SfxLokHelper::setView(nView2);
+        pXImpressDocument->setPart(2);
+        SdPage* pPage3 = pViewShell2->GetActualPage();
+
+        CPPUNIT_ASSERT_MESSAGE("Page Change didn't work", pPage1 != pPage3);
+
+        SdrObject* pPage3TextBoxObject = pPage3->GetObj(0);
+        CPPUNIT_ASSERT_EQUAL(u"Text Box 1"_ustr, 
pPage3TextBoxObject->GetName());
+
+        pView2->SdrBeginTextEdit(pPage3TextBoxObject);
+        CPPUNIT_ASSERT_EQUAL(true, pView2->IsTextEdit());
+
+        SfxLokHelper::setView(nView1);
+        pXImpressDocument->setPart(0);
+
+        CPPUNIT_ASSERT_EQUAL(true, pView2->IsTextEdit());
+
+        SfxLokHelper::setView(nView2);
+        pXImpressDocument->setPart(2);
+
+        // Fails before fix
+        CPPUNIT_ASSERT_EQUAL(true, pView2->IsTextEdit());
+    }
 }
 
 CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSidebarHide)
diff --git a/sd/source/ui/view/drviews1.cxx b/sd/source/ui/view/drviews1.cxx
index e6eef33c79c3..b3a7292166ff 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -30,6 +30,7 @@
 #include <svx/svdpagv.hxx>
 #include <sfx2/viewfrm.hxx>
 #include <sfx2/bindings.hxx>
+#include <sfx2/lokhelper.hxx>
 #include <svx/svdoole2.hxx>
 #include <sfx2/dispatch.hxx>
 #include <sfx2/module.hxx>
@@ -943,7 +944,7 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage, 
bool bAllowChangeFocus,
             }
         }
 
-        if (bAllowChangeFocus)
+        if (bAllowChangeFocus && !SfxLokHelper::isSettingView())
             mpDrawView->SdrEndTextEdit();
 
         mpActualPage = nullptr;

Reply via email to