Podpořte nás!

officehelper module

Pro přístup k tomuto příkazu...

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

Otevře pojmenovanou rouru náhodného jména, k přístupu k rouře použije místní kontext. Vrátí kontext vzdálené součásti, odkud můžete získat ServiceManager voláním getServiceManager() na vrácený objekt.

Ikona tipu

SessionManager je doporučená alternativa k metodě bootstrap.


Syntaxe:

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

Parametry:

soffice: Konkrétní binární kopie LibreOfficeDev, například přenosná nebo vývojová verze.

delays: Určuje více pokusů o připojení. Výchozí nastavení je uspání na 1, 3, 5 a 7 sekund mezi pokusy.

report: Volitelný název metody používaný k hlášení nebo protokolování selhání připojení.

Příklad:


      # Spuštění LO jako služby a získání kontextu její vzdálené komponenty
      import officehelper
      ctx = officehelper.bootstrap()
      # váš kód patří sem
      # request context multiples times and report processing in console
      import officehelper as oh
      ctx = oh.bootstrap(delays=(5,10,15,20),report=print)
      # váš kód patří sem
      # Použijte konkrétní binární verzi
      from officehelper import bootstrap
      ctx = bootstrap(soffice=r"USB:\\PortableApps\\libO-7.6\\App\libreoffice\\program\\soffice.exe")
      # váš kód patří sem
    

Takové náhodně uspořádané pojmenované kanály je třeba uvolnit z paměti, jak je znázorněno:


      # 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.

Syntaxe:

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

Parametry:

Příklad:

soffice: Konkrétní binární kopie LibreOfficeDev, například přenosná nebo vývojová verze.

delays: Určuje více pokusů o připojení. Výchozí nastavení je uspání na 1, 3, 5 a 7 sekund mezi pokusy.


      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()
    
Ikona tipu

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