include/unotest/macros_test.hxx | 9 +++++++++ oox/qa/unit/export.cxx | 8 +------- sd/qa/unit/sdmodeltestbase.hxx | 11 ----------- unotest/Library_unotest.mk | 1 + unotest/source/cpp/macros_test.cxx | 17 +++++++++++++++++ 5 files changed, 28 insertions(+), 18 deletions(-)
New commits: commit 27c1318fba70d3682b0938c41eed216373775e69 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Thu Dec 2 08:45:26 2021 +0100 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Mon Jan 10 08:45:03 2022 +0100 test: move parseExportStream() from SdModelTestBaseXML up to MacrosTest Move parseExportStream() from SdModelTestBaseXML up to MacrosTest, so oox/ test code can use it as well. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126215 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit f36767fde87191258ea21f3faac0be6ad79328e0) Change-Id: I8ba7d6f3b535456ddaa7cd0f0bb5d56fce7a7766 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128173 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/include/unotest/macros_test.hxx b/include/unotest/macros_test.hxx index 14917794d38d..ed879b835a55 100644 --- a/include/unotest/macros_test.hxx +++ b/include/unotest/macros_test.hxx @@ -28,11 +28,16 @@ struct TestMacroInfo }; class BasicDLL; +class SvStream; namespace test { class Directories; } +namespace utl +{ +class TempFile; +} namespace unotest { @@ -76,6 +81,10 @@ public: const OUString& rCommand, const css::uno::Sequence<css::beans::PropertyValue>& rPropertyValues); + /// Opens rStreamName from rTempFile, assuming it's a ZIP storage. + static std::unique_ptr<SvStream> parseExportStream(const utl::TempFile& rTempFile, + const OUString& rStreamName); + void setUpNssGpg(const test::Directories& rDirectories, const OUString& rTestName); void tearDownNssGpg(); diff --git a/oox/qa/unit/export.cxx b/oox/qa/unit/export.cxx index 6e6620ab63a4..5db14c35d03b 100644 --- a/oox/qa/unit/export.cxx +++ b/oox/qa/unit/export.cxx @@ -13,11 +13,9 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XStorable.hpp> -#include <com/sun/star/packages/zip/ZipFileAccess.hpp> #include <unotools/mediadescriptor.hxx> #include <unotools/tempfile.hxx> -#include <unotools/ucbstreamhelper.hxx> using namespace ::com::sun::star; @@ -138,11 +136,7 @@ CPPUNIT_TEST_FIXTURE(Test, testDmlGroupshapePolygon) // Then make sure that the group shape, the group shape's child size and the child shape's size // match: - uno::Reference<packages::zip::XZipFileAccess2> xNameAccess - = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, getTempFile().GetURL()); - uno::Reference<io::XInputStream> xInputStream(xNameAccess->getByName("word/document.xml"), - uno::UNO_QUERY); - std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); + std::unique_ptr<SvStream> pStream = parseExportStream(getTempFile(), "word/document.xml"); xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get()); assertXPath(pXmlDoc, "//wpg:grpSpPr/a:xfrm/a:ext", "cx", "5328360"); // Without the accompanying fix in place, this test would have failed, the <a:chExt> element was diff --git a/sd/qa/unit/sdmodeltestbase.hxx b/sd/qa/unit/sdmodeltestbase.hxx index 08f66de864f1..73b5b70f63e1 100644 --- a/sd/qa/unit/sdmodeltestbase.hxx +++ b/sd/qa/unit/sdmodeltestbase.hxx @@ -443,17 +443,6 @@ class SdModelTestBaseXML { public: - std::unique_ptr<SvStream> parseExportStream(utl::TempFile const & rTempFile, const OUString& rStreamName) - { - // Read the stream we're interested in. - 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> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); - return pStream; - } - xmlDocUniquePtr parseExport(utl::TempFile const & rTempFile, OUString const& rStreamName) { std::unique_ptr<SvStream> const pStream(parseExportStream(rTempFile, rStreamName)); diff --git a/unotest/Library_unotest.mk b/unotest/Library_unotest.mk index ea697699ee82..3acfe2f69ed9 100644 --- a/unotest/Library_unotest.mk +++ b/unotest/Library_unotest.mk @@ -22,6 +22,7 @@ $(eval $(call gb_Library_use_libraries,unotest,\ cppuhelper \ sal \ sb \ + utl \ )) $(eval $(call gb_Library_use_externals,unotest,\ diff --git a/unotest/source/cpp/macros_test.cxx b/unotest/source/cpp/macros_test.cxx index af6ac567edf3..0141af0ec1ab 100644 --- a/unotest/source/cpp/macros_test.cxx +++ b/unotest/source/cpp/macros_test.cxx @@ -14,6 +14,7 @@ #include <com/sun/star/document/MacroExecMode.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/frame/DispatchHelper.hpp> +#include <com/sun/star/packages/zip/ZipFileAccess.hpp> #include <basic/basrdll.hxx> #include <cppunit/TestAssert.h> @@ -23,6 +24,8 @@ #include <osl/file.hxx> #include <osl/process.h> #include <osl/thread.h> +#include <unotools/tempfile.hxx> +#include <unotools/ucbstreamhelper.hxx> using namespace css; @@ -85,6 +88,20 @@ void MacrosTest::dispatchCommand(const uno::Reference<lang::XComponent>& xCompon xDispatchHelper->executeDispatch(xFrame, rCommand, OUString(), 0, rPropertyValues); } +std::unique_ptr<SvStream> MacrosTest::parseExportStream(const utl::TempFile& rTempFile, + const OUString& rStreamName) +{ + const OUString aUrl = rTempFile.GetURL(); + uno::Reference<uno::XComponentContext> xComponentContext + = comphelper::getProcessComponentContext(); + uno::Reference<packages::zip::XZipFileAccess2> const xZipNames( + packages::zip::ZipFileAccess::createWithURL(xComponentContext, aUrl)); + uno::Reference<io::XInputStream> const xInputStream(xZipNames->getByName(rStreamName), + uno::UNO_QUERY); + std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream, true)); + return pStream; +} + void MacrosTest::setUpNssGpg(const test::Directories& rDirectories, const OUString& rTestName) { OUString aSourceDir = rDirectories.getURLFromSrc("/test/signing-keys/");