diff options
author | Andras Timar <andras.timar@collabora.com> | 2022-01-11 16:21:56 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-01-11 20:13:17 +0100 |
commit | 0dc3730568161ee61701cf2e61cd2afbffbab060 (patch) | |
tree | c4408ca5dca9c8a11ceffb47d1db425617ada43f | |
parent | calcRTL: don't negate X before computing display... (diff) | |
download | online-feature/calc-rtl.tar.gz online-feature/calc-rtl.zip |
js: added braces
feature/calc-rtl
Signed-off-by: Andras Timar <andras.timar@collabora.com>
Change-Id: I0cabe4764ed67b56d0c7a16f468b3ce517bd2230
-rw-r--r-- | browser/src/control/Control.AutofilterDropdown.js | 5 | ||||
-rw-r--r-- | browser/src/control/Control.ColumnHeader.js | 6 | ||||
-rw-r--r-- | browser/src/layer/marker/Cursor.ts | 5 | ||||
-rw-r--r-- | browser/src/layer/tile/CalcTileLayer.js | 18 | ||||
-rw-r--r-- | browser/src/layer/tile/CanvasSectionContainer.ts | 30 | ||||
-rw-r--r-- | browser/src/layer/tile/CanvasTileLayer.js | 3 | ||||
-rw-r--r-- | browser/src/layer/tile/CommentSection.ts | 3 | ||||
-rw-r--r-- | browser/src/layer/tile/TilesSection.ts | 3 | ||||
-rw-r--r-- | browser/src/layer/vector/Path.Transform.js | 6 | ||||
-rw-r--r-- | browser/src/layer/vector/SVGGroup.js | 6 | ||||
-rw-r--r-- | browser/src/layer/vector/SplitPanesSVG.js | 3 |
11 files changed, 58 insertions, 30 deletions
diff --git a/browser/src/control/Control.AutofilterDropdown.js b/browser/src/control/Control.AutofilterDropdown.js index 9a4514ea56..a5421f941b 100644 --- a/browser/src/control/Control.AutofilterDropdown.js +++ b/browser/src/control/Control.AutofilterDropdown.js @@ -131,8 +131,9 @@ L.Control.AutofilterDropdown = L.Control.extend({ top = top - splitPos.y; } - if (this._map._docLayer.isCalc() && this._map._docLayer.isLayoutRTL()) + if (this._map._docLayer.isCalc() && this._map._docLayer.isLayoutRTL()) { left = this._map._size.x - left; + } var mainContainer = null; var builder = null; @@ -245,4 +246,4 @@ L.Control.AutofilterDropdown = L.Control.extend({ L.control.autofilterDropdown = function (options) { return new L.Control.AutofilterDropdown(options); -};
\ No newline at end of file +}; diff --git a/browser/src/control/Control.ColumnHeader.js b/browser/src/control/Control.ColumnHeader.js index 5f9347a545..237a80a2b5 100644 --- a/browser/src/control/Control.ColumnHeader.js +++ b/browser/src/control/Control.ColumnHeader.js @@ -211,10 +211,12 @@ L.Control.ColumnHeader = L.Control.Header.extend({ var isRTL = this.isCalcRTL(); - if (isRTL) + if (isRTL) { width -= dragDistance[0]; - else + } + else { width += dragDistance[0]; + } width /= app.dpiScale; width = this._map._docLayer._pixelsToTwips({x: width, y: 0}).x; diff --git a/browser/src/layer/marker/Cursor.ts b/browser/src/layer/marker/Cursor.ts index a38ec1770f..d38c8bf1a7 100644 --- a/browser/src/layer/marker/Cursor.ts +++ b/browser/src/layer/marker/Cursor.ts @@ -240,8 +240,9 @@ class Cursor { } private transformX(xpos: number): number { - if (!this.isCalcRTL()) + if (!this.isCalcRTL()) { return xpos; + } return this.map._size.x - xpos; } @@ -286,4 +287,4 @@ class Cursor { } return customCursor; }; -}
\ No newline at end of file +} diff --git a/browser/src/layer/tile/CalcTileLayer.js b/browser/src/layer/tile/CalcTileLayer.js index d2062e33ef..c950318da1 100644 --- a/browser/src/layer/tile/CalcTileLayer.js +++ b/browser/src/layer/tile/CalcTileLayer.js @@ -531,14 +531,17 @@ L.CalcTileLayer = L.CanvasTileLayer.extend({ var cornerGroupSection = sectionContainer.getSectionWithName(L.CSections.CornerGroup.name); // Scroll section covers the entire document area, and needs RTL adjustments internally. - if (cornerGroupSection) + if (cornerGroupSection) { cornerGroupSection.anchor = ['top', 'right']; + } - if (rowGroupSection) + if (rowGroupSection) { rowGroupSection.anchor = [[L.CSections.CornerGroup.name, 'bottom', 'top'], 'right']; + } - if (columnGroupSection) + if (columnGroupSection) { columnGroupSection.anchor = ['top', [L.CSections.CornerGroup.name, '-left', 'right']]; + } cornerHeaderSection.anchor = [[L.CSections.ColumnGroup.name, 'bottom', 'top'], [L.CSections.RowGroup.name, '-left', 'right']]; @@ -567,14 +570,17 @@ L.CalcTileLayer = L.CanvasTileLayer.extend({ var rowGroupSection = sectionContainer.getSectionWithName(L.CSections.RowGroup.name); var cornerGroupSection = sectionContainer.getSectionWithName(L.CSections.CornerGroup.name); - if (cornerGroupSection) + if (cornerGroupSection) { cornerGroupSection.anchor = ['top', 'left']; + } - if (rowGroupSection) + if (rowGroupSection) { rowGroupSection.anchor = [[L.CSections.CornerGroup.name, 'bottom', 'top'], 'left']; + } - if (columnGroupSection) + if (columnGroupSection) { columnGroupSection.anchor = ['top', [L.CSections.CornerGroup.name, 'right', 'left']]; + } cornerHeaderSection.anchor = [[L.CSections.ColumnGroup.name, 'bottom', 'top'], [L.CSections.RowGroup.name, 'right', 'left']]; diff --git a/browser/src/layer/tile/CanvasSectionContainer.ts b/browser/src/layer/tile/CanvasSectionContainer.ts index 7259760ac5..e6edd700bd 100644 --- a/browser/src/layer/tile/CanvasSectionContainer.ts +++ b/browser/src/layer/tile/CanvasSectionContainer.ts @@ -1544,17 +1544,22 @@ class CanvasSectionContainer { return 0; } else { - if (targetEdge === 'top') // eslint-disable-line no-lonely-if + if (targetEdge === 'top') { // eslint-disable-line no-lonely-if return targetSection.myTopLeft[1] - app.roundedDpiScale; - else if (targetEdge === 'bottom') + } + else if (targetEdge === 'bottom') { return targetSection.myTopLeft[1] + targetSection.size[1] + app.roundedDpiScale; - else if (targetEdge === 'left') + } + else if (targetEdge === 'left') { return targetSection.myTopLeft[0] - app.roundedDpiScale; - else if (targetEdge === 'right') + } + else if (targetEdge === 'right') { return targetSection.myTopLeft[0] + targetSection.size[0] + app.roundedDpiScale; + } else if (targetEdge === '-left') { - if (section.expand[0] === 'left' && section.origSizeHint) + if (section.expand[0] === 'left' && section.origSizeHint) { section.size[0] = section.origSizeHint[0]; + } return targetSection.myTopLeft[0] - section.size[0]; } } @@ -1562,10 +1567,12 @@ class CanvasSectionContainer { else { // No target section is found. Use fallback. var anchor: string = section.anchor[index][count - 1]; - if (index === 0) + if (index === 0) { return anchor === 'top' ? section.position[1]: (this.bottom - (section.position[1] + section.size[1])); - else + } + else { return anchor === 'left' ? section.position[0]: (this.right - (section.position[0] + section.size[0])); + } } } } @@ -1880,16 +1887,19 @@ class CanvasSectionContainer { section.getTestDiv = function (): HTMLDivElement { var element: HTMLDivElement = <HTMLDivElement>document.getElementById('test-div-' + this.name); - if (element) + if (element) { return element; - else + } + else { return null; + } }; section.isCalcRTL = function (): boolean { const docLayer = section.sectionProperties.docLayer; - if (docLayer && docLayer.isCalc() && docLayer.isLayoutRTL()) + if (docLayer && docLayer.isCalc() && docLayer.isLayoutRTL()) { return true; + } return false; }; diff --git a/browser/src/layer/tile/CanvasTileLayer.js b/browser/src/layer/tile/CanvasTileLayer.js index 0cb3fe48c8..3f1c21afd8 100644 --- a/browser/src/layer/tile/CanvasTileLayer.js +++ b/browser/src/layer/tile/CanvasTileLayer.js @@ -3700,8 +3700,9 @@ L.CanvasTileLayer = L.Layer.extend({ } // restore the sign(negative) of x coordinate. - if (calcRTL) + if (calcRTL) { newPos.x = -newPos.x; + } param = { TransformPosX: { diff --git a/browser/src/layer/tile/CommentSection.ts b/browser/src/layer/tile/CommentSection.ts index 348f703ad6..9feebd7931 100644 --- a/browser/src/layer/tile/CommentSection.ts +++ b/browser/src/layer/tile/CommentSection.ts @@ -383,8 +383,9 @@ class Comment { const sizeX = this.sectionProperties.data.cellPos[2]; this.size = [Math.round(sizeX * ratio), Math.round(this.sectionProperties.data.cellPos[3] * ratio)]; let startX = this.sectionProperties.data.cellPos[0]; - if (this.isCalcRTL()) // Mirroring is done in setPosition + if (this.isCalcRTL()) { // Mirroring is done in setPosition startX += sizeX; // but adjust for width of the cell. + } this.setPosition(Math.round(this.sectionProperties.data.cellPos[0] * ratio), Math.round(this.sectionProperties.data.cellPos[1] * ratio)); } else if (this.sectionProperties.docLayer._docType === 'presentation' || this.sectionProperties.docLayer._docType === 'drawing') { diff --git a/browser/src/layer/tile/TilesSection.ts b/browser/src/layer/tile/TilesSection.ts index 08288ca614..6e6fab627c 100644 --- a/browser/src/layer/tile/TilesSection.ts +++ b/browser/src/layer/tile/TilesSection.ts @@ -141,8 +141,9 @@ class TilesSection { private afterDraw(canvasCtx: CanvasRenderingContext2D): void { const mirrorTile: boolean = this.isCalcRTL(); - if (mirrorTile) + if (mirrorTile) { canvasCtx.restore(); + } } drawTileInPane (tile: any, tileBounds: any, paneBounds: any, paneOffset: any, canvasCtx: CanvasRenderingContext2D, clearBackground: boolean) { diff --git a/browser/src/layer/vector/Path.Transform.js b/browser/src/layer/vector/Path.Transform.js index 56348197af..58b0facbe6 100644 --- a/browser/src/layer/vector/Path.Transform.js +++ b/browser/src/layer/vector/Path.Transform.js @@ -1042,8 +1042,9 @@ L.Handler.PathTransform = L.Handler.extend({ * @return {L.Point} */ _getEventLayerPoint: function (evt) { - if (!this.isCalcRTL()) + if (!this.isCalcRTL()) { return evt.layerPoint; + } var evtLatLng = this._map.negateLatLng(evt.latlng); return this._map.latLngToLayerPoint(evtLatLng); @@ -1054,8 +1055,9 @@ L.Handler.PathTransform = L.Handler.extend({ * @return {L.LatLng} */ _getEventLatLng: function (evt) { - if (!this.isCalcRTL()) + if (!this.isCalcRTL()) { return evt.latlng; + } return this._map.negateLatLng(evt.latlng); }, diff --git a/browser/src/layer/vector/SVGGroup.js b/browser/src/layer/vector/SVGGroup.js index 21b92d68d1..d86329505b 100644 --- a/browser/src/layer/vector/SVGGroup.js +++ b/browser/src/layer/vector/SVGGroup.js @@ -105,8 +105,9 @@ L.SVGGroup = L.Layer.extend({ this.dragging._onDragStart(data); var pos = this._map.mouseEventToLatLng(evt); - if (this.isCalcRTL()) + if (this.isCalcRTL()) { pos = this._map.negateLatLng(pos); + } this.fire('graphicmovestart', {pos: pos}); }, @@ -140,8 +141,9 @@ L.SVGGroup = L.Layer.extend({ if (this._map) { var pos = this._map.mouseEventToLatLng(evt); - if (this.isCalcRTL()) + if (this.isCalcRTL()) { pos = this._map.negateLatLng(pos); + } this.fire('graphicmoveend', {pos: pos}); } diff --git a/browser/src/layer/vector/SplitPanesSVG.js b/browser/src/layer/vector/SplitPanesSVG.js index 8e233c7da9..ce35bfad55 100644 --- a/browser/src/layer/vector/SplitPanesSVG.js +++ b/browser/src/layer/vector/SplitPanesSVG.js @@ -79,8 +79,9 @@ L.SplitPanesSVG = L.SplitPanesRenderer.extend({ // In RTL Calc mode this h-mirrors the top-left position of a rectangle else it does nothing. _transformContainerPoint: function (pos, size) { - if (this._isCalcRTL()) + if (this._isCalcRTL()) { return new L.Point(this._map._size.x - pos.x - size.x, pos.y); + } return pos; }, |