Files
loeclipse/docs/loeclipse-doc/help/html/userdoc/javatuto/index.html
Samuel Mehrbrodt a2e2b277da Move docs to docs/ folder
In preparation to have this stuff online
2018-10-27 13:50:06 +02:00

292 lines
12 KiB
HTML

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>UNO Java component creation explained</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.68.1">
<link rel="start" href="index.html"
title="UNO Java component creation explained">
<link rel="next" href="ar01s02.html" title="Creating a new component">
<link href="../../styles.css" rel="stylesheet" type="text/css" />
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084"
alink="#0000FF">
<div class="article" lang="en-GB">
<div class="titlepage">
<div>
<div>
<h1 class="title"><a name="id2410669"></a>UNO Java component
creation explained</h1>
</div>
<div>
<h3 class="subtitle"><i>How to create a Java component with
Eclipse</i></h3>
</div>
<div class="section" lang="en-GB">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both"><a name="id2495076"></a>Introduction</h2>
</div>
</div>
</div>
<p>This paper is a tutorial to guide UNO newcomers to create their
first Java component. This tutorial will use Eclipse and it's plugin for
the LibreOffice development. Of course, every step will be detailed,
but if your are still an experienced UNO programmer, you can have a look
at the next pages to have a better view of how to use the Eclipse
plugin.</p>
<div class="section" lang="en-GB">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name="id2501774"></a>UNO Components</h3>
</div>
</div>
</div>
<p>This section will explain some very basic things about UNO
components. You might skip it if you already know it. First I will
explain what is a component and it's mains parts. Afterwards, I will
explain what is needed to create a UNO component to help you to fully
understand the different tools and their use during the tutorial.</p>
<div class="section" lang="en-GB">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name="id2500105"></a>Components anatomy</h4>
</div>
</div>
</div>
<p><span class="emphasis"><em>&#8220;A component is a
system element offering a predefined service and able to communicate
with other components&#8221;</em></span><span class="emphasis"><em><span
class="emphasis"><em> </em></span></em></span>explains <a
href="http://fr.wikipedia.org/wiki/composant" target="_top">Wikipedia
(Fr)</a><a href="http://fr.wikipedia.org/wiki/composant" target="_top"></a>. In UNO case a component will
generally be delivered as a package containing a library (share library
in C++ or jar in Java). For UNO a component is made of two distinct
parts: specifications and an implementation.</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p><span class="strong"><strong>Specification: </strong></span>definition
in a common language of what the component should do. For UNO, this
language is called UNO-IDL and is more or less similar to <a
href="http://en.wikipedia.org/wiki/Corba" target="_top">Corba</a> IDL.
The documented part that will be provided as an API to use the
component is the specification. Thus it should be complete and
implementation independent.</p>
</li>
<li>
<p><span class="strong"><strong>Implementation: </strong></span>is
the code that will realize what is described in the component
specifications. This programming language can either be C++, Java,
Python or some others. This is the internal part of the component and
will not be accessible from another component.</p>
</li>
</ul>
</div>
<p>In order UNO knows which implementation corresponds to which
specification, the component will use registries. There are two of them:
the first one describes all the component specifications (<code
class="literal">types.rdb</code>) and the second translates the
implementation into specifications (<code class="literal">services.rdb</code>)
and is generated from the implementation.</p>
</div>
<div class="section" lang="en-GB">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name="id2516729"></a>Components creation
process</h4>
</div>
</div>
</div>
<div class="figure"><a name="refIllustration0"></a>
<p class="title"><b>Figure 1.: UNO component build chain</b></p>
<div class="mediaobject"><img src="img/img000.png"
alt=": UNO component build chain"></div>
</div>
<p>To help you better understand what should be done to get a
component from it's specification and sources, you should have a look at
the illustration <a href="index.html#refIllustration0"
title="Figure 1.: UNO component build chain">1</a>. As shown by the
diagram, the specifications are compiled and merged into one <code
class="literal">types.rdb</code> registry. <code class="literal">Class</code>
files are generated from that file to translate the specifications into
a Java class definition file which is build with the implementation into
class using the <code class="literal">java</code> compiler. All the
classes are delivered as a <code class="literal">jar</code> file with a
specific manifest as we will see further in this tutorial. This doesn't
make a usable LibreOffice: the <code class="literal">types.rdb</code>
and <code class="literal">jar</code> file will have to be zipped into a
<code class="literal">.uno.pkg</code> file described with another
manifest.</p>
<p>As I will explain it later, the Eclipse plugin will hide some of
these operations, however you will need to know how they work to fully
understand the build process and what we will do in the next steps.</p>
</div>
</div>
<div class="section" lang="en-GB">
<div class="titlepage">
<div>
<div>
<h3 class="title"><a name="id2473547"></a>Installing the
development platform</h3>
</div>
</div>
</div>
<p>Now that you perfectly know what to do, we will install and
configure the development tools. This is quite simple but you might be
trapped into some problems if you don't read the next lines carefully. I
will now assume that you have none of the development tools. The
LibreOffice Eclipse integration minimal requirements are the
following one:</p>
<div class="itemizedlist">
<ul type="disc">
<li>
<p>LibreOffice</p>
</li>
<li>
<p>LibreOffice</p>
</li>
<li>
<p>Eclipse</p>
</li>
<li>
<p>Java</p>
</li>
</ul>
</div>
<div class="section" lang="en-GB">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name="id2473592"></a>LibreOffice</h4>
</div>
</div>
</div>
<p>First of all, you will need to have a working LibreOffice
and it's Software Development Kit (SDK). The last version are available
on the <a href="http://www.libreoffice.org/download" target="_top">LibreOffice
download pages</a> for the most current platforms. </p>
</div>
<div class="section" lang="en-GB">
<div class="titlepage">
<div>
<div>
<h4 class="title"><a name="id2473631"></a>Eclipse and the plugin</h4>
</div>
</div>
</div>
<p>To get Eclipse, just get to their download pages and download the
last Eclipse SDK. You will have Eclipse and it's SDK. Of course, you
might want to download only the binary runtime, but you will have to
follow more links. Once you have Eclipse, unzip it on your computer and
that's it: eclipse has a Java plugin to help you program in Java.</p>
<p>Now we will install the LibreOffice development plugin for
Eclipse using the <a href=https://marketplace.eclipse.org/content/loeclipse>Eclipse Marketplace</a>.<br/><br/>
<a href="http://marketplace.eclipse.org/marketplace-client-intro?mpc_install=2881446" class="drag" title="Drag to your running Eclipse workspace to install LOEclipse"><img class="img-responsive" src="https://marketplace.eclipse.org/sites/all/themes/solstice/public/images/marketplace/btn-install.png" alt="Drag to your running Eclipse workspace to install LOEclipse" style="margin-left:100px"/></a>
<br/>
<p>On the following page, you will see a list of &#8220;<span
class="emphasis"><em>update sites</em></span>&#8221;. These are URLs
pointing to directories containing plugins informations and archives.
Now click on the <span class="strong"><strong>Add remote
site</strong></span> button to get a small window asking for a name that will be
displayed in the list and an URL. The URL of LibreOffice plugin
update site is <a
href="http://eclipse-plugins.libreoffice.org"
target="_top">http://eclipse-plugins.libreoffice.org</a>.
<span class="strong"><strong>Do not hope to get an
archive to download here: it's the update site for Eclipse.</strong></span></p>
<p>Then validate the new update site parameters and be sure that the
LibreOffice site is checked before clicking on the <span
class="strong"><strong>Finish</strong></span> button. You should now
see a window like the one of the illustration <a
href="index.html#refIllustration2"
title="Figure 3.: LibreOffice update site contents">3</a>. <span
class="strong"><strong>Select the LibreOffice plugin
Core and Java plugins</strong></span>, click next and let the wizard guide you through
the end of the process. You will be asked to accept the plugin licence
and validate the installation archives which are not signed.</p>
<div class="figure"><a name="refIllustration2"></a>
<p class="title"><b>Figure 3.: LibreOffice update site
contents</b></p>
<div class="mediaobject">
<table border="0" summary="manufactured viewport for HTML img"
cellspacing="0" cellpadding="0" width="355">
<tr style="height: 243px">
<td><img src="img/img002.png" width="355"
alt=": LibreOffice update site contents"></td>
</tr>
</table>
</div>
</div>
<p>Congratulations, you have installed the LibreOffice plugin
successfully, there is now to configure it. The following steps will
guide you through this task. Go to the Eclipse options via the <span
class="strong"><strong>Window &gt; Preferences...</strong></span> menu.
In the list on the left, select the <span class="strong"><strong>LibreOffice
plugin &gt; SDK configuration</strong></span> item to get a window like the one shown by
the illustration <a href="index.html#refIllustration3"
title="Figure 4.: SDK configuration window">4</a>.</p>
<div class="figure"><a name="refIllustration3"></a>
<p class="title"><b>Figure 4.: SDK configuration window</b></p>
<div class="mediaobject">
<table border="0" summary="manufactured viewport for HTML img"
cellspacing="0" cellpadding="0" width="371">
<tr style="height: 233px">
<td><img src="img/img003.png" height="233"
alt=": SDK configuration window"></td>
</tr>
</table>
</div>
</div>
<p>In this window you will have to configure the path to your
LibreOffice and to it's SDK. So let us begin with the SDK path: click
on the <span class="strong"><strong>Add</strong></span> button next to
the SDKs list. You will have a window like the illustration <a
href="index.html#refIllustration4"
title="Figure 5.: New SDK path window">5</a>, browse to your
LibreOffice SDK and validate. Then you will have to do the same
for the LibreOffice path using the other <span class="strong"><strong>Add</strong></span>
button.</p>
<p>Note that a URE installation can be selected instead of a
complete LibreOffice installation. Please report to the Java URE
application tutorial for more details on the plugin's URE support.</p>
<p><span class="strong"><strong>Please make sure
that the path to the SDK doesn't contains any space on Windows: it could
cause some problems when building your UNO projects afterwards.</strong></span></p>
<div class="figure"><a name="refIllustration4"></a>
<p class="title"><b>Figure 5.: New SDK path window</b></p>
<div class="mediaobject">
<table border="0" summary="manufactured viewport for HTML img"
cellspacing="0" cellpadding="0" width="244">
<tr style="height: 143px">
<td><img src="img/img004.png" height="143"
alt=": New SDK path window"></td>
</tr>
</table>
</div>
</div>
<p>Now your LibreOffice plugin is ready to work: you can begin to
create your new component. If there was any problem during the plugin
installation, do not hesitate to report it to the <a
href="mailto:cedric.bosdonnat.ooo@free.fr" target="_top">author</a>.</p>
</div>
</div>
</div>
<div class="footnotes"><br>
<hr width="100" align="left">
<div class="footnote">
<p><sup>[<a name="ftn.ftn1" href="#ftn1">1</a>] </sup>Even thought
there is a definition on the <a
href="http://en.wikipedia.org/wiki/software_componentry" target="_top">English
wikipedia article</a>, I prefer the French one because of it completeness</p>
</div>
</div>
</div>
</body>
</html>