2021-04-25

59: Put Basic Macros into a LibreOffice/OpenOffice Extension

<The previous article in this series | The table of contents of this series | The next article in this series>

In order to package them together with key bindings/menu items/tool buttons/UNO interfaces/UNO components/UNO services, and maybe to distribute it.

Topics


About: LibreOffice
About: Apache OpenOffice
About: LibreOffice Basic
About: Apache OpenOffice Basic

The table of contents of this article


Starting Context



Target Context


  • The reader will know how to put Basic macros into a LibreOffice or Apache OpenOffice extension.

Orientation


There is an article on creating any LibreOffice or Apache OpenOffice extension that contains any Python macros.

There is an article on registering key bindings for LibreOffice or Apache OpenOffice via an extension.

There is an article on registering menu items and tool buttons for LibreOffice or Apache OpenOffice via an extension.

There is an article on invoking any LibreOffice or Apache OpenOffice macro (including ones that are contained in extensions) from your program.

There is an article on some untold or incorrectly told basics of LibreOffice or Apache OpenOffice Basic.

There is an article on an attempt to structurize one's Basic code.

There is an article on creating LibreOffice or Apache OpenOffice Basic macros without the Basic IDE.


Main Body

Stage Direction
Here are Hypothesizer 7, Objector 59A, and Objector 59B in front of a computer.


1: The Motivation for Putting Some Macros into an Extension


Hypothesizer 7
You can put any macros into your LibreOffice or Apache OpenOffice extension.

Objector 59A
I know: I can do so via 'Tools' -> 'Macros' -> 'Organize Macros' -> 'Basic' -> 'Organize...' -> 'Libraries' -> select the library -> 'Export...'.

Hypothesizer 7
That is good, sir, but that GUI creates an extension of only Basic macros, does it not?

Objector 59A
So what?

Hypothesizer 7
The merit of extension is that it is a package of the related files of a functionality.

Objector 59A
What do you mean by "related files"?

Hypothesizer 7
Key bindings, menu items, tool buttons, UNO interfaces, UNO components, and UNO services, together with the macros.

Objector 59A
. . . That GUI doesn't show such options.

Hypothesizer 7
Here is how to create extensions.

Objector 59B
I don't need to distribute my macros at all!

Hypothesizer 7
Madam, even if so, it is beneficial to organize your code and being able to install and uninstall each package as a whole, I think.


2: What to Write in the Manifest


Hypothesizer 7
The basics of creating any extension is in a previous article.

In order to put any Basic library into the extension, you need to put a node into the manifest, like this.

manifest.xml

@XML Source Code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
	<manifest:file-entry manifest:media-type="application/vnd.sun.star.basic-library" manifest:full-path="basicLibraries/theBiasPlanet_testUnoExtension"/>
</manifest:manifest>

Objector 59B
. . . Where did the directory come from?

Hypothesizer 7
You have created the directory.

Objector 59B
I haven't.

Hypothesizer 7
You have to.

Objector 59B
How?

Hypothesizer 7
It is described in a previous article.

Objector 59B
Huh? Do I have to do it without the IDE?

Hypothesizer 7
Not necessarily; even if you use the IDE, the article will be beneficial for knowing where the library directory is.


References


<The previous article in this series | The table of contents of this series | The next article in this series>