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