summaryrefslogtreecommitdiff
path: root/chart2/qa/extras
diff options
context:
space:
mode:
authorsushil_shinde <sushil.shinde@synerzip.com>2013-12-27 14:38:53 +0530
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2014-01-16 14:41:05 +0100
commitb1e6269d1c0b312a2990324f0334527d2c04414a (patch)
tree51d9a5d86a0daf09e88138228906beb8e16a14a3 /chart2/qa/extras
parent5b8a16209f1e1d8fc43157463384f6ab407ac514 (diff)
fdo#72520 : Exporting sheet external data for chart for docx files.
- Adding external data path relationship for chart[n].xml for docx files. - Added Unit Test. Change-Id: If48ed21237433ddf6659454dda95d720aabdb300
Diffstat (limited to 'chart2/qa/extras')
-rw-r--r--chart2/qa/extras/chart2export.cxx54
-rw-r--r--chart2/qa/extras/data/docx/testMultipleChart.docxbin0 -> 47534 bytes
-rw-r--r--chart2/qa/extras/data/docx/testMultiplechartembeddings.docxbin0 -> 47534 bytes
3 files changed, 54 insertions, 0 deletions
diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index eee9161d8bbb..6cef73b26831 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -13,6 +13,7 @@
#include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
#include <com/sun/star/lang/XServiceName.hpp>
#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
+#include <com/sun/star/text/XTextDocument.hpp>
#include <unotools/ucbstreamhelper.hxx>
#include <rtl/strbuf.hxx>
@@ -36,6 +37,8 @@ public:
void testBarChart();
void testCrosses();
void testChartDataTable();
+ void testChartExternalData();
+ void testEmbeddingsGrabBag();
CPPUNIT_TEST_SUITE(Chart2ExportTest);
CPPUNIT_TEST(test);
@@ -45,6 +48,8 @@ public:
CPPUNIT_TEST(testBarChart);
CPPUNIT_TEST(testCrosses);
CPPUNIT_TEST(testChartDataTable);
+ CPPUNIT_TEST(testChartExternalData);
+ CPPUNIT_TEST(testEmbeddingsGrabBag);
CPPUNIT_TEST_SUITE_END();
protected:
@@ -446,6 +451,55 @@ void Chart2ExportTest::testChartDataTable()
assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:dTable/c:showOutline", "val", "1");
}
+void Chart2ExportTest::testChartExternalData()
+{
+ load("/chart2/qa/extras/data/docx/", "testMultipleChart.docx");
+
+ xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
+ CPPUNIT_ASSERT(pXmlDoc);
+ xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, "/c:chartSpace/c:externalData");
+ CPPUNIT_ASSERT(pXmlNodes);
+}
+
+void Chart2ExportTest::testEmbeddingsGrabBag()
+{
+ // The problem was that .xlsx files were missing from docx file from embeddings folder
+ // after saving file.
+ // This test case tests whether embeddings files grabbagged properly in correct object.
+
+ load("/chart2/qa/extras/data/docx/", "testMultiplechartembeddings.docx" );
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<beans::XPropertySet> xTextDocumentPropertySet(xTextDocument, uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aGrabBag(0);
+ xTextDocumentPropertySet->getPropertyValue(OUString("InteropGrabBag")) >>= aGrabBag;
+ CPPUNIT_ASSERT(aGrabBag.hasElements()); // Grab Bag not empty
+ bool bEmbeddings = sal_False;
+ const char* testEmbeddedFileNames[3] = {"word/embeddings/Microsoft_Excel_Worksheet3.xlsx",
+ "word/embeddings/Microsoft_Excel_Worksheet2.xlsx",
+ "word/embeddings/Microsoft_Excel_Worksheet1.xlsx"};
+ for(int i = 0; i < aGrabBag.getLength(); ++i)
+ {
+ if (aGrabBag[i].Name == "OOXEmbeddings")
+ {
+ bEmbeddings = sal_True;
+ uno::Sequence<beans::PropertyValue> aEmbeddingsList(0);
+ uno::Reference<io::XInputStream> aEmbeddingXlsxStream;
+ OUString aEmbeddedfileName;
+ CPPUNIT_ASSERT(aGrabBag[i].Value >>= aEmbeddingsList); // PropertyValue of proper type
+ sal_Int32 length = aEmbeddingsList.getLength();
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(3), length);
+ for(int j = 0; j < length; ++j)
+ {
+ aEmbeddingsList[j].Value >>= aEmbeddingXlsxStream;
+ aEmbeddedfileName = aEmbeddingsList[j].Name;
+ CPPUNIT_ASSERT(aEmbeddingXlsxStream.get()); // Reference not empty
+ CPPUNIT_ASSERT_EQUAL(OUString::createFromAscii(testEmbeddedFileNames[j]),aEmbeddedfileName);
+ }
+ }
+ }
+ CPPUNIT_ASSERT(bEmbeddings); // Grab Bag has all the expected elements
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Chart2ExportTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/chart2/qa/extras/data/docx/testMultipleChart.docx b/chart2/qa/extras/data/docx/testMultipleChart.docx
new file mode 100644
index 000000000000..28d8bbcfe143
--- /dev/null
+++ b/chart2/qa/extras/data/docx/testMultipleChart.docx
Binary files differ
diff --git a/chart2/qa/extras/data/docx/testMultiplechartembeddings.docx b/chart2/qa/extras/data/docx/testMultiplechartembeddings.docx
new file mode 100644
index 000000000000..28d8bbcfe143
--- /dev/null
+++ b/chart2/qa/extras/data/docx/testMultiplechartembeddings.docx
Binary files differ