Estimated read time: 2 minutes
Writer now has much better support for preserving the cached result of fields in documents. This is especially beneficial for Word formats where the input document may have a field result which is not only a cache, but re-calculating the formula would yield a different result, even in Word.
Motivation
A Collabora Office customer gave us a DOCX document, which is essentially a calendar for planned IT maintenance windows at some organization. These calendars are tables with fields in it. The document is halfway through towards changing it to a newer year: the formulas are already changed to calculate a newer year, but all the cached field results are still for the old year.
The request was to keep showing these results and not throw them away during save, either. Their primary workflow is to fill the calendar with manual entries, not to tweak the calendar layout itself.
Results so far
The calendar now looks like this:
Matching the reference rendering:
While it looked like a broken calendar previously:
You can see that the day numbers were broken previously and now they line up properly.
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 small fixes:
-
DOCX import: don’t throw away cached value of SwHiddenTextField fixes a caching problem which was working for DOC already
-
DOCX import: fix lost cached result inside an IF field fixes caching in the context of nested IF fields (Writer in general has limited support for nested fields)
-
DOCX import: lost cached result of fields: fix leading whitespace fixes whitespace handling while caching
-
DOCX export: handle conditional fields adds an initial implementation of conditional fields in the DOCX export, which was completely missing previously.
With these, it’s now possible to edit these calendars, without breaking the fields which provide the day numbers.
Want to start using this?
You can get a snapshot / demo of Collabora Office 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.1).