From a41cf57c1eb4cabe5afc1a45d6fe535dbb935217 Mon Sep 17 00:00:00 2001 From: Balazs Varga Date: Fri, 9 Oct 2020 10:20:49 +0200 Subject: tdf#134987 convert DOCX to ODT: fix lost charts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Embedded charts of DOCX documents were lost or replaced by images during conversion to native ODT format, resulted by bad handling of XEmbedPersist objects in EmbeddedObjectContainer. Note: Add missing loext:external-data to ODF 1.3 schema definition to fix ODF validation error in gerrit. See commit 2054af83fefb955e20de2b40178a11726525057e (fdo#72520 : Added property to store external data path in chart) and commit a49a9dab3168c03a539adc131f2ade03236edb69 (fix one more ODF validation error). Change-Id: I9edff9af3a79370ea447ffc6078da3520d0c6f63 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104104 Tested-by: László Németh Reviewed-by: László Németh --- sw/qa/extras/odfexport/data/tdf134987.docx | Bin 0 -> 39541 bytes sw/qa/extras/odfexport/odfexport.cxx | 53 +++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 sw/qa/extras/odfexport/data/tdf134987.docx (limited to 'sw/qa/extras') diff --git a/sw/qa/extras/odfexport/data/tdf134987.docx b/sw/qa/extras/odfexport/data/tdf134987.docx new file mode 100644 index 000000000000..c828bf442e1c Binary files /dev/null and b/sw/qa/extras/odfexport/data/tdf134987.docx differ diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 264edddea196..08166b3c2ccb 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include @@ -778,6 +779,58 @@ DECLARE_ODFEXPORT_TEST(testFdo58949, "fdo58949.docx") CPPUNIT_ASSERT_EQUAL(3, nMatches); } +DECLARE_ODFEXPORT_TEST(testTdf134987, "tdf134987.docx") +{ + uno::Reference xTEOSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference xAccess(xTEOSupplier->getEmbeddedObjects()); + uno::Sequence aSeq(xAccess->getElementNames()); + CPPUNIT_ASSERT_EQUAL(sal_Int32(3), aSeq.getLength()); + + OUString aMediaType; + // checking first object (formula) + { + uno::Reference xEOSupplier(xAccess->getByName("1"), uno::UNO_QUERY); + uno::Reference xObj(xEOSupplier->getEmbeddedObject()); + CPPUNIT_ASSERT(xObj.is()); + + uno::Reference xSBDoc(xObj, uno::UNO_QUERY); + uno::Reference xStorage(xSBDoc->getDocumentStorage()); + CPPUNIT_ASSERT(xStorage.is()); + + uno::Reference< beans::XPropertySet > xStorProps(xStorage, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xStorProps->getPropertyValue("MediaType") >>= aMediaType); + CPPUNIT_ASSERT(aMediaType.equalsIgnoreAsciiCase(MIMETYPE_OASIS_OPENDOCUMENT_FORMULA_ASCII)); + } + // checking second object (chart) + { + uno::Reference xEOSupplier(xAccess->getByName("2"), uno::UNO_QUERY); + uno::Reference xObj(xEOSupplier->getEmbeddedObject()); + CPPUNIT_ASSERT(xObj.is()); + + uno::Reference xSBDoc(xObj, uno::UNO_QUERY); + uno::Reference xStorage(xSBDoc->getDocumentStorage()); + CPPUNIT_ASSERT(xStorage.is()); + + uno::Reference< beans::XPropertySet > xStorProps(xStorage, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xStorProps->getPropertyValue("MediaType") >>= aMediaType); + CPPUNIT_ASSERT(aMediaType.equalsIgnoreAsciiCase(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII)); + } + // checking third object (chart) + { + uno::Reference xEOSupplier(xAccess->getByName("3"), uno::UNO_QUERY); + uno::Reference xObj(xEOSupplier->getEmbeddedObject()); + CPPUNIT_ASSERT(xObj.is()); + + uno::Reference xSBDoc(xObj, uno::UNO_QUERY); + uno::Reference xStorage(xSBDoc->getDocumentStorage()); + CPPUNIT_ASSERT(xStorage.is()); + + uno::Reference< beans::XPropertySet > xStorProps(xStorage, uno::UNO_QUERY_THROW); + CPPUNIT_ASSERT(xStorProps->getPropertyValue("MediaType") >>= aMediaType); + CPPUNIT_ASSERT(aMediaType.equalsIgnoreAsciiCase(MIMETYPE_OASIS_OPENDOCUMENT_CHART_ASCII)); + } +} + DECLARE_ODFEXPORT_TEST(testStylePageNumber, "ooo321_stylepagenumber.odt") { CPPUNIT_ASSERT_EQUAL(5, getPages()); -- cgit v1.2.3