Commit 4e01df24 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Реализовал отрисовку комментариев с frozenPane

ToDo еще нужно поправить пару мест в комментариях

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@53337 954022d7-b5bf-4e40-9824-e11837661b57
parent 2deb366b
...@@ -687,16 +687,11 @@ function asc_CCellCommentator(currentSheet) { ...@@ -687,16 +687,11 @@ function asc_CCellCommentator(currentSheet) {
return (findCol && findRow) ? _this.asc_getComments(findCol.col, findRow.row) : []; return (findCol && findRow) ? _this.asc_getComments(findCol.col, findRow.row) : [];
} }
_this.drawCommentCells = function(updatedRange) { _this.drawCommentCells = function(updatedRange, offsetX, offsetY) {
if ( isViewerMode() || !_this.bShow ) if ( isViewerMode() || !_this.bShow )
return; return;
var fvr = _this.worksheet.getFirstVisibleRow();
var fvc = _this.worksheet.getFirstVisibleCol();
var lvr = _this.worksheet.getLastVisibleRow();
var lvc = _this.worksheet.getLastVisibleCol();
var drawCells = []; // Associative array var drawCells = []; // Associative array
function getCellId(col, row) { return (col + "_" + row) }; function getCellId(col, row) { return (col + "_" + row) };
...@@ -711,30 +706,29 @@ function asc_CCellCommentator(currentSheet) { ...@@ -711,30 +706,29 @@ function asc_CCellCommentator(currentSheet) {
if ( !((commentCell.nCol >= updatedRange.c1) && (commentCell.nCol <= updatedRange.c2) && (commentCell.nRow >= updatedRange.r1) && (commentCell.nRow <= updatedRange.r2)) ) if ( !((commentCell.nCol >= updatedRange.c1) && (commentCell.nCol <= updatedRange.c2) && (commentCell.nRow >= updatedRange.r1) && (commentCell.nRow <= updatedRange.r2)) )
continue; continue;
} }
if (commentCell.asc_getDocumentFlag() || commentCell.asc_getHiddenFlag() || commentCell.asc_getSolved())
continue;
var mergedRange = _this.worksheet.model.getMergedByCell(commentCell.nRow, commentCell.nCol); var mergedRange = _this.worksheet.model.getMergedByCell(commentCell.nRow, commentCell.nCol);
var drawCol = mergedRange ? mergedRange.c2 : commentCell.nCol; var drawCol = mergedRange ? mergedRange.c2 : commentCell.nCol;
var drawRow = mergedRange ? mergedRange.r1 : commentCell.nRow; var drawRow = mergedRange ? mergedRange.r1 : commentCell.nRow;
if ( commentCell.asc_getDocumentFlag() || commentCell.asc_getHiddenFlag() || commentCell.asc_getSolved() || (drawCol < fvc) || (drawRow < fvr) || (drawCol > lvc) || (drawRow > lvr) )
continue;
var cellId = getCellId(commentCell.nCol, commentCell.nRow); var cellId = getCellId(commentCell.nCol, commentCell.nRow);
if (drawCells[cellId]) if (drawCells[cellId])
continue; continue;
var metrics = _this.getCellMetrics(drawCol, drawRow); var metrics = _this.getCellMetrics(drawCol, drawRow, mergedRange, updatedRange, offsetX, offsetY);
if ( !metrics.result || (metrics.width <= 0) || (metrics.height <= 0) ) if ( !metrics.result || (metrics.width <= 0) || (metrics.height <= 0) )
continue; continue;
this.drawingCtx.beginPath(); _this.drawingCtx.beginPath();
this.drawingCtx.setFillStyle(this.commentIconColor); _this.drawingCtx.setFillStyle(_this.commentIconColor);
this.drawingCtx.moveTo(this.pxToPt(metrics.left + metrics.width - 7), this.pxToPt(metrics.top)); _this.drawingCtx.moveTo(metrics.left + metrics.width - _this.pxToPt(7), metrics.top);
this.drawingCtx.lineTo(this.pxToPt(metrics.left + metrics.width - 1), this.pxToPt(metrics.top)); _this.drawingCtx.lineTo(metrics.left + metrics.width - _this.pxToPt(1), metrics.top);
this.drawingCtx.lineTo(this.pxToPt(metrics.left + metrics.width - 1), this.pxToPt(metrics.top + 6)); _this.drawingCtx.lineTo(metrics.left + metrics.width - _this.pxToPt(1), metrics.top + _this.pxToPt(6));
this.drawingCtx.closePath(); _this.drawingCtx.closePath();
this.drawingCtx.fill(); _this.drawingCtx.fill();
drawCells[cellId] = cellId; drawCells[cellId] = cellId;
} }
...@@ -755,41 +749,42 @@ function asc_CCellCommentator(currentSheet) { ...@@ -755,41 +749,42 @@ function asc_CCellCommentator(currentSheet) {
return metrics; return metrics;
} }
_this.getCellMetrics = function(col, row) { _this.getCellMetrics = function(col, row, mergedRange, updatedRange, offsetX, offsetY) {
var metrics = { top: 0, left: 0, width: 0, height: 0, result: false }; // px var ws = _this.worksheet;
var metrics = { top: 0, left: 0, width: 0, height: 0, result: false }; // pt
var fvr = _this.worksheet.getFirstVisibleRow(); updatedRange = updatedRange ? updatedRange : ws.getVisibleRange();
var fvc = _this.worksheet.getFirstVisibleCol(); offsetX = undefined !== offsetX ? offsetX : ws.getCellLeft(updatedRange.c1, 1) - ws.getCellLeft(0, 1);
var mergedRange = _this.worksheet.model.getMergedByCell(row, col); offsetY = undefined !== offsetY ? offsetY : ws.getCellTop(updatedRange.r1, 1) - ws.getCellTop(0, 1);
if (mergedRange && (fvc < mergedRange.c2) && (fvr < mergedRange.r2)) { mergedRange = (undefined === mergedRange) ? ws.model.getMergedByCell(row, col) : mergedRange;
var startCol = (mergedRange.c1 > fvc) ? mergedRange.c1 : fvc; if (mergedRange && (updatedRange.c1 < mergedRange.c2) && (updatedRange.r1 < mergedRange.r2)) {
var startRow = (mergedRange.r1 > fvr) ? mergedRange.r1 : fvr;
metrics.top = _this.worksheet.getCellTop(startRow, 0) - _this.worksheet.getCellTop(fvr, 0) + _this.worksheet.getCellTop(0, 0); var startCol = Math.max(mergedRange.c1, updatedRange.c1);
metrics.left = _this.worksheet.getCellLeft(startCol, 0) - _this.worksheet.getCellLeft(fvc, 0) + _this.worksheet.getCellLeft(0, 0); var startRow = Math.max(mergedRange.r1, updatedRange.r1);
metrics.left = ws.getCellLeft(startCol, 1) - offsetX;
metrics.top = ws.getCellTop(startRow, 1) - offsetY;
for (var i = startCol; i <= mergedRange.c2; i++) { for (var i = startCol; i <= mergedRange.c2; i++) {
metrics.width += _this.worksheet.getColumnWidth(i, 0) metrics.width += ws.getColumnWidth(i, 1);
} }
for (var i = startRow; i <= mergedRange.r2; i++) { for (var i = startRow; i <= mergedRange.r2; i++) {
metrics.height += _this.worksheet.getRowHeight(i, 0) metrics.height += ws.getRowHeight(i, 1);
} }
metrics.result = true; metrics.result = true;
} } else if ((updatedRange.r1 <= row) && (updatedRange.c1 <= col)) {
else if ((fvr <= row) && (fvc <= col)) { metrics.left = ws.getCellLeft(col, 1) - offsetX;
metrics.top = ws.getCellTop(row, 1) - offsetY;
metrics.top = _this.worksheet.getCellTop(row, 0) - _this.worksheet.getCellTop(fvr, 0) + _this.worksheet.getCellTop(0, 0); metrics.width = ws.getColumnWidth(col, 1);
metrics.left = _this.worksheet.getCellLeft(col, 0) - _this.worksheet.getCellLeft(fvc, 0) + _this.worksheet.getCellLeft(0, 0); metrics.height = ws.getRowHeight(row, 1);
metrics.width = _this.worksheet.getColumnWidth(col, 0);
metrics.height = _this.worksheet.getRowHeight(row, 0);
metrics.result = true; metrics.result = true;
} }
return metrics; return metrics;
} };
_this.updateCommentPosition = function() { _this.updateCommentPosition = function() {
var _this = this; var _this = this;
......
...@@ -1253,13 +1253,13 @@ ...@@ -1253,13 +1253,13 @@
} }
}, },
drawAutoF2: function (visibleRange, offsetX, offsetY) { drawAutoF2: function (updatedRange, offsetX, offsetY) {
var buttons = this.allButtonAF; var buttons = this.allButtonAF;
var ws = this.worksheet; var ws = this.worksheet;
//проверяем, затрагивают ли данные кнопки визуальную область //проверяем, затрагивают ли данные кнопки визуальную область
if (buttons) { if (buttons) {
for (var i = 0; i < buttons.length; i++) { for (var i = 0; i < buttons.length; i++) {
if (!this._isNeedDrawButton(buttons[i], visibleRange)) if (!this._isNeedDrawButton(buttons[i], updatedRange))
continue; continue;
var range = ws.model.getCell(new CellAddress(buttons[i].id)).getCells(); var range = ws.model.getCell(new CellAddress(buttons[i].id)).getCells();
......
...@@ -3375,9 +3375,13 @@ ...@@ -3375,9 +3375,13 @@
} }
}, },
_drawGraphic: function(updatedRange) { _drawGraphic: function(updatedRange, offsetX, offsetY) {
this._drawElements(this.autoFilters, this.autoFilters.drawAutoF2); if (updatedRange) {
this.cellCommentator.drawCommentCells(updatedRange); this.autoFilters.drawAutoF2(updatedRange, offsetX, offsetY);
this.cellCommentator.drawCommentCells(updatedRange, offsetX, offsetY);
} else {
this._drawElements(this, this._drawGraphic);
}
}, },
cleanSelection: function (range, isFrozen) { cleanSelection: function (range, isFrozen) {
...@@ -4925,7 +4929,7 @@ ...@@ -4925,7 +4929,7 @@
var dy = this.rows[start].top - this.rows[vr.r1].top; var dy = this.rows[start].top - this.rows[vr.r1].top;
var oldEnd = vr.r2; var oldEnd = vr.r2;
var oldDec = Math.max(calcDecades(oldEnd + 1), 3); var oldDec = Math.max(calcDecades(oldEnd + 1), 3);
var diffHeight = 0; var offsetX, offsetY, diffWidth = 0, diffHeight = 0;
var oldVRE_isPartial; var oldVRE_isPartial;
var oldH = ctxH - this.cellsTop - Math.abs(dy); var oldH = ctxH - this.cellsTop - Math.abs(dy);
var y = this.cellsTop + (dy > 0 && oldH > 0 ? dy : 0); var y = this.cellsTop + (dy > 0 && oldH > 0 ? dy : 0);
...@@ -4933,6 +4937,7 @@ ...@@ -4933,6 +4937,7 @@
if (this.topLeftFrozenCell) { if (this.topLeftFrozenCell) {
cFrozen = this.topLeftFrozenCell.getCol0(); cFrozen = this.topLeftFrozenCell.getCol0();
rFrozen = this.topLeftFrozenCell.getRow0(); rFrozen = this.topLeftFrozenCell.getRow0();
diffWidth = this.cols[cFrozen].left - this.cols[0].left;
diffHeight = this.rows[rFrozen].top - this.rows[0].top; diffHeight = this.rows[rFrozen].top - this.rows[0].top;
y += diffHeight; y += diffHeight;
if (dy > 0) if (dy > 0)
...@@ -4998,16 +5003,20 @@ ...@@ -4998,16 +5003,20 @@
} }
} }
} }
offsetX = this.cols[this.visibleRange.c1].left - this.cellsLeft - diffWidth;
offsetY = this.rows[this.visibleRange.r1].top - this.cellsTop - diffHeight;
this._drawGrid(/*drawingCtx*/ undefined, range); this._drawGrid(/*drawingCtx*/ undefined, range);
this._drawCells(/*drawingCtx*/undefined, range); this._drawCells(/*drawingCtx*/undefined, range);
this._drawCellsBorders(/*drawingCtx*/undefined, range); this._drawCellsBorders(/*drawingCtx*/undefined, range);
this._drawGraphic(range, offsetX, offsetY);
if (0 < cFrozen) { if (0 < cFrozen) {
range.c1 = 0; range.c1 = 0;
range.c2 = cFrozen - 1; range.c2 = cFrozen - 1;
var offsetX = this.cols[0].left - this.cellsLeft; offsetX = this.cols[0].left - this.cellsLeft;
this._drawGrid(/*drawingCtx*/ undefined, range, offsetX); this._drawGrid(/*drawingCtx*/ undefined, range, offsetX);
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._drawGraphic(range, offsetX, offsetY);
} }
// Отрисовывать нужно всегда, вдруг бордеры // Отрисовывать нужно всегда, вдруг бордеры
this._drawFrozenPaneLines(); this._drawFrozenPaneLines();
...@@ -5022,7 +5031,6 @@ ...@@ -5022,7 +5031,6 @@
this.cellCommentator.updateCommentPosition(); this.cellCommentator.updateCommentPosition();
//ToDo this.drawDepCells(); //ToDo this.drawDepCells();
this._drawGraphic(rangeGraphic);
this.objectRender.showDrawingObjects(false, new GraphicOption(this, c_oAscGraphicOption.ScrollVertical, rangeGraphic)); this.objectRender.showDrawingObjects(false, new GraphicOption(this, c_oAscGraphicOption.ScrollVertical, rangeGraphic));
return this; return this;
}, },
...@@ -5049,7 +5057,7 @@ ...@@ -5049,7 +5057,7 @@
var ctxH = ctx.getHeight(); var ctxH = ctx.getHeight();
var dx = this.cols[start].left - this.cols[vr.c1].left; var dx = this.cols[start].left - this.cols[vr.c1].left;
var oldEnd = vr.c2; var oldEnd = vr.c2;
var diffWidth = 0; var offsetX, offsetY, diffWidth = 0, diffHeight = 0;
var oldW = ctxW - this.cellsLeft - Math.abs(dx); var oldW = ctxW - this.cellsLeft - Math.abs(dx);
var x = this.cellsLeft + (dx > 0 && oldW > 0 ? dx : 0); var x = this.cellsLeft + (dx > 0 && oldW > 0 ? dx : 0);
var y = this.headersTop; var y = this.headersTop;
...@@ -5058,6 +5066,7 @@ ...@@ -5058,6 +5066,7 @@
rFrozen = this.topLeftFrozenCell.getRow0(); rFrozen = this.topLeftFrozenCell.getRow0();
cFrozen = this.topLeftFrozenCell.getCol0(); cFrozen = this.topLeftFrozenCell.getCol0();
diffWidth = this.cols[cFrozen].left - this.cols[0].left; diffWidth = this.cols[cFrozen].left - this.cols[0].left;
diffHeight = this.rows[rFrozen].top - this.rows[0].top;
x += diffWidth; x += diffWidth;
if (dx > 0) if (dx > 0)
oldW -= diffWidth; oldW -= diffWidth;
...@@ -5086,17 +5095,21 @@ ...@@ -5086,17 +5095,21 @@
var r2 = vr.r2; var r2 = vr.r2;
var range = asc_Range(c1, r1, c2, r2); var range = asc_Range(c1, r1, c2, r2);
rangeGraphic = range.clone(); rangeGraphic = range.clone();
offsetX = this.cols[this.visibleRange.c1].left - this.cellsLeft - diffWidth;
offsetY = this.rows[this.visibleRange.r1].top - this.cellsTop - diffHeight;
this._drawColumnHeaders(/*drawingCtx*/ undefined, c1, c2); this._drawColumnHeaders(/*drawingCtx*/ undefined, c1, c2);
this._drawGrid(/*drawingCtx*/ undefined, range); this._drawGrid(/*drawingCtx*/ undefined, range);
this._drawCells(/*drawingCtx*/undefined, range); this._drawCells(/*drawingCtx*/undefined, range);
this._drawCellsBorders(/*drawingCtx*/undefined, range); this._drawCellsBorders(/*drawingCtx*/undefined, range);
this._drawGraphic(range, offsetX, offsetY);
if (rFrozen) { if (rFrozen) {
range.r1 = 0; range.r1 = 0;
range.r2 = rFrozen - 1; range.r2 = rFrozen - 1;
var offsetY = this.rows[0].top - this.cellsTop; offsetY = this.rows[0].top - this.cellsTop;
this._drawGrid(/*drawingCtx*/ undefined, range, undefined, offsetY); this._drawGrid(/*drawingCtx*/ undefined, range, undefined, offsetY);
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._drawGraphic(range, offsetX, offsetY);
} }
// Отрисовывать нужно всегда, вдруг бордеры // Отрисовывать нужно всегда, вдруг бордеры
this._drawFrozenPaneLines(); this._drawFrozenPaneLines();
...@@ -5109,7 +5122,6 @@ ...@@ -5109,7 +5122,6 @@
this.cellCommentator.updateCommentPosition(); this.cellCommentator.updateCommentPosition();
//ToDo this.drawDepCells(); //ToDo this.drawDepCells();
this._drawGraphic(rangeGraphic);
this.objectRender.showDrawingObjects(false, new GraphicOption(this, c_oAscGraphicOption.ScrollHorizontal, rangeGraphic)); this.objectRender.showDrawingObjects(false, new GraphicOption(this, c_oAscGraphicOption.ScrollHorizontal, rangeGraphic));
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