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
08a5ed40
Commit
08a5ed40
authored
May 29, 2017
by
Boris Kocherov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add CUBEMEMBER, CUBEVALUE
use lazy calculation
parent
6ee6d7fe
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
631 additions
and
24 deletions
+631
-24
cell/model/FormulaObjects/cubeFunctions.js
cell/model/FormulaObjects/cubeFunctions.js
+456
-7
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+134
-4
cell/model/Workbook.js
cell/model/Workbook.js
+41
-13
No files found.
cell/model/FormulaObjects/cubeFunctions.js
View file @
08a5ed40
This diff is collapsed.
Click to expand it.
cell/model/FormulaObjects/parserFormula.js
View file @
08a5ed40
...
...
@@ -670,6 +670,112 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cBaseType
.
prototype
.
toLocaleString
=
function
()
{
return
this
.
toString
();
};
cBaseType
.
prototype
.
CalculatePromise
=
function
(
arg
,
opt_bbox
,
isDefName
,
ws
)
{
// depromise args
var
t
=
this
,
lazy_formulas
=
[],
lazy_found
;
function
check_args_promise
()
{
var
promise_flag
=
false
,
element
,
length
,
i
;
function
cellForge
(
cell
)
{
if
(
cell
&&
cell
.
formulaParsed
&&
(
cell
.
formulaParsed
.
lazy_value
||
cell
.
formulaParsed
.
queue
))
{
promise_flag
=
true
;
lazy_formulas
.
push
(
cell
.
formulaParsed
);
}
}
for
(
i
=
0
,
length
=
arg
.
length
;
i
<
length
;
++
i
)
{
element
=
arg
[
i
];
if
(
typeof
element
===
"
function
"
)
{
promise_flag
=
true
;
}
if
(
element
instanceof
cArea
||
element
instanceof
cArea3D
)
{
element
.
foreach
(
cellForge
);
}
if
(
element
instanceof
cRef
||
element
instanceof
cRef3D
)
{
element
.
getRange
().
getCells
().
forEach
(
cellForge
);
}
}
return
promise_flag
;
}
lazy_found
=
check_args_promise
();
if
(
t
.
CalculateLazy
)
{
return
function
()
{
var
queue
=
new
RSVP
.
Queue
();
if
(
lazy_formulas
.
length
>
0
)
{
lazy_formulas
.
forEach
(
function
(
formula
)
{
var
lazy
=
formula
.
lazy_value
;
if
(
lazy
)
{
// if value lazy run it
lazy
();
}
if
(
formula
.
queue
)
{
// add dependence from already
// running but not computed lazy
queue
.
push
(
function
()
{
return
formula
.
queue
;
});
}
});
}
queue
.
push
(
function
()
{
return
RSVP
.
all
(
arg
.
map
(
function
(
z
)
{
if
(
typeof
z
===
"
function
"
)
{
return
z
();
}
else
{
return
z
;
}
}));
});
return
t
.
CalculateLazy
(
queue
,
opt_bbox
,
isDefName
,
ws
);
};
}
else
{
if
(
lazy_found
)
{
return
function
()
{
var
queue
=
new
RSVP
.
Queue
();
if
(
lazy_formulas
.
length
>
0
)
{
lazy_formulas
.
forEach
(
function
(
formula
)
{
var
lazy
=
formula
.
lazy_value
;
if
(
lazy
)
{
// if value lazy add it dependence list
lazy
();
}
if
(
formula
.
queue
)
{
// add dependence from already
// running but not computed lazy
queue
.
push
(
function
()
{
return
formula
.
queue
;
});
}
});
}
return
queue
.
push
(
function
()
{
return
RSVP
.
all
(
arg
.
map
(
function
(
z
)
{
if
(
typeof
z
===
"
function
"
)
{
return
z
();
}
else
{
return
z
;
}
}));
})
.
push
(
function
(
arg
)
{
return
t
.
Calculate
(
arg
,
opt_bbox
,
isDefName
,
ws
);
});
};
}
else
{
return
t
.
Calculate
(
arg
,
opt_bbox
,
isDefName
,
ws
);
}
}
};
/*Basic types of an elements used into formulas*/
/**
...
...
@@ -2347,6 +2453,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
cBaseOperator
.
prototype
.
Calculate
=
function
()
{
return
null
;
};
cBaseOperator
.
prototype
.
CalculatePromise
=
cBaseType
.
prototype
.
CalculatePromise
;
cBaseOperator
.
prototype
.
Assemble
=
function
(
arg
)
{
var
str
=
""
;
if
(
this
.
argumentsCurrent
===
2
)
{
...
...
@@ -2394,6 +2501,7 @@ parserHelp.setDigitSeparator(AscCommon.g_oDefaultCultureInfo.NumberDecimalSepara
this
.
value
=
new
cError
(
cErrorType
.
wrong_name
);
return
this
.
value
;
};
cBaseFunction
.
prototype
.
CalculatePromise
=
cBaseOperator
.
prototype
.
CalculatePromise
cBaseFunction
.
prototype
.
DecrementArguments
=
function
()
{
--
this
.
argumentsCurrent
;
};
...
...
@@ -4225,7 +4333,7 @@ function parserFormula( formula, parent, _ws ) {
this
.
parent
.
onFormulaEvent
(
AscCommon
.
c_oNotifyParentType
.
Change
,
eventData
);
}
}
}
else
if
(
AscCommon
.
c_oNotifyType
.
Changed
===
data
.
type
)
{
}
else
if
(
AscCommon
.
c_oNotifyType
.
Changed
===
data
.
type
)
{
if
(
this
.
parent
&&
this
.
parent
.
onFormulaEvent
)
{
this
.
parent
.
onFormulaEvent
(
AscCommon
.
c_oNotifyParentType
.
Change
,
eventData
);
}
...
...
@@ -5102,6 +5210,8 @@ parserFormula.prototype.parse = function(local, digitDelim) {
};
parserFormula
.
prototype
.
calculate
=
function
(
opt_defName
,
opt_bbox
,
opt_offset
)
{
var
value
,
formula
=
this
;
if
(
this
.
isCalculate
&&
(
!
this
.
calculateDefName
||
this
.
calculateDefName
[
opt_bbox
?
opt_bbox
.
getName
()
:
opt_bbox
]))
{
//cycle
...
...
@@ -5145,7 +5255,7 @@ parserFormula.prototype.parse = function(local, digitDelim) {
for
(
var
ind
=
0
;
ind
<
currentElement
.
getArguments
();
ind
++
)
{
arg
.
unshift
(
elemArr
.
pop
());
}
_tmp
=
currentElement
.
Calculate
(
arg
,
opt_bbox
,
opt_defName
,
this
.
ws
);
_tmp
=
currentElement
.
Calculate
Promise
(
arg
,
opt_bbox
,
opt_defName
,
this
.
ws
);
if
(
cNumFormatNull
!==
_tmp
.
numFormat
)
{
numFormat
=
_tmp
.
numFormat
;
}
else
if
(
0
>
numFormat
||
cNumFormatNone
===
currentElement
.
numFormat
)
{
...
...
@@ -5163,8 +5273,28 @@ parserFormula.prototype.parse = function(local, digitDelim) {
elemArr
.
push
(
currentElement
);
}
}
this
.
value
=
elemArr
.
pop
();
this
.
value
.
numFormat
=
numFormat
;
value
=
elemArr
.
pop
();
if
(
typeof
value
===
"
function
"
)
{
this
.
value
=
new
cError
(
cErrorType
.
getting_data
);
this
.
queue
=
true
;
this
.
lazy_value
=
function
()
{
formula
.
lazy_value
=
null
;
formula
.
queue
=
value
()
.
push
(
function
(
ret
)
{
formula
.
value
=
ret
;
formula
.
value
.
numFormat
=
numFormat
;
formula
.
_endCalculate
();
opt_bbox
.
updateOnScreen
();
formula
.
queue
=
false
;
// formula.lazy_value = null;
return
formula
.
value
;
});
return
formula
.
queue
}
}
else
{
this
.
value
=
value
;
this
.
value
.
numFormat
=
numFormat
;
}
this
.
_endCalculate
();
return
this
.
value
;
...
...
cell/model/Workbook.js
View file @
08a5ed40
...
...
@@ -908,6 +908,11 @@
this
.
buildDefName
=
{};
},
calcTree
:
function
()
{
var
dependency_graph
=
this
,
formula
,
i
,
tasks
=
[],
lazy_value
;
if
(
this
.
lockCounter
>
0
)
{
return
;
}
...
...
@@ -924,26 +929,44 @@
this
.
_broadcastCells
(
notifyData
,
calcTrack
);
}
this
.
_broadcastCellsEnd
();
for
(
var
i
=
0
;
i
<
noCalcTrack
.
length
;
++
i
)
{
var
formula
=
noCalcTrack
[
i
];
for
(
i
=
0
;
i
<
noCalcTrack
.
length
;
++
i
)
{
formula
=
noCalcTrack
[
i
];
//defName recalc when calc formula containing it. no need calc it
formula
.
setIsDirty
(
false
);
}
for
(
var
i
=
0
;
i
<
calcTrack
.
length
;
++
i
)
{
var
formula
=
calcTrack
[
i
];
for
(
i
=
0
;
i
<
calcTrack
.
length
;
++
i
)
{
formula
=
calcTrack
[
i
];
if
(
formula
.
getIsDirty
())
{
formula
.
calculate
();
}
}
//copy cleanCellCache to prevent recursion in trigger("cleanCellCache")
var
tmpCellCache
=
this
.
cleanCellCache
;
this
.
cleanCellCache
=
{};
for
(
var
i
in
tmpCellCache
)
{
this
.
wb
.
handlers
.
trigger
(
"
cleanCellCache
"
,
i
,
{
0
:
tmpCellCache
[
i
]},
AscCommonExcel
.
c_oAscCanChangeColWidth
.
none
);
for
(
i
=
calcTrack
.
length
-
1
;
i
>=
0
;
--
i
)
{
lazy_value
=
calcTrack
[
i
].
lazy_value
;
if
(
lazy_value
)
{
tasks
.
push
(
lazy_value
());
}
}
function
end
()
{
//copy cleanCellCache to prevent recursion in trigger("cleanCellCache")
var
tmpCellCache
=
dependency_graph
.
cleanCellCache
;
dependency_graph
.
cleanCellCache
=
{};
for
(
var
i
in
dependency_graph
.
cleanCellCache
)
{
dependency_graph
.
wb
.
handlers
.
trigger
(
"
cleanCellCache
"
,
i
,
{
0
:
tmpCellCache
[
i
]},
AscCommonExcel
.
c_oAscCanChangeColWidth
.
none
);
}
AscCommonExcel
.
g_oVLOOKUPCache
.
clean
();
AscCommonExcel
.
g_oHLOOKUPCache
.
clean
();
}
if
(
tasks
.
length
>
0
)
{
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
RSVP
.
all
(
tasks
);
})
.
push
(
end
);
}
else
{
end
();
}
AscCommonExcel
.
g_oVLOOKUPCache
.
clean
();
AscCommonExcel
.
g_oHLOOKUPCache
.
clean
();
},
initOpen
:
function
()
{
this
.
_foreachDefName
(
function
(
defName
)
{
...
...
@@ -5387,6 +5410,11 @@
this
.
nCol
=
-
1
;
this
.
formulaParsed
=
null
;
}
Cell
.
prototype
.
getId
=
function
()
{
return
[
this
.
ws
.
getId
(),
this
.
nRow
,
this
.
nCol
].
join
(
"
,
"
);
};
Cell
.
prototype
.
getStyle
=
function
(){
return
this
.
xfs
;
};
...
...
@@ -5945,7 +5973,7 @@
this
.
setValue
(
""
);
};
Cell
.
prototype
.
_checkDirty
=
function
(){
if
(
this
.
formulaParsed
&&
this
.
formulaParsed
.
getIsDirty
())
{
if
(
this
.
formulaParsed
&&
this
.
formulaParsed
.
getIsDirty
()
&&
!
this
.
formulaParsed
.
queue
)
{
this
.
formulaParsed
.
calculate
();
}
};
...
...
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