[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-2-1' - wsd/DocumentBroker.cpp wsd/reference.txt wsd/Storage.cpp wsd/Storage.hpp

Jan Holesovsky kendy at collabora.com
Wed Sep 27 12:59:41 UTC 2017


 wsd/DocumentBroker.cpp |    3 +++
 wsd/Storage.cpp        |    1 +
 wsd/Storage.hpp        |    9 ++++++++-
 wsd/reference.txt      |   11 +++++++++++
 4 files changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 5fe34b8e84ad4550f9cc4c80ef436e30a73d5a2a
Author: Jan Holesovsky <kendy at collabora.com>
Date:   Mon Sep 25 19:16:48 2017 +0200

    PutFile ext: X-LOOL-WOPI-IsModifiedByUser header to indicate modifications.
    
    Change-Id: I5d69903211045969d678df695717eae7452e7f04
    Reviewed-on: https://gerrit.libreoffice.org/42852
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 7ee65646..e8cc862d 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -808,6 +808,9 @@ bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool dontTerminat
         // arguments end
         oss << "}";
 
+        assert(_storage);
+        _storage->setUserModified(_isModified);
+
         const auto saveArgs = oss.str();
         LOG_TRC(".uno:Save arguments: " << saveArgs);
         const auto command = "uno .uno:Save " + saveArgs;
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 526d8783..dc2e6ac5 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -684,6 +684,7 @@ StorageBase::SaveResult WopiStorage::saveLocalFileToStorage(const Authorization&
                         Poco::DateTimeFormatter::format(Poco::DateTime(_fileInfo._modifiedTime),
                                                         Poco::DateTimeFormat::ISO8601_FRAC_FORMAT));
         }
+        request.set("X-LOOL-WOPI-IsModifiedByUser", _isUserModified? "true": "false");
 
         request.setContentType("application/octet-stream");
         request.setContentLength(size);
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index badaa306..0d5a6cbb 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -78,7 +78,8 @@ public:
         _jailPath(jailPath),
         _fileInfo("", "lool", Poco::Timestamp::fromEpochTime(0), 0),
         _isLoaded(false),
-        _forceSave(false)
+        _forceSave(false),
+        _isUserModified(false)
     {
         LOG_DBG("Storage ctor: " << uri.toString());
     }
@@ -94,6 +95,9 @@ public:
     /// even if document turned out to be changed in storage
     void forceSave() { _forceSave = true; }
 
+    /// To be able to set the WOPI extension header appropriately.
+    void setUserModified(bool isUserModified) { _isUserModified = isUserModified; }
+
     /// Returns the basic information about the file.
     const FileInfo& getFileInfo() const { return _fileInfo; }
 
@@ -129,6 +133,9 @@ protected:
     bool _isLoaded;
     bool _forceSave;
 
+    /// The document has been modified by the user.
+    bool _isUserModified;
+
     static bool FilesystemEnabled;
     static bool WopiEnabled;
     /// Allowed/denied WOPI hosts, if any and if WOPI is enabled.
diff --git a/wsd/reference.txt b/wsd/reference.txt
index 2206f89a..0df894d6 100644
--- a/wsd/reference.txt
+++ b/wsd/reference.txt
@@ -62,3 +62,14 @@ WatermarkText
 
 Note that it is possible to just hide print,save,export options while still
 being able to access them from WOPI hosts using PostMessage API (see loleaflet/reference.html)
+
+PutFile headers
+---------------
+
+PutFile additionally indicates whether the user has modified the document
+before the save, or if they just pressed the Save button without any
+modification.  The following header:
+
+   X-LOOL-WOPI-IsModifiedByUser
+
+will have the value 'true' or 'false' accordingly.


More information about the Libreoffice-commits mailing list