diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2018-02-26 07:46:09 -0500 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-03-07 14:54:58 +0100 |
commit | a8f92371317d0056212063d473bb518cfbdbf874 (patch) | |
tree | c21b763424ec533e5e7d37b071ed577d312419b8 /sd | |
parent | 54ac8cf00820ae17f25251f16989485f4271cbe7 (diff) |
oox: unit-tests for custom package preservation
Change-Id: I69d0d7d6bdc8804d0e56be19cd86a699200fc85f
Reviewed-on: https://gerrit.libreoffice.org/50895
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/data/pptx/customxml.pptx | bin | 0 -> 44229 bytes | |||
-rw-r--r-- | sd/qa/unit/export-tests-ooxml1.cxx | 23 | ||||
-rw-r--r-- | sd/qa/unit/sdmodeltestbase.hxx | 21 |
3 files changed, 36 insertions, 8 deletions
diff --git a/sd/qa/unit/data/pptx/customxml.pptx b/sd/qa/unit/data/pptx/customxml.pptx Binary files differnew file mode 100644 index 000000000000..ca9e8fe70d8f --- /dev/null +++ b/sd/qa/unit/data/pptx/customxml.pptx diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index 3daf058daa9c..9147c662c634 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -105,6 +105,7 @@ public: void testBulletMarginAndIndentation(); void testParaMarginAndindentation(); void testTdf111884(); + void testCustomXml(); CPPUNIT_TEST_SUITE(SdOOXMLExportTest1); @@ -133,6 +134,7 @@ public: CPPUNIT_TEST(testBulletMarginAndIndentation); CPPUNIT_TEST(testParaMarginAndindentation); CPPUNIT_TEST(testTdf111884); + CPPUNIT_TEST(testCustomXml); CPPUNIT_TEST_SUITE_END(); @@ -806,6 +808,27 @@ void SdOOXMLExportTest1::testTdf111884() xDocShRef->DoClose(); } +void SdOOXMLExportTest1::testCustomXml() +{ + // Load document and export it to a temporary file + ::sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("sd/qa/unit/data/pptx/customxml.pptx"), PPTX); + utl::TempFile tempFile; + xDocShRef = saveAndReload(xDocShRef.get(), PPTX, &tempFile); + xDocShRef->DoClose(); + + xmlDocPtr pXmlDoc = parseExport(tempFile, "customXml/item1.xml"); + CPPUNIT_ASSERT(pXmlDoc); + xmlDocPtr pRelsDoc = parseExport(tempFile, "customXml/_rels/item1.xml.rels"); + CPPUNIT_ASSERT(pRelsDoc); + + // Check there is a relation to itemProps1.xml. + const OUString sXmlPath = "/rels:Relationships/rels:Relationship[@Id='rId1']"; + assertXPath(pRelsDoc, OUStringToOString(sXmlPath, RTL_TEXTENCODING_UTF8), "Target", "itemProps1.xml"); + + std::shared_ptr<SvStream> pStream = parseExportStream(tempFile, "ddp/ddpfile.xen"); + CPPUNIT_ASSERT(pStream); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdOOXMLExportTest1); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 943a5e9e55a8..c7712f838899 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -372,17 +372,22 @@ class SdModelTestBaseXML { public: - xmlDocPtr parseExport(utl::TempFile & rTempFile, OUString const& rStreamName) + std::shared_ptr<SvStream> parseExportStream(utl::TempFile const & rTempFile, const OUString& rStreamName) { + // Read the stream we're interested in. OUString const url(rTempFile.GetURL()); - uno::Reference<packages::zip::XZipFileAccess2> const xZipNames( - packages::zip::ZipFileAccess::createWithURL( - comphelper::getComponentContext(m_xSFactory), url)); - uno::Reference<io::XInputStream> const xInputStream( - xZipNames->getByName(rStreamName), uno::UNO_QUERY); - std::unique_ptr<SvStream> const pStream( - utl::UcbStreamHelper::CreateStream(xInputStream, true)); + uno::Reference<packages::zip::XZipFileAccess2> const xZipNames(packages::zip::ZipFileAccess::createWithURL( + comphelper::getComponentContext(m_xSFactory), url)); + uno::Reference<io::XInputStream> const xInputStream(xZipNames->getByName(rStreamName), uno::UNO_QUERY); + std::shared_ptr<SvStream> const pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); + return pStream; + } + + xmlDocPtr parseExport(utl::TempFile const & rTempFile, OUString const& rStreamName) + { + std::shared_ptr<SvStream> const pStream(parseExportStream(rTempFile, rStreamName)); xmlDocPtr const pXmlDoc = parseXmlStream(pStream.get()); + OUString const url(rTempFile.GetURL()); pXmlDoc->name = reinterpret_cast<char *>(xmlStrdup( reinterpret_cast<xmlChar const *>(OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr()))); return pXmlDoc; |