From 9d3ac186501c299a627c1338b5e27e0b18f1ea01 Mon Sep 17 00:00:00 2001 From: LibreOfficiant Date: Sat, 26 Jan 2019 10:19:29 +0100 Subject: Improper Python code requiring update Change-Id: Ia59f0e5d67718771152cca49704173701bf1f0f8 Reviewed-on: https://gerrit.libreoffice.org/66957 Tested-by: Jenkins Reviewed-by: Olivier Hallot --- source/text/sbasic/python/python_programming.xhp | 37 +++++++++++++++--------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'source') diff --git a/source/text/sbasic/python/python_programming.xhp b/source/text/sbasic/python/python_programming.xhp index 46d9d90c19..a513c684c7 100644 --- a/source/text/sbasic/python/python_programming.xhp +++ b/source/text/sbasic/python/python_programming.xhp @@ -192,7 +192,7 @@ - ctx = ..getComponentContext() + ctx = uno.getComponentContext() smgr = ctx.getServiceManager() obj = smgr.createInstanceWithContext( .. , ctx) @@ -200,15 +200,6 @@ CreateUnoService() - - - ctx = ..getComponentContext() - smgr = ctx.getServiceManager() - - - GetProcessServiceManager() - - See Creating a Dialog @@ -241,6 +232,15 @@ EqualUnoObjects() + + + ctx = uno.getComponentContext() + smgr = ctx.getServiceManager() + + + GetProcessServiceManager() + + @@ -255,6 +255,17 @@ IsUnoStruct() + + + ctx = uno.getComponentContext() + smgr = ctx.getServiceManager() + DESK = 'com.sun.star.frame.Desktop' + obj = smgr.createInstanceWithContext(DESK , ctx) + + + StarDesktop + +

Importing an embedded Module

@@ -269,10 +280,10 @@ Adapted from 'Bibliothèque de fonctions' by Hubert Lambert at https://forum.openoffice.org/fr/forum/viewtopic.php?p=286213""" doc = XSCRIPTCONTEXT.getDocument() # current document - url = uno.fileUrlToSystemPath('{}/{}/{}', \ - format(doc.URL, 'Scripts/python', library_name) # ConvertToURL() + url = uno.fileUrlToSystemPath( \ + '{}/{}'.format(doc.URL, 'Scripts/python'+library_name)) # ConvertToURL() if not url in sys.path: # add path if necessary - sys.path.insert(0, url) # doc takes precedence + sys.path.insert(0, url) # doclib takes precedence if module_name: # import if requested return zipimport.zipimporter(url).load_module(module_name) -- cgit