ironfede / openmcdf

Microsoft Compound File .net component - pure C# - netstandard 2.0
Mozilla Public License 2.0
308 stars 76 forks source link

Rework the writing of DictionaryProperty #107

Closed Numpsy closed 7 months ago

Numpsy commented 7 months ago

According to the Microsoft documentation at https://learn.microsoft.com/en-us/openspecs/windows_protocols/MS-OLEPS/99127b7f-c440-4697-91a4-c853086d6b33 :

1) The dictinoary entry should be Number of entries entries padding so the size is a multiple of 4 bytes

and the current code doesn't do the padding.

2) Each dictionary entry should be Identifier Length Name

but the current code only writes the Identifier and Name, not the length.

Also, if the codepage is CP_WINUNICODE then each individual string entry should be passed as well.

Numpsy commented 7 months ago

Currently a draft because it doesn't handle the different padding behavior required when the code page is CP_WINUNICODE

I see that there's already some currently commented out code for the different code pages at https://github.com/ironfede/openmcdf/blob/7f287e69691b6fa2b6b1ddbdffe3495286a96c34/sources/OpenMcdf.Extensions/OLEProperties/DictionaryEntry.cs#L50 so maybe there's some scope for reusing things a bit more

Numpsy commented 7 months ago

Ok to review I think.

The code for doing the null terminators for each string type is copied from elsewhere, so there is scope to make some more bits shared once it's all working, but as it stands this is keeping the changes self contained inside the dictionary code.

ironfede commented 7 months ago

Many thanks @Numpsy