mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 01:04:50 +01:00 
			
		
		
		
	* Validate report prior to previewing
git-svn-id: trunk@57453 -
This commit is contained in:
		
							parent
							
								
									b84e7d6fa8
								
							
						
					
					
						commit
						79b6dc7b75
					
				| @ -332,6 +332,7 @@ type | |||||||
|     function NewReport: Boolean; virtual; |     function NewReport: Boolean; virtual; | ||||||
|     Function SaveReport : Boolean; virtual; |     Function SaveReport : Boolean; virtual; | ||||||
|     function OpenReport: Boolean; virtual; |     function OpenReport: Boolean; virtual; | ||||||
|  |     function ValidateReport: Boolean; | ||||||
|     procedure DoElementCreated(Sender: TObject; AElement: TFPReportElement); |     procedure DoElementCreated(Sender: TObject; AElement: TFPReportElement); | ||||||
|     Property Report : TFPReport Read FReport Write SetReport; |     Property Report : TFPReport Read FReport Write SetReport; | ||||||
|     Property FileName : String Read FFileName Write FFileName; |     Property FileName : String Read FFileName Write FFileName; | ||||||
| @ -378,6 +379,9 @@ ResourceString | |||||||
|   SErrAccessingDataDetails = 'One or more report data sources failed to open:'+ |   SErrAccessingDataDetails = 'One or more report data sources failed to open:'+ | ||||||
|                              sLineBreak+'%s'+sLineBreak+ |                              sLineBreak+'%s'+sLineBreak+ | ||||||
|                              'You will need to fix these errors before proceeding.'; |                              'You will need to fix these errors before proceeding.'; | ||||||
|  |   SErrInvalidReport = 'Invalid report design'; | ||||||
|  |   SErrFixErrors = 'The report design contains %d errors:'+sLineBreak+'%s'+sLineBreak+ | ||||||
|  |                   'You will need to fix these errors before proceeding.'; | ||||||
| 
 | 
 | ||||||
| Const | Const | ||||||
|   StateNames : Array[TDesignerState] of string = ('','Resetting', |   StateNames : Array[TDesignerState] of string = ('','Resetting', | ||||||
| @ -1036,12 +1040,31 @@ begin | |||||||
|   PreviewReport; |   PreviewReport; | ||||||
| end; | end; | ||||||
| 
 | 
 | ||||||
|  | Function TFPReportDesignerForm.ValidateReport : Boolean; | ||||||
|  | 
 | ||||||
|  | Var | ||||||
|  |   errs : TStrings; | ||||||
|  | 
 | ||||||
|  | begin | ||||||
|  |   errs:=TStringList.Create; | ||||||
|  |   try | ||||||
|  |     Report.Validate(errs); | ||||||
|  |     Result:=Errs.Count=0; | ||||||
|  |     if Not Result then | ||||||
|  |       MessageDlg(SErrInvalidReport,Format(SErrFixErrors,[Errs.Count,Errs.Text]),mtError,[mbOK],''); | ||||||
|  |   finally | ||||||
|  |     errs.Free; | ||||||
|  |   end; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
| procedure TFPReportDesignerForm.PreviewReport; | procedure TFPReportDesignerForm.PreviewReport; | ||||||
| 
 | 
 | ||||||
| Var | Var | ||||||
|   F : TFPreportPreviewExport; |   F : TFPreportPreviewExport; | ||||||
| 
 | 
 | ||||||
| begin | begin | ||||||
|  |   if not ValidateReport then | ||||||
|  |     exit; | ||||||
|   FReport.RunReport; |   FReport.RunReport; | ||||||
|   F:=TFPreportPreviewExport.Create(Self); |   F:=TFPreportPreviewExport.Create(Self); | ||||||
|   FReport.RenderReport(F); |   FReport.RenderReport(F); | ||||||
| @ -1087,11 +1110,12 @@ Var | |||||||
|   I : Integer; |   I : Integer; | ||||||
|   DesignD : TDesignReportData; |   DesignD : TDesignReportData; | ||||||
|   DatasetD : TFPReportDatasetData; |   DatasetD : TFPReportDatasetData; | ||||||
|  |   L : TFPList; | ||||||
| 
 | 
 | ||||||
| begin | begin | ||||||
|  |   FReport.SaveDataToNames; | ||||||
|   While FDataParent.ComponentCount>0 do |   While FDataParent.ComponentCount>0 do | ||||||
|     FDataParent.Components[FDataParent.ComponentCount-1].Free; |     FDataParent.Components[FDataParent.ComponentCount-1].Free; | ||||||
|   FReport.SaveDataToNames; |  | ||||||
|   FReport.ReportData.Clear; |   FReport.ReportData.Clear; | ||||||
|   For I:=0 to FReportDesignData.Count-1 do |   For I:=0 to FReportDesignData.Count-1 do | ||||||
|     begin |     begin | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 michael
						michael