Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ONLYOFFICE/sdkjs into zeg…
Browse files Browse the repository at this point in the history
…enie-5.5.0
  • Loading branch information
ramezrafla committed Apr 18, 2020
2 parents 266d1d0 + acffa84 commit 09f0bea
Show file tree
Hide file tree
Showing 55 changed files with 1,316 additions and 825 deletions.
8 changes: 4 additions & 4 deletions build/build-desktop.bat
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
CD /D %~dp0
call npm install -g grunt-cli
call npm install
rem call grunt --level=WHITESPACE_ONLY --desktop=true --formatting=PRETTY_PRINT
call grunt --level=ADVANCED --desktop=true
call grunt --level=WHITESPACE_ONLY --desktop=true --formatting=PRETTY_PRINT
rem call grunt --level=ADVANCED --desktop=true

rmdir "..\..\core-ext\desktop-sdk-wrapper\test\build\win_64\Debug\editors\sdkjs"
xcopy /s/e/k/c/y/q/i "..\deploy\sdkjs" "..\..\core-ext\desktop-sdk-wrapper\test\build\win_64\debug\editors\sdkjs"
rmdir "..\..\desktop-apps\win-linux\build\debug\win_64\editors\sdkjs"
xcopy /s/e/k/c/y/q/i "..\deploy\sdkjs" "..\..\desktop-apps\win-linux\build\debug\win_64\editors\sdkjs"

pause
12 changes: 4 additions & 8 deletions cell/.unit-tests/FormulaTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8882,26 +8882,22 @@ $( function () {
oParser = new parserFormula( "INDEX(A651:C655,,2)", "A2", ws );
ok( oParser.parse() );
var parent = AscCommonExcel.g_oRangeCache.getAscRange(oParser.parent);
parent = {nCol: parent.c1, nRow: parent.r1, ws: ws};
strictEqual( oParser.simplifyRefType(oParser.calculate(), parent).getValue(), "#VALUE!" );
strictEqual( oParser.simplifyRefType(oParser.calculate(), ws, parent.r1, parent.c1).getValue(), "#VALUE!" );

oParser = new parserFormula( "INDEX(A651:C655,,2)", "D651", ws );
ok( oParser.parse() );
parent = AscCommonExcel.g_oRangeCache.getAscRange(oParser.parent);
parent = {nCol: parent.c1, nRow: parent.r1, ws: ws};
strictEqual( oParser.simplifyRefType(oParser.calculate(), parent).getValue(), 6 );
strictEqual( oParser.simplifyRefType(oParser.calculate(), ws, parent.r1, parent.c1).getValue(), 6 );

oParser = new parserFormula( "INDEX(A651:C655,,2)", "D652", ws );
ok( oParser.parse() );
parent = AscCommonExcel.g_oRangeCache.getAscRange(oParser.parent);
parent = {nCol: parent.c1, nRow: parent.r1, ws: ws};
strictEqual( oParser.simplifyRefType(oParser.calculate(), parent).getValue(), 7 );
strictEqual( oParser.simplifyRefType(oParser.calculate(), ws, parent.r1, parent.c1).getValue(), 7 );

oParser = new parserFormula( "INDEX(A651:C655,,3)", "E652", ws );
ok( oParser.parse() );
parent = AscCommonExcel.g_oRangeCache.getAscRange(oParser.parent);
parent = {nCol: parent.c1, nRow: parent.r1, ws: ws};
strictEqual( oParser.simplifyRefType(oParser.calculate(), parent).getValue(), 12 );
strictEqual( oParser.simplifyRefType(oParser.calculate(), ws, parent.r1, parent.c1).getValue(), 12 );

oParser = new parserFormula( "INDEX(A651:C655,,4)", "E652", ws );
ok( oParser.parse() );
Expand Down
25 changes: 13 additions & 12 deletions cell/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2572,7 +2572,7 @@ var editor;
var t = this;
AscCommon.sendImgUrls(this, [imageUrl], function(data) {

if (data && data[0])
if (data && data[0] && data[0].url !== "error")
{
var ws = t.wb.getWorksheet();
ws.objectRender.addImageDrawingObject([data[0].url], null);
Expand Down Expand Up @@ -2935,7 +2935,7 @@ var editor;

AscCommon.sendImgUrls(this, [sImageUrl], function (data) {

if (data && data[0]) {
if (data && data[0] && data[0].url !== "error") {
fReplaceCallback(data[0].url);
ws.objectRender.setGraphicObjectProps(props);
}
Expand Down Expand Up @@ -3144,6 +3144,10 @@ var editor;
var d = ws.changeSelectionStartPoint(dc, dr);
this.controller.scroll(d);
this.spellcheckState.lockSpell = false;
if(this.spellcheckState.afterReplace) {
History.EndTransaction();
this.spellcheckState.afterReplace = false;
}
}
this.spellcheckState.isStart = true;
this.spellcheckState.wordsIndex = e["wordsIndex"];
Expand Down Expand Up @@ -3257,7 +3261,6 @@ var editor;
break;
}
}
this.spellcheckState.afterReplace = afterReplace;
this.spellcheckState.lastIndex = lastIndex;
this.SpellCheck_CallBack(this.spellcheckState.lastSpellInfo);
return;
Expand Down Expand Up @@ -3394,6 +3397,9 @@ var editor;
options.replaceWith = newCellText;
options.replaceWords = replaceWords;

History.Create_NewPoint();
History.StartTransaction();

ws._replaceCellsText(cellsChange, options, false, function () {
t.spellcheckState.cellsChange = [];
options.indexInArray = 0;
Expand All @@ -3417,6 +3423,7 @@ var editor;
return;
}
t.spellcheckState.lockSpell = false;
History.EndTransaction();
});
};

Expand All @@ -3429,22 +3436,16 @@ var editor;
};

spreadsheet_api.prototype.asc_ignoreNumbers = function (isIgnore) {
this.spellcheckState.isIgnoreNumbers = true;
if (!isIgnore) {
this.spellcheckState.isIgnoreNumbers = false;
}
this.spellcheckState.isIgnoreNumbers = isIgnore;
};

spreadsheet_api.prototype.asc_ignoreUppercase = function (isIgnore) {
this.spellcheckState.isIgnoreUppercase = true;
if (!isIgnore) {
this.spellcheckState.isIgnoreUppercase = false;
}
this.spellcheckState.isIgnoreUppercase = isIgnore;
};

spreadsheet_api.prototype.asc_cancelSpellCheck = function() {
this.cleanSpelling();
}
};

// Frozen pane
spreadsheet_api.prototype.asc_freezePane = function () {
Expand Down
6 changes: 0 additions & 6 deletions cell/graphics/DrawingContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,16 +667,10 @@
};

DrawingContext.prototype.AddClipRect = function (x, y, w, h) {
if (window["IS_NATIVE_EDITOR"]) {
return this;
}
return this.save().beginPath().rect(x, y, w, h).clip();
};

DrawingContext.prototype.RemoveClipRect = function () {
if (window["IS_NATIVE_EDITOR"]) {
return this;
}
return this.restore();
};

Expand Down
5 changes: 0 additions & 5 deletions cell/model/CellInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@

/** @constructor */
function asc_CCellInfo() {
this.formula = "";
this.text = "";
this.halign = "left";
this.valign = "top";
Expand Down Expand Up @@ -284,9 +283,6 @@
this.isLockedHeaderFooter = false;
}

asc_CCellInfo.prototype.asc_getFormula = function () {
return this.formula;
};
asc_CCellInfo.prototype.asc_getText = function () {
return this.text;
};
Expand Down Expand Up @@ -496,7 +492,6 @@
window["AscCommonExcel"].asc_CCellInfo = asc_CCellInfo;
prot = asc_CCellInfo.prototype;
prot["asc_getName"] = prot.asc_getName;
prot["asc_getFormula"] = prot.asc_getFormula;
prot["asc_getText"] = prot.asc_getText;
prot["asc_getHorAlign"] = prot.asc_getHorAlign;
prot["asc_getVertAlign"] = prot.asc_getVertAlign;
Expand Down
178 changes: 121 additions & 57 deletions cell/model/DataValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,15 @@
}

this.type = EFormulaType.Formula;
this._formula = new AscCommonExcel.parserFormula(this.text, null, ws);
this._formula = new AscCommonExcel.parserFormula(this.text, this, ws);
this._formula.parse();
this._formula.buildDependencies();
};
CDataFormula.prototype.onFormulaEvent = function (type, eventData) {
if (AscCommon.c_oNotifyParentType.ChangeFormula === type) {
this.text = eventData.assemble;
}
};
CDataFormula.prototype.getValue = function(vt, ws, returnRaw) {
this._init(vt, ws);
if (EFormulaType.Formula === this.type) {
Expand All @@ -129,7 +135,7 @@
this.ranges = null;

this.allowBlank = false;
this.showDropDown = false;
this.showDropDown = false; // Excel considers this field to be a refusal to display
this.showErrorMessage = false;
this.showInputMessage = false;
this.type = EDataValidationType.None;
Expand All @@ -147,6 +153,14 @@
return this;
}

CDataValidation.prototype._init = function (ws) {
if (this.formula1) {
this.formula1._init(this.type, ws);
}
if (this.formula2) {
this.formula2._init(this.type, ws);
}
};
CDataValidation.prototype.clone = function() {
var res = new CDataValidation();
if (this.ranges) {
Expand Down Expand Up @@ -184,66 +198,110 @@
}
return false;
};
CDataValidation.prototype.checkValue = function (val, ws) {
var res = true;
if (this.showErrorMessage) {
val = (this.type === EDataValidationType.TextLength) ? AscCommonExcel.getFragmentsLength(val) : AscCommonExcel.getFragmentsText(val);
if (EDataValidationType.List === this.type) {
var list = this.formula1 && this.formula1.getValue(this.type, ws, false);
if (list && AscCommonExcel.cElementType.error !== list.type) {
if (AscCommonExcel.cElementType.string === list.type) {
list = list.getValue().split(AscCommon.FormulaSeparators.functionArgumentSeparatorDef);
res = -1 !== list.indexOf(val);
} else {
list = list.getRange();
if (list) {
res = false;
list._foreachNoEmpty(function (cell) {
// ToDo check cells type
if (!cell.isEmptyTextString() && cell.getValue() === val) {
res = true;
return null;
}
});
}
}
CDataValidation.prototype.checkValue = function (cell, ws) {
if (!this.showErrorMessage) {
return true;
}

var cellType = cell.getType();
var val = cell.getValueWithoutFormat();

if (EDataValidationType.List === this.type) {
var list = this._getListValues(ws);
var values = list[0];
if (!values) {
return false;
}
var datas = list[1];
if (datas) {
for (var i = 0; i < datas.length; ++i) {

}
} else {
return -1 !== datas.indexOf(val);
}
for (var i = 0; i < datas.length; ++i) {
if (datas[i].isEqualCell(cell)) {
return true;
}
} else if (EDataValidationType.Custom === this.type) {
}
} else if (EDataValidationType.Custom === this.type) {
return true;
} else {
if (EDataValidationType.TextLength === this.type) {
val = val.length;
} else {
if (AscCommon.CellValueType.Number !== cellType) {
return false;
}
val = Number(val);
if (!isNaN(val)) {
var v1 = this.formula1 && this.formula1.getValue(this.type, ws, true);
var v2 = this.formula2 && this.formula2.getValue(this.type, ws, true);
switch (this.operator) {
case EDataValidationOperator.Between:
res = v1 <= val && val <= v2;
break;
case EDataValidationOperator.NotBetween:
res = !(v1 <= val && val <= v2);
break;
case EDataValidationOperator.Equal:
res = v1 === val;
break;
case EDataValidationOperator.NotEqual:
res = v1 !== val;
break;
case EDataValidationOperator.LessThan:
res = v1 > val;
break;
case EDataValidationOperator.LessThanOrEqual:
res = v1 >= val;
break;
case EDataValidationOperator.GreaterThan:
res = v1 < val;
break;
case EDataValidationOperator.GreaterThanOrEqual:
res = v1 <= val;
break;
}

if (isNaN(val) || (EDataValidationType.Whole === this.type && (val >> 0) !== val)) {
return false;
}
}

var res = false;

var v1 = this.formula1 && this.formula1.getValue(this.type, ws, true);
var v2 = this.formula2 && this.formula2.getValue(this.type, ws, true);
switch (this.operator) {
case EDataValidationOperator.Between:
res = v1 <= val && val <= v2;
break;
case EDataValidationOperator.NotBetween:
res = !(v1 <= val && val <= v2);
break;
case EDataValidationOperator.Equal:
res = v1 === val;
break;
case EDataValidationOperator.NotEqual:
res = v1 !== val;
break;
case EDataValidationOperator.LessThan:
res = v1 > val;
break;
case EDataValidationOperator.LessThanOrEqual:
res = v1 >= val;
break;
case EDataValidationOperator.GreaterThan:
res = v1 < val;
break;
case EDataValidationOperator.GreaterThanOrEqual:
res = v1 <= val;
break;
}
return res;
}
return res;
return false;
};
CDataValidation.prototype._getListValues = function (ws) {
var aValue, aData;
var list = this.formula1 && this.formula1.getValue(this.type, ws, false);
if (list && AscCommonExcel.cElementType.error !== list.type) {
if (AscCommonExcel.cElementType.string === list.type) {
aValue = list.getValue().split(AscCommon.FormulaSeparators.functionArgumentSeparatorDef);
} else {
list = list.getRange();
if (list) {
aValue = [];
aData = [];
list._foreachNoEmpty(function (cell) {
if (!cell.isNullTextString()) {
aValue.push(cell.getValue());
aData.push(new AscCommonExcel.CCellValue(cell));
}
});
}
}
}
return [aValue, aData];
};
CDataValidation.prototype.isListValues = function () {
return (this.type === EDataValidationType.List && !this.showDropDown);
};
CDataValidation.prototype.getListValues = function (ws) {
return this.isListValues() ? this._getListValues(ws) : null;
};

CDataValidation.prototype.getError = function () {
Expand All @@ -266,13 +324,19 @@
return this;
}

CDataValidations.prototype.init = function (ws) {
for (var i = 0; i < this.elems.length; ++i) {
this.elems[i]._init(ws);
}
};
CDataValidations.prototype.clone = function() {
var i, res = new CDataValidations();
res.disablePrompts = this.disablePrompts;
res.xWindow = this.xWindow;
res.yWindow = this.yWindow;
for (i = 0; i < this.elems.length; ++i)
for (i = 0; i < this.elems.length; ++i) {
res.elems.push(this.elems[i].clone());
}
return res;
};

Expand Down
Loading

0 comments on commit 09f0bea

Please sign in to comment.