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
8e970924
Commit
8e970924
authored
Dec 16, 2016
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
TablePart with custom formula
parent
3447b823
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
6629 additions
and
6641 deletions
+6629
-6641
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+12
-3
cell/model/Workbook.js
cell/model/Workbook.js
+6578
-6561
cell/model/WorkbookElems.js
cell/model/WorkbookElems.js
+20
-34
cell/model/autofilters.js
cell/model/autofilters.js
+19
-43
No files found.
cell/model/FormulaObjects/parserFormula.js
View file @
8e970924
...
...
@@ -3756,7 +3756,6 @@ function parserFormula( formula, parent, _ws ) {
this
.
parenthesesNotEnough
=
false
;
this
.
f
=
[];
this
.
reRowCol
=
/^
(
ROW|ROWS|COLUMN|COLUMNS
)
$/gi
this
.
regSpace
=
/
\$
/g
;
this
.
countRef
=
0
;
this
.
listenerId
=
lastListenerId
++
;
...
...
@@ -3764,6 +3763,7 @@ function parserFormula( formula, parent, _ws ) {
this
.
isDirty
=
false
;
this
.
isCalculate
=
false
;
this
.
isTable
=
false
;
this
.
isInDependencies
=
false
;
this
.
parent
=
parent
;
}
parserFormula
.
prototype
.
getWs
=
function
()
{
...
...
@@ -3881,7 +3881,9 @@ parserFormula.prototype.clone = function(formula, parent, ws) {
oRes
.
isParsed
=
this
.
isParsed
;
return
oRes
;
};
parserFormula
.
prototype
.
getFormula
=
function
()
{
return
this
.
Formula
;
}
parserFormula
.
prototype
.
setFormula
=
function
(
formula
)
{
this
.
Formula
=
formula
;
this
.
is3D
=
false
;
...
...
@@ -5100,7 +5102,10 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
}
};
parserFormula
.
prototype
.
buildDependencies
=
function
()
{
if
(
this
.
isInDependencies
)
{
return
;
}
this
.
isInDependencies
=
true
;
var
ref
,
wsR
;
var
isTable
=
this
.
isTable
;
var
bbox
;
...
...
@@ -5160,6 +5165,10 @@ parserFormula.prototype.assembleLocale = function(locale, digitDelim) {
}
};
parserFormula
.
prototype
.
removeDependencies
=
function
()
{
if
(
!
this
.
isInDependencies
)
{
return
;
}
this
.
isInDependencies
=
false
;
var
ref
;
var
wsR
;
var
isTable
=
this
.
isTable
;
...
...
cell/model/Workbook.js
View file @
8e970924
This diff is collapsed.
Click to expand it.
cell/model/WorkbookElems.js
View file @
8e970924
...
...
@@ -5673,7 +5673,7 @@ function TablePart(handlers) {
this
.
result
=
null
;
this
.
handlers
=
handlers
;
}
TablePart
.
prototype
.
clone
=
function
(
ws
,
tableName
)
{
TablePart
.
prototype
.
clone
=
function
()
{
var
i
,
res
=
new
TablePart
(
this
.
handlers
);
res
.
Ref
=
this
.
Ref
?
this
.
Ref
.
clone
()
:
null
;
res
.
HeaderRowCount
=
this
.
HeaderRowCount
;
...
...
@@ -5695,17 +5695,7 @@ TablePart.prototype.clone = function(ws, tableName) {
for
(
i
=
0
;
i
<
this
.
result
.
length
;
++
i
)
res
.
result
.
push
(
this
.
result
[
i
].
clone
());
}
if
(
tableName
)
{
res
.
DisplayName
=
tableName
;
}
else
{
res
.
DisplayName
=
this
.
DisplayName
;
}
if
(
ws
!==
null
)
res
.
recalc
(
ws
,
tableName
);
res
.
DisplayName
=
this
.
DisplayName
;
return
res
;
};
TablePart
.
prototype
.
renameSheetCopy
=
function
(
ws
,
renameParams
)
{
...
...
@@ -5726,10 +5716,6 @@ TablePart.prototype.clone = function(ws, tableName) {
this
.
TableColumns
[
i
].
buildDependencies
();
}
};
TablePart
.
prototype
.
recalc
=
function
(
ws
,
tableName
)
{
this
.
DisplayName
=
ws
.
workbook
.
dependencyFormulas
.
getNextTableName
();
ws
.
workbook
.
dependencyFormulas
.
addTableName
(
ws
,
this
);
};
TablePart
.
prototype
.
moveRef
=
function
(
col
,
row
)
{
var
ref
=
this
.
Ref
.
clone
();
ref
.
setOffset
({
offsetCol
:
col
?
col
:
0
,
offsetRow
:
row
?
row
:
0
});
...
...
@@ -6318,8 +6304,8 @@ function TableColumn() {
}
else
if
(
AscCommon
.
c_oNotifyParentType
.
ChangeFormula
===
type
)
{
if
(
eventData
.
isRebuild
)
{
var
ws
=
this
.
TotalsRowFormula
.
ws
;
this
.
TotalsRowFormula
=
null
;
//to prevent removeDependencies in
_set
TotalRowFormula
this
.
_set
TotalRowFormula
(
eventData
.
assemble
,
ws
,
true
);
this
.
TotalsRowFormula
=
null
;
//to prevent removeDependencies in
apply
TotalRowFormula
this
.
apply
TotalRowFormula
(
eventData
.
assemble
,
ws
,
true
);
}
else
{
this
.
TotalsRowFormula
.
Formula
=
eventData
.
assemble
;
this
.
TotalsRowFormula
.
buildDependencies
();
...
...
@@ -6328,12 +6314,14 @@ function TableColumn() {
};
TableColumn
.
prototype
.
renameSheetCopy
=
function
(
ws
,
renameParams
)
{
if
(
this
.
TotalsRowFormula
)
{
this
.
buildDependencies
();
this
.
TotalsRowFormula
.
renameSheetCopy
(
renameParams
);
this
.
_set
TotalRowFormula
(
this
.
TotalsRowFormula
.
assemble
(
true
),
ws
,
true
);
this
.
apply
TotalRowFormula
(
this
.
TotalsRowFormula
.
assemble
(
true
),
ws
,
true
);
}
};
TableColumn
.
prototype
.
buildDependencies
=
function
()
{
if
(
this
.
TotalsRowFormula
)
{
this
.
TotalsRowFormula
.
parse
();
this
.
TotalsRowFormula
.
buildDependencies
();
}
};
...
...
@@ -6349,7 +6337,7 @@ TableColumn.prototype.clone = function() {
res
.
TotalsRowFunction
=
this
.
TotalsRowFunction
;
if
(
this
.
TotalsRowFormula
)
{
res
.
_set
TotalRowFormula
(
this
.
TotalsRowFormula
.
Formula
,
this
.
TotalsRowFormula
.
ws
,
false
);
res
.
apply
TotalRowFormula
(
this
.
TotalsRowFormula
.
Formula
,
this
.
TotalsRowFormula
.
ws
,
false
);
}
if
(
this
.
dxf
)
res
.
dxf
=
this
.
dxf
.
clone
;
...
...
@@ -6395,9 +6383,7 @@ TableColumn.prototype.getTotalRowFormula = function(tablePart){
}
case
Asc
.
ETotalsRowFunction
.
totalrowfunctionCustom
:
{
if
(
this
.
TotalsRowFormula
)
{
res
=
this
.
TotalsRowFormula
.
Formula
;
}
res
=
this
.
getTotalsRowFormula
();
break
;
}
case
Asc
.
ETotalsRowFunction
.
totalrowfunctionMax
:
...
...
@@ -6437,18 +6423,20 @@ TableColumn.prototype.getTotalRowFormula = function(tablePart){
TableColumn
.
prototype
.
cleanTotalsData
=
function
(){
this
.
CalculatedColumnFormula
=
null
;
this
.
_set
TotalRowFormula
(
null
,
null
,
false
);
this
.
apply
TotalRowFormula
(
null
,
null
,
false
);
this
.
TotalsRowFunction
=
null
;
this
.
TotalsRowLabel
=
null
;
};
TableColumn
.
prototype
.
getTotalsRowFormula
=
function
(){
return
this
.
TotalsRowFormula
?
this
.
TotalsRowFormula
.
getFormula
()
:
null
;
};
TableColumn
.
prototype
.
setTotalsRowFormula
=
function
(
val
,
ws
){
this
.
cleanTotalsData
();
if
(
"
=
"
===
val
[
0
])
{
val
=
val
.
substring
(
1
);
}
this
.
_set
TotalRowFormula
(
val
,
ws
,
true
);
this
.
apply
TotalRowFormula
(
val
,
ws
,
true
);
this
.
TotalsRowFunction
=
Asc
.
ETotalsRowFunction
.
totalrowfunctionCustom
;
};
...
...
@@ -6465,22 +6453,20 @@ TableColumn.prototype.checkTotalRowFormula = function(ws, tablePart){
if
(
null
!==
totalRowFormula
)
{
this
.
_set
TotalRowFormula
(
totalRowFormula
,
ws
,
true
);
this
.
apply
TotalRowFormula
(
totalRowFormula
,
ws
,
true
);
this
.
TotalsRowFunction
=
Asc
.
ETotalsRowFunction
.
totalrowfunctionCustom
;
}
}
};
TableColumn
.
prototype
.
_setTotalRowFormula
=
function
(
val
,
opt_ws
,
opt_buildDep
)
{
if
(
this
.
TotalsRowFormula
)
{
this
.
TotalsRowFormula
.
removeDependencies
();
this
.
TotalsRowFormula
=
null
;
}
TableColumn
.
prototype
.
applyTotalRowFormula
=
function
(
val
,
opt_ws
,
opt_buildDep
)
{
this
.
removeDependencies
();
if
(
val
)
{
this
.
TotalsRowFormula
=
new
AscCommonExcel
.
parserFormula
(
val
,
this
,
opt_ws
);
this
.
TotalsRowFormula
.
parse
();
if
(
opt_buildDep
)
{
this
.
TotalsRowFormula
.
buildDependencies
();
this
.
buildDependencies
();
}
}
else
{
this
.
TotalsRowFormula
=
null
;
}
};
...
...
cell/model/autofilters.js
View file @
8e970924
...
...
@@ -962,9 +962,6 @@
if
(
undoData
.
clone
)
{
cloneData
=
undoData
.
clone
(
null
);
if
(
cloneData
.
buildDependencies
)
{
cloneData
.
buildDependencies
();
}
}
else
cloneData
=
undoData
;
...
...
@@ -986,10 +983,7 @@
{
if
(
cloneData
.
TableStyleInfo
)
{
if
(
!
worksheet
.
TableParts
)
worksheet
.
TableParts
=
[];
worksheet
.
TableParts
[
worksheet
.
TableParts
.
length
]
=
cloneData
;
worksheet
.
workbook
.
dependencyFormulas
.
addTableName
(
worksheet
,
cloneData
);
worksheet
.
addTablePart
(
cloneData
,
true
);
this
.
_setColorStyleTable
(
cloneData
.
Ref
,
cloneData
,
null
,
true
);
}
else
...
...
@@ -1005,7 +999,7 @@
{
if
(
cloneData
.
newFilterRef
&&
cloneData
.
oldFilter
&&
cloneData
.
oldFilter
.
DisplayName
===
worksheet
.
TableParts
[
l
].
DisplayName
)
{
worksheet
.
TableParts
[
l
]
=
cloneData
.
oldFilter
.
clone
(
null
);
worksheet
.
changeTablePart
(
l
,
cloneData
.
oldFilter
.
clone
(
null
),
false
);
//чистим стиль от старой таблицы
var
clearRange
=
new
AscCommonExcel
.
Range
(
worksheet
,
cloneData
.
newFilterRef
.
r1
,
cloneData
.
newFilterRef
.
c1
,
cloneData
.
newFilterRef
.
r2
,
cloneData
.
newFilterRef
.
c2
);
...
...
@@ -1031,9 +1025,8 @@
for
(
var
l
=
0
;
l
<
worksheet
.
TableParts
.
length
;
l
++
)
{
if
(
oldName
===
worksheet
.
TableParts
[
l
].
DisplayName
)
{
worksheet
.
TableParts
[
l
]
=
cloneData
.
oldFilter
.
clone
(
null
);
worksheet
.
workbook
.
dependencyFormulas
.
changeTableName
(
oldName
,
worksheet
.
TableParts
[
l
].
DisplayName
);
{
worksheet
.
changeTablePart
(
l
,
cloneData
.
oldFilter
.
clone
(
null
),
true
);
break
;
}
}
...
...
@@ -1048,7 +1041,7 @@
{
if
(
cloneData
.
oldFilter
.
DisplayName
===
worksheet
.
TableParts
[
l
].
DisplayName
)
{
worksheet
.
TableParts
[
l
]
=
cloneData
.
oldFilter
.
clone
(
null
);
worksheet
.
changeTablePart
(
l
,
cloneData
.
oldFilter
.
clone
(
null
),
false
);
break
;
}
}
...
...
@@ -1064,7 +1057,7 @@
//если передавать в redo displaName -> конфликт при совместном ред.(1- ый добавляет ф/т + undo, 2-ой добавляет ф/т, первый делает redo->2 одинаковых имени)
if
(
cloneData
.
Ref
.
isEqual
(
worksheet
.
TableParts
[
l
].
Ref
))
{
worksheet
.
TableParts
[
l
]
=
cloneData
.
clone
(
null
);
worksheet
.
changeTablePart
(
l
,
cloneData
.
clone
(
null
),
false
);
this
.
_setColorStyleTable
(
cloneData
.
Ref
,
cloneData
,
null
,
true
);
break
;
}
...
...
@@ -1089,7 +1082,7 @@
{
if
(
cloneData
.
Ref
.
isEqual
(
worksheet
.
TableParts
[
l
].
Ref
))
{
worksheet
.
TableParts
[
l
]
=
cloneData
;
worksheet
.
changeTablePart
(
l
,
cloneData
,
false
)
;
if
(
cloneData
.
AutoFilter
&&
cloneData
.
AutoFilter
.
FilterColumns
)
this
.
_reDrawCurrentFilter
(
cloneData
.
AutoFilter
.
FilterColumns
,
worksheet
.
TableParts
[
l
]);
else
...
...
@@ -1109,10 +1102,7 @@
{
if
(
cloneData
.
TableStyleInfo
)
{
if
(
!
worksheet
.
TableParts
)
worksheet
.
TableParts
=
[];
worksheet
.
TableParts
[
worksheet
.
TableParts
.
length
]
=
cloneData
;
worksheet
.
workbook
.
dependencyFormulas
.
addTableName
(
worksheet
,
cloneData
);
worksheet
.
addTablePart
.
push
(
cloneData
);
this
.
_setColorStyleTable
(
cloneData
.
Ref
,
cloneData
,
null
,
true
);
}
else
...
...
@@ -1133,11 +1123,7 @@
if
(
cloneData
.
Ref
.
isEqual
(
worksheet
.
TableParts
[
l
].
Ref
))
{
this
.
_cleanStyleTable
(
cloneData
.
Ref
);
worksheet
.
workbook
.
dependencyFormulas
.
delTableName
(
worksheet
.
TableParts
[
l
].
DisplayName
);
var
deleted
=
worksheet
.
TableParts
.
splice
(
l
,
1
);
for
(
var
delIndex
=
0
;
delIndex
<
deleted
.
length
;
++
delIndex
)
{
deleted
[
delIndex
].
removeDependencies
();
}
worksheet
.
deleteTablePart
(
l
);
}
}
}
...
...
@@ -1198,6 +1184,7 @@
var
changeFilter
=
function
(
filter
,
isTablePart
)
{
var
bRes
=
false
;
var
oldFilter
=
filter
.
clone
(
null
);
var
oRange
=
AscCommonExcel
.
Range
.
prototype
.
createFromBBox
(
worksheet
,
oldFilter
.
Ref
);
...
...
@@ -1220,11 +1207,9 @@
}
else
t
.
_addHistoryObj
(
oldFilter
,
AscCH
.
historyitem_AutoFilter_Empty
,
{
activeCells
:
activeCells
},
null
,
oldFilter
.
Ref
);
if
(
isTablePart
)
worksheet
.
workbook
.
dependencyFormulas
.
delTableName
(
oldFilter
.
DisplayName
)
}
else
return
filter
;
bRes
=
true
;
}
return
bRes
;
};
if
(
worksheet
.
AutoFilter
)
...
...
@@ -1233,19 +1218,13 @@
}
if
(
worksheet
.
TableParts
)
{
var
newTableParts
=
[];
for
(
var
i
=
0
;
i
<
worksheet
.
TableParts
.
length
;
i
++
)
for
(
var
i
=
worksheet
.
TableParts
.
length
-
1
;
i
>=
0
;
i
--
)
{
var
tablePart
=
worksheet
.
TableParts
[
i
];
var
filter
=
changeFilter
(
tablePart
,
true
);
if
(
filter
){
newTableParts
.
push
(
filter
);
}
else
{
tablePart
.
removeDependencies
();
if
(
!
changeFilter
(
tablePart
,
true
))
{
worksheet
.
deleteTablePart
(
i
);
}
}
worksheet
.
TableParts
=
newTableParts
;
}
t
.
_setStyleTablePartsAfterOpenRows
(
activeCells
);
...
...
@@ -3072,7 +3051,7 @@
}
var
oldLabel
=
tableColumn
.
TotalsRowLabel
;
var
oldFormula
=
tableColumn
.
TotalsRowFormula
?
tableColumn
.
TotalsRowFormula
.
Formula
:
null
;
var
oldFormula
=
tableColumn
.
getTotalsRowFormula
()
;
if
(
null
!==
formula
)
{
...
...
@@ -3616,8 +3595,6 @@
}
else
{
if
(
!
worksheet
.
TableParts
)
worksheet
.
TableParts
=
[];
//ref = Asc.g_oRangeCache.getAscRange(val[0].id + ':' + val[val.length - 1].idNext).clone();
newFilter
=
worksheet
.
createTablePart
();
...
...
@@ -3651,8 +3628,7 @@
}
newFilter
.
DisplayName
=
newTableName
;
worksheet
.
workbook
.
dependencyFormulas
.
addTableName
(
worksheet
,
newFilter
);
var
tableColumns
;
if
(
tablePart
&&
tablePart
.
TableColumns
)
{
...
...
@@ -3668,7 +3644,7 @@
}
newFilter
.
TableColumns
=
tableColumns
;
worksheet
.
TableParts
[
worksheet
.
TableParts
.
length
]
=
newFilter
;
worksheet
.
addTablePart
(
newFilter
,
true
)
;
//TODO возможно дублируется при всавке(ф-ия _pasteFromBinary) - пересмотреть
if
(
tablePart
)
{
var
renameParams
=
{};
...
...
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