Hal Vaughan wrote:
I hope this is a simple and quick question. I have a program I wrote in
Java to work with OpenOffice.org back while it was in version 1.0 and
1.1. At that point, doing anything with the API was quite complex.
All I have to do is:
- open a doc
- print that doc
- close the doc
- quite OOo when done with all the docs I'm printing
To create the interface in Java I had to create 3-4 objects and to open
a doc, I had to create several objects and printing required that, too.
I need to make some changes and and am having some difficulties and I'm
heavily pressed for time. If the API is still basically the same, I
won't be looking over new materials, but I'd like to know if it's
changed so it's easier. For instance, I could create an interface and
send an Uno command for quit, but anything else I had to do was much
more complex.
Well the API is more or less the same. We've introduced some new
concepts which are not reflected by most API's at the moment
(compatibility and time reasons, which of course is sad enough). Anyway
if you use a socket connection you simplify the whole UNO bootstrap
stuff with one call (pipe connection to the new started or connected to
default office). If you interested in this, i would recommend out
NetBeans plugin and take a look to the UNO Client Application project
type that does some more packaging stuff for you as well.
You are under time pressure and i would suggest that you change nothing
at the moment. But for your records, the following should work:
######
// the bootstrap API needs some special manifest entry and
// some glue code packaged with your jar
XComponentContext xContext = Bootstrap.bootstrap();
XComponentLoader xLoader =
(XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class,
xContext.getServiceManager().createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext));
// load document hidden
PropertyValue[] args = new PropertyValue[1];
args[0] = new PropertyValue();
args[0].Name = "Hidden";
args[0].Value = new Boolean(true);
XComponent xDoc = (XComponent)UnoRuntime.queryInterface(
XTextDocument.class, xLoader.loadComponentFromURL(
sDocFileUrl, "_blank", 0, args));
// set printer and print
XPrintable xPrintable = (XPrintable)UnoRuntime.queryInterface(
XPrintable.class, xDoc);
PropertyValue[] printerDesc = new PropertyValue[1];
printerDesc[0] = new PropertyValue();
printerDesc[0].Name = "Name";
printerDesc[0].Value = sPrinterName;
xPrintable.setPrinter(printerDesc);
// set print options if necessary
//PropertyValue[] printOpts = new PropertyValue[1];
//printOpts[0] = new PropertyValue();
//printOpts[0].Name = "Pages";
//printOpts[0].Value = "1";
xPrintable.print(null);
// maybe use a print listener to check your print jobs before terminate
// close document
XCloseable xCloseable = (XCloseable)UnoRuntime.queryInterface(
XCloseable.class, xDoc);
xCloseable.close(false);
// terminate the office
XDesktop xDesktop = (XDesktop)UnoRuntime.queryInterface(
XDesktop.class, xLoader);
xDesktop.terminate();
#######
Well you need some API calls but the advantage is that it is flexible
and you can use it from several languages.
With more multiple inheritance interfaces we would be able to reduce the
queryInterface calls and provide more intuitive views and access to the
underlying objects.
Juergen
Has a simpler interface for the API been set up for versions 2.0 and
higher (or 2.2 and those to come)? Or am I better off just leaving
things as they are and not trying to improve anything?
I don't need links and details. I'm already 2 days late finishing this,
working on almost no sleep, and just want to know if I need to look
into this or if I can just skip it.
Thanks!
Hal
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]