Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Found OpenXmlUnknownElement instead of CommentPropertiesExtension #1751

Closed
tomjebo opened this issue Jul 16, 2024 · 0 comments · Fixed by #1754
Closed

Found OpenXmlUnknownElement instead of CommentPropertiesExtension #1751

tomjebo opened this issue Jul 16, 2024 · 0 comments · Fixed by #1754
Assignees

Comments

@tomjebo
Copy link
Collaborator

tomjebo commented Jul 16, 2024

Describe the bug

In part \ppt\comment\modernComment... part is coded in the SDK metadata as p188:ext. This causes OpenXmlUnknownElement to be assigned as the child of p188:extLst.
       <p188:extLst>
            <p:ext xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" uri="{5BB2D875-25FF-4072-B9AC-8F64D62656EB}">
                <p228:taskDetails xmlns:p228="http://schemas.microsoft.com/office/powerpoint/2022/08/main">
                    <p228:history>
                        <p228:event time="2024-07-16T05:56:24.928" id="{22A90AAB-29DC-4F45-80B8-41660EB3CE91}">
                            <p228:atrbtn authorId="{DDBD2B34-3E97-38F7-B7A9-5BD8D52D7288}"/>
                            <p228:anchr>
                                <p228:comment id="{C5BB4569-00FC-429B-B44C-282847B06E34}"/>
                            </p228:anchr>
                            <p228:add/>

This should be fixed on our schema processor.

To Reproduce
Create a presentation with a modern comment. Then inspect the \ppt\comment\modernCommentXXXX.xml part. The above shows p:ext and that is per the Office schemas.

However, when parsing in SDK code:

    SlidePart sp = pd.PresentationPart.GetPartsOfType<SlidePart>().First();

    PowerPointCommentPart ppcp = sp.GetPartsOfType<PowerPointCommentPart>().First();

    if (ppcp.RootElement is null)
    {
        throw new InvalidDataException("no root element!");
    }

    CommentPropertiesExtensionList cpel = ppcp.RootElement.Descendants<CommentPropertiesExtensionList>().First();

    if (cpel is null)
    {
        throw new InvalidDataException("Presentation modern comment part is missing p188:extlst");
    }

    CommentPropertiesExtension cpe = cpel.ChildElements.First<CommentPropertiesExtension>();
    
    if (cpe is null)
    {
// This line will throw because cpe is null due to the p:ext being wrapped by OpenXmlUnknownElement. 
// In our patched schemas we code this as p188:ext which is wrong. 
        throw new InvalidDataException("Presentation modern comment part is missing p188:ext");
    }

Steps to reproduce the behavior:
Use the code above to access the ext child element the extLst in a p188:cm block.

Observed behavior
cpe is null.

Expected behavior
In the code above, cpe should be a valid CommentPropertiesExtension object wrapping the p:ext.

Desktop (please complete the following information):

  • OS: Windows
  • .NET Target: .Net 8.0
  • DocumentFormat.OpenXml Version: 3.0.2
@tomjebo tomjebo self-assigned this Jul 16, 2024
@tomjebo tomjebo changed the title Bug with Open XML SDK Found OpenXmlUnknown CommentPropertiesExtension Jul 19, 2024
@tomjebo tomjebo changed the title Found OpenXmlUnknown CommentPropertiesExtension Found OpenXmlUnknownElement instead of CommentPropertiesExtension Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant