Commit aeec50fd authored by Dmitry.Shahtanov's avatar Dmitry.Shahtanov

совместное редактирование именованных диапазонов.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@64616 954022d7-b5bf-4e40-9824-e11837661b57
parent 6530936a
......@@ -1509,10 +1509,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
"updateAllSheetsLock": function () {t._onUpdateAllSheetsLock.apply(t, arguments);},
"showDrawingObjects": function () {t._onShowDrawingObjects.apply(t, arguments);},
"showComments": function () {t._onShowComments.apply(t, arguments);},
"cleanSelection": function () {t._onCleanSelection.apply(t, arguments);},
"updateDocumentCanSave": function () {t._onUpdateDocumentCanSave();},
"checkCommentRemoveLock": function (lockElem) {return t._onCheckCommentRemoveLock(lockElem);}
}, this.asc_getViewerMode());
"cleanSelection": function () {t._onCleanSelection.apply(t, arguments);},
"updateDocumentCanSave": function () {t._onUpdateDocumentCanSave();},
"checkCommentRemoveLock": function (lockElem) {return t._onCheckCommentRemoveLock(lockElem);},
"unlockDefName": function () {t._onUnlockDefName.apply(t, arguments);},
"checkDefNameLock": function (lockElem) {return t._onCheckDefNameLock(lockElem);}
}, this.asc_getViewerMode());
if (!this.CoAuthoringApi) {
this.asyncServerIdEndLoaded ();
......@@ -1543,8 +1545,9 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
if (lockType === c_oAscLockTypeElem.Object) {
drawing = g_oTableId.Get_ById(lockElem.Element["rangeOrObjectId"]);
if (drawing)
if (drawing){
drawing.lockType = lockElem.Type;
}
}
if (t.wb) {
......@@ -1554,6 +1557,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
// Шлем update для листов
t._onUpdateSheetsLock(lockElem);
t._onUpdateDefinedNames(lockElem);
var ws = t.wb.getWorksheet();
var lockSheetId = lockElem.Element["sheetId"];
if (lockSheetId === ws.model.getId()) {
......@@ -2145,14 +2150,24 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
spreadsheet_api.prototype.asc_setDefinedNames = function (defName) {
// return this.wb.setDefinedNames(defName);
// Проверка глобального лока
if (this.collaborativeEditing.getGlobalLock())
return;
return this.wb.editDefinedNames(null, defName);
};
spreadsheet_api.prototype.asc_editDefinedNames = function (oldName, newName) {
// Проверка глобального лока
if (this.collaborativeEditing.getGlobalLock())
return;
return this.wb.editDefinedNames(oldName, newName);
};
spreadsheet_api.prototype.asc_delDefinedNames = function (oldName) {
// Проверка глобального лока
if (this.collaborativeEditing.getGlobalLock())
return;
return this.wb.delDefinedNames(oldName);
};
......@@ -2164,6 +2179,22 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
return this.wb.getDefaultDefinedName();
};
spreadsheet_api.prototype._onUpdateDefinedNames = function (lockElem) {
var dN = this.wbModel.dependencyFormulas.defNameList[lockElem.Element["rangeOrObjectId"]];
if(dN){
dN.isLock = lockElem["UserId"];
this.handlers.trigger("asc_onRefreshDefNameList");
}
}
spreadsheet_api.prototype._onUnlockDefName = function(){
this.wb.unlockDefName();
}
spreadsheet_api.prototype._onCheckDefNameLock = function(){
return this.wb._onCheckDefNameLock();
}
// Залочена ли работа с листом
spreadsheet_api.prototype.asc_isWorksheetLockedOrDeleted = function (index) {
var ws = this.wbModel.getWorksheet(index);
......
......@@ -245,12 +245,13 @@
prot["asc_getClearFilter"] = prot.asc_getClearFilter;//TODO DELETE
/** @constructor */
function asc_CDefName(n, r, s, t, h) {
function asc_CDefName(n, r, s, t, h, l) {
this.Name = n;
this.LocalSheetId = s;
this.Ref = r;
this.isTable = t;
this.Hidden = h;
this.isLock = l;
}
asc_CDefName.prototype = {
......@@ -258,7 +259,8 @@
asc_getScope: function(){return this.LocalSheetId;},
asc_getRef: function(){return this.Ref;},
asc_getIsTable: function(){return this.isTable;},
asc_getIsHidden: function(){return this.Hidden;}
asc_getIsHidden: function(){return this.Hidden;},
asc_getIsLock: function(){return this.isLock;}
};
window["Asc"].asc_CDefName = window["Asc"]["asc_CDefName"] = asc_CDefName;
......@@ -269,6 +271,7 @@
prot["asc_getRef"] = prot.asc_getRef;
prot["asc_getIsTable"] = prot.asc_getIsTable;
prot["asc_getIsHidden"] = prot.asc_getIsHidden;
prot["asc_getIsLock"] = prot.asc_getIsLock;
}
)(window);
\ No newline at end of file
......@@ -213,8 +213,10 @@
// Когда не совместное редактирование чистить ничего не нужно, но отправлять нужно.
var bIsCollaborative = this.getCollaborativeEditing();
var bCheckRedraw = false;
var bRedrawGraphicObjects = false;
var bCheckRedraw = false,
bRedrawGraphicObjects = false,
bUnlockDefName = false,
dN;
if (bIsCollaborative && (0 < this.m_arrNeedUnlock.length ||
0 < this.m_arrNeedUnlock2.length)) {
bCheckRedraw = true;
......@@ -232,6 +234,10 @@
drawing.lockType = c_oAscLockTypes.kLockTypeNone;
bRedrawGraphicObjects = true;
}
if(!bUnlockDefName){
bUnlockDefName = this.handlers.trigger("checkDefNameLock", oLock);
}
this.handlers.trigger("releaseLocks", oLock.Element["guid"]);
}
// Очищаем примененные чужие изменения
......@@ -246,6 +252,9 @@
drawing.lockType = c_oAscLockTypes.kLockTypeNone;
bRedrawGraphicObjects = true;
}
if(!bUnlockDefName){
bUnlockDefName = this.handlers.trigger("checkDefNameLock", oLock);
}
}
this.m_arrNeedUnlock.splice(nIndex, 1);
......@@ -283,6 +292,10 @@
if (bCheckRedraw || bRedrawGraphicObjects)
this.handlers.trigger("showDrawingObjects");
if(bUnlockDefName){
this.handlers.trigger("unlockDefName");
}
if (0 === this.m_nUseType)
this.m_nUseType = 1;
} else {
......
......@@ -1078,6 +1078,26 @@ DependencyGraph.prototype = {
}
return list;
},
unlockDefName:function(){
var nodesList = this.defNameList;
for ( var id in nodesList ) {
if ( nodesList[id].isLock ) {
delete nodesList[id].isLock;
}
}
},
checkDefNameLock:function(){
var nodesList = this.defNameList;
for ( var id in nodesList ) {
if ( nodesList[id].isLock ) {
return true;
}
}
return false;
},
getNextTableName:function ( ws, Ref ) {
this.nTableNameMaxIndex++;
var sNewName = this.sTableNamePattern + this.nTableNameMaxIndex,
......@@ -1620,7 +1640,7 @@ DefNameVertex.prototype = {
return new Asc.asc_CDefName( this.Name,
this.Ref,
this.sheetId == "WB" ? null : a ? a.getIndex() : null,
this.isTable, this.Hidden );
this.isTable, this.Hidden, this.isLock );
},
changeDefName:function ( newName ) {
......@@ -2471,9 +2491,10 @@ Workbook.prototype.getDefinesNamesWB = function (defNameListId) {
return names.sort(sort);
};
Workbook.prototype.getDefinesNames = function ( name, sheetId ) {
var res = this.dependencyFormulas.getDefNameNodeByName( name, sheetId );
return res;
return this.dependencyFormulas.getDefNameNodeByName( name, sheetId );
};
Workbook.prototype.getDefinedName = function ( name ) {
return this.dependencyFormulas.getDefNameNodeByName( name.Name, name.LocalSheetId );
};
Workbook.prototype.delDefinesNames = function ( defName ) {
History.Create_NewPoint();
......@@ -2600,6 +2621,12 @@ Workbook.prototype.findDefinesNames = function ( ref, sheetId ) {
return this.dependencyFormulas.getDefNameNodeByRef( ref, sheetId );
};
Workbook.prototype.unlockDefName = function(){
this.dependencyFormulas.unlockDefName();
};
Workbook.prototype.checkDefNameLock = function(){
return this.dependencyFormulas.checkDefNameLock();
};
Workbook.prototype.buildDependency = function(){
this.dependencyFormulas.clear();
// this.dependencyFormulas = null;
......
......@@ -1970,20 +1970,53 @@
WorkbookView.prototype.editDefinedNames = function (oldName, newName) {
//ToDo проверка defName.ref на знак "=" в начале ссылки. знака нет тогда это либо число либо строка, так делает Excel.
var res = this.model.editDefinesNames(oldName, newName);
if (this.collaborativeEditing.getGlobalLock())
return;
var ws = this.getWorksheet(),
t = this
if( oldName ){
this.handlers.trigger("asc_onEditDefName", oldName, newName);
var editDefinedNamesCallback = function (res) {
if (res) {
t.model.editDefinesNames(oldName, newName);
t.handlers.trigger("asc_onEditDefName", oldName, newName);
t.handlers.trigger("asc_onRefreshDefNameList");
}
};
var defNameId = t.model.getDefinedName(oldName).nodeId;
ws._isLockedDefNames(editDefinedNamesCallback, defNameId);
}
else{
this.handlers.trigger("asc_onDefName", res);
this.handlers.trigger("asc_onDefName", this.model.editDefinesNames(oldName, newName));
}
};
WorkbookView.prototype.delDefinedNames = function (oldName) {
//ToDo проверка defName.ref на знак "=" в начале ссылки. знака нет тогда это либо число либо строка, так делает Excel.
if (this.collaborativeEditing.getGlobalLock())
return;
var ws = this.getWorksheet(),
t = this
if( oldName ){
var delDefinedNamesCallback = function (res) {
if (res) {
t.handlers.trigger("asc_onDelDefName", this.model.delDefinesNames(oldName));
t.handlers.trigger("asc_onRefreshDefNameList");
}
};
var defNameId = t.model.getDefinedName(oldName).nodeId;
ws._isLockedDefNames(delDefinedNamesCallback, defNameId);
this.handlers.trigger("asc_onDelDefName", this.model.delDefinesNames(oldName));
}
};
......@@ -1994,6 +2027,14 @@
return new Asc.asc_CDefName( "", ws.getSelectionRangeValue(), null );
};
WorkbookView.prototype.unlockDefName = function () {
this.model.unlockDefName();
this.handlers.trigger("asc_onRefreshDefNameList");
};
WorkbookView.prototype._onCheckDefNameLock = function () {
return this.model.checkDefNameLock();
};
// Печать
......
......@@ -9066,6 +9066,38 @@
this.collaborativeEditing.addCheckLock(lockInfo);
this.collaborativeEditing.onEndCheckLock(callback);
};
WorksheetView.prototype._isLockedDefNames = function (callback,defNameId) {
if (false === this.collaborativeEditing.isCoAuthoringExcellEnable()) {
// Запрещено совместное редактирование
asc_applyFunction(callback, true);
return;
}
var sheetId = this.model.getId();
var lockInfo = this.collaborativeEditing.getLockInfo(c_oAscLockTypeElem.Object, null, -1, defNameId);
if (false === this.collaborativeEditing.getCollaborativeEditing()) {
// Пользователь редактирует один: не ждем ответа, а сразу продолжаем редактирование
asc_applyFunction(callback, true);
callback = undefined;
}
if (false !== this.collaborativeEditing.getLockIntersection(lockInfo,
c_oAscLockTypes.kLockTypeMine, /*bCheckOnlyLockAll*/false)) {
// Редактируем сами
asc_applyFunction(callback, true);
return;
} else if (false !== this.collaborativeEditing.getLockIntersection(lockInfo,
c_oAscLockTypes.kLockTypeOther, /*bCheckOnlyLockAll*/false)) {
// Уже ячейку кто-то редактирует
asc_applyFunction(callback, false);
return;
}
this.collaborativeEditing.onStartCheckLock();
this.collaborativeEditing.addCheckLock(lockInfo);
this.collaborativeEditing.onEndCheckLock(callback);
};
// Залочен ли весь лист
WorksheetView.prototype._isLockedAll = function (callback) {
if (false === this.collaborativeEditing.isCoAuthoringExcellEnable()) {
......
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