[Libreoffice-commits] online.git: loleaflet/src wsd/DocumentBroker.cpp wsd/Storage.cpp wsd/Storage.hpp

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 11 17:44:20 UTC 2020


 loleaflet/src/control/Control.DocumentNameInput.js |    7 +++----
 loleaflet/src/map/handler/Map.WOPI.js              |    4 ++++
 wsd/DocumentBroker.cpp                             |    2 ++
 wsd/Storage.cpp                                    |    1 +
 wsd/Storage.hpp                                    |    4 ++++
 5 files changed, 14 insertions(+), 4 deletions(-)

New commits:
commit d34854f6884940b683d4cff4b8a7496de63cae35
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue Jun 9 17:43:58 2020 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Thu Jun 11 19:44:01 2020 +0200

    Add support for BreadcrumbDocName.
    
    Change-Id: I06c56e92dd3acf9269140ecefb0c8bc731191260
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/95960
    Tested-by: Jenkins
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
    Reviewed-by: Michael Meeks <michael.meeks at collabora.com>

diff --git a/loleaflet/src/control/Control.DocumentNameInput.js b/loleaflet/src/control/Control.DocumentNameInput.js
index 28db57f41..cfc4e5998 100644
--- a/loleaflet/src/control/Control.DocumentNameInput.js
+++ b/loleaflet/src/control/Control.DocumentNameInput.js
@@ -40,7 +40,7 @@ L.Control.DocumentNameInput = L.Control.extend({
 	},
 
 	documentNameCancel: function() {
-		$('#document-name-input').val(this.map['wopi'].BaseFileName);
+		$('#document-name-input').val(this.map['wopi'].BreadcrumbDocName);
 		this.map._onGotFocus();
 	},
 
@@ -97,10 +97,9 @@ L.Control.DocumentNameInput = L.Control.extend({
 	},
 
 	onWopiProps: function(e) {
-		if (e.BaseFileName !== null) {
+		if (e.BaseFileName !== null)
 			// set the document name into the name field
-			$('#document-name-input').val(e.BaseFileName);
-		}
+			$('#document-name-input').val(e.BreadcrumbDocName !== undefined ? e.BreadcrumbDocName : e.BaseFileName);
 
 		if (e.UserCanNotWriteRelative === false) {
 			// Save As allowed
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index da79219e8..3e41b7fae 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -10,6 +10,7 @@ L.Map.WOPI = L.Handler.extend({
 	// wouldn't be possible otherwise.
 	PostMessageOrigin: '*',
 	BaseFileName: '',
+	BreadcrumbDocName: '',
 	DocumentLoadedTime: false,
 	HidePrintOption: false,
 	HideSaveOption: false,
@@ -76,6 +77,9 @@ L.Map.WOPI = L.Handler.extend({
 		}
 
 		this.BaseFileName = wopiInfo['BaseFileName'];
+		this.BreadcrumbDocName = wopiInfo['BreadcrumbDocName'];
+		if (this.BreadcrumbDocName === undefined)
+			this.BreadcrumbDocName = this.BaseFileName;
 		this.HidePrintOption = !!wopiInfo['HidePrintOption'];
 		this.HideSaveOption = !!wopiInfo['HideSaveOption'];
 		this.HideExportOption = !!wopiInfo['HideExportOption'];
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 55e921295..f62241808 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -659,6 +659,8 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
             wopifileinfo->setHideExportOption(true);
 
         wopiInfo->set("BaseFileName", wopiStorage->getFileInfo().getFilename());
+        if (wopifileinfo->getBreadcrumbDocName().size())
+            wopiInfo->set("BreadcrumbDocName", wopifileinfo->getBreadcrumbDocName());
 
         if (!wopifileinfo->getTemplateSaveAs().empty())
             wopiInfo->set("TemplateSaveAs", wopifileinfo->getTemplateSaveAs());
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index 3960544c2..1da4eaf74 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -737,6 +737,7 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo &fileInfo,
     JsonUtil::findJSONValue(object, "SupportsLocks", _supportsLocks);
     JsonUtil::findJSONValue(object, "SupportsRename", _supportsRename);
     JsonUtil::findJSONValue(object, "UserCanRename", _userCanRename);
+    JsonUtil::findJSONValue(object, "BreadcrumbDocName", _breadcrumbDocName);
     bool booleanFlag = false;
     if (JsonUtil::findJSONValue(object, "DisableChangeTrackingRecord", booleanFlag))
         _disableChangeTrackingRecord = (booleanFlag ? WOPIFileInfo::TriState::True : WOPIFileInfo::TriState::False);
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 5adb2da0c..b426d44bd 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -386,6 +386,8 @@ public:
         const std::string& getWatermarkText() const { return _watermarkText; }
         const std::string& getTemplateSaveAs() const { return _templateSaveAs; }
         const std::string& getTemplateSource() const { return _templateSource; }
+        const std::string& getBreadcrumbDocName() const { return _breadcrumbDocName; }
+
         bool getUserCanWrite() const { return _userCanWrite; }
         std::string& getPostMessageOrigin() { return _postMessageOrigin; }
         void setHidePrintOption(bool hidePrintOption) { _hidePrintOption = hidePrintOption; }
@@ -425,6 +427,8 @@ public:
         std::string _templateSaveAs;
         /// In case we want to use this file as a template.
         std::string _templateSource;
+        /// User readable string of document name to show in UI, if present.
+        std::string _breadcrumbDocName;
         /// If user accessing the file has write permission
         bool _userCanWrite;
         /// WOPI Post message property


More information about the Libreoffice-commits mailing list