Skip to content

Shapes inside mc:AlternateContent are never rendered #11

Description

@mantissaman

Split out of #3.

Shapes wrapped in mc:AlternateContent are never drawn. They survive a load and save because we keep unknown XML verbatim, but the layout engine never sees them, so nothing is rendered and no space is reserved.

Cause

Word writes a shape as a compatibility block. The modern DrawingML version goes in mc:Choice and a VML fallback goes in mc:Fallback:

<mc:AlternateContent>
  <mc:Choice Requires="wps"><w:drawing>...</w:drawing></mc:Choice>
  <mc:Fallback><w:pict><v:shape .../></w:pict></mc:Fallback>
</mc:AlternateContent>

CT_R::from_xml knows about w:drawing but not about mc:AlternateContent, so the whole block falls into the unknown element branch and is captured as raw XML. The w:drawing inside it is never parsed into a RunContent::Drawing, so it never reaches layout.

In the file attached to #3 there are five of these, and every one of them is invisible in our output.

Fix

Handle mc:AlternateContent in the run parser. Descend into mc:Choice when we support what it requires, and fall back to mc:Fallback otherwise. Keeping the raw copy for write back is still fine, the point is to also parse the content so layout can use it.

Rendering the shape geometry itself is a separate and larger job. This issue is only about the drawing inside mc:Choice becoming visible to layout, which also fixes the reserved space.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions