diff --git a/.github/workflows/artifact.yml b/.github/workflows/artifact.yml
index ed1954dc..ad9c6a3a 100644
--- a/.github/workflows/artifact.yml
+++ b/.github/workflows/artifact.yml
@@ -28,6 +28,7 @@ jobs:
rm -rf ./.git/
rm ./.gitmodules
rm -rf ./assets/document-templates/.git
+ rm -rf ./assets/document-formats/.git
cd ./appinfo
sed -i 's|apl2|agpl|' info.xml
cd $cwd
diff --git a/.gitmodules b/.gitmodules
index 7aeeb33f..e7c7242c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -2,3 +2,6 @@
path = assets/document-templates
url = https://github.com/ONLYOFFICE/document-templates
branch = main/new
+[submodule "assets/document-formats"]
+ path = assets/document-formats
+ url = https://github.com/ONLYOFFICE/document-formats
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d7fe68d7..ac21e52d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,7 @@
- compatible with ownCloud Web 7.0
- list of users to protect ranges of cells
- offline viewer for share link
+- updatable list of supported formats
## Added
- reference data from coediting
diff --git a/README.md b/README.md
index d2e64e4c..10f8988d 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,8 @@ The app allows to:
Supported formats:
-* For viewing and editing: DOCX, XLSX, PPTX, CSV, TXT, DOCXF, OFORM.
-* For viewing only: PDF.
-* For converting to Office Open XML formats: DOC, DOCM, DOT, DOTX, EPUB, HTM, HTML, ODP, ODT, POT, POTM, POTX, PPS, PPSM, PPSX, PPT, PPTM, RTF, XLS, XLSM, XLT, XLTM, XLTX.
+* For editing: DOCM, DOCX, DOCXF, DOTM, DOTX, EPUB, FB2, HTML, ODT, OTT, RTF, TXT, CSV, ODS, OTS, XLSM, XLSX, XLTM, XLTX, ODP, OTP, POTM, POTX, PPSM, PPSX, PPTM, PPTX.
+* For viewing only: DJVU, DOC, DOT, FODT, HTM, MHT, MHTML, OFORM, PDF, STW, SXW, WPS, WPT, XML, XPS, ET, ETT, FODS, SXC, XLS, XLSB, XLT, DPS, DPT, FODP, POT, PPS, PPT, SXI.
ODT, ODS, and ODP is also available for instant conversion. After you enable the corresponding option in the admin settings, ODF-formatted documents are immediately converted in the editor and opened after you click on it.
@@ -234,12 +233,12 @@ The table below will help you to make the right choice.
| Conversion Service | + | + |
| Document Builder Service | + | + |
| **Interface** | **Community Edition** | **Enterprise Edition** |
-| Tabbed interface | + | + |
-| Dark theme | + | + |
-| 125%, 150%, 175%, 200% scaling | + | + |
-| White Label | - | - |
-| Integrated test example (node.js) | + | + |
-| Mobile web editors | - | +* |
+| Tabbed interface | + | + |
+| Dark theme | + | + |
+| 125%, 150%, 175%, 200% scaling | + | + |
+| White Label | - | - |
+| Integrated test example (node.js) | + | + |
+| Mobile web editors | - | +* |
| **Plugins & Macros** | **Community Edition** | **Enterprise Edition** |
| Plugins | + | + |
| Macros | + | + |
diff --git a/assets/document-formats b/assets/document-formats
new file mode 160000
index 00000000..730e13c8
--- /dev/null
+++ b/assets/document-formats
@@ -0,0 +1 @@
+Subproject commit 730e13c89d717c03eabd845a51ad1ddc673b13ac
diff --git a/js/main.js b/js/main.js
index 2e71b6e0..e065fb0a 100644
--- a/js/main.js
+++ b/js/main.js
@@ -330,74 +330,65 @@
return true;
}
- OCA.Files.fileActions.registerAction({
- name: "onlyofficeOpen",
- displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
- mime: config.mime,
- permissions: OC.PERMISSION_READ,
- iconClass: "icon-onlyoffice-open",
- actionHandler: OCA.Onlyoffice.FileClick
- });
-
- if (config.def) {
- OCA.Files.fileActions.setDefault(config.mime, "onlyofficeOpen");
- }
-
- if (config.conv) {
+ let mimeTypes = config.mime;
+ mimeTypes.forEach((mime) => {
OCA.Files.fileActions.registerAction({
- name: "onlyofficeConvert",
- displayName: t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"),
- mime: config.mime,
- permissions: ($("#isPublic").val() ? OC.PERMISSION_UPDATE : OC.PERMISSION_READ),
- iconClass: "icon-onlyoffice-convert",
- actionHandler: OCA.Onlyoffice.FileConvertClick
- });
- }
-
- if (config.fillForms) {
- OCA.Files.fileActions.registerAction({
- name: "onlyofficeFill",
- displayName: t(OCA.Onlyoffice.AppName, "Fill in form in ONLYOFFICE"),
- mime: config.mime,
- permissions: OC.PERMISSION_UPDATE,
- iconClass: "icon-onlyoffice-fill",
+ name: "onlyofficeOpen",
+ displayName: t(OCA.Onlyoffice.AppName, "Open in ONLYOFFICE"),
+ mime: mime,
+ permissions: OC.PERMISSION_READ,
+ iconClass: "icon-onlyoffice-open",
actionHandler: OCA.Onlyoffice.FileClick
});
- }
- if (config.fillForms) {
- OCA.Files.fileActions.setDefault(config.mime, "onlyofficeFill");
- }
+ if (config.def) {
+ OCA.Files.fileActions.setDefault(mime, "onlyofficeOpen");
+ }
- if (config.createForm) {
- var permission = OC.PERMISSION_READ;
- if ($("#isPublic").val()) {
- permission = OC.PERMISSION_UPDATE;
- if (parseInt($("#sharePermission").val()) === (OC.PERMISSION_READ | OC.PERMISSION_CREATE)) {
- permission = OC.PERMISSION_READ;
- }
+ if (config.conv) {
+ OCA.Files.fileActions.registerAction({
+ name: "onlyofficeConvert",
+ displayName: t(OCA.Onlyoffice.AppName, "Convert with ONLYOFFICE"),
+ mime: mime,
+ permissions: ($("#isPublic").val() ? OC.PERMISSION_UPDATE : OC.PERMISSION_READ),
+ iconClass: "icon-onlyoffice-convert",
+ actionHandler: OCA.Onlyoffice.FileConvertClick
+ });
}
- OCA.Files.fileActions.registerAction({
- name: "onlyofficeCreateForm",
- displayName: t(OCA.Onlyoffice.AppName, "Create form"),
- mime: config.mime,
- permissions: permission,
- iconClass: "icon-onlyoffice-create",
- actionHandler: OCA.Onlyoffice.CreateFormClick
- });
- }
+ if (config.fillForms) {
+ OCA.Files.fileActions.registerAction({
+ name: "onlyofficeFill",
+ displayName: t(OCA.Onlyoffice.AppName, "Fill in form in ONLYOFFICE"),
+ mime: mime,
+ permissions: OC.PERMISSION_UPDATE,
+ iconClass: "icon-onlyoffice-fill",
+ actionHandler: OCA.Onlyoffice.FileClick
+ });
+ }
- if (config.saveas && !$("#isPublic").val()) {
- OCA.Files.fileActions.registerAction({
- name: "onlyofficeDownload",
- displayName: t(OCA.Onlyoffice.AppName, "Download as"),
- mime: config.mime,
- permissions: OC.PERMISSION_READ,
- iconClass: "icon-onlyoffice-download",
- actionHandler: OCA.Onlyoffice.DownloadClick
- });
- }
+ if (config.createForm) {
+ OCA.Files.fileActions.registerAction({
+ name: "onlyofficeCreateForm",
+ displayName: t(OCA.Onlyoffice.AppName, "Create form"),
+ mime: mime,
+ permissions: ($("#isPublic").val() ? OC.PERMISSION_UPDATE : OC.PERMISSION_READ),
+ iconClass: "icon-onlyoffice-create",
+ actionHandler: OCA.Onlyoffice.CreateFormClick
+ });
+ }
+
+ if (config.saveas && !$("#isPublic").val()) {
+ OCA.Files.fileActions.registerAction({
+ name: "onlyofficeDownload",
+ displayName: t(OCA.Onlyoffice.AppName, "Download as"),
+ mime: mime,
+ permissions: OC.PERMISSION_READ,
+ iconClass: "icon-onlyoffice-download",
+ actionHandler: OCA.Onlyoffice.DownloadClick
+ });
+ }
+ });
});
}
diff --git a/lib/appconfig.php b/lib/appconfig.php
index 77c84e2f..3558c4e0 100644
--- a/lib/appconfig.php
+++ b/lib/appconfig.php
@@ -23,6 +23,8 @@
use \DateInterval;
use \DateTime;
+use OCP\ICache;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\ILogger;
@@ -312,6 +314,13 @@ class AppConfig {
*/
private $_editors_check_interval = "editors_check_interval";
+ /**
+ * The config key for store cache
+ *
+ * @var ICache
+ */
+ private $cache;
+
/**
* @param string $AppName - application name
*/
@@ -320,6 +329,8 @@ public function __construct($AppName) {
$this->config = \OC::$server->getConfig();
$this->logger = \OC::$server->getLogger();
+ $cacheFactory = \OC::$server->getMemCacheFactory();
+ $this->cache = $cacheFactory->createLocal($this->appName);
}
/**
@@ -1232,7 +1243,7 @@ public function checkEncryptionModule() {
* @NoAdminRequired
*/
public function formatsSetting() {
- $result = $this->formats;
+ $result = $this->buildOnlyofficeFormats();
$defFormats = $this->getDefaultFormats();
foreach ($defFormats as $format => $setting) {
@@ -1280,47 +1291,104 @@ public function getEditorsCheckInterval() {
}
/**
- * Additional data about formats
- *
- * @var array
- */
- private $formats = [
- "csv" => [ "mime" => "text/csv", "type" => "cell", "edit" => true, "editable" => true, "saveas" => ["ods", "pdf", "xlsx"] ],
- "doc" => [ "mime" => "application/msword", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
- "docm" => [ "mime" => "application/vnd.ms-word.document.macroEnabled.12", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
- "docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "word", "edit" => true, "def" => true, "review" => true, "comment" => true, "saveas" => ["odt", "pdf", "rtf", "txt"] ],
- "docxf" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf", "type" => "word", "edit" => true, "def" => true, "review" => true, "comment" => true, "saveas" => ["odt", "pdf", "rtf", "txt"], "createForm" => true ],
- "oform" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform", "type" => "word", "fillForms" => true, "def" => true ],
- "dot" => [ "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
- "dotx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.template", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
- "epub" => [ "mime" => "application/epub+zip", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
- "htm" => [ "type" => "word", "conv" => true ],
- "html" => [ "mime" => "text/html", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
- "odp" => [ "mime" => "application/vnd.oasis.opendocument.presentation", "type" => "slide", "conv" => true, "editable" => true, "saveas" => ["pdf", "pptx"] ],
- "ods" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet", "type" => "cell", "conv" => true, "editable" => true, "saveas" => ["csv", "pdf", "xlsx"] ],
- "odt" => [ "mime" => "application/vnd.oasis.opendocument.text", "type" => "word", "conv" => true, "editable" => true, "saveas" => ["docx", "pdf", "rtf", "txt"] ],
- "otp" => [ "mime" => "application/vnd.oasis.opendocument.presentation-template", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
- "ots" => [ "mime" => "application/vnd.oasis.opendocument.spreadsheet-template", "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
- "ott" => [ "mime" => "application/vnd.oasis.opendocument.text-template", "type" => "word", "conv" => true, "saveas" => ["docx", "odt", "pdf", "rtf", "txt"] ],
- "pdf" => [ "mime" => "application/pdf", "type" => "word" ],
- "pot" => [ "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
- "potm" => [ "mime" => "application/vnd.ms-powerpoint.template.macroEnabled.12", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
- "potx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.template", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
- "pps" => [ "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
- "ppsm" => [ "mime" => "application/vnd.ms-powerpoint.slideshow.macroEnabled.12", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
- "ppsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
- "ppt" => [ "mime" => "application/vnd.ms-powerpoint", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
- "pptm" => [ "mime" => "application/vnd.ms-powerpoint.presentation.macroEnabled.12", "type" => "slide", "conv" => true, "saveas" => ["pdf", "pptx", "odp"] ],
- "pptx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "type" => "slide", "edit" => true, "def" => true, "comment" => true, "saveas" => ["pdf", "odp"] ],
- "rtf" => [ "mime" => "text/rtf", "type" => "word", "conv" => true, "editable" => true, "saveas" => ["docx", "odt", "pdf", "txt"] ],
- "txt" => [ "mime" => "text/plain", "type" => "word", "edit" => true, "editable" => true, "saveas" => ["docx", "odt", "pdf", "rtf"] ],
- "xls" => [ "mime" => "application/vnd.ms-excel", "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
- "xlsm" => [ "mime" => "application/vnd.ms-excel.sheet.macroEnabled.12", "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
- "xlsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "type" => "cell", "edit" => true, "def" => true, "comment" => true, "modifyFilter" => true, "saveas" => ["csv", "ods", "pdf"] ],
- "xlt" => [ "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
- "xltm" => [ "mime" => "application/vnd.ms-excel.template.macroEnabled.12", "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ],
- "xltx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.template", "type" => "cell", "conv" => true, "saveas" => ["csv", "ods", "pdf", "xlsx"] ]
- ];
+ * Get ONLYOFFICE formats list
+ *
+ * @return array
+ */
+ private function buildOnlyofficeFormats() {
+ try {
+ $onlyofficeFormats = $this->getFormats();
+ $result = [];
+ $additionalFormats = $this->getAdditionalFormatAttributes();
+
+ if ($onlyofficeFormats !== false) {
+ foreach ($onlyofficeFormats as $onlyOfficeFormat) {
+ if ($onlyOfficeFormat["name"]
+ && $onlyOfficeFormat["mime"]
+ && $onlyOfficeFormat["type"]
+ && $onlyOfficeFormat["actions"]
+ && $onlyOfficeFormat["convert"]) {
+ $result[$onlyOfficeFormat["name"]] = [
+ "mime" => $onlyOfficeFormat["mime"],
+ "type" => $onlyOfficeFormat["type"],
+ "edit" => in_array("edit", $onlyOfficeFormat["actions"]),
+ "editable" => in_array("lossy-edit", $onlyOfficeFormat["actions"]),
+ "conv" => in_array("auto-convert", $onlyOfficeFormat["actions"]),
+ "fillForms" => in_array("fill", $onlyOfficeFormat["actions"]),
+ "saveas" => $onlyOfficeFormat["convert"],
+ ];
+ if (isset($additionalFormats[$onlyOfficeFormat["name"]])) {
+ $result[$onlyOfficeFormat["name"]] = array_merge($result[$onlyOfficeFormat["name"]], $additionalFormats[$onlyOfficeFormat["name"]]);
+ }
+ }
+ }
+ }
+ return $result;
+ } catch (\Exception $e) {
+ $this->logger->logException($e, ["message" => "Format matrix error", "app" => $this->appName]);
+ return [];
+ }
+ }
+
+ /**
+ * Get the additional format attributes
+ *
+ * @return array
+ */
+ private function getAdditionalFormatAttributes() {
+ $additionalFormatAttributes = [
+ "docx" => [
+ "def" => true,
+ "review" => true,
+ "comment" => true,
+ ],
+ "docxf" => [
+ "def" => true,
+ "review" => true,
+ "comment" => true,
+ "createForm" => true,
+ ],
+ "oform" => [
+ "def" => true,
+ ],
+ "pdf" => [
+ "def" => true,
+ ],
+ "pptx" => [
+ "def" => true,
+ "comment" => true,
+ ],
+ "xlsx" => [
+ "def" => true,
+ "comment" => true,
+ "modifyFilter" => true,
+ ],
+ "txt" => [
+ "edit" => true,
+ ],
+ "csv" => [
+ "edit" => true,
+ ],
+ ];
+ return $additionalFormatAttributes;
+ }
+
+ /**
+ * Get the formats list from cache or file
+ *
+ * @return array
+ */
+ public function getFormats() {
+ $cachedFormats = $this->cache->get("document_formats");
+ if ($cachedFormats !== null) {
+ return json_decode($cachedFormats, true);
+ }
+
+ $formats = file_get_contents(dirname(__DIR__) . DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "document-formats" . DIRECTORY_SEPARATOR . "onlyoffice-docs-formats.json");
+ $this->cache->set("document_formats", $formats, 6 * 3600);
+ $this->logger->debug("Getting formats from file", ["app" => $this->appName]);
+ return json_decode($formats, true);
+ }
/**
* DEMO DATA
diff --git a/templates/settings.php b/templates/settings.php
index a49f1cf7..ebd4c575 100644
--- a/templates/settings.php
+++ b/templates/settings.php
@@ -164,7 +164,7 @@