Merge branch '3929_office_formats_ext'

* 3929_office_formats_ext:
  mcext/doc: improve open of documents in MS Office formats.
  Ticket #3929: mc.ext: improve recognition of MS Office formats.
This commit is contained in:
Andrew Borodin 2018-08-28 10:49:10 +03:00
commit 5f80acde87
2 changed files with 30 additions and 9 deletions

View File

@ -25,9 +25,13 @@ staroffice_console() {
} }
get_ooffice_executable() { get_ooffice_executable() {
which loffice >/dev/null 2>&1 && \ if loffice >/dev/null 2>&1; then
echo "loffice" || \ echo "loffice"
elif ooffice >/dev/null 2>&1; then
echo "ooffice" echo "ooffice"
else
echo -n
fi
} }
do_view_action() { do_view_action() {
@ -116,7 +120,9 @@ do_open_action() {
ooffice) ooffice)
if [ -n "$DISPLAY" ]; then if [ -n "$DISPLAY" ]; then
OOFFICE=`get_ooffice_executable` OOFFICE=`get_ooffice_executable`
(${OOFFICE} "${MC_EXT_FILENAME}" &) if [ -n "${OOFFICE}" ]; then
(${OOFFICE} "${MC_EXT_FILENAME}" &)
fi
else else
if [ `echo "${MC_EXT_FILENAME}" | grep -c "${STAROFFICE_REGEXP}"` -ne 0 ]; then if [ `echo "${MC_EXT_FILENAME}" | grep -c "${STAROFFICE_REGEXP}"` -ne 0 ]; then
staroffice_console "${MC_EXT_FILENAME}" staroffice_console "${MC_EXT_FILENAME}"
@ -133,7 +139,12 @@ do_open_action() {
;; ;;
msdoc) msdoc)
if [ -n "$DISPLAY" ]; then if [ -n "$DISPLAY" ]; then
(abiword "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) OOFFICE=`get_ooffice_executable`
if [ -n "${OOFFICE}" ]; then
(${OOFFICE} "${MC_EXT_FILENAME}" &)
else
(abiword "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
fi
else else
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html -1 wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html -1
@ -143,7 +154,12 @@ do_open_action() {
;; ;;
msxls) msxls)
if [ -n "$DISPLAY" ]; then if [ -n "$DISPLAY" ]; then
(gnumeric "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) OOFFICE=`get_ooffice_executable`
if [ -n "${OOFFICE}" ]; then
(${OOFFICE} "${MC_EXT_FILENAME}" &)
else
(gnumeric "${MC_EXT_FILENAME}" >/dev/null 2>&1 &)
fi
else else
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html" xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html"
@ -154,7 +170,9 @@ do_open_action() {
msppt) msppt)
if [ -n "$DISPLAY" ]; then if [ -n "$DISPLAY" ]; then
OOFFICE=`get_ooffice_executable` OOFFICE=`get_ooffice_executable`
(${OOFFICE} "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) if [ -n "${OOFFICE}" ]; then
(${OOFFICE} "${MC_EXT_FILENAME}" &)
fi
else else
tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX`
ppthtml "${MC_EXT_FILENAME}" > "$tmp/page.html" ppthtml "${MC_EXT_FILENAME}" > "$tmp/page.html"

View File

@ -607,7 +607,7 @@ shell/i/.gnumeric
Open=@EXTHELPERSDIR@/doc.sh open gnumeric Open=@EXTHELPERSDIR@/doc.sh open gnumeric
# Microsoft Word Document # Microsoft Word Document
regex/i/\.(do[ct]|wri)$ regex/i/\.(do[ct]|wri|docx)$
Open=@EXTHELPERSDIR@/doc.sh open msdoc Open=@EXTHELPERSDIR@/doc.sh open msdoc
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msdoc View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msdoc
type/^Microsoft\ Word type/^Microsoft\ Word
@ -626,13 +626,16 @@ type/^Microsoft\ Excel
Open=@EXTHELPERSDIR@/doc.sh open msxls Open=@EXTHELPERSDIR@/doc.sh open msxls
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msxls View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msxls
regex/i/\.(ppt|pps)$ # Microsoft PowerPoint Presentation
regex/i/\.(pp[ts]|pptx)$
Open=@EXTHELPERSDIR@/doc.sh open msppt Open=@EXTHELPERSDIR@/doc.sh open msppt
View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msppt View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msppt
# Use OpenOffice.org to open any MS Office documents # Use OpenOffice.org/LibreOffice to open any MS Office documents
type/^Microsoft\ Office\ Document type/^Microsoft\ Office\ Document
Open=@EXTHELPERSDIR@/doc.sh open ooffice Open=@EXTHELPERSDIR@/doc.sh open ooffice
type/^Microsoft\ OOXML
Open=@EXTHELPERSDIR@/doc.sh open ooffice
# Framemaker # Framemaker
type/^FrameMaker type/^FrameMaker