Consultor Eletrônico



Kbase P119614: How to use OpenOffice.org from a 4GL application?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/11/2009
Status: Verified

GOAL:

How to use OpenOffice.org from a 4GL application?

GOAL:

How to open Open Office windows from the 4GL?

GOAL:

How to create an Open Office document from the 4GL?

GOAL:

How to use OLE Automation with OpenOffice and 4GL?

FACT(s) (Environment):

Progress 9.x
OpenEdge 10.x
Windows

FIX:

OpenOffice.org is based on an interface-based component model called Universal Network Objects (UNO). UNO offers interoperability between different programming languages, different object models, different machine architectures and different processes either in LAN or via the Internet. There exist bindings for Java, C, C++, OLE Automation and Python.
To use UNO in 4GL on Windows, it is recommended to use the OLE automation interface.
Unlike with other office suites, a single parent COM object is responsible for all OpenOffice.org applications: com.sun.star.ServiceManager. From that object all OpenOffice.org applications can be started and interacted with.
The following program demonstrates how to start OpenOffice.org Writer and create a document.
DEFINE VARIABLE hSM AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hDesktop AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hDocument AS COM-HANDLE NO-UNDO.

DEFINE VARIABLE hText AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE hCursor AS COM-HANDLE NO-UNDO.

/* Some methods require an Array parameters for extra arguments. The
only Progress database that translates to Array is RAW. */
DEFINE VARIABLE extraArgs AS RAW NO-UNDO.

CREATE "com.sun.star.ServiceManager" hSM.
hDesktop = hSM:createInstance("com.sun.star.frame.Desktop").
hDocument = hDesktop:loadComponentFromURL("private:factory/swriter", "_blank", 0, extraArgs).
hText = hDocument:getText().
hCursor = hText:createTextCursor().
hText:insertString(hCursor, "This is an example document.", FALSE).