Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
7fe0a878
Commit
7fe0a878
authored
Sep 07, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify matchingValue/matching functions
parent
527168b2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
37 deletions
+46
-37
cell/model/FormulaObjects/databaseFunctions.js
cell/model/FormulaObjects/databaseFunctions.js
+2
-2
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+2
-2
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+33
-12
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+9
-21
No files found.
cell/model/FormulaObjects/databaseFunctions.js
View file @
7fe0a878
...
...
@@ -51,9 +51,9 @@
return
false
;
}
condition
=
condition
.
getValue
();
//
condition = condition.getValue();
if
(
""
===
condition
){
if
(
""
===
condition
.
value
){
res
=
true
;
}
else
{
var
conditionObj
=
AscCommonExcel
.
matchingValue
(
condition
);
...
...
cell/model/FormulaObjects/mathematicFunctions.js
View file @
7fe0a878
...
...
@@ -4464,7 +4464,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
.
toString
()
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
);
if
(
cElementType
.
cellsRange
===
arg0
.
type
)
{
var
arg0Matrix
=
arg0
.
getMatrix
(),
arg2Matrix
=
arg2
.
getMatrix
(),
valMatrix2
;
for
(
var
i
=
0
;
i
<
arg0Matrix
.
length
;
i
++
)
{
...
...
@@ -4539,7 +4539,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
.
toString
()
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
);
var
arg1Matrix
=
arg1
.
getMatrix
();
if
(
arg0Matrix
.
length
!==
arg1Matrix
.
length
)
{
...
...
cell/model/FormulaObjects/parserFormula.js
View file @
7fe0a878
...
...
@@ -5778,26 +5778,36 @@ function parseNum( str ) {
var
matchingOperators
=
new
RegExp
(
"
^ *[<=> ]+ *
"
);
function
matchingValue
(
val
)
{
var
search
,
op
;
var
match
=
val
.
match
(
matchingOperators
);
if
(
match
)
{
search
=
val
.
substr
(
match
[
0
].
length
);
op
=
match
[
0
].
replace
(
/
\s
/g
,
""
);
function
matchingValue
(
oVal
)
{
var
res
;
if
(
cElementType
.
string
===
oVal
.
type
){
var
search
,
op
;
var
val
=
oVal
.
getValue
();
var
match
=
val
.
match
(
matchingOperators
);
if
(
match
)
{
search
=
val
.
substr
(
match
[
0
].
length
);
op
=
match
[
0
].
replace
(
/
\s
/g
,
""
);
}
else
{
search
=
val
;
op
=
null
;
}
var
parseRes
=
AscCommon
.
g_oFormatParser
.
parse
(
search
);
res
=
{
val
:
parseRes
?
new
cNumber
(
parseRes
.
value
)
:
new
cString
(
search
),
op
:
op
};
}
else
{
search
=
val
;
op
=
null
;
res
=
{
val
:
oVal
,
op
:
null
};
}
var
parseRes
=
AscCommon
.
g_oFormatParser
.
parse
(
search
);
return
{
val
:
parseRes
?
new
cNumber
(
parseRes
.
value
)
:
new
cString
(
search
),
op
:
op
};
return
res
;
}
function
matching
(
x
,
matchingInfo
)
{
var
y
=
matchingInfo
.
val
;
var
operator
=
matchingInfo
.
op
;
var
res
=
false
,
rS
;
if
(
cElementType
.
string
===
y
.
type
)
{
if
(
'
<
'
===
operator
||
'
>
'
===
operator
||
'
<=
'
===
operator
||
'
>=
'
===
operator
)
{
if
(
cElementType
.
number
===
y
.
type
&&
(
'
<
'
===
operator
||
'
>
'
===
operator
||
'
<=
'
===
operator
||
'
>=
'
===
operator
)
)
{
var
_funcVal
=
_func
[
x
.
type
][
y
.
type
](
x
,
y
,
operator
);
if
(
cElementType
.
error
===
_funcVal
.
type
){
return
false
;
...
...
@@ -5823,7 +5833,7 @@ function parseNum( str ) {
res
=
rS
;
break
;
}
}
else
{
}
else
if
(
cElementType
.
number
===
y
.
type
)
{
rS
=
(
x
.
type
===
y
.
type
);
switch
(
operator
)
{
case
"
<>
"
:
...
...
@@ -5843,9 +5853,20 @@ function parseNum( str ) {
break
;
case
"
=
"
:
default
:
if
(
cElementType
.
string
===
x
.
type
){
x
=
x
.
tocNumber
();
}
res
=
(
x
.
value
===
y
.
value
);
break
;
}
}
else
if
(
cElementType
.
bool
===
y
.
type
)
{
if
(
y
.
type
===
x
.
type
&&
x
.
value
===
y
.
value
){
res
=
true
;
}
}
else
if
(
cElementType
.
error
===
y
.
type
)
{
if
(
y
.
type
===
x
.
type
&&
x
.
value
===
y
.
value
){
res
=
true
;
}
}
return
res
;
}
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
7fe0a878
...
...
@@ -1597,11 +1597,10 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
arg1
=
arg1
.
toString
();
var
r
=
arg0
.
getRange
();
var
r2
=
arg2
.
getRange
();
ws
=
arg0
.
getWS
();
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
.
toString
()
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
);
if
(
cElementType
.
cellsRange
===
arg0
.
type
)
{
arg0
.
foreach2
(
function
(
v
,
cell
)
{
if
(
matching
(
v
,
matchingInfo
))
{
...
...
@@ -1678,7 +1677,7 @@
if
(
cElementType
.
string
!==
arg2
.
type
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
.
toString
()
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
);
var
arg1Matrix
=
arg1
.
getMatrix
();
if
(
arg0Matrix
.
length
!==
arg1Matrix
.
length
)
{
...
...
@@ -2686,31 +2685,20 @@
return this.value = new cError(cErrorType.wrong_value_type);
}*/
var
compareValues
=
function
(
val
,
matchingInfo
){
var
res
;
if
(
val
.
type
===
arg1
.
type
&&
val
.
value
===
arg1
.
value
){
return
true
;
}
res
=
matching
(
val
,
matchingInfo
);
return
res
;
};
var
val
;
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
.
toString
()
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
);
if
(
cElementType
.
cellsRange
===
arg0
.
type
)
{
arg0
.
foreach2
(
function
(
_val
)
{
_count
+=
compareValues
(
_val
,
matchingInfo
);
_count
+=
matching
(
_val
,
matchingInfo
);
})
}
else
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
val
=
arg0
.
getValue
();
for
(
var
i
=
0
;
i
<
val
.
length
;
i
++
)
{
_count
+=
compareValues
(
val
[
i
],
matchingInfo
);
_count
+=
matching
(
val
[
i
],
matchingInfo
);
}
}
else
{
val
=
arg0
.
getValue
();
_count
+=
compareValues
(
val
,
matchingInfo
);
_count
+=
matching
(
val
,
matchingInfo
);
}
return
this
.
value
=
new
cNumber
(
_count
);
...
...
@@ -2752,7 +2740,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
.
toString
()
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
);
arg1Matrix
=
arg0
.
getMatrix
();
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
arg1Matrix
=
arg1Matrix
[
0
];
...
...
@@ -5136,7 +5124,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
.
toString
()
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
);
var
arg1Matrix
=
arg1
.
getMatrix
();
if
(
arg0Matrix
.
length
!==
arg1Matrix
.
length
)
{
...
...
@@ -5241,7 +5229,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
.
toString
()
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
);
var
arg1Matrix
=
arg1
.
getMatrix
();
if
(
arg0Matrix
.
length
!==
arg1Matrix
.
length
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment