From cdbe4e125cb002b3aeae4b75a6b7286b336205d4 Mon Sep 17 00:00:00 2001 From: Richard Webb Date: Thu, 13 Jun 2024 17:13:05 +0100 Subject: [PATCH] Store the value of FmtID0 when reading a property set, and use that value on write if available. --- .../OLEProperties/OLEPropertiesContainer.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sources/OpenMcdf.Extensions/OLEProperties/OLEPropertiesContainer.cs b/sources/OpenMcdf.Extensions/OLEProperties/OLEPropertiesContainer.cs index 4c240890..15bb34ad 100644 --- a/sources/OpenMcdf.Extensions/OLEProperties/OLEPropertiesContainer.cs +++ b/sources/OpenMcdf.Extensions/OLEProperties/OLEPropertiesContainer.cs @@ -17,6 +17,7 @@ public class OLEPropertiesContainer public bool HasUserDefinedProperties { get; private set; } public ContainerType ContainerType { get; internal set; } + private Guid? FmtID0 { get; } public PropertyContext Context { get; private set; } @@ -100,6 +101,7 @@ internal OLEPropertiesContainer(CFStream cfStream) break; } + this.FmtID0 = pStream.FMTID0; this.PropertyNames = (Dictionary)pStream.PropertySet0.Properties .Where(p => p.PropertyType == PropertyType.DictionaryProperty).FirstOrDefault()?.Value; @@ -238,6 +240,8 @@ public void Save(CFStream cfStream) Stream s = new StreamDecorator(cfStream); BinaryWriter bw = new BinaryWriter(s); + Guid fmtId0 = this.FmtID0 ?? (this.ContainerType == ContainerType.SummaryInfo ? new Guid(WellKnownFMTID.FMTID_SummaryInformation) : new Guid(WellKnownFMTID.FMTID_DocSummaryInformation)); + PropertySetStream ps = new PropertySetStream { ByteOrder = 0xFFFE, @@ -247,7 +251,7 @@ public void Save(CFStream cfStream) NumPropertySets = 1, - FMTID0 = this.ContainerType == ContainerType.SummaryInfo ? new Guid(WellKnownFMTID.FMTID_SummaryInformation) : new Guid(WellKnownFMTID.FMTID_DocSummaryInformation), + FMTID0 = fmtId0, Offset0 = 0, FMTID1 = Guid.Empty,