Hi Ian, Ian Shields wrote: > I'm still working on my filter and trying to understand how to extract > graphics from a Writer document in Java. So far, I cannot find the Java > equivalents to certain parts of the snippet at > http://codesnippets.services.openoffice.org/Writer/Writer.ExtractGfx.snip > > In particular, the closest thing I can find to the oZipArchive in the > example is XZipFileAccess which I created as follows: > Object zipArgs[] = new Object[1]; > zipArgs[0] = xSource.getURL(); > XZipFileAccess xZipFileAccess = > (XZipFileAccess) UnoRuntime.queryInterface( > XZipFileAccess.class, > m_xMCF.createInstanceWithArgumentsAndContext( > "com.sun.star.packages.zip.ZipFileAccess", > zipArgs, m_Ctx));
Sorry, but this sourcecode has nothing to do with the example provided by the link you have mentioned. Why the com.sun.star.packages.zip.ZipFileAccess service is used here, the example clearly uses com.sun.star.packages.Package service. All the functionality used in the example should work well through java bridge. The documentation for com.sun.star.packages.Package service can be found using following link http://api.openoffice.org/docs/common/ref/com/sun/star/packages/Package.html Hope that helps. Best regards, Mikhail. >>From a graphic property set I can extract a graphic URL > String graphicURL = AnyConverter.toString(xGraphicPropSet > .getPropertyValue("GraphicURL")); > which gives me something like: > vnd.sun.star.GraphicObject:10000000000003590000036584C7606C > > I have a gif and a jpg file in the doc I am working on and a file > Pictures/10000000000003590000036584C7606C.jpg > in the compressed .odt file, so I figure there ought to be some way of > determining the mime type programatically, but I'm at a standstill. > > If I use > PropertyValue[] mediaProps = new PropertyValue[1]; > mediaProps[0] = new PropertyValue(); > mediaProps[0].Name = "URL"; > mediaProps[0].Value = graphicURL; > and then > XPropertySet xGraphicProps = (XPropertySet) > UnoRuntime.queryInterface(XPropertySet.class, > xGraphicProvider.queryGraphicDescriptor(mediaProps)); > The property set claims to have a mimetype property, but it is an empty > string. I also tried > XGraphic xGraphic = (XGraphic) > UnoRuntime.queryInterface( > XGraphic.class, > xGraphicProvider.queryGraphic(mediaProps)); > And got a null XGraphic object returned. > > I am able to extract the 10000000000003590000036584C7606C part of the > above URL and use it to get an XInputStream > String graphicURLPrefix = > graphicURL.substring("vnd.sun.star.GraphicObject:".length()); > XInputStream graphicFile = (XInputStream) > UnoRuntime.queryInterface( > XInputStream.class, > xZipFileAccess.getStreamByPattern("*Pictures/" > + graphicURLPrefix + "*")); > from which I can read the file length, so I'm making some progress, > although I still can't figure out the mime type. > > I'm left with at least two problems. > > 1) There doesn't seem to be any equivalent in Java/Uno to the > getByHierarchicalName call used in the snippet. It doesn't exist in > XZipFileAccess as far as I can see. > > 2) Is there somethign wrong with the way I set up the media properties > for the graphics progider query? It seems that the > vnd.sun.star.GraphicObject:10000000000003590000036584C7606C isn't an > adequate URL or I'm missing something else in the media properties. > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
