return solipa_ooo;
}
+/**
+ * solipa_ooo_python_init:
+ * @ooo:
+ *
+ */
+void
+solipa_ooo_python_init (SolipaOOO* ooo)
+{
+ SolipaOOOPrivate *priv = SOLIPA_OOO_GET_PRIVATE (ooo);
+
+ Py_Initialize ();
+ priv->m_main = PyImport_AddModule ("__main__");
+ priv->dict = PyModule_GetDict (priv->m_main);
+
+ PyRun_SimpleString (ENCODING);
+}
+
/**
* solipa_ooo_set_transient:
* @ooo:
gchar
*solipa_ooo_pycmd_header (SolipaOOO *ooo)
{
+ GString *str;
gchar *ret;
SolipaOOOPrivate *priv = SOLIPA_OOO_GET_PRIVATE (ooo);
- ret = g_strdup_printf (ENCODING "\n"
+ str = g_string_new ("");
+
+#ifdef G_OS_WIN32
+
+ gchar *ooo_path;
+
+ ooo_path = g_strjoinv ("\\\\", g_strsplit (priv->ooo_path, "\\", -1));
+ g_string_printf (str, "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)));
+
+ g_free (ooo_path);
+
+#endif
+
+ g_string_append_printf (str,
"import uno\n"
"import string\n"
"from com.sun.star.beans import PropertyValue\n"
"desktop = context.ServiceManager.createInstanceWithContext(\"com.sun.star.frame.Desktop\", context)\n",
priv->ooo_port);
+ ret = g_strdup (str->str);
+ g_string_free (str, TRUE);
+
return ret;
}
SolipaOOOPrivate *priv = SOLIPA_OOO_GET_PRIVATE (ooo);
- /* apro python */
- Py_Initialize ();
- priv->m_main = PyImport_AddModule ("__main__");
- priv->dict = PyModule_GetDict (priv->m_main);
-
- PyRun_SimpleString (ENCODING);
+ solipa_ooo_python_init (ooo);
#ifdef G_OS_WIN32