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
07f71564
Commit
07f71564
authored
May 06, 2016
by
GoshaZotov
Committed by
Alexander.Trofimov
May 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
functions for color sort
parent
e76d4e7a
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
90 additions
and
20 deletions
+90
-20
cell/model/UndoRedo.js
cell/model/UndoRedo.js
+5
-1
cell/model/Workbook.js
cell/model/Workbook.js
+15
-10
cell/model/autofilters.js
cell/model/autofilters.js
+66
-7
cell/view/WorksheetView.js
cell/view/WorksheetView.js
+4
-2
No files found.
cell/model/UndoRedo.js
View file @
07f71564
...
@@ -1721,7 +1721,8 @@ var g_oUndoRedoData_AutoFilterProperties = {
...
@@ -1721,7 +1721,8 @@ var g_oUndoRedoData_AutoFilterProperties = {
ShowLastColumn
:
13
,
ShowLastColumn
:
13
,
ShowRowStripes
:
14
,
ShowRowStripes
:
14
,
HeaderRowCount
:
15
,
HeaderRowCount
:
15
,
TotalsRowCount
:
16
TotalsRowCount
:
16
,
color
:
17
};
};
function
UndoRedoData_AutoFilter
()
{
function
UndoRedoData_AutoFilter
()
{
this
.
Properties
=
g_oUndoRedoData_AutoFilterProperties
;
this
.
Properties
=
g_oUndoRedoData_AutoFilterProperties
;
...
@@ -1747,6 +1748,7 @@ function UndoRedoData_AutoFilter() {
...
@@ -1747,6 +1748,7 @@ function UndoRedoData_AutoFilter() {
this
.
HeaderRowCount
=
null
;
this
.
HeaderRowCount
=
null
;
this
.
TotalsRowCount
=
null
;
this
.
TotalsRowCount
=
null
;
this
.
color
=
null
;
}
}
UndoRedoData_AutoFilter
.
prototype
=
{
UndoRedoData_AutoFilter
.
prototype
=
{
getType
:
function
()
getType
:
function
()
...
@@ -1778,6 +1780,7 @@ UndoRedoData_AutoFilter.prototype = {
...
@@ -1778,6 +1780,7 @@ UndoRedoData_AutoFilter.prototype = {
case
this
.
Properties
.
ShowRowStripes
:
return
this
.
ShowRowStripes
;
break
;
case
this
.
Properties
.
ShowRowStripes
:
return
this
.
ShowRowStripes
;
break
;
case
this
.
Properties
.
HeaderRowCount
:
return
this
.
HeaderRowCount
;
break
;
case
this
.
Properties
.
HeaderRowCount
:
return
this
.
HeaderRowCount
;
break
;
case
this
.
Properties
.
TotalsRowCount
:
return
this
.
TotalsRowCount
;
break
;
case
this
.
Properties
.
TotalsRowCount
:
return
this
.
TotalsRowCount
;
break
;
case
this
.
Properties
.
color
:
return
this
.
color
;
break
;
}
}
return
null
;
return
null
;
...
@@ -1803,6 +1806,7 @@ UndoRedoData_AutoFilter.prototype = {
...
@@ -1803,6 +1806,7 @@ UndoRedoData_AutoFilter.prototype = {
case
this
.
Properties
.
ShowRowStripes
:
this
.
ShowRowStripes
=
value
;
break
;
case
this
.
Properties
.
ShowRowStripes
:
this
.
ShowRowStripes
=
value
;
break
;
case
this
.
Properties
.
HeaderRowCount
:
this
.
HeaderRowCount
=
value
;
break
;
case
this
.
Properties
.
HeaderRowCount
:
this
.
HeaderRowCount
=
value
;
break
;
case
this
.
Properties
.
TotalsRowCount
:
this
.
TotalsRowCount
=
value
;
break
;
case
this
.
Properties
.
TotalsRowCount
:
this
.
TotalsRowCount
=
value
;
break
;
case
this
.
Properties
.
color
:
this
.
color
=
value
;
break
;
}
}
return
null
;
return
null
;
},
},
...
...
cell/model/Workbook.js
View file @
07f71564
...
@@ -8563,7 +8563,7 @@ Range.prototype.cleanHyperlinks=function(){
...
@@ -8563,7 +8563,7 @@ Range.prototype.cleanHyperlinks=function(){
this
.
removeHyperlink
(
aHyperlinks
.
inner
[
i
].
data
);
this
.
removeHyperlink
(
aHyperlinks
.
inner
[
i
].
data
);
History
.
EndTransaction
();
History
.
EndTransaction
();
};
};
Range
.
prototype
.
sort
=
function
(
nOption
,
nStartCol
,
c
olor
){
Range
.
prototype
.
sort
=
function
(
nOption
,
nStartCol
,
sortC
olor
){
//todo горизонтальная сортировка
//todo горизонтальная сортировка
var
aMerged
=
this
.
worksheet
.
mergeManager
.
get
(
this
.
bbox
);
var
aMerged
=
this
.
worksheet
.
mergeManager
.
get
(
this
.
bbox
);
if
(
aMerged
.
outer
.
length
>
0
||
(
aMerged
.
inner
.
length
>
0
&&
null
==
_isSameSizeMerged
(
this
.
bbox
,
aMerged
.
inner
)))
if
(
aMerged
.
outer
.
length
>
0
||
(
aMerged
.
inner
.
length
>
0
&&
null
==
_isSameSizeMerged
(
this
.
bbox
,
aMerged
.
inner
)))
...
@@ -8577,8 +8577,8 @@ Range.prototype.sort=function(nOption, nStartCol, color){
...
@@ -8577,8 +8577,8 @@ Range.prototype.sort=function(nOption, nStartCol, color){
nStartCol
=
merged
.
bbox
.
c1
;
nStartCol
=
merged
.
bbox
.
c1
;
}
}
this
.
worksheet
.
workbook
.
lockDraw
();
this
.
worksheet
.
workbook
.
lockDraw
();
var
colorFill
=
nOption
===
Asc
.
c_oAscSortOptions
.
ByColorFill
?
color
:
null
;
var
colorFill
=
nOption
===
Asc
.
c_oAscSortOptions
.
ByColorFill
;
var
colorText
=
nOption
===
Asc
.
c_oAscSortOptions
.
ByColorFont
?
color
:
null
;
var
colorText
=
nOption
===
Asc
.
c_oAscSortOptions
.
ByColorFont
;
var
isSortColor
=
!!
(
colorFill
||
colorText
);
var
isSortColor
=
!!
(
colorFill
||
colorText
);
var
oRes
=
null
;
var
oRes
=
null
;
...
@@ -8629,14 +8629,19 @@ Range.prototype.sort=function(nOption, nStartCol, color){
...
@@ -8629,14 +8629,19 @@ Range.prototype.sort=function(nOption, nStartCol, color){
if
(
colorFill
)
if
(
colorFill
)
{
{
var
styleCell
=
oCell
.
getStyle
();
var
styleCell
=
oCell
.
getStyle
();
colorFillCell
=
styleCell
!==
null
?
styleCell
.
fill
:
null
;
colorFillCell
=
styleCell
!==
null
&&
styleCell
.
fill
?
styleCell
.
fill
.
bg
:
null
;
}
}
else
if
(
colorText
)
else
if
(
colorText
)
{
{
var
value2
=
oCell
.
getValue2
();
var
value2
=
oCell
.
getValue2
();
for
(
var
n
=
0
;
n
<
value2
.
length
;
n
++
)
for
(
var
n
=
0
;
n
<
value2
.
length
;
n
++
)
{
{
colorsTextCell
.
push
(
value2
[
n
].
c
);
if
(
null
===
colorsTextCell
)
{
colorsTextCell
=
[];
}
colorsTextCell
.
push
(
value2
[
n
].
format
.
c
);
}
}
}
}
...
@@ -8689,15 +8694,16 @@ Range.prototype.sort=function(nOption, nStartCol, color){
...
@@ -8689,15 +8694,16 @@ Range.prototype.sort=function(nOption, nStartCol, color){
var
colorFillCmp
=
function
(
color1
,
color2
)
var
colorFillCmp
=
function
(
color1
,
color2
)
{
{
var
res
=
false
;
var
res
=
false
;
//TODO возможно так сравнивать не правильно, позже пересмотреть
if
(
colorFill
)
if
(
colorFill
)
{
{
res
=
color1
!==
null
&&
color2
!==
null
&&
color1
.
isEqual
(
color2
)
===
true
?
true
:
false
;
res
=
(
color1
!==
null
&&
color2
!==
null
&&
color1
.
rgb
===
color2
.
rgb
)
||
(
color1
===
color2
)
?
true
:
false
;
}
}
else
if
(
colorText
&&
color1
&&
color1
.
length
)
else
if
(
colorText
&&
color1
&&
color1
.
length
)
{
{
for
(
var
n
=
0
;
n
<
color1
.
length
;
n
++
)
for
(
var
n
=
0
;
n
<
color1
.
length
;
n
++
)
{
{
if
(
color1
[
n
]
&&
color
1
[
n
].
isEqual
(
color2
))
if
(
color1
[
n
]
&&
color
2
!==
null
&&
color1
[
n
].
rgb
===
color2
.
rgb
)
{
{
res
=
true
;
res
=
true
;
break
;
break
;
...
@@ -8712,11 +8718,10 @@ Range.prototype.sort=function(nOption, nStartCol, color){
...
@@ -8712,11 +8718,10 @@ Range.prototype.sort=function(nOption, nStartCol, color){
{
{
var
newArrayNeedColor
=
[];
var
newArrayNeedColor
=
[];
var
newArrayAnotherColor
=
[];
var
newArrayAnotherColor
=
[];
var
sortColor
=
colorText
?
colorText
:
colorFill
;
for
(
var
i
=
0
;
i
<
aSortElems
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
aSortElems
.
length
;
i
++
)
{
{
var
color
=
colorFill
?
aSortElems
[
i
].
colorFill
:
aSortElems
[
i
].
color
Text
;
var
color
=
colorFill
?
aSortElems
[
i
].
colorFill
:
aSortElems
[
i
].
color
sText
;
if
(
colorFillCmp
(
color
,
sortColor
))
if
(
colorFillCmp
(
color
,
sortColor
))
{
{
newArrayNeedColor
.
push
(
aSortElems
[
i
]);
newArrayNeedColor
.
push
(
aSortElems
[
i
]);
...
@@ -8727,7 +8732,7 @@ Range.prototype.sort=function(nOption, nStartCol, color){
...
@@ -8727,7 +8732,7 @@ Range.prototype.sort=function(nOption, nStartCol, color){
}
}
}
}
aSortElems
=
newArray
AnotherColor
.
concat
(
newArrayNeedColor
);
aSortElems
=
newArray
NeedColor
.
concat
(
newArrayAnotherColor
);
}
}
else
else
{
{
...
...
cell/model/autofilters.js
View file @
07f71564
...
@@ -719,7 +719,7 @@
...
@@ -719,7 +719,7 @@
this
.
changeTableStyleInfo
(
data
.
styleName
,
data
.
activeCells
);
this
.
changeTableStyleInfo
(
data
.
styleName
,
data
.
activeCells
);
break
;
break
;
case
AscCH
.
historyitem_AutoFilter_Sort
:
case
AscCH
.
historyitem_AutoFilter_Sort
:
this
.
sortColFilter
(
data
.
type
,
data
.
cellId
,
data
.
activeCells
);
this
.
sortColFilter
(
data
.
type
,
data
.
cellId
,
data
.
activeCells
,
null
,
null
,
data
.
color
);
break
;
break
;
case
AscCH
.
historyitem_AutoFilter_Empty
:
case
AscCH
.
historyitem_AutoFilter_Empty
:
this
.
isEmptyAutoFilters
(
data
.
activeCells
);
this
.
isEmptyAutoFilters
(
data
.
activeCells
);
...
@@ -1498,9 +1498,8 @@
...
@@ -1498,9 +1498,8 @@
History
.
EndTransaction
();
History
.
EndTransaction
();
},
},
sortColFilter
:
function
(
type
,
cellId
,
activeRange
,
sortProps
,
displayName
)
{
sortColFilter
:
function
(
type
,
cellId
,
activeRange
,
sortProps
,
displayName
,
color
)
{
var
curFilter
,
sortRange
,
filterRef
,
startCol
,
maxFilterRow
;
var
curFilter
,
sortRange
,
filterRef
,
startCol
,
maxFilterRow
;
var
resType
=
type
==
'
ascending
'
;
var
t
=
this
;
var
t
=
this
;
if
(
!
sortProps
)
if
(
!
sortProps
)
...
@@ -1508,7 +1507,7 @@
...
@@ -1508,7 +1507,7 @@
curFilter
=
sortProps
.
curFilter
,
sortRange
=
sortProps
.
sortRange
,
filterRef
=
sortProps
.
filterRef
,
startCol
=
sortProps
.
startCol
,
maxFilterRow
=
sortProps
.
maxFilterRow
;
curFilter
=
sortProps
.
curFilter
,
sortRange
=
sortProps
.
sortRange
,
filterRef
=
sortProps
.
filterRef
,
startCol
=
sortProps
.
startCol
,
maxFilterRow
=
sortProps
.
maxFilterRow
;
var
onSortAutoFilterCallback
=
function
(
success
)
var
onSortAutoFilterCallback
=
function
(
type
)
{
{
History
.
Create_NewPoint
();
History
.
Create_NewPoint
();
History
.
StartTransaction
();
History
.
StartTransaction
();
...
@@ -1523,13 +1522,12 @@
...
@@ -1523,13 +1522,12 @@
curFilter
.
SortState
.
SortConditions
=
[];
curFilter
.
SortState
.
SortConditions
=
[];
curFilter
.
SortState
.
SortConditions
[
0
]
=
new
AscCommonExcel
.
SortCondition
();
curFilter
.
SortState
.
SortConditions
[
0
]
=
new
AscCommonExcel
.
SortCondition
();
}
}
if
(
!
curFilter
.
SortState
.
SortConditions
[
0
])
curFilter
.
SortState
.
SortConditions
[
0
]
=
new
AscCommonExcel
.
SortCondition
();
curFilter
.
SortState
.
SortConditions
[
0
]
=
new
AscCommonExcel
.
SortCondition
();
var
cellIdRange
=
new
Asc
.
Range
(
startCol
,
filterRef
.
r1
,
startCol
,
filterRef
.
r1
);
var
cellIdRange
=
new
Asc
.
Range
(
startCol
,
filterRef
.
r1
,
startCol
,
filterRef
.
r1
);
curFilter
.
SortState
.
SortConditions
[
0
].
Ref
=
new
Asc
.
Range
(
startCol
,
filterRef
.
r1
,
startCol
,
filterRef
.
r2
);
curFilter
.
SortState
.
SortConditions
[
0
].
Ref
=
new
Asc
.
Range
(
startCol
,
filterRef
.
r1
,
startCol
,
filterRef
.
r2
);
curFilter
.
SortState
.
SortConditions
[
0
].
ConditionDescending
=
resT
ype
;
curFilter
.
SortState
.
SortConditions
[
0
].
ConditionDescending
=
t
ype
;
if
(
curFilter
.
TableStyleInfo
)
if
(
curFilter
.
TableStyleInfo
)
{
{
...
@@ -1540,7 +1538,67 @@
...
@@ -1540,7 +1538,67 @@
History
.
EndTransaction
();
History
.
EndTransaction
();
};
};
onSortAutoFilterCallback
();
var
onSortColorAutoFilterCallback
=
function
(
type
)
{
History
.
Create_NewPoint
();
History
.
StartTransaction
();
var
oldFilter
=
curFilter
.
clone
(
null
);
//изменяем содержимое фильтра
if
(
!
curFilter
.
SortState
)
{
curFilter
.
SortState
=
new
SortState
();
curFilter
.
SortState
.
Ref
=
new
Asc
.
Range
(
startCol
,
curFilter
.
Ref
.
r1
,
startCol
,
maxFilterRow
);
curFilter
.
SortState
.
SortConditions
=
[];
curFilter
.
SortState
.
SortConditions
[
0
]
=
new
SortCondition
();
}
curFilter
.
SortState
.
SortConditions
[
0
]
=
new
SortCondition
();
var
cellIdRange
=
new
Asc
.
Range
(
startCol
,
filterRef
.
r1
,
startCol
,
filterRef
.
r1
);
curFilter
.
SortState
.
SortConditions
[
0
].
Ref
=
new
Asc
.
Range
(
startCol
,
filterRef
.
r1
,
startCol
,
filterRef
.
r2
);
curFilter
.
SortState
.
SortConditions
[
0
].
dxf
=
new
CellXfs
();
if
(
type
===
Asc
.
c_oAscSortOptions
.
ByColorFill
)
{
curFilter
.
SortState
.
SortConditions
[
0
].
dxf
.
fill
=
new
Fill
();
curFilter
.
SortState
.
SortConditions
[
0
].
dxf
.
fill
.
bg
=
color
;
curFilter
.
SortState
.
SortConditions
[
0
].
ConditionSortBy
=
Asc
.
ESortBy
.
sortbyCellColor
;
}
else
{
curFilter
.
SortState
.
SortConditions
[
0
].
dxf
.
font
=
new
Font
();
curFilter
.
SortState
.
SortConditions
[
0
].
dxf
.
font
.
c
=
color
;
curFilter
.
SortState
.
SortConditions
[
0
].
ConditionSortBy
=
Asc
.
ESortBy
.
sortbyFontColor
;
}
if
(
curFilter
.
TableStyleInfo
)
{
t
.
_setColorStyleTable
(
curFilter
.
Ref
,
curFilter
);
}
t
.
_addHistoryObj
({
oldFilter
:
oldFilter
},
AscCH
.
historyitem_AutoFilter_Sort
,
{
activeCells
:
cellIdRange
,
type
:
type
,
cellId
:
cellId
,
color
:
color
},
null
,
curFilter
.
Ref
);
History
.
EndTransaction
();
};
switch
(
type
)
{
case
Asc
.
c_oAscSortOptions
.
Ascending
:
case
Asc
.
c_oAscSortOptions
.
Descending
:
{
onSortAutoFilterCallback
(
type
===
Asc
.
c_oAscSortOptions
.
Ascending
);
break
;
}
case
Asc
.
c_oAscSortOptions
.
ByColorFill
:
case
Asc
.
c_oAscSortOptions
.
ByColorFont
:
{
onSortColorAutoFilterCallback
(
type
);
break
;
}
}
},
},
getPropForSort
:
function
(
cellId
,
activeRange
,
displayName
)
getPropForSort
:
function
(
cellId
,
activeRange
,
displayName
)
...
@@ -2498,6 +2556,7 @@
...
@@ -2498,6 +2556,7 @@
oHistoryObject
.
bWithoutFilter
=
bWithoutFilter
?
bWithoutFilter
:
false
;
oHistoryObject
.
bWithoutFilter
=
bWithoutFilter
?
bWithoutFilter
:
false
;
oHistoryObject
.
displayName
=
redoObject
.
displayName
;
oHistoryObject
.
displayName
=
redoObject
.
displayName
;
oHistoryObject
.
val
=
redoObject
.
val
;
oHistoryObject
.
val
=
redoObject
.
val
;
oHistoryObject
.
color
=
redoObject
.
color
;
if
(
redoObject
.
pasteStyleObj
)
if
(
redoObject
.
pasteStyleObj
)
{
{
...
...
cell/view/WorksheetView.js
View file @
07f71564
...
@@ -12023,9 +12023,11 @@
...
@@ -12023,9 +12023,11 @@
History
.
Create_NewPoint
();
History
.
Create_NewPoint
();
History
.
StartTransaction
();
History
.
StartTransaction
();
var
sort
=
sortProps
.
sortRange
.
sort
(
type
,
sortProps
.
startCol
,
color
);
var
rgbColor
=
color
?
new
RgbColor
((
color
.
asc_getR
()
<<
16
)
+
(
color
.
asc_getG
()
<<
8
)
+
color
.
asc_getB
())
:
null
;
var
sort
=
sortProps
.
sortRange
.
sort
(
type
,
sortProps
.
startCol
,
rgbColor
);
t
.
cellCommentator
.
sortComments
(
sort
);
t
.
cellCommentator
.
sortComments
(
sort
);
t
.
model
.
autoFilters
.
sortColFilter
(
type
,
cellId
,
ar
,
sortProps
,
displayName
);
t
.
model
.
autoFilters
.
sortColFilter
(
type
,
cellId
,
ar
,
sortProps
,
displayName
,
rgbColor
);
t
.
_onUpdateFormatTable
(
sortProps
.
sortRange
.
bbox
,
false
);
t
.
_onUpdateFormatTable
(
sortProps
.
sortRange
.
bbox
,
false
);
History
.
EndTransaction
();
History
.
EndTransaction
();
...
...
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