Commit ebdc78f8 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

Добавил класс VisibleRange (содержит сам диапазон + offset).

Переделал отрисовку drawCommentCells.
Добавил получение для ячейки getCellVisibleRange (для закрепленных областей). Возвращает VisibleRange.
Добавил функции getColSize и getRowSize.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@60474 954022d7-b5bf-4e40-9824-e11837661b57
parent c6fe2d35
......@@ -581,52 +581,31 @@ CCellCommentator.prototype.drawCommentCells = function() {
if ( this.isViewerMode() || !this.bShow )
return;
var drawCells = []; // Associative array
function getCellId(col, row) { return (col + "_" + row); }
for (var n = 0; n < this.worksheet.drawingArea.frozenPlaces.length; n++) {
var frozenPlace = this.worksheet.drawingArea.frozenPlaces[n];
var fv = frozenPlace.getFirstVisible();
var lvr = this.worksheet.getLastVisibleRow();
var lvc = this.worksheet.getLastVisibleCol();
for (var i = 0; i < this.aComments.length; i++) {
// Get cell metrics
var commentCell = this.aComments[i];
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 (drawCol < fv.col || drawRow < fv.row || drawCol > lvc || drawRow > lvr)
continue;
if ( !frozenPlace.isCellInside({ col: drawCol, row: drawRow }) )
continue;
var cellId = getCellId(commentCell.nCol, commentCell.nRow);
if (drawCells[cellId])
continue;
var metrics = this.getCellMetrics(drawCol, drawRow);
if ( !metrics.result || (metrics.width <= 0) || (metrics.height <= 0) )
continue;
this.drawingCtx.beginPath();
this.drawingCtx.setFillStyle(this.commentIconColor);
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();
this.drawingCtx.setFillStyle(this.commentIconColor);
var commentCell, mergedRange, nCol, nRow, vr, nColSize, nRowSize, x, y;
for (var i = 0; i < this.aComments.length; ++i) {
commentCell = this.aComments[i];
if (commentCell.asc_getDocumentFlag() || commentCell.asc_getHiddenFlag() || commentCell.asc_getSolved())
continue;
drawCells[cellId] = cellId;
mergedRange = this.worksheet.model.getMergedByCell(commentCell.nRow, commentCell.nCol);
nCol = mergedRange ? mergedRange.c2 : commentCell.nCol;
nRow = mergedRange ? mergedRange.r1 : commentCell.nRow;
if (vr = this.worksheet.getCellVisibleRange(nCol, nRow)) {
nColSize = this.worksheet.getColSize(nCol);
nRowSize = this.worksheet.getRowSize(nRow);
if (nColSize && nRowSize) {
x = nColSize.left + nColSize.width - vr.offsetX;
y = nRowSize.top - vr.offsetY;
this.drawingCtx.beginPath();
this.drawingCtx.moveTo(x - this.pxToPt(7), y);
this.drawingCtx.lineTo(x - this.pxToPt(1), y);
this.drawingCtx.lineTo(x - this.pxToPt(1), y + this.pxToPt(6));
this.drawingCtx.fill();
}
}
}
//if (this.lastSelectedId)
// this.asc_selectComment(this.lastSelectedId, false);
};
CCellCommentator.prototype.getTextMetrics = function(text, units) {
......
......@@ -575,6 +575,12 @@
return sRes;
};
function VisibleRange(visibleRange, offsetX, offsetY) {
this.visibleRange = visibleRange;
this.offsetX = offsetX;
this.offsetY = offsetY;
}
function RangeCache()
{
this.oCache = {};
......@@ -1489,6 +1495,7 @@
window["Asc"].Range = Range;
window["Asc"].ActiveRange = ActiveRange;
window["Asc"].FormulaRange = FormulaRange;
window["Asc"].VisibleRange = VisibleRange;
window["Asc"].g_oRangeCache = g_oRangeCache;
window["Asc"].HandlersList = HandlersList;
......
......@@ -31,6 +31,7 @@
var asc_Range = asc.Range;
var asc_ActiveRange = asc.ActiveRange;
var asc_CMM = asc.asc_CMouseMoveData;
var asc_VR = asc.VisibleRange
var asc_CCellFlag = asc.asc_CCellFlag;
var asc_CFont = asc.asc_CFont;
......@@ -347,6 +348,41 @@
return this;
}
WorksheetView.prototype.getCellVisibleRange = function (col, row) {
var vr, offsetX = 0, offsetY = 0, cFrozen, rFrozen;
if (this.topLeftFrozenCell) {
cFrozen = this.topLeftFrozenCell.getCol0() - 1;
rFrozen = this.topLeftFrozenCell.getRow0() - 1;
if (col <= cFrozen && row <= rFrozen)
vr = new asc_Range(0, 0, cFrozen, rFrozen);
else if (col <= cFrozen) {
vr = new asc_Range(0, this.visibleRange.r1, cFrozen, this.visibleRange.r2);
offsetY -= this.rows[rFrozen + 1].top - this.cellsTop;
} else if (row <= rFrozen) {
vr = new asc_Range(this.visibleRange.c1, 0, this.visibleRange.c2, rFrozen);
offsetX -= this.cols[cFrozen + 1].left - this.cellsLeft;
} else {
vr = this.visibleRange;
offsetX -= this.cols[cFrozen + 1].left - this.cellsLeft;
offsetY -= this.rows[rFrozen + 1].top - this.cellsTop;
}
} else
vr = this.visibleRange;
offsetX += this.cols[vr.c1].left - this.cellsLeft;
offsetY += this.rows[vr.r1].top - this.cellsTop;
return vr.contains(col, row) ? new asc_VR(vr, offsetX, offsetY) : null;
};
WorksheetView.prototype.getColSize = function (col) {
return (col >= 0 && col < this.cols.length) ? this.cols[col] : null;
};
WorksheetView.prototype.getRowSize = function (row) {
return (row >= 0 && row < this.rows.length) ? this.rows[row] : null;
};
WorksheetView.prototype.getFrozenCell = function () {
return this.topLeftFrozenCell;
};
......
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