Commit b6fcf95b authored by GoshaZotov's avatar GoshaZotov

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

parents a7c5b29c 2ff49bbc
......@@ -74,7 +74,7 @@ var c_oAscError = Asc.c_oAscError;
DesktopOfflineUpdateLocalName(this);
this.onUpdateDocumentModified(AscCommon.History.Is_Modified());
this.onUpdateDocumentModified(AscCommon.History.Have_Changes());
};
asc['spreadsheet_api'].prototype._onNeedParams = function(data, opt_isPassword)
......@@ -162,7 +162,7 @@ AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
}
};
AscCommon.CHistory.prototype.Is_Modified = function(IsNotUserSave, IsNoSavedNoModifyed)
AscCommon.CHistory.prototype.Have_Changes = function(IsNotUserSave, IsNoSavedNoModifyed)
{
var checkIndex = (this.Is_UserSaveMode() && !IsNotUserSave) ? this.UserSavedIndex : this.SavedIndex;
if (-1 === this.Index && null === checkIndex && false === this.ForceSave)
......@@ -198,7 +198,7 @@ window["Asc"]['spreadsheet_api'].prototype.onUpdateDocumentModified = function(b
this._onUpdateDocumentCanSave();
if (undefined !== window["AscDesktopEditor"]) {
window["AscDesktopEditor"]["onDocumentModifiedChanged"](AscCommon.History ? AscCommon.History.Is_Modified(undefined, true) : bValue);
window["AscDesktopEditor"]["onDocumentModifiedChanged"](AscCommon.History ? AscCommon.History.Have_Changes(undefined, true) : bValue);
}
}
};
......@@ -260,7 +260,7 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error)
else
AscCommon.History.UserSavedIndex = window["Asc"]["editor"].LastUserSavedIndex;
window["Asc"]["editor"].onUpdateDocumentModified(AscCommon.History.Is_Modified());
window["Asc"]["editor"].onUpdateDocumentModified(AscCommon.History.Have_Changes());
window["Asc"]["editor"].LastUserSavedIndex = undefined;
if (2 == error)
......
......@@ -874,8 +874,8 @@ var editor;
if (!this.canSave || this.asc_getCellEditMode()) {
// Пока идет сохранение или редактирование ячейки, мы не закрываем документ
return true;
} else if (History && History.Is_Modified) {
return History.Is_Modified();
} else if (History && History.Have_Changes) {
return History.Have_Changes();
}
return false;
};
......@@ -1532,7 +1532,7 @@ var editor;
t.sync_EndAction(c_oAscAsyncActionType.Information, c_oAscAsyncAction.Save);
// Обновляем состояние возможности сохранения документа
t.onUpdateDocumentModified(History.Is_Modified());
t.onUpdateDocumentModified(History.Have_Changes());
if (undefined !== window["AscDesktopEditor"]) {
window["AscDesktopEditor"]["OnSave"]();
......@@ -2612,10 +2612,19 @@ var editor;
};
// Frozen pane
spreadsheet_api.prototype.asc_freezePane = function() {
spreadsheet_api.prototype.asc_freezePane = function () {
this.wb.getWorksheet().freezePane();
};
spreadsheet_api.prototype.asc_setSparklineGroup = function (id, oSparklineGroup) {
var changedSparkline = AscCommon.g_oTableId.Get_ById(id);
if (changedSparkline) {
changedSparkline.set(oSparklineGroup);
this.wb._onWSSelectionChanged();
this.wb.getWorksheet().draw();
}
};
// Cell interface
spreadsheet_api.prototype.asc_getCellInfo = function() {
return this.wb.getSelectionInfo();
......@@ -3044,7 +3053,7 @@ var editor;
!History.IsEndTransaction() || !this.canSave) {
return;
}
if (!History.Is_Modified(true) && !(this.collaborativeEditing.getCollaborativeEditing() && 0 !== this.collaborativeEditing.getOwnLocksLength())) {
if (!History.Have_Changes(true) && !(this.collaborativeEditing.getCollaborativeEditing() && 0 !== this.collaborativeEditing.getOwnLocksLength())) {
if (this.collaborativeEditing.getFast() && this.collaborativeEditing.haveOtherChanges()) {
AscCommon.CollaborativeEditing.Clear_CollaborativeMarks();
......@@ -3071,7 +3080,7 @@ var editor;
spreadsheet_api.prototype._onUpdateDocumentCanSave = function() {
// Можно модифицировать это условие на более быстрое (менять самим состояние в аргументах, а не запрашивать каждый раз)
var tmp = History.Is_Modified() || (this.collaborativeEditing.getCollaborativeEditing() && 0 !== this.collaborativeEditing.getOwnLocksLength());
var tmp = History.Have_Changes() || (this.collaborativeEditing.getCollaborativeEditing() && 0 !== this.collaborativeEditing.getOwnLocksLength());
if (tmp !== this.isDocumentCanSave) {
this.isDocumentCanSave = tmp;
this.handlers.trigger('asc_onDocumentCanSaveChanged', this.isDocumentCanSave);
......@@ -3532,6 +3541,9 @@ var editor;
// Frozen pane
prot["asc_freezePane"] = prot.asc_freezePane;
// Sparklines
prot["asc_setSparklineGroup"] = prot.asc_setSparklineGroup;
// Cell interface
prot["asc_getCellInfo"] = prot.asc_getCellInfo;
prot["asc_getActiveCellCoord"] = prot.asc_getActiveCellCoord;
......
......@@ -378,34 +378,6 @@ var c_oAscPopUpSelectorType = {
Custom: 2
};
var c_oAscSparklineAttributes = {
type: 1,
lineWeight: 2,
displayEmptyCellsAs: 4,
markers: 8,
high: 16,
low: 32,
first: 64,
last: 128,
negative: 256,
displayXAxis: 512,
displayHidden: 1024,
minAxisType: 2048,
maxAxisType: 4096,
rightToLeft: 8192
};
var c_oAscSparklineColors = {
Series: 1,
Negative: 2,
Axis: 4,
Markers: 8,
First: 16,
Last: 32,
High: 64,
Low: 128
};
//----------------------------------------------------------export----------------------------------------------------
window['AscCommonExcel'] = window['AscCommonExcel'] || {};
window['AscCommonExcel'].c_oAscAlignType = c_oAscAlignType;
......@@ -593,30 +565,4 @@ var c_oAscPopUpSelectorType = {
prot['Individual'] = prot.Individual;
prot['Group'] = prot.Group;
prot['Custom'] = prot.Custom;
window['Asc']['c_oAscSparklineAttributes'] = window['Asc'].c_oAscSparklineAttributes = c_oAscSparklineAttributes;
prot = c_oAscSparklineAttributes;
prot['type'] = prot.type;
prot['lineWeight'] = prot.lineWeight;
prot['displayEmptyCellsAs'] = prot.displayEmptyCellsAs;
prot['markers'] = prot.markers;
prot['high'] = prot.high;
prot['low'] = prot.low;
prot['first'] = prot.first;
prot['last'] = prot.last;
prot['negative'] = prot.negative;
prot['displayXAxis'] = prot.displayXAxis;
prot['displayHidden'] = prot.displayHidden;
prot['minAxisType'] = prot.minAxisType;
prot['maxAxisType'] = prot.maxAxisType;
prot['rightToLeft'] = prot.rightToLeft;
window['Asc']['c_oAscSparklineColors'] = window['Asc'].c_oAscSparklineColors = c_oAscSparklineColors;
prot = c_oAscSparklineColors;
prot['Series'] = prot.Series;
prot['Negative'] = prot.Negative;
prot['Axis'] = prot.Axis;
prot['Markers'] = prot.Markers;
prot['First'] = prot.First;
prot['Last'] = prot.Last;
prot['High'] = prot.High;
prot['Low'] = prot.Low;
})(window);
......@@ -173,6 +173,12 @@ CHistory.prototype.init = function(workbook) {
CHistory.prototype.Is_UserSaveMode = function() {
return this.UserSaveMode;
};
CHistory.prototype.Is_Clear = function() {
if ( this.Points.length <= 0 )
return true;
return false;
};
CHistory.prototype.Clear = function()
{
this.Index = -1;
......@@ -709,7 +715,7 @@ CHistory.prototype._sendCanUndoRedo = function()
{
this.workbook.handlers.trigger("setCanUndo", this.Can_Undo());
this.workbook.handlers.trigger("setCanRedo", this.Can_Redo());
this.workbook.handlers.trigger("setDocumentModified", this.Is_Modified());
this.workbook.handlers.trigger("setDocumentModified", this.Have_Changes());
};
CHistory.prototype.SetSelection = function(range)
{
......@@ -835,7 +841,7 @@ CHistory.prototype.Get_DeleteIndex = function () {
return DeleteIndex;
};
/** @returns {boolean} */
CHistory.prototype.Is_Modified = function(IsNotUserSave) {
CHistory.prototype.Have_Changes = function(IsNotUserSave) {
var checkIndex = (this.Is_UserSaveMode() && !IsNotUserSave) ? this.UserSavedIndex : this.SavedIndex;
if (-1 === this.Index && null === checkIndex && false === this.ForceSave) {
return false;
......
......@@ -6663,7 +6663,7 @@
var oThis = this;
var res = c_oSerConstants.ReadOk;
if (c_oSer_Sparkline.SparklineGroup === type) {
var newSparklineGroup = new AscCommonExcel.sparklineGroup();
var newSparklineGroup = new AscCommonExcel.sparklineGroup(true);
res = this.bcr.Read1(length, function (t, l) {
return oThis.ReadSparklineGroup(t, l, newSparklineGroup);
});
......
This diff is collapsed.
......@@ -691,7 +691,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
var val_ax_props = new AscCommon.asc_ValAxisSettings();
if(settings.type !== c_oAscChartTypeSettings.barStackedPer)
{
if(oSparklineGroup.minAxisType === Asc.c_oAscSparklineAxisMinMax.Custom && oSparklineGroup.manualMin != null)
if(oSparklineGroup.minAxisType === Asc.c_oAscSparklineAxisMinMax.Custom && oSparklineGroup.manualMin !== null)
{
val_ax_props.putMinValRule(c_oAscValAxisRule.fixed);
val_ax_props.putMinVal(oSparklineGroup.manualMin);
......@@ -700,7 +700,7 @@ CSparklineView.prototype.initFromSparkline = function(oSparkline, oSparklineGrou
{
val_ax_props.putMinValRule(c_oAscValAxisRule.auto);
}
if(oSparklineGroup.maxAxisType === Asc.c_oAscSparklineAxisMinMax.Custom && oSparklineGroup.manualMax != null)
if(oSparklineGroup.maxAxisType === Asc.c_oAscSparklineAxisMinMax.Custom && oSparklineGroup.manualMax !== null)
{
val_ax_props.putMinValRule(c_oAscValAxisRule.fixed);
val_ax_props.putMinVal(oSparklineGroup.manualMax);
......
......@@ -589,14 +589,21 @@
this.CoAuthoringApi.onSession = function(data) {
var code = data["code"];
var reason = data["reason"];
var interval = data["interval"];
var extendSession = true;
if (c_oCloseCode.sessionIdle == code) {
extendSession = false;
var lastTime = new Date().getTime();
var idleTime = new Date().getTime() - lastTime;
if (idleTime < interval) {
t.CoAuthoringApi.extendSession(idleTime);
} else {
extendSession = false;
}
} else if (c_oCloseCode.sessionAbsolute == code) {
extendSession = false;
}
if (!extendSession) {
if (true != History.Is_Clear()) {
if (History.Have_Changes()) {
//enter view mode because save async
t.sendEvent('asc_onCoAuthoringDisconnect');
t.asc_setViewMode(true);
......@@ -606,8 +613,13 @@
t.CoAuthoringApi.disconnect(code, reason);
};
AscCommon.CollaborativeEditing.Apply_Changes();
AscCommon.CollaborativeEditing.Send_Changes();
if (t.collaborativeEditing.applyChanges) {
t.collaborativeEditing.applyChanges();
t.collaborativeEditing.sendChanges();
} else {
AscCommon.CollaborativeEditing.Apply_Changes();
AscCommon.CollaborativeEditing.Send_Changes();
}
} else {
t.CoAuthoringApi.disconnect(code, reason);
}
......@@ -619,19 +631,19 @@
* @param {Bool} isDisconnectAtAll окончательно ли отсоединяемся(true) или будем пробовать сделать reconnect(false) + сами отключились
* @param {Bool} isCloseCoAuthoring
*/
this.CoAuthoringApi.onDisconnect = function(e, isDisconnectAtAll, isCloseCoAuthoring)
this.CoAuthoringApi.onDisconnect = function(e, errorCode)
{
if (AscCommon.ConnectionState.None === t.CoAuthoringApi.get_state())
{
t.asyncServerIdEndLoaded();
}
if (isDisconnectAtAll)
if (null != errorCode)
{
// Посылаем наверх эвент об отключении от сервера
t.sendEvent('asc_onCoAuthoringDisconnect');
// И переходим в режим просмотра т.к. мы не можем сохранить файл
t.asc_setViewMode(true);
t.sendEvent('asc_onError', isCloseCoAuthoring ? c_oAscError.ID.UserDrop : c_oAscError.ID.CoAuthoringDisconnect, c_oAscError.Level.NoCritical);
t.sendEvent('asc_onError', errorCode, c_oAscError.Level.NoCritical);
}
};
this.CoAuthoringApi.onDocumentOpen = function(inputWrap)
......
......@@ -102,8 +102,8 @@
this._CoAuthoringApi.onLocksReleasedEnd = function() {
t.callback_OnLocksReleasedEnd();
};
this._CoAuthoringApi.onDisconnect = function(e, isDisconnectAtAll, isCloseCoAuthoring) {
t.callback_OnDisconnect(e, isDisconnectAtAll, isCloseCoAuthoring);
this._CoAuthoringApi.onDisconnect = function(e, errorCode) {
t.callback_OnDisconnect(e, errorCode);
};
this._CoAuthoringApi.onWarning = function(e) {
t.callback_OnWarning(e);
......@@ -328,9 +328,9 @@
}
};
CDocsCoApi.prototype.extendSession = function() {
CDocsCoApi.prototype.extendSession = function(idleTime) {
if (this._CoAuthoringApi && this._onlineWork) {
this._CoAuthoringApi.extendSession();
this._CoAuthoringApi.extendSession(idleTime);
}
};
......@@ -394,9 +394,9 @@
* @param {Bool} isDisconnectAtAll окончательно ли отсоединяемся(true) или будем пробовать сделать reconnect(false) + сами отключились
* @param {Bool} isCloseCoAuthoring
*/
CDocsCoApi.prototype.callback_OnDisconnect = function(e, isDisconnectAtAll, isCloseCoAuthoring) {
CDocsCoApi.prototype.callback_OnDisconnect = function(e, errorCode) {
if (this.onDisconnect) {
this.onDisconnect(e, isDisconnectAtAll, isCloseCoAuthoring);
this.onDisconnect(e, errorCode);
}
};
......@@ -786,8 +786,8 @@
}
};
DocsCoApi.prototype.extendSession = function() {
this._send({'type': 'extendSession'});
DocsCoApi.prototype.extendSession = function(idleTime) {
this._send({'type': 'extendSession', 'idletime': idleTime});
};
DocsCoApi.prototype.openDocument = function(data) {
......@@ -1162,7 +1162,7 @@
DocsCoApi.prototype._onDrop = function(data) {
this.disconnect();
this.onDisconnect(data ? data['description'] : '', true, this.isCloseCoAuthoring);
this.onDisconnect(data ? data['description'] : '', this._getDisconnectErrorCode());
};
DocsCoApi.prototype._onWarning = function(data) {
......@@ -1301,6 +1301,7 @@
'block': this.ownedLockBlocks,
'sessionId': this._id,
'sessionTimeConnect': this._sessionTimeConnect,
'sessionTimeIdle': 0,
'documentFormatSave': this._documentFormatSave,
'view': this._isViewer,
'isCloseCoAuthoring': this.isCloseCoAuthoring,
......@@ -1404,11 +1405,13 @@
t._state = ConnectionState.Reconnect;
var bIsDisconnectAtAll = (c_oCloseCode.serverShutdown === evt.code || c_oCloseCode.sessionIdle === evt.code ||
c_oCloseCode.sessionAbsolute === evt.code || t.attemptCount >= t.maxAttemptCount);
var errorCode = null;
if (bIsDisconnectAtAll) {
t._state = ConnectionState.ClosedAll;
errorCode = t._getDisconnectErrorCode(evt.code);
}
if (t.onDisconnect) {
t.onDisconnect(evt.reason, bIsDisconnectAtAll, t.isCloseCoAuthoring);
t.onDisconnect(evt.reason, errorCode);
}
//Try reconect
if (!bIsDisconnectAtAll) {
......@@ -1437,6 +1440,17 @@
return window['SockJS'] ? window['SockJS'] : require('sockjs');
};
DocsCoApi.prototype._getDisconnectErrorCode = function(opt_closeCode) {
if(c_oCloseCode.serverShutdown === opt_closeCode) {
return Asc.c_oAscError.ID.CoAuthoringDisconnect;
} else if(c_oCloseCode.sessionIdle === opt_closeCode){
return Asc.c_oAscError.ID.CoAuthoringDisconnect;
} else if(c_oCloseCode.sessionAbsolute === opt_closeCode){
return Asc.c_oAscError.ID.CoAuthoringDisconnect;
}
return this.isCloseCoAuthoring ? Asc.c_oAscError.ID.UserDrop : Asc.c_oAscError.ID.CoAuthoringDisconnect;
};
//----------------------------------------------------------export----------------------------------------------------
window['AscCommon'] = window['AscCommon'] || {};
window['AscCommon'].CDocsCoApi = CDocsCoApi;
......
......@@ -318,25 +318,24 @@ function openFileCommand(binUrl, changesUrl, Signature, callback) {
} else {
bEndLoadChanges = true;
}
if (window['IS_NATIVE_EDITOR']) {
result = window["native"]["openFileCommand"](sFileUrl, changesUrl, Signature);
var url;
var nIndex = sFileUrl.lastIndexOf("/");
url = (-1 !== nIndex) ? sFileUrl.substring(0, nIndex + 1) : sFileUrl;
if (0 < result.length) {
oResult.bSerFormat = Signature === result.substring(0, Signature.length);
oResult.data = result;
oResult.url = url;
} else {
bError = true;
}
bEndLoadFile = true;
onEndOpen();
}
if (window['IS_NATIVE_EDITOR']) {
var result = window["native"]["openFileCommand"](sFileUrl, changesUrl, Signature);
var url;
var nIndex = sFileUrl.lastIndexOf("/");
url = (-1 !== nIndex) ? sFileUrl.substring(0, nIndex + 1) : sFileUrl;
if (0 < result.length) {
oResult.bSerFormat = Signature === result.substring(0, Signature.length);
oResult.data = result;
oResult.url = url;
} else {
bError = true;
}
bEndLoadFile = true;
onEndOpen();
}
}
function sendCommand(editor, fCallback, rdata, dataContainer) {
//json не должен превышать размера 2097152, иначе при его чтении будет exception
......@@ -2708,7 +2707,12 @@ CUserCacheColor.prototype.init = function(nColor) {
script.type = 'text/javascript';
script.src = url;
script.onreadystatechange = callback;
script.onreadystatechange = function () {
if (this.readyState === 'complete' || this.readyState === 'loaded') {
script.onreadystatechange = null;
setTimeout(callback, 0);
}
};
script.onload = callback;
// Fire the loading
......
......@@ -432,7 +432,7 @@
}
}
var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + value + "})();";
var _script = "(function(){ var Api = window.g_asc_plugins.api;\n" + value + "\n})();";
eval(_script);
if (pluginData.getAttribute("recalculate") == true)
......
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