[Libreoffice-commits] core.git: sw/qa sw/source

Samuel Mehrbrodt (via logerrit) logerrit at kemper.freedesktop.org
Mon Mar 9 09:33:43 UTC 2020


 sw/qa/python/testdocuments/xtextrange.odt |binary
 sw/qa/python/xtextrange.py                |   21 +++++++++++++++++++++
 sw/source/core/unocore/unotext.cxx        |   12 ++++++++----
 3 files changed, 29 insertions(+), 4 deletions(-)

New commits:
commit 2b7e24334c9b9c69c1ebf03ed66a2143c6aec972
Author:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
AuthorDate: Fri Mar 6 12:39:32 2020 +0100
Commit:     Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>
CommitDate: Mon Mar 9 10:33:04 2020 +0100

    tdf#131184 Allow comparing text ranges in table with body text
    
    Change-Id: I191d8778d362cd28474eea6d18bfe40044887e30
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90086
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt at cib.de>

diff --git a/sw/qa/python/testdocuments/xtextrange.odt b/sw/qa/python/testdocuments/xtextrange.odt
index 5881ea44a447..70c978349869 100644
Binary files a/sw/qa/python/testdocuments/xtextrange.odt and b/sw/qa/python/testdocuments/xtextrange.odt differ
diff --git a/sw/qa/python/xtextrange.py b/sw/qa/python/xtextrange.py
index 9c00ebad51b3..75e4aed79561 100644
--- a/sw/qa/python/xtextrange.py
+++ b/sw/qa/python/xtextrange.py
@@ -91,6 +91,27 @@ class TestXTextRange(unittest.TestCase):
         xTextRange2 = xTextTable.getCellByName("A1")
         self.assertEqual(xTextRange2.getString(), "beforeC1after")
 
+    def test_textRangesCompare(self):
+        doc = self._uno.getDoc()
+        # Bookmark in body text
+        bookmark1 = doc.getBookmarks().getByIndex(0).getAnchor()
+
+        # Bookmarks in table
+        bookmark2 = doc.getBookmarks().getByIndex(1).getAnchor()
+        bookmark3 = doc.getBookmarks().getByIndex(2).getAnchor()
+
+        res = doc.Text.compareRegionStarts(bookmark1, bookmark2)
+        self.assertEqual(res, 1)
+
+        res = doc.Text.compareRegionStarts(bookmark2, bookmark1)
+        self.assertEqual(res, -1)
+
+        res = doc.Text.compareRegionStarts(bookmark2, bookmark3)
+        self.assertEqual(res, 1)
+
+        res = doc.Text.compareRegionStarts(bookmark1, bookmark3)
+        self.assertEqual(res, 1)
+
 if __name__ == '__main__':
     unittest.main()
 
diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index 68b0576b7ba7..207ff49b94dd 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -996,14 +996,18 @@ bool SwXText::Impl::CheckForOwnMember(
     const SwNode& rSrcNode = rPaM.GetNode();
     const SwStartNode* pTmp = rSrcNode.FindSttNodeByType(eSearchNodeType);
 
-    // skip SectionNodes
-    while(pTmp && pTmp->IsSectionNode())
+    // skip SectionNodes / TableNodes to be able to compare across table/section boundaries
+    while (pTmp
+           && (pTmp->IsSectionNode() || pTmp->IsTableNode()
+               || (m_eType != CursorType::TableText
+                   && pTmp->GetStartNodeType() == SwTableBoxStartNode)))
     {
         pTmp = pTmp->StartOfSectionNode();
     }
 
-    //if the document starts with a section
-    while(pOwnStartNode->IsSectionNode())
+    while (pOwnStartNode->IsSectionNode() || pOwnStartNode->IsTableNode()
+           || (m_eType != CursorType::TableText
+               && pOwnStartNode->GetStartNodeType() == SwTableBoxStartNode))
     {
         pOwnStartNode = pOwnStartNode->StartOfSectionNode();
     }


More information about the Libreoffice-commits mailing list