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