Commit 057a2881 authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

при работе с а/ф перевожу Ref в Range

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56558 954022d7-b5bf-4e40-9824-e11837661b57
parent 81aa3d06
...@@ -961,13 +961,7 @@ ...@@ -961,13 +961,7 @@
//get range for copy/paste //get range for copy/paste
if(this.isCopyPaste) if(this.isCopyPaste)
{ {
var parseRef = aTables[i].Ref.split(":"); var rangeTable = aTables[i].Ref;
if(parseRef[0] && parseRef[1])
{
var startRange = new CellAddress(parseRef[0]);
var endRange = new CellAddress(parseRef[1]);
rangeTable = Asc.Range(startRange.col - 1, startRange.row - 1, endRange.col - 1, endRange.row - 1);
}
} }
if(!this.isCopyPaste || (this.isCopyPaste && rangeTable && this.isCopyPaste.containsRange(rangeTable))) if(!this.isCopyPaste || (this.isCopyPaste && rangeTable && this.isCopyPaste.containsRange(rangeTable)))
this.bs.WriteItem(c_oSer_TablePart.Table, function(){oThis.WriteTable(aTables[i]);}); this.bs.WriteItem(c_oSer_TablePart.Table, function(){oThis.WriteTable(aTables[i]);});
...@@ -980,7 +974,7 @@ ...@@ -980,7 +974,7 @@
if(null != table.Ref) if(null != table.Ref)
{ {
this.memory.WriteByte(c_oSer_TablePart.Ref); this.memory.WriteByte(c_oSer_TablePart.Ref);
this.memory.WriteString2(table.Ref); this.memory.WriteString2(table.Ref.getName());
} }
//HeaderRowCount //HeaderRowCount
if(null != table.HeaderRowCount) if(null != table.HeaderRowCount)
...@@ -1013,8 +1007,8 @@ ...@@ -1013,8 +1007,8 @@
//Ref //Ref
if(null != autofilter.Ref) if(null != autofilter.Ref)
{ {
this.memory.WriteByte(c_oSer_AutoFilter.Ref); this.memory.WriteByte(c_oSer_AutoFilter.Ref);
this.memory.WriteString2(autofilter.Ref); this.memory.WriteString2(autofilter.Ref.getName());
} }
//FilterColumns //FilterColumns
if(null != autofilter.FilterColumns) if(null != autofilter.FilterColumns)
...@@ -3555,7 +3549,7 @@ ...@@ -3555,7 +3549,7 @@
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if ( c_oSer_TablePart.Ref == type ) if ( c_oSer_TablePart.Ref == type )
oTable.Ref = this.stream.GetString2LE(length); oTable.Ref = Asc.g_oRangeCache.getAscRange(this.stream.GetString2LE(length));
else if ( c_oSer_TablePart.HeaderRowCount == type ) else if ( c_oSer_TablePart.HeaderRowCount == type )
oTable.HeaderRowCount = this.stream.GetULongLE(); oTable.HeaderRowCount = this.stream.GetULongLE();
else if ( c_oSer_TablePart.TotalsRowCount == type ) else if ( c_oSer_TablePart.TotalsRowCount == type )
...@@ -3599,7 +3593,7 @@ ...@@ -3599,7 +3593,7 @@
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if ( c_oSer_AutoFilter.Ref == type ) if ( c_oSer_AutoFilter.Ref == type )
oAutoFilter.Ref = this.stream.GetString2LE(length); oAutoFilter.Ref = Asc.g_oRangeCache.getAscRange(this.stream.GetString2LE(length));
else if ( c_oSer_AutoFilter.FilterColumns == type ) else if ( c_oSer_AutoFilter.FilterColumns == type )
{ {
oAutoFilter.FilterColumns = []; oAutoFilter.FilterColumns = [];
......
...@@ -4392,7 +4392,7 @@ function TablePart() { ...@@ -4392,7 +4392,7 @@ function TablePart() {
} }
TablePart.prototype.clone = function(ws) { TablePart.prototype.clone = function(ws) {
var i, res = new TablePart(); var i, res = new TablePart();
res.Ref = this.Ref; res.Ref = this.Ref ? this.Ref.clone() : null;
res.HeaderRowCount = this.HeaderRowCount; res.HeaderRowCount = this.HeaderRowCount;
res.TotalsRowCount = this.TotalsRowCount; res.TotalsRowCount = this.TotalsRowCount;
if (this.AutoFilter) if (this.AutoFilter)
...@@ -4429,8 +4429,8 @@ function AutoFilter() { ...@@ -4429,8 +4429,8 @@ function AutoFilter() {
} }
AutoFilter.prototype.clone = function() { AutoFilter.prototype.clone = function() {
var i, res = new AutoFilter(); var i, res = new AutoFilter();
res.Ref = this.Ref; res.Ref = this.Ref ? this.Ref.clone() : null;
res.refTable = this.refTable; res.refTable = this.refTable ? this.refTable.clone() : null;
if (this.FilterColumns) { if (this.FilterColumns) {
res.FilterColumns = []; res.FilterColumns = [];
for (i = 0; i < this.FilterColumns.length; ++i) for (i = 0; i < this.FilterColumns.length; ++i)
......
...@@ -293,9 +293,9 @@ var gUndoInsDelCellsFlag = true; ...@@ -293,9 +293,9 @@ var gUndoInsDelCellsFlag = true;
{ {
ref = addFormatTableOptionsObj.asc_getRange(); ref = addFormatTableOptionsObj.asc_getRange();
addNameColumn = !addFormatTableOptionsObj.asc_getIsTitle(); addNameColumn = !addFormatTableOptionsObj.asc_getIsTitle();
var newRange = this._refToRange(ref); /*var newRange = this._refToRange(ref);
if(newRange) if(newRange)
activeCells = newRange; activeCells = newRange;*/
} }
else if(addFormatTableOptionsObj) else if(addFormatTableOptionsObj)
addNameColumn = false; addNameColumn = false;
...@@ -322,6 +322,10 @@ var gUndoInsDelCellsFlag = true; ...@@ -322,6 +322,10 @@ var gUndoInsDelCellsFlag = true;
} }
} }
History.StartTransaction(); History.StartTransaction();
if(rangeShift && rangeShift.r1)
rangeShift = ws.model.getRange3(rangeShift.r1, rangeShift.c1, rangeShift.r1, rangeShift.c2);
if(paramsForCallBack)//меняем/удаляем/устанавливаем стиль для а/ф if(paramsForCallBack)//меняем/удаляем/устанавливаем стиль для а/ф
{ {
switch(paramsForCallBack) switch(paramsForCallBack)
...@@ -330,11 +334,15 @@ var gUndoInsDelCellsFlag = true; ...@@ -330,11 +334,15 @@ var gUndoInsDelCellsFlag = true;
{ {
var cloneFilterOld = filterChange.clone(aWs); var cloneFilterOld = filterChange.clone(aWs);
filterChange.TableStyleInfo.Name = lTable; filterChange.TableStyleInfo.Name = lTable;
splitRange = filterChange.Ref.split(':'); /*splitRange = filterChange.Ref.split(':');
t._setColorStyleTable(splitRange[0], splitRange[1], filterChange); t._setColorStyleTable(splitRange[0], splitRange[1], filterChange);
startCell = t._idToRange(splitRange[0]); startCell = t._idToRange(splitRange[0]);
endCell = t._idToRange(splitRange[1]); endCell = t._idToRange(splitRange[1]);
rangeFilter = new Asc.Range(startCell.c1, startCell.r1, endCell.c1, endCell.r1); rangeFilter = new Asc.Range(startCell.c1, startCell.r1, endCell.c1, endCell.r1);*/
rangeFilter = filterChange.Ref;
t._setColorStyleTable(rangeFilter, filterChange)
if (bIsActiveSheet && !bIsOpenFilter) { if (bIsActiveSheet && !bIsOpenFilter) {
// ToDo нужно обновлять не весь видимый диапазон, а только диапазон фильтра // ToDo нужно обновлять не весь видимый диапазон, а только диапазон фильтра
ws._updateCellsRange(rangeFilter, /*canChangeColWidth*/ c_oAscCanChangeColWidth.none); ws._updateCellsRange(rangeFilter, /*canChangeColWidth*/ c_oAscCanChangeColWidth.none);
...@@ -492,7 +500,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -492,7 +500,7 @@ var gUndoInsDelCellsFlag = true;
//устанавливаем стиль для таблицы //устанавливаем стиль для таблицы
if(!isAll) if(!isAll)
{ {
t._setColorStyleTable(result[0].id, result[result.length -1].idNext, aWs.TableParts[aWs.TableParts.length - 1], null, true); t._setColorStyleTable(aWs.TableParts[aWs.TableParts.length - 1].Ref, aWs.TableParts[aWs.TableParts.length - 1], null, true);
var firstCell = ws.model.getCell(new CellAddress((result[0].id))); var firstCell = ws.model.getCell(new CellAddress((result[0].id)));
var endCell = ws.model.getCell(new CellAddress((result[result.length -1].idNext))); var endCell = ws.model.getCell(new CellAddress((result[result.length -1].idNext)));
var arn = var arn =
...@@ -509,7 +517,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -509,7 +517,7 @@ var gUndoInsDelCellsFlag = true;
if(isAll) { if(isAll) {
aWs.AutoFilter = {}; aWs.AutoFilter = {};
aWs.AutoFilter.result = result; aWs.AutoFilter.result = result;
aWs.AutoFilter.Ref = result[0].id + ':' + result[result.length -1].idNext; aWs.AutoFilter.Ref = t._refToRange(result[0].id + ':' + result[result.length -1].idNext);
} }
} }
newRes = newRes =
...@@ -517,7 +525,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -517,7 +525,7 @@ var gUndoInsDelCellsFlag = true;
result: result, result: result,
isVis: true isVis: true
}; };
changesElemHistory.refTable = result[0].id + ':' + result[result.length -1].idNext; changesElemHistory.refTable = t._refToRange(result[0].id + ':' + result[result.length -1].idNext);
if(addNameColumn) if(addNameColumn)
changesElemHistory.addColumn = true; changesElemHistory.addColumn = true;
t._addHistoryObj(changesElemHistory, historyitem_AutoFilter_Add, t._addHistoryObj(changesElemHistory, historyitem_AutoFilter_Add,
...@@ -552,11 +560,15 @@ var gUndoInsDelCellsFlag = true; ...@@ -552,11 +560,15 @@ var gUndoInsDelCellsFlag = true;
{ {
changesElemHistory = filterChange.clone(aWs); changesElemHistory = filterChange.clone(aWs);
filterChange.TableStyleInfo.Name = lTable; filterChange.TableStyleInfo.Name = lTable;
splitRange = filterChange.Ref.split(':');
/*splitRange = filterChange.Ref.split(':');
t._setColorStyleTable(splitRange[0], splitRange[1], filterChange); t._setColorStyleTable(splitRange[0], splitRange[1], filterChange);
startCell = t._idToRange(splitRange[0]); startCell = t._idToRange(splitRange[0]);
endCell = t._idToRange(splitRange[1]); endCell = t._idToRange(splitRange[1]);*/
rangeFilter = new Asc.Range(startCell.c1, startCell.r1, endCell.c1, endCell.r1);
rangeFilter = filterChange.Ref;
t._setColorStyleTable(rangeFilter, filterChange);
t._addHistoryObj(changesElemHistory, historyitem_AutoFilter_Add, t._addHistoryObj(changesElemHistory, historyitem_AutoFilter_Add,
{activeCells: activeCells, lTable: lTable}); {activeCells: activeCells, lTable: lTable});
if (bIsActiveSheet && !bIsOpenFilter) { if (bIsActiveSheet && !bIsOpenFilter) {
...@@ -598,10 +610,12 @@ var gUndoInsDelCellsFlag = true; ...@@ -598,10 +610,12 @@ var gUndoInsDelCellsFlag = true;
if(ref) if(ref)
{ {
splitRange = ref.split(':'); /*splitRange = ref.split(':');
startCell = t._idToRange(splitRange[0]); startCell = t._idToRange(splitRange[0]);
endCell = t._idToRange(splitRange[1]); endCell = t._idToRange(splitRange[1]);
rangeFilter = new Asc.Range(startCell.c1, startCell.r1, endCell.c1, endCell.r1); rangeFilter = new Asc.Range(startCell.c1, startCell.r1, endCell.c1, endCell.r1);*/
rangeFilter = ref;
} }
else else
rangeFilter = ws.visibleRange; rangeFilter = ws.visibleRange;
...@@ -666,7 +680,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -666,7 +680,7 @@ var gUndoInsDelCellsFlag = true;
//устанавливаем стиль для таблицы //устанавливаем стиль для таблицы
if(!isAll) if(!isAll)
{ {
t._setColorStyleTable(result[0].id, result[result.length -1].idNext, aWs.TableParts[aWs.TableParts.length - 1], null,true); t._setColorStyleTable(aWs.TableParts[aWs.TableParts.length - 1].Ref, aWs.TableParts[aWs.TableParts.length - 1], null,true);
var firstCell = ws.model.getCell(new CellAddress((result[0].id))); var firstCell = ws.model.getCell(new CellAddress((result[0].id)));
var endCell = ws.model.getCell(new CellAddress((result[result.length -1].idNext))); var endCell = ws.model.getCell(new CellAddress((result[result.length -1].idNext)));
var arn = var arn =
...@@ -683,7 +697,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -683,7 +697,7 @@ var gUndoInsDelCellsFlag = true;
if(!aWs.AutoFilter) if(!aWs.AutoFilter)
aWs.AutoFilter = {}; aWs.AutoFilter = {};
aWs.AutoFilter.result = result; aWs.AutoFilter.result = result;
aWs.AutoFilter.Ref = result[0].id + ':' + result[result.length -1].idNext; aWs.AutoFilter.Ref = t._refToRange(result[0].id + ':' + result[result.length -1].idNext);
} }
}; };
...@@ -695,7 +709,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -695,7 +709,7 @@ var gUndoInsDelCellsFlag = true;
var ref = var ref =
{ {
Ref: result[0].id + ':' + result[result.length -1].idNext Ref: t._refToRange(result[0].id + ':' + result[result.length -1].idNext)
}; };
if(addNameColumn && addFormatTableOptionsObj) if(addNameColumn && addFormatTableOptionsObj)
...@@ -770,9 +784,15 @@ var gUndoInsDelCellsFlag = true; ...@@ -770,9 +784,15 @@ var gUndoInsDelCellsFlag = true;
{ {
filterChange = allAutoFilters[apocal.num]; filterChange = allAutoFilters[apocal.num];
} }
rangeShift = ws.model.getRange(new CellAddress(filterChange.Ref.split(":")[0]), new CellAddress(filterChange.Ref.split(":")[1])); //rangeShift = ws.model.getRange(new CellAddress(filterChange.Ref.split(":")[0]), new CellAddress(filterChange.Ref.split(":")[1]));
rangeShift = filterChange.Ref;
paramsForCallBack = 'changeStyle'; paramsForCallBack = 'changeStyle';
rangeShift1 = t._getAscRange(rangeShift.bbox);
//rangeShift1 = t._getAscRange(rangeShift.bbox);
rangeShift1 = rangeShift;
if(isTurnOffHistory) if(isTurnOffHistory)
onAddAutoFiltersCallback(true); onAddAutoFiltersCallback(true);
else else
...@@ -797,29 +817,37 @@ var gUndoInsDelCellsFlag = true; ...@@ -797,29 +817,37 @@ var gUndoInsDelCellsFlag = true;
else else
currentFil = allAutoFilters[apocal.num]; currentFil = allAutoFilters[apocal.num];
} }
rangeShift = ws.model.getRange(new CellAddress(currentFil.Ref.split(":")[0]), new CellAddress(currentFil.Ref.split(":")[1]));
//rangeShift = ws.model.getRange(new CellAddress(currentFil.Ref.split(":")[0]), new CellAddress(currentFil.Ref.split(":")[1]));
rangeShift = currentFil.Ref;
if(apocal.changeAllFOnTable) if(apocal.changeAllFOnTable)
{ {
var startCells = this._idToRange(currentFil.Ref.split(":")[0]); /*var startCells = this._idToRange(currentFil.Ref.split(":")[0]);
var endCells = this._idToRange(currentFil.Ref.split(":")[1]); var endCells = this._idToRange(currentFil.Ref.split(":")[1]);
activeCells = new Asc.Range(startCells.c1, startCells.r1, endCells.c1, endCells.r1); activeCells = new Asc.Range(startCells.c1, startCells.r1, endCells.c1, endCells.r1);*/
activeCells = currentFil.Ref;
var rowAdd = 0; var rowAdd = 0;
var tableColumns = []; var tableColumns = [];
var j = 0; var j = 0;
rangeShift = ws.model.getRange3(activeCells.r1, activeCells.c1, activeCells.r1, activeCells.c2);
//rangeShift = ws.model.getRange3(activeCells.r1, activeCells.c1, activeCells.r1, activeCells.c2);
rangeShift = activeCells;
if(addNameColumn) if(addNameColumn)
{ {
rowAdd = 1; rowAdd = 1;
} }
paramsForCallBack = 'changeAllFOnTable'; paramsForCallBack = 'changeAllFOnTable';
rangeShift1 = t._getAscRange(activeCells,rowAdd); rangeShift1 = t._getAscRange(activeCells, rowAdd);
selectionTable = rangeShift1.clone(); selectionTable = rangeShift1.clone();
} }
else else
{ {
paramsForCallBack = 'deleteFilter'; paramsForCallBack = 'deleteFilter';
rangeShift1 = t._getAscRange(rangeShift.bbox); rangeShift1 = t._getAscRange(rangeShift);
} }
if(isTurnOffHistory) if(isTurnOffHistory)
...@@ -845,9 +873,15 @@ var gUndoInsDelCellsFlag = true; ...@@ -845,9 +873,15 @@ var gUndoInsDelCellsFlag = true;
{ {
filterChange = allAutoFilters[apocal.num]; filterChange = allAutoFilters[apocal.num];
} }
rangeShift = ws.model.getRange(new CellAddress(filterChange.Ref.split(":")[0]), new CellAddress(filterChange.Ref.split(":")[1]));
//rangeShift = ws.model.getRange(new CellAddress(filterChange.Ref.split(":")[0]), new CellAddress(filterChange.Ref.split(":")[1]));
rangeShift = filterChange.Ref;
paramsForCallBack = 'changeStyleWithoutFilter'; paramsForCallBack = 'changeStyleWithoutFilter';
rangeShift1 = t._getAscRange(rangeShift.bbox);
//rangeShift1 = t._getAscRange(rangeShift.bbox);
rangeShift1 = rangeShift;
if(isTurnOffHistory) if(isTurnOffHistory)
onAddAutoFiltersCallback(true); onAddAutoFiltersCallback(true);
else else
...@@ -861,9 +895,15 @@ var gUndoInsDelCellsFlag = true; ...@@ -861,9 +895,15 @@ var gUndoInsDelCellsFlag = true;
isVis: true isVis: true
}; };
var ourFilter = allAutoFilters[apocal.num - 1]; var ourFilter = allAutoFilters[apocal.num - 1];
rangeShift = ws.model.getRange(new CellAddress(ourFilter.Ref.split(":")[0]), new CellAddress(ourFilter.Ref.split(":")[1]));
//rangeShift = ws.model.getRange(new CellAddress(ourFilter.Ref.split(":")[0]), new CellAddress(ourFilter.Ref.split(":")[1]));
rangeShift = ourFilter.Ref;
paramsForCallBack = 'setStyleTableForAutoFilter'; paramsForCallBack = 'setStyleTableForAutoFilter';
rangeShift1 = t._getAscRange(rangeShift.bbox);
//rangeShift1 = t._getAscRange(rangeShift.bbox);
rangeShift1 = rangeShift;
if(isTurnOffHistory) if(isTurnOffHistory)
onAddAutoFiltersCallback(true); onAddAutoFiltersCallback(true);
else else
...@@ -877,9 +917,15 @@ var gUndoInsDelCellsFlag = true; ...@@ -877,9 +917,15 @@ var gUndoInsDelCellsFlag = true;
isVis: true isVis: true
}; };
var ourFilter = allAutoFilters[apocal.num]; var ourFilter = allAutoFilters[apocal.num];
rangeShift = ws.model.getRange(new CellAddress(ourFilter.Ref.split(":")[0]), new CellAddress(ourFilter.Ref.split(":")[1]));
//rangeShift = ws.model.getRange(new CellAddress(ourFilter.Ref.split(":")[0]), new CellAddress(ourFilter.Ref.split(":")[1]));
rangeShift = ourFilter.Ref;
paramsForCallBack = 'setStyleTableForAutoFilter1'; paramsForCallBack = 'setStyleTableForAutoFilter1';
rangeShift1 = t._getAscRange(rangeShift.bbox);
//rangeShift1 = t._getAscRange(rangeShift.bbox);
rangeShift1 = rangeShift;
if(isTurnOffHistory) if(isTurnOffHistory)
onAddAutoFiltersCallback(true); onAddAutoFiltersCallback(true);
else else
...@@ -906,13 +952,22 @@ var gUndoInsDelCellsFlag = true; ...@@ -906,13 +952,22 @@ var gUndoInsDelCellsFlag = true;
{ {
if(aWs.AutoFilter.Ref == "" || !aWs.AutoFilter.Ref) if(aWs.AutoFilter.Ref == "" || !aWs.AutoFilter.Ref)
return; return;
var allFil = aWs.AutoFilter.Ref.split(':');
/*var allFil = aWs.AutoFilter.Ref.split(':');
var sCell = ws.model.getCell( new CellAddress(allFil[0])); var sCell = ws.model.getCell( new CellAddress(allFil[0]));
var eCell = ws.model.getCell( new CellAddress(allFil[1])); var eCell = ws.model.getCell( new CellAddress(allFil[1]));*/
allFil = aWs.AutoFilter.Ref;
var n = 0; var n = 0;
result = []; result = [];
var startCol = sCell.first.col - 1;
var endCol = eCell.first.col - 1; /*var startCol = sCell.first.col - 1;
var endCol = eCell.first.col - 1;*/
var startCol = allFil.c1;
var endCol = allFil.c2;
//проверяем диапазон //проверяем диапазон
if(ws.cols.length < eCell.first.col) if(ws.cols.length < eCell.first.col)
ws.expandColsOnScroll(false,true,eCell.first.col); ws.expandColsOnScroll(false,true,eCell.first.col);
...@@ -920,15 +975,19 @@ var gUndoInsDelCellsFlag = true; ...@@ -920,15 +975,19 @@ var gUndoInsDelCellsFlag = true;
ws.expandColsOnScroll(false,true,eCell.first.row); ws.expandColsOnScroll(false,true,eCell.first.row);
for(var col = startCol; col <= endCol; col++) for(var col = startCol; col <= endCol; col++)
{ {
var idCell = new CellAddress(sCell.first.row - 1, col, 0); var idCell = new CellAddress(allFil.r1, col, 0);
var idCellNext = new CellAddress(eCell.first.row - 1, col, 0); var idCellNext = new CellAddress(allFil.r2, col, 0);
var cellId = idCell.getID(); var cellId = idCell.getID();
//скрыты ли какие-нибудь строки данной ячейкой, если да, то добавляем их в массив this.hiddenRowsArr //скрыты ли какие-нибудь строки данной ячейкой, если да, то добавляем их в массив this.hiddenRowsArr
//this._addRowsInHiddenArray(cellId,sCell,eCell,ws); //this._addRowsInHiddenArray(cellId,sCell,eCell,ws);
result[n] = new Result(); result[n] = new Result();
result[n].x = ws.cols[col].left; result[n].x = ws.cols[col].left;
result[n].y = ws.rows[sCell.first.row - 1].top;
//result[n].y = ws.rows[sCell.first.row - 1].top;
result[n].y = ws.rows[allFil.r1].top;
result[n].width = ws.cols[col].width; result[n].width = ws.cols[col].width;
result[n].height = ws.rows[startCol].height; result[n].height = ws.rows[startCol].height;
result[n].id = cellId; result[n].id = cellId;
...@@ -942,25 +1001,27 @@ var gUndoInsDelCellsFlag = true; ...@@ -942,25 +1001,27 @@ var gUndoInsDelCellsFlag = true;
{ {
if(aWs.TableParts[openFilter].Ref == "" || !aWs.TableParts[openFilter].Ref) if(aWs.TableParts[openFilter].Ref == "" || !aWs.TableParts[openFilter].Ref)
return; return;
var allFil = aWs.TableParts[openFilter].Ref.split(':'); var allFil = aWs.TableParts[openFilter].Ref;
var sCell = ws.model.getCell( new CellAddress(allFil[0]));
var eCell = ws.model.getCell( new CellAddress(allFil[1])); //var sCell = ws.model.getCell( new CellAddress(allFil[0]));
//var eCell = ws.model.getCell( new CellAddress(allFil[1]));
var n = 0; var n = 0;
result = []; result = [];
var startCol = sCell.first.col - 1; var startCol = allFil.c1;
var endCol = eCell.first.col - 1; var endCol = allFil.c2;
for(col = startCol; col <= endCol; col++) for(col = startCol; col <= endCol; col++)
{ {
var idCell = new CellAddress(sCell.first.row - 1, col, 0); var idCell = new CellAddress(allFil.r1, col, 0);
var idCellNext = new CellAddress(eCell.first.row - 1, col, 0); var idCellNext = new CellAddress(allFil.r2, col, 0);
var cellId = idCell.getID(); var cellId = idCell.getID();
//скрыты ли какие-нибудь строки данной ячейкой, если да, то добавляем их в массив this.hiddenRowsArr //скрыты ли какие-нибудь строки данной ячейкой, если да, то добавляем их в массив this.hiddenRowsArr
//this._addRowsInHiddenArray(cellId,sCell,eCell,ws); //this._addRowsInHiddenArray(cellId,sCell,eCell,ws);
result[n] = new Result(); result[n] = new Result();
result[n].x = ws.cols[col].left; result[n].x = ws.cols[col].left;
result[n].y = ws.rows[sCell.first.row - 1].top; result[n].y = ws.rows[allFil.r1].top;
result[n].width = ws.cols[col].width; result[n].width = ws.cols[col].width;
result[n].height = ws.rows[startCol].height; result[n].height = ws.rows[startCol].height;
result[n].id = cellId; result[n].id = cellId;
...@@ -1035,7 +1096,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1035,7 +1096,7 @@ var gUndoInsDelCellsFlag = true;
//устанавливаем стиль для таблицы //устанавливаем стиль для таблицы
if(!isAll && openFilter != undefined) if(!isAll && openFilter != undefined)
this._setColorStyleTable(result[0].id, result[result.length -1].idNext, aWs.TableParts[openFilter]); this._setColorStyleTable(aWs.TableParts[openFilter].Ref, aWs.TableParts[openFilter]);
if(openFilter != undefined) if(openFilter != undefined)
{ {
...@@ -1305,7 +1366,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1305,7 +1366,7 @@ var gUndoInsDelCellsFlag = true;
var sortCol = curCell.c1; var sortCol = curCell.c1;
sortRange.sort(type,sortCol); sortRange.sort(type,sortCol);
if(currentFilter.TableStyleInfo) if(currentFilter.TableStyleInfo)
t._setColorStyleTable(currentFilter.Ref.split(":")[0], currentFilter.Ref.split(":")[1], currentFilter); t._setColorStyleTable(currentFilter.Ref, currentFilter);
t._addHistoryObj(oldFilter, historyitem_AutoFilter_Sort, t._addHistoryObj(oldFilter, historyitem_AutoFilter_Sort,
{activeCells: activeCells, type: type, cellId: cellId}); {activeCells: activeCells, type: type, cellId: cellId});
History.EndTransaction(); History.EndTransaction();
...@@ -1329,7 +1390,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1329,7 +1390,7 @@ var gUndoInsDelCellsFlag = true;
History.StartTransaction(); History.StartTransaction();
sortRange.sort(type,sortCol); sortRange.sort(type,sortCol);
if(currentFilter.TableStyleInfo) if(currentFilter.TableStyleInfo)
t._setColorStyleTable(currentFilter.Ref.split(":")[0], currentFilter.Ref.split(":")[1], currentFilter); t._setColorStyleTable(currentFilter.Ref, currentFilter);
History.EndTransaction(); History.EndTransaction();
ws._cleanCache(selectionRange); ws._cleanCache(selectionRange);
ws.isChanged = true; ws.isChanged = true;
...@@ -1366,10 +1427,14 @@ var gUndoInsDelCellsFlag = true; ...@@ -1366,10 +1427,14 @@ var gUndoInsDelCellsFlag = true;
var num = filter.num; var num = filter.num;
if(aWs.AutoFilter && !filter.all) if(aWs.AutoFilter && !filter.all)
num = filter.num - 1; num = filter.num - 1;
var curFilter = allAutoFilters[num]; var curFilter = allAutoFilters[num];
var splitRef = curFilter.Ref.split(":"); /*var splitRef = curFilter.Ref.split(":");
var startCellFilter = this._idToRange(splitRef[0]); var startCellFilter = this._idToRange(splitRef[0]);
var endCellFilter = this._idToRange(splitRef[1]); var endCellFilter = this._idToRange(splitRef[1]);*/
var splitRef = curFilter.Ref;
if(activeRange.r1 == activeRange.r2 && activeRange.c1 == activeRange.c2)//внутри фильтра одна выделенная ячейка if(activeRange.r1 == activeRange.r2 && activeRange.c1 == activeRange.c2)//внутри фильтра одна выделенная ячейка
{ {
for(var i = 0; i < curFilter.result.length; i++) for(var i = 0; i < curFilter.result.length; i++)
...@@ -1382,11 +1447,13 @@ var gUndoInsDelCellsFlag = true; ...@@ -1382,11 +1447,13 @@ var gUndoInsDelCellsFlag = true;
} }
} }
} }
else if(startCellFilter.r1 == activeRange.r1 && startCellFilter.c1 == activeRange.c1 && endCellFilter.r1 == activeRange.r2 && endCellFilter.c1 == activeRange.c2)//выделен весь фильтр(сортируем по 1 столбцу) //else if(startCellFilter.r1 == activeRange.r1 && startCellFilter.c1 == activeRange.c1 && endCellFilter.r1 == activeRange.r2 && endCellFilter.c1 == activeRange.c2)//выделен весь фильтр(сортируем по 1 столбцу)
else if(splitRef.r1 == activeRange.r1 && splitRef.c1 == activeRange.c1 && splitRef.r2 == activeRange.r2 && splitRef.c2 == activeRange.c2)//выделен весь фильтр(сортируем по 1 столбцу)
{ {
cellId = splitRef[0]; cellId = Asc.Range(splitRef.c1, splitRef.r1, splitRef.c1, splitRef.r1);
} }
else if(startCellFilter.r1 == activeRange.r1)//захват в выделенную область части заголовка - сортируем выделенную область, за исключением заголовка else if(splitRef.r1 == activeRange.r1)//захват в выделенную область части заголовка - сортируем выделенную область, за исключением заголовка
//else if(startCellFilter.r1 == activeRange.r1)//захват в выделенную область части заголовка - сортируем выделенную область, за исключением заголовка
{ {
sortCol = activeRange.c1; sortCol = activeRange.c1;
sortRange = ws.model.getRange3(activeRange.r1 + 1, activeRange.c1, activeRange.r2, activeRange.c2); sortRange = ws.model.getRange3(activeRange.r1 + 1, activeRange.c1, activeRange.r2, activeRange.c2);
...@@ -1412,8 +1479,13 @@ var gUndoInsDelCellsFlag = true; ...@@ -1412,8 +1479,13 @@ var gUndoInsDelCellsFlag = true;
return; return;
} }
} }
if(typeof cellId !== "string")
cellId = t._rangeToId(cellId);
activeCells = t._idToRange(cellId); activeCells = t._idToRange(cellId);
var indexFilter = t._findArrayFromAllFilter3(activeCells,cellId);
var indexFilter = t._findArrayFromAllFilter3(activeCells, cellId);
var filtersOp = indexFilter.split(':'); var filtersOp = indexFilter.split(':');
if(filtersOp[0] == 'all') if(filtersOp[0] == 'all')
{ {
...@@ -1423,17 +1495,30 @@ var gUndoInsDelCellsFlag = true; ...@@ -1423,17 +1495,30 @@ var gUndoInsDelCellsFlag = true;
{ {
currentFilter = aWs.TableParts[filtersOp[0]]; currentFilter = aWs.TableParts[filtersOp[0]];
} }
oldFilter = currentFilter.clone(aWs); oldFilter = currentFilter.clone(aWs);
var rangeCell = currentFilter.Ref.split(':');
/*var rangeCell = currentFilter.Ref.split(':');
var startCell = t._idToRange(rangeCell[0]); var startCell = t._idToRange(rangeCell[0]);
var endCell = t._idToRange(rangeCell[1]); var endCell = t._idToRange(rangeCell[1]);*/
var rangeCell = currentFilter.Ref;
curCell = t._idToRange(cellId); curCell = t._idToRange(cellId);
curCell.r1 = endCell.r1;
selectionRange = new Asc.Range(startCell.c1, startCell.r1 + 1, endCell.c2, endCell.r2); //curCell.r1 = endCell.r1;
curCell.r1 = rangeCell.r1;
//selectionRange = new Asc.Range(startCell.c1, startCell.r1 + 1, endCell.c2, endCell.r2);
selectionRange = new Asc.Range(rangeCell.c1, rangeCell.r1 + 1, rangeCell.c2, rangeCell.r2);
newEndId = t._rangeToId(curCell); newEndId = t._rangeToId(curCell);
startCell.r1 = startCell.r1 + 1; //startCell.r1 = startCell.r1 + 1;
sortRange = ws.model.getRange3(startCell.r1, startCell.c1, endCell.r1, endCell.c1); //sortRange = ws.model.getRange3(startCell.r1, startCell.c1, endCell.r1, endCell.c1);
sortRange = ws.model.getRange3(rangeCell.r1 + 1, rangeCell.c1, rangeCell.r2, rangeCell.c2);
var sortRange1 = t._getAscRange(sortRange.bbox); var sortRange1 = t._getAscRange(sortRange.bbox);
if(isTurnOffHistory) if(isTurnOffHistory)
...@@ -1454,7 +1539,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1454,7 +1539,7 @@ var gUndoInsDelCellsFlag = true;
var activeCells = ar; var activeCells = ar;
if(aWs.AutoFilter) if(aWs.AutoFilter)
{ {
var oRange = aWs.getRange2(aWs.AutoFilter.Ref); var oRange = Range.prototype.createFromBBox(aWs, aWs.AutoFilter.Ref);
var bbox = oRange.getBBox0(); var bbox = oRange.getBBox0();
//смотрим находится ли фильтр внутри выделенного фрагмента //смотрим находится ли фильтр внутри выделенного фрагмента
if(activeCells.r1 <= bbox.r1 && activeCells.r2 >= bbox.r2 && activeCells.c1 <= bbox.c1 && activeCells.c2 >= bbox.c2) if(activeCells.r1 <= bbox.r1 && activeCells.r2 >= bbox.r2 && activeCells.c1 <= bbox.c1 && activeCells.c2 >= bbox.c2)
...@@ -1478,7 +1563,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1478,7 +1563,7 @@ var gUndoInsDelCellsFlag = true;
for(var i = 0; i < aWs.TableParts.length; i++) for(var i = 0; i < aWs.TableParts.length; i++)
{ {
var oCurFilter = aWs.TableParts[i].clone(aWs); var oCurFilter = aWs.TableParts[i].clone(aWs);
var oRange = aWs.getRange2(oCurFilter.Ref); var oRange = Range.prototype.createFromBBox(aWs, oCurFilter.Ref);
if(insCells) if(insCells)
oCurFilter.insCells = true; oCurFilter.insCells = true;
var bbox = oRange.getBBox0(); var bbox = oRange.getBBox0();
...@@ -1625,7 +1710,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1625,7 +1710,7 @@ var gUndoInsDelCellsFlag = true;
{ {
for(var l = 0; l < aWs.TableParts.length; l++) for(var l = 0; l < aWs.TableParts.length; l++)
{ {
if(cloneData.refTable == aWs.TableParts[l].Ref) if(cloneData.refTable.isEqual(aWs.TableParts[l].Ref))
{ {
this._cleanStyleTable(aWs, cloneData.refTable); this._cleanStyleTable(aWs, cloneData.refTable);
aWs.TableParts.splice(l,1); aWs.TableParts.splice(l,1);
...@@ -1639,7 +1724,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1639,7 +1724,7 @@ var gUndoInsDelCellsFlag = true;
if(cloneData.Ref) if(cloneData.Ref)
{ {
var isEn = false; var isEn = false;
if(aWs.AutoFilter && aWs.AutoFilter.Ref == cloneData.Ref) if(aWs.AutoFilter && aWs.AutoFilter.Ref.isEqual(cloneData.Ref))
{ {
this._reDrawCurrentFilter(cloneData.FilterColumns, cloneData.result); this._reDrawCurrentFilter(cloneData.FilterColumns, cloneData.result);
aWs.AutoFilter = cloneData; aWs.AutoFilter = cloneData;
...@@ -1649,23 +1734,50 @@ var gUndoInsDelCellsFlag = true; ...@@ -1649,23 +1734,50 @@ var gUndoInsDelCellsFlag = true;
{ {
for(var l = 0; l < aWs.TableParts.length; l++) for(var l = 0; l < aWs.TableParts.length; l++)
{ {
if(cloneData.Ref == aWs.TableParts[l].Ref) if(cloneData.Ref.isEqual(aWs.TableParts[l].Ref))
{ {
var cloneResult = []; /*if(cloneData.AutoFilter)
for(var k = 0; k < cloneData.result.length; k++) {*/
{ var cloneResult = [];
cloneResult[k] = cloneData.result[k].clone(); for(var k = 0; k < cloneData.result.length; k++)
} {
if(!aWs.TableParts[l].AutoFilter && cloneData.AutoFilter) cloneResult[k] = cloneData.result[k].clone();
this._addButtonAF({result: cloneResult,isVis: true}); }
else if(aWs.TableParts[l].AutoFilter && !cloneData.AutoFilter) if(!aWs.TableParts[l].AutoFilter && cloneData.AutoFilter)
this._addButtonAF({result: aWs.TableParts[l].result,isVis: false}); this._addButtonAF({result: cloneResult,isVis: true});
aWs.TableParts[l] = cloneData; else if(aWs.TableParts[l].AutoFilter && !cloneData.AutoFilter)
if(cloneData.AutoFilter && cloneData.AutoFilter.FilterColumns) this._addButtonAF({result: aWs.TableParts[l].result,isVis: false});
this._reDrawCurrentFilter(cloneData.AutoFilter.FilterColumns, cloneData.result, aWs.TableParts[l]); aWs.TableParts[l] = cloneData;
if(cloneData.AutoFilter && cloneData.AutoFilter.FilterColumns)
this._reDrawCurrentFilter(cloneData.AutoFilter.FilterColumns, cloneData.result, aWs.TableParts[l]);
else
this._reDrawCurrentFilter(null, cloneData.result, aWs.TableParts[l]);
isEn = true;
/*}
else else
this._reDrawCurrentFilter(null, cloneData.result, aWs.TableParts[l]); {
isEn = true; var cloneResult = [];
for(var k = 0; k < cloneData.result.length; k++)
{
cloneResult[k] = cloneData.result[k].clone();
};
this._cleanStyleTable(aWs, cloneData.Ref);
if(!aWs.TableParts[l].AutoFilter && cloneData.AutoFilter)
this._addButtonAF({result: cloneResult,isVis: true});
else if(aWs.TableParts[l].AutoFilter && !cloneData.AutoFilter)
this._addButtonAF({result: aWs.TableParts[l].result,isVis: false});
aWs.AutoFilter = cloneData;
//if(cloneData.AutoFilter && cloneData.AutoFilter.FilterColumns)
//this._reDrawCurrentFilter(cloneData.AutoFilter.FilterColumns, cloneData.result, aWs.TableParts[l]);
//else
//this._reDrawCurrentFilter(null, cloneData.result, aWs.TableParts[l]);
isEn = false;
}; */
break; break;
} }
} }
...@@ -1677,7 +1789,11 @@ var gUndoInsDelCellsFlag = true; ...@@ -1677,7 +1789,11 @@ var gUndoInsDelCellsFlag = true;
if(!aWs.TableParts) if(!aWs.TableParts)
aWs.TableParts = []; aWs.TableParts = [];
aWs.TableParts[aWs.TableParts.length] = cloneData; aWs.TableParts[aWs.TableParts.length] = cloneData;
var splitRange = cloneData.Ref.split(':');
//var splitRange = cloneData.Ref.split(':');
var splitRange = cloneData.Ref;
/*if(!gUndoInsDelCellsFlag) /*if(!gUndoInsDelCellsFlag)
{ {
gUndoInsDelCellsFlag = gUndoInsDelCellsFlag =
...@@ -1688,7 +1804,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1688,7 +1804,7 @@ var gUndoInsDelCellsFlag = true;
} }
} }
else*/ else*/
this._setColorStyleTable(splitRange[0], splitRange[1], cloneData, null, true); this._setColorStyleTable(splitRange, cloneData, null, true);
this._addButtonAF({result: cloneData.result,isVis: true}); this._addButtonAF({result: cloneData.result,isVis: true});
} }
else else
...@@ -1701,7 +1817,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1701,7 +1817,7 @@ var gUndoInsDelCellsFlag = true;
} }
else if(cloneData.oldFilter)//в случае удаления/добавления строк else if(cloneData.oldFilter)//в случае удаления/добавления строк
{ {
if(aWs.AutoFilter && this._rangeHitInAnRange(this._refToRange(cloneData.oldFilter.Ref), this._refToRange(aWs.AutoFilter.Ref))) if(aWs.AutoFilter && this._rangeHitInAnRange(cloneData.oldFilter.Ref, aWs.AutoFilter.Ref))
{ {
aWs.AutoFilter = cloneData.oldFilter; aWs.AutoFilter = cloneData.oldFilter;
this._addButtonAF({result: cloneData.oldFilter.result,isVis: true}); this._addButtonAF({result: cloneData.oldFilter.result,isVis: true});
...@@ -1710,12 +1826,15 @@ var gUndoInsDelCellsFlag = true; ...@@ -1710,12 +1826,15 @@ var gUndoInsDelCellsFlag = true;
{ {
for(var l = 0; l < aWs.TableParts.length; l++) for(var l = 0; l < aWs.TableParts.length; l++)
{ {
if(this._rangeHitInAnRange(this._refToRange(cloneData.oldFilter.Ref), this._refToRange(aWs.TableParts[l].Ref))) if(this._rangeHitInAnRange(cloneData.oldFilter.Ref, aWs.TableParts[l].Ref))
{ {
aWs.TableParts[l] = cloneData.oldFilter; aWs.TableParts[l] = cloneData.oldFilter;
this._addButtonAF({result: cloneData.oldFilter.result,isVis: true}); this._addButtonAF({result: cloneData.oldFilter.result,isVis: true});
var splitRange = cloneData.oldFilter.Ref.split(':');
this._setColorStyleTable(splitRange[0], splitRange[1], cloneData.oldFilter, null, true); //var splitRange = cloneData.oldFilter.Ref.split(':');
var splitRange = cloneData.oldFilter.Ref;
this._setColorStyleTable(splitRange, cloneData.oldFilter, null, true);
break; break;
} }
} }
...@@ -1725,7 +1844,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1725,7 +1844,7 @@ var gUndoInsDelCellsFlag = true;
{ {
if(cloneData.Ref) if(cloneData.Ref)
{ {
if(aWs.AutoFilter && aWs.AutoFilter.Ref == cloneData.Ref) if(aWs.AutoFilter && aWs.AutoFilter.Ref.isEqual(cloneData.Ref))
{ {
if(aWs.AutoFilter.result) if(aWs.AutoFilter.result)
this._addButtonAF({result: aWs.AutoFilter.result, isVis: false}); this._addButtonAF({result: aWs.AutoFilter.result, isVis: false});
...@@ -1736,7 +1855,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1736,7 +1855,7 @@ var gUndoInsDelCellsFlag = true;
{ {
for(var l = 0; l < aWs.TableParts.length; l++) for(var l = 0; l < aWs.TableParts.length; l++)
{ {
if(cloneData.Ref == aWs.TableParts[l].Ref) if(cloneData.Ref.isEqual(aWs.TableParts[l].Ref))
{ {
this._cleanStyleTable(aWs, cloneData.Ref); this._cleanStyleTable(aWs, cloneData.Ref);
...@@ -1798,7 +1917,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1798,7 +1917,7 @@ var gUndoInsDelCellsFlag = true;
var currentFilter = tableParts[i]; var currentFilter = tableParts[i];
if(currentFilter && currentFilter.Ref) if(currentFilter && currentFilter.Ref)
{ {
var ref = currentFilter.Ref.split(':'); /*var ref = currentFilter.Ref.split(':');
var startId = this._idToRange(ref[0]); var startId = this._idToRange(ref[0]);
var endId = this._idToRange(ref[1]); var endId = this._idToRange(ref[1]);
var tableRange = var tableRange =
...@@ -1807,10 +1926,12 @@ var gUndoInsDelCellsFlag = true; ...@@ -1807,10 +1926,12 @@ var gUndoInsDelCellsFlag = true;
c1: startId.c1, c1: startId.c1,
r2: endId.r1, r2: endId.r1,
c2: endId.c1 c2: endId.c1
}; };*/
var tableRange = currentFilter.Ref;
//проверяем, попадает хотя бы одна ячейка из диапазона в область фильтра //проверяем, попадает хотя бы одна ячейка из диапазона в область фильтра
if(this._rangeHitInAnRange(range,tableRange)) if(this._rangeHitInAnRange(range, tableRange))
this._setColorStyleTable(ref[0], ref[1], currentFilter); this._setColorStyleTable(tableRange, currentFilter);
} }
} }
} }
...@@ -1826,7 +1947,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -1826,7 +1947,7 @@ var gUndoInsDelCellsFlag = true;
{ {
if(aWs.TableParts[i].Ref) if(aWs.TableParts[i].Ref)
{ {
var ref = aWs.TableParts[i].Ref.split(":"); /*var ref = aWs.TableParts[i].Ref.split(":");
var startRange = this._idToRange(ref[0]); var startRange = this._idToRange(ref[0]);
var endRange = this._idToRange(ref[1]); var endRange = this._idToRange(ref[1]);
tableRange = tableRange =
...@@ -1835,7 +1956,10 @@ var gUndoInsDelCellsFlag = true; ...@@ -1835,7 +1956,10 @@ var gUndoInsDelCellsFlag = true;
r2: endRange.r1, r2: endRange.r1,
c1: startRange.c1, c1: startRange.c1,
c2: endRange.c1 c2: endRange.c1
} }*/
tableRange = aWs.TableParts[i].Ref;
} }
if(this._rangeHitInAnRange(range,tableRange)) if(this._rangeHitInAnRange(range,tableRange))
return tableRange; return tableRange;
...@@ -2240,7 +2364,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -2240,7 +2364,7 @@ var gUndoInsDelCellsFlag = true;
var oldFilter = filterObj.clone(aWs); var oldFilter = filterObj.clone(aWs);
var cell = ws.model.getCell( new CellAddress(activeCells.r1, activeCells.c1,0)); var cell = ws.model.getCell( new CellAddress(activeCells.r1, activeCells.c1,0));
var filterRange = this._refToRange(ref); var filterRange = ref;
var rangeStart = filterRange; var rangeStart = filterRange;
if(newAcCells.c1 == (rangeStart.c1 + parseInt(filtersOp[1]))) if(newAcCells.c1 == (rangeStart.c1 + parseInt(filtersOp[1])))
...@@ -2275,7 +2399,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -2275,7 +2399,7 @@ var gUndoInsDelCellsFlag = true;
isMerged = false; isMerged = false;
var lengthRows = array.length; var lengthRows = array.length;
if(ref && ref.split(":")[1]) if(ref)
lengthRows = filterRange.r2 - filterRange.r1; lengthRows = filterRange.r2 - filterRange.r1;
var allFilterOpenElements = true; var allFilterOpenElements = true;
...@@ -2784,7 +2908,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -2784,7 +2908,7 @@ var gUndoInsDelCellsFlag = true;
{ {
if(!oldFilters[i].Ref || oldFilters[i].Ref == "") if(!oldFilters[i].Ref || oldFilters[i].Ref == "")
continue; continue;
var fromCellId = oldFilters[i].Ref.split(':')[0]; /*var fromCellId = oldFilters[i].Ref.split(':')[0];
var toCellId = oldFilters[i].Ref.split(':')[1]; var toCellId = oldFilters[i].Ref.split(':')[1];
var startId = ws.model.getCell( new CellAddress(fromCellId)); var startId = ws.model.getCell( new CellAddress(fromCellId));
var endId = ws.model.getCell( new CellAddress(toCellId)); var endId = ws.model.getCell( new CellAddress(toCellId));
...@@ -2794,7 +2918,10 @@ var gUndoInsDelCellsFlag = true; ...@@ -2794,7 +2918,10 @@ var gUndoInsDelCellsFlag = true;
c1: startId.first.col - 1, c1: startId.first.col - 1,
r2: endId.first.row - 1, r2: endId.first.row - 1,
c2: endId.first.col - 1 c2: endId.first.col - 1
}; };*/
oldRange = oldFilters[i].Ref;
if(cloneActiveRange.r1 <= oldRange.r1 && cloneActiveRange.r2 >= oldRange.r2 && cloneActiveRange.c1 <= oldRange.c1 && cloneActiveRange.c2 >= oldRange.c2) if(cloneActiveRange.r1 <= oldRange.r1 && cloneActiveRange.r2 >= oldRange.r2 && cloneActiveRange.c1 <= oldRange.c1 && cloneActiveRange.c2 >= oldRange.c2)
{ {
if(oldRange.r2 > ar.r1 && ar.c2 >= oldRange.c1 && ar.c2 <= oldRange.c2)//top if(oldRange.r2 > ar.r1 && ar.c2 >= oldRange.c1 && ar.c2 <= oldRange.c2)//top
...@@ -3013,7 +3140,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -3013,7 +3140,7 @@ var gUndoInsDelCellsFlag = true;
{ {
if(!oldFilters[i].Ref || oldFilters[i].Ref == "") if(!oldFilters[i].Ref || oldFilters[i].Ref == "")
continue; continue;
var fromCellId = oldFilters[i].Ref.split(':')[0]; /*var fromCellId = oldFilters[i].Ref.split(':')[0];
var toCellId = oldFilters[i].Ref.split(':')[1]; var toCellId = oldFilters[i].Ref.split(':')[1];
var startId = ws.model.getCell( new CellAddress(fromCellId)); var startId = ws.model.getCell( new CellAddress(fromCellId));
var endId = ws.model.getCell( new CellAddress(toCellId)); var endId = ws.model.getCell( new CellAddress(toCellId));
...@@ -3023,7 +3150,10 @@ var gUndoInsDelCellsFlag = true; ...@@ -3023,7 +3150,10 @@ var gUndoInsDelCellsFlag = true;
c1: startId.first.col - 1, c1: startId.first.col - 1,
r2: endId.first.row - 1, r2: endId.first.row - 1,
c2: endId.first.col - 1 c2: endId.first.col - 1
}; };*/
var oldRange = oldFilters[i].Ref;
if(cloneActiveRange.r1 <= oldRange.r1 && cloneActiveRange.r2 >= oldRange.r2 && cloneActiveRange.c1 <= oldRange.c1 && cloneActiveRange.c2 >= oldRange.c2) if(cloneActiveRange.r1 <= oldRange.r1 && cloneActiveRange.r2 >= oldRange.r2 && cloneActiveRange.c1 <= oldRange.c1 && cloneActiveRange.c2 >= oldRange.c2)
{ {
if(oldRange.r2 > ar.r1 && ar.c2 >= oldRange.c1 && ar.c2 <= oldRange.c2)//top if(oldRange.r2 > ar.r1 && ar.c2 >= oldRange.c1 && ar.c2 <= oldRange.c2)//top
...@@ -3497,11 +3627,13 @@ var gUndoInsDelCellsFlag = true; ...@@ -3497,11 +3627,13 @@ var gUndoInsDelCellsFlag = true;
{ {
if(!allF[i].Ref || allF[i].Ref == "") if(!allF[i].Ref || allF[i].Ref == "")
continue; continue;
var cCell = allF[i].Ref.split(':'); /*var cCell = allF[i].Ref.split(':');
var fromCell = ws.model.getCell(new CellAddress(cCell[0])); var fromCell = ws.model.getCell(new CellAddress(cCell[0]));
var toCell = ws.model.getCell(new CellAddress(cCell[1])); var toCell = ws.model.getCell(new CellAddress(cCell[1]));*/
var cCell = allF[i].Ref;
var range = Asc.Range(fromCell.first.col - 1, fromCell.first.row - 1, toCell.first.col - 1, toCell.first.row - 1); var range = cCell;
if(!allF[i].AutoFilter && !allF[i].TableStyleInfo) if(!allF[i].AutoFilter && !allF[i].TableStyleInfo)
{ {
...@@ -3606,7 +3738,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -3606,7 +3738,7 @@ var gUndoInsDelCellsFlag = true;
var index = undefined; var index = undefined;
if(aWs.AutoFilter) if(aWs.AutoFilter)
{ {
var ref = aWs.AutoFilter.Ref.split(':'); /*var ref = aWs.AutoFilter.Ref.split(':');
var sCell = ws.model.getCell( new CellAddress(ref[0])); var sCell = ws.model.getCell( new CellAddress(ref[0]));
var eCell = ws.model.getCell( new CellAddress(ref[1])); var eCell = ws.model.getCell( new CellAddress(ref[1]));
var rangeFilter = var rangeFilter =
...@@ -3615,7 +3747,10 @@ var gUndoInsDelCellsFlag = true; ...@@ -3615,7 +3747,10 @@ var gUndoInsDelCellsFlag = true;
c2: eCell.first.col - 1 , c2: eCell.first.col - 1 ,
r1: sCell.first.row - 1, r1: sCell.first.row - 1,
r2: eCell.first.row - 1 r2: eCell.first.row - 1
}; };*/
var rangeFilter = aWs.AutoFilter.Ref;
if(range.r1 >= rangeFilter.r1 && range.c1 >= rangeFilter.c1 && range.r2 <= rangeFilter.r2 && range.c2 <= rangeFilter.c2) if(range.r1 >= rangeFilter.r1 && range.c1 >= rangeFilter.c1 && range.r2 <= rangeFilter.r2 && range.c2 <= rangeFilter.c2)
{ {
var res = aWs.AutoFilter.result; var res = aWs.AutoFilter.result;
...@@ -3637,7 +3772,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -3637,7 +3772,7 @@ var gUndoInsDelCellsFlag = true;
var tableParts = aWs.TableParts; var tableParts = aWs.TableParts;
for(var tP = 0; tP < tableParts.length; tP++) for(var tP = 0; tP < tableParts.length; tP++)
{ {
var ref = tableParts[tP].Ref.split(':'); /*var ref = tableParts[tP].Ref.split(':');
var sCell = ws.model.getCell( new CellAddress(ref[0])); var sCell = ws.model.getCell( new CellAddress(ref[0]));
var eCell = ws.model.getCell( new CellAddress(ref[1])); var eCell = ws.model.getCell( new CellAddress(ref[1]));
var rangeFilter = var rangeFilter =
...@@ -3646,7 +3781,10 @@ var gUndoInsDelCellsFlag = true; ...@@ -3646,7 +3781,10 @@ var gUndoInsDelCellsFlag = true;
c2: eCell.first.col - 1 , c2: eCell.first.col - 1 ,
r1: sCell.first.row - 1, r1: sCell.first.row - 1,
r2: eCell.first.row - 1 r2: eCell.first.row - 1
}; };*/
var rangeFilter = tableParts[tP].Ref;
if(range.r1 >= rangeFilter.r1 && range.c1 >= rangeFilter.c1 && range.r2 <= rangeFilter.r2 && range.c2 <= rangeFilter.c2) if(range.r1 >= rangeFilter.r1 && range.c1 >= rangeFilter.c1 && range.r2 <= rangeFilter.r2 && range.c2 <= rangeFilter.c2)
{ {
index = tP; index = tP;
...@@ -3698,7 +3836,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -3698,7 +3836,7 @@ var gUndoInsDelCellsFlag = true;
if(this.allButtonAF[aF].id == arr.result[i].id) if(this.allButtonAF[aF].id == arr.result[i].id)
{ {
this.allButtonAF[aF] = arr.result[i]; this.allButtonAF[aF] = arr.result[i];
this.allButtonAF[aF].inFilter = arr.result[0].id + ':' + arr.result[arr.result.length - 1].idNext; this.allButtonAF[aF].inFilter = this._refToRange(arr.result[0].id + ':' + arr.result[arr.result.length - 1].idNext);
isInsert = true; isInsert = true;
break; break;
} }
...@@ -3707,7 +3845,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -3707,7 +3845,7 @@ var gUndoInsDelCellsFlag = true;
if(!isInsert) if(!isInsert)
{ {
this.allButtonAF[leng + n] = arr.result[i]; this.allButtonAF[leng + n] = arr.result[i];
this.allButtonAF[leng + n].inFilter = arr.result[0].id + ':' + arr.result[arr.result.length - 1].idNext; this.allButtonAF[leng + n].inFilter = this._refToRange(arr.result[0].id + ':' + arr.result[arr.result.length - 1].idNext);
n++; n++;
} }
} }
...@@ -3748,15 +3886,15 @@ var gUndoInsDelCellsFlag = true; ...@@ -3748,15 +3886,15 @@ var gUndoInsDelCellsFlag = true;
}, },
_cleanStyleTable : function(aWs, sRef) _cleanStyleTable : function(aWs, sRef)
{ {
var oRange = aWs.getRange2(sRef); var oRange = Range.prototype.createFromBBox(aWs, sRef);
oRange.setTableStyle(null); oRange.setTableStyle(null);
}, },
_setColorStyleTable: function(id, idNext, options, isOpenFilter, isSetVal) _setColorStyleTable: function(range, options, isOpenFilter, isSetVal)
{ {
var ws = this.worksheet; var ws = this.worksheet;
var firstCellAddress = new CellAddress(id); //var firstCellAddress = new CellAddress(id);
var endCellAddress = new CellAddress(idNext); //var endCellAddress = new CellAddress(idNext);
var bbox = {r1: firstCellAddress.getRow0(), c1: firstCellAddress.getCol0(), r2: endCellAddress.getRow0(), c2: endCellAddress.getCol0()}; var bbox = range;
//ограничим количество строчек/столбцов //ограничим количество строчек/столбцов
var maxValCol = 20000; var maxValCol = 20000;
var maxValRow = 100000; var maxValRow = 100000;
...@@ -4239,7 +4377,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -4239,7 +4377,7 @@ var gUndoInsDelCellsFlag = true;
{ {
var ref = currentFilter.Ref; var ref = currentFilter.Ref;
var rangeFilter = this._refToRange(ref); var rangeFilter = ref;
//var filterStart = ws.model.getCell(new CellAddress(ref.split(':')[0])); //var filterStart = ws.model.getCell(new CellAddress(ref.split(':')[0]));
//var filterEnd = ws.model.getCell(new CellAddress(ref.split(':')[1])); //var filterEnd = ws.model.getCell(new CellAddress(ref.split(':')[1]));
...@@ -4311,7 +4449,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -4311,7 +4449,7 @@ var gUndoInsDelCellsFlag = true;
{ {
newFilter = new AutoFilter(); newFilter = new AutoFilter();
newFilter.result = val; newFilter.result = val;
ref = val[0].id + ':' + val[val.length - 1].idNext; ref = this._refToRange(val[0].id + ':' + val[val.length - 1].idNext);
newFilter.Ref = ref; newFilter.Ref = ref;
aWs.AutoFilter = newFilter; aWs.AutoFilter = newFilter;
} }
...@@ -4343,7 +4481,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -4343,7 +4481,7 @@ var gUndoInsDelCellsFlag = true;
{ {
if(!aWs.TableParts) if(!aWs.TableParts)
aWs.TableParts = []; aWs.TableParts = [];
ref = val[0].id + ':' + val[val.length - 1].idNext; ref = this._refToRange(val[0].id + ':' + val[val.length - 1].idNext);
newFilter = new TablePart(); newFilter = new TablePart();
newFilter.Ref = ref; newFilter.Ref = ref;
...@@ -4631,7 +4769,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -4631,7 +4769,7 @@ var gUndoInsDelCellsFlag = true;
for(var num = 0; num < buttons.length; num++) for(var num = 0; num < buttons.length; num++)
{ {
//в случае числового фильтра, смотрим ищем конфиликт только со столбцами из данного фильтра //в случае числового фильтра, смотрим ищем конфиликт только со столбцами из данного фильтра
if(customFil != undefined && buttons[num].inFilter == customFil) if(customFil != undefined && customFil.isEqual(buttons[num].inFilter))
{ {
isCurrenCell = false; isCurrenCell = false;
if(!isCurrenCell && cellId == buttons[num].id) if(!isCurrenCell && cellId == buttons[num].id)
...@@ -4641,7 +4779,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -4641,7 +4779,7 @@ var gUndoInsDelCellsFlag = true;
return 'hidden'; return 'hidden';
} }
} }
else if(customFil == undefined && ref == buttons[num].inFilter) else if(customFil == undefined && ref.isEqual(buttons[num].inFilter))
{ {
isCurrenCell = false; isCurrenCell = false;
if(!isCurrenCell && cellId == buttons[num].id) if(!isCurrenCell && cellId == buttons[num].id)
...@@ -4670,7 +4808,10 @@ var gUndoInsDelCellsFlag = true; ...@@ -4670,7 +4808,10 @@ var gUndoInsDelCellsFlag = true;
var aWs = this._getCurrentWS(); var aWs = this._getCurrentWS();
if(aWs.AutoFilter) if(aWs.AutoFilter)
{ {
var ref = aWs.AutoFilter.Ref.split(':'); //var ref = aWs.AutoFilter.Ref.split(':');
var ref = aWs.AutoFilter.Ref;
var options = { var options = {
ref:ref, ref:ref,
val:val, val:val,
...@@ -4685,7 +4826,10 @@ var gUndoInsDelCellsFlag = true; ...@@ -4685,7 +4826,10 @@ var gUndoInsDelCellsFlag = true;
var length; var length;
for(var lT = 0; lT < aWs.TableParts.length; lT++) for(var lT = 0; lT < aWs.TableParts.length; lT++)
{ {
var ref = aWs.TableParts[lT].Ref.split(':'); //var ref = aWs.TableParts[lT].Ref.split(':');
var ref = aWs.TableParts[lT].Ref;
var options = { var options = {
ref:ref, ref:ref,
val:val, val:val,
...@@ -4705,13 +4849,18 @@ var gUndoInsDelCellsFlag = true; ...@@ -4705,13 +4849,18 @@ var gUndoInsDelCellsFlag = true;
History.TurnOn(); History.TurnOn();
}, },
_changeFilterAfterInsertColumn: function(options,type,activeCells) _changeFilterAfterInsertColumn: function(options, type, activeCells)
{ {
var ref = options.ref, val = options.val, col = options.col, index = options.index; var ref = options.ref, val = options.val, col = options.col, index = options.index;
//var aWs = this._getCurrentWS(ws); //var aWs = this._getCurrentWS(ws);
var range = {}; var range = {};
var startRange = this._idToRange(ref[0]);
var endRange = this._idToRange(ref[1]); /*var startRange = this._idToRange(ref[0]);
var endRange = this._idToRange(ref[1]);*/
var startRange = Asc.Range(ref.c1, ref.r1, ref.c1, ref.r1);;
var endRange = Asc.Range(ref.c2, ref.r2, ref.c2, ref.r2);;
range.start = startRange; range.start = startRange;
range.end = endRange; range.end = endRange;
if(index == undefined) if(index == undefined)
...@@ -4791,6 +4940,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -4791,6 +4940,7 @@ var gUndoInsDelCellsFlag = true;
//change current filter after insert column //change current filter after insert column
_editFilterAfterInsertColumn: function(cRange,val,col,type,activeCells) _editFilterAfterInsertColumn: function(cRange,val,col,type,activeCells)
{ {
console.time("test");
var bUndoChanges = this.worksheet.model.workbook.bUndoChanges; var bUndoChanges = this.worksheet.model.workbook.bUndoChanges;
var bRedoChanges = this.worksheet.model.workbook.bRedoChanges; var bRedoChanges = this.worksheet.model.workbook.bRedoChanges;
var ws = this.worksheet; var ws = this.worksheet;
...@@ -4800,15 +4950,16 @@ var gUndoInsDelCellsFlag = true; ...@@ -4800,15 +4950,16 @@ var gUndoInsDelCellsFlag = true;
var buttons = this.allButtonAF; var buttons = this.allButtonAF;
if(cRange.index == 'all') if(cRange.index == 'all')
{ {
filter = aWs.AutoFilter; filter = aWs.AutoFilter.clone(aWs);
filterColums = filter.FilterColumns; filterColums = filter.FilterColumns;
} }
else else
{ {
filter = aWs.TableParts[cRange.index]; filter = aWs.TableParts[cRange.index].clone(aWs);
if(filter.AutoFilter) if(filter.AutoFilter)
filterColums = filter.AutoFilter.FilterColumns; filterColums = filter.AutoFilter.FilterColumns;
} };
var oldFilter = filter.clone(aWs); var oldFilter = filter.clone(aWs);
if(val < 0) if(val < 0)
...@@ -4816,32 +4967,42 @@ var gUndoInsDelCellsFlag = true; ...@@ -4816,32 +4967,42 @@ var gUndoInsDelCellsFlag = true;
var activeRange = ws.activeRange; var activeRange = ws.activeRange;
if(activeCells && typeof activeCells == 'object') if(activeCells && typeof activeCells == 'object')
activeRange = Asc.Range(activeCells.c1, activeCells.r1, activeCells.c2, activeCells.r2); activeRange = Asc.Range(activeCells.c1, activeCells.r1, activeCells.c2, activeCells.r2);
var splitRefFilter = filter.Ref.split(":");
/*var splitRefFilter = filter.Ref.split(":");
var startCell = this._idToRange(splitRefFilter[0]); var startCell = this._idToRange(splitRefFilter[0]);
var endCell = this._idToRange(splitRefFilter[1]); var endCell = this._idToRange(splitRefFilter[1]);*/
var splitRefFilter = filter.Ref;
var isDelFilter = false; var isDelFilter = false;
//в данных случаях нужно удалять весь фильтр, как в EXCEl //в данных случаях нужно удалять весь фильтр, как в EXCEl
if(activeRange.contains(startCell.c1,startCell.r1) && activeRange.contains(startCell.c1,endCell.r1) && activeRange.contains(endCell.c1,startCell.r1) && activeRange.contains(endCell.c1,endCell.r1))//под удаление попал весь фильтр //if(activeRange.contains(startCell.c1,startCell.r1) && activeRange.contains(startCell.c1,endCell.r1) && activeRange.contains(endCell.c1,startCell.r1) && activeRange.contains(endCell.c1,endCell.r1))//под удаление попал весь фильтр
if(activeRange.contains(splitRefFilter.c1,splitRefFilter.r1) && activeRange.contains(splitRefFilter.c1,splitRefFilter.r2) && activeRange.contains(splitRefFilter.c2,splitRefFilter.r1) && activeRange.contains(splitRefFilter.c2, splitRefFilter.r2))//под удаление попал весь фильтр
{ {
isDelFilter = true; isDelFilter = true;
} }
else if(type == 'insRow' && activeRange.r1 == startCell.r1 && activeRange.r2 == endCell.r1 && activeRange.c1 >= startCell.c1 && activeRange.c2 <= endCell.c1)//выделен один из столбцов и удаляем строки //else if(type == 'insRow' && activeRange.r1 == startCell.r1 && activeRange.r2 == endCell.r1 && activeRange.c1 >= startCell.c1 && activeRange.c2 <= endCell.c1)//выделен один из столбцов и удаляем строки
else if(type == 'insRow' && activeRange.r1 == splitRefFilter.r1 && activeRange.r2 == splitRefFilter.r2 && activeRange.c1 >= splitRefFilter.c1 && activeRange.c2 <= splitRefFilter.c2)//выделен один из столбцов и удаляем строки
{ {
isDelFilter = true; isDelFilter = true;
} }
else if(type != 'insRow' && activeRange.c1 == startCell.c1 && activeRange.c2 == endCell.c1 && activeRange.r1 >= startCell.r1 && activeRange.r2 <= endCell.r1)//выделена одина из строк и удаляем столбцы //else if(type != 'insRow' && activeRange.c1 == startCell.c1 && activeRange.c2 == endCell.c1 && activeRange.r1 >= startCell.r1 && activeRange.r2 <= endCell.r1)//выделена одина из строк и удаляем столбцы
else if(type != 'insRow' && activeRange.c1 == splitRefFilter.c1 && activeRange.c2 == splitRefFilter.c2 && activeRange.r1 >= splitRefFilter.r1 && activeRange.r2 <= splitRefFilter.r2)//выделена одина из строк и удаляем столбцы
{ {
isDelFilter = true; isDelFilter = true;
} }
if(isDelFilter) if(isDelFilter)
{ {
activeRange = /*activeRange =
{ {
r1: startCell.r1, r1: startCell.r1,
c1: startCell.c1, c1: startCell.c1,
r2: endCell.r1, r2: endCell.r1,
c2: endCell.c1 c2: endCell.c1
} }*/
activeRange = splitRefFilter;
this.isEmptyAutoFilters(activeRange, true, true, true); this.isEmptyAutoFilters(activeRange, true, true, true);
return true; return true;
} }
...@@ -4871,7 +5032,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -4871,7 +5032,7 @@ var gUndoInsDelCellsFlag = true;
cRange.end.c1 = 0; cRange.end.c1 = 0;
} }
filter.Ref = this._rangeToId(cRange.start) + ":" + this._rangeToId(cRange.end); filter.Ref = Asc.Range(cRange.start.c1, cRange.start.r1, cRange.end.c1, cRange.end.r1);
//change result into filter and change info in button //change result into filter and change info in button
if(filter.result && filter.result.length > 0) if(filter.result && filter.result.length > 0)
{ {
...@@ -4924,7 +5085,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -4924,7 +5085,7 @@ var gUndoInsDelCellsFlag = true;
curFilter.idNext = nextId; curFilter.idNext = nextId;
} }
} }
filter.Ref = this._rangeToId(cRange.start) + ":" + this._rangeToId(cRange.end); filter.Ref = Asc.Range(cRange.start.c1, cRange.start.r1, cRange.end.c1, cRange.end.r1);
} }
else//если добавляем колонку внутрь фильтра else//если добавляем колонку внутрь фильтра
{ {
...@@ -4934,254 +5095,11 @@ var gUndoInsDelCellsFlag = true; ...@@ -4934,254 +5095,11 @@ var gUndoInsDelCellsFlag = true;
else else
cRange.end.c1 = cRange.end.c1 + val; cRange.end.c1 = cRange.end.c1 + val;
//filter.Ref = this._rangeToId(cRange.start) + ":" + this._rangeToId(cRange.end); //filter.Ref = this._rangeToId(cRange.start) + ":" + this._rangeToId(cRange.end);
var inFilter = this._rangeToId(cRange.start) + ":" + this._rangeToId(cRange.end);
var cloneFilterColums = []; //change result into filter and change info in button
filter = this._changeInfoFilterAfterInsertCols(filter, type, col, cRange, val, filterColums, activeCells);
if(filterColums)
{
for(var k = 0; k < filterColums.length; k++)
{
cloneFilterColums[k] = filterColums[k].clone();
}
}
//change result into filter and change info in button
if(filter.result && filter.result.length > 0)
{
//change array
var changeNum = [];
var newResult = [];
var n = 0;
var isChangeColumn = false;
var insertIndexes = [];
for(var filR = 0; filR < filter.result.length; filR++)
{
var endCount = 0;
var curFilter = filter.result[filR];
var newFirstCol = this._idToRange(curFilter.id);
var newFirstColCell = newFirstCol.c1;
if(type == 'insRow')
newFirstColCell = newFirstCol.r1;
//добавляем колонку(колонки), вставляем новый фильтр
if(newFirstColCell == col)
{
for(var insCol = 1; insCol <= val; insCol++)
{
var localChangeCol = this._idToRange(curFilter.id);
var localNextCol = this._idToRange(curFilter.idNext);
if(type == 'insRow')
{
localChangeCol.r1 = localChangeCol.r1 + insCol - 1;
localNextCol.r1 = localNextCol.r1 + insCol - 1;
}
else
{
localChangeCol.c1 = localChangeCol.c1 + insCol - 1;
localNextCol.c1 = localNextCol.c1 + insCol - 1;
}
var id = this._rangeToId(localChangeCol);
var nextId = this._rangeToId(localNextCol);
newResult[n] = new Result();
newResult[n].x =curFilter.x;
newResult[n].y = curFilter.y;
newResult[n].width = curFilter.width;
newResult[n].height = curFilter.height;
newResult[n].id = id;
newResult[n].idNext = nextId;
newResult[n].hiddenRows = [];
var num = 1;
this._changeContentButton(newResult[n],num,'add',inFilter);
//changeNum[insCol - 1] = n;
n++;
}
if(val < 0)//удаляем кнопки в случае удаления ячеек
{
this._changeContentButton(curFilter,Math.abs(val),'del',inFilter);
//убираем примененный фильтр
if(filterColums)
{
for(var zF = filR; zF < filR + Math.abs(val); zF++)
{
for(var s = 0; s < cloneFilterColums.length; s++)
{
if(zF == cloneFilterColums[s].ColId)
cloneFilterColums.splice(s,1);
}
}
}
filR = filR + Math.abs(val) - 1;
}
else
{
var newNextCol = this._idToRange(curFilter.idNext);
if(type == 'insRow')
{
newFirstCol.r1 = newFirstCol.r1 + val;
newNextCol.r1 = newNextCol.r1 + val;
}
else
{
newFirstCol.c1 = newFirstCol.c1 + val;
newNextCol.c1 = newNextCol.c1 + val;
}
var id = this._rangeToId(newFirstCol);
var nextId = this._rangeToId(newNextCol);
curFilter.inFilter = inFilter;
curFilter.id = id;
curFilter.idNext = nextId;
newResult[n] = curFilter;
//смещаем примененный фильтр(у filter.FilterColumns просматриваем colId)
if(filterColums)
{
for(var s = 0; s < filterColums.length; s++)
{
if(filterColums[s].ColId == filR && filR > endCount)
{
cloneFilterColums[s].ColId = filR + val;
endCount = filR + val;
break;
}
}
}
n++;
}
}
else if(newFirstColCell < col)
{
if(type == 'insRow')
{
var newNextCol = this._idToRange(curFilter.idNext);
newNextCol.r1 = newNextCol.r1 + val;
var nextId = this._rangeToId(newNextCol);
curFilter.idNext = nextId;
}
curFilter.inFilter = inFilter;
newResult[n] = curFilter;
n++;
}
else
{
var newNextCol = this._idToRange(curFilter.idNext);
if(type == 'insRow')
{
newFirstCol.r1 = newFirstCol.r1 + val;
newNextCol.r1 = newNextCol.r1 + val;
}
else
{
newFirstCol.c1 = newFirstCol.c1 + val;
newNextCol.c1 = newNextCol.c1 + val;
}
var id = this._rangeToId(newFirstCol);
var nextId = this._rangeToId(newNextCol);
/*if(buttons && buttons.length)
{
for(var b = 0; b < buttons.length; b++)
{
if(buttons[b].id == curFilter.id && !insertIndexes[b])
{
buttons[b].inFilter = inFilter;
buttons[b].id = id;
buttons[b].idNext = nextId;
insertIndexes[b] = true;
break;
}
}
}*/
curFilter.inFilter = inFilter;
curFilter.id = id;
curFilter.idNext = nextId;
newResult[n] = curFilter;
//смещаем примененный фильтр(у filter.FilterColumns просматриваем colId)
if(filterColums)
{
for(var s = 0; s < filterColums.length; s++)
{
if(filterColums[s].ColId == filR && filR > endCount)
{
cloneFilterColums[s].ColId = filR + val;
endCount = filR + val;
break;
}
}
}
n++;
}
}
if(cloneFilterColums)
{
if(cRange.index == 'all')
{
filter.FilterColumns = cloneFilterColums;
filter.Ref = inFilter;
}
else
{
if(filter.AutoFilter)
filter.AutoFilter.FilterColumns = cloneFilterColums;
filter.AutoFilter.Ref = inFilter;
}
}
//change tableColumn
if(filter.TableColumns && type != 'insRow')
{
var newTableColumn = [];
var startCell = col - this._idToRange(inFilter.split(":")[0]).c1;
var isN = 0;
if(newResult.length < filter.TableColumns.length)
{
filter.TableColumns.splice(startCell,filter.TableColumns.length - newResult.length)
}
else
{
for(var l = 0; l < newResult.length; l++)
{
var columnValue = filter.TableColumns[isN].Name;
if(startCell == l)
{
for(var s = 0; s < val; s++)
{
var range2 = this._idToRange(newResult[0].id);
if(s != 0)
l = l + 1;
var tempArray = newTableColumn.concat(filter.TableColumns);
var newNameColumn = this._generateColumnName(tempArray, startCell - 1);
newTableColumn[l] = new TableColumn();
newTableColumn[l].Name = newNameColumn;
ws.model.getCell(new CellAddress(range2.r1,range2.c1 + l,0)).setValue(newNameColumn);
}
}
else
{
newTableColumn[l] = new TableColumn();
newTableColumn[l].Name = columnValue;
isN++;
}
}
filter.TableColumns = newTableColumn;
}
}
filter.result = newResult;
filter.Ref = inFilter;
if(val > 0)
this._addButtonAF(newResult);
}
//записываем в историю, если активная область касается данных фильтров //записываем в историю, если активная область касается данных фильтров
if(!bUndoChanges && !bRedoChanges && val < 0) if(!bUndoChanges && !bRedoChanges && val < 0)
{ {
...@@ -5195,10 +5113,277 @@ var gUndoInsDelCellsFlag = true; ...@@ -5195,10 +5113,277 @@ var gUndoInsDelCellsFlag = true;
this._addHistoryObj(changeElement, null, null, true); this._addHistoryObj(changeElement, null, null, true);
History.EndTransaction(); History.EndTransaction();
} }
} };
if(cRange.index == 'all')
{
aWs.AutoFilter = filter;
}
else
{
aWs.TableParts[cRange.index] = filter;
};
console.timeEnd("test");
}, },
_changeInfoFilterAfterInsertCols: function(filter, type, col, cRange, val, filterColums, activeCells)
{
var ws = this.worksheet;
var inFilter = Asc.Range(cRange.start.c1, cRange.start.r1, cRange.end.c1, cRange.end.r1);
var cloneFilterColums = [];
if(filterColums)
{
for(var k = 0; k < filterColums.length; k++)
{
cloneFilterColums[k] = filterColums[k].clone();
}
};
if(filter.result && filter.result.length > 0)
{
//change array
var changeNum = [];
var newResult = [];
var n = 0;
var isChangeColumn = false;
var insertIndexes = [];
for(var filR = 0; filR < filter.result.length; filR++)
{
var endCount = 0;
var curFilter = filter.result[filR];
var newFirstCol = this._idToRange(curFilter.id);
var newFirstColCell = newFirstCol.c1;
if(type == 'insRow')
newFirstColCell = newFirstCol.r1;
//добавляем колонку(колонки), вставляем новый фильтр
if(newFirstColCell == col)
{
for(var insCol = 1; insCol <= val; insCol++)
{
var localChangeCol = this._idToRange(curFilter.id);
var localNextCol = this._idToRange(curFilter.idNext);
if(type == 'insRow')
{
localChangeCol.r1 = localChangeCol.r1 + insCol - 1;
localNextCol.r1 = localNextCol.r1 + insCol - 1;
}
else
{
localChangeCol.c1 = localChangeCol.c1 + insCol - 1;
localNextCol.c1 = localNextCol.c1 + insCol - 1;
}
var id = this._rangeToId(localChangeCol);
var nextId = this._rangeToId(localNextCol);
newResult[n] = new Result();
newResult[n].x =curFilter.x;
newResult[n].y = curFilter.y;
newResult[n].width = curFilter.width;
newResult[n].height = curFilter.height;
newResult[n].id = id;
newResult[n].idNext = nextId;
newResult[n].hiddenRows = [];
var num = 1;
this._changeContentButton(newResult[n],num,'add',inFilter);
//changeNum[insCol - 1] = n;
n++;
}
if(val < 0)//удаляем кнопки в случае удаления ячеек
{
this._changeContentButton(curFilter,Math.abs(val),'del',inFilter);
//убираем примененный фильтр
if(filterColums)
{
for(var zF = filR; zF < filR + Math.abs(val); zF++)
{
for(var s = 0; s < cloneFilterColums.length; s++)
{
if(zF == cloneFilterColums[s].ColId)
cloneFilterColums.splice(s,1);
}
}
}
filR = filR + Math.abs(val) - 1;
}
else
{
var newNextCol = this._idToRange(curFilter.idNext);
if(type == 'insRow')
{
newFirstCol.r1 = newFirstCol.r1 + val;
newNextCol.r1 = newNextCol.r1 + val;
}
else
{
newFirstCol.c1 = newFirstCol.c1 + val;
newNextCol.c1 = newNextCol.c1 + val;
}
var id = this._rangeToId(newFirstCol);
var nextId = this._rangeToId(newNextCol);
curFilter.inFilter = inFilter;
curFilter.id = id;
curFilter.idNext = nextId;
newResult[n] = curFilter;
//смещаем примененный фильтр(у filter.FilterColumns просматриваем colId)
if(filterColums)
{
for(var s = 0; s < filterColums.length; s++)
{
if(filterColums[s].ColId == filR && filR > endCount)
{
cloneFilterColums[s].ColId = filR + val;
endCount = filR + val;
break;
}
}
}
n++;
}
}
else if(newFirstColCell < col)
{
if(type == 'insRow')
{
var newNextCol = this._idToRange(curFilter.idNext);
newNextCol.r1 = newNextCol.r1 + val;
var nextId = this._rangeToId(newNextCol);
curFilter.idNext = nextId;
}
curFilter.inFilter = inFilter;
newResult[n] = curFilter;
n++;
}
else
{
var newNextCol = this._idToRange(curFilter.idNext);
if(type == 'insRow')
{
newFirstCol.r1 = newFirstCol.r1 + val;
newNextCol.r1 = newNextCol.r1 + val;
}
else
{
newFirstCol.c1 = newFirstCol.c1 + val;
newNextCol.c1 = newNextCol.c1 + val;
}
var id = this._rangeToId(newFirstCol);
var nextId = this._rangeToId(newNextCol);
var oldId = curFilter.id;
curFilter.inFilter = inFilter;
curFilter.id = id;
curFilter.idNext = nextId;
newResult[n] = curFilter;
if(type == 'insCol')
this._changeContentButton(newResult[n], null,'change', null, oldId);
//смещаем примененный фильтр(у filter.FilterColumns просматриваем colId)
if(filterColums)
{
for(var s = 0; s < filterColums.length; s++)
{
if(filterColums[s].ColId == filR && filR > endCount)
{
cloneFilterColums[s].ColId = filR + val;
endCount = filR + val;
break;
}
}
}
n++;
}
};
if(type == 'insCol')
{
for(var n = 0; n < newResult.length; n++)
{
this._changeContentButton(newResult[n], 1, 'add', inFilter);
}
};
if(cloneFilterColums)
{
if(cRange.index == 'all')
{
filter.FilterColumns = cloneFilterColums;
filter.Ref = inFilter;
}
else
{
if(filter.AutoFilter)
filter.AutoFilter.FilterColumns = cloneFilterColums;
filter.AutoFilter.Ref = inFilter;
}
};
//change tableColumn
if(filter.TableColumns && type != 'insRow')
{
var newTableColumn = [];
var startCell = col - inFilter.c1;
var isN = 0;
if(newResult.length < filter.TableColumns.length)
{
filter.TableColumns.splice(startCell,filter.TableColumns.length - newResult.length)
}
else
{
for(var l = 0; l < newResult.length; l++)
{
if(startCell == l)
{
for(var s = 0; s < val; s++)
{
var range2 = this._idToRange(newResult[0].id);
if(s != 0)
l = l + 1;
var tempArray = newTableColumn.concat(filter.TableColumns);
var newNameColumn = this._generateColumnName(tempArray, startCell - 1);
newTableColumn[l] = new TableColumn();
newTableColumn[l].Name = newNameColumn;
ws.model.getCell(new CellAddress(range2.r1,range2.c1 + l,0)).setValue(newNameColumn);
}
}
else
{
var columnValue = filter.TableColumns[isN].Name;
newTableColumn[l] = new TableColumn();
newTableColumn[l].Name = columnValue;
isN++;
}
}
filter.TableColumns = newTableColumn;
}
};
filter.result = newResult;
filter.Ref = inFilter;
if(val > 0)
this._addButtonAF(newResult);
return filter;
};
},
_changeContentButton: function(array,val,type,inFilter) _changeContentButton: function(array, val, type, inFilter, oldId)
{ {
var ws = this.worksheet; var ws = this.worksheet;
var buttons = this.allButtonAF; var buttons = this.allButtonAF;
...@@ -5230,7 +5415,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -5230,7 +5415,7 @@ var gUndoInsDelCellsFlag = true;
buttons[buttons.length] = array; buttons[buttons.length] = array;
} }
} }
else else if(type == 'del')
{ {
for(var j = 0; j < val; j++) for(var j = 0; j < val; j++)
{ {
...@@ -5261,7 +5446,22 @@ var gUndoInsDelCellsFlag = true; ...@@ -5261,7 +5446,22 @@ var gUndoInsDelCellsFlag = true;
} }
} }
} }
} }
else if(type == 'change')
{
var isChange = false;
for(var j = 0; j < buttons.length; j++)
{
if(oldId == buttons[j].id)
{
buttons[j] = array;
isChange = true;
};
if(!isChange)
buttons[buttons.length] = array;
}
};
}, },
// ToDo - от _reDrawFilters в будущем стоит избавиться, ведь она проставляет стили ячейкам, а это не нужно делать (сменить отрисовку) // ToDo - от _reDrawFilters в будущем стоит избавиться, ведь она проставляет стили ячейкам, а это не нужно делать (сменить отрисовку)
...@@ -5275,8 +5475,11 @@ var gUndoInsDelCellsFlag = true; ...@@ -5275,8 +5475,11 @@ var gUndoInsDelCellsFlag = true;
{ {
for(var tP = 0; tP < aWs.TableParts.length; tP++) for(var tP = 0; tP < aWs.TableParts.length; tP++)
{ {
var ref = aWs.TableParts[tP].Ref.split(':'); //var ref = aWs.TableParts[tP].Ref.split(':');
this._setColorStyleTable(ref[0], ref[1], aWs.TableParts[tP])
var ref = aWs.TableParts[tP].Ref;
this._setColorStyleTable(ref, aWs.TableParts[tP])
} }
} }
if(!isNUpdate) if(!isNUpdate)
...@@ -5851,8 +6054,12 @@ var gUndoInsDelCellsFlag = true; ...@@ -5851,8 +6054,12 @@ var gUndoInsDelCellsFlag = true;
if(tableParts) if(tableParts)
{ {
var aWs = this._getCurrentWS(); var aWs = this._getCurrentWS();
var ref = tableParts.Ref.split(':');
this._setColorStyleTable(ref[0], ref[1], tableParts) //var ref = tableParts.Ref.split(':');
var ref = tableParts.Ref;
this._setColorStyleTable(ref, tableParts)
} }
}, },
...@@ -6126,10 +6333,14 @@ var gUndoInsDelCellsFlag = true; ...@@ -6126,10 +6333,14 @@ var gUndoInsDelCellsFlag = true;
for(var i = 0; i < aWs.TableParts.length; i++) for(var i = 0; i < aWs.TableParts.length; i++)
{ {
var filter = aWs.TableParts[i]; var filter = aWs.TableParts[i];
var ref = filter.Ref.split(":"); /*var ref = filter.Ref.split(":");
var startRange = this._idToRange(ref[0]); var startRange = this._idToRange(ref[0]);
var endRange = this._idToRange(ref[1]); var endRange = this._idToRange(ref[1]);
var tableRange = new Asc.Range(startRange.c1, startRange.r1, endRange.c2, startRange.r1); var tableRange = new Asc.Range(startRange.c1, startRange.r1, endRange.c2, startRange.r1);*/
var ref = filter.Ref;
var tableRange = new Asc.Range(ref.c1, ref.r1, ref.c2, ref.r1);
//в этом случае нашли ячейки(ячейку), которая входит в состав заголовка фильтра //в этом случае нашли ячейки(ячейку), которая входит в состав заголовка фильтра
var intersection = range.intersection(tableRange); var intersection = range.intersection(tableRange);
if(intersection != null) if(intersection != null)
...@@ -6137,7 +6348,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -6137,7 +6348,7 @@ var gUndoInsDelCellsFlag = true;
//проходимся по всем заголовкам //проходимся по всем заголовкам
for(var j = tableRange.c1; j <= tableRange.c2; j++) for(var j = tableRange.c1; j <= tableRange.c2; j++)
{ {
cell = ws.model.getCell(new CellAddress(startRange.r1, j, 0)) cell = ws.model.getCell(new CellAddress(ref.r1, j, 0))
val = cell.getValue(); val = cell.getValue();
//если не пустая изменяем TableColumns //если не пустая изменяем TableColumns
if(val != "" && intersection.c1 <= j && intersection.c2 >= j ) if(val != "" && intersection.c1 <= j && intersection.c2 >= j )
...@@ -6186,12 +6397,12 @@ var gUndoInsDelCellsFlag = true; ...@@ -6186,12 +6397,12 @@ var gUndoInsDelCellsFlag = true;
oCurFilter = []; oCurFilter = [];
oCurFilter[i] = findFilters[i].clone(aWs); oCurFilter[i] = findFilters[i].clone(aWs);
ref = findFilters[i].Ref; ref = findFilters[i].Ref;
range = this._refToRange(ref); range = ref;
newRange = Asc.Range(range.c1 + diffCol, range.r1 + diffRow, range.c2 + diffCol, range.r2 + diffRow); newRange = Asc.Range(range.c1 + diffCol, range.r1 + diffRow, range.c2 + diffCol, range.r2 + diffRow);
newRef = this._rangeToRef(newRange); //newRef = this._rangeToRef(newRange);
findFilters[i].Ref = newRef; findFilters[i].Ref = newRange;
if(findFilters[i].AutoFilter) if(findFilters[i].AutoFilter)
findFilters[i].AutoFilter.Ref = newRef; findFilters[i].AutoFilter.Ref = newRange;
if(!data && findFilters[i].AutoFilter && findFilters[i].AutoFilter.FilterColumns) if(!data && findFilters[i].AutoFilter && findFilters[i].AutoFilter.FilterColumns)
delete findFilters[i].AutoFilter.FilterColumns; delete findFilters[i].AutoFilter.FilterColumns;
...@@ -6210,7 +6421,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -6210,7 +6421,7 @@ var gUndoInsDelCellsFlag = true;
{ {
var id; var id;
var idNext; var idNext;
if(buttons[n].inFilter == ref && findFilters[i] && findFilters[i].result && findFilters[i].result.length) if(buttons[n].inFilter.isEqual(ref) && findFilters[i] && findFilters[i].result && findFilters[i].result.length)
{ {
for(var b = 0; b < findFilters[i].result.length; b++) for(var b = 0; b < findFilters[i].result.length; b++)
{ {
...@@ -6223,7 +6434,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -6223,7 +6434,7 @@ var gUndoInsDelCellsFlag = true;
break; break;
} }
} }
buttons[n].inFilter = newRef; buttons[n].inFilter = newRange;
buttons[n].id = id ? id : this._shiftId(buttons[n].id, diffCol, diffRow); buttons[n].id = id ? id : this._shiftId(buttons[n].id, diffCol, diffRow);
buttons[n].idNext = idNext ? idNext : this._shiftId(buttons[n].idNext, diffCol, diffRow); buttons[n].idNext = idNext ? idNext : this._shiftId(buttons[n].idNext, diffCol, diffRow);
} }
...@@ -6632,7 +6843,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -6632,7 +6843,7 @@ var gUndoInsDelCellsFlag = true;
//var range = this._getAscRange(range); //var range = this._getAscRange(range);
if(aWs.AutoFilter) if(aWs.AutoFilter)
{ {
rangeFilter = this._refToRange(aWs.AutoFilter.Ref); rangeFilter = aWs.AutoFilter.Ref;
if(range.c1 <= rangeFilter.c1 && range.r1 <= rangeFilter.r1 && range.c2 >= rangeFilter.c2 && range.r2 >= rangeFilter.r2) if(range.c1 <= rangeFilter.c1 && range.r1 <= rangeFilter.r1 && range.c2 >= rangeFilter.c2 && range.r2 >= rangeFilter.r2)
{ {
result[result.length] = aWs.AutoFilter result[result.length] = aWs.AutoFilter
...@@ -6644,7 +6855,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -6644,7 +6855,7 @@ var gUndoInsDelCellsFlag = true;
{ {
if(aWs.TableParts[k]) if(aWs.TableParts[k])
{ {
rangeFilter = this._refToRange(aWs.TableParts[k].Ref); rangeFilter = aWs.TableParts[k].Ref;
if(range.c1 <= rangeFilter.c1 && range.r1 <= rangeFilter.r1 && range.c2 >= rangeFilter.c2 && range.r2 >= rangeFilter.r2) if(range.c1 <= rangeFilter.c1 && range.r1 <= rangeFilter.r1 && range.c2 >= rangeFilter.c2 && range.r2 >= rangeFilter.r2)
{ {
result[result.length] = aWs.TableParts[k]; result[result.length] = aWs.TableParts[k];
......
...@@ -8061,7 +8061,7 @@ ...@@ -8061,7 +8061,7 @@
var diffCol; var diffCol;
for(var aF = 0; aF < aFilters.length; aF++) for(var aF = 0; aF < aFilters.length; aF++)
{ {
tablePartRange = t.autoFilters._refToRange(aFilters[aF].Ref); tablePartRange = aFilters[aF].Ref;
diffRow = tablePartRange.r1 - refInsertBinary.r1; diffRow = tablePartRange.r1 - refInsertBinary.r1;
diffCol = tablePartRange.c1 - refInsertBinary.c1; diffCol = tablePartRange.c1 - refInsertBinary.c1;
range = t.model.getRange3(diffRow + selectionRange.r1, diffCol + selectionRange.c1, diffRow + selectionRange.r1 + (tablePartRange.r2 - tablePartRange.r1), diffCol + selectionRange.c1 + (tablePartRange.c2 - tablePartRange.c1)); range = t.model.getRange3(diffRow + selectionRange.r1, diffCol + selectionRange.c1, diffRow + selectionRange.r1 + (tablePartRange.r2 - tablePartRange.r1), diffCol + selectionRange.c1 + (tablePartRange.c2 - tablePartRange.c1));
......
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