Number labels

From Apache OpenOffice Wiki
Jump to: navigation, search

Writer Icon.png

Writer Project

Please view the guidelines
before contributing.

Popular Subcategories:

Internal Documentation:

API Documentation:

Ongoing Efforts:

Label generation in ODT

In the ODT file format the label of a number has the form

SUBLEVEL ::= (NUM ".")

where PREFIX and POSTFIX are arbitrary strings and NUM is a string representation of the number value (e.g. 1, A, I, i, ..., ).

Consider for example the numbered paragraph

(A.I.1) text text text text

whose label consists of the PREFIX “(“, the POSFIX “)”, the SUBLEVELs “A.” and “I.” and the number “1”.

In the ODT file format the above sample paragraph numbering will be represented as

<text:list-style style:name="L1">
	<text:list-level-style-number text:level="1" style:num-format="A">
	<text:list-level-style-number text:level="2" style:num-format="I">
	<text:list-level-style-number text:level="3" style:num-prefix="(" 
			style:num-suffix=")" style:num-format="1" 

Label generation in WW

The number label generation of WW is different. WW has a “labeltext” which includes placeholders for the desired numbers. Consider for example the labeltext


which models e.g. the label (A.I.1.) of the above paragraph when assuming that %0 is a placeholder for the number at level 0 whose format is “A, B, ...”; that %1 is a placeholder for the number at level 1 whose format is “I, II, ...” and that %2 is a placeholder for the number at level 2 whose format is “1, 2, ...”. Obviously every OO.o Writer label can be expressed by a WW “labeltext”. However the opposite is not true. Consider the following labeltext


which generates labels of the form “1;1.1:”, “1;1.2:”, etc. It is not possible to express labels of that kind using OpenOffice Writer.

Bullet lists sample

In bullet lists the "text:label-text" attribute would supersede the "text:bullet-char" attribute. By using a label text which simply contains to "%0, %1, ..." wildcard any kind of bullet lists with any kind of prefix and suffix can be simulated.

E.g. text:label-text="*.)" would simply generate a a bullet with a ".)" postfix.

ODT Enhancement

For better roundtrip compatibility we suggest the implementation of a label specification mechanism into the ODT file format which is also based on a “labeltext”. A leveltext is an arbitrary string which contains placeholders of the form “%i” to represent the string representation of the ith-level's number.

In the file format the enhancement can be represented by adding an attribute “text:labeltext” to the text:list-level-style-number of the ODT file format. If the “text:labeltext” attribute is present, then the label will be generated using the “text:labeltext” attribute; in case the “text:labeltext” attribute is not present, the label will be generated using the style:num-prefix, style:num-suffix and text:display-levels attributes.

For backward compatibility we suggest ODT generating entities to also write the style:num-prefix, style:num-suffix and text:display-levels attributes. The following heuristic could be applied to infer the old attributes:

1. Let %max resp. %min be the greatest placeholder resp. the lowest placeholder in the leveltext. The text:display-levels attribute is set to %max-%min+1.

2. The style:num-prefix attribute is set to the substring starting at the first position of the labeltext and ending at the occurrence of the first placeholder.

3. The style:num-suffix attribute is set to the substring starting behind the occurrence of the last placeholder and ending at the end of the leveltext.

For example the leveltext “%0;%1.%2:” will be heuristically transformed to style:num-prefix=””, style:num-suffix=”:” and text:display-levels=”3”.

OD Schema enhancements

<define name="common-num-format-prefix-suffix-attlist" combine="interleave">
  <attribute name="style:label-text"><ref name="string"/></attribute>

The "style:label-text" supersedes the following attributes:

  • style:num-prefix
  • style:num-suffix
  • text:display-levels
  • text:bullet-char

The "text:label-text" attribute is a freeform string from which the label text for a number is generated. The "text:label-text" attribute may contains wildcards "%0, %1, %2, %3, %4, %5, %6, %7, %8, %9" for the counters. A "%" sign is encoded as "%%".

OO Writer enhancements


Personal tools