diff --git a/OpenMcdf.Ole/OlePropertiesContainer.cs b/OpenMcdf.Ole/OlePropertiesContainer.cs index 72cbfe0..2e935c5 100644 --- a/OpenMcdf.Ole/OlePropertiesContainer.cs +++ b/OpenMcdf.Ole/OlePropertiesContainer.cs @@ -71,7 +71,7 @@ public OlePropertiesContainer(CfbStream cfStream) for (int i = 0; i < pStream.PropertySet0.Properties.Count; i++) { PropertyIdentifierAndOffset propertyIdentifierAndOffset = pStream.PropertySet0.PropertyIdentifierAndOffsets[i]; - if (propertyIdentifierAndOffset.PropertyIdentifier == 0) continue; + if (propertyIdentifierAndOffset.PropertyIdentifier == SpecialPropertyIdentifiers.Dictionary) continue; //if (propertyIdentifierAndOffset.PropertyIdentifier == 1) continue; //if (propertyIdentifierAndOffset.PropertyIdentifier == 0x80000000) continue; @@ -95,7 +95,7 @@ public OlePropertiesContainer(CfbStream cfStream) for (int i = 0; i < propertySet1.Properties.Count; i++) { PropertyIdentifierAndOffset propertyIdentifierAndOffset = propertySet1.PropertyIdentifierAndOffsets[i]; - if (propertyIdentifierAndOffset.PropertyIdentifier is 0 or 0x80000000) + if (propertyIdentifierAndOffset.PropertyIdentifier is SpecialPropertyIdentifiers.Dictionary or SpecialPropertyIdentifiers.Locale) continue; var p = (ITypedPropertyValue)propertySet1.Properties[i]; diff --git a/OpenMcdf.Ole/PropertySet.cs b/OpenMcdf.Ole/PropertySet.cs index 196cf0d..2d666b3 100644 --- a/OpenMcdf.Ole/PropertySet.cs +++ b/OpenMcdf.Ole/PropertySet.cs @@ -13,7 +13,7 @@ internal sealed class PropertySet public void LoadContext(int propertySetOffset, BinaryReader br) { long currPos = br.BaseStream.Position; - int codePageOffset = (int)(propertySetOffset + PropertyIdentifierAndOffsets.First(pio => pio.PropertyIdentifier == 1).Offset); + int codePageOffset = (int)(propertySetOffset + PropertyIdentifierAndOffsets.First(pio => pio.PropertyIdentifier == SpecialPropertyIdentifiers.CodePage).Offset); br.BaseStream.Seek(codePageOffset, SeekOrigin.Begin); var vType = (VTPropertyType)br.ReadUInt16(); @@ -30,6 +30,6 @@ public void Add(IDictionary propertyNames) Value = propertyNames }; Properties.Add(dictionaryProperty); - PropertyIdentifierAndOffsets.Add(new PropertyIdentifierAndOffset() { PropertyIdentifier = 0, Offset = 0 }); + PropertyIdentifierAndOffsets.Add(new PropertyIdentifierAndOffset() { PropertyIdentifier = SpecialPropertyIdentifiers.Dictionary, Offset = 0 }); } } diff --git a/OpenMcdf.Ole/PropertySetStream.cs b/OpenMcdf.Ole/PropertySetStream.cs index b76f30a..0264307 100644 --- a/OpenMcdf.Ole/PropertySetStream.cs +++ b/OpenMcdf.Ole/PropertySetStream.cs @@ -214,7 +214,7 @@ public void Write(BinaryWriter bw) private static IProperty ReadProperty(uint propertyIdentifier, int codePage, BinaryReader br, PropertyFactory factory) { - if (propertyIdentifier == 0) + if (propertyIdentifier == SpecialPropertyIdentifiers.Dictionary) { DictionaryProperty dictionaryProperty = new(codePage); dictionaryProperty.Read(br); diff --git a/OpenMcdf.Ole/SpecialPropertyIdentifiers.cs b/OpenMcdf.Ole/SpecialPropertyIdentifiers.cs new file mode 100644 index 0000000..654c852 --- /dev/null +++ b/OpenMcdf.Ole/SpecialPropertyIdentifiers.cs @@ -0,0 +1,9 @@ +namespace OpenMcdf.Ole; + +// Identifiers for properties that we treat specially. +internal static class SpecialPropertyIdentifiers +{ + public const uint Dictionary = 0; + public const uint CodePage = 1; + public const uint Locale = 0x80000000; +}