Commit ffe56802 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

в parserHelper добавил operand_str и pCurrPos (иначе каждый раз пересоздавание...

в parserHelper добавил operand_str и pCurrPos (иначе каждый раз пересоздавание объекта было). Переделал prototype = new Object на prototype.{add method}

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57461 954022d7-b5bf-4e40-9824-e11837661b57
parent a9207adf
......@@ -244,7 +244,7 @@ var rx_operators = /^ *[-+*\/^&%<=>:] */,
rg_validDEC2HEXNumber = /^-?[0-9]{1,12}$/,
rg_validHEXNumber = /^[0-9A-Fa-f]{1,10}$/,
rg_validOCTNumber = /^[0-7]{1,10}$/,
rg_complex_number = new XRegExp( "^(?<real>[-+]?(?:\\d*(?:\\.\\d+)?(?:[Ee][+-]?\\d+)?))?(?<img>([-+]?(\\d*(?:\\.\\d+)?(?:[Ee][+-]?\\d+)?)?[ij])?)", "g" )
rg_complex_number = new XRegExp( "^(?<real>[-+]?(?:\\d*(?:\\.\\d+)?(?:[Ee][+-]?\\d+)?))?(?<img>([-+]?(\\d*(?:\\.\\d+)?(?:[Ee][+-]?\\d+)?)?[ij])?)", "g" );
/**
......@@ -252,23 +252,21 @@ var rx_operators = /^ *[-+*\/^&%<=>:] */,
* @constructor
*/
function parserHelper() {
this.operand_str = null;
this.pCurrPos = null;
}
parserHelper.prototype = {
_reset:function () {
delete this.operand_str;
delete this.pCurrPos;
},
isOperator:function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
parserHelper.prototype._reset = function () {
this.operand_str = null;
this.pCurrPos = null;
};
parserHelper.prototype.isOperator = function ( formula, start_pos ) {
if (this instanceof parserHelper) {
this._reset();
}
var str = formula.substring( start_pos );
var match = str.match( rx_operators );
if ( match == null || match == undefined )
return false;
else {
if (match != null) {
var mt = str.match( rx_LG );
if ( mt ) match = mt;
this.operand_str = match[0].replace( rx_space_g, "" );
......@@ -276,9 +274,8 @@ parserHelper.prototype = {
return true;
}
return false;
},
isFunc:function ( formula, start_pos ) {
};
parserHelper.prototype.isFunc = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
......@@ -286,47 +283,42 @@ parserHelper.prototype = {
var frml = formula.substring( start_pos );
var match = (frml).match( rg );
if ( match != null && match != undefined ) {
if (match != null) {
if ( match.length == 2 ) {
this.pCurrPos += match[1].length;
this.operand_str = match[1];
return true;
}
}
// this.operand_str = null;
return false;
},
isArea:function ( formula, start_pos ) {
};
parserHelper.prototype.isArea = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var subSTR = formula.substring( start_pos );
var match = subSTR.match( rgRange ) || subSTR.match( rgCols ) || subSTR.match( rgRows );
if ( match != null || match != undefined ) {
if (match != null) {
this.pCurrPos += match[0].length;
this.operand_str = match[0];
return true;
}
// this.operand_str = null;
return false;
},
isRef:function ( formula, start_pos, allRef ) {
};
parserHelper.prototype.isRef = function ( formula, start_pos, allRef ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var substr = formula.substring( start_pos );
var match = substr.match( rx_ref );
if ( match != null || match != undefined ) {
if (match != null) {
var m0 = match[0], m1 = match[1], m2 = match[2];
if ( match.length >= 3 && g_oCellAddressUtils.colstrToColnum( m1.substr( 0, (m1.length - m2.length) ) ) <= gc_nMaxCol && parseInt( m2 ) <= gc_nMaxRow ) {
this.pCurrPos += m0.indexOf( " " ) > -1 ? m0.length - 1 : m1.length;
this.operand_str = m1;
return true;
}
else if ( allRef ) {
} else if ( allRef ) {
match = substr.match( rx_refAll );
if ( (match != null || match != undefined) && match.length >= 3 ) {
var m1 = match[1];
......@@ -337,11 +329,9 @@ parserHelper.prototype = {
}
}
// this.operand_str = null;
return false;
},
is3DRef:function ( formula, start_pos ) {
};
parserHelper.prototype.is3DRef = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
......@@ -349,138 +339,113 @@ parserHelper.prototype = {
var subSTR = formula.substring( start_pos );
var match = rx_ref3D_quoted.xexec( subSTR ) || rx_ref3D_non_quoted.xexec( subSTR );
if ( match != null || match != undefined ) {
if (match != null) {
this.pCurrPos += match[0].length;
this.operand_str = match[1];
return [ true, match["name_from"] ? match["name_from"].replace( /''/g, "'" ) : null, match["name_to"] ? match["name_to"].replace( /''/g, "'" ) : null ];
}
// this.operand_str = null;
return [false, null, null];
},
isNextPtg:function ( formula, start_pos ) {
};
parserHelper.prototype.isNextPtg = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var subSTR = formula.substring( start_pos );
return (
( subSTR.match( rx_before_operators ) != null || subSTR.match( rx_before_operators ) != undefined ) &&
( subSTR.match( rx_space ) != null || subSTR.match( rx_space ) != undefined )
)
},
isNumber:function ( formula, start_pos ) {
return (subSTR.match( rx_before_operators ) != null && subSTR.match( rx_space ) != null);
};
parserHelper.prototype.isNumber = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var match = (formula.substring( start_pos )).match( rx_number );
if ( match == null || match == undefined )
return false;
else {
if (match != null) {
this.operand_str = match[0];
this.pCurrPos += match[0].length;
return true;
}
return false;
},
isLeftParentheses:function ( formula, start_pos ) {
};
parserHelper.prototype.isLeftParentheses = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var match = (formula.substring( start_pos )).match( rx_LeftParentheses );
if ( match == null || match == undefined )
return false;
else {
if (match != null) {
this.operand_str = match[0].replace( rx_space, "" );
this.pCurrPos += match[0].length;
return true;
}
return false;
},
isRightParentheses:function ( formula, start_pos ) {
};
parserHelper.prototype.isRightParentheses = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var match = (formula.substring( start_pos )).match( rx_RightParentheses );
if ( match == null || match == undefined )
return false;
else {
if (match != null) {
this.operand_str = match[0].replace( rx_space, "" );
this.pCurrPos += match[0].length;
return true;
}
return false;
},
isComma:function ( formula, start_pos ) {
};
parserHelper.prototype.isComma = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var match = (formula.substring( start_pos )).match( rx_Comma );
if ( match == null || match == undefined )
return false;
else {
if (match != null) {
this.operand_str = match[0];
this.pCurrPos += match[0].length;
return true;
}
return false;
},
isError:function ( formula, start_pos ) {
};
parserHelper.prototype.isError = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var match = (formula.substring( start_pos )).match( rx_error );
if ( match == null || match == undefined )
return false;
else {
if (match != null) {
this.operand_str = match[0];
this.pCurrPos += match[0].length;
return true;
}
return false;
},
isBoolean:function ( formula, start_pos ) {
};
parserHelper.prototype.isBoolean = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var match = (formula.substring( start_pos )).match( rx_bool );
if ( match == null || match == undefined )
return false;
else {
if (match != null) {
this.operand_str = match[1];
this.pCurrPos += match[1].length;
return true;
}
return false;
},
isString:function ( formula, start_pos ) {
};
parserHelper.prototype.isString = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var match = (formula.substring( start_pos )).match( rx_string );
if ( match != null || match != undefined ) {
if (match != null) {
this.operand_str = match[1].replace( "\"\"", "\"" );
this.pCurrPos += match[0].length;
return true;
}
return false;
},
isName:function ( formula, start_pos, wb, ws ) {
};
parserHelper.prototype.isName = function ( formula, start_pos, wb, ws ) {
if ( this instanceof parserHelper ) {
this._reset();
}
......@@ -488,7 +453,7 @@ parserHelper.prototype = {
var subSTR = formula.substring( start_pos );
var match = rx_name.xexec( subSTR );
if ( match != null || match != undefined ) {
if (match != null) {
var name = match["name"];
if ( name && name.length != 0 && wb.DefinedNames && wb.isDefinedNamesExists( name, ws ? ws.getId() : null ) ) {
this.pCurrPos += name.length;
......@@ -498,59 +463,50 @@ parserHelper.prototype = {
this.operand_str = name;
}
return [false];
},
isArray:function ( formula, start_pos, wb ) {
};
parserHelper.prototype.isArray = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var subSTR = formula.substring( start_pos );
var match = (formula.substring( start_pos )).match( rx_array );
if ( match != null || match != undefined ) {
if (match != null) {
this.operand_str = match[0].substring( 1, match[0].length - 1 );
this.pCurrPos += match[0].length;
return true;
}
return false;
},
isLeftBrace:function ( formula, start_pos ) {
};
parserHelper.prototype.isLeftBrace = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var match = (formula.substring( start_pos )).match( rx_LeftBrace );
if ( match == null || match == undefined )
return false;
else {
if (match != null) {
this.operand_str = match[0].replace( /\s/, "" );
this.pCurrPos += match[0].length;
return true;
}
return false;
},
isRightBrace:function ( formula, start_pos ) {
};
parserHelper.prototype.isRightBrace = function ( formula, start_pos ) {
if ( this instanceof parserHelper ) {
this._reset();
}
var match = (formula.substring( start_pos )).match( rx_RightBrace );
if ( match == null || match == undefined )
return false;
else {
if (match != null) {
this.operand_str = match[0].replace( rx_space, "" );
this.pCurrPos += match[0].length;
return true;
}
return false;
},
// Парсим ссылку на диапазон в листе
parse3DRef:function ( formula ) {
};
// Парсим ссылку на диапазон в листе
parserHelper.prototype.parse3DRef = function ( formula ) {
// Сначала получаем лист
var is3DRefResult = this.is3DRef( formula, 0 );
if ( is3DRefResult && true === is3DRefResult[0] ) {
......@@ -574,26 +530,23 @@ parserHelper.prototype = {
}
// Возвращаем ошибку
return null;
},
// Возвращает ссылку на диапазон с листом (название листа экранируется)
get3DRef: function (sheet, range) {
};
// Возвращает ссылку на диапазон с листом (название листа экранируется)
parserHelper.prototype.get3DRef = function (sheet, range) {
sheet = sheet.split(":");
var wsFrom = sheet[0],
wsTo = sheet[1] === undefined ? wsFrom : sheet[1];
if ( rx_test_ws_name.test( wsFrom ) && rx_test_ws_name.test( wsTo ) ) {
return (wsFrom !== wsTo ? wsFrom + ":" + wsTo : wsFrom) + "!" + range;
}
else{
} else {
wsFrom = wsFrom.replace( /'/g, "''" );
wsTo = wsTo.replace( /'/g, "''" );
return "'" + (wsFrom !== wsTo ? wsFrom + ":" + wsTo : wsFrom) + "'!" + range;
}
},
// Возвращает экранируемое название листа
getEscapeSheetName: function (sheet) {
};
// Возвращает экранируемое название листа
parserHelper.prototype.getEscapeSheetName = function (sheet) {
return rx_test_ws_name.test(sheet) ? sheet : "'" + sheet.replace(/'/g, "''") + "'";
}
};
var parserHelp = new parserHelper();
\ No newline at end of file
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