@@ -394,41 +394,34 @@ protected function registerCoreProviders() {
394394 }
395395
396396 if (count ($ checkImagick ->queryFormats ('PDF ' )) === 1 ) {
397- if (\OC_Helper::is_function_enabled ('shell_exec ' )) {
398- $ officeFound = is_string ($ this ->config ->getSystemValue ('preview_libreoffice_path ' , null ));
399-
400- if (!$ officeFound ) {
401- //let's see if there is libreoffice or openoffice on this machine
402- $ whichLibreOffice = shell_exec ('command -v libreoffice ' );
403- $ officeFound = !empty ($ whichLibreOffice );
404- if (!$ officeFound ) {
405- $ whichOpenOffice = shell_exec ('command -v openoffice ' );
406- $ officeFound = !empty ($ whichOpenOffice );
407- }
408- }
397+ // Office requires openoffice or libreoffice
398+ $ officeBinary = $ this ->config ->getSystemValue ('preview_libreoffice_path ' , null );
399+ if (is_null ($ officeBinary )) {
400+ $ officeBinary = \OC_Helper::findBinaryPath ('libreoffice ' );
401+ }
402+ if (is_null ($ officeBinary )) {
403+ $ officeBinary = \OC_Helper::findBinaryPath ('openoffice ' );
404+ }
409405
410- if ($ officeFound ) {
411- $ this ->registerCoreProvider (Preview \MSOfficeDoc::class, '/application\/msword/ ' );
412- $ this ->registerCoreProvider (Preview \MSOffice2003::class, '/application\/vnd.ms-.*/ ' );
413- $ this ->registerCoreProvider (Preview \MSOffice2007::class, '/application\/vnd.openxmlformats-officedocument.*/ ' );
414- $ this ->registerCoreProvider (Preview \OpenDocument::class, '/application\/vnd.oasis.opendocument.*/ ' );
415- $ this ->registerCoreProvider (Preview \StarOffice::class, '/application\/vnd.sun.xml.*/ ' );
416- }
406+ if (is_string ($ officeBinary )) {
407+ $ this ->registerCoreProvider (Preview \MSOfficeDoc::class, '/application\/msword/ ' , ["officeBinary " => $ officeBinary ]);
408+ $ this ->registerCoreProvider (Preview \MSOffice2003::class, '/application\/vnd.ms-.*/ ' , ["officeBinary " => $ officeBinary ]);
409+ $ this ->registerCoreProvider (Preview \MSOffice2007::class, '/application\/vnd.openxmlformats-officedocument.*/ ' , ["officeBinary " => $ officeBinary ]);
410+ $ this ->registerCoreProvider (Preview \OpenDocument::class, '/application\/vnd.oasis.opendocument.*/ ' , ["officeBinary " => $ officeBinary ]);
411+ $ this ->registerCoreProvider (Preview \StarOffice::class, '/application\/vnd.sun.xml.*/ ' , ["officeBinary " => $ officeBinary ]);
417412 }
418413 }
419414 }
420415
421416 // Video requires avconv or ffmpeg
422417 if (in_array (Preview \Movie::class, $ this ->getEnabledDefaultProvider ())) {
423- $ avconvBinary = \OC_Helper::findBinaryPath ('avconv ' );
424- $ ffmpegBinary = $ avconvBinary ? null : \OC_Helper::findBinaryPath ('ffmpeg ' );
425-
426- if ($ avconvBinary || $ ffmpegBinary ) {
427- // FIXME // a bit hacky but didn't want to use subclasses
428- \OC \Preview \Movie::$ avconvBinary = $ avconvBinary ;
429- \OC \Preview \Movie::$ ffmpegBinary = $ ffmpegBinary ;
418+ $ movieBinary = \OC_Helper::findBinaryPath ('avconv ' );
419+ if (is_null ($ movieBinary )) {
420+ $ movieBinary = \OC_Helper::findBinaryPath ('ffmpeg ' );
421+ }
430422
431- $ this ->registerCoreProvider (Preview \Movie::class, '/video\/.*/ ' );
423+ if (is_string ($ movieBinary )) {
424+ $ this ->registerCoreProvider (Preview \Movie::class, '/video\/.*/ ' , ["movieBinary " => $ movieBinary ]);
432425 }
433426 }
434427 }
0 commit comments