[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-7' - 6 commits - loleaflet/reference.html loleaflet/src loolwsd/LOOLSession.cpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp
Henry Castro
hcastro at collabora.com
Mon Dec 21 03:57:38 PST 2015
loleaflet/reference.html | 47 ++++++++++++++++++++++++--
loleaflet/src/control/Control.ColumnHeader.js | 7 +++
loleaflet/src/control/Control.RowHeader.js | 7 +++
loleaflet/src/control/Scroll.js | 6 +++
loleaflet/src/core/Socket.js | 34 +++++++++++++-----
loleaflet/src/layer/tile/GridLayer.js | 6 +--
loleaflet/src/layer/tile/TileLayer.js | 21 +++++++----
loleaflet/src/map/Map.js | 5 +-
loolwsd/LOOLSession.cpp | 8 +++-
loolwsd/LOOLWSD.cpp | 4 --
loolwsd/LOOLWSD.hpp | 2 -
11 files changed, 113 insertions(+), 34 deletions(-)
New commits:
commit 25156f9ddfbeed518c8ebb9362c3307e62a199ac
Author: Henry Castro <hcastro at collabora.com>
Date: Fri Dec 18 16:51:08 2015 -0400
loolwsd: when no available child sessions, pre spawns more children
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 513cd5c..f5299aa 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -688,7 +688,7 @@ void MasterProcessSession::dispatchChild()
{
LOOLWSD::_namedMutexLOOL.lock();
std::cout << Util::logPrefix() << "No available child sessions, queue new child session" << std::endl;
- LOOLWSD::_sharedForkChild.begin()[0] = (LOOLWSD::_sharedForkChild.begin()[0] > 0 ? LOOLWSD::_sharedForkChild.begin()[0] + 1 : 1);
+ LOOLWSD::_sharedForkChild.begin()[0] = LOOLWSD::_numPreSpawnedChildren;
LOOLWSD::_namedMutexLOOL.unlock();
}
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 0970fc5..62e4c32 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -32,6 +32,7 @@ public:
// statics
static int portNumber;
static int timeoutCounter;
+ static int _numPreSpawnedChildren;
static bool doTest;
static bool volatile isShutDown;
static std::string cache;
@@ -73,7 +74,6 @@ private:
int createComponent();
int createDesktop();
- static int _numPreSpawnedChildren;
static std::mutex _rngMutex;
#if ENABLE_DEBUG
commit a623b5a8c0d0a3aebf8ed9b9602c357ccb04fbe3
Author: Henry Castro <hcastro at collabora.com>
Date: Fri Dec 18 16:45:30 2015 -0400
loolwsd: clean up unnecessary code
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 184ddfd..a74d867 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1360,10 +1360,6 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
// wait broker process finish
waitpid(-1, &status, WUNTRACED);
- // remove child root
- if (LOOLWSD::_childId > 0)
- File(LOOLWSD::childRoot + Path::separator() + std::to_string(LOOLWSD::_childId)).remove(true);
-
return Application::EXIT_OK;
}
commit 937fdca4d48488b1220f7ac599c485ab09c095d2
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Dec 18 18:52:23 2015 +0200
loleaflet: ccu#1347 - row/column headers can be < than the map
diff --git a/loleaflet/src/control/Control.ColumnHeader.js b/loleaflet/src/control/Control.ColumnHeader.js
index fcd8064..6cd846f 100644
--- a/loleaflet/src/control/Control.ColumnHeader.js
+++ b/loleaflet/src/control/Control.ColumnHeader.js
@@ -76,6 +76,13 @@ L.Control.ColumnHeader = L.Control.extend({
text.innerHTML = columns[iterator].text;
column.width = Math.round(converter.call(context, twip).x) - 1 + 'px';
}
+ if (this._map.getDocSize().x < this._map.getSize().x) {
+ // the column headers no longer need to strecth to the whole screen
+ L.DomUtil.setStyle(this._table, 'width', 0);
+ }
+ else {
+ L.DomUtil.setStyle(this._table, 'width', '100%');
+ }
},
_onUpdatePermission: function () {
diff --git a/loleaflet/src/control/Control.RowHeader.js b/loleaflet/src/control/Control.RowHeader.js
index 42f45fd..2aef1da 100644
--- a/loleaflet/src/control/Control.RowHeader.js
+++ b/loleaflet/src/control/Control.RowHeader.js
@@ -72,6 +72,13 @@ L.Control.RowHeader = L.Control.extend({
L.DomUtil.setStyle(text, 'line-height', height);
L.DomUtil.setStyle(text, 'height', height);
}
+ if (this._map.getDocSize().y < this._map.getSize().y) {
+ // the row headers no longer need to strecth to the whole screen
+ L.DomUtil.setStyle(this._table, 'height', 0);
+ }
+ else {
+ L.DomUtil.setStyle(this._table, 'height', '100%');
+ }
},
_onUpdatePermission: function () {
commit 82c3d3aeed23db5fe2aaefeb0e7d6b516a03b997
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Dec 18 15:40:03 2015 +0200
fire the `commandresult` when the saveAs command has finished
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 3e28ec0..730fe05 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -1862,7 +1862,7 @@ unexpected behaviour.</h4>
<tr>
<td><code><b>commandresult</b></code></td>
<td><code><a href="#commandresult-event">CommandResultEvent</a></code></td>
- <td>Fired when the a dispatched uno command has finished.</td>
+ <td>Fired when a dispatched uno command or the 'saveas' command has finished.</td>
</tr>
<tr>
<td><code><b>commandstatechanged</b></code></td>
@@ -1977,7 +1977,7 @@ unexpected behaviour.</h4>
<tr>
<td><code><b>commandName</b></code></td>
<td><code><a href="#commandstatechanged-values">CommandStateChangedValues</a></code></td>
- <td>UNO command.</td>
+ <td>UNO command or 'saveas'.</td>
</tr>
<tr>
<td><code><b>success</b></code></td>
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index fbfea8b..513cd5c 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -1505,11 +1505,15 @@ bool ChildProcessSession::saveAs(const char* /*buffer*/, int /*length*/, StringT
}
}
- _loKitDocument->pClass->saveAs(_loKitDocument, url.c_str(),
+ bool success = _loKitDocument->pClass->saveAs(_loKitDocument, url.c_str(),
format.size() == 0 ? NULL :format.c_str(),
filterOptions.size() == 0 ? NULL : filterOptions.c_str());
sendTextFrame("saveas: url=" + url);
+ std::string successStr = success ? "true" : "false";
+ sendTextFrame("unocommandresult: {"
+ "\"commandName\":\"saveas\","
+ "\"success\":\"" + successStr + "\"}");
return true;
}
commit 60a8fafb62092311791366af58b5d990e9fae1ea
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Dec 18 14:40:46 2015 +0200
loleaflet: allow specifying the starting zoom level
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index b15b7dd..3e28ec0 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -1491,6 +1491,33 @@ unexpected behaviour.</h4>
<td>Whether the document is automatically zoomed so that the width fits the viewing area when
the window is resized. The document will not be zoomed in more than map.options.zoom.</td>
</tr>
+ <tr>
+ <td><code><b>zoom</b></code></td>
+ <td><code>Number</code></td>
+ <td><code><span class="literal">10</span></code></td>
+ <td>Default zoom level in which the document will be loaded.</td>
+ </tr>
+ <tr>
+ <td><code><b>tileWidthTwips</b></code></td>
+ <td><code>Number</code></td>
+ <td><code><span class="literal">3000</span></code></td>
+ <td>Default tile width in twips (how much of the document is covered horizontally in a 256x256 pixels tile).
+ Unless you know what you are doing, this should not be modified.</td>
+ </tr>
+ <tr>
+ <td><code><b>tileHeightTwips</b></code></td>
+ <td><code>Number</code></td>
+ <td><code><span class="literal">3000</span></code></td>
+ <td>Default tile height in twips (how much of the document is covered vertically in a 256x256 pixels tile).
+ Unless you know what you are doing, this should not be modified.</td>
+ </tr>
+ <tr>
+ <td><code><b>defaultZoom</b></code></td>
+ <td><code>Number</code></td>
+ <td><code><span class="literal">10</span></code></td>
+ <td>The zoom level at which the tile size in twips equals the default size (3000 x 3000).
+ Unless you know what you are doing, this should not be modified.</td>
+ </tr>
</table>
<h2 id="loleaflet-general">General</h2>
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 1c7397f2..e8d34ef 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -107,32 +107,45 @@ L.Socket = {
if (textMsg.startsWith('status:') && !this._map._docLayer) {
// first status message, we need to create the document layer
+ var tileWidthTwips = this._map.options.tileWidthTwips;
+ var tileHeightTwips = this._map.options.tileHeightTwips;
+ if (this._map.options.zoom !== this._map.options.defaultZoom) {
+ var scale = this._map.options.crs.scale(this._map.options.defaultZoom - this._map.options.zoom);
+ tileWidthTwips = Math.round(tileWidthTwips * scale);
+ tileHeightTwips = Math.round(tileHeightTwips * scale);
+ }
+
var command = this.parseServerCmd(textMsg);
var docLayer = null;
if (command.type === 'text') {
docLayer = new L.WriterTileLayer('', {
permission: this._map.options.permission,
+ tileWidthTwips: tileWidthTwips,
+ tileHeightTwips: tileHeightTwips,
docType: command.type
});
}
else if (command.type === 'spreadsheet') {
docLayer = new L.CalcTileLayer('', {
permission: this._map.options.permission,
+ tileWidthTwips: tileWidthTwips,
+ tileHeightTwips: tileHeightTwips,
docType: command.type
});
}
else {
- if (command.type === 'presentation') {
+ if (command.type === 'presentation' &&
+ this._map.options.defaultZoom === this._map.options.zoom) {
+ // If we have a presentation document and the zoom level has not been set
+ // in the options, resize the document so that it fits the viewing area
var verticalTiles = this._map.getSize().y / 256;
- var tileTwipsSize = Math.round(command.height / verticalTiles);
- }
- else {
- tileTwipsSize = 3000;
+ tileWidthTwips = Math.round(command.height / verticalTiles);
+ tileHeightTwips = Math.round(command.height / verticalTiles);
}
docLayer = new L.ImpressTileLayer('', {
permission: this._map.options.permission,
- tileWidthTwips: tileTwipsSize,
- tileHeightTwips: tileTwipsSize,
+ tileWidthTwips: tileWidthTwips,
+ tileHeightTwips: tileHeightTwips,
docType: command.type
});
}
@@ -224,10 +237,11 @@ L.Socket = {
}
}
if (command.tileWidth && command.tileHeight && this._map._docLayer) {
+ var defaultZoom = this._map.options.zoom;
var scale = command.tileWidth / this._map._docLayer.options.tileWidthTwips;
- // scale = 1.2 ^ (10 - zoom)
- // zoom = 10 -log(scale) / log(1.2)
- command.zoom = Math.round(10 - Math.log(scale) / Math.log(1.2));
+ // scale = 1.2 ^ (defaultZoom - zoom)
+ // zoom = defaultZoom -log(scale) / log(1.2)
+ command.zoom = Math.round(defaultZoom - Math.log(scale) / Math.log(1.2));
}
return command;
}
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index e023189..ed9211c 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -17,10 +17,8 @@ L.GridLayer = L.Layer.extend({
zIndex: null,
bounds: null,
- minZoom: 0,
+ minZoom: 0
// maxZoom: <Number>
- tileWidthTwips: 3000,
- tileHeightTwips: 3000
},
initialize: function (options) {
@@ -359,7 +357,7 @@ L.GridLayer = L.Layer.extend({
_updateTileTwips: function () {
// smaller zoom = zoom in
- var factor = Math.pow(1.2, (10 - this._tileZoom));
+ var factor = Math.pow(1.2, (this._map.options.zoom - this._tileZoom));
this._tileWidthTwips = Math.round(this.options.tileWidthTwips * factor);
this._tileHeightTwips = Math.round(this.options.tileHeightTwips * factor);
},
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 1f8042e..9f650c0 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -13,8 +13,9 @@ L.Map = L.Evented.extend({
fadeAnimation: true,
trackResize: true,
markerZoomAnimation: true,
- edit: false,
- readonly: false
+ defaultZoom: 10,
+ tileWidthTwips: 3000,
+ tileHeightTwips: 3000
},
initialize: function (id, options) { // (HTMLElement or String, Object)
commit 5d4a34fe8f93146c921f7ecca228bd67cf68d232
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Fri Dec 18 12:50:07 2015 +0200
loleaflet: map.fitWidthZoom(maxZoom) method
I've also added an initialization parameter that controls whether the
document should automatically call fitWidthZoom on resize.
diff --git a/loleaflet/reference.html b/loleaflet/reference.html
index 5409c99..b15b7dd 100644
--- a/loleaflet/reference.html
+++ b/loleaflet/reference.html
@@ -1484,6 +1484,13 @@ unexpected behaviour.</h4>
<td><code><span class="literal">true</span></code></td>
<td>Whether the print handler is active (for Chrome).</td>
</tr>
+ <tr>
+ <td><code><b>autoFitWidth</b></code></td>
+ <td><code>Boolean</code></td>
+ <td><code><span class="literal">true</span></code></td>
+ <td>Whether the document is automatically zoomed so that the width fits the viewing area when
+ the window is resized. The document will not be zoomed in more than map.options.zoom.</td>
+ </tr>
</table>
<h2 id="loleaflet-general">General</h2>
@@ -1619,7 +1626,14 @@ unexpected behaviour.</h4>
<td><code>undfined</code></td>
<td>Cancels the automatic update for the preview defined by 'id'.</td>
</tr>
-
+ <tr>
+ <td><code><b>fitWidthZoom</b>(
+ <nobr><Number><i>maxZoom</i>)</nobr>
+ </code></td>
+ <td><code>undfined</code></td>
+ <td>Zooms in or out so that the document's width fits the viewing area. The document will not zoom in more
+ than `maxZoom` if the parameter is provided.</td>
+ </tr>
</table>
<h3 id="scroll-options">ScrollOptions</h3>
diff --git a/loleaflet/src/control/Scroll.js b/loleaflet/src/control/Scroll.js
index b3109b9..cc980ae 100644
--- a/loleaflet/src/control/Scroll.js
+++ b/loleaflet/src/control/Scroll.js
@@ -46,5 +46,11 @@ L.Map.include({
else {
this.off('moveend', this._docLayer._updateScrollOffset, this._docLayer);
}
+ },
+
+ fitWidthZoom: function (maxZoom) {
+ if (this._docLayer) {
+ this._docLayer._fitWidthZoom(null, maxZoom);
+ }
}
});
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 1a3ef06..f14d67c 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -128,7 +128,9 @@ L.TileLayer = L.GridLayer.extend({
map.on('dragstart', this._onDragStart, this);
map.on('requestloksession', this._onRequestLOKSession, this);
map.on('error', this._mapOnError, this);
- map.on('resize', this._fitDocumentHorizontally, this);
+ if (map.options.autoFitWidth !== false) {
+ map.on('resize', this._fitWidthZoom, this);
+ }
// Retrieve the initial cell cursor position (as LOK only sends us an
// updated cell cursor when the selected cell is changed and not the initial
// cell).
@@ -931,19 +933,22 @@ L.TileLayer = L.GridLayer.extend({
L.Socket.sendMessage('requestloksession');
},
- _fitDocumentHorizontally: function (e) {
- if (this._docType !== 'spreadsheet') {
+ _fitWidthZoom: function (e, maxZoom) {
+ var size = e ? e.newSize : this._map.getSize();
+ maxZoom = maxZoom ? maxZoom : this._map.options.zoom;
+ if (this._docType !== 'spreadsheet' || !e) {
+ // If it's not a spreadsheet or the method has been invoked manually
var crsScale = this._map.options.crs.scale(1);
- if (this._docPixelSize.x > e.newSize.x) {
- var ratio = this._docPixelSize.x / e.newSize.x;
+ if (this._docPixelSize.x > size.x) {
+ var ratio = this._docPixelSize.x / size.x;
var zoomDelta = Math.ceil(Math.log(ratio) / Math.log(crsScale));
this._map.setZoom(Math.max(1, this._map.getZoom() - zoomDelta), {animate: false});
}
- else if (e.newSize.x / this._docPixelSize.x > crsScale) {
+ else if (size.x / this._docPixelSize.x > crsScale) {
// we could zoom in
- ratio = e.newSize.x / this._docPixelSize.x;
+ ratio = size.x / this._docPixelSize.x;
zoomDelta = Math.ceil(Math.log(ratio) / Math.log(crsScale));
- this._map.setZoom(Math.min(10, this._map.getZoom() + zoomDelta), {animate: false});
+ this._map.setZoom(Math.min(maxZoom, this._map.getZoom() + zoomDelta), {animate: false});
}
}
},
More information about the Libreoffice-commits
mailing list