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 7f9f6fdd6f74d0b9c824a8a0c0384addb5c2ffe6
Author:     Michael Stahl <michael.st...@allotropia.de>
AuthorDate: Wed Jun 14 15:35:24 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Jun 15 08:59:19 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>
    (cherry picked from commit 142aa77265361492e74707b08c5bcd366e7205ad)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153072
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

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 f42b5e7f9a28..a5176b5d32e6 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 6616407836de..7fb017154135 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -8102,6 +8102,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 );
                 }
 
@@ -8243,6 +8246,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);
                 }
 

Reply via email to