mirror of https://github.com/xwiki-labs/cryptpad
Fix ooslide export
This commit is contained in:
parent
a76fc3a427
commit
eebf94b084
|
@ -1393,7 +1393,6 @@ define([
|
|||
APP.onStrictSaveChanges();
|
||||
return;
|
||||
}
|
||||
console.error(APP.isFast, APP.themeLocked);
|
||||
var AscCommon = window.frames[0] && window.frames[0].AscCommon;
|
||||
if (Util.find(AscCommon, ['CollaborativeEditing','m_bFast'])
|
||||
&& APP.themeLocked) {
|
||||
|
@ -1465,6 +1464,15 @@ define([
|
|||
return { 'Id': f.Id, };
|
||||
});
|
||||
var type = common.getMetadataMgr().getPrivateData().ooType;
|
||||
var images = (e && window.frames[0].AscCommon.g_oDocumentUrls.urls) || {};
|
||||
var theme = e && window.frames[0].AscCommon.g_image_loader.map_image_index;
|
||||
if (theme) {
|
||||
Object.keys(theme).forEach(function (url) {
|
||||
if (!/^(\/|blob:|data:)/.test(url)) {
|
||||
images[url] = url;
|
||||
}
|
||||
});
|
||||
}
|
||||
sframeChan.query('Q_OO_CONVERT', {
|
||||
data: data,
|
||||
type: type,
|
||||
|
@ -1818,12 +1826,23 @@ define([
|
|||
};
|
||||
|
||||
APP.remoteTheme = function () {
|
||||
APP.themeRemote = true;
|
||||
/*
|
||||
APP.themeRemote = true;
|
||||
*/
|
||||
};
|
||||
APP.changeTheme = function (id) {
|
||||
/*
|
||||
// XXX disabled:
|
||||
Uncaught TypeError: Cannot read property 'calculatedType' of null
|
||||
at CPresentation.changeTheme (sdk-all.js?ver=4.11.0-1633612942653-1633619288217:15927)
|
||||
*/
|
||||
|
||||
id = id;
|
||||
/*
|
||||
APP.themeChanged = {
|
||||
id: id
|
||||
};
|
||||
*/
|
||||
};
|
||||
APP.openURL = function (url) {
|
||||
common.openUnsafeURL(url);
|
||||
|
@ -1840,6 +1859,20 @@ define([
|
|||
downloadImages[name] = Util.mkEvent(true);
|
||||
|
||||
if (typeof data === 'undefined') {
|
||||
if (/^http/.test(name) && /slide\/themes\/theme/.test(name)) {
|
||||
Util.fetch(name, function (err, u8) {
|
||||
if (err) { return; }
|
||||
mediasData[name] = {
|
||||
blobUrl: name,
|
||||
content: u8,
|
||||
name: name
|
||||
};
|
||||
var b = new Blob([u8], {type: "image/jpeg"});
|
||||
var blobUrl = URL.createObjectURL(b);
|
||||
return void callback(blobUrl);
|
||||
});
|
||||
return;
|
||||
}
|
||||
debug("CryptPad - could not find matching media for " + name);
|
||||
return void callback("");
|
||||
}
|
||||
|
@ -1912,22 +1945,17 @@ define([
|
|||
var type = common.getMetadataMgr().getPrivateData().ooType;
|
||||
var title = md.title || md.defaultTitle || type;
|
||||
var blob = new Blob([xlsData], {type: "application/pdf"});
|
||||
if (privateData.app !== "sheet") {
|
||||
UI.removeModals();
|
||||
var url = URL.createObjectURL(blob, { type: "application/pdf" });
|
||||
cb({
|
||||
"type":"save",
|
||||
"status":"ok",
|
||||
"data": url
|
||||
});
|
||||
saveAs(blob, title+'.pdf');
|
||||
return;
|
||||
}
|
||||
saveAs(blob, title+'.pdf');
|
||||
UI.removeModals();
|
||||
var url = URL.createObjectURL(blob, { type: "application/pdf" });
|
||||
cb({
|
||||
"type":"save",
|
||||
"status":"ok",
|
||||
"data": url
|
||||
});
|
||||
if (APP.exportingPDF) {
|
||||
saveAs(blob, title+'.pdf');
|
||||
}
|
||||
delete APP.exportingPDF;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -1951,6 +1979,7 @@ define([
|
|||
return;
|
||||
}
|
||||
if (extension === "pdf") {
|
||||
APP.exportingPDF = 1;
|
||||
return void e.asc_Print({});
|
||||
}
|
||||
x2tConvertData(data, filename, extension, function (xlsData) {
|
||||
|
|
|
@ -53,6 +53,7 @@ define([
|
|||
x2t.FS.mkdir('/working');
|
||||
x2t.FS.mkdir('/working/media');
|
||||
x2t.FS.mkdir('/working/fonts');
|
||||
x2t.FS.mkdir('/working/themes');
|
||||
x2tInitialized = true;
|
||||
x2tReady.fire();
|
||||
debug("x2t mount done");
|
||||
|
@ -135,11 +136,29 @@ define([
|
|||
|
||||
// Adding images
|
||||
Object.keys(images || {}).forEach(function (_mediaFileName) {
|
||||
var mediaFileName = _mediaFileName.substring(6);
|
||||
if (/\.bin$/.test(_mediaFileName)) { return; }
|
||||
var mediasSources = obj.mediasSources || {};
|
||||
var mediasData = obj.mediasData || {};
|
||||
var mediaData = mediasData[_mediaFileName];
|
||||
var mediaFileName;
|
||||
if (mediaData) { // Theme image
|
||||
var path = _mediaFileName.split('/');
|
||||
mediaFileName = path.pop();
|
||||
var theme = path[path.indexOf('themes') + 1];
|
||||
try {
|
||||
x2t.FS.mkdir('/working/themes/'+theme);
|
||||
x2t.FS.mkdir('/working/themes/'+theme+'/media');
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
}
|
||||
x2t.FS.writeFile('/working/themes/'+theme+'/media/' + mediaFileName, new Uint8Array(mediaData.content));
|
||||
debug("Writing media data " + mediaFileName + " at /working/themes/"+theme+"/media/");
|
||||
return;
|
||||
}
|
||||
// mediaData is undefined, check mediasSources
|
||||
mediaFileName = _mediaFileName.substring(6);
|
||||
var mediaSource = mediasSources[mediaFileName];
|
||||
var mediaData = mediaSource ? mediasData[mediaSource.src] : undefined;
|
||||
mediaData = mediaSource ? mediasData[mediaSource.src] : undefined;
|
||||
if (mediaData) {
|
||||
debug("Writing media data " + mediaFileName);
|
||||
debug("Data");
|
||||
|
@ -156,6 +175,7 @@ define([
|
|||
var params = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
|
||||
+ "<TaskQueueDataConvert xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">"
|
||||
+ "<m_sFileFrom>/working/" + fileName + "</m_sFileFrom>"
|
||||
+ "<m_sThemeDir>/working/themes</m_sThemeDir>"
|
||||
+ "<m_sFileTo>/working/" + fileName + "." + outputFormat + "</m_sFileTo>"
|
||||
+ pdfData
|
||||
+ getFromId(inputFormat)
|
||||
|
|
Loading…
Reference in New Issue