Commit b88afb82 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@48546 954022d7-b5bf-4e40-9824-e11837661b57
parent 362f8bad
...@@ -1518,7 +1518,8 @@ function DrawingObjects() { ...@@ -1518,7 +1518,8 @@ function DrawingObjects() {
var userId = null; var userId = null;
var documentId = null; var documentId = null;
_this.objectLocker = null;
_this.drawingDocument = null; _this.drawingDocument = null;
_this.asyncImageEndLoaded = null; _this.asyncImageEndLoaded = null;
_this.asyncImagesDocumentEndLoaded = null; _this.asyncImagesDocumentEndLoaded = null;
...@@ -1893,6 +1894,7 @@ function DrawingObjects() { ...@@ -1893,6 +1894,7 @@ function DrawingObjects() {
autoShapeTrack = new CAutoshapeTrack(); autoShapeTrack = new CAutoshapeTrack();
autoShapeTrack.init( trackOverlay, 0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix, shapeOverlayCtx.m_dWidthMM, shapeOverlayCtx.m_dHeightMM ); autoShapeTrack.init( trackOverlay, 0, 0, shapeOverlayCtx.m_lWidthPix, shapeOverlayCtx.m_lHeightPix, shapeOverlayCtx.m_dWidthMM, shapeOverlayCtx.m_dHeightMM );
_this.objectLocker = new ObjectLocker(worksheet);
_this.drawingDocument = new CDrawingDocument(this); _this.drawingDocument = new CDrawingDocument(this);
_this.drawingDocument.AutoShapesTrack = autoShapeTrack; _this.drawingDocument.AutoShapesTrack = autoShapeTrack;
_this.drawingDocument.TargetHtmlElement = document.getElementById('id_target_cursor'); _this.drawingDocument.TargetHtmlElement = document.getElementById('id_target_cursor');
...@@ -3078,7 +3080,12 @@ function DrawingObjects() { ...@@ -3078,7 +3080,12 @@ function DrawingObjects() {
_this.sendGraphicObjectProps(); _this.sendGraphicObjectProps();
worksheet.model.workbook.handlers.trigger("asc_onEndAddShape"); worksheet.model.workbook.handlers.trigger("asc_onEndAddShape");
_this.lockDrawingObject(obj.id, true, true);
//_this.lockDrawingObject(obj.id, true, true);
_this.objectLocker.reset();
_this.objectLocker.addObjectId(obj.id);
_this.objectLocker.checkObjects( function(result){ return result; } );
return ret; return ret;
} }
...@@ -3865,3 +3872,55 @@ function DrawingObjects() { ...@@ -3865,3 +3872,55 @@ function DrawingObjects() {
return tmp; return tmp;
} }
} }
//-----------------------------------------------------------------------------------
// Universal object locker/checker
//-----------------------------------------------------------------------------------
function ObjectLocker(ws) {
var _t = this;
var aObjectId = [];
var worksheet = ws;
_t.reset = function() {
aObjectId = [];
}
_t.addObjectId = function(id) {
aObjectId.push(id);
}
_t.checkObjects = function(callback) {
if (false === worksheet.collaborativeEditing.isCoAuthoringExcellEnable()) {
// Запрещено совместное редактирование
if ($.isFunction(callback)) {callback(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);}
}
else if ( false !== worksheet.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeMine) ) {
// Редактируем сами
if ($.isFunction(callback)) {callback(true);}
return;
}
else if ( false !== worksheet.collaborativeEditing.getLockIntersection(lockInfo, c_oAscLockTypes.kLockTypeOther) ) {
// Уже ячейку кто-то редактирует
if ($.isFunction(callback)) {callback(false);}
return;
}
worksheet.collaborativeEditing.addCheckLock(lockInfo);
}
worksheet.collaborativeEditing.onEndCheckLock(callback);
}
}
\ No newline at end of file
...@@ -1634,11 +1634,13 @@ function RotateState(drawingObjectsController, drawingObjects, majorObject) ...@@ -1634,11 +1634,13 @@ function RotateState(drawingObjectsController, drawingObjects, majorObject)
} }
var worksheet = this.drawingObjects.getWorksheet(); var worksheet = this.drawingObjects.getWorksheet();
worksheet.collaborativeEditing.onStartCheckLock(); //worksheet.collaborativeEditing.onStartCheckLock();
this.drawingObjects.objectLocker.reset();
var track_objects = this.drawingObjectsController.arrTrackObjects; var track_objects = this.drawingObjectsController.arrTrackObjects;
for(i =0; i < track_objects.length; ++i) for(i =0; i < track_objects.length; ++i)
{ {
this.drawingObjects.lockDrawingObject(track_objects[i].originalObject.Get_Id(), false, false) //this.drawingObjects.lockDrawingObject(track_objects[i].originalObject.Get_Id(), false, false);
this.drawingObjects.objectLocker.addObjectId(track_objects[i].originalObject.Get_Id());
} }
var track_objects2 = []; var track_objects2 = [];
for(i = 0; i < track_objects.length; ++i) for(i = 0; i < track_objects.length; ++i)
...@@ -1659,7 +1661,9 @@ function RotateState(drawingObjectsController, drawingObjects, majorObject) ...@@ -1659,7 +1661,9 @@ function RotateState(drawingObjectsController, drawingObjects, majorObject)
} }
}; };
worksheet.collaborativeEditing.onEndCheckLock(callback); //worksheet.collaborativeEditing.onEndCheckLock(callback);
this.drawingObjects.objectLocker.checkObjects(callback);
//History.Create_NewPoint(); //History.Create_NewPoint();
//this.drawingObjectsController.trackEnd(); //this.drawingObjectsController.trackEnd();
this.drawingObjectsController.clearTrackObjects(); this.drawingObjectsController.clearTrackObjects();
...@@ -1758,11 +1762,13 @@ function ResizeState(drawingObjectsController, drawingObjects, majorObject, card ...@@ -1758,11 +1762,13 @@ function ResizeState(drawingObjectsController, drawingObjects, majorObject, card
{ {
var worksheet = this.drawingObjects.getWorksheet(); var worksheet = this.drawingObjects.getWorksheet();
worksheet.collaborativeEditing.onStartCheckLock(); //worksheet.collaborativeEditing.onStartCheckLock();
this.drawingObjects.objectLocker.reset();
var track_objects = this.drawingObjectsController.arrTrackObjects; var track_objects = this.drawingObjectsController.arrTrackObjects;
for(var i =0; i < track_objects.length; ++i) for(var i =0; i < track_objects.length; ++i)
{ {
this.drawingObjects.lockDrawingObject(track_objects[i].originalObject.Get_Id(), false, false) //this.drawingObjects.lockDrawingObject(track_objects[i].originalObject.Get_Id(), false, false);
this.drawingObjects.objectLocker.addObjectId(track_objects[i].originalObject.Get_Id());
} }
var track_objects2 = []; var track_objects2 = [];
for(i = 0; i < track_objects.length; ++i) for(i = 0; i < track_objects.length; ++i)
...@@ -1783,8 +1789,8 @@ function ResizeState(drawingObjectsController, drawingObjects, majorObject, card ...@@ -1783,8 +1789,8 @@ function ResizeState(drawingObjectsController, drawingObjects, majorObject, card
} }
}; };
worksheet.collaborativeEditing.onEndCheckLock(callback); //worksheet.collaborativeEditing.onEndCheckLock(callback);
this.drawingObjects.objectLocker.checkObjects(callback);
//History.Create_NewPoint(); //History.Create_NewPoint();
//this.drawingObjectsController.trackEnd(); //this.drawingObjectsController.trackEnd();
...@@ -2034,9 +2040,14 @@ function TrackNewShapeState(drawingObjectsController, drawingObjects, presetGeom ...@@ -2034,9 +2040,14 @@ function TrackNewShapeState(drawingObjectsController, drawingObjects, presetGeom
//лочим добавленный шейп //лочим добавленный шейп
var worksheet = this.drawingObjects.getWorksheet(); var worksheet = this.drawingObjects.getWorksheet();
worksheet.collaborativeEditing.onStartCheckLock();
this.drawingObjects.lockDrawingObject(this.resultObject.Get_Id(), false, false); //worksheet.collaborativeEditing.onStartCheckLock();
worksheet.collaborativeEditing.onEndCheckLock(function(bLock){}); this.drawingObjects.objectLocker.reset();
//this.drawingObjects.lockDrawingObject(this.resultObject.Get_Id(), false, false);
this.drawingObjects.objectLocker.addObjectId(this.resultObject.Get_Id());
//worksheet.collaborativeEditing.onEndCheckLock(function(bLock){});
this.drawingObjects.objectLocker.checkObjects(function(bLock){});
asc["editor"].asc_endAddShape(); asc["editor"].asc_endAddShape();
}; };
...@@ -2257,11 +2268,13 @@ function MoveState(drawingObjectsController, drawingObjects, startX, startY, rec ...@@ -2257,11 +2268,13 @@ function MoveState(drawingObjectsController, drawingObjects, startX, startY, rec
this.onMouseUp = function(e, x, y) this.onMouseUp = function(e, x, y)
{ {
var worksheet = this.drawingObjects.getWorksheet(); var worksheet = this.drawingObjects.getWorksheet();
worksheet.collaborativeEditing.onStartCheckLock(); //worksheet.collaborativeEditing.onStartCheckLock();
this.drawingObjects.objectLocker.reset();
var track_objects = this.drawingObjectsController.arrTrackObjects; var track_objects = this.drawingObjectsController.arrTrackObjects;
for(var i =0; i < track_objects.length; ++i) for(var i =0; i < track_objects.length; ++i)
{ {
this.drawingObjects.lockDrawingObject(track_objects[i].originalObject.Get_Id(), false, false) //this.drawingObjects.lockDrawingObject(track_objects[i].originalObject.Get_Id(), false, false);
this.drawingObjects.objectLocker.addObjectId(track_objects[i].originalObject.Get_Id());
} }
var track_objects2 = []; var track_objects2 = [];
for(i = 0; i < track_objects.length; ++i) for(i = 0; i < track_objects.length; ++i)
...@@ -2282,7 +2295,9 @@ function MoveState(drawingObjectsController, drawingObjects, startX, startY, rec ...@@ -2282,7 +2295,9 @@ function MoveState(drawingObjectsController, drawingObjects, startX, startY, rec
} }
}; };
worksheet.collaborativeEditing.onEndCheckLock(callback); //worksheet.collaborativeEditing.onEndCheckLock(callback);
this.drawingObjects.objectLocker.checkObjects(callback);
//History.Create_NewPoint(); //History.Create_NewPoint();
//this.drawingObjectsController.trackEnd(); //this.drawingObjectsController.trackEnd();
this.drawingObjectsController.clearTrackObjects(); this.drawingObjectsController.clearTrackObjects();
...@@ -2379,11 +2394,13 @@ function ChangeAdjState(drawingObjectsController, drawingObjects) ...@@ -2379,11 +2394,13 @@ function ChangeAdjState(drawingObjectsController, drawingObjects)
this.onMouseUp = function(e, x, y) this.onMouseUp = function(e, x, y)
{ {
var worksheet = this.drawingObjects.getWorksheet(); var worksheet = this.drawingObjects.getWorksheet();
worksheet.collaborativeEditing.onStartCheckLock(); //worksheet.collaborativeEditing.onStartCheckLock();
this.drawingObjects.objectLocker.reset();
var track_objects = this.drawingObjectsController.arrTrackObjects; var track_objects = this.drawingObjectsController.arrTrackObjects;
for(var i =0; i < track_objects.length; ++i) for(var i =0; i < track_objects.length; ++i)
{ {
this.drawingObjects.lockDrawingObject(track_objects[i].originalShape.Get_Id(), false, false) //this.drawingObjects.lockDrawingObject(track_objects[i].originalShape.Get_Id(), false, false);
this.drawingObjects.objectLocker.addObjectId(track_objects[i].originalObject.Get_Id());
} }
var track_objects2 = []; var track_objects2 = [];
for(i = 0; i < track_objects.length; ++i) for(i = 0; i < track_objects.length; ++i)
...@@ -2404,7 +2421,9 @@ function ChangeAdjState(drawingObjectsController, drawingObjects) ...@@ -2404,7 +2421,9 @@ function ChangeAdjState(drawingObjectsController, drawingObjects)
} }
}; };
worksheet.collaborativeEditing.onEndCheckLock(callback); //worksheet.collaborativeEditing.onEndCheckLock(callback);
this.drawingObjects.objectLocker.checkObjects(callback);
//History.Create_NewPoint(); //History.Create_NewPoint();
//this.drawingObjectsController.trackEnd(); //this.drawingObjectsController.trackEnd();
this.drawingObjectsController.clearTrackObjects(); this.drawingObjectsController.clearTrackObjects();
...@@ -3137,8 +3156,10 @@ function MoveInGroupState(drawingObjectsController, drawingObjects, group, start ...@@ -3137,8 +3156,10 @@ function MoveInGroupState(drawingObjectsController, drawingObjects, group, start
{ {
var worksheet = this.drawingObjects.getWorksheet(); var worksheet = this.drawingObjects.getWorksheet();
worksheet.collaborativeEditing.onStartCheckLock(); //worksheet.collaborativeEditing.onStartCheckLock();
this.drawingObjects.lockDrawingObject(this.group.Get_Id(), false, false); this.drawingObjects.objectLocker.reset();
//this.drawingObjects.lockDrawingObject(this.group.Get_Id(), false, false);
this.drawingObjects.objectLocker.addObjectId(this.group.Get_Id());
var track_objects2 = []; var track_objects2 = [];
for(var i = 0; i < this.drawingObjectsController.arrTrackObjects.length; ++i) for(var i = 0; i < this.drawingObjectsController.arrTrackObjects.length; ++i)
{ {
...@@ -3166,7 +3187,9 @@ function MoveInGroupState(drawingObjectsController, drawingObjects, group, start ...@@ -3166,7 +3187,9 @@ function MoveInGroupState(drawingObjectsController, drawingObjects, group, start
} }
}; };
worksheet.collaborativeEditing.onEndCheckLock(callback); //worksheet.collaborativeEditing.onEndCheckLock(callback);
this.drawingObjects.objectLocker.checkObjects(callback);
//this.drawingObjectsController.trackEnd(); //this.drawingObjectsController.trackEnd();
// this.group.normalize(); // this.group.normalize();
// this.group.updateCoordinatesAfterInternalResize(); // this.group.updateCoordinatesAfterInternalResize();
...@@ -3262,8 +3285,10 @@ function ChangeAdjInGroupState(drawingObjectsController, drawingObjects, group) ...@@ -3262,8 +3285,10 @@ function ChangeAdjInGroupState(drawingObjectsController, drawingObjects, group)
var worksheet = this.drawingObjects.getWorksheet(); var worksheet = this.drawingObjects.getWorksheet();
worksheet.collaborativeEditing.onStartCheckLock(); //worksheet.collaborativeEditing.onStartCheckLock();
this.drawingObjects.lockDrawingObject(this.group.Get_Id(), false, false); this.drawingObjects.objectLocker.reset();
//this.drawingObjects.lockDrawingObject(this.group.Get_Id(), false, false);
this.drawingObjects.objectLocker.addObjectId(this.group.Get_Id());
var track_objects2 = []; var track_objects2 = [];
for(var i = 0; i < this.drawingObjectsController.arrTrackObjects.length; ++i) for(var i = 0; i < this.drawingObjectsController.arrTrackObjects.length; ++i)
{ {
...@@ -3283,7 +3308,8 @@ function ChangeAdjInGroupState(drawingObjectsController, drawingObjects, group) ...@@ -3283,7 +3308,8 @@ function ChangeAdjInGroupState(drawingObjectsController, drawingObjects, group)
drawingObjects.showDrawingObjects(true); drawingObjects.showDrawingObjects(true);
} }
}; };
worksheet.collaborativeEditing.onEndCheckLock(callback); //worksheet.collaborativeEditing.onEndCheckLock(callback);
this.drawingObjects.objectLocker.checkObjects(callback);
this.drawingObjectsController.clearTrackObjects(); this.drawingObjectsController.clearTrackObjects();
this.drawingObjects.OnUpdateOverlay(); this.drawingObjects.OnUpdateOverlay();
...@@ -3372,8 +3398,10 @@ function RotateInGroupState(drawingObjectsController, drawingObjects, group, maj ...@@ -3372,8 +3398,10 @@ function RotateInGroupState(drawingObjectsController, drawingObjects, group, maj
{ {
var worksheet = this.drawingObjects.getWorksheet(); var worksheet = this.drawingObjects.getWorksheet();
worksheet.collaborativeEditing.onStartCheckLock(); //worksheet.collaborativeEditing.onStartCheckLock();
this.drawingObjects.lockDrawingObject(this.group.Get_Id(), false, false); this.drawingObjects.objectLocker.reset();
//this.drawingObjects.lockDrawingObject(this.group.Get_Id(), false, false);
this.drawingObjects.objectLocker.addObjectId(this.group.Get_Id());
var track_objects2 = []; var track_objects2 = [];
for(var i = 0; i < this.drawingObjectsController.arrTrackObjects.length; ++i) for(var i = 0; i < this.drawingObjectsController.arrTrackObjects.length; ++i)
{ {
...@@ -3401,7 +3429,9 @@ function RotateInGroupState(drawingObjectsController, drawingObjects, group, maj ...@@ -3401,7 +3429,9 @@ function RotateInGroupState(drawingObjectsController, drawingObjects, group, maj
} }
}; };
worksheet.collaborativeEditing.onEndCheckLock(callback); //worksheet.collaborativeEditing.onEndCheckLock(callback);
this.drawingObjects.objectLocker.checkObjects(callback);
//this.drawingObjectsController.trackEnd(); //this.drawingObjectsController.trackEnd();
// this.group.normalize(); // this.group.normalize();
// this.group.updateCoordinatesAfterInternalResize(); // this.group.updateCoordinatesAfterInternalResize();
...@@ -3499,8 +3529,10 @@ function ResizeInGroupState(drawingObjectsController, drawingObjects, group, maj ...@@ -3499,8 +3529,10 @@ function ResizeInGroupState(drawingObjectsController, drawingObjects, group, maj
this.onMouseUp = function(e, x, y) this.onMouseUp = function(e, x, y)
{ {
var worksheet = this.drawingObjects.getWorksheet(); var worksheet = this.drawingObjects.getWorksheet();
worksheet.collaborativeEditing.onStartCheckLock(); //worksheet.collaborativeEditing.onStartCheckLock();
this.drawingObjects.lockDrawingObject(this.group.Get_Id(), false, false); this.drawingObjects.objectLocker.reset();
//this.drawingObjects.lockDrawingObject(this.group.Get_Id(), false, false);
this.drawingObjects.objectLocker.addObjectId(this.group.Get_Id());
var track_objects2 = []; var track_objects2 = [];
for(var i = 0; i < this.drawingObjectsController.arrTrackObjects.length; ++i) for(var i = 0; i < this.drawingObjectsController.arrTrackObjects.length; ++i)
{ {
...@@ -3526,7 +3558,9 @@ function ResizeInGroupState(drawingObjectsController, drawingObjects, group, maj ...@@ -3526,7 +3558,9 @@ function ResizeInGroupState(drawingObjectsController, drawingObjects, group, maj
} }
}; };
worksheet.collaborativeEditing.onEndCheckLock(callback); //worksheet.collaborativeEditing.onEndCheckLock(callback);
this.drawingObjects.objectLocker.checkObjects(callback);
this.drawingObjectsController.clearTrackObjects(); this.drawingObjectsController.clearTrackObjects();
this.drawingObjects.OnUpdateOverlay(); this.drawingObjects.OnUpdateOverlay();
this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group)); this.drawingObjectsController.changeCurrentState(new GroupState(this.drawingObjectsController, this.drawingObjects, this.group));
......
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