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
c0373bb5
Commit
c0373bb5
authored
May 30, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
separate functions from cFLOOR_MATH into base class
parent
69c13eea
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
115 deletions
+73
-115
cell/model/FormulaObjects/mathematicFunctions.js
cell/model/FormulaObjects/mathematicFunctions.js
+17
-115
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+56
-0
No files found.
cell/model/FormulaObjects/mathematicFunctions.js
View file @
c0373bb5
...
@@ -1622,34 +1622,27 @@
...
@@ -1622,34 +1622,27 @@
cFLOOR_MATH
.
prototype
.
argumentsMax
=
3
;
cFLOOR_MATH
.
prototype
.
argumentsMax
=
3
;
cFLOOR_MATH
.
prototype
.
isXLFN
=
true
;
cFLOOR_MATH
.
prototype
.
isXLFN
=
true
;
cFLOOR_MATH
.
prototype
.
Calculate
=
function
(
arg
)
{
cFLOOR_MATH
.
prototype
.
Calculate
=
function
(
arg
)
{
var
arg0
=
arg
[
0
],
arg1
=
arg
[
1
],
arg2
=
arg
[
2
];
var
argClone
=
[];
if
(
arg0
instanceof
cArea
||
arg0
instanceof
cArea3D
)
{
argClone
[
0
]
=
this
.
_checkCAreaArg
(
arg
[
0
],
arguments
[
1
]);
arg0
=
arg0
.
cross
(
arguments
[
1
]);
argClone
[
1
]
=
this
.
_checkCAreaArg
(
arg
[
1
],
arguments
[
1
]);
}
argClone
[
2
]
=
this
.
_checkCAreaArg
(
arg
[
2
],
arguments
[
1
]);
if
(
arg1
instanceof
cArea
||
arg1
instanceof
cArea3D
)
{
arg1
=
arg1
.
cross
(
arguments
[
1
]);
}
if
(
arg2
instanceof
cArea
||
arg2
instanceof
cArea3D
)
{
arg2
=
arg2
.
cross
(
arguments
[
1
]);
}
arg
0
=
arg
[
0
].
tocNumber
();
arg
Clone
[
0
]
=
argClone
[
0
].
tocNumber
();
if
(
!
arg
1
){
if
(
!
arg
Clone
[
1
]
){
arg
1
=
arg
[
0
]
>
0
?
new
cNumber
(
1
)
:
new
cNumber
(
-
1
);
arg
Clone
[
1
]
=
argClone
[
0
]
>
0
?
new
cNumber
(
1
)
:
new
cNumber
(
-
1
);
}
}
arg
2
=
arg
[
2
]
?
arg
[
2
].
tocNumber
()
:
new
cNumber
(
0
);
arg
Clone
[
2
]
=
argClone
[
2
]
?
argClone
[
2
].
tocNumber
()
:
new
cNumber
(
0
);
if
(
arg0
instanceof
cError
)
{
var
argError
;
return
this
.
value
=
arg0
;
if
(
false
!==
(
argError
=
this
.
_checkErrorArg
(
argClone
))){
}
return
this
.
value
=
argError
;
if
(
arg1
instanceof
cError
)
{
return
this
.
value
=
arg1
;
}
if
(
arg2
instanceof
cError
)
{
return
this
.
value
=
arg2
;
}
}
function
floorHelper
(
number
,
significance
,
mod
)
{
function
floor_math
(
argArray
)
{
var
number
=
argArray
[
0
];
var
significance
=
argArray
[
1
];
var
mod
=
argArray
[
2
];
if
(
significance
===
0
||
number
===
0
)
{
if
(
significance
===
0
||
number
===
0
)
{
return
new
cNumber
(
0.0
);
return
new
cNumber
(
0.0
);
}
}
...
@@ -1664,98 +1657,7 @@
...
@@ -1664,98 +1657,7 @@
}
}
}
}
if
(
arg0
instanceof
cArray
&&
arg1
instanceof
cArray
&&
arg2
instanceof
cArray
)
{
return
this
.
value
=
this
.
_findArrayInNumberArguments
(
argClone
,
floor_math
);
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
elem
;
var
b
=
arg1
.
getElementRowCol
(
r
,
c
);
var
d
=
arg2
.
getElementRowCol
(
r
,
c
);
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
if
(
arg0
instanceof
cArray
&&
arg1
instanceof
cArray
)
{
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
elem
;
var
b
=
arg1
.
getElementRowCol
(
r
,
c
);
var
d
=
arg2
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
if
(
arg0
instanceof
cArray
&&
arg2
instanceof
cArray
)
{
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
elem
;
var
b
=
arg1
;
var
d
=
arg2
.
getElementRowCol
(
r
,
c
);
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
if
(
arg1
instanceof
cArray
&&
arg2
instanceof
cArray
)
{
arg1
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
arg0
;
var
b
=
elem
;
var
d
=
arg2
.
getElementRowCol
(
r
,
c
);
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg1
;
}
else
if
(
arg0
instanceof
cArray
)
{
arg0
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
elem
;
var
b
=
arg1
;
var
d
=
arg2
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg0
;
}
else
if
(
arg1
instanceof
cArray
)
{
arg1
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
arg0
;
var
b
=
elem
;
var
d
=
arg2
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg1
;
}
else
if
(
arg2
instanceof
cArray
)
{
arg2
.
foreach
(
function
(
elem
,
r
,
c
)
{
var
a
=
arg0
;
var
b
=
arg1
;
var
d
=
elem
;
if
(
a
instanceof
cNumber
&&
b
instanceof
cNumber
&&
d
instanceof
cNumber
)
{
this
.
array
[
r
][
c
]
=
floorHelper
(
a
.
getValue
(),
b
.
getValue
(),
d
.
getValue
());
}
else
{
this
.
array
[
r
][
c
]
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
});
return
this
.
value
=
arg2
;
}
if
(
arg0
instanceof
cString
||
arg1
instanceof
cString
||
arg2
instanceof
cString
)
{
return
this
.
value
=
new
cError
(
cErrorType
.
wrong_value_type
);
}
return
this
.
value
=
floorHelper
(
arg0
.
getValue
(),
arg1
.
getValue
(),
arg2
.
getValue
());
};
};
cFLOOR_MATH
.
prototype
.
getInfo
=
function
()
{
cFLOOR_MATH
.
prototype
.
getInfo
=
function
()
{
return
{
return
{
...
...
cell/model/FormulaObjects/parserFormula.js
View file @
c0373bb5
...
@@ -2369,6 +2369,62 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
...
@@ -2369,6 +2369,62 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cBaseFunction
.
prototype
.
checkArguments
=
function
()
{
cBaseFunction
.
prototype
.
checkArguments
=
function
()
{
return
this
.
argumentsMin
<=
this
.
argumentsCurrent
&&
this
.
argumentsCurrent
<=
this
.
argumentsMax
;
return
this
.
argumentsMin
<=
this
.
argumentsCurrent
&&
this
.
argumentsCurrent
<=
this
.
argumentsMax
;
};
};
cBaseFunction
.
prototype
.
_findArrayInNumberArguments
=
function
(
inputArguments
,
calculateFunc
){
var
argsArray
=
[];
for
(
var
i
=
0
;
i
<
inputArguments
.
length
;
i
++
){
if
(
cElementType
.
array
===
inputArguments
[
i
].
type
){
inputArguments
[
i
].
foreach
(
function
(
elem
,
r
,
c
)
{
var
arg
;
argsArray
=
[];
for
(
var
j
=
0
;
j
<
inputArguments
.
length
;
j
++
){
if
(
i
===
j
){
arg
=
elem
;
}
else
if
(
cElementType
.
array
===
inputArguments
[
j
].
type
){
arg
=
inputArguments
[
j
].
getElementRowCol
(
r
,
c
);
}
else
{
arg
=
inputArguments
[
j
];
}
if
(
arg
&&
cElementType
.
number
===
arg
.
type
){
argsArray
[
j
]
=
arg
.
getValue
();
}
else
{
argsArray
=
null
;
break
;
}
}
this
.
array
[
r
][
c
]
=
null
===
argsArray
?
new
cError
(
cErrorType
.
wrong_value_type
)
:
calculateFunc
(
argsArray
);
});
return
inputArguments
[
i
];
}
else
{
if
(
cElementType
.
string
===
inputArguments
[
i
].
type
){
return
new
cError
(
cErrorType
.
wrong_value_type
);
}
else
{
argsArray
[
i
]
=
inputArguments
[
i
].
getValue
();
}
}
}
return
calculateFunc
(
argsArray
);
};
cBaseFunction
.
prototype
.
_checkCAreaArg
=
function
(
arg
,
arg1
)
{
if
(
arg
instanceof
cArea
||
arg
instanceof
cArea3D
)
{
arg
=
arg
.
cross
(
arg1
);
}
return
arg
;
};
cBaseFunction
.
prototype
.
_checkErrorArg
=
function
(
argArray
)
{
var
res
=
false
;
for
(
var
i
=
0
;
i
<
argArray
.
length
;
i
++
)
{
if
(
argArray
[
i
]
instanceof
cError
)
{
return
argArray
[
i
];
}
}
return
res
;
};
/** @constructor */
/** @constructor */
function
parentLeft
()
{
function
parentLeft
()
{
...
...
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