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

fixed:

Bug 24830 - Ячейка с числом, перед которым стоит знак апострофа, считается в функциях
Bug 25133 - Не рассчитывается формула когда аргумент задан именованным диапазоном

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57107 954022d7-b5bf-4e40-9824-e11837661b57
parent d5ba9273
...@@ -317,9 +317,9 @@ cString.prototype.tocNumber = function () { ...@@ -317,9 +317,9 @@ cString.prototype.tocNumber = function () {
res = new cNumber( 0 ); res = new cNumber( 0 );
} }
if ( this.value[0] === '"' && this.value[this.value.length - 1] === '"' ) { /*if ( this.value[0] === '"' && this.value[this.value.length - 1] === '"' ) {
m = this.value.substring( 1, this.value.length - 1 ); m = this.value.substring( 1, this.value.length - 1 );
} }*/
if ( !parseNum( m ) ) { if ( !parseNum( m ) ) {
res = new cError( cErrorType.wrong_value_type ); res = new cError( cErrorType.wrong_value_type );
} }
...@@ -522,7 +522,7 @@ cArea.prototype.getValue = function () { ...@@ -522,7 +522,7 @@ cArea.prototype.getValue = function () {
break; break;
case CellValueType.String: case CellValueType.String:
val.push( checkTypeCell( "" + cell.getValueWithoutFormat() ) ); val.push( new cString( cell.getValueWithoutFormat() ) );
break; break;
default: default:
...@@ -546,19 +546,20 @@ cArea.prototype.getValue2 = function ( cell ) { ...@@ -546,19 +546,20 @@ cArea.prototype.getValue2 = function ( cell ) {
r._foreachNoEmpty( function ( cellData ) { r._foreachNoEmpty( function ( cellData ) {
if ( cell.getID() === cellData.getName() ) { if ( cell.getID() === cellData.getName() ) {
var cellType = cellData.getType(); var cellType = cellData.getType();
if ( cellType === CellValueType.Number ) { switch(cellType){
case CellValueType.Number:
cellData.getValueWithoutFormat() === "" ? val.push( new cEmpty() ) : val.push( new cNumber( cellData.getValueWithoutFormat() ) ); cellData.getValueWithoutFormat() === "" ? val.push( new cEmpty() ) : val.push( new cNumber( cellData.getValueWithoutFormat() ) );
} break;
else if ( cellType === CellValueType.Bool ) { case CellValueType.Bool:
val.push( new cBool( cellData.getValueWithoutFormat() ) ); val.push( new cBool( cellData.getValueWithoutFormat() ) );
} break;
else if ( cellType === CellValueType.Error ) { case CellValueType.Error:
val.push( new cError( cellData.getValueWithoutFormat() ) ); val.push( new cError( cellData.getValueWithoutFormat() ) );
} break;
else if ( cellType === CellValueType.String ) { case CellValueType.String:
val.push( checkTypeCell( "" + cellData.getValueWithoutFormat() ) ); val.push( new cString( cellData.getValueWithoutFormat() ) );
} break;
else { default:
if ( cellData.getValueWithoutFormat() && cellData.getValueWithoutFormat() !== "" ) { if ( cellData.getValueWithoutFormat() && cellData.getValueWithoutFormat() !== "" ) {
val.push( new cNumber( cellData.getValueWithoutFormat() ) ); val.push( new cNumber( cellData.getValueWithoutFormat() ) );
} }
...@@ -820,19 +821,20 @@ cArea3D.prototype.getValue = function () { ...@@ -820,19 +821,20 @@ cArea3D.prototype.getValue = function () {
} }
_r[i]._foreachNoEmpty( function ( _cell ) { _r[i]._foreachNoEmpty( function ( _cell ) {
var cellType = _cell.getType(); var cellType = _cell.getType();
if ( cellType === CellValueType.Number ) { switch(cellType){
case CellValueType.Number:
_cell.getValueWithoutFormat() === "" ? _val.push( new cEmpty() ) : _val.push( new cNumber( _cell.getValueWithoutFormat() ) ); _cell.getValueWithoutFormat() === "" ? _val.push( new cEmpty() ) : _val.push( new cNumber( _cell.getValueWithoutFormat() ) );
} break;
else if ( cellType === CellValueType.Bool ) { case CellValueType.Bool:
_val.push( new cBool( _cell.getValueWithoutFormat() ) ); _val.push( new cBool( _cell.getValueWithoutFormat() ) );
} break;
else if ( cellType === CellValueType.Error ) { case CellValueType.Error:
_val.push( new cError( _cell.getValueWithoutFormat() ) ); _val.push( new cError( _cell.getValueWithoutFormat() ) );
} break;
else if ( cellType === CellValueType.String ) { case CellValueType.String:
_val.push( checkTypeCell( "" + _cell.getValueWithoutFormat() ) ); _val.push( new cString( _cell.getValueWithoutFormat() ) );
} break;
else { default:{
if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() !== "" ) { if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() !== "" ) {
_val.push( new cNumber( _cell.getValueWithoutFormat() ) ); _val.push( new cNumber( _cell.getValueWithoutFormat() ) );
} }
...@@ -840,6 +842,8 @@ cArea3D.prototype.getValue = function () { ...@@ -840,6 +842,8 @@ cArea3D.prototype.getValue = function () {
_val.push( checkTypeCell( "" + _cell.getValueWithoutFormat() ) ); _val.push( checkTypeCell( "" + _cell.getValueWithoutFormat() ) );
} }
} }
}
} ); } );
} }
return _val; return _val;
...@@ -865,19 +869,24 @@ cArea3D.prototype.getValue2 = function ( cell ) { ...@@ -865,19 +869,24 @@ cArea3D.prototype.getValue2 = function ( cell ) {
_r[0]._foreachNoEmpty( function ( _cell ) { _r[0]._foreachNoEmpty( function ( _cell ) {
if ( cell.getID() === _cell.getName() ) { if ( cell.getID() === _cell.getName() ) {
var cellType = _cell.getType(); var cellType = _cell.getType();
if ( cellType === CellValueType.Number ) { switch(cellType){
case CellValueType.Number:{
_cell.getValueWithoutFormat() === "" ? _val.push( new cEmpty() ) : _val.push( new cNumber( _cell.getValueWithoutFormat() ) ); _cell.getValueWithoutFormat() === "" ? _val.push( new cEmpty() ) : _val.push( new cNumber( _cell.getValueWithoutFormat() ) );
break;
} }
else if ( cellType === CellValueType.Bool ) { case CellValueType.Bool:{
_val.push( new cBool( _cell.getValueWithoutFormat() ) ); _val.push( new cBool( _cell.getValueWithoutFormat() ) );
break;
} }
else if ( cellType === CellValueType.Error ) { case CellValueType.Error:{
_val.push( new cError( _cell.getValueWithoutFormat() ) ); _val.push( new cError( _cell.getValueWithoutFormat() ) );
break;
} }
else if ( cellType === CellValueType.String ) { case CellValueType.String:{
_val.push( checkTypeCell( "" + _cell.getValueWithoutFormat() ) ); _val.push( new cString( _cell.getValueWithoutFormat() ) );
break
} }
else { default:{
if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() !== "" ) { if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() !== "" ) {
_val.push( new cNumber( _cell.getValueWithoutFormat() ) ); _val.push( new cNumber( _cell.getValueWithoutFormat() ) );
} }
...@@ -886,6 +895,7 @@ cArea3D.prototype.getValue2 = function ( cell ) { ...@@ -886,6 +895,7 @@ cArea3D.prototype.getValue2 = function ( cell ) {
} }
} }
} }
}
} ); } );
if ( _val[0] === undefined || _val[0] === null ) { if ( _val[0] === undefined || _val[0] === null ) {
...@@ -1133,6 +1143,7 @@ cRef.prototype.getValue = function () { ...@@ -1133,6 +1143,7 @@ cRef.prototype.getValue = function () {
return new cError( cErrorType.bad_reference ); return new cError( cErrorType.bad_reference );
} }
var cellType = this.range.getType(), v, res; var cellType = this.range.getType(), v, res;
if ( cellType === CellValueType.Number ) { if ( cellType === CellValueType.Number ) {
v = this.range.getValueWithoutFormat(); v = this.range.getValueWithoutFormat();
if ( v === "" ) { if ( v === "" ) {
...@@ -1148,6 +1159,10 @@ cRef.prototype.getValue = function () { ...@@ -1148,6 +1159,10 @@ cRef.prototype.getValue = function () {
else if ( cellType === CellValueType.Error ) { else if ( cellType === CellValueType.Error ) {
res = new cError( "" + this.range.getValueWithoutFormat() ); res = new cError( "" + this.range.getValueWithoutFormat() );
} }
else if ( cellType === CellValueType.String ) {
res = new cString( this.range.getValueWithoutFormat() );
// res = checkTypeCell( "" + this.range.getValueWithoutFormat() );
}
else { else {
res = checkTypeCell( "" + this.range.getValueWithoutFormat() ); res = checkTypeCell( "" + this.range.getValueWithoutFormat() );
} }
...@@ -1739,13 +1754,14 @@ cUnarPlusOperator.prototype.Assemble = function ( arg ) { ...@@ -1739,13 +1754,14 @@ cUnarPlusOperator.prototype.Assemble = function ( arg ) {
return new cString( "+" + arg[0] ); return new cString( "+" + arg[0] );
}; };
function cPlusOperator() { function cAddOperator() {
cBaseOperator.apply( this, ['+', 20] ); cBaseOperator.apply( this, ['+', 20] );
} }
cPlusOperator.prototype = Object.create( cBaseOperator.prototype ); cAddOperator.prototype = Object.create( cBaseOperator.prototype );
cPlusOperator.prototype.Calculate = function ( arg ) { cAddOperator.prototype.Calculate = function ( arg ) {
var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert(); // var arg0 = arg[0].tryConvert(), arg1 = arg[1].tryConvert();
var arg0 = arg[0].tocNumber(), arg1 = arg[1].tocNumber();
return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "+", arguments[1].first ); return this.value = _func[arg0.type][arg1.type]( arg0, arg1, "+", arguments[1].first );
}; };
...@@ -1948,7 +1964,7 @@ var cFormulaOperators = { ...@@ -1948,7 +1964,7 @@ var cFormulaOperators = {
'^':cPowOperator, '^':cPowOperator,
'*':cMultOperator, '*':cMultOperator,
'/':cDivOperator, '/':cDivOperator,
'+':cPlusOperator, '+':cAddOperator,
'-':cMinusOperator, '-':cMinusOperator,
'&':cConcatSTROperator /*concat str*/, '&':cConcatSTROperator /*concat str*/,
'=':cEqualsOperator/*equals*/, '=':cEqualsOperator/*equals*/,
...@@ -1997,6 +2013,7 @@ _func[cElementType.error] = []; ...@@ -1997,6 +2013,7 @@ _func[cElementType.error] = [];
_func[cElementType.cellsRange] = []; _func[cElementType.cellsRange] = [];
_func[cElementType.empty] = []; _func[cElementType.empty] = [];
_func[cElementType.array] = []; _func[cElementType.array] = [];
_func[cElementType.cell] = [];
_func[cElementType.number][cElementType.number] = function ( arg0, arg1, what ) { _func[cElementType.number][cElementType.number] = function ( arg0, arg1, what ) {
...@@ -2763,6 +2780,136 @@ _func.binarySearch = function ( sElem, arrTagert, regExp ) { ...@@ -2763,6 +2780,136 @@ _func.binarySearch = function ( sElem, arrTagert, regExp ) {
}; };
_func[cElementType.number][cElementType.cell] = function(arg0,arg1,what,cellAddress){
var ar1 = arg1.tocNumber();
switch(what){
case ">":{
return new cBool( arg0.getValue() > ar1.getValue() );
}
case ">=":{
return new cBool( arg0.getValue() >= ar1.getValue() );
}
case "<":{
return new cBool( arg0.getValue() < ar1.getValue() );
}
case "<=":{
return new cBool( arg0.getValue() <= ar1.getValue() );
}
case "=":{
return new cBool( arg0.getValue() === ar1.getValue() );
}
case "<>":{
return new cBool( arg0.getValue() !== ar1.getValue() );
}
case "-":{
return new cNumber( arg0.getValue() - ar1.getValue() );
}
case "+":{
return new cNumber( arg0.getValue() + ar1.getValue() );
}
case "/":{
if ( arg1.getValue() !== 0 ) {
return new cNumber( arg0.getValue() / ar1.getValue() );
}
else {
return new cError( cErrorType.division_by_zero );
}
}
case "*":{
return new cNumber( arg0.getValue() * ar1.getValue() );
}
default:{
return new cError( cErrorType.wrong_value_type );
}
}
};
_func[cElementType.cell][cElementType.number] = function(arg0,arg1,what,cellAddress){
var ar0 = arg0.tocNumber();
switch(what){
case ">":{
return new cBool( ar0.getValue() > arg1.getValue() );
}
case ">=":{
return new cBool( ar0.getValue() >= arg1.getValue() );
}
case "<":{
return new cBool( ar0.getValue() < arg1.getValue() );
}
case "<=":{
return new cBool( ar0.getValue() <= arg1.getValue() );
}
case "=":{
return new cBool( ar0.getValue() === arg1.getValue() );
}
case "<>":{
return new cBool( ar0.getValue() !== arg1.getValue() );
}
case "-":{
return new cNumber( ar0.getValue() - arg1.getValue() );
}
case "+":{
return new cNumber( ar0.getValue() + arg1.getValue() );
}
case "/":{
if ( arg1.getValue() !== 0 ) {
return new cNumber( ar0.getValue() / arg1.getValue() );
}
else {
return new cError( cErrorType.division_by_zero );
}
}
case "*":{
return new cNumber( ar0.getValue() * arg1.getValue() );
}
default:{
return new cError( cErrorType.wrong_value_type );
}
}
};
_func[cElementType.cell][cElementType.cell] = function(arg0,arg1,what,cellAddress){
var ar0 = arg0.tocNumber();
switch(what){
case ">":{
return new cBool( ar0.getValue() > arg1.getValue() );
}
case ">=":{
return new cBool( ar0.getValue() >= arg1.getValue() );
}
case "<":{
return new cBool( ar0.getValue() < arg1.getValue() );
}
case "<=":{
return new cBool( ar0.getValue() <= arg1.getValue() );
}
case "=":{
return new cBool( ar0.getValue() === arg1.getValue() );
}
case "<>":{
return new cBool( ar0.getValue() !== arg1.getValue() );
}
case "-":{
return new cNumber( ar0.getValue() - arg1.getValue() );
}
case "+":{
return new cNumber( ar0.getValue() + arg1.getValue() );
}
case "/":{
if ( arg1.getValue() !== 0 ) {
return new cNumber( ar0.getValue() / arg1.getValue() );
}
else {
return new cError( cErrorType.division_by_zero );
}
}
case "*":{
return new cNumber( ar0.getValue() * arg1.getValue() );
}
default:{
return new cError( cErrorType.wrong_value_type );
}
}
};
/** класс отвечающий за парсинг строки с формулой, подсчета формулы, перестройки формулы при манипуляции с ячейкой*/ /** класс отвечающий за парсинг строки с формулой, подсчета формулы, перестройки формулы при манипуляции с ячейкой*/
/** @constructor */ /** @constructor */
...@@ -3139,7 +3286,7 @@ parserFormula.prototype = { ...@@ -3139,7 +3286,7 @@ parserFormula.prototype = {
} }
} }
/* Referens to DefinesNames */ /* Referens to DefinesNames */
else if ( parserHelp.isName.call( this, this.Formula, this.pCurrPos, this.wb )[0] ) { // Shall be placed strongly before Area and Ref else if ( parserHelp.isName.call( this, this.Formula, this.pCurrPos, this.wb, this.ws )[0] ) { // Shall be placed strongly before Area and Ref
found_operand = new cName( this.operand_str, this.wb ); found_operand = new cName( this.operand_str, this.wb );
} }
/* Referens to cells area A1:A10 */ /* Referens to cells area A1:A10 */
......
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