From bdedb40277b9697c321dc116d14b5d2c212d8b94 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Sat, 25 May 2019 23:12:55 +0000 Subject: [PATCH] jvcllaz: Add html test demo for JvNet packages. Fix some bugs in html conversion routines. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6948 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/jvcllaz/design/JvNet/jvnetreg.pas | 2 +- .../jvcllaz/examples/JvHTML/JvHTMLTest.lpi | 93 ++ .../jvcllaz/examples/JvHTML/JvHTMLTest.lpr | 22 + .../jvcllaz/examples/JvHTML/demoform.lfm | 205 +++ .../jvcllaz/examples/JvHTML/demoform.pas | 51 + .../jvcllaz/examples/JvHTML/htmltestform.lfm | 1221 +++++++++++++++++ .../jvcllaz/examples/JvHTML/htmltestform.pas | 111 ++ components/jvcllaz/run/JvNet/jvformtohtml.pas | 396 +++--- .../jvcllaz/run/JvNet/jvstringlisttohtml.pas | 5 +- components/jvcllaz/run/JvNet/jvstrtohtml.pas | 7 +- 10 files changed, 1912 insertions(+), 201 deletions(-) create mode 100644 components/jvcllaz/examples/JvHTML/JvHTMLTest.lpi create mode 100644 components/jvcllaz/examples/JvHTML/JvHTMLTest.lpr create mode 100644 components/jvcllaz/examples/JvHTML/demoform.lfm create mode 100644 components/jvcllaz/examples/JvHTML/demoform.pas create mode 100644 components/jvcllaz/examples/JvHTML/htmltestform.lfm create mode 100644 components/jvcllaz/examples/JvHTML/htmltestform.pas diff --git a/components/jvcllaz/design/JvNet/jvnetreg.pas b/components/jvcllaz/design/JvNet/jvnetreg.pas index 9ee192a14..efa2d7de5 100644 --- a/components/jvcllaz/design/JvNet/jvnetreg.pas +++ b/components/jvcllaz/design/JvNet/jvnetreg.pas @@ -19,7 +19,7 @@ uses procedure Register; begin - RegisterComponents(RsPaletteJvcl, [ + RegisterComponents(RsPaletteJvclNonVisual, [ TJvHtmlParser, TJvFormToHtml, TJvStringListToHtml, TJvStrToHtml ]); end; diff --git a/components/jvcllaz/examples/JvHTML/JvHTMLTest.lpi b/components/jvcllaz/examples/JvHTML/JvHTMLTest.lpi new file mode 100644 index 000000000..49ee575f3 --- /dev/null +++ b/components/jvcllaz/examples/JvHTML/JvHTMLTest.lpi @@ -0,0 +1,93 @@ + + + + + + + + + <Scaled Value="True"/> + <ResourceType Value="res"/> + <UseXPManifest Value="True"/> + <XPManifest> + <DpiAware Value="True"/> + </XPManifest> + <Icon Value="0"/> + </General> + <BuildModes> + <Item Name="Default" Default="True"/> + </BuildModes> + <PublishOptions> + <Version Value="2"/> + <UseFileFilters Value="True"/> + </PublishOptions> + <RunParams> + <FormatVersion Value="2"/> + <Modes Count="0"/> + </RunParams> + <RequiredPackages Count="3"> + <Item1> + <PackageName Value="SynEdit"/> + </Item1> + <Item2> + <PackageName Value="JvNetLazR"/> + </Item2> + <Item3> + <PackageName Value="LCL"/> + </Item3> + </RequiredPackages> + <Units> + <Unit> + <Filename Value="JvHTMLTest.lpr"/> + <IsPartOfProject Value="True"/> + </Unit> + <Unit> + <Filename Value="htmltestform.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="MainForm"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="HTMLTestForm"/> + </Unit> + <Unit> + <Filename Value="demoform.pas"/> + <IsPartOfProject Value="True"/> + <ComponentName Value="Form2"/> + <HasResources Value="True"/> + <ResourceBaseClass Value="Form"/> + <UnitName Value="DemoForm"/> + </Unit> + </Units> + </ProjectOptions> + <CompilerOptions> + <Version Value="11"/> + <PathDelim Value="\"/> + <Target> + <Filename Value="..\..\bin\JvHTMLTest"/> + </Target> + <SearchPaths> + <IncludeFiles Value="$(ProjOutDir)"/> + <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> + </SearchPaths> + <Linking> + <Options> + <Win32> + <GraphicApplication Value="True"/> + </Win32> + </Options> + </Linking> + </CompilerOptions> + <Debugging> + <Exceptions Count="3"> + <Item1> + <Name Value="EAbort"/> + </Item1> + <Item2> + <Name Value="ECodetoolError"/> + </Item2> + <Item3> + <Name Value="EFOpenError"/> + </Item3> + </Exceptions> + </Debugging> +</CONFIG> diff --git a/components/jvcllaz/examples/JvHTML/JvHTMLTest.lpr b/components/jvcllaz/examples/JvHTML/JvHTMLTest.lpr new file mode 100644 index 000000000..c62696b7e --- /dev/null +++ b/components/jvcllaz/examples/JvHTML/JvHTMLTest.lpr @@ -0,0 +1,22 @@ +program JvHTMLTest; + +{$mode objfpc}{$H+} + +uses + {$IFDEF UNIX}{$IFDEF UseCThreads} + cthreads, + {$ENDIF}{$ENDIF} + Interfaces, // this includes the LCL widgetset + Forms, HTMLTestForm, DemoForm + { you can add units after this }; + +{$R *.res} + +begin + RequireDerivedFormResource:=True; + Application.Scaled:=True; + Application.Initialize; + Application.CreateForm(TMainForm, MainForm); + Application.Run; +end. + diff --git a/components/jvcllaz/examples/JvHTML/demoform.lfm b/components/jvcllaz/examples/JvHTML/demoform.lfm new file mode 100644 index 000000000..23f5a2d9a --- /dev/null +++ b/components/jvcllaz/examples/JvHTML/demoform.lfm @@ -0,0 +1,205 @@ +object Form2: TForm2 + Left = 445 + Height = 386 + Top = 170 + Width = 487 + Caption = 'Find' + ClientHeight = 386 + ClientWidth = 487 + LCLVersion = '2.1.0.0' + object lblTextToFind: TLabel + Left = 24 + Height = 15 + Top = 16 + Width = 59 + Caption = 'Text to find' + ParentColor = False + end + object edName: TEdit + Left = 128 + Height = 23 + Top = 11 + Width = 337 + TabOrder = 0 + Text = 'object' + end + object btnFind: TButton + Left = 264 + Height = 25 + Top = 344 + Width = 75 + Caption = 'Find' + ModalResult = 1 + TabOrder = 8 + end + object btnCancel: TButton + Left = 390 + Height = 25 + Top = 344 + Width = 75 + Caption = 'Cancel' + ModalResult = 2 + TabOrder = 9 + end + object cmbReplaceWidth: TComboBox + Left = 128 + Height = 23 + Top = 46 + Width = 337 + ItemHeight = 15 + TabOrder = 2 + Text = 'class' + end + object btnHelp: TButton + Left = 16 + Height = 25 + Top = 344 + Width = 75 + Caption = 'Help' + ModalResult = 6 + TabOrder = 7 + end + object cbReplaceWith: TCheckBox + Left = 24 + Height = 19 + Top = 48 + Width = 87 + Caption = 'Replace with' + TabOrder = 1 + end + object gbOptions: TGroupBox + Left = 24 + Height = 231 + Top = 89 + Width = 232 + Caption = 'Options' + ClientHeight = 211 + ClientWidth = 228 + TabOrder = 3 + object cbCaseSensitive: TCheckBox + Left = 18 + Height = 19 + Top = 8 + Width = 93 + Caption = 'Case sensitive' + TabOrder = 0 + end + object cbWholeWordsOnly: TCheckBox + Left = 18 + Height = 19 + Top = 36 + Width = 115 + Caption = 'Whole words only' + TabOrder = 1 + end + object cbRegularExpressions: TCheckBox + Left = 18 + Height = 19 + Top = 64 + Width = 123 + Caption = 'Regular expressions' + TabOrder = 2 + end + object cbMultilinePattern: TCheckBox + Left = 18 + Height = 19 + Top = 96 + Width = 108 + Caption = 'Multiline pattern' + TabOrder = 3 + end + object cbPromptOnReplace: TCheckBox + Left = 18 + Height = 19 + Top = 128 + Width = 118 + Caption = 'Prompt on replace' + Enabled = False + TabOrder = 4 + end + end + object gbOrigin: TGroupBox + Left = 280 + Height = 71 + Top = 89 + Width = 185 + Caption = 'Origin' + ClientHeight = 51 + ClientWidth = 181 + TabOrder = 4 + object rbFromCursor: TRadioButton + Left = 16 + Height = 19 + Top = 0 + Width = 84 + Caption = 'From cursor' + Checked = True + TabOrder = 0 + TabStop = True + end + object rbFromBeginning: TRadioButton + Left = 16 + Height = 19 + Top = 24 + Width = 105 + Caption = 'From beginning' + TabOrder = 1 + end + end + object gbSearchScope: TGroupBox + Left = 280 + Height = 72 + Top = 168 + Width = 185 + Caption = 'Search scope' + ClientHeight = 52 + ClientWidth = 181 + TabOrder = 5 + object rbSelectedText: TRadioButton + Left = 16 + Height = 19 + Top = 1 + Width = 86 + Caption = 'Selected text' + Checked = True + TabOrder = 0 + TabStop = True + end + object rbGlobal: TRadioButton + Left = 16 + Height = 19 + Top = 24 + Width = 54 + Caption = 'Global' + TabOrder = 1 + end + end + object gbDirection: TGroupBox + Left = 280 + Height = 72 + Top = 248 + Width = 185 + Caption = 'Direction' + ClientHeight = 52 + ClientWidth = 181 + TabOrder = 6 + object rbBackwardSearch: TRadioButton + Left = 16 + Height = 19 + Top = 0 + Width = 108 + Caption = 'Backward search' + Checked = True + TabOrder = 0 + TabStop = True + end + object rbForwardSearch: TRadioButton + Left = 16 + Height = 19 + Top = 24 + Width = 100 + Caption = 'Forward search' + TabOrder = 1 + end + end +end diff --git a/components/jvcllaz/examples/JvHTML/demoform.pas b/components/jvcllaz/examples/JvHTML/demoform.pas new file mode 100644 index 000000000..cb36d0dc1 --- /dev/null +++ b/components/jvcllaz/examples/JvHTML/demoform.pas @@ -0,0 +1,51 @@ +unit DemoForm; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls; + +type + + { TForm2 } + + TForm2 = class(TForm) + btnFind: TButton; + btnCancel: TButton; + btnHelp: TButton; + cbReplaceWith: TCheckBox; + cbCaseSensitive: TCheckBox; + cbWholeWordsOnly: TCheckBox; + cbRegularExpressions: TCheckBox; + cbMultilinePattern: TCheckBox; + cbPromptOnReplace: TCheckBox; + cmbReplaceWidth: TComboBox; + edName: TEdit; + gbOptions: TGroupBox; + gbOrigin: TGroupBox; + gbSearchScope: TGroupBox; + gbDirection: TGroupBox; + lblTextToFind: TLabel; + rbFromCursor: TRadioButton; + rbFromBeginning: TRadioButton; + rbSelectedText: TRadioButton; + rbGlobal: TRadioButton; + rbBackwardSearch: TRadioButton; + rbForwardSearch: TRadioButton; + private + + public + + end; + +var + Form2: TForm2; + +implementation + +{$R *.lfm} + +end. + diff --git a/components/jvcllaz/examples/JvHTML/htmltestform.lfm b/components/jvcllaz/examples/JvHTML/htmltestform.lfm new file mode 100644 index 000000000..969c88c3a --- /dev/null +++ b/components/jvcllaz/examples/JvHTML/htmltestform.lfm @@ -0,0 +1,1221 @@ +object MainForm: TMainForm + Left = 326 + Height = 384 + Top = 127 + Width = 858 + Caption = 'JvHTMLTest' + ClientHeight = 384 + ClientWidth = 858 + OnShow = FormShow + LCLVersion = '2.1.0.0' + object PageControl: TPageControl + Left = 0 + Height = 384 + Top = 0 + Width = 858 + ActivePage = pgStringToHTML + Align = alClient + TabIndex = 0 + TabOrder = 0 + object pgStringToHTML: TTabSheet + Caption = 'String to HTML' + ClientHeight = 356 + ClientWidth = 850 + object edTextIn: TEdit + AnchorSideLeft.Control = lblTextIn + AnchorSideTop.Control = lblTextIn + AnchorSideTop.Side = asrBottom + Left = 24 + Height = 23 + Top = 43 + Width = 496 + BorderSpacing.Top = 4 + OnChange = edTextInChange + TabOrder = 0 + Text = '10% of 100 $ is 10 $.' + end + object lblTextIn: TLabel + AnchorSideLeft.Control = pgStringToHTML + AnchorSideTop.Control = pgStringToHTML + Left = 24 + Height = 15 + Top = 24 + Width = 50 + BorderSpacing.Left = 24 + BorderSpacing.Top = 24 + Caption = 'Input text' + ParentColor = False + end + object lblTextAsHTML: TLabel + AnchorSideLeft.Control = lblTextIn + AnchorSideTop.Control = edTextIn + AnchorSideTop.Side = asrBottom + Left = 24 + Height = 15 + Top = 90 + Width = 105 + BorderSpacing.Top = 24 + Caption = 'Converted to HTML' + ParentColor = False + end + object edHTML: TEdit + AnchorSideLeft.Control = lblTextIn + AnchorSideTop.Control = lblTextAsHTML + AnchorSideTop.Side = asrBottom + Left = 24 + Height = 23 + Top = 109 + Width = 498 + BorderSpacing.Top = 4 + ReadOnly = True + TabOrder = 1 + Text = 'edHTML' + end + object edTextOut: TEdit + AnchorSideLeft.Control = lblTextIn + AnchorSideTop.Control = lblTextOut + AnchorSideTop.Side = asrBottom + Left = 24 + Height = 23 + Top = 175 + Width = 498 + BorderSpacing.Top = 4 + ReadOnly = True + TabOrder = 2 + Text = 'edTextOut' + end + object lblTextOut: TLabel + AnchorSideLeft.Control = lblTextIn + AnchorSideTop.Control = edHTML + AnchorSideTop.Side = asrBottom + Left = 24 + Height = 15 + Top = 156 + Width = 122 + BorderSpacing.Top = 24 + Caption = 'Converted back to text:' + ParentColor = False + end + end + object pgStringsToHTML: TTabSheet + Caption = 'Strings to HTML' + ClientHeight = 356 + ClientWidth = 850 + object Memo: TMemo + Left = 6 + Height = 344 + Top = 6 + Width = 315 + Align = alLeft + BorderSpacing.Left = 6 + BorderSpacing.Top = 6 + BorderSpacing.Right = 1 + BorderSpacing.Bottom = 6 + Lines.Strings = ( + 'Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ' + ) + OnChange = MemoChange + TabOrder = 0 + end + inline StringsSynEdit: TSynEdit + AnchorSideLeft.Control = Splitter1 + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = pgStringsToHTML + AnchorSideRight.Control = pgStringsToHTML + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = edHTMLTitle + Left = 329 + Height = 315 + Top = 6 + Width = 515 + BorderSpacing.Left = 2 + BorderSpacing.Top = 6 + BorderSpacing.Right = 6 + BorderSpacing.Bottom = 6 + Anchors = [akTop, akLeft, akRight, akBottom] + Font.Height = -13 + Font.Name = 'Courier New' + Font.Pitch = fpFixed + Font.Quality = fqAntialiased + ParentColor = False + ParentFont = False + TabOrder = 1 + Gutter.Width = 57 + Gutter.MouseActions = <> + RightGutter.Width = 0 + RightGutter.MouseActions = <> + Highlighter = SynHTMLSyn + Keystrokes = < + item + Command = ecUp + ShortCut = 38 + end + item + Command = ecSelUp + ShortCut = 8230 + end + item + Command = ecScrollUp + ShortCut = 16422 + end + item + Command = ecDown + ShortCut = 40 + end + item + Command = ecSelDown + ShortCut = 8232 + end + item + Command = ecScrollDown + ShortCut = 16424 + end + item + Command = ecLeft + ShortCut = 37 + end + item + Command = ecSelLeft + ShortCut = 8229 + end + item + Command = ecWordLeft + ShortCut = 16421 + end + item + Command = ecSelWordLeft + ShortCut = 24613 + end + item + Command = ecRight + ShortCut = 39 + end + item + Command = ecSelRight + ShortCut = 8231 + end + item + Command = ecWordRight + ShortCut = 16423 + end + item + Command = ecSelWordRight + ShortCut = 24615 + end + item + Command = ecPageDown + ShortCut = 34 + end + item + Command = ecSelPageDown + ShortCut = 8226 + end + item + Command = ecPageBottom + ShortCut = 16418 + end + item + Command = ecSelPageBottom + ShortCut = 24610 + end + item + Command = ecPageUp + ShortCut = 33 + end + item + Command = ecSelPageUp + ShortCut = 8225 + end + item + Command = ecPageTop + ShortCut = 16417 + end + item + Command = ecSelPageTop + ShortCut = 24609 + end + item + Command = ecLineStart + ShortCut = 36 + end + item + Command = ecSelLineStart + ShortCut = 8228 + end + item + Command = ecEditorTop + ShortCut = 16420 + end + item + Command = ecSelEditorTop + ShortCut = 24612 + end + item + Command = ecLineEnd + ShortCut = 35 + end + item + Command = ecSelLineEnd + ShortCut = 8227 + end + item + Command = ecEditorBottom + ShortCut = 16419 + end + item + Command = ecSelEditorBottom + ShortCut = 24611 + end + item + Command = ecToggleMode + ShortCut = 45 + end + item + Command = ecCopy + ShortCut = 16429 + end + item + Command = ecPaste + ShortCut = 8237 + end + item + Command = ecDeleteChar + ShortCut = 46 + end + item + Command = ecCut + ShortCut = 8238 + end + item + Command = ecDeleteLastChar + ShortCut = 8 + end + item + Command = ecDeleteLastChar + ShortCut = 8200 + end + item + Command = ecDeleteLastWord + ShortCut = 16392 + end + item + Command = ecUndo + ShortCut = 32776 + end + item + Command = ecRedo + ShortCut = 40968 + end + item + Command = ecLineBreak + ShortCut = 13 + end + item + Command = ecSelectAll + ShortCut = 16449 + end + item + Command = ecCopy + ShortCut = 16451 + end + item + Command = ecBlockIndent + ShortCut = 24649 + end + item + Command = ecLineBreak + ShortCut = 16461 + end + item + Command = ecInsertLine + ShortCut = 16462 + end + item + Command = ecDeleteWord + ShortCut = 16468 + end + item + Command = ecBlockUnindent + ShortCut = 24661 + end + item + Command = ecPaste + ShortCut = 16470 + end + item + Command = ecCut + ShortCut = 16472 + end + item + Command = ecDeleteLine + ShortCut = 16473 + end + item + Command = ecDeleteEOL + ShortCut = 24665 + end + item + Command = ecUndo + ShortCut = 16474 + end + item + Command = ecRedo + ShortCut = 24666 + end + item + Command = ecGotoMarker0 + ShortCut = 16432 + end + item + Command = ecGotoMarker1 + ShortCut = 16433 + end + item + Command = ecGotoMarker2 + ShortCut = 16434 + end + item + Command = ecGotoMarker3 + ShortCut = 16435 + end + item + Command = ecGotoMarker4 + ShortCut = 16436 + end + item + Command = ecGotoMarker5 + ShortCut = 16437 + end + item + Command = ecGotoMarker6 + ShortCut = 16438 + end + item + Command = ecGotoMarker7 + ShortCut = 16439 + end + item + Command = ecGotoMarker8 + ShortCut = 16440 + end + item + Command = ecGotoMarker9 + ShortCut = 16441 + end + item + Command = ecSetMarker0 + ShortCut = 24624 + end + item + Command = ecSetMarker1 + ShortCut = 24625 + end + item + Command = ecSetMarker2 + ShortCut = 24626 + end + item + Command = ecSetMarker3 + ShortCut = 24627 + end + item + Command = ecSetMarker4 + ShortCut = 24628 + end + item + Command = ecSetMarker5 + ShortCut = 24629 + end + item + Command = ecSetMarker6 + ShortCut = 24630 + end + item + Command = ecSetMarker7 + ShortCut = 24631 + end + item + Command = ecSetMarker8 + ShortCut = 24632 + end + item + Command = ecSetMarker9 + ShortCut = 24633 + end + item + Command = EcFoldLevel1 + ShortCut = 41009 + end + item + Command = EcFoldLevel2 + ShortCut = 41010 + end + item + Command = EcFoldLevel3 + ShortCut = 41011 + end + item + Command = EcFoldLevel4 + ShortCut = 41012 + end + item + Command = EcFoldLevel5 + ShortCut = 41013 + end + item + Command = EcFoldLevel6 + ShortCut = 41014 + end + item + Command = EcFoldLevel7 + ShortCut = 41015 + end + item + Command = EcFoldLevel8 + ShortCut = 41016 + end + item + Command = EcFoldLevel9 + ShortCut = 41017 + end + item + Command = EcFoldLevel0 + ShortCut = 41008 + end + item + Command = EcFoldCurrent + ShortCut = 41005 + end + item + Command = EcUnFoldCurrent + ShortCut = 41003 + end + item + Command = EcToggleMarkupWord + ShortCut = 32845 + end + item + Command = ecNormalSelect + ShortCut = 24654 + end + item + Command = ecColumnSelect + ShortCut = 24643 + end + item + Command = ecLineSelect + ShortCut = 24652 + end + item + Command = ecTab + ShortCut = 9 + end + item + Command = ecShiftTab + ShortCut = 8201 + end + item + Command = ecMatchBracket + ShortCut = 24642 + end + item + Command = ecColSelUp + ShortCut = 40998 + end + item + Command = ecColSelDown + ShortCut = 41000 + end + item + Command = ecColSelLeft + ShortCut = 40997 + end + item + Command = ecColSelRight + ShortCut = 40999 + end + item + Command = ecColSelPageDown + ShortCut = 40994 + end + item + Command = ecColSelPageBottom + ShortCut = 57378 + end + item + Command = ecColSelPageUp + ShortCut = 40993 + end + item + Command = ecColSelPageTop + ShortCut = 57377 + end + item + Command = ecColSelLineStart + ShortCut = 40996 + end + item + Command = ecColSelLineEnd + ShortCut = 40995 + end + item + Command = ecColSelEditorTop + ShortCut = 57380 + end + item + Command = ecColSelEditorBottom + ShortCut = 57379 + end> + MouseActions = <> + MouseTextActions = <> + MouseSelActions = <> + VisibleSpecialChars = [vscSpace, vscTabAtLast] + SelectedColor.BackPriority = 50 + SelectedColor.ForePriority = 50 + SelectedColor.FramePriority = 50 + SelectedColor.BoldPriority = 50 + SelectedColor.ItalicPriority = 50 + SelectedColor.UnderlinePriority = 50 + SelectedColor.StrikeOutPriority = 50 + BracketHighlightStyle = sbhsBoth + BracketMatchColor.Background = clNone + BracketMatchColor.Foreground = clNone + BracketMatchColor.Style = [fsBold] + FoldedCodeColor.Background = clNone + FoldedCodeColor.Foreground = clGray + FoldedCodeColor.FrameColor = clGray + MouseLinkColor.Background = clNone + MouseLinkColor.Foreground = clBlue + LineHighlightColor.Background = clNone + LineHighlightColor.Foreground = clNone + inline SynLeftGutterPartList1: TSynGutterPartList + object SynGutterMarks1: TSynGutterMarks + Width = 24 + MouseActions = <> + end + object SynGutterLineNumber1: TSynGutterLineNumber + Width = 17 + MouseActions = <> + MarkupInfo.Background = clBtnFace + MarkupInfo.Foreground = clNone + DigitCount = 2 + ShowOnlyLineNumbersMultiplesOf = 1 + ZeroStart = False + LeadingZeros = False + end + object SynGutterChanges1: TSynGutterChanges + Width = 4 + MouseActions = <> + ModifiedColor = 59900 + SavedColor = clGreen + end + object SynGutterSeparator1: TSynGutterSeparator + Width = 2 + MouseActions = <> + MarkupInfo.Background = clWhite + MarkupInfo.Foreground = clGray + end + object SynGutterCodeFolding1: TSynGutterCodeFolding + MouseActions = <> + MarkupInfo.Background = clNone + MarkupInfo.Foreground = clGray + MouseActionsExpanded = <> + MouseActionsCollapsed = <> + end + end + end + object Splitter1: TSplitter + Left = 322 + Height = 356 + Top = 0 + Width = 5 + OnChangeBounds = Splitter1Moved + end + object lblHTMLTitle: TLabel + AnchorSideLeft.Control = StringsSynEdit + AnchorSideTop.Control = edHTMLTitle + AnchorSideTop.Side = asrCenter + AnchorSideBottom.Side = asrBottom + Left = 329 + Height = 15 + Top = 331 + Width = 56 + BorderSpacing.Bottom = 6 + Caption = 'HTML title' + FocusControl = edHTMLTitle + ParentColor = False + end + object edHTMLTitle: TEdit + AnchorSideLeft.Control = lblHTMLTitle + AnchorSideLeft.Side = asrBottom + AnchorSideBottom.Control = Memo + AnchorSideBottom.Side = asrBottom + Left = 391 + Height = 23 + Top = 327 + Width = 232 + Anchors = [akLeft, akBottom] + BorderSpacing.Left = 6 + OnChange = edHTMLTitleChange + TabOrder = 3 + Text = 'Converted by TJvStringListToHtml' + end + object cbIncludeHeader: TCheckBox + AnchorSideLeft.Control = edHTMLTitle + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = edHTMLTitle + AnchorSideTop.Side = asrCenter + Left = 639 + Height = 19 + Top = 329 + Width = 98 + BorderSpacing.Left = 16 + Caption = 'Include header' + Checked = True + OnChange = cbIncludeHeaderChange + State = cbChecked + TabOrder = 4 + end + end + object pgFormToHTML: TTabSheet + Caption = 'Form to HTML' + ClientHeight = 356 + ClientWidth = 850 + inline FormSynEdit: TSynEdit + AnchorSideLeft.Control = pgFormToHTML + AnchorSideTop.Control = pgFormToHTML + AnchorSideRight.Control = pgFormToHTML + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = Button1 + Left = 6 + Height = 313 + Top = 6 + Width = 838 + BorderSpacing.Around = 6 + Anchors = [akTop, akLeft, akRight, akBottom] + Font.Height = -13 + Font.Name = 'Courier New' + Font.Pitch = fpFixed + Font.Quality = fqAntialiased + ParentColor = False + ParentFont = False + TabOrder = 0 + Gutter.Width = 57 + Gutter.MouseActions = <> + RightGutter.Width = 0 + RightGutter.MouseActions = <> + Highlighter = SynHTMLSyn + Keystrokes = < + item + Command = ecUp + ShortCut = 38 + end + item + Command = ecSelUp + ShortCut = 8230 + end + item + Command = ecScrollUp + ShortCut = 16422 + end + item + Command = ecDown + ShortCut = 40 + end + item + Command = ecSelDown + ShortCut = 8232 + end + item + Command = ecScrollDown + ShortCut = 16424 + end + item + Command = ecLeft + ShortCut = 37 + end + item + Command = ecSelLeft + ShortCut = 8229 + end + item + Command = ecWordLeft + ShortCut = 16421 + end + item + Command = ecSelWordLeft + ShortCut = 24613 + end + item + Command = ecRight + ShortCut = 39 + end + item + Command = ecSelRight + ShortCut = 8231 + end + item + Command = ecWordRight + ShortCut = 16423 + end + item + Command = ecSelWordRight + ShortCut = 24615 + end + item + Command = ecPageDown + ShortCut = 34 + end + item + Command = ecSelPageDown + ShortCut = 8226 + end + item + Command = ecPageBottom + ShortCut = 16418 + end + item + Command = ecSelPageBottom + ShortCut = 24610 + end + item + Command = ecPageUp + ShortCut = 33 + end + item + Command = ecSelPageUp + ShortCut = 8225 + end + item + Command = ecPageTop + ShortCut = 16417 + end + item + Command = ecSelPageTop + ShortCut = 24609 + end + item + Command = ecLineStart + ShortCut = 36 + end + item + Command = ecSelLineStart + ShortCut = 8228 + end + item + Command = ecEditorTop + ShortCut = 16420 + end + item + Command = ecSelEditorTop + ShortCut = 24612 + end + item + Command = ecLineEnd + ShortCut = 35 + end + item + Command = ecSelLineEnd + ShortCut = 8227 + end + item + Command = ecEditorBottom + ShortCut = 16419 + end + item + Command = ecSelEditorBottom + ShortCut = 24611 + end + item + Command = ecToggleMode + ShortCut = 45 + end + item + Command = ecCopy + ShortCut = 16429 + end + item + Command = ecPaste + ShortCut = 8237 + end + item + Command = ecDeleteChar + ShortCut = 46 + end + item + Command = ecCut + ShortCut = 8238 + end + item + Command = ecDeleteLastChar + ShortCut = 8 + end + item + Command = ecDeleteLastChar + ShortCut = 8200 + end + item + Command = ecDeleteLastWord + ShortCut = 16392 + end + item + Command = ecUndo + ShortCut = 32776 + end + item + Command = ecRedo + ShortCut = 40968 + end + item + Command = ecLineBreak + ShortCut = 13 + end + item + Command = ecSelectAll + ShortCut = 16449 + end + item + Command = ecCopy + ShortCut = 16451 + end + item + Command = ecBlockIndent + ShortCut = 24649 + end + item + Command = ecLineBreak + ShortCut = 16461 + end + item + Command = ecInsertLine + ShortCut = 16462 + end + item + Command = ecDeleteWord + ShortCut = 16468 + end + item + Command = ecBlockUnindent + ShortCut = 24661 + end + item + Command = ecPaste + ShortCut = 16470 + end + item + Command = ecCut + ShortCut = 16472 + end + item + Command = ecDeleteLine + ShortCut = 16473 + end + item + Command = ecDeleteEOL + ShortCut = 24665 + end + item + Command = ecUndo + ShortCut = 16474 + end + item + Command = ecRedo + ShortCut = 24666 + end + item + Command = ecGotoMarker0 + ShortCut = 16432 + end + item + Command = ecGotoMarker1 + ShortCut = 16433 + end + item + Command = ecGotoMarker2 + ShortCut = 16434 + end + item + Command = ecGotoMarker3 + ShortCut = 16435 + end + item + Command = ecGotoMarker4 + ShortCut = 16436 + end + item + Command = ecGotoMarker5 + ShortCut = 16437 + end + item + Command = ecGotoMarker6 + ShortCut = 16438 + end + item + Command = ecGotoMarker7 + ShortCut = 16439 + end + item + Command = ecGotoMarker8 + ShortCut = 16440 + end + item + Command = ecGotoMarker9 + ShortCut = 16441 + end + item + Command = ecSetMarker0 + ShortCut = 24624 + end + item + Command = ecSetMarker1 + ShortCut = 24625 + end + item + Command = ecSetMarker2 + ShortCut = 24626 + end + item + Command = ecSetMarker3 + ShortCut = 24627 + end + item + Command = ecSetMarker4 + ShortCut = 24628 + end + item + Command = ecSetMarker5 + ShortCut = 24629 + end + item + Command = ecSetMarker6 + ShortCut = 24630 + end + item + Command = ecSetMarker7 + ShortCut = 24631 + end + item + Command = ecSetMarker8 + ShortCut = 24632 + end + item + Command = ecSetMarker9 + ShortCut = 24633 + end + item + Command = EcFoldLevel1 + ShortCut = 41009 + end + item + Command = EcFoldLevel2 + ShortCut = 41010 + end + item + Command = EcFoldLevel3 + ShortCut = 41011 + end + item + Command = EcFoldLevel4 + ShortCut = 41012 + end + item + Command = EcFoldLevel5 + ShortCut = 41013 + end + item + Command = EcFoldLevel6 + ShortCut = 41014 + end + item + Command = EcFoldLevel7 + ShortCut = 41015 + end + item + Command = EcFoldLevel8 + ShortCut = 41016 + end + item + Command = EcFoldLevel9 + ShortCut = 41017 + end + item + Command = EcFoldLevel0 + ShortCut = 41008 + end + item + Command = EcFoldCurrent + ShortCut = 41005 + end + item + Command = EcUnFoldCurrent + ShortCut = 41003 + end + item + Command = EcToggleMarkupWord + ShortCut = 32845 + end + item + Command = ecNormalSelect + ShortCut = 24654 + end + item + Command = ecColumnSelect + ShortCut = 24643 + end + item + Command = ecLineSelect + ShortCut = 24652 + end + item + Command = ecTab + ShortCut = 9 + end + item + Command = ecShiftTab + ShortCut = 8201 + end + item + Command = ecMatchBracket + ShortCut = 24642 + end + item + Command = ecColSelUp + ShortCut = 40998 + end + item + Command = ecColSelDown + ShortCut = 41000 + end + item + Command = ecColSelLeft + ShortCut = 40997 + end + item + Command = ecColSelRight + ShortCut = 40999 + end + item + Command = ecColSelPageDown + ShortCut = 40994 + end + item + Command = ecColSelPageBottom + ShortCut = 57378 + end + item + Command = ecColSelPageUp + ShortCut = 40993 + end + item + Command = ecColSelPageTop + ShortCut = 57377 + end + item + Command = ecColSelLineStart + ShortCut = 40996 + end + item + Command = ecColSelLineEnd + ShortCut = 40995 + end + item + Command = ecColSelEditorTop + ShortCut = 57380 + end + item + Command = ecColSelEditorBottom + ShortCut = 57379 + end> + MouseActions = <> + MouseTextActions = <> + MouseSelActions = <> + VisibleSpecialChars = [vscSpace, vscTabAtLast] + SelectedColor.BackPriority = 50 + SelectedColor.ForePriority = 50 + SelectedColor.FramePriority = 50 + SelectedColor.BoldPriority = 50 + SelectedColor.ItalicPriority = 50 + SelectedColor.UnderlinePriority = 50 + SelectedColor.StrikeOutPriority = 50 + BracketHighlightStyle = sbhsBoth + BracketMatchColor.Background = clNone + BracketMatchColor.Foreground = clNone + BracketMatchColor.Style = [fsBold] + FoldedCodeColor.Background = clNone + FoldedCodeColor.Foreground = clGray + FoldedCodeColor.FrameColor = clGray + MouseLinkColor.Background = clNone + MouseLinkColor.Foreground = clBlue + LineHighlightColor.Background = clNone + LineHighlightColor.Foreground = clNone + inline SynLeftGutterPartList1: TSynGutterPartList + object SynGutterMarks1: TSynGutterMarks + Width = 24 + MouseActions = <> + end + object SynGutterLineNumber1: TSynGutterLineNumber + Width = 17 + MouseActions = <> + MarkupInfo.Background = clBtnFace + MarkupInfo.Foreground = clNone + DigitCount = 2 + ShowOnlyLineNumbersMultiplesOf = 1 + ZeroStart = False + LeadingZeros = False + end + object SynGutterChanges1: TSynGutterChanges + Width = 4 + MouseActions = <> + ModifiedColor = 59900 + SavedColor = clGreen + end + object SynGutterSeparator1: TSynGutterSeparator + Width = 2 + MouseActions = <> + MarkupInfo.Background = clWhite + MarkupInfo.Foreground = clGray + end + object SynGutterCodeFolding1: TSynGutterCodeFolding + MouseActions = <> + MarkupInfo.Background = clNone + MarkupInfo.Foreground = clGray + MouseActionsExpanded = <> + MouseActionsCollapsed = <> + end + end + end + object Button1: TButton + AnchorSideLeft.Control = pgFormToHTML + AnchorSideBottom.Control = pgFormToHTML + AnchorSideBottom.Side = asrBottom + Left = 6 + Height = 25 + Top = 325 + Width = 143 + Anchors = [akLeft, akBottom] + AutoSize = True + BorderSpacing.Left = 6 + BorderSpacing.Bottom = 6 + Caption = 'Show form and HTML' + OnClick = Button1Click + TabOrder = 1 + end + end + end + object SynHTMLSyn: TSynHTMLSyn + DefaultFilter = 'HTML Document (*.htm,*.html)|*.htm;*.html' + Enabled = False + left = 712 + top = 80 + end + object JvFormToHtml1: TJvFormToHtml + left = 624 + top = 80 + end + object JvStringListToHtml1: TJvStringListToHtml + HTMLLineBreak = '<BR />' + HTMLTitle = 'Converted by TJvStringListToHtml' + left = 624 + top = 146 + end +end diff --git a/components/jvcllaz/examples/JvHTML/htmltestform.pas b/components/jvcllaz/examples/JvHTML/htmltestform.pas new file mode 100644 index 000000000..590f940d1 --- /dev/null +++ b/components/jvcllaz/examples/JvHTML/htmltestform.pas @@ -0,0 +1,111 @@ +unit HTMLTestForm; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls, + ExtCtrls, SynEdit, SynHighlighterHTML, JvStringListToHtml, JvStrToHtml, + JvFormToHtml; + +type + + { TMainForm } + + TMainForm = class(TForm) + Button1: TButton; + cbIncludeHeader: TCheckBox; + edHTMLTitle: TEdit; + edTextOut: TEdit; + edTextIn: TEdit; + edHTML: TEdit; + JvFormToHtml1: TJvFormToHtml; + JvStringListToHtml1: TJvStringListToHtml; + lblHTMLTitle: TLabel; + lblTextIn: TLabel; + lblTextAsHTML: TLabel; + lblTextOut: TLabel; + Memo: TMemo; + PageControl: TPageControl; + Splitter1: TSplitter; + FormSynEdit: TSynEdit; + StringsSynEdit: TSynEdit; + SynHTMLSyn: TSynHTMLSyn; + pgFormToHTML: TTabSheet; + pgStringToHTML: TTabSheet; + pgStringsToHTML: TTabSheet; + procedure Button1Click(Sender: TObject); + procedure cbIncludeHeaderChange(Sender: TObject); + procedure edHTMLTitleChange(Sender: TObject); + procedure edTextInChange(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure MemoChange(Sender: TObject); + procedure Splitter1Moved(Sender: TObject); + private + + public + + end; + +var + MainForm: TMainForm; + +implementation + +{$R *.lfm} + +uses + DemoForm; + +{ TMainForm } + +procedure TMainForm.Button1Click(Sender: TObject); +var + F: TForm2; +begin + F := TForm2.Create(nil); + try + JvFormToHtml1.FormToHtml(F, FormSynEdit.Lines); + F.ShowModal; + finally + F.Free; + end; +end; + +procedure TMainForm.cbIncludeHeaderChange(Sender: TObject); +begin + JvStringListToHTML1.IncludeHeader := cbIncludeHeader.Checked; + MemoChange(nil); +end; + +procedure TMainForm.edHTMLTitleChange(Sender: TObject); +begin + MemoChange(nil); +end; + +procedure TMainForm.edTextInChange(Sender: TObject); +begin + edHTML.Text := StringToHTML(edTextIn.Text); + edTextOut.Text := HTMLToString(edHTML.Text); +end; + +procedure TMainForm.FormShow(Sender: TObject); +begin + edTextInChange(nil); + MemoChange(nil); +end; + +procedure TMainForm.MemoChange(Sender: TObject); +begin + StringsSynEdit.Lines.Clear; + JvStringListToHTML1.ConvertToHTMLStrings(Memo.Lines, StringsSynEdit.Lines); +end; + +procedure TMainForm.Splitter1Moved(Sender: TObject); +begin + MemoChange(nil); +end; + +end. + diff --git a/components/jvcllaz/run/JvNet/jvformtohtml.pas b/components/jvcllaz/run/JvNet/jvformtohtml.pas index 440bf75f1..d66e1e21a 100644 --- a/components/jvcllaz/run/JvNet/jvformtohtml.pas +++ b/components/jvcllaz/run/JvNet/jvformtohtml.pas @@ -37,6 +37,7 @@ type TJvFormToHtml = class(TComponent) //TJvComponent) public procedure FormToHtml(const Form: TCustomForm; const Filename: string); + procedure FormToHtml(const Form: TCustomForm; HTML: TStrings); end; @@ -54,206 +55,215 @@ end; procedure TJvFormToHtml.FormToHtml(const Form: TCustomForm; const Filename: string); var - I, J: Integer; - C: TComponent; - S, S2, St: string; HTML: TStringList; begin HTML := TStringList.Create; try - HTML.Add('<HTML><BODY>'); - for I := 0 to Form.ComponentCount - 1 do - begin - C := Form.Components[I]; - St := ''; - if C is TLabel then - begin - St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TLabel(C).Left, TLabel(C).Top, TLabel(C).Height, TLabel(C).Width]) + - FontToCss((C as TLabel).Font) + '"' + - ' TITLE="' + (C as TLabel).Hint + '"' + - ' NAME=' + (C as TLabel).Name + - '>' + - TLabel(C).Caption + '</LABEL>'; - end - else - if C is TButton then - begin - if not TButton(C).Enabled then - S := ' DISABLED' - else - S := ''; - - St := Format('<BUTTON style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TButton(C).Left, TButton(C).Top, TButton(C).Height, TButton(C).Width]) + - FontToCss(TButton(C).Font) + '"' + - ' TITLE="' + TButton(C).Hint + '"' + - ' TABORDER=' + IntToStr(TButton(C).TabOrder) + - ' NAME=' + TButton(C).Name + - S + - '>' + - TButton(C).Caption + '</BUTTON>'; - end - else - if C is TMemo then - begin - S := ''; - if TMemo(C).ReadOnly then - S := S + ' ReadOnly'; - if not TMemo(C).Enabled then - S := S + ' DISABLED'; - - S2 := ''; - if TMemo(C).WordWrap then - S2 := S2 + ' WRAP=PHYSICAL' - else - S2 := S2 + ' WRAP=OFF'; - - St := Format('<TEXTAREA style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TMemo(C).Left, TMemo(C).Top, TMemo(C).Height, TMemo(C).Width]) + - FontToCss(TMemo(C).Font) + '"' + - ' TITLE="' + TMemo(C).Hint + '"' + - S + - ' NAME=' + TMemo(C).Name + - ' TABORDER=' + IntToStr(TMemo(C).TabOrder) + - S2 + - '>' + - TMemo(C).Text + '</TEXTAREA>'; - end - else - if C is TCheckBox then - begin - S := ''; - if not TCheckBox(C).Enabled then - S := S + ' DISABLED'; - if TCheckBox(C).Checked then - S := S + ' CHECKED'; - - St := Format('<INPUT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TCheckBox(C).Left, TCheckBox(C).Top, TCheckBox(C).Height, 10]) + - FontToCss(TCheckBox(C).Font) + '"' + - ' TITLE="' + TCheckBox(C).Hint + '"' + - S + - ' TABORDER=' + IntToStr(TCheckBox(C).TabOrder) + - ' NAME=' + TCheckBox(C).Name + - ' TYPE="CHECKBOX">'; - HTML.Add(St); - St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TCheckBox(C).Left + 13, TCheckBox(C).Top, TCheckBox(C).Height, TCheckBox(C).Width]) + - FontToCss(TCheckBox(C).Font) + '"' + - ' TITLE="' + TCheckBox(C).Hint + '"' + - '>' + - TCheckBox(C).Caption + '</LABEL>'; - end - else - if C is TRadioButton then - begin - S := ''; - if not TRadioButton(C).Enabled then - S := S + ' DISABLED'; - if TRadioButton(C).Checked then - S := S + ' CHECKED'; - - St := Format('<INPUT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TRadioButton(C).Left, TRadioButton(C).Top, TRadioButton(C).Height, 10]) + - FontToCss(TRadioButton(C).Font) + '"' + - ' TITLE="' + TRadioButton(C).Hint + '"' + - S + - ' NAME=' + TRadioButton(C).Parent.Name + - ' TABORDER=' + IntToStr(TRadioButton(C).TabOrder) + - ' TYPE="RADIO">'; - HTML.Add(St); - St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TRadioButton(C).Left + 13, TRadioButton(C).Top, - TRadioButton(C).Height, TRadioButton(C).Width]) + - FontToCss(TRadioButton(C).Font) + '"' + - ' TITLE="' + TRadioButton(C).Hint + '"' + - '>' + - TRadioButton(C).Caption + '</LABEL>'; - end - else - if C is TEdit then - begin - S := ''; - if TEdit(C).ReadOnly then - S := S + ' ReadOnly'; - if TEdit(C).MaxLength <> 0 then - S := S + ' MAXLENGTH=' + IntToStr(TEdit(C).MaxLength); - if not TEdit(C).Enabled then - S := S + ' DISABLED'; - - St := Format('<INPUT TYPE="TEXT" style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TEdit(C).Left, TEdit(C).Top, TEdit(C).Height, TEdit(C).Width]) + - FontToCss(TEdit(C).Font) + '"' + - ' TITLE="' + TEdit(C).Hint + '"' + - ' TABORDER=' + IntToStr(TEdit(C).TabOrder) + - ' NAME=' + TEdit(C).Name + - S + - ' Value=' + TEdit(C).Text + - '>'; - end - else - if C is TComboBox then - begin - if not TComboBox(C).Enabled then - S := ' DISABLED' - else - S := ''; - - St := Format('<SELECT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TComboBox(C).Left, TComboBox(C).Top, TComboBox(C).Height, TComboBox(C).Width]) + - FontToCss(TComboBox(C).Font) + '"' + - ' TITLE="' + TComboBox(C).Hint + '"' + - ' TABORDER=' + IntToStr(TComboBox(C).TabOrder) + - ' NAME=' + TComboBox(C).Name + - S + - '>'; - HTML.Add(St); - for J := 0 to TComboBox(C).Items.Count - 1 do - begin - if TComboBox(C).ItemIndex = J then - HTML.Add('<OPTION SELECTED>' + TComboBox(C).Items[J]) - else - HTML.Add('<OPTION>' + TComboBox(C).Items[J]); - end; - St := '</SELECT>'; - end - else - if C is TListBox then - begin - if not TListBox(C).Enabled then - S := ' DISABLED' - else - S := ''; - - St := Format('<SELECT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', - [TListBox(C).Left, TListBox(C).Top, TListBox(C).Height, TListBox(C).Width]) + - FontToCss(TListBox(C).Font) + '"' + - ' MULTIPLE TITLE="' + TListBox(C).Hint + '"' + - ' TABORDER=' + IntToStr(TListBox(C).TabOrder) + - ' NAME=' + TListBox(C).Name + - S + - '>'; - HTML.Add(St); - for J := 0 to TListBox(C).Items.Count - 1 do - begin - if TListBox(C).ItemIndex = J then - HTML.Add('<OPTION SELECTED>' + TListBox(C).Items[J]) - else - HTML.Add('<OPTION>' + TListBox(C).Items[J]); - end; - St := '</SELECT>'; - end; - - if St <> '' then - HTML.Add(St); - end; - HTML.Add('</BODY></HTML>'); - - HTML.SaveToFile(Filename); + FormToHTML(Form, HTML); + HTML.SaveToFile(FileName); finally HTML.Free; end; end; +procedure TJvFormToHtml.FormToHtml(const Form: TCustomForm; + HTML: TStrings); +var + I, J: Integer; + C: TComponent; + S, S2, St: string; +begin + if HTML = nil then + exit; + + HTML.Add('<HTML><BODY>'); + for I := 0 to Form.ComponentCount - 1 do + begin + C := Form.Components[I]; + St := ''; + if C is TLabel then + begin + St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TLabel(C).Left, TLabel(C).Top, TLabel(C).Height, TLabel(C).Width]) + + FontToCss((C as TLabel).Font) + '"' + + ' TITLE="' + (C as TLabel).Hint + '"' + + ' NAME=' + (C as TLabel).Name + + '>' + + TLabel(C).Caption + '</LABEL>'; + end + else + if C is TButton then + begin + if not TButton(C).Enabled then + S := ' DISABLED' + else + S := ''; + + St := Format('<BUTTON style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TButton(C).Left, TButton(C).Top, TButton(C).Height, TButton(C).Width]) + + FontToCss(TButton(C).Font) + '"' + + ' TITLE="' + TButton(C).Hint + '"' + + ' TABORDER=' + IntToStr(TButton(C).TabOrder) + + ' NAME=' + TButton(C).Name + + S + + '>' + + TButton(C).Caption + '</BUTTON>'; + end + else + if C is TMemo then + begin + S := ''; + if TMemo(C).ReadOnly then + S := S + ' ReadOnly'; + if not TMemo(C).Enabled then + S := S + ' DISABLED'; + + S2 := ''; + if TMemo(C).WordWrap then + S2 := S2 + ' WRAP=PHYSICAL' + else + S2 := S2 + ' WRAP=OFF'; + + St := Format('<TEXTAREA style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TMemo(C).Left, TMemo(C).Top, TMemo(C).Height, TMemo(C).Width]) + + FontToCss(TMemo(C).Font) + '"' + + ' TITLE="' + TMemo(C).Hint + '"' + + S + + ' NAME=' + TMemo(C).Name + + ' TABORDER=' + IntToStr(TMemo(C).TabOrder) + + S2 + + '>' + + TMemo(C).Text + '</TEXTAREA>'; + end + else + if C is TCheckBox then + begin + S := ''; + if not TCheckBox(C).Enabled then + S := S + ' DISABLED'; + if TCheckBox(C).Checked then + S := S + ' CHECKED'; + + St := Format('<INPUT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TCheckBox(C).Left, TCheckBox(C).Top, TCheckBox(C).Height, 10]) + + FontToCss(TCheckBox(C).Font) + '"' + + ' TITLE="' + TCheckBox(C).Hint + '"' + + S + + ' TABORDER=' + IntToStr(TCheckBox(C).TabOrder) + + ' NAME=' + TCheckBox(C).Name + + ' TYPE="CHECKBOX">'; + HTML.Add(St); + St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TCheckBox(C).Left + 13, TCheckBox(C).Top, TCheckBox(C).Height, TCheckBox(C).Width]) + + FontToCss(TCheckBox(C).Font) + '"' + + ' TITLE="' + TCheckBox(C).Hint + '"' + + '>' + + TCheckBox(C).Caption + '</LABEL>'; + end + else + if C is TRadioButton then + begin + S := ''; + if not TRadioButton(C).Enabled then + S := S + ' DISABLED'; + if TRadioButton(C).Checked then + S := S + ' CHECKED'; + + St := Format('<INPUT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TRadioButton(C).Left, TRadioButton(C).Top, TRadioButton(C).Height, 10]) + + FontToCss(TRadioButton(C).Font) + '"' + + ' TITLE="' + TRadioButton(C).Hint + '"' + + S + + ' NAME=' + TRadioButton(C).Parent.Name + + ' TABORDER=' + IntToStr(TRadioButton(C).TabOrder) + + ' TYPE="RADIO">'; + HTML.Add(St); + St := Format('<LABEL style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TRadioButton(C).Left + 13, TRadioButton(C).Top, + TRadioButton(C).Height, TRadioButton(C).Width]) + + FontToCss(TRadioButton(C).Font) + '"' + + ' TITLE="' + TRadioButton(C).Hint + '"' + + '>' + + TRadioButton(C).Caption + '</LABEL>'; + end + else + if C is TEdit then + begin + S := ''; + if TEdit(C).ReadOnly then + S := S + ' ReadOnly'; + if TEdit(C).MaxLength <> 0 then + S := S + ' MAXLENGTH=' + IntToStr(TEdit(C).MaxLength); + if not TEdit(C).Enabled then + S := S + ' DISABLED'; + + St := Format('<INPUT TYPE="TEXT" style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TEdit(C).Left, TEdit(C).Top, TEdit(C).Height, TEdit(C).Width]) + + FontToCss(TEdit(C).Font) + '"' + + ' TITLE="' + TEdit(C).Hint + '"' + + ' TABORDER=' + IntToStr(TEdit(C).TabOrder) + + ' NAME=' + TEdit(C).Name + + S + + ' Value=' + TEdit(C).Text + + '>'; + end + else + if C is TComboBox then + begin + if not TComboBox(C).Enabled then + S := ' DISABLED' + else + S := ''; + + St := Format('<SELECT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TComboBox(C).Left, TComboBox(C).Top, TComboBox(C).Height, TComboBox(C).Width]) + + FontToCss(TComboBox(C).Font) + '"' + + ' TITLE="' + TComboBox(C).Hint + '"' + + ' TABORDER=' + IntToStr(TComboBox(C).TabOrder) + + ' NAME=' + TComboBox(C).Name + + S + + '>'; + HTML.Add(St); + for J := 0 to TComboBox(C).Items.Count - 1 do + begin + if TComboBox(C).ItemIndex = J then + HTML.Add('<OPTION SELECTED>' + TComboBox(C).Items[J]) + else + HTML.Add('<OPTION>' + TComboBox(C).Items[J]); + end; + St := '</SELECT>'; + end + else + if C is TListBox then + begin + if not TListBox(C).Enabled then + S := ' DISABLED' + else + S := ''; + + St := Format('<SELECT style="position:absolute;Left:%d;Top:%d;Height:%d;Width:%d', + [TListBox(C).Left, TListBox(C).Top, TListBox(C).Height, TListBox(C).Width]) + + FontToCss(TListBox(C).Font) + '"' + + ' MULTIPLE TITLE="' + TListBox(C).Hint + '"' + + ' TABORDER=' + IntToStr(TListBox(C).TabOrder) + + ' NAME=' + TListBox(C).Name + + S + + '>'; + HTML.Add(St); + for J := 0 to TListBox(C).Items.Count - 1 do + begin + if TListBox(C).ItemIndex = J then + HTML.Add('<OPTION SELECTED>' + TListBox(C).Items[J]) + else + HTML.Add('<OPTION>' + TListBox(C).Items[J]); + end; + St := '</SELECT>'; + end; + + if St <> '' then + HTML.Add(St); + end; + HTML.Add('</BODY></HTML>'); +end; + end. diff --git a/components/jvcllaz/run/JvNet/jvstringlisttohtml.pas b/components/jvcllaz/run/JvNet/jvstringlisttohtml.pas index 6bec869d8..4e2e9afd6 100644 --- a/components/jvcllaz/run/JvNet/jvstringlisttohtml.pas +++ b/components/jvcllaz/run/JvNet/jvstringlisttohtml.pas @@ -130,12 +130,13 @@ end; procedure TJvStringListToHtml.DoStringsChange(Sender: TObject); begin - FreeAndNil(FHTML); + FHTML.Clear; // wp: clear instead of Free +// FreeAndNil(FHTML); end; function TJvStringListToHtml.GetHTML: TStrings; begin - if ComponentState * [csLoading, csDestroying] <> [] then +// if ComponentState * [csLoading, csDestroying] <> [] then // wp: removed if FHTML.Count = 0 then ConvertToHTMLStrings(Strings, FHTML); Result := FHTML; diff --git a/components/jvcllaz/run/JvNet/jvstrtohtml.pas b/components/jvcllaz/run/JvNet/jvstrtohtml.pas index c532c2bd6..884468372 100644 --- a/components/jvcllaz/run/JvNet/jvstrtohtml.pas +++ b/components/jvcllaz/run/JvNet/jvstrtohtml.pas @@ -320,12 +320,8 @@ const var ConversionsHash: array of Word; -{$IFNDEF UNICODE} -const - MB_ERR_INVALID_CHARS = 8; -{$ENDIF ~UNICODE} -{ TJvStrToHtml } + { TJvStrToHtml } constructor TJvStrToHtml.Create(AOwner: TComponent); begin @@ -478,6 +474,7 @@ begin if not found then begin Delete(html, Length(html), 1); Delete(html, 1, 1); + if html[1] = '#' then Delete(html, 1, 1); if html[1] = 'x' then html[1] := '$'; Append(UnicodeToUTF8(StrToInt(html))); end;