DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:odt:styleimportgeneral

How does style import work in general?

This page gives some general information about style import to make it easier to understand how the ODT plugin imports and uses styles from the different sources, e.g. an ODT template or CSS template file.

Style import in the ODT plugin follows this procedure:

  1. Import the automatic styles from “plugins/odt/ODT/ODTDefaultStyles.php”. These are not visible for the user, automatic styles are used for direct formatting only.
  2. Import the common and master styles from “plugins/odt/styles.xml”. Common styles are visible for the user in LibreOffice under “Styles and Formatting”.
  3. If no other sources are set in the exported DokuWiki page or the ODT plugin configuration then this is already all which is done for style import. The document will just use the ODT plugin's built-in styles.
  4. Import styles from an ODT file if an ODT template file is configured in the ODT plugin configuration. See config option odt_template, file must have the extension .odt.
  5. Import styles from an CSS file if an CSS template file is configured in the ODT plugin configuration. See config option odt_template, file must have the extension .css.
  6. Import styles from an ODT file if an ODT template file is specified via the syntax tag
    {{odt>template:mytemplate.odt}}
  7. Import styles from an CSS file if an CSS template file is specified via the syntax tag
    {{odt>template:mytemplate.css}}
  8. Read the content of a DokuWiki page and import it like an CSS file if specified via the syntax tag
    {{odt>templatepage:mycsspage}}

How is a single style imported from an ODT template file?

Importing a style from an ODT template file is quite simple. The style just needs to match the name of the styles used by the ODT plugin. Because it is already an ODT encoded style all settings can simply be copied and used by the ODT plugin.

How is a single style imported from an CSS template file?

This is more complicated. Not all CSS settings/properties have an equivalent in the ODT format. This is also true for HTML elements, e.g. there is no div element in the ODT format. Therefore CSS import is different for each HTML element. The details of CSS import/usage for each style will be described on separate pages.

Independently from that there are two possible methods and only one is implemented until now:

Static CSS import

Today the ODT plugin only supports a static CSS import. That means on start of the ODT export it will only once check for CSS settings which can be applied to an ODT style. It is assumed that this is sufficient for most usage scenarios.

Full/Dynamic CSS import

With full/dynamic CSS import it is meant to do the same things like a browser is doing on displaying a HTML page. On each newly created element, e.g. a paragraph, check for the matching CSS properties (that means evaluate the matching CSS selectors) and apply the matching properties to the paragraph.

Supporting this method would mean the following for the ODT plugin:

  1. check for matching CSS properties on opening new elements, e.g. paragraphs, lists, tables…
  2. check if there is already an ODT style having this properties
  3. if yes, assign it to the element
  4. if no, create a new ODT style and assign it to the element

This would potentially slow down the ODT plugin a lot, also I am not sure if this method would be required for “everyday” ODT plugin applications.

:!: Anyway, if this method is required please post a feature request on github and please describe the use-case. I can then think about implementing it or not. Actually it is not planned. :!:

plugin/odt/styleimportgeneral.txt · Last modified: 2017-04-17 12:07 by LarsDW223