[Libreoffice-commits] core.git: desktop/source ios/experimental
Tor Lillqvist
tml at collabora.com
Wed Aug 13 02:41:27 PDT 2014
desktop/source/app/sofficemain.cxx | 32 ++++++++++
ios/experimental/TiledLibreOffice/TiledLibreOffice/AppDelegate.m | 4 +
ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m | 10 +++
3 files changed, 46 insertions(+)
New commits:
commit 09f5922baf2cb455553d08a96d0576f7f8a45d16
Author: Tor Lillqvist <tml at collabora.com>
Date: Wed Aug 13 12:27:44 2014 +0300
Add code to test encryption and export to .docx on iOS
Conditional on the environment variable
PTYL_TEST_ENCRYPTION_AND_EXPORT, eek. The document is written out
using the name of the input document with .new.docx appended.
I placed the function that handles it, somewhat arbitrarily, in
sofficemain.cxx. The invocation of this function is, also somewhat
arbitrarily, placed in TiledView's drawLayer:inContext: method.
Quite possibly this test functionality occasionally causes solar mutex
deadlocks or whatever, but at least in Xcode, when one has placed some
breakpoints in it, it seems to work. Which is what matters, as this is
code for manual testing, not invoked normally.
Change-Id: I38bb4b406edf47f0f24857b6044e3bf4eaf17c34
diff --git a/desktop/source/app/sofficemain.cxx b/desktop/source/app/sofficemain.cxx
index baf6a1b..ef7d172 100644
--- a/desktop/source/app/sofficemain.cxx
+++ b/desktop/source/app/sofficemain.cxx
@@ -26,10 +26,19 @@
#include "cmdlineargs.hxx"
#include "cmdlinehelp.hxx"
+#include <osl/file.hxx>
#include <rtl/bootstrap.hxx>
#include <tools/extendapplicationenvironment.hxx>
#include <vcl/svmain.hxx>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/frame/Desktop.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/frame/XStorable2.hpp>
+#include <comphelper/storagehelper.hxx>
+#include <cppuhelper/bootstrap.hxx>
+#include <unotools/mediadescriptor.hxx>
+
#ifdef ANDROID
# include <jni.h>
@@ -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<css::frame::XComponentLoader> loader(css::frame::Desktop::create(cppu::defaultBootstrap_InitialComponentContext()), css::uno::UNO_QUERY);
+ css::uno::Reference<css::lang::XComponent> component;
+ component.set(loader->loadComponentFromURL(sUri, "_default", 0, {}));
+
+ utl::MediaDescriptor media;
+ media[utl::MediaDescriptor::PROP_FILTERNAME()] <<= OUString("MS Word 2007 XML");
+ css::uno::Sequence<css::beans::NamedValue> encryptionData = comphelper::OStorageHelper::CreatePackageEncryptionData("myPassword");
+ media[utl::MediaDescriptor::PROP_ENCRYPTIONDATA()] <<= encryptionData;
+
+ css::uno::Reference<css::frame::XModel> model(component, css::uno::UNO_QUERY);
+ css::uno::Reference<css::frame::XStorable2> 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 10e5d70..8bad26b 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 aafbd43..1b8b8c2 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);
More information about the Libreoffice-commits
mailing list