Commit 46b48509 authored by konovalovsergey's avatar konovalovsergey

errors SheetMemory.insertRange,copyRangeByChunk

parent 544ff7de
...@@ -2500,12 +2500,14 @@ ...@@ -2500,12 +2500,14 @@
} }
}; };
SheetMemory.prototype.insertRange = function(start, insertCount) { SheetMemory.prototype.insertRange = function(start, insertCount) {
this.checkSize(this.count + insertCount); if (start < this.count) {
var startOffset = start * this.structSize; this.checkSize(this.count + insertCount);
var endOffset = (start + insertCount) * this.structSize; var startOffset = start * this.structSize;
var endData = (this.count - insertCount) * this.structSize; var endOffset = (start + insertCount) * this.structSize;
this.data.set(this.data.subarray(startOffset, endData), endOffset); var endData = (this.count - insertCount) * this.structSize;
this.data.fill(0, startOffset, endOffset); this.data.set(this.data.subarray(startOffset, endData), endOffset);
this.data.fill(0, startOffset, endOffset);
}
}; };
SheetMemory.prototype.copyRange = function(sheetMemory, startFrom, startTo, count) { SheetMemory.prototype.copyRange = function(sheetMemory, startFrom, startTo, count) {
sheetMemory.checkSize(startFrom + count); sheetMemory.checkSize(startFrom + count);
...@@ -2517,11 +2519,14 @@ ...@@ -2517,11 +2519,14 @@
this.data.set(sheetMemory.data.subarray(startOffsetFrom, endOffsetFrom), startOffsetTo); this.data.set(sheetMemory.data.subarray(startOffsetFrom, endOffsetFrom), startOffsetTo);
}; };
SheetMemory.prototype.copyRangeByChunk = function(from, fromCount, to, toCount) { SheetMemory.prototype.copyRangeByChunk = function(from, fromCount, to, toCount) {
var fromStartOffset = from * this.structSize; if (from < this.count) {
var fromEndOffset = (from + fromCount) * this.structSize; this.checkSize(to + toCount);
var fromSubArray = this.data.subarray(fromStartOffset, fromEndOffset); var fromStartOffset = from * this.structSize;
for (var i = to; i < to + toCount; i += fromCount) { var fromEndOffset = Math.min((from + fromCount), this.count) * this.structSize;
this.data.set(fromSubArray, i * this.structSize); var fromSubArray = this.data.subarray(fromStartOffset, fromEndOffset);
for (var i = to; i < to + toCount; i += fromCount) {
this.data.set(fromSubArray, i * this.structSize);
}
} }
}; };
SheetMemory.prototype.fill = function(value, start, end) { SheetMemory.prototype.fill = function(value, start, end) {
...@@ -4407,7 +4412,7 @@ ...@@ -4407,7 +4412,7 @@
} else { } else {
toData = oThis.getColDataNoEmpty(to); toData = oThis.getColDataNoEmpty(to);
if(toData) { if(toData) {
toData.copyRange(fromData, r1From, r1To, count); toData.fill(0, r1To, r1To + count);
} }
} }
}; };
......
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