Skip to content

Commit

Permalink
Merge pull request #3303 from nextcloud/preview-emf
Browse files Browse the repository at this point in the history
  • Loading branch information
kesselb authored Nov 20, 2023
2 parents 81fc84a + 123e69c commit 37d67ff
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 1 addition & 0 deletions composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
35 changes: 35 additions & 0 deletions lib/Preview/EMF.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

/**
* @copyright 2023 Daniel Kesselberg <mail@danielkesselberg.de>
*
* @author Daniel Kesselberg <mail@danielkesselberg.de>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Richdocuments\Preview;

class EMF extends Office {
/**
* {@inheritDoc}
*/
public function getMimeType() {
return '/image\/emf/';
}
}
10 changes: 8 additions & 2 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</file>
<file src="lib/AppInfo/Application.php">
<MissingDependency>
<code>EMF</code>
<code>MSExcel</code>
<code>MSWord</code>
<code>OOXML</code>
Expand Down Expand Up @@ -47,7 +48,7 @@
<code><![CDATA[$node->getId()]]></code>
</InvalidScalarArgument>
<RedundantCondition>
<code>$app !== ''</code>
<code><![CDATA[$app !== '']]></code>
</RedundantCondition>
</file>
<file src="lib/Controller/TemplatesController.php">
Expand All @@ -66,7 +67,7 @@
<code>null</code>
</NullArgument>
<TypeDoesNotContainType>
<code>$path === ''</code>
<code><![CDATA[$path === '']]></code>
</TypeDoesNotContainType>
<UndefinedInterfaceMethod>
<code>putContent</code>
Expand All @@ -83,6 +84,11 @@
<code><![CDATA[$share && method_exists($share, 'getAttributes')]]></code>
</RedundantCondition>
</file>
<file src="lib/Preview/EMF.php">
<MissingDependency>
<code>Office</code>
</MissingDependency>
</file>
<file src="lib/Preview/MSExcel.php">
<MissingDependency>
<code>Office</code>
Expand Down

0 comments on commit 37d67ff

Please sign in to comment.