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.

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

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:

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

And both match the reference rendering:

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:

Finally you can compare that with the 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:

And this is how it used to look like:

Finally you can compare that with the 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:

And this is how it used to look like:

Finally you can compare that with the reference:

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

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:
- sw clearing breaks: add document model
- sw clearing breaks: add UNO API to insert this
- sw clearing breaks: add UNO API to insert this with custom clear / char props
- sw clearing breaks: include this in the UNO API text portion enum
- sw clearing breaks: initial layout support
- sw clearing breaks: fix rendering of the line break char itself
- sw clearing breaks: add DOCX import
- sw clearing breaks: add DOCX export
- sw clearing breaks: fix layout when the line is empty
- sw clearing breaks: add ODF export
- sw clearing breaks: add ODF import
- sw clearing breaks: add DOC import
- sw clearing breaks: add DOC export
- sw clearing breaks: add RTF filter
- sw clearing breaks: add HTML filter
- sw clearing breaks: add plain text export
- sw clearing breaks: add insert UI
- sw clearing breaks: add clearing indicator during rendering
- sw clearing breaks: add layout support for the left and right cases
- sw clearing breaks: link ODF proposal
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).