Commit b6c604be authored by Oleg Korshul's avatar Oleg Korshul

.

parent 70ab3428
...@@ -249,8 +249,15 @@ window["Asc"]['spreadsheet_api'].prototype.asc_isOffline = function() ...@@ -249,8 +249,15 @@ window["Asc"]['spreadsheet_api'].prototype.asc_isOffline = function()
return true; 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); window["Asc"]["editor"].sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
var _param = ""; var _param = "";
...@@ -259,9 +266,9 @@ window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs) ...@@ -259,9 +266,9 @@ window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs)
if (AscCommon.AscBrowser.isRetina) if (AscCommon.AscBrowser.isRetina)
_param += "retina=true;"; _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); window["Asc"]["editor"].sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
if (0 == error) if (0 == error)
...@@ -284,6 +291,14 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error) ...@@ -284,6 +291,14 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error)
window.SaveQuestionObjectBeforeSign = null; 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; window["Asc"]['spreadsheet_api'].prototype["asc_addImageDrawingObject"] = window["Asc"]['spreadsheet_api'].prototype.asc_addImageDrawingObject;
......
...@@ -209,6 +209,45 @@ window["UpdateInstallPlugins"] = function() ...@@ -209,6 +209,45 @@ window["UpdateInstallPlugins"] = function()
_editor.sendEvent("asc_onPluginsInit", _plugins); _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) { AscCommon.InitDragAndDrop = function(oHtmlElement, callback) {
if ("undefined" != typeof(FileReader) && null != oHtmlElement) { if ("undefined" != typeof(FileReader) && null != oHtmlElement) {
oHtmlElement["ondragover"] = function (e) { oHtmlElement["ondragover"] = function (e) {
...@@ -232,9 +271,16 @@ AscCommon.InitDragAndDrop = function(oHtmlElement, callback) { ...@@ -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; 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); _editor._onNeedParams(undefined, (_code == 90 || _code == 91) ? true : undefined);
}; };
...@@ -426,6 +472,33 @@ function getBinaryArray(_data, _len) ...@@ -426,6 +472,33 @@ function getBinaryArray(_data, _len)
return _array; 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.isSafari = false;
//AscBrowser.isSafariMacOs = false; //AscBrowser.isSafariMacOs = false;
......
...@@ -150,6 +150,13 @@ ...@@ -150,6 +150,13 @@
this.pluginsMap[guid] = { isSystem : true }; 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 ------------------- // pointer events methods -------------------
enablePointerEvents : function() enablePointerEvents : function()
{ {
...@@ -212,6 +219,10 @@ ...@@ -212,6 +219,10 @@
} }
return false; return false;
}, },
isRunned : function(guid)
{
return (undefined !== this.runnedPluginsMap[guid]);
},
run : function(guid, variation, data, isNoUse_isNoSystemPluginsOnlyOne) run : function(guid, variation, data, isNoUse_isNoSystemPluginsOnlyOne)
{ {
if (this.runAndCloseData) // run only on close!!! if (this.runAndCloseData) // run only on close!!!
...@@ -422,7 +433,7 @@ ...@@ -422,7 +433,7 @@
} }
}, },
init : function(guid) init : function(guid, raw_data)
{ {
var plugin = this.getPluginByGuid(guid); var plugin = this.getPluginByGuid(guid);
var runObject = this.runnedPluginsMap[guid]; var runObject = this.runnedPluginsMap[guid];
...@@ -430,46 +441,53 @@ ...@@ -430,46 +441,53 @@
if (!plugin || !runObject || !runObject.startData) if (!plugin || !runObject || !runObject.startData)
return; return;
switch (plugin.variations[runObject.currentVariation].initDataType) if (undefined === raw_data)
{ {
case Asc.EPluginDataType.text: switch (plugin.variations[runObject.currentVariation].initDataType)
{ {
var text_data = { case Asc.EPluginDataType.text:
data : "", {
pushData : function(format, value) var text_data = {
{ data: "",
this.data = value; pushData: function (format, value)
} {
}; this.data = value;
}
this.api.asc_CheckCopy(text_data, 1); };
if (text_data.data == null)
text_data.data = ""; this.api.asc_CheckCopy(text_data, 1);
runObject.startData.setAttribute("data", text_data.data); if (text_data.data == null)
break; text_data.data = "";
} runObject.startData.setAttribute("data", text_data.data);
case Asc.EPluginDataType.html: break;
{ }
var text_data = { case Asc.EPluginDataType.html:
data : "", {
pushData : function(format, value) var text_data = {
{ data: "",
this.data = value; pushData: function (format, value)
} {
}; this.data = value;
}
this.api.asc_CheckCopy(text_data, 2); };
if (text_data.data == null)
text_data.data = ""; this.api.asc_CheckCopy(text_data, 2);
runObject.startData.setAttribute("data", text_data.data); if (text_data.data == null)
break; text_data.data = "";
} runObject.startData.setAttribute("data", text_data.data);
case Asc.EPluginDataType.ole: break;
{ }
// теперь выше задается case Asc.EPluginDataType.ole:
break; {
// теперь выше задается
break;
}
} }
} }
else
{
runObject.startData.setAttribute("data", raw_data);
}
var _iframe = document.getElementById(runObject.frameId); var _iframe = document.getElementById(runObject.frameId);
if (_iframe) if (_iframe)
...@@ -865,6 +883,9 @@ ...@@ -865,6 +883,9 @@
}); });
if (window["AscDesktopEditor"] && window["UpdateSystemPlugins"])
window["UpdateSystemPlugins"]();
return window.g_asc_plugins; return window.g_asc_plugins;
}; };
......
...@@ -179,8 +179,15 @@ Asc['asc_docs_api'].prototype.asc_Save = function (isNoUserSave, isSaveAs) ...@@ -179,8 +179,15 @@ Asc['asc_docs_api'].prototype.asc_Save = function (isNoUserSave, isSaveAs)
window["DesktopOfflineAppDocumentStartSave"](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); editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
var _param = ""; var _param = "";
...@@ -189,9 +196,9 @@ window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs) ...@@ -189,9 +196,9 @@ window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs)
if (AscCommon.AscBrowser.isRetina) if (AscCommon.AscBrowser.isRetina)
_param += "retina=true;"; _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); editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
if (0 == error) if (0 == error)
...@@ -214,6 +221,14 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error) ...@@ -214,6 +221,14 @@ window["DesktopOfflineAppDocumentEndSave"] = function(error)
window.SaveQuestionObjectBeforeSign = null; 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) Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
{ {
......
/* /*
* (c) Copyright Ascensio System SIA 2010-2017 * (c) Copyright Ascensio System SIA 2010-2017
* *
* This program is a free software product. You can redistribute it and/or * 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) * 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 * 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 * 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 * that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights. * of any third-party rights.
* *
* This program is distributed WITHOUT ANY WARRANTY; without even the implied * This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For * 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 * 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, * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021. * EU, LV-1021.
* *
* The interactive user interfaces in modified source and object code versions * The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under * of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3. * Section 5 of the GNU AGPL version 3.
* *
* Pursuant to Section 7(b) of the License you must retain the original Product * 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 * 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. * grant you any rights under trademark law for use of our trademarks.
* *
* All the Product's GUI elements, including illustrations and icon sets, as * All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the * well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License * Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
* *
*/ */
"use strict"; "use strict";
// Import // Import
var c_oAscError = Asc.c_oAscError; var c_oAscError = Asc.c_oAscError;
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
////////////// OPEN //////////////////////// ////////////// OPEN ////////////////////////
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
Asc['asc_docs_api'].prototype._OfflineAppDocumentStartLoad = function() Asc['asc_docs_api'].prototype._OfflineAppDocumentStartLoad = function()
{ {
this.asc_registerCallback('asc_onDocumentContentReady', function(){ this.asc_registerCallback('asc_onDocumentContentReady', function(){
DesktopOfflineUpdateLocalName(editor); DesktopOfflineUpdateLocalName(editor);
setTimeout(function(){window["UpdateInstallPlugins"]();}, 10); setTimeout(function(){window["UpdateInstallPlugins"]();}, 10);
}); });
AscCommon.History.UserSaveMode = true; AscCommon.History.UserSaveMode = true;
window["AscDesktopEditor"]["LocalStartOpen"](); window["AscDesktopEditor"]["LocalStartOpen"]();
}; };
Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data, _len) Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data, _len)
{ {
AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"](); AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"]();
if (_data == "") if (_data == "")
{ {
this.sendEvent("asc_onError", c_oAscError.ID.ConvertationOpenError, c_oAscError.Level.Critical); this.sendEvent("asc_onError", c_oAscError.ID.ConvertationOpenError, c_oAscError.Level.Critical);
return; return;
} }
var _binary = getBinaryArray(_data, _len); var _binary = getBinaryArray(_data, _len);
var _sign_len = AscCommon.c_oSerFormat.Signature.length; var _sign_len = AscCommon.c_oSerFormat.Signature.length;
var _signature = ""; var _signature = "";
if (_binary.length >= _sign_len) if (_binary.length >= _sign_len)
{ {
for (var i = 0; i < _sign_len; i++) for (var i = 0; i < _sign_len; i++)
{ {
_signature += String.fromCharCode(_binary[i]); _signature += String.fromCharCode(_binary[i]);
} }
} }
if (AscCommon.c_oSerFormat.Signature !== _signature) if (AscCommon.c_oSerFormat.Signature !== _signature)
{ {
this.OpenDocument(_url, _binary); this.OpenDocument(_url, _binary);
} }
else else
{ {
this.OpenDocument2(_url, _binary); this.OpenDocument2(_url, _binary);
this.WordControl.m_oLogicDocument.Set_FastCollaborativeEditing(false); this.WordControl.m_oLogicDocument.Set_FastCollaborativeEditing(false);
} }
this.WordControl.m_oLogicDocument.Set_FastCollaborativeEditing(false); this.WordControl.m_oLogicDocument.Set_FastCollaborativeEditing(false);
DesktopOfflineUpdateLocalName(this); DesktopOfflineUpdateLocalName(this);
window["DesktopAfterOpen"](this); window["DesktopAfterOpen"](this);
}; };
window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data, _len) window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data, _len)
{ {
AscCommon.g_oDocumentUrls.documentUrl = _url; AscCommon.g_oDocumentUrls.documentUrl = _url;
if (AscCommon.g_oDocumentUrls.documentUrl.indexOf("file:") != 0) if (AscCommon.g_oDocumentUrls.documentUrl.indexOf("file:") != 0)
{ {
if (AscCommon.g_oDocumentUrls.documentUrl.indexOf("/") != 0) if (AscCommon.g_oDocumentUrls.documentUrl.indexOf("/") != 0)
AscCommon.g_oDocumentUrls.documentUrl = "/" + AscCommon.g_oDocumentUrls.documentUrl; AscCommon.g_oDocumentUrls.documentUrl = "/" + AscCommon.g_oDocumentUrls.documentUrl;
AscCommon.g_oDocumentUrls.documentUrl = "file://" + AscCommon.g_oDocumentUrls.documentUrl; AscCommon.g_oDocumentUrls.documentUrl = "file://" + AscCommon.g_oDocumentUrls.documentUrl;
} }
editor._OfflineAppDocumentEndLoad(_url, _data, _len); editor._OfflineAppDocumentEndLoad(_url, _data, _len);
}; };
Asc['asc_docs_api'].prototype.asc_setAdvancedOptions = function(idOption, option) Asc['asc_docs_api'].prototype.asc_setAdvancedOptions = function(idOption, option)
{ {
if (window["Asc"].c_oAscAdvancedOptionsID.TXT === idOption) { if (window["Asc"].c_oAscAdvancedOptionsID.TXT === idOption) {
var _param = ""; var _param = "";
_param += ("<m_nCsvTxtEncoding>" + option.asc_getCodePage() + "</m_nCsvTxtEncoding>"); _param += ("<m_nCsvTxtEncoding>" + option.asc_getCodePage() + "</m_nCsvTxtEncoding>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param); window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
} }
else if (window["Asc"].c_oAscAdvancedOptionsID.DRM === idOption) { else if (window["Asc"].c_oAscAdvancedOptionsID.DRM === idOption) {
var _param = ""; var _param = "";
_param += ("<m_sPassword>" + AscCommon.CopyPasteCorrectString(option.asc_getPassword()) + "</m_sPassword>"); _param += ("<m_sPassword>" + AscCommon.CopyPasteCorrectString(option.asc_getPassword()) + "</m_sPassword>");
window["AscDesktopEditor"]["SetAdvancedOptions"](_param); window["AscDesktopEditor"]["SetAdvancedOptions"](_param);
} }
}; };
Asc['asc_docs_api'].prototype["asc_setAdvancedOptions"] = Asc['asc_docs_api'].prototype.asc_setAdvancedOptions; Asc['asc_docs_api'].prototype["asc_setAdvancedOptions"] = Asc['asc_docs_api'].prototype.asc_setAdvancedOptions;
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
////////////// CHANGES ///////////////////// ////////////// CHANGES /////////////////////
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave) AscCommon.CHistory.prototype.Reset_SavedIndex = function(IsUserSave)
{ {
this.SavedIndex = (null === this.SavedIndex && -1 === this.Index ? null : this.Index); this.SavedIndex = (null === this.SavedIndex && -1 === this.Index ? null : this.Index);
if (true === this.Is_UserSaveMode()) if (true === this.Is_UserSaveMode())
{ {
if (true === IsUserSave) if (true === IsUserSave)
{ {
this.UserSavedIndex = this.Index; this.UserSavedIndex = this.Index;
this.ForceSave = false; this.ForceSave = false;
} }
} }
else else
{ {
this.ForceSave = false; this.ForceSave = false;
} }
}; };
AscCommon.CHistory.prototype.Have_Changes = function(IsNotUserSave, IsNoSavedNoModifyed) AscCommon.CHistory.prototype.Have_Changes = function(IsNotUserSave, IsNoSavedNoModifyed)
{ {
if (true === this.Is_UserSaveMode() && true !== IsNotUserSave) if (true === this.Is_UserSaveMode() && true !== IsNotUserSave)
{ {
if (-1 === this.Index && null === this.UserSavedIndex && false === this.ForceSave) if (-1 === this.Index && null === this.UserSavedIndex && false === this.ForceSave)
{ {
if (window["AscDesktopEditor"]) if (window["AscDesktopEditor"])
{ {
if (0 != window["AscDesktopEditor"]["LocalFileGetOpenChangesCount"]()) if (0 != window["AscDesktopEditor"]["LocalFileGetOpenChangesCount"]())
return true; return true;
if (!window["AscDesktopEditor"]["LocalFileGetSaved"]() && IsNoSavedNoModifyed !== true) if (!window["AscDesktopEditor"]["LocalFileGetSaved"]() && IsNoSavedNoModifyed !== true)
return true; return true;
} }
return false; return false;
} }
if (this.Index != this.UserSavedIndex || true === this.ForceSave) if (this.Index != this.UserSavedIndex || true === this.ForceSave)
return true; return true;
return false; return false;
} }
else else
{ {
if (-1 === this.Index && null === this.SavedIndex && false === this.ForceSave) if (-1 === this.Index && null === this.SavedIndex && false === this.ForceSave)
return false; return false;
if (this.Index != this.SavedIndex || true === this.ForceSave) if (this.Index != this.SavedIndex || true === this.ForceSave)
return true; return true;
return false; return false;
} }
}; };
window["DesktopOfflineAppDocumentApplyChanges"] = function(_changes) window["DesktopOfflineAppDocumentApplyChanges"] = function(_changes)
{ {
editor._coAuthoringSetChanges(_changes, new AscCommonWord.CDocumentColor( 191, 255, 199 )); editor._coAuthoringSetChanges(_changes, new AscCommonWord.CDocumentColor( 191, 255, 199 ));
//editor["asc_nativeApplyChanges"](_changes); //editor["asc_nativeApplyChanges"](_changes);
//editor["asc_nativeCalculateFile"](); //editor["asc_nativeCalculateFile"]();
}; };
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
//////////////// SAVE ////////////////////// //////////////// SAVE //////////////////////
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
Asc['asc_docs_api'].prototype.SetDocumentModified = function(bValue) Asc['asc_docs_api'].prototype.SetDocumentModified = function(bValue)
{ {
this.isDocumentModify = bValue; this.isDocumentModify = bValue;
this.sendEvent("asc_onDocumentModifiedChanged"); this.sendEvent("asc_onDocumentModifiedChanged");
if (undefined !== window["AscDesktopEditor"]) if (undefined !== window["AscDesktopEditor"])
{ {
window["AscDesktopEditor"]["onDocumentModifiedChanged"](AscCommon.History ? AscCommon.History.Have_Changes(undefined, true) : bValue); window["AscDesktopEditor"]["onDocumentModifiedChanged"](AscCommon.History ? AscCommon.History.Have_Changes(undefined, true) : bValue);
} }
}; };
Asc['asc_docs_api'].prototype.asc_Save = function (isNoUserSave, isSaveAs) Asc['asc_docs_api'].prototype.asc_Save = function (isNoUserSave, isSaveAs)
{ {
if (true !== isNoUserSave) if (true !== isNoUserSave)
this.IsUserSave = true; this.IsUserSave = true;
if (this.IsUserSave) if (this.IsUserSave)
{ {
this.LastUserSavedIndex = AscCommon.History.UserSavedIndex; this.LastUserSavedIndex = AscCommon.History.UserSavedIndex;
} }
if (true === this.canSave && !this.isLongAction()) if (true === this.canSave && !this.isLongAction())
{ {
var _isNaturalSave = this.IsUserSave; var _isNaturalSave = this.IsUserSave;
this.canSave = false; this.canSave = false;
if (this.WordControl.m_oLogicDocument != null) if (this.WordControl.m_oLogicDocument != null)
{ {
var t = this; var t = this;
this.CoAuthoringApi.askSaveChanges(function(e) { this.CoAuthoringApi.askSaveChanges(function(e) {
t.onSaveCallback(e); t.onSaveCallback(e);
}); });
if (this.CoAuthoringApi.onUnSaveLock) if (this.CoAuthoringApi.onUnSaveLock)
this.CoAuthoringApi.onUnSaveLock(); this.CoAuthoringApi.onUnSaveLock();
} }
else else
{ {
this.canSave = true; this.canSave = true;
} }
if (_isNaturalSave === true) if (_isNaturalSave === true)
window["DesktopOfflineAppDocumentStartSave"](isSaveAs); window["DesktopOfflineAppDocumentStartSave"](isSaveAs);
} }
}; };
window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs) window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs, password, isForce)
{ {
editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save); window.doadssIsSaveAs = isSaveAs;
if (true !== isForce && window.g_asc_plugins && window.g_asc_plugins.isRunned("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}"))
var _param = ""; {
if (isSaveAs === true) window.g_asc_plugins.init("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}", { "type" : "generatePassword" });
_param += "saveas=true;"; return;
if (AscCommon.AscBrowser.isRetina) }
_param += "retina=true;";
editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
window["AscDesktopEditor"]["LocalFileSave"](_param);
}; var _param = "";
window["DesktopOfflineAppDocumentEndSave"] = function(error) if (isSaveAs === true)
{ _param += "saveas=true;";
editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save); if (AscCommon.AscBrowser.isRetina)
if (error == 0) _param += "retina=true;";
DesktopOfflineUpdateLocalName(editor);
else window["AscDesktopEditor"]["LocalFileSave"](_param, password);
AscCommon.History.UserSavedIndex = editor.LastUserSavedIndex; };
window["DesktopOfflineAppDocumentEndSave"] = function(error, hash, password)
editor.UpdateInterfaceState(); {
editor.LastUserSavedIndex = undefined; editor.sync_EndAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
if (error == 0)
if (2 == error) DesktopOfflineUpdateLocalName(editor);
editor.sendEvent("asc_onError", c_oAscError.ID.ConvertationSaveError, c_oAscError.Level.NoCritical); else
AscCommon.History.UserSavedIndex = editor.LastUserSavedIndex;
if (0 == error)
{ editor.UpdateInterfaceState();
if (window.SaveQuestionObjectBeforeSign) editor.LastUserSavedIndex = undefined;
{
var _obj = window.SaveQuestionObjectBeforeSign; if (2 == error)
editor.sendEvent("asc_onSignatureClick", _obj.guid, _obj.width, _obj.height); editor.sendEvent("asc_onError", c_oAscError.ID.ConvertationSaveError, c_oAscError.Level.NoCritical);
window.SaveQuestionObjectBeforeSign = null;
} if (0 == error)
} {
}; if (window.SaveQuestionObjectBeforeSign)
Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent) {
{ var _obj = window.SaveQuestionObjectBeforeSign;
this.asc_Save(false, true); editor.sendEvent("asc_onSignatureClick", _obj.guid, _obj.width, _obj.height);
}; window.SaveQuestionObjectBeforeSign = null;
}
Asc['asc_docs_api'].prototype.AddImageUrl = function(url, imgProp) }
{
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url); if (hash !== null && hash !== undefined && hash != "")
this.AddImageUrlAction(AscCommon.g_oDocumentUrls.getImageUrl(_url), imgProp); {
}; if (window.g_asc_plugins && window.g_asc_plugins.isRunned("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}"))
Asc['asc_docs_api'].prototype.AddImage = function() {
{ window.g_asc_plugins.init("asc.{F2402876-659F-47FB-A646-67B49F2B57D0}", {"type": "setPasswordByFile", "hash": hash, "password": password});
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"](); }
}; }
Asc['asc_docs_api'].prototype.asc_addImage = function() };
{ Asc['asc_docs_api'].prototype.asc_DownloadAs = function(typeFile, bIsDownloadEvent)
window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"](); {
}; this.asc_Save(false, true);
Asc['asc_docs_api'].prototype.asc_isOffline = function() };
{
return 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["asc_addImage"] = Asc['asc_docs_api'].prototype.asc_addImage; Asc['asc_docs_api'].prototype.AddImage = function()
Asc['asc_docs_api'].prototype["AddImageUrl"] = Asc['asc_docs_api'].prototype.AddImageUrl; {
Asc['asc_docs_api'].prototype["AddImage"] = Asc['asc_docs_api'].prototype.AddImage; window["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
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_addImage = function()
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["AscDesktopEditor"]["LocalFileGetImageUrlFromOpenFileDialog"]();
};
Asc['asc_docs_api'].prototype.asc_isOffline = function()
window["DesktopOfflineAppDocumentAddImageEnd"] = function(url) {
{ return true;
if (url == "") };
return;
var _url = window["AscDesktopEditor"]["LocalFileGetImageUrl"](url);
editor.AddImageUrlAction(AscCommon.g_oDocumentUrls.getImageUrl(_url));
}; 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;
window["on_editor_native_message"] = function(sCommand, sParam) 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;
if (!window.editor) Asc['asc_docs_api'].prototype["asc_DownloadAs"] = Asc['asc_docs_api'].prototype.asc_DownloadAs;
return; 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;
if (sCommand == "save")
editor.asc_Save();
else if (sCommand == "saveAs") window["DesktopOfflineAppDocumentAddImageEnd"] = function(url)
editor.asc_Save(false, true); {
else if (sCommand == "print") if (url == "")
editor.asc_Print(); 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