[api-dev] Re: MailMerge settings
Hi Fernand, Il 11/05/2011 19:52, Fernand Vanrie ha scritto: Paolo , I think you need refresh your textfields, when needed i can send you some code tomorrow Thank you for the suggestion. Actually I forgot to mention that I did already experimented the refresh method (at textfield collection level) and the update method at textfield level, and they both did not work for me ciao Paolo M -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: MailMerge settings
Paolo , ja, you need to change the textfield - textmaster datasource one by one as Ariel explained. i personal , never used the textmaster stuff to fill a textfield, always used a Datasourcebrowser or a Resultset to fill up the textfields, using the colum/textfield names as a link to fill hope it works Fernand Hi Fernand, Il 11/05/2011 19:52, Fernand Vanrie ha scritto: Paolo , I think you need refresh your textfields, when needed i can send you some code tomorrow Thank you for the suggestion. Actually I forgot to mention that I did already experimented the refresh method (at textfield collection level) and the update method at textfield level, and they both did not work for me ciao Paolo M -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: MailMerge settings
Il 12/05/2011 00:32, Ariel Constenla-Haile ha scritto: Hello Paolo, On Wednesday 11 May 2011, 13:33, Paolo Mantovani wrote: Hallo, I need to change (via API) the database bound to a given document. In practice I need to perform via API the same operation that you normally do via the menu Modify-Change Database. In Writer I see Edit - Exchange Database Yes, sorry for my heuristic translation from the Italian;) [] the above shows you are missing (b), it is not enough to change the com.sun.star.text.DocumentSettings, you have to instantiate the field masters, and modify the existing fields. Note that SwDoc::ChangeDBFields does a few things more: it updates the text section's condition (a text section may bi hidden according to a db related condition like Datasource.Table.Field EQ Something so you have to change Dataource.Table to newdatasource.newtable in your example) http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/core/doc/docfld.cxx#1918 it updates *not only* database fields, but also other text fields, see the switch in http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/core/doc/docfld.cxx#1947 I've studied your reply with great attention and interest. Thank you very much for the very valuable information and for the solution that you suggested. Unfortunately it seems much more complicated than I could imagine, and currently I'm a bit rusty, but I will give it a try. Thanks again Paolo Mantovani -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: MailMerge settings
Paolo , I think you need refresh your textfields, when needed i can send you some code tomorrow Greetz Fernand Hallo, I need to change (via API) the database bound to a given document. In practice I need to perform via API the same operation that you normally do via the menu Modify-Change Database. I tried with: oSet = oDoc.createInstance(com.sun.star.text.DocumentSettings) oSet.CurrentDatabaseDataSource = newsource oSet.CurrentDatabaseCommandType = com.sun.star.sdb.CommandType.TABLE oSet.CurrentDatabaseCommand = newtable But this does not affect the database fieldmasters in the document, that are still pointing to the old datasource. It seems that I'm missing something. Any help? thank you Paolo Mantovani -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: MailMerge settings
Hello Paolo, On Wednesday 11 May 2011, 13:33, Paolo Mantovani wrote: Hallo, I need to change (via API) the database bound to a given document. In practice I need to perform via API the same operation that you normally do via the menu Modify-Change Database. In Writer I see Edit - Exchange Database I tried with: oSet = oDoc.createInstance(com.sun.star.text.DocumentSettings) oSet.CurrentDatabaseDataSource = newsource oSet.CurrentDatabaseCommandType = com.sun.star.sdb.CommandType.TABLE oSet.CurrentDatabaseCommand = newtable In fact, this *does* exchange the database, just see the dialog in the Edit - Exchange Database menu, at the bottom you'll see that settings are changed and stored; for example, I had Database1.Contacts and after executing your code I see in this dialog Database applied to document: newsource.newtable Changing the document settings does not even test if there is actually a DB and a table with the given names. It is the client code responsibility to check this and register the new data source in case the test fails. But this does not affect the database fieldmasters in the document, that are still pointing to the old datasource. Updating/refreshing the fields as Fernand suggested does not work; as far as I could understand reading the implementation, you have to instantiate new field masters for your new data source (because Writer does not seem to create them until they are in use, that is, until the user really inserts a field), and then update all the fields in the documents iterating on the text field collection (not via XRefreshable.refresh()). I haven't test any of these, but it seems to be what happens internally when .uno:ChangeDatabaseField is dispatched: * the slot id FN_CHANGE_DBFIELD is executed by the SwBaseShell, void SwBaseShell::ExecField http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/ui/shells/basesh.cxx#2914 * the dialog impl. is SwChangeDBDlg http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/ui/inc/changedb.hxx http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/ui/fldui/changedb.cxx You can see how two different things happen there: a) changing the data source, will lead to void SwDoc::ChgDBData(const SwDBData rNewData) http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/core/doc/doc.cxx#682 b) updating the document's field will lead to void SwDoc::ChangeDBFields( const SvStringsDtor rOldNames, const String rNewName ) http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/core/doc/docfld.cxx#1908 Using the API to change the com.sun.star.text.DocumentSettings does the same as (a), it calls SwDoc::ChgDBData http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/ui/uno/SwXDocumentSettings.cxx#465 It seems that I'm missing something. the above shows you are missing (b), it is not enough to change the com.sun.star.text.DocumentSettings, you have to instantiate the field masters, and modify the existing fields. Note that SwDoc::ChangeDBFields does a few things more: it updates the text section's condition (a text section may bi hidden according to a db related condition like Datasource.Table.Field EQ Something so you have to change Dataource.Table to newdatasource.newtable in your example) http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/core/doc/docfld.cxx#1918 it updates *not only* database fields, but also other text fields, see the switch in http://svn.services.openoffice.org/opengrok/xref/DEV300_m106/sw/source/core/doc/docfld.cxx#1947 Hope this helps. Regards -- Ariel Constenla-Haile La Plata, Argentina signature.asc Description: This is a digitally signed message part.