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