Skip to content

Commit 07fba48

Browse files
committed
Multipage view layout misc.
* Rename twopages.svg to lc_multipageview.svg so the file is automatically recognized by the JSDialog class. * Use map state handlers for toggling the multipage view layout. JSDialog class can toggle its button automatically. * Remove twopages_a.svg since JSDialogs has its own toggled state style. * Rename getPos2 to getPosSimplePoint and add an explanation. * Disable setting the viewSize and viewedRectangle properties externally in multipage view. Remove type checks from a few places. Signed-off-by: Gökay Şatır <[email protected]> Change-Id: I84634917f221a7908ad14d5ed0f619f61729900d
1 parent 1db52fc commit 07fba48

File tree

10 files changed

+41
-29
lines changed

10 files changed

+41
-29
lines changed
File renamed without changes.

browser/images/twopages_a.svg

Lines changed: 0 additions & 1 deletion
This file was deleted.

browser/src/app/TilesMiddleware.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class TileCoordData {
5555
return new cool.Point(this.x, this.y);
5656
}
5757

58-
getPos2() {
58+
// Returns SimplePoint. To replace getPos in the short term.
59+
getPosSimplePoint() {
5960
return cool.SimplePoint.fromCorePixels([this.x, this.y], this.part);
6061
}
6162

browser/src/app/ViewLayoutMultiPage.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,4 +411,20 @@ class ViewLayoutMultiPage extends ViewLayoutBase {
411411
this.resetViewLayout();
412412
this.updateViewData();
413413
}
414+
415+
public get viewSize() {
416+
return this._viewSize;
417+
}
418+
419+
public set viewSize(size: cool.SimplePoint) {
420+
return; // Disable setting the size externally.
421+
}
422+
423+
public get viewedRectangle() {
424+
return this._viewedRectangle;
425+
}
426+
427+
public set viewedRectangle(rectangle: cool.SimpleRectangle) {
428+
return; // Disable setting the viewed rectangle externally.
429+
}
414430
}

browser/src/canvas/sections/CommentListSection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,11 +2130,11 @@ export class CommentSection extends CanvasSectionObject {
21302130
if (availableSpace < this.sectionProperties.commentWidth && !this.isCollapsed)
21312131
horizontalScroll = (app.activeDocument.fileSize.cX + this.sectionProperties.commentWidth) * app.pixelsToTwips * app.dpiScale;
21322132

2133-
if (lastY > app.activeDocument.fileSize.pY && app.activeDocument.activeView.type !== 'ViewLayoutMultiPage') {
2133+
if (lastY > app.activeDocument.fileSize.pY) {
21342134
app.activeDocument.activeView.viewSize = new cool.SimplePoint(horizontalScroll, lastY * app.pixelsToTwips);
21352135
this.containerObject.requestReDraw();
21362136
}
2137-
else if (app.activeDocument.activeView.type !== 'ViewLayoutMultiPage')
2137+
else
21382138
app.activeDocument.activeView.viewSize = new cool.SimplePoint(horizontalScroll, app.activeDocument.fileSize.y);
21392139

21402140
this.disableLayoutAnimation = false;

browser/src/canvas/sections/TilesSection.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ export class TilesSection extends CanvasSectionObject {
196196

197197
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
198198
private paintSimple (tile: any, async: boolean): void {
199-
const tilePos: cool.SimplePoint = tile.coords.getPos2();
199+
const tilePos: cool.SimplePoint = tile.coords.getPosSimplePoint();
200200

201201
if ((async || this.containerObject.isZoomChanged()) && !app.file.fileBasedView) {
202202
// Non Calc tiles(handled by paintSimple) can have transparent pixels,
@@ -376,7 +376,7 @@ export class TilesSection extends CanvasSectionObject {
376376
const tile = TileManager.get(visibleCoordList[i]);
377377

378378
if (tile && tile.isReadyToDraw()) {
379-
const tilePos = tile.coords.getPos2();
379+
const tilePos = tile.coords.getPosSimplePoint();
380380

381381
const layoutRectangle1 = view.documentRectangles[view.getClosestRectangleIndex(tilePos)];
382382
const layoutRectangle2 = view.documentRectangles[view.getClosestRectangleIndex(cool.SimplePoint.fromCorePixels([tilePos.pX, tilePos.pY + TileManager.tileSize]))];

browser/src/control/Control.StatusBar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class StatusBar extends JSDialog.Toolbar {
247247
{type: 'toolitem', id: 'signstatus', command: '.uno:Signature', w2icon: '', text: _UNO('.uno:Signature'), visible: false},
248248
{type: 'spacer', id: 'permissionspacer'},
249249
this._generateHtmlItem('documentstatus', 2), // spreadsheet, text, presentation, drawing
250-
{type: 'customtoolitem', id: 'multi-page-view', command: 'multipageview', text: _('Multi Page View'), icon: 'twopages.svg', dataPriority: 10, visible: false}, // text
250+
{type: 'customtoolitem', id: 'multi-page-view', command: 'multipageview', text: _('Multi Page View'), dataPriority: 10, visible: false}, // text
251251
{type: 'customtoolitem', id: 'prev', command: 'prev', text: _UNO('.uno:PageUp', 'text'), pressAndHold: true, dataPriority: 9},
252252
{type: 'customtoolitem', id: 'next', command: 'next', text: _UNO('.uno:PageDown', 'text'), pressAndHold: true, dataPriority: 9},
253253
{type: 'separator', id: 'prevnextbreak', orientation: 'vertical', dataPriority: 9},

browser/src/docdispatcher.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -717,21 +717,22 @@ class Dispatcher {
717717
};
718718

719719
this.actionsMap['multipageview'] = function () {
720-
const buttonElement = document.getElementById('multi-page-view');
721-
const imageElement = buttonElement.querySelector('img');
722-
let source = imageElement.src;
720+
if (app.activeDocument && app.activeDocument.activeView) {
721+
let commandState = false;
722+
if (app.activeDocument.activeView.type === 'ViewLayoutMultiPage') {
723+
app.activeDocument.activeView = new ViewLayoutWriter();
724+
} else {
725+
app.activeDocument.activeView = new ViewLayoutMultiPage();
726+
commandState = true;
727+
}
723728

724-
if (source.indexOf('twopages.svg') !== -1) {
725-
source = source.replace('twopages.svg', 'twopages_a.svg');
726-
app.activeDocument.activeView = new ViewLayoutMultiPage();
727-
} else {
728-
source = source.replace('twopages_a.svg', 'twopages.svg');
729-
app.activeDocument.activeView = new ViewLayoutWriter();
729+
app.map.fire('commandstatechanged', {
730+
commandName: 'multipageview',
731+
state: commandState ? 'true' : 'false',
732+
});
733+
app.activeDocument.activeView.sendClientVisibleArea();
734+
app.sectionContainer.requestReDraw();
730735
}
731-
732-
imageElement.src = source;
733-
app.activeDocument.activeView.sendClientVisibleArea();
734-
app.sectionContainer.requestReDraw();
735736
};
736737
}
737738

browser/src/layer/tile/CanvasTileLayer.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3613,11 +3613,9 @@ window.L.CanvasTileLayer = window.L.Layer.extend({
36133613

36143614
const size = [documentEndPos.x - documentPos.x, documentEndPos.y - documentPos.y];
36153615

3616-
if (app.activeDocument.activeView.type !== 'ViewLayoutMultiPage') {
3617-
app.activeDocument.activeView.viewedRectangle = new cool.SimpleRectangle(
3618-
documentPos.x * app.pixelsToTwips, documentPos.y * app.pixelsToTwips, size[0] * app.pixelsToTwips, size[1] * app.pixelsToTwips
3619-
);
3620-
}
3616+
app.activeDocument.activeView.viewedRectangle = new cool.SimpleRectangle(
3617+
documentPos.x * app.pixelsToTwips, documentPos.y * app.pixelsToTwips, size[0] * app.pixelsToTwips, size[1] * app.pixelsToTwips
3618+
);
36213619
},
36223620

36233621
pauseDrawing: function () {

browser/src/layer/tile/WriterTileLayer.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ window.L.WriterTileLayer = window.L.CanvasTileLayer.extend({
112112

113113
if (sizeChanged) {
114114
app.activeDocument.fileSize = new cool.SimplePoint(statusJSON.width, statusJSON.height);
115-
116-
// Views should be setting view size. But it has time.
117-
if (app.activeDocument.activeView.type !== 'ViewLayoutMultiPage')
118-
app.activeDocument.activeView.viewSize = app.activeDocument.fileSize.clone();
115+
app.activeDocument.activeView.viewSize = app.activeDocument.fileSize.clone();
119116

120117
this._docType = statusJSON.type;
121118
this._updateMaxBounds(true);

0 commit comments

Comments
 (0)