Macros
for Open Office 2.x
by J.
de Rosny
1. Introduction
2. Warning
3. First library: Save
Selection as Pdf
4. Second library:
Modify
formula style in a write document
5. Third
library: inverse the order of points in a polygon or
bezier curve
6. How to
install the library with Open Office 2.x
7. How to run
a
macro with Open Office 2.x
8. Send me
message
Introduction
A few years ago, I wrote my PhD
thesis with StarOffice, the Open Office ancestor. At that time, I wrote
my first startbasic macros for this software. Since then I often use
Open Office
for different purposes and still write some macros for OOo. In this web
site, I propose three libraries that I developed. I hope you will find
them useful.
These libraries have been tested only on Windows XP and OOo 2.0. They
are likely to work on
other systems. Please feel free to give me some feedback
(good or not!).
WARNING
BECAUSE
THE LIBRARY ARE LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE
LIBRARY. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE
COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
First
library: Save Selection as Pdf
This library supplies
one
deficiency of OOo: When you export a selection in pdf file, the
selected
part is saved in a full-size page. Here the selected part is saved in a
document with dimensions that fit the selection.This library may work
on OOo 1.5.
Description of the library macros :
-
“save_selection_as_pdf” macro
This macro saves the selected part of a draw document in a pdf file
with dimensions fitting the
size of the selected object. It is very useful to create pdflatex
figures.
First, select the drawing part to save. Second, run the macro
"save_selection_as_pdf". Then choose the pdf file quality (see dialog
bellow). Due to the macro implementation, the selection is
automatically copied in the OOo clipboard when the macro is launched.
(quality pdf file dialog)
Then a "Save As" dialog appears. The macro works with draw and impress
documents.
- “version”
macro
return the version of the macro.
How does the macro work?
This macro
copies in the clipboard the selected part of the draw document, then it
creates a hidden document where the clipboard is pasted. The size of
the document is automatically sets to the maximal size of the selected
part. Then the classical "save as" pdf file procedure is called and the
hidden document destroyed.
Download
the last version of the
library (SaveSelectionAsPdf.zip)
(For Internet explorer, click right
button on the download link, and select save target as ...)
How to install the library?
How to run the macros?
Any
comment?
Second
library: Modify formula style in a write document
The formula editor of Open Office is
very convenient. However one major drawback is the default text
margins. The formula is inserted in a paragraph with a lot of space
before and after. These macros let you choose the space that you want
around the formula. This macro does not work on OOo 1.5.
Description of the
macros of the library :
- «
select_dialog_parameters
» macro
This macro opens the dialog:

(formurla parameter
dialog)
You can set the
left and right margins and the font size of the formula. There are two
kinds of margins. The margins inside and outside the formula. The
formula margins should be larger than 0. Otherwise, the left and right
sides of the formula are not displayed. The Text formula margins can be
0 (and it's better).
- «
modify_all_formula » macro
This macro modifies all the formula in the current write document with parameters defined in the formula parameter
dialog. When
the macro is launched, a
progress bar appears. During the modification, you have not
access to your document. Warning,
sometimes the macro crashes OOo. So save your document before
running this macro. Sometimes when the macro is run, OOo
asks you to save or not your document. Its a bug. You can choose either
of them.
- «
modify_selected_formula » macro
This macro modifies
all the formula in
the current selection with parameters defined in the formula parameter
dialog. This macro works with draw and impress doucument.
- «
generate_formula » macro
You write the code of a formula expression (ex. sqrt{2}) in the write
document.
You select the text expression. You run this macro, the sqrt{2}
command is transformed into formula with the parameters defined in the
dialog.
- «
version » macro
Gives the current version of the macro.
Download the last
version of the
library (formulaTools.zip)
(For
Internet explorer, click right button on the download link, and select
save target as ...)
How to install the library?
How to run the macros?
Any comment?
Third
library: inverse the order of points in a polygon or bezier curve
«
flip_polygon_segment_order » macro
This macro inverse the
order of points in a
polygon or bezier curve. This macro is useful to connect two curves
together by the right extermities. See the example bellow. I
created a 4 segment polygon. I duplicate it and transform it by a
vertical mirror symetry (see figure 1). Now I select the two
polygons, click right button and select "connect" sub menu.
By
default OOo connects the wrong ends. To connect the good ends, I start
from Fig. 1, I select the first polygon. I call the macro. The result
is shown in fig 3. You see that the larger square of the polygon that
shows the first point of the polygon is now at the other extremity. The
macro inverses the point order. Now the connection of the two polygons
gives the good result (see fig 4)

Figure 1 : The two polygons
Figure 2 : The two polygons connected without
applying the
macro

Figure 3 : The macro is
applied to the
first polygon
Figure 4
: The two polygons connected after applying the macro
Here there are two ways to install
the macro. Either you download the library in zip format and you
install it using the procedure describe here
OR you
download directly the starbasic source of the macro in txt format.
Download the last version of the macro as
the
:
How to install the library?
How to run the macros?
Any comment?
How
to install the Library in Open
Office 2.x
Open the « tools/package manager » menu. Select my
packages and click on the « add ... » button. A
file manager appears. Select the zip file that you have downloaded
containing the macro. That's it.
How
to run a macro with
Open Office 2.x
Open the tools / macros / execute
macro submenu. The « macro select » dialog is
opened :

« Select macro »
dialog (French version)
On the left, select the
library you want to use (here formulaTools).
Select the "main"
module. Now on the right appears the list of macros of the
library. Select the macro that you want to execute and click on run.
Send
me a message
Visites :1198