diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-05-15 16:04:47 +0200 |
---|---|---|
committer | Tomaž Vajngerl <tomaz.vajngerl@collabora.com> | 2014-05-15 19:51:08 +0200 |
commit | 780cedb2cf63f6ffa3290d053172a117384b7383 (patch) | |
tree | 0f4b367572a7ce70c3b3a97b57a91f0622c7de67 /test/source/xmltesttools.cxx | |
parent | 7da0a6e562de26222a8c56ae9a5a51611264c59a (diff) |
test: parseXmlStream & parseHtmlStream added to test tools
Change-Id: Iff8af5e9ffefb4c3cecf387b16473d45e8b4a65a
Diffstat (limited to 'test/source/xmltesttools.cxx')
-rw-r--r-- | test/source/xmltesttools.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index e80674d2238b..1cb231c0849d 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -9,12 +9,29 @@ #include <test/xmltesttools.hxx> +#include <boost/scoped_array.hpp> + XmlTestTools::XmlTestTools() {} XmlTestTools::~XmlTestTools() {} +htmlDocPtr XmlTestTools::parseXml(utl::TempFile& aTempFile) +{ + SvFileStream aFileStream(aTempFile.GetURL(), STREAM_READ); + return parseXmlStream(&aFileStream); +} + +xmlDocPtr XmlTestTools::parseXmlStream(SvStream* pStream) +{ + sal_Size nSize = pStream->remainingSize(); + boost::scoped_array<sal_uInt8> pBuffer(new sal_uInt8[nSize + 1]); + pStream->Read(pBuffer.get(), nSize); + pBuffer[nSize] = 0; + return xmlParseDoc(reinterpret_cast<xmlChar*>(pBuffer.get())); +} + xmlNodeSetPtr XmlTestTools::getXPathNode(xmlDocPtr pXmlDoc, const OString& rXPath) { xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc); |