diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-12-11 16:55:55 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-12-15 17:44:35 +0100 |
commit | 1af4dbd827b615a10e4686486fa9034e7adf1289 (patch) | |
tree | f822e7de070866a175083a89f2ad96362c2788cb | |
parent | 2a9f1dd27a5df97013f73e61eecf53b2348d055a (diff) |
sw: extend various OOXML export test to check embedded objects
Change-Id: I272afd26addfde5065939db4a04c2f0f01aa28c8
-rw-r--r-- | sw/qa/extras/inc/swmodeltestbase.hxx | 1 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 24 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport4.cxx | 89 | ||||
-rw-r--r-- | sw/source/filter/ww8/docxexport.cxx | 1 |
4 files changed, 114 insertions, 1 deletions
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index 8a51f82b97df..273bdfce3338 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -693,6 +693,7 @@ protected: xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("lc"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/lockedCanvas")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("extended-properties"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a14"), BAD_CAST("http://schemas.microsoft.com/office/drawing/2010/main")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("c"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("o"), BAD_CAST("urn:schemas-microsoft-com:office:office")); // odt xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index fa2d847ff1da..239cfe870f2d 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -305,6 +305,30 @@ DECLARE_OOXMLEXPORT_TEST(testChartDupe, "chart-dupe.docx") uno::Reference<container::XIndexAccess> xEmbeddedObjects(xTextEmbeddedObjectsSupplier->getEmbeddedObjects(), uno::UNO_QUERY); // This was 2, on second import we got a duplicated chart copy. CPPUNIT_ASSERT_EQUAL(sal_Int32(1), xEmbeddedObjects->getCount()); + + xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml"); + + if (!pXmlDocCT) + return; // initial import + + assertXPath(pXmlDocCT, + "/ContentType:Types/ContentType:Override[@PartName='/word/charts/chart1.xml']", + "ContentType", + "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"); + assertXPath(pXmlDocCT, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Worksheet1.xlsx']", "ContentType", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); + + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/charts/_rels/chart1.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='../embeddings/Microsoft_Excel_Worksheet1.xlsx']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); + // check the content too + xmlDocPtr pXmlDocChart1 = parseExport("word/charts/chart1.xml"); + assertXPath(pXmlDocChart1, + "/c:chartSpace/c:externalData", + "id", + "rId1"); } DECLARE_OOXMLEXPORT_TEST(testPositionAndRotation, "position-and-rotation.docx") diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx index 9857fe640099..041e54b3e85a 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx @@ -390,6 +390,27 @@ DECLARE_OOXMLEXPORT_TEST(testChartInFooter, "chart-in-footer.docx") // Check footer1.xml.rels contains in doc after roundtrip. // Check Id = rId1 in footer1.xml.rels assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship","Id","rId1"); + assertXPath(pXmlDoc, + "/rels:Relationships/rels:Relationship[@Id='rId1']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart"); + + xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml"); + assertXPath(pXmlDocCT, + "/ContentType:Types/ContentType:Override[@PartName='/word/charts/chart1.xml']", + "ContentType", + "application/vnd.openxmlformats-officedocument.drawingml.chart+xml"); + + // check the content too + xmlDocPtr pXmlDocFooter1 = parseExport("word/footer1.xml"); + assertXPath(pXmlDocFooter1, + "/w:ftr/w:p[1]/w:r/w:drawing/wp:inline/a:graphic/a:graphicData", + "uri", + "http://schemas.openxmlformats.org/drawingml/2006/chart"); + assertXPath(pXmlDocFooter1, + "/w:ftr/w:p[1]/w:r/w:drawing/wp:inline/a:graphic/a:graphicData/c:chart", + "id", + "rId1"); uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY); if (xDrawPageSupplier.is()) @@ -516,7 +537,26 @@ DECLARE_OOXMLEXPORT_TEST(testOleObject, "test_ole_object.docx") if (!pXmlDoc) return; - assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata", "o:title", ""); + assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata", "o:title", ""); + assertXPath(pXmlDoc, + "/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject", + "DrawAspect", + "Content"); + // TODO: ProgID="Package" - what is this? Zip with 10k extra header? + + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.bin']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"); + // check the media type too + xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml"); + assertXPath(pXmlDocCT, + "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.bin']", + "ContentType", + "application/vnd.openxmlformats-officedocument.oleObject"); + } DECLARE_OOXMLEXPORT_TEST(testFdo74792, "fdo74792.docx") @@ -678,6 +718,26 @@ DECLARE_OOXMLEXPORT_TEST(testOLEObjectinHeader, "2129393649.docx") return; assertXPath(pXmlDoc,"/rels:Relationships/rels:Relationship[1]","Id","rId1"); + + xmlDocPtr pXmlDocCT = parseExport("[Content_Types].xml"); + + // check the media type too + assertXPath(pXmlDocCT, + "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.bin']", + "ContentType", + "application/vnd.openxmlformats-officedocument.oleObject"); + + // check the content too + xmlDocPtr pXmlDocHeader1 = parseExport("word/header1.xml"); + assertXPath(pXmlDocHeader1, + "/w:hdr/w:tbl/w:tr[1]/w:tc[2]/w:p[1]/w:r/w:object/o:OLEObject", + "ProgID", + "Word.Picture.8"); + xmlDocPtr pXmlDocHeader2 = parseExport("word/header2.xml"); + assertXPath(pXmlDocHeader2, + "/w:hdr/w:tbl/w:tr[1]/w:tc[2]/w:p[1]/w:r/w:object/o:OLEObject", + "ProgID", + "Word.Picture.8"); } DECLARE_OOXMLEXPORT_TEST(test_ClosingBrace, "2120112713.docx") @@ -766,6 +826,19 @@ DECLARE_OOXMLEXPORT_TEST(testContentTypeXLSM, "fdo76098.docx") return; assertXPath(pXmlDoc, "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", "ContentType", "application/vnd.ms-excel.sheet.macroEnabled.12"); + + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/charts/_rels/chart1.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='../embeddings/Microsoft_Excel_Macro-Enabled_Worksheet1.xlsm']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package"); + // check the content too + xmlDocPtr pXmlDocChart1 = parseExport("word/charts/chart1.xml"); + assertXPath(pXmlDocChart1, + "/c:chartSpace/c:externalData", + "id", + "rId1"); } DECLARE_OOXMLEXPORT_TEST(test76108, "test76108.docx") @@ -822,6 +895,20 @@ DECLARE_OOXMLEXPORT_TEST(testEmbeddedExcelChart, "EmbeddedExcelChart.docx") "/ContentType:Types/ContentType:Override[@PartName='/word/embeddings/oleObject1.xls']", "ContentType", "application/vnd.ms-excel"); + + // check the rels too + xmlDocPtr pXmlDocRels = parseExport("word/_rels/document.xml.rels"); + assertXPath(pXmlDocRels, + "/rels:Relationships/rels:Relationship[@Target='embeddings/oleObject1.xls']", + "Type", + "http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject"); + + // check the content too + xmlDocPtr pXmlDocContent = parseExport("word/document.xml"); + assertXPath(pXmlDocContent, + "/w:document/w:body/w:p/w:r/w:object/o:OLEObject", + "ProgID", + "Excel.Chart.8"); } DECLARE_OOXMLEXPORT_TEST(testTdf83227, "tdf83227.docx") diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 50c49f6fb9c5..43a57ab69617 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -1458,6 +1458,7 @@ void DocxExport::WriteEmbeddings() embeddingsList[j].Value >>= embeddingsStream; OUString contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + // FIXME: this .xlsm hack is silly - if anything the mime-type for an existing embedded object shoud be read from [Content_Types].xml if (embeddingPath.endsWith(".xlsm")) contentType = "application/vnd.ms-excel.sheet.macroEnabled.12"; else if (embeddingPath.endsWith(".bin")) |