mirror of
https://github.com/webodf/WebODF.git
synced 2026-12-01 16:56:05 +01:00
Add a number of more precise types and remove unneeded casts.
This commit is contained in:
@@ -253,7 +253,7 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Text} e
|
||||
* @param {!CompositionEvent} e
|
||||
*/
|
||||
function compositionEnd(e) {
|
||||
lastCompositionData = e.data;
|
||||
|
||||
@@ -313,6 +313,7 @@ gui.SessionViewOptions = function () {
|
||||
|
||||
/**
|
||||
* @param {!ops.OdtCursor} cursor
|
||||
* @return {undefined}
|
||||
*/
|
||||
function onCursorAdded(cursor) {
|
||||
var memberId = cursor.getMemberId(),
|
||||
@@ -332,6 +333,7 @@ gui.SessionViewOptions = function () {
|
||||
|
||||
/**
|
||||
* @param {!ops.OdtCursor} cursor
|
||||
* @return {undefined}
|
||||
*/
|
||||
function onCursorMoved(cursor) {
|
||||
var memberId = cursor.getMemberId(),
|
||||
|
||||
@@ -87,10 +87,16 @@ gui.UndoStateRules = function UndoStateRules() {
|
||||
|
||||
/**
|
||||
* @param {!ops.Operation} op
|
||||
* @return {number}
|
||||
* @return {number|undefined}
|
||||
*/
|
||||
function getOpPosition(op) {
|
||||
return op.spec().position;
|
||||
var key = "position",
|
||||
spec = op.spec(),
|
||||
value;
|
||||
if (spec.hasOwnProperty(key)) {
|
||||
value = /**@type{number}*/(spec[key]);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -291,7 +291,7 @@ ops.OdtDocument = function OdtDocument(odfCanvas) {
|
||||
* Convert a cursor range to a DOM range
|
||||
* @param {!number} position
|
||||
* @param {!number} length
|
||||
* @return {Range}
|
||||
* @return {!Range}
|
||||
*/
|
||||
this.convertCursorToDomRange = function (position, length) {
|
||||
var range = getDOMDocument().createRange(),
|
||||
@@ -841,7 +841,7 @@ ops.OdtDocument = function OdtDocument(odfCanvas) {
|
||||
this.moveCursor = function (memberid, position, length, selectionType) {
|
||||
var cursor = cursors[memberid],
|
||||
selectionRange = self.convertCursorToDomRange(position, length);
|
||||
if (cursor && selectionRange) {
|
||||
if (cursor) {
|
||||
cursor.setSelectedRange(selectionRange, length >= 0);
|
||||
cursor.setSelectionType(selectionType || ops.OdtCursor.RangeSelection);
|
||||
}
|
||||
|
||||
@@ -192,6 +192,9 @@ ops.OpAddAnnotation = function OpAddAnnotation() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpAddAnnotation.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "AddAnnotation",
|
||||
|
||||
@@ -76,6 +76,9 @@ ops.OpAddCursor = function OpAddCursor() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpAddCursor.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "AddCursor",
|
||||
|
||||
@@ -69,6 +69,9 @@ ops.OpAddMember = function OpAddMember() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpAddMember.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "AddMember",
|
||||
|
||||
@@ -103,6 +103,9 @@ ops.OpAddStyle = function OpAddStyle() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpAddStyle.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "AddStyle",
|
||||
|
||||
@@ -106,7 +106,7 @@ ops.OpApplyDirectStyling = function OpApplyDirectStyling() {
|
||||
*/
|
||||
this.execute = function (document) {
|
||||
var odtDocument = /**@type{ops.OdtDocument}*/(document),
|
||||
range = /**@type{!Range}*/(odtDocument.convertCursorToDomRange(position, length)),
|
||||
range = odtDocument.convertCursorToDomRange(position, length),
|
||||
impactedParagraphs = odfUtils.getParagraphElements(range);
|
||||
|
||||
applyStyle(odtDocument, range, setProperties);
|
||||
@@ -127,6 +127,9 @@ ops.OpApplyDirectStyling = function OpApplyDirectStyling() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpApplyDirectStyling.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "ApplyDirectStyling",
|
||||
|
||||
@@ -92,7 +92,7 @@ ops.OpApplyHyperlink = function OpApplyHyperlink() {
|
||||
this.execute = function (document) {
|
||||
var odtDocument = /**@type{ops.OdtDocument}*/(document),
|
||||
ownerDocument = odtDocument.getDOMDocument(),
|
||||
range = /**@type{!Range}*/(odtDocument.convertCursorToDomRange(position, length)),
|
||||
range = odtDocument.convertCursorToDomRange(position, length),
|
||||
boundaryNodes = domUtils.splitBoundaries(range),
|
||||
/**@type{!Array.<!Element>}*/
|
||||
modifiedParagraphs = [],
|
||||
@@ -133,6 +133,9 @@ ops.OpApplyHyperlink = function OpApplyHyperlink() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpApplyHyperlink.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "ApplyHyperlink",
|
||||
|
||||
@@ -128,6 +128,9 @@ ops.OpInsertImage = function OpInsertImage() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpInsertImage.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "InsertImage",
|
||||
|
||||
@@ -185,6 +185,9 @@ ops.OpInsertTable = function OpInsertTable() {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpInsertTable.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "InsertTable",
|
||||
|
||||
@@ -225,6 +225,9 @@ ops.OpInsertText = function OpInsertText() {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpInsertText.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "InsertText",
|
||||
|
||||
@@ -74,12 +74,15 @@ ops.OpMoveCursor = function OpMoveCursor() {
|
||||
}
|
||||
|
||||
selectedRange = odtDocument.convertCursorToDomRange(position, length);
|
||||
cursor.setSelectedRange(/**@type{!Range}*/(selectedRange), length >= 0);
|
||||
cursor.setSelectedRange(selectedRange, length >= 0);
|
||||
cursor.setSelectionType(selectionType);
|
||||
odtDocument.emit(ops.OdtDocument.signalCursorMoved, cursor);
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpMoveCursor.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "MoveCursor",
|
||||
|
||||
@@ -114,6 +114,9 @@ ops.OpRemoveAnnotation = function OpRemoveAnnotation() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpRemoveAnnotation.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "RemoveAnnotation",
|
||||
|
||||
@@ -68,6 +68,9 @@ ops.OpRemoveBlob = function OpRemoveBlob() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpRemoveBlob.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "RemoveBlob",
|
||||
|
||||
@@ -70,6 +70,9 @@ ops.OpRemoveCursor = function OpRemoveCursor() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpRemoveCursor.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "RemoveCursor",
|
||||
|
||||
@@ -81,6 +81,9 @@ ops.OpRemoveHyperlink = function OpRemoveHyperlink() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpRemoveHyperlink.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "RemoveHyperlink",
|
||||
|
||||
@@ -61,6 +61,9 @@ ops.OpRemoveMember = function OpRemoveMember() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpRemoveMember.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "RemoveMember",
|
||||
|
||||
@@ -78,6 +78,9 @@ ops.OpRemoveStyle = function OpRemoveStyle() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpRemoveStyle.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "RemoveStyle",
|
||||
|
||||
@@ -239,7 +239,7 @@ ops.OpRemoveText = function OpRemoveText() {
|
||||
odtDocument.upgradeWhitespacesAtPosition(position + length);
|
||||
|
||||
range = odtDocument.convertCursorToDomRange(position, length);
|
||||
domUtils.splitBoundaries(/**@type{!Range}*/(range));
|
||||
domUtils.splitBoundaries(range);
|
||||
paragraphElement = odtDocument.getParagraphElement(range.startContainer);
|
||||
textNodes = odfUtils.getTextElements(range, false, true);
|
||||
paragraphs = odfUtils.getParagraphElements(range);
|
||||
@@ -280,6 +280,9 @@ ops.OpRemoveText = function OpRemoveText() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpRemoveText.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "RemoveText",
|
||||
|
||||
@@ -70,6 +70,9 @@ ops.OpSetBlob = function OpSetBlob() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpSetBlob.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "SetBlob",
|
||||
|
||||
@@ -91,6 +91,9 @@ ops.OpSetParagraphStyle = function OpSetParagraphStyle() {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpSetParagraphStyle.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "SetParagraphStyle",
|
||||
|
||||
@@ -191,6 +191,9 @@ ops.OpSplitParagraph = function OpSplitParagraph() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpSplitParagraph.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "SplitParagraph",
|
||||
|
||||
@@ -101,6 +101,9 @@ ops.OpUpdateMember = function OpUpdateMember() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpUpdateMember.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "UpdateMember",
|
||||
|
||||
@@ -88,6 +88,9 @@ ops.OpUpdateMetadata = function OpUpdateMetadata() {
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpUpdateMetadata.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "UpdateMetadata",
|
||||
|
||||
@@ -143,6 +143,9 @@ ops.OpUpdateParagraphStyle = function OpUpdateParagraphStyle() {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* @return {!ops.OpUpdateParagraphStyle.Spec}
|
||||
*/
|
||||
this.spec = function () {
|
||||
return {
|
||||
optype: "UpdateParagraphStyle",
|
||||
|
||||
@@ -74,6 +74,6 @@ ops.Operation.prototype.group;
|
||||
ops.Operation.prototype.execute = function (document) {"use strict"; };
|
||||
|
||||
/**
|
||||
* @return {!{optype:string,memberid:string,timestamp:number,position:number}}
|
||||
* @return {!{optype:string,memberid:string,timestamp:number}}
|
||||
*/
|
||||
ops.Operation.prototype.spec = function () {"use strict"; };
|
||||
|
||||
Reference in New Issue
Block a user