Once more about mailmerging and registering queries using from remote:
------------------------8<------------------------ XComponentContext xComponentContext = new LocalOfficeConnection().getComponentContext(); XMultiComponentFactory xMCF = xComponentContext.getServiceManager(); XMultiServiceFactory xMSF = (XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xMCF);
try {
XComponentLoader xComponentLoader = (XComponentLoader)
UnoRuntime.queryInterface(XComponentLoader.class,
xMCF.createInstanceWithContext( "com.sun.star.frame.Desktop",
xComponentContext));
PropertyValue[] loadProps = new PropertyValue[0];if( preview ) {
XTextDocument oDoc = (XTextDocument)
UnoRuntime.queryInterface(XTextDocument.class,
xComponentLoader.loadComponentFromURL( templateFile, "_blank", 0,
loadProps));
Object dbContext = xMSF.createInstance("com.sun.star.sdb.DatabaseContext");
XNameAccess nameAccess =
(XNameAccess)UnoRuntime.queryInterface(XNameAccess.class, dbContext);
Object dataSource = nameAccess.getByName("mailMerge");if( dataSource != null ) {
System.out.println("before registering!");
registerQuery(dataSource);
System.out.println("after registering!");
} else {
// TODO MESSAGE BOX
}
}private void registerQuery(Object dataSource) throws Exception {
XQueryDefinitionsSupplier xQuerySup =
(XQueryDefinitionsSupplier)UnoRuntime.queryInterface(XQueryDefinitionsSupplier.class,dataSource);
XNameAccess xQDefs = xQuerySup.getQueryDefinitions();
XSingleServiceFactory xSingleFac =
(XSingleServiceFactory)UnoRuntime.queryInterface(XSingleServiceFactory.class,
xQDefs);
XPropertySet xProp = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xSingleFac.createInstance());
xProp.setPropertyValue("Command",getQuery());
xProp.setPropertyValue("EscapeProcessing", new Boolean(true));XNameContainer xCont = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xQDefs);
if( xCont.hasByName("mailMergeQuery") ) {
xCont.replaceByName("mailMergeQuery",xProp);
} else {
xCont.insertByName("mailMergeQuery",xProp);
}
}
------------------------8<------------------------
when there's is no mailMergeQuery everything works as expected, the query is inserted and can be used, but when using replaceByName the oo-process coredumps. I don't know if the core-dump is useful but I could provide it :-(
Tom
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
