Index: gc_lang/fr/oxt/helpers.py ================================================================== --- gc_lang/fr/oxt/helpers.py +++ gc_lang/fr/oxt/helpers.py @@ -1,16 +1,18 @@ -# -*- coding: utf8 -*- +# Helpers for LibreOffice extension -import uno +import os import traceback -from com.sun.star.beans import PropertyValue +import uno - -# XRay - API explorer +from com.sun.star.beans import PropertyValue from com.sun.star.uno import RuntimeException as _rtex + + def xray (myObject): + "XRay - API explorer" try: sm = uno.getComponentContext().ServiceManager mspf = sm.createInstanceWithContext("com.sun.star.script.provider.MasterScriptProviderFactory", uno.getComponentContext()) scriptPro = mspf.createScriptProvider("") xScript = scriptPro.getScript("vnd.sun.star.script:XrayTool._Main.Xray?language=Basic&location=application") @@ -18,17 +20,17 @@ return except: raise _rtex("\nBasic library Xray is not installed", uno.getComponentContext()) -# MRI - API Explorer def mri (ctx, xTarget): + "MRI - API Explorer" try: xMri = ctx.ServiceManager.createInstanceWithContext("mytools.Mri", ctx) xMri.inspect(xTarget) except: - raise _rtex("\Python extension MRI is not installed", uno.getComponentContext()) + raise _rtex("\nPython extension MRI is not installed", uno.getComponentContext()) def getConfigSetting (sNodeConfig, bUpdate): "get a configuration node" # example: xNode = getConfigSetting("/org.openoffice.Office.Common/Path/Current", False) @@ -58,5 +60,15 @@ #print(xContainerWindow.Size.Width, ">", xWindowSize.Width) #print(xContainerWindow.Size.Height, ">", xWindowSize.Height) xWindowSize.Width = xWindowSize.Width * 0.666 xWindowSize.Height = xWindowSize.Height * 0.666 return xWindowSize + + +def getAbsolutePathOf (sPath=""): + xDefaultContext = uno.getComponentContext().ServiceManager.DefaultContext + xPackageInfoProvider = xDefaultContext.getValueByName("/singletons/com.sun.star.deployment.PackageInformationProvider") + sFullPath = xPackageInfoProvider.getPackageLocation("French.linguistic.resources.from.Dicollecte.by.OlivierR") + if sPath and not sPath.startswith("/"): + sPath = "/" + sPath + sFullPath = sFullPath[8:] + sPath + return os.path.abspath(sFullPath)