loleaflet: remove pagepartrectangles request and handling in loleaflet

Change-Id: Ib83e7c0ca05a7d7d1a3d30675ef3cf5804f5ac4c
This commit is contained in:
Ashod Nakashian 2017-02-05 11:31:48 -05:00
parent 5dad626b6d
commit 5cac95e6a9
8 changed files with 7 additions and 126 deletions

View file

@ -291,9 +291,6 @@ Writer pages:
+ e.currentPage = the page on which the cursor lies
+ e.pages = number of pages
+ e.docType = document type, should be 'text'
map.on('partpagerectangles', function (e) {}) where:
+ e.pixelRectangles = An array of bounds representing each page's dimension in pixels on the current zoom level
+ e.twipsRectangles = An array of bounds representing each page's dimension in twips.
Error:
- events

View file

@ -1922,11 +1922,6 @@ unexpected behaviour.</h4>
<td><code><a href="#pagenumberchanged-event">PageNumberChangedEvent</a></code></td>
<td>Fired when the number of pages changes.</td>
</tr>
<tr>
<td><code><b>partpagerectangles</b></code></td>
<td><code><a href="#partpagerectangles-event">PartPageRectanglesEvent</a></code></td>
<td>Fired when the document is ready, contains information about the size of each page.</td>
</tr>
<tr>
<td><code><b>print</b></code></td>
<td><code><a href="#print-event">PrintEvent</a></code></td>
@ -2186,26 +2181,6 @@ The <code>id</code> property of ErrorEvent can have the following values:
</tr>
</table>
<h3 id="partpagerectangles-event">PartPageRectangles</h3>
<table data-id='events'>
<tr>
<th class="width100">property</th>
<th>type</th>
<th>description</th>
</tr>
<tr>
<td><code><b>pixelRectangles</b></code></td>
<td><code><a href="#bounds">Bounds[]</a></code></td>
<td>An array of bounds representing each page's dimension in pixels on the current zoom level.</td>
</tr>
<tr>
<td><code><b>twipsRectangles</b></code></td>
<td><code><a href="#bounds">Bounds[]</a></code></td>
<td>An array of bounds representing each page's dimension in twips.</td>
</tr>
</table>
<h3 id="print-event">PrintEvent</h3>
<table data-id='events'>

View file

@ -145,17 +145,6 @@ describe('Parts and Pages', function () {
expect(Math.floor(map.getDocSize().y)).to.be(2946);
});
it('Get page sizes', function () {
var pageSizes = map.getPageSizes();
expect(pageSizes).to.only.have.keys(['twips', 'pixels']);
expect(pageSizes.twips.length).to.be(map.getNumberOfPages());
expect(pageSizes.pixels.length).to.be(map.getNumberOfPages());
expect(pageSizes.twips[0].min.equals(new L.Point(284, 284))).to.be.ok();
expect(pageSizes.twips[0].max.equals(new L.Point(12190, 17122))).to.be.ok();
expect(pageSizes.twips[1].min.equals(new L.Point(284, 17406))).to.be.ok();
expect(pageSizes.twips[1].max.equals(new L.Point(12190, 34244))).to.be.ok();
});
it('Get document type', function () {
expect(map.getDocType()).to.be('text');
});

View file

@ -13,14 +13,6 @@ describe('Search', function () {
edit: false,
readOnly: false
});
map.once('partpagerectangles', function(e) {
done();
});
setTimeout(function() {
done(new Error('No response for partpagerectangles'));
}, 5000);
});
afterEach(function () {
@ -52,7 +44,7 @@ describe('Search', function () {
expect(e.count).to.be(1);
expect(e.results[0].part).to.be(0);
// the first page contains the search result
expect(map.getPageSizes().pixels[0].contains(e.results[0].rectangles[0])).to.be.ok();
//expect(map.getPageSizes().pixels[0].contains(e.results[0].rectangles[0])).to.be.ok();
done();
});
map.search('doc');
@ -64,7 +56,7 @@ describe('Search', function () {
expect(e.count).to.be(1);
expect(e.results[0].part).to.be(0);
// the second page contains the search result
expect(map.getPageSizes().pixels[1].contains(e.results[0].rectangles[0])).to.be.ok();
//expect(map.getPageSizes().pixels[1].contains(e.results[0].rectangles[0])).to.be.ok();
done();
});
map.search('doc', true);
@ -94,10 +86,10 @@ describe('Search', function () {
expect(e.results.length).to.be(5);
// first 4 results are in first page
for (var i = 0; i < e.count - 1; i++) {
expect(map.getPageSizes().pixels[0].contains(e.results[i].rectangles[0])).to.be.ok();
//expect(map.getPageSizes().pixels[0].contains(e.results[i].rectangles[0])).to.be.ok();
}
// last result is in second page
expect(map.getPageSizes().pixels[1].contains(e.results[e.count - 1].rectangles[0])).to.be.ok();
//expect(map.getPageSizes().pixels[1].contains(e.results[e.count - 1].rectangles[0])).to.be.ok();
done();
});
map.highlightAll('doc');
@ -111,7 +103,7 @@ describe('Search', function () {
// Output of previous highlight all operation is still cached
expect(map._docLayer._searchResults.length).to.be(5);
// the first page contains the search result
expect(map.getPageSizes().pixels[0].contains(e.results[0].rectangles[0])).to.be.ok();
//expect(map.getPageSizes().pixels[0].contains(e.results[0].rectangles[0])).to.be.ok();
done();
});
map.search('doc');
@ -125,7 +117,7 @@ describe('Search', function () {
// Output of previous highlight all operation is still cached
expect(map._docLayer._searchResults.length).to.be(5);
// the second page contains the search result
expect(map.getPageSizes().pixels[1].contains(e.results[0].rectangles[0])).to.be.ok();
//expect(map.getPageSizes().pixels[1].contains(e.results[0].rectangles[0])).to.be.ok();
done();
});
map.search('doc', true);

View file

@ -61,14 +61,7 @@ L.Map.include({
var docLayer = this._docLayer;
if (docLayer._docType === 'text') {
if (index >= docLayer._partPageRectanglesTwips.length) {
return;
}
var part = 0;
var tilePosX = docLayer._partPageRectanglesTwips[index].min.x;
var tilePosY = docLayer._partPageRectanglesTwips[index].min.y;
var tileWidth = docLayer._partPageRectanglesTwips[index].max.x - tilePosX;
var tileHeight = docLayer._partPageRectanglesTwips[index].max.y - tilePosY;
return;
}
else {
part = index;
@ -294,12 +287,6 @@ L.Map.include({
return this._docLayer._docPixelSize;
},
getPageSizes: function () {
return {
twips: this._docLayer._partPageRectanglesTwips,
pixels: this._docLayer._partPageRectanglesPixels};
},
getDocType: function () {
if (!this._docLayer)
return null;

View file

@ -131,7 +131,6 @@ L.Socket = L.Class.extend({
msg += ' options=' + JSON.stringify(options);
}
this._doSend(msg);
this._doSend('partpagerectangles');
for (var i = 0; i < this._msgQueue.length; i++) {
this._doSend(this._msgQueue[i].msg, this._msgQueue[i].coords);
}

View file

@ -135,8 +135,6 @@ L.TileLayer = L.GridLayer.extend({
this._msgQueue = [];
this._toolbarCommandValues = {};
this._previewInvalidations = [];
this._partPageRectanglesTwips = [];
this._partPageRectanglesPixels = [];
this._clientZoom = 'tilepixelwidth=' + this._tileWidthPx + ' ' +
'tilepixelheight=' + this._tileHeightPx + ' ' +
'tiletwipwidth=' + this.options.tileWidthTwips + ' ' +
@ -187,7 +185,6 @@ L.TileLayer = L.GridLayer.extend({
map.on('drop', this._onDrop, this);
map.on('zoomend', this._onUpdateCursor, this);
map.on('zoomend', this._onUpdatePartPageRectangles, this);
if (this._docType === 'spreadsheet') {
map.on('zoomend', this._onCellCursorShift, this);
}
@ -343,9 +340,6 @@ L.TileLayer = L.GridLayer.extend({
else if (textMsg.startsWith('mousepointer:')) {
this._onMousePointerMsg(textMsg);
}
else if (textMsg.startsWith('partpagerectangles:')) {
this._onPartPageRectanglesMsg(textMsg);
}
else if (textMsg.startsWith('renderfont:')) {
this._onRenderFontMsg(textMsg, img);
}
@ -855,34 +849,6 @@ L.TileLayer = L.GridLayer.extend({
}
},
_onPartPageRectanglesMsg: function (textMsg) {
textMsg = textMsg.substring(19);
var pages = textMsg.split(';');
this._partPageRectanglesTwips = [];
this._partPageRectanglesPixels = [];
for (var i = 0; i < pages.length; i++) {
var strTwips = pages[i].match(/\d+/g);
if (!strTwips) {
// probably not a text file
return;
}
var topLeftTwips = new L.Point(parseInt(strTwips[0]), parseInt(strTwips[1]));
var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
var bottomRightTwips = topLeftTwips.add(offset);
var pageBoundsTwips = new L.Bounds(topLeftTwips, bottomRightTwips);
this._partPageRectanglesTwips.push(pageBoundsTwips);
var pageBoundsPixels = new L.Bounds(
this._twipsToPixels(topLeftTwips),
this._twipsToPixels(bottomRightTwips));
this._partPageRectanglesPixels.push(pageBoundsPixels);
}
this._map.fire('partpagerectangles', {
pixelRectangles: this._partPageRectanglesPixels,
twipsRectangles: this._partPageRectanglesTwips
});
this._onCurrentPageUpdate();
},
_onRenderFontMsg: function (textMsg, img) {
var command = this._map._socket.parseServerCmd(textMsg);
this._map.fire('renderfont', {
@ -1843,22 +1809,6 @@ L.TileLayer = L.GridLayer.extend({
}
},
_onUpdatePartPageRectangles: function () {
if (this._partPageRectanglesPixels.length > 0) {
this._partPageRectanglesPixels = [];
for (var i = 0; i < this._partPageRectanglesTwips.length; i++) {
var pageBounds = new L.Bounds(
this._twipsToPixels(this._partPageRectanglesTwips[i].min),
this._twipsToPixels(this._partPageRectanglesTwips[i].max));
this._partPageRectanglesPixels.push(pageBounds);
}
this._map.fire('partpagerectangles', {
pixelRectangles: this._partPageRectanglesPixels,
twipsRectangles: this._partPageRectanglesTwips
});
}
},
// Cells can change position during changes of zoom level in calc
// hence we need to request an updated cell cursor position for this level.
_onCellCursorShift: function (force) {

View file

@ -149,10 +149,6 @@ uno <command>
<command> is a line of text.
partpagerectangles
Invokes lok::Document::getPartPageRectangles().
clientvisiblearea x=<x> y=<y> width=<width> height=<height>
Invokes lok::Document::setClientVisibleArea().
@ -300,10 +296,6 @@ statechanged: <key>=<value>
Notifies client of state changed events of <key>.
Eg: 'statechanged: .uno:Undo=enabled'
partpagerectangles: <payload>
Payload format is the same as LOK_CALLBACK_TEXT_SELECTION.
textselectioncontent: <content>
Current selection's content