Commit 6baf9b7c authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

fix bug #26281

Сортировка комментариев теперь работает правильно

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@61126 954022d7-b5bf-4e40-9824-e11837661b57
parent 51c0fcd8
......@@ -775,36 +775,27 @@ CCellCommentator.prototype.updateCommentsDependencies = function(bInsert, operTy
updateCommentsList(aChangedComments);
};
CCellCommentator.prototype.sortComments = function(activeRange, changes) {
var t = this;
if (changes && activeRange) {
var updateCommentsList = function(aComments) {
if ( aComments.length ) {
History.StartTransaction();
for (var i = 0; i < aComments.length; i++) {
t.asc_changeComment(aComments[i].asc_getId(), aComments[i], true);
}
History.EndTransaction();
t.drawCommentCells();
}
};
CCellCommentator.prototype.sortComments = function(sortData) {
var comment, isChangeComment = false, places = sortData.places, i = 0, l = places.length, j, row, line;
var range = sortData.bbox, oComments = this.getRangeComments(new Asc.Range(range.c1, range.r1, range.c2, range.r2));
if (null === oComments)
return;
var aChangedComments = [];
for (var i = 0; i < changes.places.length; i++) {
History.StartTransaction();
var list = this.asc_getComments(activeRange.c1, changes.places[i].from);
for (var j = 0; j < list.length; j++) {
var comment = new asc_CCommentData(list[j]);
comment.nRow = changes.places[i].to;
aChangedComments.push(comment);
for (; i < l; ++i) {
if (oComments.hasOwnProperty((row = places[i].from))) {
for (j = 0, line = oComments[row]; j < line.length; ++j) {
comment = new asc_CCommentData(line[j]);
comment.nRow = places[i].to;
this.asc_changeComment(comment.asc_getId(), comment, true);
}
}
updateCommentsList(aChangedComments);
}
History.EndTransaction();
if (isChangeComment)
this.drawCommentCells();
};
CCellCommentator.prototype.resetLastSelectedId = function() {
......@@ -1301,6 +1292,25 @@ CCellCommentator.prototype.asc_getComments = function(col, row) {
return comments;
};
CCellCommentator.prototype.getRangeComments = function(range) {
var oComments = {};
if (!this.bShow)
return null;
var i, length, comment, bEmpty = true;
for (i = 0, length = this.aComments.length; i < length; ++i) {
comment = this.aComments[i];
if (range.contains(comment.nCol, comment.nRow)) {
bEmpty = false;
if (!oComments.hasOwnProperty(comment.nRow))
oComments[comment.nRow] = [];
oComments[comment.nRow].push(comment);
}
}
return bEmpty ? null : oComments;
};
CCellCommentator.prototype.asc_getDocumentComments = function() {
// Array of root items
......
......@@ -1509,7 +1509,6 @@ var gUndoInsDelCellsFlag = true;
var activeCells;
var newEndId;
var t = this;
var selectionRange;
var sortCol;
var onSortAutoFilterCallback = function(success)
......@@ -1534,10 +1533,7 @@ var gUndoInsDelCellsFlag = true;
currentFilter.SortState.SortConditions[0].Ref = cellId + ":" + newEndId;
currentFilter.SortState.SortConditions[0].ConditionDescending = type;
//сама сортировка
sortCol = curCell.c1;
var changes = sortRange.sort(type,sortCol);
ws.cellCommentator.sortComments(sortRange.bbox, changes);
ws.cellCommentator.sortComments(sortRange.sort(type, curCell.c1));
if(currentFilter.TableStyleInfo)
t._setColorStyleTable(currentFilter.Ref, currentFilter);
......@@ -1551,48 +1547,35 @@ var gUndoInsDelCellsFlag = true;
if(isTurnOffHistory)
History.TurnOn();
}
else
return false;
};
var standartSort = function(success)
{
if(success)
{
if(isTurnOffHistory)
var standartSort = function(success) {
if (success) {
if (isTurnOffHistory)
History.TurnOff();
History.Create_NewPoint();
History.StartTransaction();
var changes = sortRange.sort(type,sortCol);
ws.cellCommentator.sortComments(sortRange.bbox, changes);
if(currentFilter.TableStyleInfo)
ws.cellCommentator.sortComments(sortRange.sort(type, sortCol));
if (currentFilter.TableStyleInfo)
t._setColorStyleTable(currentFilter.Ref, currentFilter);
History.EndTransaction();
if(!aWs.workbook.bUndoChanges && !aWs.workbook.bRedoChanges)
if (!aWs.workbook.bUndoChanges && !aWs.workbook.bRedoChanges)
ws._onUpdateFormatTable(sortRange.bbox, false);
if(isTurnOffHistory)
if (isTurnOffHistory)
History.TurnOn();
}
else
{
return false;
}
};
if(type == 'ascending' || type == 'descending')
{
var activeRange = ar;
if(cellId)
activeRange = t._idToRange(cellId);
var filter = t._searchFilters(activeRange, null);
if(type == 'ascending')
type = true;
else
type = false;
type = (type === 'ascending');
if(filter && filter == "error")//если захвачена часть фильтра
{
return;
......@@ -1607,10 +1590,6 @@ var gUndoInsDelCellsFlag = true;
num = filter.num - 1;
var curFilter = allAutoFilters[num];
/*var splitRef = curFilter.Ref.split(":");
var startCellFilter = this._idToRange(splitRef[0]);
var endCellFilter = this._idToRange(splitRef[1]);*/
var splitRef = curFilter.Ref;
if(activeRange.r1 == activeRange.r2 && activeRange.c1 == activeRange.c2)//внутри фильтра одна выделенная ячейка
......@@ -1625,7 +1604,6 @@ var gUndoInsDelCellsFlag = true;
}
}
}
//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 = Asc.Range(splitRef.c1, splitRef.r1, splitRef.c1, splitRef.r1);
......@@ -1639,17 +1617,14 @@ var gUndoInsDelCellsFlag = true;
cellId = Asc.Range(activeRange.startCol, splitRef.r1, activeRange.startCol, splitRef.r1);
}
else if(splitRef.r1 == activeRange.r1)//захват в выделенную область части заголовка - сортируем выделенную область, за исключением заголовка
//else if(startCellFilter.r1 == activeRange.r1)//захват в выделенную область части заголовка - сортируем выделенную область, за исключением заголовка
{
sortCol = activeRange.c1;
sortRange = ws.model.getRange3(activeRange.r1 + 1, activeRange.c1, activeRange.r2, activeRange.c2);
selectionRange = activeRange;
var sortRange1 = t._getAscRange(sortRange.bbox);
currentFilter = curFilter;
if(isTurnOffHistory)
standartSort(true);
else
ws._isLockedCells (sortRange1, /*subType*/null, standartSort);
ws._isLockedCells(t._getAscRange(sortRange.bbox), /*subType*/null, standartSort);
return;
}
else
......@@ -1683,34 +1658,18 @@ var gUndoInsDelCellsFlag = true;
}
oldFilter = currentFilter.clone(aWs);
/*var rangeCell = currentFilter.Ref.split(':');
var startCell = t._idToRange(rangeCell[0]);
var endCell = t._idToRange(rangeCell[1]);*/
var rangeCell = currentFilter.Ref;
curCell = t._idToRange(cellId);
//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);
//startCell.r1 = startCell.r1 + 1;
//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);
if(isTurnOffHistory)
onSortAutoFilterCallback(true);
else
ws._isLockedCells (sortRange1, /*subType*/null, onSortAutoFilterCallback);
ws._isLockedCells (t._getAscRange(sortRange.bbox), /*subType*/null, onSortAutoFilterCallback);
},
isEmptyAutoFilters: function(ar, turnOnHistory, insCells, deleteFilterAfterDeleteColRow, exceptionArray, doNotChangeFilters)
......
......@@ -159,11 +159,6 @@
function Range(c1, r1, c2, r2, normalize) {
if ( !(this instanceof Range) ) {return new Range(c1, r1, c2, r2, normalize);}
// if (typeOf(c1) !== kNumberL || typeOf(c2) !== kNumberL ||
// typeOf(r1) !== kNumberL || typeOf(r2) !== kNumberL) {
// throw "Error: Range("+c1+","+r1+","+c2+","+r2+") - numerical args are expected";
// }
/** @type Number */
this.c1 = c1;
/** @type Number */
......
......@@ -8034,8 +8034,7 @@
case "sort":
if (isLargeRange) { callTrigger = true; t.handlers.trigger("slowOperation", true); }
var changes = range.sort(val, arn.startCol);
t.cellCommentator.sortComments(arn, changes);
t.cellCommentator.sortComments(range.sort(val, arn.startCol));
break;
case "empty":
......
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