From 7fced7bbd0d6d7769dcf13ab326c793d4096a247 Mon Sep 17 00:00:00 2001 From: Szymon Kłos Date: Wed, 9 Mar 2022 16:41:36 +0100 Subject: svx: don't remove object right after insertion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is regression from: commit 2d95b3846eac367d2baadc194ab258dc31e7bd33 Author: Tomaz Vajngerl Date: Thu Oct 7 16:48:46 2021 +0200 svx: Don't end text edit mode for all views It was visible with "direct insertion" where user doesn't need to draw anything but textbox is inserted in the center of a screen (eg. used in LOK case) Object was inserted into a view and right after that was removed when EndTextEditCurrentView was called Change-Id: I9943d46746aabadf96d76d6e74770b56d648b79d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131263 Tested-by: Jenkins CollaboraOffice Reviewed-by: Mert Tumer Reviewed-on: https://gerrit.libreoffice.org/c/core/+/131537 Tested-by: Jenkins Reviewed-by: Szymon Kłos --- sc/qa/unit/tiledrendering/tiledrendering.cxx | 31 +++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'sc/qa') diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index 5b84eef452b9..04c22438f74b 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -121,6 +121,7 @@ public: void testEditCursorBounds(); void testTextSelectionBounds(); void testSheetViewDataCrash(); + void testTextBoxInsert(); CPPUNIT_TEST_SUITE(ScTiledRenderingTest); CPPUNIT_TEST(testRowColumnHeaders); @@ -175,6 +176,7 @@ public: CPPUNIT_TEST(testEditCursorBounds); CPPUNIT_TEST(testTextSelectionBounds); CPPUNIT_TEST(testSheetViewDataCrash); + CPPUNIT_TEST(testTextBoxInsert); CPPUNIT_TEST_SUITE_END(); private: @@ -456,7 +458,12 @@ struct EditCursorMessage final { std::stringstream aStream(pMessage); boost::property_tree::ptree aTree; boost::property_tree::read_json(aStream, aTree); - std::string aVal = aTree.get_child("refpoint").get_value(); + std::string aVal; + boost::property_tree::ptree::const_assoc_iterator it = aTree.find("refpoint"); + if (it != aTree.not_found()) + aVal = aTree.get_child("refpoint").get_value(); + else + return; // happens in testTextBoxInsert test uno::Sequence aSeq = comphelper::string::convertCommaSeparated(OUString::createFromAscii(aVal.c_str())); CPPUNIT_ASSERT_EQUAL(sal_Int32(2), aSeq.getLength()); @@ -2783,6 +2790,28 @@ void ScTiledRenderingTest::testSheetViewDataCrash() Scheduler::ProcessEventsToIdle(); } +void ScTiledRenderingTest::testTextBoxInsert() +{ + comphelper::LibreOfficeKit::setActive(); + + createDoc("empty.ods"); + ViewCallback aView1; + + // insert textbox + uno::Sequence aArgs( + comphelper::InitPropertySequence({ + { "CreateDirectly", uno::Any(true) } + })); + comphelper::dispatchCommand(".uno:DrawText", aArgs); + Scheduler::ProcessEventsToIdle(); + + // check if we have textbox selected + CPPUNIT_ASSERT(!aView1.m_ShapeSelection.isEmpty()); + CPPUNIT_ASSERT(aView1.m_ShapeSelection != "EMPTY"); + + Scheduler::ProcessEventsToIdle(); +} + } CPPUNIT_TEST_SUITE_REGISTRATION(ScTiledRenderingTest); -- cgit