summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2018-02-26 07:46:09 -0500
committerAndras Timar <andras.timar@collabora.com>2018-03-26 07:46:14 +0200
commitcf256ad5858bea8834cb5ce49e4f76bb0b14d7dd (patch)
tree914bd8f85cdd280d12067bbe38dcf11dace217a3 /sc
parent3558a6b712c5d53b3a51c8bb711e1d20be61d2a2 (diff)
oox: unit-tests for custom package preservation
Change-Id: I69d0d7d6bdc8804d0e56be19cd86a699200fc85f Reviewed-on: https://gerrit.libreoffice.org/50855 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Jan Holesovsky <kendy@collabora.com> (cherry picked from commit 4de1c0223ceb76556ff1c20000b4ea95bfc1d2a0)
Diffstat (limited to 'sc')
-rw-r--r--sc/qa/unit/data/xlsx/customxml.xlsxbin0 -> 13282 bytes
-rw-r--r--sc/qa/unit/helper/xpath.cxx7
-rw-r--r--sc/qa/unit/helper/xpath.hxx6
-rw-r--r--sc/qa/unit/subsequent_export-test.cxx17
4 files changed, 29 insertions, 1 deletions
diff --git a/sc/qa/unit/data/xlsx/customxml.xlsx b/sc/qa/unit/data/xlsx/customxml.xlsx
new file mode 100644
index 000000000000..53619ae4af30
--- /dev/null
+++ b/sc/qa/unit/data/xlsx/customxml.xlsx
Binary files differ
diff --git a/sc/qa/unit/helper/xpath.cxx b/sc/qa/unit/helper/xpath.cxx
index 2d047b60bf61..562facc84f1e 100644
--- a/sc/qa/unit/helper/xpath.cxx
+++ b/sc/qa/unit/helper/xpath.cxx
@@ -25,14 +25,19 @@ xmlDocPtr XPathHelper::parseExport(ScDocShell& rShell, uno::Reference<lang::XMul
return parseExport(pTempFile, xSFactory, rFile);
}
-xmlDocPtr XPathHelper::parseExport(std::shared_ptr<utl::TempFile> const & pTempFile, uno::Reference<lang::XMultiServiceFactory> const & xSFactory, const OUString& rFile)
+std::shared_ptr<SvStream> XPathHelper::parseExportStream(std::shared_ptr<utl::TempFile> const & pTempFile, uno::Reference<lang::XMultiServiceFactory> const & xSFactory, const OUString& rFile)
{
// Read the XML stream we're interested in.
uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(xSFactory), pTempFile->GetURL());
uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(rFile), uno::UNO_QUERY);
CPPUNIT_ASSERT(xInputStream.is());
std::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
+ return pStream;
+}
+xmlDocPtr XPathHelper::parseExport(std::shared_ptr<utl::TempFile> const & pTempFile, uno::Reference<lang::XMultiServiceFactory> const & xSFactory, const OUString& rFile)
+{
+ std::shared_ptr<SvStream> pStream = parseExportStream(pTempFile, xSFactory, rFile);
return XmlTestTools::parseXmlStream(pStream.get());
}
diff --git a/sc/qa/unit/helper/xpath.hxx b/sc/qa/unit/helper/xpath.hxx
index 6f8c8aa3c170..ddffd31a4585 100644
--- a/sc/qa/unit/helper/xpath.hxx
+++ b/sc/qa/unit/helper/xpath.hxx
@@ -48,6 +48,12 @@ namespace XPathHelper
const OUString& rFile, sal_Int32 nFormat);
/**
+ * Tries to parse the specified file in the temp file zip container as a binary file.
+ */
+ SCQAHELPER_DLLPUBLIC std::shared_ptr<SvStream> parseExportStream(std::shared_ptr<utl::TempFile> const & pTempFile,
+ uno::Reference<lang::XMultiServiceFactory> const & xSFactory, const OUString& rFile);
+
+ /**
* Tries to parse the specified file in the temp file zip container as an xml file.
*
* Should be used when the same exported file is used for testing different files in
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 122fad288343..38aa2e10e955 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -162,6 +162,7 @@ public:
void testCeilingFloorXLS();
void testCeilingFloorODS();
+ void testCustomXml();
#if !defined _WIN32
void testRelativePathsODS();
@@ -268,6 +269,7 @@ public:
CPPUNIT_TEST(testCeilingFloorODSToXLSX);
CPPUNIT_TEST(testCeilingFloorXLS);
CPPUNIT_TEST(testCeilingFloorODS);
+ CPPUNIT_TEST(testCustomXml);
#if !defined(_WIN32)
CPPUNIT_TEST(testRelativePathsODS);
#endif
@@ -3030,6 +3032,21 @@ void ScExportTest::testCeilingFloorODS()
testCeilingFloor(FORMAT_ODS);
}
+void ScExportTest::testCustomXml()
+{
+ // Load document and export it to a temporary file
+ ScDocShellRef xShell = loadDoc("customxml.", FORMAT_XLSX);
+ CPPUNIT_ASSERT_MESSAGE("Failed to load the document.", xShell.is());
+
+ std::shared_ptr<utl::TempFile> pXPathFile = ScBootstrapFixture::exportTo(&(*xShell), FORMAT_XLSX);
+ xmlDocPtr pXmlDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "customXml/item1.xml");
+ CPPUNIT_ASSERT(pXmlDoc);
+ xmlDocPtr pRelsDoc = XPathHelper::parseExport(pXPathFile, m_xSFactory, "customXml/_rels/item1.xml.rels");
+ CPPUNIT_ASSERT(pRelsDoc);
+
+ std::shared_ptr<SvStream> pStream = XPathHelper::parseExportStream(pXPathFile, m_xSFactory, "ddp/ddpfile.xen");
+ CPPUNIT_ASSERT(pStream);
+}
#if !defined _WIN32
void ScExportTest::testRelativePathsODS()