Giuseppe,
>xIdFactory.createContentIdentifier(aThePackageUrl+"/META-INF/manifest.xml");
I suppose aThePackageUrl starts with "vnd.sun.star.pkg:". Use
"vnd.sun.star.zip:" instead. pkg denotes an OOo document, where
manifest.xml is an implementation detail and not directly accessible via
UCB API. zip gives you access to the raw zip container content.
- Kai.
On 19.03.2008 12:53 Uhr, Giuseppe Castagno wrote:
Hi all,
After I successfully opened a package (e.g. an ODT document) with Java
using UCB low level APIs, I tried to read the content of one of the
contained streams.
With no luck so far. Is there somewhere some example about how to do that?
After I successfully opened it with (sorry for the ugly indentation):
<Java code>
...
XMultiServiceFactory xMSF = ....
...
Object oUCB = xMSF.createInstanceWithArguments(
"com.sun.star.ucb.UniversalContentBroker", keys );
// Obtain required UCB interfaces
XContentIdentifierFactory xIdFactory =
(XContentIdentifierFactory)UnoRuntime.queryInterface(XContentIdentifierFactory.class,
oUCB);
XContentProvider xProvider =
(XContentProvider)UnoRuntime.queryInterface(XContentProvider.class, oUCB);
...
XContentIdentifier xIdPackStream =
xIdFactory.createContentIdentifier(aThePackageUrl+"/META-INF/manifest.xml");
XContent xPackStreamContent = xProvider.queryContent(xIdPackStream);
String contentF = xPackStreamContent.getContentType();
System.out.println("root folder type: " + contentF);
if(
contentF.contentEquals("application/vnd.sun.star.pkg-stream" )) {
System.out.println("Found a META-INF/metafile.xml
element (the root)\n");
//now open the stream content and try to read it
OpenCommandArgument2 aArg = new OpenCommandArgument2();
aArg.Mode = OpenMode.ALL;// FOLDER, DOCUMENTS -> simple
filter
aArg.Priority = 32768;// Ignored by most implementations
// Fill info for the properties wanted.
Property[] aProps = new Property[2];
Property prop1 = new Property();
prop1.Name = "Title";
prop1.Handle = -1;// n/a
aProps[0] = prop1;
Property prop2 = new Property();
prop2.Name = "IsFolder";
prop2.Handle = -1;// n/a
aProps[1] = prop2;
XDynamicResultSet xSet;
aArg.Properties = aProps;
Object oSet = executeCommand(xPackStreamContent,
"open", aArg);
//convert the object from Object to XDynamicResultSet
Type aType = AnyConverter.getType(oSet);
xSet = (XDynamicResultSet) AnyConverter.toObject(new
com.sun.star.uno.Type
(com.sun.star.ucb.XDynamicResultSet.class), oSet);
// now list the xSet elements
XResultSet xResultSet = xSet.getStaticResultSet();
</code>
where executeCommand() is basically the one found here [1],
It seems the wrong approach since xResultSet throws an exception.
Any help is greatly appreciated.
--
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]