Ask Your Question
1

Where do I start with API programming in LO? [closed]

asked 2014-09-11 04:05:42 +0200

dev_al gravatar image

updated 2016-03-04 16:05:01 +0200

Alex Kemp gravatar image

Years ago, I wrote a VB app that opens an MS Word doc, and does 'stuff'. Now, I would like to migrate that program to use LibreOffice (4.3.1) instead of MS Word. I've spent some time looking around, but perhaps I'm not using the correct terminology?

The 'stuff' I do is fairly simple using the DOM model in MS Word 1) find the first table on the first page, get the row/col count and read the data. 2) find all subsequent occurrences of that table (same rows/cols) throughout the document, read the data.

I'd like to interact with the Word doc using C++ or PHP (Using Windows 7). I'm actually wondering if LibreOffice's API (if there is one) is actually the way to go with this? Is there a better way?

Any pointers where to start would be very much appreciated... Many thanks in advance...

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-03-04 16:05:36.636413

3 Answers

Sort by » oldest newest most voted
0

answered 2014-09-11 05:34:02 +0200

oweng gravatar image

I recommend starting with the links collected in this alternate forum thread. The guide by Andrew Pitonyak is generally cited as the best. You are probably going to have to use C++ in preference to PHP.

edit flag offensive delete link more
0

answered 2014-09-27 18:04:31 +0200

crlMIDI gravatar image

updated 2014-10-01 17:50:58 +0200

I'm surprised we are being referred to other forums like http://en.libreofficeforum.org/node/6017 . Many people like me used VBA with Microsoft Office without too much trouble despite its faults. There are (or were; I havn't been there for a while) all sorts of user guides and code snippets on the web. Not all the snippets work, of course.

I can't find a suitable beginners' guide to the LO Basic equivalent, which is inevitably more difficult to use because autocompletion can't be provided for structural reasons. There are third-part aids like X-ray Tools, but they may not be suitable for all newcomers to LO Basic.

One cause for confusion is that the LO 3 Basic guide seems to imply that you have to create a UNO service do do anything (code example: Obj = createUnoService("com.sun.star.frame.Desktop")).

On the other hand a recent example on the present forum ( http://ask.libreoffice.org/en/questio... ) doesn't require such code, and starts like this after the Dim statements:

oSDescriptor => ThisComponent.createSearchDescriptor()

oSDescriptor.setSearchString("\d\d(.|,)?\d")

oSDescriptor.setPropertyValue("SearchRegularExpression",True)

oSearchResult = ThisComponent.findAll(oSDescriptor)

Presumable the UNO service is already running in LO 4.3.1.2, but I'll need to go on a "fishing expedition" to find some properties, services and syntax of "createSearchDescriptor()".

At least question 25137 above shows that if you ask nicely, someone nice may do the coding for you :-)

In anwer to einpoklum (27 September) I have been searching for a while but didn't find an answer. So I thought it would be fair to make and justify a comment to the effect that there isn't an up-to-date 'getting started' guide suitable for end users, and that some kind of authoritative look-up facility is needed to compensate for the absence of auto-completion. Andrew Pitonyak's "Macros Explained" document is excellent, but it's written at a level suitable for developers. Perhaps LO developers havn't realised how many "ordinary" MS Office users write macros that are a little beyond the reach of a macro recorder; comparable ease of use should be a "must have" for LO.

@oweng Your comment reinforces what I said in my reply above to einpoklum.

As clearly implied by the OP, for the last couple of decades "ordinary" users of Office software expect to have access to macro coding facilities, for which they can learn enough from books line "VBA for idiots", and from the built-in help and the enormous amount of information that has become available over the years on the web. The same notion applies to hundreds of scientific, technical, educational and artistic applications, with the apparently unique exception of OO/LO. Writing code is a necessity for very many people, and no longer reserved for specialists: just look at any technical drawing, electronics design, maths or statistics package to see how it's provided for. With some applications, such as the widely-used open-source maths package Scilab, all user ... (more)

edit flag offensive delete link more

Comments

Most of what you wrote here seems to be commentary rather than the actual answer...

einpoklum gravatar imageeinpoklum ( 2014-09-27 18:44:25 +0200 )edit

@crlMIDI, the Pitonyak guide (and likely every other guide) is "written at a level suitable for developers" because that is what an API is ... advanced-level exposure of / access to the inner workings of a product i.e., programming. There is a significant difference between not knowing how to program and wanting to learn LO Basic vs having some knowledge of programming and wanting to learn. Those in the former group, should first learn some entry-level programming techniques.

oweng gravatar imageoweng ( 2014-10-01 02:28:51 +0200 )edit
0

answered 2014-09-11 10:14:24 +0200

dev_al gravatar image

Thank-you :)

Pitonyak's guide refers specifically to macros. Is that what I'd need to use?
I need to write an automated tool, not one that requires manual intervention.

edit flag offensive delete link more

Comments

In this case you should ask on stackoverflow not here, try odfpy

or unzip your .odt and grep the relevant parts from content.xml

karolus gravatar imagekarolus ( 2014-09-11 12:41:10 +0200 )edit

@dev_al, the term "macro" is used generally to mean program module (usually written in LO Basic, but also in other languages for which the UNO / API is available), rather than the more usual definition of a macroinstruction that is expanded / mapped.

oweng gravatar imageoweng ( 2014-09-12 10:10:59 +0200 )edit

Question Tools

1 follower

Stats

Asked: 2014-09-11 04:05:42 +0200

Seen: 747 times

Last updated: Oct 01 '14