summaryrefslogtreecommitdiffstats
path: root/lib/preview
diff options
context:
space:
mode:
authorGeorg Ehrke <georg@ownCloud.com>2013-06-11 13:15:24 +0200
committerGeorg Ehrke <georg@ownCloud.com>2013-06-11 13:15:24 +0200
commit67816da0bfe16ecb58d3a3bdb70c1fb9a79cff75 (patch)
treeff919879456a727ea86a38820907c8978a067fc9 /lib/preview
parent28cf63d37d6a2b90ae32a2b5b7193a5f5c69830d (diff)
downloadnextcloud-server-67816da0bfe16ecb58d3a3bdb70c1fb9a79cff75.tar.gz
nextcloud-server-67816da0bfe16ecb58d3a3bdb70c1fb9a79cff75.zip
save current work state of office fallback
Diffstat (limited to 'lib/preview')
-rw-r--r--lib/preview/msoffice.php95
-rw-r--r--lib/preview/opendocument.php12
2 files changed, 81 insertions, 26 deletions
diff --git a/lib/preview/msoffice.php b/lib/preview/msoffice.php
index c99ca313c72..4fedb735c95 100644
--- a/lib/preview/msoffice.php
+++ b/lib/preview/msoffice.php
@@ -7,22 +7,24 @@
*/
namespace OC\Preview;
-class MSOffice2003 extends Provider {
+class DOC extends Provider {
- public function getMimeType(){
- return null;
+ public function getMimeType() {
+ return '/application\/msword/';
}
- public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview){
- return false;
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+
}
+
}
+\OC\Preview::registerProvider('OC\Preview\DOC');
-class MSOffice2007 extends Provider {
+class DOCX extends Provider {
- public function getMimeType(){
- return null;
+ public function getMimeType() {
+ return '/application\/vnd.openxmlformats-officedocument.wordprocessingml.document/';
}
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
@@ -39,36 +41,50 @@ class MSOffice2007 extends Provider {
unlink($tmpdoc);
- //new image object
$image = new \OC_Image($pdf);
- //check if image object is valid
- if (!$image->valid()) return false;
-
- return $image;
+
+ return $image->valid() ? $image : false;
}
+
}
-class DOC extends MSOffice2003 {
+\OC\Preview::registerProvider('OC\Preview\DOCX');
+
+class MSOfficeExcel extends Provider {
public function getMimeType() {
- return '/application\/msword/';
+ return null;
}
-}
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ require_once('PHPExcel/Classes/PHPExcel.php');
+ require_once('PHPExcel/Classes/PHPExcel/IOFactory.php');
+ //require_once('mpdf/mpdf.php');
-\OC\Preview::registerProvider('OC\Preview\DOC');
+ $abspath = $fileview->toTmpFile($path);
+ $tmppath = \OC_Helper::tmpFile();
-class DOCX extends MSOffice2007 {
+ $rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF;
+ $rendererLibraryPath = \OC::$THIRDPARTYROOT . '/dompdf';
- public function getMimeType() {
- return '/application\/vnd.openxmlformats-officedocument.wordprocessingml.document/';
+ \PHPExcel_Settings::setPdfRenderer($rendererName, $rendererLibraryPath);
+
+ $phpexcel = new \PHPExcel($abspath);
+ $excel = \PHPExcel_IOFactory::createWriter($phpexcel, 'PDF');
+ $excel->save($tmppath);
+
+ $pdf = new \imagick($tmppath . '[0]');
+ $pdf->setImageFormat('jpg');
+
+ unlink($abspath);
+ unlink($tmppath);
+
+ return $image->valid() ? $image : false;
}
}
-\OC\Preview::registerProvider('OC\Preview\DOCX');
-
-class XLS extends MSOffice2003 {
+class XLS extends MSOfficeExcel {
public function getMimeType() {
return '/application\/vnd.ms-excel/';
@@ -78,7 +94,7 @@ class XLS extends MSOffice2003 {
\OC\Preview::registerProvider('OC\Preview\XLS');
-class XLSX extends MSOffice2007 {
+class XLSX extends MSOfficeExcel {
public function getMimeType() {
return '/application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet/';
@@ -88,7 +104,34 @@ class XLSX extends MSOffice2007 {
\OC\Preview::registerProvider('OC\Preview\XLSX');
-class PPT extends MSOffice2003 {
+class MSOfficePowerPoint extends Provider {
+
+ public function getMimeType() {
+ return null;
+ }
+
+ public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
+ //require_once('');
+ //require_once('');
+
+ $abspath = $fileview->toTmpFile($path);
+ $tmppath = \OC_Helper::tmpFile();
+
+ $excel = PHPPowerPoint_IOFactory::createWriter($abspath, 'PDF');
+ $excel->save($tmppath);
+
+ $pdf = new \imagick($tmppath . '[0]');
+ $pdf->setImageFormat('jpg');
+
+ unlink($abspath);
+ unlink($tmppath);
+
+ return $image->valid() ? $image : false;
+ }
+
+}
+
+class PPT extends MSOfficePowerPoint {
public function getMimeType() {
return '/application\/vnd.ms-powerpoint/';
@@ -98,7 +141,7 @@ class PPT extends MSOffice2003 {
\OC\Preview::registerProvider('OC\Preview\PPT');
-class PPTX extends MSOffice2007 {
+class PPTX extends MSOfficePowerPoint {
public function getMimeType() {
return '/application\/vnd.openxmlformats-officedocument.presentationml.presentation/';
diff --git a/lib/preview/opendocument.php b/lib/preview/opendocument.php
index e69de29bb2d..786a038ff82 100644
--- a/lib/preview/opendocument.php
+++ b/lib/preview/opendocument.php
@@ -0,0 +1,12 @@
+<?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 OpenDocument {
+
+} \ No newline at end of file