From 09f5922baf2cb455553d08a96d0576f7f8a45d16 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Wed, 13 Aug 2014 12:27:44 +0300 Subject: 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 --- .../TiledLibreOffice/TiledLibreOffice/AppDelegate.m | 4 ++++ ios/experimental/TiledLibreOffice/TiledLibreOffice/TiledView.m | 10 ++++++++++ 2 files changed, 14 insertions(+) (limited to 'ios') 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); -- cgit