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

- Исправлено падение при ресайзе в мобильной версии

- Расчёт from/to объетов в закрепленных областях
- Частичный отказ от общего CoordsManager

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@54386 954022d7-b5bf-4e40-9824-e11837661b57
parent 5a314c7b

/*if ( _this.drawingArea.frozenPlaces[i].isPointInside(x, y) ) {
var rect = _this.drawingArea.frozenPlaces[i].getRect();
var canvas = worksheet.overlayCtx;
canvas.clear();
canvas.ctx.beginPath();
canvas.ctx.strokeStyle = "#FF0000";
canvas.ctx.rect(rect.x - 0.5, rect.y - 0.5, rect.w, rect.h);
canvas.ctx.stroke();
}*/
"use strict";
//-----------------------------------------------------------------------------------
// Drawing area manager
......@@ -193,20 +183,37 @@ function FrozenPlace(ws, type) {
_this.getRect = function() {
var rect = { x: 0, y: 0, w: 0, h: 0 };
var fv = _this.getFirstVisible();
rect.x = _this.worksheet.getCellLeft(_this.range.c1, 0);
rect.y = _this.worksheet.getCellTop(_this.range.r1, 0);
rect.w = _this.worksheet.getCellLeft(_this.range.c2, 0) - rect.x;
rect.h = _this.worksheet.getCellTop(_this.range.r2, 0) - rect.y;
return rect;
}
_this.getFirstVisible = function() {
var fv = { col: 0, row: 0 };
switch (_this.type) {
// Two places
case FrozenAreaType.Top: {
fv.col = _this.worksheet.getFirstVisibleCol();
}
break;
case FrozenAreaType.Bottom: {
fv.col = _this.worksheet.getFirstVisibleCol();
fv.row = _this.worksheet.getFirstVisibleRow();
}
break;
case FrozenAreaType.Left: {
fv.row = _this.worksheet.getFirstVisibleRow();
}
break;
case FrozenAreaType.Right: {
fv.col = _this.worksheet.getFirstVisibleCol();
fv.row = _this.worksheet.getFirstVisibleRow();
}
break;
......@@ -214,35 +221,32 @@ function FrozenPlace(ws, type) {
case FrozenAreaType.LeftTop: {
}
break;
case FrozenAreaType.RightTop: {
fv.col = _this.worksheet.getFirstVisibleCol();
}
break;
case FrozenAreaType.LeftBottom: {
fv.row = _this.worksheet.getFirstVisibleRow();
}
break;
case FrozenAreaType.RightBottom: {
fv.col = _this.worksheet.getFirstVisibleCol();
fv.row = _this.worksheet.getFirstVisibleRow();
}
break;
// No frozen areas
case FrozenAreaType.Center: {
fv.col = _this.worksheet.getFirstVisibleCol();
fv.row = _this.worksheet.getFirstVisibleRow();
}
break;
}
rect.x = _this.worksheet.getCellLeft(_this.range.c1, 0);
rect.y = _this.worksheet.getCellTop(_this.range.r1, 0);
rect.w = _this.worksheet.getCellLeft(_this.range.c2, 0) - rect.x;
rect.h = _this.worksheet.getCellTop(_this.range.r2, 0) - rect.y;
return rect;
}
_this.getFirstVisible = function() {
return { col : _this.worksheet.getFirstVisibleCol(),
row : _this.worksheet.getFirstVisibleRow(),
col0 : _this.worksheet.getFirstVisibleCol(true),
row0 : _this.worksheet.getFirstVisibleRow(true) };
return fv;
}
_this.isPointInside = function(x, y) {
......@@ -278,11 +282,6 @@ function FrozenPlace(ws, type) {
return result;
}
_this.intersectionExists = function(object) {
var result = false;
return result;
}
_this.getVerticalScroll = function() {
// No scroll for Top, LeftTop, RightTop
......@@ -296,44 +295,42 @@ function FrozenPlace(ws, type) {
scroll = headerPx;
}
break;
case FrozenAreaType.Bottom: {
scroll = _this.worksheet.getCellTop(fv.row, 0) - _this.worksheet.getCellTop(_this.frozenCell.row, 0) + headerPx;
}
break;
case FrozenAreaType.Left: {
scroll = _this.worksheet.getCellTop(fv.row, 0) - headerPx - headerPx;
//scroll = _this.worksheet.getCellTop(fv.row, 0) - _this.worksheet.getCellTop(_this.frozenCell.row, 0) + headerPx;
scroll = -convertMetrics((_this.worksheet.rows[fv.row].top - _this.worksheet.rows[_this.frozenCell.row].top), 1, 0) + headerPx;
}
break;
case FrozenAreaType.Left:
case FrozenAreaType.Right: {
scroll = _this.worksheet.getCellTop(fv.row, 0) - headerPx - headerPx;
//scroll = _this.worksheet.getCellTop(fv.row, 0) - headerPx - headerPx;
scroll = -convertMetrics((_this.worksheet.rows[fv.row].top - _this.worksheet.cellsTop), 1, 0) + headerPx;
}
break;
// Four places
case FrozenAreaType.LeftTop: {
scroll = headerPx;
}
break;
case FrozenAreaType.LeftTop:
case FrozenAreaType.RightTop: {
scroll = headerPx;
}
break;
case FrozenAreaType.LeftBottom: {
scroll = _this.worksheet.getCellTop(fv.row, 0) - _this.worksheet.getCellTop(_this.frozenCell.row, 0) + headerPx;
}
break;
case FrozenAreaType.LeftBottom:
case FrozenAreaType.RightBottom: {
scroll = _this.worksheet.getCellTop(fv.row, 0) - _this.worksheet.getCellTop(_this.frozenCell.row, 0) + headerPx;
//scroll = _this.worksheet.getCellTop(fv.row, 0) - _this.worksheet.getCellTop(_this.frozenCell.row, 0) + headerPx;
scroll = -convertMetrics((_this.worksheet.rows[fv.row].top - _this.worksheet.rows[_this.frozenCell.row].top), 1, 0) + headerPx;
}
break;
// No frozen areas
case FrozenAreaType.Center: {
scroll = _this.worksheet.getCellTop(fv.row, 0) - headerPx - headerPx;
//scroll = _this.worksheet.getCellTop(fv.row, 0);// - headerPx - headerPx;
scroll = -convertMetrics((_this.worksheet.rows[fv.row].top - _this.worksheet.cellsTop), 1, 0) + headerPx;
}
break;
}
return -scroll;
return scroll;
}
_this.getHorizontalScroll = function() {
......@@ -345,48 +342,46 @@ function FrozenPlace(ws, type) {
switch (_this.type) {
// Two places
case FrozenAreaType.Top: {
scroll = _this.worksheet.getCellLeft(fv.col, 0) - headerPx - headerPx;
}
break;
case FrozenAreaType.Top:
case FrozenAreaType.Bottom: {
scroll = _this.worksheet.getCellLeft(fv.col, 0) - headerPx - headerPx;
//scroll = _this.worksheet.getCellLeft(fv.col, 0) - headerPx - headerPx;
scroll = -convertMetrics((_this.worksheet.cols[fv.col].left - _this.worksheet.cellsLeft), 1, 0) + headerPx;
}
break;
case FrozenAreaType.Left: {
scroll = headerPx;
}
break;
case FrozenAreaType.Right: {
scroll = _this.worksheet.getCellLeft(fv.col, 0) - _this.worksheet.getCellLeft(_this.frozenCell.col, 0) + headerPx;
//scroll = _this.worksheet.getCellLeft(fv.col, 0) - _this.worksheet.getCellLeft(_this.frozenCell.col, 0) + headerPx;
scroll = -convertMetrics((_this.worksheet.cols[fv.col].left - _this.worksheet.cols[_this.frozenCell.col].left), 1, 0) + headerPx;
}
break;
// Four places
case FrozenAreaType.LeftTop: {
scroll = headerPx;
}
break;
case FrozenAreaType.RightTop: {
scroll = _this.worksheet.getCellLeft(fv.col, 0) - _this.worksheet.getCellLeft(_this.frozenCell.col, 0) + headerPx;
}
break;
case FrozenAreaType.LeftTop:
case FrozenAreaType.LeftBottom: {
scroll = headerPx;
}
break;
case FrozenAreaType.RightTop:
case FrozenAreaType.RightBottom: {
scroll = _this.worksheet.getCellLeft(fv.col, 0) - _this.worksheet.getCellLeft(_this.frozenCell.col, 0) + headerPx;
//scroll = _this.worksheet.getCellLeft(fv.col, 0) - _this.worksheet.getCellLeft(_this.frozenCell.col, 0) + headerPx;
scroll = -convertMetrics((_this.worksheet.cols[fv.col].left - _this.worksheet.cols[_this.frozenCell.col].left), 1, 0) + headerPx;
}
break;
break;
// No frozen areas
case FrozenAreaType.Center: {
scroll = _this.worksheet.getCellLeft(fv.col, 0) - headerPx - headerPx;
//scroll = _this.worksheet.getCellLeft(fv.col, 0);// - headerPx - headerPx;
scroll = -convertMetrics((_this.worksheet.cols[fv.col].left - _this.worksheet.cellsLeft), 1, 0) + headerPx;
}
break;
}
return -scroll;
return scroll;
}
_this.clip = function(canvas) {
......@@ -457,12 +452,83 @@ function FrozenPlace(ws, type) {
autoShapeTrack.Graphics.m_oCoordTransform.ty = y;
autoShapeTrack.Graphics.CalculateFullTransform();
_this.worksheet.objectRender.controller.recalculateCurPos();
//if ( _this.worksheet.objectRender.selectedGraphicObjectsExists() )
// _this.worksheet.objectRender.controller.updateSelectionState();
}
}
_this.calculateCell = function(x, y) {
var cell = { col: 0, colOff: 0, colOffPx: 0,
row: 0, rowOff: 0, rowOffPx: 0 };
if ( _this.isPointInside(x, y) ) {
var fv = _this.getFirstVisible();
var _x = x + _this.worksheet.getCellLeft(0, 0);
var _y = y + _this.worksheet.getCellTop(0, 0);
var xPt = _this.worksheet.objectRender.convertMetric(_x, 0, 1);
var yPt = _this.worksheet.objectRender.convertMetric(_y, 0, 1);
var offsetX = 0;// _this.worksheet.cols[fv.col].left - _this.worksheet.cellsLeft;
var offsetY = 0;//_this.worksheet.rows[fv.row].top - _this.worksheet.cellsTop;
/* Проверки на максимум в листе */
var isMaxCol = function() {
var result = false;
if ( _this.worksheet.cols.length >= gc_nMaxCol )
result = true;
return result;
}
var isMaxRow = function() {
var result = false;
if ( _this.worksheet.rows.length >= gc_nMaxRow )
result = true;
return result;
}
//
var delta = 0;
var what = roundPlus(xPt - offsetX, 3);
var col = _this.worksheet._findColUnderCursor( what, true );
while (col == null) {
if ( isMaxCol() ) {
col = _this.worksheet._findColUnderCursor( _this.worksheet.cols[gc_nMaxCol - 1].left - 1, true );
break;
}
_this.worksheet.expandColsOnScroll(true);
_this.worksheet.handlers.trigger("reinitializeScrollX");
col = _this.worksheet._findColUnderCursor( what + delta, true );
if ( what < 0 )
delta++;
}
cell.col = col.col;
cell.colOffPx = Math.max(0, _x - _this.worksheet.getCellLeft(cell.col, 0));
cell.colOff = _this.worksheet.objectRender.convertMetric(cell.colOffPx, 0, 3);
delta = 0;
what = roundPlus(yPt - offsetY, 3);
var row = _this.worksheet._findRowUnderCursor( what, true );
while (row == null) {
if ( isMaxRow() ) {
row = _this.worksheet._findRowUnderCursor( _this.worksheet.rows[gc_nMaxRow - 1].top - 1, true );
break;
}
_this.worksheet.expandRowsOnScroll(true);
_this.worksheet.handlers.trigger("reinitializeScrollY");
row = _this.worksheet._findRowUnderCursor( what + delta, true );
if ( what < 0 )
delta++;
}
cell.row = row.row;
cell.rowOffPx = Math.max(0, _y - _this.worksheet.getCellTop(cell.row, 0));
cell.rowOff = _this.worksheet.objectRender.convertMetric(cell.rowOffPx, 0, 3);
}
return cell;
}
// Range constructor
_this.initRange();
......@@ -528,10 +594,10 @@ function DrawingArea(ws) {
}
}
_this.drawObject = function(object, canvas) {
_this.drawObject = function(object) {
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) {
if ( _this.frozenPlaces[i].isObjectInside(object) ) {
_this.frozenPlaces[i].drawObject(object, canvas);
_this.frozenPlaces[i].drawObject(object);
}
}
}
......@@ -570,7 +636,7 @@ function DrawingArea(ws) {
if (null == drawingDocument.m_oDocumentRenderer) {
if (drawingDocument.m_bIsSelection) {
if (drawingDocument.m_bIsSelection ) {
if (drawingDocument.m_bIsSelection) {
trackOverlay.m_oControl.HtmlElement.style.display = "block";
if (null == trackOverlay.m_oContext)
......@@ -584,21 +650,18 @@ function DrawingArea(ws) {
ctx.globalAlpha = 1.0;
_this.worksheet.objectRender.controller.drawSelection(drawingDocument);
if (_this.worksheet.objectRender.controller.needUpdateOverlay()) {
if ( _this.worksheet.objectRender.controller.needUpdateOverlay() ) {
trackOverlay.Show();
shapeOverlayCtx.put_GlobalAlpha(true, 0.5);
_this.worksheet.objectRender.controller.drawTracks(shapeOverlayCtx);
shapeOverlayCtx.put_GlobalAlpha(true, 1);
}
}
else
{
else {
ctx.fillStyle = "rgba(51,102,204,255)";
ctx.beginPath();
for (var i = drawingDocument.m_lDrawingFirst; i <= drawingDocument.m_lDrawingEnd; i++)
{
for (var i = drawingDocument.m_lDrawingFirst; i <= drawingDocument.m_lDrawingEnd; i++) {
var drawPage = drawingDocument.m_arrPages[i].drawingPage;
drawingDocument.m_oDocumentRenderer.DrawSelection(i, trackOverlay, drawPage.left, drawPage.top, drawPage.right - drawPage.left, drawPage.bottom - drawPage.top);
}
......@@ -623,4 +686,20 @@ function DrawingArea(ws) {
}
return null;
}
_this.calculateCell = function(x, y) {
var cell = { col: 0, colOff: 0, colOffPx: 0,
row: 0, rowOff: 0, rowOffPx: 0 };
for ( var i = 0; i < _this.frozenPlaces.length; i++ ) {
if ( _this.frozenPlaces[i].isPointInside(x, y) ) {
cell = _this.frozenPlaces[i].calculateCell(x, y);
break;
}
}
return cell;
}
_this.calculateCoords = function(cell) {
}
}
\ No newline at end of file
......@@ -2723,8 +2723,10 @@ function DrawingObjects() {
if ( (_t.graphicObject.x < 0) || (_t.graphicObject.y < 0) || (_t.graphicObject.extX <= 0) || (_t.graphicObject.extY <= 0) )
return;
var fromCell = _this.coordsManager.calculateCell( mmToPx(_t.graphicObject.x), mmToPx(_t.graphicObject.y) );
var toCell = _this.coordsManager.calculateCell( mmToPx(_t.graphicObject.x + _t.graphicObject.extX), mmToPx(_t.graphicObject.y + _t.graphicObject.extY) );
//var fromCell = _this.coordsManager.calculateCell( mmToPx(_t.graphicObject.x), mmToPx(_t.graphicObject.y) );
//var toCell = _this.coordsManager.calculateCell( mmToPx(_t.graphicObject.x + _t.graphicObject.extX), mmToPx(_t.graphicObject.y + _t.graphicObject.extY) );
var fromCell = _this.drawingArea.calculateCell( mmToPx(_t.graphicObject.x), mmToPx(_t.graphicObject.y) );
var toCell = _this.drawingArea.calculateCell( mmToPx(_t.graphicObject.x + _t.graphicObject.extX), mmToPx(_t.graphicObject.y + _t.graphicObject.extY) );
_t.from.col = fromCell.col;
_t.from.colOff = fromCell.colOff;
......@@ -3199,33 +3201,37 @@ function DrawingObjects() {
_this._uploadMessage = function(event) {
if ( null != event && null != event.data ) {
var data = JSON.parse(event.data);
if ((null != data) && (null != data["type"]))
{
if (PostMessageType.UploadImage == data["type"]) {
if (c_oAscServerError.NoError == data["error"]) {
var sheetId = null;
if (null != data["input"])
sheetId = data["input"]["sheetId"];
var urls = data["urls"];
if (urls && urls.length > 0 && sheetId == worksheet.model.getId()) {
var url = urls[0];
if ( api.isImageChangeUrl || api.isShapeImageChangeUrl )
_this.editImageDrawingObject(url);
try {
var data = JSON.parse(event.data);
if ((null != data) && (null != data["type"]))
{
if (PostMessageType.UploadImage == data["type"]) {
if (c_oAscServerError.NoError == data["error"]) {
var sheetId = null;
if (null != data["input"])
sheetId = data["input"]["sheetId"];
var urls = data["urls"];
if (urls && urls.length > 0 && sheetId == worksheet.model.getId()) {
var url = urls[0];
if ( api.isImageChangeUrl || api.isShapeImageChangeUrl )
_this.editImageDrawingObject(url);
else
_this.addImageDrawingObject(url, null);
}
else
_this.addImageDrawingObject(url, null);
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
else
else {
worksheet.model.workbook.handlers.trigger("asc_onError", api.asc_mapAscServerErrorToAscError(data["error"]), c_oAscError.Level.NoCritical);
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
else {
worksheet.model.workbook.handlers.trigger("asc_onError", api.asc_mapAscServerErrorToAscError(data["error"]), c_oAscError.Level.NoCritical);
worksheet.model.workbook.handlers.trigger("asc_onEndAction", c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.LoadImage);
}
}
}
}
catch(e) {
var msg = e.message;
}
}
}
......@@ -3333,22 +3339,7 @@ function DrawingObjects() {
worksheet._drawCellsBorders(/*drawingCtx*/undefined, r_);
}
}
}
_this.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 };
}
}
//-----------------------------------------------------------------------------------
// Drawing objects
......@@ -4757,28 +4748,11 @@ function DrawingObjects() {
}
_this.setScrollOffset = function() {
if ( shapeCtx && shapeOverlayCtx && autoShapeTrack ) {
/*var x = scrollOffset.getX();
var y = scrollOffset.getY();
shapeCtx.m_oCoordTransform.tx = x;
shapeCtx.m_oCoordTransform.ty = y;
shapeCtx.CalculateFullTransform();
shapeOverlayCtx.m_oCoordTransform.tx = x;
shapeOverlayCtx.m_oCoordTransform.ty = y;
shapeOverlayCtx.CalculateFullTransform();
autoShapeTrack.Graphics.m_oCoordTransform.tx = x;
autoShapeTrack.Graphics.m_oCoordTransform.ty = y;
autoShapeTrack.Graphics.CalculateFullTransform();
this.controller.recalculateCurPos();
if ( _this.selectedGraphicObjectsExists() )
this.controller.updateSelectionState();*/
}
/*if ( shapeCtx && shapeOverlayCtx && autoShapeTrack ) {
for (var i = 0; i < _this.drawingArea.frozenPlaces.length; i++) {
_this.drawingArea.frozenPlaces[i].setTransform(shapeCtx, shapeOverlayCtx, autoShapeTrack);
}
}*/
}
_this.getDrawingCanvas = function() {
......@@ -5197,6 +5171,7 @@ function DrawingObjects() {
}
_this.checkCursorDrawingObject = function(x, y) {
var offsets = _this.drawingArea.getOffsets(x, y);
if ( offsets ) {
var objectInfo = { cursor: null, id: null, object: null };
......@@ -5537,9 +5512,7 @@ function CoordsManager(ws, bLog) {
}
}
//-----------------------------------------------------------------------------------
// Common
//-----------------------------------------------------------------------------------
//{ Common
function writeToBinaryDocContent(docContent, w)
{
......@@ -5745,3 +5718,4 @@ function getTextString(docContent)
}
return ret;
}
//}
......@@ -638,6 +638,10 @@
var graphicObjects = t.handlers.trigger("getSelectedGraphicObjects");
if ( !t.isMousePressed && graphicObjects.length && t.enableKeyEvents ) {
// Mac OS
if ( event.metaKey )
event.ctrlKey = true;
if (t.handlers.trigger("graphicObjectWindowKeyDown", event))
return true;
}
......
......@@ -1414,8 +1414,8 @@
ws = t.getWorksheet();
// Запрещаем копирование диаграмм в iframe
if ( t.Api.isChartEditor && ws.objectRender.selectedGraphicObjectsExists() )
return;
//if ( t.Api.isChartEditor && ws.objectRender.selectedGraphicObjectsExists() )
// return;
t.clipboard.copyRange(ws.getSelectedRange(), ws, true);
ws.emptySelection(c_oAscCleanOptions.All);
......
......@@ -6273,6 +6273,7 @@
};
WorksheetView.prototype.changeSelectionStartPoint = function (x, y, isCoord, isSelectMode) {
var ar = (this.isFormulaEditMode) ? this.arrActiveFormulaRanges[this.arrActiveFormulaRanges.length - 1]: this.activeRange;
var sc = ar.startCol, sr = ar.startRow, ret = {};
var isChangeSelectionShape = false;
......
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