Commit 821a1205 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@48931 954022d7-b5bf-4e40-9824-e11837661b57
parent 2f56a01f
......@@ -5,6 +5,11 @@
* Date: 13/08/2012
*/
var locktype_None = 1; // никто не залочил данный объект
var locktype_Mine = 2; // данный объект залочен текущим пользователем
var locktype_Other = 3; // данный объект залочен другим(не текущим) пользователем
var locktype_Other2 = 4; // данный объект залочен другим(не текущим) пользователем (обновления уже пришли)
var locktype_Other3 = 5; // данный объект был залочен (обновления пришли) и снова стал залочен
if ( !window["Asc"] ) { // Для вставки диаграмм в Word
window["Asc"] = {};
......@@ -2178,16 +2183,6 @@ function DrawingObjects() {
return _t.graphicObject != null;
}
_t.isLocked = function(callback) {
_this.objectLocker.reset();
if ( _t.graphicObject ) {
_this.objectLocker.addObjectId(_t.graphicObject.Id);
_this.objectLocker.checkObjects(callback);
}
else
callback(true);
}
_t.getWorkbook = function() {
return (_t.worksheet ? _t.worksheet.model.workbook : null);
}
......@@ -2468,6 +2463,7 @@ function DrawingObjects() {
autoShapeTrack = new CAutoshapeTrack();
autoShapeTrack.init( trackOverlay, 0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix, shapeOverlayCtx.m_dWidthMM, shapeOverlayCtx.m_dHeightMM );
shapeCtx.m_oAutoShapesTrack = autoShapeTrack;
_this.objectLocker = new ObjectLocker(worksheet);
_this.drawingDocument = new CDrawingDocument(this);
......@@ -2520,7 +2516,7 @@ function DrawingObjects() {
drawingObject.graphicObject.drawingObjects = _this;
drawingObject.graphicObject.recalculate(aImagesSync);
aObjects.push( drawingObject );
}
}
if (drawingObject.graphicObject instanceof CGroupShape) {
......@@ -2741,6 +2737,12 @@ function DrawingObjects() {
boundsChecker.init(1, 1, 1, 1);
drawingObject.graphicObject.draw(boundsChecker);
boundsChecker.CorrectBounds();
// Коррекция для селекта при блокировке
var delta = 12;
boundsChecker.Bounds.min_x -= delta;
boundsChecker.Bounds.min_y -= delta;
boundsChecker.Bounds.max_x += delta;
boundsChecker.Bounds.max_y += delta;
return boundsChecker;
}
return null;
......@@ -2759,15 +2761,15 @@ function DrawingObjects() {
}
aBoundsCheckers = [];
if ( bHeaders )
_this.drawWorksheetHeaders(true);
// Чистим текущие области
for ( var i = 0; i < aObjects.length; i++ ) {
var boundsChecker = _this.getBoundsChecker(aObjects[i]);
restoreSheetArea(boundsChecker);
aBoundsCheckers.push(boundsChecker);
}
}
if ( bHeaders )
_this.drawWorksheetHeaders(true);
}
function restoreSheetArea(checker) {
......@@ -2826,7 +2828,7 @@ function DrawingObjects() {
if ( clearCanvas )
_this.clearDrawingObjects();
if ( !aObjects.length )
return;
......@@ -2877,7 +2879,7 @@ function DrawingObjects() {
_this.OnUpdateOverlay();
else
_this.raiseLayerDrawingObjects();
_this.drawWorksheetHeaders();
}
......@@ -3183,8 +3185,6 @@ function DrawingObjects() {
_this.updateDrawingObject = function(bInsert, operType, updateRange) {
// !!! Не вызывается сверху если Undo/Redo
var changedRange = null;
var metrics = null;
......@@ -3502,9 +3502,11 @@ function DrawingObjects() {
}
// Update graphic object
History.TurnOff();
obj.graphicObject.setPosition( pxToMm(obj.getRealLeftOffset(true)), pxToMm(obj.getRealTopOffset(true)) );
obj.graphicObject.recalculateTransform();
obj.graphicObject.calculateTransformTextMatrix();
History.TurnOn();
_this.showDrawingObjects(true);
}
}
......@@ -3598,7 +3600,6 @@ function DrawingObjects() {
obj.graphicObject = graphic;
graphic.setDrawingBase(obj);
//obj.graphicObject.select(_this.controller);
var ret;
if(isRealNumber(position))
{
......@@ -3620,8 +3621,8 @@ function DrawingObjects() {
worksheet.model.workbook.handlers.trigger("asc_onEndAddShape");
_this.objectLocker.reset();
_this.objectLocker.addObjectId(obj.id);
_this.objectLocker.checkObjects( function(result){ return result; } );
_this.objectLocker.addObjectId(obj.graphicObject.Id);
_this.objectLocker.checkObjects( function(result) {} );
return ret;
}
......@@ -3672,6 +3673,14 @@ function DrawingObjects() {
}
}
_this.getDrawingBase = function(graphicId) {
for (var i = 0; i < aObjects.length; i++) {
if ( aObjects[i].graphicObject.Id == graphicId )
return aObjects[i];
}
return null;
}
_this.deleteDrawingBase = function(graphicId) {
for (var i = 0; i < aObjects.length; i++) {
......@@ -3724,20 +3733,23 @@ function DrawingObjects() {
return response;
}
_this.selectGraphicObject = function() {
/*if ( _this.drawingDocument && _this.controller.selectedObjects.length ) {
// Сначала селект диапазона диаграммы
for (var i = 0; i < _this.controller.selectedObjects.length; i++) {
var graphicObject = _this.controller.selectedObjects[i];
if ( graphicObject.isChart() ) {
_this.selectDrawingObjectRange(graphicObject.Id);
}
_this.setGraphicObjectLockState = function(id, state) {
for (var i = 0; i < aObjects.length; i++) {
if ( id == aObjects[i].graphicObject.Id ) {
aObjects[i].graphicObject.lockType = state;
shapeCtx.DrawLockObjectRect(aObjects[i].graphicObject.lockType, aObjects[i].graphicObject.x, aObjects[i].graphicObject.y, aObjects[i].graphicObject.extX, aObjects[i].graphicObject.extY );
break;
}
_this.raiseLayerDrawingObjects();
_this.OnUpdateOverlay();
}*/
}
}
_this.reseltLockedGraphicObjects = function() {
for (var i = 0; i < aObjects.length; i++) {
aObjects[i].graphicObject.lockType = c_oAscLockTypes.kLockTypeNone;
}
_this.showDrawingObjects(true);
}
_this.setScrollOffset = function(x_px, y_px) {
......@@ -3790,9 +3802,6 @@ function DrawingObjects() {
return _this.controller.selectedObjects.length > 0;
}
_this.getSelectedObjectsStack = function() {
}
_this.loadImageRedraw = function(imageUrl) {
var _image = api.ImageLoader.LoadImage(imageUrl, 1);
......@@ -4108,13 +4117,15 @@ function DrawingObjects() {
if ( !aObjects.length )
return null;
var objectInfo = { cursor: null, data: null, isGraphicObject: false };
var objectInfo = { cursor: null, id: null, object: null, isGraphicObject: false };
var graphicObjectInfo = _this.controller.isPointInDrawingObjects( pxToMm(x - scrollOffset.x), pxToMm(y - scrollOffset.y) );
if ( graphicObjectInfo && graphicObjectInfo.objectId ) {
objectInfo.data = graphicObjectInfo.objectId;
objectInfo.id = graphicObjectInfo.objectId;
objectInfo.object = _this.getDrawingBase(graphicObjectInfo.objectId);
objectInfo.cursor = graphicObjectInfo.cursorType;
objectInfo.isGraphicObject = true;
return objectInfo;
}
return null;
......@@ -4255,35 +4266,44 @@ function ObjectLocker(ws) {
aObjectId.push(id);
}
// For array of objects -=Use reset before use=-
_t.checkObjects = function(callback) {
function callbackEx(result) {
worksheet._drawCollaborativeElements(true);
if ( callback )
callback(result);
}
if ( !aObjectId.length || (false === worksheet.collaborativeEditing.isCoAuthoringExcellEnable()) ) {
// Запрещено совместное редактирование
if ($.isFunction(callback)) {callback(true);}
if ($.isFunction(callback)) {callbackEx(true);}
return;
}
var sheetId = worksheet.model.getId();
worksheet.collaborativeEditing.onStartCheckLock();
for ( var i = 0; i < aObjectId.length; i++ ) {
var lockInfo = worksheet.collaborativeEditing.getLockInfo( c_oAscLockTypeElem.Object, /*subType*/null, sheetId, aObjectId[i] );
if ( false === worksheet.collaborativeEditing.getCollaborativeEditing() ) {
// Пользователь редактирует один: не ждем ответа, а сразу продолжаем редактирование
if ($.isFunction(callback)) { callback(true); }
if ($.isFunction(callback)) { callbackEx(true); }
callback = undefined;
}
else if ( false !== worksheet.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeMine) ) {
// Редактируем сами, проверяем дальше
// Редактируем сами, проверяем дальше
continue;
}
else if ( false !== worksheet.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther) ) {
// Уже ячейку кто-то редактирует
if ($.isFunction(callback)) {callback(false);}
if ($.isFunction(callback)) {callbackEx(false);}
return;
}
}
worksheet.collaborativeEditing.addCheckLock(lockInfo);
}
worksheet.collaborativeEditing.onEndCheckLock(callback);
worksheet.collaborativeEditing.onEndCheckLock(callbackEx);
}
}
\ No newline at end of file
......@@ -1178,16 +1178,17 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var t = this;
this.collaborativeEditing = new asc_CCollaborativeEditing(/*handlers*/{
"askLock": function () {t.CoAuthoringApi.askLock.apply(t.CoAuthoringApi, arguments);},
"releaseLocks": function () {t.CoAuthoringApi.releaseLocks.apply(t.CoAuthoringApi, arguments);},
"sendChanges": function () {t._onSaveChanges.apply(t, arguments);},
"applyChanges": function () {t._onApplyChanges.apply(t, arguments);},
"updateAfterApplyChanges": function () {t._onUpdateAfterApplyChanges.apply(t, arguments);},
"drawSelection": function () {t._onDrawSelection.apply(t, arguments);},
"showDrawingObjects": function () {t._onShowDrawingObjects.apply(t, arguments);},
"showComments": function () {t._onShowComments.apply(t, arguments);},
"unlockComments": function () {t._onUnlockComments.apply(t);},
"cleanSelection": function () {t._onCleanSelection.apply(t, arguments);}
"askLock": function () {t.CoAuthoringApi.askLock.apply(t.CoAuthoringApi, arguments);},
"releaseLocks": function () {t.CoAuthoringApi.releaseLocks.apply(t.CoAuthoringApi, arguments);},
"sendChanges": function () {t._onSaveChanges.apply(t, arguments);},
"applyChanges": function () {t._onApplyChanges.apply(t, arguments);},
"updateAfterApplyChanges": function () {t._onUpdateAfterApplyChanges.apply(t, arguments);},
"drawSelection": function () {t._onDrawSelection.apply(t, arguments);},
"showDrawingObjects": function () {t._onShowDrawingObjects.apply(t, arguments);},
"resetLockedGraphicObjects": function () {t._onResetLockedGraphicObjects.apply(t, arguments);},
"showComments": function () {t._onShowComments.apply(t, arguments);},
"unlockComments": function () {t._onUnlockComments.apply(t);},
"cleanSelection": function () {t._onCleanSelection.apply(t, arguments);}
});
if (!this.CoAuthoringApi) {
......@@ -1439,6 +1440,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
}
},
_onResetLockedGraphicObjects: function () {
if (this.wb) {
this.wb.getWorksheet().objectRender.reseltLockedGraphicObjects();
}
},
_onShowComments: function () {
if (this.wb) {
this.wb.getWorksheet().cellCommentator.drawCommentCells();
......
......@@ -243,6 +243,7 @@
this.handlers.trigger("drawSelection");
this.handlers.trigger("unlockComments");
this.handlers.trigger("showComments");
this.handlers.trigger("resetLockedGraphicObjects");
this.handlers.trigger("showDrawingObjects");
}
},
......
......@@ -131,6 +131,7 @@ function CShape(drawingBase, drawingObjects, legendEntry)
this.spPr = new CSpPr();
this.style = null;
this.txBody = null;
this.lockType = c_oAscLockTypes.kLockTypeNone;
this.group = null;
......@@ -1827,6 +1828,40 @@ CShape.prototype =
var shape_drawer = new CShapeDrawer();
shape_drawer.fromShape(this, graphics);
shape_drawer.draw(this.spPr.geometry);
if(graphics instanceof CGraphics)
{
var transform = this.transform;
var extX = this.extX;
var extY = this.extY;
/*var callback = function(result)
{
var lockType = parseInt(result);
if ( !isNaN(lockType) )
{
graphics.SetIntegerGrid(false);
graphics.transform3(transform, false);
graphics.DrawLockObjectRect(lockType, 0, 0, extX, extY );
graphics.reset();
graphics.SetIntegerGrid(true);
}
}
if(!isRealObject(this.group))
{
this.drawingBase.isLocked(callback);
}*/
if(!isRealObject(this.group))
{
graphics.SetIntegerGrid(false);
graphics.transform3(transform, false);
graphics.DrawLockObjectRect(this.lockType, 0, 0, extX, extY );
graphics.reset();
graphics.SetIntegerGrid(true);
}
}
graphics.reset();
graphics.SetIntegerGrid(true);
if ( this.txBody )
......
......@@ -462,6 +462,7 @@ function CGraphics()
this.m_oPen = new CPen();
this.m_oBrush = new CBrush();
this.m_oAutoShapesTrack = null;
this.m_oFontManager = null;
this.m_bIsFillTextCanvasColor = 0;
......@@ -1800,7 +1801,7 @@ CGraphics.prototype =
DrawLockObjectRect : function(lock_type, x, y, w, h)
{
if (lock_type == locktype_None || editor.WordControl.m_oDrawingDocument.IsLockObjectsEnable === false || editor.isViewMode)
if (lock_type == locktype_None)
return;
if (lock_type == locktype_Mine)
......@@ -1823,7 +1824,7 @@ CGraphics.prototype =
var w_dot = 2 * dKoefMMToPx;
var w_dist = 1 * dKoefMMToPx;
var _interf = editor.WordControl.m_oDrawingDocument.AutoShapesTrack;
var _interf = this.m_oAutoShapesTrack;
var eps = 5 * dKoefMMToPx;
var _x = x - eps;
......
......@@ -3158,8 +3158,9 @@
var objectState = (c_oAscLockTypes.kLockTypeMine === type) ? c_oAscObjectLockState.Off : c_oAscObjectLockState.On;
var arrayObjects = (c_oAscLockTypes.kLockTypeMine === type) ? this.collaborativeEditing.getLockObjectsMe(currentSheetId) : this.collaborativeEditing.getLockObjectsOther(currentSheetId);
if ( arrayObjects.length )
this.objectRender.showDrawingObjects(false);
for (i = 0; i < arrayObjects.length; ++i) {
this.objectRender.setGraphicObjectLockState(arrayObjects[i], (c_oAscLockTypes.kLockTypeMine === type) ? c_oAscLockTypes.kLockTypeMine : c_oAscLockTypes.kLockTypeOther);
}
}
// set clipping rect to cells area
......@@ -4980,18 +4981,18 @@
return {cursor: kCurFillHandle, target: "shape", col: -1, row: -1};
var drawingInfo = this.objectRender.checkCursorDrawingObject(x, y);
if (drawingInfo && drawingInfo.data) {
if (drawingInfo && drawingInfo.id) {
// Возможно картинка с lock
/*lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, sheetId, drawingInfo.data);
lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, sheetId, drawingInfo.id);
isLocked = this.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther,false);
if (false !== isLocked) {
// Кто-то сделал lock
userId = isLocked.UserId;
lockRangePosLeft = drawingInfo.data.getVisibleLeftOffset(true);
lockRangePosTop = drawingInfo.data.getVisibleTopOffset(true);
}*/
lockRangePosLeft = drawingInfo.object.getVisibleLeftOffset(true);
lockRangePosTop = drawingInfo.object.getVisibleTopOffset(true);
}
return {cursor: drawingInfo.cursor, target: "shape", drawingId: drawingInfo.data, col: -1, row: -1, userId: userId, lockRangePosLeft: lockRangePosLeft, lockRangePosTop: lockRangePosTop};
return {cursor: drawingInfo.cursor, target: "shape", drawingId: drawingInfo.id, col: -1, row: -1, userId: userId, lockRangePosLeft: lockRangePosLeft, lockRangePosTop: lockRangePosTop};
}
var autoFilterCursor = this.autoFilters.isButtonAFClick(x,y,this);
......@@ -5351,7 +5352,7 @@
var cursorInfo = this.objectRender.checkCursorDrawingObject(xpos, ypos);
if ( cursorInfo ) {
var graphicSelectionType = this.objectRender.getGraphicSelectionType(cursorInfo.data);
var graphicSelectionType = this.objectRender.getGraphicSelectionType(cursorInfo.id);
ar.type = graphicSelectionType;
return;
}
......@@ -8141,9 +8142,9 @@
t.model.onEndTriggerAction();
t.autoFilters.insertColumn(t, prop, _updateRangeIns, arn);
if ( !bUndoRedo ) {
//if ( !bUndoRedo ) {
t.objectRender.updateDrawingObject(true, val, _updateRangeIns);
}
//}
t.cellCommentator.updateCommentsDependencies(true, val, _updateRangeIns);
};
if(bUndoRedo)
......@@ -8161,9 +8162,9 @@
t.model.onEndTriggerAction();
t.autoFilters.insertRows(t, prop,_updateRangeIns, arn);
if ( !bUndoRedo ) {
//if ( !bUndoRedo ) {
t.objectRender.updateDrawingObject(true, val, _updateRangeIns);
}
//}
t.cellCommentator.updateCommentsDependencies(true, val, _updateRangeIns);
};
if(bUndoRedo)
......@@ -8220,9 +8221,9 @@
fullRecalc = true;
t.model.removeCols(_updateRangeDel.c1, _updateRangeDel.c2);
t.autoFilters.insertColumn(t, prop,_updateRangeDel, arn);
if (!bUndoRedo) {
//if (!bUndoRedo) {
t.objectRender.updateDrawingObject(false, val, _updateRangeDel);
}
//}
t.cellCommentator.updateCommentsDependencies(false, val, _updateRangeDel);
};
if(bUndoRedo)
......@@ -8237,9 +8238,9 @@
fullRecalc = true;
t.model.removeRows(_updateRangeDel.r1, _updateRangeDel.r2);
t.autoFilters.insertRows(t, prop,_updateRangeDel, arn);
if (!bUndoRedo) {
//if (!bUndoRedo) {
t.objectRender.updateDrawingObject(false, val, _updateRangeDel);
}
//}
t.cellCommentator.updateCommentsDependencies(false, val, _updateRangeDel);
};
if(bUndoRedo)
......
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