Commit 851cd12a authored by Alexander.Trofimov's avatar Alexander.Trofimov

fix bug 32866

parent 00ccb924
...@@ -1047,13 +1047,16 @@ cArea.prototype.isValid = function () { ...@@ -1047,13 +1047,16 @@ cArea.prototype.isValid = function () {
var r = this.getRange(); var r = this.getRange();
return !!r; return !!r;
}; };
cArea.prototype.countCells = function () { cArea.prototype.countCells = function () {
var r = this.getRange(), bbox = r.bbox, count = (Math.abs(bbox.c1 - bbox.c2) + 1) * (Math.abs(bbox.r1 - bbox.r2) + 1); var r = this.getRange(), bbox = r.bbox, count = (Math.abs(bbox.c1 - bbox.c2) + 1) *
r._foreachNoEmpty( function () { (Math.abs(bbox.r1 - bbox.r2) + 1);
count--; r._foreachNoEmpty(function (cell) {
} ); if (!cell || !cell.isEmptyTextString()) {
return new cNumber( count ); count--;
}; }
});
return new cNumber(count);
};
cArea.prototype.foreach = function ( action ) { cArea.prototype.foreach = function ( action ) {
var r = this.getRange(); var r = this.getRange();
if ( r ) { if ( r ) {
...@@ -1292,36 +1295,33 @@ cArea3D.prototype.isValid = function () { ...@@ -1292,36 +1295,33 @@ cArea3D.prototype.isValid = function () {
} }
return true; return true;
}; };
cArea3D.prototype.countCells = function () { cArea3D.prototype.countCells = function () {
var _wsA = this.wsRange(); var _wsA = this.wsRange();
var _val = []; var _val = [];
if ( _wsA.length < 1 ) { if (_wsA.length < 1) {
_val.push( new cError( cErrorType.bad_reference ) ); _val.push(new cError(cErrorType.bad_reference));
return _val; return _val;
} }
for ( var i = 0; i < _wsA.length; i++ ) { var i;
if ( !_wsA[i] ) { for (i = 0; i < _wsA.length; i++) {
_val.push( new cError( cErrorType.bad_reference ) ); if (!_wsA[i]) {
return _val; _val.push(new cError(cErrorType.bad_reference));
} return _val;
}
}
var _r = this.range(_wsA), bbox = _r[0].bbox, count = (Math.abs(bbox.c1 - bbox.c2) + 1) *
(Math.abs(bbox.r1 - bbox.r2) + 1);
count = _r.length * count;
for ( var i = 0; i < _r.length; i++ ) {
_r[i]._foreachNoEmpty( function ( _cell ) {
if ( _cell.getType() === CellValueType.Number && _cell.getValueWithoutFormat() === "" ) {
return null;
}
count--; }
return !null; var _r = this.range(_wsA), bbox = _r[0].bbox, count = (Math.abs(bbox.c1 - bbox.c2) + 1) *
} ); (Math.abs(bbox.r1 - bbox.r2) + 1);
} count = _r.length * count;
return new cNumber( count ); for (i = 0; i < _r.length; i++) {
}; _r[i]._foreachNoEmpty(function (cell) {
if (!cell || !cell.isEmptyTextString()) {
count--;
}
});
}
return new cNumber(count);
};
cArea3D.prototype.getMatrix = function () { cArea3D.prototype.getMatrix = function () {
var arr = [], r = this.getRange(), res; var arr = [], r = this.getRange(), res;
for (var k = 0; k < r.length; k++) { for (var k = 0; k < r.length; k++) {
......
...@@ -1107,43 +1107,37 @@ cCOUNTA.prototype.getInfo = function () { ...@@ -1107,43 +1107,37 @@ cCOUNTA.prototype.getInfo = function () {
}; };
}; };
function cCOUNTBLANK() { function cCOUNTBLANK() {
// cBaseFunction.call( this, "COUNTBLANK" ); this.name = "COUNTBLANK";
// this.setArgumentsMin( 1 ); this.type = cElementType.func;
// this.setArgumentsMax( 1 ); this.value = null;
// this.setFormat( this.formatType.noneFormat ); this.argumentsMin = 1;
this.argumentsCurrent = 0;
this.name = "COUNTBLANK"; this.argumentsMax = 1;
this.type = cElementType.func; this.formatType = {
this.value = null; def: -1, //подразумевается формат первой ячейки входящей в формулу.
this.argumentsMin = 1; noneFormat: -2
this.argumentsCurrent = 0; };
this.argumentsMax = 1; this.numFormat = this.formatType.noneFormat;
this.formatType = {
def:-1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat:-2
};
this.numFormat = this.formatType.noneFormat;
}
cCOUNTBLANK.prototype = Object.create( cBaseFunction.prototype );
cCOUNTBLANK.prototype.Calculate = function ( arg ) {
var arg0 = arg[0];
if ( arg0 instanceof cArea || arg0 instanceof cArea3D )
return this.value = arg0.countCells();
else if ( arg0 instanceof cRef || arg0 instanceof cRef3D ) {
return this.value = new cNumber( 1 );
} }
else
return this.value = new cError( cErrorType.bad_reference ); cCOUNTBLANK.prototype = Object.create(cBaseFunction.prototype);
}; cCOUNTBLANK.prototype.Calculate = function (arg) {
cCOUNTBLANK.prototype.getInfo = function () { var arg0 = arg[0];
return { if (arg0 instanceof cArea || arg0 instanceof cArea3D) {
name:this.name, return this.value = arg0.countCells();
args:"( argument-list )" } else if (arg0 instanceof cRef || arg0 instanceof cRef3D) {
return this.value = new cNumber(1);
} else {
return this.value = new cError(cErrorType.bad_reference);
}
};
cCOUNTBLANK.prototype.getInfo = function () {
return {
name: this.name, args: "( argument-list )"
};
}; };
};
function cCOUNTIF() { function cCOUNTIF() {
this.name = "COUNTIF"; this.name = "COUNTIF";
......
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