Implemented additional functionality, sorta works, but not really

This commit is contained in:
Michael Becker 2015-12-01 00:09:10 -05:00
parent c152cc4e9c
commit d3c79f8e3c
5 changed files with 321 additions and 11 deletions

View File

@ -197,7 +197,6 @@ namespace UniversalEditor.DataFormats.Help.Compiled.WinHelp
while (!reader.EndOfStream)
{
Internal.TOPICLINK topicLink = ReadTOPICLINK(reader);
switch (topicLink.RecordType)
{
case Internal.TopicLinkRecordType.TopicHeader:
@ -218,20 +217,78 @@ namespace UniversalEditor.DataFormats.Help.Compiled.WinHelp
break;
}
case Internal.TopicLinkRecordType.Display31:
case Internal.TopicLinkRecordType.Table31:
{
// TODO: test with putty.hlp
byte unknown1 = reader.ReadByte();
byte unknown2 = reader.ReadByte();
ushort id = reader.ReadUInt16();
ushort flags = reader.ReadUInt16(); // unknownfollows, spacingabovefollows, rightindentfollows, etc.
byte[] blahblah = reader.ReadBytes(7);
ushort sanityCheck0xFF = reader.ReadUInt16();
if (sanityCheck0xFF == 0xFF)
if (topicLink.RecordType == Internal.TopicLinkRecordType.Display31 || topicLink.RecordType == Internal.TopicLinkRecordType.Table31)
{
// end of character formatting. proceed with next ParagraphInfo if RecordType is 0x23, else you are done
string value = reader.ReadNullTerminatedString();
int TopicSize = ReadCompressedInt32(reader);
ushort TopicLength = ReadCompressedUInt16(reader);
}
if (topicLink.RecordType == Internal.TopicLinkRecordType.Table31)
{
short column = reader.ReadInt16(); // -1 if end of topic, don't continue
short unknown = reader.ReadInt16();
byte always0 = reader.ReadByte();
}
byte unknown01 = reader.ReadByte();
byte unknown02 = reader.ReadByte();
ushort id = reader.ReadUInt16();
Internal.TopicLinkDisplay31Flags flags = (Internal.TopicLinkDisplay31Flags)reader.ReadUInt16();
if ((flags & Internal.TopicLinkDisplay31Flags.UnknownFollows) == Internal.TopicLinkDisplay31Flags.UnknownFollows)
{
// read compressed long Unknown
}
if ((flags & Internal.TopicLinkDisplay31Flags.SpacingAboveFollows) == Internal.TopicLinkDisplay31Flags.SpacingAboveFollows)
{
// read compressed short SpacingAbove
}
if ((flags & Internal.TopicLinkDisplay31Flags.SpacingBelowFollows) == Internal.TopicLinkDisplay31Flags.SpacingBelowFollows)
{
}
if ((flags & Internal.TopicLinkDisplay31Flags.SpacingLinesFollows) == Internal.TopicLinkDisplay31Flags.SpacingLinesFollows)
{
short spacingLines = ReadCompressedInt16(reader);
}
if ((flags & Internal.TopicLinkDisplay31Flags.LeftIndentFollows) == Internal.TopicLinkDisplay31Flags.LeftIndentFollows)
{
}
if ((flags & Internal.TopicLinkDisplay31Flags.RightIndentFollows) == Internal.TopicLinkDisplay31Flags.RightIndentFollows)
{
short rightIndent = ReadCompressedInt16(reader);
}
if ((flags & Internal.TopicLinkDisplay31Flags.FirstLineIndentFollows) == Internal.TopicLinkDisplay31Flags.FirstLineIndentFollows)
{
}
if ((flags & Internal.TopicLinkDisplay31Flags.BorderInfoFollows) == Internal.TopicLinkDisplay31Flags.BorderInfoFollows)
{
Internal.TopicLinkDisplay31BorderStyle borderStyle = (Internal.TopicLinkDisplay31BorderStyle)reader.ReadByte();
short borderWidth = reader.ReadInt16();
}
if ((flags & Internal.TopicLinkDisplay31Flags.TabInfoFollows) == Internal.TopicLinkDisplay31Flags.TabInfoFollows)
{
// compressed short TabStopCount
// ... da fuq?
}
Internal.TopicLinkDisplay31Opcode opcode = (Internal.TopicLinkDisplay31Opcode)reader.ReadUInt16();
while (opcode != Internal.TopicLinkDisplay31Opcode.EndOfCharacterFormatting)
{
switch (opcode)
{
}
opcode = (Internal.TopicLinkDisplay31Opcode)reader.ReadUInt16();
}
// end of character formatting. proceed with next ParagraphInfo if RecordType is 0x23, else you are done
string value = reader.ReadNullTerminatedString();
break;
}
}
@ -240,6 +297,67 @@ namespace UniversalEditor.DataFormats.Help.Compiled.WinHelp
#endregion
}
private ushort ReadCompressedUInt16(Reader reader)
{
// A compressed unsigned short is made of a single byte. Divide by two to get the value if it's even.
// Divide by two and add 128 times the value of the next byte if it's odd.
ushort retval = 0;
retval = (ushort)reader.ReadByte();
if ((retval % 2) == 0)
{
retval = (ushort)((double)retval / 2);
}
else
{
ushort retval2 = (ushort)reader.ReadByte();
retval = (ushort)(((double)retval / 2) + (128 * retval2));
}
return retval;
}
private int ReadCompressedInt32(Reader reader)
{
int retval = 0;
// A compressed signed long is made of a 2 byte value. Divide by two and subtract 16384 to get its
// value if it's even. Divide by two, add 32768 times the value of the next 2 bytes and subtract
// 67108864 if it's odd.
retval = (int)reader.ReadInt16();
if ((retval % 2) == 0)
{
retval = (int)(((double)retval / 2) - 16384);
}
else
{
int retval2 = (int)reader.ReadInt16();
retval = (int)((((double)retval / 2) + (32768 * retval2)) - 67108864);
}
return retval;
}
private static short ReadCompressedInt16(Reader reader)
{
short retval = 0;
// A compressed signed short is made of a single byte. Divide by two and subtract 64 to get the value
// if it's even. Divide by two, add 128 times the value of the next byte and subtract 16384 if it's
// odd.
retval = (short)reader.ReadByte();
if ((retval % 2) == 0)
{
// compressedShortValue is even, divide by two to get the value
retval = (short)(((double)retval / 2) - 64);
}
else
{
short retval2 = (short)reader.ReadByte();
retval = (short)((((double)retval / 2) + (128 * retval2)) - 16384);
}
return retval;
}
// A compressed unsigned long is made of a 2 byte value. Divide by two to get its value if it's even.
// Divide by two and add 32768 times the value of the next 2 bytes if it's odd.
private Internal.TOPICHEADER ReadTOPICHEADER(Reader reader)
{
Internal.TOPICHEADER item = new Internal.TOPICHEADER();

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.Help.Compiled.WinHelp.Internal
{
public enum TopicLinkDisplay31BorderStyle : byte
{
None = 0x00,
Box = 0x01,
Top = 0x02,
Left = 0x04,
Bottom = 0x08,
Right = 0x10,
Thick = 0x20,
Double = 0x40,
Unknown = 0x80
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.Help.Compiled.WinHelp.Internal
{
[Flags()]
public enum TopicLinkDisplay31Flags : ushort
{
None = 0x0000,
UnknownFollows = 0x0001,
SpacingAboveFollows = 0x0002,
SpacingBelowFollows = 0x0004,
SpacingLinesFollows = 0x0008,
LeftIndentFollows = 0x0010,
RightIndentFollows = 0x0020,
FirstLineIndentFollows = 0x0040,
Unused1 = 0x0080,
BorderInfoFollows = 0x0100,
TabInfoFollows = 0x0200,
RightAlignedParagraph = 0x0400,
CenterAlignedParagraph = 0x0800
}
}

View File

@ -0,0 +1,144 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace UniversalEditor.DataFormats.Help.Compiled.WinHelp.Internal
{
public enum TopicLinkDisplay31Opcode
{
None = 0x00,
/// <summary>
/// long vfldNumber 0 = {vfld} n = {vfld n}
/// </summary>
VFldNumber = 0x20,
/// <summary>
/// short dtypeNumber 0 = {dtype} n = {dtype n}
/// </summary>
DTypeNumber = 0x21,
/// <summary>
/// short FontNumber index into Descriptor array of internal |FONT file
/// </summary>
FontNumber = 0x80,
/// <summary>
/// No firstlineindent / spacingabove on next paragraph
/// </summary>
LineBreak = 0x81,
/// <summary>
/// Next paragraph has same Paragraphinfo as this one
/// </summary>
EndOfParagraph = 0x82,
/// <summary>
/// Jump to next tab stop
/// </summary>
Tab = 0x83,
PictureCenter = 0x86,
PictureLeft = 0x87,
PictureRight = 0x88,
HotspotEnd = 0x89,
NonBreakingSpace = 0x8B,
NonBreakingHyphen = 0x8C,
/// <summary>
/// short Length; char MacroString[Length - 3];
/// </summary>
Macro = 0xC8,
/// <summary>
/// short Length; char MacroString[Length - 3];
/// </summary>
MacroWithoutFontChange = 0xCC,
/// <summary>
/// Popup jump
/// TOPICOFFSET TopicOffset
/// </summary>
PopupJump0xE0 = 0xE0,
/// <summary>
/// Topic jump
/// TOPICOFFSET TopicOffset
/// </summary>
TopicJump0xE1 = 0xE1,
/// <summary>
/// Popup jump
/// TOPICOFFSET TopicOffset
/// </summary>
PopupJump0xE2 = 0xE2,
/// <summary>
/// Topic jump
/// TOPICOFFSET TopicOffset
/// </summary>
PopupJump0xE3 = 0xE3,
/// <summary>
/// Popup jump without font change
/// TOPICOFFSET TopicOffset
/// </summary>
PopupJumpWithoutFontChange = 0xE6,
/// <summary>
/// Topic jump without font change
/// TOPICOFFSET TopicOffset
/// </summary>
TopicJumpWithoutFontChange = 0xE7,
/// <summary>
/// Popup jump into external file
/// short SizeOfFollowingStruct
/// struct
/// {
/// unsigned char Type 0, 1, 4 or 6
/// TOPICOFFSET TopicOffset
/// unsigned char WindowNumber only if Type = 1
/// STRINGZ NameOfExternalFile only if Type = 4 or 6
/// STRINGZ WindowName only if Type = 6
/// }
/// </summary>
PopupJumpIntoExternalFile = 0xEA,
/// <summary>
/// Popup jump into external file without font change
/// short SizeOfFollowingStruct
/// struct
/// {
/// unsigned char Type 0, 1, 4 or 6
/// TOPICOFFSET TopicOffset
/// unsigned char WindowNumber only if Type = 1
/// STRINGZ NameOfExternalFile only if Type = 4 or 6
/// STRINGZ WindowName only if Type = 6
/// }
/// </summary>
PopupJumpIntoExternalFileWithoutFontChange = 0xEB,
/// <summary>
/// Topic jump into external file / secondary window
/// short SizeOfFollowingStruct
/// struct
/// {
/// unsigned char Type 0, 1, 4 or 6
/// TOPICOFFSET TopicOffset
/// unsigned char WindowNumber only if Type = 1
/// STRINGZ NameOfExternalFile only if Type = 4 or 6
/// STRINGZ WindowName only if Type = 6
/// }
/// </summary>
TopicJumpIntoExternalFileSecondaryWindow = 0xEE,
/// <summary>
/// Topic jump into external file / secondary window without font change
/// short SizeOfFollowingStruct
/// struct
/// {
/// unsigned char Type 0, 1, 4 or 6
/// TOPICOFFSET TopicOffset
/// unsigned char WindowNumber only if Type = 1
/// STRINGZ NameOfExternalFile only if Type = 4 or 6
/// STRINGZ WindowName only if Type = 6
/// }
/// </summary>
TopicJumpIntoExternalFileSecondaryWindowWithoutFontChange = 0xEF,
/// <summary>
/// End of character formatting. Proceed with next Paragraphinfo if RecordType is 0x23, else you are done.
/// </summary>
EndOfCharacterFormatting = 0xFF
}
}

View File

@ -72,6 +72,9 @@
<Compile Include="DataFormats\Help\Compiled\WinHelp\Internal\TOPICBLOCKHEADER.cs" />
<Compile Include="DataFormats\Help\Compiled\WinHelp\Internal\TOPICHEADER.cs" />
<Compile Include="DataFormats\Help\Compiled\WinHelp\Internal\TOPICLINK.cs" />
<Compile Include="DataFormats\Help\Compiled\WinHelp\Internal\TopicLinkDisplay31BorderStyle.cs" />
<Compile Include="DataFormats\Help\Compiled\WinHelp\Internal\TopicLinkDisplay31Flags.cs" />
<Compile Include="DataFormats\Help\Compiled\WinHelp\Internal\TopicLinkDisplay31Opcode.cs" />
<Compile Include="DataFormats\Help\Compiled\WinHelp\Internal\TopicLinkRecordType.cs" />
<Compile Include="DataFormats\Help\TableOfContents\V3\H1TDataFormat.cs" />
<Compile Include="DataFormats\Shortcut\Microsoft\LNKDataFlags.cs" />