How build Python Extention for OpenOffice Writer

Creating a macro - Writing a Script - Using the API

How build Python Extention for OpenOffice Writer

Postby karpo518 » Wed Jun 21, 2017 4:04 pm

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)
karpo518
 
Posts: 15
Joined: Wed May 24, 2017 4:17 pm

Re: How build Python Extention for OpenOffice Writer

Postby Villeroy » Wed Jun 21, 2017 7:36 pm

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 32 times
Script_Installer.ott
ScriptInstaler.ott to install JavaScript and Python macros
(15.01 KiB) Downloaded 33 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24659
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How build Python Extention for OpenOffice Writer

Postby karpo518 » Thu Jun 22, 2017 3:35 pm

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)
karpo518
 
Posts: 15
Joined: Wed May 24, 2017 4:17 pm

Re: How build Python Extention for OpenOffice Writer

Postby Villeroy » Thu Jun 22, 2017 4:00 pm

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 16.04, OpenOffice 4.x & LibreOffice 5.x
User avatar
Villeroy
Volunteer
 
Posts: 24659
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How build Python Extention for OpenOffice Writer

Postby nostarch » Tue Jul 18, 2017 7:54 pm

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
nostarch
 
Posts: 1
Joined: Tue Jul 18, 2017 7:43 pm

Re: How build Python Extention for OpenOffice Writer

Postby karpo518 » Wed Jul 19, 2017 9:59 am

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   Expand viewCollapse view
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)
karpo518
 
Posts: 15
Joined: Wed May 24, 2017 4:17 pm

Re: How build Python Extention for OpenOffice Writer

Postby LibreOfficiant » Tue Aug 01, 2017 2:21 pm

libO 5.3 x32 / Win7 x64 and Win10 x64 | libO 5.2 / Ubuntu 16.10 Yakkety Yak x64 | aOOo 4.2.6.3 / Mint 17.1 x64
Python toolbox: StarUML, Geany, PyCharm and Apso, MRI, xRay, Object Inspector..
https://wiki.documentfoundation.org/Macros/Design_Guide/fr
LibreOfficiant
 
Posts: 3
Joined: Wed Jan 25, 2017 9:36 pm


Return to Macros and UNO API

Who is online

Users browsing this forum: tiendatanduin and 4 guests