summaryrefslogtreecommitdiff
path: root/sd
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2016-01-11 11:02:01 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2016-01-12 09:01:16 +0000
commit378fdafaafcdb83385fd0f1504b830eb7b16ebcb (patch)
tree4f016a3197dd19c955f15d98286d295dfd8bfa5c /sd
parent434b7dd17befbad3c24df8cf3fedbdc1372670d6 (diff)
sd: enhance the OLE object test to also test the exported XML
Needs adding various helpers to be able to use XPath. (cherry picked from commit 7dbdd410daeb6f51127da511990e98e77c62cd83) sd: with any luck the OLE test should run on WNT now too ... with the new implementation in oox. (cherry picked from commit 92266dd8267481b654efd0dd76f1d145f9dc9e18) Change-Id: Ifa7b1e5434fb253430da2bfcc5d38ea347d437af Reviewed-on: https://gerrit.libreoffice.org/21356 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Diffstat (limited to 'sd')
-rw-r--r--sd/CppunitTest_sd_export_tests.mk5
-rw-r--r--sd/qa/unit/export-tests.cxx107
-rw-r--r--sd/qa/unit/sdmodeltestbase.hxx20
3 files changed, 113 insertions, 19 deletions
diff --git a/sd/CppunitTest_sd_export_tests.mk b/sd/CppunitTest_sd_export_tests.mk
index 3384377752b6..5e5bafd99055 100644
--- a/sd/CppunitTest_sd_export_tests.mk
+++ b/sd/CppunitTest_sd_export_tests.mk
@@ -11,7 +11,10 @@
$(eval $(call gb_CppunitTest_CppunitTest,sd_export_tests))
-$(eval $(call gb_CppunitTest_use_external,sd_export_tests,boost_headers))
+$(eval $(call gb_CppunitTest_use_externals,sd_export_tests,\
+ boost_headers \
+ libxml2 \
+))
$(eval $(call gb_CppunitTest_add_exception_objects,sd_export_tests, \
sd/qa/unit/export-tests \
diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx
index 32175f4d5efe..da9d53f33e0a 100644
--- a/sd/qa/unit/export-tests.cxx
+++ b/sd/qa/unit/export-tests.cxx
@@ -9,6 +9,7 @@
#include <officecfg/Office/Common.hxx>
#include "sdmodeltestbase.hxx"
#include "Outliner.hxx"
+#include <test/xmltesttools.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertysequence.hxx>
#include <svl/stritem.hxx>
@@ -40,6 +41,7 @@
#include <svx/xflclit.hxx>
#include <animations/animationnodehelper.hxx>
#include <unotools/mediadescriptor.hxx>
+#include <unotools/ucbstreamhelper.hxx>
#include <rtl/ustring.hxx>
#include <com/sun/star/drawing/XDrawPage.hpp>
@@ -64,6 +66,7 @@
#include <com/sun/star/frame/XStorable.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <com/sun/star/drawing/FillStyle.hpp>
+#include <com/sun/star/packages/zip/ZipFileAccess.hpp>
#include <com/sun/star/text/XTextField.hpp>
#include <com/sun/star/text/WritingMode2.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
@@ -99,7 +102,7 @@ CPPUNIT_NS_END
using namespace css;
using namespace css::animations;
-class SdExportTest : public SdModelTestBase
+class SdExportTest : public SdModelTestBase, public XmlTestTools
{
public:
void testN821567();
@@ -137,9 +140,7 @@ public:
void testFdo90607();
void testTdf91378();
-#if !defined WNT
void testBnc822341();
-#endif
void testTdf80224();
void testTdf92527();
@@ -178,15 +179,65 @@ public:
CPPUNIT_TEST(testTransparentBackground);
CPPUNIT_TEST(testTdf91378);
-#if !defined WNT
CPPUNIT_TEST(testBnc822341);
-#endif
CPPUNIT_TEST(testTdf80224);
CPPUNIT_TEST(testExportTransitionsPPTX);
CPPUNIT_TEST(testTdf92527);
CPPUNIT_TEST_SUITE_END();
+
+ virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override
+ {
+ struct { char const * pPrefix; char const * pURI; } namespaces[] =
+ {
+ // ODF
+ { "draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" },
+ { "fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" },
+ { "number", "urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" },
+ { "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" },
+ { "style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0" },
+ { "svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" },
+ { "table", "urn:oasis:names:tc:opendocument:xmlns:table:1.0" },
+ { "text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" },
+ { "xlink", "http://www.w3c.org/1999/xlink" },
+ // OOXML
+ { "ContentType", "http://schemas.openxmlformats.org/package/2006/content-types" },
+ { "rels", "http://schemas.openxmlformats.org/package/2006/relationships" },
+ { "mc", "http://schemas.openxmlformats.org/markup-compatibility/2006" },
+ { "v", "urn:schemas-microsoft-com:vml" },
+ { "a", "http://schemas.openxmlformats.org/drawingml/2006/main" },
+ { "c", "http://schemas.openxmlformats.org/drawingml/2006/chart" },
+ { "pic", "http://schemas.openxmlformats.org/drawingml/2006/picture" },
+ { "wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" },
+ { "p", "http://schemas.openxmlformats.org/presentationml/2006/main" },
+ { "w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main" },
+ { "wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" },
+ { "wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" },
+ };
+ for (size_t i = 0; i < SAL_N_ELEMENTS(namespaces); ++i)
+ {
+ xmlXPathRegisterNs(pXmlXPathCtx,
+ reinterpret_cast<xmlChar const *>(namespaces[i].pPrefix),
+ reinterpret_cast<xmlChar const *>(namespaces[i].pURI));
+ }
+ }
+
+ xmlDocPtr parseExport(utl::TempFile & rTempFile, OUString const& rStreamName)
+ {
+ 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));
+ xmlDocPtr const pXmlDoc = parseXmlStream(pStream.get());
+ pXmlDoc->name = reinterpret_cast<char *>(xmlStrdup(
+ reinterpret_cast<xmlChar const *>(OUStringToOString(url, RTL_TEXTENCODING_UTF8).getStr())));
+ return pXmlDoc;
+ }
};
void SdExportTest::testN821567()
@@ -1030,16 +1081,33 @@ void SdExportTest::testTdf91378()
xDocShRef->DoClose();
}
-#if !defined WNT
-
void SdExportTest::testBnc822341()
{
// Check import / export of embedded text document
::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("sd/qa/unit/data/odp/bnc822341.odp"), ODP);
- xDocShRef = saveAndReload( xDocShRef, PPTX );
+ utl::TempFile tempFile1;
+ xDocShRef = saveAndReload( xDocShRef, PPTX, &tempFile1 );
// Export an LO specific ole object (imported from an ODP document)
{
+ xmlDocPtr pXmlDocCT = parseExport(tempFile1, "[Content_Types].xml");
+ assertXPath(pXmlDocCT,
+ "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.wordprocessingml.document']",
+ "PartName",
+ "/ppt/embeddings/oleObject1.docx");
+
+ xmlDocPtr pXmlDocRels = parseExport(tempFile1, "ppt/slides/_rels/slide1.xml.rels");
+ assertXPath(pXmlDocRels,
+ "/rels:Relationships/rels:Relationship[@Target='../embeddings/oleObject1.docx']",
+ "Type",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
+
+ xmlDocPtr pXmlDocContent = parseExport(tempFile1, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDocContent,
+ "/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/p:oleObj",
+ "progId",
+ "Word.Document.12");
+
const SdrPage *pPage = GetPage( 1, xDocShRef );
const SdrObject* pObj = dynamic_cast<SdrObject*>( pPage->GetObj(0) );
@@ -1047,10 +1115,29 @@ void SdExportTest::testBnc822341()
CPPUNIT_ASSERT_EQUAL( static_cast<sal_uInt16>(OBJ_OLE2), pObj->GetObjIdentifier() );
}
- xDocShRef = saveAndReload( xDocShRef, PPTX );
+ utl::TempFile tempFile2;
+ xDocShRef = saveAndReload( xDocShRef, PPTX, &tempFile2 );
// Export an MS specific ole object (imported from a PPTX document)
{
+ xmlDocPtr pXmlDocCT = parseExport(tempFile2, "[Content_Types].xml");
+ assertXPath(pXmlDocCT,
+ "/ContentType:Types/ContentType:Override[@ContentType='application/vnd.openxmlformats-officedocument.wordprocessingml.document']",
+ "PartName",
+ "/ppt/embeddings/oleObject1.docx");
+
+ xmlDocPtr pXmlDocRels = parseExport(tempFile2, "ppt/slides/_rels/slide1.xml.rels");
+ assertXPath(pXmlDocRels,
+ "/rels:Relationships/rels:Relationship[@Target='../embeddings/oleObject1.docx']",
+ "Type",
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships/package");
+
+ xmlDocPtr pXmlDocContent = parseExport(tempFile2, "ppt/slides/slide1.xml");
+ assertXPath(pXmlDocContent,
+ "/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData/p:oleObj",
+ "progId",
+ "Word.Document.12");
+
SdDrawDocument *pDoc = xDocShRef->GetDoc();
CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != nullptr );
const SdrPage *pPage = pDoc->GetPage(1);
@@ -1064,8 +1151,6 @@ void SdExportTest::testBnc822341()
xDocShRef->DoClose();
}
-#endif
-
void SdExportTest::testBulletMarginAndIndentation()
{
::sd::DrawDocShellRef xDocShRef = loadURL( getURLFromSrc("/sd/qa/unit/data/pptx/bulletMarginAndIndent.pptx"), PPTX );
diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx
index a9682bbeb1dc..4c465470c4ef 100644
--- a/sd/qa/unit/sdmodeltestbase.hxx
+++ b/sd/qa/unit/sdmodeltestbase.hxx
@@ -180,21 +180,27 @@ protected:
pShell->DoClose();
}
- sd::DrawDocShellRef saveAndReload(sd::DrawDocShell *pShell, sal_Int32 nExportType)
+ sd::DrawDocShellRef saveAndReload(sd::DrawDocShell *pShell, sal_Int32 nExportType,
+ utl::TempFile * pTempFile = nullptr)
{
FileFormat* pFormat = getFormat(nExportType);
- utl::TempFile aTempFile;
- save(pShell, pFormat, aTempFile);
+ std::unique_ptr<utl::TempFile> pNewTempFile;
+ if (!pTempFile)
+ {
+ pNewTempFile.reset(new utl::TempFile);
+ pTempFile = pNewTempFile.get();
+ }
+ save(pShell, pFormat, *pTempFile);
if(nExportType == ODP)
{
- // BootstrapFixture::validate(aTempFile.GetFileName(), test::ODF);
+ // BootstrapFixture::validate(pTempFile->GetFileName(), test::ODF);
}
else if(nExportType == PPTX)
{
- BootstrapFixture::validate(aTempFile.GetFileName(), test::OOXML);
+ BootstrapFixture::validate(pTempFile->GetFileName(), test::OOXML);
}
- aTempFile.EnableKillingFile();
- return loadURL(aTempFile.GetURL(), nExportType);
+ pTempFile->EnableKillingFile();
+ return loadURL(pTempFile->GetURL(), nExportType);
}
/** Dump shapes in xDocShRef, and compare the dump against content of pShapesDumpFileNameBase<number>.xml.