]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Aggiunta la funzione SolipaOOO::salva_documento_pdf. ooo
authorAndrea Zagli <azagli@libero.it>
Sat, 23 Jul 2011 07:41:19 +0000 (09:41 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 23 Jul 2011 07:41:19 +0000 (09:41 +0200)
src/ooo.c
src/ooo.h
tests/ooo.c

index 5a9987db8baf3f4abb02b9b3b24265079864bc7b..30291cd01f5d0ef44ee856fe4b98bcfc5a6acd56 100644 (file)
--- 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;
+}
index 6755595b08eea2a801736a898ade316e68f04dd4..f42f35931df0393594d2335b3b5c65ad6052a474 100644 (file)
--- 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
 
index 45921cc70fb64a40a950785c3e14e0fc034317a5..92447cdc4f9c46f39005e9dcf525f7151b89babb 100644 (file)
@@ -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 ();