2017-02-26

10: Let's Learn Basic Concepts of UNO, Part One

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

Main body START

To Know How to Handle (Read or Write) LibreOffice or Apache OpenOffice Writer or Calc Documents via Extensions from Java or Macro Programs

We Should Understand Basic Concepts of UNO Accurately

-Hypothesizer

We should understand basic concepts of UNO accurately so that we can make good use of UNO.

-Rebutter

Yes. About anything, unless we understand basics accurately, we can't make good use of it.

-Hypothesizer

As a note, sometimes, I can't understand well the usage of terms in the reference documents. For example, does a 'UNO object' mean a class instance or a class? Does a 'UNO component' mean a class, a Jar, or a UNO extension? Does the term, 'service', always represent a same concept in various appearances? . . . What we aim to do is to clarify every concept distinguished from other concepts, and to use every term only in one meaning. Accordingly, our usage of terms is a bit different from the reference documents'. We aren't trying to be different, but it's inescapable to describe things as we can understand them ourselves.

-Rebutter

Ah-ha, let's see what we can do.

What Are UNO Objects?

-Hypothesizer

Let's start with UNO objects. The UNO object is a class instance that performs the UNO protocol. I mean, just a plain Java class instance isn't a UNO object because it doesn't observe the UNO protocol. And note that when we use the term, UNO object, it always means a class instance, not a class.

-Rebutter

What do you mean by 'performs the UNO protocol'?

-Hypothesizer

What's important about UNO is that the UNO object can be handled in a predetermined way even from different programming language environments. For that to happen, there must be a protocol that is observed by all the UNO objects. I called the protocol 'the UNO protocol'.

-Rebutter

Ah-ha.

-Hypothesizer

About the sample UNO extension we built in the previous article, the object referred by the variable, l_hiUnoExtensions, in the LibreOffice Basic macro is a UNO object.

-Rebutter

I see.

What Are UNO Components?

-Hypothesizer

And we will call the class from which UNO objects are instantiated a 'UNO component'. So, a UNO component is always a class, not a class instance, not a Jar, not a UNO extension. That way, the distinction between the UNO object and the UNO component will be clear.

-Rebutter

Yes, it's clear.

-Hypothesizer

Although the reference documents seem to use the term, component, wantonly, we will use the term, UNO component, in that strict one meaning.

-Rebutter

All right.

-Hypothesizer

In the sample UNO extension, HiUnoExtensionsImplementation is a UNO component.

-Rebutter

I see.

What Are UNO Interfaces?

-Hypothesizer

The UNO interface is an abstract outward manifestation of an aspect of a UNO component. By 'abstract', I mean, not including implementations.

-Rebutter

The UNO interface is to the UNO component as the Java interface is to the Java class?

-Hypothesizer

Yes. A UNO component implements UNO interfaces as a Java class implements Java interfaces. In fact, in Java, a UNO component is a Java class that implements UNO interfaces, which are Java interfaces. I used the term, aspect, above, because a UNO component can implement multiple UNO interfaces, and a UNO interface doesn't always represent the whole of the UNO component, but an aspect of the UNO component.

What's important is that any UNO component has to implement at least one UNO interface. Rather, I should say, a Java class becomes a UNO component by implementing a UNO interface.

-Rebutter

Is any Java class that implements a UNO interface a UNO component?

-Hypothesizer

Yes, it is. In our terms, 'UNO component' and 'UNO interface implementation' mean the same thing.

-Rebutter

I see.

-Hypothesizer

There is a root UNO interface, 'com.sun.star.uno.XInterface', and every other UNO interface is a descendant interface of the root UNO interface. A UNO interface can inherit multiple UNO interfaces, . . . now.

-Rebutter

Now?

-Hypothesizer

I mean, in old specifications, it couldn't, and that is a cause of some complications, but we will talk about it later.

-Rebutter

OK.

-Hypothesizer

In the sample UNO extension, XHiUnoExtensions is a UNO interface.

-Rebutter

I see.

Main body END

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>