summaryrefslogtreecommitdiff
path: root/xmloff/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2021-08-30 20:12:46 +0200
committerMiklos Vajna <vmiklos@collabora.com>2021-08-31 09:29:40 +0200
commit4f4452f6a74201e862971a79ba5bdcd06f3ba9ce (patch)
tree9bb16643175e864d1a81f38aa44957960504773d /xmloff/qa
parenta36d1308f946d890fcdf7887169f284704e4a5bf (diff)
tdf#126126 ODT import: improve import of cross-table commented text range
Regression from commit d4b473dd9ba77427b28d97847067b8877c2033d9 (office:annotation-end import, 2012-07-20), the problem was that XMLAnnotationImportContext::EndElement() assumed that we can always call gotoRange() to go from the annotation start and end points, but this is not true: an annotation may start inside a table and end outside a table, which is not a valid selection, so gotoRange() fails. Fix the regression part by just creating a text range for the anchor of the comment, so the comment is attached to the end of the range, and this way the rest of the comment & the document can be at least opened. [ It seems bookmarks behave similarly: they don't block the whole import, but don't work cross table boundaries, either. ] Change-Id: I1b5a2e2e7501ce3054379fc79d2045c3439c52e4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121322 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Diffstat (limited to 'xmloff/qa')
-rw-r--r--xmloff/qa/unit/data/comment-table-border.fodt16
-rw-r--r--xmloff/qa/unit/text.cxx8
2 files changed, 24 insertions, 0 deletions
diff --git a/xmloff/qa/unit/data/comment-table-border.fodt b/xmloff/qa/unit/data/comment-table-border.fodt
new file mode 100644
index 000000000000..29f54da9afe3
--- /dev/null
+++ b/xmloff/qa/unit/data/comment-table-border.fodt
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<office:document xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text">
+ <office:body>
+ <office:text>
+ <table:table>
+ <table:table-column table:style-name="Table1.A"/>
+ <table:table-row>
+ <table:table-cell table:style-name="Table1.A1" office:value-type="string">
+ <text:p>A<office:annotation office:name="0"><text:p>x</text:p></office:annotation>b</text:p>
+ </table:table-cell>
+ </table:table-row>
+ </table:table>
+ <text:p>b<office:annotation-end office:name="0"/><text:span>Z</text:span></text:p>
+ </office:text>
+ </office:body>
+</office:document>
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index 22d1d3c15fcf..9a177099b8a3 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -153,6 +153,14 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testBibliographyLocalUrl)
CPPUNIT_ASSERT_EQUAL(OUString("file:///home/me/test.pdf"), aActual);
}
+CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCommentTableBorder)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "comment-table-border.fodt";
+ // Without the accompanying fix in place, this failed to load, as a comment that started in a
+ // table and ended outside a table aborted the whole importer.
+ getComponent() = loadFromDesktop(aURL);
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */