Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Christian, Hi Noelson, *, On Thu, Mar 08, 2007 at 09:35:26AM -0300, Noelson Duarte wrote: The service OfficeDocument has an interface XEventBroadcast to register listeners of event documents. There are two events of interest here: OnMailMerge e OnMailMergeFinished. Maybe this is the way to do your work (only a guess). I assume these are the same as you can reach wia Tools|Macros → Organize → Assign (although OnMailMergeFinished isn't listed there) Unfortunately, this doesn't work for the following reasons: * Event is only triggered using the old (IMHO better) dialog, not with the new one * Only one event is triggered, so I have no way to edit the individual documents You're right. Here, after a try, no success. And looking at http://api.openoffice.org/docs/common/ref/com/sun/star/document/Events.html What is the difference between OnSaveDone and OnSaveFinished? I don't know and Developer's Guide doesn't list OnSaveFinished. Thanks for your suggestion though ciao Christian -- NP: Kashmir 9:41 - For Srila Prabhupada Thanks. Noelson - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Noelson, *, On Thu, Mar 08, 2007 at 09:35:26AM -0300, Noelson Duarte wrote: The service OfficeDocument has an interface XEventBroadcast to register listeners of event documents. There are two events of interest here: OnMailMerge e OnMailMergeFinished. Maybe this is the way to do your work (only a guess). I assume these are the same as you can reach wia Tools|Macros → Organize → Assign (although OnMailMergeFinished isn't listed there) Unfortunately, this doesn't work for the following reasons: * Event is only triggered using the old (IMHO better) dialog, not with the new one * Only one event is triggered, so I have no way to edit the individual documents And looking at http://api.openoffice.org/docs/common/ref/com/sun/star/document/Events.html What is the difference between OnSaveDone and OnSaveFinished? Thanks for your suggestion though ciao Christian -- NP: Kashmir 9:41 - For Srila Prabhupada - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Christian, The service OfficeDocument has an interface XEventBroadcast to register listeners of event documents. There are two events of interest here: OnMailMerge e OnMailMergeFinished. Maybe this is the way to do your work (only a guess). HTH - Original Message - From: Christian Lohmaier [EMAIL PROTECTED] To: dev@api.openoffice.org Sent: Wednesday, March 07, 2007 4:44 PM Subject: Re: [api-dev] Registering an XMailMergeListener - possible at all? Hi Marc, On Wed, Mar 07, 2007 at 07:31:52PM +0100, Marc Santhoff wrote: Am Mittwoch, den 07.03.2007, 14:59 +0100 schrieb Christian Lohmaier: http://api.openoffice.org/servlets/ReadMsg?listName=devmsgNo=11328 But at least it showshow this stuff is expected to work. [...] (and indeed the cited sample doesn't use the mailmergelistener at all) I guess I'll just file an issue to have something like you need to create your own mail-merge to use the listener to the docs. Please do that, it happens that some framework designs from the thinking lab are conceptually nice and orthogonal but not well suited for practically using them. ??? Why not add a hint for other users that they cannot use the mailmerge-listener to hook-up into the existing wizard? That would save those that come after me the fuzz about trying with no success and asking on the mailinglist and waiting for an answer, only to get to know that trying with the mailmerge-listener was wasted time since it cannot be used that way? From having a quick look at the code at least the setup of a database connection is shown, too. Yes, but this still would require me to write code to ask the user for the requested database and to duplicate all the stuff the current mail-merge wizard has builtin. (I personally don't like the wizard at all, but I don't want to write one myself either) Okay, thinking about it two ideas come to my mind: 1. Hacking up^w Improving the wizard Honestly, I like the OOo 1.x way much better. No fancy wizard. Just drag the fields into your document where you want them, optionally add some conditions (that's where help from a wizard would come handy), then select the set of rows you want to have included and fire off the mailmerge. If I'm honest too, I must admit that I'm only rarely using 2.x and never did use the wizard myself. Isn't it possible to switch that thing off? It is somewhat possible. You must edit your toolbar to add an icon for the old mailmerge. The new wizard and the old way have the same name, so you have to guess. You cannot add this icon to the database-beamer toolbar, you have to add it to the default toolbar. And even worse: you cannot select the datarows before launching the wizard, the selection is lost. Instead the old-style-dialog will open a new dialog that has a grid control that showst the databasetable. There you can highlight the rows that should be part of the mailmerge. I'll try mail merge on 2.x later on ... Please do. And you'll shake your head... For me 1.1.[3|5] is still working well in most situations. ;) Choose whether print/save and maybe offer a way to see a preview. That is my view of a useful wizard. Sounds good, the preview widget is already in the code somewhere. On the other hand: you might have choosen the wrong task for beginners level. You got me totally wrong. I do not intend to write a new wizard. I was seeking an easy solution to integrate the functionality of my addon. Both for me, as well for the user who'll use the addon. I thought of adding a button run the merge with the addon, that would just launch OOo own's mail-merge wizard, but with the listener added, so that I could modify the created documents (but now I know that this doesn't work)... Everything else, especially hacking OOo itself is much of an effort (and as you wrote yourself: Not something for a beginner like me :-) ciao Christian -- NP: Evanescence - Like You - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 268.18.7/713 - Release Date: 7/3/2007 09:24 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Marc, *, On Sat, Mar 03, 2007 at 05:29:12AM +0100, Marc Santhoff wrote: Am Freitag, den 02.03.2007, 16:09 +0100 schrieb Christian Lohmaier: On Mon, Feb 19, 2007 at 06:32:12PM +0100, Marc Santhoff wrote: Am Montag, den 19.02.2007, 15:43 +0100 schrieb Christian Lohmaier: [mailmerge-listener] [...] I think I found the mail you're refering to, but unforutnately it doesn't use the wizard-functionality, but instead requests the database/table to use in the merge as arguments. http://api.openoffice.org/servlets/ReadMsg?listName=devmsgNo=11328 But at least it showshow this stuff is expected to work. Yes, the basic-macro already hinted to that... :-( I personally think this doesn't make too much sense then. If you have to set up all yourself, then you can do (have to basically if you want the user to be able to choose only parts of the dataset) the additional step to iterate through the database as well and the mailmergelistener is pretty useless/not much of a shortcut then. (and indeed the cited sample doesn't use the mailmergelistener at all) I guess I'll just file an issue to have something like you need to create your own mail-merge to use the listener to the docs. From having a quick look at the code at least the setup of a database connection is shown, too. Yes, but this still would require me to write code to ask the user for the requested database and to duplicate all the stuff the current mail-merge wizard has builtin. (I personally don't like the wizard at all, but I don't want to write one myself either) Okay, thinking about it two ideas come to my mind: 1. Hacking up^w Improving the wizard Honestly, I like the OOo 1.x way much better. No fancy wizard. Just drag the fields into your document where you want them, optionally add some conditions (that's where help from a wizard would come handy), then select the set of rows you want to have included and fire off the mailmerge. Choose whether print/save and maybe offer a way to see a preview. That is my view of a useful wizard. The sources should be somewhere near the database wizard. That is found here: http://installation.openoffice.org/source/browse/installation/wizards As written earlier, I'd love to avoid any unnecessary stuff. I'm a novice/beginner. So hacking together a complete wizard/replacement is just over my capabilities. It could be a nice feature to have ... although I don't know if there is something similar in other countries or if this would be german only. In that case it would be US-only (the postnet barcodes) The principle however could apply to other use-cases as well of course. 2. Trying to use one of the event hooks at the document in process There is an event Serienbriefe drucken, or maybe Dokument drucken will fit your needs. I think you could hook to one of them and trigger your macro there. Would still be a hack though... And not sure whether I'll get the individual documents (with the individual data) then, and not only the base document... The only question left then is, whether the hook is called only once at the start of mail merging or for each document with the actual data merged in already. Exactly.. ciao Christian -- NP: nichts - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Am Mittwoch, den 07.03.2007, 14:59 +0100 schrieb Christian Lohmaier: http://api.openoffice.org/servlets/ReadMsg?listName=devmsgNo=11328 But at least it showshow this stuff is expected to work. Yes, the basic-macro already hinted to that... :-( I personally think this doesn't make too much sense then. If you have to set up all yourself, then you can do (have to basically if you want the user to be able to choose only parts of the dataset) the additional step to iterate through the database as well and the mailmergelistener is pretty useless/not much of a shortcut then. (and indeed the cited sample doesn't use the mailmergelistener at all) I guess I'll just file an issue to have something like you need to create your own mail-merge to use the listener to the docs. Please do that, it happens that some framework designs from the thinking lab are conceptually nice and orthogonal but not well suited for practically using them. From having a quick look at the code at least the setup of a database connection is shown, too. Yes, but this still would require me to write code to ask the user for the requested database and to duplicate all the stuff the current mail-merge wizard has builtin. (I personally don't like the wizard at all, but I don't want to write one myself either) Okay, thinking about it two ideas come to my mind: 1. Hacking up^w Improving the wizard Honestly, I like the OOo 1.x way much better. No fancy wizard. Just drag the fields into your document where you want them, optionally add some conditions (that's where help from a wizard would come handy), then select the set of rows you want to have included and fire off the mailmerge. If I'm honest too, I must admit that I'm only rarely using 2.x and never did use the wizard myself. Isn't it possible to switch that thing off? I'll try mail merge on 2.x later on ... For me 1.1.[3|5] is still working well in most situations. ;) Choose whether print/save and maybe offer a way to see a preview. That is my view of a useful wizard. Sounds good, the preview widget is already in the code somewhere. On the other hand: you might have choosen the wrong task for beginners level. Marc - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Marc, On Wed, Mar 07, 2007 at 07:31:52PM +0100, Marc Santhoff wrote: Am Mittwoch, den 07.03.2007, 14:59 +0100 schrieb Christian Lohmaier: http://api.openoffice.org/servlets/ReadMsg?listName=devmsgNo=11328 But at least it showshow this stuff is expected to work. [...] (and indeed the cited sample doesn't use the mailmergelistener at all) I guess I'll just file an issue to have something like you need to create your own mail-merge to use the listener to the docs. Please do that, it happens that some framework designs from the thinking lab are conceptually nice and orthogonal but not well suited for practically using them. ??? Why not add a hint for other users that they cannot use the mailmerge-listener to hook-up into the existing wizard? That would save those that come after me the fuzz about trying with no success and asking on the mailinglist and waiting for an answer, only to get to know that trying with the mailmerge-listener was wasted time since it cannot be used that way? From having a quick look at the code at least the setup of a database connection is shown, too. Yes, but this still would require me to write code to ask the user for the requested database and to duplicate all the stuff the current mail-merge wizard has builtin. (I personally don't like the wizard at all, but I don't want to write one myself either) Okay, thinking about it two ideas come to my mind: 1. Hacking up^w Improving the wizard Honestly, I like the OOo 1.x way much better. No fancy wizard. Just drag the fields into your document where you want them, optionally add some conditions (that's where help from a wizard would come handy), then select the set of rows you want to have included and fire off the mailmerge. If I'm honest too, I must admit that I'm only rarely using 2.x and never did use the wizard myself. Isn't it possible to switch that thing off? It is somewhat possible. You must edit your toolbar to add an icon for the old mailmerge. The new wizard and the old way have the same name, so you have to guess. You cannot add this icon to the database-beamer toolbar, you have to add it to the default toolbar. And even worse: you cannot select the datarows before launching the wizard, the selection is lost. Instead the old-style-dialog will open a new dialog that has a grid control that showst the databasetable. There you can highlight the rows that should be part of the mailmerge. I'll try mail merge on 2.x later on ... Please do. And you'll shake your head... For me 1.1.[3|5] is still working well in most situations. ;) Choose whether print/save and maybe offer a way to see a preview. That is my view of a useful wizard. Sounds good, the preview widget is already in the code somewhere. On the other hand: you might have choosen the wrong task for beginners level. You got me totally wrong. I do not intend to write a new wizard. I was seeking an easy solution to integrate the functionality of my addon. Both for me, as well for the user who'll use the addon. I thought of adding a button run the merge with the addon, that would just launch OOo own's mail-merge wizard, but with the listener added, so that I could modify the created documents (but now I know that this doesn't work)... Everything else, especially hacking OOo itself is much of an effort (and as you wrote yourself: Not something for a beginner like me :-) ciao Christian -- NP: Evanescence - Like You - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Marc, *, On Mon, Feb 19, 2007 at 06:32:12PM +0100, Marc Santhoff wrote: Am Montag, den 19.02.2007, 15:43 +0100 schrieb Christian Lohmaier: [mailmerge-listener] If I cannot use the builtin wizard, but have to ask the user for the desired Database, etc myself and have to start the mailmerge from within my extension, then this would be far too much effort and thus pretty useless to me. You could search the archives of this list for: From [EMAIL PROTECTED] Mon Sep 27 14:43:34 2004 Subject: Re: [api-dev] mailmerge api usage Message-id: [EMAIL PROTECTED] There you can find a complete working example of doing MailMerge written in Java. If it is not on the list please tell me, I'll forward it to you. I think I found the mail you're refering to, but unforutnately it doesn't use the wizard-functionality, but instead requests the database/table to use in the merge as arguments. http://api.openoffice.org/servlets/ReadMsg?listName=devmsgNo=11328 From having a quick look at the code at least the setup of a database connection is shown, too. Yes, but this still would require me to write code to ask the user for the requested database and to duplicate all the stuff the current mail-merge wizard has builtin. (I personally don't like the wizard at all, but I don't want to write one myself either) [...]--- % java MailMerger -merge URL of template file Data Source name Table name I don't want to deal with selecting the datasource/table at all. I only want to replace either a field or a bookmark/placeholder in the merge-document before it is printed/saved. /--- So it shows much more than doing MailMerge ... Yes, it shows how one could do this, but I want to avoid all this... I think I'll just tell the user to use the modify document button and then run the macro. Not perfect, but still far easier than setting up a mail-merge from scratch. ciao Christian -- NP: The Smashing Pumpkins - Porcelina Of The Vast Oceans - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Moin Christian, Am Freitag, den 02.03.2007, 16:09 +0100 schrieb Christian Lohmaier: Hi Marc, *, On Mon, Feb 19, 2007 at 06:32:12PM +0100, Marc Santhoff wrote: Am Montag, den 19.02.2007, 15:43 +0100 schrieb Christian Lohmaier: [mailmerge-listener] If I cannot use the builtin wizard, but have to ask the user for the desired Database, etc myself and have to start the mailmerge from within my extension, then this would be far too much effort and thus pretty useless to me. You could search the archives of this list for: From [EMAIL PROTECTED] Mon Sep 27 14:43:34 2004 Subject: Re: [api-dev] mailmerge api usage Message-id: [EMAIL PROTECTED] There you can find a complete working example of doing MailMerge written in Java. If it is not on the list please tell me, I'll forward it to you. I think I found the mail you're refering to, but unforutnately it doesn't use the wizard-functionality, but instead requests the database/table to use in the merge as arguments. http://api.openoffice.org/servlets/ReadMsg?listName=devmsgNo=11328 But at least it showshow this stuff is expected to work. From having a quick look at the code at least the setup of a database connection is shown, too. Yes, but this still would require me to write code to ask the user for the requested database and to duplicate all the stuff the current mail-merge wizard has builtin. (I personally don't like the wizard at all, but I don't want to write one myself either) Okay, thinking about it two ideas come to my mind: 1. Hacking up^w Improving the wizard The sources should be somewhere near the database wizard. That is found here: http://installation.openoffice.org/source/browse/installation/wizards It could be a nice feature to have ... although I don't know if there is something similar in other countries or if this would be german only. 2. Trying to use one of the event hooks at the document in process There is an event Serienbriefe drucken, or maybe Dokument drucken will fit your needs. I think you could hook to one of them and trigger your macro there. The only question left then is, whether the hook is called only once at the start of mail merging or for each document with the actual data merged in already. HTH, Marc - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Noëlson, Marc, *, On Fri, Feb 16, 2007 at 04:54:13PM -0300, Noelson Duarte wrote: Does anybody have the solution or even a working sample at hand? I'd really appreciate it. You'll find a sample (OOoBasic) here: http://www.oooforum.org/forum/viewtopic.phtml?t=8393 oProps must be Variant, not object here, but apart form that this macro shows that it is possible to use a mailmergelistener. Perhaps it helps you. That snippet, along with Marcs answer helped somewhat: I know that the mailmerge listener is not suitable for my case. If I cannot use the builtin wizard, but have to ask the user for the desired Database, etc myself and have to start the mailmerge from within my extension, then this would be far too much effort and thus pretty useless to me. If there would be a way to still use the wizard however, then this could work... Mut the mailmerge-object requires a documentURL and other properties before it can be executed. (and the documentURL would require the user to save the document first, etc...), so I doubt that this is possible :-( So thank you very much for the pointer answers. ciao Christian -- NP: Marilyn Manson - Kinderfeld - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Am Montag, den 19.02.2007, 15:43 +0100 schrieb Christian Lohmaier: Hi Noëlson, Marc, *, N'Abend, On Fri, Feb 16, 2007 at 04:54:13PM -0300, Noelson Duarte wrote: Does anybody have the solution or even a working sample at hand? I'd really appreciate it. You'll find a sample (OOoBasic) here: http://www.oooforum.org/forum/viewtopic.phtml?t=8393 oProps must be Variant, not object here, but apart form that this macro shows that it is possible to use a mailmergelistener. Perhaps it helps you. That snippet, along with Marcs answer helped somewhat: I know that the mailmerge listener is not suitable for my case. If I cannot use the builtin wizard, but have to ask the user for the desired Database, etc myself and have to start the mailmerge from within my extension, then this would be far too much effort and thus pretty useless to me. You could search the archives of this list for: From [EMAIL PROTECTED] Mon Sep 27 14:43:34 2004 Subject: Re: [api-dev] mailmerge api usage Message-id: [EMAIL PROTECTED] There you can find a complete working example of doing MailMerge written in Java. If it is not on the list please tell me, I'll forward it to you. From having a quick look at the code at least the setup of a database connection is shown, too. The solution for the problem of touching each document is made by using fields in a doc template, I think you can adopt this for inserting barcode pics instead of text snippets. From the surrounding explanations: --- This command will: - Open up a new Writer document - Create a new Data Source with the name provided - Configure the data source to load tables from the Data Source directory - Configure the data source to use , as the value separator - Insert each of the headings in the first row of the table specified as fields in the Writer document - Save the Writer document as a OpenOffice.org Writer template with the name provided ... % java MailMerger -merge URL of template file Data Source name Table name This will perform a MailMerge using the template file, data source and table names provided. These should be the same names that you used in the -create command /--- So it shows much more than doing MailMerge ... If there would be a way to still use the wizard however, then this could work... Mut the mailmerge-object requires a documentURL and other properties before it can be executed. (and the documentURL would require the user to save the document first, etc...), so I doubt that this is possible :-( So thank you very much for the pointer answers. You're welcome- Marc - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Marc, *, On Wed, Feb 14, 2007 at 11:22:45PM +0100, Marc Santhoff wrote: Am Mittwoch, den 14.02.2007, 20:32 +0100 schrieb Christian Lohmaier: On Wed, Feb 14, 2007 at 07:14:37PM +0100, Steffen Grund wrote: [throwing away the mail-merge-object] From your other mail: [variable scope: only within the method] ... and if this exit point is reached the object is lost because there is no further reference to it. I don't know if the object is really needed, but if you want to store it you have to hold a reference in a variable, otherwise the java garbage collector will dispose it at it's next run. Hmm - Thanks for pointing this out, but I don't think the object is still necessary (but I'm not sure about this, so I tried what you suggested:) You could simply do: 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 }; -- private static final(?) Object mailMerge = null; That unfortunately did not make any difference. Does anybody have the solution or even a working sample at hand? I'd really appreciate it. ciao Christian -- NP: As I Lay Dying - Meaning In Tragedy - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Christian, Does anybody have the solution or even a working sample at hand? I'd really appreciate it. ciao Christian -- NP: As I Lay Dying - Meaning In Tragedy You'll find a sample (OOoBasic) here: http://www.oooforum.org/forum/viewtopic.phtml?t=8393 Perhaps it helps you. HTH - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Am Freitag, den 16.02.2007, 18:41 +0100 schrieb Christian Lohmaier: Hi Marc, *, Hi Christian, Does anybody have the solution or even a working sample at hand? I'd really appreciate it. I did post another message quickly after the first one, because I saw that your solution could not work imo the way it is. That message never reached the list, so I quote it here again: Von: Marc Santhoff [EMAIL PROTECTED] An: dev@api.openoffice.org Betreff: Re: [api-dev] Registering an XMailMergeListener - possible at all? Datum: Wed, 14 Feb 2007 23:45:55 +0100 Hi, me again, from reading your code I think you're on the Holzweg, this implmentation cannot work. You create a mailmerge object instance, register the listener and forget about the mailmerger. Since for each mail merge task a new individual MailMerge-object is created, the listener has to attached to that one in use currently. It seems you need to: - create a MailMerge-instance - create your PostNet-Service - hand over the MailMerge from the first step to the PostNetImpl from the second step for registration (some method like XPostnetjava.registerTo(MailMerge myMerger) or the like - start the mail merge I hope I got this right ... Marc I hope this explanation helps, Marc - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Christian, perhaps I am getting this wrong, because you shortened your code to post it here, but: you add a listener to a MailMerge object and then throw the object away? Second, exactly what kind of event do you want to be notified of? Regards, Steffen - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Hi Steffen, On Wed, Feb 14, 2007 at 07:14:37PM +0100, Steffen Grund wrote: thank you for having a look! perhaps I am getting this wrong, because you shortened your code to post it here, but: you add a listener to a MailMerge object and then throw the object away? Hmm - I don't mean to throw it away. I'm a novice, and I don't see where I throw it away. If you say it is thrown away, then this is very likely my problem, although with a terminate listener that way works. Second, exactly what kind of event do you want to be notified of? ? I don't have a choice to choose between events, do I? There only is that one listener with only that single notify-method. But here's what I intend to do: I want to write an extension for issue http://www.openoffice.org/issues/show_bug.cgi?id=5948 to insert PostNet Barcodes for envelopes. A while back I hacked something together that used autoTexts made of drawing shapes to insert the barcode. That was a hackish method that is rather slow. I now rewrote that thing in java and use barcode4j to generate the barcode in png format and insert the image into the document. This is much faster than the autotext approach. But to be useful, this needs to be hooked-up to the mailmerge, otherwise you would have to manually print each envelope. Wo what I hope for is a way to get notified with Hey, this doc is about to get printed/saved: Do something with it, and then my extensions gets the chance to parse the address and insert the barcode and proceed to the next doc, or alternatively: Here's all the merged docs in one single document: Do something with it. If the MailMerge-Listener is not the way to go here, what else would you suggest? ciao Christian -- NP: Linkin Park - Hit The Floor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Am Mittwoch, den 14.02.2007, 20:32 +0100 schrieb Christian Lohmaier: On Wed, Feb 14, 2007 at 07:14:37PM +0100, Steffen Grund wrote: thank you for having a look! perhaps I am getting this wrong, because you shortened your code to post it here, but: you add a listener to a MailMerge object and then throw the object away? Hmm - I don't mean to throw it away. I'm a novice, and I don't see where I throw it away. If you say it is thrown away, then this is very likely my problem, although with a terminate listener that way works. From your other mail: // org.openoffice.cloph.postnet.XPostnetjava: public void addMMEListener() { MailmergeEventListener MMListener = new MailmergeEventListener(); XMultiComponentFactory xMCF = m_xContext.getServiceManager(); Object mailMerge = null; ^ here you define an object only visible in this method try { mailMerge = xMCF.createInstanceWithContext( com.sun.star.text.MailMerge, m_xContext); } catch (Exception e) { e.printStackTrace(); } now the empty object reference has a value XMailMergeBroadcaster xMMB = null; xMMB = (XMailMergeBroadcaster) UnoRuntime.queryInterface( XMailMergeBroadcaster.class, mailMerge); here the value get's used xMMB.addMailMergeEventListener(MMListener); System.out.println(added listener); } ... and if this exit point is reached the object is lost because there is no further reference to it. I don't know if the object is really needed, but if you want to store it you have to hold a reference in a variable, otherwise the java garbage collector will dispose it at it's next run. You could simply do: 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 }; -- private static final(?) Object mailMerge = null; and only assign the retrieved object in the method addMMEListener() to it. This way the object stays alive until it's getting disposed manually or by disposing the surrounding PostNetJavaImpl object. That's the way java works. C++ is similar. It's one reason for inventing reference counting on object instances. HTH, Marc - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
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]
Re: [api-dev] Registering an XMailMergeListener - possible at all?
Christian Lohmaier wrote: Hi *, 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. Hi, 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. Regards, Oliver - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]