<table><tr><td style="">davidllewellynjones created this revision.<br />davidllewellynjones added reviewers: pvuorela, dcaliste.<br />davidllewellynjones added a project: Calligra: 3.0.<br />Herald added a subscriber: Calligra-Devel-list.<br />davidllewellynjones requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D25256">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>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.</p>
<p>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.</p>
<p>According to Section 2.9.45 of the <a href="https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-ppt" class="remarkup-link" target="_blank" rel="noreferrer">PPT specification version 6</a>, the following fields must be masked out:</p>
<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">masks.leftMargin
masks.indent
masks.defaultTabSize
masks.tabStops</pre></div>
<p>In spite of this LibreOffice includes the <tt style="background: #ebebeb; font-size: 13px;">leftMargin</tt> and <tt style="background: #ebebeb; font-size: 13px;">indent</tt> fields (flags 0x100 and 0x400). I'm not familiar with the LibreOffice codebase, but it looks like <a href="https://cgit.freedesktop.org/libreoffice/core/tree/sd/source/filter/eppt/epptso.cxx?id=85d947d52d27b4ade68a735e23bd393bced26046#n709" class="remarkup-link" target="_blank" rel="noreferrer">this</a> is the problem code. From this same code it look like LibreOffice doesn't export the <tt style="background: #ebebeb; font-size: 13px;">defaultTabSize</tt> or <tt style="background: #ebebeb; font-size: 13px;">tabStops</tt> fields (which is correct).</p>
<p>This patch loosens Calligra's validation to allow these flags to be set. I've tested this with a bunch of files which previously failed to load, including quite complex ones, and they all seem to load fine once the patch is applied.</p>
<p>A couple of important notes.</p>
<ol class="remarkup-list">
<li class="remarkup-list-item">The validation code is generated by <a href="https://github.com/KDE/binschema/" class="remarkup-link" target="_blank" rel="noreferrer">binschema</a> and I'll submit a separate patch there.</li>
<li class="remarkup-list-item">The <tt style="background: #ebebeb; font-size: 13px;">calligra/filters/libmso/generated/mso.jar</tt> file also needs to be updated to <a href="http://www.flypig.co.uk/dnload/dnload/other/mso.jar" class="remarkup-link" target="_blank" rel="noreferrer">this version</a>, but I couldn't see a way to include the binary file in with this patch.</li>
</ol></div></div><br /><div><strong>TEST PLAN</strong><div><ol class="remarkup-list">
<li class="remarkup-list-item">Save out a file from LibreOffice in PPT format, or download <a href="http://www.flypig.co.uk/dnload/dnload/other/calligra-importppt.zip" class="remarkup-link" target="_blank" rel="noreferrer">this archive</a> with a test file inside.</li>
<li class="remarkup-list-item">Attempt to load the file into Calligra Stage.</li>
<li class="remarkup-list-item">Note that it refuses to load with the error "Invalid file format".</li>
<li class="remarkup-list-item">Apply the patch.</li>
<li class="remarkup-list-item">Attempt to load the same file again.</li>
<li class="remarkup-list-item">Note that it loads correctly. If you used my test file, witness my amazing presentation design.</li>
</ol></div></div><br /><div><strong>REPOSITORY</strong><div><div>R8 Calligra</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D25256">https://phabricator.kde.org/D25256</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>filters/libmso/generated/simpleParser.cpp<br />
filters/libmso/generated/simpleParser.h</div></div></div><br /><div><strong>To: </strong>davidllewellynjones, pvuorela, dcaliste<br /><strong>Cc: </strong>Calligra-Devel-list, davidllewellynjones, dcaliste, cochise, vandenoever<br /></div>