From 0aeeaa5dc2981481af3fe1bef3c72a70b7097b13 Mon Sep 17 00:00:00 2001 From: jesus Date: Fri, 18 May 2012 17:20:40 +0000 Subject: [PATCH] LazReport, lrcodereport: version is 1.0, updated icon, cleanup, first page is now programmers responsability, sample update to export to pdf, from Julio Jimenez Borreguero git-svn-id: trunk@37321 - --- .../addons/lrcodereport/lr_codereport.lrs | 35 ++++++++---------- .../addons/lrcodereport/lr_codereport.pas | 12 +----- .../addons/lrcodereport/lr_codereport_pkg.lpk | 1 + .../addons/lrcodereport/sample/main.lfm | 16 ++++++-- .../addons/lrcodereport/sample/main.pas | 24 +++++++++++- .../addons/lrcodereport/tlrcodereport.png | Bin 520 -> 436 bytes 6 files changed, 55 insertions(+), 33 deletions(-) diff --git a/components/lazreport/source/addons/lrcodereport/lr_codereport.lrs b/components/lazreport/source/addons/lrcodereport/lr_codereport.lrs index c76e40c9bf..52cdb1ac0d 100644 --- a/components/lazreport/source/addons/lrcodereport/lr_codereport.lrs +++ b/components/lazreport/source/addons/lrcodereport/lr_codereport.lrs @@ -1,22 +1,19 @@ LazarusResources.Add('tlrcodereport','PNG',[ #137'PNG'#13#10#26#10#0#0#0#13'IHDR'#0#0#0#24#0#0#0#24#8#6#0#0#0#224'w='#248#0 - +#0#0#1'sRGB'#0#174#206#28#233#0#0#0#6'bKGD'#0#255#0#255#0#255#160#189#167#147 - +#0#0#0#9'pHYs'#0#0#11#19#0#0#11#19#1#0#154#156#24#0#0#0#7'tIME'#7#220#5#17#19 - +#2#19'!'#133#247#11#0#0#1#136'IDATH'#199#221'U1k'#194'`'#16'}'#9'N'#197'E' - +#167'"8'#20'3'#137' '#168'T'#2']#'#14'bG'#23#145'RHJ7'#23#193#138#147#160'E' - +#220#11#173'HK'#23'G'#17#28'B'#226#230' '#14'*'#221'E'#128#187'8y'#29'bClM' - +#19'5K'#251#224#131#11#247'%'#239'{'#247#189#187#0''#29#140#241'A'#18'E:' - +#245#131'/'#205'&c'#154#148'D'#145'l'#163#213'"'#242'x'#180#24' ""I'#20'i4' - +#28#238#28#210#181#143'('#153'HX'#158#244'm0'#192#249'z'#13#16'a'#3#128'5' - +#217#183#151'@V'#20#235'ZD'#163#192'd'#2't'#187'`y'#222't'#219#209#10'bD'#184 - +'u'#187#177#201#229#240#202'q'#168':'#174#192#128#234'/9'#215#225#190'31'#9 - +#145'}'#130#179'xI'#143'W'#163#154'^2YQ'#144#20#4'-VU'#214#171#183'X'#160'R'#160#0#0#0#0'IEND'#174'B`'#130 ]); diff --git a/components/lazreport/source/addons/lrcodereport/lr_codereport.pas b/components/lazreport/source/addons/lrcodereport/lr_codereport.pas index 4383be1d45..91e5821cb5 100644 --- a/components/lazreport/source/addons/lrcodereport/lr_codereport.pas +++ b/components/lazreport/source/addons/lrcodereport/lr_codereport.pas @@ -70,7 +70,6 @@ type FrameColor: TColor; BorderLines: TfrFrameBorders; FrameWidth: double; - CodeFormat: string; end; { TlrCodeReport } @@ -81,7 +80,6 @@ type XRatio, YRatio: double; PaperSize, PaperWidth, PaperHeight: integer; PaperOrientation: TPrinterOrientation; - //PaperSize: TPaperSize FReport, FOwnedReport: TfrReport; ABitMap: TBitMap; SavedLineStyle: TlrLineStyle; @@ -123,7 +121,6 @@ type function GetPageHeightMM: double; function GetActivePage: integer; - {* Styles *} procedure ResetLineStyle; procedure ResetTextRectStyle; @@ -182,6 +179,7 @@ type {* Drawring BarCode *} procedure DrawBarCode(X, Y, W, H: double; Code: string; Style: TlrBarCodeStyle); + published property OnBeginReport: TNotifyEvent read FOnBeginReport write FOnBeginReport; property Report: TfrReport read GetReport write SetReport; @@ -226,7 +224,7 @@ begin PageMargin.Top := 0; ABitMap := TBitMap.Create; // for canvas stuff // Set default paper - PaperSize := 9; // A4 check LR_Prntr for a list + PaperSize := 9; // A4 check LR_Prntr unit for a list PaperWidth := 0; PaperHeight := 0; PaperOrientation := poPortrait; @@ -260,7 +258,6 @@ end; procedure TlrCodeReport.RunReport; begin - NewPage; // Create the first page if Assigned(OnBeginReport) then OnBeginReport(Self); Report.ShowReport; @@ -475,7 +472,6 @@ begin Result.FrameColor := clBlack; Result.BorderLines := []; Result.FrameWidth := 1; - Result.CodeFormat := 'BARCODE'; end; function TlrCodeReport.PageCount: integer; @@ -555,7 +551,6 @@ procedure TlrCodeReport.DrawText(X, Y, W, H: double; Text: string; Style: TlrTextRectStyle); var AText: TfrMemoview; - ARect: TRect; begin AText := TfrMemoView.Create; AText.CreateUniqueName; @@ -586,8 +581,6 @@ begin AText.Memo.Add(Text); AText.CalcGaps; - ARect := AText.DRect; - //AText.Font.Name:= Style.FontName; Report.Pages[ActivePage].Objects.Add(AText); // Update Cursor Cursor.YTop := AText.Top / YRatio; // adjust to ratio used @@ -780,7 +773,6 @@ begin ABarCode.FrameColor := Style.FrameColor; ABarCode.Frames := Style.BorderLines; ABarCode.FrameWidth := Style.FrameWidth; - ABarCode.FormatStr := Style.CodeFormat; Report.Pages[ActivePage].Objects.Add(ABarCode); end; diff --git a/components/lazreport/source/addons/lrcodereport/lr_codereport_pkg.lpk b/components/lazreport/source/addons/lrcodereport/lr_codereport_pkg.lpk index d435004b8a..9e5aa64320 100644 --- a/components/lazreport/source/addons/lrcodereport/lr_codereport_pkg.lpk +++ b/components/lazreport/source/addons/lrcodereport/lr_codereport_pkg.lpk @@ -14,6 +14,7 @@ + diff --git a/components/lazreport/source/addons/lrcodereport/sample/main.lfm b/components/lazreport/source/addons/lrcodereport/sample/main.lfm index 08ff5ff426..712e3d6ecc 100644 --- a/components/lazreport/source/addons/lrcodereport/sample/main.lfm +++ b/components/lazreport/source/addons/lrcodereport/sample/main.lfm @@ -1,15 +1,15 @@ object Form1: TForm1 Left = 296 - Height = 358 + Height = 397 Top = 163 Width = 458 Caption = 'Form1' - ClientHeight = 358 + ClientHeight = 397 ClientWidth = 458 LCLVersion = '1.1' object Image1: TImage Left = 8 - Height = 301 + Height = 300 Top = 8 Width = 443 Anchors = [akTop, akLeft, akRight, akBottom] @@ -2901,6 +2901,16 @@ object Form1: TForm1 OnClick = Button1Click TabOrder = 0 end + object Button2: TButton + Left = 8 + Height = 25 + Top = 360 + Width = 443 + Anchors = [akLeft, akRight, akBottom] + Caption = 'Export to PDF' + OnClick = Button2Click + TabOrder = 1 + end object frTNPDFExport1: TfrTNPDFExport left = 184 top = 152 diff --git a/components/lazreport/source/addons/lrcodereport/sample/main.pas b/components/lazreport/source/addons/lrcodereport/sample/main.pas index 957e05eeca..d33d1bcf7e 100644 --- a/components/lazreport/source/addons/lrcodereport/sample/main.pas +++ b/components/lazreport/source/addons/lrcodereport/sample/main.pas @@ -14,12 +14,14 @@ type TForm1 = class(TForm) Button1: TButton; + Button2: TButton; frBarCodeObject1: TfrBarCodeObject; frShapeObject1: TfrShapeObject; frTNPDFExport1: TfrTNPDFExport; Image1: TImage; Report: TlrCodeReport; procedure Button1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); procedure ReportBeginReport(Sender: TObject); private { private declarations } @@ -38,7 +40,23 @@ implementation procedure TForm1.Button1Click(Sender: TObject); begin - report.RunReport; + //report.RunReport; + if Report.PageCount = 0 then + begin + ReportBeginReport(report); + end; + Report.Report.ShowReport; +end; + +procedure TForm1.Button2Click(Sender: TObject); +begin + //direct export to PDF. Set the desired destination file. + if Report.PageCount = 0 then + begin + ReportBeginReport(report); + Report.Report.PrepareReport; + end; + Report.Report.ExportTo(TfrTNPDFExportFilter, '/tmp/generated-pdf.pdf'); end; procedure TForm1.ReportBeginReport(Sender: TObject); @@ -51,6 +69,10 @@ begin begin // Set paper... 1=Letter 9=A4.... //SetPaper(1, poLandscape); // try uncomment this line to test another paper size + + // Important. Before drawing, add a page + NewPage; + // Set up a custom style BoxText := GetDefaultTextRectStyle; BoxText.FontName := 'Times'; diff --git a/components/lazreport/source/addons/lrcodereport/tlrcodereport.png b/components/lazreport/source/addons/lrcodereport/tlrcodereport.png index 288e7f296c75d8827bdf2a063448d4e27fd38b7b..e5cbebec4e85f5845cf0e6a3de8de11ef9902242 100644 GIT binary patch delta 362 zcmV-w0hRuU1hfN?Hwh~MKLGztXXr|iKp=k-2`3Jzbi#cA00A^fL_t(Y$E}nxZo*Iu zhW{sJ>OnfOGq7~1BDe$th{x0mbYtNTja1HoGO-{%GO)meI`;^y?vN5idG?D9c#Gxu z_vdHZ`Ne{uw6CIYFk1HiV{hQndsHFN_hti2LD}tNoabWTwk*3pstd}bBz@*w-7SA2 z!qR)OfJWeD_z3{G9@Y^JCr(5vqD<40R2yyrgE!#3t9>j%+cX5-%FjEVrV+Rv)^`!? zF9k-gF-as~nWC5=CW!>BQzX5C_{bc=wk$EubJH7$0#Xvm-`<1XQ_)=%jrApN3Lzp? zA*c_YXXt%J)Tx<2~_8rv+2j<$$x)VvVb&x+`LP^Bmo!PPLlGe zT9l&D`0gS|QMF^(W5-p)CALr|$MjiKH14?fnbw^*Q3pa1{>07*qo IM6N<$g7vDY3;+NC delta 447 zcmV;w0YLt=1Be8WHwpg${{a7>y{D6rKp=k+69N+Pv zNfc=`9PS*_wT~#7NLZfqZ7{(3dJPa^1AsNzx0gUx6zf_f`Zg z3XCPwW4|AdjRwH7KsI|C!H$A$eC2=jB9~4B0Nw)uln)_TjcV2k3@9IZ$!0b+D!5!O zaWk7~O~-MlOsCG+RL_OOK&Jz+EGqfD^9r8kb37M|AOQD^1umRwG(FerpkrV_?5yKqT$+l)uC