Commit 92ddbb5e authored by Alexander.Trofimov's avatar Alexander.Trofimov

refactoring bool values in formulas

parent fb1a6397
...@@ -751,7 +751,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -751,7 +751,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cString.prototype.tocBool = function () { cString.prototype.tocBool = function () {
var res; var res;
if (parserHelp.isBoolean(this.value, 0)) { if (parserHelp.isBoolean(this.value, 0)) {
res = new cBool(parserHelp.operand_str.toUpperCase() === cBoolLocal["t"].toUpperCase()); res = new cBool(parserHelp.operand_str.toUpperCase() === cBoolLocal.t);
} else { } else {
res = this; res = this;
} }
...@@ -769,7 +769,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -769,7 +769,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
var v = false; var v = false;
switch (val.toString().toUpperCase()) { switch (val.toString().toUpperCase()) {
case "TRUE": case "TRUE":
case cBoolLocal["t"].toUpperCase(): case cBoolLocal.t:
v = true; v = true;
} }
cBaseType.call(this, v); cBaseType.call(this, v);
...@@ -791,7 +791,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -791,7 +791,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
return new cString(this.value ? "TRUE" : "FALSE"); return new cString(this.value ? "TRUE" : "FALSE");
}; };
cBool.prototype.toLocaleString = function () { cBool.prototype.toLocaleString = function () {
return new cString(this.value ? cBoolLocal["t"].toUpperCase() : cBoolLocal["f"].toUpperCase()); return new cString(this.value ? cBoolLocal.t : cBoolLocal.f);
}; };
cBool.prototype.tocBool = function () { cBool.prototype.tocBool = function () {
return this; return this;
...@@ -881,10 +881,9 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -881,10 +881,9 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cError.prototype = Object.create(cBaseType.prototype); cError.prototype = Object.create(cBaseType.prototype);
cError.prototype.constructor = cError; cError.prototype.constructor = cError;
cError.prototype.type = cElementType.error; cError.prototype.type = cElementType.error;
cError.prototype.tocNumber = cError.prototype.tocNumber = cError.prototype.tocString = cError.prototype.tocBool = function () {
cError.prototype.tocString = cError.prototype.tocBool = cError.prototype.tocEmpty = function () { return this;
return this; };
};
cError.prototype.toLocaleString = function () { cError.prototype.toLocaleString = function () {
switch (this.value) { switch (this.value) {
case cErrorOrigin["value"]: case cErrorOrigin["value"]:
...@@ -941,9 +940,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara ...@@ -941,9 +940,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
} }
return cErrorLocal["na"]; return cErrorLocal["na"];
}; };
/*cError.prototype.toString = function () {
return new cString( this.value ? cBoolLocal["t"].toUpperCase() : cBoolLocal["f"].toUpperCase() );
};*/
/** /**
* @constructor * @constructor
......
...@@ -3092,8 +3092,8 @@ CCellValue.prototype = ...@@ -3092,8 +3092,8 @@ CCellValue.prototype =
var sResult = ""; var sResult = "";
if(null != this.number) if(null != this.number)
{ {
if(CellValueType.Bool == this.type) if(CellValueType.Bool === this.type)
sResult = this.number == 1 ? cBoolLocal["t"].toUpperCase() : cBoolLocal["f"].toUpperCase(); sResult = this.number == 1 ? cBoolLocal.t : cBoolLocal.f;
else else
sResult = this.number.toString(); sResult = this.number.toString();
} }
...@@ -3256,11 +3256,11 @@ CCellValue.prototype = ...@@ -3256,11 +3256,11 @@ CCellValue.prototype =
} }
} }
} }
} else if (CellValueType.Bool == this.type) { } else if (CellValueType.Bool === this.type) {
if (null != this.number) { if (null != this.number) {
sText = (0 != this.number) ? cBoolLocal["t"].toUpperCase() : cBoolLocal["f"].toUpperCase(); sText = (0 != this.number) ? cBoolLocal.t : cBoolLocal.f;
} }
} else if (CellValueType.Error == this.type) { } else if (CellValueType.Error === this.type) {
if (null != this.text) { if (null != this.text) {
sText = this._getValueTypeError(this.text); sText = this._getValueTypeError(this.text);
} }
...@@ -3299,13 +3299,13 @@ CCellValue.prototype = ...@@ -3299,13 +3299,13 @@ CCellValue.prototype =
{ {
if(null != this.text || null != this.number) if(null != this.text || null != this.number)
{ {
if (CellValueType.Bool == this.type && null != this.number) if (CellValueType.Bool === this.type && null != this.number)
oValueText = (this.number == 1) ? cBoolLocal["t"].toUpperCase() : cBoolLocal["f"].toUpperCase(); oValueText = (this.number == 1) ? cBoolLocal.t : cBoolLocal.f;
else else
{ {
if(null != this.text) if(null != this.text)
oValueText = this.text; oValueText = this.text;
if(CellValueType.Number == this.type || CellValueType.String == this.type) if(CellValueType.Number === this.type || CellValueType.String === this.type)
{ {
var oNumFormat; var oNumFormat;
if(null != xfs && null != xfs.num) if(null != xfs && null != xfs.num)
...@@ -3511,13 +3511,11 @@ CCellValue.prototype = ...@@ -3511,13 +3511,11 @@ CCellValue.prototype =
else else
{ {
var sUpText = val.toUpperCase(); var sUpText = val.toUpperCase();
if(cBoolLocal["t"].toUpperCase() == sUpText || cBoolLocal["f"].toUpperCase() == sUpText) if(cBoolLocal.t === sUpText || cBoolLocal.f === sUpText)
{ {
this.type = CellValueType.Bool; this.type = CellValueType.Bool;
this.number = (cBoolLocal["t"].toUpperCase() == sUpText) ? 1 : 0; this.number = (cBoolLocal.t === sUpText) ? 1 : 0;
} }
// else if( "#NULL!" == sUpText || "#DIV/0!" == sUpText || "#NAME?" == sUpText || "#NUM!" == sUpText ||
// "#N/A" == sUpText || "#REF!" == sUpText || "#VALUE!" == sUpText )
else if(checkCellValueTypeError(sUpText)) else if(checkCellValueTypeError(sUpText))
{ {
this.type = CellValueType.Error; this.type = CellValueType.Error;
......
...@@ -2615,7 +2615,7 @@ ...@@ -2615,7 +2615,7 @@
for (var f in oFormulaList) { for (var f in oFormulaList) {
this.formulasList.push(f); this.formulasList.push(f);
} }
this.arrExcludeFormulas = [cBoolLocal["t"].toUpperCase(), cBoolLocal["f"].toUpperCase()]; this.arrExcludeFormulas = [cBoolLocal.t, cBoolLocal.f];
}; };
WorkbookView.prototype._setHintsProps = function(bIsHinting, bIsSubpixHinting) { WorkbookView.prototype._setHintsProps = function(bIsHinting, bIsSubpixHinting) {
......
...@@ -792,25 +792,26 @@ ...@@ -792,25 +792,26 @@
columns: 6 columns: 6
}; };
var cStrucTableLocalColumns = null, var cStrucTableLocalColumns = null;
cBoolLocal = {}, var cBoolOrigin = {'t': 'TRUE', 'f': 'FALSE'};
cErrorOrigin = { var cBoolLocal = {};
"nil": "#NULL!", var cErrorOrigin = {
"div": "#DIV\/0!", "nil": "#NULL!",
"value": "#VALUE!", "div": "#DIV\/0!",
"ref": "#REF!", "value": "#VALUE!",
"name": "#NAME?", "ref": "#REF!",
"num": "#NUM!", "name": "#NAME?",
"na": "#N\/A", "num": "#NUM!",
"getdata": "#GETTING_DATA", "na": "#N\/A",
"uf": "#UNSUPPORTED_FUNCTION!" "getdata": "#GETTING_DATA",
}, "uf": "#UNSUPPORTED_FUNCTION!"
cErrorLocal = {}; };
var cErrorLocal = {};
function build_local_rx(data) function build_local_rx(data)
{ {
rx_table_local = build_rx_table(data ? data["StructureTables"] : null); rx_table_local = build_rx_table(data ? data["StructureTables"] : null);
rx_bool_local = build_rx_bool(data ? data["CONST_TRUE_FALSE"] : null); rx_bool_local = build_rx_bool((data && data["CONST_TRUE_FALSE"]) || cBoolOrigin);
rx_error_local = build_rx_error(data ? data["CONST_ERROR"] : null); rx_error_local = build_rx_error(data ? data["CONST_ERROR"] : null);
} }
...@@ -858,12 +859,9 @@ ...@@ -858,12 +859,9 @@
function build_rx_bool(local) function build_rx_bool(local)
{ {
// ToDo переделать на более правильную реализацию. Не особо правильное копирование var t = cBoolLocal.t = local['t'].toUpperCase();
local = local ? local : {"t": "TRUE", "f": "FALSE"}; var f = cBoolLocal.f = local['f'].toUpperCase();
var t = cBoolLocal['t'] = local['t'];
var f = cBoolLocal['f'] = local['f'];
build_rx_array_local(local);
return new RegExp("^(" + t + "|" + f + ")([-+*\\/^&%<=>: ;),]|$)", "i"); return new RegExp("^(" + t + "|" + f + ")([-+*\\/^&%<=>: ;),]|$)", "i");
} }
...@@ -902,20 +900,6 @@ ...@@ -902,20 +900,6 @@
cErrorLocal["uf"] + ")", "i"); cErrorLocal["uf"] + ")", "i");
} }
function build_rx_array_local(localBool, digitSepar, localError)
{
var localBool = ( localBool ? localBool : {"t": "TRUE", "f": "FALSE"} );
rx_array_local = build_rx_array(localBool, digitSepar, localError);
}
function build_rx_array(localBool, digitSepar, localError)
{
return new RegExp("^\\{(([+-]?\\d*(\\d|\\" + digitSepar + ")\\d*([eE][+-]?\\d+)?)?(\"((\"\"|[^\"])*)\")?" +
"(#NULL!|#DIV\/0!|#VALUE!|#REF!|#NAME\\?|#NUM!|#UNSUPPORTED_FUNCTION!|#N\/A|#GETTING_DATA|" +
localBool["t"] + "|" + localBool["f"] + ")?[" + FormulaSeparators.arrayRowSeparator + "\\" + FormulaSeparators.arrayColSeparator + "]?)*\\}", "i");
}
var PostMessageType = { var PostMessageType = {
UploadImage: 0, UploadImage: 0,
ExtensionExist: 1 ExtensionExist: 1
...@@ -1416,7 +1400,7 @@ ...@@ -1416,7 +1400,7 @@
rx_error = build_rx_error(null), rx_error = build_rx_error(null),
rx_error_local = build_rx_error(null), rx_error_local = build_rx_error(null),
rx_bool = build_rx_bool(null), rx_bool = build_rx_bool(cBoolOrigin),
rx_bool_local = rx_bool, rx_bool_local = rx_bool,
rx_string = /^\"((\"\"|[^\"])*)\"/, rx_string = /^\"((\"\"|[^\"])*)\"/,
rx_test_ws_name = new test_ws_name2(), rx_test_ws_name = new test_ws_name2(),
...@@ -1430,9 +1414,6 @@ ...@@ -1430,9 +1414,6 @@
rx_numberDef = /^ *[+-]?\d*(\d|\.)\d*([eE][+-]?\d+)?/, rx_numberDef = /^ *[+-]?\d*(\d|\.)\d*([eE][+-]?\d+)?/,
rx_CommaDef = /^ *[,;] */, rx_CommaDef = /^ *[,;] */,
rx_array_local = /^\{(([+-]?\d*(\d|\.)\d*([eE][+-]?\d+)?)?(\"((\"\"|[^\"])*)\")?(#NULL!|#DIV\/0!|#VALUE!|#REF!|#NAME\?|#NUM!|#UNSUPPORTED_FUNCTION!|#N\/A|#GETTING_DATA|FALSE|TRUE)?[,;]?)*\}/i,
rx_array = /^\{(([+-]?\d*(\d|\.)\d*([eE][+-]?\d+)?)?(\"((\"\"|[^\"])*)\")?(#NULL!|#DIV\/0!|#VALUE!|#REF!|#NAME\?|#NUM!|#UNSUPPORTED_FUNCTION!|#N\/A|#GETTING_DATA|FALSE|TRUE)?[,;]?)*\}/i,
rx_ControlSymbols = /^ *[\u0000-\u001F\u007F-\u009F] */, rx_ControlSymbols = /^ *[\u0000-\u001F\u007F-\u009F] */,
emailRe = /^(mailto:)?([a-z0-9'\._-]+@[a-z0-9\.-]+\.[a-z0-9]{2,4})([a-яё0-9\._%+-=\? :&]*)/i, emailRe = /^(mailto:)?([a-z0-9'\._-]+@[a-z0-9\.-]+\.[a-z0-9]{2,4})([a-яё0-9\._%+-=\? :&]*)/i,
...@@ -1866,7 +1847,7 @@ ...@@ -1866,7 +1847,7 @@
if (match != null) if (match != null)
{ {
var name = match["name"]; var name = match["name"];
if (name && name.length != 0 && name != cBoolLocal["t"] && name != cBoolLocal["f"]/*&& wb.DefinedNames && wb.isDefinedNamesExists( name, ws ? ws.getId() : null )*/) if (name && 0 !== name.length && name.toUpperCase() !== cBoolLocal.t && name.toUpperCase() !== cBoolLocal.f/*&& wb.DefinedNames && wb.isDefinedNamesExists( name, ws ? ws.getId() : null )*/)
{ {
this.pCurrPos += name.length; this.pCurrPos += name.length;
this.operand_str = name; this.operand_str = name;
...@@ -1876,24 +1857,6 @@ ...@@ -1876,24 +1857,6 @@
} }
return [false]; return [false];
}; };
parserHelper.prototype.isArray = function (formula, start_pos, digitDelim)
{
if (this instanceof parserHelper)
{
this._reset();
}
var match = (formula.substring(start_pos)).match(digitDelim ? rx_array_local : rx_array);
if (match != null)
{
this.operand_str = match[0].substring(1, match[0].length - 1);
this.pCurrPos += match[0].length;
return true;
}
return false;
};
parserHelper.prototype.isLeftBrace = function (formula, start_pos) parserHelper.prototype.isLeftBrace = function (formula, start_pos)
{ {
if (this instanceof parserHelper) if (this instanceof parserHelper)
...@@ -2140,7 +2103,6 @@ ...@@ -2140,7 +2103,6 @@
FormulaSeparators.functionArgumentSeparator = ";"; FormulaSeparators.functionArgumentSeparator = ";";
rx_number = new RegExp("^ *[+-]?\\d*(\\d|\\" + FormulaSeparators.digitSeparator + ")\\d*([eE][+-]?\\d+)?"); rx_number = new RegExp("^ *[+-]?\\d*(\\d|\\" + FormulaSeparators.digitSeparator + ")\\d*([eE][+-]?\\d+)?");
rx_Comma = new RegExp("^ *[" + FormulaSeparators.functionArgumentSeparator + "] *"); rx_Comma = new RegExp("^ *[" + FormulaSeparators.functionArgumentSeparator + "] *");
// build_rx_array_local( cBoolLocal, digitSeparator, null);
rx_arraySeparators = new RegExp("^ *[" + FormulaSeparators.arrayRowSeparator + "\\" + FormulaSeparators.arrayColSeparator + "] *"); rx_arraySeparators = new RegExp("^ *[" + FormulaSeparators.arrayRowSeparator + "\\" + FormulaSeparators.arrayColSeparator + "] *");
} }
else else
...@@ -2151,7 +2113,6 @@ ...@@ -2151,7 +2113,6 @@
FormulaSeparators.functionArgumentSeparator = FormulaSeparators.functionArgumentSeparatorDef; FormulaSeparators.functionArgumentSeparator = FormulaSeparators.functionArgumentSeparatorDef;
rx_number = new RegExp("^ *[+-]?\\d*(\\d|\\" + FormulaSeparators.digitSeparatorDef + ")\\d*([eE][+-]?\\d+)?"); rx_number = new RegExp("^ *[+-]?\\d*(\\d|\\" + FormulaSeparators.digitSeparatorDef + ")\\d*([eE][+-]?\\d+)?");
rx_Comma = new RegExp("^ *[" + FormulaSeparators.functionArgumentSeparatorDef + "] *"); rx_Comma = new RegExp("^ *[" + FormulaSeparators.functionArgumentSeparatorDef + "] *");
// build_rx_array_local( cBoolLocal, digitSeparatorDef, null);
rx_arraySeparators = new RegExp("^ *[" + FormulaSeparators.arrayRowSeparatorDef + "\\" + FormulaSeparators.arrayColSeparatorDef + "] *"); rx_arraySeparators = new RegExp("^ *[" + FormulaSeparators.arrayRowSeparatorDef + "\\" + FormulaSeparators.arrayColSeparatorDef + "] *");
} }
rx_table_local = build_rx_table_cur(); rx_table_local = build_rx_table_cur();
......
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