Index ¦ Archives ¦ RSS

Editeng RTF export: fixing a lost paragraph style

Estimated read time: 2 minutes

Impress shape text doesn't have much support for styles, e.g. the default UI in Writer gives you a paragraph style dropdown, and you don't get the same in Impress. Still, a paragraph style is attached to bullets based on their outline level, and Impress has a View → Outline menu item to give you that styled text you can copy. Pasting that to Writer started to lose styles recently and it's now fixed to work again.

This work is primarily for Collabora Online, but the feature is available in desktop Impress as well.

Motivation

As described in a previous commit, I had a case where lots of not needed paragraph styles were exported to RTF in case an Impress document had enough master pages. The idea was to only export actually used paragraph styles, to avoid wasting CPU power.

Turns out filtering out paragraph styles has to happen at two locations:

  • in the style table to assign an index to a paragraph style
  • when referring to those styles

The problem was that unused styles were removed from the style table, but not from the style → index mapping, so as soon as you had both used and unused paragraph styles, the declared and the referred style indexes didn't match anymore.

Results so far

Here is a sample paste result in Writer, where you can see that the text doesn't have a custom paragraph style:

Bugdoc: old Writer paste

And here is the same paste, now with paragraph styles restored:

Bugdoc: new Writer paste

As you can see, now the pasted text has paragraph styles.

How is this implemented?

If you would like to know a bit more about how this works, continue reading... :-)

The bugfix commit was editeng RTF export: fix broken offsets into the para style table.

The tracking bug was tdf#163883.

Want to start using this?

You can get a development edition of Collabora Online 24.04 and try it out yourself right now: try the development edition. Collabora intends to continue supporting and contributing to LibreOffice, the code is merged so we expect all of this work will be available in TDF's next release too (25.2).

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.