Skip to content

Commit 56d61e5

Browse files
committed
browser: ts: type window.app and fix all errrors
Signed-off-by: Dennis Francis <[email protected]> Change-Id: Iab0d9b55006689bac3e1f532fb94320ad2da7262
1 parent a406e60 commit 56d61e5

17 files changed

+177
-109
lines changed

browser/src/app/CellSelectionMarkerMiddleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class CellSelectionMarkers {
3939
this.start.setShowSection(true);
4040
this.end.setShowSection(true);
4141

42+
Util.ensureValue(app.calc.cellCursorRectangle);
4243
var cellRectangle = app.map._docLayer._cellSelectionArea
4344
? app.map._docLayer._cellSelectionArea.clone()
4445
: app.calc.cellCursorRectangle.clone();

browser/src/app/Log.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
* Logger contains methods for logging the activity
1313
*/
1414

15-
type Direction = 'INCOMING' | 'OUTGOING';
1615
interface LogMsg {
1716
msg: string;
18-
direction: Direction;
17+
direction: string;
1918
time: number;
2019
}
2120

@@ -28,7 +27,7 @@ class Logger {
2827
this.startTime = null;
2928
}
3029

31-
public log(msg: string, direction: Direction): void {
30+
public log(msg: string, direction: string): void {
3231
const time = Date.now();
3332
if (!this.startTime) this.startTime = time;
3433

browser/src/app/SearchService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class SearchService {
7373

7474
window.L.Map.THIS.fire('clearselection');
7575

76+
Util.ensureValue(app.activeDocument);
7677
var searchStartPointX = app.activeDocument.activeLayout.viewedRectangle.x1;
7778
var searchStartPointY = app.activeDocument.activeLayout.viewedRectangle.y1;
7879
if (

browser/src/app/TextSelectionMiddleware.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ class TextSelections {
102102
var endPos = { x: this.endRectangle.pX1, y: this.endRectangle.pY2 };
103103

104104
if (app.map._docLayer.isCalcRTL()) {
105+
Util.ensureValue(app.activeDocument);
105106
// Mirror position from right to left.
106107
startPos.x =
107108
app.activeDocument.activeLayout.viewedRectangle.pX2 -

browser/src/app/iface/Map.Interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ interface MapInterface extends Evented {
8585

8686
_clip: ClipboardInterface;
8787

88-
setPermission(permission: 'edit' | 'readonly' | 'view'): void;
88+
setPermission(permission: string): void;
8989
onLockFailed(reason: string): void;
9090
updateModificationIndicator(newModificationTime: string): void;
9191
isEditMode(): boolean;

browser/src/canvas/sections/AutoFillBaseSection.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class AutoFillBaseSection extends CanvasSectionObject {
6969
protected setMarkerPosition() {
7070
var center: number = 0;
7171
if (!(<any>window).mode.isDesktop()) {
72+
Util.ensureValue(app.calc.cellCursorRectangle);
7273
center = app.calc.cellCursorRectangle.pWidth * 0.5;
7374
}
7475

@@ -198,6 +199,7 @@ class AutoFillBaseSection extends CanvasSectionObject {
198199
}
199200

200201
protected autoScroll(point: cool.SimplePoint) {
202+
Util.ensureValue(app.activeDocument);
201203
const viewedRectangle = app.activeDocument.activeLayout.viewedRectangle;
202204
const viewCenter = viewedRectangle.pCenter;
203205
const refX =

browser/src/canvas/sections/InvalidationRectangleSection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class InvalidationRectangleSection extends CanvasSectionObject {
4949
this.context.strokeStyle = 'red';
5050

5151
const anchor: number[] = this.containerObject.getDocumentAnchor();
52+
Util.ensureValue(app.activeDocument);
5253
const xDiff =
5354
anchor[0] - app.activeDocument.activeLayout.viewedRectangle.pX1;
5455
const yDiff =

browser/src/canvas/sections/MouseControl.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class MouseControl extends CanvasSectionObject {
7575
modifier: number,
7676
) {
7777
let viewToDocumentPos = point.clone();
78+
Util.ensureValue(app.activeDocument);
7879

7980
// Convert to pure canvas html element coordinate.
8081
viewToDocumentPos.pX +=
@@ -121,6 +122,7 @@ class MouseControl extends CanvasSectionObject {
121122

122123
// Gets the mouse position on browser page in CSS pixels.
123124
public getMousePagePosition() {
125+
Util.ensureValue(app.activeDocument);
124126
const boundingClientRectangle = this.context.canvas.getBoundingClientRect();
125127
const pagePosition = this.currentPosition.clone();
126128
pagePosition.pX -=
@@ -141,6 +143,7 @@ class MouseControl extends CanvasSectionObject {
141143
}
142144

143145
private refreshPosition(point: cool.SimplePoint) {
146+
Util.ensureValue(app.activeDocument);
144147
let topLeftX = app.activeDocument.activeLayout.viewedRectangle.pX1;
145148
let topLeftY = app.activeDocument.activeLayout.viewedRectangle.pY1;
146149

@@ -161,6 +164,7 @@ class MouseControl extends CanvasSectionObject {
161164
else if (app.map._docLayer._docType === 'spreadsheet') {
162165
const textCursor =
163166
app.file.textCursor.visible &&
167+
app.calc.cellCursorRectangle &&
164168
app.calc.cellCursorRectangle.pContainsPoint(
165169
this.currentPosition.pToArray(),
166170
);
@@ -202,6 +206,8 @@ class MouseControl extends CanvasSectionObject {
202206
this.amplitude[1] * Math.exp(-elapsed / 650),
203207
];
204208

209+
Util.ensureValue(app.activeDocument);
210+
205211
if (Math.abs(delta[0]) > 0.2 || Math.abs(delta[1]) > 0.2) {
206212
app.activeDocument.activeLayout.scrollTo(
207213
app.activeDocument.activeLayout.viewedRectangle.pX1 + delta[0],
@@ -291,6 +297,7 @@ class MouseControl extends CanvasSectionObject {
291297
diff.x -= this.positionOnMouseDown.x;
292298
diff.y -= this.positionOnMouseDown.y;
293299

300+
Util.ensureValue(app.activeDocument);
294301
const viewedRectangle =
295302
app.activeDocument.activeLayout.viewedRectangle.clone();
296303

@@ -399,10 +406,11 @@ class MouseControl extends CanvasSectionObject {
399406
else if (app.map._docLayer._docType === 'spreadsheet') {
400407
const acceptInput =
401408
app.calc.cellCursorVisible &&
409+
app.calc.cellCursorRectangle &&
402410
app.calc.cellCursorRectangle.containsPoint(
403411
this.currentPosition.toArray(),
404412
);
405-
return acceptInput;
413+
return acceptInput as boolean;
406414
} else return false;
407415
}
408416

browser/src/canvas/sections/OtherViewCursorSection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class TextCursorSection extends HTMLObjectSection {
6060
}
6161

6262
if (result && app.file.textCursor.visible) {
63+
Util.ensureValue(app.file.textCursor.rectangle);
6364
const pos = [
6465
app.file.textCursor.rectangle.pX1,
6566
app.file.textCursor.rectangle.pY1,

browser/src/canvas/sections/ShapeHandleScalingSubSection.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ class ShapeHandleScalingSubSection extends CanvasSectionObject {
347347

348348
// While dragging a handle, we want to simulate handles to their final positions.
349349
moveHandlesOnDrag(point: cool.SimplePoint, e: MouseEvent) {
350+
Util.ensureValue(app.activeDocument);
350351
const shapeRecProps = this.calculateNewShapeRectangleProperties([
351352
point.pX + this.myTopLeft[0] + app.activeDocument.activeLayout.viewedRectangle.pX1 - this.containerObject.getDocumentAnchor()[0],
352353
point.pY + this.myTopLeft[1] + app.activeDocument.activeLayout.viewedRectangle.pY1 - this.containerObject.getDocumentAnchor()[1]

0 commit comments

Comments
 (0)