From ee736cda7e6e5ff820febb3ce4b66ad5fb71e32a Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 24 Nov 2006 10:34:51 +0000 Subject: [PATCH] Nach der Umstellung von Template.pm in r1330 werden neue Hilfsscripte benoetigt, um die Verbindung zum laufenden OpenOffice zu bedienen. Die Funktionalitaet von xvfb-run wird direkt von Template.pm uebernommen. Neue Einstellungen in lx-erp.conf fuer die daemonisierte OpenOffice-Variante. --- lx-erp.conf | 16 ++- scripts/oo-uno-convert-pdf.py | 69 ++++++++++++ scripts/oo-uno-test-conn.py | 32 ++++++ scripts/spawn_oo.pl | 41 +++++++ .../data/org/openoffice/Office/Linguistic.xcu | 100 +++++++++++++++++ xvfb-run | 102 ------------------ 6 files changed, 254 insertions(+), 106 deletions(-) create mode 100755 scripts/oo-uno-convert-pdf.py create mode 100755 scripts/oo-uno-test-conn.py create mode 100755 scripts/spawn_oo.pl delete mode 100755 xvfb-run diff --git a/lx-erp.conf b/lx-erp.conf index 1a91c1908..515daba96 100644 --- a/lx-erp.conf +++ b/lx-erp.conf @@ -53,10 +53,18 @@ $opendocument_templates = 1; # Pfad zu OpenOffice.org writer $openofficeorg_writer_bin = "/usr/bin/oowriter"; -# Pfad zu einem Script, dass einen "X virtual frame buffer" startet -# und OpenOffice unter ihm laufen laesst. Lx-Office bringt ein -# solches Script mit. -$xvfb_run_bin = getcwd() . "/xvfb-run"; +# Soll OpenOffice dauerhaft gestartet bleiben? Die Konvertierung nachfolgender +# Dokumente geht dann schneller. Allerdings wird auf dem System ein +# installiertes Python mit den Python-UNO-Bindings benoetigt, die Bestandteil +# von OpenOffice sind. +$openofficeorg_daemon = 1; +$openofficeorg_daemon_port = 2002; + +# Pfad zum "X virtual frame buffer", unter dem OpenOffice gestartet wird. +# Zusaetzlich muessen die Programme "xauth" und "mcookie" gefunden werden +# koennen, was eine Aenderung an PATH bedeuten kann. +$ENV{"PATH"} = $ENV{"PATH"} . ":/usr/X11R6/bin:/usr/X11/bin"; +$xvfb_bin = "/usr/bin/Xvfb"; # Das charset, in dem die Daten in der Datenbank abgelegt sind. $dbcharset = "ISO-8859-15"; diff --git a/scripts/oo-uno-convert-pdf.py b/scripts/oo-uno-convert-pdf.py new file mode 100755 index 000000000..5a2ab46c6 --- /dev/null +++ b/scripts/oo-uno-convert-pdf.py @@ -0,0 +1,69 @@ +#!/usr/bin/python + +import uno, sys + +from unohelper import Base, systemPathToFileUrl, absolutize +from os import getcwd +from os.path import splitext +from com.sun.star.beans import PropertyValue + +def establish_connection(port): + local_ctx = uno.getComponentContext() + local_smgr = local_ctx.ServiceManager + + resolver = local_smgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local_ctx) + ctx = resolver.resolve("uno:socket,host=localhost,port=%s;urp;StarOffice.ComponentContext" % port) + smgr = ctx.ServiceManager + + desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx) + + return desktop + +def load_file(desktop, path): + cwd = systemPathToFileUrl(getcwd()) + file_url = absolutize(cwd, systemPathToFileUrl(path)) + sys.stderr.write(file_url + "\n") + + in_props = ( + # PropertyValue("Hidden", 0 , True, 0), + ) + return desktop.loadComponentFromURL(file_url, "_blank", 0, in_props) + + +def write_pdf(doc, path): + out_props = ( + PropertyValue("FilterName", 0, "writer_pdf_Export", 0), + PropertyValue("Overwrite", 0, True, 0), + ) + + (dest, ext) = splitext(path) + dest = dest + ".pdf" + dest_url = absolutize(systemPathToFileUrl(getcwd()), systemPathToFileUrl(dest)) + sys.stderr.write(dest_url + "\n") + doc.storeToURL(dest_url, out_props) + doc.dispose() + +def main(): + if len(sys.argv) <= 2: + sys.exit(1) + + try: + desktop = establish_connection(sys.argv[1]) + except: + sys.exit(2) + + try: + doc = load_file(desktop, sys.argv[2]) + if not doc: + sys.exit(3) + except: + sys.exit(3) + + try: + write_pdf(doc, sys.argv[2]) + except: + sys.exit(4) + + sys.exit(0) + +main() diff --git a/scripts/oo-uno-test-conn.py b/scripts/oo-uno-test-conn.py new file mode 100755 index 000000000..183a290e2 --- /dev/null +++ b/scripts/oo-uno-test-conn.py @@ -0,0 +1,32 @@ +#!/usr/bin/python + +import uno, sys + +from unohelper import Base, systemPathToFileUrl, absolutize +from os import getcwd +from os.path import splitext +from com.sun.star.beans import PropertyValue + +def establish_connection(port): + local_ctx = uno.getComponentContext() + local_smgr = local_ctx.ServiceManager + + resolver = local_smgr.createInstanceWithContext("com.sun.star.bridge.UnoUrlResolver", local_ctx) + ctx = resolver.resolve("uno:socket,host=localhost,port=%s;urp;StarOffice.ComponentContext" % port) + smgr = ctx.ServiceManager + + desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx) + + return desktop + +def main(): + if len(sys.argv) <= 1: + sys.exit(1) + + try: + desktop = establish_connection(sys.argv[1]) + except: + sys.exit(2) + sys.exit(0) + +main() diff --git a/scripts/spawn_oo.pl b/scripts/spawn_oo.pl new file mode 100755 index 000000000..387961e2e --- /dev/null +++ b/scripts/spawn_oo.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl + +use DBI; +use Data::Dumper; + +use SL::LXDebug; + +use SL::Form; +use SL::Template; + +$userspath = "users"; +$templates = "templates"; +$memberfile = "users/members"; +$sendmail = "| /usr/sbin/sendmail -t"; + +$| = 1; + +$lxdebug = LXDebug->new(); + +require "lx-erp.conf"; + +$form = new Form; +$form->{"script"} = "oe.pl"; +$form->{"path"} = "bin/mozilla"; + + +$ENV{'HOME'} = getcwd() . "/$userspath"; + +my $template = OpenDocumentTemplate->new("", $form, \%myconfig, $userspath); + +if (@ARGV && ($ARGV[0] eq "-r")) { + system("ps auxww | " . + "grep -v awk | " . + "awk '/^www-data.*(soffice|Xvfb)/ { print \$2 }' | " . + "xargs -r kill"); + sleep(10); +} + +exit(1) unless ($template->spawn_xvfb()); +exit(2) unless ($template->spawn_openoffice()); +exit(0); diff --git a/users/.openoffice.org2/user/registry/data/org/openoffice/Office/Linguistic.xcu b/users/.openoffice.org2/user/registry/data/org/openoffice/Office/Linguistic.xcu index 2fd8654d2..0dc5b5bd6 100644 --- a/users/.openoffice.org2/user/registry/data/org/openoffice/Office/Linguistic.xcu +++ b/users/.openoffice.org2/user/registry/data/org/openoffice/Office/Linguistic.xcu @@ -5,4 +5,104 @@ en-US + + + -411764226 + + + + org.openoffice.lingu.LibHnjHyphenator + + + org.openoffice.lingu.LibHnjHyphenator + + + org.openoffice.lingu.LibHnjHyphenator + + + + + org.openoffice.lingu.LibHnjHyphenator + + + org.openoffice.lingu.LibHnjHyphenator + + + org.openoffice.lingu.LibHnjHyphenator + + + + + org.openoffice.lingu.MySpellSpellChecker + + + org.openoffice.lingu.MySpellSpellChecker + + + org.openoffice.lingu.MySpellSpellChecker + + + org.openoffice.lingu.MySpellSpellChecker + + + org.openoffice.lingu.MySpellSpellChecker + + + + + org.openoffice.lingu.new.Thesaurus + + + org.openoffice.lingu.new.Thesaurus + + + org.openoffice.lingu.new.Thesaurus + + + org.openoffice.lingu.new.Thesaurus + + + org.openoffice.lingu.new.Thesaurus + + + + + org.openoffice.lingu.MySpellSpellChecker + + + org.openoffice.lingu.MySpellSpellChecker + + + org.openoffice.lingu.MySpellSpellChecker + + + org.openoffice.lingu.MySpellSpellChecker + + + org.openoffice.lingu.MySpellSpellChecker + + + + + org.openoffice.lingu.new.Thesaurus + + + org.openoffice.lingu.new.Thesaurus + + + org.openoffice.lingu.new.Thesaurus + + + org.openoffice.lingu.new.Thesaurus + + + org.openoffice.lingu.new.Thesaurus + + + + + + true + + \ No newline at end of file diff --git a/xvfb-run b/xvfb-run deleted file mode 100755 index 7a4251c30..000000000 --- a/xvfb-run +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh - -# This script starts an instance of Xvfb, the "fake" X server, runs a command -# with that server available, and kills the X server when done. The return -# value of the command becomes the return value of this script. - -# This is a stripped-down version of the 'xvfb-run' script provided by -# Debian's 'xvfb' package which itself is licensed under the GPL, just as -# Lx-Office is. It is unclear who wrote the original script, but the -# CVS Id tag mentioned 'branden'. - -set -e - -PROGNAME=xvfb-run -SERVERNUM=99 -AUTHFILE= -ERRORFILE=/dev/null -STARTWAIT=3 -XVFBARGS="-screen 0 640x480x8" -LISTENTCP="-nolisten tcp" -XAUTHPROTO=. - -# Query the terminal to establish a default number of columns to use for -# displaying messages to the user. This is used only as a fallback in the event -# the COLUMNS variable is not set. ($COLUMNS can react to SIGWINCH while the -# script is running, and this cannot, only being calculated once.) -DEFCOLUMNS=$(stty size 2>/dev/null | awk '{print $2}') || true -if ! expr "$DEFCOLUMNS" : "[[:digit:]]\+$" >/dev/null 2>&1; then - DEFCOLUMNS=80 -fi - -# Display a message, wrapping lines at the terminal width. -message () { - echo "$PROGNAME: $*" | fmt -t -w ${COLUMNS:-$DEFCOLUMNS} -} - -# Display an error message. -error () { - message "error: $*" >&2 -} - -# Find a free server number by looking at .X*-lock files in /tmp. -find_free_servernum() { - # Sadly, the "local" keyword is not POSIX. Leave the next line commented in - # the hope Debian Policy eventually changes to allow it in /bin/sh scripts - # anyway. - #local i - - i=$SERVERNUM - while [ -f /tmp/.X$i-lock ]; do - i=$(($i + 1)) - done - echo $i -} - -SERVERNUM=$(find_free_servernum) - -PATH=$PATH:/usr/bin/x11:/usr/X11R6/bin - -if ! which xauth >/dev/null; then - error "xauth command not found" - exit 3 -fi - -# If the user did not specify an X authorization file to use, set up a temporary -# directory to house one. -XVFB_RUN_TMPDIR="${TMPDIR:-/tmp}/$PROGNAME.$$" -if ! mkdir -p -m 700 "$XVFB_RUN_TMPDIR"; then - error "temporary directory $XVFB_RUN_TMPDIR already exists" - exit 4 -fi -AUTHFILE=$(tempfile -n "$XVFB_RUN_TMPDIR/Xauthority") - -# Start Xvfb. -MCOOKIE=$(mcookie) -XAUTHORITY=$AUTHFILE xauth add ":$SERVERNUM" "$XAUTHPROTO" "$MCOOKIE" \ - >"$ERRORFILE" 2>&1 -XAUTHORITY=$AUTHFILE Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP >"$ERRORFILE" \ - 2>&1 & -XVFBPID=$! -sleep "$STARTWAIT" - -# Start the command and save its exit status. -set +e -DISPLAY=:$SERVERNUM XAUTHORITY=$AUTHFILE "$@" 2>&1 -RETVAL=$? -set -e - -# Kill Xvfb now that the command has exited. -kill $XVFBPID - -# Clean up. -XAUTHORITY=$AUTHFILE xauth remove ":$SERVERNUM" >"$ERRORFILE" 2>&1 -if [ -n "$XVFB_RUN_TMPDIR" ]; then - if ! rm -r "$XVFB_RUN_TMPDIR"; then - error "problem while cleaning up temporary directory" - exit 5 - fi -fi - -# Return the executed command's exit status. -exit $RETVAL -- 2.20.1