2013-05-31 14:23:51 +04:00
|
|
|
<?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;
|
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
class DOC extends Provider {
|
2013-05-31 14:23:51 +04:00
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
public function getMimeType() {
|
|
|
|
return '/application\/msword/';
|
2013-05-31 14:23:51 +04:00
|
|
|
}
|
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
2013-06-18 15:53:02 +04:00
|
|
|
require_once();
|
2013-05-31 14:23:51 +04:00
|
|
|
}
|
2013-06-11 15:15:24 +04:00
|
|
|
|
2013-05-31 14:23:51 +04:00
|
|
|
}
|
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
\OC\Preview::registerProvider('OC\Preview\DOC');
|
2013-05-31 14:23:51 +04:00
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
class DOCX extends Provider {
|
2013-05-31 14:23:51 +04:00
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
public function getMimeType() {
|
|
|
|
return '/application\/vnd.openxmlformats-officedocument.wordprocessingml.document/';
|
2013-05-31 14:23:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
$image = new \OC_Image($pdf);
|
2013-06-12 13:40:01 +04:00
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
return $image->valid() ? $image : false;
|
2013-05-31 14:23:51 +04:00
|
|
|
}
|
2013-06-11 15:15:24 +04:00
|
|
|
|
2013-05-31 14:23:51 +04:00
|
|
|
}
|
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
\OC\Preview::registerProvider('OC\Preview\DOCX');
|
|
|
|
|
|
|
|
class MSOfficeExcel extends Provider {
|
2013-05-31 14:23:51 +04:00
|
|
|
|
|
|
|
public function getMimeType() {
|
2013-06-11 15:15:24 +04:00
|
|
|
return null;
|
2013-05-31 14:23:51 +04:00
|
|
|
}
|
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
|
|
|
require_once('PHPExcel/Classes/PHPExcel.php');
|
|
|
|
require_once('PHPExcel/Classes/PHPExcel/IOFactory.php');
|
2013-05-31 14:23:51 +04:00
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
$abspath = $fileview->toTmpFile($path);
|
|
|
|
$tmppath = \OC_Helper::tmpFile();
|
2013-05-31 14:23:51 +04:00
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
$rendererName = \PHPExcel_Settings::PDF_RENDERER_DOMPDF;
|
2013-06-12 13:40:01 +04:00
|
|
|
$rendererLibraryPath = \OC::$THIRDPARTYROOT . '/3rdparty/dompdf';
|
2013-05-31 14:23:51 +04:00
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
\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);
|
|
|
|
|
2013-06-12 13:40:01 +04:00
|
|
|
$image = new \OC_Image($pdf);
|
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
return $image->valid() ? $image : false;
|
2013-05-31 14:23:51 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
class XLS extends MSOfficeExcel {
|
2013-05-31 14:23:51 +04:00
|
|
|
|
|
|
|
public function getMimeType() {
|
|
|
|
return '/application\/vnd.ms-excel/';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
\OC\Preview::registerProvider('OC\Preview\XLS');
|
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
class XLSX extends MSOfficeExcel {
|
2013-05-31 14:23:51 +04:00
|
|
|
|
|
|
|
public function getMimeType() {
|
|
|
|
return '/application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet/';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
\OC\Preview::registerProvider('OC\Preview\XLSX');
|
|
|
|
|
2013-06-18 15:53:02 +04:00
|
|
|
/* //There is no (good) php-only solution for converting powerpoint documents to pdfs / pngs ...
|
2013-06-11 15:15:24 +04:00
|
|
|
class MSOfficePowerPoint extends Provider {
|
|
|
|
|
|
|
|
public function getMimeType() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
|
2013-06-12 15:20:59 +04:00
|
|
|
return false;
|
2013-06-11 15:15:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
class PPT extends MSOfficePowerPoint {
|
2013-05-31 14:23:51 +04:00
|
|
|
|
|
|
|
public function getMimeType() {
|
|
|
|
return '/application\/vnd.ms-powerpoint/';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
\OC\Preview::registerProvider('OC\Preview\PPT');
|
|
|
|
|
2013-06-11 15:15:24 +04:00
|
|
|
class PPTX extends MSOfficePowerPoint {
|
2013-05-31 14:23:51 +04:00
|
|
|
|
|
|
|
public function getMimeType() {
|
|
|
|
return '/application\/vnd.openxmlformats-officedocument.presentationml.presentation/';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-06-18 15:53:02 +04:00
|
|
|
\OC\Preview::registerProvider('OC\Preview\PPTX');
|
|
|
|
*/
|