diff --git a/lib/Capabilities.php b/lib/Capabilities.php index 45e9bdd5f6..fa0d03e782 100644 --- a/lib/Capabilities.php +++ b/lib/Capabilities.php @@ -43,10 +43,14 @@ class Capabilities implements ICapability { 'application/vnd.visio', 'application/vnd.ms-visio.drawing', 'application/vnd.wordperfect', - 'application/msonenote', - 'application/msword', 'application/rtf', 'text/rtf', + 'text/csv' + ]; + + const MIMETYPES_MSOFFICE = [ + 'application/msonenote', + 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'application/vnd.ms-word.document.macroEnabled.12', @@ -66,7 +70,6 @@ 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', - 'text/csv' ]; public const MIMETYPES_OPTIONAL = [ @@ -104,25 +107,33 @@ public function getCapabilities() { if (!$this->capabilities) { $collaboraCapabilities = $this->capabilitiesService->getCapabilities(); - $filteredMimetypes = self::MIMETYPES; + + $defaultMimetypes = self::MIMETYPES; $optionalMimetypes = self::MIMETYPES_OPTIONAL; + + if (!$this->capabilitiesService->hasOtherOOXMLApps()) { + array_push($defaultMimetypes, ...self::MIMETYPES_MSOFFICE); + } else { + array_push($optionalMimetypes, ...self::MIMETYPES_MSOFFICE); + } + // If version is too old, draw is not supported if (!$this->capabilitiesService->hasDrawSupport()) { - $filteredMimetypes = array_diff($filteredMimetypes, [ + $defaultMimetypes = array_diff($defaultMimetypes, [ 'application/vnd.oasis.opendocument.graphics', 'application/vnd.oasis.opendocument.graphics-flat-xml', ]); } if (!$this->appManager->isEnabledForUser('files_pdfviewer')) { - $filteredMimetypes[] = 'application/pdf'; + $defaultMimetypes[] = 'application/pdf'; $optionalMimetypes = array_diff($optionalMimetypes, ['application/pdf']); } $this->capabilities = [ 'richdocuments' => [ 'version' => \OC::$server->getAppManager()->getAppVersion('richdocuments'), - 'mimetypes' => array_values($filteredMimetypes), + 'mimetypes' => array_values($defaultMimetypes), 'mimetypesNoDefaultOpen' => array_values($optionalMimetypes), 'collabora' => $collaboraCapabilities, 'direct_editing' => isset($collaboraCapabilities['hasMobileSupport']) && $this->config->getAppValue('mobile_editing') ?: false, diff --git a/lib/Service/CapabilitiesService.php b/lib/Service/CapabilitiesService.php index 081024d552..57f7c008ea 100644 --- a/lib/Service/CapabilitiesService.php +++ b/lib/Service/CapabilitiesService.php @@ -112,6 +112,18 @@ public function getProductName(): string { return $this->l10n->t('Nextcloud Office'); } + public function hasOtherOOXMLApps(): bool { + if ($this->appManager->isEnabledForUser('officeonline')) { + return true; + } + + if ($this->appManager->isEnabledForUser('onlyoffice')) { + return true; + } + + return false; + } + public function clear(): void { $this->cache->remove('capabilities'); }