View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0037996 | Packages | LazReport | public | 2020-10-27 15:39 | 2021-01-19 21:23 |
Reporter | Stefan Sinne | Assigned To | Jesus Reyes | ||
Priority | normal | Severity | minor | Reproducibility | have not tried |
Status | resolved | Resolution | fixed | ||
Fixed in Version | 2.1 (SVN) | ||||
Summary | 0037996: Package lazreportpdfexport new feature: Create link annotation for TfrMemoView.URLInfo | ||||
Description | With the added patch the exporter will create a link annotation for a TfrMemoView that has a valid URI given in property URLInfo. For this patch to work it is necesarry to first apply the patches of ticket 0037995 for ccr package powerpdf. | ||||
Tags | No tags attached. | ||||
Fixed in Revision | 64408 | ||||
LazTarget | 2.2 | ||||
Widgetset | |||||
Attached Files |
|
related to | 0037995 | resolved | Jesus Reyes | Lazarus CCR | PowerPDF new feature: Link (URI Action) annotations |
|
lr_e_pdf.pas.diff (3,318 bytes)
Index: lr_e_pdf.pas =================================================================== --- lr_e_pdf.pas (revisi�n: 64044) +++ lr_e_pdf.pas (copia de trabajo) @@ -11,6 +11,15 @@ { http://www.base2ti.com/zlib.htm } { } {****************************************************} +{* + * 2020.10.23 added export of annotation links for TfrMemoView.URLInfo. + * (<setfan[at]smartsoftware[dot]com>) + * The URI put into URLInfo must start with a common scheme + * identifier (http://, ftp://, etc.) and must be a valid uri with + * all special characters already escaped. You could use for example + * the functions EncodeURL and EncodeURLElement from the Synapse + * project, unit synacode. + *} unit lr_e_pdf; @@ -72,7 +81,7 @@ implementation -uses lr_Const; +uses lr_Const, PRAnnotation; type TfrMemoView_ = class(TfrMemoView); @@ -485,9 +494,39 @@ View: TfrView); var PRTLabel: TPRLabel; + PRTAnno: TPRAnnotation; nx, ny, ndx, ndy: Integer; gapx, gapy: integer; memo: TfrMemoView; + + // Simple uri check, since TfrMemoView.URLInfo may be used in other projects + // to store other data than an URI. + function IsValidURI(uri: PChar): Boolean; + const + cHTTP: PChar = 'http://'; + cHTTPS: PChar = 'https://'; + cFTP: PChar = 'ftp://'; + cFILE: PChar = 'file://'; + cGOPHER: PChar = 'gopher://'; + cMAILTO: PChar = 'mailto:'; + cNEWS: PChar = 'news:'; + cNNTP: PChar = 'nntp://'; + cTELNET: PChar = 'telnet://'; + cWAIS: PChar = 'wais://'; + cPROSPERO: PChar = 'prospero://'; + begin + result := (strlicomp(uri, cHTTP, strlen(cHTTP)) = 0) or + (strlicomp(uri, cHTTPS, strlen(cHTTPS)) = 0) or + (strlicomp(uri, cFTP, strlen(cFTP)) = 0) or + (strlicomp(uri, cFILE, strlen(cFILE)) = 0) or + (strlicomp(uri, cGOPHER, strlen(cGOPHER)) = 0) or + (strlicomp(uri, cMAILTO, strlen(cMAILTO)) = 0) or + (strlicomp(uri, cNEWS, strlen(cNEWS)) = 0) or + (strlicomp(uri, cNNTP, strlen(cNNTP)) = 0) or + (strlicomp(uri, cTELNET, strlen(cTELNET)) = 0) or + (strlicomp(uri, cWAIS, strlen(cWAIS)) = 0) or + (strlicomp(uri, cPROSPERO, strlen(cPROSPERO)) = 0); + end; begin gapx := trunc(View.FrameWidth / 2 + 0.5) + 2; gapy := trunc(View.FrameWidth / 4 + 0.5) + 1; @@ -522,6 +561,17 @@ PRTLabel.FontUnderline := fsUnderline in memo.Font.Style; PRTLabel.Angle:= memo.Angle; PRTLabel.AlignJustified := memo.Justify and not memo.LastLine; + if IsValidURI(PChar(memo.URLInfo)) then begin + // create link annotation + PRTAnno := TPRAnnotation.Create(PRPanel); + PRTAnno.Parent := PRPanel; + PRTAnno.SubType := asLink; + PRTAnno.Action.URI := memo.URLInfo; + PRTAnno.Left := PRTLabel.Left; + PRTAnno.Top := PRTLabel.Top; + PRTAnno.Width := PRTLabel.Width; + PRTAnno.Height := PRTLabel.Height; + end; end; finally end; |
|
This is a new versión, which supposes that TfrMemoView.URLInfo, if filled, is a valid URI and so will be used for the link annotation. No need to test if the uri is valid, which is quite complicated. The user has to assure the right format. lr_e_pdf.pas-2.diff (1,888 bytes)
Index: lr_e_pdf.pas =================================================================== --- lr_e_pdf.pas (revisi�n: 64044) +++ lr_e_pdf.pas (copia de trabajo) @@ -11,6 +11,14 @@ { http://www.base2ti.com/zlib.htm } { } {****************************************************} +{* + * 2020.10.23 added export of annotation links for TfrMemoView.URLInfo. + * (<setfan[at]smartsoftware[dot]com>) + * The URI put into URLInfo is supposed to be a valid uri + * (http://..., ftp://..., etc.) with all special characters already + * escaped. You could use for example the functions EncodeURL and + * EncodeURLElement from the Synapse project, unit synacode. + *} unit lr_e_pdf; @@ -72,7 +80,7 @@ implementation -uses lr_Const; +uses lr_Const, PRAnnotation; type TfrMemoView_ = class(TfrMemoView); @@ -485,6 +493,7 @@ View: TfrView); var PRTLabel: TPRLabel; + PRTAnno: TPRAnnotation; nx, ny, ndx, ndy: Integer; gapx, gapy: integer; memo: TfrMemoView; @@ -522,6 +531,18 @@ PRTLabel.FontUnderline := fsUnderline in memo.Font.Style; PRTLabel.Angle:= memo.Angle; PRTLabel.AlignJustified := memo.Justify and not memo.LastLine; + // suppose that URLInfo always contains a valid URI + if Trim(memo.URLInfo) <> '' then begin + // create link annotation + PRTAnno := TPRAnnotation.Create(PRPanel); + PRTAnno.Parent := PRPanel; + PRTAnno.SubType := asLink; + PRTAnno.Action.URI := memo.URLInfo; + PRTAnno.Left := PRTLabel.Left; + PRTAnno.Top := PRTLabel.Top; + PRTAnno.Width := PRTLabel.Width; + PRTAnno.Height := PRTLabel.Height; + end; end; finally end; |
|
Applied, thank you. |
Date Modified | Username | Field | Change |
---|---|---|---|
2020-10-27 15:39 | Stefan Sinne | New Issue | |
2020-10-27 15:39 | Stefan Sinne | File Added: lr_e_pdf.pas.diff | |
2020-10-27 15:39 | Stefan Sinne | File Added: test.pdf | |
2020-10-27 16:06 | Marco van de Voort | Relationship added | related to 0037995 |
2020-10-27 22:56 | Jesus Reyes | Assigned To | => Jesus Reyes |
2020-10-27 22:56 | Jesus Reyes | Status | new => assigned |
2020-10-28 17:40 | Stefan Sinne | Note Added: 0126608 | |
2020-10-28 17:40 | Stefan Sinne | File Added: lr_e_pdf.pas-2.diff | |
2021-01-19 21:23 | Jesus Reyes | Status | assigned => resolved |
2021-01-19 21:23 | Jesus Reyes | Resolution | open => fixed |
2021-01-19 21:23 | Jesus Reyes | Fixed in Version | => 2.1 (SVN) |
2021-01-19 21:23 | Jesus Reyes | Fixed in Revision | => 64408 |
2021-01-19 21:23 | Jesus Reyes | LazTarget | => 2.2 |
2021-01-19 21:23 | Jesus Reyes | Note Added: 0128433 |