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

fix: Bug 20808 - Число введенное с одинарной кавычкой не рассчитывается в формуле

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@50309 954022d7-b5bf-4e40-9824-e11837661b57
parent b5c93b86
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
<script type="text/javascript" src="../model/History.js"></script> <script type="text/javascript" src="../model/History.js"></script>
<script type="text/javascript" src="../model/UndoRedo.js"></script> <script type="text/javascript" src="../model/UndoRedo.js"></script>
<script type="text/javascript" src="../view/scroll.js"></script> <script type="text/javascript" src="../../Common/scroll.js"></script>
<script type="text/javascript" src="../view/StringRender.js"></script> <script type="text/javascript" src="../view/StringRender.js"></script>
<script type="text/javascript" src="../view/CellTextRender.js"></script> <script type="text/javascript" src="../view/CellTextRender.js"></script>
<script type="text/javascript" src="../view/CellEditorView.js"></script> <script type="text/javascript" src="../view/CellEditorView.js"></script>
......
...@@ -173,6 +173,25 @@ ...@@ -173,6 +173,25 @@
strictEqual( oParser.calculate().getValue(), "#VALUE!" ); strictEqual( oParser.calculate().getValue(), "#VALUE!" );
} ) } )
test( "Test: \"String+Number\"", function () {
oParser = new parserFormula( "1+\"099\"", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 100 );
ws.getRange2( "A1469" ).setValue( "'099" );
ws.getRange2( "A1470" ).setValue( "\"099\"" );
oParser = new parserFormula( "1+A1469", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 100 );
oParser = new parserFormula( "1+A1470", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#VALUE!" );
} )
test( "Test: \"POWER(2,8)\"", function () { test( "Test: \"POWER(2,8)\"", function () {
oParser = new parserFormula( "POWER(2,8)", "A1", ws ); oParser = new parserFormula( "POWER(2,8)", "A1", ws );
ok( oParser.parse() ); ok( oParser.parse() );
...@@ -294,12 +313,24 @@ ...@@ -294,12 +313,24 @@
strictEqual( oParser.calculate().getValue(), 20 ); strictEqual( oParser.calculate().getValue(), 20 );
} ) } )
test( "Test: MONTH", function () { test( "Test: MONTH #1", function () {
oParser = new parserFormula( "MONTH(2013)", "A1", ws ); oParser = new parserFormula( "MONTH(2013)", "A1", ws );
ok( oParser.parse() ); ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 7 ); strictEqual( oParser.calculate().getValue(), 7 );
} ) } )
test( "Test: MONTH #2", function () {
oParser = new parserFormula( "MONTH(DATE(2013,2,2))", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), 2 );
} )
test( "Test: MONTH #3", function () {
oParser = new parserFormula( "MONTH(NOW())", "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), new Date().getUTCMonth()+1 );
} )
test( "Test: \"10-3\"", function () { test( "Test: \"10-3\"", function () {
oParser = new parserFormula( "10-3", "A1", ws ); oParser = new parserFormula( "10-3", "A1", ws );
ok( oParser.parse() ); ok( oParser.parse() );
......
...@@ -1241,6 +1241,13 @@ cString.prototype.tocBool = function () { ...@@ -1241,6 +1241,13 @@ cString.prototype.tocBool = function () {
cString.prototype.tocString = function () { cString.prototype.tocString = function () {
return this; return this;
}; };
cString.prototype.tryConvert = function () {
var res = checkTypeCell(""+this.value);
if( res instanceof cEmpty )
return this;
else
return res;
};
/** @constructor */ /** @constructor */
function cBool( val ) { function cBool( val ) {
...@@ -1391,7 +1398,7 @@ cArea.prototype.getValue = function () { ...@@ -1391,7 +1398,7 @@ cArea.prototype.getValue = function () {
_val.push( new cError( _cell.getValueWithoutFormat() ) ); _val.push( new cError( _cell.getValueWithoutFormat() ) );
break; break;
case CellValueType.String: case CellValueType.String:
_val.push( new cString( _cell.getValueWithoutFormat() ) ); _val.push( checkTypeCell( "" + _cell.getValueWithoutFormat() ) );
break; break;
default: default:
if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() != "" ) { if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() != "" ) {
...@@ -1422,7 +1429,7 @@ cArea.prototype.getValue2 = function ( cell ) { ...@@ -1422,7 +1429,7 @@ cArea.prototype.getValue2 = function ( cell ) {
_val.push( new cError( _cell.getValueWithoutFormat() ) ); _val.push( new cError( _cell.getValueWithoutFormat() ) );
break; break;
case CellValueType.String: case CellValueType.String:
_val.push( new cString( _cell.getValueWithoutFormat() ) ); _val.push( checkTypeCell( "" + _cell.getValueWithoutFormat() ) );
break; break;
default: default:
if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() != "" ) { if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() != "" ) {
...@@ -1585,27 +1592,16 @@ cRef.prototype.getValue = function () { ...@@ -1585,27 +1592,16 @@ cRef.prototype.getValue = function () {
{ {
var v = this.range.getValueWithoutFormat(); var v = this.range.getValueWithoutFormat();
if ( v == "" ) if ( v == "" )
return new cEmpty( "" + v ) return new cEmpty()
else else
return new cNumber( "" + v ); return new cNumber( "" + v );
} }
case CellValueType.String:
return new cString( "" + this.range.getValueWithoutFormat() );
case CellValueType.Bool: case CellValueType.Bool:
return new cBool( "" + this.range.getValueWithoutFormat() ) return new cBool( "" + this.range.getValueWithoutFormat() )
case CellValueType.Error: case CellValueType.Error:
return new cError( "" + this.range.getValueWithoutFormat() ) return new cError( "" + this.range.getValueWithoutFormat() )
default: default:
var _val = "" + this.range.getValueWithoutFormat(); return checkTypeCell( "" + this.range.getValueWithoutFormat() )
if ( _val == "" || _val == null )
return new cEmpty();
else if ( parserHelp.isNumber( _val ) )
return new cNumber( parserHelp.operand_str )
else if ( parserHelp.isBoolean( _val ) )
return new cBool( parserHelp.operand_str )
else if ( parserHelp.isError( _val ) )
return new cError( parserHelp.operand_str )
else return new cString( _val );
} }
}; };
cRef.prototype.tocNumber = function () { cRef.prototype.tocNumber = function () {
...@@ -1700,7 +1696,7 @@ cArea3D.prototype.getValue = function () { ...@@ -1700,7 +1696,7 @@ cArea3D.prototype.getValue = function () {
_val.push( new cError( _cell.getValueWithoutFormat() ) ); _val.push( new cError( _cell.getValueWithoutFormat() ) );
break; break;
case CellValueType.String: case CellValueType.String:
_val.push( new cString( _cell.getValueWithoutFormat() ) ); _val.push( checkTypeCell( "" + _cell.getValueWithoutFormat() ) );
break; break;
default: default:
if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() != "" ) { if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() != "" ) {
...@@ -1745,7 +1741,7 @@ cArea3D.prototype.getValue2 = function ( cell ) { ...@@ -1745,7 +1741,7 @@ cArea3D.prototype.getValue2 = function ( cell ) {
_val.push( new cError( _cell.getValueWithoutFormat() ) ); _val.push( new cError( _cell.getValueWithoutFormat() ) );
break; break;
case CellValueType.String: case CellValueType.String:
_val.push( new cString( _cell.getValueWithoutFormat() ) ); _val.push( checkTypeCell( "" + _cell.getValueWithoutFormat() ) );
break; break;
default: default:
if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() != "" ) { if ( _cell.getValueWithoutFormat() && _cell.getValueWithoutFormat() != "" ) {
...@@ -1990,16 +1986,7 @@ cRef3D.prototype.getValue = function () { ...@@ -1990,16 +1986,7 @@ cRef3D.prototype.getValue = function () {
case CellValueType.Error: case CellValueType.Error:
return new cError( "" + _r.getValueWithoutFormat() ) return new cError( "" + _r.getValueWithoutFormat() )
default: default:
var _val = "" + _r.getValueWithoutFormat(); return checkTypeCell( "" + _r.getValueWithoutFormat() )
if ( _val == "" || _val == null )
return new cEmpty();
else if ( parserHelp.isNumber( _val ) )
return new cNumber( parserHelp.operand_str )
else if ( parserHelp.isBoolean( _val ) )
return new cBool( parserHelp.operand_str )
else if ( parserHelp.isError( _val ) )
return new cError( parserHelp.operand_str )
else return new cString( _val );
} }
}; };
cRef3D.prototype.tocBool = function () { cRef3D.prototype.tocBool = function () {
......
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