Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Start adding some constants for properties that are treated specially #267

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions OpenMcdf.Ole/OlePropertiesContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions OpenMcdf.Ole/PropertySet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -30,6 +30,6 @@ public void Add(IDictionary<uint, string> propertyNames)
Value = propertyNames
};
Properties.Add(dictionaryProperty);
PropertyIdentifierAndOffsets.Add(new PropertyIdentifierAndOffset() { PropertyIdentifier = 0, Offset = 0 });
PropertyIdentifierAndOffsets.Add(new PropertyIdentifierAndOffset() { PropertyIdentifier = SpecialPropertyIdentifiers.Dictionary, Offset = 0 });
}
}
2 changes: 1 addition & 1 deletion OpenMcdf.Ole/PropertySetStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions OpenMcdf.Ole/SpecialPropertyIdentifiers.cs
Original file line number Diff line number Diff line change
@@ -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;
}
Loading