CanvasTileLayer: Add extra size for Impress when doc is read only.
ImpressTileLayer: Set document height differently when the file is read only. Signed-off-by: Gökay Şatır <gokay.satir@collabora.com> Change-Id: I97123e8aec4ed73a6616e2772533a6e156bbeb2d
This commit is contained in:
parent
326c5d6011
commit
a39372f53e
5 changed files with 42 additions and 17 deletions
|
@ -162,8 +162,8 @@ L.Map.include({
|
|||
var part = index;
|
||||
var tilePosX = 0;
|
||||
var tilePosY = 0;
|
||||
var tileWidth = docLayer._docWidthTwips;
|
||||
var tileHeight = docLayer._docHeightTwips;
|
||||
var tileWidth = docLayer._partWidthTwips ? docLayer._partWidthTwips: docLayer._docWidthTwips;
|
||||
var tileHeight = docLayer._partHeightTwips ? docLayer._partHeightTwips: docLayer._docHeightTwips;
|
||||
}
|
||||
var docRatio = tileWidth / tileHeight;
|
||||
var imgRatio = maxWidth / maxHeight;
|
||||
|
|
|
@ -573,7 +573,7 @@ app.definitions.Socket = L.Class.extend({
|
|||
// Lets also try to set the permission ourself since this can well be received
|
||||
// after doclayer is initialized. There's no harm to call this in any case.
|
||||
this._map.setPermission(perm);
|
||||
if (!app.file)
|
||||
if (!app.file) // Just a precaution.
|
||||
app.file = {};
|
||||
|
||||
app.file.readOnly = perm === 'readonly' ? true: false;
|
||||
|
|
|
@ -486,7 +486,7 @@ L.AnnotationManagerImpress = L.AnnotationManagerBase.extend({
|
|||
var annotations = [];
|
||||
if (this._annotations && this.getPartHashes() && this.getSelectedPart() !== undefined)
|
||||
annotations = this._annotations[this.getSelectedPartHash()];
|
||||
return (annotations !== undefined && annotations.length > 0) ? this.options.extraSize : null;
|
||||
return (annotations !== undefined && annotations.length > 0) ? this.options.extraSize : new L.Point(0, 0);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -5404,11 +5404,12 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
if (coords.x < 0 || coords.y < 0) {
|
||||
return false;
|
||||
}
|
||||
if ((coords.x / this._tileSize) * this._tileWidthTwips >= this._docWidthTwips ||
|
||||
(coords.y / this._tileSize) * this._tileHeightTwips >= this._docHeightTwips) {
|
||||
else if ((coords.x / this._tileSize) * this._tileWidthTwips > this._docWidthTwips ||
|
||||
(coords.y / this._tileSize) * this._tileHeightTwips > this._docHeightTwips) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
else
|
||||
return true;
|
||||
},
|
||||
|
||||
_updateMaxBounds: function (sizeChanged, options, zoom) {
|
||||
|
@ -5420,9 +5421,10 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
}
|
||||
|
||||
var dpiScale = this._painter._dpiScale;
|
||||
var extraSize = options ? options.extraSize : null;
|
||||
var extraSize = new L.Point(0, 0);
|
||||
if (this._docType === 'presentation')
|
||||
extraSize = this._annotationManager.allocateExtraSize();
|
||||
extraSize = this._annotationManager.allocateExtraSize(); // This changes only the width.
|
||||
|
||||
var docPixelLimits = new L.Point(this._docWidthTwips / this.options.tileWidthTwips,
|
||||
this._docHeightTwips / this.options.tileHeightTwips);
|
||||
// docPixelLimits should be in csspx.
|
||||
|
@ -5432,10 +5434,9 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
topLeft = this._map.unproject(topLeft.multiplyBy(scale));
|
||||
var bottomRight = new L.Point(docPixelLimits.x, docPixelLimits.y);
|
||||
bottomRight = bottomRight.multiplyBy(scale);
|
||||
if (extraSize) {
|
||||
// extraSize is unscaled.
|
||||
bottomRight = bottomRight.add(extraSize);
|
||||
}
|
||||
|
||||
// extraSize is unscaled.
|
||||
bottomRight = bottomRight.add(extraSize);
|
||||
bottomRight = this._map.unproject(bottomRight);
|
||||
|
||||
if (this._documentInfo === '' || sizeChanged) {
|
||||
|
@ -5447,10 +5448,9 @@ L.CanvasTileLayer = L.Layer.extend({
|
|||
var scrollPixelLimits = new L.Point(this._docWidthTwips / this._tileWidthTwips,
|
||||
this._docHeightTwips / this._tileHeightTwips);
|
||||
scrollPixelLimits = scrollPixelLimits.multiplyBy(this._tileSize / dpiScale);
|
||||
if (extraSize) {
|
||||
// extraSize is unscaled.
|
||||
scrollPixelLimits = scrollPixelLimits.add(extraSize);
|
||||
}
|
||||
// extraSize is unscaled.
|
||||
scrollPixelLimits = scrollPixelLimits.add(extraSize);
|
||||
|
||||
this._docPixelSize = {x: scrollPixelLimits.x, y: scrollPixelLimits.y};
|
||||
this._map.fire('docsize', {x: scrollPixelLimits.x, y: scrollPixelLimits.y, extraSize: extraSize});
|
||||
},
|
||||
|
|
|
@ -15,6 +15,22 @@ L.ImpressTileLayer = L.CanvasTileLayer.extend({
|
|||
this._addButton = L.control.mobileSlide();
|
||||
L.DomUtil.addClass(L.DomUtil.get('mobile-edit-button'), 'impress');
|
||||
}
|
||||
this._spaceBetweenParts = 100; // In twips. This is used when all parts of an Impress or Draw document is shown in one view (like a Writer file). This mode is used when document is read only.
|
||||
|
||||
// app.file variable should exist, this is a precaution.
|
||||
if (!app.file)
|
||||
app.file = {};
|
||||
|
||||
// Before this instance is created, app.file.readOnly and app.file.editComments variables are set.
|
||||
// If document is on read only mode, we will draw all parts at once.
|
||||
// Let's call default view the "part based view" and new view the "file based view".
|
||||
if (app.file.readOnly)
|
||||
app.file.fileBasedView = true;
|
||||
else
|
||||
app.file.partBasedView = true;
|
||||
|
||||
this._partHeightTwips = 0; // Single part's height.
|
||||
this._partWidthTwips = 0; // Single part's width. These values are equal to _docWidthTwips & _docHeightTwips when app.file.partBasedView is true.
|
||||
},
|
||||
|
||||
newAnnotation: function (comment) {
|
||||
|
@ -270,6 +286,15 @@ L.ImpressTileLayer = L.CanvasTileLayer.extend({
|
|||
L.DomUtil.addClass(L.DomUtil.get('presentation-controls-wrapper'), 'drawing');
|
||||
}
|
||||
this._parts = command.parts;
|
||||
this._partHeightTwips = this._docHeightTwips;
|
||||
this._partWidthTwips = this._docWidthTwips;
|
||||
|
||||
if (app.file.fileBasedView) {
|
||||
var totalHeight = this._parts * this._docHeightTwips; // Total height in twips.
|
||||
totalHeight += (this._parts - 1) * this._spaceBetweenParts; // Space between parts.
|
||||
this._docHeightTwips = totalHeight;
|
||||
}
|
||||
|
||||
this._updateMaxBoundsImpress(true);
|
||||
this._documentInfo = textMsg;
|
||||
this._viewId = parseInt(command.viewid);
|
||||
|
|
Loading…
Reference in a new issue