diff --git a/composer.json b/composer.json index 06386ea69a..16fd823873 100644 --- a/composer.json +++ b/composer.json @@ -31,6 +31,7 @@ "lint": "find . -name \\*.php -not -path './vendor/*' -print0 | xargs -0 -n1 php -l", "psalm": "psalm.phar", "psalm:fix": "psalm.phar --alter --issues=InvalidReturnType,InvalidNullableReturnType,MismatchingDocblockParamType,MismatchingDocblockReturnType,MissingParamType,InvalidFalsableReturnType", + "psalm:update-baseline": "psalm.phar --threads=1 --update-baseline --set-baseline=tests/psalm-baseline.xml", "cs:check": "php-cs-fixer fix --dry-run --diff", "cs:fix": "php-cs-fixer fix", "test:unit": "vendor/bin/phpunit -c tests/phpunit.xml" diff --git a/composer/composer/autoload_classmap.php b/composer/composer/autoload_classmap.php index 2aa64bd592..b8bd7aa4bc 100644 --- a/composer/composer/autoload_classmap.php +++ b/composer/composer/autoload_classmap.php @@ -52,6 +52,7 @@ 'OCA\\Richdocuments\\Migration\\Version30717Date20210310164901' => $baseDir . '/../lib/Migration/Version30717Date20210310164901.php', 'OCA\\Richdocuments\\Migration\\Version50200Date20211220212457' => $baseDir . '/../lib/Migration/Version50200Date20211220212457.php', 'OCA\\Richdocuments\\PermissionManager' => $baseDir . '/../lib/PermissionManager.php', + 'OCA\\Richdocuments\\Preview\\EMF' => $baseDir . '/../lib/Preview/EMF.php', 'OCA\\Richdocuments\\Preview\\MSExcel' => $baseDir . '/../lib/Preview/MSExcel.php', 'OCA\\Richdocuments\\Preview\\MSWord' => $baseDir . '/../lib/Preview/MSWord.php', 'OCA\\Richdocuments\\Preview\\OOXML' => $baseDir . '/../lib/Preview/OOXML.php', diff --git a/composer/composer/autoload_static.php b/composer/composer/autoload_static.php index 7a0f9877b8..aea309c791 100644 --- a/composer/composer/autoload_static.php +++ b/composer/composer/autoload_static.php @@ -67,6 +67,7 @@ class ComposerStaticInitRichdocuments 'OCA\\Richdocuments\\Migration\\Version30717Date20210310164901' => __DIR__ . '/..' . '/../lib/Migration/Version30717Date20210310164901.php', 'OCA\\Richdocuments\\Migration\\Version50200Date20211220212457' => __DIR__ . '/..' . '/../lib/Migration/Version50200Date20211220212457.php', 'OCA\\Richdocuments\\PermissionManager' => __DIR__ . '/..' . '/../lib/PermissionManager.php', + 'OCA\\Richdocuments\\Preview\\EMF' => __DIR__ . '/..' . '/../lib/Preview/EMF.php', 'OCA\\Richdocuments\\Preview\\MSExcel' => __DIR__ . '/..' . '/../lib/Preview/MSExcel.php', 'OCA\\Richdocuments\\Preview\\MSWord' => __DIR__ . '/..' . '/../lib/Preview/MSWord.php', 'OCA\\Richdocuments\\Preview\\OOXML' => __DIR__ . '/..' . '/../lib/Preview/OOXML.php', diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 9e31e7a50e..aab6db3484 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -37,6 +37,7 @@ use OCA\Richdocuments\Listener\ShareLinkListener; use OCA\Richdocuments\Middleware\WOPIMiddleware; use OCA\Richdocuments\PermissionManager; +use OCA\Richdocuments\Preview\EMF; use OCA\Richdocuments\Preview\MSExcel; use OCA\Richdocuments\Preview\MSWord; use OCA\Richdocuments\Preview\OOXML; @@ -175,6 +176,10 @@ public function registerProvider() { return $container->get(OpenDocument::class); }); + $previewManager->registerProvider('/image\/emf/', function () use ($container) { + return $container->get(EMF::class); + }); + if (!$previewManager->isMimeSupported('application/pdf')) { $previewManager->registerProvider('/application\/pdf/', function () use ($container) { return $container->get(Pdf::class); diff --git a/lib/Preview/EMF.php b/lib/Preview/EMF.php new file mode 100644 index 0000000000..2ecb0a12f2 --- /dev/null +++ b/lib/Preview/EMF.php @@ -0,0 +1,35 @@ + + * + * @author Daniel Kesselberg + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCA\Richdocuments\Preview; + +class EMF extends Office { + /** + * {@inheritDoc} + */ + public function getMimeType() { + return '/image\/emf/'; + } +} diff --git a/tests/psalm-baseline.xml b/tests/psalm-baseline.xml index 5366513922..c55752e530 100644 --- a/tests/psalm-baseline.xml +++ b/tests/psalm-baseline.xml @@ -10,6 +10,7 @@ + EMF MSExcel MSWord OOXML @@ -47,7 +48,7 @@ getId()]]> - $app !== '' + @@ -66,7 +67,7 @@ null - $path === '' + putContent @@ -83,6 +84,11 @@ + + + Office + + Office