Commit 78898f9f authored by Alexey.Musinov's avatar Alexey.Musinov

Merge branch 'develop' of https://github.com/ONLYOFFICE/sdkjs into develop

* 'develop' of https://github.com/ONLYOFFICE/sdkjs:
  force save on timeout
  select shape
  mobile color for selection
  delete unused variable
  fix bug 34073
parents 9d1b50cc d5f6213c
...@@ -1349,6 +1349,7 @@ var editor; ...@@ -1349,6 +1349,7 @@ var editor;
if (this.isMobileVersion) { if (this.isMobileVersion) {
this.wb.defaults.worksheetView.halfSelection = true; this.wb.defaults.worksheetView.halfSelection = true;
this.wb.defaults.worksheetView.activeCellBorderColor = new CColor(79, 158, 79);
var _container = document.getElementById(this.HtmlElementName); var _container = document.getElementById(this.HtmlElementName);
if (_container) if (_container)
_container.style.overflow = "hidden"; _container.style.overflow = "hidden";
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
* Import * Import
* ----------------------------------------------------------------------------- * -----------------------------------------------------------------------------
*/ */
var c_oAscBorderStyles = AscCommon.c_oAscBorderStyles;
var c_oAscFormatPainterState = AscCommon.c_oAscFormatPainterState; var c_oAscFormatPainterState = AscCommon.c_oAscFormatPainterState;
var AscBrowser = AscCommon.AscBrowser; var AscBrowser = AscCommon.AscBrowser;
var CColor = AscCommon.CColor; var CColor = AscCommon.CColor;
......
...@@ -11753,12 +11753,13 @@ ...@@ -11753,12 +11753,13 @@
if(bIsExpandRange) if(bIsExpandRange)
{ {
var selectionRange = t.model.selectionRange; var selectionRange = t.model.selectionRange;
var activeCell = selectionRange.activeCell; var activeCell = selectionRange.activeCell.clone();
var activeCellRange = new Asc.Range(activeCell.col, activeCell.row, activeCell.col, activeCell.row); var activeCellRange = new Asc.Range(activeCell.col, activeCell.row, activeCell.col, activeCell.row);
var expandRange = t.model.autoFilters._getAdjacentCellsAF(activeCellRange, true); var expandRange = t.model.autoFilters._getAdjacentCellsAF(activeCellRange, true);
//change selection //change selection
t.setSelection(expandRange); t.setSelection(expandRange);
selectionRange.activeCell = activeCell;
} }
//sort //sort
......
...@@ -1702,6 +1702,7 @@ function DrawingObjects() { ...@@ -1702,6 +1702,7 @@ function DrawingObjects() {
var oShape = oTrack.getShape(false, _this.drawingDocument, null); var oShape = oTrack.getShape(false, _this.drawingDocument, null);
oShape.setWorksheet(worksheet.model); oShape.setWorksheet(worksheet.model);
oShape.addToDrawingObjects(); oShape.addToDrawingObjects();
oShape.select(_this.controller, 0);
worksheet.setSelectionShape(true); worksheet.setSelectionShape(true);
_this.controller.startRecalculate(); _this.controller.startRecalculate();
}); });
......
...@@ -644,6 +644,13 @@ ...@@ -644,6 +644,13 @@
} }
} }
}; };
this.CoAuthoringApi.onForceSave = function(data) {
if (AscCommon.c_oAscForceSaveTypes.Button === data.type) {
t.sendEvent('asc_onForceSaveButton');
} else if (AscCommon.c_oAscForceSaveTypes.Timeout === data.type) {
t.sendEvent('asc_onForceSaveTimeout', data.saved);
}
};
/** /**
* Event об отсоединении от сервера * Event об отсоединении от сервера
* @param {jQuery} e event об отсоединении с причиной * @param {jQuery} e event об отсоединении с причиной
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
var c_oEditorId = AscCommon.c_oEditorId; var c_oEditorId = AscCommon.c_oEditorId;
var c_oCloseCode = AscCommon.c_oCloseCode; var c_oCloseCode = AscCommon.c_oCloseCode;
var c_oAscServerCommandErrors = AscCommon.c_oAscServerCommandErrors; var c_oAscServerCommandErrors = AscCommon.c_oAscServerCommandErrors;
var c_oAscForceSaveTypes = AscCommon.c_oAscForceSaveTypes;
// Класс надстройка, для online и offline работы // Класс надстройка, для online и offline работы
function CDocsCoApi(options) { function CDocsCoApi(options) {
...@@ -53,6 +54,7 @@ ...@@ -53,6 +54,7 @@
this.onCursor = options.onCursor; this.onCursor = options.onCursor;
this.onMeta = options.onMeta; this.onMeta = options.onMeta;
this.onSession = options.onSession; this.onSession = options.onSession;
this.onForceSave = options.onForceSave;
this.onLocksAcquired = options.onLocksAcquired; this.onLocksAcquired = options.onLocksAcquired;
this.onLocksReleased = options.onLocksReleased; this.onLocksReleased = options.onLocksReleased;
this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks
...@@ -93,6 +95,9 @@ ...@@ -93,6 +95,9 @@
}; };
this._CoAuthoringApi.onSession = function(e) { this._CoAuthoringApi.onSession = function(e) {
t.callback_OnSession(e); t.callback_OnSession(e);
};
this._CoAuthoringApi.onForceSave = function(e) {
t.callback_OnForceSave(e);
}; };
this._CoAuthoringApi.onLocksAcquired = function(e) { this._CoAuthoringApi.onLocksAcquired = function(e) {
t.callback_OnLocksAcquired(e); t.callback_OnLocksAcquired(e);
...@@ -391,6 +396,12 @@ ...@@ -391,6 +396,12 @@
this.onSession(e); this.onSession(e);
} }
}; };
CDocsCoApi.prototype.callback_OnForceSave = function(e) {
if (this.onForceSave) {
this.onForceSave(e);
}
};
CDocsCoApi.prototype.callback_OnLocksAcquired = function(e) { CDocsCoApi.prototype.callback_OnLocksAcquired = function(e) {
if (this.onLocksAcquired) { if (this.onLocksAcquired) {
...@@ -507,6 +518,7 @@ ...@@ -507,6 +518,7 @@
this.onCursor = options.onCursor; this.onCursor = options.onCursor;
this.onMeta = options.onMeta; this.onMeta = options.onMeta;
this.onSession = options.onSession; this.onSession = options.onSession;
this.onForceSave = options.onForceSave;
this.onLocksAcquired = options.onLocksAcquired; this.onLocksAcquired = options.onLocksAcquired;
this.onLocksReleased = options.onLocksReleased; this.onLocksReleased = options.onLocksReleased;
this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks this.onLocksReleasedEnd = options.onLocksReleasedEnd; // ToDo переделать на массив release locks
...@@ -542,7 +554,9 @@ ...@@ -542,7 +554,9 @@
this.jwtTimeOutId = null; this.jwtTimeOutId = null;
this._id = null; this._id = null;
this._sessionTimeConnect = null; this._sessionTimeConnect = null;
this._lastForceSaveId = null; this._allChangesSaved = null;
this._lastForceSaveTime = null;
this._lastForceSaveButtonTime = null;
this._indexUser = -1; this._indexUser = -1;
// Если пользователей больше 1, то совместно редактируем // Если пользователей больше 1, то совместно редактируем
this.isCoAuthoring = false; this.isCoAuthoring = false;
...@@ -559,6 +573,7 @@ ...@@ -559,6 +573,7 @@
this.arrayChanges = null; this.arrayChanges = null;
// Время последнего сохранения (для разрыва соединения) // Время последнего сохранения (для разрыва соединения)
this.lastOtherSaveTime = -1; this.lastOtherSaveTime = -1;
this.lastOwnSaveTime = -1;
// Локальный индекс изменений // Локальный индекс изменений
this.changesIndex = 0; this.changesIndex = 0;
// Дополнительная информация для Excel // Дополнительная информация для Excel
...@@ -840,7 +855,7 @@ ...@@ -840,7 +855,7 @@
}; };
DocsCoApi.prototype.forceSave = function() { DocsCoApi.prototype.forceSave = function() {
this._send({'type': 'forcesave', 'saveid': new Date().getTime()}); this._send({'type': 'forceSaveStart'});
}; };
DocsCoApi.prototype.openDocument = function(data) { DocsCoApi.prototype.openDocument = function(data) {
...@@ -941,13 +956,36 @@ ...@@ -941,13 +956,36 @@
} }
}; };
DocsCoApi.prototype._onForceSave = function(data) { DocsCoApi.prototype._onForceSaveStart = function(data) {
if (data['code'] === c_oAscServerCommandErrors.NoError) { if (data['code'] === c_oAscServerCommandErrors.NoError) {
this._lastForceSaveId = data['saveid']; this._lastForceSaveButtonTime = data['time'];
} else if (data['code'] !== c_oAscServerCommandErrors.NotModified) { } else if (data['code'] !== c_oAscServerCommandErrors.NotModified) {
this.onWarning(c_oAscError.ID.Unknown); this.onWarning(c_oAscError.ID.Unknown);
} }
}; };
DocsCoApi.prototype._onForceSave = function(data) {
if (c_oAscForceSaveTypes.Button === data['type']) {
if (this._lastForceSaveButtonTime == data['time']) {
this.onForceSave({type: c_oAscForceSaveTypes.Button, saved:true});
}
} else if(c_oAscForceSaveTypes.Timeout === data['type']) {
this._lastForceSaveTime = data['time'];
this._checkLastForceSave();
}
};
DocsCoApi.prototype._checkLastForceSave = function(data) {
if (null != this._lastForceSaveTime) {
var newState = false;
if((-1 == this.lastOtherSaveTime || this.lastOtherSaveTime <= this._lastForceSaveTime) &&
(-1 == this.lastOwnSaveTime || this.lastOwnSaveTime <= this._lastForceSaveTime)) {
newState = true;
}
if(newState != this._allChangesSaved){
this._allChangesSaved = newState;
this.onForceSave({type: c_oAscForceSaveTypes.Timeout, saved:this._allChangesSaved});
}
}
};
DocsCoApi.prototype._onGetLock = function(data) { DocsCoApi.prototype._onGetLock = function(data) {
if (this.check_state() && data["locks"]) { if (this.check_state() && data["locks"]) {
...@@ -1104,7 +1142,12 @@ ...@@ -1104,7 +1142,12 @@
if (-1 !== data['index']) { if (-1 !== data['index']) {
this.changesIndex = data['index']; this.changesIndex = data['index'];
} }
if (-1 !== data['time']) {
this.lastOwnSaveTime = data['time'];
this._checkLastForceSave();
}
if (this.onUnSaveLock) { if (this.onUnSaveLock) {
this.onUnSaveLock(); this.onUnSaveLock();
} }
...@@ -1124,6 +1167,7 @@ ...@@ -1124,6 +1167,7 @@
this.onSaveChanges(JSON.parse(changesOneUser), change['useridoriginal'], bFirstLoad); this.onSaveChanges(JSON.parse(changesOneUser), change['useridoriginal'], bFirstLoad);
} }
} }
this._checkLastForceSave();
} }
} }
}; };
...@@ -1306,6 +1350,7 @@ ...@@ -1306,6 +1350,7 @@
this._state = ConnectionState.Authorized; this._state = ConnectionState.Authorized;
this._id = data['sessionId']; this._id = data['sessionId'];
this._sessionTimeConnect = data['sessionTimeConnect']; this._sessionTimeConnect = data['sessionTimeConnect'];
this._lastForceSaveTime = data['lastForceSaveTime'];
this._onAuthParticipantsChanged(data['participants']); this._onAuthParticipantsChanged(data['participants']);
...@@ -1496,7 +1541,10 @@ ...@@ -1496,7 +1541,10 @@
case 'refreshToken' : case 'refreshToken' :
t._onRefreshToken(dataObject["messages"]); t._onRefreshToken(dataObject["messages"]);
break; break;
case 'forcesave' : case 'forceSaveStart' :
t._onForceSaveStart(dataObject["messages"]);
break;
case 'forceSave' :
t._onForceSave(dataObject["messages"]); t._onForceSave(dataObject["messages"]);
break; break;
} }
......
/* * (c) Copyright Ascensio System SIA 2010-2017 * * This program is a free software product. You can redistribute it and/or * modify it under the terms of the GNU Affero General Public License (AGPL) * version 3 as published by the Free Software Foundation. In accordance with * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect * that Ascensio System SIA expressly excludes the warranty of non-infringement * of any third-party rights. * * This program is distributed WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html * * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, * EU, LV-1021. * * The interactive user interfaces in modified source and object code versions * of the Program must display Appropriate Legal Notices, as required under * Section 5 of the GNU AGPL version 3. * * Pursuant to Section 7(b) of the License you must retain the original Product * logo when distributing the program. Pursuant to Section 7(e) we decline to * grant you any rights under trademark law for use of our trademarks. * * All the Product's GUI elements, including illustrations and icon sets, as * well as technical writing content are licensed under the terms of the * Creative Commons Attribution-ShareAlike 4.0 International. See the License * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ "use strict"; (/** * @param {Window} window * @param {undefined} undefined */ function(window, undefined) { /** * Класс user для совместного редактирования/просмотра документа * ----------------------------------------------------------------------------- * * @constructor * @memberOf Asc */ function asc_CUser(val) { this.id = null; // уникальный id - пользователя this.idOriginal = null; // уникальный id - пользователя this.userName = null; // имя пользователя this.state = undefined; // состояние (true - подключен, false - отключился) this.indexUser = -1; // Индекс пользователя (фактически равно числу заходов в документ на сервере) this.color = null; // цвет пользователя this.view = false; // просмотр(true), редактор(false) this._setUser(val); return this; } asc_CUser.prototype._setUser = function(val) { if (val) { this.id = val['id']; this.idOriginal = val['idOriginal']; this.userName = val['username']; this.indexUser = val['indexUser']; this.color = AscCommon.getUserColorById(this.idOriginal, this.userName, false, true); this.view = val['view']; } }; asc_CUser.prototype.asc_getId = function() { return this.id; }; asc_CUser.prototype.asc_getUserName = function() { return this.userName; }; asc_CUser.prototype.asc_getFirstName = function() { return this.firstName; }; asc_CUser.prototype.asc_getLastName = function() { return this.lastName; }; asc_CUser.prototype.asc_getState = function() { return this.state; }; asc_CUser.prototype.asc_getColor = function() { return '#' + ('000000' + this.color.toString(16)).substr(-6); }; asc_CUser.prototype.asc_getView = function() { return this.view; }; asc_CUser.prototype.setId = function(val) { this.id = val; }; asc_CUser.prototype.setUserName = function(val) { this.userName = val; }; asc_CUser.prototype.setFirstName = function(val) { this.firstName = val; }; asc_CUser.prototype.setLastName = function(val) { this.lastName = val; }; asc_CUser.prototype.setState = function(val) { this.state = val; }; var ConnectionState = { Reconnect: -1, // reconnect state None: 0, // not initialized WaitAuth: 1, // waiting session id Authorized: 2, // authorized ClosedCoAuth: 3, // closed coauthoring ClosedAll: 4, // closed all SaveChanges: 10, // save AskSaveChanges: 11 // ask save }; var c_oEditorId = { Word:0, Spreadsheet:1, Presentation:2 }; var c_oCloseCode = { serverShutdown: 4001, sessionIdle: 4002, sessionAbsolute: 4003, accessDeny: 4004, jwtExpired: 4005, jwtError: 4006 }; var c_oAscServerCommandErrors = { NoError: 0, DocumentIdError: 1, ParseError: 2, UnknownError: 3, NotModified: 4, UnknownCommand: 5, Token: 6, TokenExpire: 7 }; /* * Export * ----------------------------------------------------------------------------- */ var prot; window['AscCommon'] = window['AscCommon'] || {}; window["AscCommon"].asc_CUser = asc_CUser; prot = asc_CUser.prototype; prot["asc_getId"] = prot.asc_getId; prot["asc_getUserName"] = prot.asc_getUserName; prot["asc_getState"] = prot.asc_getState; prot["asc_getColor"] = prot.asc_getColor; prot["asc_getView"] = prot.asc_getView; window["AscCommon"].ConnectionState = ConnectionState; window["AscCommon"].c_oEditorId = c_oEditorId; window["AscCommon"].c_oCloseCode = c_oCloseCode; window["AscCommon"].c_oAscServerCommandErrors = c_oAscServerCommandErrors; })(window); /* * (c) Copyright Ascensio System SIA 2010-2017 * * This program is a free software product. You can redistribute it and/or * modify it under the terms of the GNU Affero General Public License (AGPL) * version 3 as published by the Free Software Foundation. In accordance with * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect * that Ascensio System SIA expressly excludes the warranty of non-infringement * of any third-party rights. * * This program is distributed WITHOUT ANY WARRANTY; without even the implied * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html * * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, * EU, LV-1021. * * The interactive user interfaces in modified source and object code versions * of the Program must display Appropriate Legal Notices, as required under * Section 5 of the GNU AGPL version 3. * * Pursuant to Section 7(b) of the License you must retain the original Product * logo when distributing the program. Pursuant to Section 7(e) we decline to * grant you any rights under trademark law for use of our trademarks. * * All the Product's GUI elements, including illustrations and icon sets, as * well as technical writing content are licensed under the terms of the * Creative Commons Attribution-ShareAlike 4.0 International. See the License * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ "use strict"; (/** * @param {Window} window * @param {undefined} undefined */ function(window, undefined) { /** * Класс user для совместного редактирования/просмотра документа * ----------------------------------------------------------------------------- * * @constructor * @memberOf Asc */ function asc_CUser(val) { this.id = null; // уникальный id - пользователя this.idOriginal = null; // уникальный id - пользователя this.userName = null; // имя пользователя this.state = undefined; // состояние (true - подключен, false - отключился) this.indexUser = -1; // Индекс пользователя (фактически равно числу заходов в документ на сервере) this.color = null; // цвет пользователя this.view = false; // просмотр(true), редактор(false) this._setUser(val); return this; } asc_CUser.prototype._setUser = function(val) { if (val) { this.id = val['id']; this.idOriginal = val['idOriginal']; this.userName = val['username']; this.indexUser = val['indexUser']; this.color = AscCommon.getUserColorById(this.idOriginal, this.userName, false, true); this.view = val['view']; } }; asc_CUser.prototype.asc_getId = function() { return this.id; }; asc_CUser.prototype.asc_getUserName = function() { return this.userName; }; asc_CUser.prototype.asc_getFirstName = function() { return this.firstName; }; asc_CUser.prototype.asc_getLastName = function() { return this.lastName; }; asc_CUser.prototype.asc_getState = function() { return this.state; }; asc_CUser.prototype.asc_getColor = function() { return '#' + ('000000' + this.color.toString(16)).substr(-6); }; asc_CUser.prototype.asc_getView = function() { return this.view; }; asc_CUser.prototype.setId = function(val) { this.id = val; }; asc_CUser.prototype.setUserName = function(val) { this.userName = val; }; asc_CUser.prototype.setFirstName = function(val) { this.firstName = val; }; asc_CUser.prototype.setLastName = function(val) { this.lastName = val; }; asc_CUser.prototype.setState = function(val) { this.state = val; }; var ConnectionState = { Reconnect: -1, // reconnect state None: 0, // not initialized WaitAuth: 1, // waiting session id Authorized: 2, // authorized ClosedCoAuth: 3, // closed coauthoring ClosedAll: 4, // closed all SaveChanges: 10, // save AskSaveChanges: 11 // ask save }; var c_oEditorId = { Word:0, Spreadsheet:1, Presentation:2 }; var c_oCloseCode = { serverShutdown: 4001, sessionIdle: 4002, sessionAbsolute: 4003, accessDeny: 4004, jwtExpired: 4005, jwtError: 4006 }; var c_oAscServerCommandErrors = { NoError: 0, DocumentIdError: 1, ParseError: 2, UnknownError: 3, NotModified: 4, UnknownCommand: 5, Token: 6, TokenExpire: 7 }; var c_oAscForceSaveTypes = { Command: 0, Button: 1, Timeout: 2 }; /* * Export * ----------------------------------------------------------------------------- */ var prot; window['AscCommon'] = window['AscCommon'] || {}; window["AscCommon"].asc_CUser = asc_CUser; prot = asc_CUser.prototype; prot["asc_getId"] = prot.asc_getId; prot["asc_getUserName"] = prot.asc_getUserName; prot["asc_getState"] = prot.asc_getState; prot["asc_getColor"] = prot.asc_getColor; prot["asc_getView"] = prot.asc_getView; window["AscCommon"].ConnectionState = ConnectionState; window["AscCommon"].c_oEditorId = c_oEditorId; window["AscCommon"].c_oCloseCode = c_oCloseCode; window["AscCommon"].c_oAscServerCommandErrors = c_oAscServerCommandErrors; window["AscCommon"].c_oAscForceSaveTypes = c_oAscForceSaveTypes; })(window);
\ No newline at end of file \ No newline at end of file
......
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