Dear All:
I am trying to play with the MailMerger java possibly written more than 5 years
ago.
I have not a few problems, possibly my open office is too new, version 3.1.1.
1. DataSource should be converted to XDataBaseDocument first before
converted to XModel (Fixed).
XDocumentDataSource xDocumentDataSource = (XDocumentDataSource)
UnoRuntime.queryInterface(XDocumentDataSource.class, dataSource);
XOfficeDatabaseDocument xDatabaseDocument =
xDocumentDataSource.getDatabaseDocument();
XStorable store = (
XStorable)UnoRuntime.queryInterface(XStorable.class, xDatabaseDocument);
XModel model = ( XModel)UnoRuntime.queryInterface(XModel.class,
xDatabaseDocument);
store.storeAsURL("file:///C:/ToBeDeleted/Documents/test7.odb",
model.getArgs());
/**** ABOVE is working ****/
2. Failed with saving the template.
/*************Follwing code does not work ****/
PropertyValue[] propertyvalue = new PropertyValue[2];
propertyvalue[0] = new PropertyValue();
propertyvalue[0].Name = "Overwrite";
propertyvalue[0].Value = new Boolean(true);
propertyvalue[1] = new PropertyValue();
propertyvalue[1].Name = "FilterName";
//// Here I even changed the FilteName, it still does not working properly.
//// Definitely I can use dispatcher to do "saveAs"
propertyvalue[1].Value = "writer_StarOffice_XML_Writer_Template";
// Store the document
xStorable.storeAsURL("///C:/ToBeDeleted/Documents/my.stw",
propertyvalue);
3. Failed with the merging.
/**** Following code does not work ****/
oObjProps.setPropertyValue("DataSourceName", mDataSourceName);
oObjProps.setPropertyValue("Command", mTableName);
oObjProps.setPropertyValue("CommandType",
new Integer(com.sun.star.sdb.CommandType.TABLE));
oObjProps.setPropertyValue("OutputType",
new Short(com.sun.star.text.MailMergeType.PRINTER));
oObjProps.setPropertyValue("DocumentURL", mFileURL);
///Exception throw at the above line
4. Failed with the XConnection to the datasource.
We may need to add the connection to the text.MailMerger
But it failed to get the connection.
oObjProps.setPropertyValue("ActiveConnection",
datasource.getConnection('', '''));
Anyone has the latest java MailMerger for Open Office 3.1.1?
Many thanks for all your efforts and time.
Best wishes,
Ted
_________________________________________________________________
Use Messenger in your Hotmail inbox Find out how here
http://windowslive.ninemsn.com.au/article.aspx?id=823454