diff options
author | Andras Timar <andras.timar@collabora.com> | 2017-02-07 07:56:57 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2017-02-08 11:56:05 +0100 |
commit | 4184364712caa9899af6d986aa37b4b470511a97 (patch) | |
tree | de5b46aa67a686d894d81ca12e41f1dd40ec8f95 /sc | |
parent | 32714aacbaa720ed3bcdd6f04c2f910d4096a0e5 (diff) |
allow to call xpath expression on different files in container
Change-Id: I422ea6a7bf2a9a39772947707b41cfea8f7261bd
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/helper/xpath.cxx | 6 | ||||
-rw-r--r-- | sc/qa/unit/helper/xpath.hxx | 17 |
2 files changed, 22 insertions, 1 deletions
diff --git a/sc/qa/unit/helper/xpath.cxx b/sc/qa/unit/helper/xpath.cxx index 78b48ddb6b5c..fb0de43432c9 100644 --- a/sc/qa/unit/helper/xpath.cxx +++ b/sc/qa/unit/helper/xpath.cxx @@ -12,7 +12,6 @@ #include <cppunit/TestAssert.h> #include "qahelper.hxx" -#include <unotools/tempfile.hxx> #include <unotools/ucbstreamhelper.hxx> #include <test/xmltesttools.hxx> @@ -23,6 +22,11 @@ xmlDocPtr XPathHelper::parseExport(ScDocShell* pShell, uno::Reference<lang::XMul { std::shared_ptr<utl::TempFile> pTempFile = ScBootstrapFixture::exportTo(pShell, nFormat); + return parseExport(pTempFile, xSFactory, rFile); +} + +xmlDocPtr XPathHelper::parseExport(std::shared_ptr<utl::TempFile> const & pTempFile, uno::Reference<lang::XMultiServiceFactory> const & xSFactory, const OUString& rFile) +{ // Read the XML stream we're interested in. uno::Reference<packages::zip::XZipFileAccess2> xNameAccess = packages::zip::ZipFileAccess::createWithURL(comphelper::getComponentContext(xSFactory), pTempFile->GetURL()); uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName(rFile), uno::UNO_QUERY); diff --git a/sc/qa/unit/helper/xpath.hxx b/sc/qa/unit/helper/xpath.hxx index dedd92961762..60858c2c2ccf 100644 --- a/sc/qa/unit/helper/xpath.hxx +++ b/sc/qa/unit/helper/xpath.hxx @@ -12,12 +12,16 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <unotools/tempfile.hxx> + #include <libxml/xpathInternals.h> #include <libxml/parserInternals.h> #include <rtl/string.hxx> #include <rtl/ustring.hxx> +#include <memory> + #if defined(SCQAHELPER_DLLIMPLEMENTATION) #define SCQAHELPER_DLLPUBLIC SAL_DLLPUBLIC_EXPORT #else @@ -35,9 +39,22 @@ namespace XPathHelper * test the resulting file directly, by opening the zip file, parsing an * xml stream, and asserting an XPath expression. This method returns the * xml stream, so that you can do the asserting. + * + * Warning: This method saves the document and does not export it! If you need to + * test several files in the same exported xml file you need to export the file manually + * and call the parseExport method that takes a TempFile */ SCQAHELPER_DLLPUBLIC xmlDocPtr parseExport(ScDocShell* pShell, uno::Reference< lang::XMultiServiceFactory> xSFactory, const OUString& rFile, sal_Int32 nFormat); + + /** + * Tries to parse the specified file in the temp file zip container as an xml file. + * + * Should be used when the same exported file is used for testing different files in + * the same zip file. + */ + SCQAHELPER_DLLPUBLIC xmlDocPtr parseExport(std::shared_ptr<utl::TempFile> const & pTempFile, uno::Reference< lang::XMultiServiceFactory> const & xSFactory, + const OUString& rFile); } #endif |