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.

--
Kind Regards,
Giuseppe Castagno
Acca Esse http://www.acca-esse.eu
[EMAIL PROTECTED]
[EMAIL PROTECTED]
[1] http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/UCB/Executing_Content_Commands

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to