Commit ea26cf6b authored by GoshaZotov's avatar GoshaZotov Committed by Alexander.Trofimov

add function af_getFilterTypes(for definition color/text/digit data in filter column)

parent d3da4cd0
...@@ -119,7 +119,8 @@ ...@@ -119,7 +119,8 @@
values : 1, values : 1,
filter : 2, filter : 2,
automaticRowCount : 3, automaticRowCount : 3,
displayName: 4 displayName: 4,
isTextFilter: 5
}; };
function AutoFiltersOptions () { function AutoFiltersOptions () {
...@@ -133,6 +134,8 @@ ...@@ -133,6 +134,8 @@
this.sortVal = null; this.sortVal = null;
this.automaticRowCount = null; this.automaticRowCount = null;
this.displayName = null; this.displayName = null;
this.isTextFilter = null;
return this; return this;
} }
...@@ -152,6 +155,7 @@ ...@@ -152,6 +155,7 @@
case this.Properties.filter: return this.filter; break; case this.Properties.filter: return this.filter; break;
case this.Properties.automaticRowCount: return this.automaticRowCount; break; case this.Properties.automaticRowCount: return this.automaticRowCount; break;
case this.Properties.displayName: return this.displayName; break; case this.Properties.displayName: return this.displayName; break;
case this.Properties.isTextFilter: return this.isTextFilter; break;
} }
return null; return null;
...@@ -163,6 +167,7 @@ ...@@ -163,6 +167,7 @@
case this.Properties.filter: this.filter = value;break; case this.Properties.filter: this.filter = value;break;
case this.Properties.automaticRowCount: this.automaticRowCount = value;break; case this.Properties.automaticRowCount: this.automaticRowCount = value;break;
case this.Properties.displayName: this.displayName = value;break; case this.Properties.displayName: this.displayName = value;break;
case this.Properties.isTextFilter: this.IsTextFilter = value;break;
} }
}, },
...@@ -174,13 +179,15 @@ ...@@ -174,13 +179,15 @@
asc_setAutomaticRowCount : function(val) { this.automaticRowCount = val; }, asc_setAutomaticRowCount : function(val) { this.automaticRowCount = val; },
asc_setDiplayName : function(val) { this.displayName = val; }, asc_setDiplayName : function(val) { this.displayName = val; },
asc_setIsTextFilter : function(val) { this.isTextFilter = val; },
asc_getCellId : function() { return this.cellId; }, asc_getCellId : function() { return this.cellId; },
asc_getValues : function() { return this.values; }, asc_getValues : function() { return this.values; },
asc_getFilterObj : function() { return this.filter; }, asc_getFilterObj : function() { return this.filter; },
asc_getSortState : function() { return this.sortVal; }, asc_getSortState : function() { return this.sortVal; },
asc_getDisplayName : function(val) { return this.displayName; } asc_getDisplayName : function(val) { return this.displayName; },
asc_getIsTextFilter : function(val) { return this.IsTextFilter; },
}; };
var g_oAutoFilterObj = { var g_oAutoFilterObj = {
...@@ -4641,6 +4648,7 @@ ...@@ -4641,6 +4648,7 @@
prot["asc_getFilterObj"] = prot.asc_getFilterObj; prot["asc_getFilterObj"] = prot.asc_getFilterObj;
prot["asc_getCellId"] = prot.asc_getCellId; prot["asc_getCellId"] = prot.asc_getCellId;
prot["asc_getDisplayName"] = prot.asc_getDisplayName; prot["asc_getDisplayName"] = prot.asc_getDisplayName;
prot["asc_getIsTextFilter"] = prot.asc_getIsTextFilter;
window["AscCommonExcel"].AutoFilterObj = AutoFilterObj; window["AscCommonExcel"].AutoFilterObj = AutoFilterObj;
prot = AutoFilterObj.prototype; prot = AutoFilterObj.prototype;
......
...@@ -12679,9 +12679,83 @@ ...@@ -12679,9 +12679,83 @@
autoFilterObject.asc_setAutomaticRowCount(automaticRowCount); autoFilterObject.asc_setAutomaticRowCount(automaticRowCount);
autoFilterObject.asc_setDiplayName(displayName); autoFilterObject.asc_setDiplayName(displayName);
var columnRange = Asc.Range(rangeButton.c1, autoFilter.Ref.r1 + 1, rangeButton.c1, autoFilter.Ref.r2);
var filterTypes = this.af_getFilterTypes(columnRange);
autoFilterObject.asc_setIsTextFilter(filterTypes.text);
this.handlers.trigger("setAutoFiltersDialog", autoFilterObject); this.handlers.trigger("setAutoFiltersDialog", autoFilterObject);
}; };
WorksheetView.prototype.af_getFilterTypes = function(columnRange)
{
var t = this;
var ws = this.model;
var res = {text: true, colors: [], fontColors: []};
var tempText = 0, tempDigit = 0;
var alreadyAddColors = {}, alreadyAddFontColors = {};
for(var i = columnRange.r1; i <= columnRange.r2; i++)
{
var cell = ws._getCellNoEmpty(i, columnRange.c1);
if(!cell)
{
continue;
}
if(cell.isEmptyText() === false)
{
var type = cell.getType();
if(type === 0)
{
tempDigit++;
}
else
{
tempText++;
}
}
if(cell.oValue.multiText !== null)
{
for(var j = 0; j < cell.oValue.multiText.length; j++)
{
var fontColor = cell.oValue.multiText[j].format ? cell.oValue.multiText[j].format.c : null;
if(fontColor !== null && alreadyAddFontColors[fontColor.rgb] !== true && g_oColorManager.isEqual(fontColor, g_oDefaultFont.c) === false)
{
res.fontColors.push(fontColor);
alreadyAddFontColors[fontColor.rgb] = true;
}
}
}
else
{
var fontColor = cell.xfs && cell.xfs.font ? cell.xfs.font.c : null;
if(fontColor !== null && alreadyAddFontColors[fontColor.rgb] !== true && g_oColorManager.isEqual(fontColor, g_oDefaultFont.c) === false)
{
res.fontColors.push(fontColor);
alreadyAddFontColors[fontColor.rgb] = true;
}
}
var color = cell.getStyle();
if(color !== null && color.fill && color.fill.bg && alreadyAddColors[color.fill.bg.rgb] !== true)
{
res.colors.push(color.fill);
alreadyAddColors[color.fill.bg.rgb] = true;
}
}
if(tempDigit > tempText)
{
res.text = false;
}
return res;
};
WorksheetView.prototype.af_changeSelectionTablePart = function(activeRange) WorksheetView.prototype.af_changeSelectionTablePart = function(activeRange)
{ {
var t = this; var t = this;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment