redrgreen General User

Joined: 01 May 2004 Posts: 41
|
Posted: Mon Jul 30, 2012 3:40 am Post subject: Mailmerge in sdk3 |
|
|
Hi has anyone used the Mailmerge Service in either Java or C++ with SDK version 3, the code I posted here back in 2004 no longer works (I am getting blank spaces where my mailmerge fields should be) and I am finding it difficult finding any documentation outlining the new proceedure.
Any help much appreciated.
| redrgreen wrote: | Following on from what we did here http://www.oooforum.org/forum/viewtopic.php?t=8702
we can use the query to do a mail merge here is the code
| Code: |
Reference< XInterface > rMM; //our MailMerge Service
Reference< XMultiServiceFactory > rRSM; //represents the remote service manager
|
| Code: |
rRSM = ooConnect();
if(rRSM.is())
{
wxMessageBox("Connected to the office");
rMM = Reference< XInterface >(rRSM->createInstance(
OUString::createFromAscii("com.sun.star.text.MailMerge")));
if(rMM.is())
{
runMerge();
}
}
|
The MailMerge function
| Code: |
void MyFrame::runMerge()
{
Reference< XPropertySet > rProps (rMM, UNO_QUERY);
Any mProps[5];
//set the properties for the mailmerge
mProps[0] <<= OUString::createFromAscii("NewDataSourceName");
mProps[1] <<= OUString::createFromAscii("file:///c:/mailmerge.sxw");
mProps[2] <<= sal_Int32(1); //comandtype = QUERY = 1
mProps[3] <<= sal_Int16(1); //OutputType = PRINTER = 1
mProps[4] <<= OUString::createFromAscii("Query1");
rProps->setPropertyValue(
OUString::createFromAscii("DataSourceName"), mProps[0]);
rProps->setPropertyValue(
OUString::createFromAscii("DocumentURL"), mProps[1]);
rProps->setPropertyValue(
OUString::createFromAscii("CommandType"), mProps[2]);
rProps->setPropertyValue(
OUString::createFromAscii("Command"), mProps[4]);
rProps->setPropertyValue(
OUString::createFromAscii("OutputType"), mProps[3]);
//create an empty sequence of type NamedValue to pass to the execute function
//we could use this to pass parameters to the mailmerge
Sequence< NamedValue > mSeq;
//need the XJob interface of MailMerge service which has one method ie execute()
//to complete the merge
Reference< XJob > rJob (rMM, UNO_QUERY);
rJob->execute(mSeq);
}
|
|
|
|