[Libreoffice-commits] core.git: 3 commits - chart2/qa sc/qa

Markus Mohrhard markus.mohrhard at googlemail.com
Sat Jul 19 13:23:15 PDT 2014


 chart2/qa/extras/chart2export.cxx     |  131 +++++++---------------------------
 sc/qa/unit/helper/xpath.cxx           |   87 ----------------------
 sc/qa/unit/helper/xpath.hxx           |   32 --------
 sc/qa/unit/subsequent_export-test.cxx |   31 +++++++-
 4 files changed, 61 insertions(+), 220 deletions(-)

New commits:
commit 83da521ee211bbc7426b4f7f0a3acb033d9d7680
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jul 19 22:22:15 2014 +0200

    one more simplification
    
    Change-Id: I9aaf67872dde324f403598a7361cd4eda60b82b0

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 3ce0486..44a3d66 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -161,17 +161,8 @@ xmlDocPtr Chart2ExportTest::parseExport(const OUString& rDir, const OUString& rF
     uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(findChartFile(rDir, xNameAccess)), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xInputStream.is());
     boost::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
-    sal_uInt64 const nSize = pStream->remainingSize();
-    OStringBuffer aDocument(nSize);
-    char ch;
-    for (sal_Size i = 0; i < nSize; ++i)
-    {
-        pStream->ReadChar( ch );
-        aDocument.append(ch);
-    }
 
-    // Parse the XML.
-    return xmlParseMemory((const char*)aDocument.getStr(), aDocument.getLength());
+    return parseXmlStream(pStream.get());
 }
 
 void Chart2ExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
diff --git a/sc/qa/unit/helper/xpath.cxx b/sc/qa/unit/helper/xpath.cxx
index 59955ff..c90b7c0 100644
--- a/sc/qa/unit/helper/xpath.cxx
+++ b/sc/qa/unit/helper/xpath.cxx
@@ -15,6 +15,8 @@
 #include <unotools/tempfile.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 
+#include <test/xmltesttools.hxx>
+
 #include <com/sun/star/packages/zip/ZipFileAccess.hpp>
 
 xmlDocPtr XPathHelper::parseExport(ScDocShell* pShell, uno::Reference<lang::XMultiServiceFactory> xSFactory, const OUString& rFile, sal_Int32 nFormat)
@@ -26,18 +28,8 @@ xmlDocPtr XPathHelper::parseExport(ScDocShell* pShell, uno::Reference<lang::XMul
     uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(rFile), uno::UNO_QUERY);
     CPPUNIT_ASSERT(xInputStream.is());
     boost::shared_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true));
-    sal_uInt64 const nSize = pStream->remainingSize();
-    OStringBuffer aDocument(nSize);
-    char ch;
-    for (sal_Size i = 0; i < nSize; ++i)
-    {
-        pStream->ReadChar( ch );
-        aDocument.append(ch);
-    }
-    CPPUNIT_ASSERT(!aDocument.isEmpty());
-
-    // Parse the XML.
-    return xmlParseMemory((const char*)aDocument.getStr(), aDocument.getLength());
+
+    return XmlTestTools::parseXmlStream(pStream.get());
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit e674cd3f77ed8cf3aebf8008236188316192ddd6
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jul 19 22:12:59 2014 +0200

    use the shared XPath test code in chart2
    
    Change-Id: Ia8481516eb3d53f406824cc2ef8873fe1cba3909

diff --git a/chart2/qa/extras/chart2export.cxx b/chart2/qa/extras/chart2export.cxx
index 899ff10..3ce0486 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -9,6 +9,8 @@
 
 #include "charttest.hxx"
 
+#include <test/xmltesttools.hxx>
+
 #include <com/sun/star/chart/ErrorBarStyle.hpp>
 #include <com/sun/star/chart2/XRegressionCurveContainer.hpp>
 #include <com/sun/star/lang/XServiceName.hpp>
@@ -27,8 +29,11 @@
 using uno::Reference;
 using beans::XPropertySet;
 
-class Chart2ExportTest : public ChartTest
+class Chart2ExportTest : public ChartTest, public XmlTestTools
 {
+protected:
+
+    virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx);
 public:
     Chart2ExportTest() : ChartTest() {}
     void test();
@@ -108,38 +113,6 @@ protected:
      */
     xmlDocPtr parseExport(const OUString& rDir, const OUString& rFilterFormat);
 
-    /**
-     * Helper method to return nodes represented by rXPath.
-     */
-    xmlNodeSetPtr getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath);
-
-    /**
-     * Assert that rXPath exists, and returns exactly one node.
-     * In case rAttribute is provided, the rXPath's attribute's value must
-     * equal to the rExpected value.
-     */
-    void assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute = OString(), const OUString& rExpectedValue = OUString());
-
-    /**
-     * Assert that rXPath exists, and returns exactly nNumberOfNodes nodes.
-     * Useful for checking that we do _not_ export some node (nNumberOfNodes == 0).
-     */
-    void assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNodes);
-
-    /**
-     * Same as the assertXPath(), but don't assert: return the string instead.
-     */
-    OUString getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute);
-    /**
-    Assert that rXPath exists, and its content equals rContent.
-    */
-    void assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent);
-    /**
-    Same as the assertXPathContent(), but don't assert: return the string instead.
-    */
-    OUString getXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath);
-
-private:
 };
 
 void Chart2ExportTest::test()
@@ -201,65 +174,27 @@ xmlDocPtr Chart2ExportTest::parseExport(const OUString& rDir, const OUString& rF
     return xmlParseMemory((const char*)aDocument.getStr(), aDocument.getLength());
 }
 
-xmlNodeSetPtr Chart2ExportTest::getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath)
+void Chart2ExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
 {
-    xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc);
-    xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w"), BAD_CAST("http://schemas.openxmlformats.org/wordprocessingml/2006/main"));
-    xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml"));
-    xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("c"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart"));
-    xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main"));
-    xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("mc"), BAD_CAST("http://schemas.openxmlformats.org/markup-compatibility/2006"));
-    xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wps"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingShape"));
-    xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wpg"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup"));
-    xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("wp"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"));
-    xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx);
-    return pXmlXpathObj->nodesetval;
-}
-
-void Chart2ExportTest::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute, const OUString& rExpectedValue)
-{
-    OUString aValue = getXPath(pXmlDoc, rXPath, rAttribute);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE(
-        OString("Attribute '" + rAttribute + "' of '" + rXPath + "' incorrect value.").getStr(),
-        rExpectedValue, aValue);
-}
-
-void Chart2ExportTest::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNodes)
-{
-    xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE(
-        OString("XPath '" + rXPath + "' number of nodes is incorrect").getStr(),
-        nNumberOfNodes, xmlXPathNodeSetGetLength(pXmlNodes));
-}
-
-void Chart2ExportTest::assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent)
-{
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("XPath contents of child does not match", rContent, getXPathContent(pXmlDoc, rXPath));
-}
-
-OUString Chart2ExportTest::getXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath)
-{
-             xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
-
-             CPPUNIT_ASSERT_MESSAGE(OString("XPath '" + rXPath + "' not found").getStr(),
-                     xmlXPathNodeSetGetLength(pXmlNodes) > 0);
-
-             xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
-
-            _xmlNode *pNode = &(pXmlNode->children[0]);
-             return pNode ? OUString::createFromAscii((const char*)((pXmlNode->children[0]).content)) : OUString();
-}
-
-OUString Chart2ExportTest::getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute)
-{
-    xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE(
-        OString("XPath '" + rXPath + "' number of nodes is incorrect").getStr(),
-        1, xmlXPathNodeSetGetLength(pXmlNodes));
-    if (rAttribute.isEmpty())
-        return OUString();
-    xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
-    return OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr())));
+    struct { xmlChar* pPrefix; xmlChar* pURI; } aNamespaces[] =
+    {
+        { BAD_CAST("w"), BAD_CAST("http://schemas.openxmlformats.org/wordprocessingml/2006/main") },
+        { BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml") },
+        { BAD_CAST("c"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart") },
+        { BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main") },
+        { BAD_CAST("mc"), BAD_CAST("http://schemas.openxmlformats.org/markup-compatibility/2006") },
+        { BAD_CAST("wps"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingShape") },
+        { BAD_CAST("wpg"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup") },
+        { BAD_CAST("wp"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing") },
+        { BAD_CAST("office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0") },
+        { BAD_CAST("table"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:table:1.0") },
+        { BAD_CAST("text"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:text:1.0") },
+        { BAD_CAST("xlink"), BAD_CAST("http://www.w3c.org/1999/xlink") }
+    };
+    for(size_t i = 0; i < SAL_N_ELEMENTS(aNamespaces); ++i)
+    {
+        xmlXPathRegisterNs(pXmlXPathCtx, aNamespaces[i].pPrefix, aNamespaces[i].pURI );
+    }
 }
 
 namespace {
@@ -584,7 +519,8 @@ void Chart2ExportTest::testChartExternalData()
 
     xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML Text");
     CPPUNIT_ASSERT(pXmlDoc);
-    xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, "/c:chartSpace/c:externalData");
+    xmlXPathObjectPtr pXmlPathObj = getXPathNode(pXmlDoc, "/c:chartSpace/c:externalData");
+    xmlNodeSetPtr pXmlNodes = pXmlPathObj->nodesetval;
     CPPUNIT_ASSERT(pXmlNodes);
 }
 
commit e566d0e007c5821eb136b4effdada0edf43ad9f9
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Jul 19 22:02:41 2014 +0200

    there is already a shared XPath test class
    
    Change-Id: I3c94d1f8302aba52164fb27f40832415eb435a85

diff --git a/sc/qa/unit/helper/xpath.cxx b/sc/qa/unit/helper/xpath.cxx
index 875b7d0..59955ff 100644
--- a/sc/qa/unit/helper/xpath.cxx
+++ b/sc/qa/unit/helper/xpath.cxx
@@ -40,77 +40,4 @@ xmlDocPtr XPathHelper::parseExport(ScDocShell* pShell, uno::Reference<lang::XMul
     return xmlParseMemory((const char*)aDocument.getStr(), aDocument.getLength());
 }
 
-xmlNodeSetPtr XPathHelper::getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath)
-{
-    struct { xmlChar* pPrefix; xmlChar* pURI; } aNamespaces[] =
-    {
-        { BAD_CAST("w"), BAD_CAST("http://schemas.openxmlformats.org/wordprocessingml/2006/main") },
-        { BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml") },
-        { BAD_CAST("c"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart") },
-        { BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main") },
-        { BAD_CAST("mc"), BAD_CAST("http://schemas.openxmlformats.org/markup-compatibility/2006") },
-        { BAD_CAST("wps"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingShape") },
-        { BAD_CAST("wpg"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup") },
-        { BAD_CAST("wp"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing") },
-        { BAD_CAST("office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0") },
-        { BAD_CAST("table"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:table:1.0") },
-        { BAD_CAST("text"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:text:1.0") },
-        { BAD_CAST("xlink"), BAD_CAST("http://www.w3c.org/1999/xlink") }
-    };
-    xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc);
-    for(size_t i = 0; i < SAL_N_ELEMENTS(aNamespaces); ++i)
-    {
-        xmlXPathRegisterNs(pXmlXpathCtx, aNamespaces[i].pPrefix, aNamespaces[i].pURI );
-    }
-
-    xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(rXPath.getStr()), pXmlXpathCtx);
-    return pXmlXpathObj->nodesetval;
-}
-
-void XPathHelper::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute, const OUString& rExpectedValue)
-{
-    OUString aValue = getXPath(pXmlDoc, rXPath, rAttribute);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE(
-            OString("Attribute '" + rAttribute + "' of '" + rXPath + "' incorrect value.").getStr(),
-            rExpectedValue, aValue);
-}
-
-void XPathHelper::assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNodes)
-{
-    xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE(
-            OString("XPath '" + rXPath + "' number of nodes is incorrect").getStr(),
-            nNumberOfNodes, xmlXPathNodeSetGetLength(pXmlNodes));
-}
-
-void XPathHelper::assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent)
-{
-    CPPUNIT_ASSERT_EQUAL_MESSAGE("XPath contents of child does not match", rContent, getXPathContent(pXmlDoc, rXPath));
-}
-
-OUString XPathHelper::getXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath)
-{
-    xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
-
-    CPPUNIT_ASSERT_MESSAGE(OString("XPath '" + rXPath + "' not found").getStr(),
-            xmlXPathNodeSetGetLength(pXmlNodes) > 0);
-
-    xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
-
-    _xmlNode *pNode = &(pXmlNode->children[0]);
-    return pNode ? OUString::createFromAscii((const char*)((pXmlNode->children[0]).content)) : OUString();
-}
-
-OUString XPathHelper::getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute)
-{
-    xmlNodeSetPtr pXmlNodes = getXPathNode(pXmlDoc, rXPath);
-    CPPUNIT_ASSERT_EQUAL_MESSAGE(
-            OString("XPath '" + rXPath + "' number of nodes is incorrect").getStr(),
-            1, xmlXPathNodeSetGetLength(pXmlNodes));
-    if (rAttribute.isEmpty())
-        return OUString();
-    xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
-    return OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr())));
-}
-
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/qa/unit/helper/xpath.hxx b/sc/qa/unit/helper/xpath.hxx
index 1a63401..dedd929 100644
--- a/sc/qa/unit/helper/xpath.hxx
+++ b/sc/qa/unit/helper/xpath.hxx
@@ -25,7 +25,6 @@
 #endif
 
 #include "docsh.hxx"
-#include "scdllapi.h"
 
 using namespace com::sun::star;
 
@@ -39,37 +38,6 @@ namespace XPathHelper
      */
     SCQAHELPER_DLLPUBLIC xmlDocPtr parseExport(ScDocShell* pShell, uno::Reference< lang::XMultiServiceFactory> xSFactory,
             const OUString& rFile, sal_Int32 nFormat);
-
-    /**
-     * Helper method to return nodes represented by rXPath.
-     */
-    SCQAHELPER_DLLPUBLIC xmlNodeSetPtr getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath);
-
-    /**
-     * Assert that rXPath exists, and returns exactly one node.
-     * In case rAttribute is provided, the rXPath's attribute's value must
-     * equal to the rExpected value.
-     */
-    SCQAHELPER_DLLPUBLIC void assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute = OString(), const OUString& rExpectedValue = OUString());
-
-    /**
-     * Assert that rXPath exists, and returns exactly nNumberOfNodes nodes.
-     * Useful for checking that we do _not_ export some node (nNumberOfNodes == 0).
-     */
-    SCQAHELPER_DLLPUBLIC void assertXPath(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfNodes);
-
-    /**
-     * Same as the assertXPath(), but don't assert: return the string instead.
-     */
-    SCQAHELPER_DLLPUBLIC OUString getXPath(xmlDocPtr pXmlDoc, const OString& rXPath, const OString& rAttribute);
-    /**
-    Assert that rXPath exists, and its content equals rContent.
-    */
-    SCQAHELPER_DLLPUBLIC void assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent);
-    /**
-    Same as the assertXPathContent(), but don't assert: return the string instead.
-    */
-    SCQAHELPER_DLLPUBLIC OUString getXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath);
 }
 
 #endif
diff --git a/sc/qa/unit/subsequent_export-test.cxx b/sc/qa/unit/subsequent_export-test.cxx
index 9517710..0939ec0 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -50,13 +50,17 @@
 #include <editeng/udlnitem.hxx>
 #include <formula/grammar.hxx>
 
+#include <test/xmltesttools.hxx>
+
 #include <com/sun/star/table/BorderLineStyle.hpp>
 
 using namespace ::com::sun::star;
 using namespace ::com::sun::star::uno;
 
-class ScExportTest : public ScBootstrapFixture
+class ScExportTest : public ScBootstrapFixture, XmlTestTools
 {
+protected:
+    virtual void registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx);
 public:
     ScExportTest();
 
@@ -161,6 +165,29 @@ private:
 
 };
 
+void ScExportTest::registerNamespaces(xmlXPathContextPtr& pXmlXPathCtx)
+{
+    struct { xmlChar* pPrefix; xmlChar* pURI; } aNamespaces[] =
+    {
+        { BAD_CAST("w"), BAD_CAST("http://schemas.openxmlformats.org/wordprocessingml/2006/main") },
+        { BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml") },
+        { BAD_CAST("c"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/chart") },
+        { BAD_CAST("a"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/main") },
+        { BAD_CAST("mc"), BAD_CAST("http://schemas.openxmlformats.org/markup-compatibility/2006") },
+        { BAD_CAST("wps"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingShape") },
+        { BAD_CAST("wpg"), BAD_CAST("http://schemas.microsoft.com/office/word/2010/wordprocessingGroup") },
+        { BAD_CAST("wp"), BAD_CAST("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing") },
+        { BAD_CAST("office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0") },
+        { BAD_CAST("table"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:table:1.0") },
+        { BAD_CAST("text"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:text:1.0") },
+        { BAD_CAST("xlink"), BAD_CAST("http://www.w3c.org/1999/xlink") }
+    };
+    for(size_t i = 0; i < SAL_N_ELEMENTS(aNamespaces); ++i)
+    {
+        xmlXPathRegisterNs(pXmlXPathCtx, aNamespaces[i].pPrefix, aNamespaces[i].pURI );
+    }
+}
+
 #if !defined MACOSX && !defined DRAGONFLY
 ScDocShellRef ScExportTest::saveAndReloadPassword(ScDocShell* pShell, const OUString &rFilter,
     const OUString &rUserData, const OUString& rTypeName, sal_uLong nFormatType)
@@ -1832,7 +1859,7 @@ void ScExportTest::testRelativePaths()
 
     xmlDocPtr pDoc = XPathHelper::parseExport(&(*xDocSh), m_xSFactory, "content.xml", ODS);
     CPPUNIT_ASSERT(pDoc);
-    OUString aURL = XPathHelper::getXPath(pDoc,
+    OUString aURL = getXPath(pDoc,
             "/office:document-content/office:body/office:spreadsheet/table:table/table:table-row[2]/table:table-cell[2]/text:p/text:a", "href");
     // make sure that the URL is relative
     CPPUNIT_ASSERT(aURL.startsWith(".."));


More information about the Libreoffice-commits mailing list