I forget to mention OfficeDocument is no third party wrapper: package com.sun.star.comp.beans;
public class OfficeDocument extends Wrapper implements com.sun.star.frame.XModel, com.sun.star.util.XModifiable, com.sun.star.frame.XStorable, com.sun.star.view.XPrintable --- Kent Gibson <[EMAIL PROTECTED]> wrote: > hi-ya Stephan, > > this is more curious. > > So I use a XDispatchHelper as per your example and > ok > it still does not work. Ok no change, and I get an > result: > > DispatchResultEvent result = ( DispatchResultEvent ) > xDH.executeDispatch( xDP, ".uno:PrinterSetup", "", > 0, > LoadArgs ); > Any theResult = ( Any ) result.Result; > Type type = theResult.getType(); > short theState = result.State; > > The theState is 0, which I am pretty sure is no > success. The type is void. > > But then I go and use this same code to regression > test printing (.uno:PrintDefault) and this code > hangs. > Other than hanging the behaviour is slightly > different, instead of a window popping up and > ticking > down the pages, a progress bar appears at the bottom > where the status bar belongs and then it just hangs > as > soon as the progress reaches 100%. It hangs my > application so I kill it and then out pops out my > print job. > > hmm. > > any ideas? > > thanks > > --- Stephan Wunderlich <[EMAIL PROTECTED]> > wrote: > > > Hi Kent, > > > > > Here is the java code I use: > > > > > > OfficeDocument document = > > > this.connection.getDocumentN(); > > > XController controller = > > > document.getCurrentController(); > > > > > > XFrame frame = controller.getFrame(); > > > > > > XDispatchProvider xDispProvider = ( > > XDispatchProvider > > > ) UnoRuntime.queryInterface( > > > XDispatchProvider.class,controller ); > > > XURLTransformer xParser = ( > > > com.sun.star.util.XURLTransformer ) > > > UnoRuntime.queryInterface( > XURLTransformer.class, > > > > > > > > this.connection.getServiceFactoryN().createInstance(URL_TRANSFORMER > > > ) ); > > > URL[] aParseURL = new URL[1]; > > > aParseURL[ 0 ] = new URL(); > > > > > > aParseURL[ 0 ].Complete = toDispatch; > > > xParser.parseStrict( aParseURL ); > > > URL aURL = aParseURL[ 0 ]; > > > XDispatch xDispatcher = > > xDispProvider.queryDispatch( > > > aURL, "", 0 ); //$NON-NLS-1$ > > > // dispatch > > > if ( xDispatcher != null ) > > > { > > > xDispatcher.dispatch( aURL, new > PropertyValue[] > > { } > > > ); > > > } > > > > > > also no visible effect. > > > > do you use an additional Wrapper ? ... Can't > recall > > to have heard of a > > class named OfficeDocument that comes with the > > office ... maybe I just > > overread something :-) > > > > Anyway ... the following java-code works like a > > charm for me ... > > > > > --------------------------------------------------------------- > > > > public static void main(String[] args) { > > > > > > try { > > XComponentContext xContext = > > > > com.sun.star.comp.helper.Bootstrap.bootstrap(); > > > > // get the servie manager rom the office > > XMultiComponentFactory xMCF = > > xContext.getServiceManager(); > > > > // create a new instance of the the > desktop > > Object oDesktop = > > xMCF.createInstanceWithContext( > > "com.sun.star.frame.Desktop", > xContext > > ); > > > > Object DH = > xMCF.createInstanceWithContext( > > "com.sun.star.frame.DispatchHelper", > > xContext ); > > > > XDispatchHelper xDH = (XDispatchHelper) > > UnoRuntime.queryInterface( > > XDispatchHelper.class, DH); > > > > // query the desktop object for the > > XComponentLoader > > XComponentLoader xCLoader = ( > > XComponentLoader ) > > UnoRuntime.queryInterface( > > XComponentLoader.class, oDesktop > ); > > > > PropertyValue LoadArgs[] = new > > PropertyValue []{}; > > > > XComponent xComp = > > xCLoader.loadComponentFromURL( > > "private:factory/swriter", > > "_blank", 0, LoadArgs ); > > > > XModel xModel = (XModel) > > > UnoRuntime.queryInterface(XModel.class, > > xComp); > > > > XDispatchProvider xDP = > (XDispatchProvider) > > > > UnoRuntime.queryInterface(XDispatchProvider.class, > > > > xModel.getCurrentController().getFrame()); > > > > xDH.executeDispatch(xDP, > > ".uno:PrinterSetup", "", 0, LoadArgs); > > > > } catch(Exception e){ > > System.err.println(" Exception " + e); > > e.printStackTrace(System.err); > > } > > System.out.println("... done"); > > > > } > > > > > --------------------------------------------------------------- > > > > Hope that helps > > > > Regards > > > > Stephan > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: > > [EMAIL PROTECTED] > > For additional commands, e-mail: > > [EMAIL PROTECTED] > > > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam > protection around > http://mail.yahoo.com > > --------------------------------------------------------------------- > To unsubscribe, e-mail: > [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] > > __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]