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 #endif +#ifdef IOS +#import "DocumentViewController.h" +#endif + #include #include #include @@ -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(); + + 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 4287624e9..0c28b94bd 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -39,10 +39,6 @@ #include #include -#ifdef IOS -#import "DocumentViewController.h" -#endif - #include #include @@ -1288,17 +1284,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; }