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-27 14:37:38 +0100
commit5e07e42556e1399e37ad3ccf02b75f3b1d03551a (patch)
tree3d1d22b7a874b0d81ff097f94228a67a5db4e1bc /writerfilter/qa
parent6764475689d26d846a228cccc1e641cc4238e63e (diff)
DOCX import: handle <w:altChunk r:id="..."/>
This refers to a self-contained full DOCX file inside a DOCX file. (cherry picked from commit 4347d505e7d1c90809dd356334fcdc7936c84f73) Conflicts: writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx writerfilter/source/dmapper/DomainMapper_Impl.cxx writerfilter/source/dmapper/DomainMapper_Impl.hxx Change-Id: Ic9451833db30231f08ff2e2493da678edbc9a4c6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104869 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
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 dff03f974a66..8aa53fcee3ec 100644
--- a/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/qa/cppunittests/dmapper/DomainMapper_Impl.cxx
@@ -110,6 +110,27 @@ CPPUNIT_TEST_FIXTURE(Test, testNumberingRestartStyleParent)
xPara.set(xParaEnum->nextElement(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("2."), xPara->getPropertyValue(aProp).get<OUString>());
}
+
+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