Commit c5b52c29 authored by Boris Kocherov's avatar Boris Kocherov

gadget mode changes

parent c95c52d8
This diff is collapsed.
......@@ -1625,6 +1625,7 @@ var editor;
// Обновляем состояние возможности сохранения документа
t.onUpdateDocumentModified(History.Have_Changes());
t.jio_save();
if (undefined !== window["AscDesktopEditor"]) {
window["AscDesktopEditor"]["OnSave"]();
}
......
......@@ -424,9 +424,9 @@ function CFontFileLoader(id)
g_fontNamesEncoder = new ZBase32Encoder();
//var _name = this.Id;
var _name = g_fontNamesEncoder.Encode(this.Id) + ".js";
var _name = g_fontNamesEncoder.Encode(this.Id) + ".ttf";
xhr.open('GET', basePath + "odttf/" + _name, true); // TODO:
xhr.open('GET', basePath + "ttf/" + _name, true); // TODO:
if (typeof ArrayBuffer !== 'undefined' && !window.opera)
xhr.responseType = 'arraybuffer';
......@@ -482,14 +482,6 @@ function CFontFileLoader(id)
oThis.SetStreamIndex(__font_data_idx);
}
// decode
var guidOdttf = [0xA0, 0x66, 0xD6, 0x20, 0x14, 0x96, 0x47, 0xfa, 0x95, 0x69, 0xB8, 0x50, 0xB0, 0x41, 0x49, 0x48];
var _stream = g_fonts_streams[g_fonts_streams.length - 1];
var _data = _stream.data;
var _count_decode = Math.min(32, _stream.size);
for (var i = 0; i < _count_decode; ++i)
_data[i] ^= guidOdttf[i % 16];
};
xhr.send(null);
......
......@@ -51,7 +51,7 @@
this.fonts_streams = [];
// теперь вся информация о всех возможных шрифтах. Они во всех редакторах должны быть одни и те же
this.fontFilesPath = "../../../../fonts/";
this.fontFilesPath = "onlyoffice/fonts/";
this.fontFiles = AscFonts.g_font_files;
this.fontInfos = AscFonts.g_font_infos;
this.map_font_index = AscFonts.g_map_font_index;
......
This diff is collapsed.
......@@ -2826,13 +2826,65 @@
function loadSdk(sdkName, callback)
{
var config_file;
function loadScriptPromise(src) {
return new RSVP.Promise(function (resolve, reject) {
var s;
s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
if (window['AscNotLoadAllScript'])
{
callback();
}
else
{
loadScript('./../../../../sdkjs/' + sdkName + '/sdk-all.js', callback);
if (!Common.Gateway.props.binary_loader) {
switch (sdkName) {
case 'word':
config_file = "webword.json";
break;
case 'cell':
config_file = "webexcel.json";
break;
case 'slide':
config_file = "webpowerpoint.json";
break;
}
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax({
type: "GET",
dataType: "json",
url: Common.Gateway.props.base_url +
"sdkjs/build/configs/" +
config_file
});
})
.push(function (response) {
var queue = new RSVP.Queue(),
sdk = response.target.response.compile.sdk,
list = sdk.common;
list = list.concat(sdk.private);
list.concat(sdk.desktop.common).forEach(function (url) {
url = url.replace('../', Common.Gateway.props.base_url +
'sdkjs/');
queue.push(function () {
return loadScriptPromise(url);
});
});
return queue;
})
.push(callback);
}
loadScript(Common.Gateway.props.base_url + '/sdkjs/' + sdkName + '/sdk-all.js', callback);
}
}
......
......@@ -42,6 +42,23 @@ var AscCommon;
var AscCommonWord;
var AscCommonExcel;
var AscCommonSlide;
var Common = {};
Common.Gateway = {
props: {
value: "",
documentType: "",
binary_loader: true,
base_url: ""
}
};
/**
* @param {String} doc_id
* @param {String} attach_id
* @return {Object}
*/
Common.Gateway.jio_getAttachment = function (doc_id, attach_id) {};
function jq(){}
function DE(){}
......
This diff is collapsed.
......@@ -1899,6 +1899,7 @@ background-repeat: no-repeat;\
// Обновляем состояние возможности сохранения документа
t._onUpdateDocumentCanSave();
t.jio_save();
if (undefined !== window["AscDesktopEditor"])
{
window["AscDesktopEditor"]["OnSave"]();
......
......@@ -43,32 +43,25 @@ Asc['asc_docs_api'].prototype._OfflineAppDocumentStartLoad = function()
this.asc_registerCallback('asc_onDocumentContentReady', function(){
DesktopOfflineUpdateLocalName(editor);
setTimeout(function(){window["UpdateInstallPlugins"]();}, 10);
//setTimeout(function(){window["UpdateInstallPlugins"]();}, 10);
});
AscCommon.History.UserSaveMode = true;
window["AscDesktopEditor"]["LocalStartOpen"]();
return this.jio_open();
};
Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data, _len)
Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _binary)
{
AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"]();
if (_data == "")
//AscCommon.g_oIdCounter.m_sUserId = window["AscDesktopEditor"]["CheckUserId"]();
if (_binary == "")
{
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]);
}
var _signature = _binary.slice(0, _sign_len);
if (typeof _signature !== 'string') {
_signature = String.fromCharCode.apply(null, _signature);
}
if (AscCommon.c_oSerFormat.Signature !== _signature)
{
this.OpenDocument(_url, _binary);
......@@ -78,14 +71,9 @@ Asc['asc_docs_api'].prototype._OfflineAppDocumentEndLoad = function(_url, _data,
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)
window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data)
{
AscCommon.g_oDocumentUrls.documentUrl = _url;
if (AscCommon.g_oDocumentUrls.documentUrl.indexOf("file:") != 0)
......@@ -94,22 +82,22 @@ window["DesktopOfflineAppDocumentEndLoad"] = function(_url, _data, _len)
AscCommon.g_oDocumentUrls.documentUrl = "/" + AscCommon.g_oDocumentUrls.documentUrl;
AscCommon.g_oDocumentUrls.documentUrl = "file://" + AscCommon.g_oDocumentUrls.documentUrl;
}
editor._OfflineAppDocumentEndLoad(_url, _data, _len);
editor._OfflineAppDocumentEndLoad(_url, _data);
};
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) {
var _param = "";
_param += ("<m_nCsvTxtEncoding>" + option.asc_getCodePage() + "</m_nCsvTxtEncoding>");
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);
}
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;
......@@ -164,131 +152,48 @@ AscCommon.CHistory.prototype.Have_Changes = function(IsNotUserSave, IsNoSavedNoM
return false;
}
};
window["DesktopOfflineAppDocumentApplyChanges"] = function(_changes)
{
editor._coAuthoringSetChanges(_changes, new AscCommonWord.CDocumentColor( 191, 255, 199 ));
//editor["asc_nativeApplyChanges"](_changes);
//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)
window["DesktopOfflineAppDocumentStartSave"] = function(isSaveAs)
{
if (true !== isNoUserSave)
this.IsUserSave = true;
if (this.IsUserSave)
{
this.LastUserSavedIndex = AscCommon.History.UserSavedIndex;
}
editor.sync_StartAction(Asc.c_oAscAsyncActionType.BlockInteraction, Asc.c_oAscAsyncAction.Save);
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["AscDesktopEditor"]["LocalFileSave"](_param);
};
window["DesktopOfflineAppDocumentEndSave"] = function(error, hash, password)
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;
}
}
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)
{
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;
......@@ -317,7 +222,7 @@ window["on_editor_native_message"] = function(sCommand, sParam)
{
if (!window.editor)
return;
if (sCommand == "save")
editor.asc_Save();
else if (sCommand == "saveAs")
......
......@@ -2278,6 +2278,7 @@ background-repeat: no-repeat;\
// Обновляем состояние возможности сохранения документа
t._onUpdateDocumentCanSave();
t.jio_save();
if (undefined !== window["AscDesktopEditor"])
{
window["AscDesktopEditor"]["OnSave"]();
......
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