FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Read the PropertySet Locale property into the PropertyContext by Numpsy · Pull Request #259 · openmcdf/openmcdf · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cs  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ public void TestRetainDictionaryPropertyInAppSpecificStreams()

Assert.AreEqual(ContainerType.AppSpecific, co.ContainerType);
Assert.AreEqual(expectedFmtid0, co.FMTID0);
Assert.AreEqual(1040u, co.Context.Locale);
CollectionAssert.AreEqual(expectedPropertyNames, co.PropertyNames);

// Write test file
Expand Down
3 changes: 2 additions & 1 deletion OpenMcdf.Ole/OlePropertiesContainer.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public OlePropertiesContainer(CfbStream cfStream)

Context = new PropertyContext()
{
CodePage = pStream.PropertySet0.PropertyContext.CodePage
CodePage = pStream.PropertySet0.PropertyContext.CodePage,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Oh wait. Should Context even be a member of OlePropertiesContainer? Can the one from PropertySet be used instead? I'm not sure of the reason for interaction, but its seems just like duplication at a glance.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hmm, don't know why it was cloning the context originally, and I didn't think to just use the existing context instance directly on read :-(

The write side at https://github.com/ironfede/openmcdf/blob/319c003b7b71cc232683b3048c4622ef528fa11e/OpenMcdf.Ole/OlePropertiesContainer.cs#L243 is already just using the same context instead of cloning it, so it'd make sense to make them consistent

Locale = pStream.PropertySet0.PropertyContext.Locale
};

for (int i = 0; i < pStream.PropertySet0.Properties.Count; i++)
Expand Down
14 changes: 14 additions & 0 deletions OpenMcdf.Ole/PropertySet.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,27 @@ internal sealed class PropertySet
public void LoadContext(int propertySetOffset, BinaryReader br)
{
long currPos = br.BaseStream.Position;

// Read the code page - this should always be present
int codePageOffset = (int)(propertySetOffset + PropertyIdentifierAndOffsets.First(pio => pio.PropertyIdentifier == SpecialPropertyIdentifiers.CodePage).Offset);
br.BaseStream.Seek(codePageOffset, SeekOrigin.Begin);

var vType = (VTPropertyType)br.ReadUInt16();
br.ReadUInt16(); // Ushort Padding
PropertyContext.CodePage = (ushort)br.ReadInt16();

// Read the Locale, if present
PropertyIdentifierAndOffset? localeProperty = PropertyIdentifierAndOffsets.FirstOrDefault(pio => pio.PropertyIdentifier == SpecialPropertyIdentifiers.Locale);
if (localeProperty is not null)
{
long localeOffset = (propertySetOffset + localeProperty.Offset);
br.BaseStream.Seek(localeOffset, SeekOrigin.Begin);

vType = (VTPropertyType)br.ReadUInt16();
br.ReadUInt16(); // Ushort Padding
PropertyContext.Locale = br.ReadUInt32();
}

br.BaseStream.Position = currPos;
}

Expand Down

Back | FazBrowse Home | New Git URL