Commit 8ec4d9ed authored by Alexander.Trofimov's avatar Alexander.Trofimov

general function to hit in resize corner

parent 237529ef
...@@ -6225,90 +6225,88 @@ ...@@ -6225,90 +6225,88 @@
return null; return null;
}; };
WorksheetView.prototype._getCursorFormulaOrChart = function ( vr, x, y, offsetX, offsetY ) { WorksheetView.prototype._hitResizeCorner = function (x1, y1, x2, y2) {
var wEps = this.width_1px, hEps = this.height_1px;
return Math.abs(x2 - x1) <= wEps + this.width_2px && Math.abs(y2 - y1) <= hEps + this.height_2px;
};
WorksheetView.prototype._getCursorFormulaOrChart = function (vr, x, y, offsetX, offsetY) {
var i, l; var i, l;
var cursor, oFormulaRange, oFormulaRangeIn, xFormula1, xFormula2, yFormula1, yFormula2; var cursor, oFormulaRange, oFormulaRangeIn, xFormula1, xFormula2, yFormula1, yFormula2;
var col = -1, row = -1; var col = -1, row = -1;
var arrRanges = this.isFormulaEditMode ? this.arrActiveFormulaRanges : this.arrActiveChartsRanges, targetArr = this.isFormulaEditMode ? 0 : -1; var arrRanges = this.isFormulaEditMode ? this.arrActiveFormulaRanges :
var ppiX = this._getPPIX(), ppiY = this._getPPIY(); this.arrActiveChartsRanges, targetArr = this.isFormulaEditMode ? 0 : -1;
var width_1px = asc_calcnpt( 0, ppiX, 1/*px*/ ), var wEps = this.width_2px, hEps = this.height_2px;
width_2px = asc_calcnpt( 0, ppiX, 2/*px*/ ),
width_3px = asc_calcnpt( 0, ppiX, 3/*px*/ ), for (i = 0, l = arrRanges.length; i < l; ++i) {
width_4px = asc_calcnpt( 0, ppiX, 4/*px*/ ), oFormulaRange = arrRanges[i].clone(true);
width_5px = asc_calcnpt( 0, ppiX, 5/*px*/ ),
width_7px = asc_calcnpt( 0, ppiX, 7/*px*/ ),
height_1px = asc_calcnpt( 0, ppiY, 1/*px*/ ),
height_2px = asc_calcnpt( 0, ppiY, 2/*px*/ ),
height_3px = asc_calcnpt( 0, ppiY, 3/*px*/ ),
height_4px = asc_calcnpt( 0, ppiY, 4/*px*/ ),
height_5px = asc_calcnpt( 0, ppiY, 5/*px*/ ),
height_7px = asc_calcnpt( 0, ppiY, 7/*px*/ );
for ( i = 0, l = arrRanges.length; i < l; ++i ) {
oFormulaRange = arrRanges[i].clone( true );
oFormulaRange.isName = arrRanges[i].isName; oFormulaRange.isName = arrRanges[i].isName;
oFormulaRangeIn = oFormulaRange.intersectionSimple( vr ); oFormulaRangeIn = oFormulaRange.intersectionSimple(vr);
if ( oFormulaRangeIn && !oFormulaRange.isName ) { if (oFormulaRangeIn && !oFormulaRange.isName) {
xFormula1 = this.cols[oFormulaRangeIn.c1].left - offsetX; xFormula1 = this.cols[oFormulaRangeIn.c1].left - offsetX;
xFormula2 = this.cols[oFormulaRangeIn.c2].left + this.cols[oFormulaRangeIn.c2].width - offsetX; xFormula2 = this.cols[oFormulaRangeIn.c2].left + this.cols[oFormulaRangeIn.c2].width - offsetX;
yFormula1 = this.rows[oFormulaRangeIn.r1].top - offsetY; yFormula1 = this.rows[oFormulaRangeIn.r1].top - offsetY;
yFormula2 = this.rows[oFormulaRangeIn.r2].top + this.rows[oFormulaRangeIn.r2].height - offsetY; yFormula2 = this.rows[oFormulaRangeIn.r2].top + this.rows[oFormulaRangeIn.r2].height - offsetY;
if ( (x >= xFormula1 + width_3px && x <= xFormula2 - width_5px) && if (this.hitResizeCorner(xFormula1 - this.width_1px, yFormula1 - this.height_1px, x, y)) {
((y >= yFormula1 - height_2px && y <= yFormula1 + height_2px) || (y >= yFormula2 - height_2px && y <= yFormula2 + height_2px)) || /*TOP-LEFT*/
(y >= yFormula1 + height_3px && y <= yFormula2 - height_5px) &&
((x >= xFormula1 - width_2px && x <= xFormula1 + width_2px) || (x >= xFormula2 - width_2px && x <= xFormula2 + width_2px)) ) {
cursor = kCurMove;
break;
}
else if ( x >= xFormula1 - width_3px && x < xFormula1 + width_2px && y >= yFormula1 - height_3px && y < yFormula1 + height_2px ) {/*TOP-LEFT*/
cursor = kCurSEResize; cursor = kCurSEResize;
col = oFormulaRange.c2; col = oFormulaRange.c2;
row = oFormulaRange.r2; row = oFormulaRange.r2;
break; break;
} } else if (this.hitResizeCorner(xFormula2, yFormula1 - this.height_1px, x, y)) {
else if ( x > xFormula2 - width_3px && x <= xFormula2 + width_2px && y >= yFormula1 - height_3px && y < yFormula1 + height_2px ) {/*TOP-RIGHT*/ /*TOP-RIGHT*/
cursor = kCurNEResize; cursor = kCurNEResize;
col = oFormulaRange.c1;
row = oFormulaRange.r2;
break;
}
else if ( x > xFormula2 - width_3px && x <= xFormula2 + width_2px && y > yFormula2 - height_3px && y <= yFormula2 + height_2px ) {/*BOTTOM-RIGHT*/
cursor = kCurSEResize;
col = oFormulaRange.c1; col = oFormulaRange.c1;
row = oFormulaRange.r1; row = oFormulaRange.r2;
break; break;
} } else if (this.hitResizeCorner(xFormula1 - this.width_1px, yFormula2, x, y)) {
else if ( x >= xFormula1 - width_3px && x < xFormula1 + width_2px && y > yFormula2 - height_3px && y <= yFormula2 + height_2px ) {/*BOTTOM-LEFT*/ /*BOTTOM-LEFT*/
cursor = kCurNEResize; cursor = kCurNEResize;
col = oFormulaRange.c2; col = oFormulaRange.c2;
row = oFormulaRange.r1; row = oFormulaRange.r1;
break; break;
} else if (this.hitResizeCorner(xFormula2, yFormula2, x, y)) {
/*BOTTOM-RIGHT*/
cursor = kCurSEResize;
col = oFormulaRange.c1;
row = oFormulaRange.r1;
break;
} else if (((Math.abs(x - xFormula1) <= wEps || Math.abs(x - xFormula2) <= wEps) &&
hEps <= y - yFormula1 && y - yFormula2 <= hEps) ||
((Math.abs(y - yFormula1) <= hEps || Math.abs(y - yFormula2) <= hEps) && wEps <= x - xFormula1 &&
x - xFormula2 <= wEps)) {
cursor = kCurMove;
break;
} }
} }
} }
return cursor ? { return cursor ? {
cursor : cursor, cursor: cursor,
target : c_oTargetType.MoveResizeRange, target: c_oTargetType.MoveResizeRange,
col : col, col: col,
row : row, row: row,
formulaRange : oFormulaRange, formulaRange: oFormulaRange,
indexFormulaRange: i, indexFormulaRange: i,
targetArr : targetArr targetArr: targetArr
} : null; } : null;
}; };
WorksheetView.prototype._isCursorOnSelectionBorder = function ( ar, vr, x, y ) { WorksheetView.prototype._isCursorOnSelectionBorder = function (ar, vr, x, y) {
var arIntersection = ar.intersectionSimple( vr ); var arIntersection = ar.intersectionSimple(vr);
var left, top, right, bottom, wEps = this.width_2px, hEps = this.height_2px; var left, top, right, bottom, wEps = this.width_2px, hEps = this.height_2px;
if ( arIntersection ) { if (arIntersection) {
left = ar.c1 === arIntersection.c1 ? this.cols[ar.c1].left : null; left = ar.c1 === arIntersection.c1 ? this.cols[ar.c1].left : null;
right = ar.c2 === arIntersection.c2 ? this.cols[ar.c2].left + this.cols[ar.c2].width : null; right = ar.c2 === arIntersection.c2 ? this.cols[ar.c2].left + this.cols[ar.c2].width : null;
top = ar.r1 === arIntersection.r1 ? this.rows[ar.r1].top : null; top = ar.r1 === arIntersection.r1 ? this.rows[ar.r1].top : null;
bottom = ar.r2 === arIntersection.r2 ? this.rows[ar.r2].top + this.rows[ar.r2].height : null; bottom = ar.r2 === arIntersection.r2 ? this.rows[ar.r2].top + this.rows[ar.r2].height : null;
var isLeft = (null !== left && x >= left - wEps && x <= left + wEps), isRight = (null !== right && x >= right - wEps && x <= right + wEps), isTop = (null !== top && y >= top - hEps && y <= top + hEps), isBottom = (null !== bottom && y >= bottom - hEps && y <= bottom + hEps), isHorMiddle = ((null === left || x >= left - wEps) && (null === right || x <= right + wEps)), isVerMiddle = ((null === top || y >= top - hEps) && (null === bottom || y <= bottom + hEps)); var isLeft = (null !== left && x >= left - wEps && x <= left + wEps), isRight = (null !== right &&
x >= right - wEps && x <= right + wEps), isTop = (null !== top && y >= top - hEps &&
if ( ((isLeft || isRight) && isVerMiddle) || ((isTop || isBottom) && isHorMiddle) ) { y <= top + hEps), isBottom = (null !== bottom && y >= bottom - hEps &&
y <= bottom + hEps), isHorMiddle = ((null === left || x >= left - wEps) &&
(null === right || x <= right + wEps)), isVerMiddle = ((null === top || y >= top - hEps) &&
(null === bottom || y <= bottom + hEps));
if (((isLeft || isRight) && isVerMiddle) || ((isTop || isBottom) && isHorMiddle)) {
// Мы навели на границу выделения // Мы навели на границу выделения
return true; return true;
} }
...@@ -6316,92 +6314,94 @@ ...@@ -6316,92 +6314,94 @@
return false; return false;
}; };
WorksheetView.prototype.getCursorTypeFromXY = function ( x, y, isViewerMode ) { WorksheetView.prototype.getCursorTypeFromXY = function (x, y, isViewerMode) {
var c, r, f, i, offsetX, offsetY, cellCursor, sheetId = this.model.getId(), userId, lockRangePosLeft, lockRangePosTop, lockInfo, oHyperlink, widthDiff = 0, heightDiff = 0, isLocked = false, ar = this.activeRange, target = c_oTargetType.Cells, row = -1, col = -1, isSelGraphicObject, isNotFirst; var c, r, f, i, offsetX, offsetY, cellCursor, sheetId = this.model.getId(), userId, lockRangePosLeft, lockRangePosTop, lockInfo, oHyperlink, widthDiff = 0, heightDiff = 0, isLocked = false, ar = this.activeRange, target = c_oTargetType.Cells, row = -1, col = -1, isSelGraphicObject, isNotFirst;
var frozenCursor = this._isFrozenAnchor( x, y ); var frozenCursor = this._isFrozenAnchor(x, y);
if ( !isViewerMode && frozenCursor.result ) { if (!isViewerMode && frozenCursor.result) {
lockInfo = this.collaborativeEditing.getLockInfo( c_oAscLockTypeElem.Object, null, sheetId, AscCommonExcel.c_oAscLockNameFrozenPane ); lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, sheetId,
isLocked = this.collaborativeEditing.getLockIntersection( lockInfo, c_oAscLockTypes.kLockTypeOther, false ); AscCommonExcel.c_oAscLockNameFrozenPane);
if ( false !== isLocked ) { isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther, false);
if (false !== isLocked) {
// Кто-то сделал lock // Кто-то сделал lock
var frozenCell = this.topLeftFrozenCell ? this.topLeftFrozenCell : new AscCommon.CellAddress( 0, 0, 0 ); var frozenCell = this.topLeftFrozenCell ? this.topLeftFrozenCell : new AscCommon.CellAddress(0, 0, 0);
userId = isLocked.UserId; userId = isLocked.UserId;
lockRangePosLeft = this.getCellLeft( frozenCell.getCol0(), 0 ); lockRangePosLeft = this.getCellLeft(frozenCell.getCol0(), 0);
lockRangePosTop = this.getCellTop( frozenCell.getRow0(), 0 ); lockRangePosTop = this.getCellTop(frozenCell.getRow0(), 0);
} }
return { return {
cursor : frozenCursor.cursor, cursor: frozenCursor.cursor,
target : frozenCursor.name, target: frozenCursor.name,
col : -1, col: -1,
row : -1, row: -1,
userId : userId, userId: userId,
lockRangePosLeft: lockRangePosLeft, lockRangePosLeft: lockRangePosLeft,
lockRangePosTop : lockRangePosTop lockRangePosTop: lockRangePosTop
}; };
} }
var drawingInfo = this.objectRender.checkCursorDrawingObject( x, y ); var drawingInfo = this.objectRender.checkCursorDrawingObject(x, y);
if ( asc["editor"].isStartAddShape && AscCommonExcel.CheckIdSatetShapeAdd( this.objectRender.controller.curState ) ) { if (asc["editor"].isStartAddShape &&
AscCommonExcel.CheckIdSatetShapeAdd(this.objectRender.controller.curState)) {
return {cursor: kCurFillHandle, target: c_oTargetType.Shape, col: -1, row: -1}; return {cursor: kCurFillHandle, target: c_oTargetType.Shape, col: -1, row: -1};
} }
if ( drawingInfo && drawingInfo.id ) { if (drawingInfo && drawingInfo.id) {
// Возможно картинка с lock // Возможно картинка с lock
lockInfo = this.collaborativeEditing.getLockInfo( c_oAscLockTypeElem.Object, null, sheetId, drawingInfo.id ); lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, sheetId, drawingInfo.id);
isLocked = this.collaborativeEditing.getLockIntersection( lockInfo, c_oAscLockTypes.kLockTypeOther, false ); isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther, false);
if ( false !== isLocked ) { if (false !== isLocked) {
// Кто-то сделал lock // Кто-то сделал lock
userId = isLocked.UserId; userId = isLocked.UserId;
lockRangePosLeft = drawingInfo.object.getVisibleLeftOffset( true ); lockRangePosLeft = drawingInfo.object.getVisibleLeftOffset(true);
lockRangePosTop = drawingInfo.object.getVisibleTopOffset( true ); lockRangePosTop = drawingInfo.object.getVisibleTopOffset(true);
} }
if ( drawingInfo.hyperlink instanceof ParaHyperlink ) { if (drawingInfo.hyperlink instanceof ParaHyperlink) {
oHyperlink = new AscCommonExcel.Hyperlink(); oHyperlink = new AscCommonExcel.Hyperlink();
oHyperlink.Tooltip = drawingInfo.hyperlink.ToolTip; oHyperlink.Tooltip = drawingInfo.hyperlink.ToolTip;
var spl = drawingInfo.hyperlink.Value.split( "!" ); var spl = drawingInfo.hyperlink.Value.split("!");
if ( spl.length === 2 ) { if (spl.length === 2) {
oHyperlink.setLocation( drawingInfo.hyperlink.Value ); oHyperlink.setLocation(drawingInfo.hyperlink.Value);
} } else {
else {
oHyperlink.Hyperlink = drawingInfo.hyperlink.Value; oHyperlink.Hyperlink = drawingInfo.hyperlink.Value;
} }
cellCursor = {cursor: drawingInfo.cursor, target: c_oTargetType.Cells, col: -1, row: -1, userId: userId}; cellCursor =
{cursor: drawingInfo.cursor, target: c_oTargetType.Cells, col: -1, row: -1, userId: userId};
return { return {
cursor : kCurHyperlink, cursor: kCurHyperlink,
target : c_oTargetType.Hyperlink, target: c_oTargetType.Hyperlink,
hyperlink : new asc_CHyperlink( oHyperlink ), hyperlink: new asc_CHyperlink(oHyperlink),
cellCursor: cellCursor, cellCursor: cellCursor,
userId : userId userId: userId
}; };
} }
return { return {
cursor : drawingInfo.cursor, cursor: drawingInfo.cursor,
target : c_oTargetType.Shape, target: c_oTargetType.Shape,
drawingId : drawingInfo.id, drawingId: drawingInfo.id,
col : -1, col: -1,
row : -1, row: -1,
userId : userId, userId: userId,
lockRangePosLeft: lockRangePosLeft, lockRangePosLeft: lockRangePosLeft,
lockRangePosTop : lockRangePosTop lockRangePosTop: lockRangePosTop
}; };
} }
x *= asc_getcvt( 0/*px*/, 1/*pt*/, this._getPPIX() ); x *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIX());
y *= asc_getcvt( 0/*px*/, 1/*pt*/, this._getPPIY() ); y *= asc_getcvt(0/*px*/, 1/*pt*/, this._getPPIY());
var oResDefault = {cursor: kCurDefault, target: c_oTargetType.None, col: -1, row: -1}; var oResDefault = {cursor: kCurDefault, target: c_oTargetType.None, col: -1, row: -1};
if ( x < this.cellsLeft && y < this.cellsTop ) { if (x < this.cellsLeft && y < this.cellsTop) {
return {cursor: kCurCorner, target: c_oTargetType.Corner, col: -1, row: -1}; return {cursor: kCurCorner, target: c_oTargetType.Corner, col: -1, row: -1};
} }
var cFrozen = -1, rFrozen = -1; var cFrozen = -1, rFrozen = -1;
offsetX = this.cols[this.visibleRange.c1].left - this.cellsLeft; offsetX = this.cols[this.visibleRange.c1].left - this.cellsLeft;
offsetY = this.rows[this.visibleRange.r1].top - this.cellsTop; offsetY = this.rows[this.visibleRange.r1].top - this.cellsTop;
if ( this.topLeftFrozenCell ) { if (this.topLeftFrozenCell) {
cFrozen = this.topLeftFrozenCell.getCol0(); cFrozen = this.topLeftFrozenCell.getCol0();
rFrozen = this.topLeftFrozenCell.getRow0(); rFrozen = this.topLeftFrozenCell.getRow0();
widthDiff = this.cols[cFrozen].left - this.cols[0].left; widthDiff = this.cols[cFrozen].left - this.cols[0].left;
...@@ -6411,9 +6411,9 @@ ...@@ -6411,9 +6411,9 @@
offsetY = (y < this.cellsTop + heightDiff) ? 0 : offsetY - heightDiff; offsetY = (y < this.cellsTop + heightDiff) ? 0 : offsetY - heightDiff;
} }
if ( x <= this.cellsLeft && y >= this.cellsTop ) { if (x <= this.cellsLeft && y >= this.cellsTop) {
r = this._findRowUnderCursor( y, true ); r = this._findRowUnderCursor(y, true);
if ( r === null ) { if (r === null) {
return oResDefault; return oResDefault;
} }
isNotFirst = (r.row !== (-1 !== rFrozen ? 0 : this.visibleRange.r1)); isNotFirst = (r.row !== (-1 !== rFrozen ? 0 : this.visibleRange.r1));
...@@ -6422,14 +6422,14 @@ ...@@ -6422,14 +6422,14 @@
return { return {
cursor: f ? kCurRowResize : kCurRowSelect, cursor: f ? kCurRowResize : kCurRowSelect,
target: f ? c_oTargetType.RowResize : c_oTargetType.RowHeader, target: f ? c_oTargetType.RowResize : c_oTargetType.RowHeader,
col : -1, col: -1,
row : r.row + (isNotFirst && f && y < r.top + 3 ? -1 : 0), row: r.row + (isNotFirst && f && y < r.top + 3 ? -1 : 0),
mouseY: f ? ((y < r.top + 3) ? (r.top - y - this.height_1px) : (r.bottom - y - this.height_1px)) : null mouseY: f ? ((y < r.top + 3) ? (r.top - y - this.height_1px) : (r.bottom - y - this.height_1px)) : null
}; };
} }
if ( y <= this.cellsTop && x >= this.cellsLeft ) { if (y <= this.cellsTop && x >= this.cellsLeft) {
c = this._findColUnderCursor( x, true ); c = this._findColUnderCursor(x, true);
if ( c === null ) { if (c === null) {
return oResDefault; return oResDefault;
} }
isNotFirst = c.col !== (-1 !== cFrozen ? 0 : this.visibleRange.c1); isNotFirst = c.col !== (-1 !== cFrozen ? 0 : this.visibleRange.c1);
...@@ -6438,23 +6438,23 @@ ...@@ -6438,23 +6438,23 @@
return { return {
cursor: f ? kCurColResize : kCurColSelect, cursor: f ? kCurColResize : kCurColSelect,
target: f ? c_oTargetType.ColumnResize : c_oTargetType.ColumnHeader, target: f ? c_oTargetType.ColumnResize : c_oTargetType.ColumnHeader,
col : c.col + (isNotFirst && f && x < c.left + 3 ? -1 : 0), col: c.col + (isNotFirst && f && x < c.left + 3 ? -1 : 0),
row : -1, row: -1,
mouseX: f ? ((x < c.left + 3) ? (c.left - x - this.width_1px) : (c.right - x - this.width_1px)) : null mouseX: f ? ((x < c.left + 3) ? (c.left - x - this.width_1px) : (c.right - x - this.width_1px)) : null
}; };
} }
if ( this.stateFormatPainter ) { if (this.stateFormatPainter) {
if ( x <= this.cellsLeft && y >= this.cellsTop ) { if (x <= this.cellsLeft && y >= this.cellsTop) {
r = this._findRowUnderCursor( y, true ); r = this._findRowUnderCursor(y, true);
if ( r !== null ) { if (r !== null) {
target = c_oTargetType.RowHeader; target = c_oTargetType.RowHeader;
row = r.row; row = r.row;
} }
} }
if ( y <= this.cellsTop && x >= this.cellsLeft ) { if (y <= this.cellsTop && x >= this.cellsLeft) {
c = this._findColUnderCursor( x, true ); c = this._findColUnderCursor(x, true);
if ( c !== null ) { if (c !== null) {
target = c_oTargetType.ColumnHeader; target = c_oTargetType.ColumnHeader;
col = c.col; col = c.col;
} }
...@@ -6462,9 +6462,9 @@ ...@@ -6462,9 +6462,9 @@
return {cursor: kCurFormatPainterExcel, target: target, col: col, row: row}; return {cursor: kCurFormatPainterExcel, target: target, col: col, row: row};
} }
if ( this.isFormulaEditMode || this.isChartAreaEditMode ) { if (this.isFormulaEditMode || this.isChartAreaEditMode) {
var oFormulaOrChartCursor = this._getCursorFormulaOrChart( this.visibleRange, x, y, offsetX, offsetY ); var oFormulaOrChartCursor = this._getCursorFormulaOrChart(this.visibleRange, x, y, offsetX, offsetY);
if ( oFormulaOrChartCursor ) { if (oFormulaOrChartCursor) {
return oFormulaOrChartCursor; return oFormulaOrChartCursor;
} }
} }
...@@ -6473,47 +6473,49 @@ ...@@ -6473,47 +6473,49 @@
var yWithOffset = y + offsetY; var yWithOffset = y + offsetY;
isSelGraphicObject = this.objectRender.selectedGraphicObjectsExists(); isSelGraphicObject = this.objectRender.selectedGraphicObjectsExists();
if ( !isViewerMode && !isSelGraphicObject ) { if (!isViewerMode && !isSelGraphicObject) {
// Эпсилон для fillHandle // Эпсилон для fillHandle
var fillHandleEpsilon = this.width_1px; var fillHandleEpsilon = this.width_1px;
if ( !this.isChartAreaEditMode && x >= (this.fillHandleL - fillHandleEpsilon) && x <= (this.fillHandleR + fillHandleEpsilon) && y >= (this.fillHandleT - fillHandleEpsilon) && y <= (this.fillHandleB + fillHandleEpsilon) ) { if (!this.isChartAreaEditMode && x >= (this.fillHandleL - fillHandleEpsilon) &&
x <= (this.fillHandleR + fillHandleEpsilon) && y >= (this.fillHandleT - fillHandleEpsilon) &&
y <= (this.fillHandleB + fillHandleEpsilon)) {
// Мы на "квадрате" для автозаполнения // Мы на "квадрате" для автозаполнения
return {cursor: kCurFillHandle, target: c_oTargetType.FillHandle, col: -1, row: -1}; return {cursor: kCurFillHandle, target: c_oTargetType.FillHandle, col: -1, row: -1};
} }
// Навели на выделение (стоит вынести в отдельный метод) // Навели на выделение (стоит вынести в отдельный метод)
if ( this._isCursorOnSelectionBorder( ar, this.visibleRange, xWithOffset, yWithOffset ) ) { if (this._isCursorOnSelectionBorder(ar, this.visibleRange, xWithOffset, yWithOffset)) {
return {cursor: kCurMove, target: c_oTargetType.MoveRange, col: -1, row: -1}; return {cursor: kCurMove, target: c_oTargetType.MoveRange, col: -1, row: -1};
} }
if ( this.topLeftFrozenCell ) { if (this.topLeftFrozenCell) {
var oFrozenRange; var oFrozenRange;
cFrozen -= 1; cFrozen -= 1;
rFrozen -= 1; rFrozen -= 1;
if ( 0 <= cFrozen && 0 <= rFrozen ) { if (0 <= cFrozen && 0 <= rFrozen) {
oFrozenRange = new asc_Range( 0, 0, cFrozen, rFrozen ); oFrozenRange = new asc_Range(0, 0, cFrozen, rFrozen);
if ( this._isCursorOnSelectionBorder( ar, oFrozenRange, x, y ) ) { if (this._isCursorOnSelectionBorder(ar, oFrozenRange, x, y)) {
return {cursor: kCurMove, target: c_oTargetType.MoveRange, col: -1, row: -1}; return {cursor: kCurMove, target: c_oTargetType.MoveRange, col: -1, row: -1};
} }
} }
if ( 0 <= cFrozen ) { if (0 <= cFrozen) {
oFrozenRange = new asc_Range( 0, this.visibleRange.r1, cFrozen, this.visibleRange.r2 ); oFrozenRange = new asc_Range(0, this.visibleRange.r1, cFrozen, this.visibleRange.r2);
if ( this._isCursorOnSelectionBorder( ar, oFrozenRange, x, yWithOffset ) ) { if (this._isCursorOnSelectionBorder(ar, oFrozenRange, x, yWithOffset)) {
return {cursor: kCurMove, target: c_oTargetType.MoveRange, col: -1, row: -1}; return {cursor: kCurMove, target: c_oTargetType.MoveRange, col: -1, row: -1};
} }
} }
if ( 0 <= rFrozen ) { if (0 <= rFrozen) {
oFrozenRange = new asc_Range( this.visibleRange.c1, 0, this.visibleRange.c2, rFrozen ); oFrozenRange = new asc_Range(this.visibleRange.c1, 0, this.visibleRange.c2, rFrozen);
if ( this._isCursorOnSelectionBorder( ar, oFrozenRange, xWithOffset, y ) ) { if (this._isCursorOnSelectionBorder(ar, oFrozenRange, xWithOffset, y)) {
return {cursor: kCurMove, target: c_oTargetType.MoveRange, col: -1, row: -1}; return {cursor: kCurMove, target: c_oTargetType.MoveRange, col: -1, row: -1};
} }
} }
} }
} }
if ( x > this.cellsLeft && y > this.cellsTop ) { if (x > this.cellsLeft && y > this.cellsTop) {
c = this._findColUnderCursor( x, true ); c = this._findColUnderCursor(x, true);
r = this._findRowUnderCursor( y, true ); r = this._findRowUnderCursor(y, true);
if ( c === null || r === null ) { if (c === null || r === null) {
return oResDefault; return oResDefault;
} }
...@@ -6523,115 +6525,126 @@ ...@@ -6523,115 +6525,126 @@
var lockAllPosTop = undefined; var lockAllPosTop = undefined;
var userIdAllProps = undefined; var userIdAllProps = undefined;
var userIdAllSheet = undefined; var userIdAllSheet = undefined;
if ( !isViewerMode && this.collaborativeEditing.getCollaborativeEditing() ) { if (!isViewerMode && this.collaborativeEditing.getCollaborativeEditing()) {
var c1Recalc = null, r1Recalc = null; var c1Recalc = null, r1Recalc = null;
var selectRangeRecalc = new asc_Range( c.col, r.row, c.col, r.row ); var selectRangeRecalc = new asc_Range(c.col, r.row, c.col, r.row);
// Пересчет для входящих ячеек в добавленные строки/столбцы // Пересчет для входящих ячеек в добавленные строки/столбцы
var isIntersection = this._recalcRangeByInsertRowsAndColumns( sheetId, selectRangeRecalc ); var isIntersection = this._recalcRangeByInsertRowsAndColumns(sheetId, selectRangeRecalc);
if ( false === isIntersection ) { if (false === isIntersection) {
lockInfo = this.collaborativeEditing.getLockInfo( c_oAscLockTypeElem.Range, /*subType*/null, sheetId, new AscCommonExcel.asc_CCollaborativeRange( selectRangeRecalc.c1, selectRangeRecalc.r1, selectRangeRecalc.c2, selectRangeRecalc.r2 ) ); lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Range, /*subType*/null, sheetId,
isLocked = this.collaborativeEditing.getLockIntersection( lockInfo, c_oAscLockTypes.kLockTypeOther, /*bCheckOnlyLockAll*/false ); new AscCommonExcel.asc_CCollaborativeRange(selectRangeRecalc.c1, selectRangeRecalc.r1, selectRangeRecalc.c2, selectRangeRecalc.r2));
if ( false !== isLocked ) { isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther,
/*bCheckOnlyLockAll*/false);
if (false !== isLocked) {
// Кто-то сделал lock // Кто-то сделал lock
userId = isLocked.UserId; userId = isLocked.UserId;
lockRange = isLocked.Element["rangeOrObjectId"]; lockRange = isLocked.Element["rangeOrObjectId"];
c1Recalc = this.collaborativeEditing.m_oRecalcIndexColumns[sheetId].getLockOther( lockRange["c1"], c_oAscLockTypes.kLockTypeOther ); c1Recalc =
r1Recalc = this.collaborativeEditing.m_oRecalcIndexRows[sheetId].getLockOther( lockRange["r1"], c_oAscLockTypes.kLockTypeOther ); this.collaborativeEditing.m_oRecalcIndexColumns[sheetId].getLockOther(lockRange["c1"],
if ( null !== c1Recalc && null !== r1Recalc ) { c_oAscLockTypes.kLockTypeOther);
lockRangePosLeft = this.getCellLeft( c1Recalc, /*pt*/1 ); r1Recalc = this.collaborativeEditing.m_oRecalcIndexRows[sheetId].getLockOther(lockRange["r1"],
lockRangePosTop = this.getCellTop( r1Recalc, /*pt*/1 ); c_oAscLockTypes.kLockTypeOther);
if (null !== c1Recalc && null !== r1Recalc) {
lockRangePosLeft = this.getCellLeft(c1Recalc, /*pt*/1);
lockRangePosTop = this.getCellTop(r1Recalc, /*pt*/1);
// Пересчитываем X и Y относительно видимой области // Пересчитываем X и Y относительно видимой области
lockRangePosLeft -= offsetX; lockRangePosLeft -= offsetX;
lockRangePosTop -= offsetY; lockRangePosTop -= offsetY;
// Пересчитываем в px // Пересчитываем в px
lockRangePosLeft *= asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() ); lockRangePosLeft *= asc_getcvt(1/*pt*/, 0/*px*/, this._getPPIX());
lockRangePosTop *= asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIY() ); lockRangePosTop *= asc_getcvt(1/*pt*/, 0/*px*/, this._getPPIY());
} }
} }
} } else {
else { lockInfo =
lockInfo = this.collaborativeEditing.getLockInfo( c_oAscLockTypeElem.Range, /*subType*/null, sheetId, null ); this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Range, /*subType*/null, sheetId, null);
} }
// Проверим не удален ли весь лист (именно удален, т.к. если просто залочен, то не рисуем рамку вокруг) // Проверим не удален ли весь лист (именно удален, т.к. если просто залочен, то не рисуем рамку вокруг)
lockInfo["type"] = c_oAscLockTypeElem.Sheet; lockInfo["type"] = c_oAscLockTypeElem.Sheet;
isLocked = this.collaborativeEditing.getLockIntersection( lockInfo, c_oAscLockTypes.kLockTypeOther, /*bCheckOnlyLockAll*/true ); isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther,
if ( false !== isLocked ) { /*bCheckOnlyLockAll*/true);
if (false !== isLocked) {
// Кто-то сделал lock // Кто-то сделал lock
userIdAllSheet = isLocked.UserId; userIdAllSheet = isLocked.UserId;
lockAllPosLeft = this.cellsLeft * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() ); lockAllPosLeft = this.cellsLeft * asc_getcvt(1/*pt*/, 0/*px*/, this._getPPIX());
lockAllPosTop = this.cellsTop * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIY() ); lockAllPosTop = this.cellsTop * asc_getcvt(1/*pt*/, 0/*px*/, this._getPPIY());
} }
// Проверим не залочены ли все свойства листа (только если не удален весь лист) // Проверим не залочены ли все свойства листа (только если не удален весь лист)
if ( undefined === userIdAllSheet ) { if (undefined === userIdAllSheet) {
lockInfo["type"] = c_oAscLockTypeElem.Range; lockInfo["type"] = c_oAscLockTypeElem.Range;
lockInfo["subType"] = c_oAscLockTypeElemSubType.InsertRows; lockInfo["subType"] = c_oAscLockTypeElemSubType.InsertRows;
isLocked = this.collaborativeEditing.getLockIntersection( lockInfo, c_oAscLockTypes.kLockTypeOther, /*bCheckOnlyLockAll*/true ); isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther,
if ( false !== isLocked ) { /*bCheckOnlyLockAll*/true);
if (false !== isLocked) {
// Кто-то сделал lock // Кто-то сделал lock
userIdAllProps = isLocked.UserId; userIdAllProps = isLocked.UserId;
lockAllPosLeft = this.cellsLeft * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIX() ); lockAllPosLeft = this.cellsLeft * asc_getcvt(1/*pt*/, 0/*px*/, this._getPPIX());
lockAllPosTop = this.cellsTop * asc_getcvt( 1/*pt*/, 0/*px*/, this._getPPIY() ); lockAllPosTop = this.cellsTop * asc_getcvt(1/*pt*/, 0/*px*/, this._getPPIY());
} }
} }
} }
var autoFilterInfo = this.af_checkCursor( x, y, offsetX, offsetY, { var autoFilterInfo = this.af_checkCursor(x, y, offsetX, offsetY, {
cFrozen: cFrozen, rFrozen: rFrozen cFrozen: cFrozen, rFrozen: rFrozen
}, r, c ); }, r, c);
if ( autoFilterInfo && !isViewerMode ) { if (autoFilterInfo && !isViewerMode) {
return { return {
cursor: kCurAutoFilter, target: c_oTargetType.FilterObject, col: -1, row: -1, idFilter: autoFilterInfo.id cursor: kCurAutoFilter,
target: c_oTargetType.FilterObject,
col: -1,
row: -1,
idFilter: autoFilterInfo.id
}; };
} }
// Проверим есть ли комменты // Проверим есть ли комменты
var comments = this.cellCommentator.getComments( c.col, r.row ); var comments = this.cellCommentator.getComments(c.col, r.row);
var coords = undefined; var coords = undefined;
var indexes = undefined; var indexes = undefined;
if ( 0 < comments.length ) { if (0 < comments.length) {
indexes = []; indexes = [];
for ( i = 0; i < comments.length; ++i ) { for (i = 0; i < comments.length; ++i) {
indexes.push( comments[i].asc_getId() ); indexes.push(comments[i].asc_getId());
} }
coords = this.cellCommentator.getCommentsCoords( comments ); coords = this.cellCommentator.getCommentsCoords(comments);
} }
// Проверим, может мы в гиперлинке // Проверим, может мы в гиперлинке
oHyperlink = this.model.getHyperlinkByCell( r.row, c.col ); oHyperlink = this.model.getHyperlinkByCell(r.row, c.col);
cellCursor = { cellCursor = {
cursor : kCurCells, cursor: kCurCells,
target : c_oTargetType.Cells, target: c_oTargetType.Cells,
col : (c ? c.col : -1), col: (c ? c.col : -1),
row : (r ? r.row : -1), row: (r ? r.row : -1),
userId : userId, userId: userId,
lockRangePosLeft: lockRangePosLeft, lockRangePosLeft: lockRangePosLeft,
lockRangePosTop : lockRangePosTop, lockRangePosTop: lockRangePosTop,
userIdAllProps : userIdAllProps, userIdAllProps: userIdAllProps,
lockAllPosLeft : lockAllPosLeft, lockAllPosLeft: lockAllPosLeft,
lockAllPosTop : lockAllPosTop, lockAllPosTop: lockAllPosTop,
userIdAllSheet : userIdAllSheet, userIdAllSheet: userIdAllSheet,
commentIndexes : indexes, commentIndexes: indexes,
commentCoords : coords commentCoords: coords
}; };
if ( null !== oHyperlink ) { if (null !== oHyperlink) {
return { return {
cursor : kCurHyperlink, cursor: kCurHyperlink,
target : c_oTargetType.Hyperlink, target: c_oTargetType.Hyperlink,
hyperlink : new asc_CHyperlink( oHyperlink ), hyperlink: new asc_CHyperlink(oHyperlink),
cellCursor : cellCursor, cellCursor: cellCursor,
userId : userId, userId: userId,
lockRangePosLeft: lockRangePosLeft, lockRangePosLeft: lockRangePosLeft,
lockRangePosTop : lockRangePosTop, lockRangePosTop: lockRangePosTop,
userIdAllProps : userIdAllProps, userIdAllProps: userIdAllProps,
userIdAllSheet : userIdAllSheet, userIdAllSheet: userIdAllSheet,
lockAllPosLeft : lockAllPosLeft, lockAllPosLeft: lockAllPosLeft,
lockAllPosTop : lockAllPosTop, lockAllPosTop: lockAllPosTop,
commentIndexes : indexes, commentIndexes: indexes,
commentCoords : coords commentCoords: coords
}; };
} }
return cellCursor; return cellCursor;
......
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