| View previous topic :: View next topic |
| Author |
Message |
Agrouf General User

Joined: 28 Feb 2007 Posts: 5
|
Posted: Wed Feb 28, 2007 7:28 am Post subject: Multiple TextFieldMasters with same name |
|
|
I'm using the java API.
I have a Writer Document and I'm trying to insert several times the same document in it but with different values for User TextFields. I'm using XDocumentInsertable.insertDocumentFromURL to do this.
The problem is that the text fields in the inserted documents are inserted with the same name each time and when I try to set the content for the text field, it sets the content for all the fields with the same name, but I want different value for each inserted document.
Any idea how I can do this?
Thanks for your time. |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8976 Location: Lexinton, Kentucky, USA
|
Posted: Wed Feb 28, 2007 8:51 am Post subject: |
|
|
| Do you have a registered data source for the document and does your document contain one or more Next Record fields? |
|
| Back to top |
|
 |
Agrouf General User

Joined: 28 Feb 2007 Posts: 5
|
Posted: Wed Feb 28, 2007 2:36 pm Post subject: |
|
|
No, Idon't, but it sounds like something I would need.
I will google it because I'm such a newbie!
Or maybe you can point me to some good documentation about data sources?
Thanks. |
|
| Back to top |
|
 |
Agrouf General User

Joined: 28 Feb 2007 Posts: 5
|
Posted: Thu Mar 01, 2007 3:09 am Post subject: |
|
|
After a lot of searching, I still don't get how to do what I want :
I have a master document and a document containing something like :
Name : <User Text Field Name>
Age : <User Text Field Age>
Birthday : <User Text Field birthday>
...
I want the master document to include several times the other document with different data, and I want to insert the fields programmatically (java).
I can't find any documentation about data sources that allow me to do that. I didn't find a suitable documentation that explain how to put the fields and the next records field the way I want. They all refer to tables, but I don't want the fields to appear in a table, I want them to appear as in the document.
Can someone please point me to the good documentation or briefly explain how I can do this?
Thank you. |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8976 Location: Lexinton, Kentucky, USA
|
Posted: Thu Mar 01, 2007 5:41 am Post subject: |
|
|
Your's is a difficult question to answer without knowing more about what you are trying to do. In some ways it sounds like you are trying to do programatically something that OOo can do automatically so let me ask some questions.
Will your Java program ask the user for different Names, Ages and Birthdays? If not, then can I assume this information is already known and could be store in a database to be merged into the document?
If the information is already known is there any reason to use a Java macro to merge the different sets of information if you can do it directly in the GUI?
Are you using a Master Document simply because you don't want to type the same document more that once? |
|
| Back to top |
|
 |
Agrouf General User

Joined: 28 Feb 2007 Posts: 5
|
Posted: Thu Mar 01, 2007 8:48 am Post subject: |
|
|
Actually, I'm trying to print a document from another application with java through the uno interface.
The Application already supports printing with MS Word.
It has recently started supporting printing with OpenOffice for customers who don't want to pay for a Word license.
All MS Doc templates have been migrated to OpenOffice, but some documents are not as good as their Word counterpart because the list of contact people is a table with openoffice, but a table is not suitable to display large amount of informations (as a result phone numbers appear vertically).
I'm trying to modify the java code so as to implement the list of contact better, like it is done in the MS Word one : a contact is a separate document with user fields and the list of contact is a reference to the contact document, which is included as many times as there are contacts, and it looks prettier than a table.
The code currently creates rows in a table and insert text in the cells.
The program asks nothing from the user.
The information is already known in the java program, so it could indeed be stored in a database, but installing mySQL or another program is not an option. Only openOffice (does it have a database engine by itself?).
We can't use the GUI because we just want to print the document and the customer doesn't know how to use openOffice.
We are using a master document because there are other informations which are simple (not repeated). The inclusion of documents is for the lists.
Sorry if that is not so clear, english is not my first language and I'm new to openOffice.
I'm interested if you have any pointer to make me started.
I didn't even find a documentation on how to merge a database from the GUI, and I would be interested if you could direct me to this.
If you have any idea how to start, thanks for sharing. |
|
| Back to top |
|
 |
Agrouf General User

Joined: 28 Feb 2007 Posts: 5
|
Posted: Mon Mar 05, 2007 1:59 am Post subject: |
|
|
I've found this link :
http://codesnippets.services.openoffice.org/Writer/Writer.MailMerge.snip
It looks like what I need. I'm going to use the mail merge function of openOffice, but it looks like I'll have to create a physical file in order to write the data to be merged (there doesn't seem to be a way to merge data from memory).
Thanks for the help. |
|
| Back to top |
|
 |
JohnV Administrator

Joined: 07 Mar 2003 Posts: 8976 Location: Lexinton, Kentucky, USA
|
Posted: Mon Mar 05, 2007 3:26 pm Post subject: |
|
|
Yes, OOo has a database component and can also connect to other databases. See File > New > Database. OOo comes with one database "Bibliography" with one table "biblio".
You use the term Master Document which in OOo is how you combine different files into a single document, say you write each chapter as a separate file then you would use a Master Document to assemble your book. I think you may mean a Template which is a document with fixed content that you create other documents from so you can add content. Your basic letterhead is an excellent use for a Template. Can you tell us which you mean?
OOo will allow you to list sets of database records from the GUI. Try this:
Open a new Writer document and press F4 to open the data source viewer (a data source is basically a database that has been registered for use in other documents).
Open Bibliography, open the Tables item and click on biblio.
When the records appear on the right select several using the gray boxes to their left.
Click the Data to Text icon which is found above the field names.
Put the bullet in Text and move some field names from left to right. You can do basic editing in the right window to enter spacing, paragraph breaks and the like. You want at least one paragraph break after the last field name to separate your records.
Click OK and the data should flow into your document.
Is this close to what you want to do with your Java code? If so, do you think you can translate Basic code over to Java because I can't do that for you if I even have the Basic code you need? |
|
| Back to top |
|
 |
|