Commit d18dfb21 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Поправил проблему с getValue у cArea

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@59915 954022d7-b5bf-4e40-9824-e11837661b57
parent d5753ea7
...@@ -32,7 +32,7 @@ cFormulaFunction.LookupAndReference = { ...@@ -32,7 +32,7 @@ cFormulaFunction.LookupAndReference = {
'RTD':cRTD, 'RTD':cRTD,
'TRANSPOSE':cTRANSPOSE, 'TRANSPOSE':cTRANSPOSE,
'VLOOKUP':cVLOOKUP 'VLOOKUP':cVLOOKUP
} };
function cADDRESS() { function cADDRESS() {
// cBaseFunction.call( this, "ADDRESS" ); // cBaseFunction.call( this, "ADDRESS" );
...@@ -161,7 +161,7 @@ function cCHOOSE() { ...@@ -161,7 +161,7 @@ function cCHOOSE() {
} }
cCHOOSE.prototype = Object.create( cBaseFunction.prototype ) cCHOOSE.prototype = Object.create( cBaseFunction.prototype );
cCHOOSE.prototype.Calculate = function ( arg ) { cCHOOSE.prototype.Calculate = function ( arg ) {
var arg0 = arg[0]; var arg0 = arg[0];
...@@ -183,13 +183,13 @@ cCHOOSE.prototype.Calculate = function ( arg ) { ...@@ -183,13 +183,13 @@ cCHOOSE.prototype.Calculate = function ( arg ) {
} }
return this.value = new cError( cErrorType.wrong_value_type ); return this.value = new cError( cErrorType.wrong_value_type );
} };
cCHOOSE.prototype.getInfo = function () { cCHOOSE.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( index , argument-list )" args:"( index , argument-list )"
}; };
} };
function cCOLUMN() { function cCOLUMN() {
// cBaseFunction.call( this, "COLUMN" ); // cBaseFunction.call( this, "COLUMN" );
...@@ -210,7 +210,7 @@ function cCOLUMN() { ...@@ -210,7 +210,7 @@ function cCOLUMN() {
} }
cCOLUMN.prototype = Object.create( cBaseFunction.prototype ) cCOLUMN.prototype = Object.create( cBaseFunction.prototype );
cCOLUMN.prototype.Calculate = function ( arg ) { cCOLUMN.prototype.Calculate = function ( arg ) {
var arg0; var arg0;
if ( this.argumentsCurrent == 0 ) { if ( this.argumentsCurrent == 0 ) {
...@@ -236,13 +236,13 @@ cCOLUMN.prototype.Calculate = function ( arg ) { ...@@ -236,13 +236,13 @@ cCOLUMN.prototype.Calculate = function ( arg ) {
} }
else else
return this.value = new cError( cErrorType.bad_reference ); return this.value = new cError( cErrorType.bad_reference );
} };
cCOLUMN.prototype.getInfo = function () { cCOLUMN.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( [ reference ] )" args:"( [ reference ] )"
}; };
} };
function cCOLUMNS() { function cCOLUMNS() {
// cBaseFunction.call( this, "COLUMNS" ); // cBaseFunction.call( this, "COLUMNS" );
...@@ -263,7 +263,7 @@ function cCOLUMNS() { ...@@ -263,7 +263,7 @@ function cCOLUMNS() {
} }
cCOLUMNS.prototype = Object.create( cBaseFunction.prototype ) cCOLUMNS.prototype = Object.create( cBaseFunction.prototype );
cCOLUMNS.prototype.Calculate = function ( arg ) { cCOLUMNS.prototype.Calculate = function ( arg ) {
var arg0 = arg[0]; var arg0 = arg[0];
if ( arg0 instanceof cArray ) { if ( arg0 instanceof cArray ) {
...@@ -282,13 +282,13 @@ cCOLUMNS.prototype.Calculate = function ( arg ) { ...@@ -282,13 +282,13 @@ cCOLUMNS.prototype.Calculate = function ( arg ) {
} }
else else
return this.value = new cError( cErrorType.wrong_value_type ); return this.value = new cError( cErrorType.wrong_value_type );
} };
cCOLUMNS.prototype.getInfo = function () { cCOLUMNS.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( array )" args:"( array )"
}; };
} };
function cGETPIVOTDATA() { function cGETPIVOTDATA() {
cBaseFunction.call( this, "GETPIVOTDATA" ); cBaseFunction.call( this, "GETPIVOTDATA" );
...@@ -317,7 +317,7 @@ function cHLOOKUP() { ...@@ -317,7 +317,7 @@ function cHLOOKUP() {
} }
cHLOOKUP.prototype = Object.create( cBaseFunction.prototype ) cHLOOKUP.prototype = Object.create( cBaseFunction.prototype );
cHLOOKUP.prototype.Calculate = function ( arg ) { cHLOOKUP.prototype.Calculate = function ( arg ) {
var arg0 = arg[0], arg1 = arg[1], arg2 = arg[2], arg3 = this.argumentsCurrent == 4 ? arg[3].tocBool() : new cBool( true ); var arg0 = arg[0], arg1 = arg[1], arg2 = arg[2], arg3 = this.argumentsCurrent == 4 ? arg[3].tocBool() : new cBool( true );
var numberRow = arg2.getValue() - 1, valueForSearching = arg0.getValue(), resC = -1, min, regexp; var numberRow = arg2.getValue() - 1, valueForSearching = arg0.getValue(), resC = -1, min, regexp;
...@@ -354,7 +354,7 @@ cHLOOKUP.prototype.Calculate = function ( arg ) { ...@@ -354,7 +354,7 @@ cHLOOKUP.prototype.Calculate = function ( arg ) {
// range._foreachColNoEmpty( /*func for col*/ null, /*func for cell in col*/ f ); // range._foreachColNoEmpty( /*func for col*/ null, /*func for cell in col*/ f );
} }
else if ( arg1 instanceof cArea3D ) { else if ( arg1 instanceof cArea3D ) {
var range = arg1.getRange()[0], ws = arg1.getWS() var range = arg1.getRange()[0], ws = arg1.getWS();
bb = range.getBBox0(); bb = range.getBBox0();
if ( numberRow > bb.r2 - bb.r1 ) if ( numberRow > bb.r2 - bb.r1 )
return this.value = new cError( cErrorType.bad_reference ); return this.value = new cError( cErrorType.bad_reference );
...@@ -393,7 +393,7 @@ cHLOOKUP.prototype.Calculate = function ( arg ) { ...@@ -393,7 +393,7 @@ cHLOOKUP.prototype.Calculate = function ( arg ) {
} }
min = Math.min( min, elem.getValue() ); min = Math.min( min, elem.getValue() );
} ) } );
if ( min > valueForSearching ) { if ( min > valueForSearching ) {
return this.value = new cError( cErrorType.not_available ); return this.value = new cError( cErrorType.not_available );
...@@ -421,27 +421,28 @@ cHLOOKUP.prototype.Calculate = function ( arg ) { ...@@ -421,27 +421,28 @@ cHLOOKUP.prototype.Calculate = function ( arg ) {
var c = new CellAddress( bb.r1 + numberRow, resC, 0 ); var c = new CellAddress( bb.r1 + numberRow, resC, 0 );
var v = arg1.getWS()._getCellNoEmpty( c.getRow0(), c.getCol0() ) var v = arg1.getWS()._getCellNoEmpty( c.getRow0(), c.getCol0() );
if ( v ) if ( v )
v = v.getValueWithoutFormat(); v = v.getValueWithoutFormat();
else else
v = ""; v = "";
return this.value = checkTypeCell( v ); return this.value = checkTypeCell( v );
} };
cHLOOKUP.prototype.getInfo = function () { cHLOOKUP.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( lookup-value , table-array , row-index-num [ , [ range-lookup-flag ] ] )" args:"( lookup-value , table-array , row-index-num [ , [ range-lookup-flag ] ] )"
}; };
} };
function cHYPERLINK() { function cHYPERLINK() {
cBaseFunction.call( this, "HYPERLINK" ); cBaseFunction.call( this, "HYPERLINK" );
} }
cHYPERLINK.prototype = Object.create( cBaseFunction.prototype ) cHYPERLINK.prototype = Object.create( cBaseFunction.prototype );
/** @constructor */
function cINDEX() { function cINDEX() {
// cBaseFunction.call( this, "INDEX" ); // cBaseFunction.call( this, "INDEX" );
...@@ -485,7 +486,7 @@ cINDEX.prototype.Calculate = function ( arg ) { ...@@ -485,7 +486,7 @@ cINDEX.prototype.Calculate = function ( arg ) {
} }
if (arg0 instanceof cArray || arg0 instanceof cArea) { if (arg0 instanceof cArray || arg0 instanceof cArea) {
res = arg0.getValue(arg1.getValue() - 1, arg2.getValue() - 1); res = arg0.getValue2(arg1.getValue() - 1, arg2.getValue() - 1);
} else { } else {
res = arg0.tryConvert(); res = arg0.tryConvert();
} }
...@@ -497,8 +498,9 @@ cINDEX.prototype.getInfo = function () { ...@@ -497,8 +498,9 @@ cINDEX.prototype.getInfo = function () {
name:this.name, name:this.name,
args:"( array , [ row-number ] [ , [ column-number ] ] ) " + this.name + "( reference , [ row-number ] [ , [ column-number ] [ , [ area-number ] ] ] )" args:"( array , [ row-number ] [ , [ column-number ] ] ) " + this.name + "( reference , [ row-number ] [ , [ column-number ] [ , [ area-number ] ] ] )"
}; };
} };
/** @constructor */
function cINDIRECT() { function cINDIRECT() {
// cBaseFunction.call( this, "INDIRECT" ); // cBaseFunction.call( this, "INDIRECT" );
// this.setArgumentsMin( 1 ); // this.setArgumentsMin( 1 );
...@@ -695,10 +697,8 @@ cLOOKUP.prototype.Calculate = function ( arg ) { ...@@ -695,10 +697,8 @@ cLOOKUP.prototype.Calculate = function ( arg ) {
return this.value = new cError( cErrorType.not_available ); return this.value = new cError( cErrorType.not_available );
} }
var c = new CellAddress( BBox.r1 + resR, BBox.c1 + resC ) var c = new CellAddress( BBox.r1 + resR, BBox.c1 + resC );
return this.value = checkTypeCell( _arg2.getWS()._getCellNoEmpty( c.getRow0(), c.getCol0() ).getValueWithoutFormat() ); return this.value = checkTypeCell( _arg2.getWS()._getCellNoEmpty( c.getRow0(), c.getCol0() ).getValueWithoutFormat() );
} }
else { else {
var arg1Range = arg1.getRange(), arg2Range = arg2.getRange(); var arg1Range = arg1.getRange(), arg2Range = arg2.getRange();
...@@ -708,28 +708,25 @@ cLOOKUP.prototype.Calculate = function ( arg ) { ...@@ -708,28 +708,25 @@ cLOOKUP.prototype.Calculate = function ( arg ) {
if ( arg1 instanceof cArea3D ) { if ( arg1 instanceof cArea3D ) {
arg1Range = arg1.getMatrix()[0]; arg1Range = arg1.getMatrix()[0];
// arg1Range = arg1Range[0];
} }
else if ( arg1 instanceof cArea ) { else if ( arg1 instanceof cArea ) {
arg1Range = arg1.getMatrix(); arg1Range = arg1.getMatrix();
} }
if ( arg2 instanceof cArea3D ) { if ( arg2 instanceof cArea3D ) {
arg2Range = arg2.getMatrix()[0]; arg2Range = arg2.getMatrix()[0];
// arg2Range = arg2Range[0];
} }
else if ( arg2 instanceof cArea ) { else if ( arg2 instanceof cArea ) {
arg2Range = arg2.getMatrix(); arg2Range = arg2.getMatrix();
} }
var index = _func.binarySearch( arg0, function () { var index = _func.binarySearch( arg0, function () {
var a = [] var a = [];
for ( var i = 0; i < arg1Range.length; i++ ) { for ( var i = 0; i < arg1Range.length; i++ ) {
a.push( arg1Range[i][0] ) a.push( arg1Range[i][0] )
} }
return a; return a;
}() ) }() );
if ( index < 0 ) return this.value = new cError( cErrorType.not_available ); if ( index < 0 ) return this.value = new cError( cErrorType.not_available );
...@@ -749,17 +746,14 @@ cLOOKUP.prototype.Calculate = function ( arg ) { ...@@ -749,17 +746,14 @@ cLOOKUP.prototype.Calculate = function ( arg ) {
else else
return this.value = new cRef( arg1.ws.getCell3( (b.r1 - 1) + index, (b.c1 - 1) + 0 ).getName(), arg1.ws ); return this.value = new cRef( arg1.ws.getCell3( (b.r1 - 1) + index, (b.c1 - 1) + 0 ).getName(), arg1.ws );
} }
return this.value = arg2.getValue()[index];
} }
};
}
cLOOKUP.prototype.getInfo = function () { cLOOKUP.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( lookup-value , lookup-vector , result-vector )" args:"( lookup-value , lookup-vector , result-vector )"
}; };
} };
function cMATCH() { function cMATCH() {
...@@ -778,7 +772,7 @@ function cMATCH() { ...@@ -778,7 +772,7 @@ function cMATCH() {
this.numFormat = this.formatType.def; this.numFormat = this.formatType.def;
} }
cMATCH.prototype = Object.create( cBaseFunction.prototype ) cMATCH.prototype = Object.create( cBaseFunction.prototype );
cMATCH.prototype.Calculate = function ( arg ) { cMATCH.prototype.Calculate = function ( arg ) {
var arg0 = arg[0], arg1 = arg[1], arg2 = arg[2] ? arg[2] : new cNumber( 1 ); var arg0 = arg[0], arg1 = arg[1], arg2 = arg[2] ? arg[2] : new cNumber( 1 );
...@@ -882,13 +876,13 @@ cMATCH.prototype.Calculate = function ( arg ) { ...@@ -882,13 +876,13 @@ cMATCH.prototype.Calculate = function ( arg ) {
return this.value = findMatch( arg0, arg1, arg2 ) return this.value = findMatch( arg0, arg1, arg2 )
} };
cMATCH.prototype.getInfo = function () { cMATCH.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( lookup-value , lookup-array [ , [ match-type ]] )" args:"( lookup-value , lookup-array [ , [ match-type ]] )"
}; };
} };
function cOFFSET() { function cOFFSET() {
// cBaseFunction.call( this, "OFFSET" ); // cBaseFunction.call( this, "OFFSET" );
...@@ -1049,7 +1043,7 @@ function cROW() { ...@@ -1049,7 +1043,7 @@ function cROW() {
} }
cROW.prototype = Object.create( cBaseFunction.prototype ) cROW.prototype = Object.create( cBaseFunction.prototype );
cROW.prototype.Calculate = function ( arg ) { cROW.prototype.Calculate = function ( arg ) {
var arg0; var arg0;
if ( this.argumentsCurrent == 0 ) { if ( this.argumentsCurrent == 0 ) {
...@@ -1075,13 +1069,13 @@ cROW.prototype.Calculate = function ( arg ) { ...@@ -1075,13 +1069,13 @@ cROW.prototype.Calculate = function ( arg ) {
} }
else else
return this.value = new cError( cErrorType.bad_reference ); return this.value = new cError( cErrorType.bad_reference );
} };
cROW.prototype.getInfo = function () { cROW.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( [ reference ] )" args:"( [ reference ] )"
}; };
} };
function cROWS() { function cROWS() {
// cBaseFunction.call( this, "ROWS" ); // cBaseFunction.call( this, "ROWS" );
...@@ -1102,7 +1096,7 @@ function cROWS() { ...@@ -1102,7 +1096,7 @@ function cROWS() {
} }
cROWS.prototype = Object.create( cBaseFunction.prototype ) cROWS.prototype = Object.create( cBaseFunction.prototype );
cROWS.prototype.Calculate = function ( arg ) { cROWS.prototype.Calculate = function ( arg ) {
var arg0 = arg[0]; var arg0 = arg[0];
if ( arg0 instanceof cArray ) { if ( arg0 instanceof cArray ) {
...@@ -1121,19 +1115,19 @@ cROWS.prototype.Calculate = function ( arg ) { ...@@ -1121,19 +1115,19 @@ cROWS.prototype.Calculate = function ( arg ) {
} }
else else
return this.value = new cError( cErrorType.wrong_value_type ); return this.value = new cError( cErrorType.wrong_value_type );
} };
cROWS.prototype.getInfo = function () { cROWS.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( array )" args:"( array )"
}; };
} };
function cRTD() { function cRTD() {
cBaseFunction.call( this, "RTD" ); cBaseFunction.call( this, "RTD" );
} }
cRTD.prototype = Object.create( cBaseFunction.prototype ) cRTD.prototype = Object.create( cBaseFunction.prototype );
function cTRANSPOSE() { function cTRANSPOSE() {
// cBaseFunction.call( this, "TRANSPOSE" ); // cBaseFunction.call( this, "TRANSPOSE" );
...@@ -1152,7 +1146,7 @@ function cTRANSPOSE() { ...@@ -1152,7 +1146,7 @@ function cTRANSPOSE() {
} }
cTRANSPOSE.prototype = Object.create( cBaseFunction.prototype ) cTRANSPOSE.prototype = Object.create( cBaseFunction.prototype );
cTRANSPOSE.prototype.Calculate = function ( arg ) { cTRANSPOSE.prototype.Calculate = function ( arg ) {
function TransposeMatrix( A ) { function TransposeMatrix( A ) {
...@@ -1186,13 +1180,13 @@ cTRANSPOSE.prototype.Calculate = function ( arg ) { ...@@ -1186,13 +1180,13 @@ cTRANSPOSE.prototype.Calculate = function ( arg ) {
return this.value = TransposeMatrix( arg0 ); return this.value = TransposeMatrix( arg0 );
} };
cTRANSPOSE.prototype.getInfo = function () { cTRANSPOSE.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( array )" args:"( array )"
}; };
} };
function VHLOOKUPCache( bHor ) { function VHLOOKUPCache( bHor ) {
this.cacheId = {}; this.cacheId = {};
......
...@@ -92,7 +92,7 @@ function cABS() { ...@@ -92,7 +92,7 @@ function cABS() {
} }
cABS.prototype = Object.create( cBaseFunction.prototype ) cABS.prototype = Object.create( cBaseFunction.prototype );
cABS.prototype.Calculate = function ( arg ) { cABS.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 ) {
...@@ -115,13 +115,13 @@ cABS.prototype.Calculate = function ( arg ) { ...@@ -115,13 +115,13 @@ cABS.prototype.Calculate = function ( arg ) {
return this.value = new cNumber( Math.abs( arg0.getValue() ) ); return this.value = new cNumber( Math.abs( arg0.getValue() ) );
} }
return this.value = arg0; return this.value = arg0;
} };
cABS.prototype.getInfo = function () { cABS.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( x )" args:"( x )"
} }
} };
function cACOS() { function cACOS() {
// cBaseFunction.call( this, "ACOS" ); // cBaseFunction.call( this, "ACOS" );
...@@ -142,7 +142,7 @@ function cACOS() { ...@@ -142,7 +142,7 @@ function cACOS() {
} }
cACOS.prototype = Object.create( cBaseFunction.prototype ) cACOS.prototype = Object.create( cBaseFunction.prototype );
cACOS.prototype.Calculate = function ( arg ) { cACOS.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 ) {
...@@ -167,13 +167,13 @@ cACOS.prototype.Calculate = function ( arg ) { ...@@ -167,13 +167,13 @@ cACOS.prototype.Calculate = function ( arg ) {
return this.value = isNaN( a ) ? new cError( cErrorType.not_numeric ) : new cNumber( a ); return this.value = isNaN( a ) ? new cError( cErrorType.not_numeric ) : new cNumber( a );
} }
return this.value = arg0; return this.value = arg0;
} };
cACOS.prototype.getInfo = function () { cACOS.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( x )" args:"( x )"
}; };
} };
function cACOSH() { function cACOSH() {
// cBaseFunction.call( this, "ACOSH" ); // cBaseFunction.call( this, "ACOSH" );
......
...@@ -503,46 +503,10 @@ cArea.prototype.getValue = function () { ...@@ -503,46 +503,10 @@ cArea.prototype.getValue = function () {
} }
return val; return val;
}; };
cArea.prototype.getValue2 = function ( cell ) { cArea.prototype.getValue2 = function (i, j) {
var val = [], r = this.getRange(); var r = this.getRange();
if ( !r ) { var cell = r.worksheet._getCellNoEmpty(r.bbox.r1 + i, r.bbox.c1 + j);
val.push( new cError( cErrorType.bad_reference ) ); return this._parseCellValue(cell);
}
else {
r._foreachNoEmpty( function ( cellData ) {
if ( cell.getID() === cellData.getName() ) {
var cellType = cellData.getType();
switch(cellType){
case CellValueType.Number:
cellData.getValueWithoutFormat() === "" ? val.push( new cEmpty() ) : val.push( new cNumber( cellData.getValueWithoutFormat() ) );
break;
case CellValueType.Bool:
val.push( new cBool( cellData.getValueWithoutFormat() ) );
break;
case CellValueType.Error:
val.push( new cError( cellData.getValueWithoutFormat() ) );
break;
case CellValueType.String:
val.push( new cString( cellData.getValueWithoutFormat() ) );
break;
default:
if ( cellData.getValueWithoutFormat() && cellData.getValueWithoutFormat() !== "" ) {
val.push( new cNumber( cellData.getValueWithoutFormat() ) );
}
else {
val.push( checkTypeCell( "" + cellData.getValueWithoutFormat() ) );
}
}
}
} );
}
if ( val[0] === undefined || val[0] === null ) {
return new cEmpty();
}
else {
return val[0];
}
}; };
cArea.prototype.getRange = function () { cArea.prototype.getRange = function () {
if( !this.range ){ if( !this.range ){
...@@ -596,24 +560,18 @@ cArea.prototype.getBBox0 = function () { ...@@ -596,24 +560,18 @@ cArea.prototype.getBBox0 = function () {
}; };
cArea.prototype.cross = function ( arg ) { cArea.prototype.cross = function ( arg ) {
var r = this.getRange(), cross; var r = this.getRange(), cross;
if ( !r ) { if (!r) {
return new cError( cErrorType.wrong_name ); return new cError(cErrorType.wrong_name);
} }
cross = r.cross( arg ); cross = r.cross(arg);
if ( cross ) { if (cross) {
if ( cross.r != undefined ) { if (cross.r != undefined) {
return this.getValue2( new CellAddress( cross.r, this.getBBox().c1 ) ); return this.getValue2(cross.r - this.getBBox().r1, 0);
} } else if (cross.c != undefined) {
else if ( cross.c != undefined ) { return this.getValue2(0, cross.c - this.getBBox().c1);
return this.getValue2( new CellAddress( this.getBBox().r1, cross.c ) );
}
else {
return new cError( cErrorType.wrong_value_type );
} }
} }
else { return new cError(cErrorType.wrong_value_type);
return new cError( cErrorType.wrong_value_type );
}
}; };
cArea.prototype.isValid = function () { cArea.prototype.isValid = function () {
var r = this.getRange(); var r = this.getRange();
...@@ -662,17 +620,12 @@ cArea.prototype.foreach2 = function ( action ) { ...@@ -662,17 +620,12 @@ cArea.prototype.foreach2 = function ( action ) {
}); });
} }
}; };
cArea.prototype.getValue = function (i, j) {
var r = this.getRange();
var cell = r.worksheet._getCellNoEmpty(r.bbox.r1 + i, r.bbox.c1 + j);
return this._parseCellValue(cell);
};
cArea.prototype.getMatrix = function () { cArea.prototype.getMatrix = function () {
var t = this, arr = [], r = this.getRange(); var t = this, arr = [], r = this.getRange();
r._foreach2( function ( cell, i, j, r1, c1 ) { r._foreach2( function ( cell, i, j, r1, c1 ) {
if (!arr[i - r1]) if (!arr[i - r1])
arr[i - r1] = []; arr[i - r1] = [];
arr[i - r1][j - c1] = t._parseCellValue(); arr[i - r1][j - c1] = t._parseCellValue(cell);
} ); } );
return arr; return arr;
}; };
...@@ -1401,7 +1354,7 @@ cArray.prototype.isValidArray = function () { ...@@ -1401,7 +1354,7 @@ cArray.prototype.isValidArray = function () {
} }
return true; return true;
}; };
cArray.prototype.getValue = function (i, j) { cArray.prototype.getValue2 = function (i, j) {
var result = this.array[i]; var result = this.array[i];
return result ? result[j] : result; return result ? result[j] : result;
}; };
...@@ -1417,6 +1370,7 @@ cArray.prototype.fillFromArray = function ( arr ) { ...@@ -1417,6 +1370,7 @@ cArray.prototype.fillFromArray = function ( arr ) {
} }
}; };
/** @constructor */
function cUndefined(){this.value = undefined;} function cUndefined(){this.value = undefined;}
cUndefined.prototype = Object.create( cBaseType.prototype ); cUndefined.prototype = Object.create( cBaseType.prototype );
...@@ -1603,6 +1557,7 @@ cBaseFunction.prototype = { ...@@ -1603,6 +1557,7 @@ cBaseFunction.prototype = {
} }
}; };
/** @constructor */
function parentLeft() { function parentLeft() {
this.name = "("; this.name = "(";
this.type = cElementType.operator; this.type = cElementType.operator;
...@@ -1629,6 +1584,7 @@ parentLeft.prototype.Assemble2 = function ( arg, start, count ) { ...@@ -1629,6 +1584,7 @@ parentLeft.prototype.Assemble2 = function ( arg, start, count ) {
return new cString( "(" + arg[start + count - 1] + ")" ); return new cString( "(" + arg[start + count - 1] + ")" );
}; };
/** @constructor */
function parentRight() { function parentRight() {
this.name = ")"; this.name = ")";
this.type = cElementType.operator; this.type = cElementType.operator;
...@@ -1639,6 +1595,7 @@ parentRight.prototype.toString = function () { ...@@ -1639,6 +1595,7 @@ parentRight.prototype.toString = function () {
return this.name; return this.name;
}; };
/** @constructor */
function cUnarMinusOperator() { function cUnarMinusOperator() {
cBaseOperator.apply( this, ['un_minus'/**name operator*/, 50/**priority of operator*/, 1/**count arguments*/] ); cBaseOperator.apply( this, ['un_minus'/**name operator*/, 50/**priority of operator*/, 1/**count arguments*/] );
this.isRightAssociative = true; this.isRightAssociative = true;
...@@ -1672,6 +1629,7 @@ cUnarMinusOperator.prototype.Assemble2 = function ( arg, start, count ) { ...@@ -1672,6 +1629,7 @@ cUnarMinusOperator.prototype.Assemble2 = function ( arg, start, count ) {
return new cString( "-" + arg[start + count - 1] ); return new cString( "-" + arg[start + count - 1] );
}; };
/** @constructor */
function cUnarPlusOperator() { function cUnarPlusOperator() {
cBaseOperator.apply( this, ['un_plus', 50, 1] ); cBaseOperator.apply( this, ['un_plus', 50, 1] );
this.isRightAssociative = true; this.isRightAssociative = true;
...@@ -1696,6 +1654,7 @@ cUnarPlusOperator.prototype.Assemble2 = function ( arg, start, count ) { ...@@ -1696,6 +1654,7 @@ cUnarPlusOperator.prototype.Assemble2 = function ( arg, start, count ) {
return new cString( "+" + arg[start + count - 1] ); return new cString( "+" + arg[start + count - 1] );
}; };
/** @constructor */
function cAddOperator() { function cAddOperator() {
cBaseOperator.apply( this, ['+', 20] ); cBaseOperator.apply( this, ['+', 20] );
} }
...@@ -1715,6 +1674,7 @@ cAddOperator.prototype.Calculate = function ( arg ) { ...@@ -1715,6 +1674,7 @@ cAddOperator.prototype.Calculate = function ( arg ) {
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "+", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "+", arguments[1].first );
}; };
/** @constructor */
function cMinusOperator() { function cMinusOperator() {
cBaseOperator.apply( this, ['-', 20] ); cBaseOperator.apply( this, ['-', 20] );
} }
...@@ -1733,6 +1693,7 @@ cMinusOperator.prototype.Calculate = function ( arg ) { ...@@ -1733,6 +1693,7 @@ cMinusOperator.prototype.Calculate = function ( arg ) {
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "-", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "-", arguments[1].first );
}; };
/** @constructor */
function cPercentOperator() { function cPercentOperator() {
cBaseOperator.apply( this, ['%', 45, 1] ); cBaseOperator.apply( this, ['%', 45, 1] );
this.isRightAssociative = true; this.isRightAssociative = true;
...@@ -1765,6 +1726,7 @@ cPercentOperator.prototype.Assemble2 = function ( arg, start, count ) { ...@@ -1765,6 +1726,7 @@ cPercentOperator.prototype.Assemble2 = function ( arg, start, count ) {
return new cString( arg[start + count - 1] + this.name ); return new cString( arg[start + count - 1] + this.name );
}; };
/** @constructor */
function cPowOperator() { function cPowOperator() {
cBaseOperator.apply( this, ['^', 40] ); cBaseOperator.apply( this, ['^', 40] );
} }
...@@ -1797,6 +1759,7 @@ cPowOperator.prototype.Calculate = function ( arg ) { ...@@ -1797,6 +1759,7 @@ cPowOperator.prototype.Calculate = function ( arg ) {
return this.value = new cNumber( _v ); return this.value = new cNumber( _v );
}; };
/** @constructor */
function cMultOperator() { function cMultOperator() {
cBaseOperator.apply( this, ['*', 30] ); cBaseOperator.apply( this, ['*', 30] );
} }
...@@ -1815,6 +1778,7 @@ cMultOperator.prototype.Calculate = function ( arg ) { ...@@ -1815,6 +1778,7 @@ cMultOperator.prototype.Calculate = function ( arg ) {
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "*", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "*", arguments[1].first );
}; };
/** @constructor */
function cDivOperator() { function cDivOperator() {
cBaseOperator.apply( this, ['/', 30] ); cBaseOperator.apply( this, ['/', 30] );
} }
...@@ -1833,6 +1797,7 @@ cDivOperator.prototype.Calculate = function ( arg ) { ...@@ -1833,6 +1797,7 @@ cDivOperator.prototype.Calculate = function ( arg ) {
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "/", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "/", arguments[1].first );
}; };
/** @constructor */
function cConcatSTROperator() { function cConcatSTROperator() {
cBaseOperator.apply( this, ['&', 15] ); cBaseOperator.apply( this, ['&', 15] );
} }
...@@ -1854,6 +1819,7 @@ cConcatSTROperator.prototype.Calculate = function ( arg ) { ...@@ -1854,6 +1819,7 @@ cConcatSTROperator.prototype.Calculate = function ( arg ) {
new cString( arg0.toString().concat( arg1.toString() ) ); new cString( arg0.toString().concat( arg1.toString() ) );
}; };
/** @constructor */
function cEqualsOperator() { function cEqualsOperator() {
cBaseOperator.apply( this, ['=', 10] ); cBaseOperator.apply( this, ['=', 10] );
} }
...@@ -1872,6 +1838,7 @@ cEqualsOperator.prototype.Calculate = function ( arg ) { ...@@ -1872,6 +1838,7 @@ cEqualsOperator.prototype.Calculate = function ( arg ) {
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "=", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "=", arguments[1].first );
}; };
/** @constructor */
function cNotEqualsOperator() { function cNotEqualsOperator() {
cBaseOperator.apply( this, ['<>', 10] ); cBaseOperator.apply( this, ['<>', 10] );
} }
...@@ -1890,6 +1857,7 @@ cNotEqualsOperator.prototype.Calculate = function ( arg ) { ...@@ -1890,6 +1857,7 @@ cNotEqualsOperator.prototype.Calculate = function ( arg ) {
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "<>", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "<>", arguments[1].first );
}; };
/** @constructor */
function cLessOperator() { function cLessOperator() {
cBaseOperator.apply( this, ['<', 10] ); cBaseOperator.apply( this, ['<', 10] );
} }
...@@ -1908,6 +1876,7 @@ cLessOperator.prototype.Calculate = function ( arg ) { ...@@ -1908,6 +1876,7 @@ cLessOperator.prototype.Calculate = function ( arg ) {
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "<", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "<", arguments[1].first );
}; };
/** @constructor */
function cLessOrEqualOperator() { function cLessOrEqualOperator() {
cBaseOperator.apply( this, ['<=', 10] ); cBaseOperator.apply( this, ['<=', 10] );
} }
...@@ -1926,6 +1895,7 @@ cLessOrEqualOperator.prototype.Calculate = function ( arg ) { ...@@ -1926,6 +1895,7 @@ cLessOrEqualOperator.prototype.Calculate = function ( arg ) {
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "<=", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "<=", arguments[1].first );
}; };
/** @constructor */
function cGreaterOperator() { function cGreaterOperator() {
cBaseOperator.apply( this, ['>', 10] ); cBaseOperator.apply( this, ['>', 10] );
} }
...@@ -1944,6 +1914,7 @@ cGreaterOperator.prototype.Calculate = function ( arg ) { ...@@ -1944,6 +1914,7 @@ cGreaterOperator.prototype.Calculate = function ( arg ) {
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, ">", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, ">", arguments[1].first );
}; };
/** @constructor */
function cGreaterOrEqualOperator() { function cGreaterOrEqualOperator() {
cBaseOperator.apply( this, ['>=', 10] ); cBaseOperator.apply( this, ['>=', 10] );
} }
......
...@@ -4015,12 +4015,14 @@ cQUARTILE.prototype.getInfo = function () { ...@@ -4015,12 +4015,14 @@ cQUARTILE.prototype.getInfo = function () {
}; };
}; };
/** @constructor */
function cRANK() { function cRANK() {
cBaseFunction.call( this, "RANK" ); cBaseFunction.call( this, "RANK" );
} }
cRANK.prototype = Object.create( cBaseFunction.prototype ) cRANK.prototype = Object.create( cBaseFunction.prototype );
/** @constructor */
function cRSQ() { function cRSQ() {
// cBaseFunction.call( this, "RSQ" ); // cBaseFunction.call( this, "RSQ" );
// this.setArgumentsMin( 2 ); // this.setArgumentsMin( 2 );
...@@ -4040,7 +4042,7 @@ function cRSQ() { ...@@ -4040,7 +4042,7 @@ function cRSQ() {
} }
cRSQ.prototype = Object.create( cBaseFunction.prototype ) cRSQ.prototype = Object.create( cBaseFunction.prototype );
cRSQ.prototype.Calculate = function ( arg ) { cRSQ.prototype.Calculate = function ( arg ) {
function rsq( x, y ) { function rsq( x, y ) {
...@@ -4093,7 +4095,7 @@ cRSQ.prototype.Calculate = function ( arg ) { ...@@ -4093,7 +4095,7 @@ cRSQ.prototype.Calculate = function ( arg ) {
} ); } );
} }
else else
return this.value = cError( cErrorType.wrong_value_type ) return this.value = cError( cErrorType.wrong_value_type );
if ( arg1 instanceof cArea ) { if ( arg1 instanceof cArea ) {
arr1 = arg1.getValue(); arr1 = arg1.getValue();
...@@ -4104,18 +4106,19 @@ cRSQ.prototype.Calculate = function ( arg ) { ...@@ -4104,18 +4106,19 @@ cRSQ.prototype.Calculate = function ( arg ) {
} ); } );
} }
else else
return this.value = cError( cErrorType.wrong_value_type ) return this.value = cError( cErrorType.wrong_value_type );
return this.value = rsq( arr0, arr1 ); return this.value = rsq( arr0, arr1 );
} };
cRSQ.prototype.getInfo = function () { cRSQ.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( array-1 , array-2 )" args:"( array-1 , array-2 )"
}; };
} };
/** @constructor */
function cSKEW() { function cSKEW() {
// cBaseFunction.call( this, "SKEW" ); // cBaseFunction.call( this, "SKEW" );
// this.setArgumentsMin( 1 ); // this.setArgumentsMin( 1 );
...@@ -4135,7 +4138,7 @@ function cSKEW() { ...@@ -4135,7 +4138,7 @@ function cSKEW() {
} }
cSKEW.prototype = Object.create( cBaseFunction.prototype ) cSKEW.prototype = Object.create( cBaseFunction.prototype );
cSKEW.prototype.Calculate = function ( arg ) { cSKEW.prototype.Calculate = function ( arg ) {
function skew( x ) { function skew( x ) {
...@@ -4151,7 +4154,7 @@ cSKEW.prototype.Calculate = function ( arg ) { ...@@ -4151,7 +4154,7 @@ cSKEW.prototype.Calculate = function ( arg ) {
} }
if ( xLength <= 2 ) if ( xLength <= 2 )
return new cError( cErrorType.not_available ) return new cError( cErrorType.not_available );
_x /= xLength; _x /= xLength;
...@@ -4209,15 +4212,15 @@ cSKEW.prototype.Calculate = function ( arg ) { ...@@ -4209,15 +4212,15 @@ cSKEW.prototype.Calculate = function ( arg ) {
} }
return this.value = skew( arr0 ); return this.value = skew( arr0 );
};
}
cSKEW.prototype.getInfo = function () { cSKEW.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( argument-list )" args:"( argument-list )"
}; };
} };
/** @constructor */
function cSLOPE() { function cSLOPE() {
// cBaseFunction.call( this, "SLOPE" ); // cBaseFunction.call( this, "SLOPE" );
// this.setArgumentsMin( 2 ); // this.setArgumentsMin( 2 );
...@@ -4237,7 +4240,7 @@ function cSLOPE() { ...@@ -4237,7 +4240,7 @@ function cSLOPE() {
} }
cSLOPE.prototype = Object.create( cBaseFunction.prototype ) cSLOPE.prototype = Object.create( cBaseFunction.prototype );
cSLOPE.prototype.Calculate = function ( arg ) { cSLOPE.prototype.Calculate = function ( arg ) {
function slope( y, x ) { function slope( y, x ) {
...@@ -4304,14 +4307,15 @@ cSLOPE.prototype.Calculate = function ( arg ) { ...@@ -4304,14 +4307,15 @@ cSLOPE.prototype.Calculate = function ( arg ) {
return this.value = slope( arr0, arr1 ); return this.value = slope( arr0, arr1 );
} };
cSLOPE.prototype.getInfo = function () { cSLOPE.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( array-1 , array-2 )" args:"( array-1 , array-2 )"
}; };
} };
/** @constructor */
function cSMALL() { function cSMALL() {
// cBaseFunction.call( this, "SMALL" ); // cBaseFunction.call( this, "SMALL" );
// this.setArgumentsMin( 2 ); // this.setArgumentsMin( 2 );
...@@ -4332,7 +4336,7 @@ function cSMALL() { ...@@ -4332,7 +4336,7 @@ function cSMALL() {
} }
cSMALL.prototype = Object.create( cBaseFunction.prototype ) cSMALL.prototype = Object.create( cBaseFunction.prototype );
cSMALL.prototype.Calculate = function ( arg ) { cSMALL.prototype.Calculate = function ( arg ) {
function frequency( A, k ) { function frequency( A, k ) {
...@@ -4391,7 +4395,7 @@ cSMALL.prototype.getInfo = function () { ...@@ -4391,7 +4395,7 @@ cSMALL.prototype.getInfo = function () {
name:this.name, name:this.name,
args:"( array , k )" args:"( array , k )"
}; };
} };
function cSTANDARDIZE() { function cSTANDARDIZE() {
// cBaseFunction.call( this, "STANDARDIZE" ); // cBaseFunction.call( this, "STANDARDIZE" );
...@@ -4412,7 +4416,7 @@ function cSTANDARDIZE() { ...@@ -4412,7 +4416,7 @@ function cSTANDARDIZE() {
} }
cSTANDARDIZE.prototype = Object.create( cBaseFunction.prototype ) cSTANDARDIZE.prototype = Object.create( cBaseFunction.prototype );
cSTANDARDIZE.prototype.Calculate = function ( arg ) { cSTANDARDIZE.prototype.Calculate = function ( arg ) {
var arg0 = arg[0], arg1 = arg[1], arg2 = arg[2]; var arg0 = arg[0], arg1 = arg[1], arg2 = arg[2];
...@@ -4454,13 +4458,13 @@ cSTANDARDIZE.prototype.Calculate = function ( arg ) { ...@@ -4454,13 +4458,13 @@ cSTANDARDIZE.prototype.Calculate = function ( arg ) {
if ( arg2 instanceof cError ) return this.value = arg2; if ( arg2 instanceof cError ) return this.value = arg2;
return this.value = standardize( arg0.getValue(), arg1.getValue(), arg2.getValue() ); return this.value = standardize( arg0.getValue(), arg1.getValue(), arg2.getValue() );
} };
cSTANDARDIZE.prototype.getInfo = function () { cSTANDARDIZE.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"( x , mean , standard-deviation )" args:"( x , mean , standard-deviation )"
}; };
} };
function cSTDEV() { function cSTDEV() {
// cBaseFunction.call( this, "STDEV" ); // cBaseFunction.call( this, "STDEV" );
...@@ -4482,7 +4486,7 @@ function cSTDEV() { ...@@ -4482,7 +4486,7 @@ function cSTDEV() {
} }
cSTDEV.prototype = Object.create( cBaseFunction.prototype ) cSTDEV.prototype = Object.create( cBaseFunction.prototype );
cSTDEV.prototype.Calculate = function ( arg ) { cSTDEV.prototype.Calculate = function ( arg ) {
var count = 0, sum = new cNumber( 0 ), member = []; var count = 0, sum = new cNumber( 0 ), member = [];
for ( var i = 0; i < arg.length; i++ ) { for ( var i = 0; i < arg.length; i++ ) {
...@@ -4537,7 +4541,7 @@ cSTDEV.prototype.getInfo = function () { ...@@ -4537,7 +4541,7 @@ cSTDEV.prototype.getInfo = function () {
name:this.name, name:this.name,
args:"( argument-list )" args:"( argument-list )"
}; };
} };
function cSTDEVA() { function cSTDEVA() {
// cBaseFunction.call( this, "STDEVA" ); // cBaseFunction.call( this, "STDEVA" );
......
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