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
ea8df8bc
Commit
ea8df8bc
authored
Mar 01, 2017
by
Alexander.Trofimov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move matchInfo to matchingValue function
parent
cdb75f73
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
82 deletions
+40
-82
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+6
-27
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+17
-3
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+17
-52
No files found.
cell/model/FormulaObjects/mathematicFunctions.js
View file @
ea8df8bc
...
...
@@ -3996,13 +3996,11 @@ cSQRTPI.prototype.getInfo = function () {
noneFormat
:
-
2
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
operatorRE
=
new
RegExp
(
"
^ *[<=> ]+ *
"
);
this
.
spaceRE
=
/
\s
/g
;
}
cSUMIF
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cSUMIF
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
]
?
arg
[
2
]
:
arg
[
0
],
_sum
=
0
,
valueForSearching
;
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
]
?
arg
[
2
]
:
arg
[
0
],
_sum
=
0
,
matchingInfo
;
if
(
cElementType
.
cell
!==
arg0
.
type
&&
cElementType
.
cell3D
!==
arg0
.
type
&&
cElementType
.
cellsRange
!==
arg0
.
type
)
{
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
arg0
=
arg0
.
tocArea
();
...
...
@@ -4037,21 +4035,13 @@ cSQRTPI.prototype.getInfo = function () {
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
arg1
=
arg1
.
toString
();
var
match
=
arg1
.
match
(
this
.
operatorRE
),
search
,
oper
;
if
(
match
)
{
search
=
arg1
.
substr
(
match
[
0
].
length
);
oper
=
match
[
0
].
replace
(
this
.
spaceRE
,
""
);
}
else
{
search
=
arg1
;
}
valueForSearching
=
AscCommonExcel
.
matchingValue
(
search
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
.
toString
());
if
(
cElementType
.
cellsRange
===
arg0
.
type
)
{
var
arg0Matrix
=
arg0
.
getMatrix
(),
arg2Matrix
=
arg2
.
getMatrix
(),
valMatrix2
;
for
(
var
i
=
0
;
i
<
arg0Matrix
.
length
;
i
++
)
{
for
(
var
j
=
0
;
j
<
arg0Matrix
[
i
].
length
;
j
++
)
{
if
(
arg2Matrix
[
i
]
&&
(
valMatrix2
=
arg2Matrix
[
i
][
j
])
&&
cElementType
.
number
===
valMatrix2
.
type
&&
AscCommonExcel
.
matching
(
arg0Matrix
[
i
][
j
],
valueForSearching
,
oper
))
{
AscCommonExcel
.
matching
(
arg0Matrix
[
i
][
j
],
matchingInfo
))
{
_sum
+=
valMatrix2
.
getValue
();
}
}
...
...
@@ -4081,8 +4071,6 @@ cSQRTPI.prototype.getInfo = function () {
noneFormat
:
-
2
};
this
.
numFormat
=
this
.
formatType
.
def
;
this
.
operatorRE
=
new
RegExp
(
"
^ *[<=> ]+ *
"
);
this
.
spaceRE
=
/
\s
/g
;
}
cSUMIFS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
...
...
@@ -4100,7 +4088,7 @@ cSQRTPI.prototype.getInfo = function () {
}
var
arg0Matrix
=
arg0
.
getMatrix
();
var
i
,
j
,
arg1
,
arg2
,
valueForSearching
,
match
,
search
,
oper
;
var
i
,
j
,
arg1
,
arg2
,
matchingInfo
;
for
(
var
k
=
1
;
k
<
arg
.
length
;
k
+=
2
)
{
arg1
=
arg
[
k
];
arg2
=
arg
[
k
+
1
];
...
...
@@ -4128,16 +4116,7 @@ cSQRTPI.prototype.getInfo = function () {
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
arg2
=
arg2
.
toString
();
match
=
arg2
.
match
(
this
.
operatorRE
);
if
(
match
)
{
search
=
arg2
.
substr
(
match
[
0
].
length
);
oper
=
match
[
0
].
replace
(
this
.
spaceRE
,
""
);
}
else
{
search
=
arg2
;
oper
=
null
;
}
valueForSearching
=
AscCommonExcel
.
matchingValue
(
search
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
.
toString
());
var
arg1Matrix
=
arg1
.
getMatrix
();
if
(
arg0Matrix
.
length
!==
arg1Matrix
.
length
)
{
...
...
@@ -4148,7 +4127,7 @@ cSQRTPI.prototype.getInfo = function () {
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
for
(
j
=
0
;
j
<
arg1Matrix
[
i
].
length
;
++
j
)
{
if
(
arg0Matrix
[
i
][
j
]
&&
!
AscCommonExcel
.
matching
(
arg1Matrix
[
i
][
j
],
valueForSearching
,
oper
))
{
if
(
arg0Matrix
[
i
][
j
]
&&
!
AscCommonExcel
.
matching
(
arg1Matrix
[
i
][
j
],
matchingInfo
))
{
arg0Matrix
[
i
][
j
]
=
null
;
}
}
...
...
cell/model/FormulaObjects/parserFormula.js
View file @
ea8df8bc
...
...
@@ -5364,11 +5364,25 @@ function parseNum( str ) {
return
!
isNaN
(
str
);
}
function
matchingValue
(
search
)
{
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
,
""
);
}
else
{
search
=
val
;
op
=
null
;
}
var
parseRes
=
AscCommon
.
g_oFormatParser
.
parse
(
search
);
return
parseRes
?
new
cNumber
(
parseRes
.
value
)
:
new
cString
(
search
)
;
return
{
val
:
parseRes
?
new
cNumber
(
parseRes
.
value
)
:
new
cString
(
search
),
op
:
op
}
;
}
function
matching
(
x
,
y
,
operator
)
{
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
)
{
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
ea8df8bc
...
...
@@ -560,7 +560,7 @@
cAVERAGEIF
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cAVERAGEIF
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
]
?
arg
[
2
]
:
arg
[
0
],
_sum
=
0
,
_count
=
0
,
valueForSearching
,
ws
;
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
]
?
arg
[
2
]
:
arg
[
0
],
_sum
=
0
,
_count
=
0
,
matchingInfo
,
ws
;
if
((
cElementType
.
cell
!==
arg0
.
type
&&
cElementType
.
cell3D
!==
arg0
.
type
&&
cElementType
.
cellsRange
!==
arg0
.
type
)
||
(
cElementType
.
cell
!==
arg2
.
type
&&
cElementType
.
cell3D
!==
arg2
.
type
&&
...
...
@@ -581,19 +581,13 @@
}
arg1
=
arg1
.
toString
();
var
operators
=
new
RegExp
(
"
^ *[<=> ]+ *
"
),
match
=
arg1
.
match
(
operators
),
search
,
oper
,
val
;
if
(
match
)
{
search
=
arg1
.
substr
(
match
[
0
].
length
);
oper
=
match
[
0
].
replace
(
/
\s
/g
,
""
);
}
else
{
search
=
arg1
;
}
valueForSearching
=
AscCommonExcel
.
matchingValue
(
search
);
var
val
;
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
.
toString
());
if
(
cElementType
.
cellsRange
===
arg0
.
type
)
{
ws
=
arg0
.
getWS
();
var
tmpCellArg0
=
arg0
.
getRange
().
getCells
()[
0
],
tmpCellArg2
=
arg2
.
getRange
(),
offset
,
bbox
,
r2
;
arg0
.
foreach2
(
function
(
v
,
cell
)
{
if
(
matching
(
v
,
valueForSearching
,
oper
))
{
if
(
matching
(
v
,
matchingInfo
))
{
offset
=
cell
.
getOffset
(
tmpCellArg0
);
tmpCellArg2
=
arg2
.
getRange
();
tmpCellArg2
.
setOffset
(
offset
);
...
...
@@ -613,7 +607,7 @@
})
}
else
{
val
=
arg0
.
getValue
();
if
(
matching
(
val
,
valueForSearching
,
oper
))
{
if
(
matching
(
val
,
matchingInfo
))
{
var
r
=
arg0
.
getRange
();
ws
=
arg0
.
getWS
();
var
r1
=
r
.
bbox
.
r1
,
c1
=
arg2
.
getRange
().
bbox
.
c1
;
...
...
@@ -661,7 +655,7 @@
}
var
arg0Matrix
=
arg0
.
getMatrix
();
var
i
,
j
,
arg1
,
arg2
,
operators
,
match
,
search
,
oper
,
valueForSearching
;
var
i
,
j
,
arg1
,
arg2
,
matchingInfo
;
for
(
var
k
=
1
;
k
<
arg
.
length
;
k
+=
2
)
{
arg1
=
arg
[
k
];
arg2
=
arg
[
k
+
1
];
...
...
@@ -681,18 +675,7 @@
if
(
cElementType
.
string
!==
arg2
.
type
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
arg2
=
arg2
.
toString
();
operators
=
new
RegExp
(
"
^ *[<=> ]+ *
"
);
match
=
arg2
.
match
(
operators
);
if
(
match
)
{
search
=
arg2
.
substr
(
match
[
0
].
length
);
oper
=
match
[
0
].
replace
(
/
\s
/g
,
""
);
}
else
{
search
=
arg2
;
oper
=
null
;
}
valueForSearching
=
AscCommonExcel
.
matchingValue
(
search
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg2
.
toString
());
var
arg1Matrix
=
arg1
.
getMatrix
();
if
(
arg0Matrix
.
length
!==
arg1Matrix
.
length
)
{
...
...
@@ -704,7 +687,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
for
(
j
=
0
;
j
<
arg1Matrix
[
i
].
length
;
++
j
)
{
if
(
arg0Matrix
[
i
][
j
]
&&
!
AscCommonExcel
.
matching
(
arg1Matrix
[
i
][
j
],
valueForSearching
,
oper
))
{
if
(
arg0Matrix
[
i
][
j
]
&&
!
AscCommonExcel
.
matching
(
arg1Matrix
[
i
][
j
],
matchingInfo
))
{
arg0Matrix
[
i
][
j
]
=
null
;
}
}
...
...
@@ -1172,7 +1155,7 @@
cCOUNTIF
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOUNTIF
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
_count
=
0
,
valueForSearching
;
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
_count
=
0
,
matchingInfo
;
if
(
cElementType
.
cell
!==
arg0
.
type
&&
cElementType
.
cell3D
!==
arg0
.
type
&&
cElementType
.
cellsRange
!==
arg0
.
type
&&
cElementType
.
cellsRange3D
!==
arg0
.
type
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
...
...
@@ -1189,28 +1172,20 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
arg1
=
arg1
.
toString
();
var
operators
=
new
RegExp
(
"
^ *[<=> ]+ *
"
),
search
,
oper
,
val
,
match
=
arg1
.
match
(
operators
);
if
(
match
)
{
search
=
arg1
.
substr
(
match
[
0
].
length
);
oper
=
match
[
0
].
replace
(
/
\s
/g
,
""
);
}
else
{
search
=
arg1
;
}
valueForSearching
=
AscCommonExcel
.
matchingValue
(
search
);
var
val
;
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
.
toString
());
if
(
cElementType
.
cellsRange
===
arg0
.
type
)
{
arg0
.
foreach2
(
function
(
_val
)
{
_count
+=
matching
(
_val
,
valueForSearching
,
oper
);
_count
+=
matching
(
_val
,
matchingInfo
);
})
}
else
if
(
cElementType
.
cellsRange3D
===
arg0
.
type
)
{
val
=
arg0
.
getValue
();
for
(
var
i
=
0
;
i
<
val
.
length
;
i
++
)
{
_count
+=
matching
(
val
[
i
],
valueForSearching
,
oper
);
_count
+=
matching
(
val
[
i
],
matchingInfo
);
}
}
else
{
val
=
arg0
.
getValue
();
_count
+=
matching
(
val
,
valueForSearching
,
oper
);
_count
+=
matching
(
val
,
matchingInfo
);
}
return
this
.
value
=
new
cNumber
(
_count
);
...
...
@@ -1238,8 +1213,7 @@
cCOUNTIFS
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cCOUNTIFS
.
prototype
.
Calculate
=
function
(
arg
)
{
var
i
,
j
,
arg0
,
arg1
,
valueForSearching
,
arg0Matrix
,
arg1Matrix
,
_count
=
0
;
var
search
,
oper
,
match
,
operators
=
new
RegExp
(
"
^ *[<=> ]+ *
"
);
var
i
,
j
,
arg0
,
arg1
,
matchingInfo
,
arg0Matrix
,
arg1Matrix
,
_count
=
0
;
for
(
var
k
=
0
;
k
<
arg
.
length
;
k
+=
2
)
{
arg0
=
arg
[
k
];
arg1
=
arg
[
k
+
1
];
...
...
@@ -1258,16 +1232,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
arg1
=
arg1
.
toString
();
match
=
arg1
.
match
(
operators
);
if
(
match
)
{
search
=
arg1
.
substr
(
match
[
0
].
length
);
oper
=
match
[
0
].
replace
(
/
\s
/g
,
""
);
}
else
{
search
=
arg1
;
oper
=
null
;
}
valueForSearching
=
AscCommonExcel
.
matchingValue
(
search
);
matchingInfo
=
AscCommonExcel
.
matchingValue
(
arg1
.
toString
());
arg1Matrix
=
arg0
.
getMatrix
();
if
(
!
arg0Matrix
)
{
arg0Matrix
=
arg1Matrix
;
...
...
@@ -1280,7 +1245,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
for
(
j
=
0
;
j
<
arg1Matrix
[
i
].
length
;
++
j
)
{
if
(
arg0Matrix
[
i
][
j
]
&&
!
matching
(
arg1Matrix
[
i
][
j
],
valueForSearching
,
oper
))
{
if
(
arg0Matrix
[
i
][
j
]
&&
!
matching
(
arg1Matrix
[
i
][
j
],
matchingInfo
))
{
arg0Matrix
[
i
][
j
]
=
null
;
}
}
...
...
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