[Libreoffice-commits] online.git: ios/Mobile
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Tue Nov 27 11:56:08 UTC 2018
ios/Mobile/Document.mm | 10 ++++++++--
ios/Mobile/DocumentViewController.mm | 6 ++++++
2 files changed, 14 insertions(+), 2 deletions(-)
New commits:
commit a2e1f383b989319f2873b92358a5da1161555578
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Tue Nov 27 13:18:24 2018 +0200
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Tue Nov 27 13:55:39 2018 +0200
Implement document saving properly to make saving to NextCloud work
Even if the LO core code, as called by the Online code, already has
saved the document back to the file from which it was loaded, in order
for a file provider extension like NextCloud to notice that, it is
essential to call saveToURL:forSaveOperation:completionHandler:. The
contentsForType:error: method can just return a NSFileWrapper for the
same, already saved, file, though.
Change-Id: Ic063c8603ca38930083866d973e500336cad517e
diff --git a/ios/Mobile/Document.mm b/ios/Mobile/Document.mm
index c2614f253..0676fd8ff 100644
--- a/ios/Mobile/Document.mm
+++ b/ios/Mobile/Document.mm
@@ -37,8 +37,14 @@
@implementation Document
- (id)contentsForType:(NSString*)typeName error:(NSError **)errorPtr {
- // Encode your document with an instance of NSData or NSFileWrapper
- return [[NSData alloc] init];
+ // Somehow this doesn't feel right, creating an NSFileWrapper around the file that was given to
+ // us for loadFromContents. I get the vague feeling that the file is perhaps just a temporary
+ // data container created by the system for us to be used while loading the document data, and
+ // not the actual permanent document, especially in the case of things like NextCloud. Or is it?
+ // Is savng back to it (which we have already done by the time we get here, in the LO core code)
+ // correct? This does seem to work, though. Anyway, clearly I need to read more documentation
+ // for UIDocument etc.
+ return [[NSFileWrapper alloc] initWithURL:[self fileURL] options:0 error:errorPtr];
}
- (BOOL)loadFromContents:(id)contents ofType:(NSString *)typeName error:(NSError **)errorPtr {
diff --git a/ios/Mobile/DocumentViewController.mm b/ios/Mobile/DocumentViewController.mm
index 294851684..ff65b9a94 100644
--- a/ios/Mobile/DocumentViewController.mm
+++ b/ios/Mobile/DocumentViewController.mm
@@ -220,6 +220,12 @@
// Close one end of the socket pair, that will wake up the forwarding thread above
fakeSocketClose(closeNotificationPipeForForwardingThread[0]);
+ [self.document saveToURL:[self.document fileURL]
+ forSaveOperation:UIDocumentSaveForOverwriting
+ completionHandler:^(BOOL success) {
+ LOG_TRC("save completion handler gets " << (success?"YES":"NO"));
+ }];
+
[self dismissDocumentViewController];
return;
}
More information about the Libreoffice-commits
mailing list