How build Python Extention for OpenOffice Writer

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
karpo518
Posts: 15
Joined: Wed May 24, 2017 4:17 pm

How build Python Extention for OpenOffice Writer

Post by karpo518 »

I used "Basic Addon Builder" for basic macros. How i can to pack python macros?
Libre Office 5.1.6.2, Linux Mint 18 (64 bit)
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How build Python Extention for OpenOffice Writer

Post by Villeroy »

Well, in most cases a JavaScript/Python macro is just a plain text file (module) saved in some subdirectory of the user profile.
An extension may include some macro code but macros are not the same as an extension. Instead of wasting my time with this horrible extension framework, I wrote a very simple script installer. It is a Writer template with a user-defined variable, a modified "Default" paragraph style, a frame with a button and a Basic macro.
Just replace the placeholder field with your code and adjust the user-defined variable "ScriptPath" by double-clicking the field in the text frame.

P.S. The extension compiler can compile extensions with all kinds of scripts. I hate that framework so much that I did not even spend any time with that helpful tool.
Attachments
AutoRefresh.py.odt
ScriptInstaler.ott with example code and script path
(18.2 KiB) Downloaded 239 times
Script_Installer.ott
ScriptInstaler.ott to install JavaScript and Python macros
(15.01 KiB) Downloaded 245 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
karpo518
Posts: 15
Joined: Wed May 24, 2017 4:17 pm

Re: How build Python Extention for OpenOffice Writer

Post by karpo518 »

My macro is a single file, but i need addition functions of extention.

i need:
1. set version and description
2. set custom icon in top panel for running macros
3. set update URL

Can anyone share a compilation code template for my case(or any example code)? I mean basic code for extension compiler.
Libre Office 5.1.6.2, Linux Mint 18 (64 bit)
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How build Python Extention for OpenOffice Writer

Post by Villeroy »

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
nostarch
Posts: 1
Joined: Tue Jul 18, 2017 7:43 pm

Re: How build Python Extention for OpenOffice Writer

Post by nostarch »

Hi. I've just registered for this board because we need some help automating our workflow from OpenOffice to Adobe InDesign. I can't PM so I'm dropping this message off here.

I'm trying to find someone to hire to automate, for example, the import of automated cross references from OOo to InDesign. Villeroy, I see that you often post about technical topics and I wonder whether this is the sort of thing you might be interested in.

You can reach me directly at bill-at-nostarch-dot-com

Thank you,

Bill Pollock, No Starch Press
OpenOffice 4.1.x on Ubuntu
karpo518
Posts: 15
Joined: Wed May 24, 2017 4:17 pm

Re: How build Python Extention for OpenOffice Writer

Post by karpo518 »

Problem does not solved. I got error, when i run macros for compilation. http://joxi.ru/J2bNx90IXWkN42. What is that means?

Code:

Code: Select all

REM  *****  BASIC  *****

Option Explicit

Sub exampleDescription
  beginDescription("PlainToHTMLNew", "1.0.0")
    setExtensionDescription("en")
    setPublisherName("en", "Alexey Tyapkin", "http://www.oooyes.com")
    setDisplayName("en", "PlainToHTMLNewDisplayName")
    beginUpdateInformation("direct", "direct") 
  	setUpdateSource("http://otp.tw1.ru/PlainToHTML2/", "http://otp.tw1.ru/PlainToHTML2/") ' first choice
    endUpdateInformation
  endDescription  

  beginAddonUI
    beginAddonMenu
      beginCommand
        beginTitles("Writer")
          setTitle("This is an apple", "en")
        endTitles
         setURL("Python", "PlainToText2.py", "PlainToHtml")
        setImage("icon.png")
      endCommand
    endAddonMenu
  endAddonUI

End Sub
Libre Office 5.1.6.2, Linux Mint 18 (64 bit)
User avatar
LibreOfficiant
Posts: 12
Joined: Wed Jan 25, 2017 9:36 pm

Re: How build Python Extention for OpenOffice Writer

Post by LibreOfficiant »

libO 5.4 64bit, (PortableApps: libO 6.0, aOO 4.1, OOo 3.2 32bit) on Win7/Win10 x64 | aOO 4.1.x & libO 5.4.x on Mint 18 Sarah & OSX 10.9 Mavericks x64
Python toolbox: Geany, PyCharm and APSO, MRI extensions..
https://wiki.documentfoundation.org/Macros/Design_Guide
Post Reply