From adaea81bf63815fb171850ea9f4a2e9c9f2144d1 Mon Sep 17 00:00:00 2001 From: Gülşah Köse Date: Fri, 18 Jun 2021 11:23:41 +0300 Subject: tdf#142716 Update selection after any text is inserted. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we don't update the selection after insertion of new text SvxUnoTextBase::createEnumeration knows old selection and losts last part of the text. Change-Id: I20f6530f34097ff213ff00cff617139887fd287a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117409 Tested-by: Jenkins Reviewed-by: Gülşah Köse (cherry picked from commit e837f50313a703b6b26abb78f224472c1e4734ea) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117557 Reviewed-by: Mike Kaganski --- editeng/source/uno/unotext.cxx | 14 +++++++------- sd/qa/unit/data/pptx/tdf142716.pptx | Bin 0 -> 23281 bytes sd/qa/unit/export-tests.cxx | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 sd/qa/unit/data/pptx/tdf142716.pptx diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx index 6761f8b8b622..81699a1365d3 100644 --- a/editeng/source/uno/unotext.cxx +++ b/editeng/source/uno/unotext.cxx @@ -1732,13 +1732,6 @@ void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< text::XTextRan if( !xRange.is() ) return; - if (GetEditSource()) - { - ESelection aSelection; - ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); - SetSelection( aSelection ); - } - SvxUnoTextRangeBase* pRange = comphelper::getUnoTunnelImplementation( xRange ); if(!pRange) return; @@ -1754,6 +1747,13 @@ void SAL_CALL SvxUnoTextBase::insertString( const uno::Reference< text::XTextRan pRange->setString( aString ); pRange->CollapseToEnd(); + + if (GetEditSource()) + { + ESelection aSelection; + ::GetSelection( aSelection, GetEditSource()->GetTextForwarder() ); + SetSelection( aSelection ); + } } void SAL_CALL SvxUnoTextBase::insertControlCharacter( const uno::Reference< text::XTextRange >& xRange, sal_Int16 nControlCharacter, sal_Bool bAbsorb ) diff --git a/sd/qa/unit/data/pptx/tdf142716.pptx b/sd/qa/unit/data/pptx/tdf142716.pptx new file mode 100644 index 000000000000..4ef29e389449 Binary files /dev/null and b/sd/qa/unit/data/pptx/tdf142716.pptx differ diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index d8a214804643..ce57bd18271d 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -57,6 +57,7 @@ public: void testImageWithSpecialID(); void testTdf62176(); void testTransparentBackground(); + void testTdf142716(); void testEmbeddedPdf(); void testEmbeddedText(); void testTransparenText(); @@ -97,6 +98,7 @@ public: CPPUNIT_TEST(testImageWithSpecialID); CPPUNIT_TEST(testTdf62176); CPPUNIT_TEST(testTransparentBackground); + CPPUNIT_TEST(testTdf142716); CPPUNIT_TEST(testEmbeddedPdf); CPPUNIT_TEST(testEmbeddedText); CPPUNIT_TEST(testTransparenText); @@ -295,6 +297,22 @@ void SdExportTest::testTransparentBackground() xDocShRef->DoClose(); } +void SdExportTest::testTdf142716() +{ + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc(u"/sd/qa/unit/data/pptx/tdf142716.pptx"), PPTX); + xDocShRef = saveAndReload( xDocShRef.get(), PPTX ); + + const SdrPage *pPage = GetPage( 1, xDocShRef ); + const SdrTextObj *pObj = dynamic_cast( pPage->GetObj( 0 ) ); + + OUString sText = pObj->GetOutlinerParaObject()->GetTextObject().GetText(0); + + // Without fix "yyy" part will be lost. + CPPUNIT_ASSERT_EQUAL( OUString( "xxx and yyy" ), sText); + + xDocShRef->DoClose(); +} + void SdExportTest::testMediaEmbedding() { #ifdef _WIN32 -- cgit v1.2.3