|
List Info
Thread: Determining graphic mime types with Java
|
|
| Determining graphic mime types with Java |

|
2006-11-28 16:23:03 |
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.
--
Ian Shields <ian cybershields.com>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| Determining graphic mime types with Java |

|
2006-11-28 17:24:51 |
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)).g
etInputStream()
oOriginalGraphic.getPropertyValue("MimeType")
I few weeks ago I asked this list for an "URL" to
the ZipFile, but no
answer so far
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: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| Determining graphic mime types with Java |

|
2006-11-29 04:59:30 |
Thanks Fernand.
I tried this tonight but couldn't figure out the
corresponding
interfaces in Java (if they exist). I think I might need an
XDocumentSubStorageSupplier, but it's a mystery to me how I
would create
one.
This area seems to be a hole in both implementation and
documentation.
On Tue, 2006-11-28 at 18:24 +0100, 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)).g
etInputStream()
> oOriginalGraphic.getPropertyValue("MimeType")
>
> I few weeks ago I asked this list for an
"URL" to the ZipFile, but no
> answer so far
>
> Hope it helps a bit
> Fernand
--
Ian Shields <ian cybershields.com>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
| Determining graphic mime types with Java |

|
2006-11-29 10:03:24 |
Ian Shields schreef:
> Thanks Fernand.
>
> I tried this tonight but couldn't figure out the
corresponding
> interfaces in Java (if they exist). I think I might
need an
> XDocumentSubStorageSupplier, but it's a mystery to me
how I would create
> one.
>
Do you uses the "ObjectInspector":
http://api.openoffice.org/Projects/ObjectIns
pector/Inspector.uno.pkg
I now nothing about Java but after selecting the pictures I
found a lot
of info about the "SubStorage"
> This area seems to be a hole in both implementation and
documentation.
>
> On Tue, 2006-11-28 at 18:24 +0100, 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)).g
etInputStream()
>>
oOriginalGraphic.getPropertyValue("MimeType")
>>
>> I few weeks ago I asked this list for an
"URL" to the ZipFile, but no
>> answer so far
>>
>> Hope it helps a bit
>> Fernand
>>
>
>
------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribe api.openoffice.org
For additional commands, e-mail: dev-help api.openoffice.org
|
|
[1-4]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|