Commit 620ef446 authored by Igor.Zotov's avatar Igor.Zotov Committed by Alexander.Trofimov

изменена функция addAutoFilter

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@58758 954022d7-b5bf-4e40-9824-e11837661b57
parent cbed86b2
...@@ -328,6 +328,9 @@ var gUndoInsDelCellsFlag = true; ...@@ -328,6 +328,9 @@ var gUndoInsDelCellsFlag = true;
if(rangeShift && rangeShift.r1 != undefined) if(rangeShift && rangeShift.r1 != undefined)
rangeShift = ws.model.getRange3(rangeShift.r1, rangeShift.c1, rangeShift.r1, rangeShift.c2); rangeShift = ws.model.getRange3(rangeShift.r1, rangeShift.c1, rangeShift.r1, rangeShift.c2);
var isUpdateRange = null;
var recalc = false;
if(paramsForCallBack)//меняем/удаляем/устанавливаем стиль для а/ф if(paramsForCallBack)//меняем/удаляем/устанавливаем стиль для а/ф
{ {
switch(paramsForCallBack) switch(paramsForCallBack)
...@@ -336,26 +339,16 @@ var gUndoInsDelCellsFlag = true; ...@@ -336,26 +339,16 @@ 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(':');
t._setColorStyleTable(splitRange[0], splitRange[1], filterChange);
startCell = t._idToRange(splitRange[0]);
endCell = t._idToRange(splitRange[1]);
rangeFilter = new Asc.Range(startCell.c1, startCell.r1, endCell.c1, endCell.r1);*/
rangeFilter = filterChange.Ref; rangeFilter = filterChange.Ref;
t._setColorStyleTable(rangeFilter, filterChange) t._setColorStyleTable(rangeFilter, filterChange)
if (bIsActiveSheet && !bIsOpenFilter) { isUpdateRange = rangeFilter;
// ToDo нужно обновлять не весь видимый диапазон, а только диапазон фильтра
ws._updateCellsRange(rangeFilter, /*canChangeColWidth*/ c_oAscCanChangeColWidth.none);
}
// Смена стиля // Смена стиля
t._addHistoryObj(cloneFilterOld, historyitem_AutoFilter_Add, t._addHistoryObj(cloneFilterOld, historyitem_AutoFilter_Add,
{activeCells: activeCells, lTable: lTable}); {activeCells: activeCells, lTable: lTable});
History.EndTransaction();
if(isTurnOffHistory)
History.TurnOn();
return true;
break; break;
} }
case 'deleteFilter': case 'deleteFilter':
...@@ -423,13 +416,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -423,13 +416,7 @@ var gUndoInsDelCellsFlag = true;
if(isInsert && bIsActiveSheet && !bIsOpenFilter) if(isInsert && bIsActiveSheet && !bIsOpenFilter)
{ {
ws.isChanged = true; ws.isChanged = true;
// ToDo - тоже стоит посмотреть, нужна ли общая перерисовка
ws.changeWorksheet("update");
} }
History.EndTransaction();
if(isTurnOffHistory)
History.TurnOn();
return true;
} }
break; break;
} }
...@@ -535,14 +522,13 @@ var gUndoInsDelCellsFlag = true; ...@@ -535,14 +522,13 @@ var gUndoInsDelCellsFlag = true;
arn.c2 = arn.c2 - 1; arn.c2 = arn.c2 - 1;
arn.r1 = arn.r1 - 1; arn.r1 = arn.r1 - 1;
arn.r2 = arn.r2 - 1; arn.r2 = arn.r2 - 1;
ws.setSelection(arn,true);
} }
ws._updateCellsRange(activeCells, /*canChangeColWidth*/ c_oAscCanChangeColWidth.none);
} }
History.EndTransaction();
if(isTurnOffHistory) isUpdateRange = activeCells;
History.TurnOn(); recalc = true;
return true;
break;
} }
case 'changeStyleWithoutFilter': case 'changeStyleWithoutFilter':
{ {
...@@ -559,13 +545,10 @@ var gUndoInsDelCellsFlag = true; ...@@ -559,13 +545,10 @@ var gUndoInsDelCellsFlag = true;
t._addHistoryObj(changesElemHistory, historyitem_AutoFilter_Add, t._addHistoryObj(changesElemHistory, historyitem_AutoFilter_Add,
{activeCells: activeCells, lTable: lTable}); {activeCells: activeCells, lTable: lTable});
if (bIsActiveSheet && !bIsOpenFilter) {
ws._updateCellsRange(rangeFilter, /*canChangeColWidth*/ c_oAscCanChangeColWidth.none); isUpdateRange = rangeFilter;
}
History.EndTransaction(); break;
if(isTurnOffHistory)
History.TurnOn();
return true;
} }
case 'setStyleTableForAutoFilter': case 'setStyleTableForAutoFilter':
{ {
...@@ -573,10 +556,7 @@ var gUndoInsDelCellsFlag = true; ...@@ -573,10 +556,7 @@ var gUndoInsDelCellsFlag = true;
var ref = allAutoFilters[apocal.num - 1].Ref; var ref = allAutoFilters[apocal.num - 1].Ref;
allAutoFilters[apocal.num - 1].AutoFilter = new AutoFilter(); allAutoFilters[apocal.num - 1].AutoFilter = new AutoFilter();
allAutoFilters[apocal.num - 1].AutoFilter.Ref = ref; allAutoFilters[apocal.num - 1].AutoFilter.Ref = ref;
/*allAutoFilters[apocal.num - 1].AutoFilter =
{
Ref: allAutoFilters[apocal.num - 1].Ref
};*/
break; break;
} }
case 'setStyleTableForAutoFilter1': case 'setStyleTableForAutoFilter1':
...@@ -600,23 +580,14 @@ var gUndoInsDelCellsFlag = true; ...@@ -600,23 +580,14 @@ var gUndoInsDelCellsFlag = true;
if(ref) if(ref)
{ {
/*splitRange = ref.split(':');
startCell = t._idToRange(splitRange[0]);
endCell = t._idToRange(splitRange[1]);
rangeFilter = new Asc.Range(startCell.c1, startCell.r1, endCell.c1, endCell.r1);*/
rangeFilter = ref; rangeFilter = ref;
} }
else else
rangeFilter = ws.visibleRange; rangeFilter = ws.visibleRange;
//обновляем
if(arn && bIsActiveSheet && !bIsOpenFilter) { isUpdateRange = rangeFilter;
ws._updateCellsRange(rangeFilter, /*canChangeColWidth*/ c_oAscCanChangeColWidth.none); recalc = true;
}
History.EndTransaction();
if(isTurnOffHistory)
History.TurnOn();
return true;
}; };
} }
else if(paramsForCallBackAdd)//добавляем а/ф else if(paramsForCallBackAdd)//добавляем а/ф
...@@ -670,82 +641,94 @@ var gUndoInsDelCellsFlag = true; ...@@ -670,82 +641,94 @@ var gUndoInsDelCellsFlag = true;
} }
}; };
//добавляем структуру нового фильтра
if(openFilter == undefined)
t._addNewFilter(result,tableColumns,aWs,isAll,lTable);
//устанавливаем стиль для таблицы if(paramsForCallBackAdd)
if(!isAll)
{ {
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))); if(openFilter == undefined)
var endCell = ws.model.getCell(new CellAddress((result[result.length -1].idNext))); t._addNewFilter(result,tableColumns,aWs,isAll,lTable);
var arn =
//устанавливаем стиль для таблицы
if(!isAll)
{ {
r1: firstCell.first.row, t._setColorStyleTable(aWs.TableParts[aWs.TableParts.length - 1].Ref, aWs.TableParts[aWs.TableParts.length - 1], null,true);
r2: endCell.first.row, var firstCell = ws.model.getCell(new CellAddress((result[0].id)));
c1: firstCell.first.col, var endCell = ws.model.getCell(new CellAddress((result[result.length -1].idNext)));
c2: endCell.first.col var arn =
} {
} r1: firstCell.first.row,
r2: endCell.first.row,
if(openFilter == undefined) { c1: firstCell.first.col,
if(isAll) { c2: endCell.first.col
if(!aWs.AutoFilter) }
aWs.AutoFilter = new AutoFilter();
aWs.AutoFilter.result = result;
aWs.AutoFilter.Ref = Asc.g_oRangeCache.getAscRange(result[0].id + ':' + result[result.length -1].idNext);
} }
};
newRes =
{
result: result,
isVis: true
};
var ref =
{
Ref: Asc.g_oRangeCache.getAscRange(result[0].id + ':' + result[result.length -1].idNext)
};
if(addNameColumn && addFormatTableOptionsObj)
addFormatTableOptionsObj.range = ref;
t._addHistoryObj(ref, historyitem_AutoFilter_Add,
{activeCells: activeCells, lTable: lTable, addFormatTableOptionsObj: addFormatTableOptionsObj});
if(isInsertButton){
if (bIsActiveSheet)
t._addButtonAF(newRes, bIsOpenFilter);
else
t._addButtonAF(newRes, true);
}
else if(!t.allButtonAF)
t.allButtonAF = [];
//обновляем if(openFilter == undefined) {
if(arn && bIsActiveSheet && !bIsOpenFilter) if(isAll) {
{ if(!aWs.AutoFilter)
if(openFilter == undefined) aWs.AutoFilter = new AutoFilter();
aWs.AutoFilter.result = result;
aWs.AutoFilter.Ref = Asc.g_oRangeCache.getAscRange(result[0].id + ':' + result[result.length -1].idNext);
}
};
newRes =
{
result: result,
isVis: true
};
var ref =
{ {
ws.isChanged = true; Ref: Asc.g_oRangeCache.getAscRange(result[0].id + ':' + result[result.length -1].idNext)
arn.c1 = arn.c1 - 1; };
arn.c2 = arn.c2 - 1;
arn.r1 = arn.r1 - 1; if(addNameColumn && addFormatTableOptionsObj)
arn.r2 = arn.r2 - 1; addFormatTableOptionsObj.range = ref;
ws.setSelection(arn,true); t._addHistoryObj(ref, historyitem_AutoFilter_Add,
{activeCells: activeCells, lTable: lTable, addFormatTableOptionsObj: addFormatTableOptionsObj});
if(isInsertButton){
if (bIsActiveSheet)
t._addButtonAF(newRes, bIsOpenFilter);
else
t._addButtonAF(newRes, true);
} }
// ToDo - и еще это обновление стоит после switch, в котором тоже происходит обновление - возможно будет 2 раза else if(!t.allButtonAF)
rangeFilter = new Asc.Range(arn.c1, arn.r1, arn.c2, arn.r2); t.allButtonAF = [];
ws._updateCellsRange(rangeFilter, /*canChangeColWidth*/ c_oAscCanChangeColWidth.none);
}; //обновляем
if(arn && bIsActiveSheet && !bIsOpenFilter)
if(paramsForCallBackAdd && !bIsOpenFilter && !aWs.workbook.bCollaborativeChanges && (paramsForCallBackAdd == "addTableFilterOneCell" || paramsForCallBackAdd == "addTableFilterManyCells")) {
ws._onEndAddFormatTable(rangeFilter); if(openFilter == undefined)
{
ws.isChanged = true;
arn.c1 = arn.c1 - 1;
arn.c2 = arn.c2 - 1;
arn.r1 = arn.r1 - 1;
arn.r2 = arn.r2 - 1;
}
// ToDo - и еще это обновление стоит после switch, в котором тоже происходит обновление - возможно будет 2 раза
rangeFilter = new Asc.Range(arn.c1, arn.r1, arn.c2, arn.r2);
};
if(paramsForCallBackAdd && !bIsOpenFilter && !aWs.workbook.bCollaborativeChanges && (paramsForCallBackAdd == "addTableFilterOneCell" || paramsForCallBackAdd == "addTableFilterManyCells"))
ws._onEndAddFormatTable(rangeFilter, true);
History.EndTransaction();
if(isTurnOffHistory)
History.TurnOn();
}
else
{
if(isUpdateRange != null)
ws._onEndAddFormatTable(isUpdateRange, recalc);
History.EndTransaction();
if(isTurnOffHistory)
History.TurnOn();
}
History.EndTransaction();
if(isTurnOffHistory)
History.TurnOn();
return true; return true;
} }
...@@ -2853,8 +2836,6 @@ var gUndoInsDelCellsFlag = true; ...@@ -2853,8 +2836,6 @@ var gUndoInsDelCellsFlag = true;
//var activeRange = ws.activeRange.clone(); //var activeRange = ws.activeRange.clone();
this._reDrawFilters(); this._reDrawFilters();
//ws.setSelection(activeRange);
}, },
_getAutoFilterArray: function(cell) { _getAutoFilterArray: function(cell) {
......
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