sd/qa/unit/tiledrendering/data/TextBoxAndRect.odg |binary
 sd/qa/unit/tiledrendering/data/Type-in-draw.odg   |binary
 sd/qa/unit/tiledrendering/tiledrendering.cxx      |   38 ++++++++++++++++++++++
 sd/source/ui/view/drviews1.cxx                    |    2 -
 4 files changed, 39 insertions(+), 1 deletion(-)

New commits:
commit 1611b288492558fa5d17b08abd1e9b6508503851
Author:     Caolán McNamara <[email protected]>
AuthorDate: Thu Jan 15 09:39:14 2026 +0000
Commit:     Caolán McNamara <[email protected]>
CommitDate: Thu Jan 15 14:26:07 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/+/197340
    Tested-by: Jenkins CollaboraOffice <[email protected]>
    Reviewed-by: Caolán McNamara <[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/data/Type-in-draw.odg 
b/sd/qa/unit/tiledrendering/data/Type-in-draw.odg
new file mode 100644
index 000000000000..afac468f1926
Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/Type-in-draw.odg 
differ
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx 
b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 85c62eae34bd..12769303a9bc 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -2652,6 +2652,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 430c54dedb65..fba9a9c8835e 100644
--- a/sd/source/ui/view/drviews1.cxx
+++ b/sd/source/ui/view/drviews1.cxx
@@ -942,7 +942,7 @@ bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage, 
bool bAllowChangeFocus)
             }
         }
 
-        if (bAllowChangeFocus)
+        if (bAllowChangeFocus && !SfxLokHelper::isSettingView())
             mpDrawView->SdrEndTextEdit();
 
         mpActualPage = nullptr;

Reply via email to