sw/qa/extras/ooxmlexport/data/tdf155690.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport13.cxx | 47 ++++++++++++++++++++++ writerfilter/source/dmapper/DomainMapper_Impl.cxx | 6 ++ 3 files changed, 53 insertions(+)
New commits: commit 142aa77265361492e74707b08c5bcd366e7205ad Author: Michael Stahl <michael.st...@allotropia.de> AuthorDate: Wed Jun 14 15:35:24 2023 +0200 Commit: Michael Stahl <michael.st...@allotropia.de> CommitDate: Wed Jun 14 16:54:26 2023 +0200 tdf#155690 writerfilter: fix import of bookmark in table... ... at start of section. (regression from commit 2e8aad6d45c53d554ccaf26de998ede708cfc289) Change-Id: I1e0e720758b607b69645b29c46f4092264289f9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153053 Tested-by: Jenkins Reviewed-by: Michael Stahl <michael.st...@allotropia.de> diff --git a/sw/qa/extras/ooxmlexport/data/tdf155690.docx b/sw/qa/extras/ooxmlexport/data/tdf155690.docx new file mode 100644 index 000000000000..1839862688ee Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf155690.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx index f6c1b84fcec9..80243ba64a2d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport13.cxx @@ -58,6 +58,53 @@ DECLARE_OOXMLEXPORT_TEST(testTdf126994_lostPageBreak, "tdf126994_lostPageBreak.d CPPUNIT_ASSERT_EQUAL_MESSAGE( "Number of Pages", 3, getPages() ); } +DECLARE_OOXMLEXPORT_TEST(testTdf155690, "tdf155690.docx") +{ + uno::Reference<text::XBookmarksSupplier> xBookmarksSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XNameAccess> xBookmarks = xBookmarksSupplier->getBookmarks(); + { + uno::Reference<text::XTextContent> xMark(xBookmarks->getByName("row1_1"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xMark.is()); + // the problem was that the start was after the H + CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), xMark->getAnchor()->getString()); + } + { + uno::Reference<text::XTextContent> xMark(xBookmarks->getByName("row1_2"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xMark.is()); + CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), xMark->getAnchor()->getString()); + } + { + uno::Reference<text::XTextContent> xMark(xBookmarks->getByName("row1_3"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xMark.is()); + CPPUNIT_ASSERT_EQUAL(OUString("ello world"), xMark->getAnchor()->getString()); + } + { + uno::Reference<text::XTextContent> xMark(xBookmarks->getByName("row1_4"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xMark.is()); + CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), xMark->getAnchor()->getString()); + } + { + uno::Reference<text::XTextContent> xMark(xBookmarks->getByName("row2_1"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xMark.is()); + CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), xMark->getAnchor()->getString()); + } + { + uno::Reference<text::XTextContent> xMark(xBookmarks->getByName("row2_1"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xMark.is()); + CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), xMark->getAnchor()->getString()); + } + { + uno::Reference<text::XTextContent> xMark(xBookmarks->getByName("row2_3"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xMark.is()); + CPPUNIT_ASSERT_EQUAL(OUString("ello world"), xMark->getAnchor()->getString()); + } + { + uno::Reference<text::XTextContent> xMark(xBookmarks->getByName("row2_4"), uno::UNO_QUERY); + CPPUNIT_ASSERT(xMark.is()); + CPPUNIT_ASSERT_EQUAL(OUString("Hello world"), xMark->getAnchor()->getString()); + } +} + CPPUNIT_TEST_FIXTURE(Test, testTdf121374_sectionHF) { loadAndReload("tdf121374_sectionHF.odt"); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index 41ca8bf8d45e..f75fbf529c96 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -8344,6 +8344,9 @@ void DomainMapper_Impl::StartOrEndBookmark( const OUString& rId ) else { xCursor = xText->createTextCursorByRange( aBookmarkIter->second.m_xTextRange ); + } + if (!aBookmarkIter->second.m_bIsStartOfText) + { xCursor->goRight( 1, false ); } @@ -8485,6 +8488,9 @@ void DomainMapper_Impl::startOrEndPermissionRange(sal_Int32 permissinId) else { xCursor = xText->createTextCursorByRange(aPermIter->second.m_xTextRange); + } + if (!aPermIter->second.m_bIsStartOfText) + { xCursor->goRight(1, false); }