Commit a5896310 authored by GoshaZotov's avatar GoshaZotov

fix for various bugs

parent cc0d753a
......@@ -4981,6 +4981,15 @@ TablePart.prototype.changeDisplayName = function(newName)
this.DisplayName = newName;
};
TablePart.prototype.getRangeWithoutHeaderFooter = function()
{
var startRow = this.HeaderRowCount === null ? this.Ref.r1 + 1 : this.Ref.r1;
var endRow = this.TotalsRowCount > 0 ? this.Ref.r2 - 1 : this.Ref.r2;
return Asc.Range(this.Ref.c1, startRow, this.Ref.c2, endRow);
};
/** @constructor */
function AutoFilter() {
this.Ref = null;
......@@ -5140,6 +5149,11 @@ AutoFilter.prototype.isShowButton = function()
return res;
};
AutoFilter.prototype.getRangeWithoutHeaderFooter = function()
{
return Asc.Range(this.Ref.c1, this.Ref.r1 + 1, this.Ref.c2, this.Ref.r2);
};
function FilterColumns() {
this.ColId = null;
......@@ -6053,7 +6067,30 @@ ColorFilter.prototype.isHideValue = function(cell) {
var res = true;
if(this.dxf && this.dxf.fill && this.dxf.fill.bg && cell)
var isEqualColors = function(filterColor, cellColor)
{
var res = false;
if(filterColor === cellColor)
{
res = true;
}
else if(!filterColor && (!cellColor || null === cellColor.rgb || 0 === cellColor.rgb))
{
res = true;
}
else if(!cellColor && (!filterColor || null === filterColor.rgb || 0 === filterColor.rgb))
{
res = true;
}
else if(cellColor && filterColor && cellColor.rgb === filterColor.rgb)
{
res = true;
}
return res;
};
if(this.dxf && this.dxf.fill && cell)
{
var filterColor = this.dxf.fill.bg;
cell = cell.getCells()[0];
......@@ -6065,7 +6102,7 @@ ColorFilter.prototype.isHideValue = function(cell) {
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 && fontColor.rgb === filterColor.rgb)
if(isEqualColors(filterColor,fontColor ))
{
res = false;
break;
......@@ -6075,11 +6112,7 @@ ColorFilter.prototype.isHideValue = function(cell) {
else
{
var fontColor = cell.xfs && cell.xfs.font ? cell.xfs.font.c : null;
if(fontColor !== null && fontColor.rgb === filterColor.rgb)
{
res = false;
}
else if(fontColor === null && (null === filterColor || (null !== filterColor && (0 === filterColor.rgb || null === filterColor.rgb))))
if(isEqualColors(filterColor,fontColor))
{
res = false;
}
......@@ -6088,11 +6121,9 @@ ColorFilter.prototype.isHideValue = function(cell) {
else
{
var color = cell.getStyle();
if(color !== null && color.fill && color.fill.bg && color.fill.bg.rgb === filterColor.rgb)
{
res = false;
}
else if(color === null && (null === this.dxf.fill.bg || (null !== this.dxf.fill.bg && null === this.dxf.fill.bg.rgb)))
var cellColor = color !== null && color.fill && color.fill.bg ? color.fill.bg : null;
if(isEqualColors(filterColor, cellColor))
{
res = false;
}
......
"use strict";
"use strict";
(
/**
* @param {jQuery} $
......@@ -615,7 +615,7 @@
//**get filter**
var filter = this._getFilterByDisplayName(displayName);
var autoFilter = filter && filter.getType() === g_nFiltersType.tablePart ? filter.AutoFilter : filter;
var autoFilter = filter && false === filter.isAutoFilter() ? filter.AutoFilter : filter;
if(filter === null)
return false;
......@@ -652,7 +652,6 @@
}
}
this._resetTablePartStyle();
History.EndTransaction();
return {minChangeRow: minChangeRow, updateRange: filter.Ref, filter: filter};
......@@ -1612,7 +1611,7 @@
//изменяем содержимое фильтра
if(!curFilter.SortState)
{
curFilter.SortState = new SortState();
curFilter.SortState = new AscCommonExcel.SortState();
curFilter.SortState.Ref = new Asc.Range(startCol, curFilter.Ref.r1, startCol, maxFilterRow);
curFilter.SortState.SortConditions = [];
curFilter.SortState.SortConditions[0] = new AscCommonExcel.SortCondition();
......@@ -1624,16 +1623,16 @@
curFilter.SortState.SortConditions[0].Ref = new Asc.Range(startCol, filterRef.r1, startCol, filterRef.r2);
curFilter.SortState.SortConditions[0].dxf = new CellXfs();
curFilter.SortState.SortConditions[0].dxf = new AscCommonExcel.CellXfs();
if(type === Asc.c_oAscSortOptions.ByColorFill)
{
curFilter.SortState.SortConditions[0].dxf.fill = new Fill();
curFilter.SortState.SortConditions[0].dxf.fill = new AscCommonExcel.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 = new AscCommonExcel.Font();
curFilter.SortState.SortConditions[0].dxf.font.c = color;
curFilter.SortState.SortConditions[0].ConditionSortBy = Asc.ESortBy.sortbyFontColor;
}
......@@ -1730,8 +1729,8 @@
}
}
maxFilterRow = filterRef.r2;
var ascSortRange = curFilter.getRangeWithoutHeaderFooter();
maxFilterRow = ascSortRange.r2;
if(curFilter.isAutoFilter() && curFilter.isApplyAutoFilter() === false)//нужно подхватить нижние ячейки в случае, если это не применен а/ф
{
var automaticRange = this._getAdjacentCellsAF(curFilter.Ref, true);
......@@ -1741,7 +1740,7 @@
maxFilterRow = automaticRowCount;
}
sortRange = worksheet.getRange3(filterRef.r1 + 1, filterRef.c1, maxFilterRow, filterRef.c2);
sortRange = worksheet.getRange3(ascSortRange.r1, ascSortRange.c1, maxFilterRow, ascSortRange.c2);
return {sortRange: sortRange, curFilter: curFilter, filterRef: filterRef, startCol: startCol, maxFilterRow: maxFilterRow};
},
......@@ -2574,7 +2573,7 @@
{
var res = null;
var autoFilter = filter && filter.getType() === g_nFiltersType.tablePart ? filter.AutoFilter : filter;
var autoFilter = filter && false === filter.isAutoFilter() ? filter.AutoFilter : filter;
if(autoFilter && autoFilter.FilterColumns && autoFilter.FilterColumns.length)
{
......@@ -2591,7 +2590,7 @@
{
var res = null;
var autoFilter = filter && filter.getType() === g_nFiltersType.tablePart ? filter.AutoFilter : filter;
var autoFilter = filter && false === filter.isAutoFilter() ? filter.AutoFilter : filter;
if(autoFilter && autoFilter.FilterColumns && autoFilter.FilterColumns.length)
{
......@@ -4498,7 +4497,7 @@
clearFilterColumn: function(cellId, displayName)
{
var filter = this._getFilterByDisplayName(displayName);
var autoFilter = filter && filter.getType() === g_nFiltersType.tablePart ? filter.AutoFilter : filter;
var autoFilter = filter && false === filter.isAutoFilter() ? filter.AutoFilter : filter;
var oldFilter = filter.clone(null);
......
......@@ -10417,7 +10417,7 @@
case c_oAscInsertOptions.InsertColumns:
isCheckChangeAutoFilter = t.model.autoFilters.isRangeIntersectionSeveralTableParts( arn );
if ( isCheckChangeAutoFilter === true ) {
this.workbook.handlers.trigger("asc_onError", c_oAscError.ID.AutoFilterChangeFormatTableError, c_oAscError.Level.NoCritical);
this.model.workbook.handlers.trigger("asc_onError", c_oAscError.ID.AutoFilterChangeFormatTableError, c_oAscError.Level.NoCritical);
return;
}
......@@ -12025,7 +12025,8 @@
if(filter && filter.SortState && filter.SortState.SortConditions && filter.SortState.SortConditions[0])
{
var sortState = filter.SortState;
var sortRange = t.model.getRange3(filter.Ref.r1, filter.Ref.c1, filter.Ref.r2, filter.Ref.c2);
var rangeWithoutHeaderFooter = filter.getRangeWithoutHeaderFooter();
var sortRange = t.model.getRange3(rangeWithoutHeaderFooter.r1, rangeWithoutHeaderFooter.c1, rangeWithoutHeaderFooter.r2, rangeWithoutHeaderFooter.c2);
var startCol = sortState.SortConditions[0].Ref.c1;
var type;
var rgbColor = null;
......@@ -12061,6 +12062,7 @@
t.cellCommentator.sortComments(sort);
}
t.model.autoFilters._resetTablePartStyle();
var rowChange = applyFilterProps.rowChange;
var updateRange = applyFilterProps.updateRange;
......@@ -12207,7 +12209,7 @@
History.Create_NewPoint();
History.StartTransaction();
var rgbColor = color ? new RgbColor((color.asc_getR() << 16) + (color.asc_getG() << 8) + color.asc_getB()) : null;
var rgbColor = color ? new AscCommonExcel.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);
......@@ -12947,6 +12949,7 @@
var t = this;
var ws = this.model;
var res = {text: true, colors: [], fontColors: []};
var alreadyAddColors = {}, alreadyAddFontColors = {};
var getAscColor = function(color)
{
......@@ -12959,28 +12962,65 @@
return ascColor;
};
var addFontColorsToArray = function(fontColor)
{
var rgb = null === fontColor || fontColor && 0 === fontColor.rgb ? null : fontColor.rgb;
var isDefaultFontColor = !!(null === rgb);
if(true !== alreadyAddFontColors[rgb])
{
if(isDefaultFontColor)
{
res.fontColors.push(null);
alreadyAddFontColors[null] = true;
}
else
{
var ascFontColor = getAscColor(fontColor);
res.fontColors.push(ascFontColor);
alreadyAddFontColors[rgb] = true;
}
}
};
var addCellColorsToArray = function(color)
{
var rgb = null !== color && color.fill && color.fill.bg ? color.fill.bg.rgb : null;
var isDefaultCellColor = !!(null === rgb);
if(true !== alreadyAddColors[rgb])
{
if(isDefaultCellColor)
{
res.colors.push(null);
alreadyAddColors[null] = true;
}
else
{
var ascColor = getAscColor(color.fill.bg);
res.colors.push(ascColor);
alreadyAddColors[rgb] = true;
}
}
};
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)
{
//добавляем без цвета ячейку
if(true !== alreadyAddColors[null])
if(!cell && true !== alreadyAddColors[null])
{
alreadyAddColors[null] = true;
res.colors.push(null);
}
continue;
}
if(false === cell.isEmptyText())
{
var type = cell.getType();
if(type === 0)
{
tempDigit++;
......@@ -12991,60 +13031,23 @@
}
}
//font colors
if(null !== cell.oValue.multiText)
{
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(null !== fontColor && true !== alreadyAddFontColors[fontColor.rgb] && false === g_oColorManager.isEqual(fontColor, g_oDefaultFont.c))
{
var ascFontColor = getAscColor(fontColor);
res.fontColors.push(ascFontColor);
alreadyAddFontColors[fontColor.rgb] = true;
}
else if(null === fontColor && true !== alreadyAddFontColors[g_oDefaultFont.c.rgb])
{
var ascFontColor = getAscColor(g_oDefaultFont.c);
res.fontColors.push(ascFontColor);
alreadyAddFontColors[g_oDefaultFont.c.rgb] = true;
}
addFontColorsToArray(fontColor);
}
}
else
{
var fontColor = cell.xfs && cell.xfs.font ? cell.xfs.font.c : null;
if(null !== fontColor && true !== alreadyAddFontColors[fontColor.rgb] && false === g_oColorManager.isEqual(fontColor, g_oDefaultFont.c))
{
var ascFontColor = getAscColor(fontColor);
res.fontColors.push(ascFontColor);
alreadyAddFontColors[fontColor.rgb] = true;
addFontColorsToArray(fontColor);
}
else if(null === fontColor && true !== alreadyAddFontColors[g_oDefaultFont.c.rgb])
{
var ascFontColor = getAscColor(g_oDefaultFont.c);
res.fontColors.push(ascFontColor);
alreadyAddFontColors[g_oDefaultFont.c.rgb] = true;
}
}
var color = cell.getStyle();
if(null !== color && color.fill && color.fill.bg && true !== alreadyAddColors[color.fill.bg.rgb])
{
var ascColor = getAscColor(color.fill.bg);
res.colors.push(ascColor);
alreadyAddColors[color.fill.bg.rgb] = true;
}
else if(null === color && true !== alreadyAddColors[null])
{
alreadyAddColors[null] = true;
res.colors.push(null);
}
//cell colors
addCellColorsToArray(cell.getStyle());
}
//если один элемент в массиве, не отправляем его в меню
......@@ -13057,10 +13060,7 @@
res.fontColors = [];
}
if(tempDigit > tempText)
{
res.text = false;
}
res.text = tempDigit > tempText ? false : true;
return res;
};
......@@ -13547,7 +13547,7 @@
{
res = false;
}
else if(!isOneTableIntersection)
else if(intersectionTableParts && null !== isOneTableIntersection)
{
res = false;
}
......@@ -13575,7 +13575,7 @@
{
res = false;
}
else if(!isOneTableIntersection)
else if(intersectionTableParts && null !== isOneTableIntersection)
{
res = false;
}
......@@ -13619,7 +13619,7 @@
{
res = false;
}
else if(!isOneTableIntersection)
else if(!isOneTableIntersection && null !== isOneTableIntersection)
{
res = false;
}
......@@ -13646,7 +13646,7 @@
{
res = false;
}
else if(!isOneTableIntersection)
else if(!isOneTableIntersection && null !== isOneTableIntersection)
{
res = false;
}
......
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