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

Exception with SmartArt diagrams #1840

Closed
manfromarce opened this issue Nov 24, 2024 · 3 comments
Closed

Exception with SmartArt diagrams #1840

manfromarce opened this issue Nov 24, 2024 · 3 comments
Assignees

Comments

@manfromarce
Copy link

Describe the bug
It seems that few DOCX files can also have the application/vnd.openxmlformats-officedocument.drawingml.diagramDrawing+xml content type for SmartArt diagrams. I don't know if this is allowed in the specification, Word and other editors can open them properly but the Open XML SDK throws the following exception:

The document cannot be opened because there is an invalid part with an unexpected content type.
[Part Uri=/word/diagrams/drawing1.xml],
[Content Type=application/vnd.openxmlformats-officedocument.drawingml.diagramDrawing+xml],
[Expected Content Type=application/vnd.ms-office.drawingml.diagramDrawing+xml]

To Reproduce
Build and run this sample (a DOCX file which causes the issue is included): ConsoleApp1.zip

Observed behavior
An DocumentFormat.OpenXml.Packaging.OpenXmlPackageException is thrown.

Desktop (please complete the following information):

  • OS: Windows
  • Office version [e.g. 16.0.15427.20178]
  • .NET Target: .NET 8
  • DocumentFormat.OpenXml Version: 3.2.0
@tomjebo
Copy link
Collaborator

tomjebo commented Jan 21, 2025

@manfromarce, I verified that application/vnd.ms-office.drawingml.diagramDrawing+xml should be valid according to [MS-ODRAWXML] 2.1.3 Diagram Layout which also has the following behavior note:

<3> Section 2.1.3: The Diagram Layout extension is also present in Microsoft Office 2007 Service
Pack 2 (SP2).

It is not listed in the ISO 29500-1 standard, it is an extension part in MS-ODRAWXML and therefore this should be the correct content type for a drawing part with the relationship http://schemas.microsoft.com/office/2007/relationships/diagramDrawing

If I create a diagram in Word latest version, I get this for the drawing part:

  <Override PartName="/word/diagrams/drawing1.xml" ContentType="application/vnd.ms-office.drawingml.diagramDrawing+xml"/>

Which matches the SDK and of course this can be read by the SDK with no exception thrown.

Did you create the test document Document2.docx using Microsoft Word and if so, what version did you use? I would need reproduce this.

@tomjebo
Copy link
Collaborator

tomjebo commented Jan 22, 2025

I've also checked our Office source and vnd.openxmlformats-officedocument.drawingml.diagramDrawing+xml doesn't show up in the history anywhere so I'm thinking that this probably occurs in other document generators.
I'll close this issue for now.

@manfromarce if you can reproduce this with a specific version of Word them please feel free to comment here and we'll investigate.

@tomjebo tomjebo closed this as completed Jan 22, 2025
@manfromarce
Copy link
Author

Yes, this occurred with a document created by OnlyOffice. If you think this syntax is not correct I will report the issue to them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants