LibreOffice SymbolLibreOffice Symbol

Please support us!

officehelper module

ይህን ትእዛዝ ለ መፈጸም...

Open Tools - Macros - LibreOfficeDev Basic - Edit and select Application Macros container.


officehelper module starts a LibreOfficeDev process opening a named pipe of random name. officehelper binds IDE-based Python scripts to a running LibreOfficeDev instance for debugging purpose.

Methods

List of Methods in officehelper module

bootstrap

SessionManager


bootstrap

Opens a named pipe of random name, uses the local context to access the pipe. Returns the remote component context, from whereon you can get the ServiceManager by calling getServiceManager() on the returned object.

የ ምክር ምልክት

SessionManager is a preferred alternative to bootstrap method.


አገባብ:

bootstrap(soffice: str, delays=(1,3,5,7), report: str): uno

ደንቦች:

soffice: A specific binary copy of LibreOfficeDev, such as a portable or a development version.

delays: Specifies multiple connection attempts. Default is to sleep 1, 3, 5 and 7 seconds between retries.

report: Optional method name used to report or log connection failures.

ለምሳሌ:


      # Start LO as a service, get its remote component context
      import officehelper
      ctx = officehelper.bootstrap()
      # your code goes here
      
      # request context multiples times and report processing in console
      import officehelper as oh
      ctx = oh.bootstrap(delays=(5,10,15,20),report=print)
      # your code goes here
      
      # Use a specific binary version
      from officehelper import bootstrap
      ctx = bootstrap(soffice=r"USB:\\PortableApps\\libO-7.6\\App\libreoffice\\program\\soffice.exe")
      # your code goes here
    

Such randomized named pipes require to be released from memory as shown:


      # named pipe memory cleanup
      smgr = ctx.getServiceManager()
      desktop = smgr.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
      desktop.terminate()
    

SessionManager class

Opens a named pipe of random name, uses the local context to access the pipe. Returns the remote component context, from whereon you can get the ServiceManager by calling getServiceManager() on the returned object. In addition SessionManager releases memory from the randomly named LibreOfficeDev process and reports connection attempts to the console.

አገባብ:

SessionManager(soffice: str, delays=(1,3,5,7)): uno

ደንቦች:

ለምሳሌ:

soffice: A specific binary copy of LibreOfficeDev, such as a portable or a development version.

delays: Specifies multiple connection attempts. Default is to sleep 1, 3, 5 and 7 seconds between retries.


      def my_script():
          # user code goes here
      
      g_exportedScripts = (my_script,)  # LibreOffice entry points
      
      if __name__ == "__main__":  # entry point for IDEs
          from officehelper import SessionManager
          with SessionManager() as ctx:  # remote Python context
              my_script()
    
የ ምክር ምልክት

Use scriptforge.ScriptForge() method to bind IDE-based Python scripts to a LibreOfficeDev permanent service started with the command line.