2020-03-08

41: Set Any Page Property of Word Processor Document with UNO

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

Any word processor document typically associated with an OpenDocument Text/Office Open XML Document/Microsoft Word file, using LibreOffice

Topics


About: UNO (Universal Network Objects)
About: LibreOffice
About: Apache OpenOffice
About: the Java programming language
About: C++
About: Microsoft .NET Framework
About: the Python programming language
About: LibreOffice Basic
About: Apache OpenOffice Basic
About: BeanShell
About: JavaScript

The table of contents of this article


Starting Context



Target Context


  • The reader will know how to set any page property of any word processor document that is loaded in a LibreOffice or Apache OpenOffice instance, from his or her program.
Stage Direction
Here are Hypothesizer 7, Objector 41A, and Objector 41B in front of a computer.


Orientation


Hypothesizer 7
In this article, we will know how to set any page property of any word processor document that is loaded in a LibreOffice or Apache OpenOffice instance, from our program.

In fact, this article is an extension of a previous article on setting the size of any page of any word processor document.

Objector 41A
What do you mean by "extension"?

Hypothesizer 7
Sir, the logic for setting any property has been already explained in the previous article; while the previous article uses the 2 properties, 'Size' and 'IsLandscape', you can use any other property instead of them, if you know the specifications of the property, which you will know in this article (more specifically, in another article introduced in this article).

Objector 41B
I need to handle also some spread sheets documents.

Hypothesizer 7
Madam, there is also an article on spread sheet documents.


Main Body


1: The Logic for Setting Any Page Property of Any Word Processor Document


Hypothesizer 7
The logic for setting any page property of any word processor document has been already explained in a previous article and will not be repeated here.

Just, in the 4th section, use another property name instead of "Size" and a datum of the corresponding datum type.


2: A List of the Properties


Hypothesizer 7
Here is a list of the properties.

Please note that the cited property types are UNO datum types.

Objector 41A
Which means . . .

Hypothesizer 7
Each UNO datum type is mapped to a language-specific datum type in each UNO-supported programming language. For example, 'long' is mapped to 'int' (not 'long') in Java; in Python, any integral number is mapped to 'int' because there is no such thing as 'short' or 'byte'.

For the specifications of the complex types like '::com::sun::star::container::XNameContainer', please look at the UNO API reference.

Objector 41A
. . . "unknown how a page style can be un-physical"?

Hypothesizer 7
Honesty, I do not know what being un-physical exactly means. Not ”physical”? Any object in the memory is physical in my opinion. . . . I guest that being un-physical means, more appropriately stated, being temporary or something (I claim that for however short duration something exists, it is not un-physical at all).

Objector 41A
. . .

Hypothesizer 7
Anyway, I am not concerned with the property at all, because it should be always 'true' as far as I am concerned.

Objector 41A
"unknown how this is effective"?

Hypothesizer 7
Honesty, there are some properties which I do not know mean what. As they do not seem to correspond to any of the settings on the GUI page style dialog, I am not really concerned with them either.

In fact, there is a concern that there is no property that corresponds to the "Register-true" setting on the GUI page style dialog. In fact, a UNO API page claims that there is a property named "RegisterModeActive", which does not seem to really exist.

Objector 41A
Why?

Hypothesizer 7
I do not know, although I know that the official document is fairly sloppy.

Objector 41A
. . . On the other hand, the page seems to list only a small part of the properties.

Hypothesizer 7
Yes, it does: for example, it does not list 'HeaderTextFirst', which exists, because the first page can have a specific header text; as another example, it does not list 'FillGradient', which is necessary in order to access the exact page background gradient settings.

Objector 41A
And I wonder why it cannot be more articulate. . . . What does "the left border distance of the page" mean? Distance between the left border and what (I'm sure it isn't 'the page', because the page is the whole square area and 'distance between the left border and the page' doesn't make sense although 'distance between the left border and the page left edge' or 'distance between the left border and the page main contents' may make sense)? Talking of a distance without specifying the 2 terminal points is meaningless . . .


3: The Conclusion and Beyond


Hypothesizer 7
Now, we know how to set any page property of any word processor document that is loaded in a LibreOffice or Apache OpenOffice instance, from our program.

We will see the specifications of the properties of more other UNO components in some future articles.


References


  • N/A. (N/A). LibreOffice: Main Page. Retrieved from https://api.libreoffice.org/docs/idl/ref/index.html
<The previous article in this series | The table of contents of this series | The next article in this series>