Fixes #1608, adds support for multiple alternate content sections#1609
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for multiple AlternateContent sections within a Word processing run, addressing issue #1608. The change modifies the data structure to handle a collection of alternate content items rather than a single instance.
- Changes
alternateContentfield from single object to List collection - Updates parsing logic to accumulate multiple
AlternateContentsections - Modifies serialization to iterate through all alternate content items
| Vml.CT_AlternateContent alternateContentField = null; | ||
|
|
||
| List<Vml.CT_AlternateContent> alternateContentField; |
There was a problem hiding this comment.
The alternateContentField should be initialized to prevent null reference exceptions. Consider initializing it as 'new List<Vml.CT_AlternateContent>()' or ensure all usage checks for null.
There was a problem hiding this comment.
Can you change the name to alternateContentFields?
| if (ctObj.alternateContent == null) | ||
| { | ||
| ctObj.alternateContent = new List<Vml.CT_AlternateContent>(); | ||
| } | ||
|
|
There was a problem hiding this comment.
The null check and list initialization happens inside the loop for each AlternateContent element. Consider initializing the list once outside the parsing loop or in the constructor to avoid repeated null checks.
| if (ctObj.alternateContent == null) | |
| { | |
| ctObj.alternateContent = new List<Vml.CT_AlternateContent>(); | |
| } |
3007c94 to
9e0784d
Compare
|
LGTM |
#1608 Tested locally, seems to work.
AlternativeContentsections can also contain paragraphs, this is something that might need attention later.