@@ -417,41 +417,34 @@ protected function registerCoreProviders() {
417417 }
418418
419419 if (count ($ checkImagick ->queryFormats ('PDF ' )) === 1 ) {
420- if (\OC_Helper::is_function_enabled ('shell_exec ' )) {
421- $ officeFound = is_string ($ this ->config ->getSystemValue ('preview_libreoffice_path ' , null ));
422-
423- if (!$ officeFound ) {
424- //let's see if there is libreoffice or openoffice on this machine
425- $ whichLibreOffice = shell_exec ('command -v libreoffice ' );
426- $ officeFound = !empty ($ whichLibreOffice );
427- if (!$ officeFound ) {
428- $ whichOpenOffice = shell_exec ('command -v openoffice ' );
429- $ officeFound = !empty ($ whichOpenOffice );
430- }
431- }
420+ // Office requires openoffice or libreoffice
421+ $ officeBinary = $ this ->config ->getSystemValue ('preview_libreoffice_path ' , null );
422+ if (is_null ($ officeBinary )) {
423+ $ officeBinary = \OC_Helper::findBinaryPath ('libreoffice ' );
424+ }
425+ if (is_null ($ officeBinary )) {
426+ $ officeBinary = \OC_Helper::findBinaryPath ('openoffice ' );
427+ }
432428
433- if ($ officeFound ) {
434- $ this ->registerCoreProvider (Preview \MSOfficeDoc::class, '/application\/msword/ ' );
435- $ this ->registerCoreProvider (Preview \MSOffice2003::class, '/application\/vnd.ms-.*/ ' );
436- $ this ->registerCoreProvider (Preview \MSOffice2007::class, '/application\/vnd.openxmlformats-officedocument.*/ ' );
437- $ this ->registerCoreProvider (Preview \OpenDocument::class, '/application\/vnd.oasis.opendocument.*/ ' );
438- $ this ->registerCoreProvider (Preview \StarOffice::class, '/application\/vnd.sun.xml.*/ ' );
439- }
429+ if (is_string ($ officeBinary )) {
430+ $ this ->registerCoreProvider (Preview \MSOfficeDoc::class, '/application\/msword/ ' , ["officeBinary " => $ officeBinary ]);
431+ $ this ->registerCoreProvider (Preview \MSOffice2003::class, '/application\/vnd.ms-.*/ ' , ["officeBinary " => $ officeBinary ]);
432+ $ this ->registerCoreProvider (Preview \MSOffice2007::class, '/application\/vnd.openxmlformats-officedocument.*/ ' , ["officeBinary " => $ officeBinary ]);
433+ $ this ->registerCoreProvider (Preview \OpenDocument::class, '/application\/vnd.oasis.opendocument.*/ ' , ["officeBinary " => $ officeBinary ]);
434+ $ this ->registerCoreProvider (Preview \StarOffice::class, '/application\/vnd.sun.xml.*/ ' , ["officeBinary " => $ officeBinary ]);
440435 }
441436 }
442437 }
443438
444439 // Video requires avconv or ffmpeg
445440 if (in_array (Preview \Movie::class, $ this ->getEnabledDefaultProvider ())) {
446- $ avconvBinary = \OC_Helper::findBinaryPath ('avconv ' );
447- $ ffmpegBinary = $ avconvBinary ? null : \OC_Helper::findBinaryPath ('ffmpeg ' );
448-
449- if ($ avconvBinary || $ ffmpegBinary ) {
450- // FIXME // a bit hacky but didn't want to use subclasses
451- \OC \Preview \Movie::$ avconvBinary = $ avconvBinary ;
452- \OC \Preview \Movie::$ ffmpegBinary = $ ffmpegBinary ;
441+ $ movieBinary = \OC_Helper::findBinaryPath ('avconv ' );
442+ if (is_null ($ movieBinary )) {
443+ $ movieBinary = \OC_Helper::findBinaryPath ('ffmpeg ' );
444+ }
453445
454- $ this ->registerCoreProvider (Preview \Movie::class, '/video\/.*/ ' );
446+ if (is_string ($ movieBinary )) {
447+ $ this ->registerCoreProvider (Preview \Movie::class, '/video\/.*/ ' , ["movieBinary " => $ movieBinary ]);
455448 }
456449 }
457450 }
0 commit comments