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

fix:

Bug 30182 - SyntaxError: \ at end of pattern при вычислении формул (http://bugzserver/show_bug.cgi?id=30182)
Bug 27782 - Формулы при проверке значений в ячейках чувствительны к регистру (http://bugzserver/show_bug.cgi?id=27782)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64437 954022d7-b5bf-4e40-9824-e11837661b57
parent fa635ce4
......@@ -222,6 +222,10 @@ Math.sign = function ( x ) {
return x > 0 ? 1 : x < 0 ? -1 : 0;
};
RegExp.escape = function(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
}
String.prototype.repeat = function ( s, n ) {
var a = [];
while ( a.length < n ) {
......@@ -2393,7 +2397,7 @@ _func[cElementType.string][cElementType.string] = function ( arg0, arg1, what )
return new cBool( arg0.getValue().toLowerCase() === arg1.getValue().toLowerCase() );
}
else if ( what === "<>" ) {
return new cBool( arg0.getValue() !== arg1.getValue() );
return new cBool( arg0.getValue().toLowerCase() !== arg1.getValue().toLowerCase() );
}
else if ( what === "-" ) {
_arg0 = arg0.tocNumber();
......
......@@ -589,7 +589,7 @@ cFIND.prototype.Calculate = function ( arg ) {
if ( arg1 instanceof cError ) return this.value = arg1;
str = arg1.getValue();
searchStr = arg0.getValue();
searchStr = RegExp.escape(arg0.getValue());
if ( arg2 ) {
......@@ -1550,12 +1550,12 @@ cSUBSTITUTE.prototype.Calculate = function ( arg ) {
return this.value = new cError( cErrorType.wrong_value_type );
}
var string = arg0.getValue(), old_string = arg1.getValue(), new_string = arg2.getValue(), index = 0, res;
res = string.replace( new RegExp( old_string, "g" ), function ( equal, p1, source ) {
var string = arg0.getValue(), old_string = arg1.getValue(), new_string = arg2.getValue(), occurence = arg3.getValue(), index = 0, res;
res = string.replace( new RegExp( RegExp.escape(old_string), "g" ), function ( equal, p1, source ) {
index++;
if ( arg3.getValue() == 0 || arg3.getValue() > source.length )
if ( occurence == 0 || occurence > source.length )
return new_string;
else if ( arg3.getValue() == index ) {
else if ( occurence == index ) {
return new_string;
}
return equal;
......
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