4 Configuration
4.2 Writer2xhtml and Calc2xhtml configuration
Also the XHTML export can be configured with a configuration file in xml format. This is a sample configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<option name="custom_stylesheet" value="/mystyle.css" />
<option name="ignore_styles" value="false" />
<option name="use_dublin_core" value="true" />
<option name="convert_to_px" value="true" />
<option name="split_level" value="1" />
<xhtml-style-map name="mystyle" family="paragraph" element="p" css="mycssclass" />
</config>
The following subsections explains the available options. The options written in italics can be set using the dialog if you use Writer2xhtml as an export filter.
Style options
You can control some general aspects of the generated XHTML documents using these technical options.
no_doctype |
If you set this options to true (default is false), Writer2xhtml will not include the !DOCTYPE declaration in the converted document. The !DOCTYPE is required for a valid xhtml document: This option should only be used if you need to process the document further. |
encoding |
This option is used to specify the character encoding to use for the xhtml document. Currently supported encodings are UTF-8 (default), UTF-16, ISO-8859-1 and US-ASCII. Characters not supported by the encoding are exported as numeric character entities. |
use_named_entities |
If you set this options to true (default is false), Writer2xhtml will use named character entities as defined by (X)HTML. If you export to XHTML+MathML, also named MathML entities will be used. |
add_bom |
In rare cases, it may be required to ad a BOM (Byte Order Mark) to the XHTML document. Most applications will not need this, but you can set this options to true to enable this (default is false). |
custom-stylesheet |
Use this options to give an URL to your own, external CSS stylesheet. If the value is empty or the option is not specified, no external stylesheet will be used. For more advanced solutions (eg. different style sheets for screen viewing and printing) you can use an XHTML template – see below. |
The following options are used to control the conversion of the formatting in the source document. If you use an external CSS style sheet, this is important to define.
formatting |
The option formatting is used to specify how much text formatting (character, paragraph and list formatting) to export8. Possible values are convert_all (default): Convert all formatting to CSS. ignore_styles: Convert hard formatting but not formatting by styles. Use this value if you use a custom stylesheet, but still want to be able to add some hard formatting (eg. a centered paragraph, some bold text etc.) ignore_hard: Convert formatting by styles, but no hard formatting (except as given by attribute style maps, see below). Use this if the document is well structured using styles, so that any hard formatting should be considered an error. ignore_all: Convert no formatting at all. Use this value if you use a custom stylesheet and the document is well structured using styles, so that any hard formatting should be considered an error. |
frame_formatting |
Used for the same purpose for frame formatting. |
section_formatting |
Used for the same purpose for section formatting. (But note that OOo does not offer section styles currently). |
table_formatting |
Used for the same purpose for table formatting. (But note that OOo does not offer table styles currently). |
ignore_table_dimensions |
Set this option to true if you don't want table dimensions (table width, column width and row height) to be exported, but want to leave the layout of the tables to the browser. Default is false. |
tabstop_style |
Used this option to specify a style used for tabstops. Normally tabstops are exported as spaces, but with this option the space will be contained in a span element, eg. <span class="tabstop"> </span> You can then define a CSS rule like eg. tabstop { width: 2em; } |
use_list_hack |
This option is used to fix a problem with continued lists. If you set this options to true (default is false), Writer2xhtml will export a list that continues on level 2 or below like <ol><ol><li>...</li></ol></ol> This is not valid in xhtml, but works in browsers. Also two deprecated attributes are used to continue numbering. |
In addition, a number of options defines how dimensions in the source document should be handled.
convert_to_px |
When this option is true (default), Writer2xhtml will convert all units to px, otherwise the original units are used. The resolution is assumed to be 96ppi, you can change this with the scaling option. Eg. a scaling of 75% will change the resolution to 72ppi. |
scaling |
Use this option to specify a scaling of all formatting, ie. to get a different text size than the original document. The value must be a percentage, default is 100%. |
column_scaling |
Use this option to specify an additional scaling for table colums. The value must be a percentage, default is 100%. |
natural_image_size 9 |
Use this option to specify that the size of images should not be exported, hence LaTeX should use the original size of the image. Default is false. |
Options for special content
use_dublin_core |
Use this option to specify if Dublin Core Meta data should be exported (the format will be as specified in http://dublincore.org/documents/dcq-html/). If the value is false, it will not be exported (default is true). |
notes |
If this option is set to true (default), notes in the document will be exported as XHTML comments. These are not directly visible in the browser. If you don't want to include notes, set this option to false. |
AutoCorrect options
ignore_double_spaces |
This options can have the values true (default) or false. Setting the option to true will instruct Writer2xhtml to ignore double spaces, otherwise they are converted to non-breaking spaces. |
ignore_empty_paragraphs |
This option can have the values true (default) or false. Setting the option to true will instruct Writer2xhtml to ignore empty paragraphs.. |
ignore_hard_line_breaks |
This option can have the values true or false (default). Setting the option to true will instruct Writer2xhtml to ignore hard line breaks (Shift-Enter in OOo). |
File options
split_level |
This option is used to specify that the Writer documents should be split in several documents and the outline level at which the splitting should happen (the default 0 means no split). This is convenient for long documents. Each output document will get a simple navigation panel in the header and the footer. |
repeat_levels |
If you split the document, you can use this option to specify that headings of higher levels should be repeated on page breaks. This may help the user to identify the current position in the document. Default is 5 (all levels are repeated). |
save_images_in_subdir |
Images contained in the document are normally placed in the same directory as the XHTML document. If the document contains a large number of images, it may be more convenient to put the images in a subdirectory. Set this option to true to do this. |
uplink |
This option is used to specify a link which brings the user up in a page hierarchy. For example "../index.html". |
Options specific for spreadsheet documents
calc_split |
Set this option to true if you want spreadsheet documents should be split in several documents (one for each sheet). This is convenient for large spreadsheets. Each output document will get a simple navigation panel in the header and the footer. The default value is false, which means that the entire spreadsheet will be converted to a singe XHTML document. |
display_hidden_sheets |
Set this option to true if you want to export sheets that are defined as hidden. Default is false. |
display_hidden_rows_cols |
Set this option to true if you want to export rows or columns that are defined as hidden. Default is false. |
display_filtered_rows_cols |
Set this option to true if you want to export rows or columns that are not visible due to a filter. Default is false. |
apply_print_ranges |
I you set this option to true, the print ranges defined in the document will be used. The content of the result will thus be identical to the content of printed output. If you set the option to false (default), the content of the output will be identical to the content that you can see when editing the document. |
use_title_as_heading |
If you set this option to true (default), the title of the document will be included in the XHTML document as a heading. |
use_sheet_names_as_headings |
If you set this option to true (default), the sheet name will be added as a heading above each table in the XHTML document. |
Options for batch conversion
directory_icon |
Used to specify an URL for an (icon) image that represents a directory. This is used when Writer2xhtml creates index pages for a directory. |
document_icon |
Used to specify an URL for an (icon) image that represents a document. This is used when Writer2xhtml creates index pages for a directory. |
Style maps
In addition to the options, you can specify that certain styles in Writer should be mapped to specific XHTML elements and CSS style classes. Here are some examples showing how to use some of the built-in Writer styles to create XHTML elements:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<!-- map OOo paragraph styles to xhtml elements -->
<xhtml-style-map name="Text body" family="paragraph"
element="p" css="(none)" />
<xhtml-style-map name="Sender" family="paragraph"
element="address" css="(none)" />
<xhtml-style-map name="Quotations" family="paragraph"
block-element="blockquote" block-css="(none)"
element="p" css="(none)" />
<!-- map OOo text styles to xhtml elements -->
<xhtml-style-map name="Citation" family="text"
element="cite" css="(none)" />
<xhtml-style-map name="Emphasis" family="text"
element="em" css="(none)" />
<!-- map hard formatting attributes to xhtml elements -->
<xhtml-style-map name="bold" family="attribute"
element="b" css="(none)" />
<xhtml-style-map name="italics" family="attribute"
element="i" css="(none)" />
</config>
An extended version of this is distributed with Writer2LaTeX, please see the file cleanxhtml.xml.
The attributes of the xhtml-style-map element are used as follows:
-
name specifies the name of the Writer style.
-
family10 specifies the style family in Writer; this can either be text, paragraph, frame, list or attribute. The last value does not specify a real style, but refers to hard formatting attributes. The possible names in this case are bold, italics, fixed (for fixed pitch fonts), superscript and subscript.
-
element specifies the XHTML element to use when converting this style. This is not used for frame and list styles.
-
css specifies the CSS style class to use when converting this style. If it is not specified or the value is “(none)”, no CSS class will be used.
-
block-element only has effect for paragraph styles. It is used to specify a block XHTML element, that should surround several exported paragraphs with this style.
-
block-css specifies the CSS style class to be used for this block element. If it is not specified or the value is “(none)”, no CSS class will be used.
For example the rules above produces code like this:
<p>This paragraph is Text body</p>
<address>This paragraph is Sender</address>
<blockquote>
<p>This paragraph is Quotations</p>
<p>This paragraph is also Quotations</p>
</blockquote>
<p>This paragraph is also Text body and has some <em>text with emphasis style</em> and uses some <b>hard formatting</b>.</p>
You can use your own Writer styles together with your own CSS style sheet to create further style mappings, for example:
<xhtml-style-map name="Some OOo style" family="paragraph"
block-element="div" block-css="block_style"
element="p" css="par_style" />
to produce output like this:
<div class=”block_style”>
<p class=”par_style”>Paragraph with Some OOo style</p>
<p class=”par_style”>Yet another</p>
</div>
Note that the rules for hard formatting are only used when formatting is set to ignore_hard or ignore_all. It is not recommended to rely on these rules, using real text styles is preferable. They are included because the use of hard character formatting is very common even in otherwise well-structured documents.
8 This and the following options replaces the former option ignore_styles.
9 In previous versions, this option was called keep_image_size, but has been renamed to avoid confusion (the old name is still supported).
10 Previously this attributed was called class.