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
fe0502b0
Commit
fe0502b0
authored
Nov 03, 2016
by
Sergey Luzyanin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://github.com/ONLYOFFICE/sdkjs
into develop
parents
47617874
442cfa53
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
186 additions
and
15 deletions
+186
-15
cell/.unit-tests/FormulaTests.js
cell/.unit-tests/FormulaTests.js
+154
-2
cell/model/FormulaObjects/statisticalFunctions.js
cell/model/FormulaObjects/statisticalFunctions.js
+8
-8
cell/utils/utils.js
cell/utils/utils.js
+15
-0
cell/view/WorksheetView.js
cell/view/WorksheetView.js
+8
-4
common/Private/license.js
common/Private/license.js
+1
-1
No files found.
cell/.unit-tests/FormulaTests.js
View file @
fe0502b0
...
...
@@ -800,6 +800,33 @@ $( function () {
oParser
=
new
parserFormula
(
"
MAX(S5:S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
ws
.
getRange2
(
"
S5
"
).
setValue
(
"
#DIV/0!
"
);
ws
.
getRange2
(
"
S6
"
).
setValue
(
"
TRUE
"
);
ws
.
getRange2
(
"
S7
"
).
setValue
(
"
qwe
"
);
ws
.
getRange2
(
"
S8
"
).
setValue
(
""
);
ws
.
getRange2
(
"
S9
"
).
setValue
(
"
-1
"
);
oParser
=
new
parserFormula
(
"
MAX(S5)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#DIV/0!
"
);
oParser
=
new
parserFormula
(
"
MAX(S6)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MAX(S7)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MAX(S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MAX(S5:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#DIV/0!
"
);
oParser
=
new
parserFormula
(
"
MAX(S6:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
-
1
);
oParser
=
new
parserFormula
(
"
MAX(-1, TRUE)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
}
);
test
(
"
Test:
\"
MAXA
\"
"
,
function
()
{
...
...
@@ -812,6 +839,33 @@ $( function () {
oParser
=
new
parserFormula
(
"
MAXA(S5:S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
ws
.
getRange2
(
"
S5
"
).
setValue
(
"
#DIV/0!
"
);
ws
.
getRange2
(
"
S6
"
).
setValue
(
"
TRUE
"
);
ws
.
getRange2
(
"
S7
"
).
setValue
(
"
qwe
"
);
ws
.
getRange2
(
"
S8
"
).
setValue
(
""
);
ws
.
getRange2
(
"
S9
"
).
setValue
(
"
-1
"
);
oParser
=
new
parserFormula
(
"
MAXA(S5)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#DIV/0!
"
);
oParser
=
new
parserFormula
(
"
MAXA(S6)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
oParser
=
new
parserFormula
(
"
MAXA(S7)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MAXA(S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MAXA(S5:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#DIV/0!
"
);
oParser
=
new
parserFormula
(
"
MAXA(S6:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
oParser
=
new
parserFormula
(
"
MAXA(-1, TRUE)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
}
);
test
(
"
Test:
\"
MIN
\"
"
,
function
()
{
...
...
@@ -824,6 +878,33 @@ $( function () {
oParser
=
new
parserFormula
(
"
MIN(S5:S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
-
1
/
Math
.
fact
(
2
)
);
ws
.
getRange2
(
"
S5
"
).
setValue
(
"
#DIV/0!
"
);
ws
.
getRange2
(
"
S6
"
).
setValue
(
"
TRUE
"
);
ws
.
getRange2
(
"
S7
"
).
setValue
(
"
qwe
"
);
ws
.
getRange2
(
"
S8
"
).
setValue
(
""
);
ws
.
getRange2
(
"
S9
"
).
setValue
(
"
2
"
);
oParser
=
new
parserFormula
(
"
MIN(S5)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#DIV/0!
"
);
oParser
=
new
parserFormula
(
"
MIN(S6)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MIN(S7)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MIN(S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MIN(S5:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#DIV/0!
"
);
oParser
=
new
parserFormula
(
"
MIN(S6:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
2
);
oParser
=
new
parserFormula
(
"
MIN(2, TRUE)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
}
);
test
(
"
Test:
\"
MINA
\"
"
,
function
()
{
...
...
@@ -836,6 +917,33 @@ $( function () {
oParser
=
new
parserFormula
(
"
MINA(S5:S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
-
1
/
Math
.
fact
(
2
)
);
ws
.
getRange2
(
"
S5
"
).
setValue
(
"
#DIV/0!
"
);
ws
.
getRange2
(
"
S6
"
).
setValue
(
"
TRUE
"
);
ws
.
getRange2
(
"
S7
"
).
setValue
(
"
qwe
"
);
ws
.
getRange2
(
"
S8
"
).
setValue
(
""
);
ws
.
getRange2
(
"
S9
"
).
setValue
(
"
2
"
);
oParser
=
new
parserFormula
(
"
MINA(S5)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#DIV/0!
"
);
oParser
=
new
parserFormula
(
"
MINA(S6)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
oParser
=
new
parserFormula
(
"
MINA(S7)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MINA(S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MINA(S5:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
"
#DIV/0!
"
);
oParser
=
new
parserFormula
(
"
MINA(S6:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
MINA(2, TRUE)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
}
);
test
(
"
Test: SUM(S7:S9,{1,2,3})
"
,
function
()
{
...
...
@@ -2051,7 +2159,29 @@ $( function () {
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
ws
.
getRange2
(
"
S5
"
).
setValue
(
"
#DIV/0!
"
);
ws
.
getRange2
(
"
S6
"
).
setValue
(
"
TRUE
"
);
ws
.
getRange2
(
"
S7
"
).
setValue
(
"
qwe
"
);
ws
.
getRange2
(
"
S8
"
).
setValue
(
""
);
ws
.
getRange2
(
"
S9
"
).
setValue
(
"
2
"
);
oParser
=
new
parserFormula
(
"
COUNT(S5)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
COUNT(S6)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
COUNT(S7)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
COUNT(S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
COUNT(S5:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
oParser
=
new
parserFormula
(
"
COUNT(S6:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
}
);
test
(
"
Test:
\"
COUNTA
\"
"
,
function
()
{
...
...
@@ -2078,7 +2208,29 @@ $( function () {
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
2
);
ws
.
getRange2
(
"
S5
"
).
setValue
(
"
#DIV/0!
"
);
ws
.
getRange2
(
"
S6
"
).
setValue
(
"
TRUE
"
);
ws
.
getRange2
(
"
S7
"
).
setValue
(
"
qwe
"
);
ws
.
getRange2
(
"
S8
"
).
setValue
(
""
);
ws
.
getRange2
(
"
S9
"
).
setValue
(
"
2
"
);
oParser
=
new
parserFormula
(
"
COUNTA(S5)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
oParser
=
new
parserFormula
(
"
COUNTA(S6)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
oParser
=
new
parserFormula
(
"
COUNTA(S7)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
1
);
oParser
=
new
parserFormula
(
"
COUNTA(S8)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
0
);
oParser
=
new
parserFormula
(
"
COUNTA(S5:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
4
);
oParser
=
new
parserFormula
(
"
COUNTA(S6:S9)
"
,
"
A1
"
,
ws
);
ok
(
oParser
.
parse
()
);
strictEqual
(
oParser
.
calculate
().
getValue
(),
3
);
}
);
test
(
"
Test:
\"
COUNTIF
\"
"
,
function
()
{
...
...
cell/model/FormulaObjects/statisticalFunctions.js
View file @
fe0502b0
...
...
@@ -2690,7 +2690,7 @@ cMAX.prototype.Calculate = function ( arg ) {
if
(
argI
instanceof
cRef
||
argI
instanceof
cRef3D
)
{
if
(
argIVal
instanceof
cError
)
return
this
.
value
=
argIVal
;
if
(
argIVal
instanceof
cNumber
||
argIVal
instanceof
cBool
||
argIVal
instanceof
cEmpty
)
{
if
(
argIVal
instanceof
cNumber
)
{
var
v
=
argIVal
.
tocNumber
();
if
(
v
.
getValue
()
>
max
)
max
=
v
.
getValue
();
...
...
@@ -2699,7 +2699,7 @@ cMAX.prototype.Calculate = function ( arg ) {
else
if
(
argI
instanceof
cArea
||
argI
instanceof
cArea3D
)
{
var
argArr
=
argI
.
getValue
();
for
(
var
j
=
0
;
j
<
argArr
.
length
;
j
++
)
{
if
(
argArr
[
j
]
instanceof
cNumber
||
argArr
[
j
]
instanceof
cBool
||
argArr
[
j
]
instanceof
cEmpty
)
{
if
(
argArr
[
j
]
instanceof
cNumber
)
{
var
v
=
argArr
[
j
].
tocNumber
();
if
(
v
.
getValue
()
>
max
)
max
=
v
.
getValue
();
...
...
@@ -2742,7 +2742,7 @@ cMAX.prototype.Calculate = function ( arg ) {
max
=
argI
.
getValue
();
}
}
return
this
.
value
=
(
max
.
value
===
Number
.
NEGATIVE_INFINITY
?
new
cNumber
(
0
)
:
new
cNumber
(
max
)
);
return
this
.
value
=
(
max
===
Number
.
NEGATIVE_INFINITY
?
new
cNumber
(
0
)
:
new
cNumber
(
max
)
);
};
cMAX
.
prototype
.
getInfo
=
function
()
{
return
{
...
...
@@ -2832,7 +2832,7 @@ cMAXA.prototype.Calculate = function ( arg ) {
max
=
argI
.
getValue
();
}
}
return
this
.
value
=
(
max
.
value
===
Number
.
NEGATIVE_INFINITY
?
new
cNumber
(
0
)
:
new
cNumber
(
max
)
)
return
this
.
value
=
(
max
===
Number
.
NEGATIVE_INFINITY
?
new
cNumber
(
0
)
:
new
cNumber
(
max
)
)
};
cMAXA
.
prototype
.
getInfo
=
function
()
{
return
{
...
...
@@ -2954,7 +2954,7 @@ cMIN.prototype.Calculate = function ( arg ) {
if
(
argI
instanceof
cRef
||
argI
instanceof
cRef3D
)
{
if
(
argIVal
instanceof
cError
)
return
this
.
value
=
argIVal
;
if
(
argIVal
instanceof
cNumber
||
argIVal
instanceof
cBool
||
argIVal
instanceof
cEmpty
)
{
if
(
argIVal
instanceof
cNumber
)
{
var
v
=
argIVal
.
tocNumber
();
if
(
v
.
getValue
()
<
min
)
min
=
v
.
getValue
();
...
...
@@ -2963,7 +2963,7 @@ cMIN.prototype.Calculate = function ( arg ) {
else
if
(
argI
instanceof
cArea
||
argI
instanceof
cArea3D
)
{
var
argArr
=
argI
.
getValue
();
for
(
var
j
=
0
;
j
<
argArr
.
length
;
j
++
)
{
if
(
argArr
[
j
]
instanceof
cNumber
||
argArr
[
j
]
instanceof
cBool
||
argArr
[
j
]
instanceof
cEmpty
)
{
if
(
argArr
[
j
]
instanceof
cNumber
)
{
var
v
=
argArr
[
j
].
tocNumber
();
if
(
v
.
getValue
()
<
min
)
min
=
v
.
getValue
();
...
...
@@ -3007,7 +3007,7 @@ cMIN.prototype.Calculate = function ( arg ) {
min
=
argI
.
getValue
();
}
}
return
this
.
value
=
(
min
.
value
===
Number
.
POSITIVE_INFINITY
?
new
cNumber
(
0
)
:
new
cNumber
(
min
)
);
return
this
.
value
=
(
min
===
Number
.
POSITIVE_INFINITY
?
new
cNumber
(
0
)
:
new
cNumber
(
min
)
);
};
cMIN
.
prototype
.
getInfo
=
function
()
{
return
{
...
...
@@ -3099,7 +3099,7 @@ cMINA.prototype.Calculate = function ( arg ) {
min
=
argI
.
getValue
();
}
}
return
this
.
value
=
(
min
.
value
===
Number
.
POSITIVE_INFINITY
?
new
cNumber
(
0
)
:
new
cNumber
(
min
)
);
return
this
.
value
=
(
min
===
Number
.
POSITIVE_INFINITY
?
new
cNumber
(
0
)
:
new
cNumber
(
min
)
);
};
cMINA
.
prototype
.
getInfo
=
function
()
{
return
{
...
...
cell/utils/utils.js
View file @
fe0502b0
...
...
@@ -1825,6 +1825,19 @@
asc_CCompleteMenu
.
prototype
.
asc_getName
=
function
()
{
return
this
.
name
;};
asc_CCompleteMenu
.
prototype
.
asc_getType
=
function
()
{
return
this
.
type
;};
function
CCacheMeasureEmpty
()
{
this
.
cache
=
{};
}
CCacheMeasureEmpty
.
prototype
.
add
=
function
(
elem
,
val
)
{
var
font
=
(
this
.
cache
[
elem
.
fn
]
||
(
this
.
cache
[
elem
.
fn
]
=
{}));
font
[
elem
.
fs
]
=
val
;
};
CCacheMeasureEmpty
.
prototype
.
get
=
function
(
elem
)
{
var
font
=
this
.
cache
[
elem
.
fn
];
return
font
?
font
[
elem
.
fs
]
:
null
;
};
var
g_oCacheMeasureEmpty
=
new
CCacheMeasureEmpty
();
/*
* Export
* -----------------------------------------------------------------------------
...
...
@@ -1987,4 +2000,6 @@
prot
=
asc_CCompleteMenu
.
prototype
;
prot
[
"
asc_getName
"
]
=
prot
.
asc_getName
;
prot
[
"
asc_getType
"
]
=
prot
.
asc_getType
;
window
[
"
AscCommonExcel
"
].
g_oCacheMeasureEmpty
=
g_oCacheMeasureEmpty
;
})(
window
);
cell/view/WorksheetView.js
View file @
fe0502b0
...
...
@@ -4472,10 +4472,14 @@
// Пустая ячейка с измененной гарнитурой или размером, учитвается в высоте
str
=
c
.
getValue2
();
if
(
0
<
str
.
length
)
{
// Без текста не будет толка
strCopy
=
[
str
[
0
].
clone
()];
strCopy
[
0
].
text
=
'
A
'
;
tm
=
this
.
_roundTextMetrics
(
this
.
stringRender
.
measureString
(
strCopy
,
fl
));
strCopy
=
str
[
0
];
if
(
!
(
tm
=
AscCommonExcel
.
g_oCacheMeasureEmpty
.
get
(
strCopy
)))
{
// Без текста не будет толка
strCopy
=
strCopy
.
clone
();
strCopy
.
text
=
'
A
'
;
tm
=
this
.
_roundTextMetrics
(
this
.
stringRender
.
measureString
([
strCopy
],
fl
));
AscCommonExcel
.
g_oCacheMeasureEmpty
.
add
(
strCopy
,
tm
);
}
this
.
_updateRowHeight
(
tm
,
col
,
row
,
isMerged
,
fMergedRows
);
}
}
...
...
common/Private/license.js
View file @
fe0502b0
...
...
@@ -38,7 +38,7 @@ AscCommon.baseEditorsApi.prototype._onEndPermissions = function () {
if
(
null
!==
this
.
licenseResult
)
{
var
type
=
this
.
licenseResult
[
'
type
'
];
oResult
.
setLicenseType
(
type
);
oResult
.
setCanBranding
(
Asc
.
c_oLicenseResult
.
Error
!==
type
);
// Для тех, у кого есть лицензия, branding доступен
oResult
.
setCanBranding
(
this
.
licenseResult
[
'
branding
'
]);
oResult
.
setIsLight
(
this
.
licenseResult
[
'
light
'
]);
oResult
.
setTrial
(
this
.
licenseResult
[
'
trial
'
]);
oResult
.
setRights
(
this
.
licenseResult
[
'
rights
'
]);
...
...
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