summaryrefslogtreecommitdiff
path: root/sw/qa/python
diff options
context:
space:
mode:
authorSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-03-06 12:39:32 +0100
committerSamuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>2020-03-09 10:33:04 +0100
commit2b7e24334c9b9c69c1ebf03ed66a2143c6aec972 (patch)
treef7a278515983a356ca499c5040c83d0dfe2e8c30 /sw/qa/python
parentcb5fc86005a85af06d8ad0bf1ac7aab7649c0048 (diff)
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@cib.de>
Diffstat (limited to 'sw/qa/python')
-rw-r--r--sw/qa/python/testdocuments/xtextrange.odtbin10716 -> 10528 bytes
-rw-r--r--sw/qa/python/xtextrange.py21
2 files changed, 21 insertions, 0 deletions
diff --git a/sw/qa/python/testdocuments/xtextrange.odt b/sw/qa/python/testdocuments/xtextrange.odt
index 5881ea44a447..70c978349869 100644
--- a/sw/qa/python/testdocuments/xtextrange.odt
+++ b/sw/qa/python/testdocuments/xtextrange.odt
Binary files 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()