Commit f1e5bbc8 authored by Sergey.Konovalov's avatar Sergey.Konovalov Committed by Alexander.Trofimov

(1.0.0.63): FileConverterService2

[Bug 29211] New: Unknown error при попытке скачивания XLXS из редактируемого XLST.
Убраны ограницения на количество страниц печатаемых в pdf за один запрос. теперь pdf печатается полностью - бинарник отправляется по-частям.

git-svn-id: svn://192.168.3.15/activex/AVS/Sources/TeamlabOffice/trunk/OfficeWeb@62179 954022d7-b5bf-4e40-9824-e11837661b57
parent b14ac8a3
......@@ -7,6 +7,38 @@ var g_sSpellCheckServiceLocalUrl = "/SpellChecker.ashx";
var g_sTrackingServiceLocalUrl = "/TrackingService.ashx";
var g_nMaxJsonLength = 2097152;
var g_nMaxJsonLengthChecked = g_nMaxJsonLength / 1000;
var g_nMaxRequestLength = 1048576;//<requestLimits maxAllowedContentLength="30000000" /> default 30mb
function g_fSaveWithParts(fSendCommand, fCallback, oAdditionalData, aParts) {
if(null == aParts){
var nDataLength = oAdditionalData["data"].length;
aParts = [];
if(nDataLength > g_nMaxRequestLength){
for(var i = 0; i < Math.ceil(nDataLength / g_nMaxRequestLength); ++i)
aParts.push(oAdditionalData["data"].substring(i * g_nMaxRequestLength, (i + 1) * g_nMaxRequestLength));
oAdditionalData["data"] = aParts.shift();
oAdditionalData["savetype"] = c_oAscSaveTypes.PartStart;
}
else
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
}
else{
oAdditionalData["data"] = aParts.shift();
if(aParts.length > 0)
oAdditionalData["savetype"] = c_oAscSaveTypes.Part;
else
oAdditionalData["savetype"] = c_oAscSaveTypes.Complete;
}
fSendCommand(function (incomeObject) {
if(null != incomeObject && "savepart" == incomeObject["type"]){
var outputData = JSON.parse(incomeObject["data"]);
oAdditionalData["savekey"] = outputData["savekey"];
g_fSaveWithParts(fSendCommand, fCallback, oAdditionalData, aParts);
}
else
fCallback(incomeObject);
}, oAdditionalData);
};
function fSortAscending( a, b ) {
return a - b;
......
......@@ -36,8 +36,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
this.handlers = new asc.asc_CHandlersList(eventsHandlers);
// Вид печати
this.adjustPrint = null;
// Рассчитанные данные для печати
this.printPagesData = null;
this.isMobileVersion = false;
......@@ -897,10 +895,6 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
setTimeout(function(){oThis._asc_sendCommand(callback, rData);}, 3000);
break;
case "savepart":
var outputData = JSON.parse(incomeObject["data"]);
oThis._asc_downloadAs(outputData["format"], callback, false, null, outputData["savekey"]);
break;
case "getsettings":
if(callback)
callback(incomeObject);
......@@ -1048,15 +1042,12 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
oAdditionalData["userid"] = this.documentUserId;
oAdditionalData["vkey"] = this.documentVKey;
oAdditionalData["outputformat"] = 0x1002;
var data;
this.wb._initCommentsToSave();
var oBinaryFileWriter = new Asc.BinaryFileWriter(this.wbModel);
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
data = oBinaryFileWriter.Write();
oAdditionalData["data"] = data;
oAdditionalData["data"] = oBinaryFileWriter.Write();
var t = this;
this._asc_sendCommand (function (incomeObject) {
g_fSaveWithParts(function(fCallback1, oAdditionalData1){t._asc_sendCommand(fCallback1, oAdditionalData1);}, function (incomeObject) {
if(null != incomeObject && "save" == incomeObject["type"])
t.asc_processSavedFile(incomeObject["data"], false);
}, oAdditionalData);
......@@ -1081,13 +1072,13 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
oAdditionalData["innersave"] = true;
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
oAdditionalData["data"] = data;
this._asc_sendCommand (/*callback*/ function(incomeObject){
g_fSaveWithParts(function(fCallback1, oAdditionalData1){that._asc_sendCommand(fCallback1, oAdditionalData1);}, /*callback*/ function(incomeObject){
if(null != incomeObject && "save" == incomeObject["type"])
that.asc_processSavedFile(incomeObject["data"], true);
}, oAdditionalData);
};
spreadsheet_api.prototype._asc_downloadAs = function (sFormat, fCallback, bStart, options, sSaveKey) { //fCallback({returnCode:"", ...})
spreadsheet_api.prototype._asc_downloadAs = function (sFormat, fCallback, bStart, options) { //fCallback({returnCode:"", ...})
//sFormat: xlsx, xls, ods, csv, html
var oAdditionalData = {};
oAdditionalData["c"] = "save";
......@@ -1095,42 +1086,14 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
oAdditionalData["userid"] = this.documentUserId;
oAdditionalData["vkey"] = this.documentVKey;
oAdditionalData["outputformat"] = sFormat;
if(null != sSaveKey)
oAdditionalData["savekey"] = sSaveKey;
var data;
if(c_oAscFileType.PDF === sFormat)
{
if (null === this.printPagesData) {
// Рассчитываем данные о страницах
this.printPagesData = this.wb.calcPagesPrint(this.adjustPrint);
}
var printPagesData = this.wb.calcPagesPrint(this.adjustPrint);
var pdf_writer = new CPdfPrinter(this.wbModel.sUrlPath);
var isEndPrint = this.wb.printSheet(pdf_writer, this.printPagesData);
data = pdf_writer.DocumentRenderer.Memory.GetBase64Memory();
var isEndPrint = this.wb.printSheet(pdf_writer, printPagesData);
if (isEndPrint) {
// Закончили печатить
if (bStart) {
// Первый раз отправляем данные
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
} else {
// Не в первый раз отправляем данные
oAdditionalData["savetype"] = c_oAscSaveTypes.Complete;
}
// Очищаем данные о печати
this.printPagesData = null;
} else {
// Продолжаем печать
if (bStart) {
// Первый раз отправляем данные
oAdditionalData["savetype"] = c_oAscSaveTypes.PartStart;
} else {
// Не в первый раз отправляем данные
oAdditionalData["savetype"] = c_oAscSaveTypes.Part;
}
}
oAdditionalData["data"] = pdf_writer.DocumentRenderer.Memory.GetBase64Memory();
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
} else if (c_oAscFileType.CSV === sFormat && !options) {
// Мы открывали команду, надо ее закрыть.
this.asc_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.DownloadAs);
......@@ -1151,15 +1114,15 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
oAdditionalData["delimiter"] = options.asc_getDelimiter();
}
}
data = oBinaryFileWriter.Write();
oAdditionalData["data"] = oBinaryFileWriter.Write();
if (undefined != window['appBridge']) {
window['appBridge']['dummyCommandSave_CSV'] (data);
window['appBridge']['dummyCommandSave_CSV'] (oAdditionalData["data"]);
return;
}
}
oAdditionalData["data"] = data;
this._asc_sendCommand (fCallback, oAdditionalData);
var t = this;
g_fSaveWithParts(function(fCallback1, oAdditionalData1){t._asc_sendCommand(fCallback1, oAdditionalData1);}, fCallback, oAdditionalData);
};
......@@ -3304,10 +3267,10 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
oAdditionalData["outputformat"] = c_oAscFileType.PDF;
t.adjustPrint = new asc_CAdjustPrint();
t.printPagesData = t.wb.calcPagesPrint(t.adjustPrint);
var printPagesData = t.wb.calcPagesPrint(t.adjustPrint);
var pdf_writer = new CPdfPrinter(t.wbModel.sUrlPath);
t.wb.printSheet(pdf_writer, t.printPagesData);
t.wb.printSheet(pdf_writer, printPagesData);
return pdf_writer.DocumentRenderer.Memory.GetBase64Memory();
};
......@@ -3351,8 +3314,7 @@ var ASC_DOCS_API_USE_EMBEDDED_FONTS = "@@ASC_DOCS_API_USE_EMBEDDED_FONTS";
var oBinaryFileWriter = new Asc.BinaryFileWriter(t.wbModel);
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
var data = oBinaryFileWriter.Write();
return data;
return oBinaryFileWriter.Write();
}
}
......
......@@ -1955,10 +1955,9 @@
ws.drawForPrint(pdf_writer, null);
isEndPrint = true;
} else {
var currentIndex = printPagesData.currentIndex;
var indexWorksheet = -1;
var indexWorksheetTmp = -1;
for (var i = currentIndex; i < printPagesData.arrPages.length && i < currentIndex + printPagesData.c_maxPagesCount; ++i) {
for (var i = 0; i < printPagesData.arrPages.length; ++i) {
indexWorksheetTmp = printPagesData.arrPages[i].indexWorksheet;
if (indexWorksheetTmp !== indexWorksheet) {
ws = this.getWorksheet(indexWorksheetTmp);
......@@ -1967,7 +1966,6 @@
ws.drawForPrint(pdf_writer, printPagesData.arrPages[i]);
}
isEndPrint = (i === printPagesData.arrPages.length);
printPagesData.currentIndex = i;
}
return isEndPrint;
......
......@@ -1210,7 +1210,7 @@ function CDrawingDocument()
this.isComleteRenderer2 = function()
{
var start = Math.max(this.m_lCurrentRendererPage, 0);
var end = Math.min(start + 50, this.SlidesCount - 1);
var end = this.SlidesCount - 1;
if ((end + 1) >= this.SlidesCount)
return true;
......@@ -1232,7 +1232,7 @@ function CDrawingDocument()
}
var start = this.m_lCurrentRendererPage;
var end = Math.min(this.m_lCurrentRendererPage + 50, pagescount - 1);
var end = pagescount - 1;
var renderer = this.m_oDocRenderer;
renderer.Memory.Seek(0);
......
......@@ -5104,10 +5104,6 @@ function sendCommand(editor, fCallback, rdata){
"data": incomeObject["data"]};
setTimeout( function(){sendCommand(editor, fCallback, rData)}, 3000);
break;
case "savepart":
var outputData = JSON.parse(incomeObject["data"]);
_downloadAs(editor, outputData["format"], fCallback, false, outputData["savekey"]);
break;
case "getsettings":
if(fCallback)
......@@ -5192,34 +5188,15 @@ function _downloadAs(editor, filetype, fCallback, bStart, sSaveKey)
oAdditionalData["userid"] = documentUserId;
oAdditionalData["vkey"] = documentVKey;
oAdditionalData["outputformat"] = filetype;
if(null != sSaveKey)
oAdditionalData["savekey"] = sSaveKey;
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
if(c_oAscFileType.PDF == filetype)
{
var dd = editor.WordControl.m_oDrawingDocument;
if(dd.isComleteRenderer2())
{
if(false == bStart)
oAdditionalData["savetype"] = c_oAscSaveTypes.Complete;
else
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
}
else
{
if(false == bStart)
oAdditionalData["savetype"] = c_oAscSaveTypes.Part;
else
oAdditionalData["savetype"] = c_oAscSaveTypes.PartStart;
}
oAdditionalData["data"] = dd.ToRendererPart();
sendCommand(editor, fCallback, oAdditionalData);
}
else
{
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
oAdditionalData["data"] = editor.WordControl.SaveDocument();
sendCommand(editor, fCallback, oAdditionalData);
}
g_fSaveWithParts(function(fCallback1, oAdditionalData1){sendCommand(editor, fCallback1, oAdditionalData1);}, fCallback, oAdditionalData);
}
function _getFullImageSrc(src)
......
......@@ -2138,7 +2138,7 @@ function CDrawingDocument()
{
var pagescount = Math.min(this.m_lPagesCount, this.m_lCountCalculatePages);
var start = Math.max(this.m_lCurrentRendererPage, 0);
var end = Math.min(start + 50, pagescount - 1);
var end = pagescount - 1;
if ((end + 1) >= pagescount)
return true;
......@@ -2159,7 +2159,7 @@ function CDrawingDocument()
}
var start = this.m_lCurrentRendererPage;
var end = Math.min(this.m_lCurrentRendererPage + 50, pagescount - 1);
var end = pagescount - 1;
var renderer = this.m_oDocRenderer;
renderer.Memory.Seek(0);
......
......@@ -2204,7 +2204,7 @@ asc_docs_api.prototype.asc_Print = function()
else
editor.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);}, true);
editor.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, c_oAscAsyncAction.Print);});
}
};
asc_docs_api.prototype.Undo = function()
......@@ -2366,7 +2366,7 @@ asc_docs_api.prototype.asc_DownloadAs = function(typeFile) {//передаем
t.asc_fireCallback("asc_onError", c_oAscError.ID.Unknown, c_oAscError.Level.NoCritical);
}
t.sync_EndAction(c_oAscAsyncActionType.BlockInteraction, actionType);
}, true);
});
};
asc_docs_api.prototype.asc_DownloadAsMailMerge = function(typeFile, StartIndex, EndIndex, bIsDownload) {
var oDocumentMailMerge = this.WordControl.m_oLogicDocument.Get_MailMergedDocument(StartIndex, EndIndex);
......@@ -2389,7 +2389,7 @@ asc_docs_api.prototype.asc_DownloadAsMailMerge = function(typeFile, StartIndex,
else
t.asc_fireCallback("asc_onError", c_oAscError.ID.MailMergeSaveFile, c_oAscError.Level.NoCritical);
}
}, true);
});
}
return null != oDocumentMailMerge ? true : false;
};
......@@ -7010,10 +7010,6 @@ function sendCommand(editor, fCallback, rdata){
setTimeout( function(){sendCommand(editor, fCallback, rData)}, 3000);
}
break;
case "savepart":
var outputData = JSON.parse(incomeObject["data"]);
_downloadAs(editor, null, outputData["format"], fCallback, false, outputData["savekey"]);
break;
case "getsettings":
if(fCallback)
......@@ -7088,25 +7084,18 @@ function _onOpenCommand(fCallback, incomeObject) {
}
});
}
function _downloadAs(editor, oDocumentMailMerge, filetype, fCallback, bStart, sSaveKey) {
function _downloadAs(editor, oDocumentMailMerge, filetype, fCallback) {
var oAdditionalData = {};
oAdditionalData["c"] = "save";
oAdditionalData["id"] = documentId;
oAdditionalData["userid"] = documentUserId;
oAdditionalData["vkey"] = documentVKey;
oAdditionalData["outputformat"] = filetype;
if (null != sSaveKey)
oAdditionalData["savekey"] = sSaveKey;
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
if (null == oDocumentMailMerge && c_oAscFileType.PDF === filetype) {
var dd = editor.WordControl.m_oDrawingDocument;
if (dd.isComleteRenderer2()) {
oAdditionalData["savetype"] = bStart ? c_oAscSaveTypes.CompleteAll : c_oAscSaveTypes.Complete;
} else {
oAdditionalData["savetype"] = bStart ? c_oAscSaveTypes.PartStart : c_oAscSaveTypes.Part;
}
oAdditionalData["data"] = dd.ToRendererPart();
} else if (c_oAscFileType.JSON === filetype) {
oAdditionalData['savetype'] = c_oAscSaveTypes.CompleteAll;
oAdditionalData['url'] = editor.mailMergeFileData['url'];
oAdditionalData['format'] = editor.mailMergeFileData['fileType'];
// ToDo select csv params
......@@ -7119,10 +7108,9 @@ function _downloadAs(editor, oDocumentMailMerge, filetype, fCallback, bStart, sS
else
oLogicDocument = editor.WordControl.m_oLogicDocument;
var oBinaryFileWriter = new BinaryFileWriter(oLogicDocument);
oAdditionalData["savetype"] = c_oAscSaveTypes.CompleteAll;
oAdditionalData["data"] = oBinaryFileWriter.Write();
}
sendCommand(editor, fCallback, oAdditionalData);
g_fSaveWithParts(function(fCallback1, oAdditionalData1){sendCommand(editor, fCallback1, oAdditionalData1);}, fCallback, oAdditionalData);
}
function _addImageUrl2 (url)
......
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