File ooconvert of Package OpenOffice_org-converter
#! /bin/bash
# This script converts a document from one office format to another by
# connecting to an OpenOffice.org instance via Python-UNO bridge.
#
# Uses DocumentConverter.py from http://www.artofsolving.com/files/DocumentConverter.py
#
# Copyright (C) 1996-2008 SUSE Linux Products GmbH, Nuernberg, Germany.
#
# Author: Jan Holesovsky <kendy@suse.cz>, 2008
# Petr Mladek <kendy@suse.cz>, 2008
#
# Licensed under the GNU LGPL v2.1 - http://www.gnu.org/licenses/lgpl-2.1.html
# - or any later version.
document_converter_py=/usr/share/ooo3/basis-link/program/DocumentConverter.py
function usage()
{
cat << EOF
Converts the input file to the output file using OpenOffice.org.
Usage: ${0##*/} input output
EOF
}
if test -z "$1" -o "$1" = "--help" -o $# -gt 2 ; then
usage && exit 1;
fi
INPUT=$1
OUTPUT=$2
if test ! -f $INPUT ; then
echo "Error: INPUT file does not exist: $INPUT"
exit 1;
fi
# detect the OOo installation
ooo_home=
soffice=`which soffice 2>/dev/null`
if test -L $soffice ; then
soffice_path=`readlink $soffice`
ooo_home=`dirname $soffice_path`/..
fi
# try some fallbacks
if test -z "$ooo_home" ; then
for dir in /usr/lib64/ooo3 \
/usr/lib/ooo3 ; do
test -f "$dir/program/soffice" && ooo_home="$dir" && continue
done
fi
if test -z "$ooo_home" ; then
echo "Error: Unable to find OpenOffice.org instalation"
exit 1;
fi
# start the OOo
echo "Starting OpenOffice.org..."
RUNNING=`ps | grep soffice.bin | grep -v grep`
[ -z "$RUNNING" ] || { echo "OOo is running, please close it first" ; exit 1 ; }
$ooo_home/program/soffice -accept="socket,port=8100;urp;" -norestore -nofirststartwizard -nologo -headless &
sleep 10
# run the tests
echo "Doing the conversion..."
export PYTHONPATH="$ooo_home/basis-link/program"
python $document_converter_py $INPUT $OUTPUT
# kill the OOo
killall soffice.bin