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