Commit 7f5aea56 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@64870 954022d7-b5bf-4e40-9824-e11837661b57
parent db5f9bcb
...@@ -730,9 +730,9 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS"; ...@@ -730,9 +730,9 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
ws.applyAutoFilter(type, autoFilterObject); ws.applyAutoFilter(type, autoFilterObject);
}; };
spreadsheet_api.prototype.asc_sortColFilter = function(type, cellId) { spreadsheet_api.prototype.asc_sortColFilter = function(type, cellId, displayName) {
var ws = this.wb.getWorksheet(); var ws = this.wb.getWorksheet();
ws.sortColFilter(type, cellId); ws.sortColFilter(type, cellId, displayName);
}; };
spreadsheet_api.prototype.asc_getAddFormatTableOptions = function() { spreadsheet_api.prototype.asc_getAddFormatTableOptions = function() {
......
...@@ -168,7 +168,8 @@ var maxIndividualValues = 10000; ...@@ -168,7 +168,8 @@ var maxIndividualValues = 10000;
asc_getValues : function() { return this.values; }, asc_getValues : function() { return this.values; },
asc_getFilterObj : function() { return this.filter; }, asc_getFilterObj : function() { return this.filter; },
asc_getSortState : function() { return this.sortVal; } asc_getSortState : function() { return this.sortVal; },
asc_getDisplayName : function(val) { return this.displayName; },
}; };
var g_oAutoFilterObj = { var g_oAutoFilterObj = {
...@@ -1084,6 +1085,22 @@ var maxIndividualValues = 10000; ...@@ -1084,6 +1085,22 @@ var maxIndividualValues = 10000;
} }
} }
} }
else if(type === historyitem_AutoFilter_Sort && cloneData.oldFilter)//сортировка
{
if(aWs.AutoFilter && cloneData.oldFilter.getType() === g_nFiltersType.autoFilter)
aWs.AutoFilter = cloneData.oldFilter.clone(null);
else if(aWs.TableParts)
{
for(var l = 0; l < aWs.TableParts.length; l++)
{
if(cloneData.oldFilter.DisplayName === aWs.TableParts[l].DisplayName)
{
aWs.TableParts[l] = cloneData.oldFilter.clone(null);
break;
}
}
}
}
else if(cloneData.FilterColumns || cloneData.AutoFilter || cloneData.TableColumns || (cloneData.Ref && (cloneData instanceof AutoFilter || cloneData instanceof TablePart)))//add else if(cloneData.FilterColumns || cloneData.AutoFilter || cloneData.TableColumns || (cloneData.Ref && (cloneData instanceof AutoFilter || cloneData instanceof TablePart)))//add
{ {
if(cloneData.Ref) if(cloneData.Ref)
...@@ -1559,13 +1576,13 @@ var maxIndividualValues = 10000; ...@@ -1559,13 +1576,13 @@ var maxIndividualValues = 10000;
History.EndTransaction(); History.EndTransaction();
}, },
sortColFilter: function(type, cellId, activeRange, isTurnOffHistory) { sortColFilter: function(type, cellId, activeRange, isTurnOffHistory, displayName) {
var aWs = this._getCurrentWS(); var aWs = this._getCurrentWS();
var ws = this.worksheet; var ws = this.worksheet;
var t = this; var t = this;
var bUndoChanges = aWs.workbook.bUndoChanges; var bUndoChanges = aWs.workbook.bUndoChanges;
var bRedoChanges = aWs.workbook.bRedoChanges; var bRedoChanges = aWs.workbook.bRedoChanges;
var curFilter, sortRange, filterRef, startCol; var curFilter, sortRange, filterRef, startCol, maxFilterRow;
var onSortAutoFilterCallback = function(success) var onSortAutoFilterCallback = function(success)
{ {
...@@ -1582,7 +1599,7 @@ var maxIndividualValues = 10000; ...@@ -1582,7 +1599,7 @@ var maxIndividualValues = 10000;
if(!curFilter.SortState) if(!curFilter.SortState)
{ {
curFilter.SortState = new SortState(); curFilter.SortState = new SortState();
curFilter.SortState.Ref = curFilter.Ref; curFilter.SortState.Ref = new Asc.Range(startCol, curFilter.Ref.r1, startCol, maxFilterRow);
curFilter.SortState.SortConditions = []; curFilter.SortState.SortConditions = [];
curFilter.SortState.SortConditions[0] = new SortCondition(); curFilter.SortState.SortConditions[0] = new SortCondition();
} }
...@@ -1594,7 +1611,7 @@ var maxIndividualValues = 10000; ...@@ -1594,7 +1611,7 @@ var maxIndividualValues = 10000;
curFilter.SortState.SortConditions[0].Ref = new Asc.Range(startCol, filterRef.r1, startCol, filterRef.r2); curFilter.SortState.SortConditions[0].Ref = new Asc.Range(startCol, filterRef.r1, startCol, filterRef.r2);
curFilter.SortState.SortConditions[0].ConditionDescending = resType; curFilter.SortState.SortConditions[0].ConditionDescending = resType;
cellId = t._rangeToId(cellIdRange); //cellId = t._rangeToId(cellIdRange);
//сама сортировка //сама сортировка
if(!bRedoChanges && !bUndoChanges) if(!bRedoChanges && !bUndoChanges)
...@@ -1614,48 +1631,76 @@ var maxIndividualValues = 10000; ...@@ -1614,48 +1631,76 @@ var maxIndividualValues = 10000;
} }
}; };
if(cellId) //if(cellId)
activeRange = t._idToRange(cellId); //activeRange = t._idToRange(cellId);
var resType = type == 'ascending'; var resType = type == 'ascending';
if(displayName !== undefined)
{
curFilter = this._getFilterByDisplayName(displayName);
filterRef = curFilter.Ref;
var filter = t.searchRangeInTableParts(activeRange); if(cellId !== '')
if(filter === -2)//если захвачена часть ф/т startCol = filterRef.c1 + cellId;
return; else
startCol = activeRange.startCol;
if(filter === -1)//если нет ф/т в выделенном диапазоне }
else
{ {
if(aWs.AutoFilter && aWs.AutoFilter.Ref) var filter = t.searchRangeInTableParts(activeRange);
if(filter === -2)//если захвачена часть ф/т
return;
if(filter === -1)//если нет ф/т в выделенном диапазоне
{ {
curFilter = aWs.AutoFilter; if(aWs.AutoFilter && aWs.AutoFilter.Ref)
filterRef = curFilter.Ref; {
curFilter = aWs.AutoFilter;
filterRef = curFilter.Ref;
}
//в данному случае может быть захвачен а/ф, если он присутвует(надо проверить), либо нажата кнопка а/ф
if(curFilter && (filterRef.isEqual(activeRange) || cellId !== ''))
{
if(cellId !== '')
startCol = filterRef.c1 + cellId;
else
startCol = activeRange.startCol;
if(startCol === undefined)
startCol = activeRange.c1;
}
else//внутри а/ф либо без а/ф либо часть а/ф
{
ws.setSelectionInfo("sort", resType);
return;
}
} }
else
//в данному случае может быть захвачен а/ф, если он присутвует(надо проверить), либо нажата кнопка а/ф
if(curFilter && (filterRef.isEqual(activeRange) || cellId))
{ {
//получаем данную ф/т
curFilter = aWs.TableParts[filter];
filterRef = curFilter.Ref;
startCol = activeRange.startCol; startCol = activeRange.startCol;
if(startCol === undefined) if(startCol === undefined)
startCol = activeRange.c1; startCol = activeRange.c1;
} }
else//внутри а/ф либо без а/ф либо часть а/ф
{
ws.setSelectionInfo("sort", resType);
return;
}
} }
else
maxFilterRow = filterRef.r2;
if(curFilter.getType() === g_nFiltersType.autoFilter && curFilter.isApplyAutoFilter() === false)//нужно подхватить нижние ячейки в случае, если это не применен а/ф
{ {
//получаем данную ф/т var automaticRange = this._getAdjacentCellsAF(curFilter.Ref, aWs, true);
curFilter = aWs.TableParts[filter]; var automaticRowCount = automaticRange.r2;
filterRef = curFilter.Ref;
startCol = activeRange.startCol; if(automaticRowCount > maxFilterRow)
if(startCol === undefined) maxFilterRow = automaticRowCount;
startCol = activeRange.c1;
} }
sortRange = aWs.getRange3(filterRef.r1 + 1, filterRef.c1, filterRef.r2, filterRef.c2); sortRange = aWs.getRange3(filterRef.r1 + 1, filterRef.c1, maxFilterRow, filterRef.c2);
if(isTurnOffHistory) if(isTurnOffHistory)
onSortAutoFilterCallback(true); onSortAutoFilterCallback(true);
else else
...@@ -4733,6 +4778,7 @@ var maxIndividualValues = 10000; ...@@ -4733,6 +4778,7 @@ var maxIndividualValues = 10000;
prot["asc_getValues"] = prot.asc_getValues; prot["asc_getValues"] = prot.asc_getValues;
prot["asc_getFilterObj"] = prot.asc_getFilterObj; prot["asc_getFilterObj"] = prot.asc_getFilterObj;
prot["asc_getCellId"] = prot.asc_getCellId; prot["asc_getCellId"] = prot.asc_getCellId;
prot["asc_getDisplayName"] = prot.asc_getDisplayName;
window["Asc"]["AutoFilterObj"] = window["Asc"].AutoFilterObj = AutoFilterObj; window["Asc"]["AutoFilterObj"] = window["Asc"].AutoFilterObj = AutoFilterObj;
prot = AutoFilterObj.prototype; prot = AutoFilterObj.prototype;
......
...@@ -10777,14 +10777,14 @@ ...@@ -10777,14 +10777,14 @@
this._isLockedAll(onChangeAutoFilterCallback); this._isLockedAll(onChangeAutoFilterCallback);
}; };
WorksheetView.prototype.sortColFilter = function (type,cellId) { WorksheetView.prototype.sortColFilter = function (type, cellId, displayName) {
var t = this; var t = this;
var ar = this.activeRange.clone(true); var ar = this.activeRange.clone(true);
var onChangeAutoFilterCallback = function (isSuccess) { var onChangeAutoFilterCallback = function (isSuccess) {
if (false === isSuccess) if (false === isSuccess)
return; return;
t.autoFilters.sortColFilter(type, cellId, ar); t.autoFilters.sortColFilter(type, cellId, ar, null, displayName);
}; };
this._isLockedAll(onChangeAutoFilterCallback); this._isLockedAll(onChangeAutoFilterCallback);
}; };
......
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