Extract preview from opendocument files

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2020-04-05 11:00:57 +02:00
parent 0734582c06
commit a2e671c489
No known key found for this signature in database
GPG Key ID: 4C614C6ED2CDE6DF
2 changed files with 18 additions and 1 deletions

View File

@ -25,11 +25,26 @@
namespace OC\Preview; namespace OC\Preview;
//.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt //.odt, .ott, .oth, .odm, .odg, .otg, .odp, .otp, .ods, .ots, .odc, .odf, .odb, .odi, .oxt
class OpenDocument extends Office { use OCP\Files\File;
use OCP\IImage;
class OpenDocument extends Bundled {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public function getMimeType(): string { public function getMimeType(): string {
return '/application\/vnd.oasis.opendocument.*/'; return '/application\/vnd.oasis.opendocument.*/';
} }
/**
* @inheritDoc
*/
public function getThumbnail(File $file, int $maxX, int $maxY): ?IImage {
$image = $this->extractThumbnail($file, 'Thumbnails/thumbnail.png');
if ($image->valid()) {
return $image;
}
return null;
}
} }

View File

@ -300,6 +300,7 @@ class PreviewManager implements IPreview {
Preview\MarkDown::class, Preview\MarkDown::class,
Preview\MP3::class, Preview\MP3::class,
Preview\TXT::class, Preview\TXT::class,
Preview\OpenDocument::class,
], $imageProviders)); ], $imageProviders));
if (in_array(Preview\Image::class, $this->defaultProviders)) { if (in_array(Preview\Image::class, $this->defaultProviders)) {
@ -340,6 +341,7 @@ class PreviewManager implements IPreview {
$this->registerCoreProvider(Preview\BMP::class, '/image\/bmp/'); $this->registerCoreProvider(Preview\BMP::class, '/image\/bmp/');
$this->registerCoreProvider(Preview\XBitmap::class, '/image\/x-xbitmap/'); $this->registerCoreProvider(Preview\XBitmap::class, '/image\/x-xbitmap/');
$this->registerCoreProvider(Preview\MP3::class, '/audio\/mpeg/'); $this->registerCoreProvider(Preview\MP3::class, '/audio\/mpeg/');
$this->registerCoreProvider(Preview\OpenDocument::class, '/application\/vnd.oasis.opendocument.*/');
// SVG, Office and Bitmap require imagick // SVG, Office and Bitmap require imagick
if (extension_loaded('imagick')) { if (extension_loaded('imagick')) {