#! /bin/bash

test -f /tmp/.libreoffice-debug && {
	exec >/tmp/$(basename $0).log 2>&1
	set -x
	echo $*
}

case $(basename $0) in
	soffice*)
		filearg="$1"
		;;
	libreoffice*)
		filearg="$2"
		;;
esac    

# wenn OpenOffice schon läuft, muß Pfad nach UTF-8 konvertiert werden.
if test "$(ps h -C soffice.bin -o user)" == $USER ; then
	f=$(echo "$filearg" | recode iso8859-1..utf-8)
	test $? -eq 0 && filearg="$f"
fi

case $(basename $0) in
	soffice*)
		soffice "$filearg"
		;;
	libreoffice*)
		libreoffice "$1" "$filearg"
		;;
esac    
