Skip to content

Commit

Permalink
Merge branch '3.0-poc' into 3.0-poc-draft
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-visionaid committed Nov 13, 2024
2 parents 584da52 + f454dac commit f4692b9
Show file tree
Hide file tree
Showing 20 changed files with 517 additions and 10 deletions.
Binary file added OpenMcdf.Ole.Tests/2custom.doc
Binary file not shown.
Binary file added OpenMcdf.Ole.Tests/CLSIDPropertyTest.file
Binary file not shown.
Binary file added OpenMcdf.Ole.Tests/Issue134.cfs
Binary file not shown.
440 changes: 440 additions & 0 deletions OpenMcdf.Ole.Tests/OlePropertiesExtensionsTests.cs

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions OpenMcdf.Ole.Tests/OpenMcdf.Ole.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net48;net8.0</TargetFrameworks>
<OutputType>Exe</OutputType>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<EnableMSTestRunner>true</EnableMSTestRunner>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="MSTest" Version="3.6.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OpenMcdf.Ole\OpenMcdf.Ole.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="2custom.doc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="CLSIDPropertyTest.file">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="english.presets.doc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Issue134.cfs">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="report.xls">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="SampleWorkBook_bug98.xls">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="winUnicodeDictionary.doc">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="wstr_presets.doc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="_Test.ppt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file added OpenMcdf.Ole.Tests/SampleWorkBook_bug98.xls
Binary file not shown.
Binary file added OpenMcdf.Ole.Tests/_Test.ppt
Binary file not shown.
Binary file added OpenMcdf.Ole.Tests/english.presets.doc
Binary file not shown.
Binary file added OpenMcdf.Ole.Tests/report.xls
Binary file not shown.
Binary file added OpenMcdf.Ole.Tests/winUnicodeDictionary.doc
Binary file not shown.
Binary file added OpenMcdf.Ole.Tests/wstr_presets.doc
Binary file not shown.
4 changes: 3 additions & 1 deletion OpenMcdf.Ole/CodePages.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace OpenMcdf.Ole;
using System.Text;

namespace OpenMcdf.Ole;

internal static class CodePages
{
Expand Down
2 changes: 1 addition & 1 deletion OpenMcdf.Ole/DocumentSummaryInfoPropertyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ protected override ITypedPropertyValue CreateLpstrProperty(VTPropertyType vType,
if (propertyIdentifier is 0x0000000C or 0x0000000D)
return new VT_Unaligned_LPSTR_Property(vType, codePage, isVariant);

return CreateLpstrProperty(vType, codePage, propertyIdentifier, isVariant);
return base.CreateLpstrProperty(vType, codePage, propertyIdentifier, isVariant);
}
}
7 changes: 4 additions & 3 deletions OpenMcdf.Ole/OlePropertiesContainer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace OpenMcdf.Ole;
using System.Text;

namespace OpenMcdf.Ole;

public enum ContainerType
{
Expand Down Expand Up @@ -42,8 +44,7 @@ public OlePropertiesContainer(CfbStream cfStream)

this.cfStream = cfStream;

cfStream.Position = 0;
using BinaryReader reader = new(cfStream);
using BinaryReader reader = new(cfStream, Encoding.Unicode, true);
pStream.Read(reader);

if (pStream.FMTID0 == FormatIdentifiers.SummaryInformation)
Expand Down
2 changes: 0 additions & 2 deletions OpenMcdf.Ole/PropertyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ internal abstract class PropertyFactory
{
static PropertyFactory()
{
#if NETSTANDARD2_0_OR_GREATER
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
#endif
}

public ITypedPropertyValue CreateProperty(VTPropertyType vType, int codePage, uint propertyIdentifier, bool isVariant = false)
Expand Down
4 changes: 4 additions & 0 deletions OpenMcdf.Ole/PropertySetStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public PropertySetStream()

public void Read(BinaryReader br)
{
br.BaseStream.Position = 0;

ByteOrder = br.ReadUInt16();
Version = br.ReadUInt16();
SystemIdentifier = br.ReadUInt32();
Expand Down Expand Up @@ -113,6 +115,8 @@ public void Read(BinaryReader br)

public void Write(BinaryWriter bw)
{
bw.BaseStream.Position = 0;

OffsetContainer oc0 = new();
OffsetContainer oc1 = new();

Expand Down
2 changes: 1 addition & 1 deletion OpenMcdf.Tests/OpenMcdf.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>net48;net8.0-windows</TargetFrameworks>
<OutputType>Exe</OutputType>
<LangVersion>11.0</LangVersion>
<LangVersion>12.0</LangVersion>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
6 changes: 6 additions & 0 deletions OpenMcdf.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenMcdf.Ole", "OpenMcdf.Ol
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StructuredStorageExplorer", "StructuredStorageExplorer\StructuredStorageExplorer.csproj", "{D5DDCC19-80C4-40D2-AEBF-2DA1CCB1D543}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenMcdf.Ole.Tests", "OpenMcdf.Ole.Tests\OpenMcdf.Ole.Tests.csproj", "{34F153C4-3EFA-4D6E-B860-AEE300CCCF98}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -58,6 +60,10 @@ Global
{D5DDCC19-80C4-40D2-AEBF-2DA1CCB1D543}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5DDCC19-80C4-40D2-AEBF-2DA1CCB1D543}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5DDCC19-80C4-40D2-AEBF-2DA1CCB1D543}.Release|Any CPU.Build.0 = Release|Any CPU
{34F153C4-3EFA-4D6E-B860-AEE300CCCF98}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34F153C4-3EFA-4D6E-B860-AEE300CCCF98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34F153C4-3EFA-4D6E-B860-AEE300CCCF98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34F153C4-3EFA-4D6E-B860-AEE300CCCF98}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
4 changes: 3 additions & 1 deletion OpenMcdf/RootStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public static RootStorage Create(Stream stream, Version version = Version.V3, St
return new RootStorage(rootContextSite, flags);
}

public static RootStorage CreateInMemory(Version version = Version.V3) => Create(new MemoryStream(), version);

public static RootStorage Open(string fileName, FileMode mode, StorageModeFlags flags = StorageModeFlags.None)
{
ThrowIfLeaveOpen(flags);
Expand Down Expand Up @@ -91,7 +93,7 @@ public static RootStorage Open(Stream stream, StorageModeFlags flags = StorageMo
this.storageModeFlags = storageModeFlags;
}

public void Dispose() => Context?.Dispose();
public void Dispose() => Context.Dispose();

public void Flush(bool consolidate = false)
{
Expand Down
2 changes: 1 addition & 1 deletion StructuredStorageExplorer/StreamDataProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace StructuredStorageExplorer;

public class StreamDataProvider : IByteProvider
internal sealed class StreamDataProvider : IByteProvider
{
/// <summary>
/// Modifying stream
Expand Down

0 comments on commit f4692b9

Please sign in to comment.