diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx index baf6a1be1da1..ef7d1725098c 100644 --- a/desktop/source/app/sofficemain.cxx +++ b/desktop/source/app/sofficemain.cxx @@ -26,10 +26,19 @@ #include "cmdlineargs.hxx" #include "cmdlinehelp.hxx" +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include + #ifdef ANDROID # include @@ -114,6 +123,29 @@ touch_lo_runMain() } +extern "C" void PtylTestEncryptionAndExport(const char *pathname) +{ + OUString sUri(pathname, strlen(pathname), RTL_TEXTENCODING_UTF8); + sUri = "file://" + sUri; + + css::uno::Reference loader(css::frame::Desktop::create(cppu::defaultBootstrap_InitialComponentContext()), css::uno::UNO_QUERY); + css::uno::Reference component; + component.set(loader->loadComponentFromURL(sUri, "_default", 0, {})); + + utl::MediaDescriptor media; + media[utl::MediaDescriptor::PROP_FILTERNAME()] <<= OUString("MS Word 2007 XML"); + css::uno::Sequence encryptionData = comphelper::OStorageHelper::CreatePackageEncryptionData("myPassword"); + media[utl::MediaDescriptor::PROP_ENCRYPTIONDATA()] <<= encryptionData; + + css::uno::Reference model(component, css::uno::UNO_QUERY); + css::uno::Reference storable2(model, css::uno::UNO_QUERY); + OUString saveAsUri(sUri + ".new.docx"); + SAL_INFO("desktop.app", "Trying to store as " << saveAsUri); + OUString testPathName; + osl::File::getSystemPathFromFileURL(saveAsUri+".txt", testPathName); + storable2->storeToURL(saveAsUri, media.getAsConstPropertyValueList()); +} + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m index 10e5d70204d0..8bad26bd13ea 100644 --- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m +++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m @@ -55,11 +55,15 @@ return YES; } +const char *ptyl_test_encryption_pathname; + - (void)startDisplaying:(NSString*)documentPath; { ViewController *vc = [[ViewController alloc] init]; self.window.rootViewController = vc; + ptyl_test_encryption_pathname = [documentPath UTF8String]; + [[[NSThread alloc] initWithTarget:self selector:@selector(threadMainMethod:) object:documentPath] start]; vc.view = [[View alloc] initWithFrame:[self.window frame]]; } diff --git a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m index aafbd430682e..1b8b8c20e481 100644 --- a/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m +++ b/ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m @@ -132,12 +132,22 @@ static bool tileMatches(const char *spec, CGRect bb) y == (int) (bb.origin.y / bb.size.height)); } +extern void PtylTestEncryptionAndExport(const char *pathname); +extern const char *ptyl_test_encryption_pathname; + - (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx { // Even if I set the CATL's tileSize to 512x512 above, this is // called initially with a clip bbox of 128x128. Odd, I would have // expected it to be called with a bbox of 256x256. + static bool once = false; + if (!once) { + once = true; + if (getenv("PTYL_TEST_ENCRYPTION_AND_EXPORT")) + PtylTestEncryptionAndExport(ptyl_test_encryption_pathname); + } + CGRect bb = CGContextGetClipBoundingBox(ctx); CGContextSaveGState(ctx);