Difference between revisions of "Documentation/OOoAuthors User Manual/Writer Guide/Working with Fields"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Using document properties to hold information that changes)
m (interwiki link added)
 
(24 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{NeedsWork}}
+
{{DISPLAYTITLE:Working with Fields}}
This page was created by converting ODT to Mediawiki using Writer2MediaWiki.
+
[[de:DE/Dokumentation/OOo_2.x/Handb%C3%BCcher/Writer-Handbuch/Mit_Feldern_arbeiten]]
 
+
{{WriterFieldsTOC|ShowPrevNext=block
 +
|PrevPage=Documentation/OOoAuthors User Manual/Writer Guide/Problem solving
 +
|NextPage=Documentation/OOoAuthors_User_Manual/Writer Guide/Quick and easy field entry}}__notoc__
 
This is Chapter '''14''' of the '''OpenOffice.org 2.x Writer Guide''' (Third edition), produced by the [http://oooauthors.org/ OOoAuthors group]. A PDF of this chapter is available from the [http://documentation.openoffice.org/manuals/oooauthors2/ OOoAuthors Guides page] at OpenOffice.org.
 
This is Chapter '''14''' of the '''OpenOffice.org 2.x Writer Guide''' (Third edition), produced by the [http://oooauthors.org/ OOoAuthors group]. A PDF of this chapter is available from the [http://documentation.openoffice.org/manuals/oooauthors2/ OOoAuthors Guides page] at OpenOffice.org.
 
[[User_Manuals| &lt;&lt; User Manuals page]]<br>
 
[[Writer Guide| &lt;&lt; Writer Guide Table of Contents]]<br>
 
[[Writer Guide/Working with Master Documents| &lt;&lt; Chapter 13 Working with Master Documents]] &nbsp;&nbsp;|
 
&nbsp;&nbsp;[[Writer Guide/Using Forms in Writer| Chapter 15 Using Forms in Writer &gt;&gt;]]
 
  
  
Line 17: Line 14:
 
To turn field shadings on or off quickly, choose '''View > Field Shadings''' or press ''Control+F8''.
 
To turn field shadings on or off quickly, choose '''View > Field Shadings''' or press ''Control+F8''.
  
= Quick and easy field entry =
 
You can quickly insert common fields into your document by choosing '''Insert > Fields''' from the menu bar and selecting the required field from the list, as shown below.
 
 
[[Image:WG14-1.png|Inserting common fields]]<br>''Inserting common fields.''
 
 
= Using document properties to hold information that changes =
 
The Properties dialog box for any document contains locations on the ''Description'' tab and the ''User Defined'' tab for information that you might want to include in your document, especially if it is information that might change during the course of the project. To display this dialog box, click '''File > Properties'''.
 
 
Later in this chapter, we will see how to use this information in fields. You can return to this dialog box at any time and change the information you entered. When you do so, all of the references to that information will change wherever they appear in the document. For example, you might need to change the contents of the ''Title'' field from the draft title to the production title.
 
 
[[Image:WG14-2.png|Description tab of Properties dialog box]]<br>''The Description tab of the document’s Properties dialog box.''
 
 
The ''User Defined'' tab provides four fields for you to use, as required. You can change the default names for these fields to more meaningful names. The example below shows that three of the defaults have been changed: ''Info 1'' to ''Chapter subtitle'', ''Info 2'' to ''Chapter number'', and ''Info 3'' to ''Name of guide''.
 
 
[[Image:WG14-3.png|User Defined tab of Properties dialog box]]<br>''The User Defined tab of the document’s Properties dialog box.''
 
 
To change these field names, click the '''Info fields''' button near the bottom of the dialog box. In the small pop-up dialog box (Edit Field Names, not shown here), type the field names you want and then click '''OK'''.
 
 
= Using other fields to hold information that changes =
 
One way that people use fields is to hold information that is likely to change during the course of a project. For example, the name of a manager, a product, or even your entire company may change just before the document is due to be printed. If you have inserted the changeable information as fields, you can change the information in one place, and it will automatically change in all the places where that field occurs.
 
 
Writer provides several places where you can store the information referred to by a field. We will look at some of them here.
 
 
Seven document properties (Time, Date, Title, Subject, Author, Page Number, and Page Count) are on the '''Insert > Fields''' menu (Figure 1). To insert one of these fields, click on it in the menu.
 
 
Other document properties are on the ''DocInformation'' and ''Document'' tabs of the Fields dialog box (Figure 4 and Figure 5), reached by clicking '''Insert > Fields > Other'''.
 
 
To insert one of these fields, select it in the ''Type''''' '''list and then select from the ''Select''''' '''and ''Format''''' '''lists if choices appear. Finally, click '''Insert'''.
 
 
<center>[[Image:|thumb|<center>''Figure 4: Inserting a Date Modified field using the DocInformation tab of the Fields dialog box''</center>]]</center>
 
 
<center>[[Image:|thumb|<center>''Figure 5: Inserting a File name field using the Document tab of the Fields dialog box''</center>]]</center>
 
 
Some of these items are picked up from the ''User Data'' page of the Options dialog box, so make sure the information on that page is correct.
 
 
 
{| class="prettytable"
 
| <center>'''TIP'''</center>
 
| Although these fields are often used to hold information that changes, you can make the content unchangeable by selecting the '''Fixed content '''checkbox (visible in Figure 4) when inserting the field. If necessary, you can come back to this dialog box later and deselect this checkbox to make the field variable again.
 
 
|}
 
= Using AutoText to insert often-used fields =
 
If you use the same fields often, you will want a quick and easy way to insert them. Use AutoText for this purpose. To define an AutoText entry for a field:
 
 
# Insert a field into your document, as described previously.
 
# Select the field, and then click '''Edit > AutoText '''(or press ''Ctrl+F3'').
 
# On the AutoText dialog box (Figure 6), choose the group where this new entry will be stored (in this example, it is going into ''My AutoText''), type a name for the entry, and change the suggested shortcut if you wish.
 
# Click the '''AutoText '''button and click '''New''' to have the entry inserted as a field. Do not choose '''New (text only)''' because the AutoText entry will be plain text, not a field. Click '''Close''' to close the AutoText dialog box.
 
# Now whenever you want to insert this field at the cursor position, type the shortcut, and then press ''F3''.
 
 
[[Image:|thumb|''Figure 6: Creating a new AutoText entry'']]
 
 
= Defining your own numbering sequences =
 
You may want to define your own numbering sequences to use in situations where you do not always want the number at the start of the paragraph or where you want more control than the built-in numbering choices give you.
 
 
This topic describes how to create and use a numbering sequence, using a “number range variable” field.
 
 
== Create a number range variable ==
 
To create a number range variable using Arabic (1, 2, 3) numbers:
 
 
# Place the insertion point in a blank paragraph in your document.
 
# Click '''Insert > Fields > Other''' and select the ''Variables''''' '''tab (Figure 7).
 
# In the ''Type''''' '''list, select '''Number range'''. In the ''Format''''' '''list, select '''Arabic (1 2 3)'''. Type whatever you want in the ''Name''''' '''field. (I have used '''Step'' '''''in this example.)
 
# Click '''Insert'''. The name of the variable ('''Step''') now appears in the ''Selection'' list, and a number field (showing '''1''') appears at the insertion point in your document. The Fields dialog box remains open, so you may need to move it out of the way to see the field in the document.
 
# Hover the mouse pointer over this number field and you will see the field code of '''Step = Step+1'''. If you click several more times on the '''Insert '''button in the Fields dialog box, the numbers '''2''', '''3''', '''4''', and so on will appear in the document.
 
# Now you may want to create another field to restart the Step sequence at 1, so you can use the same sequence name more than once in your document (for example, to begin each set of instructions).
 
 
<center>[[Image:|thumb|<center>''Figure 7: Defining a number range variable''</center>]]</center>
 
 
# To create this new field, open the Fields dialog box to the ''Variables'' tab. Make sure the variable name Step appears in the ''Name'' box. In the ''Value''''' '''box, type '''Step=1''', as shown in Figure 8. Click '''Insert'''. Now hover the mouse pointer over the new field in your document and you will see the field code of '''Step = Step=1'''.
 
 
<center>[[Image:|thumb|<center>''Figure 8: Defining a field to restart a number range variable''</center>]]</center>
 
 
== Use AutoText to insert a number range field ==
 
You certainly do not want to go through all of that every time you want to put in a step number. Instead, create two AutoText entries, one for the ''Step = Step=1'' field (call it '''Step1''', for example) and one for the ''Step = Step+1'' field ('''StepNext'''). See “[[#Using AutoText to insert often-used fields|Using AutoText to insert often-used fields]]” on page [[#Using AutoText to insert often-used fields|4]].
 
 
You can create similar fields for substeps or other sequences that you want to be numbered with letters (a, b, c), Roman numerals (i, ii, iii), or some other sequence. In the Fields dialog box, choose the required format in the ''Format'' list when creating the field codes.
 
 
 
{| class="prettytable"
 
| <center>'''TIP'''</center>
 
| If a user-defined variable is not in use in the document, the [[Image:]] icon next to the ''Value'' box is active. You can delete the variable by clicking this icon. To remove a variable that is used in the current document, first delete from the document all fields using that variable, and then remove the variable from the list.
 
 
|}
 
= Using automatic cross-references =
 
If you type in references to other parts of the document, those references can easily get out of date if you reword a heading, add or remove figures, or reorganize topics. Replace any typed cross-references with automatic ones and, when you update fields, all the references will update automatically to show the current wording or page numbers. The ''References'' tab of the Fields dialog box (Figure 9) lists some items, such as bookmarks, figures, tables, and user-defined number range variables. Other items that you might expect to be listed, such as headings, are not shown.
 
 
<center>[[Image:|thumb|<center></center> <center>''Figure 9: The References tab of the Fields dialog box''</center>]]</center>
 
 
== Prepare items as targets for cross-referencing ==
 
Before you can insert a cross-reference to anything that is not automatically shown on the ''References'' tab, such as a heading, you must prepare or “set” that heading as an item to be referenced. To do this, you can either use bookmarks or set references.
 
 
=== Using bookmarks ===
 
Bookmarks are listed in the Navigator and can be accessed directly from there with a single mouse click. In HTML documents, bookmarks are converted to anchors that you can jump to via hyperlink.
 
 
# Select the text you want to bookmark. Click '''Insert > Bookmark'''.
 
# On the Insert Bookmark dialog box (Figure 10), the larger box lists any previously defined bookmarks. Type a name for this bookmark in the top box. Click '''OK'''.
 
 
<center>[[Image:|thumb|<center>''Figure 10: Inserting a bookmark''</center>]]</center>
 
 
=== Setting references ===
 
# Click '''Insert > Cross reference'''.
 
# On the ''References'' tab of the Fields dialog box (Figure 11), click '''Set Reference '''in the ''Type'' list. The ''Selection'' list shows any references that have been defined.<br/> You can leave this page open while you set many headings as references.
 
# Click in the document and highlight the text of the first heading to be used as a target for a cross-reference. Click on the Fields dialog box. The text of the heading will appear in the ''Value'' box in the lower right of the dialog box. In the ''Name'' box, type some text by which you can identify this heading.
 
# Click '''Insert'''. The text you typed in the ''Name'' box now appears in the ''Selection'' list.
 
# Repeat steps 3 and 4 as often as required.
 
 
<center>[[Image:|thumb|<center>''Figure 11: Setting text to be used as a target for a cross-reference''</center>]]</center>
 
 
== Insert cross-references ==
 
To insert a cross-reference to a heading or other text:
 
 
# In your document, place the cursor where you want the cross-reference to appear.
 
# If the Fields dialog box is not open, click '''Insert > Cross Reference'''. On the ''References''''' '''tab of the Fields dialog box (Figure 12), in the ''Type''''' '''list, click '''Insert Reference''' or '''Bookmarks''' (depending on how you set your references).<br/> You can leave this page open while you insert many cross-references.
 
# Click on the required item in the ''Selection''''' '''list, which shows the bookmarks or references that have been defined. In the ''Format''''' '''list, choose the type of reference required. Usually this will be '''Reference''' (to insert the full text of the reference or bookmark) or '''Page '''(to insert the number of the page the referenced or bookmarked text is on). Click '''Insert'''.
 
 
<center>[[Image:|thumb|<center>''Figure 12: Inserting a cross-reference to a heading''</center>]]</center>
 
 
To insert a cross-reference to an item (such as a figure caption) that you have previously inserted into the document as a numbering-sequence field:
 
 
# In your document, place the cursor where you want the cross-reference to appear. If the Fields dialog box is not already open, click '''Insert > Cross-reference'''.
 
# On the ''References''''' '''tab of the Fields dialog box (Figure 9), select '''Figure '''in the ''Type''''' '''list.
 
# Click on the required item in the ''Selection''''' '''list, which shows the list of figures that have previously been inserted into the document. The ''Format''''' '''list shows different choices from those given for headings. Choose the type of reference required. Usually this will be '''Category and Number '''(to insert the word “Figure” and its number), '''Reference''' (to insert the word “Figure” with its number and the full text of the caption), or '''Page '''(to insert the number of the page the figure is on).
 
# Click '''Insert'''.
 
 
= Using fields in headers and footers =
 
You can insert fields into headers or footers, using techniques described earlier in this chapter:
 
 
* To insert a page number, document title, author, creation date and time, current date and time, or total page count field, use document properties (see page [[#Using document properties to hold information that changes|1]]).
 
* You can insert a cross-reference to a bookmark or a set reference.
 
* If you have used ''Heading 1'' for your chapter titles, you can use a document field to insert the current chapter title, so it changes from one chapter to the next. See Figure 13, which calls chapter titles “names”. If you have used outline numbering on your ''Heading 1'', you can choose whether to include these numbers in the field.
 
 
* You can insert cross-references to other heading levels by specifying a value in the ''Layer''''' '''box in the lower right of the ''Document'' tab of the Fields dialog box (Figure 13). That is, Layer 1 = Heading 1, Layer 2 = Heading 2, and so on.<br/> A cross-reference field in the header of a page picks up the ''first ''heading of that level on the page, and a field in the footer picks up the ''last ''heading of that level.
 
 
<center>[[Image:|thumb|<center>''Figure 13: Inserting the current chapter name and number into your document''</center>]]</center>
 
 
* To include the chapter number with the page number, position the cursor just before the ''Page'' field you inserted. Click '''Insert > Fields > Other'''. On the ''Document'' tab of the Fields dialog box, select '''Chapter''' in the ''Type'' column and '''Chapter number without separator''' in the ''Format'' column. Click '''Insert'''.<br/> Go to the header or footer where you inserted this field, type the character you want to appear between the chapter number and the page number—for example, a period or a dash. <br/> The table of contents will not automatically pick up these chapter numbers, so you will need to make a change on the '''Indexes and Tables''' menu item, as described in Chapter 12, “Creating Tables of Contents, Indexes, and Bibliographies”.
 
 
* You can add a page count to the footer—for example “Page 9 of 12”. Type the word “Page” and a space in front of the ''Page'' field. Type a space, the word “of”, and a space after the ''Page'' field. Then click '''Insert > Fields > Page Count'''.
 
 
= Using fields instead of outline numbering for chapter numbers =
 
The technique in “[[#Using fields in headers and footers|Using fields in headers and footers]]” on page [[#Using fields in headers and footers|11]], combined with outline-numbered chapter headings (described in Chapter 7, “Working with Styles”), works well when you want the field to show information for the current chapter. But what if you want to use a cross-reference to refer to a different chapter? You cannot bookmark or set a reference to the chapter number part of a heading created using outline numbering.
 
 
 
{| class="prettytable"
 
| <center>'''TIP'''</center>
 
| If you use this technique, some other features will not work because Writer does not recognize the field as chapter numbers. For example, you will not be able to include chapter numbers with the page numbers in headers or footers, or the table of contents, using the technique described in “[[#Using fields in headers and footers|Using fields in headers and footers]]” on page [[#Using fields in headers and footers|11]].
 
 
|}
 
To have chapter numbers that update automatically and can be used in cross-referencing, use a number range field.
 
 
# Define your number range variable, as described in “[[#Defining your own numbering sequences|Defining your own numbering sequences]]” on page [[#Defining your own numbering sequences|5]]. I have called this variable '''Chapter'''.
 
# To insert the field into your ''Heading 1'', type '''<nowiki>Chapter<space></nowiki>'''. Click '''Insert > Fields > Other'''. On the ''Variables''''' '''tab, pick '''Number range''', '''Chapter, Arabic (1 2 3)'''. Click '''Insert'''. You will need to do this manually for each ''Heading 1''.
 
# Select the entire text of the first ''Heading 1'', including the word “'''Chapter'''” and the chapter number, and set a reference to it.
 
# You can now insert a cross-reference to this heading anywhere in your document.
 
 
 
{| class="prettytable"
 
| <center>'''Tip'''</center>
 
| You can also use this technique for easier management of appendix numbering. Keep your appendix headings in the ''Heading 1'' style, define a separate number range sequence for appendix numbers (choosing “'''A,B,C'''” for the number format), and type '''<nowiki>Appendix<space><insert appendix number field></nowiki>''' in the ''Heading 1'' paragraph. You can then use the same page styles for chapters and appendixes, and the same field in the header or footer of chapters and appendixes.
 
 
|}
 
= Tricks for working with fields =
 
== Keyboard shortcuts for fields ==
 
Here are some handy keyboard shortcuts to use when working with fields:
 
 
''Ctrl+F2''Open the Fields dialog box.
 
 
''Ctrl+F8''Field shadings on/off.
 
 
''Ctrl+F9''Show/hide field names.
 
 
''F9''Update fields.
 
 
== Fixing the contents of fields ==
 
You can specify '''Fixed content''' for many items on the ''Document'' and ''DocInformation'' tabs so the field contents do not update. For example, you might use a field to insert the creation date of a document, and you would not want that date to change. In another place you might use a date field to show the current date, which you do want to change; in that case, deselect '''Fixed content''' when you insert the field.
 
 
== Converting fields into text ==
 
Writer does not provide any easy way to convert field contents into text. To do this, you need to copy the field contents and paste them back as unformatted text. This is not a very good solution if you have hundreds of fields that you want to change, but you could use a macro to automate the process.
 
 
= Developing conditional content =
 
Conditional content is text and graphics that are included or excluded depending on a condition you specify.
 
 
A simple example is a reminder letter for an overdue account. The first and second reminders might have a subject line of “Reminder Notice”, but the third reminder letter might have the subject “Final Notice” and a different final paragraph.
 
 
A more complex example is a software manual for a product that comes in two versions, Pro and Lite. Both product versions have much in common, but the Pro version includes some features that are not in the Lite version. If you use conditional content, you can maintain one file containing information for both versions and print (or create online help) customized for each version. You do not have to maintain two sets of the information that is the same for both versions, so you will not forget to update both versions when something changes.
 
 
== Choose the types of conditional content to use ==
 
This section describes several Writer features that can help you design and maintain conditional content. You can use one or any combination of these features in the same document.
 
 
=== Conditional text ===
 
With conditional text, you can have two alternative texts (a word, phrase, or sentence). One text will be displayed and printed if the condition you specify is met, and the other will be displayed and printed if the condition is not met. You cannot include graphics or edit the text except in the field dialog (not in the body of the document). You also cannot format part of the text (for example, bolding one word but not the others), but you can format the field to affect all of the field contents (for example, bolding all of the words). You cannot include a cross-reference or other field in the text.
 
 
=== Hidden text ===
 
With hidden text (a word, phrase, or sentence), you have only two choices: show or hide. If the condition you specify is met, the text is hidden; if the condition is not met, the text is displayed. The disadvantages are the same as for conditional text: you cannot include graphics, edit the text in the body of the document, format part of the text, or include a field.
 
 
=== Hidden paragraphs ===
 
Hidden paragraphs are like any other paragraogs, but you can specify a condition under which the paragraph is not displayed or printed. A blank paragraph can also be hidden—for example, if a database field has no content for the current record. This is very useful when merging an address into a letter: if you allow two lines for the street address and the database record uses only one line, you can prevent the blank line from appearing in your document. You can include graphics, edit the text in the body of the document, format any part of the text, and include fields.
 
 
=== Hidden sections ===
 
Hidden sections are like hidden paragraphs, but they can include more than one paragraph—for example, a heading plus one or more paragraphs. However, a section cannot contain less than a paragraph, so you cannot use this method for single words or phrases. The contents of a hidden section behave just like the contents of any other part of the document, but you can specify a condition under which the section is not displayed or printed. In addition, you can password protect a section.
 
 
== Plan your conditional content ==
 
Conditions are what programmers call ''logical expressions''. You must formulate a logical expression for each condition because a condition is always either true (met) or false (not met). You can use the same condition in many places in your document, for different types of conditional content.
 
 
To make conditional content work, you need to:
 
 
# Choose or define a variable.
 
# Define a logical expression (condition) involving the selected variable.
 
 
=== Choose or define a variable ===
 
You can use the following variables in your condition:
 
 
* User-defined variables
 
* Predefined OpenOffice.org variables, which use statistical values from the document properties
 
* User data
 
* Database field contents—for example from your address book
 
 
You cannot use internal variables (for example, page number or chapter name) to formulate conditions.
 
 
The examples in this chapter use user-defined variables.
 
 
=== Define a logical expression (condition) involving the selected variable ===
 
The condition compares a specified fixed value with the contents of a variable or database field.
 
 
To formulate a condition, use the same elements as you would to create a formula: operators, mathematical and statistical functions, number formats, variables, and constants. The possible operators are given in the online help; look in the index under “operators: in formulas”. You can define quite complex expressions, but in most cases a simple condition will do the job.
 
 
== Create the variable ==
 
To create your variable, click '''Insert > Fields > Other'''. You can use choices found on the ''DocInformation'', ''Variables'', and ''Database'' tabs.
 
 
=== DocInformation fields ===
 
“[[#Using document properties to hold information that changes|Using document properties to hold information that changes]]” on page [[#Using document properties to hold information that changes|1]] described how to set up a user-defined document property. You can use that document property as the variable in your condition statement, or you can create another document property field specifically for conditions.
 
 
=== User-defined variable field ===
 
To set up a variable or user field:
 
 
# Place the cursor where you want the field to be inserted.
 
# On the Fields dialog box, select the ''Variables''''' '''tab (Figure 14).
 
# Select '''Set variable''' in the ''Type''''' '''list and '''Text '''in the ''Format''''' '''list. Type a name for the variable in the ''Name''''' '''box, and a value in the ''Value''''' '''box. I have chosen “'''ProLite'''” for the name (to remind me that this variable is related to the two product versions), and I set the value as “'''Lite'''” because I can remember “If it is the Lite version, then this text should be hidden.”
 
# Select '''Invisible '''so the field does not show in the document. Click '''Insert''', then click '''Close'''.
 
 
<center>[[Image:|thumb|<center></center> <center>''Figure 14: Defining a variable to use with conditional content''</center>]]</center>
 
 
# A small gray mark should be visible where you inserted the field. Hover the mouse pointer over this mark and you will see the field formula ''ProLite = Lite''. We will come back to this field later.
 
 
 
{| class="prettytable"
 
| <center>'''TIPS'''</center>
 
| Because the gray mark is so small, you may have trouble finding it again, especially if you have other fields in the document. You may prefer to leave the variable field visible while you work, and change it to invisible just before you create final copy.
 
 
At any time, you can place the insertion point just before the field and click '''Edit > Fields''' or right-click the field, and then click '''Fields '''on the pop-up menu. On the Edit Fields dialog box (Figure 18), select or deselect the '''Invisible''' checkbox.
 
 
|}
 
== Apply the condition to the content ==
 
Now that you have defined the variable, you can use it in a condition statement. This topic describes some of the possibilities.
 
 
=== Conditional text ===
 
First, let us set up some conditional text that will insert the words “'''Great Product Lite'''” into the Lite version and “'''Great Product Pro'''” into the Pro version of the manual. You would use this field whenever you want to mention the name of the product.
 
 
# Place the cursor where you want one of these phrases to appear. (You can move or delete it later, if you wish.)
 
# Open the Fields dialog box by clicking '''Insert > Fields > Other''', select the ''Functions''''' '''tab, and select '''Conditional text '''in the ''Type''''' '''list.
 
# As shown in Figure 15, type '''ProLite EQ "Lite"''' in the ''Condition''''' '''box, '''Great Product Lite '''in the ''Then''''' '''box, and '''Great Product Pro '''in the ''Else''''' '''box.
 
 
 
{| class="prettytable"
 
| <center>'''Note'''</center>
 
| These fields are case-sensitive, and quotation marks are required around a text value such as '''Lite'''.
 
 
|}
 
<center>[[Image:|thumb|<center>''Figure 15: Inserting conditional text''</center>]]</center>
 
 
# Click '''Insert '''to insert the field, then click '''Close'''. You should see '''Great Product Lite''''' ''in your text.
 
 
 
{| class="prettytable"
 
| <center>'''Tip'''</center>
 
| If you want to insert this field into your text in many places (as you probably would for a product name), create an AutoText entry for it. See “[[#Using AutoText to insert often-used fields|Using AutoText to insert often-used fields]]” on page [[#Using AutoText to insert often-used fields|4]] for instructions.
 
 
|}
 
=== Hidden text ===
 
You might use hidden text for words or short phrases that describe features of Great Product Pro that are not found in the Lite version. You can reuse the same field in several places in your document—for example, by copying and pasting it.
 
 
To create a hidden text field:
 
 
# Click '''Insert > Fields > Other '''and select the ''Functions''''' '''tab.
 
# Select '''Hidden text '''in the ''Type''''' '''list, as shown in Figure 16.
 
# Type '''ProLite EQ "Lite"''' in the ''Condition''''' '''box and type the required text in the ''Hidden text''''' '''box. Remember, this is the text that is ''hidden ''if the condition is true.
 
# Click '''Insert '''to create and insert the field.
 
 
<center>[[Image:|thumb|<center>''Figure 16: Creating a condition for hidden text''</center>]]</center>
 
 
=== Hidden paragraphs ===
 
 
{| class="prettytable"
 
| <center>'''Tip'''</center>
 
| To enable hidden paragraphs, remove the check mark from '''View > Hidden Paragraphs'''. When this option is selected, you cannot hide any paragraph.
 
 
|}
 
A paragraph is hidden if the condition is true. To hide a paragraph:
 
 
# Click in the paragraph to be hidden.
 
# Click '''Insert > Fields > Other''' and select the ''Functions'' tab (Figure 16).
 
# Select '''Hidden paragraph''' in the ''Type'' list.
 
# For this example,type '''ProLite EQ "Lite"''' in the ''Condition''''' '''box.
 
# Click '''Insert '''to create and insert the field. If an extra paragraph mark appears, delete it.
 
 
=== Hidden sections ===
 
A conditional section is hidden if the condition is true. To create a conditional section:
 
 
# Select the text that you want to be included in the conditional section. (You can edit this text later, just as you can edit any other text.)
 
# Click '''Insert > Section'''. On the Insert Section dialog box (Figure 17), select the '''Hide''' checkbox and enter the condition in the ''with Condition''''' '''box. You can also give the section a name, if you wish. Click '''Insert''' to insert the section into your document.
 
 
<center>[[Image:|thumb|<center>''Figure 17: Creating a section to be hidden when a specified condition is met''</center>]]</center>
 
 
To show the hidden section so you can edit it:
 
 
# Click '''Format > Sections'''.
 
# On the Edit Sections dialog box, select the section from the list.
 
# Deselect the '''Hide''' checkbox, and then click '''OK'''. You can now edit the contents of the section. Afterwards, you can click '''Format > Sections''' again and select the '''Hide''' checkbox to hide the section again.
 
 
To make the hidden section a normal part of the document (that is, to remove the section markers, but not the contents of the section):
 
 
# Show the hidden section, as described above.
 
# On the Edit Sections dialog box, select the section from the list.
 
# Click '''Remove'''. The contents of the section are now a normal part of the document.
 
 
== Change the value of the variable ==
 
# Find the variable field you created in “[[#Create the variable|Create the variable]]” on page [[#Create the variable|15]].
 
# Click once just in front of this field, then right-click and click '''Fields '''on the pop-up menu.
 
# On the Edit Fields: Variables dialog box (Figure 18), change the value of the variable to '''Pro'''.
 
# If you have set fields to update automatically, all of the conditional and hidden text that uses this variable as a condition will change.
 
 
<center>[[Image:|thumb|<center>''Figure 18: Changing the value of the variable''</center>]]</center>
 
 
 
{| class="prettytable"
 
| <center>'''Tip'''</center>
 
| To turn on automatic updating of fields, click '''Tools > Options > OpenOffice.org Writer''' '''>''' '''General''', and select '''Fields '''under '''Update: Automatically'''.
 
 
|}
 
== Editing hidden paragraphs and sections ==
 
To show all the hidden paragraphs and sections so you can edit their contents, change the value of the variable to something that the conditions will not recognize. In our example, you could change the value to '''1'''.
 
 
The technique does not affect the display of hidden and conditional text, which can only be edited in the Edit Fields dialog.
 
 
= Using placeholder fields =
 
A placeholder field prompts you to enter something (text, a table, a frame, a graphic, or an object).
 
 
To insert a placeholder field into a document:
 
 
# On the ''Functions'' tab of the Fields dialog box, select '''Placeholder''' in the ''Type'' column and select what the placeholder is for in the ''Format'' column.
 
# In the ''Placeholder'' box, type the text that you want to appear in the placeholder field.
 
# In the ''Reference'' box, type the text that you want to display as a help tip when you rest the mouse pointer over the field.
 
 
Figure 19 shows the results of inserting a placeholder field for a graphic.
 
 
<center>[[Image:|thumb|<center></center> <center>''Figure 19: Inserting a placeholder field''</center>]]</center>
 
 
Because the ''<nowiki><Logo></nowiki>'' field is a graphics placeholder, when you click on the field in the document, the Insert picture dialog box opens, prompting you to select a graphic (picture). When you select a picture and click '''Open''', the picture replaces the field in the document.
 
 
Similarly, clicking on a table placeholder field opens the Insert Table dialog box, clicking on a frame placeholder field opens the Frame dialog box, and clicking on an object placeholder field opens the Insert OLE Object dialog box. The text placeholder field is different: you simply click on it and type some text in the ''Placeholder'' box, which replaces the field.
 
  
  
 
{{CCBY}}
 
{{CCBY}}
[[Category: Documentation]]
+
[[Category: Writer Guide (Documentation)]]

Latest revision as of 19:31, 25 September 2009


This is Chapter 14 of the OpenOffice.org 2.x Writer Guide (Third edition), produced by the OOoAuthors group. A PDF of this chapter is available from the OOoAuthors Guides page at OpenOffice.org.


Introduction to fields

Fields are extremely useful features of Writer. They are used for data that changes in a document, such as the current date or the total number of pages. This chapter describes how to use a few of them.

Tip: Fields have a gray background when viewed on screen, unless you have deselected the Field shadings checkbox or changed the color of field shadings on the Appearance page of the Options – OpenOffice.org dialog box. This gray background will not show when you print the file to hardcopy or PDF.

To turn field shadings on or off quickly, choose View > Field Shadings or press Control+F8.


Content on this page is licensed under the Creative Common Attribution 3.0 license (CC-BY).
Personal tools
In other languages