Index ¦ Archives ¦ RSS

Import of DOCX and RTF linked graphic into LibreOffice Writer

Estimated read time: 1 minutes

As it has been reported, the RTF includepicture field was ignored on import. As writerfilter has quite some shared code for DOCX and RTF import, I also looked at the state of linked graphics in the DOCX import, and that wasn’t better, either.

Although, the root causes were different. ;-) Regarding DOCX, a linked and a non-linked graphic has quite similar drawingML markup: the only difference is if the graphic has a relationship alias (embedded case) or a (possibly relative) external URL. Relative external URLs were broken, as the writerfilter → oox call (to import the graphic) did not forward the base URL, so oox had no chance to properly resolve a relative URL.

Regarding RTF, a linked graphic is represented as an includepicture field, and now the RTF tokenizer resolves that to a real graphic. As you can see on the above screenshot series (new Writer behavior, old Writer, and reference), we now behave the same way as the reference (or the Writer DOC import).

A related interesting fact I noticed is that includepicture fields in OOXML are valid, but it seems Word never writes them: either their expanded field result is outdated (e.g. it’s some text), or if the user updates the field, then their implementation instantly replaces the field with a drawingML markup that links the graphic.

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