summaryrefslogtreecommitdiff
path: root/sw/qa/extras/odfexport
diff options
context:
space:
mode:
authorLászló Németh <nemeth@numbertext.org>2021-02-24 15:05:38 +0100
committerLászló Németh <nemeth@numbertext.org>2021-02-25 08:42:13 +0100
commitd325cd0c69b7c0cc4f47105749a98995de81cc9d (patch)
tree3932106b70b3c700d38f2ba0c447e98419f5eda1 /sw/qa/extras/odfexport
parentb5422296c55b3fe7b1f96920263feb9c2f97f51d (diff)
tdf#115815 sw: fix lost annotation ranges of redlines
Annotations of tracked deletions lost their ranges during ODF export, according to the limitation of ODF or its recent implementation. As a workaround, save and restore the start of the annotation ranges using temporary bookmarks (which can be part of text:deletion). Note: maybe it's possible to split redline ranges regarding to the start of the annotation ranges, mixing tracked deletions with normal text or tracked insertions, but this would be a not backward compatible solution, because the ODF import of this file inserts extra (not tracked) spaces around the annotation, losing the original text content. Change-Id: I786993a05ee1683076e213374a92969d1856cf8c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111489 Tested-by: László Németh <nemeth@numbertext.org> Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/qa/extras/odfexport')
-rw-r--r--sw/qa/extras/odfexport/data/tdf115815.odtbin0 -> 9809 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx39
2 files changed, 39 insertions, 0 deletions
diff --git a/sw/qa/extras/odfexport/data/tdf115815.odt b/sw/qa/extras/odfexport/data/tdf115815.odt
new file mode 100644
index 000000000000..7c2aad0da638
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf115815.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 98712ae76fdc..4e86f035fa92 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -767,6 +767,45 @@ DECLARE_ODFEXPORT_TEST(testFdo60769, "fdo60769.odt")
}
}
+DECLARE_ODFEXPORT_TEST(testTdf115815, "tdf115815.odt")
+{
+ CPPUNIT_ASSERT_EQUAL(1, getPages());
+ // Test comment range feature on tracked deletion.
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ uno::Reference<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration();
+ bool bAnnotationStart = false;
+ bool bBeforeAnnotation = true;
+ OUString sTextBeforeAnnotation;
+ while (xRunEnum->hasMoreElements())
+ {
+ uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY);
+ OUString aType = getProperty<OUString>(xPropertySet, "TextPortionType");
+ // there is no AnnotationEnd with preceding AnnotationStart,
+ // i.e. annotation with lost range
+ CPPUNIT_ASSERT(aType != "AnnotationEnd" || !bAnnotationStart);
+
+ bAnnotationStart = (aType == "Annotation");
+
+ // collect paragraph text before the first annotation
+ if (bBeforeAnnotation)
+ {
+ if (bAnnotationStart)
+ bBeforeAnnotation = false;
+ else if (aType == "Text")
+ {
+ uno::Reference<text::XTextRange> xRun(xPropertySet, uno::UNO_QUERY);
+ sTextBeforeAnnotation += xRun->getString();
+ }
+ }
+ }
+
+ // This was "Lorem ipsum" (collapsed annotation range)
+ CPPUNIT_ASSERT_EQUAL(OUString("Lorem "), sTextBeforeAnnotation);
+}
+
DECLARE_ODFEXPORT_TEST(testFdo58949, "fdo58949.docx")
{
/*