A structural table edit regenerates each cell from the model, and tableCellXml
hand-built the paragraph properties out of w:numPr and w:jc alone. Everything
else the parser had captured was discarded, w:bidi included.
For an Arabic or Hebrew table that is a visible break. Word writes an RTL cell as
w:bidi plus a logical w:jc, where "left" means start and renders flush right. The
parser converts that to a visual value, and hand-building wrote the visual value
back as though it were the logical one:
cell with <w:bidi/><w:jc w:val="left"/>
before w:bidi present, paragraph is RTL, renders flush right
after w:bidi gone, <w:jc w:val="right"/>, paragraph is LTR
cell with <w:bidi/> and no w:jc
before RTL default, renders flush right
after no w:pPr at all, LTR default, renders flush left
The table keeps w:bidiVisual from its original tblPr, so the result is a shape
Word never writes: right-to-left columns with left-to-right paragraphs inside.
Route the cell through mergePPrFormat, the helper that fixed the same defect for
headers and footers, so the parsed format comes back whole. Shading, spacing,
indent, page-break-before, paragraph borders, tab stops and the drop-cap frame
return with it.
mergePPrFormat needed a correction first. Its interleave branch walks the fresh
children once with a monotonic index, so they have to arrive in schema order, but
only the fresh-build branch sorted them. formatPPrChildren emits by concern and
leaves framePr and tabs until last, so a paragraph carrying a tab stop came back
as w:jc followed by w:tabs, which is the ordering Word offers to repair. Every
table paragraph takes the interleave branch, so this had to be right before the
rest could be. The fresh children are now sorted on both branches.
One trap worth naming: cell.align is read straight off w:jc, so it holds Word's
logical value, while paragraph.align has already been converted to a visual one.
Only left and right differ between the two, so a bidi paragraph takes the cell
fallback for centre and justify and ignores it for left and right, where the two
coordinate systems disagree and the cell value cannot be placed in either with
confidence. Outside bidi the fallback is unchanged.
Not fixed here. keepNext, keepLines, widowControl and contextualSpacing are
parsed into the format model but formatPPrChildren does not emit any of them, so
they are still lost on every rebuild, in tables and elsewhere alike. w:tblPrEx is
neither parsed nor emitted, so a row-level property exception is still dropped.
A cell paragraph carries neither rawPPr nor pPrChange, so a paragraph-level
tracked revision inside a cell does not survive regeneration, on this revision or
before it. All three are separate changes.