Index ¦ Archives ¦ RSS > Category: libreoffice ¦ RSS

Improving borders of merged table cells in Writer

Estimated read time: 2 minutes

Writer now has better support for Word-compatible border rending when it comes to vertically merged cells in tables.

First, thanks Docmosis who made this work by Collabora possible.

Motivation

Both Word and Writer allow specifying borders for any kind of table cells. When the user creates a vertically merged cell, there is a covering cell and there is one or more covered table cells.

The Writer approach is to render the cell borders according to the properties of the covering cell. This has the benefit that each edge of the table cell has a single border style (e.g. dashed or hairline).

The Word approach is to render the cell borders as if there would be no vertical merge, according to the properties of the covered cell. This has the benefit that merging the content of cells vertically doesn’t change the border rendering, but it also requires more complex code for painting.

Results so far

Writer can now detect that your tables originate from Word formats and render table borders the Word way in that case.

Here is how the new rendering result look like:

https://share.vmiklos.hu/blog/sw-merged-border/new.png
Figure 1. Writer rendering in compatibility mode, new output

And here is how it used to look like:

https://share.vmiklos.hu/blog/sw-merged-border/old.png
Figure 2. Writer rendering in compatibility mode, old output

And finally the reference rendering is:

https://share.vmiklos.hu/blog/sw-merged-border/ref.png
Figure 3. Writer rendering in compatibility mode, reference output

You can see that the B4 and B5 cells are covered, they had some unwanted border on their left side and this is now gone.

How is this implemented?

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

  • First, some building blocks were introduced: SwCellFrame::GetCoveredCellInRow() can look up a covered cell in a certain row, provided that this cell covers it

  • Building on top of this, SwCellFrame::GetCoveredCells() can provide a list of cell frames which are covered by the current cell, due to vertical merge. This is needed, because previously the layout didn’t have to consider properties of covered cells, so while the document model had this information, it was not visible to the layout in a convenient way

  • Using the above functionality, SwTabFramePainter::Insert() can suppress painting of certain border lines in Word compatibility mode

  • Finally, the code change can be covered with a test by recording the rendering and asserting the vertical positions of border points: we can check that all the positions belong to the 1st, 2nd or 3rd rows, and not to a row below them

Want to start using this?

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 (7.2).


My hack week at Collabora: improvements to gutter margin in Writer

Estimated read time: 3 minutes

As mentioned in a previous such report, a hack week is when we are allowed to hack on anything we want in LibreOffice / Collabora Office / Collabora Online for a few days at Collabora. I used this time to implement core support for RTL gutter margin in Writer.

Motivation

I posted about Writer gutter margin in general back in February, and two follow-up requests accumulated around this new feature since then.

First, the gutter margin could be on the left or at the top for non-mirrored documents, which initially sounded like a complete solution, but later it turned out that right-to-left (RTL) documents want it on the right.

Second, there was a request from the OASIS TC to to implement the ODF filter differently for gutter margin.

Neither of these is simple to do, so this hackweek was a good opportunity to address these problems.

Results so far

Here is the layout and user interface for RTL gutter looks like:

https://share.vmiklos.hu/blog/hackweek-2021/layout-ui.png
Figure 1. RTL gutter margin in Writer, layout and UI

You can see how the gutter is on the right (not the left) and you can alter this behavior with a dedicated checkbox on the UI.

How is this implemented?

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

Finally I had a little bit of remaining time, so I addressed a request from the OASIS ODF TC:

Want to start using this?

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 (7.2).


Bibliography improvements in LibreOffice Writer

Estimated read time: 2 minutes

The bibliography feature in Writer allows authors of e.g. scientific papers to track sources: first you can insert bibliography entry fields, then at the end you can generate a bibliography table automatically.

Writer now has two improvements in this area: more information about these entries in the form of a mouse tooltip and clickable URLs in the table.

First, thanks TUBITAK ULAKBIM who made this work by Collabora possible.

Motivation

Generating a bibliography (table) for a document is a two-step process: first the user inserts bibliography entry fields to refer to sources, then later the bibliography can be auto-generated. It was not great that details of a source was only visible in the Writer edit window after generating the bibliography table. A somewhat related shortcoming was that URLs of sources were handled as plain text, while users expect that references are also clickable, similar to e.g. table of contents.

Results so far

This is how a tooltip looks like, available even if there is no bibliography table yet:

https://share.vmiklos.hu/blog/sw-bibliography/tooltip.png
Figure 1. Tooltip for bibliography entry fields

And URLs in the bibliography table are now clickable:

https://share.vmiklos.hu/blog/sw-bibliography/url.png
Figure 2. Clickable URLs in the bibliography table

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 development steps:

Want to start using this?

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 (7.2).


Gutter margin in Writer

Estimated read time: 3 minutes

The page gutter defines the amount of extra space added to the specified margin (typically left), above any existing margin values.

Writer now has much better support for gutter margins: not only this margin type can be specified explicitly, it’s also possible to select if the gutter should be on the left or on the top, and it works with mirrored margins as well.

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

Motivation

Word has a gutter margin feature, and we saw that some UI-level workaround appeared to have something similar based on the LibreOffice technology. We thought it’s much better to impelement this properly, so that the result is interoperable with Word, and also available both in Online and on the desktop.

Results so far

This is how the UI looks like in Online:

https://share.vmiklos.hu/blog/sw-gutter-margin/online.png
Figure 1. New UI in Online

This is how the new render result looks like:

https://share.vmiklos.hu/blog/sw-gutter-margin/new.png
Figure 2. New render result in Writer

Matching the reference rendering:

https://share.vmiklos.hu/blog/sw-gutter-margin/ref.png
Figure 3. Reference render result

While the gutter was just missing previously:

https://share.vmiklos.hu/blog/sw-gutter-margin/old.png
Figure 4. Old render result in Writer

You can see that the gutter margin is now handled 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 incremental development steps:

  • First, we added a new "gutter" margin type (length) and a gutter position (left or top) to the document model & UNO API.

  • This was followed by adding the layout, which is always the most challenging part of a new Writer feature. In this case the basic functionality was implemented by reducing the "print area" of page frames, so that the positioning of header, body and footer frames all respect the gutter margin. Then additional care was taken to ignore the gutter margin for page borders to be compatible with Word. Finally the margin position and mirrored margin support was implemented.

  • Then we looked at import/export: this feature is now supported with the ODP, DOCX, DOC and RTF formats. Note that some best-effort handling was there in the DOC filter already, but the gutter margin was (semantically) lost on export.

  • You already saw the new UI above: this allows changing the amount of the gutter margin, specifying its position, finally the preview widget also takes the gutter margin into account. Note that this dialog is shared code between Writer, Calc and Impress: we made sure to not break those other apps with the extended UI, which is specific to Writer.

  • Brief help has been added for these new UI controls and submitting an ODF extension proposal to OASIS is in progress to standardize the so far LO-specific markup:

<style:page-layout-properties loext:margin-gutter="1.27cm">

With these, it’s now possible to add, modify, render and delete gutter margins for your documents, while preserving them during ODT and DOCX import/export, without introducing any weird fake line shapes.

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.2).


Handling PDF digital signatures with PDFium FOSDEM talk

Estimated read time: 2 minutes

Figure 1. Slides of the talk

The next step in the recent PDFium-based signature verification story is my Handling PDF digital signatures in LibreOffice with PDFium talk at FOSDEM 2021, in the LibreOffice devroom (pre-recorded video). The talk gives you an overview of digital signing in general, all the ODF/OOXML/PDF handling, signing/verification, various other related past Collabora projects, and then goes into details regarding how PDFium was improved and is used to do a better PDF signature verification in LibreOffice when opening PDF files in Draw.

The virtual room had around 150 participants and the Matrix based online conference was well-organized. Speakers even got a free t-shirt before the event, I appreciated the "bring your own beer" joke :-)

An other benefit of this unusual setup was to avoid the dreaded room is full problems, where you carefully selected a talk to attend and then failed to hear it.

I expect quite some other slides from other Collaborans and the wider community will be available on Planet, don’t miss them.

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.2).


Shadow for tables from PPTX in Impress

Estimated read time: 2 minutes

Impress now has much better support for the shadow of table shapes: not only shape styles can result in table shadows, but it’s also possible to add this as direct formatting. Also the shadow result is PowerPoint-compatible in the direct formatting case.

First, thanks to our partner SUSE for working with Collabora to make this possible.

Motivation

We got a PPTX document, which has a table shape with blurry shadow. The shadow was completely missing in Impress. It was discovered that in case you configure the default shape style to have shadow, then there is some initial table shadow support in Impress, but that was not used in the PPTX case.

The request was to improve the shadow rendering to be PowerPoint-compatible and in general support table shadows as direct formatting as a new feature.

Results so far

The table shadow now looks like this:

https://share.vmiklos.hu/blog/sd-table-shadow/new.png
Figure 1. New render result in Impress

Matching the reference rendering:

https://share.vmiklos.hu/blog/sd-table-shadow/ref.png
Figure 2. Reference render result

While shadow was just missing previously:

https://share.vmiklos.hu/blog/sd-table-shadow/old.png
Figure 3. Old render result in Impress

You can see that not only the shadow is there, but also the cell backgrounds and the blurry shadow is rendered 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:

With these, it’s now possible to add, edit, render and delete these table shadows, while preserving them during ODP and PPTX import/export.

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.2).


Better PDF signature verification in Draw

Estimated read time: 2 minutes

Draw now has much better support for detecting unsigned incremental updates between signatures at the end of PDF documents. We now also make sure that incremental updates introduced for adding signatures really just add annotations and don’t change the actual content.

Motivation

There has been a recent evaluation of PDF signature verification, which included Draw. While we got a checkmark on their Shadow Hide test, their Shadow Replace test found conditional problems and their Shadow Hide-and-Replace test was not happy, either.

So time to look at what are those corner-cases and how the situation can be improved, so people keep trusting that if Draw says a signature is valid, it’s indeed valid.

Results so far

There were 4 incremental improvements in this area:

These were enough so that talking to the authors of that evaluation now confirmed that these problems are all gone.

How is this implemented?

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

PDF signature verification works by using a custom PDF tokenizer. You can read about that code in the PDF tokenizer section of this post. The bottom line is that we now have both PDFium and this custom tokenizer, somewhat duplicating the functionality.

After talking to the PDFium developers (see the relevant mailing list thread), there were open regarding adding all the high level API to allow PDF signature verification based on PDFium, and not via our own tokenizer. See this header file for the set of relevant APIs added. A combinations of those allowed to adapt the code on our side and use PDFium for signature verification, not the own tokanizer.

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).


Better handling of cached field results in Writer

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:

https://lh3.googleusercontent.com/6o7pvix-dJ9QhCX65FUkWeQZ60B89sHqDpBvd7WVRLtAzBW1323odrQ13aV_CgEFvgh7Iee-ePq95oPOf1Q-jMxvX1MBsz9FhgKd9vymyrdMBIZbF459hNKE1dM4XLcwXkGYh8ksmok=w1920
Figure 1. New render result in Writer

Matching the reference rendering:

https://lh3.googleusercontent.com/GJd2zcnspXDb7Wa2p32TInf9C8MAgt92h3G6PYuUwUvpQi5f3AdRbl5yGq8FN7kUPMcZwuFpohTKmX33s8u-AxFSO9rZFgH4X-fwrg8jShtJoA1KyGws_-ymUvINmK-5xo2_hd7YmLI=w1920
Figure 2. Reference render result

While it looked like a broken calendar previously:

https://lh3.googleusercontent.com/bpOVqcZX2CcKouuADNyPx1PMyI3I6CyjIDIAnUbylsT-ZimxSkPcUaRbMDd8MzHlG3Uqw2d-TunD4m7U4DUlm_O_esJt6CAY-H7Z5tdQxZ6q_MYxgJphutr_-JRVYh8uLmspiiI532U=w1920
Figure 3. Old render result in Writer

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:

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).


Detecting 0-byte files based on extension in Impress and elsewhere

Estimated read time: 3 minutes

Impress (and Writer and Calc) now has support for detecting 0-byte files on open/import based on their extension. This builds on top of the previous language-independent template improvements. This means that e.g. a 0-byte PPTX file will open as an empty Impress presentation, not in Writer.

Motivation

We regularly see customers wanting minimal templates, which are language independent and have no content. Such files are handy if your workflow is to first name an empty document (create it) and only then edit it (and not the other way around: first create the document, then save it by giving it a name). This is easy for .txt files: if it’s zero bytes, it’s empty. But then this approach is also expected to work for other file formats as well, where our original approach was more technical: if it’s an empty file, that that can be only plain text, so we (almost) always opened it in Writer, not matching the user expectations.

Instead of explaining the problem to people again and again (that a literally empty PPTX file is not a PPTX template), there is value in just adapting the code instead to "do what I mean".

Results so far

An empty PPTX file is now handled like this:

https://lh3.googleusercontent.com/zk3b0f2Rx3t5vFVuKiimujSJWYwPNH05PCf5Indih3OwMDeBrOUH1X7N22PO46kIbxTVzI0V3IV-bE0sMycTHGj2eRqKT6K7eQkZ0Py9QVCPIhV0pdKdGPLGH08xpw72wFQ-3eGyX4k=w1920
Figure 1. Empty PPTX file opening in Impress

You can see this is no longer opening in Writer as plain text but in Impress, which is clearly a less surprising behavior.

Here is what happens if you open an empty DOTX (template):

https://lh3.googleusercontent.com/cVB_kK2wDyNIJjLt9v9UcNS4AagRCifwBofp70mHfNVzopvrN1cxcsVLhWfEArhab_PwSFkAvLlMUS1witevRcKeEn9UXYtw5o4VeGSztvnNUi6YMtR3t2DUIu1k2LLOUhnpckAnrwQ=w1920
Figure 2. Empty DOTX file creates a new Writer document

You can see that it is even recognized that this is a template format, so a new document is created, not the template itself is opened for editing.

How is this implemented?

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

You can see the code change in this commit. First, we restrict this trick to file URLs, and also to empty files.

Second, we look at the extension of the file and try to match an import filter that usually handles that extension. This helps, because then nominally the correct filter will be used for the import, so save will not ask for a filename (as it happens for new documents), but it will know what target filename and export filter to use.

Finally we need to avoid actually invoking the import filter, because no file content is not something an import filter has to handle if its filter detection would reject the file. (E.g. PPTX is expected to be a valid ZIP file.) This is important, because we want to avoid touching each & every file filter to not fail for empty file content — instead we want to handle this centrally, at a single place.

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).


OOXML / PDF Digital Signing in Draw and elsewhere conference talk

Estimated read time: 1 minutes

Today I gave a OOXML / PDF Digital Signing in Draw and elsewhere talk at the LibreOffice Conference 2020. The (virtual) room was well-crowded — somehow people find digital signatures interesting. ;-)

It contains an overview of the ODF/OOXML/PDF signing feature set and also details the latest improvements, like visible PDF signing.

I expect quite some other slides from other Collaborans and the wider community will be available on Planet, don’t miss them.

You can get a snapshot / demo of Collabora Office and try the presented features 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).

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