Commit d71c9bcb authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov Committed by Alexander.Trofimov

функции на прототипах

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53848 954022d7-b5bf-4e40-9824-e11837661b57
parent 15695f4d
...@@ -7,32 +7,46 @@ ...@@ -7,32 +7,46 @@
*/ */
cFormulaFunction.Cube = { cFormulaFunction.Cube = {
'groupName':"Cube", 'groupName':"Cube",
'CUBEKPIMEMBER':function () { 'CUBEKPIMEMBER':cCUBEKPIMEMBER,
var r = new cBaseFunction( "CUBEKPIMEMBER" ); 'CUBEMEMBER':cCUBEMEMBER,
return r; 'CUBEMEMBERPROPERTY':cCUBEMEMBERPROPERTY,
}, 'CUBERANKEDMEMBER':cCUBERANKEDMEMBER,
'CUBEMEMBER':function () { 'CUBESET':cCUBESET,
var r = new cBaseFunction( "CUBEMEMBER" ); 'CUBESETCOUNT':cCUBESETCOUNT,
return r; 'CUBEVALUE':cCUBEVALUE
},
'CUBEMEMBERPROPERTY':function () {
var r = new cBaseFunction( "CUBEMEMBERPROPERTY" );
return r;
},
'CUBERANKEDMEMBER':function () {
var r = new cBaseFunction( "CUBERANKEDMEMBER" );
return r;
},
'CUBESET':function () {
var r = new cBaseFunction( "CUBESET" );
return r;
},
'CUBESETCOUNT':function () {
var r = new cBaseFunction( "CUBESETCOUNT" );
return r;
},
'CUBEVALUE':function () {
var r = new cBaseFunction( "CUBEVALUE" );
return r;
}
} }
function cCUBEKPIMEMBER() {
cBaseFunction.call( this, "CUBEKPIMEMBER" );
}
cCUBEKPIMEMBER.prototype = Object.create( cBaseFunction.prototype )
function cCUBEMEMBER() {
cBaseFunction.call( this, "CUBEMEMBER" );
}
cCUBEMEMBER.prototype = Object.create( cBaseFunction.prototype )
function cCUBEMEMBERPROPERTY() {
cBaseFunction.call( this, "CUBEMEMBERPROPERTY" );
}
cCUBEMEMBERPROPERTY.prototype = Object.create( cBaseFunction.prototype )
function cCUBERANKEDMEMBER() {
cBaseFunction.call( this, "CUBERANKEDMEMBER" );
}
cCUBERANKEDMEMBER.prototype = Object.create( cBaseFunction.prototype )
function cCUBESET() {
cBaseFunction.call( this, "CUBESET" );
}
cCUBESET.prototype = Object.create( cBaseFunction.prototype )
function cCUBESETCOUNT() {
cBaseFunction.call( this, "CUBESETCOUNT" );
}
cCUBESETCOUNT.prototype = Object.create( cBaseFunction.prototype )
function cCUBEVALUE() {
cBaseFunction.call( this, "CUBEVALUE" );
}
cCUBEVALUE.prototype = Object.create( cBaseFunction.prototype )
...@@ -7,52 +7,76 @@ ...@@ -7,52 +7,76 @@
*/ */
cFormulaFunction.Database = { cFormulaFunction.Database = {
'groupName':"Database", 'groupName':"Database",
'DAVERAGE':function () { 'DAVERAGE':cDAVERAGE,
var r = new cBaseFunction( "DAVERAGE" ); 'DCOUNT':cDCOUNT,
return r; 'DCOUNTA':cDCOUNTA,
}, 'DGET':cDGET,
'DCOUNT':function () { 'DMAX':cDMAX,
var r = new cBaseFunction( "DCOUNT" ); 'DMIN':cDMIN,
return r; 'DPRODUCT':cDPRODUCT,
}, 'DSTDEV':cDSTDEV,
'DCOUNTA':function () { 'DSTDEVP':cDSTDEVP,
var r = new cBaseFunction( "DCOUNTA" ); 'DSUM':cDSUM,
return r; 'DVAR':cDVAR,
}, 'DVARP':cDVARP
'DGET':function () {
var r = new cBaseFunction( "DGET" );
return r;
},
'DMAX':function () {
var r = new cBaseFunction( "DMAX" );
return r;
},
'DMIN':function () {
var r = new cBaseFunction( "DMIN" );
return r;
},
'DPRODUCT':function () {
var r = new cBaseFunction( "DPRODUCT" );
return r;
},
'DSTDEV':function () {
var r = new cBaseFunction( "DSTDEV" );
return r;
},
'DSTDEVP':function () {
var r = new cBaseFunction( "DSTDEVP" );
return r;
},
'DSUM':function () {
var r = new cBaseFunction( "DSUM" );
return r;
},
'DVAR':function () {
var r = new cBaseFunction( "DVAR" );
return r;
},
'DVARP':function () {
var r = new cBaseFunction( "DVARP" );
return r;
}
} }
function cDAVERAGE() {
cBaseFunction.call( this, "DAVERAGE" );
}
cDAVERAGE.prototype = Object.create( cBaseFunction.prototype )
function cDCOUNT() {
cBaseFunction.call( this, "DCOUNT" );
}
cDCOUNT.prototype = Object.create( cBaseFunction.prototype )
function cDCOUNTA() {
cBaseFunction.call( this, "DCOUNTA" );
}
cDCOUNTA.prototype = Object.create( cBaseFunction.prototype )
function cDGET() {
cBaseFunction.call( this, "DGET" );
}
cDGET.prototype = Object.create( cBaseFunction.prototype )
function cDMAX() {
cBaseFunction.call( this, "DMAX" );
}
cDMAX.prototype = Object.create( cBaseFunction.prototype )
function cDMIN() {
cBaseFunction.call( this, "DMIN" );
}
cDMIN.prototype = Object.create( cBaseFunction.prototype )
function cDPRODUCT() {
cBaseFunction.call( this, "DPRODUCT" );
}
cDPRODUCT.prototype = Object.create( cBaseFunction.prototype )
function cDSTDEV() {
cBaseFunction.call( this, "DSTDEV" );
}
cDSTDEV.prototype = Object.create( cBaseFunction.prototype )
function cDSTDEVP() {
cBaseFunction.call( this, "DSTDEVP" );
}
cDSTDEVP.prototype = Object.create( cBaseFunction.prototype )
function cDSUM() {
cBaseFunction.call( this, "DSUM" );
}
cDSUM.prototype = Object.create( cBaseFunction.prototype )
function cDVAR() {
cBaseFunction.call( this, "DVAR" );
}
cDVAR.prototype = Object.create( cBaseFunction.prototype )
function cDVARP() {
cBaseFunction.call( this, "DVARP" );
}
cDVARP.prototype = Object.create( cBaseFunction.prototype )
...@@ -5,13 +5,25 @@ ...@@ -5,13 +5,25 @@
* Time: 15:22 * Time: 15:22
* To change this template use File | Settings | File Templates. * To change this template use File | Settings | File Templates.
*/ */
"use strict";
cFormulaFunction.Logical = { cFormulaFunction.Logical = {
'groupName':"Logical", 'groupName':"Logical",
'AND':function () { 'AND':cAND,
var r = new cBaseFunction( "AND" ); 'FALSE':cFALSE,
r.setArgumentsMin( 1 ); 'IF':cIF,
r.setArgumentsMax( 255 ); 'IFERROR':cIFERROR,
r.Calculate = function ( arg ) { 'NOT':cNOT,
'OR':cOR,
'TRUE':cTRUE
}
function cAND() {
cBaseFunction.call( this, "AND" );
this.setArgumentsMin( 1 );
this.setArgumentsMax( 255 );
}
cAND.prototype = Object.create( cBaseFunction.prototype )
cAND.prototype.Calculate = function ( arg ) {
var argResult = null; var argResult = null;
for ( var i = 0; i < arg.length; i++ ) { for ( var i = 0; i < arg.length; i++ ) {
if ( arg[i] instanceof cArea || arg[i] instanceof cArea3D ) { if ( arg[i] instanceof cArea || arg[i] instanceof cArea3D ) {
...@@ -66,35 +78,37 @@ cFormulaFunction.Logical = { ...@@ -66,35 +78,37 @@ cFormulaFunction.Logical = {
if ( argResult == null ) if ( argResult == null )
return this.value = new cError( cErrorType.wrong_value_type ); return this.value = new cError( cErrorType.wrong_value_type );
return this.value = argResult; return this.value = argResult;
} }
r.getInfo = function () { cAND.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"(logical1, logical2, ...)" args:"(logical1, logical2, ...)"
}; };
} }
return r;
}, function cFALSE() {
'FALSE':function () { cBaseFunction.call( this, "FALSE" );
var r = new cBaseFunction( "FALSE" ); this.setArgumentsMin( 0 );
r.setArgumentsMin( 0 ); this.setArgumentsMax( 0 );
r.setArgumentsMax( 0 ); }
r.Calculate = function () { cFALSE.prototype = Object.create( cBaseFunction.prototype )
cFALSE.prototype.Calculate = function () {
return this.value = new cBool( false ); return this.value = new cBool( false );
} }
r.getInfo = function () { cFALSE.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"()" args:"()"
}; };
} }
return r;
}, function cIF() {
'IF':function () { cBaseFunction.call( this, "IF" );
var r = new cBaseFunction( "IF" ); this.setArgumentsMin( 1 );
r.setArgumentsMin( 1 ); this.setArgumentsMax( 3 );
r.setArgumentsMax( 3 ); }
r.Calculate = function ( arg ) { cIF.prototype = Object.create( cBaseFunction.prototype )
cIF.prototype.Calculate = function ( arg ) {
var arg0 = arg[0], arg1 = arg[1], arg2 = arg[2]; var arg0 = arg[0], arg1 = arg[1], arg2 = arg[2];
if ( arg0 instanceof cArray ) if ( arg0 instanceof cArray )
...@@ -123,20 +137,21 @@ cFormulaFunction.Logical = { ...@@ -123,20 +137,21 @@ cFormulaFunction.Logical = {
arg2 : arg2 :
new cBool( false ); new cBool( false );
} }
} }
r.getInfo = function () { cIF.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"(logical_test, value_if_true, value_if_false)" args:"(logical_test, value_if_true, value_if_false)"
}; };
} }
return r;
}, function cIFERROR() {
'IFERROR':function () { cBaseFunction.call( this, "IFERROR" );
var r = new cBaseFunction( "IFERROR" ); this.setArgumentsMin( 2 );
r.setArgumentsMin( 2 ); this.setArgumentsMax( 2 );
r.setArgumentsMax( 2 ); }
r.Calculate = function ( arg ) { cIFERROR.prototype = Object.create( cBaseFunction.prototype )
cIFERROR.prototype.Calculate = function ( arg ) {
var arg0 = arg[0]; var arg0 = arg[0];
if ( arg0 instanceof cArray ) { if ( arg0 instanceof cArray ) {
arg0 = arg0.getElement( 0 ); arg0 = arg0.getElement( 0 );
...@@ -151,20 +166,21 @@ cFormulaFunction.Logical = { ...@@ -151,20 +166,21 @@ cFormulaFunction.Logical = {
if ( arg0 instanceof cError ) if ( arg0 instanceof cError )
return this.value = arg[1] instanceof cArray ? arg[1].getElement( 0 ) : arg[1]; return this.value = arg[1] instanceof cArray ? arg[1].getElement( 0 ) : arg[1];
else return this.value = arg[0]; else return this.value = arg[0];
} }
r.getInfo = function () { cIFERROR.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"(value, value_if_error)" args:"(value, value_if_error)"
}; };
} }
return r;
}, function cNOT() {
'NOT':function () { cBaseFunction.call( this, "NOT" );
var r = new cBaseFunction( "NOT" ); this.setArgumentsMin( 1 );
r.setArgumentsMin( 1 ); this.setArgumentsMax( 1 );
r.setArgumentsMax( 1 ); }
r.Calculate = function ( arg ) { cNOT.prototype = Object.create( cBaseFunction.prototype )
cNOT.prototype.Calculate = function ( arg ) {
var arg0 = arg[0]; var arg0 = arg[0];
if ( arg0 instanceof cArray ) if ( arg0 instanceof cArray )
arg0 = arg0.getElement( 0 ); arg0 = arg0.getElement( 0 );
...@@ -184,20 +200,21 @@ cFormulaFunction.Logical = { ...@@ -184,20 +200,21 @@ cFormulaFunction.Logical = {
return this.value = arg0; return this.value = arg0;
else else
return this.value = new cBool( !arg0.tocBool().value ); return this.value = new cBool( !arg0.tocBool().value );
} }
r.getInfo = function () { cNOT.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"(logical)" args:"(logical)"
}; };
} }
return r;
}, function cOR() {
'OR':function () { cBaseFunction.call( this, "OR" );
var r = new cBaseFunction( "OR" ); this.setArgumentsMin( 1 );
r.setArgumentsMin( 1 ); this.setArgumentsMax( 255 );
r.setArgumentsMax( 255 ); }
r.Calculate = function ( arg ) { cOR.prototype = Object.create( cBaseFunction.prototype )
cOR.prototype.Calculate = function ( arg ) {
var argResult = null; var argResult = null;
for ( var i = 0; i < arg.length; i++ ) { for ( var i = 0; i < arg.length; i++ ) {
if ( arg[i] instanceof cArea || arg[i] instanceof cArea3D ) { if ( arg[i] instanceof cArea || arg[i] instanceof cArea3D ) {
...@@ -247,28 +264,26 @@ cFormulaFunction.Logical = { ...@@ -247,28 +264,26 @@ cFormulaFunction.Logical = {
if ( argResult == null ) if ( argResult == null )
return this.value = new cError( cErrorType.wrong_value_type ); return this.value = new cError( cErrorType.wrong_value_type );
return this.value = argResult; return this.value = argResult;
} }
r.getInfo = function () { cOR.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"(logical1, logical2, ...)" args:"(logical1, logical2, ...)"
}; };
} }
return r;
}, function cTRUE() {
'TRUE':function () { cBaseFunction.call( this, "TRUE" );
var r = new cBaseFunction( "TRUE" ); this.setArgumentsMin( 0 );
r.setArgumentsMin( 0 ); this.setArgumentsMax( 0 );
r.setArgumentsMax( 0 ); }
r.Calculate = function () { cTRUE.prototype = Object.create( cBaseFunction.prototype )
cTRUE.prototype.Calculate = function () {
return this.value = new cBool( true ); return this.value = new cBool( true );
} }
r.getInfo = function () { cTRUE.prototype.getInfo = function () {
return { return {
name:this.name, name:this.name,
args:"()" args:"()"
}; };
}
return r;
}
} }
...@@ -2659,38 +2659,38 @@ parserFormula.prototype = { ...@@ -2659,38 +2659,38 @@ parserFormula.prototype = {
else if ( parserHelp.isFunc.call( this, this.Formula, this.pCurrPos ) ) { else if ( parserHelp.isFunc.call( this, this.Formula, this.pCurrPos ) ) {
var found_operator = null; var found_operator = null;
if ( this.operand_str.toUpperCase() in cFormulaFunction.Mathematic )//mathematic if ( this.operand_str.toUpperCase() in cFormulaFunction.Mathematic )//Mathematic
found_operator = cFormulaFunction.Mathematic[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.Mathematic[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.Logical )//logical else if ( this.operand_str.toUpperCase() in cFormulaFunction.Logical )//Logical
found_operator = cFormulaFunction.Logical[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.Logical[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.Information )//information else if ( this.operand_str.toUpperCase() in cFormulaFunction.Information )//Information
found_operator = cFormulaFunction.Information[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.Information[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.Statistical )//statistical else if ( this.operand_str.toUpperCase() in cFormulaFunction.Statistical )//Statistical
found_operator = cFormulaFunction.Statistical[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.Statistical[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.TextAndData )//text and data else if ( this.operand_str.toUpperCase() in cFormulaFunction.TextAndData )//Text and data
found_operator = cFormulaFunction.TextAndData[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.TextAndData[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.Cube )//cube else if ( this.operand_str.toUpperCase() in cFormulaFunction.Cube )//Cube
found_operator = cFormulaFunction.Cube[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.Cube[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.Database )//Database else if ( this.operand_str.toUpperCase() in cFormulaFunction.Database )//Database
found_operator = cFormulaFunction.Database[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.Database[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.DateAndTime )//Date and time else if ( this.operand_str.toUpperCase() in cFormulaFunction.DateAndTime )//Date and time
found_operator = cFormulaFunction.DateAndTime[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.DateAndTime[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.Engineering )//Engineering else if ( this.operand_str.toUpperCase() in cFormulaFunction.Engineering )//Engineering
found_operator = cFormulaFunction.Engineering[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.Engineering[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.Financial )//Financial else if ( this.operand_str.toUpperCase() in cFormulaFunction.Financial )//Financial
found_operator = cFormulaFunction.Financial[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.Financial[this.operand_str.toUpperCase()]();
else if ( this.operand_str.toUpperCase() in cFormulaFunction.LookupAndReference )//Lookup and reference else if ( this.operand_str.toUpperCase() in cFormulaFunction.LookupAndReference )//Lookup and reference
found_operator = cFormulaFunction.LookupAndReference[this.operand_str.toUpperCase()](); found_operator = new cFormulaFunction.LookupAndReference[this.operand_str.toUpperCase()]();
if ( found_operator != null && found_operator != undefined ) if ( found_operator != null && found_operator != undefined )
this.elemArr.push( found_operator ); this.elemArr.push( found_operator );
......
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