Commit 388b3d65 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Поправил баг http://bugzserver/show_bug.cgi?id=24151

На scroll передаем offset-ы в отрисовку графических объектов. Перерисовываем сразу.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@56999 954022d7-b5bf-4e40-9824-e11837661b57
parent 4258ae01
......@@ -2594,100 +2594,95 @@ function CChangeTableData(changedRange, added, hided, removed)
this.removed = removed;
}
function GraphicOption(ws, type, range, aId) {
var _this = this;
var asc = window["Asc"];
var asc_Range = asc.Range;
_this.ws = ws;
_this.type = type;
_this.range = range;
_this.aId = [];
if ( aId && Array.isArray(aId) )
_this.aId = aId.concat();
function checkCol(col) {
while ( (col > 0) && !_this.ws.cols[col] )
_this.ws.expandColsOnScroll(true);
}
function checkRow(row) {
while ( (row > 0) && !_this.ws.rows[row] )
_this.ws.expandRowsOnScroll(true);
}
function GraphicOption(ws, type, range, aId, offset) {
this.ws = ws;
this.type = type;
this.range = range;
this.aId = [];
if (aId && Array.isArray(aId))
this.aId = aId.concat();
this.offset = offset;
}
GraphicOption.prototype.checkCol = function (col) {
while ((col > 0) && !this.ws.cols[col])
this.ws.expandColsOnScroll(true);
};
_this.isScrollType = function() {
return ( (_this.type === c_oAscGraphicOption.ScrollVertical) || (_this.type === c_oAscGraphicOption.ScrollHorizontal) );
};
GraphicOption.prototype.checkRow = function (row) {
while ((row > 0) && !this.ws.rows[row])
this.ws.expandRowsOnScroll(true);
};
_this.getUpdatedRange = function() {
GraphicOption.prototype.isScrollType = function() {
return ((this.type === c_oAscGraphicOption.ScrollVertical) || (this.type === c_oAscGraphicOption.ScrollHorizontal));
};
var vr = new asc_Range(_this.ws.getFirstVisibleCol(true), _this.ws.getFirstVisibleRow(true), _this.ws.visibleRange.c2, _this.ws.visibleRange.r2);
GraphicOption.prototype.getUpdatedRange = function() {
//var vr = _this.ws.visibleRange.clone();
if ( _this.isScrollType() && !range )
return vr;
var vr = new Asc.Range(this.ws.getFirstVisibleCol(true), this.ws.getFirstVisibleRow(true), this.ws.visibleRange.c2, this.ws.visibleRange.r2);
switch (_this.type) {
case c_oAscGraphicOption.ScrollVertical:
case c_oAscGraphicOption.ScrollHorizontal: {
vr = range.clone();
checkCol(++vr.c2);
checkRow(++vr.r2);
}
break;
//var vr = _this.ws.visibleRange.clone();
if ( this.isScrollType() && !this.range )
return vr;
case c_oAscGraphicOption.AddText: {
if ( _this.ws ) {
var controller = _this.ws.objectRender.controller;
var selectedObjects = controller.selectedObjects;
if ( selectedObjects.length === 1 ) {
if ( selectedObjects[0].isGroup() ) {
var groupSelectedObjects = selectedObjects[0].selectedObjects;
if ( groupSelectedObjects.length === 1 ) {
var checker = _this.ws.objectRender.getBoundsChecker(groupSelectedObjects[0]);
var coords = _this.ws.objectRender.getBoundsCheckerCoords(checker);
if ( coords ) {
vr.c1 = Math.max(coords.from.col, vr.c1);
vr.r1 = Math.max(coords.from.row, vr.r1);
checkCol(coords.to.col + 1);
vr.c2 = Math.min(coords.to.col + 1, vr.c2);
checkRow(coords.to.row + 1);
vr.r2 = Math.min(coords.to.row + 1, vr.r2);
}
}
}
else {
var drawingObject = selectedObjects[0].drawingBase;
var checker = _this.ws.objectRender.getBoundsChecker(drawingObject.graphicObject);
var coords = _this.ws.objectRender.getBoundsCheckerCoords(checker);
if ( coords ) {
vr.c1 = Math.max(coords.from.col, vr.c1);
vr.r1 = Math.max(coords.from.row, vr.r1);
checkCol(coords.to.col + 1);
vr.c2 = Math.min(coords.to.col + 1, vr.c2);
checkRow(coords.to.row + 1);
vr.r2 = Math.min(coords.to.row + 1, vr.r2);
}
}
}
}
}
break;
}
return vr;
}
}
function Exception(error) {
var err = error;
}
switch (this.type) {
case c_oAscGraphicOption.ScrollVertical:
case c_oAscGraphicOption.ScrollHorizontal: {
vr = range.clone();
this.checkCol(++vr.c2);
this.checkRow(++vr.r2);
}
break;
case c_oAscGraphicOption.AddText: {
if ( this.ws ) {
var controller = this.ws.objectRender.controller;
var selectedObjects = controller.selectedObjects;
if ( selectedObjects.length === 1 ) {
if ( selectedObjects[0].isGroup() ) {
var groupSelectedObjects = selectedObjects[0].selectedObjects;
if ( groupSelectedObjects.length === 1 ) {
var checker = this.ws.objectRender.getBoundsChecker(groupSelectedObjects[0]);
var coords = this.ws.objectRender.getBoundsCheckerCoords(checker);
if ( coords ) {
vr.c1 = Math.max(coords.from.col, vr.c1);
vr.r1 = Math.max(coords.from.row, vr.r1);
this.checkCol(coords.to.col + 1);
vr.c2 = Math.min(coords.to.col + 1, vr.c2);
this.checkRow(coords.to.row + 1);
vr.r2 = Math.min(coords.to.row + 1, vr.r2);
}
}
}
else {
var drawingObject = selectedObjects[0].drawingBase;
var checker = this.ws.objectRender.getBoundsChecker(drawingObject.graphicObject);
var coords = this.ws.objectRender.getBoundsCheckerCoords(checker);
if ( coords ) {
vr.c1 = Math.max(coords.from.col, vr.c1);
vr.r1 = Math.max(coords.from.row, vr.r1);
this.checkCol(coords.to.col + 1);
vr.c2 = Math.min(coords.to.col + 1, vr.c2);
this.checkRow(coords.to.row + 1);
vr.r2 = Math.min(coords.to.row + 1, vr.r2);
}
}
}
}
}
break;
}
return vr;
};
GraphicOption.prototype.getOffset = function () {
return this.offset;
};
function DrawingObjects() {
......@@ -3523,6 +3518,7 @@ function DrawingObjects() {
var lastTask = aDrawTasks[aDrawTasks.length - 1];
// ToDo не всегда грамотно так делать, т.к. в одном scroll я могу прислать 2 области (и их объединять не нужно)
if ( lastTask.params.graphicOption && lastTask.params.graphicOption.isScrollType() && graphicOption && (lastTask.params.graphicOption.type === graphicOption.type) ) {
lastTask.params.graphicOption.range.c1 = Math.min(lastTask.params.graphicOption.range.c1, graphicOption.range.c1);
lastTask.params.graphicOption.range.r1 = Math.min(lastTask.params.graphicOption.range.r1, graphicOption.range.r1);
......@@ -3560,10 +3556,7 @@ function DrawingObjects() {
var updatedRect = { x: 0, y: 0, w: 0, h: 0 };
var updatedRange = graphicOption.getUpdatedRange();
// var offsetX = worksheet.cols[worksheet.getFirstVisibleCol(true)].left - worksheet.cellsLeft;
// var offsetY = worksheet.rows[worksheet.getFirstVisibleRow(true)].top - worksheet.cellsTop;
var x1 = worksheet.getCellLeft(updatedRange.c1, 1);// - offsetX;
var x1 = worksheet.getCellLeft(updatedRange.c1, 1);// - offsetX;
var y1 = worksheet.getCellTop(updatedRange.r1, 1) ;//- offsetY;
var x2 = worksheet.getCellLeft(updatedRange.c2, 1);// - offsetX;
var y2 = worksheet.getCellTop(updatedRange.r2, 1);//- offsetY;
......@@ -3576,17 +3569,10 @@ function DrawingObjects() {
updatedRect.w = ptToMm(w);
updatedRect.h = ptToMm(h);
var offsetX = worksheet.getCellLeft(worksheet.getFirstVisibleCol(true), 1);
var offsetY = worksheet.getCellTop(worksheet.getFirstVisibleRow(true), 1);
var offsetScroll = graphicOption.getOffset();
shapeCtx.m_oContext.save();
shapeCtx.m_oContext.beginPath();
shapeCtx.m_oContext.rect(ptToPx(offset.left + x1 - offsetX), ptToPx(offset.top + y1 - offsetY), ptToPx(w), ptToPx(h));
shapeCtx.m_oContext.clip();
//coords.y = worksheet.getCellTop(cell.row, 0) + worksheet.objectRender.convertMetric(cell.rowOff, 3, 0) - worksheet.getCellTop(0, 0);
//coords.x = worksheet.getCellLeft(cell.col, 0) + worksheet.objectRender.convertMetric(cell.colOff, 3, 0) - worksheet.getCellLeft(0, 0);
shapeCtx.m_oContext.rect(ptToPx(x1 - offsetScroll.offsetX), ptToPx(y1 - offsetScroll.offsetY), ptToPx(w), ptToPx(h));
shapeCtx.updatedRect = updatedRect;
} else
......
......@@ -5269,6 +5269,9 @@
.fillRect(this.headersLeft, y + (scrollDown ? oldH - dy - lastRowHeight : 0),
ctxW, Math.abs(dy) + lastRowHeight);
if(this.objectRender && this.objectRender.drawingArea)
this.objectRender.drawingArea.reinitRanges();
if ( !(dy > 0 && vr.r2 === oldEnd && !oldVRE_isPartial && dx === 0) ) {
var c1 = vr.c1;
var r1 = scrollDown ? oldEnd + (oldVRE_isPartial ? 0 : 1) : vr.r1;
......@@ -5300,7 +5303,8 @@
this._drawCells(/*drawingCtx*/undefined, range);
this._drawCellsBorders(/*drawingCtx*/undefined, range);
this._drawAutoF(range, offsetX, offsetY);
this.objectRender.showDrawingObjects(false, new GraphicOption(this, c_oAscGraphicOption.ScrollVertical, range));
this.objectRender.showDrawingObjectsEx(false, new GraphicOption(this,
c_oAscGraphicOption.ScrollVertical, range, undefined, {offsetX: offsetX, offsetY: offsetY}));
if (0 < cFrozen) {
range.c1 = 0;
range.c2 = cFrozen - 1;
......@@ -5309,7 +5313,8 @@
this._drawCells(/*drawingCtx*/undefined, range, offsetX);
this._drawCellsBorders(/*drawingCtx*/undefined, range, offsetX);
this._drawAutoF(range, offsetX, offsetY);
this.objectRender.showDrawingObjects(false, new GraphicOption(this, c_oAscGraphicOption.ScrollVertical, range));
this.objectRender.showDrawingObjectsEx(false, new GraphicOption(this,
c_oAscGraphicOption.ScrollVertical, range, undefined, {offsetX: offsetX, offsetY: offsetY}));
}
// Отрисовывать нужно всегда, вдруг бордеры
this._drawFrozenPaneLines();
......@@ -5324,8 +5329,6 @@
this.handlers.trigger("onDocumentPlaceChanged");
//ToDo this.drawDepCells();
if(this.objectRender && this.objectRender.drawingArea)
this.objectRender.drawingArea.reinitRanges();
this.cellCommentator.updateCommentPosition();
this.cellCommentator.drawCommentCells();
return this;
......@@ -5393,6 +5396,9 @@
ctx.setFillStyle(this.settings.cells.defaultState.background)
.fillRect(x + (scrollRight > 0 ? oldW - dx - lastColWidth : 0), y, Math.abs(dx) + lastColWidth, ctxH);
if(this.objectRender && this.objectRender.drawingArea)
this.objectRender.drawingArea.reinitRanges();
if ( !(dx > 0 && vr.c2 === oldEnd && !oldVCE_isPartial) ) {
var c1 = scrollRight ? oldEnd + (oldVCE_isPartial ? 0 : 1) : vr.c1;
var r1 = vr.r1;
......@@ -5406,7 +5412,8 @@
this._drawCells(/*drawingCtx*/undefined, range);
this._drawCellsBorders(/*drawingCtx*/undefined, range);
this._drawAutoF(range, offsetX, offsetY);
this.objectRender.showDrawingObjects(false, new GraphicOption(this, c_oAscGraphicOption.ScrollHorizontal, range));
this.objectRender.showDrawingObjectsEx(false, new GraphicOption(this,
c_oAscGraphicOption.ScrollHorizontal, range, undefined, {offsetX: offsetX, offsetY: offsetY}));
if (rFrozen) {
range.r1 = 0;
range.r2 = rFrozen - 1;
......@@ -5415,7 +5422,8 @@
this._drawCells(/*drawingCtx*/undefined, range, undefined, offsetY);
this._drawCellsBorders(/*drawingCtx*/undefined, range, undefined, offsetY);
this._drawAutoF(range, offsetX, offsetY);
this.objectRender.showDrawingObjects(false, new GraphicOption(this, c_oAscGraphicOption.ScrollHorizontal, range));
this.objectRender.showDrawingObjectsEx(false, new GraphicOption(this,
c_oAscGraphicOption.ScrollHorizontal, range, undefined, {offsetX: offsetX, offsetY: offsetY}));
}
// Отрисовывать нужно всегда, вдруг бордеры
this._drawFrozenPaneLines();
......@@ -5428,9 +5436,6 @@
this.handlers.trigger("onDocumentPlaceChanged");
//ToDo this.drawDepCells();
if(this.objectRender && this.objectRender.drawingArea)
this.objectRender.drawingArea.reinitRanges();
this.cellCommentator.updateCommentPosition();
this.cellCommentator.drawCommentCells();
return this;
......
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