Jump to content

Calligra/Words/Outline

From KDE Community Wiki
Revision as of 17:58, 6 December 2010 by Cyrille (talk | contribs) (Created page with 'Here are some things about how outline works in ODF 1.1 (will be updated soon for ODF 1.2 if there is any change there) In ODF, the paragraphs are stored either using text:p, ei...')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Here are some things about how outline works in ODF 1.1 (will be updated soon for ODF 1.2 if there is any change there)

In ODF, the paragraphs are stored either using text:p, either using text:h.

text:h is for a heading, the headings create the document structure.

The outline level is not defined in a style, it is defined with an attribute in headings. This is really important.

It means that storing the outline level in the style/QTextBlockFormat would be a mistake. You would face a problem if you do it this way : when storing, two identical styles where only the outline differs would be duplicated in the resulting ODF file.

Another important attribute is the default-outline-level, defined for the style. The spec (§14.1, outline numbering level) is really clear about it :

"For style with family paragraph, the style:default-outline-level attribute specifies a default outline level. It takes a number like the text:outline-level attribute of the heading element <text:h>. If this attribute is existing for a paragraph style, and if the paragraph style is assigned to a paragraph by an user interface action, then office applications should convert the paragraph into a heading of the given level. However, the attribute has no effect to the differentiation of headings and paragraphs in the file format itself. The differentiation between headings and paragraphs still takes place by using either a <text:h> or a <text:p> element. If a <text:p> element references a paragraph style that has a style:default-outline-level attribute, the paragraph remains a paragraph and will not become a heading."

It is really important to notice two things there :

1) the distinction between a text:h and a text:p must be done at a block level, not with the style

2) there is a difference when you apply the paragraph style : if you apply the style at loading, the behaviour isn't the same as when applying after an user request !

Here is an example of perfectly legal OpenDocument code. Same paragraph style, but different outline level... It is allowed (but not supported by OpenOffice.org).

Demonstration code :

<text:h text:style-name="Heading_Style" text:outline-level="1" >Title 1</text:h>

<text:h text:style-name="Heading_Style" text:outline-level="2" >Title 1.1</text:h>

<text:h text:style-name="Heading_Style" text:outline-level="2" >Title 1.2</text:h>

<text:h text:style-name="Heading_Style" text:outline-level="1" >Title 2</text:h>

<text:h text:style-name="Heading_Style" text:outline-level="2" >Title 2.1</text:h>

(If you load this in OpenOffice.org, the outline-level will be overwritten by the default-outline-level of the paragraph, bad implementation....)