Commit 3b71b436 authored by Alexander.Trofimov's avatar Alexander.Trofimov Committed by Alexander.Trofimov

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

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@57226 954022d7-b5bf-4e40-9824-e11837661b57
parent a3de905c
...@@ -1092,131 +1092,135 @@ CCellCommentator.prototype.calcCommentsCoords = function(bSave) { ...@@ -1092,131 +1092,135 @@ CCellCommentator.prototype.calcCommentsCoords = function(bSave) {
} }
}; };
CCellCommentator.prototype.getCommentsCoords = function(comments) { CCellCommentator.prototype.calcCommentArea = function (comment, coords) {
/* User name
* Time
* Text
*/
// bWithScroll - учитывать вертикальный и горизонтальный скроллы var originalFont = this.overlayCtx.getFont();
var outputFont = originalFont.clone();
var t = this; // Set to bold
var coords = new asc_CCommentCoords(); outputFont.Bold = true;
outputFont.FontSize = 9;
this.overlayCtx.setFont(outputFont);
function calcCommentArea(comment, coords) { // Title
var txtMetrics = this.getTextMetrics(comment.sUserName, 1);
coords.dHeightPX += this.ptToPx(txtMetrics.height);
var userWidth = this.ptToPx(txtMetrics.width);
/* User name if (coords.dWidthPX < userWidth)
* Time coords.dWidthPX = userWidth;
* Text
*/
var originalFont = t.overlayCtx.getFont(); txtMetrics = this.getTextMetrics(comment.sTime, 1);
var outputFont = originalFont.clone(); coords.dHeightPX += this.ptToPx(txtMetrics.height);
var timeWidth = this.ptToPx(txtMetrics.width);
// Set to bold if (coords.dWidthPX < timeWidth)
outputFont.Bold = true; coords.dWidthPX = timeWidth;
outputFont.FontSize = 9;
t.overlayCtx.setFont(outputFont);
// Title // Set to normal
var txtMetrics = t.getTextMetrics(comment.sUserName, 1); outputFont.Bold = false;
coords.dHeightPX += t.ptToPx(txtMetrics.height); outputFont.FontSize = 9;
var userWidth = t.ptToPx(txtMetrics.width); this.overlayCtx.setFont(outputFont);
if (coords.dWidthPX < userWidth) // Comment text
coords.dWidthPX = userWidth; var commentSpl = comment.sText.split('\n'), i;
for (i = 0; i < commentSpl.length; i++) {
txtMetrics = t.getTextMetrics(comment.sTime, 1); txtMetrics = this.getTextMetrics(commentSpl[i], 1);
coords.dHeightPX += t.ptToPx(txtMetrics.height); coords.dHeightPX += this.ptToPx(txtMetrics.height);
var timeWidth = t.ptToPx(txtMetrics.width); var lineWidth = this.ptToPx(txtMetrics.width);
if (coords.dWidthPX < lineWidth)
coords.dWidthPX = lineWidth;
}
if (coords.dWidthPX < timeWidth) for (i = 0; i < comment.aReplies.length; i++) {
coords.dWidthPX = timeWidth; this.calcCommentArea(comment.aReplies[i], coords);
}
// Set to normal // Min values
outputFont.Bold = false; if (coords.dWidthPX < this.minAreaWidth)
outputFont.FontSize = 9; coords.dWidthPX = this.minAreaWidth;
t.overlayCtx.setFont(outputFont);
// Comment text if (coords.dHeightPX < this.minAreaHeight)
var commentSpl = comment.sText.split('\n'), i; coords.dHeightPX = this.minAreaHeight;
for (i = 0; i < commentSpl.length; i++) {
txtMetrics = t.getTextMetrics(commentSpl[i], 1); // Calc other coords
coords.dHeightPX += t.ptToPx(txtMetrics.height); coords.dWidthMM = this.pxToMm(coords.dWidthPX);
var lineWidth = t.ptToPx(txtMetrics.width); coords.dHeightMM = this.pxToMm(coords.dHeightPX);
if (coords.dWidthPX < lineWidth)
coords.dWidthPX = lineWidth;
}
for (i = 0; i < comment.aReplies.length; i++) { var headerRowOffPx = this.worksheet.getCellTop(0, 0);
calcCommentArea(comment.aReplies[i], coords); var headerColOffPx = this.worksheet.getCellLeft(0, 0);
}
// Min values var headerCellsOffsetPt = this.worksheet.getCellsOffset(1);
if (coords.dWidthPX < t.minAreaWidth)
coords.dWidthPX = t.minAreaWidth;
if (coords.dHeightPX < t.minAreaHeight) coords.nCol = comment.nCol;
coords.dHeightPX = t.minAreaHeight; coords.nRow = comment.nRow;
// Calc other coords var mergedRange = this.worksheet.model.getMergedByCell(comment.nRow, comment.nCol);
coords.dWidthMM = t.pxToMm(coords.dWidthPX);
coords.dHeightMM = t.pxToMm(coords.dHeightPX);
var headerRowOffPx = t.worksheet.getCellTop(0, 0); coords.nLeft = (mergedRange ? mergedRange.c2 : comment.nCol) + 1;
var headerColOffPx = t.worksheet.getCellLeft(0, 0); if ( !this.worksheet.cols[coords.nLeft] ) {
this.worksheet.expandColsOnScroll(true);
this.worksheet.handlers.trigger("reinitializeScrollX");
}
coords.nCol = comment.nCol; coords.nTop = mergedRange ? mergedRange.r1 : comment.nRow;
coords.nRow = comment.nRow; coords.nLeftOffset = 0;
coords.nTopOffset = 0;
var mergedRange = t.worksheet.model.getMergedByCell(comment.nRow, comment.nCol); var fvr = this.worksheet.getFirstVisibleRow(false);
var fvc = this.worksheet.getFirstVisibleCol(false);
coords.nLeft = (mergedRange ? mergedRange.c2 : comment.nCol) + 1; var frozenOffset = this.worksheet.getFrozenPaneOffset();
if ( !t.worksheet.cols[coords.nLeft] ) { if (this.worksheet.topLeftFrozenCell) {
t.worksheet.expandColsOnScroll(true); if (comment.nCol < fvc) {
t.worksheet.handlers.trigger("reinitializeScrollX"); frozenOffset.offsetX = 0;
fvc = 0;
} }
if (comment.nRow < fvr) {
frozenOffset.offsetY = 0;
fvr = 0;
}
}
coords.nTop = mergedRange ? mergedRange.r1 : comment.nRow; var fvrLeft = this.worksheet.getCellLeft(fvc, 1) - headerCellsOffsetPt.left;
coords.nLeftOffset = 0; var fvcTop = this.worksheet.getCellTop(fvr, 1) - headerCellsOffsetPt.top;
coords.nTopOffset = 0;
var fvr = t.worksheet.getFirstVisibleRow(true);
var fvc = t.worksheet.getFirstVisibleCol(true);
var frozenOffset = t.getFrozenOffset(); // Tooltip coords
if ( t.worksheet.topLeftFrozenCell ) { coords.dReverseLeftPX = this.ptToPx(this.worksheet.getCellLeft(comment.nCol, 1) - fvrLeft + frozenOffset.offsetX);
if ( comment.nCol >= t.worksheet.getFirstVisibleCol(false) ) coords.dLeftPX = this.ptToPx(this.worksheet.getCellLeft(coords.nLeft, 1) - fvrLeft + frozenOffset.offsetX);
frozenOffset.offsetX = 0; coords.dTopPX = this.ptToPx(this.worksheet.getCellTop(coords.nTop, 1) - fvcTop + frozenOffset.offsetY);
if ( comment.nRow >= t.worksheet.getFirstVisibleRow(false) )
frozenOffset.offsetY = 0;
}
// Tooltip coords // Correction for merged cell
coords.dReverseLeftPX = t.worksheet.getCellLeft(comment.nCol, 0) - t.worksheet.getCellLeft(fvc, 0) + headerColOffPx + t.ptToPx(frozenOffset.offsetX); var fvrPx = this.worksheet.getCellTop(0, 0);
coords.dLeftPX = t.worksheet.getCellLeft(coords.nLeft, 0) - t.worksheet.getCellLeft(fvc, 0) + headerColOffPx + t.ptToPx(frozenOffset.offsetX); if (coords.dTopPX < fvrPx)
coords.dTopPX = t.worksheet.getCellTop(coords.nTop, 0) - t.worksheet.getCellTop(fvr, 0) + headerRowOffPx + t.ptToPx(frozenOffset.offsetY); coords.dTopPX = fvrPx;
// Correction for merged cell coords.dLeftMM = this.worksheet.getCellLeft(coords.nLeft, 3) - this.worksheet.getCellLeft(fvc, 3);
var fvrPx = t.worksheet.getCellTop(0, 0); coords.dTopMM = this.worksheet.getCellTop(coords.nTop, 3) - this.worksheet.getCellTop(fvr, 3);
if (coords.dTopPX < fvrPx)
coords.dTopPX = fvrPx;
coords.dLeftMM = t.worksheet.getCellLeft(coords.nLeft, 3) - t.worksheet.getCellLeft(fvc, 3); var findCol = this.worksheet._findColUnderCursor(this.worksheet.getCellLeft(coords.nLeft, 1) + this.pxToPt(coords.dWidthPX + headerColOffPx) - this.worksheet.getCellLeft(fvc, 1), true);
coords.dTopMM = t.worksheet.getCellTop(coords.nTop, 3) - t.worksheet.getCellTop(fvr, 3); var findRow = this.worksheet._findRowUnderCursor(this.worksheet.getCellTop(coords.nTop, 1) + this.pxToPt(coords.dHeightPX + headerRowOffPx) - this.worksheet.getCellTop(fvr, 1), true);
var findCol = t.worksheet._findColUnderCursor(t.worksheet.getCellLeft(coords.nLeft, 1) + t.pxToPt(coords.dWidthPX + headerColOffPx) - t.worksheet.getCellLeft(fvc, 1), true); coords.nRight = findCol ? findCol.col : 0;
var findRow = t.worksheet._findRowUnderCursor(t.worksheet.getCellTop(coords.nTop, 1) + t.pxToPt(coords.dHeightPX + headerRowOffPx) - t.worksheet.getCellTop(fvr, 1), true); coords.nBottom = findRow ? findRow.row : 0;
coords.nRight = findCol ? findCol.col : 0; coords.nRightOffset = this.worksheet.getCellLeft(coords.nLeft, 0) + coords.nLeftOffset + coords.dWidthPX + headerColOffPx - this.worksheet.getCellLeft(coords.nRight, 0);
coords.nBottom = findRow ? findRow.row : 0; coords.nBottomOffset = this.worksheet.getCellTop(coords.nTop, 0) + coords.nTopOffset + coords.dHeightPX + headerRowOffPx - this.worksheet.getCellTop(coords.nBottom, 0);
coords.nRightOffset = t.worksheet.getCellLeft(coords.nLeft, 0) + coords.nLeftOffset + coords.dWidthPX + headerColOffPx - t.worksheet.getCellLeft(coords.nRight, 0); // Return original font
coords.nBottomOffset = t.worksheet.getCellTop(coords.nTop, 0) + coords.nTopOffset + coords.dHeightPX + headerRowOffPx - t.worksheet.getCellTop(coords.nBottom, 0); this.overlayCtx.setFont(originalFont);
};
// Return original font CCellCommentator.prototype.getCommentsCoords = function(comments) {
t.overlayCtx.setFont(originalFont); var coords = new asc_CCommentCoords();
}
for (var i = 0; i < comments.length; i++) { for (var i = 0; i < comments.length; i++) {
calcCommentArea(comments[i], coords); this.calcCommentArea(comments[i], coords);
} }
if (comments.length) { if (comments.length) {
...@@ -1262,21 +1266,6 @@ CCellCommentator.prototype.cleanSelectedComment = function() { ...@@ -1262,21 +1266,6 @@ CCellCommentator.prototype.cleanSelectedComment = function() {
} }
}; };
CCellCommentator.prototype.getFrozenOffset = function() {
var offsetX = 0, offsetY = 0, cFrozen = 0, rFrozen = 0, diffWidth = 0, diffHeight = 0;
if ( this.worksheet.topLeftFrozenCell ) {
cFrozen = this.worksheet.topLeftFrozenCell.getCol0();
rFrozen = this.worksheet.topLeftFrozenCell.getRow0();
diffWidth = this.worksheet.cols[cFrozen].left - this.worksheet.cols[0].left;
diffHeight = this.worksheet.rows[rFrozen].top - this.worksheet.rows[0].top;
offsetX = this.worksheet.cols[this.worksheet.visibleRange.c1].left - this.worksheet.cellsLeft - diffWidth;
offsetY = this.worksheet.rows[this.worksheet.visibleRange.r1].top - this.worksheet.cellsTop - diffHeight;
}
return { offsetX: offsetX, offsetY: offsetY };
};
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
// Misc methods // Misc methods
//----------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------
......
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