Skip to content

Commit

Permalink
Merge pull request #143 from Visionaid-International-Ltd/spelling-and…
Browse files Browse the repository at this point in the history
…-formatting

Spelling and formatting fixes
  • Loading branch information
ironfede authored Sep 3, 2024
2 parents 2e0d67b + 5b4778c commit 6037a1f
Show file tree
Hide file tree
Showing 60 changed files with 206 additions and 323 deletions.
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ variables:
buildConfiguration: 'Release'
libFramework: 'netstandard2.0'
appFramework: 'net6.0'
# pay attention to slashes
# pay attention to slashes
testsProject: 'sources/Test/OpenMcdf.Test/OpenMcdf.Test.csproj'
extensionTestsProject: 'sources/Test/OpenMcdf.Extensions.Test/OpenMcdf.Extensions.Test.csproj'
buildProject: 'sources/OpenMcdf/OpenMcdf.csproj'
# without filter it will timoeout in azure AFTER 60+ min
# without filter it will timeout in azure AFTER 60+ min
testFilter: 'Name!=Test_FIX_BUG_GH_14&Name!=Test_FIX_BUG_GH_15'

steps:
Expand Down
7 changes: 2 additions & 5 deletions sources/OpenMcdf.Extensions/CFStreamExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.IO;

namespace OpenMcdf.Extensions
{
Expand All @@ -25,7 +22,7 @@ public static Stream AsIOStream(this CFStream cfStream)
///// as a OLE properties Stream.
///// </summary>
///// <param name="cfStream"></param>
///// <returns>A <see cref="T:OpenMcdf.OLEProperties.PropertySetStream">OLE Propertie stream</see></returns>
///// <returns>A <see cref="T:OpenMcdf.OLEProperties.PropertySetStream">OLE Property Set Stream</see></returns>
//public static OLEProperties.PropertySetStream AsOLEProperties(this CFStream cfStream)
//{
// var result = new OLEProperties.PropertySetStream();
Expand Down
2 changes: 0 additions & 2 deletions sources/OpenMcdf.Extensions/OLEProperties/Common.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenMcdf.Extensions.OLEProperties
{
Expand Down
2 changes: 0 additions & 2 deletions sources/OpenMcdf.Extensions/OLEProperties/DictionaryEntry.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace OpenMcdf.Extensions.OLEProperties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using OpenMcdf.Extensions.OLEProperties.Interfaces;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
Expand Down Expand Up @@ -51,7 +50,7 @@ public void Read(BinaryReader br)

if (m > 0)
{
for(int i = 0; i < m; i++)
for (int i = 0; i < m; i++)
{
br.ReadByte();
}
Expand All @@ -69,7 +68,7 @@ public void Read(BinaryReader br)
public void Write(BinaryWriter bw)
{
long curPos = bw.BaseStream.Position;

bw.Write(entries.Count);

foreach (KeyValuePair<uint, string> kv in entries)
Expand Down Expand Up @@ -102,7 +101,7 @@ private void WriteEntry(BinaryWriter bw, uint propertyIdentifier, string name)
if (addNullTerminator)
byteLength += 2;

bw.Write((uint)byteLength / 2);
bw.Write(byteLength / 2);
bw.Write(nameBytes);

if (addNullTerminator)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.IO;

namespace OpenMcdf.Extensions.OLEProperties.Interfaces
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenMcdf.Extensions.OLEProperties.Interfaces
namespace OpenMcdf.Extensions.OLEProperties.Interfaces
{
public interface IProperty : IBinarySerializable
{
Expand All @@ -17,6 +13,6 @@ PropertyType PropertyType
{
get;
}

}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenMcdf.Extensions.OLEProperties.Interfaces
namespace OpenMcdf.Extensions.OLEProperties.Interfaces
{
public interface ITypedPropertyValue : IProperty
{
Expand All @@ -19,7 +15,7 @@ PropertyDimensions PropertyDimensions

bool IsVariant
{
get;
get;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
using System;
using OpenMcdf.Extensions.OLEProperties.Interfaces;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using OpenMcdf.Extensions.OLEProperties.Interfaces;

namespace OpenMcdf.Extensions.OLEProperties
{
Expand Down Expand Up @@ -123,7 +122,7 @@ internal OLEPropertiesContainer(CFStream cfStream)
var op = new OLEProperty(this)
{
VTType = p.VTType,
PropertyIdentifier = (uint)pStream.PropertySet0.PropertyIdentifierAndOffsets[i].PropertyIdentifier,
PropertyIdentifier = pStream.PropertySet0.PropertyIdentifierAndOffsets[i].PropertyIdentifier,
Value = p.Value
};

Expand All @@ -150,7 +149,7 @@ internal OLEPropertiesContainer(CFStream cfStream)
var op = new OLEProperty(UserDefinedProperties);

op.VTType = p.VTType;
op.PropertyIdentifier = (uint)pStream.PropertySet1.PropertyIdentifierAndOffsets[i].PropertyIdentifier;
op.PropertyIdentifier = pStream.PropertySet1.PropertyIdentifierAndOffsets[i].PropertyIdentifier;
op.Value = p.Value;

UserDefinedProperties.properties.Add(op);
Expand All @@ -159,7 +158,7 @@ internal OLEPropertiesContainer(CFStream cfStream)
var existingPropertyNames = (Dictionary<uint, string>)pStream.PropertySet1.Properties
.Where(p => p.PropertyType == PropertyType.DictionaryProperty).FirstOrDefault()?.Value;

UserDefinedProperties.PropertyNames = existingPropertyNames ?? new Dictionary<uint, string> ();
UserDefinedProperties.PropertyNames = existingPropertyNames ?? new Dictionary<uint, string>();
}
}

Expand Down Expand Up @@ -266,7 +265,7 @@ public void Save(CFStream cfStream)
}
};

PropertyFactory factory =
PropertyFactory factory =
this.ContainerType == ContainerType.DocumentSummaryInfo ? DocumentSummaryInfoPropertyFactory.Instance : DefaultPropertyFactory.Instance;

foreach (var op in this.Properties)
Expand Down
2 changes: 0 additions & 2 deletions sources/OpenMcdf.Extensions/OLEProperties/OLEProperty.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@

using System;
using System.Collections.Generic;
using System.Text;

namespace OpenMcdf.Extensions.OLEProperties
{
Expand Down
12 changes: 6 additions & 6 deletions sources/OpenMcdf.Extensions/OLEProperties/PropertyFactory.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using OpenMcdf.Extensions.OLEProperties.Interfaces;
using System;
using System.Text;
using System.IO;
using System.Text;

namespace OpenMcdf.Extensions.OLEProperties
{
Expand Down Expand Up @@ -443,7 +443,7 @@ public override void WriteScalarValue(BinaryWriter bw, string pValue)
//if (addNullTerminator)
dataLength += 2; // null terminator \u+0000

// var mod = dataLength % 4; // pad to multiple of 4 bytes
// var mod = dataLength % 4; // pad to multiple of 4 bytes

bw.Write(dataLength); // datalength of string + null char (unicode)
bw.Write(data); // string
Expand Down Expand Up @@ -602,7 +602,7 @@ public override Decimal ReadScalarValue(System.IO.BinaryReader br)

public override void WriteScalarValue(BinaryWriter bw, Decimal pValue)
{
int[] parts = Decimal.GetBits((Decimal)pValue);
int[] parts = Decimal.GetBits(pValue);

bool sign = (parts[3] & 0x80000000) != 0;
byte scale = (byte)((parts[3] >> 16) & 0x7F);
Expand All @@ -628,14 +628,14 @@ public VT_BOOL_Property(VTPropertyType vType, bool isVariant) : base(vType, isVa
public override bool ReadScalarValue(System.IO.BinaryReader br)
{

this.propertyValue = br.ReadUInt16() == (ushort)0xFFFF ? true : false;
this.propertyValue = br.ReadUInt16() == 0xFFFF ? true : false;
return (bool)propertyValue;
//br.ReadUInt16();//padding
}

public override void WriteScalarValue(BinaryWriter bw, bool pValue)
{
bw.Write((bool)pValue ? (ushort)0xFFFF : (ushort)0);
bw.Write(pValue ? (ushort)0xFFFF : (ushort)0);

}

Expand Down Expand Up @@ -761,7 +761,7 @@ public override void WriteScalarValue(BinaryWriter bw, object pValue)
}

// The default property factory.
internal sealed class DefaultPropertyFactory : PropertyFactory
internal sealed class DefaultPropertyFactory : PropertyFactory
{
public static PropertyFactory Instance { get; } = new DefaultPropertyFactory();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using OpenMcdf.Extensions.OLEProperties.Interfaces;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace OpenMcdf.Extensions.OLEProperties
{
public class PropertyIdentifierAndOffset: IBinarySerializable
public class PropertyIdentifierAndOffset : IBinarySerializable
{
public uint PropertyIdentifier { get; set; }
public uint Offset { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions sources/OpenMcdf.Extensions/OLEProperties/PropertyReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
// this.ctx.CodePage = (int)(ushort)(short)pr.Value;
// }






// }
//}
10 changes: 4 additions & 6 deletions sources/OpenMcdf.Extensions/OLEProperties/PropertySet.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
using OpenMcdf.Extensions.OLEProperties.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;
using System.Linq;

namespace OpenMcdf.Extensions.OLEProperties
{
internal class PropertySet
internal sealed class PropertySet
{

public PropertyContext PropertyContext
{
get; set;
get; set;
}

public uint Size { get; set; }
Expand Down Expand Up @@ -51,7 +49,7 @@ public void LoadContext(int propertySetOffset, BinaryReader br)

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

br.BaseStream.Position = currPos;
}
Expand Down
22 changes: 10 additions & 12 deletions sources/OpenMcdf.Extensions/OLEProperties/PropertySetStream.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using OpenMcdf.Extensions.OLEProperties.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.IO;

namespace OpenMcdf.Extensions.OLEProperties
{
internal class PropertySetStream
internal sealed class PropertySetStream
{


Expand Down Expand Up @@ -68,13 +66,13 @@ public void Read(System.IO.BinaryReader br)
// Read properties (P0)
for (int i = 0; i < PropertySet0.NumProperties; i++)
{
br.BaseStream.Seek(Offset0 + PropertySet0.PropertyIdentifierAndOffsets[i].Offset, System.IO.SeekOrigin.Begin);
br.BaseStream.Seek(Offset0 + PropertySet0.PropertyIdentifierAndOffsets[i].Offset, SeekOrigin.Begin);
PropertySet0.Properties.Add(ReadProperty(PropertySet0.PropertyIdentifierAndOffsets[i].PropertyIdentifier, PropertySet0.PropertyContext.CodePage, br, factory));
}

if (NumPropertySets == 2)
{
br.BaseStream.Seek(Offset1, System.IO.SeekOrigin.Begin);
br.BaseStream.Seek(Offset1, SeekOrigin.Begin);
PropertySet1 = new PropertySet();
PropertySet1.Size = br.ReadUInt32();
PropertySet1.NumProperties = br.ReadUInt32();
Expand All @@ -93,7 +91,7 @@ public void Read(System.IO.BinaryReader br)
// Read properties
for (int i = 0; i < PropertySet1.NumProperties; i++)
{
br.BaseStream.Seek(Offset1 + PropertySet1.PropertyIdentifierAndOffsets[i].Offset, System.IO.SeekOrigin.Begin);
br.BaseStream.Seek(Offset1 + PropertySet1.PropertyIdentifierAndOffsets[i].Offset, SeekOrigin.Begin);
PropertySet1.Properties.Add(ReadProperty(PropertySet1.PropertyIdentifierAndOffsets[i].PropertyIdentifier, PropertySet1.PropertyContext.CodePage, br, DefaultPropertyFactory.Instance));
}
}
Expand Down Expand Up @@ -186,28 +184,28 @@ public void Write(System.IO.BinaryWriter bw)

int size1 = (int)(bw.BaseStream.Position - oc1.OffsetPS);

bw.Seek(oc1.OffsetPS, System.IO.SeekOrigin.Begin);
bw.Seek(oc1.OffsetPS, SeekOrigin.Begin);
bw.Write(size1);
}

bw.Seek(oc0.OffsetPS, System.IO.SeekOrigin.Begin);
bw.Seek(oc0.OffsetPS, SeekOrigin.Begin);
bw.Write(size0);

int shiftO1 = 2 + 2 + 4 + 16 + 4 + 16; //OFFSET0
bw.Seek(shiftO1, System.IO.SeekOrigin.Begin);
bw.Seek(shiftO1, SeekOrigin.Begin);
bw.Write(oc0.OffsetPS);

if (NumPropertySets == 2)
{
bw.Seek(shiftO1 + 4 + 16, System.IO.SeekOrigin.Begin);
bw.Seek(shiftO1 + 4 + 16, SeekOrigin.Begin);
bw.Write(oc1.OffsetPS);
}

//-----------

for (int i = 0; i < PropertySet0.PropertyIdentifierAndOffsets.Count; i++)
{
bw.Seek((int)oc0.PropertyIdentifierOffsets[i] + 4, System.IO.SeekOrigin.Begin); //Offset of 4 to Offset value
bw.Seek((int)oc0.PropertyIdentifierOffsets[i] + 4, SeekOrigin.Begin); //Offset of 4 to Offset value
bw.Write((int)(oc0.PropertyOffsets[i] - oc0.OffsetPS));
}

Expand All @@ -217,7 +215,7 @@ public void Write(System.IO.BinaryWriter bw)
{
for (int i = 0; i < PropertySet1.PropertyIdentifierAndOffsets.Count; i++)
{
bw.Seek((int)oc1.PropertyIdentifierOffsets[i] + 4, System.IO.SeekOrigin.Begin); //Offset of 4 to Offset value
bw.Seek((int)oc1.PropertyIdentifierOffsets[i] + 4, SeekOrigin.Begin); //Offset of 4 to Offset value
bw.Write((int)(oc1.PropertyOffsets[i] - oc1.OffsetPS));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace OpenMcdf.Extensions.OLEProperties
{
Expand Down
Loading

0 comments on commit 6037a1f

Please sign in to comment.