[Libreoffice-commits] online.git: 4 commits - loleaflet/build loleaflet/dist loleaflet/src loolwsd/LOOLSession.cpp
Mihai Varga
mihai.varga at collabora.com
Tue Jul 7 23:24:14 PDT 2015
loleaflet/build/deps.js | 7 ++
loleaflet/dist/images/alignblock.png |binary
loleaflet/dist/images/aligncenter.png |binary
loleaflet/dist/images/alignleft.png |binary
loleaflet/dist/images/alignright.png |binary
loleaflet/dist/images/bold.png |binary
loleaflet/dist/images/italic.png |binary
loleaflet/dist/images/strikethrough.png |binary
loleaflet/dist/images/underline.png |binary
loleaflet/dist/leaflet.css | 28 +++++++++
loleaflet/src/control/Control.Buttons.js | 93 +++++++++++++++++++++++++++++++
loleaflet/src/layer/tile/TileLayer.js | 4 +
loolwsd/LOOLSession.cpp | 9 ++-
13 files changed, 140 insertions(+), 1 deletion(-)
New commits:
commit f374079d1a7e803bccca44de1f09785b23faeabc
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Jul 8 09:22:27 2015 +0300
loleaflet: toolbar control integration
diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index ec73c3e..ec2dbe3 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -228,6 +228,13 @@ var deps = {
desc: 'Switches from viewing to editing mode and backwards'
},
+ ControlButtons: {
+ src: ['control/Control.js',
+ 'control/Control.Buttons.js'],
+ heading: 'Buttons',
+ desc: 'Handles buttons from the toolbar'
+ },
+
ControlStatusIndicator: {
src: ['control/Control.js',
'control/Control.StatusIndicator.js'],
diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index c192339..90dd07f 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -305,6 +305,34 @@
user-select: none;
}
+/* Toolbar buttons control */
+
+.leaflet-control-buttons-container {
+ float: left;
+ }
+
+.leaflet-control-buttons,
+a.leaflet-control-buttons,
+a.leaflet-control-buttons:hover {
+ box-shadow: 0 1px 5px rgba(0,0,0,0.4);
+ background: #fff;
+ border-radius: 5px;
+ width: 24px;
+ height: 24px;
+ float: left;
+ }
+
+a.leaflet-control-buttons,
+a.leaflet-control-buttons:hover {
+ margin-left: 3px;
+ }
+
+.leaflet-control-buttons-active {
+ border: thin solid;
+ }
+
+
+
/* layers control */
.leaflet-control-layers {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 7f4b843..1dbc3ce 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -376,6 +376,10 @@ L.TileLayer = L.GridLayer.extend({
}
}
}
+ else if (textMsg.startsWith('statechanged:')) {
+ var state = textMsg.substr(14);
+ map.fire('statechanged', {state : state});
+ }
else if (textMsg.startsWith('status:')) {
command = this._parseServerCmd(textMsg);
if (command.width && command.height && this._documentInfo !== textMsg) {
commit 104931362e0eea5b52eaea7dc5330e91474e7815
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Jul 8 09:21:26 2015 +0300
loleaflet: toolbar buttons control
diff --git a/loleaflet/src/control/Control.Buttons.js b/loleaflet/src/control/Control.Buttons.js
new file mode 100644
index 0000000..c54c291
--- /dev/null
+++ b/loleaflet/src/control/Control.Buttons.js
@@ -0,0 +1,93 @@
+/*
+ * L.Control.Buttons handles buttons such as bold, italic, etc.
+ */
+
+L.Control.Buttons = L.Control.extend({
+ options: {
+ position: 'topleft'
+ },
+
+ onAdd: function (map) {
+ var buttonsName = 'leaflet-control-buttons',
+ container = L.DomUtil.create('div', buttonsName + '-container' + ' leaflet-bar');
+
+ this._buttons = {
+ 'bold': {title: 'Bold', uno: 'Bold', iconName: 'bold.png'},
+ 'italic': {title: 'Italic', uno: 'Italic', iconName: 'italic.png'},
+ 'underline': {title: 'Underline', uno: 'Underline', iconName: 'underline.png'},
+ 'strikethrough': {title: 'Strike-through', uno: 'Strikeout', iconName: 'strikethrough.png'},
+ 'alignleft': {title: 'Align left', uno: 'AlignLeft', iconName: 'alignleft.png'},
+ 'aligncenter': {title: 'Center horizontaly', uno: 'AlignCenter', iconName: 'aligncenter.png'},
+ 'alignright': {title: 'Align right', uno: 'AlignRight', iconName: 'alignright.png'},
+ 'alignblock': {title: 'Justified', uno: 'AlignBlock', iconName: 'alignblock.png'}
+ };
+ for (var key in this._buttons) {
+ var button = this._buttons[key];
+ button.el = this._createButton(key, button.title, button.iconName,
+ buttonsName, container, this._onButtonClick);
+ }
+ map.on('statechanged', this._onStateChange, this);
+
+ return container;
+ },
+
+ _createButton: function (id, title, iconName, className, container, fn) {
+ var link = L.DomUtil.create('a', className, container);
+ link.href = '#';
+ link.title = title;
+ var img = L.DomUtil.create('img', className, link);
+ img.id = id;
+ img.src = L.Icon.Default.imagePath + '/' + iconName;
+
+ L.DomEvent
+ .on(link, 'mousedown dblclick', L.DomEvent.stopPropagation)
+ .on(link, 'click', L.DomEvent.stop)
+ .on(link, 'click', fn, this)
+ .on(link, 'click', this._refocusOnMap, this);
+
+ return link;
+ },
+
+ _onButtonClick: function (e) {
+ var id = e.target.id;
+ var button = this._buttons[id];
+ if (button.active) {
+ L.DomUtil.removeClass(e.target, 'leaflet-control-buttons-active');
+ button.active = false;
+ }
+ else {
+ L.DomUtil.addClass(e.target, 'leaflet-control-buttons-active');
+ button.active = true;
+ }
+ this._map.socket.send('uno .uno:' + button.uno);
+ },
+
+ _onStateChange: function (e) {
+ var unoCmd = e.state.match('.uno:(.*)=')[1];
+ var state = e.state.match('.*=(.*)')[1];
+ for (var key in this._buttons) {
+ var button = this._buttons[key];
+ if (button.uno === unoCmd) {
+ if (state === 'true') {
+ L.DomUtil.addClass(button.el.firstChild, 'leaflet-control-buttons-active');
+ }
+ else if (state === 'false') {
+ L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-active');
+ }
+ }
+ }
+ }
+});
+
+L.Map.mergeOptions({
+ buttonsControl: true
+});
+
+L.Map.addInitHook(function () {
+ this.buttonsControl = new L.Control.Buttons();
+ this.addControl(this.buttonsControl);
+});
+
+L.control.buttons = function (options) {
+ return new L.Control.Buttons(options);
+};
commit 96fff483a6aea6e1013b3f1015568ca09e5f81d3
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Jul 8 09:14:45 2015 +0300
loleaflet: breeze toolbar icons
diff --git a/loleaflet/dist/images/alignblock.png b/loleaflet/dist/images/alignblock.png
new file mode 100644
index 0000000..0c647ec
Binary files /dev/null and b/loleaflet/dist/images/alignblock.png differ
diff --git a/loleaflet/dist/images/aligncenter.png b/loleaflet/dist/images/aligncenter.png
new file mode 100644
index 0000000..1326ae0
Binary files /dev/null and b/loleaflet/dist/images/aligncenter.png differ
diff --git a/loleaflet/dist/images/alignleft.png b/loleaflet/dist/images/alignleft.png
new file mode 100644
index 0000000..a037e60
Binary files /dev/null and b/loleaflet/dist/images/alignleft.png differ
diff --git a/loleaflet/dist/images/alignright.png b/loleaflet/dist/images/alignright.png
new file mode 100644
index 0000000..9ec2747
Binary files /dev/null and b/loleaflet/dist/images/alignright.png differ
diff --git a/loleaflet/dist/images/bold.png b/loleaflet/dist/images/bold.png
new file mode 100644
index 0000000..f3ff0c5
Binary files /dev/null and b/loleaflet/dist/images/bold.png differ
diff --git a/loleaflet/dist/images/italic.png b/loleaflet/dist/images/italic.png
new file mode 100644
index 0000000..56a9510
Binary files /dev/null and b/loleaflet/dist/images/italic.png differ
diff --git a/loleaflet/dist/images/strikethrough.png b/loleaflet/dist/images/strikethrough.png
new file mode 100644
index 0000000..809a2b9
Binary files /dev/null and b/loleaflet/dist/images/strikethrough.png differ
diff --git a/loleaflet/dist/images/underline.png b/loleaflet/dist/images/underline.png
new file mode 100644
index 0000000..e5ce026
Binary files /dev/null and b/loleaflet/dist/images/underline.png differ
commit 6d2d8361b67cbe580455c77eb03d3ce0398d47be
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Wed Jul 8 09:09:58 2015 +0300
loolwsd: the third argument in postUnoCommand must be null not space
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 812d27f..982a95f 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -1056,7 +1056,14 @@ bool ChildProcessSession::unoCommand(const char *buffer, int length, StringToken
return false;
}
- _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str());
+ if (tokens.count() == 2)
+ {
+ _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), 0);
+ }
+ else
+ {
+ _loKitDocument->pClass->postUnoCommand(_loKitDocument, tokens[1].c_str(), Poco::cat(std::string(" "), tokens.begin() + 2, tokens.end()).c_str());
+ }
return true;
}
More information about the Libreoffice-commits
mailing list