From: Andrea Zagli Date: Mon, 2 Jul 2018 14:30:35 +0000 (+0200) Subject: Aggiunta funzione OOO::get_cmd_apri_openoffice. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=1adb5afcd1ed8efbe2f64531d61d7aa338786a7c;p=solipa%2Flibsolipa Aggiunta funzione OOO::get_cmd_apri_openoffice. --- diff --git a/src/ooo.c b/src/ooo.c index 3a1a153..8c1a8c6 100644 --- a/src/ooo.c +++ b/src/ooo.c @@ -314,6 +314,55 @@ gchar return g_strdup (priv->ooo_version); } +/** + * solipa_ooo_get_cmd_apri_openoffice: + * @ooo: + */ +gchar +*solipa_ooo_get_cmd_apri_openoffice (SolipaOOO *ooo) +{ + gchar *dash; + gchar *command; + + SolipaOOOPrivate *priv = SOLIPA_OOO_GET_PRIVATE (ooo); + + if (g_strcmp0 (priv->ooo_version, "") == 0 + || zak_utils_compare_version (priv->ooo_version, "3.0.0", NULL, NULL) > 0) + { + dash = g_strdup ("-"); + } + else + { + dash = g_strdup (""); + } + +#ifdef G_OS_WIN32 + + command = g_strdup_printf ("\"%s %s-accept=\"socket,host=localhost,port=%d;urp;\" %s-norestore %s%s\"", + priv->ooo_soffice, + dash, + priv->ooo_port, + dash, + dash, + priv->visible ? "-invisible" : "-headless"); + +#else + + command = g_strdup_printf ("\"%s\" %s-accept=\"socket,host=localhost,port=%d;urp;\" %s-norestore %s%s", + priv->ooo_soffice, + dash, + priv->ooo_port, + dash, + dash, + priv->visible ? "-invisible" : "-headless"); + +#endif + + g_free (dash); + + return command; +} + /** * solipa_ooo_exec: * @ooo: @@ -550,6 +599,8 @@ solipa_ooo_pycmd_apri_openoffice (SolipaOOO *ooo) { GtkWidget *dialog; + gchar *command; + FILE *pipa; gboolean in_esecuzione; @@ -640,51 +691,11 @@ solipa_ooo_pycmd_apri_openoffice (SolipaOOO *ooo) } /* apro openoffice in ascolto */ - gchar *dash; - gchar *command; - guint part; - - if (g_strcmp0 (priv->ooo_version, "") == 0 - || zak_utils_compare_version (priv->ooo_version, "3.0.0", NULL, &part) > 0) - { - dash = g_strdup ("-"); - } - else - { - dash = g_strdup (""); - } - -#ifdef G_OS_WIN32 - - command = g_strconcat ("\"", - priv->ooo_soffice, - g_strdup_printf (" %s-accept=\"socket,host=localhost,port=%d;urp;\" %s-norestore %s%s\"", - dash, - priv->ooo_port, - dash, - dash, - priv->visible ? "-invisible" : "-headless"), - NULL); - -#else - - command = g_strconcat ("\"", - priv->ooo_soffice, - g_strdup_printf ("\" %s-accept=\"socket,host=localhost,port=%d;urp;\" %s-norestore %s%s", - dash, - priv->ooo_port, - dash, - dash, - priv->visible ? "-invisible" : "-headless"), - NULL); - -#endif + command = solipa_ooo_get_cmd_apri_openoffice (ooo); pipa = popen (command, "r"); g_free (command); - g_free (dash); - g_string_append_printf (str, "context = resolver.resolve(\"uno:socket,host=localhost,port=%d;urp;StarOffice.ComponentContext\")\n" "desktop = context.ServiceManager.createInstanceWithContext(\"com.sun.star.frame.Desktop\", context)\n", @@ -717,8 +728,6 @@ solipa_ooo_apri_openoffice (SolipaOOO *ooo) gboolean in_esecuzione; gchar *ooo_path; - gchar *dash; - guint part; gchar *command; guint timeout; @@ -827,31 +836,13 @@ solipa_ooo_apri_openoffice (SolipaOOO *ooo) solipa_ooo_chiudi_openoffice (ooo); } - if (g_strcmp0 (priv->ooo_version, "") == 0 - || zak_utils_compare_version (priv->ooo_version, "3.0.0", NULL, &part) > 0) - { - dash = g_strdup ("-"); - } - else - { - dash = g_strdup (""); - } - /* apro openoffice in ascolto */ #ifdef G_OS_WIN32 gchar *curdir = g_get_current_dir (); chdir (g_build_filename (priv->ooo_path, "program", NULL)); - command = g_strconcat ("\"", - priv->ooo_soffice, - g_strdup_printf (" %s-accept=\"socket,host=localhost,port=%d;urp;\" %s-norestore %s%s\"", - dash, - priv->ooo_port, - dash, - dash, - priv->visible ? "-invisible" : "-headless"), - NULL); + command = solipa_ooo_get_cmd_apri_openoffice (ooo); pipa = popen (command, "r"); @@ -860,15 +851,7 @@ solipa_ooo_apri_openoffice (SolipaOOO *ooo) #else - command = g_strconcat ("\"", - priv->ooo_soffice, - g_strdup_printf ("\" %s-accept=\"socket,host=localhost,port=%d;urp;\" %s-norestore %s%s", - dash, - priv->ooo_port, - dash, - dash, - priv->visible ? "-invisible" : "-headless"), - NULL); + command = solipa_ooo_get_cmd_apri_openoffice (ooo); if (!g_spawn_command_line_async (command, NULL)) { g_warning ("Unable to run soffice"); @@ -877,7 +860,6 @@ solipa_ooo_apri_openoffice (SolipaOOO *ooo) #endif g_free (command); - g_free (dash); if (priv->transient != NULL && GTK_IS_WINDOW (priv->transient)) diff --git a/src/ooo.h b/src/ooo.h index 60be2c2..8f08de1 100644 --- a/src/ooo.h +++ b/src/ooo.h @@ -72,6 +72,8 @@ guint solipa_ooo_get_port (SolipaOOO *ooo); void solipa_ooo_set_version (SolipaOOO *ooo, const gchar *version); gchar *solipa_ooo_get_version (SolipaOOO *ooo); +gchar *solipa_ooo_get_cmd_apri_openoffice (SolipaOOO *ooo); + void solipa_ooo_exec (SolipaOOO *ooo, const gchar *statement); gchar *solipa_ooo_pycmd_header (SolipaOOO *ooo);