richdocuments icon indicating copy to clipboard operation
richdocuments copied to clipboard

doxf/oform support

Open juliushaertl opened this issue 9 months ago • 1 comments

  • docxf/oform files should already open with Collabora
    • tested and it works by renaming them to docx
  • mimetype should be known to Nextcloud already https://github.com/nextcloud/server/pull/32481
    • [ ] https://github.com/nextcloud/server/pull/41475
  • there is a bug on 28 preventing the upload
    • [ ] https://github.com/nextcloud-libraries/nextcloud-upload/pull/955
  • otherwise it may be enough to extend richdocuments supported mimetypes
  • full compatibility in collabora still needs verification
    • [ ] Collabora does not announce the mimetype/extension in discovery
    • [ ] Files are read only for now
  • WIP branch https://github.com/nextcloud/richdocuments/compare/feat/oform-docxf?expand=1

Patch to add mimetypes for richdocuments and work around missing discovery entry of online:

diff --git a/lib/Capabilities.php b/lib/Capabilities.php
index 96e811dd..f3c795d6 100644
--- a/lib/Capabilities.php
+++ b/lib/Capabilities.php
@@ -70,6 +70,8 @@ class Capabilities implements ICapability {
                'application/vnd.ms-powerpoint.presentation.macroEnabled.12',
                'application/vnd.ms-powerpoint.template.macroEnabled.12',
                'application/vnd.ms-powerpoint.slideshow.macroEnabled.12',
+               'application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform',
+               'application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf',
                'text/csv',
        ];

diff --git a/lib/WOPI/Parser.php b/lib/WOPI/Parser.php
index 8480bef8..cf231cd8 100644
--- a/lib/WOPI/Parser.php
+++ b/lib/WOPI/Parser.php
@@ -64,6 +64,14 @@ class Parser {
                        ];
                }

+               $result = $discoveryParsed->xpath(sprintf('/wopi-discovery/net-zone/app[@name=\'%s\']/action', 'application/vnd.oasis.opendocument.text'));
+               if ($result && count($result) > 0) {
+                       return [
+                               'urlsrc' => (string)$result[0]['urlsrc'],
+                               'action' => (string)$result[0]['name'],
+                       ];
+               }
+
                $this->logger->error('Didn\'t find urlsrc for mimetype {mimetype} in this WOPI discovery response: {discovery}', ['mimetype' => $mimetype, 'discovery' => $discovery]);
                throw new \Exception('Could not find urlsrc in WOPI');
        }

juliushaertl avatar Nov 10 '23 20:11 juliushaertl

@pedropintosilva Successfully tested with a couple of patches, two notes:

  • Collabora does not announce the mimetype/extension in discovery
  • Files are read only for now

juliushaertl avatar Nov 14 '23 19:11 juliushaertl