diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b092dfe..92694cd 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "paket": { - "version": "8.0.0", + "version": "8.0.3", "commands": [ "paket" ] diff --git a/Clippit/PowerPoint/FluentPresentationBuilder.cs b/Clippit/PowerPoint/FluentPresentationBuilder.cs index 3a09f85..37dde97 100644 --- a/Clippit/PowerPoint/FluentPresentationBuilder.cs +++ b/Clippit/PowerPoint/FluentPresentationBuilder.cs @@ -75,7 +75,7 @@ private void SaveAndCleanup() xd.Descendants().Attributes("smtClean").Remove(); part.PutXDocument(); } - else if (part.Annotation() is {}) + else if (part.Annotation() is not null) part.PutXDocument(); } } @@ -84,7 +84,7 @@ private void CopyStartingParts(PresentationDocument sourceDocument) { // A Core File Properties part does not have implicit or explicit relationships to other parts. var corePart = sourceDocument.CoreFilePropertiesPart; - if (corePart?.GetXDocument().Root is {}) + if (corePart?.GetXDocument().Root is not null) { _newDocument.AddCoreFilePropertiesPart(); var newXDoc = _newDocument.CoreFilePropertiesPart.GetXDocument(); @@ -143,20 +143,20 @@ private void CopyPresentationParts(PresentationDocument sourceDocument) newPresentation.Root.Add(oldElement); // Copy Font Parts - if (oldPresentationDoc.Root.Element(P.embeddedFontLst) is {}) + if (oldPresentationDoc.Root.Element(P.embeddedFontLst) is not null) { var newFontLst = new XElement(P.embeddedFontLst); foreach (var font in oldPresentationDoc.Root.Element(P.embeddedFontLst).Elements(P.embeddedFont)) { var newEmbeddedFont = new XElement(P.embeddedFont, font.Elements(P.font)); - if (font.Element(P.regular) is {}) + if (font.Element(P.regular) is not null) newEmbeddedFont.Add(CreateEmbeddedFontPart(sourceDocument, font, P.regular)); - if (font.Element(P.bold) is {}) + if (font.Element(P.bold) is not null) newEmbeddedFont.Add(CreateEmbeddedFontPart(sourceDocument, font, P.bold)); - if (font.Element(P.italic) is {}) + if (font.Element(P.italic) is not null) newEmbeddedFont.Add(CreateEmbeddedFontPart(sourceDocument, font, P.italic)); - if (font.Element(P.boldItalic) is {}) + if (font.Element(P.boldItalic) is not null) newEmbeddedFont.Add(CreateEmbeddedFontPart(sourceDocument, font, P.boldItalic)); newFontLst.Add(newEmbeddedFont); @@ -357,7 +357,7 @@ internal void AppendSlides(PresentationDocument sourceDocument, int start, int c var newPart = newSlide.AddNewPart(); newPart.PutXDocument(notesSlide.GetXDocument()); newPart.AddPart(newSlide); - if (_newDocument.PresentationPart.NotesMasterPart is {}) + if (_newDocument.PresentationPart.NotesMasterPart is not null) newPart.AddPart(_newDocument.PresentationPart.NotesMasterPart); PBT.AddRelationships(notesSlide, newPart, new[] { newPart.GetXDocument().Root }); CopyRelatedPartsForContentParts(slide.NotesSlidePart, newPart, new[] { newPart.GetXDocument().Root }); @@ -505,7 +505,7 @@ private void CopyTableStyles(PresentationDocument oldDocument, OpenXmlPart newCo tableStyles = _newDocument.PresentationPart.TableStylesPart.GetXDocument(); // Search new TableStylesPart to see if it contains the ID - if (tableStyles.Root.Elements(A.tblStyle).FirstOrDefault(f => f.Attribute(NoNamespace.styleId).Value == styleId) is {}) + if (tableStyles.Root.Elements(A.tblStyle).FirstOrDefault(f => f.Attribute(NoNamespace.styleId).Value == styleId) is not null) continue; // Copy style to new part @@ -803,7 +803,7 @@ private void CopyRelatedPartsForContentParts(OpenXmlPart oldContentPart, OpenXml _ => null }; - if (vmlDrawingParts is {}) + if (vmlDrawingParts is not null) { // Transitional: Copy VML Drawing parts, implicit relationship foreach (var vmlPart in vmlDrawingParts) @@ -863,7 +863,8 @@ private void CopyRelatedImage(OpenXmlPart oldContentPart, OpenXmlPart newContent if (newContentPart.HasRelationship(relId)) return; - if (oldContentPart.Parts.FirstOrDefault(p => p.RelationshipId == relId) is {} oldPartIdPair) + var oldPartIdPair = oldContentPart.Parts.FirstOrDefault(p => p.RelationshipId == relId); + if (oldPartIdPair != default) { var oldPart = oldPartIdPair.OpenXmlPart as ImagePart; var temp = ManageImageCopy(oldPart); @@ -1042,7 +1043,7 @@ private void CopyRelatedMedia(OpenXmlPart oldContentPart, OpenXmlPart newContent }; var existingRel = temp.ContentPartRelTypeIdList.FirstOrDefault(cp => cp.ContentPart == newContentPart && cp.RelationshipType == desiredRelType); - if (existingRel is {}) + if (existingRel is not null) { imageReference.Attribute(attributeName).Set(existingRel.RelationshipId); } diff --git a/Clippit/PowerPoint/PresentationBuilderTools.cs b/Clippit/PowerPoint/PresentationBuilderTools.cs index 30eb478..9c7e9dd 100644 --- a/Clippit/PowerPoint/PresentationBuilderTools.cs +++ b/Clippit/PowerPoint/PresentationBuilderTools.cs @@ -326,7 +326,7 @@ internal static void AddRelationships(OpenXmlPart oldPart, OpenXmlPart newPart, continue; } var tempHyperlink = newPart.HyperlinkRelationships.FirstOrDefault(h => h.Id == relId); - if (tempHyperlink is {}) + if (tempHyperlink is not null) continue; var newRid = Relationships.GetNewRelationshipId(); var oldHyperlink = oldPart.HyperlinkRelationships.FirstOrDefault(h => h.Id == relId); diff --git a/Clippit/PtOpenXmlUtil.cs b/Clippit/PtOpenXmlUtil.cs index 79194d4..f556180 100644 --- a/Clippit/PtOpenXmlUtil.cs +++ b/Clippit/PtOpenXmlUtil.cs @@ -1835,6 +1835,8 @@ class ImageData : ContentData public ImageData(ImagePart part) { + ArgumentNullException.ThrowIfNull(part); + ContentType = part.ContentType; using var s = part.GetStream(); Hash = s.ComputeHash(); @@ -1848,6 +1850,8 @@ class MediaData : ContentData public MediaData(DataPart part) { + ArgumentNullException.ThrowIfNull(part); + ContentType = part.ContentType; using var s = part.GetStream(); Hash = s.ComputeHash(); diff --git a/Clippit/Word/FormattingAssembler.cs b/Clippit/Word/FormattingAssembler.cs index a204c36..21f2549 100644 --- a/Clippit/Word/FormattingAssembler.cs +++ b/Clippit/Word/FormattingAssembler.cs @@ -1771,8 +1771,7 @@ private static XElement FontMerge(XElement higherPriorityFont, XElement lowerPri return lowerPriorityFont; if (lowerPriorityFont == null) return higherPriorityFont; - if (higherPriorityFont == null && lowerPriorityFont == null) - return null; + var rFonts = new XElement(W.rFonts, (higherPriorityFont.Attribute(W.ascii) != null || higherPriorityFont.Attribute(W.asciiTheme) != null) ? diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 8a3c9fd..f6ac31c 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,10 @@ +#### 2.0.1 Jan 16, 2024 +- Fix regression cased by migration to struct inside OpenXML v3 +- DocumentFormat.OpenXml 3.0 -> 3.0.1 +- SixLabors.Fonts 2.0 -> 2.0.1 +- SixLabors.ImageSharp 3.0.2 -> 3.1.2 +- SixLabors.ImageSharp.Drawing 2.0.1 -> 2.1.0 + #### 2.0.0 Nov 26, 2023 - Migration to .NET 6.0 - DocumentFormat.OpenXml 3.0.0-beta0003 diff --git a/paket.lock b/paket.lock index 0bc15db..567197a 100644 --- a/paket.lock +++ b/paket.lock @@ -2,9 +2,9 @@ STORAGE: NONE RESTRICTION: == net6.0 NUGET remote: https://api.nuget.org/v3/index.json - DocumentFormat.OpenXml (3.0) - DocumentFormat.OpenXml.Framework (>= 3.0) - DocumentFormat.OpenXml.Framework (3.0) + DocumentFormat.OpenXml (3.0.1) + DocumentFormat.OpenXml.Framework (>= 3.0.1) + DocumentFormat.OpenXml.Framework (3.0.1) System.IO.Packaging (>= 8.0) IDisposableAnalyzers (4.0.7) Microsoft.CodeCoverage (17.8) @@ -18,15 +18,13 @@ NUGET Microsoft.TestPlatform.TestHost (17.8) Microsoft.TestPlatform.ObjectModel (>= 17.8) Newtonsoft.Json (>= 13.0.1) - NETStandard.Library (2.0.3) - Microsoft.NETCore.Platforms (>= 1.1) Newtonsoft.Json (13.0.3) NuGet.Frameworks (6.8) - SixLabors.Fonts (2.0) - SixLabors.ImageSharp (3.0.2) - SixLabors.ImageSharp.Drawing (2.0.1) - SixLabors.Fonts (>= 2.0) - SixLabors.ImageSharp (>= 3.0.2) + SixLabors.Fonts (2.0.1) + SixLabors.ImageSharp (3.1.2) + SixLabors.ImageSharp.Drawing (2.1) + SixLabors.Fonts (>= 2.0.1) + SixLabors.ImageSharp (>= 3.1) System.Collections.Immutable (8.0) System.Runtime.CompilerServices.Unsafe (>= 6.0) System.IO.Packaging (8.0) @@ -35,21 +33,19 @@ NUGET System.Runtime.CompilerServices.Unsafe (6.0) System.Text.Encoding.CodePages (8.0) System.Runtime.CompilerServices.Unsafe (>= 6.0) - xunit (2.6.2) - xunit.analyzers (>= 1.6) - xunit.assert (>= 2.6.2) - xunit.core (2.6.2) + xunit (2.6.6) + xunit.analyzers (>= 1.10) + xunit.assert (>= 2.6.6) + xunit.core (2.6.6) xunit.abstractions (2.0.3) - xunit.analyzers (1.6) - xunit.assert (2.6.2) - xunit.core (2.6.2) - xunit.extensibility.core (2.6.2) - xunit.extensibility.execution (2.6.2) - xunit.extensibility.core (2.6.2) - NETStandard.Library (>= 1.6.1) + xunit.analyzers (1.10) + xunit.assert (2.6.6) + xunit.core (2.6.6) + xunit.extensibility.core (2.6.6) + xunit.extensibility.execution (2.6.6) + xunit.extensibility.core (2.6.6) xunit.abstractions (>= 2.0.3) - xunit.extensibility.execution (2.6.2) - NETStandard.Library (>= 1.6.1) - xunit.extensibility.core (2.6.2) - xunit.runner.console (2.6.2) - xunit.runner.visualstudio (2.5.4) + xunit.extensibility.execution (2.6.6) + xunit.extensibility.core (2.6.6) + xunit.runner.console (2.6.6) + xunit.runner.visualstudio (2.5.6)