Re: [api-dev] GraphicProvider and export of graphics
An Exception gets thrown, and I don't really know why since xMSF exists, since I can initiate other services with it but it doesn't seem to work for the GraphicProvider. Code: XMultiServiceFactory xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, xTextDocument); new MsgBox(new Frame(), xMSF.toString(), false); // works and gives me the xMSF XGraphicProvider xGraphicProvider = null; try { xGraphicProvider = (XGraphicProvider) UnoRuntime.queryInterface(XGraphicProvider.class, xMSF.createInstance(com.sun.star.graphic.GraphicProvider)); } catch (Exception e2) { new MsgBox(new Frame(), ERR1, false); // gets thrown // TODO Auto-generated catch block e2.printStackTrace(); } Mathias Bauer schrieb: Jimmy wrote: That's exactly my problem, I can't translate it. It takes some more steps in Java to create a GraphicProvider, and I can't get it to work. Does that mean that XGraphicProvider xGraphicProvider = (XGraphicProvider) UnoRuntime.queryInterface(XGraphicProvider.class, xMSF.createInstance(com.sun.star.graphic.GraphicProvider)); does not return an object? Best regards, Mathias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] GraphicProvider and export of graphics
Jimmy wrote: An Exception gets thrown, and I don't really know why since xMSF exists, since I can initiate other services with it but it doesn't seem to work for the GraphicProvider. Code: XMultiServiceFactory xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface( XMultiServiceFactory.class, xTextDocument); Ah, I see: you took the wrong service manager. For global objects you must take the one you have bootstrapped, not the one from the document. The MultiServiceFactory at the document model is only for some special objects. If you had posted this in your first mail ... Best regards, Mathias -- Mathias Bauer - OpenOffice.org Application Framework Project Lead Please reply to the list only, [EMAIL PROTECTED] is a spam sink. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] GraphicProvider and export of graphics
I'm sorry, missed that code in the last e-mail. But which one are you talking about? This is my component initialisation and all I get is the xMCF but no xMSF which I need. It's only possible to create the xMSF with an XTextDocument, isn't it? public Editor(XComponentContext xCompContext) { xComponentContext = xCompContext; try { xMCF = xComponentContext.getServiceManager(); desktop = xMCF.createInstanceWithContext( com.sun.star.frame.Desktop, xComponentContext); xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop); xCLoader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, desktop); } catch (java.lang.Exception e) { e.printStackTrace(System.err); } } Mathias Bauer schrieb: Ah, I see: you took the wrong service manager. For global objects you must take the one you have bootstrapped, not the one from the document. The MultiServiceFactory at the document model is only for some special objects. If you had posted this in your first mail ... Best regards, Mathias - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] GraphicProvider and export of graphics
Ah I got it, I was wrong of course. I had to initiate the MSF with the MCF: XMultiServiceFactory xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, ElementController.getXMCF()); Thanks for the hint Mathias Jimmy schrieb: I'm sorry, missed that code in the last e-mail. But which one are you talking about? This is my component initialisation and all I get is the xMCF but no xMSF which I need. It's only possible to create the xMSF with an XTextDocument, isn't it? public Editor(XComponentContext xCompContext) { xComponentContext = xCompContext; try { xMCF = xComponentContext.getServiceManager(); desktop = xMCF.createInstanceWithContext( com.sun.star.frame.Desktop, xComponentContext); xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, desktop); xCLoader = (XComponentLoader) UnoRuntime.queryInterface( XComponentLoader.class, desktop); } catch (java.lang.Exception e) { e.printStackTrace(System.err); } } Mathias Bauer schrieb: Ah, I see: you took the wrong service manager. For global objects you must take the one you have bootstrapped, not the one from the document. The MultiServiceFactory at the document model is only for some special objects. If you had posted this in your first mail ... Best regards, Mathias - 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]
Re: [api-dev] GraphicProvider and export of graphics
Jimmy wrote: I'm sorry, missed that code in the last e-mail. But which one are you talking about? This is my component initialisation and all I get is the xMCF but no xMSF which I need. It's only possible to create the xMSF with an XTextDocument, isn't it? No, get the service manager from the ComponentContext. The object you get by calling xMCF = xComponentContext.getServiceManager(); is the service manager from which you can get your GraphicProvider, in the same way you got your desktop service fromit. Sorry for my comment about bootstrapping, I thought you are developing a standalone Java application, in this case you had to bootstrap UNO to get a component context. Best regards, Mathias -- Mathias Bauer - OpenOffice.org Application Framework Project Lead Please reply to the list only, [EMAIL PROTECTED] is a spam sink. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] GraphicProvider and export of graphics
Jimmy wrote: That's exactly my problem, I can't translate it. It takes some more steps in Java to create a GraphicProvider, and I can't get it to work. Does that mean that XGraphicProvider xGraphicProvider = (XGraphicProvider) UnoRuntime.queryInterface(XGraphicProvider.class, xMSF.createInstance(com.sun.star.graphic.GraphicProvider)); does not return an object? Best regards, Mathias -- Mathias Bauer - OpenOffice.org Application Framework Project Lead Please reply to the list only, [EMAIL PROTECTED] is a spam sink. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[api-dev] GraphicProvider and export of graphics
I'm trying to get hold of the GraphicProvider to store images of a Writer document. Whatever I'm doing I don't seem to be able to create the GraphicProvider with Java. My approach, which doesn't work: XGraphicProvider xGraphicProvider = (XGraphicProvider) UnoRuntime.queryInterface(XGraphicProvider.class, xMSF.createInstance(com.sun.star.graphic.GraphicProvider)); How can I create the GraphicProvider, there's not much documentation on that. On the other hand I've got an image in my writer document, which I get like this: XTextGraphicObjectsSupplier xGraphicSupplier = (XTextGraphicObjectsSupplier) UnoRuntime .queryInterface(XTextGraphicObjectsSupplier.class, xTextDocument); XNameAccess xNamedGraphics = xGraphicSupplier.getGraphicObjects(); XIndexAccess xIndexedGraphics = (XIndexAccess) UnoRuntime .queryInterface(XIndexAccess.class, xNamedGraphics); Object oGraphic = xIndexedGraphics.getByIndex(0); In the end I do need an XGraphic object to use the *storeGraphic*() method of the GraphicProvider. How can I get there from my object (which is an XTextContent)? Thanks - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] GraphicProvider and export of graphics
Hi Jimmy, I'm trying to get hold of the GraphicProvider to store images of a Writer document. the code snippet ... http://codesnippets.services.openoffice.org/ Writer/Writer.ExtractGfx.snip ... seems to do what you want. Regards Stephan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] GraphicProvider and export of graphics
I've tried this already, but thought it would be nice to export the graphics out of the document not out of a zip file (the snippet does only work if the document has been saved). I can't get it to work in Java though and I don't really see why my code isn't working. Cheers Stephan Wunderlich schrieb: Hi Jimmy, I'm trying to get hold of the GraphicProvider to store images of a Writer document. the code snippet ... http://codesnippets.services.openoffice.org/Writer/Writer.ExtractGfx.snip ... seems to do what you want. Regards Stephan - 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]
Re: [api-dev] GraphicProvider and export of graphics
Jimmy schreef: I've tried this already, but thought it would be nice to export the graphics out of the document not out of a zip file (the snippet does only work if the document has been saved). I can't get it to work in Java though and I don't really see why my code isn't working. Cheers Try to translate 1 off the 3 solutoins in basic http://api.openoffice.org/servlets/ReadMsg?listName=devmsgNo=15212 Hopes it helps Fernand Stephan Wunderlich schrieb: Hi Jimmy, I'm trying to get hold of the GraphicProvider to store images of a Writer document. the code snippet ... http://codesnippets.services.openoffice.org/Writer/Writer.ExtractGfx.snip ... seems to do what you want. Regards Stephan - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] GraphicProvider and export of graphics
No matter what I do it seems I'm always getting an Exception even when I'm trying to create a GraphicExportFilter. Object oUnoObject = xMSF.createInstance(com.sun.star.drawing.GraphicExportFilter); The xMSF is not null and does work for other things like for example:. XNamed xChildNamed = (XNamed) UnoRuntime.queryInterface(XNamed.class, xMSF.createInstance(com.sun.star.text.TextSection)); What could be wrong here?! Jimmy schrieb: That's exactly my problem, I can't translate it. It takes some more steps in Java to create a GraphicProvider, and I can't get it to work. Same with the XGraphic. So it's pretty much just that I don't know how to do it in Java...does anyone else know? thanks though Fernand Vanrie wrote: Try to translate 1 off the 3 solutoins in basic http://api.openoffice.org/servlets/ReadMsg?listName=devmsgNo=15212 Hopes it helps Fernand - 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]
Re: [api-dev] GraphicProvider and export of graphics
Hi Jimmy, as no one stepped up as of yet, a very amateurish attempt (could be wrong altogether): No matter what I do it seems I'm always getting an Exception even when I'm trying to create a GraphicExportFilter. Object oUnoObject = xMSF.createInstance(com.sun.star.drawing.GraphicExportFilter); ... cut ... What could be wrong here?! From another example (an ooRexx one which basically uses Java in the simpler ooRexx clothes) it *seems* that when you use a GraphicExportFilter you need to query the com.sun.star.document.XExporter interface object and from that the com.sun.star.document.XFilter (the ooRexx sample do not need the full qualification of the interface name). Then, on the xExporter interface object you would use the method setSourceDocument(xComp) which could be a page's XComponent interface object. On the xFilter interface object you would invoke the filter(filterProps) method supplying the filter properties array. Hope that helps a bit, ---rony P.S.: If the above helps, then you might want to look at other examples from the work from which the above solution stems from (quite a few nutshell examples) could be viewed in here: -- Example 23: Exports two draw pages as individual JPGs. -- From Ahammer, Andreas: http://wi.wu-wien.ac.at/rgf/diplomarbeiten/index.html#bakk_07 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]