Index ¦ Archives ¦ RSS

Clearing breaks in Writer

Estimated read time: 4 minutes

Writer now supports what we call clearing breaks: a new property on line breaks which controls where to put the next line in case the line break is at the end of a line which intersects with an anchored object. This feature improves compatibility with the DOCX and HTML formats.

https://share.vmiklos.hu/blog/sw-clearing-break/all-new.png
Figure 1. Word-style "all" clearing in Writer, new result.

First, thanks to NGI DAPSI who made this work by Collabora possible.

https://share.vmiklos.hu/blog/sw-clearing-break/eu.png
Figure 2. This project has received funding from the European Union’s Horizon 2020 research and innovation programme under grant agreement No 871498

Motivation

Word users expect to be able to import their documents to Writer and experience high fidelity rendering: this means Writer has to support clearing breaks, which instruct the layout to put the next line after a line break not necessarily at the next available vertical position, but perhaps the next line should "just down" to the next full line, or perhaps just do this partially. (Jump down to the next line, so no anchored object causes an additional indentation on the left or right side.)

Results

The easiest case is the "none" clearing break, i.e. when it’s not actually clearing. This looks like this:

https://share.vmiklos.hu/blog/sw-clearing-break/none-new.png
Figure 3. Word-style not clearing break, new result.

This is just a plain line break, and there are no changes here. It used to look like this in the past as well:

https://share.vmiklos.hu/blog/sw-clearing-break/none-old.png
Figure 4. Word-style not clearing break, old result.

And both match the reference rendering:

https://share.vmiklos.hu/blog/sw-clearing-break/none-ref.png
Figure 5. Word-style not clearing break, reference.

Now, what’s more interesting is the "all" clearing break, when the next line is placed in a way that it’s a full line. Figure 1 already shows how it now looks like in Writer. Here is how it used to look like:

https://share.vmiklos.hu/blog/sw-clearing-break/all-old.png
Figure 6. Word-style "all" clearing break, old result.

Finally you can compare that with the reference:

https://share.vmiklos.hu/blog/sw-clearing-break/all-ref.png
Figure 7. Word-style "all" clearing break, reference.

This is the most interesting case, and Word still provides UI to insert such breaks, so it frequently appears in documents out there. But there are two other cases, still. The "left" clearing break "jumps down", below anchored objects on the left. Here is how it looks now in Writer:

https://share.vmiklos.hu/blog/sw-clearing-break/left-new.png
Figure 8. Word-style "left" clearing break, new result

And this is how it used to look like:

https://share.vmiklos.hu/blog/sw-clearing-break/left-old.png
Figure 9. Word-style "left" clearing break, old result

Finally you can compare that with the reference:

https://share.vmiklos.hu/blog/sw-clearing-break/left-ref.png
Figure 10. Word-style "left" clearing break, reference

The last case is the mirror of this, when the "right" clearing break "jumps down", below anchored objects on the right. Here is how it looks now in Writer:

https://share.vmiklos.hu/blog/sw-clearing-break/right-new.png
Figure 11. Word-style "right" clearing break, new result

And this is how it used to look like:

https://share.vmiklos.hu/blog/sw-clearing-break/right-old.png
Figure 12. Word-style "right" clearing break, old result

Finally you can compare that with the reference:

https://share.vmiklos.hu/blog/sw-clearing-break/right-ref.png
Figure 13. Word-style "right" clearing break, reference

Other than the layout, there is also user interface for this in both LibreOffice and Collabora Online:

https://share.vmiklos.hu/blog/sw-clearing-break/ui.png
Figure 14. Insert break dialog in Collabora Online, with a new option for clearing breaks

How is this implemented?

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

As usual, the high-level problem was addressed by a series of incremental commits:

Want to start using this?

You can get a snapshot / demo of Collabora Office 2022 and try it out yourself right now: try unstable snapshot. 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 (7.4).

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