Table of contents
LibreOffice Help Index
- LibreOffice ヘルプ (help.libreoffice.org)
Macros
LibreOffice のスクリプトの割り当て
- 新しいメニュー項目にスクリプトを割り当てるには
- キーコンビネーションにスクリプトを割り当てるには
- イベントにスクリプトを割り当てるには
- 組み込みオブジェクトのイベントにスクリプトを割り当てるには
- ハイパーリンクにスクリプトを割り当てるには
- 図にスクリプトを割り当てるには
- フォームコントロールにスクリプトを割り当てるには
- LibreOffice Basic ダイアログのコントロールにスクリプトを割り当てるには
» https://help.libreoffice.org/latest/ja/text/shared/guide/scripting.html
LibreOffice Basic
- LibreOffice Basic Macros (help.libreoffice.org)
Calling Python Scripts from Basic
- Retrieving Python Scripts
- Executing Python Scripts
- Syntax
workstation_name = script.invoke(Array(), Array(), Array()) opSysName = script.invoke(Array(), in_outs, Array()) ' in_out is an Array file_len = script.invoke(Array(systemFilePath), Array(), Array()) normalizedPath = script.invoke(Array(systemFilePath), Array(), Array())
- Embedded Scripts Examples
- Personal or Shared Scripts Examples
- Python standard modules
» https://help.libreoffice.org/latest/ja/text/sbasic/guide/basic_2_python.html [EN]
Python
- LibreOffice Python Scripts Help (help.libreoffice.org)
Setting up an Integrated Development Environment (IDE) for Python
- The APSO Extension
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_ide.html [EN]
Python Scripts Organization and Location
- Python Script Locations
- LibreOffice Macros container
- My Macros
- Document macros
- Libraries, Modules and Macros
- Creating a Python Library
- Creating a Python Module
- Python macros
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_locations.html [EN]
Running Python Interactive Console
- Using a Basic macro:
- Using a Python macro:
- Usage:
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_shell.html [EN]
Programming with Python Scripts
- XSCRIPTCONTEXT Global Variable
- Module import
- More Python-Basic samples
- Importing an embeded Module
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_programming.html [EN]
Python programming examples
Getting Session Information
Examples:
With Python shell.
>>> from <the_module> import Session >>> print(Session.SharedPythonScripts()) # static method >>> print(Session().UserName) # object property >>> input(Session().UserProfile) # object property
- From Tools - Macros - Run Macro… menu.
- With LibreOffice Basic.
- Using Com/OLE and Visual Basic Scripting language.
- Python Session class:
- LibreOffice Basic Session class:
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_session.html [EN]
Identifying the operating system
- Using a Python class:
- Using a Basic classmodule:
Examples:
With Python
>>> from <the_module> import Platform >>> print(Platform().isMacOSX) # object property True >>> input(Platform().OSName) # object property Darwin
- From Tools - Macros - Run Macro… menu.
- With LibreOffice Basic
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_platform.html [EN]
Importing Python Modules
- File System module import
- User or Shared Modules
Installation Modules for Applications
With Python shell:
>>> import msgbox, uno >>> myBox = msgbox.MsgBox(uno.getComponentContext()) >>> myBox.addButton("okay") >>> myBox.renderFromButtonSize() >>> myBox.numberOflines = 2 >>> print(myBox.show("A small message",0,"Dialog title"))
- Document Module Import
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_import.html [EN]
Input/Output to Screen
Python syntax:
MsgBox(txt, buttons=0, title=None) InputBox(txt, title=None, default=None) Print(txt)
Examples:
>>> import screen_io as ui >>> reply = ui.InputBox('Please enter a phrase', title='Dear user', defaultValue="here..") >>> rc = ui.MsgBox(reply, title="Confirmation of phrase") >>> age = ui.InputBox('How old are you?', title="Hi") >>> ui.Print(age)
Installation:
- screen_io Python module
- uiScripts Basic module
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_screen.html [EN]
Monitoring Document Events
- Listening to Document Events
- With Python
- With LibreOffice Basic
- Discovering Documents Events
- With Python
- With LibreOffice Basic
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_document_events.html [EN]
Opening a Dialog with Python
- My Macros or LibreOffice Macros dialogs
Document embedded dialogs
# -*- coding: utf-8 -*- from __future__ import unicode_literals def docDialog(): """ Display a doc-based dialog """ model = XSCRIPTCONTEXT.getDocument() smgr = XSCRIPTCONTEXT.getComponentContext().ServiceManager dp = smgr.createInstanceWithArguments( "com.sun.star.awt.DialogProvider", (model,)) dlg = dp.createDialog( "vnd.sun.star.script:Standard.Dialog1?location=document") dlg.execute() dlg.dispose() g_exportedScripts = (docDialog,)
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_dialogs.html [EN]
Creating a Dialog Handler
- Assigning Dialog methods
- Creating the handler
- With Python
- With LibreOffice Basic
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_handler.html [EN]
Creating Event Listeners
- Creating an event listener
- With Python
- With LibreOffice Basic
- Other Event Listeners
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_listener.html [EN]
Calling Basic Macros from Python
- %PRODUCTNAME BASICスクリプトの取得
- Executing LibreOffice Basic Scripts
- Python Syntax
- Examples of Personal or Shared Scripts
- Examples of Embedded Scripts in Documents
» https://help.libreoffice.org/latest/ja/text/sbasic/python/python_2_basic.html [EN]
JavaScript / BeanShell
- Scripts (help.libreoffice.org)