Re: [dev] Dispatcher: .uno:Print wait for print job to finish

2009-03-31 Thread Mathias Bauer
Hi,

Fhomasp wrote:

 Hey,
 
 I need to have documents printed, which was ok to implement.
 Basically I used the dispatcher to summon me the default print dialog in
 writer.  After the ok from the user I need to close the JPanel in which is
 the container for the office document.  Problem is that it gets closed
 before the print job is finished and I'm not sure how to continue.  I can't
 use Thread.sleep() as I won't know how many pages there are going to be or
 how fast the target machine will be.  It's not good programming anyhow.
 
 I thought I'd be able to do this using XNotifyingDispatch and an
 XDispatchResultListener, however the problem persists.

The dispatcher will notify when the dispatching is finished.
Asynchronous processing inside VCL or the operating system is not taken
into account. We could implement that but ATM it isn't working like that.

You can try passing a dispatch argument in your propertyvalues called
Asynchron with the boolean value false. Then you also don't need the
NotifyingDispatch as the printing should be done when the dispatch call
returned.

Regards,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to nospamfor...@gmx.de.
I use it for the OOo lists and only rarely read other mails sent to it.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org



[dev] Dispatcher: .uno:Print wait for print job to finish

2009-03-24 Thread Fhomasp

Hey,

I need to have documents printed, which was ok to implement.
Basically I used the dispatcher to summon me the default print dialog in
writer.  After the ok from the user I need to close the JPanel in which is
the container for the office document.  Problem is that it gets closed
before the print job is finished and I'm not sure how to continue.  I can't
use Thread.sleep() as I won't know how many pages there are going to be or
how fast the target machine will be.  It's not good programming anyhow.

I thought I'd be able to do this using XNotifyingDispatch and an
XDispatchResultListener, however the problem persists.

Somehow I'd need to grab the print process and hold on to it until it
finishes.  Then I can close the container.  I don't really know how :-)

Here's my code:


 XURLTransformer xParser = (XURLTransformer)
 UnoRuntime.queryInterface(XURLTransformer.class,

 xServiceFactory.createInstance(com.sun.star.util.URLTransformer));
 URL [] parseUrl = new URL[1];
 parseUrl[0] = new URL();
 parseUrl[0].Complete = .uno:Print;
 if(xParser.parseStrict(parseUrl)){
 //ok
 }else
 {
 throw new TechnicalException(URL not
 validated,this);
 }
 
 XDispatch xDispatch =
 this.queryDispatch(parseUrl[0],,0);
 XNotifyingDispatch notifier = (XNotifyingDispatch)
 UnoRuntime.queryInterface(XNotifyingDispatch.class,
 xDispatch);
 if(notifier != null){

 notifier.dispatchWithNotification(parseUrl[0],propertyValues,new
 XDispatchResultListener(){
 
 public void
 dispatchFinished(DispatchResultEvent dre) {
 System.out.println(finish called!);
 
 if(dre.Result.equals(Boolean.TRUE)){
 brief.setBriefAfgedrukt(true);
 //I'd need to close the container here
 
 }else
 {
 panel.sluit(); //this works, there's
 no print job
 }
 }
 
 public void disposing(EventObject eventObject)
 {
 System.out.println(dispatch disposed!);
 //never gets called
 }
 
 });
 }
 
-- 
View this message in context: 
http://www.nabble.com/Dispatcher%3A-%22.uno%3APrint%22-wait-for-print-job-to-finish-tp22680911p22680911.html
Sent from the openoffice - dev mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: dev-unsubscr...@openoffice.org
For additional commands, e-mail: dev-h...@openoffice.org