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

fix bug 32866

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