sc/qa/unit/subsequent_export-test.cxx | 8 ++--- sc/qa/unit/subsequent_export-test2.cxx | 48 +++++++++++++++++++-------------- sd/qa/unit/SVGExportTests.cxx | 5 --- sd/qa/unit/export-tests-ooxml1.cxx | 25 ----------------- sd/qa/unit/export-tests-ooxml2.cxx | 32 +--------------------- sd/qa/unit/export-tests.cxx | 26 ----------------- sd/qa/unit/misc-tests.cxx | 19 ------------- test/source/xmltesttools.cxx | 17 +++++++++++ 8 files changed, 53 insertions(+), 127 deletions(-)
New commits: commit 2b7bfe009ac35cb5fda9ca14404fea924acb54fa Author: Xisco Fauli <xiscofa...@libreoffice.org> AuthorDate: Mon Jun 7 20:50:34 2021 +0200 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Mon Jun 7 22:57:57 2021 +0200 sd: use registerOOXMLNamespaces and registerODFNamespaces While at it, fix incorrect r:Relationships with rels:Relationships Change-Id: Ia8e6556b0e7d3839e00936626627471a7a276071 Change-Id: I77f950dabd4d2131256673e517625d31ade9aa76 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116800 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx index bb22dbfefe36..ae2784a832e7 100644 --- a/sc/qa/unit/subsequent_export-test.cxx +++ b/sc/qa/unit/subsequent_export-test.cxx @@ -500,7 +500,7 @@ void ScExportTest::testTdf111876() xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/worksheets/_rels/sheet1.xml.rels", FORMAT_XLSX); CPPUNIT_ASSERT(pDoc); - OUString sTarget = getXPath(pDoc, "/r:Relationships/r:Relationship", "Target"); + OUString sTarget = getXPath(pDoc, "/rels:Relationships/rels:Relationship", "Target"); // Document is saved to the temporary directory, relative path should be different than original one CPPUNIT_ASSERT(sTarget != "../xls/bug-fixes.xls"); @@ -3328,8 +3328,8 @@ void ScExportTest::testCustomXml() CPPUNIT_ASSERT(pRelsDoc); // Check there is a relation to itemProps1.xml. - assertXPath(pRelsDoc, "/r:Relationships/r:Relationship", 1); - assertXPath(pRelsDoc, "/r:Relationships/r:Relationship[@Id='rId1']", "Target", "itemProps1.xml"); + assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship", 1); + assertXPath(pRelsDoc, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target", "itemProps1.xml"); std::unique_ptr<SvStream> pStream = XPathHelper::parseExportStream(pXPathFile, m_xSFactory, "ddp/ddpfile.xen"); CPPUNIT_ASSERT(pStream); @@ -3935,7 +3935,7 @@ void ScExportTest::testHyperlinkXLSX() xmlDocUniquePtr pDoc = XPathHelper::parseExport2(*this, *xDocSh, m_xSFactory, "xl/drawings/_rels/drawing1.xml.rels", FORMAT_XLSX); CPPUNIT_ASSERT(pDoc); - assertXPath(pDoc, "/r:Relationships/r:Relationship", "Target", "#Sheet2!A1"); + assertXPath(pDoc, "/rels:Relationships/rels:Relationship", "Target", "#Sheet2!A1"); xDocSh->DoClose(); } diff --git a/sc/qa/unit/subsequent_export-test2.cxx b/sc/qa/unit/subsequent_export-test2.cxx index a47b9a413996..310d88a60f33 100644 --- a/sc/qa/unit/subsequent_export-test2.cxx +++ b/sc/qa/unit/subsequent_export-test2.cxx @@ -1198,9 +1198,11 @@ void ScExportTest2::testTdf115192XLSX() xmlDocUniquePtr pDoc = XPathHelper::parseExport2( *this, *xDocSh, m_xSFactory, "xl/drawings/_rels/drawing1.xml.rels", FORMAT_XLSX); CPPUNIT_ASSERT(pDoc); - assertXPath(pDoc, "/r:Relationships/r:Relationship[@Id='rId1']", "TargetMode", "External"); - assertXPathNoAttribute(pDoc, "/r:Relationships/r:Relationship[@Id='rId2']", "TargetMode"); - assertXPath(pDoc, "/r:Relationships/r:Relationship[@Id='rId3']", "TargetMode", "External"); + assertXPath(pDoc, "/rels:Relationships/rels:Relationship[@Id='rId1']", "TargetMode", + "External"); + assertXPathNoAttribute(pDoc, "/rels:Relationships/rels:Relationship[@Id='rId2']", "TargetMode"); + assertXPath(pDoc, "/rels:Relationships/rels:Relationship[@Id='rId3']", "TargetMode", + "External"); xDocSh->DoClose(); } @@ -1220,9 +1222,10 @@ void ScExportTest2::testTdf91634XLSX() xmlDocUniquePtr pXmlRels = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/_rels/drawing1.xml.rels"); CPPUNIT_ASSERT(pXmlRels); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId1']", "Target", + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target", "https://www.google.com/"); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId1']", "TargetMode", "External"); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId1']", "TargetMode", + "External"); xDocSh->DoClose(); } @@ -1367,13 +1370,17 @@ void ScExportTest2::testTdf123645XLSX() xmlDocUniquePtr pXmlRels = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/_rels/drawing1.xml.rels"); CPPUNIT_ASSERT(pXmlRels); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId1']", "TargetMode", "External"); - assertXPathNoAttribute(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId3']", "TargetMode"); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId5']", "TargetMode", "External"); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId1']", "Target", + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId1']", "TargetMode", + "External"); + assertXPathNoAttribute(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId3']", + "TargetMode"); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId5']", "TargetMode", + "External"); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target", "file:///C:/TEMP/test.xlsx"); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId3']", "Target", "#Sheet2!A1"); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId5']", "Target", + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId3']", "Target", + "#Sheet2!A1"); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId5']", "Target", "https://bugs.documentfoundation.org/show_bug.cgi?id=123645"); xDocSh->DoClose(); @@ -1394,9 +1401,10 @@ void ScExportTest2::testTdf125173XLSX() xmlDocUniquePtr pXmlRels = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/drawings/_rels/drawing1.xml.rels"); CPPUNIT_ASSERT(pXmlRels); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId1']", "Target", + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId1']", "Target", "http://www.google.com/"); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship[@Id='rId1']", "TargetMode", "External"); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship[@Id='rId1']", "TargetMode", + "External"); xDocSh->DoClose(); } @@ -1416,9 +1424,9 @@ void ScExportTest2::testTdf79972XLSX() xmlDocUniquePtr pXmlRels = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/_rels/sheet1.xml.rels"); CPPUNIT_ASSERT(pXmlRels); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "Target", + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship", "Target", "https://bugs.documentfoundation.org/show_bug.cgi?id=79972"); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "TargetMode", "External"); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship", "TargetMode", "External"); xDocSh->DoClose(); } @@ -1438,9 +1446,9 @@ void ScExportTest2::testTdf126024XLSX() xmlDocUniquePtr pXmlRels = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/_rels/sheet1.xml.rels"); CPPUNIT_ASSERT(pXmlRels); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "Target", + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship", "Target", "https://bugs.documentfoundation.org/"); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "TargetMode", "External"); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship", "TargetMode", "External"); xDocSh->DoClose(); } @@ -1460,9 +1468,9 @@ void ScExportTest2::testTdf126177XLSX() xmlDocUniquePtr pXmlRels = XPathHelper::parseExport(pXPathFile, m_xSFactory, "xl/worksheets/_rels/sheet1.xml.rels"); CPPUNIT_ASSERT(pXmlRels); - OUString aTarget = getXPath(pXmlRels, "/r:Relationships/r:Relationship", "Target"); + OUString aTarget = getXPath(pXmlRels, "/rels:Relationships/rels:Relationship", "Target"); CPPUNIT_ASSERT(aTarget.endsWith("test.xlsx")); - assertXPath(pXmlRels, "/r:Relationships/r:Relationship", "TargetMode", "External"); + assertXPath(pXmlRels, "/rels:Relationships/rels:Relationship", "TargetMode", "External"); xDocSh->DoClose(); } @@ -2120,7 +2128,7 @@ void ScExportTest2::testTdf138824_linkToParentDirectory() CPPUNIT_ASSERT(pDoc); // test also the Linux specific bug tdf#121472 - assertXPath(pDoc, "/r:Relationships/r:Relationship", "Target", + assertXPath(pDoc, "/rels:Relationships/rels:Relationship", "Target", "../tdf138824_externalSource.ods"); xDocSh->DoClose(); diff --git a/sd/qa/unit/SVGExportTests.cxx b/sd/qa/unit/SVGExportTests.cxx index dd9364643f08..966d3d18cfd7 100644 --- a/sd/qa/unit/SVGExportTests.cxx +++ b/sd/qa/unit/SVGExportTests.cxx @@ -99,11 +99,6 @@ class SdSVGFilterTest : public test::BootstrapFixture, public unotest::MacrosTes utl::TempFile maTempFile; protected: - virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) override - { - xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("svg"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")); - } - void load(std::u16string_view pDir, const char* pName) { return loadURL(m_directories.getURLFromSrc(pDir) + OUString::createFromAscii(pName), pName); diff --git a/sd/qa/unit/export-tests-ooxml1.cxx b/sd/qa/unit/export-tests-ooxml1.cxx index d30c204192d8..d5c2d8d41a31 100644 --- a/sd/qa/unit/export-tests-ooxml1.cxx +++ b/sd/qa/unit/export-tests-ooxml1.cxx @@ -179,30 +179,7 @@ public: virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override { - static const struct { char const * pPrefix; char const * pURI; } namespaces[] = - { - // 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" }, - { "m", "http://schemas.openxmlformats.org/officeDocument/2006/math" }, - { "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" }, - { "a14", "http://schemas.microsoft.com/office/drawing/2010/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)); - } + XmlTestTools::registerOOXMLNamespaces(pXmlXPathCtx); } }; diff --git a/sd/qa/unit/export-tests-ooxml2.cxx b/sd/qa/unit/export-tests-ooxml2.cxx index abf469788695..e901b62c70a7 100644 --- a/sd/qa/unit/export-tests-ooxml2.cxx +++ b/sd/qa/unit/export-tests-ooxml2.cxx @@ -345,36 +345,8 @@ public: virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override { - static const struct { char const * pPrefix; char const * pURI; } namespaces[] = - { - // 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" }, - { "m", "http://schemas.openxmlformats.org/officeDocument/2006/math" }, - { "pic", "http://schemas.openxmlformats.org/drawingml/2006/picture" }, - { "wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" }, - { "p", "http://schemas.openxmlformats.org/presentationml/2006/main" }, - { "p14", "http://schemas.microsoft.com/office/powerpoint/2010/main" }, - { "r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships" }, - { "w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main" }, - { "a14", "http://schemas.microsoft.com/office/drawing/2010/main" }, - { "wps", "http://schemas.microsoft.com/office/word/2010/wordprocessingShape" }, - { "wpg", "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" }, - { "dgm", "http://schemas.openxmlformats.org/drawingml/2006/diagram" }, - // ODF - { "office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0" }, - { "draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" }, - }; - 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)); - } + XmlTestTools::registerODFNamespaces(pXmlXPathCtx); + XmlTestTools::registerOOXMLNamespaces(pXmlXPathCtx); } }; diff --git a/sd/qa/unit/export-tests.cxx b/sd/qa/unit/export-tests.cxx index 0e6d89297f03..0529178f43e9 100644 --- a/sd/qa/unit/export-tests.cxx +++ b/sd/qa/unit/export-tests.cxx @@ -137,31 +137,7 @@ public: virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override { - static const struct { char const * pPrefix; char const * pURI; } namespaces[] = - { - // ODF - { "anim", "urn:oasis:names:tc:opendocument:xmlns:animation:1.0" }, - { "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" }, - { "presentation", "urn:oasis:names:tc:opendocument:xmlns:presentation: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" }, - { "loext", "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" }, - { "smil", "urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0" }, - // user-defined - { "foo", "http://example.com/" }, - }; - 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)); - } + XmlTestTools::registerODFNamespaces(pXmlXPathCtx); } }; diff --git a/sd/qa/unit/misc-tests.cxx b/sd/qa/unit/misc-tests.cxx index 1ba7d21a2d18..031aeca1f817 100644 --- a/sd/qa/unit/misc-tests.cxx +++ b/sd/qa/unit/misc-tests.cxx @@ -111,24 +111,7 @@ public: virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx) override { - static const struct { char const * pPrefix; char const * pURI; } namespaces[] = - { - // ODF - { "config", "urn:oasis:names:tc:opendocument:xmlns:config:1.0"}, - { "draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" }, - { "fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" }, - { "loext", "urn:org:documentfoundation:names:experimental:office:xmlns:loext: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" }, - { "text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0" }, - }; - 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)); - } + XmlTestTools::registerODFNamespaces(pXmlXPathCtx); } private: diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index 2305c2d203f4..10a304fac745 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -351,6 +351,15 @@ void XmlTestTools::registerODFNamespaces(xmlXPathContextPtr& pXmlXpathCtx) BAD_CAST("urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("css3t"), BAD_CAST("http://www.w3.org/TR/css3-text/")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("anim"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:animation:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("smil"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:smil-compatible:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("presentation"), + BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:presentation:1.0")); + // user-defined + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("foo"), + BAD_CAST("http://example.com/")); } void XmlTestTools::registerOOXMLNamespaces(xmlXPathContextPtr& pXmlXpathCtx) @@ -408,7 +417,7 @@ void XmlTestTools::registerOOXMLNamespaces(xmlXPathContextPtr& pXmlXpathCtx) xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("x"), BAD_CAST("http://schemas.openxmlformats.org/spreadsheetml/2006/main")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("r"), - BAD_CAST("http://schemas.openxmlformats.org/package/2006/relationships")); + BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/relationships")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xx"), BAD_CAST("urn:schemas-microsoft-com:office:excel")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xdr"), @@ -423,6 +432,12 @@ void XmlTestTools::registerOOXMLNamespaces(xmlXPathContextPtr& pXmlXpathCtx) BAD_CAST("urn:schemas-microsoft-com:office:office")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w10"), BAD_CAST("urn:schemas-microsoft-com:office:word")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("p"), + BAD_CAST("http://schemas.openxmlformats.org/presentationml/2006/main")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("p14"), + BAD_CAST("http://schemas.microsoft.com/office/powerpoint/2010/main")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dgm"), + BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/diagram")); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits