Skip to content

Commit 4d1a331

Browse files
authored
Merge pull request #138 from conormcg94/users/cmcg/clsid_property
Added CLSID property to OLEProperties
2 parents 2c60fa8 + c5545d8 commit 4d1a331

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ public ITypedPropertyValue NewProperty(VTPropertyType vType, int codePage, bool
103103
case VTPropertyType.VT_BLOB:
104104
pr = new VT_BLOB_Property(vType, isVariant);
105105
break;
106+
case VTPropertyType.VT_CLSID:
107+
pr = new VT_CLSID_Property(vType, isVariant);
108+
break;
106109
default:
107110
throw new Exception("Unrecognized property type");
108111
}
@@ -699,6 +702,27 @@ public override void WriteScalarValue(BinaryWriter bw, object pValue)
699702

700703
}
701704

705+
private class VT_CLSID_Property : TypedPropertyValue<object>
706+
{
707+
public VT_CLSID_Property(VTPropertyType vType, bool isVariant) : base(vType, isVariant)
708+
{
709+
710+
}
711+
712+
public override object ReadScalarValue(System.IO.BinaryReader br)
713+
{
714+
byte[] data = br.ReadBytes(16);
715+
return new Guid(data);
716+
}
717+
718+
public override void WriteScalarValue(BinaryWriter bw, object pValue)
719+
{
720+
byte[] r = pValue as byte[];
721+
if (r != null)
722+
bw.Write(r);
723+
}
724+
}
725+
702726
private class VT_VariantVector : TypedPropertyValue<object>
703727
{
704728
private readonly int codePage;

sources/Test/OpenMcdf.Extensions.Test/OLEPropertiesExtensionsTest.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,5 +442,17 @@ public void Test_DOCUMENT_SUMMARY_INFO_ADD_CUSTOM()
442442
Assert.AreEqual(VTPropertyType.VT_FILETIME, propArray[4].VTType);
443443
}
444444
}
445+
446+
[TestMethod]
447+
public void Test_CLSID_PROPERTY()
448+
{
449+
var guid = new Guid("15891a95-bf6e-4409-b7d0-3a31c391fa31");
450+
using (CompoundFile cf = new CompoundFile("CLSIDPropertyTest.file"))
451+
{
452+
var co = cf.RootStorage.GetStream("\u0005C3teagxwOttdbfkuIaamtae3Ie").AsOLEPropertiesContainer();
453+
var clsidProp = co.Properties.First(x => x.PropertyName == "DocumentID");
454+
Assert.AreEqual(guid, clsidProp.Value);
455+
}
456+
}
445457
}
446458
}
240 KB
Binary file not shown.

0 commit comments

Comments
 (0)