summaryrefslogtreecommitdiff
path: root/writerfilter/qa
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.com>2020-10-22 17:21:33 +0200
committerMiklos Vajna <vmiklos@collabora.com>2020-10-22 20:04:20 +0200
commit4347d505e7d1c90809dd356334fcdc7936c84f73 (patch)
tree9f1a7059dd10a4a8e7833bd96a7becfbd610a0cd /writerfilter/qa
parent4bcc9000352177464a1e914b128dc3db43407346 (diff)
DOCX import: handle <w:altChunk r:id="..."/>
This refers to a self-contained full DOCX file inside a DOCX file. Change-Id: Ic9451833db30231f08ff2e2493da678edbc9a4c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104654 Reviewed-by: Miklos Vajna <vmiklos@collabora.com> Tested-by: Jenkins
Diffstat (limited to 'writerfilter/qa')
-rw-r--r--writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx21
-rw-r--r--writerfilter/qa/cppunittests/dmapper/data/alt-chunk.docxbin0 -> 21945 bytes
2 files changed, 21 insertions, 0 deletions
diff --git a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
index de63ec4084d9..16b9bfa5023b 100644
--- a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
@@ -125,6 +125,27 @@ CPPUNIT_TEST_FIXTURE(Test, testFrameDirection)
CPPUNIT_ASSERT_EQUAL(text::WritingMode2::TB_RL,
xFrame2->getPropertyValue("WritingMode").get<sal_Int16>());
}
+
+CPPUNIT_TEST_FIXTURE(Test, testAltChunk)
+{
+ OUString aURL = m_directories.getURLFromSrc(DATA_DIRECTORY) + "alt-chunk.docx";
+ getComponent() = loadFromDesktop(aURL);
+ uno::Reference<text::XTextDocument> xTextDocument(getComponent(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(),
+ uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ uno::Reference<text::XTextRange> xPara;
+ xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Outer para 1"), xPara->getString());
+ xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Outer para 2"), xPara->getString());
+
+ // Without the accompanying fix in place, this test would have failed with a
+ // container.NoSuchElementException, as the document had only 2 paragraphs, all the "inner"
+ // content was lost.
+ xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(OUString("Inner para 1"), xPara->getString());
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/qa/cppunittests/dmapper/data/alt-chunk.docx b/writerfilter/qa/cppunittests/dmapper/data/alt-chunk.docx
new file mode 100644
index 000000000000..3348cfd0c04c
--- /dev/null
+++ b/writerfilter/qa/cppunittests/dmapper/data/alt-chunk.docx
Binary files differ