summaryrefslogtreecommitdiff
path: root/docview/components
diff options
context:
space:
mode:
authorGraeme Geldenhuys <graeme@mastermaths.co.za>2011-08-08 17:07:34 +0200
committerGraeme Geldenhuys <graeme@mastermaths.co.za>2011-08-08 17:07:34 +0200
commit16d4fd2f99a7b10fb631e1935c520b8ce7cc814b (patch)
treec33e9163957f9c6a803e106ffbfa4207db69669d /docview/components
parent42316ce6d340d69e70d19490d7885f374b3e28f8 (diff)
downloadfpGUI-16d4fd2f99a7b10fb631e1935c520b8ce7cc814b.tar.xz
richview: minor refactoring of code and fixing of one memory leak.
Diffstat (limited to 'docview/components')
-rw-r--r--docview/components/richtext/RichTextLayoutUnit.pas40
1 files changed, 20 insertions, 20 deletions
diff --git a/docview/components/richtext/RichTextLayoutUnit.pas b/docview/components/richtext/RichTextLayoutUnit.pas
index 1e593854..d6b86a69 100644
--- a/docview/components/richtext/RichTextLayoutUnit.pas
+++ b/docview/components/richtext/RichTextLayoutUnit.pas
@@ -293,6 +293,18 @@ Var
DoWrap: boolean;
// Nested procedure
+ procedure CreateDefaultCurrentLine;
+ begin
+ CurrentLine := TLayoutLine.Create;
+ CurrentLine.Style := Style;
+ CurrentLine.Height := 0;
+ CurrentLine.MaxDescender := 0;
+ CurrentLine.MaxTextHeight := 0;
+ CurrentLine.Width := 0;
+ CurrentLine.LinkIndex := CurrentLinkIndex;
+ CurrentLine.Wrapped := false;
+ end;
+
Procedure DoLine( EndPoint: PChar; NextLine: PChar; EndX: longint );
begin
// check if the max font
@@ -306,15 +318,8 @@ Var
Assert( CurrentLine.Height > 0 ); // we must have set the line height!
AddLineStart( CurrentLine );
- CurrentLine := TLayoutLine.Create;
+ CreateDefaultCurrentLine;
CurrentLine.Text := NextLine;
- CurrentLine.Style := Style;
- CurrentLine.Height := 0;
- CurrentLine.MaxDescender := 0;
- CurrentLine.MaxTextHeight := 0;
- CurrentLine.Width := 0;
- CurrentLine.LinkIndex := CurrentLinkIndex;
- CurrentLine.Wrapped := false;
assert( CurrentLinkIndex >= -1 );
assert( CurrentLinkIndex < FLinks.Count );
@@ -333,18 +338,6 @@ ProfileEvent('DEBUG: TRichTextLayout.Layout >>>>');
Style := GetDefaultStyle( FRichTextSettings );
ApplyStyle( Style, FFontManager );
CurrentLinkIndex := -1;
- P := FText; // P is the current search position
-
- CurrentLine := TLayoutLine.Create;
- CurrentLine.Text := P;
- CurrentLine.Style := Style;
- CurrentLine.Height := 0;
- CurrentLine.MaxDescender := 0;
- CurrentLine.MaxTextHeight := 0;
- CurrentLine.Width := 0;
- CurrentLine.LinkIndex := -1;
- CurrentLine.Wrapped := false;
-
WordStartX := Style.LeftMargin;
WordX := 0;
WrapX := FLayoutWidth - FRichTextSettings.Margins.Right;
@@ -352,6 +345,13 @@ ProfileEvent('DEBUG: TRichTextLayout.Layout >>>>');
WordStarted := false;
DisplayedCharsSinceFontChange := false;
+ P := FText; // P is the current search position
+
+ if FText = '' then
+ exit;
+ CreateDefaultCurrentLine;
+ CurrentLine.Text := P;
+
repeat
CurrentElement := ExtractNextTextElement( P, NextP );
assert( NextP > P );