[Libreoffice-commits] online.git: 2 commits - kit/Kit.cpp loleaflet/src

Pranav Kant pranavk at collabora.co.uk
Sat Oct 28 15:15:46 UTC 2017


 kit/Kit.cpp                                |   13 +++++++++++--
 loleaflet/src/control/Control.LokDialog.js |   27 +++++----------------------
 loleaflet/src/core/Socket.js               |    3 +++
 loleaflet/src/layer/tile/TileLayer.js      |    7 +++----
 4 files changed, 22 insertions(+), 28 deletions(-)

New commits:
commit 4ae3dae8fdba702f3f8c1b89de430749338a8f7a
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sat Oct 28 08:11:38 2017 -0700

    lokdialog: No need for transforming dialog names
    
    Now since we already get correct uno names as dialog id in the LOK
    dialog callbacks.
    
    Change-Id: Ib4a431c3e769c46069be45afea0672c6c8f5390f

diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 8b7b68aa..ba5f949c 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -18,27 +18,9 @@ L.Control.LokDialog = L.Control.extend({
 		return this._dialogs[dialogId];
 	},
 
-	_transformDialogId: function(dialogId) {
-		var ret = dialogId;
-		if (dialogId === 'SpellingDialog')
-			ret = 'SpellingAndGrammarDialog';
-		else if (dialogId === 'FindReplaceDialog')
-			ret = 'SearchDialog';
-		else if (dialogId === 'AcceptRejectChangesDialog')
-			ret = 'AcceptTrackedChanges';
-		else if (dialogId === 'FieldDialog')
-			ret = 'InsertField';
-		else if (dialogId === 'BibliographyEntryDialog')
-			ret = 'InsertAuthoritiesEntry';
-		else if (dialogId === 'IndexEntryDialog')
-			ret = 'InsertIndexesEntry';
-
-		return ret;
-	},
-
 	_onDialogMsg: function(e) {
 		// FIXME: core sends a different id for many dialogs in callbacks
-		e.dialogId = this._transformDialogId(e.dialogId);
+		e.dialogId = e.dialogId.replace('.uno:', '');
 		if (e.action === 'invalidate') {
 			// ignore any invalidate callbacks when we have closed the dialog
 			if (this._isOpen(e.dialogId)) {
@@ -291,7 +273,7 @@ L.Control.LokDialog = L.Control.extend({
 	},
 
 	_onDialogChildMsg: function(e) {
-		e.dialogId = this._transformDialogId(e.dialogId);
+		e.dialogId = e.dialogId.replace('.uno:', '');
 		if (e.action === 'invalidate') {
 			if (this._isOpen(e.dialogId))
 			{
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 46062fc5..65f1c5c3 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1194,16 +1194,14 @@ L.TileLayer = L.GridLayer.extend({
 
 	_onDialogPaintMsg: function(textMsg, img) {
 		var command = this._map._socket.parseServerCmd(textMsg);
-		var dlgWidth = command.width;
-		var dlgHeight = command.height;
 
 		this._map.fire('dialogpaint', {
 			id: command.id,
 			dialog: img,
 			title: command.title,
 			// TODO: add id too
-			width: dlgWidth,
-			height: dlgHeight
+			width: command.width,
+			height: command.height
 		});
 	},
 
commit 6375789611832f9dd566952ab1f63c7dd394a671
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Sat Oct 28 08:11:17 2017 -0700

    lokdialog: Support for dialog title
    
    Change-Id: Ie66c74290eb0583882cb9395b01c00f91df50aa0

diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index 665ab3af..2cf541ed 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -871,10 +871,11 @@ public:
         int nWidth = nCanvasWidth;
         int nHeight = nCanvasHeight;
         Timestamp timestamp;
+        char* pDialogTitle = nullptr;
         if (child)
             _loKitDocument->paintActiveFloatingWindow(tokens[1].c_str(), pixmap.data(), nWidth, nHeight);
         else
-            _loKitDocument->paintDialog(tokens[1].c_str(), pixmap.data(), nWidth, nHeight);
+            _loKitDocument->paintDialog(tokens[1].c_str(), pixmap.data(), &pDialogTitle, nWidth, nHeight);
 
         const double area = nWidth * nHeight;
         const auto elapsed = timestamp.elapsed();
@@ -883,7 +884,15 @@ public:
                 << " and rendered in " << (elapsed/1000.) <<
                 " ms (" << area / elapsed << " MP/s).");
 
-        const std::string response = std::string(child ? "dialogchildpaint:" : "dialogpaint:") + " id=" + tokens[1] + " width=" + std::to_string(nWidth) + " height=" + std::to_string(nHeight) + "\n";
+        std::string encodedDialogTitle;
+        if (pDialogTitle)
+        {
+            std::string aDialogTitle(pDialogTitle);
+            URI::encode(aDialogTitle, "", encodedDialogTitle);
+            free(pDialogTitle);
+        }
+        const std::string response = std::string(child ? "dialogchildpaint:" : "dialogpaint:") + " id=" + tokens[1] +
+            (!encodedDialogTitle.empty() ? " title=" + encodedDialogTitle : "") + " width=" + std::to_string(nWidth) + " height=" + std::to_string(nHeight) + "\n";
         std::vector<char> output;
         output.reserve(response.size() + pixmapDataSize);
         output.resize(response.size());
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 0c0aa179..8b7b68aa 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -166,10 +166,11 @@ L.Control.LokDialog = L.Control.extend({
 		delete this._dialogs[dialogId];
 	},
 
-	_paintDialog: function(dialogId, imgData) {
+	_paintDialog: function(dialogId, title, imgData) {
 		if (!this._isOpen(dialogId))
 			return;
 
+		$('#' + dialogId).dialog('option', 'title', decodeURIComponent(title));
 		var img = new Image();
 		var canvas = document.getElementById(dialogId + '-canvas');
 		var ctx = canvas.getContext('2d');
@@ -207,7 +208,7 @@ L.Control.LokDialog = L.Control.extend({
 			this._launchDialog(dialogId, e.width, e.height);
 		}
 
-		this._paintDialog(dialogId, e.dialog);
+		this._paintDialog(dialogId, e.title, e.dialog);
 	},
 
 	_onDialogChildPaint: function(e) {
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 1481f4af..97faaae9 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -745,6 +745,9 @@ L.Socket = L.Class.extend({
 			else if (tokens[i].substring(0, 6) === 'width=') {
 				command.width = parseInt(tokens[i].substring(6));
 			}
+			else if (tokens[i].substring(0, 6) === 'title=') {
+				command.title = tokens[i].substring(6);
+			}
 			else if (tokens[i].substring(0, 7) === 'height=') {
 				command.height = parseInt(tokens[i].substring(7));
 			}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 7acb28fb..46062fc5 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1200,6 +1200,7 @@ L.TileLayer = L.GridLayer.extend({
 		this._map.fire('dialogpaint', {
 			id: command.id,
 			dialog: img,
+			title: command.title,
 			// TODO: add id too
 			width: dlgWidth,
 			height: dlgHeight


More information about the Libreoffice-commits mailing list