[Libreoffice-commits] online.git: Branch 'distro/collabora/co-4-2-2' - kit/ChildSession.cpp wsd/DocumentBroker.cpp
Tor Lillqvist (via logerrit)
logerrit at kemper.freedesktop.org
Thu Apr 9 13:21:32 UTC 2020
kit/ChildSession.cpp | 29 +++++++++++++++++++++++++++++
wsd/DocumentBroker.cpp | 15 ---------------
2 files changed, 29 insertions(+), 15 deletions(-)
New commits:
commit 83cf98863473b52ae55cf637693abc3f87ca39f3
Author: Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Apr 8 12:37:46 2020 +0300
Commit: Tor Lillqvist <tml at collabora.com>
CommitDate: Thu Apr 9 15:17:09 2020 +0200
Further re-work of document saving in the iOS app
Now, finally, I think it works as it should, knock on wood. After an
auto-save (or explicit save by tapping the button), the edited
document does show up with its auto-saved contents if you open it from
iCloud Drive or Nextcloud while it is still open in the iOS app.
What I was missing was that the document hadn't actually been saved by
the core (to the temporary copy) until we get the
LOK_CALLBACK_UNO_COMMAND_RESULT for the .uno:Save. We must call the
-[UIDocumentsaveToURL:forSaveOperation:completionHandler:] only upon
receiving that callback.
Change-Id: I10486f3bc587c871ee2644a0c097493f33baf420
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91880
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Tor Lillqvist <tml at collabora.com>
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91975
diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index 54d5350b5..534d6c2fb 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -32,6 +32,10 @@
#include <Poco/Net/AcceptCertificateHandler.h>
#endif
+#ifdef IOS
+#import "DocumentViewController.h"
+#endif
+
#include <common/FileUtil.hpp>
#include <common/JsonUtil.hpp>
#include <common/Authorization.hpp>
@@ -2475,6 +2479,31 @@ void ChildSession::loKitCallback(const int type, const std::string& payload)
break;
case LOK_CALLBACK_UNO_COMMAND_RESULT:
sendTextFrame("unocommandresult: " + payload);
+#ifdef IOS
+ {
+ // After the document has been saved (into the temporary copy that we set up in
+ // -[CODocument loadFromContents:ofType:error:]), save it also using the system API so
+ // that file provider extensions notice.
+
+ Parser parser;
+ Poco::Dynamic::Var var = parser.parse(payload);
+ Object::Ptr object = var.extract<Object::Ptr>();
+
+ auto commandName = object->get("commandName");
+ auto success = object->get("success");
+
+ if (!commandName.isEmpty() && commandName.toString() == ".uno:Save" && !success.isEmpty() && success.toString() == "true")
+ {
+ CODocument *document = [[DocumentViewController singleton] document];
+
+ [document saveToURL:[document fileURL]
+ forSaveOperation:UIDocumentSaveForOverwriting
+ completionHandler:^(BOOL success) {
+ LOG_TRC("ChildSession::loKitCallback() save completion handler gets " << (success?"YES":"NO"));
+ }];
+ }
+ }
+#endif
break;
case LOK_CALLBACK_ERROR:
{
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index d89c199c4..02f6d2a2b 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -39,10 +39,6 @@
#include <common/Unit.hpp>
#include <common/FileUtil.hpp>
-#ifdef IOS
-#import "DocumentViewController.h"
-#endif
-
#include <sys/types.h>
#include <sys/wait.h>
@@ -1276,17 +1272,6 @@ bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool dontTerminat
const auto command = "uno .uno:Save " + saveArgs;
forwardToChild(sessionId, command);
_lastSaveRequestTime = std::chrono::steady_clock::now();
-#ifdef IOS
- // We need to do this here, also for auto-save, so that file provider extensions notice.
-
- CODocument *document = [[DocumentViewController singleton] document];
-
- [document saveToURL:[[[DocumentViewController singleton] document] fileURL]
- forSaveOperation:UIDocumentSaveForOverwriting
- completionHandler:^(BOOL success) {
- LOG_TRC("DocumentBroker::sendUnoSave() save completion handler gets " << (success?"YES":"NO"));
- }];
-#endif
return true;
}
More information about the Libreoffice-commits
mailing list