Commit 7a64e0f7 authored by Alexander.Trofimov's avatar Alexander.Trofimov

cBaseOperator, cBaseFunction prototype = new Object -> add method to prototype

parent 03aa784c
......@@ -1227,7 +1227,7 @@ cRef.prototype.isValid = function () {
};
cRef.prototype.getMatrix = function () {
return [[this.getValue()]];
}
};
cRef.prototype.getBBox0 = function () {
return this.getRange().getBBox0();
};
......@@ -1942,72 +1942,63 @@ function checkTypeCell( val ) {
}
}
/*--------------------------------------------------------------------------*/
/*Base classes for operators & functions */
/** @constructor */
function cBaseOperator( name, priority, argumentCount ) {
if ( name ) {
this.name = name;
} else {
this.name = "";
}
if ( priority !== undefined ) {
this.priority = priority;
} else {
this.priority = 10;
}
/*--------------------------------------------------------------------------*/
/*Base classes for operators & functions */
/** @constructor */
function cBaseOperator(name, priority, argumentCount) {
this.name = name ? name : '';
this.priority = (priority !== undefined) ? priority : 10;
this.type = cElementType.operator;
this.isRightAssociative = false;
if ( argumentCount !== undefined ) {
this.argumentsCurrent = argumentCount;
} else {
this.argumentsCurrent = 2;
}
this.argumentsCurrent = (argumentCount !== undefined) ? argumentCount : 2;
this.value = null;
this.formatType = {
def : -1, //подразумевается формат первой ячейки входящей в формулу.
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
}
}
cBaseOperator.prototype = {
constructor: cBaseOperator, getArguments: function() {
cBaseOperator.prototype.getArguments = function () {
return this.argumentsCurrent;
}, toString: function() {
};
cBaseOperator.prototype.toString = function () {
return this.name;
}, Calculate: function() {
};
cBaseOperator.prototype.Calculate = function () {
return null;
}, Assemble: function(arg) {
};
cBaseOperator.prototype.Assemble = function (arg) {
var str = "";
if ( this.argumentsCurrent === 2 ) {
if (this.argumentsCurrent === 2) {
str = arg[0] + "" + this.name + "" + arg[1];
} else {
str = this.name + "" + arg[0];
}
return new cString( str );
}, Assemble2: function(arg, start, count) {
return new cString(str);
};
cBaseOperator.prototype.Assemble2 = function (arg, start, count) {
var str = "";
if ( this.argumentsCurrent === 2 ) {
if (this.argumentsCurrent === 2) {
str += arg[start + count - 2] + this.name + arg[start + count - 1];
} else {
str += this.name + arg[start];
}
return new cString( str );
}, Assemble2Locale: function(arg, start, count, locale, digitDelim) {
return new cString(str);
};
cBaseOperator.prototype.Assemble2Locale = function (arg, start, count, locale, digitDelim) {
var str = "";
if ( this.argumentsCurrent === 2 ) {
if (this.argumentsCurrent === 2) {
str += arg[start + count - 2].toLocaleString(digitDelim) + this.name +
arg[start + count - 1].toLocaleString(digitDelim);
} else {
str += this.name + arg[start];
}
return new cString( str );
}
};
return new cString(str);
};
/** @constructor */
function cBaseFunction( name, argMin, argMax ) {
/** @constructor */
function cBaseFunction(name, argMin, argMax) {
this.name = name;
this.type = cElementType.func;
this.value = null;
......@@ -2015,87 +2006,102 @@ function cBaseFunction( name, argMin, argMax ) {
this.argumentsCurrent = 0;
this.argumentsMax = argMax ? argMax : 255;
this.formatType = {
def : -1, //подразумевается формат первой ячейки входящей в формулу.
def: -1, //подразумевается формат первой ячейки входящей в формулу.
noneFormat: -2
};
this.numFormat = this.formatType.def;
// this.isXLFN = rx_sFuncPref.test(this.name);
}
cBaseFunction.prototype = {
constructor: cBaseFunction, Calculate: function() {
this.value = new cError( cErrorType.wrong_name );
}
cBaseFunction.prototype.Calculate = function () {
this.value = new cError(cErrorType.wrong_name);
return this.value;
}, setArgumentsMin: function(count) {
};
cBaseFunction.prototype.setArgumentsMin = function (count) {
this.argumentsMin = count;
}, setArgumentsMax: function(count) {
};
cBaseFunction.prototype.setArgumentsMax = function (count) {
this.argumentsMax = count;
}, DecrementArguments: function() {
};
cBaseFunction.prototype.DecrementArguments = function () {
--this.argumentsCurrent;
}, IncrementArguments: function() {
};
cBaseFunction.prototype.IncrementArguments = function () {
++this.argumentsCurrent;
}, setName: function(name) {
};
cBaseFunction.prototype.setName = function (name) {
this.name = name;
}, setArgumentsCount: function(count) {
};
cBaseFunction.prototype.setArgumentsCount = function (count) {
this.argumentsCurrent = count;
}, getArguments: function() {
};
cBaseFunction.prototype.getArguments = function () {
return this.argumentsCurrent;
}, getMaxArguments: function() {
};
cBaseFunction.prototype.getMaxArguments = function () {
return this.argumentsMax;
}, getMinArguments: function() {
};
cBaseFunction.prototype.getMinArguments = function () {
return this.argumentsMin;
}, Assemble: function(arg) {
};
cBaseFunction.prototype.Assemble = function (arg) {
var str = "";
for ( var i = 0; i < arg.length; i++ ) {
for (var i = 0; i < arg.length; i++) {
str += arg[i].toString();
if ( i !== arg.length - 1 ) {
if (i !== arg.length - 1) {
str += ",";
}
}
if ( this.isXLFN ) {
return new cString( "_xlfn." + this.name + "(" + str + ")" );
if (this.isXLFN) {
return new cString("_xlfn." + this.name + "(" + str + ")");
}
return new cString( this.toString() + "(" + str + ")" );
}, Assemble2: function(arg, start, count) {
return new cString(this.toString() + "(" + str + ")");
};
cBaseFunction.prototype.Assemble2 = function (arg, start, count) {
var str = "", c = start + count - 1;
for ( var i = start; i <= c; i++ ) {
for (var i = start; i <= c; i++) {
str += arg[i].toString();
if ( i !== c ) {
if (i !== c) {
str += ",";
}
}
if ( this.isXLFN ) {
return new cString( "_xlfn." + this.name + "(" + str + ")" );
if (this.isXLFN) {
return new cString("_xlfn." + this.name + "(" + str + ")");
}
return new cString( this.toString() + "(" + str + ")" );
}, Assemble2Locale: function(arg, start, count, locale, digitDelim) {
return new cString(this.toString() + "(" + str + ")");
};
cBaseFunction.prototype.Assemble2Locale = function (arg, start, count, locale, digitDelim) {
var name = this.toString(), str = "", c = start + count - 1, localeName = locale ? locale[name] : name;
localeName = localeName || this.toString();
for ( var i = start; i <= c; i++ ) {
str += arg[i].toLocaleString( digitDelim );
if ( i !== c ) {
for (var i = start; i <= c; i++) {
str += arg[i].toLocaleString(digitDelim);
if (i !== c) {
str += FormulaSeparators.functionArgumentSeparator;
}
}
return new cString( localeName + "(" + str + ")" );
}, toString: function() {
return this.name.replace( rx_sFuncPref, "_xlfn." );
}, setCA: function(arg, ca, numFormat) {
return new cString(localeName + "(" + str + ")");
};
cBaseFunction.prototype.toString = function () {
return this.name.replace(rx_sFuncPref, "_xlfn.");
};
cBaseFunction.prototype.setCA = function (arg, ca, numFormat) {
this.value = arg;
if ( ca ) {
if (ca) {
this.value.ca = true;
}
if ( numFormat !== null && numFormat !== undefined ) {
if (numFormat !== null && numFormat !== undefined) {
this.value.numFormat = numFormat;
}
return this.value;
}, setFormat: function(f) {
};
cBaseFunction.prototype.setFormat = function (f) {
this.numFormat = f;
}
};
};
cBaseFunction.prototype.checkArguments = function () {
return this.argumentsMin <= this.argumentsCurrent && this.argumentsCurrent <= this.argumentsMax;
};
/** @constructor */
function parentLeft() {
......
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