Skip to content

Support mc:AlternateContent for XWPFRun.getPictureText().#1091

Merged
pjfanning merged 1 commit into
apache:trunkfrom
jaragunde:picture-text-mcAlternateContent
May 27, 2026
Merged

Support mc:AlternateContent for XWPFRun.getPictureText().#1091
pjfanning merged 1 commit into
apache:trunkfrom
jaragunde:picture-text-mcAlternateContent

Conversation

@jaragunde
Copy link
Copy Markdown
Contributor

Modern Word versions create shapes inside blocks like these:

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

The existing implementation of XWPFRun.getPictureText() only searched through drawing or pict items that are direct children of the run, ignoring whatever was inside an <mc:AlternateContent> block. We add code to include any <w:drawing> items inside these blocks.

We also modify XWPFParagraph.getPictureText() to insert line jumps between different picture texts, following the mold from XWPFRun.getPictureText().

Modern Word versions create shapes inside blocks like these:

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

The existing implementation of XWPFRun.getPictureText() only searched
through drawing or pict items that are direct children of the run,
ignoring whatever was inside an <mc:AlternateContent> block. We add
code to include any <w:drawing> items inside these blocks.

We also modify XWPFParagraph.getPictureText() to insert line jumps
between different picture texts, following the mold from
XWPFRun.getPictureText().
Copy link
Copy Markdown
Member

@pjfanning pjfanning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@pjfanning pjfanning merged commit ca8abb4 into apache:trunk May 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants