fix: prevent empty txBody in autopaged empty cells
Whenever autopage generates a new slides, there might be empty cells, that need to be properly generated to avoid the 'repair' message in PowerPoint (here's the issue: https://github.com/gitbrent/PptxGenJS/issues/1048).
Here is the content generated before this fix for empty cells in rows broken into 2 or more pages
<a:tc>
<a:txBody>
<a:bodyPr/>
<a:lstStyle/>
<----- missing empty p
</a:txBody>
...
</a:tc>
This triggers the 'repair' message in PowerPoint.
Here is what PowerPoint generates after repairing the file:
<a:tc>
<a:txBody>
<a:bodyPr/>
<a:lstStyle/>
<a:p>
<a:endParaRPr/>
</a:p>
</a:txBody>
...
</a:tc>
FYI - this also fixes the bug I reported: Table Auto-Paging Error #1168
@gitbrent any update on this one?
I can confirm, this issue reproduces in one of my projects. Steps to reproduce are exactly what @mdbaehre described in #1168
@gitbrent from my investigation, the root cause is getSlidesForTableRows function. There is a while loop, and under the described conditions the loop (Step 6 E) stops iterating on the last line of the cell containing text (https://github.com/gitbrent/PptxGenJS/blob/035cf6b26239e2ea1f27eefbcdb8134e504eb4f4/src/gen-tables.ts#L486) so the logic of adding empty text object for the remaining empty cells is not working.
My fix was very similar to the one proposed by @raulneis - just handle this on the XML building stage to ensure there will be no <a:txBody> without <a:p>. I was going to submit a PR, but found this one.
As a temporary solution, we use a local fork of the library now, but I hope this can be merged into the main repo.
One more side note: I was able to find the issue with XML validation of slide files against XSD from https://ecma-international.org/publications-and-standards/standards/ecma-376/ (Part 4, Transitional schemas). I think it would be great to add unit and/or e2e tests for a variety of use cases, with validating library output against XSD schemas.
@gitbrent what say you?