Commit 6f22105c authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

добавил функции для очистки а/ф(форматированной таблицы)

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57579 954022d7-b5bf-4e40-9824-e11837661b57
parent 843e632a
......@@ -165,7 +165,7 @@
this.styleName = null;
this.numFormatType = null;
this.angle = null;
this.autoFilter = null;
this.cleanFilter = null;
}
asc_CCellInfo.prototype = {
......@@ -187,7 +187,7 @@
asc_getStyleName: function () { return this.styleName; },
asc_getNumFormatType: function(){ return this.numFormatType; },
asc_getAngle: function () { return this.angle; },
asc_getAutoFilter: function () { return this.autoFilter; }
asc_getCleanFilter: function () { return this.cleanFilter; }
};
window["Asc"].asc_CCellInfo = window["Asc"]["asc_CCellInfo"] = asc_CCellInfo;
......
......@@ -95,6 +95,7 @@ var historyitem_AutoFilter_Empty = 3;
var historyitem_AutoFilter_ApplyDF = 4;
var historyitem_AutoFilter_ApplyMF = 5;
var historyitem_AutoFilter_Move = 6;
var historyitem_AutoFilter_CleanAutoFilter = 7;
// Типы изменений в классе CDocumentContent
......
......@@ -1603,37 +1603,47 @@ var gUndoInsDelCellsFlag = true;
History.EndTransaction();
if(turnOnHistory)
History.TurnOff();
},
isApplyAutoFilterInCell: function(activeCell)
{
var aWs = this._getCurrentWS();
var tableRange;
if(aWs.TableParts)
{
var tablePart;
for(var i = 0; i < aWs.TableParts.length; i++)
{
tablePart = aWs.TableParts[i];
//если применен фильтр или сортировка
if(tablePart.Ref && ((tablePart.AutoFilter && tablePart.AutoFilter.FilterColumns && tablePart.AutoFilter.FilterColumns.length) || (tablePart && tablePart.SortState && tablePart.SortState.SortConditions && tablePart.SortState.SortConditions[0])))
{
if(tablePart.Ref.containsRange(activeCell))
return true;
}
else
{
if(tablePart.Ref.containsRange(activeCell))
return false;
};
};
};
if(aWs.AutoFilter && ((aWs.AutoFilter.FilterColumns && aWs.AutoFilter.FilterColumns.length) || (aWs.AutoFilter.SortState && aWs.AutoFilter.SortState.SortConditions && aWs.AutoFilter.SortState.SortConditions[0])))
return true;
return false;
},
//второй параметр - чистим у найденного фильтра FilterColumns и SortState
isApplyAutoFilterInCell: function(activeCell, clean)
{
var aWs = this._getCurrentWS();
var tableRange;
if(aWs.TableParts)
{
var tablePart;
for(var i = 0; i < aWs.TableParts.length; i++)
{
tablePart = aWs.TableParts[i];
//если применен фильтр или сортировка
if(tablePart.Ref && ((tablePart.AutoFilter && tablePart.AutoFilter.FilterColumns && tablePart.AutoFilter.FilterColumns.length) || (tablePart && tablePart.SortState && tablePart.SortState.SortConditions && tablePart.SortState.SortConditions[0])))
{
if(tablePart.Ref.containsRange(activeCell))
{
if(clean)
this._cleanFilterColumnsAndSortState(tablePart, activeCell);
return true;
}
}
else
{
if(tablePart.Ref.containsRange(activeCell, activeCell))
return false;
};
};
};
if(aWs.AutoFilter && ((aWs.AutoFilter.FilterColumns && aWs.AutoFilter.FilterColumns.length) || (aWs.AutoFilter.SortState && aWs.AutoFilter.SortState.SortConditions && aWs.AutoFilter.SortState.SortConditions[0])))
{
if(clean)
this._cleanFilterColumnsAndSortState(aWs.AutoFilter);
return true;
}
return false;
},
_checkClickFrozenArea: function(x, y, offsetX, offsetY, frozenObj)
......@@ -1760,6 +1770,9 @@ var gUndoInsDelCellsFlag = true;
case historyitem_AutoFilter_Move:
this._moveAutoFilters(data.moveTo, data.moveFrom);
break;
case historyitem_AutoFilter_CleanAutoFilter:
this.isApplyAutoFilterInCell(data.activeCells, true);
break;
}
startRedo = false;
History.TurnOn();
......@@ -2030,26 +2043,45 @@ var gUndoInsDelCellsFlag = true;
{
if(aWs.TableParts[i].Ref)
{
/*var ref = aWs.TableParts[i].Ref.split(":");
var startRange = this._idToRange(ref[0]);
var endRange = this._idToRange(ref[1]);
tableRange =
{
r1: startRange.r1,
r2: endRange.r1,
c1: startRange.c1,
c2: endRange.c1
}*/
tableRange = aWs.TableParts[i].Ref;
}
tableRange = aWs.TableParts[i].Ref;
};
if(this._rangeHitInAnRange(range,tableRange))
return tableRange;
return {tableRange: tableRange, id: i};
}
}
return null;
},
checkApplyFilterOrSort: function(tablePartId)
{
var aWs = this._getCurrentWS();
var result = false;
if(tablePartId !== undefined)
{
var tablePart = aWs.TablePart[tablePartId];
if(tablePart.Ref && ((tablePart.AutoFilter && tablePart.AutoFilter.FilterColumns && tablePart.AutoFilter.FilterColumns.length) || (tablePart && tablePart.SortState && tablePart.SortState.SortConditions && tablePart.SortState.SortConditions[0])))
result = true;
}
else
{
if(aWs.AutoFilter && ((aWs.AutoFilter.FilterColumns && aWs.AutoFilter.FilterColumns.length) || (aWs.AutoFilter.SortState && aWs.AutoFilter.SortState.SortConditions && aWs.AutoFilter.SortState.SortConditions[0])))
{
result = {isFilterColumns: true, isAutoFilter: true};
}
else if(aWs.AutoFilter)
{
result = {isFilterColumns: false, isAutoFilter: true}
}
else
{
result = {isFilterColumns: false, isAutoFilter: false}
};
};
return result;
},
getAddFormatTableOptions: function(activeCells)
{
......@@ -7142,6 +7174,30 @@ var gUndoInsDelCellsFlag = true;
};
};
};
},
_cleanFilterColumnsAndSortState: function(autoFilterElement, activeCells)
{
var ws = this.worksheet;
var aWs = this._getCurrentWS();
var oldFilter = autoFilterElement.clone(aWs);
if(autoFilterElement.SortState)
autoFilterElement.SortState = null;
if(autoFilterElement.AutoFilter && autoFilterElement.AutoFilter.FilterColumns)
{
autoFilterElement.AutoFilter.FilterColumns = null;
}
else if(autoFilterElement.FilterColumns)
{
autoFilterElement.FilterColumns = null;
};
this._addHistoryObj(oldFilter, historyitem_AutoFilter_CleanAutoFilter, {activeCells: activeCells});
ws.isChanged = true;
this._reDrawFilters();
}
};
......
......@@ -6442,8 +6442,32 @@
cell_info.halign = c.getAlignHorizontalByValue().toLowerCase();
cell_info.valign = c.getAlignVertical().toLowerCase();
cell_info.isFormatTable = (null !== this.autoFilters.searchRangeInTableParts(activeCell));
//null - disable, true - pressed button, false - unpressed button
var tablePartsOptions = this.autoFilters.searchRangeInTableParts(activeCell);
if(tablePartsOptions == null)
{
var checkApplyFilterOrSort = this.autoFilters.checkApplyFilterOrSort();
cell_info.isFormatTable = checkApplyFilterOrSort.isAutoFilter;
cell_info.cleanFilter = checkApplyFilterOrSort.isFilterColumns;
}
else
{
if(tablePartsOptions.tableRange.containsRange(activeCell))
{
cell_info.isFormatTable = true;
if(this.autoFilters.checkApplyFilterOrSort(tablePartsOptions.id))
cell_info.cleanFilter = true;
else
cell_info.cleanFilter = null;
}
else
{
cell_info.isFormatTable = null;
cell_info.cleanFilter = null;
};
};
cell_info.styleName = c.getStyleName();
cell_info.angle = c.getAngle();
......@@ -6508,9 +6532,6 @@
}
}
//применен ли а/ф к данной ячейке
cell_info.autoFilter = this.autoFilters.isApplyAutoFilterInCell(activeCell);
return cell_info;
};
......
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