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
3bdbb9bd
Commit
3bdbb9bd
authored
Nov 06, 2016
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
the problem with recalculation formulas are dependent on the table total row
parent
363d8ef7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
16 deletions
+52
-16
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+41
-6
cell/model/Workbook.js
cell/model/Workbook.js
+7
-5
cell/model/WorkbookElems.js
cell/model/WorkbookElems.js
+3
-3
cell/model/autofilters.js
cell/model/autofilters.js
+1
-2
No files found.
cell/model/FormulaObjects/parserFormula.js
View file @
3bdbb9bd
...
...
@@ -3721,6 +3721,7 @@ function parserFormula( formula, parent, _ws ) {
this
.
ca
=
false
;
this
.
isDirty
=
false
;
this
.
isCalculate
=
false
;
this
.
isTable
=
false
;
this
.
parent
=
parent
;
}
parserFormula
.
prototype
.
getWs
=
function
()
{
...
...
@@ -3735,6 +3736,9 @@ function parserFormula( formula, parent, _ws ) {
parserFormula
.
prototype
.
setIsDirty
=
function
(
isDirty
)
{
this
.
isDirty
=
isDirty
;
};
parserFormula
.
prototype
.
setIsTable
=
function
(
isTable
){
this
.
isTable
=
isTable
;
};
parserFormula
.
prototype
.
notify
=
function
(
data
)
{
var
eventData
=
{
notifyData
:
data
,
assemble
:
null
,
isRebuild
:
false
,
formula
:
this
};
if
(
this
.
parent
&&
this
.
parent
.
onFormulaEvent
)
{
...
...
@@ -5060,8 +5064,9 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
};
parserFormula
.
prototype
.
buildDependencies
=
function
()
{
var
ref
,
nTo
,
wsR
;
var
ref
,
wsR
;
var
isTable
=
this
.
isTable
;
var
bbox
;
if
(
this
.
ca
)
{
this
.
wb
.
dependencyFormulas
.
startListeningVolatile
(
this
);
}
...
...
@@ -5088,14 +5093,30 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
this
.
wb
.
dependencyFormulas
.
startListeningDefName
(
ref
.
value
,
this
,
ref
.
ws
.
getId
());
}
else
if
((
cElementType
.
cell
===
ref
.
type
||
cElementType
.
cell3D
===
ref
.
type
||
cElementType
.
cellsRange
===
ref
.
type
)
&&
ref
.
isValid
())
{
this
.
wb
.
dependencyFormulas
.
startListeningRange
(
ref
.
getWsId
(),
ref
.
getRange
().
getBBox0
(),
this
);
bbox
=
ref
.
getRange
().
getBBox0
();
if
(
isTable
){
//extend table formula with header/total. This allows us not to follow their change,
//but sometimes leads to recalculate of the table although changed cells near table (it's not a problem)
bbox
=
bbox
.
clone
();
bbox
.
setOffsetFirst
({
offsetRow
:
-
1
,
offsetCol
:
0
});
bbox
.
setOffsetLast
({
offsetRow
:
1
,
offsetCol
:
0
});
}
this
.
wb
.
dependencyFormulas
.
startListeningRange
(
ref
.
getWsId
(),
bbox
,
this
);
}
else
if
(
cElementType
.
cellsRange3D
===
ref
.
type
&&
ref
.
isValid
())
{
wsR
=
ref
.
range
(
ref
.
wsRange
());
for
(
var
j
=
0
;
j
<
wsR
.
length
;
j
++
)
{
var
range
=
wsR
[
j
];
if
(
range
)
{
var
wsId
=
range
.
getWorksheet
().
getId
();
this
.
wb
.
dependencyFormulas
.
startListeningRange
(
wsId
,
range
.
getBBox0
(),
this
);
bbox
=
range
.
getBBox0
();
if
(
isTable
){
//extend table formula with header/total. This allows us not to follow their change,
//but sometimes leads to recalculate of the table although changed cells near table (it's not a problem)
bbox
=
bbox
.
clone
();
bbox
.
setOffsetFirst
({
offsetRow
:
-
1
,
offsetCol
:
0
});
bbox
.
setOffsetLast
({
offsetRow
:
1
,
offsetCol
:
0
});
}
this
.
wb
.
dependencyFormulas
.
startListeningRange
(
wsId
,
bbox
,
this
);
}
}
}
...
...
@@ -5104,6 +5125,8 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
parserFormula
.
prototype
.
removeDependencies
=
function
()
{
var
ref
;
var
wsR
;
var
isTable
=
this
.
isTable
;
var
bbox
;
if
(
this
.
ca
)
{
this
.
wb
.
dependencyFormulas
.
endListeningVolatile
(
this
);
}
...
...
@@ -5130,14 +5153,26 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
this
.
wb
.
dependencyFormulas
.
endListeningDefName
(
ref
.
value
,
this
,
ref
.
ws
.
getId
());
}
else
if
((
cElementType
.
cell
===
ref
.
type
||
cElementType
.
cell3D
===
ref
.
type
||
cElementType
.
cellsRange
===
ref
.
type
)
&&
ref
.
isValid
())
{
this
.
wb
.
dependencyFormulas
.
endListeningRange
(
ref
.
getWsId
(),
ref
.
getRange
().
getBBox0
(),
this
);
bbox
=
ref
.
getRange
().
getBBox0
();
if
(
isTable
){
bbox
=
bbox
.
clone
();
bbox
.
setOffsetFirst
({
offsetRow
:
-
1
,
offsetCol
:
0
});
bbox
.
setOffsetLast
({
offsetRow
:
1
,
offsetCol
:
0
});
}
this
.
wb
.
dependencyFormulas
.
endListeningRange
(
ref
.
getWsId
(),
bbox
,
this
);
}
else
if
(
cElementType
.
cellsRange3D
===
ref
.
type
&&
ref
.
isValid
())
{
wsR
=
ref
.
range
(
ref
.
wsRange
());
for
(
var
j
=
0
;
j
<
wsR
.
length
;
j
++
)
{
var
range
=
wsR
[
j
];
if
(
range
)
{
var
wsId
=
range
.
getWorksheet
().
getId
();
this
.
wb
.
dependencyFormulas
.
endListeningRange
(
wsId
,
range
.
getBBox0
(),
this
);
bbox
=
range
.
getBBox0
();
if
(
isTable
){
bbox
=
bbox
.
clone
();
bbox
.
setOffsetFirst
({
offsetRow
:
-
1
,
offsetCol
:
0
});
bbox
.
setOffsetLast
({
offsetRow
:
1
,
offsetCol
:
0
});
}
this
.
wb
.
dependencyFormulas
.
endListeningRange
(
wsId
,
bbox
,
this
);
}
}
}
...
...
cell/model/Workbook.js
View file @
3bdbb9bd
...
...
@@ -201,6 +201,7 @@ function getRangeType(oBBox){
this
.
ref
=
ref
;
//all ref should be 3d, so worksheet can be anyone
this
.
parsedRef
=
new
parserFormula
(
ref
,
this
,
AscCommonExcel
.
g_DefNameWorksheet
);
this
.
parsedRef
.
setIsTable
(
true
);
if
(
opt_forceBuild
)
{
this
.
parsedRef
.
parse
();
this
.
parsedRef
.
buildDependencies
();
...
...
@@ -721,13 +722,14 @@ function getRangeType(oBBox){
defName
.
setRef
(
defNameRef
);
}
},
changeTableRef
:
function
(
table
Name
,
newRef
)
{
var
defName
=
this
.
getDefNameByName
(
tableName
,
null
);
changeTableRef
:
function
(
table
)
{
var
defName
=
this
.
getDefNameByName
(
table
.
Display
Name
,
null
);
if
(
defName
)
{
this
.
buildDependency
();
var
oldUndoName
=
defName
.
getUndoDefName
();
var
newUndoName
=
defName
.
getUndoDefName
();
newUndoName
.
ref
=
defName
.
ref
.
split
(
'
!
'
)[
0
]
+
'
!
'
+
newRef
.
getAbsName
();
var
ref
=
table
.
getRangeWithoutHeaderFooter
();
newUndoName
.
ref
=
defName
.
ref
.
split
(
'
!
'
)[
0
]
+
'
!
'
+
ref
.
getAbsName
();
History
.
TurnOff
();
this
.
editDefinesNames
(
oldUndoName
,
newUndoName
);
var
notifyData
=
{
type
:
AscCommon
.
c_oNotifyType
.
ChangeDefName
,
from
:
oldUndoName
,
to
:
newUndoName
};
...
...
@@ -1379,8 +1381,8 @@ Workbook.prototype.init=function(tableCustomFunc, bNoBuildDep, bSnapshot){
var
self
=
this
;
this
.
wsHandlers
=
new
AscCommonExcel
.
asc_CHandlersList
(
/*handlers*/
{
"
changeRefTablePart
"
:
function
(
displayName
,
ref
)
{
self
.
dependencyFormulas
.
changeTableRef
(
displayName
,
ref
);
"
changeRefTablePart
"
:
function
(
table
)
{
self
.
dependencyFormulas
.
changeTableRef
(
table
);
},
"
changeColumnTablePart
"
:
function
(
tableName
)
{
self
.
dependencyFormulas
.
rebuildTable
(
tableName
);
...
...
cell/model/WorkbookElems.js
View file @
3bdbb9bd
...
...
@@ -5254,7 +5254,7 @@ TablePart.prototype.moveRef = function(col, row) {
this
.
Ref
=
ref
;
//event
this
.
handlers
.
trigger
(
"
changeRefTablePart
"
,
this
.
DisplayName
,
this
.
getRangeWithoutHeaderFooter
()
);
this
.
handlers
.
trigger
(
"
changeRefTablePart
"
,
this
);
if
(
this
.
AutoFilter
)
this
.
AutoFilter
.
moveRef
(
col
,
row
);
...
...
@@ -5269,7 +5269,7 @@ TablePart.prototype.changeRef = function(col, row, bIsFirst) {
this
.
Ref
=
ref
;
//event
this
.
handlers
.
trigger
(
"
changeRefTablePart
"
,
this
.
DisplayName
,
this
.
getRangeWithoutHeaderFooter
()
);
this
.
handlers
.
trigger
(
"
changeRefTablePart
"
,
this
);
if
(
this
.
AutoFilter
)
this
.
AutoFilter
.
changeRef
(
col
,
row
,
bIsFirst
);
...
...
@@ -5316,7 +5316,7 @@ TablePart.prototype.changeRefOnRange = function(range, autoFilters, generateNewT
}
this
.
Ref
=
Asc
.
Range
(
range
.
c1
,
range
.
r1
,
range
.
c2
,
range
.
r2
);
//event
this
.
handlers
.
trigger
(
"
changeRefTablePart
"
,
this
.
DisplayName
,
this
.
getRangeWithoutHeaderFooter
()
);
this
.
handlers
.
trigger
(
"
changeRefTablePart
"
,
this
);
if
(
this
.
AutoFilter
)
this
.
AutoFilter
.
changeRefOnRange
(
range
);
...
...
cell/model/autofilters.js
View file @
3bdbb9bd
...
...
@@ -997,8 +997,7 @@
this
.
_setStyleTables
(
cloneData
.
newFilterRef
);
//event
//todo
worksheet
.
handlers
.
trigger
(
"
changeRefTablePart
"
,
cloneData
.
oldFilter
.
DisplayName
,
cloneData
.
oldFilter
.
Ref
);
worksheet
.
handlers
.
trigger
(
"
changeRefTablePart
"
,
cloneData
.
oldFilter
);
break
;
}
...
...
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