Commit 80217d2c authored by Sergey.Konovalov's avatar Sergey.Konovalov

Изменен внутренний формат сохранения doct -> docx

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@47066 954022d7-b5bf-4e40-9824-e11837661b57
parent 7441dcc3
......@@ -65,7 +65,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.documentUrl = "null";
this.documentTitle = "null";
this.documentFormat = "null";
this.documentVKey = "null";
this.documentVKey = null;
this.documentOrigin = "";
this.cCharDelimiter = String.fromCharCode(5);
this.chartEditor = undefined;
......@@ -446,7 +446,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var that = this;
// Меняем тип состояния (на сохранение)
this.advancedOptionsAction = c_oAscAdvancedOptionsAction.Save;
this._asc_downloadAs(typeFile, function(){
this._asc_downloadAs(typeFile, function(incomeObject){
if(null != incomeObject && "save" == incomeObject.type)
{
var outputData = JSON.parse(incomeObject.data);
that.asc_processSavedFile(outputData.url, false);
}
// Меняем тип состояния (на никакое)
that.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
that.asc_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
......@@ -611,7 +616,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var v = {"id":this.documentId, "format": this.documentFormat, "vkey": this.documentVKey, "editorid": c_oEditorId.Speadsheet, "c":"reopen", "url": this.documentUrl, "title": this.documentTitle, "embeddedfonts": this.isUseEmbeddedCutFonts, "delimiter": option.asc_getDelimiter(), "codepage": option.asc_getCodePage()};
this._asc_sendCommand(function (response) {t._startOpenDocument(response);}, JSON.stringify(v));
} else if (this.advancedOptionsAction === c_oAscAdvancedOptionsAction.Save)
this._asc_downloadAs(c_oAscFileType.CSV, function(){
this._asc_downloadAs(c_oAscFileType.CSV, function(incomeObject){
if(null != incomeObject && "save" == incomeObject.type)
{
var outputData = JSON.parse(incomeObject.data);
t.asc_processSavedFile(outputData.url, false);
}
// Меняем тип состояния (на никакое)
t.advancedOptionsAction = c_oAscAdvancedOptionsAction.None;
t.asc_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
......@@ -619,7 +629,33 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
break;
}
},
asc_processSavedFile: function(url, bInner)
{
if(bInner)
{
var urlAbs = this.documentOrigin + g_sResourceServiceLocalUrl + encodeURIComponent(url);
this.handlers.trigger("asc_onSaveUrl", urlAbs, function(hasError){});
}
else
{
var urlAbs = g_sResourceServiceLocalUrl + encodeURIComponent(url);
var nIndex = this.documentTitle.lastIndexOf(".");
if(-1 != nIndex)
{
var nIndexFormat = url.lastIndexOf(".");
var sDocumentFilename = this.documentTitle.substring(0, nIndex);
urlAbs += "&filename=" + encodeURIComponent(sDocumentFilename);
if(-1 != nIndexFormat)
urlAbs += url.substring(nIndexFormat);
}
if( this.isMobileVersion ){
window.open("../../../sdk/Common/MobileDownloader/download.html?file="+urlAbs,"_parent","",false);
}
else {
getFile(urlAbs);
}
}
},
// Опции страницы (для печати)
asc_setPageOptions: function (options, index) {
var sheetIndex = (undefined !== index && null !== index) ? index : this.wbModel.getActive();
......@@ -740,39 +776,8 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
//oThis._asc_sendCommand(callback, "opencsv", oThis.documentTitle, JSON.stringify(value));
break;
case "save":
var outputData = JSON.parse(incomeObject.data);
if(c_oAscFileType.INNER != outputData.format)
{
var url = g_sResourceServiceLocalUrl + encodeURIComponent(outputData.url);
var nIndex = oThis.documentTitle.lastIndexOf(".");
if(-1 != nIndex)
{
var nIndexFormat = outputData.url.lastIndexOf(".");
var sDocumentFilename = oThis.documentTitle.substring(0, nIndex);
url += "&filename=" + encodeURIComponent(sDocumentFilename);
if(-1 != nIndexFormat)
url += outputData.url.substring(nIndexFormat);
}
if( oThis.isMobileVersion ){
window.open("../../../sdk/Common/MobileDownloader/download.html?file="+url,"_parent","",false);
}
else {
getFile(url);
}
if(callback)
callback({returnCode: 0, val:incomeObject.data});
}
else
{
var sUrl = oThis.documentOrigin + g_sResourceServiceLocalUrl + encodeURIComponent(outputData.url);
oThis.handlers.trigger("asc_onSaveUrl", sUrl, function(hasError){
if (hasError){
;//oThis._asc_sendCommand(/*callback*/null, /*command*/"cc");
}
});
if(callback)
callback(incomeObject);
}
break;
case "waitopen":
var rData = {"id":oThis.documentId, "format": oThis.documentFormat, "vkey": oThis.documentVKey, "editorid": c_oEditorId.Spreadsheet, "c":"chopen"};
......@@ -823,6 +828,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
},
_asc_save: function () {
var that = this;
this.wb._initCommentsToSave();
var oBinaryFileWriter = new BinaryFileWriter(this.wbModel);
var data = oBinaryFileWriter.Write();
......@@ -830,9 +836,15 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
oAdditionalData["c"] = "save";
oAdditionalData["id"] = this.documentId;
oAdditionalData["vkey"] = this.documentVKey;
oAdditionalData["outputformat"] = c_oAscFileType.XLSY;
oAdditionalData["outputformat"] = c_oAscFileType.INNER;
oAdditionalData["savetype"] = "completeall";
this._asc_sendCommand (/*callback*/ null, "mnuSaveAs" + this.cCharDelimiter + JSON.stringify(oAdditionalData) + this.cCharDelimiter + data);
this._asc_sendCommand (/*callback*/ function(incomeObject){
if(null != incomeObject && "save" == incomeObject.type)
{
var outputData = JSON.parse(incomeObject.data);
that.asc_processSavedFile(outputData.url, true);
}
}, "mnuSaveAs" + this.cCharDelimiter + JSON.stringify(oAdditionalData) + this.cCharDelimiter + data);
},
_asc_downloadAs: function (sFormat, fCallback, bStart, options, sSaveKey) { //fCallback({returnCode:"", ...})
......
......@@ -49,7 +49,7 @@ var c_oAscConfirm = {
ConfirmReplaceRange : 0
};
var c_oAscFileType = {
INNER: 0x1002,
INNER: 0x0101,
XLSX: 0x0101,
XLS: 0x0102,
ODS: 0x0103,
......
......@@ -485,11 +485,11 @@
var sUserNameAndId = "user_" + Math.floor ((Math.random() * 100) + 1);
api.asc_LoadDocument({
"Id" : key ? decodeURIComponent(getURLParameter("key")) : undefined,
"Url" : key ? decodeURIComponent(getURLParameter("url")) : undefined,
"Title" : key ? decodeURIComponent(getURLParameter("title")).replace(new RegExp("\\+",'g')," ") : undefined,
"Format" : key ? decodeURIComponent(getURLParameter("filetype")) : undefined,
"VKey" : key ? decodeURIComponent(getURLParameter("vkey")) : undefined,
"Id" : getURLParameter("key") ? decodeURIComponent(getURLParameter("key")) : undefined,
"Url" : getURLParameter("url") ? decodeURIComponent(getURLParameter("url")) : undefined,
"Title" : getURLParameter("title") ? decodeURIComponent(getURLParameter("title")).replace(new RegExp("\\+",'g')," ") : undefined,
"Format" : getURLParameter("filetype") ? decodeURIComponent(getURLParameter("filetype")) : undefined,
"VKey" : getURLParameter("vkey") ? decodeURIComponent(getURLParameter("vkey")) : undefined,
"Origin" : (sProtocol.search(/\w+/) >= 0 ? sProtocol + "//" : "") + sHost,
"UserId" : sUserNameAndId,
"UserName" : sUserNameAndId,
......
......@@ -9,7 +9,7 @@ var documentId = undefined;
var documentUrl = 'null';
var documentTitle = 'null';
var documentFormat = 'null';
var documentVKey = 'null';
var documentVKey = null;
var documentOrigin = "";
var c_oSerFormat =
......@@ -372,7 +372,7 @@ asc_docs_api.prototype.LoadDocument = function(c_DocInfo)
documentTitle = c_DocInfo.get_Title();
documentFormat = c_DocInfo.get_Format();
documentVKey = null;//c_DocInfo.get_VKey();
documentVKey = c_DocInfo.get_VKey();
// documentOrigin = c_DocInfo.get_Origin();
var sProtocol = window.location.protocol;
var sHost = window.location.host;
......@@ -852,7 +852,13 @@ asc_docs_api.prototype.UpdateParagraphProp = function(ParaPr){
asc_docs_api.prototype.asc_Print = function(){
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);
var editor = this;
_downloadAs(this, c_oAscFileType.PDF, function(){editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);}, true);
_downloadAs(this, c_oAscFileType.PDF, function(incomeObject){
if(null != incomeObject && "save" == incomeObject.type)
{
var outputData = JSON.parse(incomeObject.data);
editor.processSavedFile(outputData.url, false);
}
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);}, true);
}
asc_docs_api.prototype.Undo = function(){
this.WordControl.m_oLogicDocument.Document_Undo();
......@@ -888,7 +894,13 @@ asc_docs_api.prototype.asc_Save = function(){
oAdditionalData["outputformat"] = c_oAscFileType.INNER;
oAdditionalData["savetype"] = "completeall";
var sData = "mnuSaveAs" + cCharDelimiter + JSON.stringify(oAdditionalData) + cCharDelimiter + data;
sendCommand(editor, function(){}, sData);
sendCommand(editor, function(incomeObject){
if(null != incomeObject && "save" == incomeObject.type)
{
var outputData = JSON.parse(incomeObject.data);
editor.processSavedFile(outputData.url, true);
}
}, sData);
}
}
asc_docs_api.prototype.asc_OnSaveEnd = function(isDocumentSaved){
......@@ -898,10 +910,42 @@ asc_docs_api.prototype.asc_OnSaveEnd = function(isDocumentSaved){
this.SetUnchangedDocument();
}
}
asc_docs_api.prototype.processSavedFile = function(url, bInner){
if(bInner)
{
var urlAbs = documentOrigin + g_sResourceServiceLocalUrl + encodeURIComponent(url);
editor.asc_fireCallback("asc_onSaveUrl", urlAbs, function(hasError){});
}
else
{
var urlAbs = g_sResourceServiceLocalUrl + encodeURIComponent(url);
var nIndex = documentTitle.lastIndexOf(".");
if(-1 != nIndex)
{
var nIndexFormat = url.lastIndexOf(".");
var sDocumentFilename = documentTitle.substring(0, nIndex);
urlAbs += "&filename=" + encodeURIComponent(sDocumentFilename);
if(-1 != nIndexFormat)
urlAbs += url.substring(nIndexFormat);
}
if( editor.isMobileVersion ){
window.open("../../../sdk/Common/MobileDownloader/download.html?file="+urlAbs,"_parent","",false);
}
else {
getFile(urlAbs);
}
}
}
asc_docs_api.prototype.asc_DownloadAs = function(typeFile){//передаем число соответствующее своему формату.
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
var editor = this;
_downloadAs(this, typeFile, function(){editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);}, true);
_downloadAs(this, typeFile, function(incomeObject){
if(null != incomeObject && "save" == incomeObject.type)
{
var outputData = JSON.parse(incomeObject.data);
editor.processSavedFile(outputData.url, false);
}
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);}, true);
}
asc_docs_api.prototype.Resize = function(){
if (false === this.bInit_word_control)
......@@ -3769,39 +3813,8 @@ function sendCommand(editor, fCallback, rdata){
setTimeout( function(){sendCommand(editor, fCallback, JSON.stringify(rData))}, 3000);
break;
case "save":
var outputData = JSON.parse(incomeObject.data);
if(c_oAscFileType.INNER != outputData.format)
{
var url = g_sResourceServiceLocalUrl + encodeURIComponent(outputData.url);
var nIndex = documentTitle.lastIndexOf(".");
if(-1 != nIndex)
{
var nIndexFormat = outputData.url.lastIndexOf(".");
var sDocumentFilename = documentTitle.substring(0, nIndex);
url += "&filename=" + encodeURIComponent(sDocumentFilename);
if(-1 != nIndexFormat)
url += outputData.url.substring(nIndexFormat);
}
if( editor.isMobileVersion ){
window.open("../../../sdk/Common/MobileDownloader/download.html?file="+url,"_parent","",false);
}
else {
getFile(url);
if(fCallback)
fCallback(incomeObject);
}
}
else
{
var sUrl = documentOrigin + g_sResourceServiceLocalUrl + encodeURIComponent(outputData.url);
editor.asc_fireCallback("asc_onSaveUrl", sUrl, function(hasError){
if (hasError){
;//sendCommand(editor, function(){}, "cc");
}
});
if(fCallback)
fCallback(incomeObject);
}
break;
case "waitsave":
var rData = {"id":documentId, "format": documentFormat, "c":"chsave", "data": incomeObject.data};
......
......@@ -30,7 +30,7 @@ var c_oAscVertAlignJc =
};
//files type for Saving & DownloadAs
var c_oAscFileType = {
INNER: 0x1003,
INNER: 0x0081,
PDF: 0x0802,
PPTX: 0x0081,
PPT: 0x0082,
......
......@@ -2455,16 +2455,16 @@ $(".colorWatch").mouseover(function(){
c_DocInfo.put_Id( getURLParameter("key") ?
decodeURIComponent(getURLParameter("key")) :
undefined );
c_DocInfo.put_Url( getURLParameter("key") ?
c_DocInfo.put_Url( getURLParameter("url") ?
decodeURIComponent(getURLParameter("url")) :
undefined );
c_DocInfo.put_Title( getURLParameter("key") ?
c_DocInfo.put_Title( getURLParameter("title") ?
decodeURIComponent(getURLParameter("title")).replace(new RegExp("\\+",'g')," ") :
undefined );
c_DocInfo.put_Format( getURLParameter("key") ?
c_DocInfo.put_Format( getURLParameter("filetype") ?
decodeURIComponent(getURLParameter("filetype")) :
undefined );
c_DocInfo.put_VKey( getURLParameter("key") ?
c_DocInfo.put_VKey( getURLParameter("vkey") ?
decodeURIComponent(getURLParameter("vkey")) :
undefined );
......
......@@ -2253,16 +2253,16 @@ $(".colorWatch").mouseover(function(){
c_DocInfo.put_Id( getURLParameter("key") ?
decodeURIComponent(getURLParameter("key")) :
undefined );
c_DocInfo.put_Url( getURLParameter("key") ?
c_DocInfo.put_Url( getURLParameter("url") ?
decodeURIComponent(getURLParameter("url")) :
undefined );
c_DocInfo.put_Title( getURLParameter("key") ?
c_DocInfo.put_Title( getURLParameter("title") ?
decodeURIComponent(getURLParameter("title")).replace(new RegExp("\\+",'g')," ") :
undefined );
c_DocInfo.put_Format( getURLParameter("key") ?
c_DocInfo.put_Format( getURLParameter("filetype") ?
decodeURIComponent(getURLParameter("filetype")) :
undefined );
c_DocInfo.put_VKey( getURLParameter("key") ?
c_DocInfo.put_VKey( getURLParameter("vkey") ?
decodeURIComponent(getURLParameter("vkey")) :
undefined );
//c_DocInfo.put_Origin(documentOrigin);
......
......@@ -10,7 +10,7 @@ var documentId = undefined;
var documentUrl = 'null';
var documentTitle = 'null';
var documentFormat = 'null';
var documentVKey = 'null';
var documentVKey = null;
var documentOrigin = "";
function CDocOpenProgress()
......@@ -2049,7 +2049,13 @@ asc_docs_api.prototype.asc_Print = function()
sendCommand(editor, function(){editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);}, JSON.stringify(rData));
}
else
_downloadAs(this, c_oAscFileType.PDF, function(){editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);}, true);
_downloadAs(this, c_oAscFileType.PDF, function(incomeObject){
if(null != incomeObject && "save" == incomeObject.type)
{
var outputData = JSON.parse(incomeObject.data);
editor.processSavedFile(outputData.url, false);
}
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);}, true);
}
}
asc_docs_api.prototype.Undo = function()
......@@ -2145,7 +2151,13 @@ function OnSave_Callback(e)
data = JSON.stringify( CollaborativeEditing.Get_SelfChanges() );
*/
var sData = "mnuSaveAs" + cCharDelimiter + JSON.stringify(oAdditionalData) + cCharDelimiter + data;
sendCommand(editor, function(){}, sData);
sendCommand(editor, function(incomeObject){
if(null != incomeObject && "save" == incomeObject.type)
{
var outputData = JSON.parse(incomeObject.data);
editor.processSavedFile(outputData.url, true);
}
}, sData);
}
} else {
nState = editor.CoAuthoringApi.get_state();
......@@ -2161,7 +2173,13 @@ function OnSave_Callback(e)
asc_docs_api.prototype.asc_DownloadAs = function(typeFile){//передаем число соответствующее своему формату.
this.sync_StartAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
var editor = this;
_downloadAs(this, typeFile, function(){editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);}, true);
_downloadAs(this, typeFile, function(incomeObject){
if(null != incomeObject && "save" == incomeObject.type)
{
var outputData = JSON.parse(incomeObject.data);
editor.processSavedFile(outputData.url, false);
}
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);}, true);
}
asc_docs_api.prototype.Resize = function(){
if (false === this.bInit_word_control)
......@@ -2200,7 +2218,32 @@ asc_docs_api.prototype.SetFontRenderingMode = function(mode)
if (this.bInit_word_control)
this.WordControl.OnScroll();
}
asc_docs_api.prototype.processSavedFile = function(url, bInner)
{
if(bInner)
{
var urlAbs = documentOrigin + g_sResourceServiceLocalUrl + encodeURIComponent(url);
this.asc_fireCallback("asc_onSaveUrl", urlAbs, function(hasError){});
}
else
{
var urlAbs = g_sResourceServiceLocalUrl + encodeURIComponent(url);
var nIndex = documentTitle.lastIndexOf(".");
if(-1 != nIndex)
{
var nIndexFormat = url.lastIndexOf(".");
var sDocumentFilename = documentTitle.substring(0, nIndex);
urlAbs += "&filename=" + encodeURIComponent(sDocumentFilename);
if(-1 != nIndexFormat)
urlAbs += url.substring(nIndexFormat);
}
if( this.isMobileVersion ){
window.open("../../../../Common/MobileDownloader/download.html?file="+urlAbs,"_parent","",false);
}
else
getFile(urlAbs);
}
}
asc_docs_api.prototype.startGetDocInfo = function(){
/*
Возвращаем объект следующего вида:
......@@ -6086,39 +6129,8 @@ function sendCommand(editor, fCallback, rdata){
setTimeout( function(){sendCommand(editor, fCallback, JSON.stringify(rData))}, 3000);
break;
case "save":
var outputData = JSON.parse(incomeObject.data);
if(c_oAscFileType.INNER != outputData.format)
{
var url = g_sResourceServiceLocalUrl + encodeURIComponent(outputData.url);
var nIndex = documentTitle.lastIndexOf(".");
if(-1 != nIndex)
{
var nIndexFormat = outputData.url.lastIndexOf(".");
var sDocumentFilename = documentTitle.substring(0, nIndex);
url += "&filename=" + encodeURIComponent(sDocumentFilename);
if(-1 != nIndexFormat)
url += outputData.url.substring(nIndexFormat);
}
if( editor.isMobileVersion ){
window.open("../../../../Common/MobileDownloader/download.html?file="+url,"_parent","",false);
}
else {
getFile(url);
if(fCallback)
fCallback(incomeObject);
}
}
else
{
var sUrl = documentOrigin + g_sResourceServiceLocalUrl + encodeURIComponent(outputData.url);
editor.asc_fireCallback("asc_onSaveUrl", sUrl, function(hasError){
if (hasError){
;//sendCommand(editor, function(){}, "cc");
}
});
if(fCallback)
fCallback(incomeObject);
}
break;
case "waitsave":
{
......
......@@ -23,7 +23,7 @@ var c_oAscAsyncAction = {
}
//files type for Saving & DownloadAs
var c_oAscFileType = {
INNER: 0x1001,
INNER: 0x0041,
DOCX: 0x0041,
DOC: 0x0042,
ODT: 0x0043,
......
......@@ -3664,16 +3664,16 @@ $(".colorWatch").mouseover(function(){
c_DocInfo.put_Id( getURLParameter("key") ?
decodeURIComponent(getURLParameter("key")) :
undefined );
c_DocInfo.put_Url( getURLParameter("key") ?
c_DocInfo.put_Url( getURLParameter("url") ?
decodeURIComponent(getURLParameter("url")) :
undefined );
c_DocInfo.put_Title( getURLParameter("key") ?
c_DocInfo.put_Title( getURLParameter("title") ?
decodeURIComponent(getURLParameter("title")).replace(new RegExp("\\+",'g')," ") :
undefined );
c_DocInfo.put_Format( getURLParameter("key") ?
c_DocInfo.put_Format( getURLParameter("filetype") ?
decodeURIComponent(getURLParameter("filetype")) :
undefined );
c_DocInfo.put_VKey( getURLParameter("key") ?
c_DocInfo.put_VKey( getURLParameter("vkey") ?
decodeURIComponent(getURLParameter("vkey")) :
undefined );
globalCurentUser = "user_" + Math.floor((Math.random()*100)+1);
......
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