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

добавлен оператор intersection(" ") в формулах spreadsheets

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@68690 954022d7-b5bf-4e40-9824-e11837661b57
parent f3ae591a
......@@ -1147,13 +1147,13 @@ parserHelper.prototype.is3DRef = function ( formula, start_pos ) {
}
return [false, null, null];
};
parserHelper.prototype.isNextPtg = function ( formula, start_pos ) {
parserHelper.prototype.isNextPtg = function ( formula, start_pos, digitDelim ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var subSTR = formula.substring( start_pos ), match;
if( subSTR.match( rx_before_operators ) == null && (match = subSTR.match( rx_intersect )) != null ){
if( subSTR.match( rx_RightParentheses ) == null && subSTR.match( digitDelim?rx_Comma:rx_CommaDef ) == null && subSTR.match( rx_operators ) == null && (match = subSTR.match( rx_intersect )) != null ){
this.pCurrPos += match[0].length;
this.operand_str = match[0][0];
return true;
......@@ -1181,7 +1181,7 @@ parserHelper.prototype.isLeftParentheses = function ( formula, start_pos ) {
var match = (formula.substring( start_pos )).match( rx_LeftParentheses );
if (match != null) {
this.operand_str = match[0].replace( rx_space, "" );
this.operand_str = match[0].replace( rx_space_g, "" );
this.pCurrPos += match[0].length;
return true;
}
......@@ -1194,7 +1194,7 @@ parserHelper.prototype.isRightParentheses = function ( formula, start_pos ) {
var match = (formula.substring( start_pos )).match( rx_RightParentheses );
if (match != null) {
this.operand_str = match[0].replace( rx_space, "" );
this.operand_str = match[0].replace( rx_space_g, "" );
this.pCurrPos += match[0].length;
return true;
}
......
......@@ -437,6 +437,35 @@
strictEqual( oParser.calculate().getValue(), 6 );
} )
test( "Test: \"Parse intersection\"", function () {
ws.getRange2( "A7" ).setValue( "1" );
ws.getRange2( "A8" ).setValue( "2" );
ws.getRange2( "A9" ).setValue( "3" );
oParser = new parserFormula( '1 + ( A7 +A8 ) * 2', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.assemble(), "1+(A7+A8)*2" );
strictEqual( oParser.calculate().getValue(), 7 );
oParser = new parserFormula( 'sum A1:A5', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.assemble(), "sum A1:A5" );
strictEqual( oParser.calculate().getValue(), "#VALUE!" );
oParser = new parserFormula( 'sum( A1:A5 , B1:B5 ) ', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.assemble(), "SUM(A1:A5,B1:B5)" );
strictEqual( oParser.calculate().getValue(), 0 );
oParser = new parserFormula( 'sum( A1:A5 , B1:B5 , " 3 , 14 15 92 6 " ) ', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.assemble(), 'SUM(A1:A5,B1:B5," 3 , 14 15 92 6 ")' );
strictEqual( oParser.calculate().getValue(), "#VALUE!" );
} )
test( "Test: \"Arithmetical operations\"", function () {
oParser = new parserFormula( '1+3', "A1", ws );
ok( oParser.parse() );
......
......@@ -4020,7 +4020,7 @@ parserFormula.prototype = {
}*/
/* Operators*/
if ( parserHelp.isOperator.call( this, this.Formula, this.pCurrPos ) /*|| parserHelp.isNextPtg.call( this, this.Formula, this.pCurrPos )*/ ) {
if ( parserHelp.isOperator.call( this, this.Formula, this.pCurrPos ) || parserHelp.isNextPtg.call( this, this.Formula, this.pCurrPos ) ) {
wasLeftParentheses = false;
wasRigthParentheses = false;
found_operator = null;
......@@ -4034,6 +4034,9 @@ parserFormula.prototype = {
this.operand_expected = true;
found_operator = new cFormulaOperators['un_plus']();
}
else if( this.operand_str == " " ){
continue;
}
else {
this.error.push( c_oAscError.ID.FrmlWrongOperator );
this.outStack = [];
......@@ -4058,6 +4061,9 @@ parserFormula.prototype = {
this.operand_expected = false;
found_operator = new cFormulaOperators['%']();
}
else if ( this.operand_str == " " && this.pCurrPos == this.Formula.length) {
continue;
}
else {
if ( this.operand_str in cFormulaOperators ) {
found_operator = new cFormulaOperators[this.operand_str]();
......@@ -4218,7 +4224,7 @@ parserFormula.prototype = {
var arr = new cArray(), operator = { isOperator: false, operatorName: ""};
while ( this.pCurrPos < this.Formula.length && !parserHelp.isRightBrace.call(this, this.Formula, this.pCurrPos) ) {
if ( parserHelp.isArraySeparator.call( this, this.Formula, this.pCurrPos, digitDelim ) ) {
if ( this.operand_str == (digitDelim ? arrayRowSeparator : arrayRowSeparatorDef) ) {
if ( digitDelim ? rx_arraySeparators.test(this.operand_str) : rx_arraySeparatorsDef.test(this.operand_str) ) {
arr.addRow();
}
}
......
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