[Libreoffice-commits] online.git: 2 commits - kit/ChildSession.cpp loleaflet/html loleaflet/src wsd/LOOLWSD.cpp wsd/protocol.txt

Ashod Nakashian (via logerrit) logerrit at kemper.freedesktop.org
Wed Nov 6 02:43:10 UTC 2019


 kit/ChildSession.cpp                          |   10 +++++-----
 loleaflet/html/loleaflet.html.m4              |    1 +
 loleaflet/src/control/Control.Menubar.js      |   11 ++++++++++-
 loleaflet/src/control/Control.Toolbar.js      |   16 ++++++++++++++++
 loleaflet/src/control/Toolbar.js              |    4 ++++
 loleaflet/src/map/handler/Map.FileInserter.js |   15 +++++++++++++++
 loleaflet/src/unocommands.js                  |    7 +++++++
 wsd/LOOLWSD.cpp                               |    9 ++++++---
 wsd/protocol.txt                              |    4 ++++
 9 files changed, 68 insertions(+), 9 deletions(-)

New commits:
commit 887ecdb8d3e8301b67e249c88d8aab734c76fed1
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Wed Sep 12 20:07:10 2018 -0400
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Wed Nov 6 03:43:02 2019 +0100

    wsd: leaflet: Insert background
    
    This adds support for .uno:SelectBackground
    which inserts slide background image.
    
    (cherry picked from commit 30a77e7e490e4e83bb6423f41388ee9adbccfae3)
    
    Change-Id: I587b31f67d518aba348ae7e8d058ada23a61e858
    Reviewed-on: https://gerrit.libreoffice.org/67500
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp
index f67e3a1c1..c2fc39a77 100644
--- a/kit/ChildSession.cpp
+++ b/kit/ChildSession.cpp
@@ -1156,12 +1156,12 @@ bool ChildSession::insertFile(const char* /*buffer*/, int /*length*/, const std:
     }
 #endif
 
-    if (type == "graphic" || type == "graphicurl")
+    if (type == "graphic" || type == "graphicurl" || type == "selectbackground")
     {
         std::string url;
 
 #if !MOBILEAPP
-        if (type == "graphic")
+        if (type == "graphic" || type == "selectbackground")
             url = "file://" + std::string(JAILED_DOCUMENT_ROOT) + "insertfile/" + name;
         else if (type == "graphicurl")
             URI::decode(name, url);
@@ -1176,8 +1176,8 @@ bool ChildSession::insertFile(const char* /*buffer*/, int /*length*/, const std:
         url = "file://" + tempFile;
 #endif
 
-        std::string command = ".uno:InsertGraphic";
-        std::string arguments = "{"
+        const std::string command = (type == "selectbackground" ? ".uno:SelectBackground" : ".uno:InsertGraphic");
+        const std::string arguments = "{"
             "\"FileName\":{"
                 "\"type\":\"string\","
                 "\"value\":\"" + url + "\""
@@ -1185,7 +1185,7 @@ bool ChildSession::insertFile(const char* /*buffer*/, int /*length*/, const std:
 
         getLOKitDocument()->setView(_viewId);
 
-        LOG_TRC("Inserting graphic: '" << arguments.c_str() << "', '");
+        LOG_TRC("Inserting " << type << ": " << command << ' ' << arguments.c_str());
 
         getLOKitDocument()->postUnoCommand(command.c_str(), arguments.c_str(), false);
     }
diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index 3f5480c9a..3758a47a4 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -159,6 +159,7 @@ ifelse(MOBILEAPP,[true],
     </script>
 
     <input id="insertgraphic" type="file" style="position: fixed; top: -100em">
+    <input id="selectbackground" type="file" style="position: fixed; top: -100em">
 
     <div id="closebuttonwrapper">
       <div class="closebuttonimage" id="closebutton"></div>
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index ef1ffa0f9..cb46986f4 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -287,6 +287,7 @@ L.Control.Menubar = L.Control.extend({
 			{name: _UNO('.uno:InsertMenu', 'presentation'), id: 'insert', type: 'menu', menu: [
 				{name: _('Local Image...'), id: 'insertgraphic', type: 'action'},
 				{name: _UNO('.uno:InsertGraphic', 'presentation'), id: 'insertgraphicremote', type: 'action'},
+				{name: _UNO('.uno:SelectBackground', 'presentation'), id: 'selectbackground', type: 'action'},
 				{name: _UNO('.uno:InsertAnnotation', 'presentation'), id: 'insertcomment', type: 'action'},
 				{uno: '.uno:InsertObjectChart'},
 				{type: 'separator'},
@@ -1071,6 +1072,8 @@ L.Control.Menubar = L.Control.extend({
 			L.DomUtil.get('insertgraphic').click();
 		} else if (id === 'insertgraphicremote') {
 			this._map.fire('postMessage', {msgId: 'UI_InsertGraphic'});
+		} else if (id === 'selectbackground') {
+			L.DomUtil.get('selectbackground').click();
 		} else if (id === 'zoomin' && this._map.getZoom() < this._map.getMaxZoom()) {
 			this._map.zoomIn(1);
 		} else if (id === 'showresolved') {
diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js
index 44f2659e7..ba07e8e67 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -1316,6 +1316,21 @@ function onInsertFile() {
 	return false;
 }
 
+function onInsertBackground() {
+	var selectBackground = L.DomUtil.get('selectbackground');
+	if ('files' in selectBackground) {
+		for (var i = 0; i < selectBackground.files.length; i++) {
+			var file = selectBackground.files[i];
+			map.selectBackground(file);
+		}
+	}
+
+	// Set the value to null everytime so that onchange event is triggered,
+	// even if the same file is selected
+	selectBackground.value = null;
+	return false;
+}
+
 function onAddressInput(e) {
 	if (e.keyCode === 13) {
 		// address control should not have focus anymore
@@ -2378,6 +2393,7 @@ $(window).resize(function() {
 $(document).ready(function() {
 	// Attach insert file action
 	$('#insertgraphic').on('change', onInsertFile);
+	$('#selectbackground').on('change', onInsertBackground);
 });
 
 function setupToolbar(e) {
diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js
index 7dda7e3bf..8c9ee5750 100644
--- a/loleaflet/src/control/Toolbar.js
+++ b/loleaflet/src/control/Toolbar.js
@@ -179,6 +179,10 @@ L.Map.include({
 		this.fire('inserturl', {url: url});
 	},
 
+	selectBackground: function (file) {
+		this.fire('selectbackground', {file: file});
+	},
+
 	cellEnterString: function (string) {
 		var command = {
 			'StringName': {
diff --git a/loleaflet/src/map/handler/Map.FileInserter.js b/loleaflet/src/map/handler/Map.FileInserter.js
index 728eb9ab0..5bf305ec0 100644
--- a/loleaflet/src/map/handler/Map.FileInserter.js
+++ b/loleaflet/src/map/handler/Map.FileInserter.js
@@ -16,6 +16,7 @@ L.Map.FileInserter = L.Handler.extend({
 		this._childId = null;
 		this._toInsert = {};
 		this._toInsertURL = {};
+		this._toInsertBackground = {};
 		var parser = document.createElement('a');
 		parser.href = map.options.server;
 	},
@@ -33,12 +34,14 @@ L.Map.FileInserter = L.Handler.extend({
 		this._map.on('insertfile', this._onInsertFile, this);
 		this._map.on('inserturl', this._onInsertURL, this);
 		this._map.on('childid', this._onChildIdMsg, this);
+		this._map.on('selectbackground', this._onSelectBackground, this);
 	},
 
 	removeHooks: function () {
 		this._map.off('insertfile', this._onInsertFile, this);
 		this._map.off('inserturl', this._onInsertURL, this);
 		this._map.off('childid', this._onChildIdMsg, this);
+		this._map.off('selectbackground', this._onSelectBackground, this);
 	},
 
 	_onInsertFile: function (e) {
@@ -61,6 +64,16 @@ L.Map.FileInserter = L.Handler.extend({
 		}
 	},
 
+	_onSelectBackground: function (e) {
+		if (!this._childId) {
+			this._map._socket.sendMessage('getchildid');
+			this._toInsertBackground[Date.now()] = e.file;
+		}
+		else {
+			this._sendFile(Date.now(), e.file, 'selectbackground');
+		}
+	},
+
 	_onChildIdMsg: function (e) {
 		this._childId = e.id;
 		for (var name in this._toInsert) {
@@ -88,6 +101,8 @@ L.Map.FileInserter = L.Handler.extend({
 			return;
 		}
 
+		this._toInsertBackground = {};
+
 		if (window.ThisIsAMobileApp) {
 			// Pass the file contents as a base64-encoded parameter in an insertfile message
 			var reader = new FileReader();
diff --git a/loleaflet/src/unocommands.js b/loleaflet/src/unocommands.js
index 6f16e3d06..e0422f479 100644
--- a/loleaflet/src/unocommands.js
+++ b/loleaflet/src/unocommands.js
@@ -206,6 +206,7 @@ var unoCommandsArray = {
 	SaveAs:{global:{menu:_('Save ~As...'),},},
 	SearchDialog:{global:{menu:_('Find & Rep~lace...'),},},
 	SelectAll:{global:{menu:_('Select ~All'),},},
+	SelectBackground:{presentation:{menu:_('Set Background Image...'),},},
 	SelectTable:{presentation:{menu:_('~Select...'),},text:{menu:_('~Table'),},},
 	SendToBack:{global:{menu:_('~Send to Back'),},},
 	SetAnchorAtChar:{text:{menu:_('To ~Character'),},},
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 7bf4bb47c..9eb332b86 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -2644,7 +2644,7 @@ private:
                             std::vector<char> saveasRequest(saveas.begin(), saveas.end());
                             clientSession->handleMessage(true, WSOpCode::Text, saveasRequest);
                         });
-                        });
+                    });
 
                     sent = true;
                 }
@@ -2691,11 +2691,11 @@ private:
                 // protect against attempts to inject something funny here
                 if (formChildid.find('/') == std::string::npos && formName.find('/') == std::string::npos)
                 {
-                    LOG_INF("Perform insertfile: " << formChildid << ", " << formName);
                     const std::string dirPath = LOOLWSD::ChildRoot + formChildid
                                               + JAILED_DOCUMENT_ROOT + "insertfile";
+                    const std::string fileName = dirPath + '/' + form.get("name");
+                    LOG_INF("Perform insertfile: " << formChildid << ", " << formName << ", filename: " << fileName);
                     File(dirPath).createDirectories();
-                    std::string fileName = dirPath + "/" + form.get("name");
                     File(handler.getFilename()).moveTo(fileName);
                     response.setContentLength(0);
                     socket->send(response);
@@ -3379,11 +3379,13 @@ int LOOLWSD::innerMain()
         LOG_FTL("Missing --systemplate option");
         throw MissingOptionException("systemplate");
     }
+
     if (LoTemplate.empty())
     {
         LOG_FTL("Missing --lotemplate option");
         throw MissingOptionException("lotemplate");
     }
+
     if (ChildRoot.empty())
     {
         LOG_FTL("Missing --childroot option");
@@ -3494,6 +3496,7 @@ int LOOLWSD::innerMain()
         }
 #endif
     }
+
     // Stop the listening to new connections
     // and wait until sockets close.
     LOG_INF("Stopping server socket listening. ShutdownRequestFlag: " <<
diff --git a/wsd/protocol.txt b/wsd/protocol.txt
index bf11deafd..6e097587b 100644
--- a/wsd/protocol.txt
+++ b/wsd/protocol.txt
@@ -70,6 +70,10 @@ insertfile name=<name> type=<type>
         type = 'graphicurl': The file is supposed to be downloaded by the core
 	                     itself; it does so from the URL provided in 'name'
 
+selectbackground name=<name>
+
+    Inserts a graphic file with the name <name> into the document as background.
+
 key type=<type> char=<charcode> key=<keycode>
 
     <type> is 'input' or 'up', <charcode> and <keycode> are numbers.
commit f86a1cb016d896903d6222dd886666bdeb80a7b0
Author:     Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Sat Aug 4 14:17:34 2018 -0400
Commit:     Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Wed Nov 6 03:42:49 2019 +0100

    leaflet: add impress menus for sidebars
    
    (cherry picked from commit 3309b8b637488b0b20894f4d16be3e132efa8bee)
    
    Change-Id: Idc51426994cdbf679592c397122c1e4dfc314abe
    Reviewed-on: https://gerrit.libreoffice.org/81975
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index 78d68fee0..ef1ffa0f9 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -276,7 +276,13 @@ L.Control.Menubar = L.Control.extend({
 				{name: _UNO('.uno:ZoomPlus', 'presentation'), id: 'zoomin', type: 'action'},
 				{name: _UNO('.uno:ZoomMinus', 'presentation'), id: 'zoomout', type: 'action'},
 				{name: _('Reset zoom'), id: 'zoomreset', type: 'action'},
-				{uno: '.uno:Sidebar'}
+				{type: 'separator'},
+				{uno: '.uno:SlideMasterPage'},
+				{uno: '.uno:CloseMasterView'},
+				{uno: '.uno:MasterSlidesPanel'},
+				{uno: '.uno:ModifyPage'},
+				{uno: '.uno:SlideChangeWindow'},
+				{uno: '.uno:CustomAnimation'}
 			]},
 			{name: _UNO('.uno:InsertMenu', 'presentation'), id: 'insert', type: 'menu', menu: [
 				{name: _('Local Image...'), id: 'insertgraphic', type: 'action'},
diff --git a/loleaflet/src/unocommands.js b/loleaflet/src/unocommands.js
index ed094f3b9..6f16e3d06 100644
--- a/loleaflet/src/unocommands.js
+++ b/loleaflet/src/unocommands.js
@@ -24,6 +24,7 @@ var unoCommandsArray = {
 	ChangeCaseToUpper:{global:{menu:_('~UPPERCASE'),},},
 	ChangesMenu:{global:{menu:_('Track Chan~ges'),},},
 	ClearOutline:{global:{menu:_('~Remove Outline'),},},
+	CloseMasterView:{presentation:{menu:_('Close Master View'),},},
 	ColorScaleFormatDialog:{spreadsheet:{menu:_('Color Scale...'),},},
 	CommonAlignBottom:{global:{menu:_('Bottom'),},},
 	CommonAlignHorizontalCenter:{global:{menu:_('Centered'),},},
@@ -40,6 +41,7 @@ var unoCommandsArray = {
 	ControlCodes:{text:{menu:_('For~matting Marks'),},},
 	Copy:{global:{menu:_('Cop~y'),},},
 	CopyHyperlinkLocation:{global:{menu:_('Copy Hyperlink Location'),},},
+	CustomAnimation:{presentation:{menu:_('Animation'),},},
 	Cut:{global:{menu:_('~Cut'),},},
 	DataBarFormatDialog:{spreadsheet:{menu:_('Data Bar...'),},},
 	DataFilterAutoFilter:{spreadsheet:{menu:_('Auto~Filter'),},},
@@ -155,6 +157,7 @@ var unoCommandsArray = {
 	LayoutStatus:{presentation:{menu:_('Layout'),},},
 	LeftPara:{global:{context:_('Align Left'),menu:_('Left'),},},
 	MergeCells:{presentation:{menu:_('Merge Cells'),},spreadsheet:{menu:_('Merge Cells'),},text:{menu:_('Merge Cells'),},},
+	ModifyPage:{presentation:{menu:_('Slide ~Layout'),},},
 	MoveDown:{text:{menu:_('Move Down'),},},
 	MoveDownSubItems:{text:{menu:_('Move Down with Subpoints'),},},
 	MoveUp:{text:{menu:_('Move Up'),},},
@@ -226,6 +229,9 @@ var unoCommandsArray = {
 	ShowTrackedChanges:{text:{menu:_('~Show'),},},
 	Shrink:{global:{menu:_('Decrease Size'),},},
 	Sidebar:{global:{menu:_('Sidebar'),},},
+	SlideChangeWindow:{presentation:{menu:_('Slide Transition'),},},
+	SlideMasterPage:{presentation:{menu:_('~Master Slide'),},},
+	MasterSlidesPanel:{presentation:{menu:_('Master Slides'),},},
 	SlideMenu:{presentation:{menu:_('S~lide'),},},
 	SlideShowMenu:{presentation:{menu:_('~Slide Show'),},},
 	SmallCaps:{global:{menu:_('Small capitals'),},},


More information about the Libreoffice-commits mailing list