summaryrefslogtreecommitdiff
path: root/sw/qa
diff options
context:
space:
mode:
authorJacobo Aragunde Pérez <jaragunde@igalia.com>2014-02-24 12:13:45 +0100
committerJacobo Aragunde Pérez <jaragunde@igalia.com>2014-02-24 13:26:58 +0100
commit9fab183d4d8b377b155c39952a534712b245c5a9 (patch)
tree39187a509c4c0be289e3c8dbeb6f90afa5a42df8 /sw/qa
parent1428ec6f4e2bfe0d8654a9ccc713e274e08c6423 (diff)
sw: Unit test for spreadsheets embedded in docx
Change-Id: I0a91ea0ca36d57320c3495a5cedba7924d3a7ea7
Diffstat (limited to 'sw/qa')
-rw-r--r--sw/qa/extras/ooxmlexport/data/embedded-xlsx.docxbin0 -> 33370 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport.cxx31
2 files changed, 31 insertions, 0 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/embedded-xlsx.docx b/sw/qa/extras/ooxmlexport/data/embedded-xlsx.docx
new file mode 100644
index 000000000000..3b9dd2a68492
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/embedded-xlsx.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index c1d81ca39c24..1ee6af8dd9d9 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -3467,6 +3467,37 @@ DECLARE_OOXMLEXPORT_TEST(testAbi11739, "abi11739.docx")
CPPUNIT_ASSERT(getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "unhideWhenUsed") < getXPathPosition(pXmlDoc, "/w:styles/w:style[11]", "qFormat"));
}
+DECLARE_OOXMLEXPORT_TEST(testEmbeddedXlsx, "embedded-xlsx.docx")
+{
+ // check there are two objects and they are FrameShapes
+ uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xDraws(xDrawPageSupplier->getDrawPage(), uno::UNO_QUERY);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(2), xDraws->getCount());
+ CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(1)->getShapeType());
+ CPPUNIT_ASSERT_EQUAL(OUString("FrameShape"), getShape(2)->getShapeType());
+
+ // check the objects are present in the exported document.xml
+ xmlDocPtr pXmlDocument = parseExport("word/document.xml");
+ if (!pXmlDocument)
+ return;
+ assertXPath(pXmlDocument, "/w:document/w:body/w:p/w:r/w:object", 2);
+
+ // finally check the embedded files are present in the zipped document
+ uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(m_xSFactory), m_aTempFile.GetURL());
+ uno::Sequence<OUString> names = xNameAccess->getElementNames();
+ sal_Int32 nSheetFiles = 0;
+ sal_Int32 nImageFiles = 0;
+ for (int i=0; i<names.getLength(); i++)
+ {
+ if(names[i].startsWith("word/embeddings/Microsoft_Excel_Worksheet"))
+ nSheetFiles++;
+ if(names[i].startsWith("word/media/image"))
+ nImageFiles++;
+ }
+ CPPUNIT_ASSERT_EQUAL(2, nSheetFiles);
+ CPPUNIT_ASSERT_EQUAL(2, nImageFiles);
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();