Hi Oliver, *,
On Mon, Feb 12, 2007 at 11:19:27AM +0100, Oliver Specht wrote:
> Christian Lohmaier wrote:
> >
> >Before I waste my time again I'd rather ask here:
> >Is it possible at all to register a mail-merge Listener?
> >
> >My first attempts failed. I don't get any events/the method
> >notifyMailMergeEvent of my listener never is called.
>
> at least the code (sw/source/ui/uno/unomailmerge.cxx,
> sw/source/ui/dbui/dbmgr.cxx) says it is possible;-)
>
> I didn't verify that it actually works but added listeners should be
> notified for each print/save operation that is done.
I guess then it's time to show my code, maybe I just do something very
wrong and you can point me to the right direction:
package org.openoffice.cloph.postnet.comp;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.lib.uno.helper.Factory;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.registry.XRegistryKey;
import com.sun.star.text.MailMergeEvent;
import com.sun.star.text.XMailMergeBroadcaster;
import com.sun.star.text.XMailMergeListener;
import com.sun.star.uno.Exception;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XComponentContext;
public final class PostNetJavaImpl extends WeakBase
implements com.sun.star.lang.XServiceInfo,
org.openoffice.cloph.postnet.XPostnetjava
{
private final XComponentContext m_xContext;
private static final String m_implementationName =
PostNetJavaImpl.class.getName();
private static final String[] m_serviceNames = {
"org.openoffice.cloph.postnet.Postnetjava" };
public PostNetJavaImpl( XComponentContext context )
{
m_xContext = context;
};
public static XSingleComponentFactory __getComponentFactory( String
sImplementationName ) {
XSingleComponentFactory xFactory = null;
if ( sImplementationName.equals( m_implementationName ) )
xFactory = Factory.createComponentFactory(PostNetJavaImpl.class,
m_serviceNames);
return xFactory;
}
public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey
) {
return Factory.writeRegistryServiceInfo(m_implementationName,
m_serviceNames,
xRegistryKey);
}
// com.sun.star.lang.XServiceInfo:
public String getImplementationName() {
return m_implementationName;
}
public boolean supportsService( String sService ) {
int len = m_serviceNames.length;
for( int i=0; i < len; i++) {
if (sService.equals(m_serviceNames[i]))
return true;
}
return false;
}
public String[] getSupportedServiceNames() {
return m_serviceNames;
}
private static class MailmergeEventListener implements XMailMergeListener {
public void notifyMailMergeEvent(MailMergeEvent mergeEvent) {
System.out.println("Listener called :-)");
}
}
// org.openoffice.cloph.postnet.XPostnetjava:
public void addMMEListener()
{
MailmergeEventListener MMListener = new MailmergeEventListener();
XMultiComponentFactory xMCF = m_xContext.getServiceManager();
Object mailMerge = null;
try {
mailMerge = xMCF.createInstanceWithContext(
"com.sun.star.text.MailMerge", m_xContext);
} catch (Exception e) {
e.printStackTrace();
}
XMailMergeBroadcaster xMMB = null;
xMMB = (XMailMergeBroadcaster) UnoRuntime.queryInterface(
XMailMergeBroadcaster.class, mailMerge);
xMMB.addMailMergeEventListener(MMListener);
System.out.println("added listener");
}
}
ciao
Christian
--
NP: nichts
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]