[Libreoffice-commits] online.git: 2 commits - loleaflet/build loleaflet/dist loleaflet/src loolwsd/LOOLSession.cpp
Mihai Varga
mihai.varga at collabora.com
Fri Oct 16 04:08:23 PDT 2015
loleaflet/build/deps.js | 5 +
loleaflet/dist/leaflet.css | 6 +
loleaflet/src/control/Control.Buttons.js | 3
loleaflet/src/layer/tile/TileLayer.js | 15 +---
loleaflet/src/map/handler/Map.Keyboard.js | 4 +
loleaflet/src/map/handler/Map.Mouse.js | 4 +
loleaflet/src/map/handler/Map.SlideShow.js | 106 +++++++++++++++++++++++++++++
loolwsd/LOOLSession.cpp | 2
8 files changed, 133 insertions(+), 12 deletions(-)
New commits:
commit 84b7b128a0e8f2729b17028a17387d0fdc3b3b22
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Oct 16 14:05:59 2015 +0300
loleaflet: fullscreen slideshow
We request svg exports for each slide which we then display in fulscreen
diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 7913747..3618529 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -230,6 +230,11 @@ var deps = {
desc: 'Handles the print action (ctrl + P).'
},
+ SlideShow: {
+ src: ['map/handler/Map.SlideShow.js'],
+ desc: 'Creates a presentation slide show.'
+ },
+
MarkerDrag: {
src: ['layer/marker/Marker.Drag.js'],
deps: ['Marker'],
diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index 77c0381..e11233e 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -826,3 +826,9 @@ div .leaflet-bar a:first-child {
div .leaflet-bar a:last-child {
border-radius: 0 4px 4px 0;
}
+
+.slide-show {
+ background: #FFF;
+ display: block;
+ margin: 0 auto;
+}
diff --git a/loleaflet/src/control/Control.Buttons.js b/loleaflet/src/control/Control.Buttons.js
index 463e2e5..b22759a 100644
--- a/loleaflet/src/control/Control.Buttons.js
+++ b/loleaflet/src/control/Control.Buttons.js
@@ -94,6 +94,9 @@ L.Control.Buttons = L.Control.extend({
L.DomUtil.addClass(button.el.firstChild, 'leaflet-control-buttons-active');
}
}
+ else if (id === 'presentation') {
+ this._map.fire('fullscreen');
+ }
},
_onStateChange: function (e) {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 28d3e4e..e9182e5 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -276,7 +276,7 @@ L.TileLayer = L.GridLayer.extend({
var url = window.location.protocol + '//' + parser.hostname + ':' + command.port + '/' +
command.jail + '/' + command.dir + '/' + command.name;
- if (command.id !== '-1') {
+ if (command.id === 'print') {
var isFirefox = typeof InstallTrigger !== 'undefined' || navigator.userAgent.search('Firefox') >= 0;
if (isFirefox) {
// the print dialog doesn't work well on firefox
@@ -286,6 +286,9 @@ L.TileLayer = L.GridLayer.extend({
this._map.fire('filedownloadready', {url: url, name: name, id: command.id});
}
}
+ else if (command.id === 'slideshow') {
+ this._map.fire('slidedownloadready', {url: url, part: command.part});
+ }
else {
this._map._fileDownloader.src = url;
}
diff --git a/loleaflet/src/map/handler/Map.Keyboard.js b/loleaflet/src/map/handler/Map.Keyboard.js
index 37820b8..b26f4f3 100644
--- a/loleaflet/src/map/handler/Map.Keyboard.js
+++ b/loleaflet/src/map/handler/Map.Keyboard.js
@@ -180,6 +180,10 @@ L.Map.Keyboard = L.Handler.extend({
},
_onKeyDown: function (e) {
+ if (this._map.slideShow && this._map.slideShow.fullscreen) {
+ this._map.slideShow._onUserInput(e);
+ return;
+ }
var docLayer = this._map._docLayer;
this.modifier = 0;
var shift = e.originalEvent.shiftKey ? this.keyModifier.shift : 0;
diff --git a/loleaflet/src/map/handler/Map.Mouse.js b/loleaflet/src/map/handler/Map.Mouse.js
index 9fd8ba8..d5305cf 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -41,6 +41,10 @@ L.Map.Mouse = L.Handler.extend({
// document not yet loaded
return;
}
+ if (this._map.slideShow && this._map.slideShow.fullscreen) {
+ this._map.slideShow._onUserInput(e);
+ return;
+ }
if (docLayer._graphicMarker && docLayer._graphicMarker.isDragged) {
return;
}
diff --git a/loleaflet/src/map/handler/Map.SlideShow.js b/loleaflet/src/map/handler/Map.SlideShow.js
new file mode 100644
index 0000000..cbe38b1
--- /dev/null
+++ b/loleaflet/src/map/handler/Map.SlideShow.js
@@ -0,0 +1,106 @@
+/*
+ * L.Map.SlideShow is handling the slideShow action
+ */
+
+L.Map.mergeOptions({
+ slideShow: true
+});
+
+L.Map.SlideShow = L.Handler.extend({
+
+ initialize: function (map) {
+ this._map = map;
+ },
+
+ addHooks: function () {
+ this._map.on('fullscreen', this._onFullScreen, this);
+ this._map.on('slidedownloadready', this._onSlideDownloadReady, this);
+ },
+
+ removeHooks: function () {
+ this._map.off('fullscreen', this._onFullScreen, this);
+ this._map.off('slidedownloadready', this._onSlideDownloadReady, this);
+ },
+
+ _onFullScreen: function (e) {
+ this._container = L.DomUtil.create('div', '', this._map._container);
+ this._slideShow = L.DomUtil.create('img', 'slide-show', this._container);
+ if (this._slideShow.requestFullscreen) {
+ this._container.requestFullscreen();
+ }
+ else if (this._slideShow.msRequestFullscreen) {
+ this._container.msRequestFullscreen();
+ }
+ else if (this._slideShow.mozRequestFullScreen) {
+ this._container.mozRequestFullScreen();
+ }
+ else if (this._slideShow.webkitRequestFullscreen) {
+ this._container.webkitRequestFullscreen();
+ }
+
+ L.DomEvent['on'](document, 'fullscreenchange webkitfullscreenchange mozfullscreenchange msfullscreenchange',
+ this._onFullScreenChange, this);
+
+ this.fullscreen = true;
+ this._getSlides();
+ },
+
+ _onFullScreenChange: function (e) {
+
+ this.fullscreen = document.fullscreen ||
+ document.webkitIsFullScreen ||
+ document.mozFullScreen ||
+ document.msFullscreenElement;
+ if (!this.fullscreen) {
+ L.DomUtil.remove(this._container);
+ }
+ },
+
+ _getSlides: function () {
+ this._currentSlide = 0;
+ this._slides = [];
+ for (var i = 0; i < this._map.getNumberOfParts(); i++) {
+ // mark the i-th slide as not available yet
+ this._slides.push(null);
+ }
+
+ for (var i = 0; i < this._map.getNumberOfParts(); i++) {
+ L.Socket.sendMessage('downloadas name=' + i + '.svg id=slideshow ' +
+ 'part=' + i + ' format=svg options=');
+ }
+ },
+
+ _onSlideDownloadReady: function (e) {
+ var xmlHttp = new XMLHttpRequest();
+ var part = e.part;
+ xmlHttp.onreadystatechange = L.bind(function () {
+ if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
+ var blob = new Blob([xmlHttp.response], {type: 'image/svg+xml'});
+ var url = URL.createObjectURL(blob);
+ this._slides[part] = url;
+ if (part === this._currentSlide) {
+ this._slideShow.src = url;
+ }
+ }
+ }, this);
+ xmlHttp.open('GET', e.url, true);
+ xmlHttp.responseType = 'blob';
+ xmlHttp.send();
+ },
+
+ _onUserInput: function (e) {
+ if (e.type === 'mousedown' || (e.type === 'keydown' &&
+ e.originalEvent.keyCode === 39)) {
+ this._currentSlide = Math.min(this._currentSlide + 1, this._map.getNumberOfParts() - 1);
+ }
+ else if (e.type === 'keydown' && e.originalEvent.keyCode === 37) {
+ this._currentSlide = Math.max(this._currentSlide - 1, 0);
+ }
+ else {
+ return;
+ }
+ this._slideShow.src = this._slides[this._currentSlide];
+ }
+});
+
+L.Map.addInitHook('addHandler', 'slideShow', L.Map.SlideShow);
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 53a0873..35ef2d6 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -1041,7 +1041,7 @@ bool ChildProcessSession::downloadAs(const char *buffer, int length, StringToken
filterOptions.size() == 0 ? NULL : filterOptions.c_str());
sendTextFrame("downloadas: jail=" + _childId + " dir=" + tmpDir + " name=" + name +
- " port=" + std::to_string(LOOLWSD::portNumber) + " id=" + id);
+ " port=" + std::to_string(LOOLWSD::portNumber) + " id=" + id + " part=" + std::to_string(part));
return true;
}
commit b518046a5983c1a84977839756b1b74643e9598a
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Oct 15 20:27:46 2015 +0300
loleaflet: don't scroll based on the selection, but based on the cursor
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 6d2b73e..28d3e4e 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -417,16 +417,6 @@ L.TileLayer = L.GridLayer.extend({
selectionCenter = selectionCenter.add(topLeftTwips);
selectionCenter = selectionCenter.add(offset.divideBy(2));
}
- // average of all rectangles' centers
- selectionCenter = selectionCenter.divideBy(strTwips.length / 4);
- selectionCenter = this._twipsToLatLng(selectionCenter);
- if (!this._map.getBounds().contains(selectionCenter)) {
- var center = this._map.project(selectionCenter);
- center = center.subtract(this._map.getSize().divideBy(2));
- center.x = Math.round(center.x < 0 ? 0 : center.x);
- center.y = Math.round(center.y < 0 ? 0 : center.y);
- this._map.fire('scrollto', {x: center.x, y: center.y});
- }
var polygons = L.PolyUtil.rectanglesToPolygons(rectangles, this);
for (i = 0; i < polygons.length; i++) {
More information about the Libreoffice-commits
mailing list