Commit 127c9e89 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

Ошибка: при сортировке мог появится дубликат ячейки на старом месте, откуда переносим.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@60525 954022d7-b5bf-4e40-9824-e11837661b57
parent a2130dcb
...@@ -2946,9 +2946,9 @@ ...@@ -2946,9 +2946,9 @@
this.memory.WriteByte(c_oSerRowTypes.Cells); this.memory.WriteByte(c_oSerRowTypes.Cells);
this.memory.WriteByte(c_oSerPropLenType.Variable); this.memory.WriteByte(c_oSerPropLenType.Variable);
this.bs.WriteItemWithLength(function(){oThis.WriteCells(oRow.c);}); this.bs.WriteItemWithLength(function(){oThis.WriteCells(oRow);});
}; };
this.WriteCells = function(aCells) this.WriteCells = function(row)
{ {
var oThis = this; var oThis = this;
var aIndexes = []; var aIndexes = [];
...@@ -2964,13 +2964,13 @@ ...@@ -2964,13 +2964,13 @@
} }
else else
{ {
for(var i in aCells) for(var i in row.c)
aIndexes.push(i - 0); aIndexes.push(i - 0);
} }
aIndexes.sort(fSortAscending); aIndexes.sort(fSortAscending);
for(var i = 0, length = aIndexes.length; i < length; ++i) for(var i = 0, length = aIndexes.length; i < length; ++i)
{ {
var cell = aCells[aIndexes[i]]; var cell = row.c[aIndexes[i]];
//готовим ячейку к записи //готовим ячейку к записи
if(!oThis.isCopyPaste || (oThis.isCopyPaste && cell)) if(!oThis.isCopyPaste || (oThis.isCopyPaste && cell))
{ {
...@@ -2982,7 +2982,7 @@ ...@@ -2982,7 +2982,7 @@
//сохраняем как и Excel даже пустой стиль(нужно чтобы убрать стиль строки/колонки) //сохраняем как и Excel даже пустой стиль(нужно чтобы убрать стиль строки/колонки)
if(null != cell.xfs || false == cell.isEmptyText()) if(null != cell.xfs || false == cell.isEmptyText())
this.bs.WriteItem(c_oSerRowTypes.Cell, function(){oThis.WriteCell(cell, nXfsId);}); this.bs.WriteItem(c_oSerRowTypes.Cell, function(){oThis.WriteCell(cell, nXfsId, row.index);});
} }
} }
}; };
...@@ -3109,12 +3109,12 @@ ...@@ -3109,12 +3109,12 @@
} }
return nXfsId; return nXfsId;
}; };
this.WriteCell = function(cell, nXfsId) this.WriteCell = function(cell, nXfsId, nRowIndex)
{ {
var oThis = this; var oThis = this;
if(cell.nRow >= 0 && cell.nCol >= 0) if(cell.nCol >= 0)
{ {
this.bs.WriteItem(c_oSerCellTypes.RefRowCol, function(){oThis.memory.WriteLong(cell.nRow);oThis.memory.WriteLong(cell.nCol);}); this.bs.WriteItem(c_oSerCellTypes.RefRowCol, function(){oThis.memory.WriteLong(nRowIndex);oThis.memory.WriteLong(cell.nCol);});
if(null != nXfsId) if(null != nXfsId)
{ {
...@@ -5601,18 +5601,29 @@ ...@@ -5601,18 +5601,29 @@
var oThis = this; var oThis = this;
if ( c_oSerWorksheetsTypes.Row == type ) if ( c_oSerWorksheetsTypes.Row == type )
{ {
var oCellOffset = {pos: null, len: null};
var oNewRow = new Row(ws); var oNewRow = new Row(ws);
res = this.bcr.Read2Spreadsheet(length, function(t,l){ res = this.bcr.Read2Spreadsheet(length, function(t,l){
return oThis.ReadRow(t,l, oNewRow, ws); return oThis.ReadRow(t,l, oNewRow, ws, oCellOffset);
}); });
if(null != oNewRow.index) if(oNewRow.index >= 0){
//читаем ячейки
if(null != oCellOffset.pos && null != oCellOffset.len){
var nOldPos = this.stream.GetCurPos();
this.stream.Seek2(oCellOffset.pos);
res = this.bcr.Read1(oCellOffset.len, function(t,l){
return oThis.ReadCells(t,l, ws, oNewRow);
});
this.stream.Seek2(nOldPos);
}
ws.aGCells[oNewRow.index] = oNewRow; ws.aGCells[oNewRow.index] = oNewRow;
}
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadRow = function(type, length, oRow, ws) this.ReadRow = function(type, length, oRow, ws, oCellOffset)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
...@@ -5648,15 +5659,16 @@ ...@@ -5648,15 +5659,16 @@
} }
else if ( c_oSerRowTypes.Cells == type ) else if ( c_oSerRowTypes.Cells == type )
{ {
res = this.bcr.Read1(length, function(t,l){ //запоминам место чтобы читать Cells в конце, когда уже зачитан oRow.index
return oThis.ReadCells(t,l, ws, oRow.c); oCellOffset.pos = this.stream.GetCurPos();
}); oCellOffset.len = length;
res = c_oSerConstants.ReadUnknown;
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadCells = function(type, length, ws, aCells) this.ReadCells = function(type, length, ws, row)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
...@@ -5664,7 +5676,7 @@ ...@@ -5664,7 +5676,7 @@
{ {
var oNewCell = new Cell(ws); var oNewCell = new Cell(ws);
res = this.bcr.Read1(length, function(t,l){ res = this.bcr.Read1(length, function(t,l){
return oThis.ReadCell(t,l, ws, oNewCell); return oThis.ReadCell(t,l, ws, oNewCell, row.index);
}); });
if(oNewCell.nRow >= 0 && oNewCell.nCol >= 0) if(oNewCell.nRow >= 0 && oNewCell.nCol >= 0)
{ {
...@@ -5682,24 +5694,25 @@ ...@@ -5682,24 +5694,25 @@
oNewCell.oValue.type = nType; oNewCell.oValue.type = nType;
} }
} }
aCells[nCellCol] = oNewCell; row.c[nCellCol] = oNewCell;
} }
} }
else else
res = c_oSerConstants.ReadUnknown; res = c_oSerConstants.ReadUnknown;
return res; return res;
}; };
this.ReadCell = function(type, length, ws, oCell) this.ReadCell = function(type, length, ws, oCell, nRowIndex)
{ {
var res = c_oSerConstants.ReadOk; var res = c_oSerConstants.ReadOk;
var oThis = this; var oThis = this;
if ( c_oSerCellTypes.Ref == type ){ if ( c_oSerCellTypes.Ref == type ){
var oCellAddress = g_oCellAddressUtils.getCellAddress(this.stream.GetString2LE(length)); var oCellAddress = g_oCellAddressUtils.getCellAddress(this.stream.GetString2LE(length));
oCell.nRow = oCellAddress.getRow0(); oCell.nRow = nRowIndex;
oCell.nCol = oCellAddress.getCol0(); oCell.nCol = oCellAddress.getCol0();
} }
else if ( c_oSerCellTypes.RefRowCol == type ){ else if ( c_oSerCellTypes.RefRowCol == type ){
oCell.nRow = this.stream.GetULongLE(); var nRow = this.stream.GetULongLE();//todo не используем можно убрать
oCell.nRow = nRowIndex;
oCell.nCol = this.stream.GetULongLE(); oCell.nCol = this.stream.GetULongLE();
} }
else if( c_oSerCellTypes.Style == type ) else if( c_oSerCellTypes.Style == type )
......
...@@ -7153,11 +7153,12 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){ ...@@ -7153,11 +7153,12 @@ Range.prototype._sortByArray=function(oBBox, aSortData, bUndo){
var rowTo = this.worksheet._getRow(nIndexTo); var rowTo = this.worksheet._getRow(nIndexTo);
var oCurCell; var oCurCell;
var oTempCell = oTempCellsTo[nIndexFrom];
if(oTempCellsTo.hasOwnProperty(nIndexFrom)) if(oTempCellsTo.hasOwnProperty(nIndexFrom))
oCurCell = oTempCell; oCurCell = oTempCellsTo[nIndexFrom];
else else{
oCurCell = rowFrom.c[i]; oCurCell = rowFrom.c[i];
delete rowFrom.c[i];
}
oTempCellsTo[nIndexTo] = rowTo.c[i]; oTempCellsTo[nIndexTo] = rowTo.c[i];
if(null != oCurCell) if(null != oCurCell)
{ {
......
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