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
cd454371
Commit
cd454371
authored
Mar 31, 2016
by
GoshaZotov
Committed by
Alexander.Trofimov
May 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add function af_checkInsDelCells(check range before ins/del cells)
parent
29065301
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
189 additions
and
33 deletions
+189
-33
cell/model/autofilters.js
cell/model/autofilters.js
+63
-18
cell/view/WorksheetView.js
cell/view/WorksheetView.js
+126
-15
No files found.
cell/model/autofilters.js
View file @
cd454371
...
@@ -1904,6 +1904,31 @@
...
@@ -1904,6 +1904,31 @@
return
result
;
return
result
;
},
},
getTableIntersectionRange
:
function
(
range
)
{
var
worksheet
=
this
.
worksheet
;
var
res
=
null
;
var
tableParts
=
worksheet
.
TableParts
;
if
(
tableParts
)
{
for
(
var
i
=
0
;
i
<
tableParts
.
length
;
i
++
)
{
if
(
tableParts
[
i
].
Ref
.
intersection
(
range
))
{
if
(
res
===
null
)
{
res
=
[];
}
res
.
push
(
worksheet
.
TableParts
[
i
]);
}
}
}
return
res
;
},
changeFormatTableInfo
:
function
(
tablePart
,
optionType
)
changeFormatTableInfo
:
function
(
tablePart
,
optionType
)
{
{
switch
(
optionType
)
switch
(
optionType
)
...
@@ -3807,21 +3832,6 @@
...
@@ -3807,21 +3832,6 @@
return
res
;
return
res
;
},
},
_isIntersectionTableParts
:
function
(
range
)
{
var
worksheet
=
this
.
worksheet
;
var
tableParts
=
worksheet
.
TableParts
;
var
tablePart
;
for
(
var
i
=
0
;
i
<
tableParts
.
length
;
i
++
)
{
tablePart
=
tableParts
[
i
];
if
(
tablePart
.
Ref
.
intersection
(
range
))
return
true
;
}
return
false
;
},
_cleanFilterColumnsAndSortState
:
function
(
autoFilterElement
,
activeCells
)
_cleanFilterColumnsAndSortState
:
function
(
autoFilterElement
,
activeCells
)
{
{
var
worksheet
=
this
.
worksheet
;
var
worksheet
=
this
.
worksheet
;
...
@@ -3983,17 +3993,17 @@
...
@@ -3983,17 +3993,17 @@
var
tableRef
=
worksheet
.
TableParts
[
i
].
Ref
;
var
tableRef
=
worksheet
.
TableParts
[
i
].
Ref
;
if
(
tableRef
.
r1
>=
range
.
r2
)
if
(
tableRef
.
r1
>=
range
.
r2
)
{
{
if
(
range
.
c1
<
tableRef
.
c1
&&
range
.
c2
<
tableRef
.
c2
&&
range
.
c2
>=
tableRef
.
c1
)
if
(
tableRef
.
c1
<
range
.
c1
&&
tableRef
.
c2
>
range
.
c1
&&
tableRef
.
c2
<=
range
.
c2
)
{
{
result
=
true
;
result
=
true
;
break
;
break
;
}
}
else
if
(
range
.
c1
>
tableRef
.
c1
&&
range
.
c2
>
tableRef
.
c2
&&
range
.
c1
>=
tableRef
.
c1
)
else
if
(
tableRef
.
c1
>=
range
.
c1
&&
tableRef
.
c1
<
range
.
c2
&&
tableRef
.
c2
>
range
.
c2
)
{
{
result
=
true
;
result
=
true
;
break
;
break
;
}
}
else
if
((
range
.
c1
>
tableRef
.
c1
&&
range
.
c2
<=
tableRef
.
c2
)
||
(
range
.
c1
>=
tableRef
.
c1
&&
range
.
c2
<
tableRef
.
c2
))
else
if
((
tableRef
.
c1
<=
range
.
c1
&&
tableRef
.
c2
>
range
.
c2
)
||
(
tableRef
.
c1
<
range
.
c1
&&
tableRef
.
c2
>=
range
.
c2
))
{
{
result
=
true
;
result
=
true
;
break
;
break
;
...
@@ -4005,6 +4015,41 @@
...
@@ -4005,6 +4015,41 @@
return
result
;
return
result
;
},
},
isPartTablePartsRightRange
:
function
(
range
)
{
var
worksheet
=
this
.
worksheet
;
var
res
=
false
;
if
(
worksheet
.
TableParts
&&
worksheet
.
TableParts
.
length
)
{
for
(
var
i
=
0
;
i
<
worksheet
.
TableParts
.
length
;
i
++
)
{
var
tableRef
=
worksheet
.
TableParts
[
i
].
Ref
;
if
(
tableRef
.
c1
>=
range
.
c2
)
{
if
(
tableRef
.
r1
<
range
.
r1
&&
tableRef
.
r2
>
range
.
r1
&&
tableRef
.
r2
<=
range
.
r2
)
{
result
=
true
;
break
;
}
else
if
(
tableRef
.
r1
>=
range
.
r1
&&
tableRef
.
r1
<
range
.
r2
&&
tableRef
.
r2
>
range
.
r2
)
{
result
=
true
;
break
;
}
else
if
((
tableRef
.
r1
<=
range
.
r1
&&
tableRef
.
r2
>
range
.
r2
)
||
(
tableRef
.
r1
<
range
.
r1
&&
tableRef
.
r2
>=
range
.
r2
))
{
result
=
true
;
break
;
}
}
}
}
return
res
;
},
_isPartAutoFilterUnderRange
:
function
(
range
)
_isPartAutoFilterUnderRange
:
function
(
range
)
{
{
var
worksheet
=
this
.
worksheet
;
var
worksheet
=
this
.
worksheet
;
...
...
cell/view/WorksheetView.js
View file @
cd454371
...
@@ -10323,7 +10323,7 @@
...
@@ -10323,7 +10323,7 @@
range
=
t
.
model
.
getRange3
(
arn
.
r1
,
arn
.
c1
,
arn
.
r2
,
arn
.
c2
);
range
=
t
.
model
.
getRange3
(
arn
.
r1
,
arn
.
c1
,
arn
.
r2
,
arn
.
c2
);
switch
(
val
)
{
switch
(
val
)
{
case
c_oAscInsertOptions
.
InsertCellsAndShiftRight
:
case
c_oAscInsertOptions
.
InsertCellsAndShiftRight
:
isCheckChangeAutoFilter
=
t
.
model
.
autoFilters
.
isActiveCellsCrossHalfFTable
(
arn
,
c_oAscInsertOptions
.
InsertCellsAndShiftRight
,
prop
);
isCheckChangeAutoFilter
=
t
.
af_checkInsDelCells
(
arn
,
c_oAscInsertOptions
.
InsertCellsAndShiftRight
,
prop
);
if
(
isCheckChangeAutoFilter
===
false
)
{
if
(
isCheckChangeAutoFilter
===
false
)
{
return
;
return
;
}
}
...
@@ -10344,7 +10344,7 @@
...
@@ -10344,7 +10344,7 @@
this
.
_isLockedCells
(
oChangeData
.
changedRange
,
null
,
onChangeWorksheetCallback
);
this
.
_isLockedCells
(
oChangeData
.
changedRange
,
null
,
onChangeWorksheetCallback
);
break
;
break
;
case
c_oAscInsertOptions
.
InsertCellsAndShiftDown
:
case
c_oAscInsertOptions
.
InsertCellsAndShiftDown
:
isCheckChangeAutoFilter
=
t
.
model
.
autoFilters
.
isActiveCellsCrossHalfFTable
(
arn
,
c_oAscInsertOptions
.
InsertCellsAndShiftDown
,
prop
);
isCheckChangeAutoFilter
=
t
.
af_checkInsDelCells
(
arn
,
c_oAscInsertOptions
.
InsertCellsAndShiftDown
,
prop
);
if
(
isCheckChangeAutoFilter
===
false
)
{
if
(
isCheckChangeAutoFilter
===
false
)
{
return
;
return
;
}
}
...
@@ -10403,7 +10403,7 @@
...
@@ -10403,7 +10403,7 @@
range
=
t
.
model
.
getRange3
(
checkRange
.
r1
,
checkRange
.
c1
,
checkRange
.
r2
,
checkRange
.
c2
);
range
=
t
.
model
.
getRange3
(
checkRange
.
r1
,
checkRange
.
c1
,
checkRange
.
r2
,
checkRange
.
c2
);
switch
(
val
)
{
switch
(
val
)
{
case
c_oAscDeleteOptions
.
DeleteCellsAndShiftLeft
:
case
c_oAscDeleteOptions
.
DeleteCellsAndShiftLeft
:
isCheckChangeAutoFilter
=
t
.
model
.
autoFilters
.
isActiveCellsCrossHalfFTable
(
arn
,
c_oAscDeleteOptions
.
DeleteCellsAndShiftLeft
,
prop
);
isCheckChangeAutoFilter
=
t
.
af_checkInsDelCells
(
arn
,
c_oAscDeleteOptions
.
DeleteCellsAndShiftLeft
,
prop
);
if
(
isCheckChangeAutoFilter
===
false
)
{
if
(
isCheckChangeAutoFilter
===
false
)
{
return
;
return
;
}
}
...
@@ -10428,7 +10428,7 @@
...
@@ -10428,7 +10428,7 @@
this
.
_isLockedCells
(
oChangeData
.
changedRange
,
null
,
onChangeWorksheetCallback
);
this
.
_isLockedCells
(
oChangeData
.
changedRange
,
null
,
onChangeWorksheetCallback
);
break
;
break
;
case
c_oAscDeleteOptions
.
DeleteCellsAndShiftTop
:
case
c_oAscDeleteOptions
.
DeleteCellsAndShiftTop
:
isCheckChangeAutoFilter
=
t
.
model
.
autoFilters
.
isActiveCellsCrossHalfFTable
(
arn
,
c_oAscDeleteOptions
.
DeleteCellsAndShiftTop
,
prop
);
isCheckChangeAutoFilter
=
t
.
af_checkInsDelCells
(
arn
,
c_oAscDeleteOptions
.
DeleteCellsAndShiftTop
,
prop
);
if
(
isCheckChangeAutoFilter
===
false
)
{
if
(
isCheckChangeAutoFilter
===
false
)
{
return
;
return
;
}
}
...
@@ -12829,7 +12829,7 @@
...
@@ -12829,7 +12829,7 @@
{
{
var
t
=
this
;
var
t
=
this
;
var
ws
=
this
.
model
;
var
ws
=
this
.
model
;
var
acitveRange
=
this
.
activeRange
.
clone
()
;
var
acitveRange
=
this
.
activeRange
;
var
tablePart
=
ws
.
autoFilters
.
_getFilterByDisplayName
(
tableName
);
var
tablePart
=
ws
.
autoFilters
.
_getFilterByDisplayName
(
tableName
);
...
@@ -12843,37 +12843,51 @@
...
@@ -12843,37 +12843,51 @@
var
startRow
=
this
.
activeRange
.
r1
;
var
startRow
=
this
.
activeRange
.
r1
;
var
endRow
=
this
.
activeRange
.
r2
;
var
endRow
=
this
.
activeRange
.
r2
;
var
newActiveRange
=
null
;
var
newActiveRange
=
this
.
activeRange
.
clone
()
;
var
val
;
var
val
=
null
;
switch
(
optionType
)
switch
(
optionType
)
{
{
case
c_oAscInsertOptions
.
InsertTableRowAbove
:
case
c_oAscInsertOptions
.
InsertTableRowAbove
:
{
{
newActiveRange
=
new
Asc
.
Range
(
tablePart
.
Ref
.
c1
,
startRow
,
tablePart
.
Ref
.
c2
,
endRow
);
newActiveRange
.
c1
=
tablePart
.
Ref
.
c1
;
newActiveRange
.
c2
=
tablePart
.
Ref
.
c2
;
val
=
c_oAscInsertOptions
.
InsertCellsAndShiftDown
;
val
=
c_oAscInsertOptions
.
InsertCellsAndShiftDown
;
break
;
break
;
}
}
case
c_oAscInsertOptions
.
InsertTableRowBelow
:
case
c_oAscInsertOptions
.
InsertTableRowBelow
:
{
{
newActiveRange
=
new
Asc
.
Range
(
tablePart
.
Ref
.
c1
,
startRow
-
1
,
tablePart
.
Ref
.
c2
,
endRow
-
1
);
newActiveRange
.
c1
=
tablePart
.
Ref
.
c1
;
newActiveRange
.
c2
=
tablePart
.
Ref
.
c2
;
newActiveRange
.
r1
=
startRow
+
(
endRow
-
startRow
)
+
1
;
newActiveRange
.
r2
=
endRow
+
(
endRow
-
startRow
)
+
1
;
val
=
c_oAscInsertOptions
.
InsertCellsAndShiftDown
;
val
=
c_oAscInsertOptions
.
InsertCellsAndShiftDown
;
break
;
break
;
}
}
case
c_oAscInsertOptions
.
InsertTableColLeft
:
case
c_oAscInsertOptions
.
InsertTableColLeft
:
{
{
newActiveRange
=
new
Asc
.
Range
(
startCol
-
1
,
tablePart
.
Ref
.
r1
,
endCol
-
1
,
tablePart
.
Ref
.
r2
);
newActiveRange
.
c1
=
startCol
-
1
;
newActiveRange
.
c2
=
endCol
-
1
;
newActiveRange
.
r1
=
tablePart
.
Ref
.
r1
;
newActiveRange
.
r2
=
tablePart
.
Ref
.
r2
;
val
=
c_oAscInsertOptions
.
InsertCellsAndShiftRight
;
val
=
c_oAscInsertOptions
.
InsertCellsAndShiftRight
;
break
;
break
;
}
}
case
c_oAscInsertOptions
.
InsertTableColRight
:
case
c_oAscInsertOptions
.
InsertTableColRight
:
{
{
newActiveRange
=
new
Asc
.
Range
(
startCol
,
tablePart
.
Ref
.
r1
,
endCol
,
tablePart
.
Ref
.
r2
);
newActiveRange
=
new
Asc
.
Range
(
startCol
,
tablePart
.
Ref
.
r1
,
endCol
,
tablePart
.
Ref
.
r2
);
newActiveRange
.
r1
=
tablePart
.
Ref
.
r1
;
newActiveRange
.
r2
=
tablePart
.
Ref
.
r2
;
val
=
c_oAscInsertOptions
.
InsertCellsAndShiftRight
;
val
=
c_oAscInsertOptions
.
InsertCellsAndShiftRight
;
break
;
break
;
}
}
}
}
if
(
newActiveRange
!==
null
)
if
(
val
!==
null
)
{
{
t
.
activeRange
=
newActiveRange
;
t
.
activeRange
=
newActiveRange
;
t
.
changeWorksheet
(
"
insCell
"
,
val
);
t
.
changeWorksheet
(
"
insCell
"
,
val
);
...
@@ -12903,16 +12917,16 @@
...
@@ -12903,16 +12917,16 @@
var
val
;
var
val
;
switch
(
optionType
)
switch
(
optionType
)
{
{
case
c_oAsc
Insert
Options
.
DeleteColumns
:
case
c_oAsc
Delete
Options
.
DeleteColumns
:
{
{
newActiveRange
=
new
Asc
.
Range
(
startCol
,
tablePart
.
Ref
.
r1
,
endCol
,
tablePart
.
Ref
.
r2
);
newActiveRange
=
new
Asc
.
Range
(
startCol
,
tablePart
.
Ref
.
r1
,
endCol
,
tablePart
.
Ref
.
r2
);
val
=
c_oAsc
Insert
Options
.
DeleteCellsAndShiftLeft
;
val
=
c_oAsc
Delete
Options
.
DeleteCellsAndShiftLeft
;
break
;
break
;
}
}
case
c_oAsc
Insert
Options
.
DeleteRows
:
case
c_oAsc
Delete
Options
.
DeleteRows
:
{
{
newActiveRange
=
new
Asc
.
Range
(
tablePart
.
Ref
.
c1
,
startRow
,
tablePart
.
Ref
.
c2
,
endRow
);
newActiveRange
=
new
Asc
.
Range
(
tablePart
.
Ref
.
c1
,
startRow
,
tablePart
.
Ref
.
c2
,
endRow
);
val
=
c_oAsc
Insert
Options
.
DeleteCellsAndShiftTop
;
val
=
c_oAsc
Delete
Options
.
DeleteCellsAndShiftTop
;
break
;
break
;
}
}
case
c_oAscInsertOptions
.
DeleteTable
:
case
c_oAscInsertOptions
.
DeleteTable
:
...
@@ -12946,6 +12960,103 @@
...
@@ -12946,6 +12960,103 @@
//TODO тестовый вариант. нужно сделать методы и добавлять в историю
//TODO тестовый вариант. нужно сделать методы и добавлять в историю
tablePart
.
DisplayName
=
newName
;
tablePart
.
DisplayName
=
newName
;
};
};
WorksheetView
.
prototype
.
af_checkInsDelCells
=
function
(
activeRange
,
val
,
prop
)
{
var
t
=
this
;
var
ws
=
this
.
model
;
var
res
=
true
;
var
intersectionTableParts
=
ws
.
autoFilters
.
getTableIntersectionRange
(
activeRange
);
var
isPartTablePartsUnderRange
=
ws
.
autoFilters
.
_isPartTablePartsUnderRange
(
activeRange
);
var
isPartTablePartsRightRange
=
ws
.
autoFilters
.
isPartTablePartsRightRange
(
activeRange
);
var
isOneTableIntersection
=
intersectionTableParts
&&
intersectionTableParts
.
length
===
1
?
intersectionTableParts
[
0
]
:
null
;
var
checkInsCells
=
function
()
{
switch
(
val
)
{
case
c_oAscInsertOptions
.
InsertCellsAndShiftDown
:
{
//если внизу находится часть форматированной таблицы или это часть форматированной таблицы
if
(
isPartTablePartsUnderRange
)
{
res
=
false
;
}
else
if
(
isOneTableIntersection
!==
null
&&
!
(
isOneTableIntersection
.
Ref
.
c1
===
activeRange
.
c1
&&
isOneTableIntersection
.
Ref
.
c2
===
activeRange
.
c2
))
{
res
=
false
;
}
break
;
}
case
c_oAscInsertOptions
.
InsertCellsAndShiftRight
:
{
//если справа находится часть форматированной таблицы или это часть форматированной таблицы
if
(
isPartTablePartsRightRange
)
{
res
=
false
;
}
break
;
}
case
c_oAscInsertOptions
.
InsertColumns
:
{
break
;
}
case
c_oAscInsertOptions
.
InsertRows
:
{
break
;
}
}
};
var
checkDelCells
=
function
()
{
switch
(
val
)
{
case
c_oAscDeleteOptions
.
DeleteCellsAndShiftTop
:
{
if
(
isPartTablePartsUnderRange
)
{
res
=
false
;
}
break
;
}
case
c_oAscDeleteOptions
.
DeleteCellsAndShiftLeft
:
{
if
(
isPartTablePartsUnderRange
)
{
res
=
false
;
}
break
;
}
case
c_oAscDeleteOptions
.
DeleteColumns
:
{
break
;
}
case
c_oAscDeleteOptions
.
DeleteRows
:
{
break
;
}
}
};
prop
===
"
insCell
"
?
checkInsCells
()
:
checkDelCells
();
if
(
res
===
false
)
{
ws
.
workbook
.
handlers
.
trigger
(
"
asc_onError
"
,
c_oAscError
.
ID
.
AutoFilterChangeFormatTableError
,
c_oAscError
.
Level
.
NoCritical
);
}
return
res
;
};
/*
/*
* Export
* Export
* -----------------------------------------------------------------------------
* -----------------------------------------------------------------------------
...
...
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