Commit fe0502b0 authored by Sergey Luzyanin's avatar Sergey Luzyanin

Merge branch 'develop' of https://github.com/ONLYOFFICE/sdkjs into develop

parents 47617874 442cfa53
......@@ -800,6 +800,33 @@ $( function () {
oParser = new parserFormula( "MAX(S5:S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
ws.getRange2( "S5" ).setValue( "#DIV/0!" );
ws.getRange2( "S6" ).setValue( "TRUE" );
ws.getRange2( "S7" ).setValue( "qwe" );
ws.getRange2( "S8" ).setValue( "" );
ws.getRange2( "S9" ).setValue( "-1" );
oParser = new parserFormula( "MAX(S5)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#DIV/0!" );
oParser = new parserFormula( "MAX(S6)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MAX(S7)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MAX(S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MAX(S5:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#DIV/0!" );
oParser = new parserFormula( "MAX(S6:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), -1 );
oParser = new parserFormula( "MAX(-1, TRUE)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
} );
test( "Test: \"MAXA\"", function () {
......@@ -812,6 +839,33 @@ $( function () {
oParser = new parserFormula( "MAXA(S5:S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
ws.getRange2( "S5" ).setValue( "#DIV/0!" );
ws.getRange2( "S6" ).setValue( "TRUE" );
ws.getRange2( "S7" ).setValue( "qwe" );
ws.getRange2( "S8" ).setValue( "" );
ws.getRange2( "S9" ).setValue( "-1" );
oParser = new parserFormula( "MAXA(S5)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#DIV/0!" );
oParser = new parserFormula( "MAXA(S6)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
oParser = new parserFormula( "MAXA(S7)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MAXA(S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MAXA(S5:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#DIV/0!" );
oParser = new parserFormula( "MAXA(S6:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
oParser = new parserFormula( "MAXA(-1, TRUE)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
} );
test( "Test: \"MIN\"", function () {
......@@ -824,6 +878,33 @@ $( function () {
oParser = new parserFormula( "MIN(S5:S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), -1 / Math.fact( 2 ) );
ws.getRange2( "S5" ).setValue( "#DIV/0!" );
ws.getRange2( "S6" ).setValue( "TRUE" );
ws.getRange2( "S7" ).setValue( "qwe" );
ws.getRange2( "S8" ).setValue( "" );
ws.getRange2( "S9" ).setValue( "2" );
oParser = new parserFormula( "MIN(S5)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#DIV/0!" );
oParser = new parserFormula( "MIN(S6)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MIN(S7)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MIN(S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MIN(S5:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#DIV/0!" );
oParser = new parserFormula( "MIN(S6:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 2 );
oParser = new parserFormula( "MIN(2, TRUE)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
} );
test( "Test: \"MINA\"", function () {
......@@ -836,6 +917,33 @@ $( function () {
oParser = new parserFormula( "MINA(S5:S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), -1 / Math.fact( 2 ) );
ws.getRange2( "S5" ).setValue( "#DIV/0!" );
ws.getRange2( "S6" ).setValue( "TRUE" );
ws.getRange2( "S7" ).setValue( "qwe" );
ws.getRange2( "S8" ).setValue( "" );
ws.getRange2( "S9" ).setValue( "2" );
oParser = new parserFormula( "MINA(S5)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#DIV/0!" );
oParser = new parserFormula( "MINA(S6)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
oParser = new parserFormula( "MINA(S7)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MINA(S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MINA(S5:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#DIV/0!" );
oParser = new parserFormula( "MINA(S6:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "MINA(2, TRUE)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
} );
test( "Test: SUM(S7:S9,{1,2,3})", function () {
......@@ -2051,7 +2159,29 @@ $( function () {
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
ws.getRange2( "S5" ).setValue( "#DIV/0!" );
ws.getRange2( "S6" ).setValue( "TRUE" );
ws.getRange2( "S7" ).setValue( "qwe" );
ws.getRange2( "S8" ).setValue( "" );
ws.getRange2( "S9" ).setValue( "2" );
oParser = new parserFormula( "COUNT(S5)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "COUNT(S6)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "COUNT(S7)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "COUNT(S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "COUNT(S5:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
oParser = new parserFormula( "COUNT(S6:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
} );
test( "Test: \"COUNTA\"", function () {
......@@ -2078,7 +2208,29 @@ $( function () {
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 2 );
ws.getRange2( "S5" ).setValue( "#DIV/0!" );
ws.getRange2( "S6" ).setValue( "TRUE" );
ws.getRange2( "S7" ).setValue( "qwe" );
ws.getRange2( "S8" ).setValue( "" );
ws.getRange2( "S9" ).setValue( "2" );
oParser = new parserFormula( "COUNTA(S5)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
oParser = new parserFormula( "COUNTA(S6)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
oParser = new parserFormula( "COUNTA(S7)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 1 );
oParser = new parserFormula( "COUNTA(S8)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( "COUNTA(S5:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 4 );
oParser = new parserFormula( "COUNTA(S6:S9)", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 3 );
} );
test( "Test: \"COUNTIF\"", function () {
......
......@@ -2690,7 +2690,7 @@ cMAX.prototype.Calculate = function ( arg ) {
if ( argI instanceof cRef || argI instanceof cRef3D ) {
if ( argIVal instanceof cError )
return this.value = argIVal;
if ( argIVal instanceof cNumber || argIVal instanceof cBool || argIVal instanceof cEmpty ) {
if ( argIVal instanceof cNumber ) {
var v = argIVal.tocNumber();
if ( v.getValue() > max )
max = v.getValue();
......@@ -2699,7 +2699,7 @@ cMAX.prototype.Calculate = function ( arg ) {
else if ( argI instanceof cArea || argI instanceof cArea3D ) {
var argArr = argI.getValue();
for ( var j = 0; j < argArr.length; j++ ) {
if ( argArr[j] instanceof cNumber || argArr[j] instanceof cBool || argArr[j] instanceof cEmpty ) {
if ( argArr[j] instanceof cNumber ) {
var v = argArr[j].tocNumber();
if ( v.getValue() > max )
max = v.getValue();
......@@ -2742,7 +2742,7 @@ cMAX.prototype.Calculate = function ( arg ) {
max = argI.getValue();
}
}
return this.value = ( max.value === Number.NEGATIVE_INFINITY ? new cNumber( 0 ) : new cNumber( max ) );
return this.value = ( max === Number.NEGATIVE_INFINITY ? new cNumber( 0 ) : new cNumber( max ) );
};
cMAX.prototype.getInfo = function () {
return {
......@@ -2832,7 +2832,7 @@ cMAXA.prototype.Calculate = function ( arg ) {
max = argI.getValue();
}
}
return this.value = ( max.value === Number.NEGATIVE_INFINITY ? new cNumber( 0 ) : new cNumber( max ) )
return this.value = ( max === Number.NEGATIVE_INFINITY ? new cNumber( 0 ) : new cNumber( max ) )
};
cMAXA.prototype.getInfo = function () {
return {
......@@ -2954,7 +2954,7 @@ cMIN.prototype.Calculate = function ( arg ) {
if ( argI instanceof cRef || argI instanceof cRef3D ) {
if ( argIVal instanceof cError )
return this.value = argIVal;
if ( argIVal instanceof cNumber || argIVal instanceof cBool || argIVal instanceof cEmpty ) {
if ( argIVal instanceof cNumber ) {
var v = argIVal.tocNumber();
if ( v.getValue() < min )
min = v.getValue();
......@@ -2963,7 +2963,7 @@ cMIN.prototype.Calculate = function ( arg ) {
else if ( argI instanceof cArea || argI instanceof cArea3D ) {
var argArr = argI.getValue();
for ( var j = 0; j < argArr.length; j++ ) {
if ( argArr[j] instanceof cNumber || argArr[j] instanceof cBool || argArr[j] instanceof cEmpty ) {
if ( argArr[j] instanceof cNumber ) {
var v = argArr[j].tocNumber();
if ( v.getValue() < min )
min = v.getValue();
......@@ -3007,7 +3007,7 @@ cMIN.prototype.Calculate = function ( arg ) {
min = argI.getValue();
}
}
return this.value = ( min.value === Number.POSITIVE_INFINITY ? new cNumber( 0 ) : new cNumber( min ) );
return this.value = ( min === Number.POSITIVE_INFINITY ? new cNumber( 0 ) : new cNumber( min ) );
};
cMIN.prototype.getInfo = function () {
return {
......@@ -3099,7 +3099,7 @@ cMINA.prototype.Calculate = function ( arg ) {
min = argI.getValue();
}
}
return this.value = ( min.value === Number.POSITIVE_INFINITY ? new cNumber( 0 ) : new cNumber( min ) );
return this.value = ( min === Number.POSITIVE_INFINITY ? new cNumber( 0 ) : new cNumber( min ) );
};
cMINA.prototype.getInfo = function () {
return {
......
......@@ -1825,6 +1825,19 @@
asc_CCompleteMenu.prototype.asc_getName = function () {return this.name;};
asc_CCompleteMenu.prototype.asc_getType = function () {return this.type;};
function CCacheMeasureEmpty() {
this.cache = {};
}
CCacheMeasureEmpty.prototype.add = function (elem, val) {
var font = (this.cache[elem.fn] || (this.cache[elem.fn] = {}));
font[elem.fs] = val;
};
CCacheMeasureEmpty.prototype.get = function (elem) {
var font = this.cache[elem.fn];
return font ? font[elem.fs] : null;
};
var g_oCacheMeasureEmpty = new CCacheMeasureEmpty();
/*
* Export
* -----------------------------------------------------------------------------
......@@ -1987,4 +2000,6 @@
prot = asc_CCompleteMenu.prototype;
prot["asc_getName"] = prot.asc_getName;
prot["asc_getType"] = prot.asc_getType;
window["AscCommonExcel"].g_oCacheMeasureEmpty = g_oCacheMeasureEmpty;
})(window);
......@@ -4472,10 +4472,14 @@
// Пустая ячейка с измененной гарнитурой или размером, учитвается в высоте
str = c.getValue2();
if (0 < str.length) {
// Без текста не будет толка
strCopy = [str[0].clone()];
strCopy[0].text = 'A';
tm = this._roundTextMetrics(this.stringRender.measureString(strCopy, fl));
strCopy = str[0];
if (!(tm = AscCommonExcel.g_oCacheMeasureEmpty.get(strCopy))) {
// Без текста не будет толка
strCopy = strCopy.clone();
strCopy.text = 'A';
tm = this._roundTextMetrics(this.stringRender.measureString([strCopy], fl));
AscCommonExcel.g_oCacheMeasureEmpty.add(strCopy, tm);
}
this._updateRowHeight(tm, col, row, isMerged, fMergedRows);
}
}
......
......@@ -38,7 +38,7 @@ AscCommon.baseEditorsApi.prototype._onEndPermissions = function () {
if (null !== this.licenseResult) {
var type = this.licenseResult['type'];
oResult.setLicenseType(type);
oResult.setCanBranding(Asc.c_oLicenseResult.Error !== type); // Для тех, у кого есть лицензия, branding доступен
oResult.setCanBranding(this.licenseResult['branding']);
oResult.setIsLight(this.licenseResult['light']);
oResult.setTrial(this.licenseResult['trial']);
oResult.setRights(this.licenseResult['rights']);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment