Relax TextPFRun validation to allow LibreOffice PPT import

Desktop / KDE / Calligra - David Llewellyn-Jones [] - 20 November 2019 09:47 UTC

Summary: This change allows non-conforming LibreOffice PPT files to be imported.

An apparent bug in the LibreOffice PPT exporter makes it output files which technically don't conform to the PPT specification. Calligra refuses to load these files, which although technically may be the correct behaviour, is extremely annoying for the user. LibreOffice's deviation from the PPT spec is pretty minor, and a slight weakening of Calligra's validation allows the files to be imported successfully.

In more detail, when loading a drawing each text paragraph in the drawing has a TextPFRun structure ("A structure that specifies the paragraph-level formatting of a run of text"). This starts with a mask, followed by a sequence of fields. Only unmasked fields are included in the sequence.

According to Section 2.9.45 of the PPT specification version 6 [1], the following fields must be masked out:

masks.leftMargin masks.indent masks.defaultTabSize masks.tabStops

In spite of this LibreOffice includes the leftMargin and indent fields (flags 0x100 and 0x400). I'm not familiar with the LibreOffice codebase, but it looks like this is the problem code. From this same code it look like LibreOffice doesn't export the defaultTabSize or tabStops fields (which is correct).

This patch loosens Calligra's validation to allow these flags to be set. It applies the change in binschema [2] for the same reason used to generate the Calligra parser files (see binschma commit aca4fd06f1ad330ecadf05b9e862d7c91338f051).

[1] [2]

Test Plan: 1. Save out a file from LibreOffice in PPT format, or download [[ | this archive ]] with a test file inside. 2. Attempt to load the file into Calligra Stage. 3. Note that it refuses to load with the error "Invalid file format". 4. Apply the patch. 5. Attempt to load the same file again. 6. Note that it loads correctly. If you used my test file, witness my amazing presentation design.

Reviewers: pvuorela, dcaliste

Reviewed By: pvuorela

Subscribers: Calligra-Devel-list, davidllewellynjones

Tags: #calligra:_3.0

Differential Revision:

26c957c77e6 Relax TextPFRun validation to allow LibreOffice PPT import
filters/libmso/generated/mso.jar | Bin 71180 -> 74335 bytes
filters/libmso/generated/simpleParser.cpp | 32 ++++++++++++------------------
filters/libmso/generated/simpleParser.h | 2 +-
3 files changed, 14 insertions(+), 20 deletions(-)


  • Share