Commit 68b4e9ee authored by dmitry.shahtanov's avatar dmitry.shahtanov Committed by Alexander.Trofimov

локализация ошибок

parent 9cc1b482
...@@ -559,6 +559,7 @@ function test_defName(){ ...@@ -559,6 +559,7 @@ function test_defName(){
var cStrucTableLocalColumns = {"h": "Headers", "d": "Data", "a": "All", "tr": "This row", "t": "Totals"}, var cStrucTableLocalColumns = {"h": "Headers", "d": "Data", "a": "All", "tr": "This row", "t": "Totals"},
cBoolLocal = {"t":"TRUE","f":"FALSE"}, cBoolLocal = {"t":"TRUE","f":"FALSE"},
cErrorOrigin = {"nil":"#NULL!","div":"#DIV\/0!","value":"#VALUE!","ref":"#REF!","name":"#NAME\\?","num":"#NUM!","na":"#N\/A","getdata":"#GETTING_DATA","uf":"#UNSUPPORTED_FUNCTION!"},
cErrorLocal = {"nil":"#NULL!","div":"#DIV\/0!","value":"#VALUE!","ref":"#REF!","name":"#NAME\\?","num":"#NUM!","na":"#N\/A","getdata":"#GETTING_DATA","uf":"#UNSUPPORTED_FUNCTION!"}; cErrorLocal = {"nil":"#NULL!","div":"#DIV\/0!","value":"#VALUE!","ref":"#REF!","name":"#NAME\\?","num":"#NUM!","na":"#N\/A","getdata":"#GETTING_DATA","uf":"#UNSUPPORTED_FUNCTION!"};
...@@ -612,7 +613,7 @@ function build_rx_bool(local){ ...@@ -612,7 +613,7 @@ function build_rx_bool(local){
} }
function build_rx_error_local(local){ function build_rx_error_local(local){
rx_error_local = build_rx_error(null/*local*/); rx_error_local = build_rx_error(local);
} }
function build_rx_error(local){ function build_rx_error(local){
cErrorLocal = ( local ? local : {"nil":"#NULL!","div":"#DIV\/0!","value":"#VALUE!","ref":"#REF!","name":"#NAME\\?","num":"#NUM!","na":"#N\/A","getdata":"#GETTING_DATA","uf":"#UNSUPPORTED_FUNCTION!"} ); cErrorLocal = ( local ? local : {"nil":"#NULL!","div":"#DIV\/0!","value":"#VALUE!","ref":"#REF!","name":"#NAME\\?","num":"#NUM!","na":"#N\/A","getdata":"#GETTING_DATA","uf":"#UNSUPPORTED_FUNCTION!"} );
......
...@@ -440,7 +440,7 @@ function cError( val ) { ...@@ -440,7 +440,7 @@ function cError( val ) {
switch ( val ) { switch ( val ) {
case cErrorLocal["value"]: case cErrorLocal["value"]:
case "#VALUE!": case cErrorOrigin["value"]:
case cErrorType.wrong_value_type: case cErrorType.wrong_value_type:
{ {
this.value = "#VALUE!"; this.value = "#VALUE!";
...@@ -448,7 +448,7 @@ function cError( val ) { ...@@ -448,7 +448,7 @@ function cError( val ) {
break; break;
} }
case cErrorLocal["nil"]: case cErrorLocal["nil"]:
case "#NULL!": case cErrorOrigin["nil"]:
case cErrorType.null_value: case cErrorType.null_value:
{ {
this.value = "#NULL!"; this.value = "#NULL!";
...@@ -456,7 +456,7 @@ function cError( val ) { ...@@ -456,7 +456,7 @@ function cError( val ) {
break; break;
} }
case cErrorLocal["div"]: case cErrorLocal["div"]:
case "#DIV/0!": case cErrorOrigin["div"]:
case cErrorType.division_by_zero: case cErrorType.division_by_zero:
{ {
this.value = "#DIV/0!"; this.value = "#DIV/0!";
...@@ -464,7 +464,7 @@ function cError( val ) { ...@@ -464,7 +464,7 @@ function cError( val ) {
break; break;
} }
case cErrorLocal["ref"]: case cErrorLocal["ref"]:
case "#REF!": case cErrorOrigin["ref"]:
case cErrorType.bad_reference: case cErrorType.bad_reference:
{ {
this.value = "#REF!"; this.value = "#REF!";
...@@ -472,7 +472,7 @@ function cError( val ) { ...@@ -472,7 +472,7 @@ function cError( val ) {
break; break;
} }
case cErrorLocal["name"]: case cErrorLocal["name"]:
case "#NAME?": case cErrorOrigin["name"]:
case cErrorType.wrong_name: case cErrorType.wrong_name:
{ {
this.value = "#NAME?"; this.value = "#NAME?";
...@@ -480,7 +480,7 @@ function cError( val ) { ...@@ -480,7 +480,7 @@ function cError( val ) {
break; break;
} }
case cErrorLocal["num"]: case cErrorLocal["num"]:
case "#NUM!": case cErrorOrigin["num"]:
case cErrorType.not_numeric: case cErrorType.not_numeric:
{ {
this.value = "#NUM!"; this.value = "#NUM!";
...@@ -488,7 +488,7 @@ function cError( val ) { ...@@ -488,7 +488,7 @@ function cError( val ) {
break; break;
} }
case cErrorLocal["na"]: case cErrorLocal["na"]:
case "#N/A": case cErrorOrigin["na"]:
case cErrorType.not_available: case cErrorType.not_available:
{ {
this.value = "#N/A"; this.value = "#N/A";
...@@ -496,7 +496,7 @@ function cError( val ) { ...@@ -496,7 +496,7 @@ function cError( val ) {
break; break;
} }
case cErrorLocal["getdata"]: case cErrorLocal["getdata"]:
case "#GETTING_DATA": case cErrorOrigin["getdata"]:
case cErrorType.getting_data: case cErrorType.getting_data:
{ {
this.value = "#GETTING_DATA"; this.value = "#GETTING_DATA";
...@@ -504,14 +504,13 @@ function cError( val ) { ...@@ -504,14 +504,13 @@ function cError( val ) {
break; break;
} }
case cErrorLocal["uf"]: case cErrorLocal["uf"]:
case "#UNSUPPORTED_FUNCTION!": case cErrorOrigin["uf"]:
case cErrorType.unsupported_function: case cErrorType.unsupported_function:
{ {
this.value = "#UNSUPPORTED_FUNCTION!"; this.value = "#UNSUPPORTED_FUNCTION!";
this.errorType = cErrorType.unsupported_function; this.errorType = cErrorType.unsupported_function;
break; break;
} }
} }
return this; return this;
...@@ -521,6 +520,74 @@ cError.prototype = Object.create( cBaseType.prototype ); ...@@ -521,6 +520,74 @@ cError.prototype = Object.create( cBaseType.prototype );
cError.prototype.tocNumber = cError.prototype.tocString = cError.prototype.tocBool = cError.prototype.tocEmpty = function () { cError.prototype.tocNumber = cError.prototype.tocString = cError.prototype.tocBool = cError.prototype.tocEmpty = function () {
return this; return this;
}; };
cError.prototype.toLocaleString = function () {
switch ( this.value ) {
case cErrorOrigin["value"]:
case cErrorType.wrong_value_type:
{
return cErrorLocal["value"];
break;
}
case cErrorOrigin["nil"]:
case cErrorType.null_value:
{
return cErrorLocal["nil"];
break;
}
case cErrorOrigin["div"]:
case cErrorType.division_by_zero:
{
return cErrorLocal["div"];
break;
}
case cErrorOrigin["ref"]:
case cErrorType.bad_reference:
{
return cErrorLocal["ref"];
break;
}
case cErrorOrigin["name"]:
case cErrorType.wrong_name:
{
return cErrorLocal["name"];
break;
}
case cErrorOrigin["num"]:
case cErrorType.not_numeric:
{
return cErrorLocal["num"];
break;
}
case cErrorOrigin["na"]:
case cErrorType.not_available:
{
return cErrorLocal["na"];
break;
}
case cErrorOrigin["getdata"]:
case cErrorType.getting_data:
{
return cErrorLocal["getdata"];
break;
}
case cErrorOrigin["uf"]:
case cErrorType.unsupported_function:
{
return cErrorLocal["uf"];
break;
}
}
return cErrorLocal["na"];
};
/*cError.prototype.toString = function () {
return new cString( this.value ? cBoolLocal["t"].toUpperCase() : cBoolLocal["f"].toUpperCase() );
};*/
/** @constructor */ /** @constructor */
function cArea( val, ws ) {/*Area means "A1:E5" for example*/ function cArea( val, ws ) {/*Area means "A1:E5" for example*/
...@@ -4309,7 +4376,7 @@ parserFormula.prototype = { ...@@ -4309,7 +4376,7 @@ parserFormula.prototype = {
} }
/* Errors */ /* Errors */
else if ( parserHelp.isError.call( this, this.Formula, this.pCurrPos ) ) { else if ( parserHelp.isError.call( this, this.Formula, this.pCurrPos, local ) ) {
found_operand = new cError( this.operand_str ); found_operand = new cError( this.operand_str );
} }
......
...@@ -2887,6 +2887,9 @@ CCellValue.prototype = ...@@ -2887,6 +2887,9 @@ CCellValue.prototype =
for(var i = 0, length = this.textValueForEdit2.length; i < length; ++i) for(var i = 0, length = this.textValueForEdit2.length; i < length; ++i)
this.textValueForEdit += this.textValueForEdit2[i].text; this.textValueForEdit += this.textValueForEdit2[i].text;
} }
if( CellValueType.Error == this.type ){
return this._getValueTypeError(this.textValueForEdit);
}
return this.textValueForEdit; return this.textValueForEdit;
}, },
getValue2 : function(cell, dDigitsCount, fIsFitMeasurer) getValue2 : function(cell, dDigitsCount, fIsFitMeasurer)
...@@ -2994,7 +2997,7 @@ CCellValue.prototype = ...@@ -2994,7 +2997,7 @@ CCellValue.prototype =
else if(CellValueType.Error == this.type) else if(CellValueType.Error == this.type)
{ {
if(null != this.text) if(null != this.text)
sText = this.text; sText = this._getValueTypeError(this.text);
} }
if(bNeedMeasure) if(bNeedMeasure)
{ {
...@@ -3192,6 +3195,40 @@ CCellValue.prototype = ...@@ -3192,6 +3195,40 @@ CCellValue.prototype =
setValue : function(cell, val) setValue : function(cell, val)
{ {
this.clean(); this.clean();
function checkCellValueTypeError(sUpText){
switch (sUpText){
case cErrorLocal["nil"]:
return cErrorOrigin["nil"];
break;
case cErrorLocal["div"]:
return cErrorOrigin["div"];
break;
case cErrorLocal["value"]:
return cErrorOrigin["value"];
break;
case cErrorLocal["ref"]:
return cErrorOrigin["ref"];
break;
case cErrorLocal["name"]:
return cErrorOrigin["name"];
break;
case cErrorLocal["num"]:
return cErrorOrigin["num"];
break;
case cErrorLocal["na"]:
return cErrorOrigin["na"];
break;
case cErrorLocal["getdata"]:
return cErrorOrigin["getdata"];
break;
case cErrorLocal["uf"]:
return cErrorOrigin["uf"];
break;
}
return false;
}
if("" == val) if("" == val)
return; return;
var oNumFormat; var oNumFormat;
...@@ -3220,11 +3257,12 @@ CCellValue.prototype = ...@@ -3220,11 +3257,12 @@ CCellValue.prototype =
this.type = CellValueType.Bool; this.type = CellValueType.Bool;
this.number = (cBoolLocal["t"].toUpperCase() == sUpText) ? 1 : 0; this.number = (cBoolLocal["t"].toUpperCase() == sUpText) ? 1 : 0;
} }
else if("#NULL!" == sUpText || "#DIV/0!" == sUpText || "#NAME?" == sUpText || "#NUM!" == sUpText || // else if( "#NULL!" == sUpText || "#DIV/0!" == sUpText || "#NAME?" == sUpText || "#NUM!" == sUpText ||
"#N/A" == sUpText || "#REF!" == sUpText || "#VALUE!" == sUpText) // "#N/A" == sUpText || "#REF!" == sUpText || "#VALUE!" == sUpText )
else if(checkCellValueTypeError(sUpText))
{ {
this.type = CellValueType.Error; this.type = CellValueType.Error;
this.text = sUpText; this.text = checkCellValueTypeError(sUpText);
} }
else else
{ {
...@@ -3494,6 +3532,38 @@ CCellValue.prototype = ...@@ -3494,6 +3532,38 @@ CCellValue.prototype =
case this.Properties.number: this.number = value;break; case this.Properties.number: this.number = value;break;
case this.Properties.type: this.type = value;break; case this.Properties.type: this.type = value;break;
} }
},
_getValueTypeError : function (text){
switch (text){
case cErrorOrigin["nil"]:
return cErrorLocal["nil"];
break;
case cErrorOrigin["div"]:
return cErrorLocal["div"];
break;
case cErrorOrigin["value"]:
return cErrorLocal["value"];
break;
case cErrorOrigin["ref"]:
return cErrorLocal["ref"];
break;
case cErrorOrigin["name"]:
return cErrorLocal["name"];
break;
case cErrorOrigin["num"]:
return cErrorLocal["num"];
break;
case cErrorOrigin["na"]:
return cErrorLocal["na"];
break;
case cErrorOrigin["getdata"]:
return cErrorLocal["getdata"];
break;
case cErrorOrigin["uf"]:
return cErrorLocal["uf"];
break;
}
return cErrorLocal["nil"];
} }
}; };
......
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