diff options
-rw-r--r-- | components/richtext/CanvasFontManager.pas | 2 | ||||
-rw-r--r-- | src/HelpFile.pas | 27 | ||||
-rw-r--r-- | src/HelpTopic.pas | 82 | ||||
-rw-r--r-- | src/HelpWindow.pas | 8 | ||||
-rw-r--r-- | src/IPFFileFormatUnit.pas | 2 | ||||
-rw-r--r-- | src/SearchTable.pas | 60 | ||||
-rw-r--r-- | src/SearchUnit.pas | 24 | ||||
-rw-r--r-- | src/docview.lpi | 7 | ||||
-rw-r--r-- | src/docview.lpr | 10 |
9 files changed, 115 insertions, 107 deletions
diff --git a/components/richtext/CanvasFontManager.pas b/components/richtext/CanvasFontManager.pas index 4e5a84a1..819141fb 100644 --- a/components/richtext/CanvasFontManager.pas +++ b/components/richtext/CanvasFontManager.pas @@ -753,7 +753,7 @@ end; procedure TCanvasFontManager.RegisterFont( Font: TLogicalFont ); var // fa: FATTRS; - rc: LONG; + rc: longint; begin FLogicalFonts.Add( Font ); Font.ID := FLogicalFonts.Count + 1; // add 1 to stay out of Sibyl's way diff --git a/src/HelpFile.pas b/src/HelpFile.pas index 0c6ce12d..bb118596 100644 --- a/src/HelpFile.pas +++ b/src/HelpFile.pas @@ -11,8 +11,9 @@ Interface // Encapsulates the basic reading of a help file's structure. uses - Classes, SysUtils, DataTypes, - HelpFileHeader, HelpTopic, + Classes, SysUtils, + IPFFileFormatUnit, + HelpTopic, // HelpBitmap, TextSearchQuery, SearchTable, CompareWordUnit, // this unit is used to fake image support untill fpGUI has this implemented. @@ -28,14 +29,14 @@ type protected _Data: pointer; _DataLen: longint; - _pSlotData: pInt16; + _pSlotData: pUInt16; _SlotDataSize: longint; _FileName: string; _Title: string; _Header: THelpFileHeader; _Topics: TList; // of TTopic _Dictionary: TStringList; - _SlotOffsets: Int32ArrayPointer; + _SlotOffsets: UInt32ArrayPointer; _Index: TStringList; _SearchTable: TSearchTable; @@ -57,7 +58,7 @@ type function GetDictionaryWord( Index: longint ): string; public - HighlightWords: Int32ArrayPointer; + HighlightWords: UInt32ArrayPointer; constructor Create( const FileName: string; UpdateProgress: TProgressCallback ); @@ -223,7 +224,7 @@ var Topic: TTopic; EntryIndex: longint; pEntry: pTTOCEntryStart; - tocarray: ^Int32; + tocarray: ^UInt32; p: PByte; begin _Topics.Capacity := _Header.ntoc; @@ -265,10 +266,10 @@ end; type TIndexEntryHeader = packed record - TextLength: int8; - Flags: int8; - NumberOfRoots: int8; - TOCIndex: int16; + TextLength: uint8; + Flags: uint8; + NumberOfRoots: uint8; + TOCIndex: uint16; end; @@ -307,9 +308,9 @@ end; type HelpFontSpec = class FaceName: array[ 0..32 ] of char; - Height: int16; - Width: int16; - Codepage: int16; + Height: uint16; + Width: uint16; + Codepage: uint16; end; procedure THelpFile.ReadFontTable; diff --git a/src/HelpTopic.pas b/src/HelpTopic.pas index 11abf980..9872059f 100644 --- a/src/HelpTopic.pas +++ b/src/HelpTopic.pas @@ -15,7 +15,7 @@ Interface // RichTextView. uses - Classes, DataTypes, HelpWindow, HelpFileHeader; + Classes, HelpWindow, IPFFileFormatUnit; Type THelpLink = class(TObject) @@ -35,10 +35,10 @@ Type // anywhere in INF file. This structure is used for quick text retrieval when // user clicks on TOC treeview in UI THelpTopicSlot = record - pData: pInt8; // Pointer to actual Slot structure in INF file. + pData: pUInt8; // Pointer to actual Slot structure in INF file. Size: longint; // Number of bytes in the text for this Slot (slotheader.ntext) - pLocalDictionary: Int16ArrayPointer; // Pointer to Slot's local dictionary - LocalDictSize: int8; // Number of entries in the local dictionary + pLocalDictionary: UInt16ArrayPointer; // Pointer to Slot's local dictionary + LocalDictSize: uint8; // Number of entries in the local dictionary end; pHelpTopicSlot = ^ THelpTopicSlot; @@ -72,7 +72,7 @@ Type Var DebugString: string; Var ImageOffsets: TList; Var LinkIndex: longint ); - procedure TranslateIPFEscapeCode( Var pData: pInt8; + procedure TranslateIPFEscapeCode( Var pData: pUInt8; Var OutputString: string; Var DebugString: string; Var Spacing: boolean; @@ -104,7 +104,7 @@ Type // AText: The output is written to here. // ImageOffsets: For each image that occurs in the text, // the help file offset will be written to this list. - procedure GetText( HighLightWords: Int32ArrayPointer; + procedure GetText( HighLightWords: UInt32ArrayPointer; ShowCodes: boolean; var AText: string; ImageOffsets: TList ); @@ -167,12 +167,12 @@ var pExtendedInfo: pExtendedTOCEntry; titleLen: integer; i: longint; - SlotNumber: int16; + SlotNumber: uint16; XY: THelpXYPair; p: pbyte; lFlags: byte; - pSlotOffsets: Int32ArrayPointer; + pSlotOffsets: UInt32ArrayPointer; pSlotData: pSlotHeader; Slot: THelpTopicSlot; begin @@ -187,7 +187,7 @@ begin lFlags:= _pTOCEntry^.flags; - p:= pInt8( _pTOCEntry ) + sizeof( TTOCEntryStart ); + p:= pUInt8( _pTOCEntry ) + sizeof( TTOCEntryStart ); if ( lFlags and TOCEntryExtended ) > 0 then begin @@ -209,7 +209,7 @@ begin if ( pExtendedInfo^.w2 and 4 ) > 0 then begin - _ContentsGroupIndex := pint16(p)^; + _ContentsGroupIndex := puint16(p)^; // read group inc(p, sizeof(word)); end; @@ -220,14 +220,14 @@ begin // Read slot indices for i := 0 to _NumSlots-1 do begin - SlotNumber:= pint16( p )^; + SlotNumber:= puint16( p )^; if SlotNumber < FileHeader.nslots then // ??? graeme: I don't see the point of this check begin // point to correct slot offset pSlotData := pSlotHeader( FileData + pSlotOffsets^[ SlotNumber ] ); if pSlotData^.stuff <> Byte(0) then raise Exception.Create('We are NOT at the correct location in the file for the SlotHeader structure!'); - Slot.pData := pInt8(pSlotData) + sizeof(TSlotHeader); + Slot.pData := puInt8(pSlotData) + sizeof(TSlotHeader); Slot.pLocalDictionary := FileData + pSlotData^.localDictPos; Slot.LocalDictSize := pSlotData^.nLocalDict; Slot.Size := pSlotData^.ntext; @@ -349,13 +349,13 @@ Procedure TTopic.ProcessLinkedImage( Var pData: pByte; Var ImageOffsets: TList; Var LinkIndex: longint ); var - EscapeLen: int8; - EscapeCode: int8; - SubEscapeCode: int8; + EscapeLen: uint8; + EscapeCode: uint8; + SubEscapeCode: uint8; BitmapOffset: longword; - BitmapFlags: int8; + BitmapFlags: uint8; Link: THelpLink; - LinkTopicIndex: int16; + LinkTopicIndex: uint16; begin LinkTopicIndex := -1; while true do @@ -366,12 +366,12 @@ begin HPART_DEFINE: begin BitmapFlags := ( pData + 3 )^; - BitmapOffset:= pint32( pData + 4 )^; + BitmapOffset:= puint32( pData + 4 )^; end; HPART_HDREF: // define whole bitmap topic link? begin - LinkTopicIndex := pInt16( pData + 3 )^; + LinkTopicIndex := puInt16( pData + 3 )^; end else begin @@ -418,7 +418,7 @@ begin end; -procedure TTopic.TranslateIPFEscapeCode( Var pData: pInt8; +procedure TTopic.TranslateIPFEscapeCode( Var pData: pUInt8; Var OutputString: string; Var DebugString: string; Var Spacing: boolean; @@ -427,22 +427,22 @@ procedure TTopic.TranslateIPFEscapeCode( Var pData: pInt8; Var ImageOffsets: TList; Var LinkIndex: longint ); var - EscapeLen: int8; - EscapeCode: int8; + EscapeLen: uint8; + EscapeCode: uint8; Link: THelpLink; - LinkFlags1: int8; - LinkFlags2: int8; + LinkFlags1: uint8; + LinkFlags2: uint8; LinkDataIndex: longint; pLinkXY: pHelpXYPair; - Margin: int8; + Margin: uint8; EscCodeDataIndex: longint; - pLinkData: pInt8; + pLinkData: puInt8; BitmapOffset: longword; - BitmapFlags: int8; + BitmapFlags: uint8; begin EscapeLen:= pData^; @@ -479,7 +479,7 @@ begin begin Link:= THelpLink.Create; Link.HelpFile := HelpFile; - Link.TopicIndex:= pInt16( pData + 2 )^; + Link.TopicIndex:= puInt16( pData + 2 )^; if EscapeLen >= 6 then begin LinkFlags1:= ( pData + 4 ) ^; @@ -508,8 +508,8 @@ begin if ( LinkFlags2 and 4 ) > 0 then begin // group specified - Link.GroupIndex:= pint16( pLinkData )^; - inc( LinkDataIndex, sizeof( int16 ) ); + Link.GroupIndex:= puint16( pLinkData )^; + inc( LinkDataIndex, sizeof( uint16 ) ); end; if ( LinkFlags1 and 64 ) > 0 then @@ -559,7 +559,7 @@ begin begin Link:= THelpLink.Create; Link.HelpFile := HelpFile; - Link.TopicIndex:= pInt16( pData + 2 )^; + Link.TopicIndex:= puInt16( pData + 2 )^; Link.GroupIndex := -2; SetFootnoteRect( Link.Rect ); Links.Add( Link ); @@ -609,7 +609,7 @@ begin $0e: // bitmap begin BitmapFlags := ( pData + 2 )^; - BitmapOffset:= pint32( pData + 3 )^; + BitmapOffset:= puint32( pData + 3 )^; OutputString := GetImageText( BitmapOffset, BitmapFlags, @@ -661,21 +661,21 @@ end; // Main translation function. Turns the IPF data into // a text string. Translates formatting codes into tags // as for Rich Text Viewer. -procedure TTopic.GetText(HighLightWords: Int32ArrayPointer; ShowCodes: boolean; +procedure TTopic.GetText(HighLightWords: UInt32ArrayPointer; ShowCodes: boolean; var AText: string; ImageOffsets: TList); var SlotIndex: integer; Slot: THelpTopicSlot; - pData: pInt8; - pSlotEnd: pInt8; + pData: puInt8; + pSlotEnd: puInt8; S: string; Word: string; - GlobalDictIndex: int32; + GlobalDictIndex: uint32; Spacing: boolean; InFixedFont: boolean; WordsOnLine: longint; StringToAdd: string; - LocalDictIndex: int8; + LocalDictIndex: uint8; DebugString: string; EscapeDebugString: string; LinkIndex: longint; @@ -810,14 +810,14 @@ function TTopic.SearchForWord( DictIndex: integer; var SlotIndex: integer; Slot: THelpTopicSlot; - pData: pInt8; - pSlotEnd: pInt8; + pData: puInt8; + pSlotEnd: puInt8; EscapeLen: longint; - GlobalDictIndex: int32; + GlobalDictIndex: uint32; - LocalDictIndex: int8; + LocalDictIndex: uint8; begin Result := 0; for SlotIndex := 0 to _NumSlots - 1 do diff --git a/src/HelpWindow.pas b/src/HelpWindow.pas index 8f39dbf9..5d6fea59 100644 --- a/src/HelpWindow.pas +++ b/src/HelpWindow.pas @@ -12,7 +12,7 @@ Interface // and functions relevant to helpwindow dimensions. uses - DataTypes, HelpFileHeader; + IPFFileFormatUnit; const ptCharacters = 0; @@ -52,7 +52,7 @@ begin Height:= -1; end; -function GetPos( const PositionType: int8; +function GetPos( const PositionType: uint8; const Value: longint ): longint; begin case PositionType of @@ -78,8 +78,8 @@ end; procedure ReadHelpPosition( const XY: THelpXYPair; Var Rect: THelpWindowRect ); var - XPositionType: int8; - YPositionType: int8; + XPositionType: uint8; + YPositionType: uint8; begin // read origin XPositionType:= XY.Flags div 16; diff --git a/src/IPFFileFormatUnit.pas b/src/IPFFileFormatUnit.pas index ca88d64b..ac1771f7 100644 --- a/src/IPFFileFormatUnit.pas +++ b/src/IPFFileFormatUnit.pas @@ -40,6 +40,8 @@ type EWindowsHelpFormatException = class( Exception ) end; + TProgressCallback = procedure(n, outof: integer; AMessage: string) of object; + var ErrorCorruptHelpFile: string; diff --git a/src/SearchTable.pas b/src/SearchTable.pas index 3b433dac..1f0c2048 100644 --- a/src/SearchTable.pas +++ b/src/SearchTable.pas @@ -9,7 +9,7 @@ Unit SearchTable; Interface uses - Classes, DataTypes; + Classes, IPFFileFormatUnit; // Code to read and use IPF search tables // NB The RLE decompression was arrived at by trial and error @@ -28,11 +28,11 @@ type Procedure Check1ByteOfFlags( b: byte; StartingIndex: longint; - Results: Int32ArrayPointer ); + Results: UInt32ArrayPointer ); procedure DoRLESearch( p: pbyte; pDataEnd: pointer; - Results: Int32ArrayPointer ); + Results: UInt32ArrayPointer ); public constructor Create( Data: pointer; @@ -41,8 +41,8 @@ type TopicCount: longint ); destructor Destroy; override; - procedure Search( DictIndex: int16; - Results: Int32ArrayPointer ); + procedure Search( DictIndex: uint16; + Results: UInt32ArrayPointer ); end; @@ -70,8 +70,8 @@ end; procedure TSearchTable.ReadEntries; var pWordRecord: pointer; - RecordLen: int16; - WordIndex: int16; + RecordLen: uint16; + WordIndex: uint16; begin pWordRecord:= _Data; @@ -80,9 +80,9 @@ begin _Entries.Add( pWordRecord ); if _RecordLengthIs16Bit then - RecordLen:= pint16( pWordRecord )^ + RecordLen:= puint16( pWordRecord )^ else // 8 bit - RecordLen:= pint8( pWordRecord )^; + RecordLen:= puint8( pWordRecord )^; inc( pWordRecord, RecordLen ); end; end; @@ -95,7 +95,7 @@ end; // that are set. Procedure TSearchTable.Check1ByteOfFlags( b: byte; StartingIndex: longint; - Results: Int32ArrayPointer ); + Results: UInt32ArrayPointer ); var TopicIndex: longint; begin @@ -113,7 +113,7 @@ end; // running til pDataEnd. Update topic entries in Results. procedure TSearchTable.DoRLESearch( p: pbyte; pDataEnd: pointer; - Results: Int32ArrayPointer ); + Results: UInt32ArrayPointer ); var TopicIndex: integer; @@ -140,7 +140,7 @@ begin if thebyte = 0 then begin // 16 bit repeat of zeroes?? - N := pint16( p )^ + 1; + N := puint16( p )^ + 1; inc( p, 2 ); inc( TopicIndex, N ); end @@ -204,32 +204,32 @@ end; // This function finds uses of the given word (DictIndex) // using the search table. Results[ topic ] is set to // non-zero for topics which contain the word. -procedure TSearchTable.Search( DictIndex: int16; - Results: Int32ArrayPointer ); +procedure TSearchTable.Search( DictIndex: uint16; + Results: UInt32ArrayPointer ); var TopicIndex: integer; pWordRecord: pointer; - RecordLen: int16; - CompressionCode: int8; + RecordLen: uint16; + CompressionCode: uint8; pData: pointer; pDataEnd: pointer; - Flags: int8; + Flags: uint8; begin - FillInt32Array( Results, _TopicCount, 0 ); + FillUInt32Array( Results, _TopicCount, 0 ); pWordRecord:= _Entries[ DictIndex ]; // Check search table format if _RecordLengthIs16Bit then begin - RecordLen:= pint16( pWordRecord )^; - CompressionCode:= pint8( pWordRecord + 2 )^; + RecordLen:= puint16( pWordRecord )^; + CompressionCode:= puint8( pWordRecord + 2 )^; pData:= pWordRecord + 3; end else // 8 bit begin - RecordLen:= pint8( pWordRecord )^; - CompressionCode:= pint8( pWordRecord + 1 )^; + RecordLen:= puint8( pWordRecord )^; + CompressionCode:= puint8( pWordRecord + 1 )^; pData:= pWordRecord + 2; end; @@ -240,7 +240,7 @@ begin ; 1: // used in all panels - FillInt32Array( Results, _TopicCount, 1 ); + FillUInt32Array( Results, _TopicCount, 1 ); 2: // RLE begin @@ -252,18 +252,18 @@ begin 3: // list of topics containing word while pData < pDataEnd do begin - TopicIndex:= pint16( pData )^; + TopicIndex:= puint16( pData )^; Results^[ TopicIndex ] := 1; inc( pData, 2 ); end; 4: // list of topics NOT containing word begin - FillInt32Array( Results, _TopicCount, 1 ); + FillUInt32Array( Results, _TopicCount, 1 ); while pData < pDataEnd do begin - TopicIndex:= pint16( pData )^; + TopicIndex:= puint16( pData )^; Results^[ TopicIndex ] := 0; inc( pData, 2 ); end; @@ -276,13 +276,13 @@ begin TopicIndex:= 0 else begin - TopicIndex:= pInt16( pData )^ * 8; + TopicIndex:= puInt16( pData )^ * 8; inc( pData, 2 ); end; while pData < pDataEnd do begin - Flags:= pInt8( pData )^; + Flags:= puInt8( pData )^; Check1ByteOfFlags( Flags, TopicIndex, Results ); @@ -293,5 +293,5 @@ begin end; end; -Initialization -End. + +end. diff --git a/src/SearchUnit.pas b/src/SearchUnit.pas index 56600e3d..f48d35cd 100644 --- a/src/SearchUnit.pas +++ b/src/SearchUnit.pas @@ -12,7 +12,7 @@ Interface uses Classes, - HelpFile, TextSearchQuery, DataTypes; + HelpFile, TextSearchQuery, IPFFileFormatUnit; const // match weightings @@ -33,7 +33,7 @@ type procedure SearchHelpFile( HelpFile: THelpFile; Query: TTextSearchQuery; Results: TList; - HighlightWords: Int32ArrayPointer ); + HighlightWords: UInt32ArrayPointer ); Implementation @@ -50,14 +50,14 @@ uses // at the same position procedure SearchDictionary( HelpFile: THelpFile; SearchWord: string; - Results: Int32ArrayPointer ); + Results: UInt32ArrayPointer ); var DictIndex: integer; DictWord: string; WordRelevance: longint; begin SearchWord:= UpperCase( SearchWord ); - FillInt32Array( Results, HelpFile.DictionaryCount, 0 ); + FillUInt32Array( Results, HelpFile.DictionaryCount, 0 ); for DictIndex:= 0 to HelpFile.DictionaryCount - 1 do begin @@ -70,7 +70,7 @@ end; // Search titles of topics for given searchword procedure SearchTopicTitles( HelpFile: THelpFile; SearchWord: string; - Results: Int32ArrayPointer ); + Results: UInt32ArrayPointer ); var TopicIndex: longint; Title: string; @@ -107,7 +107,7 @@ end; // Search index entries for given searchword procedure SearchIndex( HelpFile: THelpFile; SearchWord: string; - Results: Int32ArrayPointer ); + Results: UInt32ArrayPointer ); var IndexIndex: longint; IndexEntry: string; @@ -170,18 +170,18 @@ end;} procedure SearchHelpFile( HelpFile: THelpFile; Query: TTextSearchQuery; Results: TList; - HighlightWords: Int32ArrayPointer ); + HighlightWords: UInt32ArrayPointer ); var Topic: TTopic; TopicIndex: longint; TermIndex: longint; Term: TSearchTerm; - TopicMatches: Int32ArrayPointer; - TopicRelevancesForTerm: Int32ArrayPointer; + TopicMatches: UInt32ArrayPointer; + TopicRelevancesForTerm: UInt32ArrayPointer; TopicMatchedTerm: boolean; WordRelevance: longint; - DictionaryRelevances: Int32ArrayPointer; + DictionaryRelevances: UInt32ArrayPointer; DictIndex: longint; TopicRelevanceForTerm: longint; TopicWordCount: longint; @@ -197,7 +197,7 @@ begin if HighlightWords <> nil then // Clear the highlightwords array - FillInt32Array( HighlightWords, HelpFile.DictionaryCount, 0 ); + FillUInt32Array( HighlightWords, HelpFile.DictionaryCount, 0 ); // Get memory for dictionary/topic relevance arrays GetMem( DictionaryRelevances, HelpFile.DictionaryCount * sizeof( longint ) ); @@ -208,7 +208,7 @@ begin begin Term := Query.Term[ TermIndex ]; - FillInt32Array( TopicRelevancesForTerm, HelpFile.TopicCount, 0 ); + FillUInt32Array( TopicRelevancesForTerm, HelpFile.TopicCount, 0 ); // Search the dictionary for matches. SearchDictionary( HelpFile, Term.Text, DictionaryRelevances ); diff --git a/src/docview.lpi b/src/docview.lpi index dda50276..c2f330e7 100644 --- a/src/docview.lpi +++ b/src/docview.lpi @@ -32,7 +32,7 @@ <PackageName Value="fpgui_toolkit"/> </Item1> </RequiredPackages> - <Units Count="22"> + <Units Count="23"> <Unit0> <Filename Value="docview.lpr"/> <IsPartOfProject Value="True"/> @@ -142,6 +142,11 @@ <IsPartOfProject Value="True"/> <UnitName Value="IPFFileFormatUnit"/> </Unit21> + <Unit22> + <Filename Value="HelpWindowDimensions.pas"/> + <IsPartOfProject Value="True"/> + <UnitName Value="HelpWindowDimensions"/> + </Unit22> </Units> </ProjectOptions> <CompilerOptions> diff --git a/src/docview.lpr b/src/docview.lpr index 17349061..bceaa006 100644 --- a/src/docview.lpr +++ b/src/docview.lpr @@ -8,11 +8,11 @@ uses {$ENDIF}{$ENDIF} Classes, {$IFDEF Timing}EpikTimer,{$ENDIF} - fpg_main, frm_main, HelpWindow, IPFEscapeCodes, - HelpTopic, CompareWordUnit, SearchTable, TextSearchQuery, nvUtilities, - nvNullObjects, HelpFile, SearchUnit, fpg_cmdlineparams, customstyle, IPFFileFormatUnit, - RichTextStyleUnit, CanvasFontManager, ACLStringUtility, RichTextDocumentUnit, - RichTextView, RichTextLayoutUnit, RichTextDisplayUnit; + fpg_main, frm_main, HelpWindow, IPFEscapeCodes, HelpTopic, CompareWordUnit, SearchTable, + TextSearchQuery, nvUtilities, nvNullObjects, HelpFile, SearchUnit, fpg_cmdlineparams, + customstyle, IPFFileFormatUnit, HelpWindowDimensions, RichTextStyleUnit, + CanvasFontManager, ACLStringUtility, RichTextDocumentUnit, RichTextView, + RichTextLayoutUnit, RichTextDisplayUnit; procedure MainProc; |