diff --git a/sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs b/sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs index af36bad1..4055a491 100644 --- a/sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs +++ b/sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs @@ -103,6 +103,9 @@ public ITypedPropertyValue NewProperty(VTPropertyType vType, int codePage, bool case VTPropertyType.VT_BLOB: pr = new VT_BLOB_Property(vType, isVariant); break; + case VTPropertyType.VT_CLSID: + pr = new VT_CLSID_Property(vType, isVariant); + break; default: throw new Exception("Unrecognized property type"); } @@ -699,6 +702,27 @@ public override void WriteScalarValue(BinaryWriter bw, object pValue) } + private class VT_CLSID_Property : TypedPropertyValue + { + public VT_CLSID_Property(VTPropertyType vType, bool isVariant) : base(vType, isVariant) + { + + } + + public override object ReadScalarValue(System.IO.BinaryReader br) + { + byte[] data = br.ReadBytes(16); + return new Guid(data); + } + + public override void WriteScalarValue(BinaryWriter bw, object pValue) + { + byte[] r = pValue as byte[]; + if (r != null) + bw.Write(r); + } + } + private class VT_VariantVector : TypedPropertyValue { private readonly int codePage; diff --git a/sources/Test/OpenMcdf.Extensions.Test/OLEPropertiesExtensionsTest.cs b/sources/Test/OpenMcdf.Extensions.Test/OLEPropertiesExtensionsTest.cs index 928958e0..51a68dd7 100644 --- a/sources/Test/OpenMcdf.Extensions.Test/OLEPropertiesExtensionsTest.cs +++ b/sources/Test/OpenMcdf.Extensions.Test/OLEPropertiesExtensionsTest.cs @@ -442,5 +442,17 @@ public void Test_DOCUMENT_SUMMARY_INFO_ADD_CUSTOM() Assert.AreEqual(VTPropertyType.VT_FILETIME, propArray[4].VTType); } } + + [TestMethod] + public void Test_CLSID_PROPERTY() + { + var guid = new Guid("15891a95-bf6e-4409-b7d0-3a31c391fa31"); + using (CompoundFile cf = new CompoundFile("CLSIDPropertyTest.file")) + { + var co = cf.RootStorage.GetStream("\u0005C3teagxwOttdbfkuIaamtae3Ie").AsOLEPropertiesContainer(); + var clsidProp = co.Properties.First(x => x.PropertyName == "DocumentID"); + Assert.AreEqual(guid, clsidProp.Value); + } + } } } diff --git a/sources/Test/TestFiles/CLSIDPropertyTest.file b/sources/Test/TestFiles/CLSIDPropertyTest.file new file mode 100644 index 00000000..27b609bf Binary files /dev/null and b/sources/Test/TestFiles/CLSIDPropertyTest.file differ