Looking for tutorial UNO....

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
RobinDesHautbois
Posts: 1
Joined: Mon Sep 10, 2012 10:17 pm

Looking for tutorial UNO....

Post by RobinDesHautbois »

Hello,
I'm looking for a tutorial on the basics of populating an OpenOffice Writer document in a Java program. The template would be created directly in Open Office and the data would come from JDBC queries, that is, manipulated as POJO objects.

I found the following tutorial:
http://www.oooforum.org/forum/viewtopic.phtml?t=61386
but it is so complete, I have a hard time finding the basics..... I'm guessing I need to better learn the basics of ODF template writing in this scenario.

I took a look at JODReports, which looks really easy to use, but it seems limited and the website for its associated PDF writer (JODConverter) is not currently showing.

I'm mostly interested in:
1. Associating document parts (labels, table headers and cells, images, charts) with java-side variables.
2. Conditional content: e.g. show/hide a table (or nested table) only if there is actually data available.
3. Customizing the appearance (colors, background-images).

Any help on finding relevant tutorials is much appreciated!
OpenOffice.org 3.4.0
Ubuntu 12.04, gnome-shell (3.4.x) 64-bit
User avatar
Hagar Delest
Moderator
Posts: 32665
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Looking for tutorial UNO....

Post by Hagar Delest »

Because of no reply in Beginner section, moved to Macros>UNO sub-forum.
Perhaps some hints here: Documentation of OpenOffice BASIC objects, etc.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
jza
Posts: 239
Joined: Mon Nov 03, 2008 11:33 am
Location: Cancún, Mexico

Re: Looking for tutorial UNO....

Post by jza »

this is a very 'basic' tutorial of OO in Java:
http://openofficejava.blogspot.mx/2009/ ... g-api.html

that said, have you seen the Python CreateTable example, it generates a document with tables and format and text and headings. I think is a much straight forward way of doing things.

Tools > Macros > Organize Macros > Python... then My Macros > Python > CreateTable

Looking at the code is pretty straightforward:
http://wiki.openoffice.org/wiki/PyUNO_s ... eSample.py

After the chunk of code, there is a breakdown with annotations.
AOO 4.1.1 on Arch Linux
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Looking for tutorial UNO....

Post by Villeroy »

IMHO, studying example snippets won't let you get the hang of it. UNO is too abstract for learning by doing.
As a fairly experienced programmer you need to know about the Frame-View-Model architecture, about UNO services and UNO interfaces.
With some knowledge about these general concepts, you get a better understanding of code snippets.
The MRI extension helps you to find any object, properties and methods for you. It does even generate code snippets while you are browsing the object hierarchy.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
jza
Posts: 239
Joined: Mon Nov 03, 2008 11:33 am
Location: Cancún, Mexico

Re: Looking for tutorial UNO....

Post by jza »

I missunderstood the situation, I thought you meant generate content in a document and you actually want to extract information from a document. This is a bit more tricky specially since you will need to query the document for active objects, which is what a code inspector. to understand what is active, althought MRI is great, I am not sure how can you automate the query of objects. Maybe some smarter algorithm that can validate the active objects in the current document and decide if it can proceed with reading the content of the document.

I also not sure how can you retrieve the actual text content from an object. AFAIK objects are used to execute instructions but not to hold document data.
AOO 4.1.1 on Arch Linux
Post Reply