From edb953f15094f5f9ca544ac8c58e11a997725fdd Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Tue, 28 May 2019 21:13:32 +0000 Subject: [PATCH] jvcllaz: Fix line-breaks in JvHTControls' HTML texts. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6967 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../examples/JvHTControls/JvHTCtrlsDemo.lpi | 2 +- .../examples/JvHTControls/JvHTCtrlsDemo.lpr | 2 +- .../jvcllaz/examples/JvHTControls/unit1.lfm | 28 +++++++++---------- .../jvcllaz/examples/JvHTControls/unit1.pas | 26 ++++++++--------- components/jvcllaz/run/JvCore/jvjvclutils.pas | 10 +++++-- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/components/jvcllaz/examples/JvHTControls/JvHTCtrlsDemo.lpi b/components/jvcllaz/examples/JvHTControls/JvHTCtrlsDemo.lpi index c538eef50..a5bd119b7 100644 --- a/components/jvcllaz/examples/JvHTControls/JvHTCtrlsDemo.lpi +++ b/components/jvcllaz/examples/JvHTControls/JvHTCtrlsDemo.lpi @@ -49,7 +49,7 @@ - + diff --git a/components/jvcllaz/examples/JvHTControls/JvHTCtrlsDemo.lpr b/components/jvcllaz/examples/JvHTControls/JvHTCtrlsDemo.lpr index 2cfa529d2..dd3d6ecc0 100644 --- a/components/jvcllaz/examples/JvHTControls/JvHTCtrlsDemo.lpr +++ b/components/jvcllaz/examples/JvHTControls/JvHTCtrlsDemo.lpr @@ -15,7 +15,7 @@ uses begin RequireDerivedFormResource:=True; Application.Initialize; - Application.CreateForm(TForm1, Form1); + Application.CreateForm(TMainForm, MainForm); Application.Run; end. diff --git a/components/jvcllaz/examples/JvHTControls/unit1.lfm b/components/jvcllaz/examples/JvHTControls/unit1.lfm index 75536bf6b..a1018c26c 100644 --- a/components/jvcllaz/examples/JvHTControls/unit1.lfm +++ b/components/jvcllaz/examples/JvHTControls/unit1.lfm @@ -1,11 +1,11 @@ -object Form1: TForm1 - Left = 256 +object MainForm: TMainForm + Left = 369 Height = 468 - Top = 122 - Width = 582 + Top = 219 + Width = 575 Caption = 'JvHTControls' ClientHeight = 468 - ClientWidth = 582 + ClientWidth = 575 OnCreate = FormCreate OnShow = FormShow LCLVersion = '2.1.0.0' @@ -13,7 +13,7 @@ object Form1: TForm1 Left = 0 Height = 422 Top = 0 - Width = 582 + Width = 575 ActivePage = TabSheet1 Align = alClient TabIndex = 0 @@ -21,10 +21,10 @@ object Form1: TForm1 object TabSheet1: TTabSheet Caption = 'TJvHTLabel' ClientHeight = 394 - ClientWidth = 574 + ClientWidth = 567 object JvHTLabel1: TJvHTLabel Left = 8 - Height = 106 + Height = 196 Hint = 'HTLabel with:
'#13#10'bold
'#13#10'italic
'#13#10'underline
'#13#10'strikeout
'#13#10'color
'#13#10'Links and custom links' Top = 8 Width = 120 @@ -36,10 +36,10 @@ object Form1: TForm1 end object Memo1: TMemo Left = 0 - Height = 122 + Height = 123 Hint = 'HTML
'#13#10'Enter HTML content' - Top = 272 - Width = 574 + Top = 271 + Width = 567 Align = alBottom Lines.Strings = ( 'HTLabel with:
' @@ -62,8 +62,8 @@ object Form1: TForm1 Cursor = crVSplit Left = 0 Height = 5 - Top = 267 - Width = 574 + Top = 266 + Width = 567 Align = alBottom ResizeAnchor = akBottom end @@ -235,7 +235,7 @@ object Form1: TForm1 Left = 6 Height = 34 Top = 428 - Width = 570 + Width = 563 OKButton.Name = 'OKButton' OKButton.DefaultCaption = True HelpButton.Name = 'HelpButton' diff --git a/components/jvcllaz/examples/JvHTControls/unit1.pas b/components/jvcllaz/examples/JvHTControls/unit1.pas index f876db085..b8288bc4f 100644 --- a/components/jvcllaz/examples/JvHTControls/unit1.pas +++ b/components/jvcllaz/examples/JvHTControls/unit1.pas @@ -11,9 +11,9 @@ uses type - { TForm1 } + { TMainForm } - TForm1 = class(TForm) + TMainForm = class(TForm) Button1: TButton; Button2: TButton; ButtonPanel1: TButtonPanel; @@ -50,31 +50,31 @@ type end; var - Form1: TForm1; + MainForm: TMainForm; implementation {$R *.lfm} -{ TForm1 } +{ TMainForm } -procedure TForm1.Memo1Change(Sender: TObject); +procedure TMainForm.Memo1Change(Sender: TObject); begin JvHTLabel1.Caption := Memo1.Text; JvHTLabel1.Hint := Memo1.Text; end; -procedure TForm1.Memo3Change(Sender: TObject); +procedure TMainForm.Memo3Change(Sender: TObject); begin JvDBHTLabel1.Mask := Memo3.Text; end; -procedure TForm1.FormCreate(Sender: TObject); +procedure TMainForm.FormCreate(Sender: TObject); begin RegisterHtHints; end; -procedure TForm1.FormShow(Sender: TObject); +procedure TMainForm.FormShow(Sender: TObject); begin MemDataset1.AppendRecord([1, 'asdfxc', 'wertfx']); MemDataset1.AppendRecord([2, 'brdrgrsdgx', 'sdfwetrcx']); @@ -83,29 +83,29 @@ begin MemDataset1.AppendRecord([5, 'trcbxg', 'her4fekg']); end; -procedure TForm1.JvDBHTLabel1HyperLinkClick(Sender: TObject; LinkName: string); +procedure TMainForm.JvDBHTLabel1HyperLinkClick(Sender: TObject; LinkName: string); begin MessageDlg('TJvDBHTLabel', 'Hyperlink: ' + LinkName, mtInformation, [mbOK], 0); end; -procedure TForm1.Button1Click(Sender: TObject); +procedure TMainForm.Button1Click(Sender: TObject); begin JvHTListBox1.Items.Add(Memo2.Text); JvHTComboBox1.Items.Add(Memo2.Text); end; -procedure TForm1.Button2Click(Sender: TObject); +procedure TMainForm.Button2Click(Sender: TObject); begin JvHTComboBox1.Items.Clear; JvHTListBox1.Items.Clear; end; -procedure TForm1.JvHTLabel1HyperLinkClick(Sender: TObject; LinkName: string); +procedure TMainForm.JvHTLabel1HyperLinkClick(Sender: TObject; LinkName: string); begin MessageDlg('TJvHTLabel', 'Hyperlink: ' + LinkName, mtInformation, [mbOK], 0); end; -procedure TForm1.JvHTListBox1HyperLinkClick(Sender: TObject; LinkName: string); +procedure TMainForm.JvHTListBox1HyperLinkClick(Sender: TObject; LinkName: string); begin MessageDlg('JvHTListBox', 'Hyperlink: ' + LinkName, mtInformation, [mbOK], 0); end; diff --git a/components/jvcllaz/run/JvCore/jvjvclutils.pas b/components/jvcllaz/run/JvCore/jvjvclutils.pas index 91f1aed0a..311388248 100644 --- a/components/jvcllaz/run/JvCore/jvjvclutils.pas +++ b/components/jvcllaz/run/JvCore/jvjvclutils.pas @@ -7081,6 +7081,7 @@ end; const cBR = '
'; + cBR2 = '
'; cHR = '
'; cTagBegin = '<'; cTagEnd = '>'; @@ -7117,8 +7118,9 @@ begin Result := Text; for I := Low(Conversions) to High(Conversions) do Result := StringReplace(Result, Conversions[I].Html, Utf8ToAnsi(Conversions[I].Text), [rfReplaceAll, rfIgnoreCase]); - Result := StringReplace(Result, sLineBreak, '', [rfReplaceAll, rfIgnoreCase]); // only
can be new line + Result := StringReplace(Result, sLineBreak, '', [rfReplaceAll, rfIgnoreCase]); // only
can be new line Result := StringReplace(Result, cBR, sLineBreak, [rfReplaceAll, rfIgnoreCase]); + Result := StringReplace(Result, cBR2, sLineBreak, [rfReplaceAll, rfIgnoreCase]); // Fixes
, but not
! Result := StringReplace(Result, cHR, cHR + sLineBreak, [rfReplaceAll, rfIgnoreCase]); // fixed

end; @@ -7367,13 +7369,14 @@ begin RemBrushColor := Canvas.Brush.Color; RemFontSize := Canvas.Font.size; end; + vStr := TStringList.Create; try Alignment := taLeftJustify; IsLink := False; MouseOnLink := False; vText := Text; - vStr.Text := vText; + vStr.Text := HTMLPrepareText(vText); LinkName := ''; TempLink := ''; ScriptPosition := spNormal; @@ -7387,7 +7390,8 @@ begin vM := ''; for vCount := 0 to vStr.Count - 1 do begin - vText := HTMLPrepareText(vStr[vCount]); +// vText := HTMLPrepareText(vStr[vCount]); + vText := vStr[vCount]; CurLeft := CalcPos(vText); while vText <> '' do begin