-
Notifications
You must be signed in to change notification settings - Fork 547
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
Add a package abstraction for System.IO.Packaging #1295
Conversation
The Package and PackagePart types from System.IO.Packaging are not built in a way to make composition easy; they do not expose public overridable methods. These abstractions will help with smoothing over some issues found in those types that are difficult to manage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you
src/DocumentFormat.OpenXml.Framework/Packaging/IPackageRelationship.cs
Outdated
Show resolved
Hide resolved
src/DocumentFormat.OpenXml.Framework/Packaging/OpenXmlPackage.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just a small question about String.Concat()
vs +
@@ -76,7 +79,7 @@ protected XDocument ToFlatOpcDocument(XProcessingInstruction? instruction) | |||
new XElement( | |||
Pkg + "package", | |||
new XAttribute(XNamespace.Xmlns + "pkg", Pkg.ToString()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to use String.Concat()
here instead?
@@ -127,7 +130,7 @@ private static XElement GetBinaryPartContentsAsXml(PackagePart part) | |||
new XElement(Pkg + "binaryData", ToChunkedBase64String(part))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to use String.Concat()
here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably - there are many issues with the FlatOpc implementations regarding performance... this PR was focused on replacing things with the ipackage rather than fixing anything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thank you
How do I do this now that var newId = (uint)(spreadsheetDocument.Package.GetRelationships().Count() + 1);
var rId = "relId" + newId;
...
spreadsheetDocument.Package.CreateRelationship(uri,
TargetMode.Internal,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet",
rId); It would be nice if the |
So, how to get parts of the packages now? using(var doc = WordprocessingDocument.Open(filepath, true)){ // some operations here doc.Close(); |
Same as @eSPiYa ... I used to get a packagepart for a image (mediaUrl) in a presentation with this code |
The obsolete has been obsoleted :) I heard enough feedback of people using this that I've reverted that. However, in v3.0, it's a new type with similar shape that should be a drop in replacement (the System.IO.Packaging types are just not as composable as needed) |
For now, we're not planning on releasing a v2.20.1 - this is mostly because we had to move to GH actions during this timeframe and we haven't back ported those changes to that branch. If having a v2.20.1 with the obsolete removed would be helpful for migrating to v3.0, please thumbs up this and we can prioritize it. |
Thanks a lot for your feedback. We'll wait for v3.0 final version... |
The Package and PackagePart types from System.IO.Packaging are not built in a way to make composition easy; they do not expose public overridable methods. These abstractions will help with smoothing over some issues found in those types that are difficult to manage.