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

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

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