diff options
author | Caolán McNamara <caolanm@redhat.com> | 2023-04-25 14:45:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2023-04-25 17:03:40 +0200 |
commit | d41b436058def4497240c54afc38b319ce388430 (patch) | |
tree | 6cba42dcca2893d6a1b408fe0b9c5aa5a4a87785 | |
parent | e7c30e6c1ee8fbea7d44ab00e2721ff13dfa4da5 (diff) |
expose recovering zips for testing
Change-Id: I4709a2fb0bbb0fcc4c7d57dad53c899e7ba79cb4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150971
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r-- | package/inc/ZipPackage.hxx | 3 | ||||
-rw-r--r-- | package/source/zippackage/ZipPackage.cxx | 12 | ||||
-rw-r--r-- | vcl/workben/fftester.cxx | 10 |
3 files changed, 25 insertions, 0 deletions
diff --git a/package/inc/ZipPackage.hxx b/package/inc/ZipPackage.hxx index e07a8d9c1c9e..e83958241247 100644 --- a/package/inc/ZipPackage.hxx +++ b/package/inc/ZipPackage.hxx @@ -37,6 +37,7 @@ #include <vector> #include <optional> +class SvStream; class ZipOutputStream; class ZipPackageFolder; class ZipFile; @@ -158,4 +159,6 @@ public: }; #endif +extern "C" SAL_DLLPUBLIC_EXPORT bool TestImportZip(SvStream& rStream); + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/package/source/zippackage/ZipPackage.cxx b/package/source/zippackage/ZipPackage.cxx index e03a17e8016a..eb7346236bb1 100644 --- a/package/source/zippackage/ZipPackage.cxx +++ b/package/source/zippackage/ZipPackage.cxx @@ -42,6 +42,7 @@ #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp> #include <com/sun/star/container/XNameContainer.hpp> #include <comphelper/fileurl.hxx> +#include <comphelper/processfactory.hxx> #include <ucbhelper/content.hxx> #include <cppuhelper/exc_hlp.hxx> #include <com/sun/star/ucb/ContentCreationException.hpp> @@ -61,6 +62,7 @@ #include <o3tl/string_view.hxx> #include <osl/diagnose.h> #include <sal/log.hxx> +#include <unotools/streamwrap.hxx> #include <unotools/tempfile.hxx> #include <com/sun/star/io/XAsyncOutputMonitor.hpp> @@ -1821,4 +1823,14 @@ package_ZipPackage_get_implementation( return cppu::acquire(new ZipPackage(context)); } +extern "C" bool TestImportZip(SvStream& rStream) +{ + // explicitly tests the "RepairPackage" recovery mode + rtl::Reference<ZipPackage> xPackage(new ZipPackage(comphelper::getProcessComponentContext())); + css::uno::Reference<css::io::XInputStream> xStream(new utl::OInputStreamWrapper(rStream)); + css::uno::Sequence<Any> aArgs{ Any(xStream), Any(NamedValue("RepairPackage", Any(true))) }; + xPackage->initialize(aArgs); + return true; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/vcl/workben/fftester.cxx b/vcl/workben/fftester.cxx index 2d624b8e4c43..bc4a692b4f81 100644 --- a/vcl/workben/fftester.cxx +++ b/vcl/workben/fftester.cxx @@ -532,6 +532,16 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) SvFileStream aFileStream(out, StreamMode::READ); ret = static_cast<int>((*pfnImport)(aFileStream)); } + else if (strcmp(argv[2], "zip") == 0) + { + static FFilterCall pfnImport(nullptr); + if (!pfnImport) + { + pfnImport = load(u"libpackage2.so", "TestImportZip"); + } + SvFileStream aFileStream(out, StreamMode::READ); + ret = static_cast<int>((*pfnImport)(aFileStream)); + } #endif } catch (...) |