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
5a8f5f6f
Commit
5a8f5f6f
authored
Apr 04, 2017
by
Sergey Konovalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
function property 'ca' moved to function prototype and calculate at parsing
parent
777a8b94
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
57 deletions
+53
-57
cell/model/FormulaObjects/dateandtimeFunctions.js
cell/model/FormulaObjects/dateandtimeFunctions.js
+27
-27
cell/model/FormulaObjects/lookupandreferenceFunctions.js
cell/model/FormulaObjects/lookupandreferenceFunctions.js
+5
-3
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+4
-2
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+17
-23
cell/model/Workbook.js
cell/model/Workbook.js
+0
-2
No files found.
cell/model/FormulaObjects/dateandtimeFunctions.js
View file @
5a8f5f6f
...
...
@@ -581,22 +581,20 @@
return
this
.
value
=
new
cError
(
cErrorType
.
not_numeric
);
}
else
if
(
!
AscCommon
.
bDate1904
)
{
if
(
val
<
60
)
{
return
this
.
setCA
(
new
cNumber
((
new
Date
((
val
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
)
).
getUTCDate
()),
false
,
0
);
return
this
.
setCalcValue
(
new
cNumber
((
new
Date
((
val
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
)
).
getUTCDate
()),
0
);
}
else
if
(
val
==
60
)
{
return
this
.
setC
A
(
return
this
.
setC
alcValue
(
new
cNumber
((
new
Date
((
val
-
AscCommonExcel
.
c_DateCorrectConst
-
1
)
*
c_msPerDay
)
).
getUTCDate
()
+
1
),
false
,
0
);
1
),
0
);
}
else
{
return
this
.
setC
A
(
return
this
.
setC
alcValue
(
new
cNumber
((
new
Date
((
val
-
AscCommonExcel
.
c_DateCorrectConst
-
1
)
*
c_msPerDay
)
).
getUTCDate
()),
false
,
0
);
0
);
}
}
else
{
return
this
.
setCA
(
new
cNumber
((
new
Date
((
val
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
)
).
getUTCDate
()),
false
,
0
);
return
this
.
setCalcValue
(
new
cNumber
((
new
Date
((
val
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
)
).
getUTCDate
()),
0
);
}
};
cDAY
.
prototype
.
getInfo
=
function
()
{
...
...
@@ -879,8 +877,8 @@
return
this
.
value
=
new
cError
(
cErrorType
.
not_numeric
);
}
else
//1 2 3 4 4 3 2 1
{
return
this
.
setC
A
(
new
cNumber
(
parseInt
((
(
val
-
Math
.
floor
(
val
)
)
*
24
).
toFixed
(
cExcelDateTimeDigits
))),
false
,
0
);
return
this
.
setC
alcValue
(
new
cNumber
(
parseInt
((
(
val
-
Math
.
floor
(
val
)
)
*
24
).
toFixed
(
cExcelDateTimeDigits
))),
0
);
}
};
cHOUR
.
prototype
.
getInfo
=
function
()
{
...
...
@@ -947,7 +945,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
not_numeric
);
}
else
{
val
=
parseInt
((
(
val
*
24
-
Math
.
floor
(
val
*
24
)
)
*
60
).
toFixed
(
cExcelDateTimeDigits
))
%
60
;
return
this
.
setC
A
(
new
cNumber
(
val
),
false
,
0
);
return
this
.
setC
alcValue
(
new
cNumber
(
val
)
,
0
);
}
};
cMINUTE
.
prototype
.
getInfo
=
function
()
{
...
...
@@ -1011,15 +1009,15 @@
}
if
(
!
AscCommon
.
bDate1904
)
{
if
(
val
==
60
)
{
return
this
.
setC
A
(
new
cNumber
(
2
),
false
,
0
);
return
this
.
setC
alcValue
(
new
cNumber
(
2
)
,
0
);
}
else
{
return
this
.
setC
A
(
return
this
.
setC
alcValue
(
new
cNumber
((
new
Date
((
(
val
==
0
?
1
:
val
)
-
AscCommonExcel
.
c_DateCorrectConst
-
1
)
*
c_msPerDay
)
).
getUTCMonth
()
+
1
),
false
,
0
);
c_msPerDay
)
).
getUTCMonth
()
+
1
),
0
);
}
}
else
{
return
this
.
setC
A
(
new
cNumber
((
new
Date
((
(
val
==
0
?
1
:
val
)
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
)
).
getUTCMonth
()
+
1
),
false
,
0
);
return
this
.
setC
alcValue
(
new
cNumber
((
new
Date
((
(
val
==
0
?
1
:
val
)
-
AscCommonExcel
.
c_DateCorrectConst
)
*
c_msPerDay
)
).
getUTCMonth
()
+
1
),
0
);
}
};
cMONTH
.
prototype
.
getInfo
=
function
()
{
...
...
@@ -1181,12 +1179,13 @@
cNOW
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cNOW
.
prototype
.
constructor
=
cNOW
;
cNOW
.
prototype
.
argumentsMax
=
0
;
cNOW
.
prototype
.
ca
=
true
;
cNOW
.
prototype
.
Calculate
=
function
()
{
var
d
=
new
Date
();
this
.
value
=
new
cNumber
(
d
.
getExcelDate
()
+
(
d
.
getHours
()
*
60
*
60
+
d
.
getMinutes
()
*
60
+
d
.
getSeconds
())
/
c_sPerDay
);
this
.
value
.
numFormat
=
22
;
return
this
.
setCA
(
this
.
value
,
true
)
;
return
this
.
value
;
};
cNOW
.
prototype
.
getInfo
=
function
()
{
return
{
...
...
@@ -1252,7 +1251,7 @@
return
this
.
value
=
new
cError
(
cErrorType
.
not_numeric
);
}
else
{
val
=
parseInt
(((
val
*
24
*
60
-
Math
.
floor
(
val
*
24
*
60
)
)
*
60
).
toFixed
(
cExcelDateTimeDigits
))
%
60
;
return
this
.
setC
A
(
new
cNumber
(
val
),
false
,
0
);
return
this
.
setC
alcValue
(
new
cNumber
(
val
)
,
0
);
}
};
cSECOND
.
prototype
.
getInfo
=
function
()
{
...
...
@@ -1313,7 +1312,7 @@
second
=
second
.
getValue
();
var
v
=
(
hour
*
60
*
60
+
minute
*
60
+
second
)
/
c_sPerDay
;
this
.
setCA
(
new
cNumber
(
v
-
Math
.
floor
(
v
)),
false
);
this
.
value
=
new
cNumber
(
v
-
Math
.
floor
(
v
)
);
if
(
arguments
[
1
].
getNumFormatStr
().
toLowerCase
()
===
"
general
"
)
{
this
.
value
.
numFormat
=
18
;
}
...
...
@@ -1382,8 +1381,9 @@
cTODAY
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cTODAY
.
prototype
.
constructor
=
cTODAY
;
cTODAY
.
prototype
.
argumentsMax
=
0
;
cTODAY
.
prototype
.
ca
=
true
;
cTODAY
.
prototype
.
Calculate
=
function
()
{
this
.
setCA
(
new
cNumber
(
new
Date
().
getExcelDate
()),
true
);
this
.
value
=
new
cNumber
(
new
Date
().
getExcelDate
()
);
if
(
arguments
[
1
].
getNumFormatStr
().
toLowerCase
()
===
"
general
"
)
{
this
.
value
.
numFormat
=
14
;
}
...
...
@@ -1719,9 +1719,9 @@
}
if
(
arguments
[
1
].
getNumFormatStr
().
toLowerCase
()
===
"
general
"
)
{
return
this
.
setC
A
(
new
cNumber
(
val
),
false
,
14
);
return
this
.
setC
alcValue
(
new
cNumber
(
val
)
,
14
);
}
else
{
return
this
.
setCA
(
new
cNumber
(
val
),
false
);
return
this
.
value
=
new
cNumber
(
val
);
}
};
cWORKDAY
.
prototype
.
getInfo
=
function
()
{
...
...
@@ -1794,11 +1794,11 @@
}
}
if
(
val
<
0
)
{
return
this
.
setC
A
(
new
cError
(
cErrorType
.
not_numeric
),
false
,
0
);
return
this
.
setC
alcValue
(
new
cError
(
cErrorType
.
not_numeric
)
,
0
);
}
else
{
return
this
.
setC
A
(
return
this
.
setC
alcValue
(
new
cNumber
((
new
Date
((
val
-
(
AscCommonExcel
.
c_DateCorrectConst
+
1
))
*
c_msPerDay
)).
getUTCFullYear
()),
false
,
0
);
0
);
}
};
cYEAR
.
prototype
.
getInfo
=
function
()
{
...
...
cell/model/FormulaObjects/lookupandreferenceFunctions.js
View file @
5a8f5f6f
...
...
@@ -567,6 +567,7 @@
cINDIRECT
.
prototype
.
constructor
=
cINDIRECT
;
cINDIRECT
.
prototype
.
argumentsMin
=
1
;
cINDIRECT
.
prototype
.
argumentsMax
=
2
;
cINDIRECT
.
prototype
.
ca
=
true
;
cINDIRECT
.
prototype
.
Calculate
=
function
(
arg
)
{
var
t
=
this
,
arg0
=
arg
[
0
].
tocString
(),
arg1
=
arg
[
1
]
?
arg
[
1
]
:
new
cBool
(
true
),
r1
=
arguments
[
1
],
wb
=
r1
.
worksheet
.
workbook
,
o
=
{
...
...
@@ -608,7 +609,7 @@
}
ret
.
addElement
(
found_operand
)
});
return
this
.
setCA
(
ret
,
true
)
;
return
this
.
value
=
ret
;
}
else
{
o
.
Formula
=
arg0
.
toString
();
parseReference
();
...
...
@@ -623,7 +624,7 @@
}
}
return
this
.
setCA
(
ret
,
true
)
;
return
this
.
value
=
ret
;
};
cINDIRECT
.
prototype
.
getInfo
=
function
()
{
...
...
@@ -906,6 +907,7 @@
cOFFSET
.
prototype
.
constructor
=
cOFFSET
;
cOFFSET
.
prototype
.
argumentsMin
=
3
;
cOFFSET
.
prototype
.
argumentsMax
=
5
;
cOFFSET
.
prototype
.
ca
=
true
;
cOFFSET
.
prototype
.
Calculate
=
function
(
arg
)
{
function
validBBOX
(
bbox
)
{
...
...
@@ -987,7 +989,7 @@
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
return
this
.
setCA
(
this
.
value
,
true
)
;
return
this
.
value
;
};
cOFFSET
.
prototype
.
getInfo
=
function
()
{
...
...
cell/model/FormulaObjects/mathematicFunctions.js
View file @
5a8f5f6f
...
...
@@ -2564,8 +2564,9 @@
cRAND
.
prototype
=
Object
.
create
(
cBaseFunction
.
prototype
);
cRAND
.
prototype
.
constructor
=
cRAND
;
cRAND
.
prototype
.
argumentsMax
=
0
;
cRAND
.
prototype
.
ca
=
true
;
cRAND
.
prototype
.
Calculate
=
function
()
{
return
this
.
setCA
(
new
cNumber
(
Math
.
random
()),
true
);
return
this
.
value
=
new
cNumber
(
Math
.
random
()
);
};
cRAND
.
prototype
.
getInfo
=
function
()
{
return
{
...
...
@@ -2587,6 +2588,7 @@
cRANDBETWEEN
.
prototype
.
constructor
=
cRANDBETWEEN
;
cRANDBETWEEN
.
prototype
.
argumentsMin
=
2
;
cRANDBETWEEN
.
prototype
.
argumentsMax
=
2
;
cRANDBETWEEN
.
prototype
.
ca
=
true
;
cRANDBETWEEN
.
prototype
.
Calculate
=
function
(
arg
)
{
function
randBetween
(
a
,
b
)
{
...
...
@@ -2644,7 +2646,7 @@
}
return
this
.
setCA
(
new
cNumber
(
randBetween
(
arg0
.
getValue
(),
arg1
.
getValue
())),
true
);
return
this
.
value
=
new
cNumber
(
randBetween
(
arg0
.
getValue
(),
arg1
.
getValue
())
);
};
cRANDBETWEEN
.
prototype
.
getInfo
=
function
()
{
return
{
...
...
cell/model/FormulaObjects/parserFormula.js
View file @
5a8f5f6f
...
...
@@ -634,7 +634,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
function
cBaseType
(
val
)
{
this
.
needRecalc
=
false
;
this
.
numFormat
=
null
;
this
.
ca
=
false
;
this
.
value
=
val
;
}
...
...
@@ -642,7 +641,6 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
oRes
.
needRecalc
=
this
.
needRecalc
;
oRes
.
numFormat
=
this
.
numFormat
;
oRes
.
value
=
this
.
value
;
oRes
.
ca
=
this
.
ca
;
};
cBaseType
.
prototype
.
getValue
=
function
()
{
return
this
.
value
;
...
...
@@ -2282,6 +2280,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cBaseFunction
.
prototype
.
argumentsMin
=
0
;
cBaseFunction
.
prototype
.
argumentsMax
=
255
;
cBaseFunction
.
prototype
.
numFormat
=
c_numFormatFirstCell
;
cBaseFunction
.
prototype
.
ca
=
false
;
cBaseFunction
.
prototype
.
Calculate
=
function
()
{
this
.
value
=
new
cError
(
cErrorType
.
wrong_name
);
return
this
.
value
;
...
...
@@ -2341,11 +2340,8 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cBaseFunction
.
prototype
.
toString
=
function
()
{
return
this
.
name
.
replace
(
rx_sFuncPref
,
"
_xlfn.
"
);
};
cBaseFunction
.
prototype
.
setC
A
=
function
(
arg
,
ca
,
numFormat
)
{
cBaseFunction
.
prototype
.
setC
alcValue
=
function
(
arg
,
numFormat
)
{
this
.
value
=
arg
;
if
(
ca
)
{
this
.
value
.
ca
=
true
;
}
if
(
numFormat
!==
null
&&
numFormat
!==
undefined
)
{
this
.
value
.
numFormat
=
numFormat
;
}
...
...
@@ -4258,6 +4254,9 @@ parserFormula.prototype.parse = function(local, digitDelim) {
elem
=
new
cBaseFunction
(
val
);
elem
.
isXLFN
=
(
0
===
val
.
indexOf
(
"
_xlfn.
"
));
}
if
(
elem
&&
elem
.
ca
)
{
this
.
ca
=
elem
.
ca
;
}
stack
.
push
(
elem
);
args
[
++
indentCount
]
=
1
;
}
else
{
...
...
@@ -4783,15 +4782,18 @@ parserFormula.prototype.parse = function(local, digitDelim) {
found_operator
.
isXLFN
=
(
this
.
operand_str
.
indexOf
(
"
_xlfn.
"
)
===
0
);
}
if
(
found_operator
!=
null
)
{
this
.
elemArr
.
push
(
found_operator
);
this
.
f
.
push
(
found_operator
);
}
else
{
this
.
error
.
push
(
c_oAscError
.
ID
.
FrmlWrongFunctionName
);
this
.
outStack
=
[];
this
.
elemArr
=
[];
return
false
;
}
if
(
found_operator
!=
null
)
{
if
(
found_operator
.
ca
)
{
this
.
ca
=
found_operator
.
ca
;
}
this
.
elemArr
.
push
(
found_operator
);
this
.
f
.
push
(
found_operator
);
}
else
{
this
.
error
.
push
(
c_oAscError
.
ID
.
FrmlWrongFunctionName
);
this
.
outStack
=
[];
this
.
elemArr
=
[];
return
false
;
}
this
.
operand_expected
=
false
;
wasRigthParentheses
=
false
;
continue
;
...
...
@@ -4919,14 +4921,6 @@ parserFormula.prototype.parse = function(local, digitDelim) {
}
this
.
isCalculate
=
false
;
this
.
isDirty
=
false
;
if
(
!!
this
.
ca
!=
this
.
value
.
ca
){
if
(
this
.
value
.
ca
)
{
this
.
wb
.
dependencyFormulas
.
startListeningVolatile
(
this
);
}
else
{
this
.
wb
.
dependencyFormulas
.
endListeningVolatile
(
this
);
}
this
.
ca
=
this
.
value
.
ca
;
}
};
/* Для обратной сборки функции иногда необходимо поменять ссылки на ячейки */
...
...
cell/model/Workbook.js
View file @
5a8f5f6f
...
...
@@ -5335,7 +5335,6 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
Cell
.
prototype
.
_calculateRefType
=
function
()
{
var
val
=
this
.
formulaParsed
.
value
;
var
nF
=
val
.
numFormat
;
var
ca
=
val
.
ca
;
if
(
cElementType
.
cell
===
val
.
type
||
cElementType
.
cell3D
===
val
.
type
)
{
val
=
val
.
getValue
();
if
(
cElementType
.
empty
===
val
.
type
)
{
...
...
@@ -5349,7 +5348,6 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
val
=
val
.
cross
(
new
Asc
.
Range
(
this
.
nCol
,
this
.
nRow
,
this
.
nCol
,
this
.
nRow
),
this
.
ws
.
getId
());
}
val
.
numFormat
=
nF
;
val
.
ca
=
ca
;
this
.
formulaParsed
.
value
=
val
;
};
Cell
.
prototype
.
_updateCellValue
=
function
()
{
...
...
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