diff options
author | Graeme Geldenhuys <graemeg@gmail.com> | 2015-09-02 23:25:41 +0100 |
---|---|---|
committer | Graeme Geldenhuys <graemeg@gmail.com> | 2015-09-02 23:25:41 +0100 |
commit | b0a9f3d90d7a8127ba41ab77a7054d797e816c83 (patch) | |
tree | b11cdae78c316a7b728522e9a4bfb43880fad8f5 /docview | |
parent | db31f06d5e7adf28fad60e36fd9e5d2cf0519e84 (diff) | |
parent | f52bde1cd49d0d01002e8b684909268b723a3edb (diff) | |
download | fpGUI-master.tar.xz |
Diffstat (limited to 'docview')
-rw-r--r-- | docview/TODO.txt | 8 | ||||
-rw-r--r-- | docview/components/richtext/CanvasFontManager.pas | 10 | ||||
-rw-r--r-- | docview/components/richtext/RichTextDisplayUnit.pas | 9 | ||||
-rw-r--r-- | docview/components/richtext/RichTextLayoutUnit.pas | 9 | ||||
-rw-r--r-- | docview/components/richtext/RichTextView.pas | 4 | ||||
-rw-r--r-- | docview/src/HelpBitmap.pas | 64 | ||||
-rw-r--r-- | docview/src/HelpTopic.pas | 3 | ||||
-rw-r--r-- | docview/src/IPFFileFormatUnit.pas | 4 | ||||
-rw-r--r-- | docview/src/docview.rc | 8 | ||||
-rw-r--r-- | docview/src/docview_clean.prj | 381 | ||||
-rw-r--r-- | docview/src/frm_main.pas | 3 | ||||
-rw-r--r-- | docview/src/lzwdecompress.pas | 55 |
12 files changed, 480 insertions, 78 deletions
diff --git a/docview/TODO.txt b/docview/TODO.txt index d0cccc7c..2307e115 100644 --- a/docview/TODO.txt +++ b/docview/TODO.txt @@ -13,11 +13,11 @@ Todo list [o] - Implement a ipfdump program. Already started work on this and is called docdump in the src directory. [ ] - Implement a IPF Compiler in Object Pascal -[ ] - Text is not selectable in RichTextView. I imagine people want to +[o] - Text is not selectable in RichTextView. I imagine people want to copy & paste examples. Although "Save current Topic" already exists. [ ] - Communication between application and docview. Both directions. Possible solutions is Pipes or IPC unit. -[ ] - Implement popup window for "notes" hyperlinks. eg: The hyper link text +[o] - Implement popup window for "notes" hyperlinks. eg: The hyper link text might be 'IBM', the "notes" link should then show a popup window (almost like a tooltip window) showing 'International Business Machines'. [ ] - RichTextView component issue. Incompatible with original OS/2 VIEW. When @@ -57,8 +57,8 @@ Todo list fpdoc IPF todo list =================== -[ ] - Class declaration in overview page is missing. Like HTML output. -[ ] - Class inheritance tree must be shown in overview page. Like HTML output. +[x] - Class declaration in overview page is missing. Like HTML output. +[x] - Class inheritance tree must be shown in overview page. Like HTML output. [ ] - [ ] - [ ] - diff --git a/docview/components/richtext/CanvasFontManager.pas b/docview/components/richtext/CanvasFontManager.pas index e650141b..fe9606e6 100644 --- a/docview/components/richtext/CanvasFontManager.pas +++ b/docview/components/richtext/CanvasFontManager.pas @@ -44,6 +44,7 @@ type constructor Create(ACanvas: TfpgCanvas; AWidget: TfpgWidget); reintroduce; destructor Destroy; override; function AverageCharWidth: longint; + function CharAscender: longint; function CharDescender: longint; function CharHeight: longint; function CharWidth( const C: TfpgChar ): longint; // Retrieve the width of the given char, in the current font @@ -179,8 +180,8 @@ begin AFontDesc := AFontDesc + ':Strikeout'; if faUnderScore in Attrs Then - if Pos(':Underscore', AFontDesc) = 0 then - AFontDesc := AFontDesc + ':Underscore'; + if Pos(':Underline', AFontDesc) = 0 then + AFontDesc := AFontDesc + ':Underline'; end; // Provide font name substitutes for some common bitmap fonts found in INF files @@ -314,6 +315,11 @@ begin Result := FCanvas.Font.TextWidth('c'); end; +function TCanvasFontManager.CharAscender: longint; +begin + Result := FCanvas.Font.Ascent; +end; + function TCanvasFontManager.MaximumCharWidth: longint; begin Result := FCanvas.Font.TextWidth('W'); diff --git a/docview/components/richtext/RichTextDisplayUnit.pas b/docview/components/richtext/RichTextDisplayUnit.pas index 482a587b..cfdd20a7 100644 --- a/docview/components/richtext/RichTextDisplayUnit.pas +++ b/docview/components/richtext/RichTextDisplayUnit.pas @@ -122,6 +122,7 @@ Procedure DrawRichTextLine( var FontManager: TCanvasFontManager; Line: TLayoutLine; Start: TPoint ); var X, Y: longint; + YBaseLine: longint; Element: TTextElement; StartedDrawing: boolean; Style: TTextDrawStyle; @@ -180,7 +181,7 @@ ProfileEvent('DEBUG: DrawRichTextLine >>>'); TextBlockStart := P; - Y := Start.Y; // + Line.MaxDescender; // co-ordinates are from top/left, so do we need descender? [Graeme] + YBaseLine := Start.Y + Line.MaxAscender; while P < EndP do begin @@ -209,6 +210,7 @@ ProfileEvent('DEBUG: DrawRichTextLine >>>'); StartedDrawing := true; end; + Y := YBaseLine - FontManager.CharAscender; // Now do the drawing if Element.ElementType = teImage then begin @@ -263,9 +265,10 @@ ProfileEvent('DEBUG: DrawRichTextLine >>>'); and ( faItalic in Style.FontAttributes ) and ( not FontManager.IsFixed ) then + begin // end of italic; add a space - inc( X, FontManager.CharWidth( ' ' ) ); - +// inc( X, FontManager.CharWidth( ' ' ) ); + end; Layout.PerformStyleTag( Element.Tag, Style, X ); NewMarginX := ( Start.X + Style.LeftMargin ); if NewMarginX > X then diff --git a/docview/components/richtext/RichTextLayoutUnit.pas b/docview/components/richtext/RichTextLayoutUnit.pas index 606b7805..8e39d65f 100644 --- a/docview/components/richtext/RichTextLayoutUnit.pas +++ b/docview/components/richtext/RichTextLayoutUnit.pas @@ -23,6 +23,7 @@ Type Length: longint; Height: longint; Width: longint; + MaxAscender: longint; MaxDescender: longint; MaxTextHeight: longint; // maximum height of text, doesn't include images LinkIndex: longint; // link index at start of line, if any @@ -136,7 +137,7 @@ uses function TLayoutLineList.GetItem(Index: Integer): TLayoutLine; begin - inherited GetItem(Index); + result := TLayoutLine( inherited GetItem(Index)); end; procedure TLayoutLineList.SetItem(Index: Integer; const AValue: TLayoutLine); @@ -240,8 +241,10 @@ Procedure TRichTextLayout.CheckFontHeights( Var Line: TLayoutLine ); var FontHeight: longint; Descender: longint; + Ascender: longint; begin FontHeight := FFontManager.CharHeight; + Ascender := FFontManager.CharAscender; Descender := FFontManager.CharDescender; if FontHeight > Line.Height then @@ -252,6 +255,9 @@ begin if Descender > Line.MaxDescender then Line.MaxDescender := Descender; + + if Ascender > Line.MaxAscender then + Line.MaxAscender := Ascender; end; function TRichTextLayout.IsValidBitmapIndex( Index: longint ): boolean; @@ -297,6 +303,7 @@ Var CurrentLine := TLayoutLine.Create; CurrentLine.Style := Style; CurrentLine.Height := 0; + CurrentLine.MaxAscender := 0; CurrentLine.MaxDescender := 0; CurrentLine.MaxTextHeight := 0; CurrentLine.Width := 0; diff --git a/docview/components/richtext/RichTextView.pas b/docview/components/richtext/RichTextView.pas index e890ca54..bc967d59 100644 --- a/docview/components/richtext/RichTextView.pas +++ b/docview/components/richtext/RichTextView.pas @@ -2414,9 +2414,13 @@ begin // BufferLength ); end; +// TODO: This doesn't seem to be used anywhere, so we could probably delete it. function TRichTextView.CopyTextToBuffer( Buffer: PChar; BufferLength: longint ): longint; begin + Result := -1; + // TODO: we do this to trap code using this, so we can fix it accordingly. + raise Exception.Create('TRichTextView.CopyTextToBuffer was called, but it is not implemented yet.'); //Result := CopyPlainTextToBuffer( FText, // FText + strlen( FText ), // Buffer, diff --git a/docview/src/HelpBitmap.pas b/docview/src/HelpBitmap.pas index 45855a1f..b5464cbf 100644 --- a/docview/src/HelpBitmap.pas +++ b/docview/src/HelpBitmap.pas @@ -1,7 +1,7 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this + Copyright (C) 2006 - 2015 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -73,7 +73,7 @@ type end; - THelpBitmap = class( TfpgImage ) + THelpBitmap = class(TfpgImage) protected _Header: INFBITMAPHEADER; _PaletteColorCount: longint; @@ -81,12 +81,12 @@ type _BitsSize: longint; FileHandle: TFileStream; _UncompressedBlockSize: longint; - function GetPaletteSize: longint; - procedure BitmapError(Msg: string); - procedure ReadBitmapData( Blocks: TList; TotalSize: longword); + function GetPaletteSize: longint; + procedure BitmapError(Msg: string); + procedure ReadBitmapData( Blocks: TList; TotalSize: longword); public - constructor CreateFromHelpFile(var AFileHandle: TFileStream; Offset: longint); - destructor Destroy; override; + constructor CreateFromHelpFile(var AFileHandle: TFileStream; Offset: longword); + destructor Destroy; override; end; @@ -128,7 +128,7 @@ begin inherited Destroy; end; -constructor THelpBitmap.CreateFromHelpFile(var AFileHandle: TFileStream; Offset: longint); +constructor THelpBitmap.CreateFromHelpFile(var AFileHandle: TFileStream; Offset: longword); var WordsPerLine: longint; LineSize: longint; @@ -282,10 +282,14 @@ var ptr: PByte; i: integer; img: TfpgImage; + {$IFDEF LZW_DEBUG} + s: TFileStream; + {$ENDIF} begin BitmapOutputPointer := nil; BitmapData := nil; ptr := nil; + lastOutByte := $0; // Allocate memory to store the bitmap BitmapData := GetMem( TotalSize ); @@ -309,6 +313,9 @@ begin case Block._CompressionType of 0,1: // uncompressed (I'm not sure about 1) begin + {$IFDEF LZW_DEBUG} + writeln('Uncompressed image type'); + {$ENDIF} MemCopy( Block._Data^, BitmapOutputPointer^, Block._Size ); BytesWrittenFromBlock := Block._Size; inc( BytesWritten, BytesWrittenFromBlock ); @@ -316,6 +323,9 @@ begin 2: // LZW compression begin + {$IFDEF LZW_DEBUG} + writeln('LZW compressed image type'); + {$ENDIF} LZWDecompressBlock( Block._Data, Block._Size, BitmapOutputPointer, @@ -353,35 +363,25 @@ begin > BitmapData + TotalSize ) then assert( false ); -{ NOTE: This doesn't seem right. It moves the pointer so later the moving of data to - ImageData will be wrong! } -// inc( BitmapOutputPointer, BytesWrittenFromBlock ); TPersistentObjectState + inc( BitmapOutputPointer, BytesWrittenFromBlock ); end; - i := TotalSize + SizeOf(_Header) + GetPaletteSize; - img := CreateImage_BMP(BitmapData, i); - - AllocateImage(32, _Header.cx, _Header.cy); - {$IFDEF LZW_DEBUG} - writeln('Width = ', Width); - writeln('Height = ', Height); - writeln('ImageDataSize = ', ImageDataSize); - writeln('------------- START -------------'); - for i := 1 to ImageDataSize do - begin - write(HexStr(BitmapOutputPointer[i-1],2)+' '); - if (i mod 16 = 0) then - writeln('') - else if (i mod 4 = 0) then - write (' | '); - end; - Writeln(''); - writeln('------------- END -------------'); + // write the decompressed image to a .BMP file to verify it is okay + s := TFileStream.Create(Format('/tmp/image_%d.bmp', [TotalSize]), fmCreate); + BitmapData[0] := Byte('B'); + s.WriteBuffer(BitmapData^, TotalSize); + s.Destroy; + BitmapData[0] := Byte('b'); {$ENDIF} -// Move(BitmapOutputPointer^, ImageData^, ImageDataSize); - Move(img.ImageData^, self.ImageData^, img.ImageDataSize); + img := CreateImage_BMP(BitmapData, TotalSize); + + FreeImage; // just as a precaution + AllocateImage(32, _Header.cx, _Header.cy); + // copy imagedata from the img instance to our THelpBitmap.ImageData + MemCopy(img.ImageData^, self.ImageData^, img.ImageDataSize); + UpdateImage; img.Free; diff --git a/docview/src/HelpTopic.pas b/docview/src/HelpTopic.pas index 8b12b569..275ab775 100644 --- a/docview/src/HelpTopic.pas +++ b/docview/src/HelpTopic.pas @@ -1119,7 +1119,7 @@ begin begin CheckForAutoURL( AText, State ); // supposed to turn word wrap on, default font - OutputString := {'<align left>}'</nowrap>'; // I guess... + OutputString := '</nowrap><align left>'; // I guess... State.Alignment := itaLeft; end; @@ -1254,6 +1254,7 @@ begin begin result := true; // supposed to turn word wrap on, default font + State.Alignment := itaLeft; State.Spacing := true; end; end; // case escape code of... diff --git a/docview/src/IPFFileFormatUnit.pas b/docview/src/IPFFileFormatUnit.pas index 7d6aade7..aeeaa003 100644 --- a/docview/src/IPFFileFormatUnit.pas +++ b/docview/src/IPFFileFormatUnit.pas @@ -239,7 +239,7 @@ const // FF XX ecSetLeftMargin = $02; - ecHighlight1 = $04; // hp1,2,3,5,6,7 + ecHighlight1 = $04; // hp1,2,3,4,5,6,7 ecLinkStart = $05; ecFootnoteLinkStart = $07; ecLinkEnd = $08; @@ -260,7 +260,7 @@ const ecStartLinkByResourceID = $1d; ecExternalLink = $1f; - // Subescape codes of + // SubEscape codes of HPART_DEFINE = 0; HPART_PT_HDREF = 1; HPART_PT_FNREF = 2; diff --git a/docview/src/docview.rc b/docview/src/docview.rc index 35c0ade5..95d3d914 100644 --- a/docview/src/docview.rc +++ b/docview/src/docview.rc @@ -1,8 +1,8 @@ MAINICON ICON "../images/docview-48x48.ico" 1 VERSIONINFO -FILEVERSION 1, 4, 0, 0 -PRODUCTVERSION 1, 4, 0, 0 +FILEVERSION 1, 4, 1, 0 +PRODUCTVERSION 1, 4, 1, 0 FILEFLAGSMASK 0 FILEOS 0x40000 FILETYPE 1 @@ -13,12 +13,12 @@ FILETYPE 1 { VALUE "CompanyName", "fpGUI Toolkit" VALUE "FileDescription", "fpGUI's INF Documentation Viewer" - VALUE "FileVersion", "1.4.0" + VALUE "FileVersion", "1.4.1" VALUE "InternalName", "docview" VALUE "LegalCopyright", "GNU Public License" VALUE "OriginalFilename", "docview" VALUE "ProductName", "fpGUI Toolkit" - VALUE "ProductVersion", "1.4.0" + VALUE "ProductVersion", "1.4.1" } } BLOCK "VarFileInfo" diff --git a/docview/src/docview_clean.prj b/docview/src/docview_clean.prj new file mode 100644 index 00000000..829ae97f --- /dev/null +++ b/docview/src/docview_clean.prj @@ -0,0 +1,381 @@ +[projectoptions] +mainfile=docview.lpr +targetfile=${PROJECTNAME}${EXEEXT} +messageoutputfile= +makecommand=${COMPILER} +makedir= +unitdirs=8 + ../components/richtext + ${FPTest}3rdparty/epiktimer/ + ${FPTest}src/ + ${FPGUI}/src + ${FPGUI}/src/corelib/gdi + ${FPGUI}/src/corelib/x11 + ${FPGUI}/src/gui + ${FPGUI}/src/corelib +unitpref=-Fu +incpref=-Fi +libpref=-Fl +objpref=-Fo +targpref=-o +befcommand=0 +aftcommand=0 +makeoptions=6 + -l -Mobjfpc -Sh + -gl -O- + -B + -O2 -XX -Xs -CX + -FUunits/${TargetCPU}-${TargetOS}/ + -gh +codetemplatedirs=1 + ${TEMPLATEDIR} +toolmenus=1 + fpGUI &UI Designer +toolfiles=1 + ${FPGUI_DIR}/uidesigner/units/${TargetCPU}-${TargetOS}/uidesigner${EXEEXT} +toolparams=1 + ${CURSOURCEFILE} +fontnames=0 +scriptbeforecopy= +scriptaftercopy= +newprojectfiles=4 + ${TEMPLATEDIR}/fptest/program.pas + ${TEMPLATEDIR}fpgui/units/i386-linux/placeholder.txt + ${TEMPLATEDIR}fpgui/units/i386-win32/placeholder.txt + ${TEMPLATEDIR}fpgui/units/x86_64-linux/placeholder.txt +newprojectfilesdest=4 + ${%PROJECTNAME%}.pas + ${%PROJECTDIR%}units/i386-linux/placeholder.txt + ${%PROJECTDIR%}units/i386-win32/placeholder.txt + ${%PROJECTDIR%}units/x86_64-linux/placeholder.txt +newfinames=3 + Program + Test Unit + Textfile +newfifilters=3 + "*.pas" "*.pp" + "*.pas" "*.pp" + +newfiexts=3 + pas + pas + +newfisources=3 + ${TEMPLATEDIR}fptest/program.pas + ${TEMPLATEDIR}fptest/unit.pas + +newfonames=2 + Mainform + Simple Form +newfonamebases=2 + + +newfosources=2 + ${TEMPLATEDIR}fpgui/mainform.pas + ${TEMPLATEDIR}fpgui/simpleform.pas +newfoforms=2 + + +forcezorder=0 +stripmessageesc=0 +copymessages=0 +closemessages=0 +checkmethods=1 +colorerror=-1610612712 +colorwarning=-1610612717 +colornote=-1610612716 +usercolors=30 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 +usercolorcomment=30 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +formatmacronames=0 +formatmacrovalues=0 +settingsfile=docview_clean.prj +settingseditor=1 +settingsdebugger=1 +settingsstorage=1 +settingsprojecttree=0 +settingsautoload=0 +settingsautosave=0 +modulenames=0 +moduletypes=0 +modulefiles=0 +befcommandon=0 +makeoptionson=6 + 63 + 31 + 34 + 32 + 63 + 60 +aftcommandon=0 +unitdirson=8 + 65599 + 65599 + 65599 + 196671 + 196640 + 196639 + 65581 + 196647 +macroon=7 + 9 + 3 + 6 + 4 + 8 + 63 + 63 +macronames=7 + TargetCPU + TargetOS + TargetCPU + TargetOS + TargetOS + HelpPath + FPTest +macrovalues=7 + x86_64 + linux + i386 + win32 + freebsd + /data/devel/FPC_Docs/inf/ + /data/devel/fptest/ +macrogroup=3 +groupcomments=6 + Linux 64-bit + Linux 32-bit + Windows 32-bit + FreeBSD 64-bit + + +toolsave=1 + -1 +toolhide=1 + 0 +toolparse=1 + 0 +toolmessages=1 + 0 +fontalias=0 +fontancestors=0 +fontheights=0 +fontwidths=0 +fontoptions=0 +fontxscales=0 +expandprojectfilemacros=4 + 1 + -1 + -1 + -1 +loadprojectfile=4 + 1 + 0 + 0 + 0 +newinheritedforms=2 + 0 + 0 +uid=0 +sourcefilemasks=5 + "*.pas" "*.dpr" "*.pp" "*.inc" "*.lpr" + "*.c" "*.cc" "*.h" + "*.mfm" + "*.ipf" + "*.sql" +syntaxdeffiles=5 + ${SYNTAXDEFDIR}pascal_dark.sdef + ${SYNTAXDEFDIR}cpp.sdef + ${SYNTAXDEFDIR}objecttext.sdef + ${SYNTAXDEFDIR}ipf2.sdef + ${SYNTAXDEFDIR}sql.sdef +filemasknames=5 + Source + Forms + Text + IPF help + All Files +filemasks=5 + "*.pp" "*.pas" "*.inc" "*.dpr" "*.lpr" + frm_*.pas + *.txt + *.ipf + * +showgrid=1 +snaptogrid=1 +moveonfirstclick=1 +noformdesignerdocking=0 +gridsizex=8 +gridsizey=8 +autoindent=1 +blockindent=2 +linenumberson=1 +rightmarginon=1 +rightmarginchars=80 +scrollheight=0 +tabstops=2 +spacetabs=1 +showtabs=0 +tabindent=0 +editfontname=Raize +editfontheight=16 +editfontwidth=0 +editfontextraspace=0 +editfontcolor=-1879048183 +editbkcolor=-1879048186 +statementcolor=14745599 +editfontantialiased=1 +editmarkbrackets=1 +backupfilecount=0 +encoding=0 +codetemplatedirs=1 + ${TEMPLATEDIR} +debugcommand=${DEBUGGER} +debugoptions= +debugtarget= +runcommand= +xtermcommand=xterm -S${PTSN}/${PTSH} +remoteconnection= +uploadcommand= +gdbprocessor=x86_64 +gdbservercommand= +gdbservercommandattach= +beforeconnect= +afterconnect= +beforeload= +afterload= +beforerun= +sourcebase= +sourcedirs=16 + ../components/richtext/ + ${FPCDIR}src/rtl/${TargetCPU}/ + ${FPCDIR}src/rtl/inc/ + ${FPCDIR}src/rtl/linux/${TargetCPU}/ + ${FPCDIR}src/rtl/linux/ + ${FPCDIR}src/rtl/unix/ + ${FPCDIR}src/rtl/objpas/sysutils/ + ${FPCDIR}src/rtl/objpas/classes/ + ${FPCDIR}src/rtl/objpas/ + ${FPTest}/ + ${tiOPF}Options/ + ${tiOPF}Core/ + ${FPGUI}/src/corelib/gdi/X/ + ${FPGUI}/src/corelib/x11/ + ${FPGUI}/src/*/ + ./ +defines=0 +progparameters=/data/devel/fpgui/docview/docs/IPFREF_v4.INF +progworkingdirectory= +envvarnames=0 +envvarvalues=0 +defineson=0 +stoponexception=0 +valuehints=1 +activateonbreak=1 +raiseonbreak=1 +showconsole=1 +externalconsole=0 +settty=1 +gdbdownload=0 +downloadalways=0 +startupbkpt=0 +startupbkpton=0 +gdbsimulator=0 +gdbserverstartonce=0 +gdbloadtimeout= +gdbserverwait=0 +nogdbserverexit=0 +gdbservertty=0 +exceptclassnames=1 + EconvertError +exceptignore=1 + 0 +nodebugbeginend=0 +sigsettings=27 + 1,1,T,F + 3,3,T,F + 4,4,T,F + 6,6,T,F + 7,7,T,F + 8,8,T,F + 9,9,T,F + 10,10,T,F + 11,11,T,F + 12,12,T,F + 13,13,T,F + 15,15,T,F + 16,16,T,F + 17,17,F,F + 18,18,T,F + 19,19,T,F + 20,20,T,F + 21,21,T,F + 22,22,T,F + 23,23,T,F + 24,24,T,F + 25,25,T,F + 26,26,T,F + 27,27,T,F + 28,28,T,F + 29,29,T,F + 30,30,T,F +defaultmake=4 diff --git a/docview/src/frm_main.pas b/docview/src/frm_main.pas index 00a192ea..27f2c51a 100644 --- a/docview/src/frm_main.pas +++ b/docview/src/frm_main.pas @@ -306,7 +306,7 @@ const procedure TMainForm.MainFormException(Sender: TObject; E: Exception); begin - TfpgMessageDialog.Critical('An unexpected error occurred.', E.Message); + fpgApplication.ShowException(E); end; procedure TMainForm.lbIndexKeyPress(Sender: TObject; var KeyCode: word; @@ -1747,6 +1747,7 @@ begin // Now load the various parts of the file(s) // into the user interface DisplayFiles( tmpHelpFiles, FirstContentsNode ); + tmpHelpFiles.Free; //if CmdLineParameters.getHelpManagerFlag then // ShowLeftPanel := Settings.ShowLeftPanel_Help diff --git a/docview/src/lzwdecompress.pas b/docview/src/lzwdecompress.pas index 0ebba38c..6645890c 100644 --- a/docview/src/lzwdecompress.pas +++ b/docview/src/lzwdecompress.pas @@ -1,7 +1,8 @@ { fpGUI - Free Pascal GUI Toolkit - Copyright (C) 2006 - 2013 See the file AUTHORS.txt, included in this + Copyright (C) 2001 - Aaron Lawrence (aaronl@consultant.com) + Copyright (C) 2006 - 2015 See the file AUTHORS.txt, included in this distribution, for details of the copyright. See the file COPYING.modifiedLGPL, included in this distribution, @@ -24,9 +25,9 @@ interface uses SysUtils, types; -procedure LZWDecompressBlock( pbInput: pByte; +procedure LZWDecompressBlock( pbInput: PByte; number_bytes: LongWord; - pbOutput: PBYTE; + pbOutput: PByte; Var bytesOut: LongWord; Var FinalCode: byte ); @@ -57,9 +58,9 @@ Implementation * Variables renamed etc to make things clearer. */ *) -// -- Stuff for LZW decompression -- */ +// -- Stuff for LZW decompression -- const INIT_BITS = 9; -const MAX_BITS = 12; //PLF Tue 95-10-03 02:16:56*/ +const MAX_BITS = 12; const HASHING_SHIFT = MAX_BITS - 8; {if MAX_BITS == 15 @@ -140,9 +141,11 @@ begin inc( pbInput ); end else - input_bit_buffer:= input_bit_buffer - or - ( longword( 0 ) shl ( 24 - input_bit_count ) ); + input_bit_buffer := input_bit_buffer or longword($00); +{ The C version of LZWDecompress uses only "or $00", so I'm assuming the code + below is not needed. Tested and I see no difference. } +// or +// ( longword( 0 ) shl ( 24 - input_bit_count ) ); inc( bytes_out ); inc( input_bit_count, 8 ); end; @@ -153,7 +156,7 @@ begin if bytes_out > bytes_to_read then begin - // flush static vars and quit */ + // flush static vars and quit bytes_out:= 0; input_bit_count:= 0; input_bit_buffer:= 0; @@ -167,11 +170,7 @@ end; // this takes one of the INF bitmap blocks // and decompresses it using LZW algorithms. -procedure LZWDecompressBlock( pbInput: pByte; - number_bytes: LongWord; - pbOutput: PBYTE; - Var bytesOut: LongWord; - Var FinalCode: byte ); +procedure LZWDecompressBlock(pbInput: PByte; number_bytes: LongWord; pbOutput: PByte; var bytesOut: LongWord; var FinalCode: byte); var nextAvailableCode: LongWord; currentCode: LongWord; @@ -196,40 +195,40 @@ begin begin if clear_flag then begin - clear_flag:= false; - lastCode:= currentCode; - character:= currentCode; + clear_flag := false; + lastCode := currentCode; + character := currentCode; - pbOutput^:= currentCode; + pbOutput^ := currentCode; inc( pbOutput ); - FinalCode:= currentCode; + FinalCode := currentCode; inc( BytesOut ); end else if currentCode = CLEAR_TABLE then begin - clear_flag:= true; - nextAvailableCode:= FIRST_CODE; - bitsPerCode:= INIT_BITS; - maxDictionaryCode:= MaxValNBits( bitsPerCode ); + clear_flag := true; + nextAvailableCode := FIRST_CODE; + bitsPerCode := INIT_BITS; + maxDictionaryCode := MaxValNBits( bitsPerCode ); end else begin if currentCode >= nextAvailableCode then begin decode_stack[ 0 ]:= character; - theString:= decode_string( Addr( decode_stack[ 1 ] ), + theString := decode_string( Addr( decode_stack[ 1 ] ), lastCode ); end else - theString:= decode_string( Addr( decode_stack[ 0 ] ), + theString := decode_string( Addr( decode_stack[ 0 ] ), currentCode ); - character:= longword( theString^ ); + character := longword( theString^ ); while theString >= Addr( decode_stack[ 0 ] ) do begin - FinalCode:= theString^; + FinalCode := theString^; - pbOutput^:= theString^; + pbOutput^ := theString^; inc( pbOutput ); dec( TheString ); |