2018-04-08

2: UNO, Its Essence and Its Relationship to LibreOffice or OpenOffice

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

UNO isn't just a peripheral interface for LibreOffice or OpenOffice. A poor understanding of its essence and implications may be confining you.

Topics


About: UNO (Universal Network Objects)
About: LibreOffice
About: Apache OpenOffice

The table of contents of this article


Starting Context


  • The reader has a basic knowledge on the personal computer architecture (what file, program, program instance (process), and so on are).
  • The reader has a basic knowledge on programming (what runtime environment, library, primitive datum type, compound datum type, and so on are).
  • The reader has a basic knowledge on the object-oriented programming paradigm (especially the concepts of object, class, interface, and implementation).
  • The reader has a knowledge on what Java and C++ are, although he or she doesn't have to be their programmer.

Target Context


  • The reader will know the essence of UNO and UNO's relationship to LibreOffice or Apache OpenOffice.

Orientation


Here is addressed an indispensable knowledge for exploiting LibreOffice or Apache OpenOffice. Almost all of the subsequent articles will be based on the knowledge.

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


Main Body


1: The Essence of UNO


Hypothesizer 7
UNO (Universal Network Objects) is a set of neutral-to-programming-languages specifications that define what UNO objects are like and how UNO objects can be handled.

Objector 2A
Your definition is pathetic. Don't use "UNO" inside your definition of UNO!

Hypothesizer 7
Sir, sometimes, it is almost inevitable.

Objector 2A
Such a definition is logically meaningless!

Hypothesizer 7
Not necessarily, sir. For example, 'x' can be legitimately defined by 'x = x * x + 0.25'.

Objector 2A
Can it?

Hypothesizer 7
You know, it is uniquely determined to be '0.5'.

Objector 2A
Then, why don't you say it to be '0.5' from the beginning!

Hypothesizer 7
Sir, sometimes, '0.5' is very difficult to be expressed in a natural language.

Objector 2A
. . . What does "neutral-to-programming-languages specifications" mean?

Hypothesizer 7
Please imagine the UNO space.

Objector 2A
Being suddenly told "the UNO space" . . .

Hypothesizer 7
Please assume that there is such a space.

Objector 2A
Does it exist per process or is there only one "UNO space" in the world?

Hypothesizer 7
That is a very good question, sir. Let us assume that there is only one UNO space in the world.

Objector 2A
Where does it exist?

Hypothesizer 7
Well . . ., it is not meaningful to ask "Where", because the UNO space is not something that sits inside the physical space.

Objector 2A
There can't be such a space . . .

Hypothesizer 7
For example, the Java space (let us assume that there is only one Java space in the world) does not sit inside the physical space.

Objector 2A
Doesn't it?

Hypothesizer 7
It is not meaningful to ask about the physical location of any Java object, is it?

Objector 2A
But the Java object is located at a specific address in a memory.

Hypothesizer 7
Not necessarily: it may have been swapped out. In fact, the Java space is a virtual space, and the address of the object is of the virtual space, not of the physical space.

Objector 2A
I don't accept such thing as a virtual space! It doesn't exist! It's a delusion!

Hypothesizer 7
. . . If you really accept no virtual space, you will not be able to comprehend any high-level programming language, or any ethic, or any emotion.

Objector 2A
"emotion"?

Hypothesizer 7
Physically speaking, joy, anger, love, or whatever is just an electronic phenomenon in your brain.

Objector 2B
What a blasphemy! Love is sacred!

Hypothesizer 7
Madam, I said "Physically speaking".

Objector 2B
But you are as though love is virtual!

Hypothesizer 7
Madam, please understand that my stance is not that being virtual is being meaningless.

Objector 2B
But love is real!

Hypothesizer 7
. . . Let us refrain from going in that direction, madam: this article is not about love.

Stage Direction
Objector 2B pouts her lips.

Hypothesizer 7
The rules (specifications, in paraphrase) in the UNO space are original to the space.

For example, the primitive datum types in it are these (in fact, some of them are not any datum type).

Objector 2A
They look like those of C++ . . .

Hypothesizer 7
Sir, they resemble, but are not exactly the same; for example, C++ has no 'string' ('::std::string' is a different thing), 'type', etc..

Objector 2A
Whatever.

Hypothesizer 7
As another example, in the UNO space, any function argument can be '[in]', '[out]', or '[inout]'.

Objector 2A
What, the hell, are they?

Hypothesizer 7
'[in]' means that the argument is for input only; '[out]' is for output only; '[inout]' is for input and output.

Objector 2A
So, do I have to learn the UNO programming language?

Hypothesizer 7
There is no such thing.

Objector 2A
What do you mean?

Hypothesizer 7
The UNO space contains some interfaces (which are called UNO interfaces), but not any implementation; so UNO has the interface definition language (called UNOIDL: UNO Interface Definition Language), but no programming language that implements logics.

Objector 2A
Such a space is useless: no logic can be implemented!

Hypothesizer 7
Not necessarily. The UNO space is mapped to each of some programming language spaces, typically, Java, C++, C#, and Python.

Objector 2A
. . . What does "mapped" mean?

Hypothesizer 7
The specifications in the UNO space are translated to some specifications in the Java space, for example.

For example, 'long' in the UNO space is translated to 'int' in the Java space.

As another example, '[out] long' (as a function argument) in the UNO space is translated to 'int []' in the Java space.

Objector 2A
Huh? Is that an array? Why does array appear there?

Hypothesizer 7
Because otherwise, Java does not allow outputting to the argument (because Java has no reference-as-in-C++).

Objector 2A
Hmm . . ., and?

Hypothesizer 7
And any implementation is done in the Java space, which means that a class (which is called a UNO component, by me) is created in the Java space.

Objector 2A
. . . When the class is instantiated in the Java space, a corresponding instance is created in the UNO space?

Hypothesizer 7
Rather, we should say that the same instance (which is called a UNO object) is projected into the UNO space.

Objector 2A
. . . I don't see any necessity of the UNO space.

Hypothesizer 7
The instance in the UNO space can be projected also into the C++ space (for example), which means that the instance can be handled in C++.

Objector 2A
Well, so, the instance, which is in fact a Java object, can be handled in C++?

Hypothesizer 7
Yes. That is the essence of UNO.

Let us see the concept in an image.


Objector 2A
Hmm . . .

Hypothesizer 7
It will be beneficial to keep having the essence in your mind, in order to be able to freely use UNO; neglecting the essence, because it is abstract, will confine you.

Objector 2A
Well . . .


2: The Necessity of UNO Bridge


Hypothesizer 7
The concept of UNO is as described in the previous secion, but conceiving that concept does not miraculously let you begin to handle a Java object from your C++ code.

Objector 2B
Of course.

Hypothesizer 7
In reality, we need a mechanism that connects the C++ runtime environment to the Java runtime environment, which is UNO bridge.

Objector 2B
I thought that the C++ runtime environment connected to the UNO space.

Hypothesizer 7
Well, let us see this image.


Hypothesizer 7
The bridge between the C++ runtime environment and the Java runtime environment conjures up the virtual reality.

Objector 2B
Love is real.

Hypothesizer 7
. . .


3: How UNO Is Related to LibreOffice or Apache OpenOffice


Hypothesizer 7
It will be beneficial to know that UNO is not just a peripheral API for LibreOffice or Apache OpenOffice; LibreOffice or Apache OpenOffice is coded UNO-wise in its entirety.

Objector 2A
Which means . . .

Hypothesizer 7
Which means that your LibreOffice or Apache OpenOffice instance is, basically, a collection of UNO objects.

Objector 2A
"basically"?

Hypothesizer 7
I mean, there are some tiny non-UNO objects in it, certainly, but the major objects are UNO objects.

Objector 2A
Hmm . . ., so what? Is that important?

Hypothesizer 7
That means that you can put your hands into the UNO objects structure from your Java, C++, C#, or Python program via the UNO space, instead of being able to do only some odd things allowed by a peripheral API.

Objector 2A
Ah, so I can handle the LibreOffice instance in any way.

Hypothesizer 7
To be exact, in any major way: you cannot handle the non-UNO objects, cannot access the non-published members of the UNO objects, and may not be able to reach some UNO objects.

Objector 2A
"non-published members"?

Hypothesizer 7
I mean the members not declared in any UNO interface.

Objector 2A
I don't understand . . .

Hypothesizer 7
You handle the UNO object via the UNO space, which is ignorant of the class (remember that the UNO space has no implementation?), but the UNO interfaces implemented by the class.

Objector 2A
Ah, and what do you mean by "not be able to reach some UNO objects"?

Hypothesizer 7
An object's existing does not mean that the object is reachable, right?

Objector 2A
Well . . .

Hypothesizer 7
You have to get the address of the object somehow, but how?

Objector 2A
Being asked "how" . . .

Hypothesizer 7
Typically, you get the address as the return of a method of another object.

Objector 2A
Of course . . .

Hypothesizer 7
But what if there is no such a method?

Objector 2A
Being asked "what" . . .

Hypothesizer 7
It is unreachable.

Objector 2A
That is a fraud!

Hypothesizer 7
. . . That is not peculiar to UNO at all.

Objector 2B
I want to know what is the relationship between LibreOffice and Apache OpenOffice.

Hypothesizer 7
In short, LibreOffice and Apache OpenOffice are two open-source office software suites forked from the same now-discontinued open-source office software suite, OpenOffice.org.

Objector 2B
Ah, that's the reason why OpenOffice.org is frequently mentioned in the official reference document.

Hypothesizer 7
That document is an old document written for OpenOffice.org.

Objector 2A
LibreOffice and Apache OpenOffice are alike, but different. . . . How different?

Hypothesizer 7
Honestly, I don't know well (I know that Apache OpenOffice cannot write Office Open XML format files or their related Microsoft Office format files), but I am talking on the premise that they aren't much different. In fact, I will always talk based on LibreOffice, which I use, assuming that my descriptions would also apply to Apache OpenOffice. If they don't somehow, . . . I will be sorry.

Objector 2B
. . . Your being sorry won't help me at all.

Hypothesizer 7
You are right, and I will be sorry about that too.

Objector 2B
. . .

Hypothesizer 7
Anyway, knowing more about the construction of LibreOffice or Apache OpenOffice will be helpful for exploiting LibreOffice or Apache OpenOffice.

The main body of LibreOffice or Apache OpenOffice is written in C++.

And LibreOffice or Apache OpenOffice provides the UNO bridges for Java, C++, Microsoft .NET Framework, and Python, that allows inter-processes connections.

Objector 2B
How macro fits in the whole picture?

Hypothesizer 7
Any macro is a UNO program that runs inside the LibreOffice or Apache OpenOffice instance and can be called from the LibreOffice or Apache OpenOffice GUI, with the UNO bridge automatically established.

Objector 2B
What do you mean by "inside the LibreOffice or Apache OpenOffice instance"? Python inside the C++ program?

Hypothesizer 7
It is possible by embedding Python with the Python/C API (by JNI for Java).

Objector 2B
Ah.


4: Your UNO Program Does Not Directly Read or Write Any Document, but Operates a LibreOffice or Apache OpenOffice Instance


Hypothesizer 7
As LibreOffice or Apache OpenOffice is an office suit, your purpose of using UNO will be, usually, reading or writing a document.

I assume that you already understand that your UNO program does not directly read or write any document.

Objector 2A
. . . "directly" is a vague word; certainly, my program reads and writes a document via the UNO library.

Hypothesizer 7
I mean, "the UNO library" you use is a UNO bridge that connects your program to a LibreOffice or Apache OpenOffice instance, not something that does reading or writing in itself.

Objector 2A
Ah, my program pulls the strings for the LibreOffice instance, right?

Hypothesizer 7
Yes.

Objector 2A
What about it?

Hypothesizer 7
It is fine if you understand what you are doing, sir.


References


  • Apache OpenOffice Wiki. (2014/01/02). Apache OpenOffice Developer's Guide. Retrieved from https://wiki.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide
<The previous article in this series | The table of contents of this series | The next article in this series>