diff --git a/misc/ext.d/doc.sh.in b/misc/ext.d/doc.sh.in index 57723e6bd..521642679 100644 --- a/misc/ext.d/doc.sh.in +++ b/misc/ext.d/doc.sh.in @@ -7,6 +7,22 @@ action=$1 filetype=$2 +STAROFFICE_REGEXP='\.(sxw|sdw|stw|sxc|stc|sxi|sti|sxd|std||sxm||sxg)$' + +staroffice_console() { + filename=$1;shift + is_view=$1; shift + if [ -n "${is_view}" ]; then + is_view='-dump' + fi + + tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` + cd $tmp + soffice2html.pl "${filename}" + elinks ${is_view} content.html + rm -rf "$tmp" +} + do_view_action() { filetype=$1 @@ -15,19 +31,36 @@ do_view_action() { ps2ascii "${MC_EXT_FILENAME}" ;; pdf) - pdftotext "${MC_EXT_FILENAME}" - + pdftotext -layout -nopgbrk "${MC_EXT_FILENAME}" - ;; odt) - odt2txt "${MC_EXT_FILENAME}" + if [ ` echo "${MC_EXT_FILENAME}" | grep -c "${STAROFFICE_REGEXP}"` -ne 0 ]; then + staroffice_console "${MC_EXT_FILENAME}" "view" + else + odt2txt "${MC_EXT_FILENAME}" + fi ;; msdoc) - antiword -t "${MC_EXT_FILENAME}" || \ + which wvHtml >/dev/null 2>&1 && + { + tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` + wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html + elinks -dump "$tmp/page.html" + rm -rf "$tmp" + } || \ + antiword -t "${MC_EXT_FILENAME}" || \ catdoc -w "${MC_EXT_FILENAME}" || \ word2x -f text "${MC_EXT_FILENAME}" - || \ strings "${MC_EXT_FILENAME}" ;; msxls) - xls2csv "${MC_EXT_FILENAME}" || \ + which xlHtml >/dev/null 2>&1 && { + tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` + xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html" + elinks -dump "$tmp/page.html" + rm -rf "$tmp" + } || \ + xls2csv "${MC_EXT_FILENAME}" || \ strings "${MC_EXT_FILENAME}" ;; dvi) @@ -46,31 +79,72 @@ do_open_action() { case "${filetype}" in ps) - (gv "${MC_EXT_FILENAME}" &) + if [ -n "$DISPLAY" ]; then + (gv "${MC_EXT_FILENAME}" &) + else + ps2ascii "${MC_EXT_FILENAME}" | ${PAGER:-more} + fi ;; pdf) - (xpdf "${MC_EXT_FILENAME}" &) + if [ -n "$DISPLAY" ]; then + (xpdf "${MC_EXT_FILENAME}" &) + else + pdftotext -layout -nopgbrk "${MC_EXT_FILENAME}" - | ${PAGER:-more} + fi #(acroread "${MC_EXT_FILENAME}" &) #(ghostview "${MC_EXT_FILENAME}" &) ;; ooffice) - (ooffice "${MC_EXT_FILENAME}" &) + if [ -n "$DISPLAY" ]; then + (ooffice "${MC_EXT_FILENAME}" &) + else + if [ ` echo "${MC_EXT_FILENAME}" | grep -c "${STAROFFICE_REGEXP}"` -ne 0 ]; then + staroffice_console "${MC_EXT_FILENAME}" + else + odt2txt "${MC_EXT_FILENAME}" | ${PAGER:-more} + fi + fi ;; abw) (abiword "${MC_EXT_FILENAME}" &) ;; msdoc) - (abiword "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + if [ -n "$DISPLAY" ]; then + (abiword "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + else + tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` + wvHtml "${MC_EXT_FILENAME}" --targetdir="$tmp" page.html -1 + elinks "$tmp/page.html" + rm -rf "$tmp" + fi ;; msxls) - (gnumeric "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + if [ -n "$DISPLAY" ]; then + (gnumeric "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + else + tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` + xlhtml -a "${MC_EXT_FILENAME}" > "$tmp/page.html" + elinks "$tmp/page.html" + rm -rf "$tmp" + fi + ;; + msppt) + if [ -n "$DISPLAY" ]; then + (ooffice %f >/dev/null 2>&1 &) + else + tmp=`mktemp -d ${TMPDIR:-/tmp}/%p.XXXXXX` + ppthtml %f > "$tmp/page.html" + elinks "$tmp/page.html" + rm -rf "$tmp" + fi ;; framemaker) fmclient -f "${MC_EXT_FILENAME}" ;; dvi) - if [ x$DISPLAY = x ]; then - dvisvga "${MC_EXT_FILENAME}" + if [ -z "$DISPLAY" ]; then + dvisvga "${MC_EXT_FILENAME}" || \ + dvi2tty "${MC_EXT_FILENAME}" | ${PAGER:-more} else (xdvi "${MC_EXT_FILENAME}" &) fi diff --git a/misc/ext.d/image.sh b/misc/ext.d/image.sh index 89dcd8b9d..f19c02937 100644 --- a/misc/ext.d/image.sh +++ b/misc/ext.d/image.sh @@ -33,7 +33,7 @@ do_open_action() { (gimp "${MC_EXT_FILENAME}" &) ;; *) - if [ "$DISPLAY" = "" ]; then + if [ -z "$DISPLAY" ]; then zgv "${MC_EXT_FILENAME}" else (gqview "${MC_EXT_FILENAME}" &) diff --git a/misc/ext.d/sound.sh b/misc/ext.d/sound.sh index 33f00e032..962426358 100644 --- a/misc/ext.d/sound.sh +++ b/misc/ext.d/sound.sh @@ -32,7 +32,7 @@ do_open_action() { case "${filetype}" in common) - if [ "$DISPLAY" = "" ]; then + if [ -z "$DISPLAY" ]; then play "${MC_EXT_FILENAME}" else (xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) @@ -46,14 +46,14 @@ do_open_action() { vplay -s 22 "${MC_EXT_FILENAME}" ;; mp3) - if [ "$DISPLAY" = "" ]; then + if [ -z "$DISPLAY" ]; then mpg123 "${MC_EXT_FILENAME}" else (xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) fi ;; ogg) - if [ "$DISPLAY" = "" ]; then + if [ -z "$DISPLAY" ]; then ogg123 "${MC_EXT_FILENAME}" else (xmms "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) diff --git a/misc/ext.d/text.sh.in b/misc/ext.d/text.sh.in index 5efd04bbb..65211a5ca 100644 --- a/misc/ext.d/text.sh.in +++ b/misc/ext.d/text.sh.in @@ -112,7 +112,14 @@ do_open_action() { esac | ${pager} ;; chm) - which kchmviewer > /dev/null 2>&1 && (kchmviewer "${MC_EXT_FILENAME}" &) || (xchm "${MC_EXT_FILENAME}" &) + if [ -n "$DISPLAY" ]; then + which kchmviewer > /dev/null 2>&1 \ + && (kchmviewer "${MC_EXT_FILENAME}" &) \ + || (xchm "${MC_EXT_FILENAME}" &) + else + chm_http "${MC_EXT_FILENAME}" & elinks http://localhost:8080/index.html + kill -INT %1 + fi ;; *) ;; diff --git a/misc/ext.d/video.sh b/misc/ext.d/video.sh index 8b7652662..6db599c6a 100644 --- a/misc/ext.d/video.sh +++ b/misc/ext.d/video.sh @@ -25,7 +25,11 @@ do_open_action() { (realplay "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) ;; *) - (mplayer "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + if [ -z "$DISPLAY" ]; then + mplayer -vo null "${MC_EXT_FILENAME}" + else + (mplayer "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) + fi #(gtv "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) #(xanim "${MC_EXT_FILENAME}" >/dev/null 2>&1 &) ;; diff --git a/misc/ext.d/web.sh.in b/misc/ext.d/web.sh.in index d00d717cd..f7531449c 100644 --- a/misc/ext.d/web.sh.in +++ b/misc/ext.d/web.sh.in @@ -6,7 +6,6 @@ action=$1 filetype=$2 - do_view_action() { filetype=$1 @@ -26,10 +25,11 @@ do_open_action() { case "${filetype}" in html) - (if test -n "@X11_WWW@" && test -n "$DISPLAY"; then + (if [ -n "@X11_WWW@" -a -n "$DISPLAY" ]; then (@X11_WWW@ file://"${MC_EXT_CURRENTDIR}"/"${MC_EXT_BASENAME}" &) 1>&2 else - links "${MC_EXT_FILENAME}" || \ + elinks "${MC_EXT_FILENAME}" || \ + links "${MC_EXT_FILENAME}" || \ lynx -force_html "${MC_EXT_FILENAME}" || \ ${PAGER:-more} "${MC_EXT_FILENAME}" fi) 2>/dev/null diff --git a/misc/mc.ext.in b/misc/mc.ext.in index 322e8bb33..5eb80aed2 100644 --- a/misc/mc.ext.in +++ b/misc/mc.ext.in @@ -564,6 +564,10 @@ type/^Microsoft\ Excel Open=@EXTHELPERSDIR@/doc.sh open msxls View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msxls +regex/i/\.(ppt|pps)$ + Open=@EXTHELPERSDIR@/doc.sh open msppt + View=%view{ascii} @EXTHELPERSDIR@/doc.sh view msppt + # Use OpenOffice.org to open any MS Office documents type/^Microsoft\ Office\ Document Open=@EXTHELPERSDIR@/doc.sh open ooffice