Commit a7dbd4bd authored by Dmitry.Vikulov's avatar Dmitry.Vikulov Committed by Alexander.Trofimov

- Исправлен баг с переоткрытием фрейма с диаграммой

- Общий расчет позиций граф.объектов и комментариев
- Доработано позиционирование комментариев в закр.областях

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54466 954022d7-b5bf-4e40-9824-e11837661b57
parent 87cab664
...@@ -2776,7 +2776,8 @@ function DrawingObjects() { ...@@ -2776,7 +2776,8 @@ function DrawingObjects() {
case c_oAscCellAnchorType.cellanchorOneCell: case c_oAscCellAnchorType.cellanchorOneCell:
{ {
var coordsFrom = _this.coordsManager.calculateCoords(_t.from); var coordsFrom = _this.coordsManager.calculateCoords(_t.from);
var cellTo = _this.coordsManager.calculateCell( coordsFrom.x + mmToPx(_t.ext.cx), coordsFrom.y + mmToPx(_t.ext.cy) ); //var cellTo = _this.coordsManager.calculateCell( coordsFrom.x + mmToPx(_t.ext.cx), coordsFrom.y + mmToPx(_t.ext.cy) );
var cellTo = _this.drawingArea.calculateCell( coordsFrom.x + mmToPx(_t.ext.cx), coordsFrom.y + mmToPx(_t.ext.cy) );
_t.to.col = cellTo.col; _t.to.col = cellTo.col;
_t.to.colOff = cellTo.colOff; _t.to.colOff = cellTo.colOff;
...@@ -2792,13 +2793,15 @@ function DrawingObjects() { ...@@ -2792,13 +2793,15 @@ function DrawingObjects() {
if ( _t.Pos.Y < 0 ) if ( _t.Pos.Y < 0 )
_t.Pos.Y = 0; _t.Pos.Y = 0;
var cellFrom = _this.coordsManager.calculateCell( mmToPx(_t.Pos.X), mmToPx(_t.Pos.Y) ); //var cellFrom = _this.coordsManager.calculateCell( mmToPx(_t.Pos.X), mmToPx(_t.Pos.Y) );
var cellFrom = _this.drawingArea.calculateCell( mmToPx(_t.Pos.X), mmToPx(_t.Pos.Y) );
_t.from.col = cellFrom.col; _t.from.col = cellFrom.col;
_t.from.colOff = cellFrom.colOff; _t.from.colOff = cellFrom.colOff;
_t.from.row = cellFrom.row; _t.from.row = cellFrom.row;
_t.from.rowOff = cellFrom.rowOff; _t.from.rowOff = cellFrom.rowOff;
var cellTo = _this.coordsManager.calculateCell( mmToPx(_t.Pos.X + _t.ext.cx), mmToPx(_t.Pos.Y + _t.ext.cy)); //var cellTo = _this.coordsManager.calculateCell( mmToPx(_t.Pos.X + _t.ext.cx), mmToPx(_t.Pos.Y + _t.ext.cy));
var cellTo = _this.drawingArea.calculateCell( mmToPx(_t.Pos.X + _t.ext.cx), mmToPx(_t.Pos.Y + _t.ext.cy));
_t.to.col = cellTo.col; _t.to.col = cellTo.col;
_t.to.colOff = cellTo.colOff; _t.to.colOff = cellTo.colOff;
_t.to.row = cellTo.row; _t.to.row = cellTo.row;
...@@ -2955,7 +2958,7 @@ function DrawingObjects() { ...@@ -2955,7 +2958,7 @@ function DrawingObjects() {
shapeCtx.m_oAutoShapesTrack = autoShapeTrack; shapeCtx.m_oAutoShapesTrack = autoShapeTrack;
_this.objectLocker = new ObjectLocker(worksheet); _this.objectLocker = new ObjectLocker(worksheet);
_this.drawingArea = new DrawingArea(worksheet); _this.drawingArea = currentSheet.drawingArea;
_this.drawingArea.init(); _this.drawingArea.init();
_this.coordsManager = new CoordsManager(worksheet, true); _this.coordsManager = new CoordsManager(worksheet, true);
_this.drawingDocument = new CDrawingDocument(this); _this.drawingDocument = new CDrawingDocument(this);
...@@ -3275,8 +3278,12 @@ function DrawingObjects() { ...@@ -3275,8 +3278,12 @@ function DrawingObjects() {
if ( checker ) { if ( checker ) {
var coords = { from: null, to: null }; var coords = { from: null, to: null };
coords.from = _this.coordsManager.calculateCell( mmToPx(checker.Bounds.min_x), mmToPx(checker.Bounds.min_y) ); //coords.from = _this.coordsManager.calculateCell( mmToPx(checker.Bounds.min_x), mmToPx(checker.Bounds.min_y) );
coords.to = _this.coordsManager.calculateCell( mmToPx(checker.Bounds.max_x), mmToPx(checker.Bounds.max_y) ); //coords.to = _this.coordsManager.calculateCell( mmToPx(checker.Bounds.max_x), mmToPx(checker.Bounds.max_y) );
coords.from = _this.drawingArea.calculateCell( mmToPx(checker.Bounds.min_x), mmToPx(checker.Bounds.min_y) );
coords.to = _this.drawingArea.calculateCell( mmToPx(checker.Bounds.max_x), mmToPx(checker.Bounds.max_y) );
return coords; return coords;
} }
return null; return null;
...@@ -3759,7 +3766,8 @@ function DrawingObjects() { ...@@ -3759,7 +3766,8 @@ function DrawingObjects() {
width /= metricCoeff; width /= metricCoeff;
} }
var cellTo = _this.coordsManager.calculateCell(realLeftOffset + width, realTopOffset + height); //var cellTo = _this.coordsManager.calculateCell(realLeftOffset + width, realTopOffset + height);
var cellTo = _this.drawingArea.calculateCell(realLeftOffset + width, realTopOffset + height);
object.to.col = cellTo.col; object.to.col = cellTo.col;
object.to.colOff = cellTo.colOff; object.to.colOff = cellTo.colOff;
object.to.row = cellTo.row; object.to.row = cellTo.row;
...@@ -4932,8 +4940,11 @@ function DrawingObjects() { ...@@ -4932,8 +4940,11 @@ function DrawingObjects() {
//worksheet._initCellsArea(true); //worksheet._initCellsArea(true);
worksheet.changeWorksheet("update"); worksheet.changeWorksheet("update");
} }
for (var i = 0; i < aObjects.length; i++) {
aObjects = []; aObjects[i].graphicObject.deleteDrawingBase();
}
aBoundsCheckers = [];
worksheet._clean(); worksheet._clean();
var listRange = new Range(worksheet.model, 0, 0, worksheet.nRowsCount - 1, worksheet.nColsCount - 1); var listRange = new Range(worksheet.model, 0, 0, worksheet.nRowsCount - 1, worksheet.nColsCount - 1);
listRange.cleanAll(); listRange.cleanAll();
...@@ -5156,7 +5167,8 @@ function DrawingObjects() { ...@@ -5156,7 +5167,8 @@ function DrawingObjects() {
var drawingObject = aObjects[i]; var drawingObject = aObjects[i];
var coords = _this.coordsManager.calculateCoords(drawingObject.from); var coords = _this.coordsManager.calculateCoords(drawingObject.from);
var cellTo = _this.coordsManager.calculateCell(coords.x + drawingObject.size.width, coords.y + drawingObject.size.height); //var cellTo = _this.coordsManager.calculateCell(coords.x + drawingObject.size.width, coords.y + drawingObject.size.height);
var cellTo = _this.drawingArea.calculateCell(coords.x + drawingObject.size.width, coords.y + drawingObject.size.height);
drawingObject.to.col = cellTo.col; drawingObject.to.col = cellTo.col;
drawingObject.to.colOff = cellTo.colOff; drawingObject.to.colOff = cellTo.colOff;
drawingObject.to.row = cellTo.row; drawingObject.to.row = cellTo.row;
......
...@@ -689,7 +689,7 @@ function asc_CCellCommentator(currentSheet) { ...@@ -689,7 +689,7 @@ 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, offsetX, offsetY) { _this.drawCommentCells = function() {
if ( isViewerMode() || !_this.bShow ) if ( isViewerMode() || !_this.bShow )
return; return;
...@@ -697,43 +697,45 @@ function asc_CCellCommentator(currentSheet) { ...@@ -697,43 +697,45 @@ function asc_CCellCommentator(currentSheet) {
var drawCells = []; // Associative array var drawCells = []; // Associative array
function getCellId(col, row) { return (col + "_" + row) }; function getCellId(col, row) { return (col + "_" + row) };
//_this.calcCommentsCoords(); for (var n = 0; n < _this.worksheet.drawingArea.frozenPlaces.length; n++) {
var frozenOffset = _this.getFrozenOffset(); 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++) {
for (var i = 0; i < _this.aComments.length; i++) { // Get cell metrics
var commentCell = _this.aComments[i];
var mergedRange = _this.worksheet.model.getMergedByCell(commentCell.nRow, commentCell.nCol);
var drawCol = mergedRange ? mergedRange.c2 : commentCell.nCol;
var drawRow = mergedRange ? mergedRange.r1 : commentCell.nRow;
// Get cell metrics if ( !frozenPlace.isCellInside({ col: drawCol, row: drawRow }) )
var commentCell = _this.aComments[i]; continue;
if ( commentCell.asc_getDocumentFlag() || commentCell.asc_getHiddenFlag() || commentCell.asc_getSolved() || (drawCol < fv.col) || (drawRow < fv.row) || (drawCol > lvc) || (drawRow > lvr) )
if ( updatedRange ) {
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 drawCol = mergedRange ? mergedRange.c2 : commentCell.nCol;
var drawRow = mergedRange ? mergedRange.r1 : commentCell.nRow;
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, mergedRange, updatedRange, offsetX, offsetY); var metrics = _this.getCellMetrics(drawCol, drawRow);
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(metrics.left + metrics.width - _this.pxToPt(7), metrics.top); _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.drawingCtx.lineTo(metrics.left + metrics.width - _this.pxToPt(1), metrics.top + _this.pxToPt(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;
}
} }
if (_this.lastSelectedId) if (_this.lastSelectedId)
_this.asc_selectComment(_this.lastSelectedId, false); _this.asc_selectComment(_this.lastSelectedId, false);
...@@ -752,42 +754,46 @@ function asc_CCellCommentator(currentSheet) { ...@@ -752,42 +754,46 @@ function asc_CCellCommentator(currentSheet) {
return metrics; return metrics;
} }
_this.getCellMetrics = function(col, row, mergedRange, updatedRange, offsetX, offsetY) { _this.getCellMetrics = function(col, row) {
var ws = _this.worksheet;
var metrics = { top: 0, left: 0, width: 0, height: 0, result: false }; // pt
updatedRange = updatedRange ? updatedRange : ws.getVisibleRange(); var metrics = { top: 0, left: 0, width: 0, height: 0, result: false }; // px
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);
mergedRange = (undefined === mergedRange) ? ws.model.getMergedByCell(row, col) : mergedRange; for (var n = 0; n < _this.worksheet.drawingArea.frozenPlaces.length; n++) {
var frozenPlace = _this.worksheet.drawingArea.frozenPlaces[n];
if ( !frozenPlace.isCellInside({ col: col, row: row }) )
continue;
var fv = frozenPlace.getFirstVisible();
var mergedRange = _this.worksheet.model.getMergedByCell(row, col);
if (mergedRange && (updatedRange.c1 < mergedRange.c2) && (updatedRange.r1 < mergedRange.r2)) { if (mergedRange && (fv.col < mergedRange.c2) && (fv.row < mergedRange.r2)) {
var startCol = Math.max(mergedRange.c1, updatedRange.c1); var startCol = (mergedRange.c1 > fv.col) ? mergedRange.c1 : fv.col;
var startRow = Math.max(mergedRange.r1, updatedRange.r1); var startRow = (mergedRange.r1 > fv.row) ? mergedRange.r1 : fv.row;
metrics.left = ws.getCellLeft(startCol, 1) - offsetX; metrics.top = _this.worksheet.getCellTop(startRow, 1) /*- _this.worksheet.getCellTop(fv.row, 1) + _this.worksheet.getCellTop(0, 1)*/ + _this.pxToPt(frozenPlace.getVerticalScroll()) - _this.worksheet.getCellTop(0, 1);
metrics.top = ws.getCellTop(startRow, 1) - offsetY; metrics.left = _this.worksheet.getCellLeft(startCol, 1) /*- _this.worksheet.getCellLeft(fv.col, 1) + _this.worksheet.getCellLeft(0, 1)*/ + _this.pxToPt(frozenPlace.getHorizontalScroll()) - _this.worksheet.getCellLeft(0, 1);
for (var i = startCol; i <= mergedRange.c2; i++) { for (var i = startCol; i <= mergedRange.c2; i++) {
metrics.width += ws.getColumnWidth(i, 1); metrics.width += _this.worksheet.getColumnWidth(i, 1)
}
for (var i = startRow; i <= mergedRange.r2; i++) {
metrics.height += _this.worksheet.getRowHeight(i, 1)
}
metrics.result = true;
} }
for (var i = startRow; i <= mergedRange.r2; i++) { else if ((fv.row <= row) && (fv.col <= col)) {
metrics.height += ws.getRowHeight(i, 1);
metrics.top = _this.worksheet.getCellTop(row, 1) /*- _this.worksheet.getCellTop(fv.row, 1) + _this.worksheet.getCellTop(0, 1)*/ + _this.pxToPt(frozenPlace.getVerticalScroll()) - _this.worksheet.getCellTop(0, 1);
metrics.left = _this.worksheet.getCellLeft(col, 1) /*- _this.worksheet.getCellLeft(fv.col, 1) + _this.worksheet.getCellLeft(0, 1)*/ + _this.pxToPt(frozenPlace.getHorizontalScroll()) - _this.worksheet.getCellLeft(0, 1);
metrics.width = _this.worksheet.getColumnWidth(col, 1);
metrics.height = _this.worksheet.getRowHeight(row, 1);
metrics.result = true;
} }
metrics.result = true;
} 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; return metrics;
}; }
_this.updateCommentPosition = function() { _this.updateCommentPosition = function() {
var _this = this; var _this = this;
......
...@@ -414,6 +414,7 @@ ...@@ -414,6 +414,7 @@
// Auto filters // Auto filters
this.autoFilters = new asc_AF(this); this.autoFilters = new asc_AF(this);
this.drawingArea = new DrawingArea(this);
this.cellCommentator = new asc_CCellCommentator(this); this.cellCommentator = new asc_CCellCommentator(this);
this.objectRender = null; this.objectRender = null;
...@@ -1832,7 +1833,8 @@ ...@@ -1832,7 +1833,8 @@
this._drawFrozenPaneLines(); this._drawFrozenPaneLines();
this._fixSelectionOfMergedCells(); this._fixSelectionOfMergedCells();
this._fixSelectionOfHiddenCells(); this._fixSelectionOfHiddenCells();
this._drawGraphic(); this._drawAutoF();
this.cellCommentator.drawCommentCells();
this.objectRender.showDrawingObjects(false); this.objectRender.showDrawingObjects(false);
if (this.overlayCtx) { if (this.overlayCtx) {
this._drawSelection(); this._drawSelection();
...@@ -3398,12 +3400,11 @@ ...@@ -3398,12 +3400,11 @@
} }
}; };
WorksheetView.prototype._drawGraphic = function (updatedRange, offsetX, offsetY) { WorksheetView.prototype._drawAutoF = function (updatedRange, offsetX, offsetY) {
if (updatedRange) { if (updatedRange) {
this.autoFilters.drawAutoF(updatedRange, offsetX, offsetY); this.autoFilters.drawAutoF(updatedRange, offsetX, offsetY);
this.cellCommentator.drawCommentCells(updatedRange, offsetX, offsetY);
} else { } else {
this._drawElements(this, this._drawGraphic); this._drawElements(this, this._drawAutoF);
} }
}; };
...@@ -5035,7 +5036,7 @@ ...@@ -5035,7 +5036,7 @@
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); this._drawAutoF(range, offsetX, offsetY);
if (0 < cFrozen) { if (0 < cFrozen) {
range.c1 = 0; range.c1 = 0;
range.c2 = cFrozen - 1; range.c2 = cFrozen - 1;
...@@ -5043,7 +5044,7 @@ ...@@ -5043,7 +5044,7 @@
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._drawAutoF(range, offsetX, offsetY);
} }
// Отрисовывать нужно всегда, вдруг бордеры // Отрисовывать нужно всегда, вдруг бордеры
this._drawFrozenPaneLines(); this._drawFrozenPaneLines();
...@@ -5057,6 +5058,7 @@ ...@@ -5057,6 +5058,7 @@
this.handlers.trigger("reinitializeScrollY"); this.handlers.trigger("reinitializeScrollY");
this.cellCommentator.updateCommentPosition(); this.cellCommentator.updateCommentPosition();
this.cellCommentator.drawCommentCells();
//ToDo this.drawDepCells(); //ToDo this.drawDepCells();
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;
...@@ -5128,7 +5130,7 @@ ...@@ -5128,7 +5130,7 @@
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); this._drawAutoF(range, offsetX, offsetY);
if (rFrozen) { if (rFrozen) {
range.r1 = 0; range.r1 = 0;
range.r2 = rFrozen - 1; range.r2 = rFrozen - 1;
...@@ -5136,7 +5138,7 @@ ...@@ -5136,7 +5138,7 @@
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._drawAutoF(range, offsetX, offsetY);
} }
// Отрисовывать нужно всегда, вдруг бордеры // Отрисовывать нужно всегда, вдруг бордеры
this._drawFrozenPaneLines(); this._drawFrozenPaneLines();
...@@ -5148,6 +5150,7 @@ ...@@ -5148,6 +5150,7 @@
this.handlers.trigger("reinitializeScrollX"); this.handlers.trigger("reinitializeScrollX");
this.cellCommentator.updateCommentPosition(); this.cellCommentator.updateCommentPosition();
this.cellCommentator.drawCommentCells();
//ToDo this.drawDepCells(); //ToDo this.drawDepCells();
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