You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

160 lines
4.8 KiB

#!/bin/sh
##
## msov -- Microsoft Office Viewer Frontend Utility
## Copyright (c) 2003 Ralf S. Engelschall <rse@engelschall.com>
##
# configuration
prefix="@l_prefix@"
# knowledge about viewers
info_doc='wd97vwr32.exe:Microsoft Office 2000, Word Viewer:Program Files/WordView/WORDVIEW.EXE'
info_xls='xlViewer.exe:Microsoft Office 2000, Excel Viewer:Program Files/XLView/XLVIEW.EXE'
info_ppt='ppview97.exe:Microsoft Office 2000, PowerPoint Viewer:Program Files/PowerPoint Viewer/PPVIEW32.EXE';
# option defaults
setup=no
format=""
help=""
quiet=no
# iterate over argument line
while [ $# -gt 0 ]; do
opt=$1
case $opt in
-*=*) arg=`echo "$opt" | sed 's/^[-_a-zA-Z0-9]*=//'` ;;
*) arg='' ;;
esac
case $opt in
-s|--setup ) setup=yes ;;
-h|--help ) help="Usage" ;;
-q|--quiet ) quiet=yes ;;
--format=* ) format=$arg ;;
-* ) help="Invalid option \`$opt'"; break ;;
* ) break ;;
esac
shift
done
# display error or usage message
if [ ".$help" != . ]; then
if [ ".$help" != ".Usage" ]; then
echo "msov:ERROR: $help" 1>&2
fi
echo "Usage: msov [-q|--quiet] [-s|--setup]" 1>&2
echo "Usage: msov [--format=doc|xls|ppt] <file>" 1>&2
echo "Usage: msov [-h|--help]" 1>&2
if [ ".$help" != ".Usage" ]; then
exit 1
else
exit 0
fi
fi
# make sure WINE area was already established
if [ ! -d "$HOME/.wine/c_drive" ]; then
echo "msov:ERROR: WINE still not setup for current user" 1>&2
echo "msov:HINT: You have to establish the WINE area $HOME/.wine first" 1>&2
echo "msov:HINT: by running the OpenPKG utility \"$prefix/bin/winesetup\"" 1>&2
exit 1
fi
# setup Office Viewers in WINE installation
if [ ".$setup" = .yes ]; then
# preparation
if [ ".$quiet" = .no ]; then
echo "++ creating temporary location in WINE area"
fi
rm -rf $HOME/.wine/c_drive/msov >/dev/null 2>&1 || true
mkdir $HOME/.wine/c_drive/msov
# perform installations
for info in "$info_doc" "$info_xls" "$info_ppt"; do
prog=`echo $info | sed -e 's;:.*$;;'`
name=`echo $info | sed -e 's;^[^:]*:;;' -e 's;:.*$;;'`
path=`echo $info | sed -e 's;^[^:]*:[^:]*:;;'`
if [ ".$quiet" = .no ]; then
echo "++ installation of $name"
echo "-- copying setup executable \"$prog\" into WINE area"
fi
cp $prefix/share/wine-msov/$prog $HOME/.wine/c_drive/msov/
if [ ".$quiet" = .no ]; then
echo "++ running setup executable \"$prog\" with WINE"
echo " (PLEASE FOLLOW THE INTERACTIVE INSTALLATION MANUALLY"
echo " YES -> CONTINUE -> OK -> ACCEPT -> INSTALL -> OK)"
fi
$prefix/bin/wine "C:\\msov\\$prog" >/dev/null 2>&1 || true
done
# cleanup
if [ ".$quiet" = .no ]; then
echo "++ removing temporary location in WINE area"
fi
rm -rf $HOME/.wine/c_drive/msov >/dev/null 2>&1 || true
exit 0
fi
# view one ore more files
if [ $# -eq 0 ]; then
echo "msov:ERROR: no files specified for viewing" 1>&2
exit 1
fi
rc=0
for file in $*; do
# make sure file exists
if [ ! -f $file ]; then
echo "msov:ERROR: file \"$file\" not found" 1>&2
rc=1
continue
fi
# determine format
fmt="$format"
if [ ".$fmt" = . ]; then
fmt=`echo "$file" | sed -e 's;^.*\.\([^.]*\)$;\1;' | tr '[A-Z]' '[a-z]'`
fi
case "$fmt" in
[dD][oO][cC] | [xX][lL][sS] | [pP][pP][tT] )
;;
* )
echo "msov:ERROR: unknown format, please use --format=doc|xls|ppt" 1>&2
rc=1
continue
;;
esac
# determine viewer application path
eval "info=\$info_${fmt}"
if [ ".$info" = . ]; then
echo "msov:ERROR: unable to determine viewer application" 1>&2
rc=1
continue
fi
prog=`echo $info | sed -e 's;:.*$;;'`
name=`echo $info | sed -e 's;^[^:]*:;;' -e 's;:.*$;;'`
path=`echo $info | sed -e 's;^[^:]*:[^:]*:;;'`
if [ ! -f "$HOME/.wine/c_drive/$path" ]; then
echo "msov:ERROR: viewer \"$path\" not found" 1>&2
echo "msov:HINT: run \"msov --setup\" first" 1>&2
rc=1
continue
fi
path=`echo "$path" | sed -e 's;^;C:\\\\;' | sed -e 's;//*;\\\\;g'`
# determine path from WINE's point of view
# (simple file in current dir is automatically handled by WINE)
case "$file" in
/*/* )
file=`echo "$file" | sed -e 's;^;R:;' | sed -e 's;//*;\\\\;g'`
;;
*/* )
file="`pwd`/$file"
file=`echo "$file" | sed -e 's;^;R:;' | sed -e 's;//*;\\\\;g'`
;;
esac
# execute the viewer application
$prefix/bin/wine "$path" "$file" >/dev/null 2>&1
done
exit $rc