Skip to content

Commit

Permalink
Merge branch release/v8.0.0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
papacarlo committed Jan 30, 2024
2 parents 5238ddb + 8ac3e38 commit 07727fb
Show file tree
Hide file tree
Showing 1,526 changed files with 71,622 additions and 24,302 deletions.
59 changes: 40 additions & 19 deletions apps/api/documents/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
type: 'desktop or mobile or embedded',
width: '100% by default',
height: '100% by default',
documentType: 'word' | 'cell' | 'slide',// deprecate 'text' | 'spreadsheet' | 'presentation',
documentType: 'word' | 'cell' | 'slide' | 'pdf' ,// deprecate 'text' | 'spreadsheet' | 'presentation',
token: <string> encrypted signature
document: {
title: 'document title',
Expand Down Expand Up @@ -87,6 +87,7 @@
id: 'user id',
name: 'user name',
group: 'group name' // for customization.reviewPermissions or permissions.reviewGroups or permissions.commentGroups. Can be multiple groups separated by commas (,) : 'Group1' or 'Group1,Group2'
image: 'image url'
},
recent: [
{
Expand Down Expand Up @@ -228,6 +229,7 @@
hideNotes: false // hide or show notes panel on first loading (presentation editor)
uiTheme: 'theme-dark' // set interface theme: id or default-dark/default-light
integrationMode: "embed" // turn off scroll to frame
mobileForceView: true/false (default: true) // turn on/off the 'reader' mode on launch. for mobile document editor only
},
coEditing: {
mode: 'fast', // <coauthoring mode>, 'fast' or 'strict'. if 'fast' and 'customization.autosave'=false -> set 'customization.autosave'=true. 'fast' - default for editor
Expand Down Expand Up @@ -436,11 +438,12 @@
'presentation': 'pptx',
'word': 'docx',
'cell': 'xlsx',
'slide': 'pptx'
'slide': 'pptx',
'pdf': 'pdf'
}, app;

if (_config.documentType=='text' || _config.documentType=='spreadsheet' ||_config.documentType=='presentation')
console.warn("The \"documentType\" parameter for the config object must take one of the values word/cell/slide.");
console.warn("The \"documentType\" parameter for the config object must take one of the values word/cell/slide/pdf.");

if (typeof _config.documentType === 'string' && _config.documentType != '') {
app = appMap[_config.documentType.toLowerCase()];
Expand All @@ -454,15 +457,16 @@

if (typeof _config.document.fileType === 'string' && _config.document.fileType != '') {
_config.document.fileType = _config.document.fileType.toLowerCase();
var type = /^(?:(xls|xlsx|ods|csv|gsheet|xlsm|xlt|xltm|xltx|fods|ots|xlsb|sxc|et|ett)|(pps|ppsx|ppt|pptx|odp|gslides|pot|potm|potx|ppsm|pptm|fodp|otp|sxi|dps|dpt)|(doc|docx|odt|gdoc|txt|rtf|mht|htm|html|mhtml|epub|docm|dot|dotm|dotx|fodt|ott|fb2|xml|oform|docxf|sxw|stw|wps|wpt|pdf|djvu|xps|oxps))$/
var type = /^(?:(xls|xlsx|ods|csv|gsheet|xlsm|xlt|xltm|xltx|fods|ots|xlsb|sxc|et|ett)|(pps|ppsx|ppt|pptx|odp|gslides|pot|potm|potx|ppsm|pptm|fodp|otp|sxi|dps|dpt)|(pdf|djvu|xps|oxps)|(doc|docx|odt|gdoc|txt|rtf|mht|htm|html|mhtml|epub|docm|dot|dotm|dotx|fodt|ott|fb2|xml|oform|docxf|sxw|stw|wps|wpt))$/
.exec(_config.document.fileType);
if (!type) {
window.alert("The \"document.fileType\" parameter for the config object is invalid. Please correct it.");
return false;
} else if (typeof _config.documentType !== 'string' || _config.documentType == ''){
if (typeof type[1] === 'string') _config.documentType = 'cell'; else
if (typeof type[2] === 'string') _config.documentType = 'slide'; else
if (typeof type[3] === 'string') _config.documentType = 'word';
if (typeof type[3] === 'string') _config.documentType = 'pdf'; else
if (typeof type[4] === 'string') _config.documentType = 'word';
}
}

Expand Down Expand Up @@ -513,6 +517,20 @@
if (_config.editorConfig.customization && _config.editorConfig.customization.integrationMode==='embed')
window.AscEmbed && window.AscEmbed.initWorker(iframe);

if (_config.document && (_config.document.isForm!==true && _config.document.isForm!==false)) {
iframe.onload = function() {
_sendCommand({
command: 'checkParams',
data: {
url: _config.document.url,
directUrl: _config.document.directUrl,
token: _config.document.token,
key: _config.document.key
}
})
};
}

if (iframe.src) {
var pathArray = iframe.src.split('/');
this.frameOrigin = pathArray[0] + '//' + pathArray[2];
Expand Down Expand Up @@ -937,35 +955,33 @@
'slide': 'presentationeditor',
'pdf': 'pdfeditor'
},
app = appMap['word'];
appType = 'word';

if (typeof config.documentType === 'string') {
app = appMap[config.documentType.toLowerCase()];
appType = config.documentType.toLowerCase();
if (config.type !== 'mobile' && config.type !== 'embedded' && !!config.document && typeof config.document.fileType === 'string') {
var type = /^(?:(pdf|djvu|xps|oxps))$/.exec(config.document.fileType);
if (type && typeof type[1] === 'string')
app = appMap['pdf'];
appType = 'pdf';
}
} else
if (!!config.document && typeof config.document.fileType === 'string') {
var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots|xlsb)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp))$/
var type = /^(?:(xls|xlsx|ods|csv|xlst|xlsy|gsheet|xlsm|xlt|xltm|xltx|fods|ots|xlsb)|(pps|ppsx|ppt|pptx|odp|pptt|ppty|gslides|pot|potm|potx|ppsm|pptm|fodp|otp)|(pdf|djvu|xps|oxps))$/
.exec(config.document.fileType);
if (type) {
if (typeof type[1] === 'string') app = appMap['cell']; else
if (typeof type[2] === 'string') app = appMap['slide'];
}
if (config.type !== 'mobile' && config.type !== 'embedded') {
type = /^(?:(pdf|djvu|xps|oxps))$/.exec(config.document.fileType);
if (type && typeof type[1] === 'string')
app = appMap['pdf'];
if (typeof type[1] === 'string') appType = 'cell'; else
if (typeof type[2] === 'string') appType = 'slide'; else
if (typeof type[3] === 'string' && config.type !== 'mobile' && config.type !== 'embedded') appType = 'pdf';
}
}
if (appType === 'pdf' && (config.type === 'mobile' || config.type === 'embedded')) {
appType = 'word';
}

path += app + "/";
path += appMap[appType] + "/";
const path_type = config.type === "mobile"
? "mobile" : (config.type === "embedded")
? "embed" : (config.document && typeof config.document.fileType === 'string' && config.document.fileType.toLowerCase() === 'oform')
? "forms" : "main";
? "embed" : "main";

path += path_type;
var index = "/index.html";
Expand Down Expand Up @@ -1019,6 +1035,11 @@
config.document && config.document.permissions && (config.document.permissions.edit === false && !config.document.permissions.review )))
params += "&mode=view";

if (config.document) {
config.document.isForm = (type && typeof type[1] === 'string') ? config.document.isForm : false;
(config.document.isForm===true || config.document.isForm===false) && (params += "&isForm=" + config.document.isForm);
}

if (config.editorConfig && config.editorConfig.customization && !!config.editorConfig.customization.compactHeader)
params += "&compact=true";

Expand Down
5 changes: 4 additions & 1 deletion apps/api/documents/index.html.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@
download: true
}
};

if (urlParams['mode'] == 'review')
docparams.permissions.edit = !(docparams.permissions.review = true);

if (urlParams['isForm'] !== undefined)
docparams.isForm = (urlParams['isForm']==='true');

return docparams;
}

Expand Down
3 changes: 3 additions & 0 deletions apps/api/wopi/editor-wopi.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,9 @@ div {
"review": (fileInfo.SupportsReviewing===false) ? false : (fileInfo.UserCanReview===false ? false : fileInfo.UserCanReview),
"copy": fileInfo.CopyPasteRestrictions!=="CurrentDocumentOnly" && fileInfo.CopyPasteRestrictions!=="BlockAll",
"print": !fileInfo.DisablePrint && !fileInfo.HidePrintOption
},
"options": {
"WOPISrc": userAuth.wopiSrc
}
},
"editorConfig": {
Expand Down
4 changes: 2 additions & 2 deletions apps/common/Gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,8 @@ if (window.Common === undefined) {
_postMessage({event:'onMakeActionLink', data: config});
},

requestUsers: function (command) {
_postMessage({event:'onRequestUsers', data: {c: command}});
requestUsers: function (command, id) {
_postMessage({event:'onRequestUsers', data: {c: command, id: id}});
},

requestSendNotify: function (emails) {
Expand Down
157 changes: 157 additions & 0 deletions apps/common/checkExtendedPDF.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
* (c) Copyright Ascensio System SIA 2010-2023
*
* 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)
* 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
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* 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
*
* You can contact Ascensio System SIA at 20A-6 Ernesta Birznieka-Upish
* street, Riga, Latvia, EU, LV-1050.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* 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
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
function checkExtendedPDF(directUrl, key, url, token, callback) {
var limit = 110;
if (directUrl) {
downloadPartialy(directUrl, limit, null, function(text) {
callback(isExtendedPDFFile(text))
});
} else {
let postData = JSON.stringify({
'url': url,
"token": token
});
var handlerUrl = "../../../../downloadfile/"+encodeURIComponent(key);
downloadPartialy(handlerUrl, limit, postData, function(text) {
callback(isExtendedPDFFile(text))
});
}
}
function isExtendedPDFFile(text) {
if (!text) {
return false;
}
const indexFirst = text.indexOf('%\xCD\xCA\xD2\xA9\x0D');
if (indexFirst === -1) {
return false;
}

let pFirst = text.substring(indexFirst + 6);

if (!(pFirst.lastIndexOf('1 0 obj\x0A<<\x0A', 0) === 0)) {
return false;
}

pFirst = pFirst.substring(11);

let signature = 'ONLYOFFICEFORM';
const indexStream = pFirst.indexOf('stream\x0D\x0A');
const indexMeta = pFirst.indexOf(signature);

if (indexStream === -1 || indexMeta === -1 || indexStream < indexMeta) {
return false;
}

let pMeta = pFirst.substring(indexMeta);
pMeta = pMeta.substring(signature.length + 3);

let indexMetaLast = pMeta.indexOf(' ');
if (indexMetaLast === -1) {
return false;
}

pMeta = pMeta.substring(indexMetaLast + 1);

indexMetaLast = pMeta.indexOf(' ');
if (indexMetaLast === -1) {
return false;
}

return true;
}
function downloadPartialy(url, limit, postData, callback) {
var callbackCalled = false;
var xhr = new XMLHttpRequest();
//value of responseText always has the current content received from the server, even if it's incomplete
// xhr.responseType = "json"; it raises an IE error. bug 66160
xhr.overrideMimeType('text/xml; charset=iso-8859-1');
xhr.onreadystatechange = function () {
if (callbackCalled) {
return;
}
if (xhr.readyState === 4) {
callbackCalled = true;
callback(xhr.responseText);
} else if (xhr.readyState === 3 && xhr.responseText.length >= limit) {
callbackCalled = true;
var res = xhr.responseText;
xhr.abort();
callback(res);
}
};
let method = postData ? 'POST' : 'GET';
xhr.open(method, url, true);
xhr.setRequestHeader('Range', 'bytes=0-' + limit); // the bytes (incl.) you request
xhr.send(postData);
}

var startCallback;
var eventFn = function(msg) {
if (msg.origin !== window.parentOrigin && msg.origin !== window.location.origin && !(msg.origin==="null" && (window.parentOrigin==="file://" || window.location.origin==="file://"))) return;

var data = msg.data;
if (Object.prototype.toString.apply(data) !== '[object String]' || !window.JSON) {
return;
}
try {
data = window.JSON.parse(data)
} catch(e) {
data = '';
}

if (data && data.command==="checkParams") {
data = data.data || {};
checkExtendedPDF(data.directUrl, data.key, data.url, data.token, startCallback);
_unbindWindowEvents();
}
};

var _bindWindowEvents = function() {
if (window.addEventListener) {
window.addEventListener("message", eventFn, false)
} else if (window.attachEvent) {
window.attachEvent("onmessage", eventFn);
}
};

var _unbindWindowEvents = function() {
if (window.removeEventListener) {
window.removeEventListener("message", eventFn)
} else if (window.detachEvent) {
window.detachEvent("onmessage", eventFn);
}
};

function listenApiMsg(callback) {
startCallback = callback;
_bindWindowEvents();
}
22 changes: 8 additions & 14 deletions apps/common/forms/lib/view/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ define([
width: 300,
header: true,
style: 'min-width: 300px;',
cls: 'modal-dlg',
buttons: null
cls: 'modal-dlg'
},

initialize : function(options) {
_.extend(this.options, {
title: this.textTitle
title: this.textTitle,
buttons: [{value: 'ok', caption: this.txtCopy}]
}, options || {});

this.template = [
Expand All @@ -73,10 +73,7 @@ define([
'</tr>',
'</table>',
'</div>',
'<div class="separator horizontal"></div>',
'<div class="footer center">',
'<button class="btn normal primary dlg-btn" style="min-width: 86px;width: auto;">' + this.txtCopy + '</button>',
'</div>'
'<div class="separator horizontal"></div>'
].join('');

this.options.tpl = _.template(this.template)(this.options);
Expand Down Expand Up @@ -160,13 +157,13 @@ define([
width: 300,
header: true,
style: 'min-width: 300px;',
cls: 'modal-dlg',
buttons: null
cls: 'modal-dlg'
},

initialize : function(options) {
_.extend(this.options, {
title: this.textTitle
title: this.textTitle,
buttons: [{value: 'ok', caption: this.txtCopy}]
}, options || {});

this.template = [
Expand All @@ -189,10 +186,7 @@ define([
'</tr>',
'</table>',
'</div>',
'<div class="separator horizontal"></div>',
'<div class="footer center">',
'<button class="btn normal primary dlg-btn" style="min-width: 86px;width: auto;">' + this.txtCopy + '</button>',
'</div>'
'<div class="separator horizontal"></div>'
].join('');

this.options.tpl = _.template(this.template)(this.options);
Expand Down
Loading

0 comments on commit 07727fb

Please sign in to comment.