Skip to content

Commit 429fd23

Browse files
committed
feat: add preview provider for emf files based on office
Signed-off-by: Daniel Kesselberg <[email protected]>
1 parent e593c06 commit 429fd23

File tree

6 files changed

+43
-3
lines changed

6 files changed

+43
-3
lines changed

config/config.sample.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@
12851285
* - ``OC\Preview\StarOffice``
12861286
* - ``OC\Preview\SVG``
12871287
* - ``OC\Preview\TIFF``
1288+
* - ``OC\Preview\EMF``
12881289
*
12891290
*
12901291
* Defaults to the following providers:
@@ -1945,7 +1946,7 @@
19451946
*
19461947
* Example for windows systems: ``array('?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r")``
19471948
* see https://en.wikipedia.org/wiki/Comparison_of_file_systems#Limits
1948-
*
1949+
*
19491950
* Defaults to ``array()``
19501951
*/
19511952
'forbidden_chars' => [],

core/js/mimetypelist.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ OC.MimeTypeList={
113113
"application/vnd.xmind.workbook": "mindmap",
114114
"image/targa": "image/tga",
115115
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform": "x-office/form",
116-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template"
116+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template",
117+
"image/x-emf": "image/emf"
117118
},
118119
files: [
119120
"application",

lib/private/Preview/EMF.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/**
6+
* @copyright 2023 Daniel Kesselberg <[email protected]>
7+
*
8+
* @author Daniel Kesselberg <[email protected]>
9+
*
10+
* @license GNU AGPL version 3 or any later version
11+
*
12+
* This program is free software: you can redistribute it and/or modify
13+
* it under the terms of the GNU Affero General Public License as
14+
* published by the Free Software Foundation, either version 3 of the
15+
* License, or (at your option) any later version.
16+
*
17+
* This program is distributed in the hope that it will be useful,
18+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
* GNU Affero General Public License for more details.
21+
*
22+
* You should have received a copy of the GNU Affero General Public License
23+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
24+
*
25+
*/
26+
27+
namespace OC\Preview;
28+
29+
class EMF extends Office
30+
{
31+
public function getMimeType(): string
32+
{
33+
return '/image\/emf/';
34+
}
35+
}

lib/private/PreviewManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ protected function registerCoreProviders() {
408408
$this->registerCoreProvider(Preview\MSOffice2007::class, '/application\/vnd.openxmlformats-officedocument.*/', ["officeBinary" => $officeBinary]);
409409
$this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/', ["officeBinary" => $officeBinary]);
410410
$this->registerCoreProvider(Preview\StarOffice::class, '/application\/vnd.sun.xml.*/', ["officeBinary" => $officeBinary]);
411+
$this->registerCoreProvider(Preview\EMF::class, '/image\/emf/', ['officeBinary' => $officeBinary]);
411412
}
412413
}
413414
}

resources/config/mimetypealiases.dist.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,6 @@
114114
"application/vnd.xmind.workbook": "mindmap",
115115
"image/targa": "image/tga",
116116
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.oform": "x-office/form",
117-
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template"
117+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document.docxf": "x-office/form-template",
118+
"image/x-emf": "image/emf"
118119
}

resources/config/mimetypemapping.dist.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"dot": ["application/msword"],
5252
"dotx": ["application/vnd.openxmlformats-officedocument.wordprocessingml.template"],
5353
"dv": ["video/dv"],
54+
"emf": ["image/emf"],
5455
"eot": ["application/vnd.ms-fontobject"],
5556
"eps": ["application/postscript"],
5657
"epub": ["application/epub+zip"],

0 commit comments

Comments
 (0)