diff options
author | Georg Ehrke <georg@ownCloud.com> | 2013-05-31 12:23:51 +0200 |
---|---|---|
committer | Georg Ehrke <georg@ownCloud.com> | 2013-05-31 12:23:51 +0200 |
commit | a11a40d9a96685d41e5acae096752f16785b16b5 (patch) | |
tree | b511752700160203e8dc4da234ab2d683d84deb6 | |
parent | f7c80a391d192a15d594c3eaf7909a3d78df1a29 (diff) | |
download | nextcloud-server-a11a40d9a96685d41e5acae096752f16785b16b5.tar.gz nextcloud-server-a11a40d9a96685d41e5acae096752f16785b16b5.zip |
add backend for microsoft office 2007 documents
-rwxr-xr-x | lib/preview.php | 2 | ||||
-rw-r--r-- | lib/preview/msoffice.php | 109 |
2 files changed, 111 insertions, 0 deletions
diff --git a/lib/preview.php b/lib/preview.php index be3abc2cd47..a73f4cb1ac0 100755 --- a/lib/preview.php +++ b/lib/preview.php @@ -20,6 +20,8 @@ require_once('preview/pdf.php'); require_once('preview/svg.php'); require_once('preview/txt.php'); require_once('preview/unknown.php'); +require_once('preview/msoffice.php'); +//require_once('preview/opendocument.php'); class Preview { //the thumbnail folder diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php new file mode 100644 index 00000000000..c99ca313c72 --- /dev/null +++ b/lib/preview/msoffice.php @@ -0,0 +1,109 @@ +<?php +/** + * Copyright (c) 2013 Georg Ehrke georg@ownCloud.com + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +namespace OC\Preview; + +class MSOffice2003 extends Provider { + + public function getMimeType(){ + return null; + } + + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview){ + return false; + } +} + + +class MSOffice2007 extends Provider { + + public function getMimeType(){ + return null; + } + + public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) { + require_once('phpdocx/classes/TransformDoc.inc'); + + $tmpdoc = $fileview->toTmpFile($path); + + $transformdoc = new \TransformDoc(); + $transformdoc->setStrFile($tmpdoc); + $transformdoc->generatePDF($tmpdoc); + + $pdf = new \imagick($tmpdoc . '[0]'); + $pdf->setImageFormat('jpg'); + + unlink($tmpdoc); + + //new image object + $image = new \OC_Image($pdf); + //check if image object is valid + if (!$image->valid()) return false; + + return $image; + } +} + +class DOC extends MSOffice2003 { + + public function getMimeType() { + return '/application\/msword/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\DOC'); + +class DOCX extends MSOffice2007 { + + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.wordprocessingml.document/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\DOCX'); + +class XLS extends MSOffice2003 { + + public function getMimeType() { + return '/application\/vnd.ms-excel/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\XLS'); + +class XLSX extends MSOffice2007 { + + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\XLSX'); + +class PPT extends MSOffice2003 { + + public function getMimeType() { + return '/application\/vnd.ms-powerpoint/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\PPT'); + +class PPTX extends MSOffice2007 { + + public function getMimeType() { + return '/application\/vnd.openxmlformats-officedocument.presentationml.presentation/'; + } + +} + +\OC\Preview::registerProvider('OC\Preview\PPTX');
\ No newline at end of file |