Hi Fernand,
Fernand Vanrie wrote:
> Ian,
>
> In Basic I used the "DocumentStorage" and then out of an
> "InputStream" the MimeType
>
> oPictures = oDocument.getDocumentStorage.getbyname("Pictures")
> mFiles() = oPictures.getElementNames
> oOriginalGraphic =
> getGraphDescritorFromStream(oPictures.getByName(mFiles(j)).getInputStream()
> oOriginalGraphic.getPropertyValue("MimeType")
Yes, this solution works well when a document is already opened. But, if
the only purpose is to access a zipfile, opening the document is not an
optimal way.
>
> I few weeks ago I asked this list for an "URL" to the ZipFile, but no
> answer so far :-)
Sorry, if I remember correctly the question was about converting of
graphic URL to ZipFile URL. You even have proposed a solution based on
the mentioned example asking whether there is a better one. So I would
treat no answer in this case as a sign that there is no better solution. ;)
Best regards,
Mikhail.
>
> Hope it helps a bit
> Fernand
>
> an Shields schreef:
>
>>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));
>>>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]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]