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() {
case c_oAscCellAnchorType.cellanchorOneCell:
{
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.colOff = cellTo.colOff;
......@@ -2792,13 +2793,15 @@ function DrawingObjects() {
if ( _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.colOff = cellFrom.colOff;
_t.from.row = cellFrom.row;
_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.colOff = cellTo.colOff;
_t.to.row = cellTo.row;
......@@ -2955,7 +2958,7 @@ function DrawingObjects() {
shapeCtx.m_oAutoShapesTrack = autoShapeTrack;
_this.objectLocker = new ObjectLocker(worksheet);
_this.drawingArea = new DrawingArea(worksheet);
_this.drawingArea = currentSheet.drawingArea;
_this.drawingArea.init();
_this.coordsManager = new CoordsManager(worksheet, true);
_this.drawingDocument = new CDrawingDocument(this);
......@@ -3275,8 +3278,12 @@ function DrawingObjects() {
if ( checker ) {
var coords = { from: null, to: null };
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.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.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 null;
......@@ -3759,7 +3766,8 @@ function DrawingObjects() {
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.colOff = cellTo.colOff;
object.to.row = cellTo.row;
......@@ -4932,8 +4940,11 @@ function DrawingObjects() {
//worksheet._initCellsArea(true);
worksheet.changeWorksheet("update");
}
for (var i = 0; i < aObjects.length; i++) {
aObjects[i].graphicObject.deleteDrawingBase();
}
aBoundsCheckers = [];
aObjects = [];
worksheet._clean();
var listRange = new Range(worksheet.model, 0, 0, worksheet.nRowsCount - 1, worksheet.nColsCount - 1);
listRange.cleanAll();
......@@ -5156,7 +5167,8 @@ function DrawingObjects() {
var drawingObject = aObjects[i];
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.colOff = cellTo.colOff;
drawingObject.to.row = cellTo.row;
......
......@@ -689,7 +689,7 @@ function asc_CCellCommentator(currentSheet) {
return (findCol && findRow) ? _this.asc_getComments(findCol.col, findRow.row) : [];
}
_this.drawCommentCells = function(updatedRange, offsetX, offsetY) {
_this.drawCommentCells = function() {
if ( isViewerMode() || !_this.bShow )
return;
......@@ -697,30 +697,31 @@ function asc_CCellCommentator(currentSheet) {
var drawCells = []; // Associative array
function getCellId(col, row) { return (col + "_" + row) };
//_this.calcCommentsCoords();
var frozenOffset = _this.getFrozenOffset();
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 ( updatedRange ) {
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 ( !frozenPlace.isCellInside({ col: drawCol, row: drawRow }) )
continue;
if ( commentCell.asc_getDocumentFlag() || commentCell.asc_getHiddenFlag() || commentCell.asc_getSolved() || (drawCol < fv.col) || (drawRow < fv.row) || (drawCol > lvc) || (drawRow > lvr) )
continue;
var cellId = getCellId(commentCell.nCol, commentCell.nRow);
if (drawCells[cellId])
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) )
continue;
......@@ -735,6 +736,7 @@ function asc_CCellCommentator(currentSheet) {
drawCells[cellId] = cellId;
}
}
if (_this.lastSelectedId)
_this.asc_selectComment(_this.lastSelectedId, false);
}
......@@ -752,42 +754,46 @@ function asc_CCellCommentator(currentSheet) {
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
var metrics = { top: 0, left: 0, width: 0, height: 0, result: false }; // px
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);
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;
mergedRange = (undefined === mergedRange) ? ws.model.getMergedByCell(row, col) : mergedRange;
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 startRow = Math.max(mergedRange.r1, updatedRange.r1);
var startCol = (mergedRange.c1 > fv.col) ? mergedRange.c1 : fv.col;
var startRow = (mergedRange.r1 > fv.row) ? mergedRange.r1 : fv.row;
metrics.left = ws.getCellLeft(startCol, 1) - offsetX;
metrics.top = ws.getCellTop(startRow, 1) - offsetY;
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.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++) {
metrics.width += ws.getColumnWidth(i, 1);
metrics.width += _this.worksheet.getColumnWidth(i, 1)
}
for (var i = startRow; i <= mergedRange.r2; i++) {
metrics.height += ws.getRowHeight(i, 1);
metrics.height += _this.worksheet.getRowHeight(i, 1)
}
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);
}
else if ((fv.row <= row) && (fv.col <= col)) {
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;
}
}
return metrics;
};
}
_this.updateCommentPosition = function() {
var _this = this;
......
......@@ -414,6 +414,7 @@
// Auto filters
this.autoFilters = new asc_AF(this);
this.drawingArea = new DrawingArea(this);
this.cellCommentator = new asc_CCellCommentator(this);
this.objectRender = null;
......@@ -1832,7 +1833,8 @@
this._drawFrozenPaneLines();
this._fixSelectionOfMergedCells();
this._fixSelectionOfHiddenCells();
this._drawGraphic();
this._drawAutoF();
this.cellCommentator.drawCommentCells();
this.objectRender.showDrawingObjects(false);
if (this.overlayCtx) {
this._drawSelection();
......@@ -3398,12 +3400,11 @@
}
};
WorksheetView.prototype._drawGraphic = function (updatedRange, offsetX, offsetY) {
WorksheetView.prototype._drawAutoF = function (updatedRange, offsetX, offsetY) {
if (updatedRange) {
this.autoFilters.drawAutoF(updatedRange, offsetX, offsetY);
this.cellCommentator.drawCommentCells(updatedRange, offsetX, offsetY);
} else {
this._drawElements(this, this._drawGraphic);
this._drawElements(this, this._drawAutoF);
}
};
......@@ -5035,7 +5036,7 @@
this._drawGrid(/*drawingCtx*/ undefined, range);
this._drawCells(/*drawingCtx*/undefined, range);
this._drawCellsBorders(/*drawingCtx*/undefined, range);
this._drawGraphic(range, offsetX, offsetY);
this._drawAutoF(range, offsetX, offsetY);
if (0 < cFrozen) {
range.c1 = 0;
range.c2 = cFrozen - 1;
......@@ -5043,7 +5044,7 @@
this._drawGrid(/*drawingCtx*/ undefined, range, offsetX);
this._drawCells(/*drawingCtx*/undefined, range, offsetX);
this._drawCellsBorders(/*drawingCtx*/undefined, range, offsetX);
this._drawGraphic(range, offsetX, offsetY);
this._drawAutoF(range, offsetX, offsetY);
}
// Отрисовывать нужно всегда, вдруг бордеры
this._drawFrozenPaneLines();
......@@ -5057,6 +5058,7 @@
this.handlers.trigger("reinitializeScrollY");
this.cellCommentator.updateCommentPosition();
this.cellCommentator.drawCommentCells();
//ToDo this.drawDepCells();
this.objectRender.showDrawingObjects(false, new GraphicOption(this, c_oAscGraphicOption.ScrollVertical, rangeGraphic));
return this;
......@@ -5128,7 +5130,7 @@
this._drawGrid(/*drawingCtx*/ undefined, range);
this._drawCells(/*drawingCtx*/undefined, range);
this._drawCellsBorders(/*drawingCtx*/undefined, range);
this._drawGraphic(range, offsetX, offsetY);
this._drawAutoF(range, offsetX, offsetY);
if (rFrozen) {
range.r1 = 0;
range.r2 = rFrozen - 1;
......@@ -5136,7 +5138,7 @@
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._drawAutoF(range, offsetX, offsetY);
}
// Отрисовывать нужно всегда, вдруг бордеры
this._drawFrozenPaneLines();
......@@ -5148,6 +5150,7 @@
this.handlers.trigger("reinitializeScrollX");
this.cellCommentator.updateCommentPosition();
this.cellCommentator.drawCommentCells();
//ToDo this.drawDepCells();
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