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
dec78404
Commit
dec78404
authored
Jan 18, 2017
by
GoshaZotov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add function asc_convertTableToRange
parent
8c3bb72f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
127 additions
and
16 deletions
+127
-16
cell/api.js
cell/api.js
+7
-1
cell/model/FormulaObjects/parserFormula.js
cell/model/FormulaObjects/parserFormula.js
+11
-4
cell/model/Workbook.js
cell/model/Workbook.js
+34
-7
cell/model/autofilters.js
cell/model/autofilters.js
+35
-4
cell/view/WorksheetView.js
cell/view/WorksheetView.js
+40
-0
No files found.
cell/api.js
View file @
dec78404
...
@@ -601,6 +601,11 @@ var editor;
...
@@ -601,6 +601,11 @@ var editor;
return
ws
.
af_changeTableRange
(
tableName
,
range
);
return
ws
.
af_changeTableRange
(
tableName
,
range
);
};
};
spreadsheet_api
.
prototype
.
asc_convertTableToRange
=
function
(
tableName
)
{
var
ws
=
this
.
wb
.
getWorksheet
();
return
ws
.
af_convertTableToRange
(
tableName
);
};
spreadsheet_api
.
prototype
.
asc_getTablePictures
=
function
(
props
)
spreadsheet_api
.
prototype
.
asc_getTablePictures
=
function
(
props
)
{
{
return
this
.
wb
.
getTablePictures
(
props
);
return
this
.
wb
.
getTablePictures
(
props
);
...
@@ -3481,6 +3486,7 @@ var editor;
...
@@ -3481,6 +3486,7 @@ var editor;
prot
[
"
asc_deleteCellsInTable
"
]
=
prot
.
asc_deleteCellsInTable
;
prot
[
"
asc_deleteCellsInTable
"
]
=
prot
.
asc_deleteCellsInTable
;
prot
[
"
asc_changeDisplayNameTable
"
]
=
prot
.
asc_changeDisplayNameTable
;
prot
[
"
asc_changeDisplayNameTable
"
]
=
prot
.
asc_changeDisplayNameTable
;
prot
[
"
asc_changeTableRange
"
]
=
prot
.
asc_changeTableRange
;
prot
[
"
asc_changeTableRange
"
]
=
prot
.
asc_changeTableRange
;
prot
[
"
asc_convertTableToRange
"
]
=
prot
.
asc_convertTableToRange
;
prot
[
"
asc_getTablePictures
"
]
=
prot
.
asc_getTablePictures
;
prot
[
"
asc_getTablePictures
"
]
=
prot
.
asc_getTablePictures
;
// Drawing objects interface
// Drawing objects interface
...
...
cell/model/FormulaObjects/parserFormula.js
View file @
dec78404
...
@@ -3875,7 +3875,7 @@ function parserFormula( formula, parent, _ws ) {
...
@@ -3875,7 +3875,7 @@ function parserFormula( formula, parent, _ws ) {
parserFormula
.
prototype
.
setIsTable
=
function
(
isTable
){
parserFormula
.
prototype
.
setIsTable
=
function
(
isTable
){
this
.
isTable
=
isTable
;
this
.
isTable
=
isTable
;
};
};
parserFormula
.
prototype
.
notify
=
function
(
data
)
{
parserFormula
.
prototype
.
notify
=
function
(
data
,
bConvertTableFormulaToRef
)
{
var
eventData
=
{
notifyData
:
data
,
assemble
:
null
,
isRebuild
:
false
,
formula
:
this
};
var
eventData
=
{
notifyData
:
data
,
assemble
:
null
,
isRebuild
:
false
,
formula
:
this
};
if
(
this
.
parent
&&
this
.
parent
.
onFormulaEvent
)
{
if
(
this
.
parent
&&
this
.
parent
.
onFormulaEvent
)
{
var
checkCanDo
=
this
.
parent
.
onFormulaEvent
(
AscCommon
.
c_oNotifyParentType
.
CanDo
,
eventData
);
var
checkCanDo
=
this
.
parent
.
onFormulaEvent
(
AscCommon
.
c_oNotifyParentType
.
CanDo
,
eventData
);
...
@@ -3903,7 +3903,7 @@ function parserFormula( formula, parent, _ws ) {
...
@@ -3903,7 +3903,7 @@ function parserFormula( formula, parent, _ws ) {
eventData
.
isRebuild
=
false
;
eventData
.
isRebuild
=
false
;
}
else
if
(
AscCommon
.
c_oNotifyType
.
ChangeDefName
===
data
.
type
)
{
}
else
if
(
AscCommon
.
c_oNotifyType
.
ChangeDefName
===
data
.
type
)
{
if
(
!
data
.
to
)
{
if
(
!
data
.
to
)
{
this
.
removeTableName
(
data
.
from
);
this
.
removeTableName
(
data
.
from
,
bConvertTableFormulaToRef
);
eventData
.
isRebuild
=
true
;
eventData
.
isRebuild
=
true
;
}
else
if
(
data
.
from
.
name
!=
data
.
to
.
name
)
{
}
else
if
(
data
.
from
.
name
!=
data
.
to
.
name
)
{
this
.
changeDefName
(
data
.
from
,
data
.
to
);
this
.
changeDefName
(
data
.
from
,
data
.
to
);
...
@@ -4889,14 +4889,21 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
...
@@ -4889,14 +4889,21 @@ parserFormula.prototype.calculate = function(opt_defName, opt_range) {
}
}
}
}
};
};
parserFormula
.
prototype
.
removeTableName
=
function
(
defName
)
{
parserFormula
.
prototype
.
removeTableName
=
function
(
defName
,
bConvertTableFormulaToRef
)
{
var
i
,
elem
;
var
i
,
elem
;
for
(
i
=
0
;
i
<
this
.
outStack
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
this
.
outStack
.
length
;
i
++
)
{
elem
=
this
.
outStack
[
i
];
elem
=
this
.
outStack
[
i
];
if
(
elem
.
type
==
cElementType
.
table
&&
elem
.
tableName
==
defName
.
name
)
{
if
(
elem
.
type
==
cElementType
.
table
&&
elem
.
tableName
==
defName
.
name
)
{
if
(
bConvertTableFormulaToRef
)
{
this
.
outStack
[
i
]
=
this
.
outStack
[
i
].
toRef
();
}
else
{
this
.
outStack
[
i
]
=
new
cError
(
cErrorType
.
bad_reference
);
this
.
outStack
[
i
]
=
new
cError
(
cErrorType
.
bad_reference
);
}
}
}
}
}
};
};
parserFormula
.
prototype
.
removeTableColumn
=
function
(
tableName
,
deleted
)
{
parserFormula
.
prototype
.
removeTableColumn
=
function
(
tableName
,
deleted
)
{
var
i
,
elem
;
var
i
,
elem
;
...
...
cell/model/Workbook.js
View file @
dec78404
...
@@ -763,6 +763,19 @@
...
@@ -763,6 +763,19 @@
var
notifyData
=
{
type
:
AscCommon
.
c_oNotifyType
.
ChangeDefName
,
from
:
defName
.
getUndoDefName
(),
to
:
null
};
var
notifyData
=
{
type
:
AscCommon
.
c_oNotifyType
.
ChangeDefName
,
from
:
defName
.
getUndoDefName
(),
to
:
null
};
this
.
_broadcastDefName
(
tableName
,
notifyData
);
this
.
_broadcastDefName
(
tableName
,
notifyData
);
},
},
delTableName2
:
function
(
tableName
)
{
this
.
buildDependency
();
var
defName
=
this
.
getDefNameByName
(
tableName
);
this
.
addToChangedDefName
(
defName
);
var
notifyData
=
{
type
:
AscCommon
.
c_oNotifyType
.
ChangeDefName
,
from
:
defName
.
getUndoDefName
(),
to
:
null
};
this
.
_broadcastDefName
(
tableName
,
notifyData
,
true
);
this
.
_delDefName
(
tableName
,
null
);
if
(
defName
)
{
defName
.
removeDependencies
();
}
},
delColumnTable
:
function
(
tableName
,
deleted
)
{
delColumnTable
:
function
(
tableName
,
deleted
)
{
this
.
buildDependency
();
this
.
buildDependency
();
var
notifyData
=
{
type
:
AscCommon
.
c_oNotifyType
.
DelColumnTable
,
tableName
:
tableName
,
deleted
:
deleted
};
var
notifyData
=
{
type
:
AscCommon
.
c_oNotifyType
.
DelColumnTable
,
tableName
:
tableName
,
deleted
:
deleted
};
...
@@ -1026,12 +1039,12 @@
...
@@ -1026,12 +1039,12 @@
this
.
volatileListeners
[
i
].
notify
(
notifyData
);
this
.
volatileListeners
[
i
].
notify
(
notifyData
);
}
}
},
},
_broadcastDefName
:
function
(
name
,
notifyData
)
{
_broadcastDefName
:
function
(
name
,
notifyData
,
bConvertTableFormulaToRef
)
{
var
nameIndex
=
getDefNameIndex
(
name
);
var
nameIndex
=
getDefNameIndex
(
name
);
var
container
=
this
.
defNameListeners
[
nameIndex
];
var
container
=
this
.
defNameListeners
[
nameIndex
];
if
(
container
)
{
if
(
container
)
{
for
(
var
listenerId
in
container
.
listeners
)
{
for
(
var
listenerId
in
container
.
listeners
)
{
container
.
listeners
[
listenerId
].
notify
(
notifyData
);
container
.
listeners
[
listenerId
].
notify
(
notifyData
,
bConvertTableFormulaToRef
);
}
}
}
}
},
},
...
@@ -4552,13 +4565,27 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
...
@@ -4552,13 +4565,27 @@ Woorksheet.prototype.isApplyFilterBySheet = function(){
this
.
workbook
.
dependencyFormulas
.
changeTableName
(
oldTablePart
.
DisplayName
,
tablePart
.
DisplayName
);
this
.
workbook
.
dependencyFormulas
.
changeTableName
(
oldTablePart
.
DisplayName
,
tablePart
.
DisplayName
);
}
}
};
};
Woorksheet
.
prototype
.
deleteTablePart
=
function
(
index
)
{
Woorksheet
.
prototype
.
deleteTablePart
=
function
(
index
,
bConvertTableFormulaToRef
)
{
if
(
bConvertTableFormulaToRef
)
{
//TODO скорее всего стоит убрать else
var
tablePart
=
this
.
TableParts
[
index
];
this
.
workbook
.
dependencyFormulas
.
delTableName2
(
tablePart
.
DisplayName
);
tablePart
.
removeDependencies
();
//delete table
this
.
TableParts
.
splice
(
index
,
1
);
}
else
{
var
deleted
=
this
.
TableParts
.
splice
(
index
,
1
);
var
deleted
=
this
.
TableParts
.
splice
(
index
,
1
);
for
(
var
delIndex
=
0
;
delIndex
<
deleted
.
length
;
++
delIndex
)
{
for
(
var
delIndex
=
0
;
delIndex
<
deleted
.
length
;
++
delIndex
)
{
var
tablePart
=
deleted
[
delIndex
];
var
tablePart
=
deleted
[
delIndex
];
this
.
workbook
.
dependencyFormulas
.
delTableName
(
tablePart
.
DisplayName
);
this
.
workbook
.
dependencyFormulas
.
delTableName
(
tablePart
.
DisplayName
);
tablePart
.
removeDependencies
();
tablePart
.
removeDependencies
();
}
}
}
};
};
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
/**
/**
...
...
cell/model/autofilters.js
View file @
dec78404
...
@@ -902,7 +902,7 @@
...
@@ -902,7 +902,7 @@
this
.
sortColFilter
(
data
.
type
,
data
.
cellId
,
data
.
activeCells
,
null
,
data
.
displayName
,
data
.
color
);
this
.
sortColFilter
(
data
.
type
,
data
.
cellId
,
data
.
activeCells
,
null
,
data
.
displayName
,
data
.
color
);
break
;
break
;
case
AscCH
.
historyitem_AutoFilter_Empty
:
case
AscCH
.
historyitem_AutoFilter_Empty
:
this
.
isEmptyAutoFilters
(
data
.
activeCells
);
this
.
isEmptyAutoFilters
(
data
.
activeCells
,
null
,
null
,
data
.
val
);
break
;
break
;
case
AscCH
.
historyitem_AutoFilter_ApplyMF
:
case
AscCH
.
historyitem_AutoFilter_ApplyMF
:
this
.
applyAutoFilter
(
data
.
autoFiltersObject
,
data
.
activeCells
);
this
.
applyAutoFilter
(
data
.
autoFiltersObject
,
data
.
activeCells
);
...
@@ -1160,7 +1160,7 @@
...
@@ -1160,7 +1160,7 @@
}
}
},
},
isEmptyAutoFilters
:
function
(
ar
,
insertType
,
exceptionArray
)
isEmptyAutoFilters
:
function
(
ar
,
insertType
,
exceptionArray
,
bConvertTableFormulaToRef
)
{
{
var
worksheet
=
this
.
worksheet
;
var
worksheet
=
this
.
worksheet
;
var
activeCells
=
ar
.
clone
();
var
activeCells
=
ar
.
clone
();
...
@@ -1195,7 +1195,7 @@
...
@@ -1195,7 +1195,7 @@
if
(
isTablePart
)
{
if
(
isTablePart
)
{
oRange
.
setTableStyle
(
null
);
oRange
.
setTableStyle
(
null
);
//write formulas history before filter history
//write formulas history before filter history
worksheet
.
deleteTablePart
(
index
);
worksheet
.
deleteTablePart
(
index
,
bConvertTableFormulaToRef
);
}
else
}
else
worksheet
.
AutoFilter
=
null
;
worksheet
.
AutoFilter
=
null
;
...
@@ -1205,7 +1205,7 @@
...
@@ -1205,7 +1205,7 @@
//заносим в историю
//заносим в историю
if
(
isTablePart
){
if
(
isTablePart
){
t
.
_addHistoryObj
(
oldFilter
,
AscCH
.
historyitem_AutoFilter_Empty
,
{
activeCells
:
activeCells
},
null
,
bbox
);
t
.
_addHistoryObj
(
oldFilter
,
AscCH
.
historyitem_AutoFilter_Empty
,
{
activeCells
:
activeCells
,
val
:
bConvertTableFormulaToRef
},
null
,
bbox
);
}
}
else
else
t
.
_addHistoryObj
(
oldFilter
,
AscCH
.
historyitem_AutoFilter_Empty
,
{
activeCells
:
activeCells
},
null
,
oldFilter
.
Ref
);
t
.
_addHistoryObj
(
oldFilter
,
AscCH
.
historyitem_AutoFilter_Empty
,
{
activeCells
:
activeCells
},
null
,
oldFilter
.
Ref
);
...
@@ -2689,6 +2689,37 @@
...
@@ -2689,6 +2689,37 @@
return
range
;
return
range
;
},
},
convertTableToRange
:
function
(
tableName
)
{
History
.
Create_NewPoint
();
History
.
StartTransaction
();
var
table
=
this
.
_getFilterByDisplayName
(
tableName
);
this
.
_convertTableStyleToStyle
(
table
);
this
.
isEmptyAutoFilters
(
table
.
Ref
,
null
,
null
,
true
);
History
.
EndTransaction
();
},
_convertTableStyleToStyle
:
function
(
table
)
{
if
(
!
table
)
{
return
;
}
for
(
var
i
=
table
.
Ref
.
r1
;
i
<=
table
.
Ref
.
r2
;
i
++
)
{
for
(
var
j
=
table
.
Ref
.
c1
;
j
<=
table
.
Ref
.
c2
;
j
++
)
{
var
cell
=
this
.
worksheet
.
_getCell
(
i
,
j
);
var
xfsFrom
=
cell
.
getCompiledStyle
();
cell
.
setStyle
(
xfsFrom
);
}
}
},
_clearRange
:
function
(
range
,
isClearText
)
_clearRange
:
function
(
range
,
isClearText
)
{
{
range
.
setTableStyle
(
null
);
range
.
setTableStyle
(
null
);
...
...
cell/view/WorksheetView.js
View file @
dec78404
...
@@ -13093,6 +13093,46 @@
...
@@ -13093,6 +13093,46 @@
formatTableInfo
.
isDeleteTable
=
true
;
formatTableInfo
.
isDeleteTable
=
true
;
};
};
WorksheetView
.
prototype
.
af_convertTableToRange
=
function
(
tableName
)
{
var
t
=
this
;
var
callback
=
function
(
isSuccess
)
{
if
(
false
===
isSuccess
)
{
return
;
}
History
.
Create_NewPoint
();
History
.
StartTransaction
();
t
.
model
.
workbook
.
dependencyFormulas
.
lockRecal
();
t
.
model
.
autoFilters
.
convertTableToRange
(
tableName
);
t
.
_onUpdateFormatTable
(
tableRange
,
false
,
true
);
t
.
model
.
workbook
.
dependencyFormulas
.
unlockRecal
();
History
.
EndTransaction
();
};
var
table
=
t
.
model
.
autoFilters
.
_getFilterByDisplayName
(
tableName
);
var
tableRange
=
null
!==
table
?
table
.
Ref
:
null
;
var
lockRange
=
tableRange
;
var
callBackLockedDefNames
=
function
(
isSuccess
)
{
if
(
false
===
isSuccess
)
{
return
;
}
t
.
_isLockedCells
(
lockRange
,
null
,
callback
);
};
//лочим данный именованный диапазон
var
defNameId
=
t
.
model
.
workbook
.
dependencyFormulas
.
getDefNameByName
(
tableName
,
t
.
model
.
getId
());
defNameId
=
defNameId
?
defNameId
.
getNodeId
()
:
null
;
t
.
_isLockedDefNames
(
callBackLockedDefNames
,
defNameId
);
};
WorksheetView
.
prototype
.
af_changeTableRange
=
function
(
tableName
,
range
)
{
WorksheetView
.
prototype
.
af_changeTableRange
=
function
(
tableName
,
range
)
{
var
t
=
this
;
var
t
=
this
;
range
=
AscCommonExcel
.
g_oRangeCache
.
getAscRange
(
range
);
range
=
AscCommonExcel
.
g_oRangeCache
.
getAscRange
(
range
);
...
...
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