Grammalecte  Check-in [cec1932c20]

Overview
Comment:[lo] update helpers
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: cec1932c2090b31e385ffdb3af131104d1dc69484f5017e8362f8473132d755d
User & Date: olr on 2019-07-12 17:40:41
Other Links: manifest | tags
Context
2019-07-13
06:25
[lo] option to launch Python console at start check-in: 6a5d9d3cff user: olr tags: lo, trunk
2019-07-12
17:40
[lo] update helpers check-in: cec1932c20 user: olr tags: lo, trunk
15:03
[lo] launch Python console from About dialog check-in: 20cfc29a6c user: olr tags: lo, trunk
Changes

Modified gc_core/py/oxt/helpers.py from [fdf5448ff6] to [4f4ff311ba].

     9      9   from com.sun.star.beans import PropertyValue
    10     10   from com.sun.star.uno import RuntimeException as _rtex
    11     11   
    12     12   
    13     13   def start_console ():
    14     14       "open console from APSO extension"
    15     15       try:
    16         -        ctx = uno.getComponentContext()
    17         -        ctx.ServiceManager.createInstance("apso.python.script.organizer.impl")
           16  +        xContext = uno.getComponentContext()
           17  +        xContext.ServiceManager.createInstance("apso.python.script.organizer.impl")
    18     18           # now we can import apso_utils library
    19     19           from apso_utils import console
    20     20           console()
    21     21       except:
    22     22           try:
    23         -            ctx = uno.getComponentContext()
    24         -            xSvMgr = ctx.getServiceManager()
    25         -            xPathSettings = xSvMgr.createInstanceWithContext("com.sun.star.util.PathSettings", ctx)
           23  +            xContext = uno.getComponentContext()
           24  +            xSvMgr = xContext.getServiceManager()
           25  +            xPathSettings = xSvMgr.createInstanceWithContext("com.sun.star.util.PathSettings", xContext)
    26     26               spPyInstallion = uno.fileUrlToSystemPath(xPathSettings.Module)
    27     27               subprocess.Popen(spPyInstallion + os.sep + "python")  # Start Python interactive Shell
    28     28           except:
    29     29               traceback.print_exc()
    30     30   
    31     31   
    32     32   def xray (xObject):
    33     33       "XRay - API explorer"
    34     34       try:
    35         -        sm = uno.getComponentContext().ServiceManager
    36         -        mspf = sm.createInstanceWithContext("com.sun.star.script.provider.MasterScriptProviderFactory", uno.getComponentContext())
    37         -        scriptPro = mspf.createScriptProvider("")
    38         -        xScript = scriptPro.getScript("vnd.sun.star.script:XrayTool._Main.Xray?language=Basic&location=application")
           35  +        xSvMgr = uno.getComponentContext().ServiceManager
           36  +        xMSPF = xSvMgr.createInstanceWithContext("com.sun.star.script.provider.MasterScriptProviderFactory", uno.getComponentContext())
           37  +        xScriptProvider = xMSPF.createScriptProvider("")
           38  +        xScript = xScriptProvider.getScript("vnd.sun.star.script:XrayTool._Main.Xray?language=Basic&location=application")
    39     39           xScript.invoke((xObject,), (), ())
    40     40           return
    41     41       except:
    42     42           raise _rtex("\nBasic library Xray is not installed", uno.getComponentContext())
    43     43   
    44     44   
    45         -def mri (ctx, xTarget):
           45  +def mri (xObject):
    46     46       "MRI - API Explorer"
    47     47       try:
    48         -        xMri = ctx.ServiceManager.createInstanceWithContext("mytools.Mri", ctx)
    49         -        xMri.inspect(xTarget)
           48  +        xContext = uno.getComponentContext()
           49  +        xMri = xContext.ServiceManager.createInstanceWithContext("mytools.Mri", xContext)
           50  +        xMri.inspect(xObject)
    50     51       except:
    51     52           raise _rtex("\nPython extension MRI is not installed", uno.getComponentContext())
    52     53   
    53     54   
    54     55   def getConfigSetting (sNodeConfig, bUpdate=False):
    55     56       "get a configuration node"
    56     57       # example: xNode = getConfigSetting("/org.openoffice.Office.Common/Path/Current", False)
................................................................................
    69     70   def printServices (o):
    70     71       for s in o.getAvailableServiceNames():
    71     72           print(' > '+s)
    72     73   
    73     74   
    74     75   def getWindowSize ():
    75     76       "return main window size"
    76         -    xCurCtx = uno.getComponentContext()
    77         -    xDesktop = xCurCtx.getServiceManager().createInstanceWithContext('com.sun.star.frame.Desktop', xCurCtx)
           77  +    xContext = uno.getComponentContext()
           78  +    xDesktop = xContext.getServiceManager().createInstanceWithContext('com.sun.star.frame.Desktop', xContext)
    78     79       xContainerWindow = xDesktop.getCurrentComponent().CurrentController.Frame.ContainerWindow
    79     80       xWindowSize = xContainerWindow.convertSizeToLogic(xContainerWindow.Size, uno.getConstantByName("com.sun.star.util.MeasureUnit.POINT"))
    80     81       #print(xContainerWindow.Size.Width, ">", xWindowSize.Width)
    81     82       #print(xContainerWindow.Size.Height, ">", xWindowSize.Height)
    82     83       xWindowSize.Width = xWindowSize.Width * 0.666
    83     84       xWindowSize.Height = xWindowSize.Height * 0.666
    84     85       return xWindowSize