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 a2644485cee8b0e93751a2ca8911a411b07cd03f
Author:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
AuthorDate: Fri Mar 6 12:39:32 2020 +0100
Commit:     Michael Stahl <michael.st...@cib.de>
CommitDate: Wed Mar 11 16:40:31 2020 +0100

    tdf#131184 Allow comparing text ranges in table with body text
    
    Change-Id: I191d8778d362cd28474eea6d18bfe40044887e30
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90038
    Tested-by: Jenkins
    Reviewed-by: Michael Stahl <michael.st...@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 db748899c582..8bdc6d575e73 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1001,14 +1001,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();
     }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to