Commit b6c604be authored by Oleg Korshul's avatar Oleg Korshul

.

parent 70ab3428
......@@ -249,8 +249,15 @@ window["Asc"]['spreadsheet_api'].prototype.asc_isOffline = function()
return true;
};
window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs)
window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs, password, isForce)
{
window.doadssIsSaveAs = isSaveAs;
if (true !== isForce && window.g_asc_plugins && window.g_asc_plugins.isRunned("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}"))
{
window.g_asc_plugins.init({ "type" : "generatePassword" });
return;
}
window["Asc"]["editor"].sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
var _param = "";
......@@ -259,9 +266,9 @@ window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs)
if (AscCommon.AscBrowser.isRetina)
_param += "retina=true;";
window["AscDesktopEditor"]["LocalFileSave"](_param);
window["AscDesktopEditor"]["LocalFileSave"](_param, password);
};
window["DesktopOfflineAppDocumentEndSave"] = function(error)
window["DesktopOfflineAppDocumentEndSave"] = function(error, hash, password)
{
window["Asc"]["editor"].sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
if (0 == error)
......@@ -284,6 +291,14 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error)
window.SaveQuestionObjectBeforeSign = null;
}
}
if (hash !== null && hash !== undefined && hash != "")
{
if (window.g_asc_plugins && window.g_asc_plugins.isRunned("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}"))
{
window.g_asc_plugins.init("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}", {"type": "setPasswordByFile", "hash": hash, "password": password});
}
}
};
window["Asc"]['spreadsheet_api'].prototype["asc_addImageDrawingObject"] = window["Asc"]['spreadsheet_api'].prototype.asc_addImageDrawingObject;
......
......@@ -209,6 +209,45 @@ window["UpdateInstallPlugins"] = function()
_editor.sendEvent("asc_onPluginsInit", _plugins);
};
window["UpdateSystemPlugins"] = function()
{
var _plugins = JSON.parse(window["AscDesktopEditor"]["GetInstallPlugins"]());
_plugins["url"] = _plugins["url"].replace(" ", "%20");
var _len = _plugins["pluginsData"].length;
for (var i = 0; i < _len; i++)
_plugins["pluginsData"][i]["baseUrl"] = _plugins["url"] + _plugins["pluginsData"][i]["guid"].substring(4) + "/";
var _editor = window["Asc"]["editor"] ? window["Asc"]["editor"] : window.editor;
var _array = [];
for (var i = 0; i < _len; i++)
{
var _plugin = _plugins["pluginsData"][i];
for (var j = 0; j < _plugin["variations"].length; j++)
{
var _variation = _plugin["variations"][j];
if (_variation["initDataType"] == "desktop")
{
_array.push(_plugin);
break;
}
}
}
var _arraySystem = [];
for (var i = 0; i < _array.length; i++)
{
var plugin = new Asc.CPlugin();
plugin.deserialize(_array[i]);
_arraySystem.push(plugin);
}
window.g_asc_plugins.registerSystem("", _arraySystem);
window.g_asc_plugins.runAllSystem();
};
AscCommon.InitDragAndDrop = function(oHtmlElement, callback) {
if ("undefined" != typeof(FileReader) && null != oHtmlElement) {
oHtmlElement["ondragover"] = function (e) {
......@@ -232,9 +271,16 @@ AscCommon.InitDragAndDrop = function(oHtmlElement, callback) {
}
}
window["asc_initAdvancedOptions"] = function(_code)
window["asc_initAdvancedOptions"] = function(_code, _file_hash)
{
var _editor = window["Asc"]["editor"] ? window["Asc"]["editor"] : window.editor;
if ((_code == 90 || _code == 91) && window.g_asc_plugins && window.g_asc_plugins.isRunned("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}"))
{
window.g_asc_plugins.init("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}", { "type" : "getPasswordByFile", "hash" : _file_hash });
return;
}
_editor._onNeedParams(undefined, (_code == 90 || _code == 91) ? true : undefined);
};
......@@ -426,6 +472,33 @@ function getBinaryArray(_data, _len)
return _array;
}
// OnlyPass ----------------------------------
Asc['asc_docs_api'].prototype["pluginMethod_OnlyPass"] = function(obj)
{
switch (obj.type)
{
case "generatePassword":
{
window["DesktopOfflineAppDocumentStartSave"](window.doadssIsSaveAs, obj["password"], true);
break;
}
case "getPasswordByFile":
{
if ("" != obj["password"])
{
var _param = ("<m_sPassword>" + AscCommon.CopyPasteCorrectString(obj["password"]) + "</m_sPassword>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
}
else
{
this._onNeedParams(undefined, true);
}
break;
}
}
};
// -------------------------------------------
// меняем среду
//AscBrowser.isSafari = false;
//AscBrowser.isSafariMacOs = false;
......
......@@ -150,6 +150,13 @@
this.pluginsMap[guid] = { isSystem : true };
}
},
runAllSystem : function()
{
for (var i = 0; i < this.systemPlugins.length; i++)
{
this.run(this.systemPlugins[i].guid, 0, "");
}
},
// pointer events methods -------------------
enablePointerEvents : function()
{
......@@ -212,6 +219,10 @@
}
return false;
},
isRunned : function(guid)
{
return (undefined !== this.runnedPluginsMap[guid]);
},
run : function(guid, variation, data, isNoUse_isNoSystemPluginsOnlyOne)
{
if (this.runAndCloseData) // run only on close!!!
......@@ -422,7 +433,7 @@
}
},
init : function(guid)
init : function(guid, raw_data)
{
var plugin = this.getPluginByGuid(guid);
var runObject = this.runnedPluginsMap[guid];
......@@ -430,46 +441,53 @@
if (!plugin || !runObject || !runObject.startData)
return;
switch (plugin.variations[runObject.currentVariation].initDataType)
if (undefined === raw_data)
{
case Asc.EPluginDataType.text:
switch (plugin.variations[runObject.currentVariation].initDataType)
{
var text_data = {
data : "",
pushData : function(format, value)
{
this.data = value;
}
};
this.api.asc_CheckCopy(text_data, 1);
if (text_data.data == null)
text_data.data = "";
runObject.startData.setAttribute("data", text_data.data);
break;
}
case Asc.EPluginDataType.html:
{
var text_data = {
data : "",
pushData : function(format, value)
{
this.data = value;
}
};
this.api.asc_CheckCopy(text_data, 2);
if (text_data.data == null)
text_data.data = "";
runObject.startData.setAttribute("data", text_data.data);
break;
}
case Asc.EPluginDataType.ole:
{
// теперь выше задается
break;
case Asc.EPluginDataType.text:
{
var text_data = {
data: "",
pushData: function (format, value)
{
this.data = value;
}
};
this.api.asc_CheckCopy(text_data, 1);
if (text_data.data == null)
text_data.data = "";
runObject.startData.setAttribute("data", text_data.data);
break;
}
case Asc.EPluginDataType.html:
{
var text_data = {
data: "",
pushData: function (format, value)
{
this.data = value;
}
};
this.api.asc_CheckCopy(text_data, 2);
if (text_data.data == null)
text_data.data = "";
runObject.startData.setAttribute("data", text_data.data);
break;
}
case Asc.EPluginDataType.ole:
{
// теперь выше задается
break;
}
}
}
else
{
runObject.startData.setAttribute("data", raw_data);
}
var _iframe = document.getElementById(runObject.frameId);
if (_iframe)
......@@ -865,6 +883,9 @@
});
if (window["AscDesktopEditor"] && window["UpdateSystemPlugins"])
window["UpdateSystemPlugins"]();
return window.g_asc_plugins;
};
......
......@@ -179,8 +179,15 @@ Asc['asc_docs_api'].prototype.asc_Save = function (isNoUserSave, isSaveAs)
window["DesktopOfflineAppDocumentStartSave"](isSaveAs);
}
};
window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs)
window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs, password, isForce)
{
window.doadssIsSaveAs = isSaveAs;
if (true !== isForce && window.g_asc_plugins && window.g_asc_plugins.isRunned("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}"))
{
window.g_asc_plugins.init("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}", { "type" : "generatePassword" });
return;
}
editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
var _param = "";
......@@ -189,9 +196,9 @@ window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs)
if (AscCommon.AscBrowser.isRetina)
_param += "retina=true;";
window["AscDesktopEditor"]["LocalFileSave"](_param);
window["AscDesktopEditor"]["LocalFileSave"](_param, password);
};
window["DesktopOfflineAppDocumentEndSave"] = function(error)
window["DesktopOfflineAppDocumentEndSave"] = function(error, hash, password)
{
editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
if (0 == error)
......@@ -214,6 +221,14 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error)
window.SaveQuestionObjectBeforeSign = null;
}
}
if (hash !== null && hash !== undefined && hash != "")
{
if (window.g_asc_plugins && window.g_asc_plugins.isRunned("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}"))
{
window.g_asc_plugins.init("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}", {"type": "setPasswordByFile", "hash": hash, "password": password});
}
}
};
Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
{
......
/*
* (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";
// Import
var c_oAscError = Asc.c_oAscError;
/////////////////////////////////////////////////////////
////////////// OPEN ////////////////////////
/////////////////////////////////////////////////////////
Asc['asc_docs_api'].prototype._OfflineAppDocumentStartLoad = function()
{
this.asc_registerCallback('asc_onDocumentContentReady', function(){
DesktopOfflineUpdateLocalName(editor);
/*
* (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";
// Import
var c_oAscError = Asc.c_oAscError;
/////////////////////////////////////////////////////////
////////////// OPEN ////////////////////////
/////////////////////////////////////////////////////////
Asc['asc_docs_api'].prototype._OfflineAppDocumentStartLoad = function()
{
this.asc_registerCallback('asc_onDocumentContentReady', function(){
DesktopOfflineUpdateLocalName(editor);
setTimeout(function(){window["UpdateInstallPlugins"]();}, 10);
});
AscCommon.History.UserSaveMode = true;
window["AscDesktopEditor"]["LocalStartOpen"]();
};
Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data, _len)
{
AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"]();
if (_data == "")
{
this.sendEvent("asc_onError", c_oAscError.ID.ConvertationOpenError, c_oAscError.Level.Critical);
return;
}
var _binary = getBinaryArray(_data, _len);
var _sign_len = AscCommon.c_oSerFormat.Signature.length;
var _signature = "";
if (_binary.length >= _sign_len)
{
for (var i = 0; i < _sign_len; i++)
{
_signature += String.fromCharCode(_binary[i]);
}
}
if (AscCommon.c_oSerFormat.Signature !== _signature)
{
this.OpenDocument(_url, _binary);
}
else
{
this.OpenDocument2(_url, _binary);
this.WordControl.m_oLogicDocument.Set_FastCollaborativeEditing(false);
}
this.WordControl.m_oLogicDocument.Set_FastCollaborativeEditing(false);
DesktopOfflineUpdateLocalName(this);
window["DesktopAfterOpen"](this);
};
window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data, _len)
{
AscCommon.g_oDocumentUrls.documentUrl = _url;
if (AscCommon.g_oDocumentUrls.documentUrl.indexOf("file:") != 0)
{
if (AscCommon.g_oDocumentUrls.documentUrl.indexOf("/") != 0)
AscCommon.g_oDocumentUrls.documentUrl = "/" + AscCommon.g_oDocumentUrls.documentUrl;
AscCommon.g_oDocumentUrls.documentUrl = "file://" + AscCommon.g_oDocumentUrls.documentUrl;
}
editor._OfflineAppDocumentEndLoad(_url, _data, _len);
};
Asc['asc_docs_api'].prototype.asc_setAdvancedOptions = function(idOption, option)
{
if (window["Asc"].c_oAscAdvancedOptionsID.TXT === idOption) {
var _param = "";
_param += ("<m_nCsvTxtEncoding>" + option.asc_getCodePage() + "</m_nCsvTxtEncoding>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
}
else if (window["Asc"].c_oAscAdvancedOptionsID.DRM === idOption) {
var _param = "";
_param += ("<m_sPassword>" + AscCommon.CopyPasteCorrectString(option.asc_getPassword()) + "</m_sPassword>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
}
};
Asc['asc_docs_api'].prototype["asc_setAdvancedOptions"] = Asc['asc_docs_api'].prototype.asc_setAdvancedOptions;
/////////////////////////////////////////////////////////
////////////// CHANGES /////////////////////
/////////////////////////////////////////////////////////
AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
{
this.SavedIndex = (null === this.SavedIndex && -1 === this.Index ? null : this.Index);
if (true === this.Is_UserSaveMode())
{
if (true === IsUserSave)
{
this.UserSavedIndex = this.Index;
this.ForceSave = false;
}
}
else
{
this.ForceSave = false;
}
};
AscCommon.CHistory.prototype.Have_Changes = function(IsNotUserSave, IsNoSavedNoModifyed)
{
if (true === this.Is_UserSaveMode() && true !== IsNotUserSave)
{
if (-1 === this.Index && null === this.UserSavedIndex && false === this.ForceSave)
{
if (window["AscDesktopEditor"])
{
if (0 != window["AscDesktopEditor"]["LocalFileGetOpenChangesCount"]())
return true;
if (!window["AscDesktopEditor"]["LocalFileGetSaved"]() && IsNoSavedNoModifyed !== true)
return true;
}
return false;
}
if (this.Index != this.UserSavedIndex || true === this.ForceSave)
return true;
return false;
}
else
{
if (-1 === this.Index && null === this.SavedIndex && false === this.ForceSave)
return false;
if (this.Index != this.SavedIndex || true === this.ForceSave)
return true;
return false;
}
};
window["DesktopOfflineAppDocumentApplyChanges"] = function(_changes)
{
editor._coAuthoringSetChanges(_changes, new AscCommonWord.CDocumentColor( 191, 255, 199 ));
//editor["asc_nativeApplyChanges"](_changes);
//editor["asc_nativeCalculateFile"]();
};
/////////////////////////////////////////////////////////
//////////////// SAVE //////////////////////
/////////////////////////////////////////////////////////
Asc['asc_docs_api'].prototype.SetDocumentModified = function(bValue)
{
this.isDocumentModify = bValue;
this.sendEvent("asc_onDocumentModifiedChanged");
if (undefined !== window["AscDesktopEditor"])
{
window["AscDesktopEditor"]["onDocumentModifiedChanged"](AscCommon.History ? AscCommon.History.Have_Changes(undefined, true) : bValue);
}
};
Asc['asc_docs_api'].prototype.asc_Save = function (isNoUserSave, isSaveAs)
{
if (true !== isNoUserSave)
this.IsUserSave = true;
if (this.IsUserSave)
{
this.LastUserSavedIndex = AscCommon.History.UserSavedIndex;
}
if (true === this.canSave && !this.isLongAction())
{
var _isNaturalSave = this.IsUserSave;
this.canSave = false;
if (this.WordControl.m_oLogicDocument != null)
{
var t = this;
this.CoAuthoringApi.askSaveChanges(function(e) {
t.onSaveCallback(e);
});
if (this.CoAuthoringApi.onUnSaveLock)
this.CoAuthoringApi.onUnSaveLock();
}
else
{
this.canSave = true;
}
if (_isNaturalSave === true)
window["DesktopOfflineAppDocumentStartSave"](isSaveAs);
}
};
window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs)
{
editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
var _param = "";
if (isSaveAs === true)
_param += "saveas=true;";
if (AscCommon.AscBrowser.isRetina)
_param += "retina=true;";
window["AscDesktopEditor"]["LocalFileSave"](_param);
};
window["DesktopOfflineAppDocumentEndSave"] = function(error)
{
editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
if (error == 0)
DesktopOfflineUpdateLocalName(editor);
else
AscCommon.History.UserSavedIndex = editor.LastUserSavedIndex;
editor.UpdateInterfaceState();
editor.LastUserSavedIndex = undefined;
if (2 == error)
editor.sendEvent("asc_onError", c_oAscError.ID.ConvertationSaveError, c_oAscError.Level.NoCritical);
if (0 == error)
{
if (window.SaveQuestionObjectBeforeSign)
{
var _obj = window.SaveQuestionObjectBeforeSign;
editor.sendEvent("asc_onSignatureClick", _obj.guid, _obj.width, _obj.height);
window.SaveQuestionObjectBeforeSign = null;
}
}
};
Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
{
this.asc_Save(false, true);
};
Asc['asc_docs_api'].prototype.AddImageUrl = function(url, imgProp)
{
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url);
this.AddImageUrlAction(AscCommon.g_oDocumentUrls.getImageUrl(_url), imgProp);
};
Asc['asc_docs_api'].prototype.AddImage = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
Asc['asc_docs_api'].prototype.asc_addImage = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
Asc['asc_docs_api'].prototype.asc_isOffline = function()
{
return true;
};
Asc['asc_docs_api'].prototype["asc_addImage"] = Asc['asc_docs_api'].prototype.asc_addImage;
Asc['asc_docs_api'].prototype["AddImageUrl"] = Asc['asc_docs_api'].prototype.AddImageUrl;
Asc['asc_docs_api'].prototype["AddImage"] = Asc['asc_docs_api'].prototype.AddImage;
Asc['asc_docs_api'].prototype["asc_Save"] = Asc['asc_docs_api'].prototype.asc_Save;
Asc['asc_docs_api'].prototype["asc_DownloadAs"] = Asc['asc_docs_api'].prototype.asc_DownloadAs;
Asc['asc_docs_api'].prototype["asc_isOffline"] = Asc['asc_docs_api'].prototype.asc_isOffline;
Asc['asc_docs_api'].prototype["SetDocumentModified"] = Asc['asc_docs_api'].prototype.SetDocumentModified;
window["DesktopOfflineAppDocumentAddImageEnd"] = function(url)
{
if (url == "")
return;
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url);
editor.AddImageUrlAction(AscCommon.g_oDocumentUrls.getImageUrl(_url));
};
window["on_editor_native_message"] = function(sCommand, sParam)
{
if (!window.editor)
return;
if (sCommand == "save")
editor.asc_Save();
else if (sCommand == "saveAs")
editor.asc_Save(false, true);
else if (sCommand == "print")
editor.asc_Print();
});
AscCommon.History.UserSaveMode = true;
window["AscDesktopEditor"]["LocalStartOpen"]();
};
Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data, _len)
{
AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"]();
if (_data == "")
{
this.sendEvent("asc_onError", c_oAscError.ID.ConvertationOpenError, c_oAscError.Level.Critical);
return;
}
var _binary = getBinaryArray(_data, _len);
var _sign_len = AscCommon.c_oSerFormat.Signature.length;
var _signature = "";
if (_binary.length >= _sign_len)
{
for (var i = 0; i < _sign_len; i++)
{
_signature += String.fromCharCode(_binary[i]);
}
}
if (AscCommon.c_oSerFormat.Signature !== _signature)
{
this.OpenDocument(_url, _binary);
}
else
{
this.OpenDocument2(_url, _binary);
this.WordControl.m_oLogicDocument.Set_FastCollaborativeEditing(false);
}
this.WordControl.m_oLogicDocument.Set_FastCollaborativeEditing(false);
DesktopOfflineUpdateLocalName(this);
window["DesktopAfterOpen"](this);
};
window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data, _len)
{
AscCommon.g_oDocumentUrls.documentUrl = _url;
if (AscCommon.g_oDocumentUrls.documentUrl.indexOf("file:") != 0)
{
if (AscCommon.g_oDocumentUrls.documentUrl.indexOf("/") != 0)
AscCommon.g_oDocumentUrls.documentUrl = "/" + AscCommon.g_oDocumentUrls.documentUrl;
AscCommon.g_oDocumentUrls.documentUrl = "file://" + AscCommon.g_oDocumentUrls.documentUrl;
}
editor._OfflineAppDocumentEndLoad(_url, _data, _len);
};
Asc['asc_docs_api'].prototype.asc_setAdvancedOptions = function(idOption, option)
{
if (window["Asc"].c_oAscAdvancedOptionsID.TXT === idOption) {
var _param = "";
_param += ("<m_nCsvTxtEncoding>" + option.asc_getCodePage() + "</m_nCsvTxtEncoding>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
}
else if (window["Asc"].c_oAscAdvancedOptionsID.DRM === idOption) {
var _param = "";
_param += ("<m_sPassword>" + AscCommon.CopyPasteCorrectString(option.asc_getPassword()) + "</m_sPassword>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
}
};
Asc['asc_docs_api'].prototype["asc_setAdvancedOptions"] = Asc['asc_docs_api'].prototype.asc_setAdvancedOptions;
/////////////////////////////////////////////////////////
////////////// CHANGES /////////////////////
/////////////////////////////////////////////////////////
AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
{
this.SavedIndex = (null === this.SavedIndex && -1 === this.Index ? null : this.Index);
if (true === this.Is_UserSaveMode())
{
if (true === IsUserSave)
{
this.UserSavedIndex = this.Index;
this.ForceSave = false;
}
}
else
{
this.ForceSave = false;
}
};
AscCommon.CHistory.prototype.Have_Changes = function(IsNotUserSave, IsNoSavedNoModifyed)
{
if (true === this.Is_UserSaveMode() && true !== IsNotUserSave)
{
if (-1 === this.Index && null === this.UserSavedIndex && false === this.ForceSave)
{
if (window["AscDesktopEditor"])
{
if (0 != window["AscDesktopEditor"]["LocalFileGetOpenChangesCount"]())
return true;
if (!window["AscDesktopEditor"]["LocalFileGetSaved"]() && IsNoSavedNoModifyed !== true)
return true;
}
return false;
}
if (this.Index != this.UserSavedIndex || true === this.ForceSave)
return true;
return false;
}
else
{
if (-1 === this.Index && null === this.SavedIndex && false === this.ForceSave)
return false;
if (this.Index != this.SavedIndex || true === this.ForceSave)
return true;
return false;
}
};
window["DesktopOfflineAppDocumentApplyChanges"] = function(_changes)
{
editor._coAuthoringSetChanges(_changes, new AscCommonWord.CDocumentColor( 191, 255, 199 ));
//editor["asc_nativeApplyChanges"](_changes);
//editor["asc_nativeCalculateFile"]();
};
/////////////////////////////////////////////////////////
//////////////// SAVE //////////////////////
/////////////////////////////////////////////////////////
Asc['asc_docs_api'].prototype.SetDocumentModified = function(bValue)
{
this.isDocumentModify = bValue;
this.sendEvent("asc_onDocumentModifiedChanged");
if (undefined !== window["AscDesktopEditor"])
{
window["AscDesktopEditor"]["onDocumentModifiedChanged"](AscCommon.History ? AscCommon.History.Have_Changes(undefined, true) : bValue);
}
};
Asc['asc_docs_api'].prototype.asc_Save = function (isNoUserSave, isSaveAs)
{
if (true !== isNoUserSave)
this.IsUserSave = true;
if (this.IsUserSave)
{
this.LastUserSavedIndex = AscCommon.History.UserSavedIndex;
}
if (true === this.canSave && !this.isLongAction())
{
var _isNaturalSave = this.IsUserSave;
this.canSave = false;
if (this.WordControl.m_oLogicDocument != null)
{
var t = this;
this.CoAuthoringApi.askSaveChanges(function(e) {
t.onSaveCallback(e);
});
if (this.CoAuthoringApi.onUnSaveLock)
this.CoAuthoringApi.onUnSaveLock();
}
else
{
this.canSave = true;
}
if (_isNaturalSave === true)
window["DesktopOfflineAppDocumentStartSave"](isSaveAs);
}
};
window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs, password, isForce)
{
window.doadssIsSaveAs = isSaveAs;
if (true !== isForce && window.g_asc_plugins && window.g_asc_plugins.isRunned("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}"))
{
window.g_asc_plugins.init("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}", { "type" : "generatePassword" });
return;
}
editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
var _param = "";
if (isSaveAs === true)
_param += "saveas=true;";
if (AscCommon.AscBrowser.isRetina)
_param += "retina=true;";
window["AscDesktopEditor"]["LocalFileSave"](_param, password);
};
window["DesktopOfflineAppDocumentEndSave"] = function(error, hash, password)
{
editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
if (error == 0)
DesktopOfflineUpdateLocalName(editor);
else
AscCommon.History.UserSavedIndex = editor.LastUserSavedIndex;
editor.UpdateInterfaceState();
editor.LastUserSavedIndex = undefined;
if (2 == error)
editor.sendEvent("asc_onError", c_oAscError.ID.ConvertationSaveError, c_oAscError.Level.NoCritical);
if (0 == error)
{
if (window.SaveQuestionObjectBeforeSign)
{
var _obj = window.SaveQuestionObjectBeforeSign;
editor.sendEvent("asc_onSignatureClick", _obj.guid, _obj.width, _obj.height);
window.SaveQuestionObjectBeforeSign = null;
}
}
if (hash !== null && hash !== undefined && hash != "")
{
if (window.g_asc_plugins && window.g_asc_plugins.isRunned("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}"))
{
window.g_asc_plugins.init("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}", {"type": "setPasswordByFile", "hash": hash, "password": password});
}
}
};
Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
{
this.asc_Save(false, true);
};
Asc['asc_docs_api'].prototype.AddImageUrl = function(url, imgProp)
{
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url);
this.AddImageUrlAction(AscCommon.g_oDocumentUrls.getImageUrl(_url), imgProp);
};
Asc['asc_docs_api'].prototype.AddImage = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
Asc['asc_docs_api'].prototype.asc_addImage = function()
{
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
Asc['asc_docs_api'].prototype.asc_isOffline = function()
{
return true;
};
Asc['asc_docs_api'].prototype["asc_addImage"] = Asc['asc_docs_api'].prototype.asc_addImage;
Asc['asc_docs_api'].prototype["AddImageUrl"] = Asc['asc_docs_api'].prototype.AddImageUrl;
Asc['asc_docs_api'].prototype["AddImage"] = Asc['asc_docs_api'].prototype.AddImage;
Asc['asc_docs_api'].prototype["asc_Save"] = Asc['asc_docs_api'].prototype.asc_Save;
Asc['asc_docs_api'].prototype["asc_DownloadAs"] = Asc['asc_docs_api'].prototype.asc_DownloadAs;
Asc['asc_docs_api'].prototype["asc_isOffline"] = Asc['asc_docs_api'].prototype.asc_isOffline;
Asc['asc_docs_api'].prototype["SetDocumentModified"] = Asc['asc_docs_api'].prototype.SetDocumentModified;
window["DesktopOfflineAppDocumentAddImageEnd"] = function(url)
{
if (url == "")
return;
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url);
editor.AddImageUrlAction(AscCommon.g_oDocumentUrls.getImageUrl(_url));
};
window["on_editor_native_message"] = function(sCommand, sParam)
{
if (!window.editor)
return;
if (sCommand == "save")
editor.asc_Save();
else if (sCommand == "saveAs")
editor.asc_Save(false, true);
else if (sCommand == "print")
editor.asc_Print();
};
\ 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