Hi Andreas,
which url must i use in order to construct a new OpenOffice.org base
document with the java api.
Database Documents differ from other documents ... you need to define a
datasource for them and they have to exist on your hard disk ... the
following code should do what you want ...
----------------------------------------------------------
XComponentContext xContext =
com.sun.star.comp.helper.Bootstrap.bootstrap();
XMultiComponentFactory xMCF = xContext.getServiceManager();
// create a new instance of the the desktop
Object oDesktop = xMCF.createInstanceWithContext(
"com.sun.star.frame.Desktop", xContext );
// query the desktop object for the XComponentLoader
XComponentLoader xCLoader = ( XComponentLoader )
UnoRuntime.queryInterface(
XComponentLoader.class, oDesktop );
//create a new datasource
Object dataSource = xMCF.createInstanceWithContext(
"com.sun.star.sdb.DataSource", xContext);
XPropertySet xSrcProp = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, dataSource);
xSrcProp.setPropertyValue("URL", "sdbc:embedded:hsqldb");
XDocumentDataSource xDDS = (XDocumentDataSource)
UnoRuntime.queryInterface(XDocumentDataSource.class, dataSource);
XStorable store = (XStorable) UnoRuntime.queryInterface(
XStorable.class,xDDS.getDatabaseDocument());
String aFile = "file:///<wherever you want it>/testdb.odb";
//store it
store.storeAsURL(aFile, new PropertyValue[] { });
//load it again
xCLoader.loadComponentFromURL(
aFile, "_blank", 0, new PropertyValue[]{});
----------------------------------------------------------
Hope that helps
Regards
Stephan
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]