From 3344ef7e4e39edb8e217c8181fbb5ece98bde4f0 Mon Sep 17 00:00:00 2001 From: Richard Webb Date: Wed, 21 Feb 2024 12:07:58 +0000 Subject: [PATCH] When creating a OLEPropertiesContainer for the UserDefinedPropeties, use the code page from PropertySet1 instead of the one from the parent section --- .../OLEProperties/OLEPropertiesContainer.cs | 2 +- .../OLEPropertiesExtensionsTest.cs | 38 ++++++++++++++++++ .../Test/TestFiles/winUnicodeDictionary.doc | Bin 0 -> 26624 bytes 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 sources/Test/TestFiles/winUnicodeDictionary.doc diff --git a/sources/OpenMcdf.Extensions/OLEProperties/OLEPropertiesContainer.cs b/sources/OpenMcdf.Extensions/OLEProperties/OLEPropertiesContainer.cs index 9c49ce0b..42afbc1e 100644 --- a/sources/OpenMcdf.Extensions/OLEProperties/OLEPropertiesContainer.cs +++ b/sources/OpenMcdf.Extensions/OLEProperties/OLEPropertiesContainer.cs @@ -131,7 +131,7 @@ internal OLEPropertiesContainer(CFStream cfStream) if (pStream.NumPropertySets == 2) { - UserDefinedProperties = new OLEPropertiesContainer(this.Context.CodePage, ContainerType.UserDefinedProperties); + UserDefinedProperties = new OLEPropertiesContainer(pStream.PropertySet1.PropertyContext.CodePage, ContainerType.UserDefinedProperties); this.HasUserDefinedProperties = true; UserDefinedProperties.ContainerType = ContainerType.UserDefinedProperties; diff --git a/sources/Test/OpenMcdf.Extensions.Test/OLEPropertiesExtensionsTest.cs b/sources/Test/OpenMcdf.Extensions.Test/OLEPropertiesExtensionsTest.cs index 93d28931..cb2a5e5b 100644 --- a/sources/Test/OpenMcdf.Extensions.Test/OLEPropertiesExtensionsTest.cs +++ b/sources/Test/OpenMcdf.Extensions.Test/OLEPropertiesExtensionsTest.cs @@ -333,5 +333,43 @@ public void Test_SUMMARY_INFO_MODIFY_LPWSTRING() } } + // winUnicodeDictionary.doc contains a UserProperties section with the CP_WINUNICODE codepage, and LPWSTR string properties + [TestMethod] + public void Test_Read_Unicode_User_Properties_Dictionary() + { + using (CompoundFile cf = new CompoundFile("winUnicodeDictionary.doc")) + { + var dsiStream = cf.RootStorage.GetStream("\u0005DocumentSummaryInformation"); + var co = dsiStream.AsOLEPropertiesContainer(); + var userProps = co.UserDefinedProperties; + + // CodePage should be CP_WINUNICODE (1200) + Assert.AreEqual(1200, userProps.Context.CodePage); + + // There should be 5 property names present, and 6 properties (the properties include the code page) + Assert.AreEqual(5, userProps.PropertyNames.Count); + Assert.AreEqual(6, userProps.Properties.Count()); + + // Check for expected names and values + var propArray = userProps.Properties.ToArray(); + + // CodePage prop + Assert.AreEqual(1u, propArray[0].PropertyIdentifier); + Assert.AreEqual("0x00000001", propArray[0].PropertyName); + Assert.AreEqual((short)1200, propArray[0].Value); + + // String properties + Assert.AreEqual("A\0", propArray[1].PropertyName); + Assert.AreEqual("\0", propArray[1].Value); + Assert.AreEqual("AB\0", propArray[2].PropertyName); + Assert.AreEqual("X\0", propArray[2].Value); + Assert.AreEqual("ABC\0", propArray[3].PropertyName); + Assert.AreEqual("XY\0", propArray[3].Value); + Assert.AreEqual("ABCD\0", propArray[4].PropertyName); + Assert.AreEqual("XYZ\0", propArray[4].Value); + Assert.AreEqual("ABCDE\0", propArray[5].PropertyName); + Assert.AreEqual("XYZ!\0", propArray[5].Value); + } + } } } diff --git a/sources/Test/TestFiles/winUnicodeDictionary.doc b/sources/Test/TestFiles/winUnicodeDictionary.doc new file mode 100644 index 0000000000000000000000000000000000000000..2ba5153c78913c14c548d70d188ceae510d70845 GIT binary patch literal 26624 zcmeHP2|ShA`#<+`?OT$B>V`^XO`#@5m@HY6MEk|Xm7SzTsc6wODP>eDNqeFxZQ7(z zNm`MaNLq*Hwv1&YzvsE`Te_2}=Kr7He}4bpdwibvIp;a&d7krr&w1bXoO91ncD-B8 zj>GB?h)5Vs#K^mLX(G`{&VaZfl~y9e7~&{<*WTWaVgn$E(&0Y{f%;wfL@Z8PoDjb9 zIc!8ipk*OQ5yAvgAl`xAfk!=#dI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