From 7fa6e82b78b8100e93be43bbc5c7b87e7a33f1a4 Mon Sep 17 00:00:00 2001 From: Andrea Zagli Date: Sat, 23 Jul 2011 09:41:19 +0200 Subject: [PATCH] Aggiunta la funzione SolipaOOO::salva_documento_pdf. --- src/ooo.c | 54 +++++++++++++++++++++++++++++++++++++++-------------- src/ooo.h | 3 +++ tests/ooo.c | 6 +++++- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/ooo.c b/src/ooo.c index 5a9987d..30291cd 100644 --- a/src/ooo.c +++ b/src/ooo.c @@ -285,25 +285,25 @@ solipa_ooo_apri_openoffice (SolipaOOO *ooo) #ifdef G_OS_WIN32 ooo_path = g_strjoinv ("\\\\", g_strsplit (priv->ooo_path, "\\", -1)); - PyRun_SimpleString (g_strdup_printf ( - "import os\n" - "import sys\n" - "os.environ['PATH'] = os.getenv('PATH') + ';%s\\\\URE\\\\bin'\n" - "os.environ['PYTHONPATH'] = '%s\\\\Basis\\\\Program'\n" - "sys.path.append('%s\\\\Basis\\\\Program')\n" - "os.environ['URE_BOOTSTRAP'] = 'file:///%s/program/fundamental.ini'\n", - ooo_path, - ooo_path, - ooo_path, - g_strjoinv ("%20", g_strsplit (g_strjoinv ("/", g_strsplit (priv->ooo_path, "\\", -1)), " ", -1))) + PyRun_SimpleString (g_strdup_printf ("import os\n" + "import sys\n" + "os.environ['PATH'] = os.getenv('PATH') + ';%s\\\\URE\\\\bin'\n" + "os.environ['PYTHONPATH'] = '%s\\\\Basis\\\\Program'\n" + "sys.path.append('%s\\\\Basis\\\\Program')\n" + "os.environ['URE_BOOTSTRAP'] = 'file:///%s/program/fundamental.ini'\n", + ooo_path, + ooo_path, + ooo_path, + g_strjoinv ("%20", g_strsplit (g_strjoinv ("/", g_strsplit (priv->ooo_path, "\\", -1)), " ", -1))) ); #endif PyRun_SimpleString ("import uno\n" - "import string\n" - "local = uno.getComponentContext()\n" - "resolver = local.ServiceManager.createInstanceWithContext(\"com.sun.star.bridge.UnoUrlResolver\", local)\n" + "import string\n" + "from com.sun.star.beans import PropertyValue\n" + "local = uno.getComponentContext()\n" + "resolver = local.ServiceManager.createInstanceWithContext(\"com.sun.star.bridge.UnoUrlResolver\", local)\n" ); /* controllo se OpenOffice è già in ascolto */ @@ -467,3 +467,29 @@ solipa_ooo_salva_documento (SolipaOOO *ooo, return TRUE; } +gboolean +solipa_ooo_salva_documento_pdf (SolipaOOO *ooo, + const gchar *filename) +{ + PyObject *obj; + + gchar *_filename; + + SolipaOOOPrivate *priv = SOLIPA_OOO_GET_PRIVATE (ooo); + + _filename = NULL; + if (filename != NULL) + { + _filename = g_strdup (filename); + g_strstrip (_filename); + } + + g_return_val_if_fail (_filename != NULL && g_strcmp0 (_filename, "") != 0, FALSE); + + PyRun_SimpleString ("property = (PropertyValue (\"FilterName\", 0, \"writer_pdf_Export\", 0), )\n"); + PyRun_SimpleString (g_strdup_printf ("document.storeToURL(\"file://%s\", property)\n", _filename)); + + /* TODO capire se il documento è stato salvato o meno */ + + return TRUE; +} diff --git a/src/ooo.h b/src/ooo.h index 6755595..f42f359 100644 --- a/src/ooo.h +++ b/src/ooo.h @@ -72,6 +72,9 @@ void solipa_ooo_string_replace (SolipaOOO *ooo, gboolean solipa_ooo_salva_documento (SolipaOOO *ooo, const gchar *filename); +gboolean solipa_ooo_salva_documento_pdf (SolipaOOO *ooo, + const gchar *filename); + G_END_DECLS diff --git a/tests/ooo.c b/tests/ooo.c index 45921cc..92447cd 100644 --- a/tests/ooo.c +++ b/tests/ooo.c @@ -57,10 +57,14 @@ main (int argc, char *argv[]) solipa_ooo_string_replace (ooo, "{prg::replace}", "\"blah blah blah\""); - if (argc == 3) + if (argc >= 3) { solipa_ooo_salva_documento (ooo, argv[2]); } + if (argc >= 4) + { + solipa_ooo_salva_documento_pdf (ooo, argv[3]); + } gtk_main (); -- 2.49.0