diff --git a/official/4.2/LibD11/DCLFRXE10.DPK b/official/4.2/LibD11/DCLFRXE10.DPK new file mode 100644 index 0000000..9f99afb --- /dev/null +++ b/official/4.2/LibD11/DCLFRXE10.DPK @@ -0,0 +1,40 @@ +// Package file for Delphi 2006 + +package dclfrxe10; + +{$R 'frxeReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Exports'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxe10; + +contains + frxeReg in 'frxeReg.pas'; + +end. diff --git a/official/4.2/LibD11/DCLFRXE11.DPK b/official/4.2/LibD11/DCLFRXE11.DPK new file mode 100644 index 0000000..a49576d --- /dev/null +++ b/official/4.2/LibD11/DCLFRXE11.DPK @@ -0,0 +1,40 @@ +// Package file for Delphi 2007 + +package dclfrxe11; + +{$R 'frxeReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Exports'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxe11; + +contains + frxeReg in 'frxeReg.pas'; + +end. diff --git a/official/4.2/LibD11/DCLFRXE9.DPK b/official/4.2/LibD11/DCLFRXE9.DPK new file mode 100644 index 0000000..57e57c8 --- /dev/null +++ b/official/4.2/LibD11/DCLFRXE9.DPK @@ -0,0 +1,40 @@ +// Package file for Delphi 2005 + +package dclfrxe9; + +{$R 'frxeReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Exports'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxe9; + +contains + frxeReg in 'frxeReg.pas'; + +end. diff --git a/official/4.2/LibD11/FRXCS10.DPK b/official/4.2/LibD11/FRXCS10.DPK new file mode 100644 index 0000000..354c9a6 --- /dev/null +++ b/official/4.2/LibD11/FRXCS10.DPK @@ -0,0 +1,55 @@ +// Package file for Delphi 2006 + +package frxcs10; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + frx10, + frxe10; + +contains + { core files } + frxServer in 'frxServer.pas', + frxMD5 in 'frxMD5.pas', + frxServerClient in 'frxServerClient.pas', + frxServerConfig in 'frxServerConfig.pas', + frxServerFormControls in 'frxServerFormControls.pas', + frxServerForms in 'frxServerForms.pas', + frxServerLog in 'frxServerLog.pas', + frxServerReports in 'frxServerReports.pas', + frxServerSessionManager in 'frxServerSessionManager.pas', + frxUsers in 'frxUsers.pas', + frxServerSSI in 'frxServerSSI.pas', + frxServerStat in 'frxServerStat.pas', + frxServerUtils in 'frxServerUtils.pas', + frxHTTPClient in 'frxHTTPClient.pas', + frxCGIClient in 'frxCGIClient.pas', + frxServerCache in 'frxServerCache.pas', + frxServerReportsList in 'frxServerReportsList.pas', + frxServerTemplates in 'frxServerTemplates.pas', + frxServerVariables in 'frxServerVariables.pas'; +end. diff --git a/official/4.2/LibD11/FRXCS11.DPK b/official/4.2/LibD11/FRXCS11.DPK new file mode 100644 index 0000000..89b0525 --- /dev/null +++ b/official/4.2/LibD11/FRXCS11.DPK @@ -0,0 +1,55 @@ +// Package file for Delphi 2007 + +package frxcs11; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + frx11, + frxe11; + +contains + { core files } + frxServer in 'frxServer.pas', + frxMD5 in 'frxMD5.pas', + frxServerClient in 'frxServerClient.pas', + frxServerConfig in 'frxServerConfig.pas', + frxServerFormControls in 'frxServerFormControls.pas', + frxServerForms in 'frxServerForms.pas', + frxServerLog in 'frxServerLog.pas', + frxServerReports in 'frxServerReports.pas', + frxServerSessionManager in 'frxServerSessionManager.pas', + frxUsers in 'frxUsers.pas', + frxServerSSI in 'frxServerSSI.pas', + frxServerStat in 'frxServerStat.pas', + frxServerUtils in 'frxServerUtils.pas', + frxHTTPClient in 'frxHTTPClient.pas', + frxCGIClient in 'frxCGIClient.pas', + frxServerCache in 'frxServerCache.pas', + frxServerReportsList in 'frxServerReportsList.pas', + frxServerTemplates in 'frxServerTemplates.pas', + frxServerVariables in 'frxServerVariables.pas'; +end. diff --git a/official/4.2/LibD11/FRXCS9.DPK b/official/4.2/LibD11/FRXCS9.DPK new file mode 100644 index 0000000..f95be75 --- /dev/null +++ b/official/4.2/LibD11/FRXCS9.DPK @@ -0,0 +1,55 @@ +// Package file for Delphi 2005 + +package frxcs9; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + frx9, + frxe9; + +contains + { core files } + frxServer in 'frxServer.pas', + frxMD5 in 'frxMD5.pas', + frxServerClient in 'frxServerClient.pas', + frxServerConfig in 'frxServerConfig.pas', + frxServerFormControls in 'frxServerFormControls.pas', + frxServerForms in 'frxServerForms.pas', + frxServerLog in 'frxServerLog.pas', + frxServerReports in 'frxServerReports.pas', + frxServerSessionManager in 'frxServerSessionManager.pas', + frxUsers in 'frxUsers.pas', + frxServerSSI in 'frxServerSSI.pas', + frxServerStat in 'frxServerStat.pas', + frxServerUtils in 'frxServerUtils.pas', + frxHTTPClient in 'frxHTTPClient.pas', + frxCGIClient in 'frxCGIClient.pas', + frxServerCache in 'frxServerCache.pas', + frxServerReportsList in 'frxServerReportsList.pas', + frxServerTemplates in 'frxServerTemplates.pas', + frxServerVariables in 'frxServerVariables.pas'; +end. diff --git a/official/4.2/LibD11/FRXE10.DPK b/official/4.2/LibD11/FRXE10.DPK new file mode 100644 index 0000000..ac4447a --- /dev/null +++ b/official/4.2/LibD11/FRXE10.DPK @@ -0,0 +1,55 @@ +// Package file for Delphi 2006 + +package frxe10; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + vcl, + vcljpg, + frx10; + +contains + frxExportHTML in 'frxExportHTML.pas', + frxExportImage in 'frxExportImage.pas', + frxExportMatrix in 'frxExportMatrix.pas', + frxExportPDF in 'frxExportPDF.pas', + frxExportRTF in 'frxExportRTF.pas', + frxExportTXT in 'frxExportTXT.pas', + frxExportTxtPrn in 'frxExportTxtPrn.pas', + frxExportXLS in 'frxExportXLS.pas', + frxExportXML in 'frxExportXML.pas', + frxExportCSV in 'frxExportCSV.pas', + frxExportText in 'frxExportText.pas', + frxExportMail in 'frxExportMail.pas', + frxExportODF in 'frxExportODF.pas', + frxZip in 'frxZip.pas', + frxFileUtils in 'frxFileUtils.pas', + frxNetUtils in 'frxNetUtils.pas', + frxPDFFile in 'frxPDFFile.pas', + frxSMTP in 'frxSMTP.pas', + frxrcExports in 'frxrcExports.pas'; + +end. diff --git a/official/4.2/LibD11/FRXE11.DPK b/official/4.2/LibD11/FRXE11.DPK new file mode 100644 index 0000000..beb43e3 --- /dev/null +++ b/official/4.2/LibD11/FRXE11.DPK @@ -0,0 +1,55 @@ +// Package file for Delphi 2007 + +package frxe11; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + vcl, + vcljpg, + frx11; + +contains + frxExportHTML in 'frxExportHTML.pas', + frxExportImage in 'frxExportImage.pas', + frxExportMatrix in 'frxExportMatrix.pas', + frxExportPDF in 'frxExportPDF.pas', + frxExportRTF in 'frxExportRTF.pas', + frxExportTXT in 'frxExportTXT.pas', + frxExportTxtPrn in 'frxExportTxtPrn.pas', + frxExportXLS in 'frxExportXLS.pas', + frxExportXML in 'frxExportXML.pas', + frxExportCSV in 'frxExportCSV.pas', + frxExportText in 'frxExportText.pas', + frxExportMail in 'frxExportMail.pas', + frxExportODF in 'frxExportODF.pas', + frxZip in 'frxZip.pas', + frxFileUtils in 'frxFileUtils.pas', + frxNetUtils in 'frxNetUtils.pas', + frxPDFFile in 'frxPDFFile.pas', + frxSMTP in 'frxSMTP.pas', + frxrcExports in 'frxrcExports.pas'; + +end. diff --git a/official/4.2/LibD11/FRXE7.RES b/official/4.2/LibD11/FRXE7.RES new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/FRXE7.RES differ diff --git a/official/4.2/LibD11/FRXE9.DPK b/official/4.2/LibD11/FRXE9.DPK new file mode 100644 index 0000000..a418c30 --- /dev/null +++ b/official/4.2/LibD11/FRXE9.DPK @@ -0,0 +1,55 @@ +// Package file for Delphi 2005 + +package frxe9; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + vcl, + vcljpg, + frx9; + +contains + frxExportHTML in 'frxExportHTML.pas', + frxExportImage in 'frxExportImage.pas', + frxExportMatrix in 'frxExportMatrix.pas', + frxExportPDF in 'frxExportPDF.pas', + frxExportRTF in 'frxExportRTF.pas', + frxExportTXT in 'frxExportTXT.pas', + frxExportTxtPrn in 'frxExportTxtPrn.pas', + frxExportXLS in 'frxExportXLS.pas', + frxExportXML in 'frxExportXML.pas', + frxExportCSV in 'frxExportCSV.pas', + frxExportText in 'frxExportText.pas', + frxExportMail in 'frxExportMail.pas', + frxExportODF in 'frxExportODF.pas', + frxZip in 'frxZip.pas', + frxFileUtils in 'frxFileUtils.pas', + frxNetUtils in 'frxNetUtils.pas', + frxPDFFile in 'frxPDFFile.pas', + frxSMTP in 'frxSMTP.pas', + frxrcExports in 'frxrcExports.pas'; + +end. diff --git a/official/4.2/LibD11/FRXE9.RES b/official/4.2/LibD11/FRXE9.RES new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/FRXE9.RES differ diff --git a/official/4.2/LibD11/adler32.zobj b/official/4.2/LibD11/adler32.zobj new file mode 100644 index 0000000..04e2028 Binary files /dev/null and b/official/4.2/LibD11/adler32.zobj differ diff --git a/official/4.2/LibD11/compress.zobj b/official/4.2/LibD11/compress.zobj new file mode 100644 index 0000000..4de94fa Binary files /dev/null and b/official/4.2/LibD11/compress.zobj differ diff --git a/official/4.2/LibD11/crc32.zobj b/official/4.2/LibD11/crc32.zobj new file mode 100644 index 0000000..4b7261c Binary files /dev/null and b/official/4.2/LibD11/crc32.zobj differ diff --git a/official/4.2/LibD11/dclfrx10.bdsproj b/official/4.2/LibD11/dclfrx10.bdsproj new file mode 100644 index 0000000..55916ba --- /dev/null +++ b/official/4.2/LibD11/dclfrx10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrx10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrx10.dpk b/official/4.2/LibD11/dclfrx10.dpk new file mode 100644 index 0000000..5717b31 --- /dev/null +++ b/official/4.2/LibD11/dclfrx10.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2006 + +package dclfrx10; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx10; + +contains + frxReg in 'frxReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrx11.bdsproj b/official/4.2/LibD11/dclfrx11.bdsproj new file mode 100644 index 0000000..bd976f6 --- /dev/null +++ b/official/4.2/LibD11/dclfrx11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrx11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrx11.dpk b/official/4.2/LibD11/dclfrx11.dpk new file mode 100644 index 0000000..3c1c920 --- /dev/null +++ b/official/4.2/LibD11/dclfrx11.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2007 + +package dclfrx11; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx11; + +contains + frxReg in 'frxReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrx4.dpk b/official/4.2/LibD11/dclfrx4.dpk new file mode 100644 index 0000000..7bd0d8e --- /dev/null +++ b/official/4.2/LibD11/dclfrx4.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 4 + +package dclfrx4; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + frx4; + +contains + frxReg in 'frxReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrx5.dpk b/official/4.2/LibD11/dclfrx5.dpk new file mode 100644 index 0000000..2d94cc6 --- /dev/null +++ b/official/4.2/LibD11/dclfrx5.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 5 + +package dclfrx5; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frx5; + +contains + frxReg in 'frxReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrx6.dpk b/official/4.2/LibD11/dclfrx6.dpk new file mode 100644 index 0000000..5c8a4d0 --- /dev/null +++ b/official/4.2/LibD11/dclfrx6.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 6 + +package dclfrx6; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx6; + +contains + frxReg in 'frxReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrx7.dpk b/official/4.2/LibD11/dclfrx7.dpk new file mode 100644 index 0000000..08ea527 --- /dev/null +++ b/official/4.2/LibD11/dclfrx7.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 7 + +package dclfrx7; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx7; + +contains + frxReg in 'frxReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrx9.bdsproj b/official/4.2/LibD11/dclfrx9.bdsproj new file mode 100644 index 0000000..23e415d --- /dev/null +++ b/official/4.2/LibD11/dclfrx9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrx9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrx9.dpk b/official/4.2/LibD11/dclfrx9.dpk new file mode 100644 index 0000000..569d021 --- /dev/null +++ b/official/4.2/LibD11/dclfrx9.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2005 + +package dclfrx9; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx9; + +contains + frxReg in 'frxReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxADO10.bdsproj b/official/4.2/LibD11/dclfrxADO10.bdsproj new file mode 100644 index 0000000..6036411 --- /dev/null +++ b/official/4.2/LibD11/dclfrxADO10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxADO10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxADO10.dpk b/official/4.2/LibD11/dclfrxADO10.dpk new file mode 100644 index 0000000..a56e5e1 --- /dev/null +++ b/official/4.2/LibD11/dclfrxADO10.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2006 + +package dclfrxADO10; + +{$R 'frxADOReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxADO10; + +contains + frxADOReg in 'frxADOReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxADO11.bdsproj b/official/4.2/LibD11/dclfrxADO11.bdsproj new file mode 100644 index 0000000..eff3731 --- /dev/null +++ b/official/4.2/LibD11/dclfrxADO11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxADO11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxADO11.dpk b/official/4.2/LibD11/dclfrxADO11.dpk new file mode 100644 index 0000000..0ecf855 --- /dev/null +++ b/official/4.2/LibD11/dclfrxADO11.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2007 + +package dclfrxADO11; + +{$R 'frxADOReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxADO11; + +contains + frxADOReg in 'frxADOReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxADO5.dpk b/official/4.2/LibD11/dclfrxADO5.dpk new file mode 100644 index 0000000..f16ff3a --- /dev/null +++ b/official/4.2/LibD11/dclfrxADO5.dpk @@ -0,0 +1,38 @@ +// Package file for Delphi 5 + +package dclfrxADO5; + +{$R 'frxADOReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frxADO5; + +contains + frxADOReg in 'frxADOReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxADO6.dpk b/official/4.2/LibD11/dclfrxADO6.dpk new file mode 100644 index 0000000..96cebe8 --- /dev/null +++ b/official/4.2/LibD11/dclfrxADO6.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 6 + +package dclfrxADO6; + +{$R 'frxADOReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxADO6; + +contains + frxADOReg in 'frxADOReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxADO7.dpk b/official/4.2/LibD11/dclfrxADO7.dpk new file mode 100644 index 0000000..46c7455 --- /dev/null +++ b/official/4.2/LibD11/dclfrxADO7.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 7 + +package dclfrxADO7; + +{$R 'frxADOReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxADO7; + +contains + frxADOReg in 'frxADOReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxADO9.bdsproj b/official/4.2/LibD11/dclfrxADO9.bdsproj new file mode 100644 index 0000000..88160f3 --- /dev/null +++ b/official/4.2/LibD11/dclfrxADO9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxADO9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxADO9.dpk b/official/4.2/LibD11/dclfrxADO9.dpk new file mode 100644 index 0000000..c1f3b2f --- /dev/null +++ b/official/4.2/LibD11/dclfrxADO9.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2005 + +package dclfrxADO9; + +{$R 'frxADOReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxADO9; + +contains + frxADOReg in 'frxADOReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxBDE10.bdsproj b/official/4.2/LibD11/dclfrxBDE10.bdsproj new file mode 100644 index 0000000..67da472 --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxBDE10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxBDE10.dpk b/official/4.2/LibD11/dclfrxBDE10.dpk new file mode 100644 index 0000000..1418330 --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE10.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2006 + +package dclfrxBDE10; + +{$R 'frxBDEReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxBDE10; + +contains + frxBDEReg in 'frxBDEReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxBDE11.bdsproj b/official/4.2/LibD11/dclfrxBDE11.bdsproj new file mode 100644 index 0000000..2c5f340 --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxBDE11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxBDE11.dpk b/official/4.2/LibD11/dclfrxBDE11.dpk new file mode 100644 index 0000000..1c0eff8 --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE11.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2007 + +package dclfrxBDE11; + +{$R 'frxBDEReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxBDE11; + +contains + frxBDEReg in 'frxBDEReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxBDE4.dpk b/official/4.2/LibD11/dclfrxBDE4.dpk new file mode 100644 index 0000000..e2b06a7 --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE4.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 4 + +package dclfrxBDE4; + +{$R 'frxBDEReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + frxBDE4; + +contains + frxBDEReg in 'frxBDEReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxBDE5.dpk b/official/4.2/LibD11/dclfrxBDE5.dpk new file mode 100644 index 0000000..cd2d66b --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE5.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 5 + +package dclfrxBDE5; + +{$R 'frxBDEReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frxBDE5; + +contains + frxBDEReg in 'frxBDEReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxBDE6.dpk b/official/4.2/LibD11/dclfrxBDE6.dpk new file mode 100644 index 0000000..8f8e266 --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE6.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 6 + +package dclfrxBDE6; + +{$R 'frxBDEReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxBDE6; + +contains + frxBDEReg in 'frxBDEReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxBDE7.dpk b/official/4.2/LibD11/dclfrxBDE7.dpk new file mode 100644 index 0000000..add7134 --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE7.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 7 + +package dclfrxBDE7; + +{$R 'frxBDEReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxBDE7; + +contains + frxBDEReg in 'frxBDEReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxBDE9.bdsproj b/official/4.2/LibD11/dclfrxBDE9.bdsproj new file mode 100644 index 0000000..55b0f6a --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxBDE9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxBDE9.dpk b/official/4.2/LibD11/dclfrxBDE9.dpk new file mode 100644 index 0000000..9e52646 --- /dev/null +++ b/official/4.2/LibD11/dclfrxBDE9.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2005 + +package dclfrxBDE9; + +{$R 'frxBDEReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxBDE9; + +contains + frxBDEReg in 'frxBDEReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxDB10.bdsproj b/official/4.2/LibD11/dclfrxDB10.bdsproj new file mode 100644 index 0000000..d8724c9 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxDB10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxDB10.dpk b/official/4.2/LibD11/dclfrxDB10.dpk new file mode 100644 index 0000000..1b20c0a --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB10.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2006 + +package dclfrxDB10; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx10, + frxDB10; + +contains + frxRegDB in 'frxRegDB.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxDB11.bdsproj b/official/4.2/LibD11/dclfrxDB11.bdsproj new file mode 100644 index 0000000..ab81331 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB11.bdsproj @@ -0,0 +1,182 @@ + + + + + + + + + + + + dclfrxDB11.dpk + + + 7.0 + + 8 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + False + False + False + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + + + + 0 + 0 + False + 1 + False + False + False + 16384 + 1048576 + 4194304 + FastReport 4.0 DB Components + + + + + + + + + + + False + + + + + + False + + + True + False + + + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + + diff --git a/official/4.2/LibD11/dclfrxDB11.dpk b/official/4.2/LibD11/dclfrxDB11.dpk new file mode 100644 index 0000000..0aa0466 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB11.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2007 + +package dclfrxDB11; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx11, + frxDB11; + +contains + frxRegDB in 'frxRegDB.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxDB4.dpk b/official/4.2/LibD11/dclfrxDB4.dpk new file mode 100644 index 0000000..e65efd8 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB4.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 4 + +package dclfrxDB4; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + frx4, + frxDB4; + +contains + frxRegDB in 'frxRegDB.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxDB5.dpk b/official/4.2/LibD11/dclfrxDB5.dpk new file mode 100644 index 0000000..a63b489 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB5.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 5 + +package dclfrxDB5; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frx5, + frxDB5; + +contains + frxRegDB in 'frxRegDB.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxDB6.dpk b/official/4.2/LibD11/dclfrxDB6.dpk new file mode 100644 index 0000000..039905f --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB6.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 6 + +package dclfrxDB6; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx6, + frxDB6; + +contains + frxRegDB in 'frxRegDB.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxDB7.dpk b/official/4.2/LibD11/dclfrxDB7.dpk new file mode 100644 index 0000000..f4999be --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB7.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 7 + +package dclfrxDB7; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx7, + frxDB7; + +contains + frxRegDB in 'frxRegDB.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxDB9.bdsproj b/official/4.2/LibD11/dclfrxDB9.bdsproj new file mode 100644 index 0000000..b524a6c --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxDB9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxDB9.dpk b/official/4.2/LibD11/dclfrxDB9.dpk new file mode 100644 index 0000000..8047270 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDB9.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2005 + +package dclfrxDB9; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx9, + frxDB9; + +contains + frxRegDB in 'frxRegDB.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxDBX10.bdsproj b/official/4.2/LibD11/dclfrxDBX10.bdsproj new file mode 100644 index 0000000..245875b --- /dev/null +++ b/official/4.2/LibD11/dclfrxDBX10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxDBX10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxDBX10.dpk b/official/4.2/LibD11/dclfrxDBX10.dpk new file mode 100644 index 0000000..685aa73 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDBX10.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2006 + +package dclfrxDBX10; + +{$R 'frxDBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 DBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxDBX10; + +contains + frxDBXReg in 'frxDBXReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxDBX11.bdsproj b/official/4.2/LibD11/dclfrxDBX11.bdsproj new file mode 100644 index 0000000..5ccaf2c --- /dev/null +++ b/official/4.2/LibD11/dclfrxDBX11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxDBX11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxDBX11.dpk b/official/4.2/LibD11/dclfrxDBX11.dpk new file mode 100644 index 0000000..0aa2b79 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDBX11.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2007 + +package dclfrxDBX11; + +{$R 'frxDBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 DBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxDBX11; + +contains + frxDBXReg in 'frxDBXReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxDBX6.dpk b/official/4.2/LibD11/dclfrxDBX6.dpk new file mode 100644 index 0000000..ec61109 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDBX6.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 6 + +package dclfrxDBX6; + +{$R 'frxDBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 DBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxDBX6; + +contains + frxDBXReg in 'frxDBXReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxDBX7.dpk b/official/4.2/LibD11/dclfrxDBX7.dpk new file mode 100644 index 0000000..67923e4 --- /dev/null +++ b/official/4.2/LibD11/dclfrxDBX7.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 7 + +package dclfrxDBX7; + +{$R 'frxDBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 DBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxDBX7; + +contains + frxDBXReg in 'frxDBXReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxDBX9.bdsproj b/official/4.2/LibD11/dclfrxDBX9.bdsproj new file mode 100644 index 0000000..e01891d --- /dev/null +++ b/official/4.2/LibD11/dclfrxDBX9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxDBX9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxDBX9.dpk b/official/4.2/LibD11/dclfrxDBX9.dpk new file mode 100644 index 0000000..499a19f --- /dev/null +++ b/official/4.2/LibD11/dclfrxDBX9.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2005 + +package dclfrxDBX9; + +{$R 'frxDBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 DBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxDBX9; + +contains + frxDBXReg in 'frxDBXReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxIBO4.dpk b/official/4.2/LibD11/dclfrxIBO4.dpk new file mode 100644 index 0000000..9638da7 --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBO4.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 4 + +package dclfrxIBO4; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 IBO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + frxIBO4; + +contains + frxRegIBO in 'frxRegIBO.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxIBO5.dpk b/official/4.2/LibD11/dclfrxIBO5.dpk new file mode 100644 index 0000000..83385c4 --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBO5.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 5 + +package dclfrxIBO5; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 IBO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frx5, + frxIBO5; + +contains + frxRegIBO in 'frxRegIBO.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxIBO6.dpk b/official/4.2/LibD11/dclfrxIBO6.dpk new file mode 100644 index 0000000..06812ea --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBO6.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 6 + +package dclfrxIBO6; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 IBO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx6, + frxIBO6; + +contains + frxRegIBO in 'frxRegIBO.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxIBO7.dpk b/official/4.2/LibD11/dclfrxIBO7.dpk new file mode 100644 index 0000000..37da91c --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBO7.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 7 + +package dclfrxIBO7; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 IBO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frx7, + frxIBO7; + +contains + frxRegIBO in 'frxRegIBO.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxIBX10.bdsproj b/official/4.2/LibD11/dclfrxIBX10.bdsproj new file mode 100644 index 0000000..202eeb2 --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBX10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxIBX10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxIBX10.dpk b/official/4.2/LibD11/dclfrxIBX10.dpk new file mode 100644 index 0000000..46e7b7f --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBX10.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2006 + +package dclfrxIBX10; + +{$R 'frxIBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxIBX10; + +contains + frxIBXReg in 'frxIBXReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxIBX11.bdsproj b/official/4.2/LibD11/dclfrxIBX11.bdsproj new file mode 100644 index 0000000..dcfee3f --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBX11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxIBX11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxIBX11.dpk b/official/4.2/LibD11/dclfrxIBX11.dpk new file mode 100644 index 0000000..4a5b53c --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBX11.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2007 + +package dclfrxIBX11; + +{$R 'frxIBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxIBX11; + +contains + frxIBXReg in 'frxIBXReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxIBX5.dpk b/official/4.2/LibD11/dclfrxIBX5.dpk new file mode 100644 index 0000000..353093d --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBX5.dpk @@ -0,0 +1,38 @@ +// Package file for Delphi 5 + +package dclfrxIBX5; + +{$R 'frxIBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frxIBX5; + +contains + frxIBXReg in 'frxIBXReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxIBX6.dpk b/official/4.2/LibD11/dclfrxIBX6.dpk new file mode 100644 index 0000000..bed7ec3 --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBX6.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 6 + +package dclfrxIBX6; + +{$R 'frxIBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxIBX6; + +contains + frxIBXReg in 'frxIBXReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxIBX7.dpk b/official/4.2/LibD11/dclfrxIBX7.dpk new file mode 100644 index 0000000..3ec9e23 --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBX7.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 7 + +package dclfrxIBX7; + +{$R 'frxIBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxIBX7; + +contains + frxIBXReg in 'frxIBXReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxIBX9.bdsproj b/official/4.2/LibD11/dclfrxIBX9.bdsproj new file mode 100644 index 0000000..da99801 --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBX9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxIBX9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxIBX9.dpk b/official/4.2/LibD11/dclfrxIBX9.dpk new file mode 100644 index 0000000..60caa79 --- /dev/null +++ b/official/4.2/LibD11/dclfrxIBX9.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2005 + +package dclfrxIBX9; + +{$R 'frxIBXReg.dcr'} +{$DESCRIPTION 'FastReport 4.0 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxIBX9; + +contains + frxIBXReg in 'frxIBXReg.pas'; + + +end. diff --git a/official/4.2/LibD11/dclfrxTee10.bdsproj b/official/4.2/LibD11/dclfrxTee10.bdsproj new file mode 100644 index 0000000..205f209 --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxTee10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxTee10.dpk b/official/4.2/LibD11/dclfrxTee10.dpk new file mode 100644 index 0000000..3b2c4f9 --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee10.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2006 + +package dclfrxTee10; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxTee10; + +contains + frxRegTee in 'frxRegTee.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxTee11.bdsproj b/official/4.2/LibD11/dclfrxTee11.bdsproj new file mode 100644 index 0000000..9279934 --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxTee11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxTee11.dpk b/official/4.2/LibD11/dclfrxTee11.dpk new file mode 100644 index 0000000..2fffe49 --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee11.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2007 + +package dclfrxTee11; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxTee11; + +contains + frxRegTee in 'frxRegTee.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxTee4.dpk b/official/4.2/LibD11/dclfrxTee4.dpk new file mode 100644 index 0000000..f01c6b0 --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee4.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 4 + +package dclfrxTee4; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + frxTee4; + +contains + frxRegTee in 'frxRegTee.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxTee5.dpk b/official/4.2/LibD11/dclfrxTee5.dpk new file mode 100644 index 0000000..b5fce54 --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee5.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 5 + +package dclfrxTee5; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frxTee5; + +contains + frxRegTee in 'frxRegTee.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxTee6.dpk b/official/4.2/LibD11/dclfrxTee6.dpk new file mode 100644 index 0000000..3357bc0 --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee6.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 6 + +package dclfrxTee6; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxTee6; + +contains + frxRegTee in 'frxRegTee.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxTee7.dpk b/official/4.2/LibD11/dclfrxTee7.dpk new file mode 100644 index 0000000..e67e5bc --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee7.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 7 + +package dclfrxTee7; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxTee7; + +contains + frxRegTee in 'frxRegTee.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxTee9.bdsproj b/official/4.2/LibD11/dclfrxTee9.bdsproj new file mode 100644 index 0000000..68636ad --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxTee9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxTee9.dpk b/official/4.2/LibD11/dclfrxTee9.dpk new file mode 100644 index 0000000..afbe7d3 --- /dev/null +++ b/official/4.2/LibD11/dclfrxTee9.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2005 + +package dclfrxTee9; + +{$R 'frxReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxTee9; + +contains + frxRegTee in 'frxRegTee.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxcs10.bdsproj b/official/4.2/LibD11/dclfrxcs10.bdsproj new file mode 100644 index 0000000..51c396c --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxcs10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxcs10.dpk b/official/4.2/LibD11/dclfrxcs10.dpk new file mode 100644 index 0000000..a14a4ec --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs10.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 2006 + +package dclfrxcs10; + +{$R 'frxRegCS.dcr'} +{$DESCRIPTION 'FastReport 4.0 Client/Server Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxcs10; + +contains + frxRegCS in 'frxRegCS.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxcs11.bdsproj b/official/4.2/LibD11/dclfrxcs11.bdsproj new file mode 100644 index 0000000..9ee981e --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxcs11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxcs11.dpk b/official/4.2/LibD11/dclfrxcs11.dpk new file mode 100644 index 0000000..913953d --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs11.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 2007 + +package dclfrxcs11; + +{$R 'frxRegCS.dcr'} +{$DESCRIPTION 'FastReport 4.0 Client/Server Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxcs11; + +contains + frxRegCS in 'frxRegCS.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxcs4.dpk b/official/4.2/LibD11/dclfrxcs4.dpk new file mode 100644 index 0000000..c985df8 --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs4.dpk @@ -0,0 +1,38 @@ +// Package file for Delphi 4 + +package dclfrxcs4; + +{$R 'frxRegCS.dcr'} +{$DESCRIPTION 'FastReport 4.0 Client/Server Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + frxcs4; + +contains + frxRegCS in 'frxRegCS.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxcs5.dpk b/official/4.2/LibD11/dclfrxcs5.dpk new file mode 100644 index 0000000..20397bd --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs5.dpk @@ -0,0 +1,38 @@ +// Package file for Delphi 5 + +package dclfrxcs5; + +{$R 'frxRegCS.dcr'} +{$DESCRIPTION 'FastReport 4.0 Client/Server Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frxcs5; + +contains + frxRegCS in 'frxRegCS.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxcs6.dpk b/official/4.2/LibD11/dclfrxcs6.dpk new file mode 100644 index 0000000..66a1bb6 --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs6.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 6 + +package dclfrxcs6; + +{$R 'frxRegCS.dcr'} +{$DESCRIPTION 'FastReport 4.0 Client/Server Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxcs6; + +contains + frxRegCS in 'frxRegCS.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxcs7.dpk b/official/4.2/LibD11/dclfrxcs7.dpk new file mode 100644 index 0000000..c77b349 --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs7.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 7 + +package dclfrxcs7; + +{$R 'frxRegCS.dcr'} +{$DESCRIPTION 'FastReport 4.0 Client/Server Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxcs7; + +contains + frxRegCS in 'frxRegCS.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxcs9.bdsproj b/official/4.2/LibD11/dclfrxcs9.bdsproj new file mode 100644 index 0000000..4ec9b14 --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxcs9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxcs9.dpk b/official/4.2/LibD11/dclfrxcs9.dpk new file mode 100644 index 0000000..a217027 --- /dev/null +++ b/official/4.2/LibD11/dclfrxcs9.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 2005 + +package dclfrxcs9; + +{$R 'frxRegCS.dcr'} +{$DESCRIPTION 'FastReport 4.0 Client/Server Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxcs9; + +contains + frxRegCS in 'frxRegCS.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxe10.bdsproj b/official/4.2/LibD11/dclfrxe10.bdsproj new file mode 100644 index 0000000..e86f2b5 --- /dev/null +++ b/official/4.2/LibD11/dclfrxe10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxe10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxe11.bdsproj b/official/4.2/LibD11/dclfrxe11.bdsproj new file mode 100644 index 0000000..fa88635 --- /dev/null +++ b/official/4.2/LibD11/dclfrxe11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxe11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfrxe4.dpk b/official/4.2/LibD11/dclfrxe4.dpk new file mode 100644 index 0000000..1a721d6 --- /dev/null +++ b/official/4.2/LibD11/dclfrxe4.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 4 + +package dclfrxe4; + +{$R 'frxeReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Exports'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + frxe4; + +contains + frxeReg in 'frxeReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxe5.dpk b/official/4.2/LibD11/dclfrxe5.dpk new file mode 100644 index 0000000..d9e654b --- /dev/null +++ b/official/4.2/LibD11/dclfrxe5.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 5 + +package dclfrxe5; + +{$R 'frxeReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Exports'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frxe5; + +contains + frxeReg in 'frxeReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxe6.dpk b/official/4.2/LibD11/dclfrxe6.dpk new file mode 100644 index 0000000..2cc60c3 --- /dev/null +++ b/official/4.2/LibD11/dclfrxe6.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 6 + +package dclfrxe6; + +{$R 'frxeReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Exports'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxe6; + +contains + frxeReg in 'frxeReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxe7.dpk b/official/4.2/LibD11/dclfrxe7.dpk new file mode 100644 index 0000000..5790821 --- /dev/null +++ b/official/4.2/LibD11/dclfrxe7.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 7 + +package dclfrxe7; + +{$R 'frxeReg.dcr'} + +{$DESCRIPTION 'FastReport 4.0 Exports'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + frxe7; + +contains + frxeReg in 'frxeReg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfrxe9.bdsproj b/official/4.2/LibD11/dclfrxe9.bdsproj new file mode 100644 index 0000000..bae2e97 --- /dev/null +++ b/official/4.2/LibD11/dclfrxe9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfrxe9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfs10.bdsproj b/official/4.2/LibD11/dclfs10.bdsproj new file mode 100644 index 0000000..50df875 --- /dev/null +++ b/official/4.2/LibD11/dclfs10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfs10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfs10.dpk b/official/4.2/LibD11/dclfs10.dpk new file mode 100644 index 0000000..ee58326 --- /dev/null +++ b/official/4.2/LibD11/dclfs10.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2006 + +package dclfs10; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs10; + +contains + fs_ireg in 'fs_ireg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfs11.bdsproj b/official/4.2/LibD11/dclfs11.bdsproj new file mode 100644 index 0000000..7a8513d --- /dev/null +++ b/official/4.2/LibD11/dclfs11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfs11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfs11.dpk b/official/4.2/LibD11/dclfs11.dpk new file mode 100644 index 0000000..ef818c5 --- /dev/null +++ b/official/4.2/LibD11/dclfs11.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2007 + +package dclfs11; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs11; + +contains + fs_ireg in 'fs_ireg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfs4.dpk b/official/4.2/LibD11/dclfs4.dpk new file mode 100644 index 0000000..9858ea0 --- /dev/null +++ b/official/4.2/LibD11/dclfs4.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 4 + +package dclfs4; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + fs4; + +contains + fs_ireg in 'fs_ireg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfs5.dpk b/official/4.2/LibD11/dclfs5.dpk new file mode 100644 index 0000000..3cfbd14 --- /dev/null +++ b/official/4.2/LibD11/dclfs5.dpk @@ -0,0 +1,39 @@ +// Package file for Delphi 5 + +package dclfs5; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + fs5; + +contains + fs_ireg in 'fs_ireg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfs6.dpk b/official/4.2/LibD11/dclfs6.dpk new file mode 100644 index 0000000..484be3f --- /dev/null +++ b/official/4.2/LibD11/dclfs6.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 6 + +package dclfs6; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs6; + +contains + fs_ireg in 'fs_ireg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfs7.dpk b/official/4.2/LibD11/dclfs7.dpk new file mode 100644 index 0000000..554e22b --- /dev/null +++ b/official/4.2/LibD11/dclfs7.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 7 + +package dclfs7; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs7; + +contains + fs_ireg in 'fs_ireg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfs9.bdsproj b/official/4.2/LibD11/dclfs9.bdsproj new file mode 100644 index 0000000..8b1acd0 --- /dev/null +++ b/official/4.2/LibD11/dclfs9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfs9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfs9.dpk b/official/4.2/LibD11/dclfs9.dpk new file mode 100644 index 0000000..e64ed1e --- /dev/null +++ b/official/4.2/LibD11/dclfs9.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 2005 + +package dclfs9; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs9; + +contains + fs_ireg in 'fs_ireg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsADO10.bdsproj b/official/4.2/LibD11/dclfsADO10.bdsproj new file mode 100644 index 0000000..957918a --- /dev/null +++ b/official/4.2/LibD11/dclfsADO10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsADO10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsADO10.dpk b/official/4.2/LibD11/dclfsADO10.dpk new file mode 100644 index 0000000..d21c660 --- /dev/null +++ b/official/4.2/LibD11/dclfsADO10.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2006 + +package dclfsADO10; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs10, + fsADO10; + +contains + fs_iadoreg in 'fs_iadoreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsADO11.bdsproj b/official/4.2/LibD11/dclfsADO11.bdsproj new file mode 100644 index 0000000..3baa552 --- /dev/null +++ b/official/4.2/LibD11/dclfsADO11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsADO11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsADO11.dpk b/official/4.2/LibD11/dclfsADO11.dpk new file mode 100644 index 0000000..394cf98 --- /dev/null +++ b/official/4.2/LibD11/dclfsADO11.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2007 + +package dclfsADO11; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs11, + fsADO11; + +contains + fs_iadoreg in 'fs_iadoreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsADO5.dpk b/official/4.2/LibD11/dclfsADO5.dpk new file mode 100644 index 0000000..83fa0f8 --- /dev/null +++ b/official/4.2/LibD11/dclfsADO5.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 5 + +package dclfsADO5; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + fs5, + fsADO5; + +contains + fs_iadoreg in 'fs_iadoreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsADO6.dpk b/official/4.2/LibD11/dclfsADO6.dpk new file mode 100644 index 0000000..5fa1b3f --- /dev/null +++ b/official/4.2/LibD11/dclfsADO6.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 6 + +package dclfsADO6; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs6, + fsADO6; + +contains + fs_iadoreg in 'fs_iadoreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsADO7.dpk b/official/4.2/LibD11/dclfsADO7.dpk new file mode 100644 index 0000000..654692b --- /dev/null +++ b/official/4.2/LibD11/dclfsADO7.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 7 + +package dclfsADO7; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs7, + fsADO7; + +contains + fs_iadoreg in 'fs_iadoreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsADO9.bdsproj b/official/4.2/LibD11/dclfsADO9.bdsproj new file mode 100644 index 0000000..42ee713 --- /dev/null +++ b/official/4.2/LibD11/dclfsADO9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsADO9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsADO9.dpk b/official/4.2/LibD11/dclfsADO9.dpk new file mode 100644 index 0000000..9ebdf0d --- /dev/null +++ b/official/4.2/LibD11/dclfsADO9.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2005 + +package dclfsADO9; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 ADO Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs9, + fsADO9; + +contains + fs_iadoreg in 'fs_iadoreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsBDE10.bdsproj b/official/4.2/LibD11/dclfsBDE10.bdsproj new file mode 100644 index 0000000..bd86a0b --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsBDE10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsBDE10.dpk b/official/4.2/LibD11/dclfsBDE10.dpk new file mode 100644 index 0000000..bb801e1 --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE10.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2006 + +package dclfsBDE10; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs10, + fsBDE10; + +contains + fs_ibdereg in 'fs_ibdereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsBDE11.bdsproj b/official/4.2/LibD11/dclfsBDE11.bdsproj new file mode 100644 index 0000000..1b1f5aa --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsBDE11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsBDE11.dpk b/official/4.2/LibD11/dclfsBDE11.dpk new file mode 100644 index 0000000..c0c9f2e --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE11.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2007 + +package dclfsBDE11; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs11, + fsBDE11; + +contains + fs_ibdereg in 'fs_ibdereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsBDE4.dpk b/official/4.2/LibD11/dclfsBDE4.dpk new file mode 100644 index 0000000..50b1256 --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE4.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 4 + +package dclfsBDE4; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + fs4, + fsBDE4; + +contains + fs_ibdereg in 'fs_ibdereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsBDE5.dpk b/official/4.2/LibD11/dclfsBDE5.dpk new file mode 100644 index 0000000..b800eea --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE5.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 5 + +package dclfsBDE5; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + fs5, + fsBDE5; + +contains + fs_ibdereg in 'fs_ibdereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsBDE6.dpk b/official/4.2/LibD11/dclfsBDE6.dpk new file mode 100644 index 0000000..32ff035 --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE6.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 6 + +package dclfsBDE6; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs6, + fsBDE6; + +contains + fs_ibdereg in 'fs_ibdereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsBDE7.dpk b/official/4.2/LibD11/dclfsBDE7.dpk new file mode 100644 index 0000000..2a4a41d --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE7.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 7 + +package dclfsBDE7; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs7, + fsBDE7; + +contains + fs_ibdereg in 'fs_ibdereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsBDE9.bdsproj b/official/4.2/LibD11/dclfsBDE9.bdsproj new file mode 100644 index 0000000..8ff5e78 --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsBDE9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsBDE9.dpk b/official/4.2/LibD11/dclfsBDE9.dpk new file mode 100644 index 0000000..2a9fdc9 --- /dev/null +++ b/official/4.2/LibD11/dclfsBDE9.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2005 + +package dclfsBDE9; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 BDE Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs9, + fsBDE9; + +contains + fs_ibdereg in 'fs_ibdereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsDB10.bdsproj b/official/4.2/LibD11/dclfsDB10.bdsproj new file mode 100644 index 0000000..4b0941c --- /dev/null +++ b/official/4.2/LibD11/dclfsDB10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsDB10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsDB10.dpk b/official/4.2/LibD11/dclfsDB10.dpk new file mode 100644 index 0000000..94f1794 --- /dev/null +++ b/official/4.2/LibD11/dclfsDB10.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2006 + +package dclfsDB10; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs10, + fsDB10; + +contains + fs_idbreg in 'fs_idbreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsDB11.bdsproj b/official/4.2/LibD11/dclfsDB11.bdsproj new file mode 100644 index 0000000..cf54521 --- /dev/null +++ b/official/4.2/LibD11/dclfsDB11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsDB11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsDB11.dpk b/official/4.2/LibD11/dclfsDB11.dpk new file mode 100644 index 0000000..0f6556c --- /dev/null +++ b/official/4.2/LibD11/dclfsDB11.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2007 + +package dclfsDB11; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs11, + fsDB11; + +contains + fs_idbreg in 'fs_idbreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsDB4.dpk b/official/4.2/LibD11/dclfsDB4.dpk new file mode 100644 index 0000000..872a4b9 --- /dev/null +++ b/official/4.2/LibD11/dclfsDB4.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 4 + +package dclfsDB4; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + fs4, + fsDB4; + +contains + fs_idbreg in 'fs_idbreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsDB5.dpk b/official/4.2/LibD11/dclfsDB5.dpk new file mode 100644 index 0000000..01d155e --- /dev/null +++ b/official/4.2/LibD11/dclfsDB5.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 5 + +package dclfsDB5; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + fs5, + fsDB5; + +contains + fs_idbreg in 'fs_idbreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsDB6.dpk b/official/4.2/LibD11/dclfsDB6.dpk new file mode 100644 index 0000000..973438d --- /dev/null +++ b/official/4.2/LibD11/dclfsDB6.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 6 + +package dclfsDB6; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs6, + fsDB6; + +contains + fs_idbreg in 'fs_idbreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsDB7.dpk b/official/4.2/LibD11/dclfsDB7.dpk new file mode 100644 index 0000000..dcda2cb --- /dev/null +++ b/official/4.2/LibD11/dclfsDB7.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 7 + +package dclfsDB7; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs7, + fsDB7; + +contains + fs_idbreg in 'fs_idbreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsDB9.bdsproj b/official/4.2/LibD11/dclfsDB9.bdsproj new file mode 100644 index 0000000..c9a5e68 --- /dev/null +++ b/official/4.2/LibD11/dclfsDB9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsDB9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsDB9.dpk b/official/4.2/LibD11/dclfsDB9.dpk new file mode 100644 index 0000000..30844d6 --- /dev/null +++ b/official/4.2/LibD11/dclfsDB9.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2005 + +package dclfsDB9; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 DB Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs9, + fsDB9; + +contains + fs_idbreg in 'fs_idbreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsIBX10.bdsproj b/official/4.2/LibD11/dclfsIBX10.bdsproj new file mode 100644 index 0000000..706b834 --- /dev/null +++ b/official/4.2/LibD11/dclfsIBX10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsIBX10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsIBX10.dpk b/official/4.2/LibD11/dclfsIBX10.dpk new file mode 100644 index 0000000..5209b7f --- /dev/null +++ b/official/4.2/LibD11/dclfsIBX10.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2006 + +package dclfsIBX10; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs10, + fsIBX10; + +contains + fs_iibxreg in 'fs_iibxreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsIBX11.bdsproj b/official/4.2/LibD11/dclfsIBX11.bdsproj new file mode 100644 index 0000000..79b6c8f --- /dev/null +++ b/official/4.2/LibD11/dclfsIBX11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsIBX11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsIBX11.dpk b/official/4.2/LibD11/dclfsIBX11.dpk new file mode 100644 index 0000000..d7acc37 --- /dev/null +++ b/official/4.2/LibD11/dclfsIBX11.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2007 + +package dclfsIBX11; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs11, + fsIBX11; + +contains + fs_iibxreg in 'fs_iibxreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsIBX5.dpk b/official/4.2/LibD11/dclfsIBX5.dpk new file mode 100644 index 0000000..1c6e40b --- /dev/null +++ b/official/4.2/LibD11/dclfsIBX5.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 5 + +package dclfsIBX5; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + fs5, + fsIBX5; + +contains + fs_iibxreg in 'fs_iibxreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsIBX6.dpk b/official/4.2/LibD11/dclfsIBX6.dpk new file mode 100644 index 0000000..5e09acd --- /dev/null +++ b/official/4.2/LibD11/dclfsIBX6.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 6 + +package dclfsIBX6; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs6, + fsIBX6; + +contains + fs_iibxreg in 'fs_iibxreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsIBX7.dpk b/official/4.2/LibD11/dclfsIBX7.dpk new file mode 100644 index 0000000..04ff045 --- /dev/null +++ b/official/4.2/LibD11/dclfsIBX7.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 7 + +package dclfsIBX7; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs7, + fsIBX7; + +contains + fs_iibxreg in 'fs_iibxreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsIBX9.bdsproj b/official/4.2/LibD11/dclfsIBX9.bdsproj new file mode 100644 index 0000000..e5dfa3d --- /dev/null +++ b/official/4.2/LibD11/dclfsIBX9.bdsproj @@ -0,0 +1,168 @@ + + + + + + + + + + + + dclfsIBX9.dpk + + + 7.0 + + + 8 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + False + False + False + True + True + True + + + 0 + 0 + 1 + False + False + False + 16384 + 1048576 + 4194304 + FastScript 1.9 IBX Components + + + + + + + + + + + False + + + + + + False + + + + + + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + diff --git a/official/4.2/LibD11/dclfsIBX9.dpk b/official/4.2/LibD11/dclfsIBX9.dpk new file mode 100644 index 0000000..bda27bc --- /dev/null +++ b/official/4.2/LibD11/dclfsIBX9.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2005 + +package dclfsIBX9; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 IBX Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs9, + fsIBX9; + +contains + fs_iibxreg in 'fs_iibxreg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsTee10.bdsproj b/official/4.2/LibD11/dclfsTee10.bdsproj new file mode 100644 index 0000000..c61771e --- /dev/null +++ b/official/4.2/LibD11/dclfsTee10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsTee10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsTee10.dpk b/official/4.2/LibD11/dclfsTee10.dpk new file mode 100644 index 0000000..26394bf --- /dev/null +++ b/official/4.2/LibD11/dclfsTee10.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2006 + +package dclfsTee10; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs10, + fsTee10; + +contains + fs_iteereg in 'fs_iteereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsTee11.bdsproj b/official/4.2/LibD11/dclfsTee11.bdsproj new file mode 100644 index 0000000..613cb95 --- /dev/null +++ b/official/4.2/LibD11/dclfsTee11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsTee11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsTee11.dpk b/official/4.2/LibD11/dclfsTee11.dpk new file mode 100644 index 0000000..8521499 --- /dev/null +++ b/official/4.2/LibD11/dclfsTee11.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2007 + +package dclfsTee11; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs11, + fsTee11; + +contains + fs_iteereg in 'fs_iteereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsTee4.dpk b/official/4.2/LibD11/dclfsTee4.dpk new file mode 100644 index 0000000..c38f46e --- /dev/null +++ b/official/4.2/LibD11/dclfsTee4.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 4 + +package dclfsTee4; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + fs4, + fsTee4; + +contains + fs_iteereg in 'fs_iteereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsTee5.dpk b/official/4.2/LibD11/dclfsTee5.dpk new file mode 100644 index 0000000..d7c96c8 --- /dev/null +++ b/official/4.2/LibD11/dclfsTee5.dpk @@ -0,0 +1,40 @@ +// Package file for Delphi 5 + +package dclfsTee5; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + fs5, + fsTee5; + +contains + fs_iteereg in 'fs_iteereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsTee6.dpk b/official/4.2/LibD11/dclfsTee6.dpk new file mode 100644 index 0000000..2b187c0 --- /dev/null +++ b/official/4.2/LibD11/dclfsTee6.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 6 + +package dclfsTee6; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs6, + fsTee6; + +contains + fs_iteereg in 'fs_iteereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsTee7.dpk b/official/4.2/LibD11/dclfsTee7.dpk new file mode 100644 index 0000000..a0bd3d5 --- /dev/null +++ b/official/4.2/LibD11/dclfsTee7.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 7 + +package dclfsTee7; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs7, + fsTee7; + +contains + fs_iteereg in 'fs_iteereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsTee9.bdsproj b/official/4.2/LibD11/dclfsTee9.bdsproj new file mode 100644 index 0000000..06055e2 --- /dev/null +++ b/official/4.2/LibD11/dclfsTee9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + dclfsTee9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/dclfsTee9.dpk b/official/4.2/LibD11/dclfsTee9.dpk new file mode 100644 index 0000000..98f07bd --- /dev/null +++ b/official/4.2/LibD11/dclfsTee9.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2005 + +package dclfsTee9; + +{$R 'fs_ireg.dcr'} + +{$DESCRIPTION 'FastScript 1.9 Tee Components'} +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + DESIGNIDE, + fs9, + fsTee9; + +contains + fs_iteereg in 'fs_iteereg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsx.dpk b/official/4.2/LibD11/dclfsx.dpk new file mode 100644 index 0000000..83340eb --- /dev/null +++ b/official/4.2/LibD11/dclfsx.dpk @@ -0,0 +1,46 @@ +// Package file for CLX + +package dclfsx; + +{$R *.res} +{$R 'fs_ireg.dcr'} +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'FastScript 1.9 Components'} +{$DESIGNONLY} +{$IMPLICITBUILD OFF} + +requires + rtl, + designide, + visualclx, + fsx +{$IFNDEF LINUX} +, bdertl, + adortl, + tee +{$ENDIF}; + +contains + fs_ireg in 'fs_ireg.pas'; + +end. diff --git a/official/4.2/LibD11/dclfsx.res b/official/4.2/LibD11/dclfsx.res new file mode 100644 index 0000000..fa40de9 Binary files /dev/null and b/official/4.2/LibD11/dclfsx.res differ diff --git a/official/4.2/LibD11/deflate.zobj b/official/4.2/LibD11/deflate.zobj new file mode 100644 index 0000000..8cf3759 Binary files /dev/null and b/official/4.2/LibD11/deflate.zobj differ diff --git a/official/4.2/LibD11/fqb.dcr b/official/4.2/LibD11/fqb.dcr new file mode 100644 index 0000000..1f3ca4c Binary files /dev/null and b/official/4.2/LibD11/fqb.dcr differ diff --git a/official/4.2/LibD11/fqb.inc b/official/4.2/LibD11/fqb.inc new file mode 100644 index 0000000..6ec0138 --- /dev/null +++ b/official/4.2/LibD11/fqb.inc @@ -0,0 +1,120 @@ +{*******************************************} +{ } +{ FastQueryBuilder v1.03 } +{ Include file } +{ } +{ Copyright (c) 2004-2005 } +{ Fast Reports Inc. } +{ } +{*******************************************} + + +{$B-} {- Complete Boolean Evaluation } +{$R-} {- Range-Checking } +{$V-} {- Var-String Checking } +{$T-} {- Typed @ operator } +{$X+} {- Extended syntax } +{$P+} {- Open string params } +{$J+} {- Writeable structured consts } +{$H+} {- Use long strings by default } + +{$IFDEF VER120} // Delphi 4.0 + {$DEFINE Delphi4} +{$ENDIF} + +{$IFDEF VER130} // Delphi 5.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} +{$ENDIF} + +{$IFDEF VER140} // Delphi 6.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} +{$ENDIF} + +{$IFDEF VER150} // Delphi 7.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN SYMBOL_PLATFORM OFF} +{$ENDIF} + +{$IFDEF VER170} // Delphi 9.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$WARN UNSAFE_CODE OFF} +{$ENDIF} + +{$IFDEF VER180} // Delphi 10.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$DEFINE Delphi10} + {$WARN UNSAFE_CODE OFF} +{$ENDIF} + +{$IFDEF VER185} // Delphi 11.0 (Spacely) + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$DEFINE Delphi10} + {$DEFINE Delphi11} + {$WARN UNSAFE_CODE OFF} +{$ENDIF} + +{$IFDEF VER190} // Delphi 11.0 (Highlander) + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$DEFINE Delphi10} + {$DEFINE Delphi11} + {$WARN UNSAFE_CODE OFF} +{$ENDIF} + +{$IFDEF VER93} // Borland C++ Builder 1.0 + {$DEFINE Delphi2} +{$ENDIF} + +{$IFDEF VER110} // Borland C++ Builder 3.0 + {$DEFINE Delphi3} + {$ObjExportAll on} +{$ENDIF} + +{$IFDEF VER125} // Borland C++ Builder 4.0 + {$DEFINE Delphi4} + {$ObjExportAll on} +{$ENDIF} + +{$IFDEF VER130} // Borland C++ Builder 5.0 + {$IFDEF BCB} + {$ObjExportAll on} + {$ENDIF} +{$ENDIF} + +{$IFDEF VER140} // Borland C++ Builder 6.0 + {$IFDEF BCB} + {$ObjExportAll on} + {$ENDIF} +{$ENDIF} + +{$IFDEF VER150} // Borland C++ Builder 7.0 + {$IFDEF BCB} + {$ObjExportAll on} + {$WARN UNSAFE_CODE OFF} + {$ENDIF} +{$ENDIF} + +{$WARNINGS OFF} diff --git a/official/4.2/LibD11/fqb.lrs b/official/4.2/LibD11/fqb.lrs new file mode 100644 index 0000000..f9246f9 --- /dev/null +++ b/official/4.2/LibD11/fqb.lrs @@ -0,0 +1,434 @@ +LazarusResources.Add('TFQBDIALOG','BMP',[ + 'BM'#248#6#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#24#0#0#0#24#0#0#0#1#0#24#0#0#0#0#0 + +#194#6#0#0#18#11#0#0#18#11#0#0#0#0#0#0#0#0#0#0#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#156'7'#14#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#155'7'#15#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#156'7'#14#255#255#255#255#255#255#255#255#255#255#255#255#187's' + +'B'#186'o@'#184'l='#182'h:'#181'e7'#178'b4'#177'_1'#175'\/'#174'Y,'#171'U)' + +#170'S'''#168'O$'#166'L!'#165'J'#31#163'G'#29#161'D'#27#160'A'#24#157'<'#19 + +#156'9'#15#156'7'#14#156'8'#16#155'7'#15#255#255#255#255#255#255#189'uE'#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#155'7'#15#228 + +#172#142#155'8'#15#255#255#255#255#255#255#191'xG'#248#248#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#14'z'#27#248#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#155'7'#15#156'7'#14#255#255 + +#255#255#255#255#192'zI'#248#248#248#248#248#248#248#248#248#248#248#248#14 + +'z'#27#14'z'#27'N'#210'x'#14'z'#27#248#248#248#175'Z-'#173'W+'#171'T('#169'Q' + +'&'#168'N#'#166'K '#164'H'#30#162'E'#28#160'B'#25#156':'#16#248#248#248#156 + +'8'#15#163'D'#30#255#255#255#193'}K'#248#248#248#248#248#248#248#248#248#28 + +#142'0N'#210'xZ'#226#137']'#230#142'R'#217'~'#14'z'#27#176']0'#248#248#248 + +#180'e7'#248#248#248#234#179#139#224#162'z'#155'7'#15#248#248#248#234#179#139 + +#160'A'#24#248#248#248#156'9'#15#156'7'#14#255#255#255#195#128'M'#248#248#248 + +#248#248#248#28#142'0.'#180'O%'#161'>'#24#151'#^'#231#143'/'#154'@'#248#248 + +#248#178'`3'#248#248#248#180'e7'#248#248#248#217'vN'#213'rJ'#160';'#18#176'L' + +'#'#248#248#248#162'D'#27#248#248#248#155'8'#15#156'7'#14#255#255#255#197#130 + +'P'#248#248#248#248#248#248#24#151'#;'#163'J'#248#248#248#248#248#248'/'#154 + +'@'#248#248#248#248#248#248#179'c5'#248#248#248#180'e7'#248#248#248#234#179 + +#139#234#179#139#248#248#248#156'7'#14#155'7'#15#160'@'#22#155'7'#15#156'7' + +#14#202#148'~'#255#255#255#197#133'R'#248#248#248#248#248#248#18#130#28#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#180'e7' + +#174'[.'#174'[.'#174'[.'#174'[.'#174'[.'#174'[.'#169'Q%'#176']0'#156':'#18 + +#155'7'#15#156'9'#15#255#255#255#255#255#255#199#135'S'#248#248#248#196#130 + +'O'#194'L'#193'|J'#191'yG'#190'uD'#188'sB'#186'o?'#184'l='#182'h:'#228#172 + +#142#180'e7'#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#156';'#17#248#248#248#156':'#16#255#255#255#255#255#255#200#138'V' + +#248#248#248#198#132'Q'#248#248#248#202#141'Y'#248#248#248#234#179#139#234 + +#179#139#234#179#139#234#179#139#248#248#248#182'h9'#179'e6'#178'a3'#176'^1' + +#163'G'#28#157'<'#18#156':'#16#156':'#16#156':'#16#248#248#248#156':'#16#255 + +#255#255#255#255#255#202#139'X'#248#248#248#198#134'T'#248#248#248#202#141'Y' + +#248#248#248#217'vN'#217'vN'#217'vN'#217'vN'#248#248#248#183'k<'#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#165'K '#255#255#255#255#255#255#203#142'Z'#248#248#248 + +#200#136'V'#248#248#248#202#141'Y'#234#179#139#234#179#139#234#179#139#234 + +#179#139#234#179#139#248#248#248#185'm>'#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#167 + +'N#'#255#255#255#255#255#255#204#144'['#248#248#248#202#139'W'#195'M'#195'' + +'M'#195'M'#195'M'#195'M'#195'M'#195'M'#195'M'#187'pA'#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#168'P%'#255#255#255#255#255#255#205#145'\'#248#248#248#202 + +#141'Y'#248#248#248#202#141'Y'#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#248#248#188'tB'#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#170'R''' + ,#255#255#255#255#255#255#206#147'^'#248#248#248#203#143'['#202#140'X'#201#138 + +'W'#200#136'T'#198#133'R'#196#130'P'#195'M'#193'|J'#192'yH'#190'vE'#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#248#172'U)'#255#255#255#255#255#255#207#149'`'#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248#248 + +#248#173'Y,'#255#255#255#255#255#255#207#150'a'#206#149'_'#205#147'^'#205#144 + +'\'#203#143'Z'#202#140'X'#201#138'V'#199#135'S'#197#132'R'#196#129'O'#194'L' + +#193'{I'#190'xG'#189'uD'#188'rA'#186'o?'#184'l<'#181'h9'#180'e6'#178'b3'#177 + +'^1'#175'[/'#255#255#255#255#255#255#208#152'b'#208#150'`'#207#148'_'#206#146 + +'^'#204#144'['#203#142'Z'#201#140'X'#200#137'V'#198#135'S'#197#132'Q'#196#128 + +'N'#194'~L'#192'zI'#191'xF'#189'tD'#187'qA'#186'n?'#184'k<'#182'h9'#179'd6' + +#178'a3'#176']1'#255#255#255#255#255#255#209#153'c'#208#151'a'#207#150'a'#206 + +#148'_'#205#146'^'#204#144'['#203#141'Y'#201#139'W'#200#137'V'#199#134'S'#197 + +#131'Q'#195#129'N'#194'}L'#192'zI'#190'wG'#188'tD'#187'qA'#185'n?'#183'k<' + +#181'g9'#179'd6'#178'`3'#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#0#0 +]); +LazarusResources.Add('TFQBTABLEAREA','BMP',[ + 'BM'#248#6#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#24#0#0#0#24#0#0#0#1#0#24#0#0#0#0#0 + +#194#6#0#0#18#11#0#0#18#11#0#0#0#0#0#0#0#0#0#0#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#185'n>'#184'k<'#182'i:'#181'f8' + +#179'd5'#178'a3'#177'^0'#175'[.'#174'Y-'#173'V*'#171'T('#169'R&'#168'P$'#167 + +'M"'#166'K '#165'I'#30#164'F'#29#163'E'#27#162'C'#25#161'A'#24#160'@'#23#159 + +'>'#21#255#255#255#255#255#255#187'q@'#250#244#234#159'>'#21#250#243#231#250 + +#243#229#250#242#228#250#241#227#249#241#226#250#240#224#249#240#224#249#239 + +#222#249#238#221#248#238#220#249#238#219#248#237#218#248#236#218#248#236#216 + +#159'>'#21#247#235#215#159'>'#21#247#235#213#160'?'#22#255#255#255#255#255 + +#255#188'sC'#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159 + +'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21 + +#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#161'@'#24#255 + +#255#255#255#255#255#190'uD'#251#245#234#250#244#233#250#244#231#250#244#230 + +#250#242#229#249#242#228#249#242#227#249#241#225#249#240#224#249#240#222#249 + +#240#222#248#239#221#248#238#220#247#238#219#248#237#218#247#237#217#247#237 + +#216#247#237#215#159'>'#21#247#236#214#161'B'#25#255#255#255#255#255#255#191 + +'xG'#251#246#235#251#245#234#250#245#233#250#244#231#250#244#231#249#243#229 + +#249#242#228#249#242#227#249#241#226#249#241#224#248#240#223#248#240#222#248 + +#239#221#248#238#220#248#238#218#248#237#217#248#237#216#248#237#216#159'>' + +#21#159'>'#21#162'D'#26#255#255#255#255#255#255#192'{I'#251#247#237#251#246 + +#235#251#245#235#250#244#233#250#244#232#250#243#230#250#243#229#250#242#227 + +#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#248 + +#238#217#159'>'#21#247#236#216#164'F'#29#255#255#255#255#255#255#193'}K'#252 + +#246#239#251#247#237#251#245#235#251#246#234#250#244#233#250#243#231#250#243 + +#231#250#243#229#173'V*'#249#242#226#249#241#226#249#241#224#249#240#222#248 + +#240#222#249#239#221#248#238#220#173'V*'#248#238#217#159'>'#21#248#236#217 + +#165'I'#30#255#255#255#255#255#255#194'M'#252#247#240#251#246#238#251#246 + +#237#251#246#236#251#245#235#250#244#233#250#244#232#250#243#230#173'V*'#249 + +#242#228#199'm@'#199'm@'#199'm@'#199'm@'#199'm@'#248#238#221#173'V*'#248#238 + +#219#159'>'#21#249#237#218#166'J'#31#255#255#255#255#255#255#196#129'O'#252 + +#248#241#252#247#239#251#247#238#249#243#229#249#243#229'$'#141'4'#249#243 + +#229#249#243#229#173'V*'#249#243#229#173'V*'#173'V*'#173'V*'#173'V*'#173'V*' + +#248#239#222#173'V*'#248#239#219#159'>'#21#248#238#219#167'L!'#255#255#255 + +#255#255#255#198#132'Q'#252#248#242#252#248#241#239#242#229'7'#152'E'#22#133 + +'&R'#216'~&'#156'?'#249#243#229#173'V*'#250#243#230#249#243#229#250#242#227 + +#250#241#227#250#241#226#249#241#224#249#240#222#173'V*'#248#239#221#159'>' + +#21#249#238#220#169'N#'#255#255#255#255#255#255#198#134'S'#252#249#243#239 + +#243#231'8'#156'HE'#199'kU'#221#129'`'#234#146'\'#228#138#25#137'+'#173'V*' + +#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#249#239#222 + +#159'>'#21#249#238#221#170'Q%'#255#255#255#255#255#255#200#136'T'#252#250#245 + +'?'#159'L0'#177'MC'#174'Y:'#159'=P'#212'xB'#168'T'#252#249#242#252#249#242 + +#250#245#233#250#244#232#250#243#231#250#243#230#250#242#228#249#241#227#249 + +#241#226#249#240#224#248#240#223#159'>'#21#248#239#223#171'S'''#255#255#255 + +#255#255#255#201#138'W'#253#250#245'7'#162'=@'#163'K'#252#249#242#252#248#241 + +'W'#169'^'#252#249#242#251#246#237#251#245#235#251#245#234#251#244#233#250 + +#244#231#250#243#230#250#243#229#249#242#227#249#242#226#249#241#226#249#241 + +#224#159'>'#21#249#239#224#171'U)'#255#255#255#255#255#255#201#140'X'#253#250 + +#246#31#136'('#252#249#242#253#249#243#252#249#242#251#248#241#252#247#240 + +#251#247#238#251#246#237#251#246#236#251#246#234#251#245#233#251#244#232#250 + +#244#230#250#243#229#249#242#228#249#242#226#249#242#226#159'>'#21#249#240 + +#225#173'X+'#255#255#255#255#255#255#203#142'Z'#253#251#247#173'V*'#173'V*' + +#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#251#245#235#251#245 + +#235#250#244#233#250#244#232#250#244#231#250#243#229#250#242#228#249#241#226 + +#159'>'#21#249#240#226#175'Z-'#255#255#255#255#255#255#204#144'['#253#251#248 + +#173'V*'#253#250#247#253#250#246#252#249#245#252#249#243#252#249#242#252#248 + +#241#252#247#240#173'V*'#251#246#237#251#246#236#251#245#234#251#244#233#250 + +#244#231#250#243#230#250#243#229#250#243#228#159'>'#21#250#241#227#175']/' + +#255#255#255#255#255#255#205#146']'#254#252#249#173'V*'#253#251#247#199'm@' + +#199'm@'#199'm@'#199'm@'#199'm@'#252#248#240#173'V*'#252#247#238#251#246#237 + +#251#246#235#251#245#234#250#244#233#250#243#232#250#243#230#250#242#229#159 + +'>'#21#250#241#228#177'_1'#255#255#255#255#255#255#206#147'^'#253#252#250#173 + ,'V*'#254#251#248#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#252#248#242#173'V*' + +#252#248#240#251#247#238#251#247#237#251#246#235#251#245#235#251#244#233#251 + +#244#231#250#243#230#159'>'#21#250#242#229#179'a3'#255#255#255#255#255#255 + +#206#148'^'#254#252#251#173'V*'#253#251#249#254#251#248#253#251#248#253#251 + +#247#253#250#245#253#249#244#252#249#243#173'V*'#252#248#241#252#247#239#252 + +#247#239#251#246#237#251#246#236#251#245#234#251#245#233#250#244#232#159'>' + +#21#250#243#231#180'd6'#255#255#255#255#255#255#206#149'`'#254#252#251#173'V' + +'*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#173'V*'#253#248 + +#242#251#248#241#252#248#240#251#247#238#252#246#236#251#246#236#251#245#234 + +#251#245#233#159'>'#21#159'>'#21#181'f8'#255#255#255#255#255#255#207#151'a' + +#254#253#252#254#252#252#254#252#251#253#252#250#254#252#249#254#252#249#253 + +#251#247#253#250#246#253#250#245#253#250#244#252#249#243#253#249#242#252#248 + +#241#252#248#240#251#247#238#251#246#237#251#246#235#250#245#234#159'>'#21 + +#251#244#234#182'i:'#255#255#255#255#255#255#208#152'b'#207#151'a'#206#149'`' + +#206#148'_'#205#147']'#204#145'\'#203#143'['#202#141'Y'#201#139'X'#200#137'V' + +#199#136'T'#197#133'R'#196#131'O'#195#128'N'#194'~L'#192'{J'#192'yH'#189'vF' + +#188'sC'#186'qA'#186'n?'#184'l='#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#0#0 +]); +LazarusResources.Add('TFQBTABLELISTBOX','BMP',[ + 'BM'#248#6#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#24#0#0#0#24#0#0#0#1#0#24#0#0#0#0#0 + +#194#6#0#0#18#11#0#0#18#11#0#0#0#0#0#0#0#0#0#0#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#185'm='#183'j;'#182'h8'#180'e6' + +#179'c5'#178'`3'#176'^0'#175'[.'#174'Y,'#172'W*'#171'U('#169'R&'#169'P$'#168 + +'M#'#167'L '#166'J '#164'H'#29#163'F'#28#162'E'#26#161'C'#25#161'B'#24#160'@' + +#23#255#255#255#255#255#255#185'o?'#250#244#233#251#243#232#250#243#231#250 + +#243#230#250#242#228#250#242#227#249#242#227#249#241#227#249#240#225#249#240 + +#225#248#240#224#248#239#224#248#238#223#248#238#221#248#238#220#248#238#220 + +#247#237#220#247#237#219#159'>'#21#247#237#218#160'A'#24#255#255#255#255#255 + +#255#187'rA'#251#244#234#250#244#233#250#244#232#250#243#231#250#242#230#250 + +#242#230#250#242#229#250#241#228#249#240#227#249#240#226#248#240#225#249#239 + +#224#248#239#223#248#238#222#248#238#222#248#237#222#248#237#221#247#238#220 + +#159'>'#21#159'>'#21#162'C'#25#255#255#255#255#255#255#189'tC'#251#245#235 + +#176'X'#0#176'X'#0#176'X'#0#176'X'#0#249#243#231#176'X'#0#176'X'#0#176'X'#0 + +#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#248 + +#238#220#159'>'#21#247#237#220#163'E'#26#255#255#255#255#255#255#189'wF'#251 + +#245#237#251#245#236#251#244#235#250#244#233#250#243#232#250#243#232#250#243 + +#231#249#242#230#250#242#229#250#242#228#250#241#227#249#240#226#249#240#226 + +#249#240#225#249#239#223#249#239#222#248#239#222#248#238#222#159'>'#21#248 + +#238#220#163'G'#28#255#255#255#255#255#255#191'yH'#251#246#238#176'X'#0#176 + +'X'#0#176'X'#0#176'X'#0#250#243#232#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176 + +'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#248#238#222#159 + +'>'#21#248#238#221#164'H'#30#255#255#255#255#255#255#193'|J'#251#246#239#251 + +#245#238#251#245#237#250#244#236#251#244#234#251#244#234#250#244#234#250#243 + +#233#250#243#232#250#243#230#250#242#230#249#241#228#249#241#227#249#241#226 + +#248#241#225#248#239#225#248#239#224#248#239#223#159'>'#21#248#239#222#165'J' + +#31#255#255#255#255#255#255#194'~L'#252#247#240#209#153'c'#209#153'c'#209#153 + +'c'#209#153'c'#251#245#236#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209 + +#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#249 + +#240#225#159'>'#21#248#238#223#167'L '#255#255#255#255#255#255#195#129'N'#251 + +#247#241#252#247#240#252#246#239#252#246#238#251#245#237#251#245#237#251#245 + +#236#251#244#235#251#244#234#250#243#232#250#243#231#249#242#230#250#242#229 + +#249#242#228#249#242#227#249#240#227#249#240#226#249#240#225#159'>'#21#249 + +#240#224#168'M"'#255#255#255#255#255#255#196#131'P'#252#248#242#209#153'c' + +#209#153'c'#209#153'c'#209#153'c'#251#246#238#209#153'c'#209#153'c'#209#153 + +'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153 + +'c'#209#153'c'#249#241#226#159'>'#21#249#240#224#169'P%'#255#255#255#255#255 + +#255#197#133'R'#253#248#243#252#248#242#252#248#241#252#247#241#252#246#240 + +#252#246#238#251#246#238#251#245#237#251#245#236#250#245#235#251#244#234#250 + +#243#233#250#243#232#250#242#231#250#242#230#250#242#230#249#242#229#249#241 + +#228#159'>'#21#248#240#226#170'R&'#255#255#255#255#255#255#198#135'T'#253#249 + +#244#209#153'c'#209#153'c'#209#153'c'#209#153'c'#252#247#240#209#153'c'#209 + +#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209 + +#153'c'#209#153'c'#209#153'c'#250#241#229#159'>'#21#249#240#227#171'U('#255 + +#255#255#255#255#255#199#137'U'#253#250#246#252#248#244#252#249#243#252#248 + +#242#252#247#241#252#247#241#252#247#240#252#247#239#252#246#238#251#246#238 + +#251#245#236#251#245#235#251#244#234#250#244#234#250#244#233#250#244#231#250 + +#243#231#250#242#230#159'>'#21#250#241#228#172'W*'#255#255#255#255#255#255 + +#200#139'W'#253#249#246'Z'#2#2'Z'#2#2'Z'#2#2'Z'#2#2#253#248#241'Z'#2#2'Z'#2#2 + +'Z'#2#2'Z'#2#2'Z'#2#2'Z'#2#2'Z'#2#2'Z'#2#2'Z'#2#2'Z'#2#2'Z'#2#2#250#243#231 + +#159'>'#21#250#241#229#174'Y,'#255#255#255#255#255#255#201#141'Y'#253#250#247 + +#253#250#246#253#249#245#253#249#244#252#248#244#252#248#244#252#248#243#252 + +#248#242#252#247#241#252#246#239#251#246#238#251#246#238#251#246#237#251#245 + +#235#251#244#235#251#244#234#250#244#233#250#243#232#159'>'#21#249#242#230 + +#175'[.'#255#255#255#255#255#255#202#143'Z'#253#251#248#176'X'#0#176'X'#0#176 + +'X'#0#176'X'#0#253#249#244#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176 + +'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#250#244#234#159'>'#21#250 + +#243#232#176'^0'#255#255#255#255#255#255#203#145'\'#254#251#249#254#250#248 + +#253#250#247#253#250#247#253#250#247#253#250#246#253#249#244#252#249#243#252 + +#248#243#253#247#241#252#247#240#252#247#240#252#246#239#251#246#238#251#245 + +#237#250#245#237#250#245#236#251#244#235#159'>'#21#250#243#232#178'a2'#255 + ,#255#255#255#255#255#204#146'\'#253#251#250#176'X'#0#176'X'#0#176'X'#0#176'X' + +#0#253#250#245#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0 + +#176'X'#0#176'X'#0#176'X'#0#176'X'#0#251#245#236#159'>'#21#250#244#234#179'c' + +'4'#255#255#255#255#255#255#205#148'^'#253#251#250#254#251#249#254#251#249 + +#253#250#248#253#251#247#253#251#246#253#250#246#253#249#246#253#249#245#252 + +#249#244#252#248#243#252#248#242#252#247#241#252#247#240#252#247#239#252#247 + +#239#252#246#238#251#246#237#159'>'#21#251#245#235#180'e7'#255#255#255#255 + +#255#255#206#148'_'#254#252#250#176'X'#0#176'X'#0#176'X'#0#176'X'#0#254#250 + +#248#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0 + +#176'X'#0#176'X'#0#176'X'#0#252#246#238#159'>'#21#159'>'#21#182'h9'#255#255 + +#255#255#255#255#207#150'`'#254#252#251#254#252#250#254#251#250#254#251#250 + +#253#251#250#253#251#248#253#251#248#254#251#248#253#250#247#253#250#246#253 + +#250#245#252#248#244#253#248#243#252#248#242#252#248#241#252#248#241#252#247 + +#241#251#247#239#159'>'#21#251#245#237#183'k;'#255#255#255#255#255#255#207 + +#151'a'#206#150'`'#206#148'_'#205#147'^'#205#146']'#203#144'\'#203#143'Z'#201 + +#141'X'#201#140'W'#199#137'U'#199#135'S'#197#133'Q'#196#131'P'#195#128'N'#194 + +'~L'#193'|I'#191'zH'#189'wE'#189'uD'#188'rB'#186'p@'#185'm>'#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#0#0 +]); +LazarusResources.Add('TFQBSYNTAXMEMO','BMP',[ + 'BM'#248#6#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#24#0#0#0#24#0#0#0#1#0#24#0#0#0#0#0 + +#194#6#0#0#18#11#0#0#18#11#0#0#0#0#0#0#0#0#0#0#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#183'k;'#181'g8'#180'd7'#179'b4' + +#177'`1'#175']/'#174'Z-'#172'W+'#171'U('#170'R&'#168'O$'#167'M"'#166'K'#31 + +#165'I'#30#163'F'#28#162'D'#26#161'B'#24#160'@'#23#159'?'#21#158'<'#20#158';' + +#18#157':'#17#255#255#255#255#255#255#184'm='#251#245#237#251#245#236#251#244 + +#235#251#244#234#250#244#233#250#243#232#249#243#231#250#242#230#250#241#229 + +#249#241#229#249#241#227#248#241#227#249#240#226#248#240#225#248#240#224#248 + +#239#224#248#238#223#248#238#222#247#238#221#247#238#221#158';'#18#255#255 + +#255#255#255#255#186'p@'#251#246#238#251#245#237'QPBQPBQPBQPBQPB'#250#243#231 + +#249#243#230#249#242#229#250#241#228#249#241#227#249#241#227#248#240#226#248 + +#240#225#249#239#225#248#239#223#248#239#223#247#238#222#247#238#222#158'<' + +#20#255#255#255#255#255#255#187'rB'#251#246#238#252#246#238'cfRcfRcfRcfRcfR' + +#250#243#233#249#243#231#249#242#230#249#242#229#249#241#228#249#241#228#249 + +#240#226#249#240#226#248#240#225#248#239#224#248#239#223#248#238#223#247#238 + +#222#159'>'#21#255#255#255#255#255#255#189'uD'#252#246#239#251#246#239#251 + +#246#237#251#245#236#251#245#236#251#245#235#250#244#234#250#244#233#249#243 + +#232#249#242#231#250#242#231#250#242#229#249#242#229#248#241#227#249#241#227 + +#248#240#226#248#240#225#248#240#224#248#239#223#248#238#223#160'@'#23#255 + +#255#255#255#255#255#191'xF'#252#247#241#251#247#239#251#246#239#251#246#238 + +#251#245#237#251#245#236'QPBQPBQPBQPBQPBQPBQPB'#249#242#228#249#241#227#248 + +#241#227#249#241#226#248#240#225#248#240#225#248#239#223#161'B'#25#255#255 + +#255#255#255#255#192'zI'#252#248#241#251#247#241#252#246#240#251#246#239#251 + +#246#238#251#245#236'cfRcfRcfRcfRcfRcfRcfR'#249#242#229#249#241#229#249#241 + +#227#249#241#227#248#240#226#248#240#225#249#239#224#162'D'#26#255#255#255 + +#255#255#255#194'}K'#252#248#242#252#248#241#251#247#241#251#247#240#251#246 + +#238#252#246#238#251#245#237#251#245#236#251#244#235#250#244#234#250#243#233 + +#250#244#232#250#243#231#250#242#230#249#242#229#250#241#228#248#241#227#248 + +#240#227#249#240#226#248#240#225#164'F'#28#255#255#255#255#255#255#195'M' + +#252#249#243#252#248#243#252#247#242#252#248#240#252#247#240#251#246#239#251 + +#246#238#3' '#250#251#245#236#3' '#250#3' '#250#3' '#250#3' '#250#3' '#250#3 + +' '#250#4#6#232#4#6#232#4#6#232#4#6#232#248#241#226#164'H'#30#255#255#255#255 + +#255#255#196#130'O'#252#249#245#252#249#243#252#248#242#252#248#241#252#248 + +#241#252#246#240#252#246#239#3' '#250#250#245#237#3' '#250#3' '#250#3' '#250 + +#3' '#250#3' '#250#4#6#232#4#6#232#4#6#232#4#6#232#4#6#232#249#241#227#166'J' + +' '#255#255#255#255#255#255#198#132'Q'#253#249#245#252#248#244#252#248#243 + +#252#248#242#252#248#241#251#247#240#251#246#240#251#246#239#251#246#238#251 + +#245#237#250#245#236#251#244#235#250#244#234#250#244#233#250#243#232#250#243 + +#232#249#242#231#250#242#229#249#242#229#249#241#228#167'M"'#255#255#255#255 + +#255#255#199#135'S'#253#249#246#253#249#245#252#248#244#252#249#243#253#248 + +#242#251#248#241'QPBQPBQPBQPBQPBQPBQPBQPBQPBQPB'#250#243#231#250#242#231#249 + +#241#229#249#242#229#168'P$'#255#255#255#255#255#255#200#136'U'#253#250#246 + +#253#250#246#253#249#245#253#249#244#252#249#243#252#248#243'cfRcfRcfRcfRcfR' + +'cfRcfRcfRcfRcfR'#249#243#232#249#243#231#249#242#230#249#242#230#170'R&'#255 + +#255#255#255#255#255#201#139'W'#253#250#248#253#250#247#253#250#245#253#249 + +#245#252#249#244#252#248#243#252#248#242#252#248#242#252#247#240#252#247#240 + +#251#246#239#251#246#238#251#246#237#251#245#236#250#244#235#250#244#235#250 + +#243#233#250#243#233#250#243#231#249#242#230#171'U('#255#255#255#255#255#255 + +#202#141'Y'#254#251#248#254#250#247#253#250#246#253#249#246#253#249#245#195 + +'ta'#195'ta'#195'ta'#195'ta'#195'ta'#195'ta'#252#246#239#251#245#238#251#246 + +#237#251#245#236#250#244#235#250#244#234#250#243#234#250#244#232#249#243#232 + +#172'W+'#255#255#255#255#255#255#203#143'Z'#253#251#248#254#251#248#253#250 + +#247#253#250#247#253#249#245#253#249#245#252#249#245#253#248#244#252#248#242 + +#252#247#241#251#247#240#252#247#240#251#246#239#251#245#238#251#245#237#251 + +#245#236#251#244#235#250#244#234#250#243#233#250#244#232#174'Z-'#255#255#255 + +#255#255#255#204#144'['#254#251#249#253#251#249#253#251#248#253#250#247#253 + +#250#246#195'ta'#195'ta'#195'ta'#195'ta'#195'ta'#195'ta'#195'ta'#251#247#240 + +#195'ta'#195'ta'#195'ta'#195'ta'#195'ta'#195'ta'#250#244#233#175'\/'#255#255 + +#255#255#255#255#205#147']'#254#252#250#254#251#249#253#251#249#253#250#248 + +#254#250#247#253#250#247#253#250#246#252#249#245#253#249#244#252#248#243#252 + +#248#243#252#248#242#252#247#241#252#246#240#252#246#239#251#245#238#251#245 + ,#237#251#244#236#251#244#235#250#244#234#177'_2'#255#255#255#255#255#255#206 + +#148'_'#254#252#250#254#251#249'QPBQPBQPBQPBQPBQPB'#252#249#245#252#249#244 + +#253#248#243#252#248#242#252#247#242#252#247#240#251#247#240#251#246#239#251 + +#246#238#251#246#237#251#245#236#251#244#235#179'b4'#255#255#255#255#255#255 + +#207#149'_'#254#252#251#254#252#250'cfRcfRcfRcfRcfRcfR'#253#250#246#253#249 + +#245#252#249#244#252#248#243#253#248#243#252#247#241#252#247#241#251#247#240 + +#252#246#238#251#246#238#251#245#237#251#245#236#180'e7'#255#255#255#255#255 + +#255#208#151'a'#254#252#251#254#251#251#254#252#250#254#251#250#253#251#250 + +#253#251#248#253#251#248#253#250#247#253#250#246#253#249#246#253#249#245#252 + +#248#245#252#248#243#252#248#243#252#248#242#252#247#241#252#247#240#251#246 + +#239#251#246#237#251#246#237#181'h8'#255#255#255#255#255#255#208#152'b'#207 + +#151'a'#207#150'`'#206#148'_'#205#146']'#204#144'\'#203#143'Z'#202#141'X'#201 + +#139'W'#200#137'U'#198#135'T'#197#132'R'#196#130'O'#194'M'#194'}K'#192'zI' + +#191'xF'#189'uD'#188'rB'#186'o?'#184'm>'#183'k;'#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#0#0 +]); +LazarusResources.Add('TFQBGRID','BMP',[ + 'BM'#248#6#0#0#0#0#0#0'6'#0#0#0'('#0#0#0#24#0#0#0#24#0#0#0#1#0#24#0#0#0#0#0 + +#194#6#0#0#18#11#0#0#18#11#0#0#0#0#0#0#0#0#0#0#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#177'a2'#178'c4'#180'e6'#181'h9'#182'j;'#184'm='#185'p?'#186'sB' + +#188'uD'#190'xF'#191'{H'#192'}K'#193'M'#195#129'N'#196#132'Q'#197#134'R'#199 + +#137'T'#199#138'V'#200#140'W'#201#142'X'#202#143'Z'#203#145'['#255#255#255 + +#255#255#255#176'^0'#252#247#241#159'>'#21#251#246#239#251#245#237#250#245 + +#236#250#244#235#250#243#233#250#243#233#249#243#231#249#242#230#249#242#229 + +#249#241#228#248#240#226#249#240#226#249#240#225#248#239#224#248#239#223#248 + +#239#222#248#238#222#247#238#221#202#144'Z'#255#255#255#255#255#255#175'\.' + +#252#247#242#159'>'#21#252#246#239#252#246#238#251#246#237#251#245#236#251 + +#245#235#250#243#234#250#242#232#250#242#231#249#242#229#249#241#229#249#241 + +#228#248#240#226#248#240#226#248#240#225#248#238#224#247#239#223#248#238#222 + +#247#238#221#201#142'Y'#255#255#255#255#255#255#174'[-'#252#248#243#159'>'#21 + +#252#247#241#176'X'#0#176'X'#0#176'X'#0#250#244#236#176'X'#0#176'X'#0#176'X' + +#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0 + +#176'X'#0#247#238#222#201#141'X'#255#255#255#255#255#255#173'Y+'#253#248#244 + +#159'>'#21#251#247#241#251#247#240#252#246#238#251#245#237#251#245#236#251 + +#245#235#251#244#234#250#244#233#250#242#232#250#242#231#249#241#230#249#241 + +#229#249#241#227#248#240#227#248#240#225#248#239#225#248#238#223#248#238#222 + +#200#140'W'#255#255#255#255#255#255#172'W*'#253#249#244#159'>'#21#252#247#242 + +#176'X'#0#176'X'#0#176'X'#0#251#246#238#176'X'#0#176'X'#0#176'X'#0#176'X'#0 + +#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#247 + +#239#223#199#138'U'#255#255#255#255#255#255#170'U('#252#249#245#159'>'#21#253 + +#248#243#252#247#242#251#247#241#252#246#239#251#246#239#251#246#237#251#244 + +#236#251#244#235#250#244#234#249#243#232#249#243#232#250#241#230#249#241#229 + +#249#241#228#248#240#227#249#240#226#248#240#225#248#239#224#198#137'T'#255 + +#255#255#255#255#255#169'S'''#253#249#246#159'>'#21#252#248#243#209#153'c' + +#209#153'c'#209#153'c'#251#247#239#209#153'c'#209#153'c'#209#153'c'#209#153 + +'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153 + +'c'#209#153'c'#248#239#225#198#134'S'#255#255#255#255#255#255#168'Q%'#253#249 + +#246#159'>'#21#252#249#245#252#249#243#252#248#243#252#248#242#251#246#240 + +#252#246#239#251#246#238#250#245#237#250#245#235#251#244#234#250#243#233#250 + +#243#232#249#242#230#249#241#229#249#241#228#248#241#227#249#241#227#249#239 + +#225#197#132'Q'#255#255#255#255#255#255#168'O#'#254#250#248#159'>'#21#253#249 + +#245#209#153'c'#209#153'c'#209#153'c'#252#247#242#209#153'c'#209#153'c'#209 + +#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209#153'c'#209 + +#153'c'#209#153'c'#248#241#228#248#240#226#196#131'P'#255#255#255#255#255#255 + +#167'N#'#253#251#248#159'>'#21#253#250#246#253#249#245#252#248#244#252#248 + +#243#252#247#242#251#247#241#252#247#240#251#246#239#251#246#238#251#245#236 + +#250#245#235#251#243#234#249#243#232#250#243#232#249#242#231#249#241#230#249 + +#241#228#248#240#227#194#129'N'#255#255#255#255#255#255#165'L!'#254#250#248 + +#159'>'#21#253#250#247#176'X'#0#176'X'#0#176'X'#0#252#248#243#176'X'#0#176'X' + +#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0 + +#176'X'#0#176'X'#0#248#241#228#194'L'#255#255#255#255#255#255#165'K'#31#253 + +#251#249#159'>'#21#253#250#248#253#250#247#253#250#245#253#249#245#253#249 + +#244#252#248#243#251#248#241#252#246#240#252#246#239#251#245#239#250#245#237 + +#251#244#236#250#244#235#250#244#233#250#243#232#249#242#231#249#241#230#249 + +#241#229#192'}K'#255#255#255#255#255#255#165'I'#31#253#251#249#159'>'#21#253 + +#251#248#176'X'#0#176'X'#0#176'X'#0#252#249#245#176'X'#0#176'X'#0#176'X'#0 + +#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#176'X'#0#250 + +#242#231#250#242#229#191'{I'#255#255#255#255#255#255#164'I'#30#254#252#251 + +#159'>'#21#253#251#249#253#251#248#254#250#247#253#250#246#253#249#245#252 + +#249#244#252#249#243#252#248#242#251#248#241#252#246#240#251#246#239#251#245 + ,#238#251#245#237#251#245#235#250#244#234#249#243#233#249#242#232#249#242#231 + +#190'yG'#255#255#255#255#255#255#163'G'#29#159'>'#21#159'>'#21#159'>'#21#159 + +'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21 + +#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>'#21#159'>' + +#21#159'>'#21#189'wF'#255#255#255#255#255#255#163'F'#28#254#252#251#159'>'#21 + +#253#251#250#254#251#249#253#251#248#253#250#248#253#250#247#253#250#246#252 + +#249#245#252#249#244#252#248#243#252#248#242#252#247#241#251#247#239#251#246 + +#238#251#245#237#250#244#236#250#244#234#250#243#234#250#243#232#188'uC'#255 + +#255#255#255#255#255#162'E'#27#163'F'#28#163'H'#29#164'I'#30#165'K'#31#166'L' + +'"'#167'N#'#168'Q$'#169'R'''#170'T('#172'W*'#173'Y,'#174'\.'#175'^0'#177'a2' + +#178'c5'#180'f7'#181'i9'#183'k;'#184'n='#186'q@'#187'sA'#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255#255 + +#255#255#255#255#255#0#0 +]); diff --git a/official/4.2/LibD11/fqb100.bdsproj b/official/4.2/LibD11/fqb100.bdsproj new file mode 100644 index 0000000..d28461b --- /dev/null +++ b/official/4.2/LibD11/fqb100.bdsproj @@ -0,0 +1,161 @@ + + + + + + + + + + + + fqb100.dpk + + + 9.0 + + + 8 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + + + 0 + 0 + 1 + False + False + False + 16384 + 1048576 + 4194304 + FastQueryBuilder 1.03 + + + + + + + + + + + False + + + + + + False + + + + + + False + + + + $00000000 + + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1053 + 1252 + + + diff --git a/official/4.2/LibD11/fqb100.dpk b/official/4.2/LibD11/fqb100.dpk new file mode 100644 index 0000000..60eebc3 --- /dev/null +++ b/official/4.2/LibD11/fqb100.dpk @@ -0,0 +1,47 @@ +package fqb100; + +{$ALIGN 8} +{$ASSERTIONS OFF} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS OFF} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS ON} +{$REFERENCEINFO OFF} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'FastQueryBuilder 1.03'} +{$RUNONLY} +{$IMPLICITBUILD OFF} +{$I fqb.inc} + +requires + vcl, + rtl, + vclx, + dbrtl, + vcldb, + bdertl + ; + +contains + fqbClass in 'fqbClass.pas' , + fqbSynmemo in 'fqbSynmemo.pas' {fqbSynmemo}, + fqbLinkForm in 'fqbLinkForm.pas' {fqbLinkForm}, + fqbUtils in 'fqbUtils.pas' , + fqbDesign in 'fqbDesign.pas' {fqbDesign}, + fqbZLib in 'fqbZLib.pas' + ; + +end. diff --git a/official/4.2/LibD11/fqb110.bdsproj b/official/4.2/LibD11/fqb110.bdsproj new file mode 100644 index 0000000..8ca5fc2 --- /dev/null +++ b/official/4.2/LibD11/fqb110.bdsproj @@ -0,0 +1,161 @@ + + + + + + + + + + + + fqb110.dpk + + + 9.0 + + + 8 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + + + 0 + 0 + 1 + False + False + False + 16384 + 1048576 + 4194304 + FastQueryBuilder 1.03 + + + + + + + + + + + False + + + + + + False + + + + + + False + + + + $00000000 + + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1053 + 1252 + + + diff --git a/official/4.2/LibD11/fqb110.dpk b/official/4.2/LibD11/fqb110.dpk new file mode 100644 index 0000000..34e5dc4 --- /dev/null +++ b/official/4.2/LibD11/fqb110.dpk @@ -0,0 +1,47 @@ +package fqb110; + +{$ALIGN 8} +{$ASSERTIONS OFF} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS OFF} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS ON} +{$REFERENCEINFO OFF} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'FastQueryBuilder 1.03'} +{$RUNONLY} +{$IMPLICITBUILD OFF} +{$I fqb.inc} + +requires + vcl, + rtl, + vclx, + dbrtl, + vcldb, + bdertl + ; + +contains + fqbClass in 'fqbClass.pas' , + fqbSynmemo in 'fqbSynmemo.pas' {fqbSynmemo}, + fqbLinkForm in 'fqbLinkForm.pas' {fqbLinkForm}, + fqbUtils in 'fqbUtils.pas' , + fqbDesign in 'fqbDesign.pas' {fqbDesign}, + fqbZLib in 'fqbZLib.pas' + ; + +end. diff --git a/official/4.2/LibD11/fqb40.bpk b/official/4.2/LibD11/fqb40.bpk new file mode 100644 index 0000000..4622d63 --- /dev/null +++ b/official/4.2/LibD11/fqb40.bpk @@ -0,0 +1,189 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = fqb40.bpl +OBJFILES = fqbReg.obj fqb40.obj +RESFILES = fqb.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +IDLFILES = +IDLGENFILES = +LIBRARIES = +SPARELIBS = Vcl40.lib +PACKAGES = vcl40.bpi vcldb40.bpi vclx40.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -Od -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -r- \ + -a8 -k -y -v -vi- -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +IDLCFLAGS = -I$(BCB)\include -I$(BCB)\include\vcl -src_suffixcpp +PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$YD -$W -$O- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zd +LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -D"FastQueryBuilder 1.0" -aa -Tpp -x -Gn -Gl \ + -Gi -v +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +!if !$d(IDL2CPP) +IDL2CPP = idl2cpp +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(IDLGENFILES) $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fqb40.cpp b/official/4.2/LibD11/fqb40.cpp new file mode 100644 index 0000000..a0e4ed2 --- /dev/null +++ b/official/4.2/LibD11/fqb40.cpp @@ -0,0 +1,18 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USEPACKAGE("vcl40.bpi"); +USERES("fqb.dcr"); +USEUNIT("fqbReg.pas"); +USEPACKAGE("vcldb40.bpi"); +USEPACKAGE("vclx40.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fqb40.dpk b/official/4.2/LibD11/fqb40.dpk new file mode 100644 index 0000000..b5e14a3 --- /dev/null +++ b/official/4.2/LibD11/fqb40.dpk @@ -0,0 +1,44 @@ +package fqb40; + +{$ALIGN ON} +{$ASSERTIONS OFF} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS OFF} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS ON} +{$REFERENCEINFO OFF} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'FastQueryBuilder 1.03'} +{$RUNONLY} +{$IMPLICITBUILD OFF} +{$I fqb.inc} + +requires + vcl40, + vclx40, + vcldb40 + ; + +contains + fqbClass in 'fqbClass.pas' , + fqbSynmemo in 'fqbSynmemo.pas' {fqbSynmemo}, + fqbLinkForm in 'fqbLinkForm.pas' {fqbLinkForm}, + fqbUtils in 'fqbUtils.pas' , + fqbDesign in 'fqbDesign.pas' {fqbDesign}, + fqbZLib in 'fqbZLib.pas' + ; + +end. diff --git a/official/4.2/LibD11/fqb50.bpk b/official/4.2/LibD11/fqb50.bpk new file mode 100644 index 0000000..3fc8999 --- /dev/null +++ b/official/4.2/LibD11/fqb50.bpk @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=1 +Special=1 +Private=0 +DLL=0 + + diff --git a/official/4.2/LibD11/fqb50.cpp b/official/4.2/LibD11/fqb50.cpp new file mode 100644 index 0000000..9b34e80 --- /dev/null +++ b/official/4.2/LibD11/fqb50.cpp @@ -0,0 +1,28 @@ + +#include +#pragma hdrstop +USEUNIT("fqbClass.pas"); +USEUNIT("fqbSynmemo.pas"); +USEUNIT("fqbLinkForm.pas"); +USEUNIT("fqbUtils.pas"); +USEUNIT("fqbDesign.pas"); +USEUNIT("fqbZLib.pas"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vclx50.bpi"); +USEPACKAGE("vcldb50.bpi"); +USEPACKAGE("vclbde50.bpi"); + +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + diff --git a/official/4.2/LibD11/fqb50.dpk b/official/4.2/LibD11/fqb50.dpk new file mode 100644 index 0000000..a612a4d --- /dev/null +++ b/official/4.2/LibD11/fqb50.dpk @@ -0,0 +1,45 @@ +package fqb50; + +{$ALIGN ON} +{$ASSERTIONS OFF} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS OFF} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS ON} +{$REFERENCEINFO OFF} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'FastQueryBuilder 1.03'} +{$RUNONLY} +{$IMPLICITBUILD OFF} +{$I fqb.inc} + +requires + vcl50, + vclx50, + vcldb50, + vclbde50 + ; + +contains + fqbClass in 'fqbClass.pas' , + fqbSynmemo in 'fqbSynmemo.pas' {fqbSynmemo}, + fqbLinkForm in 'fqbLinkForm.pas' {fqbLinkForm}, + fqbUtils in 'fqbUtils.pas' , + fqbDesign in 'fqbDesign.pas' {fqbDesign}, + fqbZLib in 'fqbZLib.pas' + ; + +end. diff --git a/official/4.2/LibD11/fqb60.bpk b/official/4.2/LibD11/fqb60.bpk new file mode 100644 index 0000000..5ee1914 --- /dev/null +++ b/official/4.2/LibD11/fqb60.bpk @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=1 +Special=1 +Private=0 +DLL=0 + + diff --git a/official/4.2/LibD11/fqb60.cpp b/official/4.2/LibD11/fqb60.cpp new file mode 100644 index 0000000..55bebe9 --- /dev/null +++ b/official/4.2/LibD11/fqb60.cpp @@ -0,0 +1,20 @@ + +#include +#pragma hdrstop +USEFORMNS("fqbSynmemo.pas", Fqbsynmemo, fqbSynmemo); +USEFORMNS("fqbLinkForm.pas", Fqblinkform, fqbLinkForm); +USEFORMNS("fqbDesign.pas", Fqbdesign, fqbDesign); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + diff --git a/official/4.2/LibD11/fqb60.dpk b/official/4.2/LibD11/fqb60.dpk new file mode 100644 index 0000000..ed6a741 --- /dev/null +++ b/official/4.2/LibD11/fqb60.dpk @@ -0,0 +1,47 @@ +package fqb60; + +{$ALIGN 8} +{$ASSERTIONS OFF} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS OFF} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS ON} +{$REFERENCEINFO OFF} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'FastQueryBuilder 1.03'} +{$RUNONLY} +{$IMPLICITBUILD OFF} +{$I fqb.inc} + +requires + vcl, + rtl, + vclx, + dbrtl, + vcldb, + bdertl + ; + +contains + fqbClass in 'fqbClass.pas' , + fqbSynmemo in 'fqbSynmemo.pas' {fqbSynmemo}, + fqbLinkForm in 'fqbLinkForm.pas' {fqbLinkForm}, + fqbUtils in 'fqbUtils.pas' , + fqbDesign in 'fqbDesign.pas' {fqbDesign}, + fqbZLib in 'fqbZLib.pas' + ; + +end. diff --git a/official/4.2/LibD11/fqb70.dpk b/official/4.2/LibD11/fqb70.dpk new file mode 100644 index 0000000..0413133 --- /dev/null +++ b/official/4.2/LibD11/fqb70.dpk @@ -0,0 +1,47 @@ +package fqb70; + +{$ALIGN 8} +{$ASSERTIONS OFF} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS OFF} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS ON} +{$REFERENCEINFO OFF} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'FastQueryBuilder 1.03'} +{$RUNONLY} +{$IMPLICITBUILD OFF} +{$I fqb.inc} + +requires + vcl, + rtl, + vclx, + dbrtl, + vcldb, + bdertl + ; + +contains + fqbClass in 'fqbClass.pas' , + fqbSynmemo in 'fqbSynmemo.pas' {fqbSynmemo}, + fqbLinkForm in 'fqbLinkForm.pas' {fqbLinkForm}, + fqbUtils in 'fqbUtils.pas' , + fqbDesign in 'fqbDesign.pas' {fqbDesign}, + fqbZLib in 'fqbZLib.pas' + ; + +end. diff --git a/official/4.2/LibD11/fqb90.bdsproj b/official/4.2/LibD11/fqb90.bdsproj new file mode 100644 index 0000000..ec17ecc --- /dev/null +++ b/official/4.2/LibD11/fqb90.bdsproj @@ -0,0 +1,161 @@ + + + + + + + + + + + + fqb90.dpk + + + 9.0 + + + 8 + 0 + 0 + 0 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 0 + 0 + 1 + 1 + 1 + 0 + 1 + 0 + 0 + 0 + 1 + 0 + 1 + 0 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + + + 0 + 0 + 1 + False + False + False + 16384 + 1048576 + 4194304 + FastQueryBuilder 1.03 + + + + + + + + + + + False + + + + + + False + + + + + + False + + + + $00000000 + + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1053 + 1252 + + + diff --git a/official/4.2/LibD11/fqb90.dpk b/official/4.2/LibD11/fqb90.dpk new file mode 100644 index 0000000..afda5e0 --- /dev/null +++ b/official/4.2/LibD11/fqb90.dpk @@ -0,0 +1,47 @@ +package fqb90; + +{$ALIGN 8} +{$ASSERTIONS OFF} +{$BOOLEVAL OFF} +{$DEBUGINFO OFF} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS OFF} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS ON} +{$REFERENCEINFO OFF} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST OFF} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$DESCRIPTION 'FastQueryBuilder 1.03'} +{$RUNONLY} +{$IMPLICITBUILD OFF} +{$I fqb.inc} + +requires + vcl, + rtl, + vclx, + dbrtl, + vcldb, + bdertl + ; + +contains + fqbClass in 'fqbClass.pas' , + fqbSynmemo in 'fqbSynmemo.pas' {fqbSynmemo}, + fqbLinkForm in 'fqbLinkForm.pas' {fqbLinkForm}, + fqbUtils in 'fqbUtils.pas' , + fqbDesign in 'fqbDesign.pas' {fqbDesign}, + fqbZLib in 'fqbZLib.pas' + ; + +end. diff --git a/official/4.2/LibD11/fqbClass.pas b/official/4.2/LibD11/fqbClass.pas new file mode 100644 index 0000000..53d3da4 --- /dev/null +++ b/official/4.2/LibD11/fqbClass.pas @@ -0,0 +1,2276 @@ +{*******************************************} +{ } +{ FastQueryBuilder 1.03 } +{ } +{ Copyright (c) 2005 } +{ Fast Reports Inc. } +{ } +{*******************************************} + +{$I fqb.inc} + +unit fqbClass; + +interface + +uses + Windows, Messages, Classes, Controls, Menus, Forms, Graphics, StdCtrls, Grids, + DB, SysUtils, ExtCtrls, CheckLst, Buttons, Comctrls +{$IFDEF Delphi6} + ,Variants +{$ENDIF}; + +type + TfqbTable = class; + TfqbTableArea = class; + EfqbError = class(Exception) + end; + + TfqbField = class(TCollectionItem) + private + FFieldName: string; + FFielType: Integer; + FLinked: Boolean; + function GetFieldName: string; + public + property FieldName: string read GetFieldName write FFieldName; + property FieldType: Integer read FFielType write FFielType; + property Linked: Boolean read FLinked write FLinked; + end; + + TfqbFieldList = class(TOwnedCollection) + private + function GetItem(Index: Integer): TfqbField; + procedure SetItem(Index: Integer; const Value: TfqbField); + public + function Add: TfqbField; + property Items[Index: Integer]: TfqbField read GetItem write SetItem; default; + end; + + TfqbLink = class(TCollectionItem) + protected + FArea: TfqbTableArea; + FDestField: TfqbField; + FDestTable: TfqbTable; + FJOp: Integer; + FJType: Integer; + FMenu: TPopupMenu; + FSelected: Boolean; + FSourceField: TfqbField; + FSourceTable: TfqbTable; + procedure DoDelete(Sender: TObject); + procedure DoOptions(Sender: TObject); + procedure Draw; + function GetDestCoords: TPoint; + function GetSourceCoords: TPoint; + procedure SetSelected(const Value: Boolean); + public + constructor Create(Collection: TCollection); override; + destructor Destroy; override; + property DestCoords: TPoint read GetDestCoords; + property DestField: TfqbField read FDestField; + property DestTable: TfqbTable read FDestTable; + property JoinOperator: Integer read FJOp write FJOp; + property JoinType: Integer read FJType write FJType; + property Selected: Boolean read FSelected write SetSelected; + property SourceCoords: TPoint read GetSourceCoords; + property SourceField: TfqbField read FSourceField; + property SourceTable: TfqbTable read FSourceTable; + end; + + TfqbLinkList = class(TOwnedCollection) + private + function GetItem(Index: Integer): TfqbLink; + procedure SetItem(Index: Integer; const Value: TfqbLink); + public + function Add: TfqbLink; + property Items[Index: Integer]: TfqbLink read GetItem write SetItem; default; + end; + + TfqbCheckListBox = class(TCheckListBox) + protected + procedure ClickCheck; override; + procedure DragOver(Sender: TObject; X, Y: Integer; State: TDragState; var + Accept: Boolean); override; + public + procedure DragDrop(Sender: TObject; X, Y: Integer); override; + end; + + TfqbTable = class(TPanel) + private + FAliasName: string; + FButtonClose: TSpeedButton; + FButtonMinimize: TSpeedButton; + FCheckListBox: TfqbCheckListBox; + FFieldList: TfqbFieldList; + FImage: TImage; + FLabel: TLabel; + FOldHeight: Integer; + FTableName: string; + function GetSellectedField: TfqbField; + procedure SetTableName(const Value: string); + procedure SetXPStyle(const AComp: TControl); + protected + procedure CreateParams(var Params: TCreateParams); override; + function GetLinkPoint(AIndex: integer; ASide: char): TPoint; + procedure Resize; override; + procedure WMMove(var Message: TWMMove); message WM_MOVE; + procedure WMNCHitTest(var M: TWMNCHitTest); message wm_NCHitTest; + procedure WMPaint(var Message: TWMPaint); message WM_PAINT; + procedure CMRelease(var Message: TMessage); message CM_RELEASE; + procedure _DoExit(Sender: TObject); + procedure _DoMinimize(Sender: TObject); + procedure _DoRestore(Sender: TObject); + property ChBox: TfqbCheckListBox read FCheckListBox; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure UpdateFieldList; + procedure UpdateLinkList; + property AliasName: string read FAliasName; + property FieldList: TfqbFieldList read FFieldList write FFieldList; + property SellectedField: TfqbField read GetSellectedField; + property TableName: string read FTableName write SetTableName; + end; + + TfqbTableArea = class(TScrollBox) + private + FCanvas: TCanvas; + FInstX: Integer; + FInstY: Integer; + FLinkList: TfqbLinkList; + protected + procedure Click; override; + function GenerateAlias(const ATableNAme: string): string; virtual; + function GetLineAtCursor: Integer; + procedure WMPaint(var Message: TWMPaint); message WM_PAINT; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function CompareFields(TableID1: integer; FIndex1: integer; TableID2: integer; + FIndex2: integer): Boolean; + procedure DragDrop(Source: TObject; X, Y: Integer); override; + procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; var + Accept: Boolean); override; + function FindTable(const AName, AAlias: string): TfqbTable; + procedure InsertTable(const X, Y : integer; const Name: string); overload; + procedure InsertTable(const Name : string); overload; + property LinkList: TfqbLinkList read FLinkList; + end; + + TfqbTableListBox = class(TListBox) + protected + procedure DblClick; override; + procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); + override; + procedure CreateWnd; override; + public + constructor Create(AOwner: TComponent); override; + end; + + PGridColumn = ^TGridColumn; + TGridColumn = record + Table: string; + Alias: string; + Field: string; + Visibl: Boolean; + Where: string; + Sort: Integer; + Func: Integer; + Group: Integer; + end; + + TfqbEdit = class(TEdit) + private + FButton: TSpeedButton; + FOnButtonClick: TNotifyEvent; + FPanel: TPanel; + FShowButton: Boolean; + procedure SetShowButton(const Value: Boolean); + protected + procedure ButtonClick(Sender: TObject); + procedure CreateParams(var Params: TCreateParams); override; + procedure CreateWnd; override; + procedure SetEditRect; + procedure WMSize(var Message: TWMSize); message WM_SIZE; + public + constructor Create(AOwner: TComponent); override; + property OnButtonClick: TNotifyEvent read FOnButtonClick write FOnButtonClick; + property ShowButton: Boolean read FShowButton write SetShowButton; + end; + + TfqbColumnResizeEvent = procedure (Sender: TCustomListview; ColumnIndex: Integer; + ColumnWidth: Integer) of object; + TfqbGrid = class(TListView) + private + FEndColumnResizeEvent: TfqbColumnResizeEvent; + FFunctionList: TComboBox; + FGroupList: TComboBox; + FPopupMenu: TPopupMenu; + FSortList: TComboBox; + FVisibleList: TComboBox; + FWhereEditor: TfqbEdit; + procedure fqbOnChange(Sender: TObject); + procedure fqbOnMenu(Sender: TObject); + procedure fqbOnPopup(Sender: TObject); + procedure fqbOnSelectItem(Sender: TObject; Item: TListItem; Selected: Boolean); + procedure fqbSetBounds(var Contr: TControl); + protected + procedure CreateWnd; override; + procedure DoColumnResize(ColumnIndex, ColumnWidth: Integer); virtual; + function FindColumnIndex(pHeader: pNMHdr): Integer; + function FindColumnWidth(pHeader: pNMHdr): Integer; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + override; + procedure RecalcColWidth; + procedure Resize; override; + procedure WMNotify(var Msg: TWMNotify); message WM_NOTIFY; + procedure WMVscroll(var Msg: TWMNotify); message WM_VSCROLL; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function AddColumn: Integer; + procedure Exchange(const AItm1, AItm2: integer); + procedure fqbUpdate; + procedure UpdateColumn; + property OnEndColumnResize: TfqbColumnResizeEvent read FEndColumnResizeEvent + write FEndColumnResizeEvent; + end; + + TfqbEngine = class(TComponent) + private + FShowSystemTables: Boolean; + public + procedure ReadFieldList(const ATableName: string; var AFieldList: TfqbFieldList); + virtual; abstract; + procedure ReadTableList(ATableList: TStrings); virtual; abstract; + function ResultDataSet: TDataSet; virtual; abstract; + procedure SetSQL(const Value: string); virtual; abstract; + published + property ShowSystemTables: Boolean read FShowSystemTables write + FShowSystemTables default False; + end; + + TfqbDialog = class(TComponent) + private + FEngine: TfqbEngine; + function GetSchemaInsideSQL: Boolean; + function GetSQL: string; + function GetSQLSchema: string; + procedure SetEngine(const Value: TfqbEngine); + procedure SetSchemaInsideSQL(const Value: Boolean); + procedure SetSQL(Value: string); + procedure SetSQLSchema(const Value: string); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + function Execute: Boolean; virtual; + property SQL: string read GetSQL write SetSQL; + property SQLSchema: string read GetSQLSchema write SetSQLSchema; + published + property Engine: TfqbEngine read FEngine write SetEngine; + property SchemaInsideSQL: Boolean read GetSchemaInsideSQL write + SetSchemaInsideSQL default True; + end; + + TfqbCore = class(TObject) + private + FEngine: TfqbEngine; + FGrid: TfqbGrid; + FSchemaInsideSQL: Boolean; + FSQL: string; + FSQLSchema: string; + FTableArea: TfqbTableArea; + FUseCoding: Boolean; + FText: string; + FUsingQuotes: Boolean; + function ExtractSchema(const Value: string): string; + function ExtractSQL(const Str: string): string; + function GetEngine: TfqbEngine; + function GetGrid: TfqbGrid; + function GetSQL: string; + function GetSQLSchema: string; + function GetTableArea: TfqbTableArea; + procedure SetSchemaInsideSQL(const Value: Boolean); + procedure SetSQL(Value: string); + procedure SetSQLSchema(const Value: string); + public + constructor Create; virtual; + destructor Destroy; override; + procedure Clear; + function GenerateSQL: string; + procedure LoadFromFile(const FileName: string); + procedure LoadFromStr(const Str: TStringList); + procedure RecognizeModel(const crc32: Cardinal; const FileName: string); + procedure SaveToFile(const FileName: string); + procedure SaveToStr(var Str: TStringList); + property Engine: TfqbEngine read GetEngine write FEngine; + property Grid: TfqbGrid read GetGrid write FGrid; + property SQL: string read GetSQL write SetSQL; + property SQLSchema: string read GetSQLSchema write SetSQLSchema; + property TableArea: TfqbTableArea read GetTableArea write FTableArea; + property SchemaInsideSQL: Boolean read FSchemaInsideSQL write SetSchemaInsideSQL + default True; + property UsingQuotes: Boolean read FUsingQuotes write FUsingQuotes; + + end; + + +function fqbCore: TfqbCore; + +const + StrFieldType : array [0..29] of string = (''{0}, 'String'{1}, 'Smallint'{2}, + 'Integer'{3}, 'Word'{4}, 'Boolean'{5}, 'Float'{6}, + 'Currency'{7}, 'BCD'{8}, 'Date'{9}, 'Time'{10}, + 'DateTime'{11}, 'Bytes'{12}, 'VarBytes'{13}, 'AutoInc'{14}, + 'Blob'{15}, 'Memo'{16}, 'Graphic'{17}, 'FmtMemo'{18}, + 'ParadoxOle'{19}, 'DBaseOle'{20}, 'TypedBinary'{21}, + 'Cursor'{22}, 'FixedChar'{23}, 'WideString'{24}, 'Largeint'{25}, + 'ADT'{26}, 'Array'{27}, 'Reference'{28}, 'DataSet'{29}); + + _fqbBeginModel = '/*_FQBMODEL'; + _fqbEndModel = '_FQBEND*/'; + +implementation + +{$R images.res} + +uses Math, IniFiles, Dialogs, Commctrl, fqbDesign, fqbLinkForm, fqbUtils, + fqbRes, fqbrcDesign + {$IFDEF Delphi7} + ,Themes + {$ENDIF} + ; + +const + clSelectedLink = clGreen; + clNotSelectedLink = clBlack; + + LinkType: array[0..5] of string = ('=', '>', '<', '>=', '<=', '<>'); + JoinType: array[0..3] of string = ('INNER JOIN', 'LEFT OUTER JOIN', + 'RIGHT OUTER JOIN', 'FULL OUTER JOIN'); + + rowColumn = 0; + rowVisibility = 1; + rowWhere = 2; + rowSort = 3; + rowFunction = 4; + rowGroup = 5; + + CompatibleIntTypes = [2, 3, 4, 12, 14]; + CompatibleDateTimeTypes = [9, 10, 11]; + CompatibleFloatTypes = [6, 7]; + +type + TcrTControl = class(TControl) + end; + +var + FfqbCore: TfqbCore = nil; + FExternalCreation: Boolean = True; + +function fqbCore: TfqbCore; +begin + if FfqbCore = nil then + begin + FExternalCreation := False; + try + FfqbCore := TfqbCore.Create; + finally + FExternalCreation := True; + end; + end; + Result := FfqbCore; +end; + +function FindFQBcomp(const AClassName: string; const Source: TComponent): TComponent; + var + i: integer; +begin + Result := nil; + if UpperCase(Source.ClassName) = UpperCase(AClassName) then + Result := Source + else + for i := 0 to Source.ComponentCount - 1 do + if Result = nil then + Result := FindFQBcomp(AClassName, Source.Components[i]) + else + Exit +end; + +{----------------------- TfqbField -----------------------} +function TfqbField.GetFieldName: string; +begin + if ((Pos(' ', FFieldName) > 0) or (Pos('/', FFieldName) > 0) + or ((UpperCase(FFieldName) <> FFieldName)) and fqbCore.UsingQuotes) then + Result := '"' + FFieldName + '"' + else + Result := FFieldName +end; + +{----------------------- TfqbFieldList -----------------------} +function TfqbFieldList.Add: TfqbField; +begin + Result := TfqbField(inherited Add) +end; + +function TfqbFieldList.GetItem(Index: Integer): TfqbField; +begin + Result := TfqbField(inherited Items[Index]) +end; + +procedure TfqbFieldList.SetItem(Index: Integer; const Value: TfqbField); +begin + Items[Index].Assign(Value) +end; + +{----------------------- TfqbLinkList -----------------------} +function TfqbLinkList.Add: TfqbLink; +begin + Result := TfqbLink(inherited Add) +end; + +function TfqbLinkList.GetItem(Index: Integer): TfqbLink; +begin + Result := TfqbLink(inherited Items[Index]) +end; + +procedure TfqbLinkList.SetItem(Index: Integer; const Value: TfqbLink); +begin + Items[Index].Assign(Value) +end; + +{----------------------- TfqbLink -----------------------} +constructor TfqbLink.Create(Collection: TCollection); +var + tmp: TMenuItem; +begin + inherited Create(Collection); + FJOp := 0; + FJType:= 0; + FMenu:= TPopupMenu.Create(nil); + tmp:= TMenuItem.Create(FMenu); + tmp.Caption:= 'Link options'; + tmp.OnClick:= DoOptions; + FMenu.Items.Add(tmp); + tmp:= TMenuItem.Create(FMenu); + tmp.Caption:= 'Delete'; + tmp.OnClick:= DoDelete; + FMenu.Items.Add(tmp) +end; + +destructor TfqbLink.Destroy; +begin + SourceField.Linked := false; + DestField.Linked := false; + FMenu.Free; + inherited Destroy; +end; + +procedure TfqbLink.DoDelete(Sender: TObject); +begin + Free +end; + +procedure TfqbLink.DoOptions(Sender: TObject); +var + fqbLinkForm: TfqbLinkForm; +begin + fqbLinkForm := TfqbLinkForm.Create(nil); + try + fqbLinkForm.txtTable1.Caption := SourceTable.TableName; + fqbLinkForm.txtCol1.Caption := SourceField.FieldName; + fqbLinkForm.txtTable2.Caption := DestTable.TableName; + fqbLinkForm.txtCol2.Caption := DestField.FieldName;; + fqbLinkForm.RadioOpt.ItemIndex := JoinOperator; + fqbLinkForm.RadioType.ItemIndex := JoinType; + if fqbLinkForm.ShowModal = mrOk then + begin + JoinOperator := fqbLinkForm.RadioOpt.ItemIndex; + JoinType := fqbLinkForm.RadioType.ItemIndex + end; + finally + fqbLinkForm.Free + end +end; + +procedure TfqbLink.Draw; +var + pnt1, pnt2: TPoint; + cnt1, cnt2: Integer; + dSrc, dDest: Integer; + + const Delta = 15; + +begin + pnt1:= SourceCoords; + pnt2:= DestCoords; + cnt1:= SourceTable.BoundsRect.Left + (SourceTable.Width div 2); + cnt2:= DestTable.BoundsRect.Left + (DestTable.Width div 2); + if cnt1 < cnt2 then + begin + dSrc:= Delta; + dDest:= -Delta + end + else + begin + dSrc:= -Delta; + dDest:= Delta + end; + FArea.FCanvas.MoveTo(pnt1.x, pnt1.y); + FArea.FCanvas.Pen.Color:= clNotSelectedLink; + FArea.FCanvas.Pen.Width:= 3; + FArea.FCanvas.LineTo(pnt1.x + dSrc, pnt1.y); + FArea.FCanvas.Pen.Width:= 1; + if Selected then + FArea.FCanvas.Pen.Color:= clSelectedLink + else + FArea.FCanvas.Pen.Color:= clNotSelectedLink; + FArea.FCanvas.LineTo(pnt2.x + dDest, pnt2.y); + FArea.FCanvas.Pen.Width:= 3; + FArea.FCanvas.Pen.Color:= clNotSelectedLink; + FArea.FCanvas.LineTo(pnt2.x, pnt2.y) +end; + +function TfqbLink.GetDestCoords: TPoint; +var + cnt1, cnt2: Integer; +begin + cnt1:= SourceTable.BoundsRect.Left + (SourceTable.Width div 2); + cnt2:= DestTable.BoundsRect.Left + (DestTable.Width div 2); + + if cnt1 < cnt2 then + Result:= DestTable.GetLinkPoint(DestField.Index,'L') + else + Result:= DestTable.GetLinkPoint(DestField.Index,'R') +end; + +function TfqbLink.GetSourceCoords: TPoint; +var + cnt1, cnt2: Integer; +begin + cnt1:= SourceTable.BoundsRect.Left + (SourceTable.Width div 2); + cnt2:= DestTable.BoundsRect.Left + (DestTable.Width div 2); + + if cnt1 < cnt2 then + Result:= SourceTable.GetLinkPoint(SourceField.Index,'R') + else + Result:= SourceTable.GetLinkPoint(SourceField.Index,'L') +end; + +procedure TfqbLink.SetSelected(const Value: Boolean); +var + i: Integer; +begin + for i:= 0 to Collection.Count - 1 do + TfqbLinkList(Collection).Items[i].FSelected := false; + FSelected := Value +end; + +{----------------------- TfqbTableArea -----------------------} +constructor TfqbTableArea.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FCanvas := TControlCanvas.Create; + TControlCanvas(FCanvas).Control := Self; + Color := clBtnFace; + FCanvas.Brush.Color := clBtnFace; + + FLinkList := TfqbLinkList.Create(Self, TfqbLink); + + FInstX := 15; + FInstY := 15; +end; + +destructor TfqbTableArea.Destroy; +begin + FCanvas.Free; + FLinkList.Free; + inherited Destroy; +end; + +procedure TfqbTableArea.Click; +var + n: Integer; +begin + n := GetLineAtCursor; + if ((n >= 0) and (n < LinkList.Count)) then + begin + LinkList[n].Selected := true; + Invalidate; + LinkList[n].FMenu.Popup(Mouse.CursorPos.X,Mouse.CursorPos.Y) + end; + inherited Click; +end; + +function TfqbTableArea.CompareFields(TableID1: integer; FIndex1: integer; TableID2: + integer; FIndex2: integer): Boolean; +var + tp1, tp2: Integer; +begin + if ((TableID1 > ComponentCount) or (TableID2 > ComponentCount)) then + Result := false + else + begin + tp1 := TfqbTable(Components[TableID1]).FieldList[Findex1].FieldType; + tp2 := TfqbTable(Components[TableID2]).FieldList[Findex2].FieldType; + + if ((tp1 in CompatibleIntTypes) + and (tp2 in CompatibleIntTypes)) then + Result := True + else + if ((tp1 in CompatibleDateTimeTypes) + and (tp2 in CompatibleDateTimeTypes)) then + Result := True + else + if ((tp1 in CompatibleFloatTypes) + and (tp2 in CompatibleFloatTypes)) then + Result := True + else + Result := TfqbTable(Components[TableID1]).FieldList[Findex1].FieldType = + TfqbTable(Components[TableID2]).FieldList[Findex2].FieldType + end +end; + +procedure TfqbTableArea.DragDrop(Source: TObject; X, Y: Integer); +begin + InsertTable(X, Y, (Source as TfqbTableListBox).Items[(Source as TfqbTableListBox).ItemIndex]) +end; + +procedure TfqbTableArea.DragOver(Source: TObject; X, Y: Integer; State: TDragState; + var Accept: Boolean); +begin + Accept := Source is TfqbTableListBox +end; + +function TfqbTableArea.FindTable(const AName, AAlias: string): TfqbTable; +var + i: Integer; +begin + Result:= nil; + for i:= 0 to ComponentCount - 1 do + if ((TfqbTable(Components[i]).TableName = AName) and + (TfqbTable(Components[i]).AliasName = AAlias)) then + Result:= TfqbTable(Components[i]) +end; + +function TfqbTableArea.GenerateAlias(const ATableNAme: string): string; +var + n: Integer; + + function FindDublicat(AAlias: string): boolean; + var i: integer; + begin + Result:= False; + for i:= 0 to ComponentCount - 1 do + begin + if AAlias = TfqbTable(Components[i]).AliasName then + begin + Result:= True; + Break + end + end + end; + +begin + Result:= ATableName[1]; + n:=1; + while FindDublicat(Result) do + begin + Result:= ATableName[1] + IntToStr(n); + Inc(n) + end +end; + +function TfqbTableArea.GetLineAtCursor: Integer; + + procedure SwapInt(var X, Y: Integer); + var + T: Integer; + begin + T := X; + X := Y; + Y := T + end; + + function InRange(const AValue, AMin, AMax: Integer): Boolean; + begin + Result := (AValue >= AMin) and (AValue <= AMax) + end; + + const + sf = 6; //Scale factor + var + i,TX1, TX2, TY1,TY2,X1,Y1, + X2,Y2,Lx, Ly, C: integer; + MousePos: TPoint; + Delta: Real; + +begin + Result:= - 1; + for i:= 0 to LinkList.Count - 1 do + begin + MousePos:= Mouse.CursorPos; + MousePos:= ScreenToClient(MousePos); + X1:= TfqbLink(LinkList[i]).GetSourceCoords.X; + X2:= TfqbLink(LinkList[i]).GetDestCoords.X; + Y1:= TfqbLink(LinkList[i]).GetSourceCoords.Y; + Y2:= TfqbLink(LinkList[i]).GetDestCoords.Y; + TX1:= X1; + TX2:= X2; + TY1:= Y1; + TY2:= Y2; + if TX1> TX2 then SwapInt(TX1, TX2); + if TY1> TY2 then SwapInt(TY1, TY2); + Lx:= X2-X1; + Ly:= Y2-Y1; + C:= -Ly*X1 + Lx*Y1; + Delta:= Sqrt(Power((X1-X2), 2) + Power((Y1-Y2), 2)) * sf; + if (Abs(-Ly*MousePos.X + Lx*MousePos.Y - C)<= Delta) and + InRange(MousePos.X, TX1 - sf, TX2 + sf) and + InRange(MousePos.Y, TY1 - sf, TY2 + sf) then + begin + Result:= i; + break + end + end +end; + +procedure TfqbTableArea.InsertTable(const X, Y : integer; const Name: string); +var + tmp: TfqbTable; +begin + tmp := TfqbTable.Create(Self); + tmp.Left := X; + tmp.Top := Y; + tmp.Parent := Self; + tmp.TableName := Name; + fqbCore.Engine.ReadFieldList(Name, tmp.FFieldList); + tmp.UpdateFieldList +end; + +procedure TfqbTableArea.InsertTable(const Name : string); +begin + InsertTable(FInstX, FInstY, Name); + + if FInstY > Height then + FInstY:= 15 + else + FInstY:= FInstY + 15; + + if FInstX > Width then + FInstX := 15 + else + FInstX:= FInstX + 15 +end; + +procedure TfqbTableArea.WMPaint(var Message: TWMPaint); +var + i: Integer; + + {$IFDEF TRIAL} + str: string; + l, dx: integer; + {$ENDIF} + +begin + inherited; + {$IFDEF TRIAL} + FCanvas.Font.Size := 50; + FCanvas.Font.Color:= clRed; + FCanvas.Font.Name := 'Tahoma'; + str := 'deretsigern'; + l := FCanvas.TextWidth(str + 'U'); + dx := (Width div 2) - (l div 2); + FCanvas.TextOut(dx, 100, 'U'); + for i := 11 downto 1 do + FCanvas.TextOut(FCanvas.PenPos.x, FCanvas.PenPos.y, str[i]); + {$ENDIF} + for i := 0 to LinkList.Count - 1 do + LinkList[i].Draw +end; + +{----------------------- TfqbTable -----------------------} +constructor TfqbTable.Create(AOwner: TComponent); +begin + inherited; + + Width := 130; + Height := 150; + BevelOuter := bvNone; + BorderWidth := 1; + + FLabel := TLabel.Create(Self); + with FLabel do + begin + Parent := Self; + Align := alTop; + Color := clActiveCaption; + Font.Charset := DEFAULT_CHARSET; + Font.Color := clCaptionText; + AutoSize := False; + Height := Height + 6; + Font.Size := Font.Size + 1; + Layout := tlCenter; + SetXPStyle(FLabel); + end; + + FImage := TImage.Create(Self); + with FImage do + begin + Parent := Self; + Top := 3; + Left := 3; + Width := 16; + Height := 16; + AutoSize := True; + FImage.Picture.Bitmap.LoadFromResourceName(HInstance,'TABLEIMAGE1'); + Transparent := True; + SetXPStyle(FImage); + end; + + FButtonClose := TSpeedButton.Create(Self); + with FButtonClose do + begin + Parent := Self; + Top := 3; + Width := 17; + Height := 15; + OnClick := _DoExit; + Glyph.LoadFromResourceName(HInstance,'BTN_CLOSE'); + end; + + FButtonMinimize := TSpeedButton.Create(Self); + with FButtonMinimize do + begin + Parent := Self; + Top := 3; + Width := 17; + Height := 15; + OnClick := _DoMinimize; + Glyph.LoadFromResourceName(HInstance,'BTN_MINI'); + end; + + FCheckListBox := TfqbCheckListBox.Create(Self); + with FCheckListBox do + begin + Parent := Self; + Align := alClient; + ItemHeight := 13; + Style := lbOwnerDrawVariable; + DragMode := dmAutomatic + end; + + Constraints.MinHeight := FLabel.Height + 8; + Constraints.MinWidth := 120; + + Caption := ''; + FFieldList := TfqbFieldList.Create(Self, TfqbField); + DragMode := dmAutomatic; + DoubleBuffered := true; + ShowHint := False; + Height := 200; + Width := 150; + + SetXPStyle(Self); +end; + +destructor TfqbTable.Destroy; +var + i: Integer; +begin + if GetParentForm(Self) <> nil then + begin + for i:= fqbCore.Grid.Items.Count - 1 downto 0 do + begin + if TGridColumn(fqbCore.Grid.Items[i].Data^).Table = TableName then + begin + FreeMem(fqbCore.Grid.Items[i].Data,SizeOf(TGridColumn)); + fqbCore.Grid.Items[i].Delete; + end + end; + fqbCore.Grid.UpdateColumn + end; + UpdateLinkList; + + FLabel.Free; + FCheckListBox.Free; + FFieldList.Free; + FImage.Free; + FButtonClose.Free; + FButtonMinimize.Free; + + if Parent <> nil then + begin + Parent.Invalidate; + Parent:= nil + end; + inherited +end; + +procedure TfqbTable.CreateParams(var Params: TCreateParams); +begin + inherited CreateParams(Params); + with Params do + begin + Style:= Style or WS_SIZEBOX; + WindowClass.Style:= WindowClass.Style xor CS_VREDRAW + end +end; + +function TfqbTable.GetLinkPoint(AIndex: integer; ASide: char): TPoint; +var + tmpRec: TRect; +begin + tmpRec := ChBox.ItemRect(AIndex); + tmpRec.Top := tmpRec.Top + FLabel.Height + (ChBox.Height - ChBox.ClientHeight); + tmpRec.Bottom := tmpRec.Bottom + FLabel.Height + (ChBox.Height - ChBox.ClientHeight); + + if tmpRec.Bottom > ClientHeight then + Result.y := ClientHeight + else + if tmpRec.Top < 0 then + Result.y := 0 + else + Result.y := tmpRec.Top + (tmpRec.Bottom - tmpRec.Top) div 2; + + Result := Parent.ScreenToClient(ClientToScreen(Result)); + + // if ASide = 'L' then Left side else if ASide = 'R' then Right side + if ASide = 'L' then + Result.x := BoundsRect.Left + else + Result.x := BoundsRect.Right +end; + +function TfqbTable.GetSellectedField: TfqbField; +begin + Result := FFieldList[ChBox.ItemIndex] +end; + +procedure TfqbTable.Resize; +begin + inherited Resize; + FButtonClose.Left := Width - 25; + FButtonMinimize.Left := Width - 42 +end; + +procedure TfqbTable.SetTableName(const Value: string); + + function GetSpace(const Width: integer):string; + begin + Result := ''; + repeat + Result := Result + ' ' + until FLabel.Canvas.TextWidth(Result) > Width + end; + +begin + FTableName := Value; + FAliasName:= TfqbTableArea(Parent).GenerateAlias(Value); + FLabel.Caption := GetSpace(FImage.Width + 2) + Value + ' - ' + FAliasName +end; + +procedure TfqbTable.SetXPStyle(const AComp: TControl); +begin + {$IFDEF Delphi7} + if ThemeServices.ThemesEnabled then + AComp.ControlStyle := AComp.ControlStyle - [csParentBackground] + [csOpaque]; + {$ENDIF}; +end; + +procedure TfqbTable.UpdateFieldList; +var + i: Integer; +begin + ChBox.Items.BeginUpdate; + ChBox.Items.Clear; + if FFieldList.Count > 0 then + ChBox.Items.Add(TfqbField(FFieldList[0]).FieldName); + for i:= 1 to FFieldList.Count - 1 do + ChBox.Items.Add(TfqbField(FFieldList[i]).FieldName + ' (' + + StrFieldType[TfqbField(FFieldList[i]).FieldType] + ')'); + ChBox.Items.EndUpdate +end; + +procedure TfqbTable.UpdateLinkList; +var + i: Integer; +begin + if Parent = nil then Exit; + for i:= (Parent as TfqbTableArea).LinkList.Count - 1 downto 0 do + if (((Parent as TfqbTableArea).LinkList[i].SourceTable = self) or ((Parent as TfqbTableArea).LinkList[i].DestTable = self)) then + (Parent as TfqbTableArea).LinkList[i].Free +end; + +procedure TfqbTable.WMMove(var Message: TWMMove); +begin + inherited; + Parent.Invalidate +end; + +procedure TfqbTable.WMNCHitTest(var M: TWMNCHitTest); +var + x: Integer; +begin + inherited; + x := ClientToScreen(Point(FButtonMinimize.Left,0)).X; + if ((M.Result = htClient) and (M.XPos - x < 0)) then + M.Result := htCaption +end; + +procedure TfqbTable.WMPaint(var Message: TWMPaint); +begin + inherited; + Parent.Invalidate +end; + +procedure TfqbTable._DoExit(Sender: TObject); +begin + PostMessage(Handle, CM_RELEASE, 0, 0); +end; + +procedure TfqbTable._DoMinimize(Sender: TObject); +begin + FOldHeight := Height; + Height := 0; + FButtonMinimize.OnClick := _DoRestore +end; + +procedure TfqbTable._DoRestore(Sender: TObject); +begin + Height := FOldHeight; + FButtonMinimize.OnClick := _DoMinimize +end; + +{----------------------- TfqbTableListBox -----------------------} +constructor TfqbTableListBox.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + DragMode := dmAutomatic; +end; + +procedure TfqbTableListBox.CreateWnd; +begin + Style := lbOwnerDrawFixed; + ItemHeight := 18; + inherited; +end; + +procedure TfqbTableListBox.DblClick; +begin + inherited DblClick; + fqbCore.TableArea.InsertTable(Items[ItemIndex]) +end; + +procedure TfqbTableListBox.DrawItem(Index: Integer; Rect: TRect; State: + TOwnerDrawState); +var + Bitmap: TBitmap; + BMPRect: TRect; +begin + inherited DrawItem(Index, Rect, State); + Canvas.FillRect(Rect); + Bitmap := TBitmap.Create; + Bitmap.LoadFromResourceName(HInstance,'TABLEIMAGE1'); + if Bitmap <> nil then + begin + BMPRect := Bounds(Rect.Left + 3, Rect.Top + 1, 16, 16); + Canvas.BrushCopy(BMPRect,Bitmap, Bounds(0, 0, Bitmap.Width, Bitmap.Height), + Bitmap.Canvas.Pixels[0, Bitmap.Height-1]); + end; + Canvas.TextOut(Rect.Left+24, Rect.Top+2, Items[Index]); + Bitmap.Free +end; + +{----------------------- TfqbDialog -----------------------} +constructor TfqbDialog.Create(AOwner: TComponent); +begin + inherited; + fqbCore.SchemaInsideSQL := True; +end; + +function TfqbDialog.Execute: Boolean; +var + tmp: TStringList; +begin + {$IFDEF TRIAL} + ShowMessage(' Fast Query Builder'#10#13'Unregistered version'); + {$ENDIF} + fqbDesigner := TfqbDesigner.Create(Self); + fqbCore.Engine := Engine; + fqbCore.Grid := fqbDesigner.fqbGrid1; + fqbCore.TableArea := fqbDesigner.fqbTableArea1; + + tmp:= TStringList.Create; + tmp.Text := fqbCore.FText; + try + try + fqbCore.LoadFromStr(tmp); + except + end; + + if fqbDesigner.ShowModal = mrOk then + begin + tmp.Clear; + fqbCore.SaveToStr(tmp); + fqbCore.FText := tmp.Text; + Result := true + end + else + Result := false; + finally + tmp.Free; + fqbDesigner.Free + end +end; + +function TfqbDialog.GetSchemaInsideSQL: Boolean; +begin + Result := fqbCore.SchemaInsideSQL; +end; + +function TfqbDialog.GetSQL: string; +begin + Result := fqbCore.SQL; +end; + +function TfqbDialog.GetSQLSchema: string; +begin + Result := fqbCore.SQLSchema; +end; + +procedure TfqbDialog.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (AComponent = FEngine) and (Operation = opRemove) then + begin + FEngine := nil; + fqbCore.Engine := nil; + end; +end; + +procedure TfqbDialog.SetEngine(const Value: TfqbEngine); +begin + if FEngine <> Value then + begin + FEngine := Value; + fqbCore.Engine := Value; + FreeNotification(FEngine); + end +end; + +procedure TfqbDialog.SetSchemaInsideSQL(const Value: Boolean); +begin + fqbCore.SchemaInsideSQL := Value; +end; + +procedure TfqbDialog.SetSQL(Value: string); +begin + fqbCore.SQL := Value; +end; + +procedure TfqbDialog.SetSQLSchema(const Value: string); +begin + fqbCore.SQLSchema := Value; +end; + +{----------------------- TfqbCore -----------------------} +constructor TfqbCore.Create; +begin + if FfqbCore <> nil then + raise EfqbError.Create('TfqbCore class already initialized.'); + if FExternalCreation then + raise EfqbError.Create('Call fqbCore function to reference this class.'); + inherited; + FUseCoding := True; + FUsingQuotes := False; +end; + +destructor TfqbCore.Destroy; +begin + FfqbCore := nil; + inherited; +end; + +procedure TfqbCore.Clear; +var + i: Integer; +begin + for i:= Grid.Items.Count - 1 downto 0 do + Dispose(PGridColumn(Grid.Items[i].Data)); + Grid.Items.Clear; + + for i := TableArea.ComponentCount - 1 downto 0 do + TableArea.Components[i].Free +end; + +function TfqbCore.ExtractSchema(const Value: string): string; +var + e, b: Integer; +begin + b := Pos(_fqbBeginModel, Value) + Length(_fqbBeginModel); + e := Pos(_fqbEndModel, Value); + if not (e = 0) then + begin + Result := Copy(Value, b, e-b); + Result := fqbTrim(Result, [#10, #13]); + end + else + Result := Value; +end; + +function TfqbCore.ExtractSQL(const Str: string): string; +var + e, b: Integer; +begin + b := Pos(_fqbBeginModel, Str); + e := Pos(_fqbEndModel, Str); + Result := Str; + Delete(Result, b, e); +end; + +function TfqbCore.GenerateSQL: string; + + const + strTab = ' '; + strSel = 'SELECT '; + strFrom = 'FROM'; + strWhere = 'WHERE'; + strOrder = 'ORDER BY '; + strGroup = 'GROUP BY '; + var + i: integer; + tmpStr, orderStr, prd, groupStr: string; + slFrom, slWhere: TStringList; + Tbl1, Tbl2, Tbl3: TfqbTable; + CopyLL: TList; + flg: boolean; + SQL: TStringList; + + function FormingFrom(const Ind: integer):string; + var + tmp: TfqbLink; + begin + tmp := TableArea.LinkList[Ind]; + Result := {strTab + }JoinType[tmp.JoinType] + ' ' + + Tbl2.TableName + ' ' + Tbl2.AliasName + ' ON (' + + Tbl1.AliasName + '.' + tmp.SourceField.FieldName + + LinkType[tmp.JoinOperator] + + Tbl2.AliasName + '.' + tmp.DestField.FieldName + ')' + end; + + function FormingFromAnd(const Ind: integer):string; + var + tmp: TfqbLink; + begin + tmp := TfqbLink(TableArea.LinkList[Ind]); + Result := ' AND (' + + Tbl1.AliasName + '.' + tmp.SourceField.FieldName + + LinkType[tmp.JoinOperator] + + Tbl3.AliasName + '.' + tmp.DestField.FieldName + ') ' + end; + +begin + SQL := TStringList.Create; + //SELECT + tmpStr := strSel; + + if Grid.Items.Count = 0 then Exit; + + for i := 0 to Grid.Items.Count - 1 do + + if TGridColumn(Grid.Items[i].Data^).Visibl then + begin + + if Grid.Items[i].SubItems[rowFunction - 1] <> '' then + prd := Grid.Items[i].SubItems[rowFunction - 1] + '(' + else + prd := ''; + + tmpStr := tmpStr + prd + TGridColumn(Grid.Items[i].Data^).Alias + '.' + + TGridColumn(Grid.Items[i].Data^).Field; + + if prd <> '' then prd := ')'; + + tmpStr := tmpStr + prd + ', ' + end; + tmpStr := Copy(tmpStr,1,Length(tmpStr) - 2); + SQL.Add(tmpStr); + + //FROM + tmpStr := ''; + slFrom := TStringList.Create; + CopyLL := TList.Create; + for i := 0 to TableArea.LinkList.Count - 1 do + CopyLL.Add(Pointer(i)); + while CopyLL.Count <> 0 do + begin + Tbl1 := TableArea.LinkList[0].SourceTable; + Tbl2 := TableArea.LinkList[0].DestTable; + slFrom.Add(strTab + Tbl1.TableName + ' ' + Tbl1.AliasName); + slFrom.Add(strTab + FormingFrom(0)); + for i := 1 to CopyLL.Count - 1 do + begin + Tbl3 := TableArea.LinkList[i].DestTable; + + if (Tbl3.AliasName = Tbl2.AliasName) then + begin + slFrom[slFrom.Count - 1] := slFrom[slFrom.Count - 1] + FormingFromAnd(Integer(CopyLL[i])); + CopyLL[i] := Pointer(-1); + end + else + begin + Tbl1 := TableArea.LinkList[Integer(CopyLL[i])].SourceTable; + Tbl2 := Tbl3; + slFrom.Add(strTab + FormingFrom(Integer(CopyLL[i]))); + CopyLL[i] := Pointer(-1) + end + + end; + CopyLL.Delete(0); + for i := CopyLL.Count - 1 downto 0 do + if Integer(CopyLL[i]) = -1 then CopyLL.Delete(i) + end; + + flg := false; + for i := 0 to Grid.Items.Count - 1 do + begin + tmpStr := TGridColumn(Grid.Items[i].Data^).Table + ' ' + + TGridColumn(Grid.Items[i].Data^).Alias; + + if Pos(tmpStr, slFrom.Text) = 0 then + begin + if slFrom.Count <> 0 then + slFrom[slFrom.Count - 1] := slFrom[slFrom.Count - 1] + ', '; + + slFrom.Add(strTab + tmpStr); + flg := true + end + end; + + if flg then + slFrom.Text := Copy(slFrom.Text,1,Length(slFrom.Text) - 2); + + CopyLL.Free; + + //WHERE + slWhere := TStringList.Create; + for i := 0 to Grid.Items.Count - 1 do + if TGridColumn(Grid.Items[i].Data^).Where <> '' then + slWhere.Add(strTab + TGridColumn(Grid.Items[i].Data^).Alias + '.' + + TGridColumn(Grid.Items[i].Data^).Field + ' ' + + TGridColumn(Grid.Items[i].Data^).Where + ' AND'); + + if slWhere.Count <> 0 then + begin + slWhere.Text:= Copy(slWhere.Text,1,Length(slWhere.Text) - 6); + slWhere.Insert(0,strWhere) + end; + + //ORDER + orderStr:= ''; + prd:= ''; + flg:= false; + for i:= 0 to Grid.Items.Count - 1 do + begin + if TGridColumn(Grid.Items[i].Data^).Sort <> 0 then + begin + if TGridColumn(Grid.Items[i].Data^).Sort = 2 then + prd := 'DESC' + else + prd := ''; + orderStr:= orderStr + TGridColumn(Grid.Items[i].Data^).Alias + '.' + + TGridColumn(Grid.Items[i].Data^).Field + ' ' + prd + ', '; + flg:= true; + end; + end; + if flg then + orderStr := Trim(Copy(orderStr,1,Length(orderStr) - 2)); + + //GROUP + groupStr:= ''; + flg:= false; + for i:= 0 to Grid.Items.Count - 1 do + begin + if TGridColumn(Grid.Items[i].Data^).Group <> 0 then + begin + groupStr:= groupStr + TGridColumn(Grid.Items[i].Data^).Alias + '.' + + TGridColumn(Grid.Items[i].Data^).Field + ', '; + flg:= true; + end; + end; + if flg then groupStr:= Copy(groupStr,1,Length(groupStr) - 2); + + SQL.Add(strFrom); + SQL.AddStrings(slFrom); + SQL.AddStrings(slWhere); + + if orderStr <> '' then SQL.Add(strOrder + orderStr); + + if groupStr <> '' then SQL.Add(strGroup + groupStr); + + slFrom.Free; + slWhere.Free; + + FText := SQL.Text; + Result := SQL.Text; + SQL.Free +end; + +function TfqbCore.GetEngine: TfqbEngine; +begin + Result := FEngine; + if not Assigned(FEngine) then + raise EfqbError.Create('fqbCore.Engine not assigned'); + +end; + +function TfqbCore.GetGrid: TfqbGrid; +begin + Result := FGrid; + if not Assigned(FGrid) then + raise EfqbError.Create('fqbCore.Grid not assigned'); +end; + +function TfqbCore.GetSQL: string; +begin + if SchemaInsideSQL then + Result := Ftext + else + Result := fqbCore.ExtractSQL(Ftext); +end; + +function TfqbCore.GetSQLSchema: string; +begin + if SchemaInsideSQL then + Result := '' + else + Result := fqbCore.ExtractSchema(Ftext); +end; + +function TfqbCore.GetTableArea: TfqbTableArea; +begin + Result := FTableArea; + if not Assigned(FTableArea) then + raise EfqbError.Create('fqbCore.TableArea not assigned'); +end; + +procedure TfqbCore.LoadFromFile(const FileName: string); +var + StrLst, StrSrc: TStringList; + tmp, tmp2: string; +begin + StrLst := TStringList.Create; + StrSrc := TStringList.Create; + StrSrc.LoadFromFile(FileName); + + try + tmp2 := ExtractSQL(StrSrc.Text); + tmp := ExtractSchema(StrSrc.Text); + + if fqbCore.FUseCoding then + begin + tmp := fqbTrim(tmp, [#10,#13]); + if tmp = '' then Exit; + tmp:= fqbDeCompress(tmp) + end; + + StrLst.Clear; + StrLst.Text := tmp; + + tmp := fqbGetUniqueFileName('fqb'); + StrLst.SaveToFile(tmp); + tmp2 := fqbTrim(tmp2, [#10,#13]); + fqbCore.RecognizeModel(fqbStringCRC32(tmp2), tmp); + finally + DeleteFile(tmp); + + StrLst.Free; + StrSrc.Free; + end; +end; + +procedure TfqbCore.LoadFromStr(const Str: TStringList); +var + tmp: string; +begin + tmp := fqbGetUniqueFileName('fqb'); + Str.SaveToFile(tmp); + try + fqbCore.LoadFromFile(tmp); + finally + DeleteFile(tmp) + end +end; + +procedure TfqbCore.RecognizeModel(const crc32: Cardinal; const FileName: string); +var + fqbFile: TIniFile; + tbl: TStringList; + i: Integer; + Rec: TRect; + parstr, tmpstr: string; + vis: TfqbTable; + lnk: TfqbLink; + c: Cardinal; + + function IndexOf(const FieldName: string): integer; + var + i: integer; + begin + Result:= -1; + for i:= 0 to vis.FieldList.Count - 1 do + if TfqbField(vis.FieldList[i]).FieldName = FieldName then + Result:= i; + end; + +begin + fqbFile:= TIniFile.Create(FileName); + tbl:= TStringList.Create; + tmpstr := fqbFile.ReadString('DataBase','SQL',''); + c := StrToInt64(tmpstr); + if c <> crc32 then + begin + ShowMessage('The file was changed. The Model can not be loaded.'); + fqbFile.Free; + tbl.Free; + Exit + end; + try + fqbCore.Engine.ReadTableList(TfqbTableListBox(FindFQBcomp('TfqbTableListBox',GetParentForm(TableArea))).Items); + fqbFile.ReadSectionValues('Tables',tbl); + try + for i:= 0 to tbl.Count - 1 do + begin + parstr:= tbl.Values[tbl.Names[i]]; + tmpstr:= fqbParse(',',parstr,1); + Rec.Top:= StrToInt(fqbParse(',',parstr,2)); + Rec.Left:= StrToInt(fqbParse(',',parstr,3)); + Rec.Right:= StrToInt(fqbParse(',',parstr,4)); + Rec.Bottom:= StrToInt(fqbParse(',',parstr,5)); + TableArea.InsertTable(Rec.Left, Rec.Top, tmpstr); + TfqbTable(TableArea.Components[i]).Height:= Rec.Right; + TfqbTable(TableArea.Components[i]).Width:= Rec.Bottom + end + except + fqbCore.Clear; + Exit + end; + tbl.Clear; + fqbFile.ReadSectionValues('Grid',tbl); + try + for i:= 0 to tbl.Count - 1 do + begin + parstr:=tbl.Values[tbl.Names[i]]; + vis:= TableArea.FindTable(fqbParse(',',parstr,2),fqbParse(',',parstr,3)); + if vis = nil then Exit; + + vis.ChBox.Checked[IndexOf(fqbParse(',',parstr,1))]:= true; + vis.ChBox.ItemIndex:= IndexOf(fqbParse(',',parstr,1)); + vis.ChBox.ClickCheck; + + // n:= Grid.Items.Count - 1; + + TGridColumn(Grid.Items[i].Data^).Table:= fqbParse(',',parstr,2); + TGridColumn(Grid.Items[i].Data^).Alias:= fqbParse(',',parstr,3); + TGridColumn(Grid.Items[i].Data^).Field:= fqbParse(',',parstr,1); + TGridColumn(Grid.Items[i].Data^).Visibl:= Boolean(StrToInt(fqbParse(',',parstr,4))); + TGridColumn(Grid.Items[i].Data^).Sort:= StrToInt(fqbParse(',',parstr,5)); + TGridColumn(Grid.Items[i].Data^).Func:= StrToInt(fqbParse(',',parstr,6)); + TGridColumn(Grid.Items[i].Data^).Group:= StrToInt(fqbParse(',',parstr,7)); + TGridColumn(Grid.Items[i].Data^).Where:= fqbParse(',',parstr,8, True); + + // format: + // field_name = table_name, alias, visible, sorting, function, group, where + end; + except + fqbCore.Clear; + Exit + end; + tbl.Clear; + fqbFile.ReadSectionValues('Links',tbl); + try + for i:= 0 to tbl.Count - 1 do + begin + parstr:=tbl.Values[tbl.Names[i]]; + + lnk:= TfqbLink(TableArea.LinkList.Add); + lnk.FArea:= TableArea; + lnk.FSourceTable := TfqbTable(TableArea.Components[StrToInt(fqbParse(',',parstr,2))]); + lnk.FSourceField := lnk.SourceTable.FieldList[StrToInt(fqbParse(',',parstr,1))]; + lnk.SourceField.Linked := True; + + lnk.FDestTable := TfqbTable(TableArea.Components[StrToInt(fqbParse(',',parstr,4))]); + lnk.FDestField := lnk.DestTable.FieldList[StrToInt(fqbParse(',',parstr,3))]; + lnk.FDestField.Linked := True; + + lnk.FJType := StrToInt(fqbParse(',',parstr, 5)); + lnk.FJOp := StrToInt(fqbParse(',',parstr, 6)); + // format: + // index = sind,slst,dind,dlst,JType,JOper + end; + except + fqbCore.Clear; + Exit + end; + Grid.UpdateColumn; + finally + fqbFile.Free; + tbl.Free + end +end; + +procedure TfqbCore.SaveToFile(const FileName: string); +var + tmp: TStringList; +begin + tmp := TStringList.Create; + fqbCore.SaveToStr(tmp); + tmp.SaveToFile(FileName); + tmp.Free; +end; + +procedure TfqbCore.SaveToStr(var Str: TStringList); +var + i: Integer; + tmp, tmp2: string; +begin + Str.Clear; + tmp2 := fqbCore.GenerateSQL; + tmp := fqbTrim(tmp2, [#10,#13]); + + if tmp = '' then Exit; + + Str.Add('[DataBase]'); + Str.Add('SQL=' + IntToStr(fqbStringCRC32(tmp))); + + Str.Add('[Tables]'); + for i:= 0 to TableArea.ComponentCount - 1 do + begin + tmp := TfqbTable(TableArea.Components[i]).AliasName + '='; + tmp := tmp + TfqbTAble(TableArea.Components[i]).TableName; + tmp := tmp + ',' + IntToStr(TfqbTable(TableArea.Components[i]).Top); + tmp := tmp + ',' + IntToStr(TfqbTable(TableArea.Components[i]).Left); + tmp := tmp + ',' + IntToStr(TfqbTable(TableArea.Components[i]).Height); + tmp := tmp + ',' + IntToStr(TfqbTable(TableArea.Components[i]).Width); + Str.Add(tmp); + // format: + // alias= tablename,top,left,height,width + end; + + Str.Add('[Grid]'); + for i:= 0 to Grid.Items.Count - 1 do + begin + tmp := IntToStr(i) + '='; + tmp:= tmp + TGridColumn(Grid.Items[i].Data^).Field; + tmp:= tmp + ',' + TGridColumn(Grid.Items[i].Data^).Table; + tmp:= tmp + ',' + TGridColumn(Grid.Items[i].Data^).Alias; + tmp:= tmp + ',' + IntToStr(Integer(TGridColumn(Grid.Items[i].Data^).Visibl)); + tmp:= tmp + ',' + IntToStr(TGridColumn(Grid.Items[i].Data^).Sort); + tmp:= tmp + ',' + IntToStr(TGridColumn(Grid.Items[i].Data^).Func); + tmp:= tmp + ',' + IntToStr(TGridColumn(Grid.Items[i].Data^).Group); + tmp:= tmp + ',' + TGridColumn(Grid.Items[i].Data^).Where; + Str.Add(tmp); + // format: + // field_name = table_name, alias, visible, sorting, function, group, where + end; + + Str.Add('[Links]'); + for i:= 0 to TableArea.LinkList.Count - 1 do + begin + tmp:= IntToStr(i) + '='; + tmp:= tmp + IntToStr(TableArea.LinkList[i].SourceField.Index); + tmp:= tmp + ',' + IntToStr(TableArea.LinkList[i].SourceTable.ComponentIndex); + tmp:= tmp + ',' + IntToStr(TableArea.LinkList[i].DestField.Index); + tmp:= tmp + ',' + IntToStr(TableArea.LinkList[i].DestTable.ComponentIndex); + tmp:= tmp + ',' + IntToStr(TfqbLink(TableArea.LinkList[i]).JoinType); + tmp:= tmp + ',' + IntToStr(TfqbLink(TableArea.LinkList[i]).JoinOperator); + Str.Add(tmp); + // format: + // index = sind,slst,dind,dlst,JType,JOper + end; + + if fqbCore.FUseCoding then + tmp := fqbCompress(str.Text) + else + tmp := str.Text; + + Str.Clear; + Str.Add(tmp2); + Str.Add(_fqbBeginModel); + Str.Add(tmp); + Str.Add(_fqbEndModel); +end; + +procedure TfqbCore.SetSchemaInsideSQL(const Value: Boolean); +begin + FSchemaInsideSQL := Value; + if SchemaInsideSQL then + begin + FSQL := fqbCore.ExtractSQL(Ftext); + FSQLSchema := fqbCore.ExtractSchema(Ftext); + end +end; + +procedure TfqbCore.SetSQL(Value: string); +begin + FSQL := fqbCore.ExtractSQL(Value); + FSQLSchema := fqbCore.ExtractSchema(Value); + Ftext := FSQL + _fqbBeginModel + #$D#$A + FSQLSchema + #$D#$A + _fqbEndModel +end; + +procedure TfqbCore.SetSQLSchema(const Value: string); +begin + FSQLSchema := fqbCore.ExtractSchema(Value); + Ftext := FSQL + _fqbBeginModel + #$D#$A + FSQLSchema + #$D#$A + _fqbEndModel +end; + +{----------------------- TfqbCheckListBox -----------------------} +procedure TfqbCheckListBox.ClickCheck; +var + tmp: TfqbGrid; + tbl: TfqbTable; + i: Integer; +begin + tmp := fqbCore.Grid; + tbl := (Parent as TfqbTable); + + if not Assigned(tmp) then + raise EfqbError.Create('Class TfqbGrid not fount on form.'); + + if State[ItemIndex] = cbChecked then + begin + i:= tmp.AddColumn; + TGridColumn(tmp.Items[i].Data^).Table:= tbl.TableName; + TGridColumn(tmp.Items[i].Data^).Field:= tbl.FieldList[ItemIndex].FieldName; + TGridColumn(tmp.Items[i].Data^).Alias:= tbl.AliasName; + TGridColumn(tmp.Items[i].Data^).Where:= ''; + TGridColumn(tmp.Items[i].Data^).Sort:= 0; + TGridColumn(tmp.Items[i].Data^).Func:= 0; + TGridColumn(tmp.Items[i].Data^).Group:= 0; + TGridColumn(tmp.Items[i].Data^).Visibl:= True + end + else + if State[ItemIndex] = cbUnchecked then + begin + for i:= tmp.Items.Count - 1 downto 0 do + begin + if ((TGridColumn(tmp.Items[i].Data^).Table = tbl.TableName) + and (TGridColumn(tmp.Items[i].Data^).Field = tbl.FieldList[ItemIndex].FieldName)) then + begin + FreeMem(tmp.Items[i].Data, SizeOf(TGridColumn)); + tmp.Items.Delete(i) + end + end + end; + tmp.UpdateColumn; + Repaint; + inherited ClickCheck; +end; + +procedure TfqbCheckListBox.DragDrop(Sender: TObject; X, Y: Integer); +var + lnk: TfqbLink; +begin + lnk := (Parent.Parent as TfqbTableArea).LinkList.Add; + lnk.FArea := Parent.Parent as TfqbTableArea; + lnk.FSourceField := ((Sender as TControl).Parent as TfqbTable).SellectedField; + lnk.FSourceField.Linked := true; + lnk.FSourceTable := (Sender as TControl).Parent as TfqbTable; + + lnk.FDestField := (Self.Parent as TfqbTable).SellectedField; + lnk.FDestField.Linked := true; + lnk.FDestTable := Self.Parent as TfqbTable; + + TfqbTableArea(Parent.Parent).Invalidate; + TfqbTable((Sender as TControl).Parent).Invalidate; + Invalidate +end; + +procedure TfqbCheckListBox.DragOver(Sender: TObject; X, Y: Integer; State: + TDragState; var Accept: Boolean); +var + int: Integer; +begin + Accept := False; + if ((not (Sender is TfqbCheckListBox)) or + (Self = Sender)) then Exit; + + int := (Self as TfqbCheckListBox).ItemAtPos(Point(X,Y),True); + + if (int > (Self as TfqbCheckListBox).Items.Count - 1) or (int < 0) then + Exit; + + (Self as TfqbCheckListBox).ItemIndex:= int; + if not (Parent.Parent as TfqbTableArea).CompareFields(Parent.ComponentIndex, int, (Sender as TfqbCheckListBox).Parent.ComponentIndex, (Sender as TfqbCheckListBox).ItemIndex) + then Exit; + + Accept := True +end; + +{----------------------- TfqbGrid -----------------------} +constructor TfqbGrid.Create(AOwner: TComponent); +var + i: Integer; + mi: TMenuItem; +begin + inherited Create(AOwner); + for i:= 0 to 5 do + with Columns.Add do + begin + case i of + rowColumn : Caption := fqbGet(1820); + rowVisibility: Caption := fqbGet(1821); + rowWhere : Caption := fqbGet(1822); + rowSort : Caption := fqbGet(1823); + rowFunction : Caption := fqbGet(1824); + rowGroup : Caption := fqbGet(1825); + end; + Width := 80; + end; + + ViewStyle := vsReport; + ColumnClick := False; + HideSelection := False; + Width := 300; + DragMode := dmAutomatic; + + OnSelectItem := fqbOnSelectItem; + + FPopupMenu := TPopupMenu.Create(Self); + mi := TMenuItem.Create(FPopupMenu); + mi.Caption := fqbGet(1826); + mi.OnClick := fqbOnMenu; + mi.Tag := -1; + FPopupMenu.Items.Add(mi); + mi := TMenuItem.Create(FPopupMenu); + mi.Caption := fqbGet(1827); + mi.OnClick := fqbOnMenu; + mi.Tag := 1; + FPopupMenu.Items.Add(mi); + + FPopupMenu.OnPopup := fqbOnPopup; + PopupMenu := FPopupMenu; +end; + +destructor TfqbGrid.Destroy; +var + i: Integer; +begin + for i:= 0 to Items.Count - 1 do + Dispose(PGridColumn(Items[i])); + inherited +end; + +function TfqbGrid.AddColumn: Integer; +var + tmp: TListItem; + p: PGridColumn; +begin + tmp := Items.Add; + tmp.SubItems.Add(''); + tmp.SubItems.Add(''); + tmp.SubItems.Add(''); + tmp.SubItems.Add(''); + tmp.SubItems.Add(''); + + New(p); + tmp.Data := p; + + Result:= tmp.Index +end; + +procedure TfqbGrid.CreateWnd; +var + wnd: HWND; +begin + inherited CreateWnd; + + FVisibleList := TComboBox.Create(Self); + FVisibleList.Visible := false; + FVisibleList.Parent := Self; + FVisibleList.Style := csOwnerDrawFixed; + FVisibleList.ItemHeight := 12; + FVisibleList.Items.Add(fqbGet(1828)); + FVisibleList.Items.Add(fqbGet(1829)); + FVisibleList.OnChange := fqbOnChange; + FVisibleList.Tag := rowVisibility; + + FWhereEditor:= TfqbEdit.Create(Self); + FWhereEditor.Visible := false; + FWhereEditor.Parent := Self; + FWhereEditor.OnChange := fqbOnChange; + FWhereEditor.Tag := rowWhere; + + FSortList := TComboBox.Create(Self); + FSortList.Visible := false; + FSortList.Parent := Self; + FSortList.Style := csOwnerDrawFixed; + FSortList.ItemHeight := 12; + FSortList.Items.Add(fqbGet(1830)); + FSortList.Items.Add(fqbGet(1831)); + FSortList.Items.Add(fqbGet(1832)); + FSortList.OnChange := fqbOnChange; + FSortList.Tag := rowSort; + + FFunctionList := TComboBox.Create(Self); + FFunctionList.Visible := false; + FFunctionList.Parent := Self; + FFunctionList.Style := csOwnerDrawFixed; + FFunctionList.ItemHeight := 12; + FFunctionList.Items.Add(fqbGet(1830)); + FFunctionList.Items.Add('AVG'); + FFunctionList.Items.Add('COUNT'); + FFunctionList.Items.Add('MAX'); + FFunctionList.Items.Add('MIN'); + FFunctionList.Items.Add('SUM'); + FFunctionList.OnChange := fqbOnChange; + FFunctionList.Tag := rowFunction; + + FGroupList := TComboBox.Create(Self); + FGroupList.Visible := False; + FGroupList.Parent := Self; + FGroupList.Style := csOwnerDrawFixed; + FGroupList.ItemHeight := 12; + FGroupList.Items.Add(fqbGet(1830)); + FGroupList.Items.Add(fqbGet(1833)); + FGroupList.OnChange := fqbOnChange; + FGroupList.Tag := rowGroup; + + RecalcColWidth; + + wnd := GetWindow(Handle, GW_CHILD); + SetWindowLong(wnd, GWL_STYLE, GetWindowLong(wnd, GWL_STYLE) and not HDS_FULLDRAG) +end; + +procedure TfqbGrid.DoColumnResize(ColumnIndex, ColumnWidth: Integer); +begin + // RecalcColWidth; + fqbUpdate; + if Assigned(FEndColumnResizeEvent) then + FEndColumnResizeEvent(Self, ColumnIndex, ColumnWidth) +end; + +procedure TfqbGrid.Exchange(const AItm1, AItm2: integer); +var + tmpStr: string; + tmpDat: Pointer; +begin + tmpStr := Items[AItm1].Caption; + tmpDat := Items[AItm1].Data; + + Items[AItm1].Caption := Items[AItm2].Caption; + Items[AItm1].Data := Items[AItm2].Data; + + Items[AItm2].Caption := tmpStr; + Items[AItm2].Data := tmpDat; + + fqbUpdate; +end; + +function TfqbGrid.FindColumnIndex(pHeader: pNMHdr): Integer; +var + hwndHeader: HWND; + ItemInfo: THdItem; + ItemIndex: Integer; + buf: array [0..128] of Char; +begin + Result := -1; + hwndHeader := pHeader^.hwndFrom; + ItemIndex := pHDNotify(pHeader)^.Item; + FillChar(iteminfo, SizeOf(iteminfo), 0); + iteminfo.Mask := HDI_TEXT; + iteminfo.pszText := buf; + iteminfo.cchTextMax := SizeOf(buf) - 1; + Header_GetItem(hwndHeader, ItemIndex, iteminfo); + if CompareStr(Columns[ItemIndex].Caption, iteminfo.pszText) = 0 then + Result := ItemIndex + else + begin + for ItemIndex := 0 to Columns.Count - 1 do + if CompareStr(Columns[ItemIndex].Caption, iteminfo.pszText) = 0 then + begin + Result := ItemIndex; + Break; + end + end +end; + +function TfqbGrid.FindColumnWidth(pHeader: pNMHdr): Integer; +begin + Result := -1; + if Assigned(PHDNotify(pHeader)^.pItem) and + ((PHDNotify(pHeader)^.pItem^.mask and HDI_WIDTH) <> 0) then + Result := PHDNotify(pHeader)^.pItem^.cxy; +end; + +procedure TfqbGrid.fqbOnChange(Sender: TObject); +var + tmp: TcrTControl; +begin + if Selected = nil then Exit; + tmp := TcrTControl(Sender); + if tmp.ClassName = 'TComboBox' then + if TComboBox(tmp).ItemIndex = 0 then + Selected.SubItems[tmp.tag - 1] := '' + else + Selected.SubItems[tmp.tag - 1] := tmp.Text; + + if tmp.ClassName = 'TfqbEdit' then + Selected.SubItems[tmp.tag - 1] := tmp.Text; + + if tmp.tag = rowVisibility then + TGridColumn(Selected.Data^).Visibl := (TComboBox(tmp).ItemIndex = 0); + if tmp.tag = rowWhere then + TGridColumn(Selected.Data^).Where := tmp.Caption; + if tmp.tag = rowSort then + TGridColumn(Selected.Data^).Sort := TComboBox(tmp).ItemIndex; + if tmp.tag = rowFunction then + TGridColumn(Selected.Data^).Func := TComboBox(tmp).ItemIndex; + if tmp.tag = rowGroup then + TGridColumn(Selected.Data^).Group := TComboBox(tmp).ItemIndex; +end; + +procedure TfqbGrid.fqbOnMenu(Sender: TObject); +begin + Exchange(Selected.Index, Selected.Index + (Sender as TComponent).Tag); + Items[Selected.Index + (Sender as TComponent).Tag].Selected := True; + UpdateColumn +end; + +procedure TfqbGrid.fqbOnPopup(Sender: TObject); +begin + if Assigned(Selected) then + begin + FPopupMenu.Items[0].Enabled := Selected.Index <> 0; + FPopupMenu.Items[1].Enabled := Selected.Index <> Items.Count - 1; + end + else + begin + FPopupMenu.Items[0].Enabled := False; + FPopupMenu.Items[1].Enabled := False; + end +end; + +procedure TfqbGrid.fqbOnSelectItem(Sender: TObject; Item: TListItem; Selected: + Boolean); +var + tmp: TfqbTableArea; + tbl: TfqbTable; + i: Integer; +begin + fqbUpdate; + tmp := fqbCore.TableArea; + if not Assigned(tmp) then Exit; + tbl := tmp.FindTable(TGridColumn(Item.Data^).Table, TGridColumn(Item.Data^).Alias); + if not Assigned(tbl) then Exit; + tbl.BringToFront; + for i:= 0 to tbl.FieldList.Count - 1 do + if tbl.FieldList[i].FieldName = TGridColumn(Item.Data^).Field then + tbl.ChBox.ItemIndex := i; +end; + +procedure TfqbGrid.fqbSetBounds(var Contr: TControl); +var + i: Integer; +begin + Contr.Visible := false; + if Selected = nil then Exit; + if Assigned(TopItem) then + if TopItem.Index > Selected.Index then Exit; + Contr.Width := Columns[Contr.Tag].Width + 1; + Contr.Top := Selected.Top - 2; + Contr.Left := 0; + for i:= 0 to Contr.Tag - 1 do + Contr.Left := Contr.Left + Columns[i].Width; + Contr.Height := 19; + if Contr.ClassName = 'TComboBox' then + begin + TComboBox(Contr).ItemIndex := TComboBox(Contr).Items.IndexOf(Selected.SubItems[Contr.Tag - 1]); + end + else + if Contr.ClassName = 'TfqbEdit' then + begin + TcrTControl(Contr).Text := Selected.SubItems[Contr.Tag - 1]; + end; + Contr.Visible := true; +end; + +procedure TfqbGrid.fqbUpdate; +begin + if not (Assigned(FVisibleList) and Assigned(FWhereEditor) + and Assigned(FSortList) and Assigned(FFunctionList) + and Assigned(FGroupList)) then Exit; + fqbSetBounds(TControl(FVisibleList)); + fqbSetBounds(TControl(FWhereEditor)); + fqbSetBounds(TControl(FSortList)); + fqbSetBounds(TControl(FFunctionList)); + fqbSetBounds(TControl(FGroupList)); + FWhereEditor.Height := 18; +end; + +procedure TfqbGrid.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + Selected := GetItemAt(5, Y); + ItemFocused := Selected +end; + +procedure TfqbGrid.RecalcColWidth; +var + i, n: Integer; + w, dw: Integer; + p: Real; +begin + if not Assigned(FVisibleList) then + Exit; + w:= 0; + n := Columns.Count - 1; + for i := 0 to n do + w := w + Columns[i].Width; + dw := 0; + for i := 0 to n do + begin + p := Columns[i].Width / w; + Columns[i].Width := Round(p * (Width - 4)); + dw := dw + Columns[i].Width; + end; + Columns[n].Width := Columns[n].Width + (Width - dw - 4); +end; + +procedure TfqbGrid.Resize; +begin + inherited; + RecalcColWidth; + fqbUpdate +end; + +procedure TfqbGrid.UpdateColumn; +var + i: Integer; +begin + for i:= 0 to Items.Count - 1 do + begin + Items[i].Caption := TGridColumn(Items[i].Data^).Field; + + if TGridColumn(Items[i].Data^).Visibl then + Items[i].SubItems[rowVisibility - 1] := '' + else + Items[i].SubItems[rowVisibility - 1] := FVisibleList.Items[1]; + + Items[i].SubItems[rowWhere - 1]:= TGridColumn(Items[i].Data^).Where; + + if TGridColumn(Items[i].Data^).Sort = 0 then + Items[i].SubItems[rowSort - 1]:= '' + else + Items[i].SubItems[rowSort - 1]:= FSortList.Items[TGridColumn(Items[i].Data^).Sort]; + + if TGridColumn(Items[i].Data^).Func = 0 then + Items[i].SubItems[rowFunction - 1]:= '' + else + Items[i].SubItems[rowFunction - 1]:= FFunctionList.Items[TGridColumn(Items[i].Data^).Func]; + + if TGridColumn(Items[i].Data^).Group = 0 then + Items[i].SubItems[rowGroup - 1]:= '' + else + Items[i].SubItems[rowGroup - 1]:= FGroupList.Items[TGridColumn(Items[i].Data^).Group]; + end +end; + +procedure TfqbGrid.WMNotify(var Msg: TWMNotify); +begin + inherited; + case Msg.NMHdr^.code of + HDN_ENDTRACK: + DoColumnResize(FindColumnIndex(Msg.NMHdr), FindColumnWidth(Msg.NMHdr)); + end +end; + +procedure TfqbGrid.WMVscroll(var Msg: TWMNotify); +begin + inherited; + fqbUpdate +end; + +{----------------------- TfqbEdit -----------------------} +constructor TfqbEdit.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FPanel := TPanel.Create(Self); + FPanel.Parent := Self; + FPanel.Align := alRight; + FPanel.Width := Height - 3; + FPanel.BevelOuter := bvNone; + + FButton := TSpeedButton.Create(Self); + FButton.Parent := FPanel; + FButton.Align := alClient; + FButton.OnClick := ButtonClick; +end; + +procedure TfqbEdit.ButtonClick(Sender: TObject); +begin + SetFocus; + if Assigned(FOnButtonClick) then + FOnButtonClick(Self); +end; + +procedure TfqbEdit.CreateParams(var Params: TCreateParams); +begin + inherited CreateParams(Params); + Params.Style := Params.Style or WS_CLIPCHILDREN; +end; + +procedure TfqbEdit.CreateWnd; +begin + inherited; + ShowButton := false; +end; + +procedure TfqbEdit.SetEditRect; +var + Rec: TRect; +begin + SendMessage(Handle, EM_GETRECT, 0, LongInt(@Rec)); + if ShowButton then + begin + Rec.Bottom := ClientHeight + 1; + Rec.Right := ClientWidth - FPanel.Width - 1 + end + else + begin + Rec.Bottom := ClientHeight + 1; + Rec.Right := ClientWidth; + end; + Rec.Top := 0; + Rec.Left := 0; + SendMessage(Handle, EM_SETRECTNP, 0, LongInt(@Rec)); +end; + +procedure TfqbEdit.SetShowButton(const Value: Boolean); +begin + FShowButton := Value; + FPanel.Visible := Value; + SetEditRect +end; + +procedure TfqbEdit.WMSize(var Message: TWMSize); +begin + inherited; + SetEditRect +end; + +procedure TfqbTable.CMRelease(var Message: TMessage); +begin + Free +end; + +initialization + RegisterClasses([TComboBox, TfqbEdit]); + +finalization + if FfqbCore <> nil then + FfqbCore.Free; + +end. diff --git a/official/4.2/LibD11/fqbDesign.dfm b/official/4.2/LibD11/fqbDesign.dfm new file mode 100644 index 0000000..f1289ce Binary files /dev/null and b/official/4.2/LibD11/fqbDesign.dfm differ diff --git a/official/4.2/LibD11/fqbDesign.lfm b/official/4.2/LibD11/fqbDesign.lfm new file mode 100644 index 0000000..039c609 --- /dev/null +++ b/official/4.2/LibD11/fqbDesign.lfm @@ -0,0 +1,680 @@ +object fqbDesigner: TfqbDesigner + Left = 213 + Top = 101 + Width = 828 + Height = 614 + Caption = 'Fast Query Builder Designer' + Color = clBtnFace + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -11 + Font.Name = 'Tahoma' + Font.Style = [] + Position = poDefaultPosOnly + ShowHint = True + OnCreate = FormCreate + OnDestroy = FormDestroy + PixelsPerInch = 96 + TextHeight = 13 + object ToolBar1: TToolBar + Left = 0 + Top = 0 + Width = 820 + Height = 28 + AutoSize = True + BorderWidth = 1 + EdgeBorders = [ebBottom] + Flat = True + Images = ImageList2 + Indent = 2 + TabOrder = 1 + object ToolButton3: TToolButton + Left = 2 + Top = 0 + Hint = 'Open' + ImageIndex = 0 + OnClick = ToolButton3Click + end + object ToolButton4: TToolButton + Left = 25 + Top = 0 + Hint = 'Save' + ImageIndex = 1 + OnClick = ToolButton4Click + end + object ToolButton5: TToolButton + Left = 48 + Top = 0 + Width = 8 + Caption = 'ToolButton5' + ImageIndex = 3 + Style = tbsSeparator + end + object ToolButton6: TToolButton + Left = 56 + Top = 0 + Hint = 'Clear' + ImageIndex = 2 + OnClick = ToolButton6Click + end + object ToolButton8: TToolButton + Left = 79 + Top = 0 + Width = 8 + Caption = 'ToolButton8' + ImageIndex = 7 + Style = tbsSeparator + end + object ToolButton10: TToolButton + Left = 87 + Top = 0 + Hint = 'Cancel' + ImageIndex = 3 + OnClick = ToolButton10Click + end + object ToolButton7: TToolButton + Left = 110 + Top = 0 + Hint = 'Ok' + ImageIndex = 4 + OnClick = ToolButton7Click + end + end + object PageControl1: TPageControl + Left = 0 + Top = 28 + Width = 820 + Height = 552 + ActivePage = TabSheet1 + Align = alClient + TabOrder = 0 + object TabSheet1: TTabSheet + Caption = 'Model' + object Splitter2: TSplitter + Left = 629 + Top = 0 + Width = 3 + Height = 524 + Cursor = crHSplit + Align = alRight + end + object Panel1: TPanel + Left = 0 + Top = 0 + Width = 629 + Height = 524 + Align = alClient + BevelOuter = bvNone + Caption = 'Panel1' + TabOrder = 1 + object Splitter1: TSplitter + Left = 0 + Top = 360 + Width = 629 + Height = 3 + Cursor = crVSplit + Align = alBottom + end + object fqbTableArea1: TfqbTableArea + Left = 0 + Top = 0 + Width = 629 + Height = 360 + Align = alClient + BorderStyle = bsNone + Color = clAppWorkSpace + ParentColor = False + TabOrder = 0 + end + object fqbGrid1: TfqbGrid + Left = 0 + Top = 363 + Width = 629 + Height = 161 + Align = alBottom + BorderStyle = bsNone + Columns = < + item + Caption = 'Collumn' + Width = 104 + end + item + Caption = 'Visible' + Width = 104 + end + item + Caption = 'Where' + Width = 104 + end + item + Caption = 'Sort' + Width = 104 + end + item + Caption = 'Function' + Width = 104 + end + item + Caption = 'Group' + Width = 105 + end> + ColumnClick = False + DragMode = dmAutomatic + GridLines = True + HideSelection = False + ReadOnly = True + RowSelect = True + TabOrder = 1 + ViewStyle = vsReport + end + end + object fqbTableListBox1: TfqbTableListBox + Left = 632 + Top = 0 + Width = 180 + Height = 524 + Align = alRight + BorderStyle = bsNone + DragMode = dmAutomatic + ItemHeight = 18 + Style = lbOwnerDrawFixed + TabOrder = 0 + end + end + object TabSheet2: TTabSheet + Caption = 'SQL' + ImageIndex = 1 + OnShow = TabSheet2Show + object fqbSyntaxMemo1: TfqbSyntaxMemo + Left = 0 + Top = 0 + Width = 812 + Height = 524 + Cursor = crIBeam + Align = alClient + Font.Charset = DEFAULT_CHARSET + Font.Color = clWindowText + Font.Height = -13 + Font.Name = 'Courier New' + Font.Style = [] + ParentColor = False + ParentFont = False + TabOrder = 0 + TabStop = True + BlockColor = clHighlight + BlockFontColor = clHighlightText + CommentAttr.Charset = DEFAULT_CHARSET + CommentAttr.Color = clNavy + CommentAttr.Height = -13 + CommentAttr.Name = 'Courier New' + CommentAttr.Style = [fsItalic] + KeywordAttr.Charset = DEFAULT_CHARSET + KeywordAttr.Color = clWindowText + KeywordAttr.Height = -13 + KeywordAttr.Name = 'Courier New' + KeywordAttr.Style = [fsBold] + StringAttr.Charset = DEFAULT_CHARSET + StringAttr.Color = clNavy + StringAttr.Height = -13 + StringAttr.Name = 'Courier New' + StringAttr.Style = [] + TextAttr.Charset = DEFAULT_CHARSET + TextAttr.Color = clWindowText + TextAttr.Height = -13 + TextAttr.Name = 'Courier New' + TextAttr.Style = [] + Lines.Strings = ( + '') + ReadOnly = True + SyntaxType = stSQL + ShowFooter = True + ShowGutter = True + end + end + object TabSheet3: TTabSheet + Caption = 'Result' + ImageIndex = 2 + OnHide = TabSheet3Hide + OnShow = TabSheet3Show + object DBGrid1: TDBGrid + Left = 0 + Top = 0 + Width = 812 + Height = 524 + Align = alClient + BorderStyle = bsNone + DataSource = DataSource1 + TabOrder = 0 + TitleFont.Charset = DEFAULT_CHARSET + TitleFont.Color = clWindowText + TitleFont.Height = -11 + TitleFont.Name = 'Tahoma' + TitleFont.Style = [] + end + end + end + object DataSource1: TDataSource + Left = 232 + Top = 72 + end + object OpenDialog1: TOpenDialog + DefaultExt = 'sql' + Filter = 'SQL files|*.sql' + Left = 264 + Top = 72 + end + object SaveDialog1: TSaveDialog + Tag = -1 + DefaultExt = 'sql' + Filter = 'SQL files|*.sql' + Left = 296 + Top = 72 + end + object ImageList2: TImageList + Left = 277 + Top = 156 + Bitmap = { + 494C010105000900040010001000FFFFFFFFFF10FFFFFFFFFFFFFFFF424D3600 + 0000000000003600000028000000400000003000000001002000000000000030 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000E8C3E000D893E0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000001090 + 40000F8E3F000E8C3F000D8A3E00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000119542001192 + 41000F9040000F8E3F000E8B3F000D893E000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000149A4300139743001295 + 410000000000109040000F8E40000E8B3E000C893E0000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000159E4500159B4400139943000000 + 000000000000000000000F9041000F8D3F000D8B3E000C883E00000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000159D4500000000000000 + 00000000000000000000000000000F8F40000F8D3F000E8B3E000D883E000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000108F40000F8E3F000E8B3F000D88 + 3D00000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000000000000F8F40000E8D3F000E8A + 3E000D883E000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000F8F40000E8D + 3F000D8B3F000C883D0000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000F8F + 3F000E8C3F000D8A3E000D883E00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000F8F40000E8C3F000D893E000C873D000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000F8F3F000E8C3F00000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000007088900060809000607880005070 + 8000506070004058600040485000303840002030300020203000101820001010 + 1000101020000000000000000000000000000000000000000000C0686000B058 + 5000A0505000A0505000A0505000904850009048400090484000804040008038 + 4000803840007038400070383000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000007088900090A0B00070B0D0000090 + D0000090D0000090D0000090C0001088C0001080B0001080B0002078A0002070 + 90002048600091A1A300000000000000000000000000D0687000F0909000E080 + 8000B048200040302000C0B8B000C0B8B000D0C0C000D0C8C00050505000A040 + 3000A0403000A038300070384000000000000000000000000000D5C0AE008070 + 6000907860009070600000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000000000000B0ADD000A0A + D900000000000000000000000000000000000000000000000000000000000000 + 00000707BD000807BB0000000000000000008088900080C0D00090A8B00080E0 + FF0060D0FF0050C8FF0050C8FF0040C0F00030B0F00030A8F00020A0E0001090 + D00020688000545E6500000000000000000000000000D0707000FF98A000F088 + 8000E0808000705850004040300090787000F0E0E000F0E8E00090807000A040 + 3000A0404000A0403000803840000000000000000000A0807000A0887000D0B0 + A000D0B0A000C0B0A000B098800060483000ACA2990000000000000000000000 + 00000000000000000000000000000000000000000000000000000B0AE0000A0A + DD000A0AD9000000000000000000000000000000000000000000000000000708 + C1000708BF000708BD0000000000000000008090A00080D0F00090A8B00090C0 + D00070D8FF0060D0FF0060D0FF0050C8FF0050C0FF0040B8F00030B0F00030A8 + F0001088D00020486000B7C5C9000000000000000000D0787000FFA0A000F090 + 9000F0888000705850000000000040403000F0D8D000F0E0D00080786000B048 + 4000B0484000A04040008040400000000000C0988000E0C0B000D0C0B000E0D0 + C000F0E0E000FFF8F000B0988000A090800060483000ACA29900000000000000 + 0000000000000000000000000000000000000000000000000000000000000B0B + E1000A0BDD000A0AD900000000000000000000000000000000000809C8000808 + C5000808C1000000000000000000000000008090A00080D8F00080C8E00090A8 + B00080E0FF0070D0FF0060D8FF0060D0FF0060D0FF0050C8FF0040C0F00040B8 + F00030B0F00020688000658A99000000000000000000D0788000FFA8B000FFA0 + A000F0909000705850007058500070585000705850007060500080686000C058 + 5000B0505000B04840008040400000000000D0B0A000F0F0E000F0E8E000F0F0 + F000FFF8FF00FFF8F000FFFFFF00B0988000A090800060483000ACA299000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000B0AE0000A0ADC000A0AD90000000000000000000909CE000808CA000808 + C800000000000000000000000000000000008098A00090E0F00090E0FF0090A8 + B00090B8C00070D8FF0060D8FF0060D8FF0060D8FF0060D0FF0050D0FF0050C8 + FF0040B8F00030A0E00049677700C0CAD10000000000E0808000FFB0B000FFB0 + B000FFA0A000F0909000F0888000E0808000E0788000D0707000D0687000C060 + 6000C0585000B05050009048400000000000D0A89000FFF8FF00FFFFFF00FFFF + FF00F0F0F000F0E8E000F0E0E000FFFFFF00B0988000A090800060483000ACA2 + 9900000000000000000000000000000000000000000000000000000000000000 + 0000000000000A0AE1000A0ADD000A0AD9000A09D5000A0AD1000909CE000000 + 0000000000000000000000000000000000008098A00090E0F000A0E8FF0080C8 + E00090A8B00080E0FF0080E0FF0080E0FF0080E0FF0080E0FF0080E0FF0080E0 + FF0070D8FF0070D8FF0050A8D00085929D0000000000E0889000FFB8C000FFB8 + B000D0606000C0605000C0585000C0504000B0503000B0483000A0402000A038 + 1000C0606000C05850009048400000000000BECBCD00D0A89000FFFFFF00FFFF + FF00FFF8FF00F0F0F000F0E8E000F0E0E000FFFFFF00B0988000A09080006048 + 3000ACA299000000000000000000000000000000000000000000000000000000 + 000000000000000000000B0BE1000A0ADD000A0AD9000A0AD500000000000000 + 00000000000000000000000000000000000090A0A000A0E8F000A0E8FF00A0E8 + FF0090B0C00090B0C00090A8B00090A8B00080A0B00080A0B0008098A0008098 + A0008090A0008090A000808890007088900000000000E0909000FFC0C000D068 + 6000FFFFFF00FFFFFF00FFF8F000F0F0F000F0E8E000F0D8D000E0D0C000E0C8 + C000A0381000C0606000904850000000000000000000BECBCD00D0A89000FFFF + FF00FFFFFF00FFF8FF00F0F0F000F0E8E000F0E0E000FFFFFF00B0988000A090 + 8000604830000000000000000000000000000000000000000000000000000000 + 000000000000000000000B0BE4000B0BE0000A0ADC000A0AD900000000000000 + 00000000000000000000000000000000000090A0B000A0E8F000A0F0FF00A0E8 + FF00A0E8FF0080D8FF0060D8FF0060D8FF0060D8FF0060D8FF0060D8FF0060D8 + FF007088900000000000000000000000000000000000E098A000FFC0C000D070 + 7000FFFFFF00FFFFFF00FFFFFF00FFF8F000F0F0F000F0E8E000F0D8D000E0D0 + C000A0402000D0686000A0505000000000000000000000000000BECBCD00D0A8 + 9000FFFFFF00FFFFFF00FFF8FF00F0F0F000F0E8E000F0E0E000FFFFFF00B098 + 8000806050000000000000000000000000000000000000000000000000000000 + 0000000000000C0CEB000B0BE7000B0BE4000A0BE0000A0BDD000A0AD9000000 + 00000000000000000000000000000000000090A0B000A0F0F000B0F0F000A0F0 + FF00A0E8FF00A0E8FF0070D8FF0090A0A0008098A0008098A0008090A0008090 + 90007088900000000000000000000000000000000000F0A0A000FFC0C000E078 + 7000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFF8F000F0F0F000F0E8E000F0D8 + D000B0483000D0707000A050500000000000000000000000000000000000BECB + CD00D0A89000FFFFFF00FFFFFF00FFF8FF00F0F0F000F0E8E000F0E0E000FFFF + FF00A08070000000000000000000000000000000000000000000000000000000 + 00000C0CF1000C0CEE000B0CEB0000000000000000000B0BE0000A0ADD000A0A + D9000000000000000000000000000000000090A8B000A0D0E000B0F0F000B0F0 + F000A0F0FF00A0E8FF0090A0B000B2C9CF000000000000000000000000000000 + 00000000000090685000906850009068500000000000F0A8A000FFC0C000E080 + 8000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFF8F000F0F0F000F0E8 + E000B0503000E0788000A0505000000000000000000000000000000000000000 + 0000BECBCD00D0A89000FFFFFF00FFFFFF00FFF8FF00FFF0F000FFF8FF00E0D0 + C000B09080000000000000000000000000000000000000000000000000000C0C + F5000C0CF3000C0CF100000000000000000000000000000000000B0BE1000A0B + DD000A0AD900000000000000000000000000CBD7DC0090A8B00090A8B00090A8 + B00090A8B00090A8B000B5C6CC00000000000000000000000000000000000000 + 000000000000D0C8C800906850009068500000000000F0B0B000FFC0C000F088 + 9000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFF8F000F0F0 + F000C050400060303000B0585000000000000000000000000000000000000000 + 000000000000BECBCD00D0A89000FFFFFF00FFFFFF00FFF8FF00E0D0D000B088 + 7000BECBCD0000000000000000000000000000000000000000000D0CF7000D0D + F7000C0CF5000000000000000000000000000000000000000000000000000B0B + E0000A0ADD000A0AD90000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000090786000C7BCB5000000 + 000000000000A0908000D2CEC9009078600000000000F0B0B000FFC0C000FF90 + 9000FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFFFFF00FFF8 + F000C0585000B0586000B0586000000000000000000000000000000000000000 + 00000000000000000000BECBCD00D0A89000C0A09000B0907000B4938300BECB + CD000000000000000000000000000000000000000000000000000D0CF7000D0C + F700000000000000000000000000000000000000000000000000000000000000 + 00000B0BE0000A0BDD0000000000000000000000000000000000000000000000 + 00000000000000000000000000000000000000000000D8D9D600A0908000A088 + 8000B0988000C5BFB900000000000000000000000000F0B8B000F0B8B000F0B0 + B000F0B0B000F0A8B000F0A0A000E098A000E0909000E0909000E0889000E080 + 8000D0788000D0787000D0707000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 000000000000000000000000000000000000424D3E000000000000003E000000 + 2800000040000000300000000100010000000000800100000000000000000000 + 000000000000000000000000FFFFFF0000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 0000000000000000000000000000000000000000000000000000000000000000 + 00000000000000000000000000000000FFFF000000000000FFFF000000000000 + F3FF000000000000E1FF000000000000C0FF000000000000887F000000000000 + 1C3F000000000000BE1F000000000000FF0F000000000000FF87000000000000 + FFC3000000000000FFE1000000000000FFF0000000000000FFF9000000000000 + FFFF000000000000FFFF000000000000FFFFFFFFFFFFFFFF0007C001FFFFFFFF + 00038001C003CFF300038001807FC7E300018001003FE3C700018001001FF18F + 00008001000FF81F000080010007FC3F000080018007FC3F00078001C007F81F + 00078001E007F18F00F88001F007E3C701F88001F807C7E3FF988001FC0FCFF3 + FF838001FFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000000 + 000000000000} + end +end diff --git a/official/4.2/LibD11/fqbDesign.lrs b/official/4.2/LibD11/fqbDesign.lrs new file mode 100644 index 0000000..057214d --- /dev/null +++ b/official/4.2/LibD11/fqbDesign.lrs @@ -0,0 +1,453 @@ +LazarusResources.Add('TfqbDesigner','FORMDATA',[ + 'TPF0'#12'TfqbDesigner'#11'fqbDesigner'#4'Left'#3#213#0#3'Top'#2'e'#5'Width'#3 + +'<'#3#6'Height'#3'f'#2#7'Caption'#6#28'Fast Query Builder Designer'#5'Color' + +#7#9'clBtnFace'#12'Font.Charset'#7#15'DEFAULT_CHARSET'#10'Font.Color'#7#12'c' + +'lWindowText'#11'Font.Height'#2#245#9'Font.Name'#6#6'Tahoma'#10'Font.Style' + +#11#0#8'Position'#7#16'poDefaultPosOnly'#8'ShowHint'#9#8'OnCreate'#7#10'Form' + +'Create'#9'OnDestroy'#7#11'FormDestroy'#13'PixelsPerInch'#2'`'#10'TextHeight' + +#2#13#0#8'TToolBar'#8'ToolBar1'#4'Left'#2#0#3'Top'#2#0#5'Width'#3'4'#3#6'Hei' + +'ght'#2#28#8'AutoSize'#9#11'BorderWidth'#2#1#11'EdgeBorders'#11#8'ebBottom'#0 + +#4'Flat'#9#6'Images'#7#10'ImageList2'#6'Indent'#2#2#8'TabOrder'#2#1#0#11'TTo' + +'olButton'#11'ToolButton3'#4'Left'#2#2#3'Top'#2#0#4'Hint'#6#4'Open'#10'Image' + +'Index'#2#0#7'OnClick'#7#16'ToolButton3Click'#0#0#11'TToolButton'#11'ToolBut' + +'ton4'#4'Left'#2#25#3'Top'#2#0#4'Hint'#6#4'Save'#10'ImageIndex'#2#1#7'OnClic' + +'k'#7#16'ToolButton4Click'#0#0#11'TToolButton'#11'ToolButton5'#4'Left'#2'0'#3 + +'Top'#2#0#5'Width'#2#8#7'Caption'#6#11'ToolButton5'#10'ImageIndex'#2#3#5'Sty' + +'le'#7#12'tbsSeparator'#0#0#11'TToolButton'#11'ToolButton6'#4'Left'#2'8'#3'T' + +'op'#2#0#4'Hint'#6#5'Clear'#10'ImageIndex'#2#2#7'OnClick'#7#16'ToolButton6Cl' + +'ick'#0#0#11'TToolButton'#11'ToolButton8'#4'Left'#2'O'#3'Top'#2#0#5'Width'#2 + +#8#7'Caption'#6#11'ToolButton8'#10'ImageIndex'#2#7#5'Style'#7#12'tbsSeparato' + +'r'#0#0#11'TToolButton'#12'ToolButton10'#4'Left'#2'W'#3'Top'#2#0#4'Hint'#6#6 + +'Cancel'#10'ImageIndex'#2#3#7'OnClick'#7#17'ToolButton10Click'#0#0#11'TToolB' + +'utton'#11'ToolButton7'#4'Left'#2'n'#3'Top'#2#0#4'Hint'#6#2'Ok'#10'ImageInde' + +'x'#2#4#7'OnClick'#7#16'ToolButton7Click'#0#0#0#12'TPageControl'#12'PageCont' + +'rol1'#4'Left'#2#0#3'Top'#2#28#5'Width'#3'4'#3#6'Height'#3'('#2#10'ActivePag' + +'e'#7#9'TabSheet1'#5'Align'#7#8'alClient'#8'TabOrder'#2#0#0#9'TTabSheet'#9'T' + +'abSheet1'#7'Caption'#6#5'Model'#0#9'TSplitter'#9'Splitter2'#4'Left'#3'u'#2#3 + +'Top'#2#0#5'Width'#2#3#6'Height'#3#12#2#6'Cursor'#7#8'crHSplit'#5'Align'#7#7 + +'alRight'#0#0#6'TPanel'#6'Panel1'#4'Left'#2#0#3'Top'#2#0#5'Width'#3'u'#2#6'H' + +'eight'#3#12#2#5'Align'#7#8'alClient'#10'BevelOuter'#7#6'bvNone'#7'Caption'#6 + +#6'Panel1'#8'TabOrder'#2#1#0#9'TSplitter'#9'Splitter1'#4'Left'#2#0#3'Top'#3 + +'h'#1#5'Width'#3'u'#2#6'Height'#2#3#6'Cursor'#7#8'crVSplit'#5'Align'#7#8'alB' + +'ottom'#0#0#13'TfqbTableArea'#13'fqbTableArea1'#4'Left'#2#0#3'Top'#2#0#5'Wid' + +'th'#3'u'#2#6'Height'#3'h'#1#5'Align'#7#8'alClient'#11'BorderStyle'#7#6'bsNo' + +'ne'#5'Color'#7#14'clAppWorkSpace'#11'ParentColor'#8#8'TabOrder'#2#0#0#0#8'T' + +'fqbGrid'#8'fqbGrid1'#4'Left'#2#0#3'Top'#3'k'#1#5'Width'#3'u'#2#6'Height'#3 + +#161#0#5'Align'#7#8'alBottom'#11'BorderStyle'#7#6'bsNone'#7'Columns'#14#1#7 + +'Caption'#6#7'Collumn'#5'Width'#2'h'#0#1#7'Caption'#6#7'Visible'#5'Width'#2 + +'h'#0#1#7'Caption'#6#5'Where'#5'Width'#2'h'#0#1#7'Caption'#6#4'Sort'#5'Width' + +#2'h'#0#1#7'Caption'#6#8'Function'#5'Width'#2'h'#0#1#7'Caption'#6#5'Group'#5 + +'Width'#2'i'#0#0#11'ColumnClick'#8#8'DragMode'#7#11'dmAutomatic'#9'GridLines' + +#9#13'HideSelection'#8#8'ReadOnly'#9#9'RowSelect'#9#8'TabOrder'#2#1#9'ViewSt' + +'yle'#7#8'vsReport'#0#0#0#16'TfqbTableListBox'#16'fqbTableListBox1'#4'Left'#3 + +'x'#2#3'Top'#2#0#5'Width'#3#180#0#6'Height'#3#12#2#5'Align'#7#7'alRight'#11 + +'BorderStyle'#7#6'bsNone'#8'DragMode'#7#11'dmAutomatic'#10'ItemHeight'#2#18#5 + +'Style'#7#16'lbOwnerDrawFixed'#8'TabOrder'#2#0#0#0#0#9'TTabSheet'#9'TabSheet' + +'2'#7'Caption'#6#3'SQL'#10'ImageIndex'#2#1#6'OnShow'#7#13'TabSheet2Show'#0#14 + +'TfqbSyntaxMemo'#14'fqbSyntaxMemo1'#4'Left'#2#0#3'Top'#2#0#5'Width'#3','#3#6 + +'Height'#3#12#2#6'Cursor'#7#7'crIBeam'#5'Align'#7#8'alClient'#12'Font.Charse' + +'t'#7#15'DEFAULT_CHARSET'#10'Font.Color'#7#12'clWindowText'#11'Font.Height'#2 + +#243#9'Font.Name'#6#11'Courier New'#10'Font.Style'#11#0#11'ParentColor'#8#10 + +'ParentFont'#8#8'TabOrder'#2#0#7'TabStop'#9#10'BlockColor'#7#11'clHighlight' + +#14'BlockFontColor'#7#15'clHighlightText'#19'CommentAttr.Charset'#7#15'DEFAU' + +'LT_CHARSET'#17'CommentAttr.Color'#7#6'clNavy'#18'CommentAttr.Height'#2#243 + +#16'CommentAttr.Name'#6#11'Courier New'#17'CommentAttr.Style'#11#8'fsItalic' + +#0#19'KeywordAttr.Charset'#7#15'DEFAULT_CHARSET'#17'KeywordAttr.Color'#7#12 + +'clWindowText'#18'KeywordAttr.Height'#2#243#16'KeywordAttr.Name'#6#11'Courie' + +'r New'#17'KeywordAttr.Style'#11#6'fsBold'#0#18'StringAttr.Charset'#7#15'DEF' + +'AULT_CHARSET'#16'StringAttr.Color'#7#6'clNavy'#17'StringAttr.Height'#2#243 + +#15'StringAttr.Name'#6#11'Courier New'#16'StringAttr.Style'#11#0#16'TextAttr' + +'.Charset'#7#15'DEFAULT_CHARSET'#14'TextAttr.Color'#7#12'clWindowText'#15'Te' + +'xtAttr.Height'#2#243#13'TextAttr.Name'#6#11'Courier New'#14'TextAttr.Style' + +#11#0#13'Lines.Strings'#1#6#0#0#8'ReadOnly'#9#10'SyntaxType'#7#5'stSQL'#10'S' + +'howFooter'#9#10'ShowGutter'#9#0#0#0#9'TTabSheet'#9'TabSheet3'#7'Caption'#6#6 + +'Result'#10'ImageIndex'#2#2#6'OnHide'#7#13'TabSheet3Hide'#6'OnShow'#7#13'Tab' + +'Sheet3Show'#0#7'TDBGrid'#7'DBGrid1'#4'Left'#2#0#3'Top'#2#0#5'Width'#3','#3#6 + ,'Height'#3#12#2#5'Align'#7#8'alClient'#11'BorderStyle'#7#6'bsNone'#10'DataSo' + +'urce'#7#11'DataSource1'#8'TabOrder'#2#0#17'TitleFont.Charset'#7#15'DEFAULT_' + +'CHARSET'#15'TitleFont.Color'#7#12'clWindowText'#16'TitleFont.Height'#2#245 + +#14'TitleFont.Name'#6#6'Tahoma'#15'TitleFont.Style'#11#0#0#0#0#0#11'TDataSou' + +'rce'#11'DataSource1'#4'Left'#3#232#0#3'Top'#2'H'#0#0#11'TOpenDialog'#11'Ope' + +'nDialog1'#10'DefaultExt'#6#3'sql'#6'Filter'#6#15'SQL files|*.sql'#4'Left'#3 + +#8#1#3'Top'#2'H'#0#0#11'TSaveDialog'#11'SaveDialog1'#3'Tag'#2#255#10'Default' + +'Ext'#6#3'sql'#6'Filter'#6#15'SQL files|*.sql'#4'Left'#3'('#1#3'Top'#2'H'#0#0 + +#10'TImageList'#10'ImageList2'#4'Left'#3#21#1#3'Top'#3#156#0#6'Bitmap'#10'&2' + +#0#0'IL'#1#1#5#0#9#0#4#0#16#0#16#0#255#255#255#255#255#16#255#255#255#255#255 + +#255#255#255'BM6'#0#0#0#0#0#0#0'6'#0#0#0'('#0#0#0'@'#0#0#0'0'#0#0#0#1#0' '#0 + +#0#0#0#0#0'0'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + ,#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + ,#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#14#140'>'#0#13#137'>'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#16#144'@'#0#15#142'?'#0#14#140'?'#0#13#138'>'#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#17#149 + +'B'#0#17#146'A'#0#15#144'@'#0#15#142'?'#0#14#139'?'#0#13#137'>'#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#20#154'C'#0 + +#19#151'C'#0#18#149'A'#0#0#0#0#0#16#144'@'#0#15#142'@'#0#14#139'>'#0#12#137 + +'>'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#21#158'E'#0 + +#21#155'D'#0#19#153'C'#0#0#0#0#0#0#0#0#0#0#0#0#0#15#144'A'#0#15#141'?'#0#13 + +#139'>'#0#12#136'>'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#21#157'E'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#15#143'@'#0#15#141 + +'?'#0#14#139'>'#0#13#136'>'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#16#143'@'#0#15 + +#142'?'#0#14#139'?'#0#13#136'='#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#15#143'@'#0 + +#14#141'?'#0#14#138'>'#0#13#136'>'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#15#143 + +'@'#0#14#141'?'#0#13#139'?'#0#12#136'='#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + ,#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#15 + +#143'?'#0#14#140'?'#0#13#138'>'#0#13#136'>'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#15#143'@'#0#14#140'?'#0#13#137'>'#0#12#135'='#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#15#143'?'#0#14#140'?'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0'p'#136#144#0'`'#128 + +#144#0'`x'#128#0'Pp'#128#0'P`p'#0'@X`'#0'@HP'#0'08@'#0' 00'#0' 0'#0#16#24' ' + +#0#16#16#16#0#16#16' '#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#192'h`'#0 + +#176'XP'#0#160'PP'#0#160'PP'#0#160'PP'#0#144'HP'#0#144'H@'#0#144'H@'#0#128'@' + +'@'#0#128'8@'#0#128'8@'#0'p8@'#0'p80'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0'p' + +#136#144#0#144#160#176#0'p'#176#208#0#0#144#208#0#0#144#208#0#0#144#208#0#0 + +#144#192#0#16#136#192#0#16#128#176#0#16#128#176#0' x'#160#0' p'#144#0' H`'#0 + +#145#161#163#0#0#0#0#0#0#0#0#0#0#0#0#0#208'hp'#0#240#144#144#0#224#128#128#0 + +#176'H '#0'@0 '#0#192#184#176#0#192#184#176#0#208#192#192#0#208#200#192#0'PP' + +'P'#0#160'@0'#0#160'@0'#0#160'80'#0'p8@'#0#0#0#0#0#0#0#0#0#0#0#0#0#213#192 + +#174#0#128'p`'#0#144'x`'#0#144'p`'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#11#10#221#0#10#10 + +#217#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#7#7 + +#189#0#8#7#187#0#0#0#0#0#0#0#0#0#128#136#144#0#128#192#208#0#144#168#176#0 + +#128#224#255#0'`'#208#255#0'P'#200#255#0'P'#200#255#0'@'#192#240#0'0'#176#240 + +#0'0'#168#240#0' '#160#224#0#16#144#208#0' h'#128#0'T^e'#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#208'pp'#0#255#152#160#0#240#136#128#0#224#128#128#0'pXP'#0'@@0'#0#144 + ,'xp'#0#240#224#224#0#240#232#224#0#144#128'p'#0#160'@0'#0#160'@@'#0#160'@0'#0 + +#128'8@'#0#0#0#0#0#0#0#0#0#160#128'p'#0#160#136'p'#0#208#176#160#0#208#176 + +#160#0#192#176#160#0#176#152#128#0'`H0'#0#172#162#153#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#11#10#224#0#10#10#221#0#10 + +#10#217#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#7#8#193#0#7#8#191#0 + +#7#8#189#0#0#0#0#0#0#0#0#0#128#144#160#0#128#208#240#0#144#168#176#0#144#192 + +#208#0'p'#216#255#0'`'#208#255#0'`'#208#255#0'P'#200#255#0'P'#192#255#0'@' + +#184#240#0'0'#176#240#0'0'#168#240#0#16#136#208#0' H`'#0#183#197#201#0#0#0#0 + +#0#0#0#0#0#208'xp'#0#255#160#160#0#240#144#144#0#240#136#128#0'pXP'#0#0#0#0#0 + +'@@0'#0#240#216#208#0#240#224#208#0#128'x`'#0#176'H@'#0#176'H@'#0#160'@@'#0 + +#128'@@'#0#0#0#0#0#192#152#128#0#224#192#176#0#208#192#176#0#224#208#192#0 + +#240#224#224#0#255#248#240#0#176#152#128#0#160#144#128#0'`H0'#0#172#162#153#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#11 + +#11#225#0#10#11#221#0#10#10#217#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#8#9#200#0#8 + +#8#197#0#8#8#193#0#0#0#0#0#0#0#0#0#0#0#0#0#128#144#160#0#128#216#240#0#128 + +#200#224#0#144#168#176#0#128#224#255#0'p'#208#255#0'`'#216#255#0'`'#208#255#0 + +'`'#208#255#0'P'#200#255#0'@'#192#240#0'@'#184#240#0'0'#176#240#0' h'#128#0 + +'e'#138#153#0#0#0#0#0#0#0#0#0#208'x'#128#0#255#168#176#0#255#160#160#0#240 + +#144#144#0'pXP'#0'pXP'#0'pXP'#0'pXP'#0'p`P'#0#128'h`'#0#192'XP'#0#176'PP'#0 + +#176'H@'#0#128'@@'#0#0#0#0#0#208#176#160#0#240#240#224#0#240#232#224#0#240 + +#240#240#0#255#248#255#0#255#248#240#0#255#255#255#0#176#152#128#0#160#144 + +#128#0'`H0'#0#172#162#153#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#11#10#224#0#10#10#220#0#10#10#217#0#0#0#0#0#0#0#0#0#9 + +#9#206#0#8#8#202#0#8#8#200#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#152#160#0 + +#144#224#240#0#144#224#255#0#144#168#176#0#144#184#192#0'p'#216#255#0'`'#216 + +#255#0'`'#216#255#0'`'#216#255#0'`'#208#255#0'P'#208#255#0'P'#200#255#0'@' + +#184#240#0'0'#160#224#0'Igw'#0#192#202#209#0#0#0#0#0#224#128#128#0#255#176 + +#176#0#255#176#176#0#255#160#160#0#240#144#144#0#240#136#128#0#224#128#128#0 + +#224'x'#128#0#208'pp'#0#208'hp'#0#192'``'#0#192'XP'#0#176'PP'#0#144'H@'#0#0#0 + +#0#0#208#168#144#0#255#248#255#0#255#255#255#0#255#255#255#0#240#240#240#0 + +#240#232#224#0#240#224#224#0#255#255#255#0#176#152#128#0#160#144#128#0'`H0'#0 + +#172#162#153#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#10#10#225#0#10#10#221#0#10#10#217#0#10#9#213#0#10#10#209#0#9#9#206 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#128#152#160#0#144#224#240#0#160 + +#232#255#0#128#200#224#0#144#168#176#0#128#224#255#0#128#224#255#0#128#224 + +#255#0#128#224#255#0#128#224#255#0#128#224#255#0#128#224#255#0'p'#216#255#0 + +'p'#216#255#0'P'#168#208#0#133#146#157#0#0#0#0#0#224#136#144#0#255#184#192#0 + +#255#184#176#0#208'``'#0#192'`P'#0#192'XP'#0#192'P@'#0#176'P0'#0#176'H0'#0 + +#160'@ '#0#160'8'#16#0#192'``'#0#192'XP'#0#144'H@'#0#0#0#0#0#190#203#205#0 + +#208#168#144#0#255#255#255#0#255#255#255#0#255#248#255#0#240#240#240#0#240 + +#232#224#0#240#224#224#0#255#255#255#0#176#152#128#0#160#144#128#0'`H0'#0#172 + +#162#153#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#11#11#225#0#10#10#221#0#10#10#217#0#10#10#213#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#144#160#160#0#160#232#240#0#160#232#255#0#160#232 + +#255#0#144#176#192#0#144#176#192#0#144#168#176#0#144#168#176#0#128#160#176#0 + +#128#160#176#0#128#152#160#0#128#152#160#0#128#144#160#0#128#144#160#0#128 + +#136#144#0'p'#136#144#0#0#0#0#0#224#144#144#0#255#192#192#0#208'h`'#0#255#255 + +#255#0#255#255#255#0#255#248#240#0#240#240#240#0#240#232#224#0#240#216#208#0 + +#224#208#192#0#224#200#192#0#160'8'#16#0#192'``'#0#144'HP'#0#0#0#0#0#0#0#0#0 + +#190#203#205#0#208#168#144#0#255#255#255#0#255#255#255#0#255#248#255#0#240 + +#240#240#0#240#232#224#0#240#224#224#0#255#255#255#0#176#152#128#0#160#144 + +#128#0'`H0'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#11#11#228#0#11#11#224#0#10#10#220#0#10#10#217#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#144#160#176#0#160#232#240#0#160#240#255#0#160 + +#232#255#0#160#232#255#0#128#216#255#0'`'#216#255#0'`'#216#255#0'`'#216#255#0 + +'`'#216#255#0'`'#216#255#0'`'#216#255#0'p'#136#144#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#224#152#160#0#255#192#192#0#208'pp'#0#255#255#255#0#255#255#255#0 + +#255#255#255#0#255#248#240#0#240#240#240#0#240#232#224#0#240#216#208#0#224 + +#208#192#0#160'@ '#0#208'h`'#0#160'PP'#0#0#0#0#0#0#0#0#0#0#0#0#0#190#203#205 + +#0#208#168#144#0#255#255#255#0#255#255#255#0#255#248#255#0#240#240#240#0#240 + +#232#224#0#240#224#224#0#255#255#255#0#176#152#128#0#128'`P'#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#12#12#235#0#11#11#231#0#11 + +#11#228#0#10#11#224#0#10#11#221#0#10#10#217#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#144#160#176#0#160#240#240#0#176#240#240#0#160#240#255#0#160#232#255 + ,#0#160#232#255#0'p'#216#255#0#144#160#160#0#128#152#160#0#128#152#160#0#128 + +#144#160#0#128#144#144#0'p'#136#144#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#240#160 + +#160#0#255#192#192#0#224'xp'#0#255#255#255#0#255#255#255#0#255#255#255#0#255 + +#255#255#0#255#248#240#0#240#240#240#0#240#232#224#0#240#216#208#0#176'H0'#0 + +#208'pp'#0#160'PP'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#190#203#205#0#208#168 + +#144#0#255#255#255#0#255#255#255#0#255#248#255#0#240#240#240#0#240#232#224#0 + +#240#224#224#0#255#255#255#0#160#128'p'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#12#12#241#0#12#12#238#0#11#12#235#0#0#0#0#0#0#0#0#0#11 + +#11#224#0#10#10#221#0#10#10#217#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#144#168#176 + +#0#160#208#224#0#176#240#240#0#176#240#240#0#160#240#255#0#160#232#255#0#144 + +#160#176#0#178#201#207#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#144'hP'#0 + +#144'hP'#0#144'hP'#0#0#0#0#0#240#168#160#0#255#192#192#0#224#128#128#0#255 + +#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0#255#248 + +#240#0#240#240#240#0#240#232#224#0#176'P0'#0#224'x'#128#0#160'PP'#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#190#203#205#0#208#168#144#0#255#255#255#0#255 + +#255#255#0#255#248#255#0#255#240#240#0#255#248#255#0#224#208#192#0#176#144 + +#128#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#12#12#245#0#12#12#243 + +#0#12#12#241#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#11#11#225#0#10#11#221#0#10#10 + +#217#0#0#0#0#0#0#0#0#0#0#0#0#0#203#215#220#0#144#168#176#0#144#168#176#0#144 + +#168#176#0#144#168#176#0#144#168#176#0#181#198#204#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#208#200#200#0#144'hP'#0#144'hP'#0#0#0#0#0#240#176 + +#176#0#255#192#192#0#240#136#144#0#255#255#255#0#255#255#255#0#255#255#255#0 + +#255#255#255#0#255#255#255#0#255#255#255#0#255#248#240#0#240#240#240#0#192'P' + +'@'#0'`00'#0#176'XP'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#190 + +#203#205#0#208#168#144#0#255#255#255#0#255#255#255#0#255#248#255#0#224#208 + +#208#0#176#136'p'#0#190#203#205#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#13 + +#12#247#0#13#13#247#0#12#12#245#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#11#11#224#0#10#10#221#0#10#10#217#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#144'x`'#0#199#188#181#0 + +#0#0#0#0#0#0#0#0#160#144#128#0#210#206#201#0#144'x`'#0#0#0#0#0#240#176#176#0 + +#255#192#192#0#255#144#144#0#255#255#255#0#255#255#255#0#255#255#255#0#255 + +#255#255#0#255#255#255#0#255#255#255#0#255#255#255#0#255#248#240#0#192'XP'#0 + +#176'X`'#0#176'X`'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#190#203#205#0#208#168#144#0#192#160#144#0#176#144'p'#0#180#147#131#0#190#203 + +#205#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#13#12#247#0#13#12#247 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#11#11#224 + +#0#10#11#221#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#216#217#214#0#160#144#128#0#160#136#128#0#176#152 + +#128#0#197#191#185#0#0#0#0#0#0#0#0#0#0#0#0#0#240#184#176#0#240#184#176#0#240 + +#176#176#0#240#176#176#0#240#168#176#0#240#160#160#0#224#152#160#0#224#144 + +#144#0#224#144#144#0#224#136#144#0#224#128#128#0#208'x'#128#0#208'xp'#0#208 + +'pp'#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0'BM>'#0#0#0#0#0#0#0'>'#0#0#0'('#0#0#0'@'#0#0#0'0'#0#0#0 + +#1#0#1#0#0#0#0#0#128#1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#255#255 + +#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#255#255#0#0#0#0#0#0#255#255#0#0#0#0#0#0 + +#243#255#0#0#0#0#0#0#225#255#0#0#0#0#0#0#192#255#0#0#0#0#0#0#136''#0#0#0#0#0 + +#0#28'?'#0#0#0#0#0#0#190#31#0#0#0#0#0#0#255#15#0#0#0#0#0#0#255#135#0#0#0#0#0 + +#0#255#195#0#0#0#0#0#0#255#225#0#0#0#0#0#0#255#240#0#0#0#0#0#0#255#249#0#0#0 + +#0#0#0#255#255#0#0#0#0#0#0#255#255#0#0#0#0#0#0#255#255#255#255#255#255#255 + +#255#0#7#192#1#255#255#255#255#0#3#128#1#192#3#207#243#0#3#128#1#128''#199 + +#227#0#1#128#1#0'?'#227#199#0#1#128#1#0#31#241#143#0#0#128#1#0#15#248#31#0#0 + +#128#1#0#7#252'?'#0#0#128#1#128#7#252'?'#0#7#128#1#192#7#248#31#0#7#128#1#224 + ,#7#241#143#0#248#128#1#240#7#227#199#1#248#128#1#248#7#199#227#255#152#128#1 + +#252#15#207#243#255#131#128#1#255#255#255#255#255#255#255#255#255#255#255#255 + +#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 +]); diff --git a/official/4.2/LibD11/fqbDesign.pas b/official/4.2/LibD11/fqbDesign.pas new file mode 100644 index 0000000..afbe985 --- /dev/null +++ b/official/4.2/LibD11/fqbDesign.pas @@ -0,0 +1,210 @@ +{*******************************************} +{ } +{ FastQueryBuilder 1.03 } +{ } +{ Copyright (c) 2005 } +{ Fast Reports Inc. } +{ } +{*******************************************} + +{$I fqb.inc} + +unit fqbDesign; + +interface + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, + Dialogs, ToolWin, ComCtrls, StdCtrls, ExtCtrls, Grids, DBGrids, + ImgList, Buttons, Menus, DB +{$IFDEF Delphi6} + ,Variants +{$ENDIF} + ,fqbSynmemo, fqbClass; + +type + + TfqbDesigner = class(TForm) + DataSource1: TDataSource; + DBGrid1: TDBGrid; + fqbGrid1: TfqbGrid; + fqbSyntaxMemo1: TfqbSyntaxMemo; + fqbTableArea1: TfqbTableArea; + fqbTableListBox1: TfqbTableListBox; + ImageList2: TImageList; + OpenDialog1: TOpenDialog; + PageControl1: TPageControl; + Panel1: TPanel; + SaveDialog1: TSaveDialog; + Splitter1: TSplitter; + Splitter2: TSplitter; + TabSheet1: TTabSheet; + TabSheet2: TTabSheet; + TabSheet3: TTabSheet; + ToolBar1: TToolBar; + ToolButton10: TToolButton; + ToolButton3: TToolButton; + ToolButton4: TToolButton; + ToolButton5: TToolButton; + ToolButton6: TToolButton; + ToolButton7: TToolButton; + ToolButton8: TToolButton; + procedure FormCreate(Sender: TObject); + procedure TabSheet2Show(Sender: TObject); + procedure TabSheet3Hide(Sender: TObject); + procedure TabSheet3Show(Sender: TObject); + procedure ToolButton10Click(Sender: TObject); + procedure ToolButton3Click(Sender: TObject); + procedure ToolButton4Click(Sender: TObject); + procedure ToolButton6Click(Sender: TObject); + procedure ToolButton7Click(Sender: TObject); + procedure FormDestroy(Sender: TObject); + protected + procedure LoadPos; + procedure SavePos; + end; + + +var + fqbDesigner: TfqbDesigner; + +implementation + +{$R *.dfm} + +uses fqbUtils, fqbRes, Registry; + +type + THackWinControl = class(TWinControl); + + +{----------------------- TfqbDesigner -----------------------} +procedure TfqbDesigner.FormCreate(Sender: TObject); +begin + LoadPos; + + ToolButton7.Hint := fqbGet(1); + ToolButton10.Hint := fqbGet(2); + ToolButton6.Hint := fqbGet(1803); + ToolButton3.Hint := fqbGet(1805); + ToolButton4.Hint := fqbGet(1804); + TabSheet1.Caption := fqbGet(1806); + TabSheet2.Caption := fqbGet(1807); + TabSheet3.Caption := fqbGet(1808); + fqbGrid1.Column[0].Caption := fqbGet(1820); + fqbGrid1.Column[1].Caption := fqbGet(1821); + fqbGrid1.Column[2].Caption := fqbGet(1822); + fqbGrid1.Column[3].Caption := fqbGet(1823); + fqbGrid1.Column[4].Caption := fqbGet(1824); + fqbGrid1.Column[5].Caption := fqbGet(1825); + + THackWinControl(fqbTableArea1).BevelKind := bkFlat; + THackWinControl(fqbTableListBox1).BevelKind := bkFlat; + THackWinControl(fqbGrid1).BevelKind := bkFlat; + THackWinControl(fqbGrid1).BevelKind := bkFlat; + THackWinControl(fqbSyntaxMemo1).BevelKind := bkFlat; + THackWinControl(DBGrid1).BevelKind := bkFlat; + + PageControl1.ActivePage := PageControl1.Pages[0]; + DataSource1.DataSet := fqbCore.Engine.ResultDataSet; + fqbTableListBox1.Items.BeginUpdate; + fqbTableListBox1.Items.Clear; + fqbCore.Engine.ReadTableList(fqbTableListBox1.Items); + fqbTableListBox1.Items.EndUpdate; +end; + +procedure TfqbDesigner.TabSheet2Show(Sender: TObject); +begin + fqbSyntaxMemo1.Lines.BeginUpdate; + fqbSyntaxMemo1.Lines.Clear; + fqbSyntaxMemo1.Lines.Text := fqbCore.GenerateSQL; + fqbSyntaxMemo1.Lines.EndUpdate +end; + +procedure TfqbDesigner.TabSheet3Hide(Sender: TObject); +begin + fqbCore.Engine.ResultDataSet.Close; +end; + +procedure TfqbDesigner.TabSheet3Show(Sender: TObject); +begin + fqbCore.Engine.ResultDataSet.Close; + fqbCore.Engine.SetSQL(fqbCore.GenerateSQL); + fqbCore.Engine.ResultDataSet.Open; +end; + +procedure TfqbDesigner.ToolButton10Click(Sender: TObject); +begin + ModalResult := mrCancel +end; + +procedure TfqbDesigner.ToolButton3Click(Sender: TObject); +begin + if OpenDialog1.Execute then + begin + fqbCore.Clear; + fqbCore.LoadFromFile(OpenDialog1.FileName); + end; +end; + +procedure TfqbDesigner.ToolButton4Click(Sender: TObject); +begin + if SaveDialog1.Execute then + fqbCore.SaveToFile(SaveDialog1.FileName); +end; + +procedure TfqbDesigner.ToolButton6Click(Sender: TObject); +begin + fqbCore.Clear; +end; + +procedure TfqbDesigner.ToolButton7Click(Sender: TObject); +begin + ModalResult := mrOk +end; + +procedure TfqbDesigner.FormDestroy(Sender: TObject); +begin + SavePos; +end; + +procedure TfqbDesigner.LoadPos; +var + Reg: TRegIniFile; + s: string; +begin + s := ChangeFileExt(ExtractFileName(Application.ExeName), ''); + Reg := TRegIniFile.Create('\Software\Fast Reports\FQBuilder\' + s); + try + Reg.RootKey := HKEY_CURRENT_USER; + Reg.OpenKey('\Software\Fast Reports\FQBuilder\' + s, True); + Top := Reg.ReadInteger(Name, 'Top', Top); + Left := Reg.ReadInteger(Name, 'Left', Left); + Height := Reg.ReadInteger(Name, 'Height', Height); + Width := Reg.ReadInteger(Name, 'Width', Width); + finally + Reg.Free; + end +end; + +procedure TfqbDesigner.SavePos; +var + Reg: TRegIniFile; + s: string; +begin + s := ChangeFileExt(ExtractFileName(Application.ExeName), ''); + Reg := TRegIniFile.Create('\Software\Fast Reports\FQBuilder\' + s); + try + Reg.RootKey := HKEY_CURRENT_USER; + Reg.OpenKey('\Software\Fast Reports\FQBuilder\' + s, True); + Reg.WriteInteger(Name, 'Top', Top); + Reg.WriteInteger(Name, 'Left', Left); + Reg.WriteInteger(Name, 'Height', Height); + Reg.WriteInteger(Name, 'Width', Width); + finally + Reg.Free; + end +end; + +end. + diff --git a/official/4.2/LibD11/fqbLinkForm.dfm b/official/4.2/LibD11/fqbLinkForm.dfm new file mode 100644 index 0000000..b14f10e Binary files /dev/null and b/official/4.2/LibD11/fqbLinkForm.dfm differ diff --git a/official/4.2/LibD11/fqbLinkForm.lfm b/official/4.2/LibD11/fqbLinkForm.lfm new file mode 100644 index 0000000..4380170 --- /dev/null +++ b/official/4.2/LibD11/fqbLinkForm.lfm @@ -0,0 +1,159 @@ +object fqbLinkForm: TfqbLinkForm + Left = 385 + Height = 193 + Top = 195 + Width = 369 + HorzScrollBar.Page = 368 + VertScrollBar.Page = 192 + ActiveControl = RadioOpt + BorderIcons = [biSystemMenu] + BorderStyle = bsDialog + Caption = 'Link Options' + Font.CharSet = RUSSIAN_CHARSET + Font.Height = -11 + Font.Name = 'Tahoma' + object Label1: TLabel + Left = 2 + Height = 17 + Top = 7 + Width = 38 + Caption = 'Table 1' + Color = clNone + ParentColor = False + end + object Label2: TLabel + Left = 2 + Height = 17 + Top = 46 + Width = 38 + Caption = 'Table 2' + Color = clNone + ParentColor = False + end + object Label3: TLabel + Left = 3 + Height = 17 + Top = 24 + Width = 51 + Caption = 'Column 1' + Color = clNone + ParentColor = False + end + object Label4: TLabel + Left = 2 + Height = 17 + Top = 62 + Width = 51 + Caption = 'Column 2' + Color = clNone + ParentColor = False + end + object RadioOpt: TRadioGroup + Left = 3 + Height = 103 + Top = 85 + Width = 126 + Anchors = [akTop, akLeft, akBottom] + AutoFill = True + Caption = 'Join Operator' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ItemIndex = 0 + Items.Strings = ( + '=' + '<' + '>' + '<=' + '>=' + '<>' + ) + TabOrder = 0 + end + object RadioType: TRadioGroup + Left = 136 + Height = 103 + Top = 85 + Width = 139 + Anchors = [akTop, akLeft, akBottom] + AutoFill = True + Caption = 'Join Type' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ItemIndex = 0 + Items.Strings = ( + 'Inner' + 'Left Outer' + 'Right Outer' + 'Full Outer' + ) + TabOrder = 1 + end + object txtTable1: TStaticText + Left = 55 + Height = 16 + Top = 7 + Width = 308 + Anchors = [akTop, akLeft, akRight] + BorderStyle = sbsSunken + TabOrder = 2 + end + object txtTable2: TStaticText + Left = 55 + Height = 16 + Top = 46 + Width = 308 + Anchors = [akTop, akLeft, akRight] + BorderStyle = sbsSunken + TabOrder = 3 + end + object txtCol1: TStaticText + Left = 55 + Height = 16 + Top = 23 + Width = 308 + Anchors = [akTop, akLeft, akRight] + BorderStyle = sbsSunken + TabOrder = 4 + end + object txtCol2: TStaticText + Left = 55 + Height = 16 + Top = 62 + Width = 308 + Anchors = [akTop, akLeft, akRight] + BorderStyle = sbsSunken + TabOrder = 5 + end + object BitBtn1: TBitBtn + Left = 290 + Height = 25 + Top = 130 + Width = 75 + Anchors = [akRight, akBottom] + Kind = bkOK + NumGlyphs = 0 + TabOrder = 6 + end + object BitBtn2: TBitBtn + Left = 290 + Height = 25 + Top = 162 + Width = 75 + Anchors = [akRight, akBottom] + Kind = bkCancel + NumGlyphs = 0 + TabOrder = 7 + end +end diff --git a/official/4.2/LibD11/fqbLinkForm.lrs b/official/4.2/LibD11/fqbLinkForm.lrs new file mode 100644 index 0000000..99e0719 --- /dev/null +++ b/official/4.2/LibD11/fqbLinkForm.lrs @@ -0,0 +1,50 @@ +{ - , lazarus } + +LazarusResources.Add('TfqbLinkForm','FORMDATA',[ + 'TPF0'#12'TfqbLinkForm'#11'fqbLinkForm'#4'Left'#3#129#1#6'Height'#3#193#0#3'T' + +'op'#3#195#0#5'Width'#3'q'#1#18'HorzScrollBar.Page'#3'p'#1#18'VertScrollBar.' + +'Page'#3#192#0#13'ActiveControl'#7#8'RadioOpt'#11'BorderIcons'#11#12'biSyste' + +'mMenu'#0#11'BorderStyle'#7#8'bsDialog'#7'Caption'#6#12'Link Options'#12'Fon' + +'t.CharSet'#7#15'RUSSIAN_CHARSET'#11'Font.Height'#2#245#9'Font.Name'#6#6'Tah' + +'oma'#0#6'TLabel'#6'Label1'#4'Left'#2#2#6'Height'#2#17#3'Top'#2#7#5'Width'#2 + +'&'#7'Caption'#6#7'Table 1'#5'Color'#7#6'clNone'#11'ParentColor'#8#0#0#6'TLa' + +'bel'#6'Label2'#4'Left'#2#2#6'Height'#2#17#3'Top'#2'.'#5'Width'#2'&'#7'Capti' + +'on'#6#7'Table 2'#5'Color'#7#6'clNone'#11'ParentColor'#8#0#0#6'TLabel'#6'Lab' + +'el3'#4'Left'#2#3#6'Height'#2#17#3'Top'#2#24#5'Width'#2'3'#7'Caption'#6#8'Co' + +'lumn 1'#5'Color'#7#6'clNone'#11'ParentColor'#8#0#0#6'TLabel'#6'Label4'#4'Le' + +'ft'#2#2#6'Height'#2#17#3'Top'#2'>'#5'Width'#2'3'#7'Caption'#6#8'Column 2'#5 + +'Color'#7#6'clNone'#11'ParentColor'#8#0#0#11'TRadioGroup'#8'RadioOpt'#4'Left' + +#2#3#6'Height'#2'g'#3'Top'#2'U'#5'Width'#2'~'#7'Anchors'#11#5'akTop'#6'akLef' + +'t'#8'akBottom'#0#8'AutoFill'#9#7'Caption'#6#13'Join Operator'#28'ChildSizin' + +'g.LeftRightSpacing'#2#6#28'ChildSizing.TopBottomSpacing'#2#6#29'ChildSizing' + +'.EnlargeHorizontal'#7#24'crsHomogenousChildResize'#27'ChildSizing.EnlargeVe' + +'rtical'#7#24'crsHomogenousChildResize'#28'ChildSizing.ShrinkHorizontal'#7#14 + +'crsScaleChilds'#26'ChildSizing.ShrinkVertical'#7#14'crsScaleChilds'#18'Chil' + +'dSizing.Layout'#7#29'cclLeftToRightThenTopToBottom'#27'ChildSizing.Controls' + +'PerLine'#2#1#9'ItemIndex'#2#0#13'Items.Strings'#1#6#1'='#6#1'<'#6#1'>'#6#2 + +'<='#6#2'>='#6#2'<>'#0#8'TabOrder'#2#0#0#0#11'TRadioGroup'#9'RadioType'#4'Le' + +'ft'#3#136#0#6'Height'#2'g'#3'Top'#2'U'#5'Width'#3#139#0#7'Anchors'#11#5'akT' + +'op'#6'akLeft'#8'akBottom'#0#8'AutoFill'#9#7'Caption'#6#9'Join Type'#28'Chil' + +'dSizing.LeftRightSpacing'#2#6#28'ChildSizing.TopBottomSpacing'#2#6#29'Child' + +'Sizing.EnlargeHorizontal'#7#24'crsHomogenousChildResize'#27'ChildSizing.Enl' + +'argeVertical'#7#24'crsHomogenousChildResize'#28'ChildSizing.ShrinkHorizonta' + +'l'#7#14'crsScaleChilds'#26'ChildSizing.ShrinkVertical'#7#14'crsScaleChilds' + +#18'ChildSizing.Layout'#7#29'cclLeftToRightThenTopToBottom'#27'ChildSizing.C' + +'ontrolsPerLine'#2#1#9'ItemIndex'#2#0#13'Items.Strings'#1#6#5'Inner'#6#10'Le' + +'ft Outer'#6#11'Right Outer'#6#10'Full Outer'#0#8'TabOrder'#2#1#0#0#11'TStat' + +'icText'#9'txtTable1'#4'Left'#2'7'#6'Height'#2#16#3'Top'#2#7#5'Width'#3'4'#1 + +#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#11'BorderStyle'#7#9'sbsSunken' + +#8'TabOrder'#2#2#0#0#11'TStaticText'#9'txtTable2'#4'Left'#2'7'#6'Height'#2#16 + +#3'Top'#2'.'#5'Width'#3'4'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#11 + +'BorderStyle'#7#9'sbsSunken'#8'TabOrder'#2#3#0#0#11'TStaticText'#7'txtCol1'#4 + +'Left'#2'7'#6'Height'#2#16#3'Top'#2#23#5'Width'#3'4'#1#7'Anchors'#11#5'akTop' + +#6'akLeft'#7'akRight'#0#11'BorderStyle'#7#9'sbsSunken'#8'TabOrder'#2#4#0#0#11 + +'TStaticText'#7'txtCol2'#4'Left'#2'7'#6'Height'#2#16#3'Top'#2'>'#5'Width'#3 + +'4'#1#7'Anchors'#11#5'akTop'#6'akLeft'#7'akRight'#0#11'BorderStyle'#7#9'sbsS' + +'unken'#8'TabOrder'#2#5#0#0#7'TBitBtn'#7'BitBtn1'#4'Left'#3'"'#1#6'Height'#2 + +#25#3'Top'#3#130#0#5'Width'#2'K'#7'Anchors'#11#7'akRight'#8'akBottom'#0#4'Ki' + +'nd'#7#4'bkOK'#9'NumGlyphs'#2#0#8'TabOrder'#2#6#0#0#7'TBitBtn'#7'BitBtn2'#4 + +'Left'#3'"'#1#6'Height'#2#25#3'Top'#3#162#0#5'Width'#2'K'#7'Anchors'#11#7'ak' + +'Right'#8'akBottom'#0#4'Kind'#7#8'bkCancel'#9'NumGlyphs'#2#0#8'TabOrder'#2#7 + +#0#0#0 +]); diff --git a/official/4.2/LibD11/fqbLinkForm.pas b/official/4.2/LibD11/fqbLinkForm.pas new file mode 100644 index 0000000..fcf4257 --- /dev/null +++ b/official/4.2/LibD11/fqbLinkForm.pas @@ -0,0 +1,40 @@ +{*******************************************} +{ } +{ FastQueryBuilder 1.03 } +{ } +{ Copyright (c) 2005 } +{ Fast Reports Inc. } +{ } +{*******************************************} + +{$I fqb.inc} + +unit fqbLinkForm; + +interface + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, Buttons; + +type + TfqbLinkForm = class(TForm) + RadioOpt: TRadioGroup; + RadioType: TRadioGroup; + txtTable1: TStaticText; + txtTable2: TStaticText; + Label1: TLabel; + Label2: TLabel; + Label3: TLabel; + txtCol1: TStaticText; + Label4: TLabel; + txtCol2: TStaticText; + BitBtn1: TBitBtn; + BitBtn2: TBitBtn; + end; + +implementation + +{$R *.DFM} + +end. diff --git a/official/4.2/LibD11/fqbReg.pas b/official/4.2/LibD11/fqbReg.pas new file mode 100644 index 0000000..a0fe66b --- /dev/null +++ b/official/4.2/LibD11/fqbReg.pas @@ -0,0 +1,37 @@ +{*******************************************} +{ } +{ FastQueryBuilder 1.03 } +{ } +{ Copyright (c) 2005 } +{ Fast Reports Inc. } +{ } +{*******************************************} + +{$I fqb.inc} + +unit fqbReg; + +interface + +procedure Register; + +implementation + +uses + Windows, Messages, Classes +{$IFNDEF Delphi6} + ,DsgnIntf +{$ELSE} + ,DesignIntf, DesignEditors +{$ENDIF} + ,fqbClass, fqbSynMemo; + +{$R 'FQB.DCR'} + +procedure Register; +begin + RegisterComponents('FastQueryBuilder', [TfqbDialog, + TfqbTableArea, TfqbTableListBox, TfqbSyntaxMemo, TfqbGrid]); +end; + +end. diff --git a/official/4.2/LibD11/fqbRes.pas b/official/4.2/LibD11/fqbRes.pas new file mode 100644 index 0000000..1a06128 --- /dev/null +++ b/official/4.2/LibD11/fqbRes.pas @@ -0,0 +1,172 @@ +{******************************************} +{ } +{ FastReport v3.0 } +{ Language resources management } +{ } +{ Copyright (c) 1998-2005 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit fqbRes; + +interface + +{$I fqb.inc} + +uses + Windows, SysUtils, Classes, Controls, Graphics, Forms, ImgList, TypInfo +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfqbResources = class(TObject) + private + FNames: TStringList; + FValues: TStringList; + public + constructor Create; + destructor Destroy; override; + function Get(const StrName: String): String; + procedure Add(const Ref, Str: String); + procedure AddStrings(const Str: String); + procedure Clear; + procedure LoadFromFile(const FileName: String); + procedure LoadFromStream(Stream: TStream); + end; + +function fqbResources: TfqbResources; +function fqbGet(ID: Integer): String; + + +implementation + +var + FResources: TfqbResources = nil; + +{ TfrxResources } + +constructor TfqbResources.Create; +begin + inherited; + FNames := TStringList.Create; + FValues := TStringList.Create; + FNames.Sorted := True; +end; + +destructor TfqbResources.Destroy; +begin + FNames.Free; + FValues.Free; + inherited; +end; + +procedure TfqbResources.Add(const Ref, Str: String); +var + i: Integer; +begin + i := FNames.IndexOf(Ref); + if i = -1 then + begin + FNames.AddObject(Ref, Pointer(FValues.Count)); + FValues.Add(Str); + end + else + FValues[Integer(FNames.Objects[i])] := Str; +end; + +procedure TfqbResources.AddStrings(const Str: String); +var + i: Integer; + sl: TStringList; + nm, vl: String; +begin + sl := TStringList.Create; + sl.Text := Str; + for i := 0 to sl.Count - 1 do + begin +// nm := sl[i]; + nm := sl.Names[i];// Copy(nm, Pos('=', nm) + 1, MaxInt); + vl := sl.Values[nm];// Copy(nm, 1, Pos('=', nm) - 1); + if (nm <> '') and (vl <> '') then + Add(nm, vl); + end; + sl.Free; +end; + +procedure TfqbResources.Clear; +begin + FNames.Clear; + FValues.Clear; +end; + +function TfqbResources.Get(const StrName: String): String; +var + i: Integer; +begin + i := FNames.IndexOf(StrName); + if i <> -1 then + Result := FValues[Integer(FNames.Objects[i])] else + Result := StrName; +end; + +procedure TfqbResources.LoadFromFile(const FileName: String); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmOpenRead); + try + LoadFromStream(f); + finally + f.Free; + end; +end; + +procedure TfqbResources.LoadFromStream(Stream: TStream); +var + sl: TStringList; + i: Integer; + nm, vl: String; +begin + sl := TStringList.Create; + try + sl.LoadFromStream(Stream); + Clear; + for i := 0 to sl.Count - 1 do + begin + nm := sl[i]; + vl := Copy(nm, Pos('=', nm) + 1, MaxInt); + nm := Copy(nm, 1, Pos('=', nm) - 1); + if (nm <> '') and (vl <> '') then + Add(nm, vl); + end; + finally + sl.Free; + end +end; + + +function fqbResources: TfqbResources; +begin + if FResources = nil then + FResources := TfqbResources.Create; + Result := FResources; +end; + +function fqbGet(ID: Integer): String; +begin + Result := fqbResources.Get(IntToStr(ID)); +end; + + +initialization + +finalization + if FResources <> nil then + FResources.Free; + FResources := nil; + +end. diff --git a/official/4.2/LibD11/fqbSynmemo.dfm b/official/4.2/LibD11/fqbSynmemo.dfm new file mode 100644 index 0000000..05d74a8 Binary files /dev/null and b/official/4.2/LibD11/fqbSynmemo.dfm differ diff --git a/official/4.2/LibD11/fqbSynmemo.lfm b/official/4.2/LibD11/fqbSynmemo.lfm new file mode 100644 index 0000000..6640491 --- /dev/null +++ b/official/4.2/LibD11/fqbSynmemo.lfm @@ -0,0 +1,54 @@ +object fqbSynMemoSearch: TfqbSynMemoSearch + Left = 289 + Height = 50 + Top = 229 + Width = 243 + HorzScrollBar.Page = 242 + VertScrollBar.Page = 49 + ActiveControl = Edit1 + BorderStyle = bsToolWindow + Caption = 'Search' + Font.Height = -11 + Font.Name = 'MS Sans Serif' + KeyPreview = True + OnKeyPress = FormKeyPress + Position = poScreenCenter + object Label1: TLabel + Left = 6 + Height = 13 + Top = 7 + Width = 69 + AutoSize = False + Caption = 'Text to find' + Color = clNone + ParentColor = False + end + object Search: TButton + Left = 111 + Height = 17 + Top = 31 + Width = 58 + BorderSpacing.InnerBorder = 4 + Caption = 'Search' + ModalResult = 1 + TabOrder = 0 + end + object Button1: TButton + Left = 175 + Height = 17 + Top = 31 + Width = 61 + BorderSpacing.InnerBorder = 4 + Cancel = True + Caption = 'Cancel' + ModalResult = 2 + TabOrder = 1 + end + object Edit1: TEdit + Left = 80 + Height = 21 + Top = 4 + Width = 156 + TabOrder = 2 + end +end diff --git a/official/4.2/LibD11/fqbSynmemo.lrs b/official/4.2/LibD11/fqbSynmemo.lrs new file mode 100644 index 0000000..ff3cd6b --- /dev/null +++ b/official/4.2/LibD11/fqbSynmemo.lrs @@ -0,0 +1,18 @@ +{ - , lazarus } + +LazarusResources.Add('TfqbSynMemoSearch','FORMDATA',[ + 'TPF0'#17'TfqbSynMemoSearch'#16'fqbSynMemoSearch'#4'Left'#3'!'#1#6'Height'#2 + +'2'#3'Top'#3#229#0#5'Width'#3#243#0#18'HorzScrollBar.Page'#3#242#0#18'VertSc' + +'rollBar.Page'#2'1'#13'ActiveControl'#7#5'Edit1'#11'BorderStyle'#7#12'bsTool' + +'Window'#7'Caption'#6#6'Search'#11'Font.Height'#2#245#9'Font.Name'#6#13'MS S' + +'ans Serif'#10'KeyPreview'#9#10'OnKeyPress'#7#12'FormKeyPress'#8'Position'#7 + +#14'poScreenCenter'#0#6'TLabel'#6'Label1'#4'Left'#2#6#6'Height'#2#13#3'Top'#2 + +#7#5'Width'#2'E'#8'AutoSize'#8#7'Caption'#6#12'Text to find'#5'Color'#7#6'cl' + +'None'#11'ParentColor'#8#0#0#7'TButton'#6'Search'#4'Left'#2'o'#6'Height'#2#17 + +#3'Top'#2#31#5'Width'#2':'#25'BorderSpacing.InnerBorder'#2#4#7'Caption'#6#6 + +'Search'#11'ModalResult'#2#1#8'TabOrder'#2#0#0#0#7'TButton'#7'Button1'#4'Lef' + +'t'#3#175#0#6'Height'#2#17#3'Top'#2#31#5'Width'#2'='#25'BorderSpacing.InnerB' + +'order'#2#4#6'Cancel'#9#7'Caption'#6#6'Cancel'#11'ModalResult'#2#2#8'TabOrde' + +'r'#2#1#0#0#5'TEdit'#5'Edit1'#4'Left'#2'P'#6'Height'#2#21#3'Top'#2#4#5'Width' + +#3#156#0#8'TabOrder'#2#2#0#0#0 +]); diff --git a/official/4.2/LibD11/fqbSynmemo.pas b/official/4.2/LibD11/fqbSynmemo.pas new file mode 100644 index 0000000..0459804 --- /dev/null +++ b/official/4.2/LibD11/fqbSynmemo.pas @@ -0,0 +1,2005 @@ +{*******************************************} +{ } +{ FastQueryBuilder 1.03 } +{ Syntax memo control } +{ } +{ (c) 2003 by Alexander Tzyganenko, } +{ Fast Reports, Inc } +{ } +{*******************************************} + +{$I fqb.inc} + +unit fqbSynmemo; + +interface + +uses + Windows, Messages, Classes, Controls, StdCtrls, Forms, Menus, Graphics, SysUtils; + +type + + TSyntaxType = (stPascal, stCpp, stSQL, stText); + TCharAttr = (caNone, caText, caBlock, caComment, caKeyword, caString); + TCharAttributes = set of TCharAttr; + + TfqbSyntaxMemo = class(TCustomControl) + private + FAllowLinesChange: Boolean; + FCharHeight: Integer; + FCharWidth: Integer; + FDoubleClicked: Boolean; + FDown: Boolean; + FGutterWidth: Integer; + FFooterHeight: Integer; + FIsMonoType: Boolean; + FKeywords: String; + FMaxLength: Integer; + FMessage: String; + FModified: Boolean; + FMoved: Boolean; + FOffset: TPoint; + FPos: TPoint; + FReadOnly: Boolean; + FSelEnd: TPoint; + FSelStart: TPoint; + FSynStrings: TStrings; + FSyntaxType: TSyntaxType; + FTempPos: TPoint; + FText: TStringList; + FKeywordAttr: TFont; + FStringAttr: TFont; + FTextAttr: TFont; + FCommentAttr: TFont; + FBlockColor: TColor; + FBlockFontColor: TColor; + FUndo: TStringList; + FUpdating: Boolean; + FUpdatingSyntax: Boolean; + FVScroll: TScrollBar; + FWindowSize: TPoint; + FPopupMenu: TPopupMenu; +{$IFDEF Delphi4} + KWheel: Integer; +{$ENDIF} + LastSearch: String; + FShowGutter: boolean; + FShowFooter: boolean; +{$IFDEF Delphi4} + Bookmarks: array of Integer; +{$ELSE} + Bookmarks: array [0..10] of Integer; +{$ENDIF} + FActiveLine: Integer; + function GetText: TStrings; + procedure SetText(Value: TStrings); + procedure SetSyntaxType(Value: TSyntaxType); + procedure SetShowGutter(Value: boolean); + procedure SetShowFooter(Value: boolean); + function FMemoFind(Text: String; var Position : TPoint): boolean; + function GetCharAttr(Pos: TPoint): TCharAttributes; + function GetLineBegin(Index: Integer): Integer; + function GetPlainTextPos(Pos: TPoint): Integer; + function GetPosPlainText(Pos: Integer): TPoint; + function GetSelText: String; + function LineAt(Index: Integer): String; + function LineLength(Index: Integer): Integer; + function Pad(n: Integer): String; + procedure AddSel; + procedure AddUndo; + procedure ClearSel; + procedure CreateSynArray; + procedure DoChange; + procedure EnterIndent; + procedure SetSelText(Value: String); + procedure ShiftSelected(ShiftRight: Boolean); + procedure ShowCaretPos; + procedure TabIndent; + procedure UnIndent; + procedure UpdateScrollBar; + procedure UpdateSyntax; + procedure DoLeft; + procedure DoRight; + procedure DoUp; + procedure DoDown; + procedure DoHome(Ctrl: Boolean); + procedure DoEnd(Ctrl: Boolean); + procedure DoPgUp; + procedure DoPgDn; + procedure DoChar(Ch: Char); + procedure DoReturn; + procedure DoDel; + procedure DoBackspace; + procedure DoCtrlI; + procedure DoCtrlU; + procedure DoCtrlR; + procedure DoCtrlL; + procedure ScrollClick(Sender: TObject); + procedure ScrollEnter(Sender: TObject); + procedure LinesChange(Sender: TObject); + procedure ShowPos; + procedure BookmarkDraw(Y :integer; line : integer); + procedure ActiveLineDraw(Y :integer; line : integer); + procedure CorrectBookmark(Line : integer; delta : integer); + procedure SetKeywordAttr(Value: TFont); + procedure SetStringAttr(Value: TFont); + procedure SetTextAttr(Value: TFont); + procedure SetCommentAttr(Value: TFont); + + protected + { Windows-specific stuff } + procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE; + procedure WMKillFocus(var Msg: TWMKillFocus); message WM_KILLFOCUS; + procedure WMSetFocus(var Msg: TWMSetFocus); message WM_SETFOCUS; + procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED; + { End of stuff } + procedure SetParent(Value: TWinControl); override; + function GetClientRect: TRect; override; + procedure DblClick; override; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure KeyDown(var Key: Word; Shift: TShiftState); override; + procedure KeyPress(var Key: Char); override; + procedure CopyPopup(Sender: TObject); + procedure PastePopup(Sender: TObject); + procedure CutPopup(Sender: TObject); +{$IFDEF Delphi4} + procedure MouseWheelUp(Sender: TObject; Shift: TShiftState; + MousePos: TPoint; var Handled: Boolean); + procedure MouseWheelDown(Sender: TObject; Shift: TShiftState; + MousePos: TPoint; var Handled: Boolean); +{$ENDIF} + procedure DOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure DDrop(Sender, Source: TObject; X, Y: Integer); + + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override; + procedure Paint; override; + procedure CopyToClipboard; + procedure CutToClipboard; + procedure PasteFromClipboard; + procedure SetPos(x, y: Integer); + procedure ShowMessage(s: String); + procedure Undo; + procedure UpdateView; + function GetPos: TPoint; + function Find(Text: String): boolean; + property Modified: Boolean read FModified write FModified; + property SelText: String read GetSelText write SetSelText; + function IsBookmark(Line : integer): integer; + procedure AddBookmark(Line, Number : integer); + procedure DeleteBookmark(Number : integer); + procedure GotoBookmark(Number : integer); + procedure SetActiveLine(Line : Integer); + function GetActiveLine: Integer; + + published + property Align; +{$IFDEF Delphi4} + property Anchors; + property BiDiMode; + property Constraints; + property DragKind; + property ParentBiDiMode; +{$ENDIF} + property Color; + property DragCursor; + property DragMode; + property Enabled; + property Font; + property ParentColor; + property ParentCtl3D; + property ParentFont; + property ParentShowHint; + property PopupMenu; + property ShowHint; + property TabOrder; + property TabStop; + property Width; + property Height; + property Visible; + property BlockColor: TColor read FBlockColor write FBlockColor; + property BlockFontColor: TColor read FBlockFontColor write FBlockFontColor; + property CommentAttr: TFont read FCommentAttr write SetCommentAttr; + property KeywordAttr: TFont read FKeywordAttr write SetKeywordAttr; + property StringAttr: TFont read FStringAttr write SetStringAttr; + property TextAttr: TFont read FTextAttr write SetTextAttr; + property Lines: TStrings read GetText write SetText; + property ReadOnly: Boolean read FReadOnly write FReadOnly; + property SyntaxType: TSyntaxType read FSyntaxType write SetSyntaxType; + property ShowFooter: boolean read FShowFooter write SetShowFooter; + property ShowGutter: boolean read FShowGutter write SetShowGutter; + property OnClick; + property OnDblClick; + property OnDragDrop; + property OnDragOver; + property OnEndDrag; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + property OnStartDrag; + end; + + TfqbSynMemoSearch = class(TForm) + Search: TButton; + Button1: TButton; + Label1: TLabel; + Edit1: TEdit; + procedure FormKeyPress(Sender: TObject; var Key: Char); + private + { Private declarations } + public + { Public declarations } + end; + +var + fqbSynMemoSearch: TfqbSynMemoSearch; + +procedure Register; + +implementation + +{$R *.DFM} + +uses Clipbrd, comctrls; + +procedure Register; +begin + RegisterComponents('FastQB2', [TfqbSyntaxMemo]) +end; + +const + PasKeywords = + 'and,array,begin,case,const,div,do,downto,else,end,except,finally,'+ + 'for,function,if,in,is,mod,nil,not,of,or,procedure,program,repeat,shl,'+ + 'shr,string,then,to,try,until,uses,var,while,with,xor'; + + CppKeywords = + 'bool,break,case,char,continue,define,default,delete,do,double,else,'+ + 'except,finally,float,for,if,include,int,is,new,return,string,switch,try,'+ + 'variant,void,while'; + + SQLKeywords = + 'active,after,all,alter,and,any,as,asc,ascending,at,auto,' + + 'base_name,before,begin,between,by,cache,cast,check,column,commit,' + + 'committed,computed,conditional,constraint,containing,count,create,' + + 'current,cursor,database,debug,declare,default,delete,desc,descending,' + + 'distinct,do,domain,drop,else,end,entry_point,escape,exception,execute,' + + 'exists,exit,external,extract,filter,for,foreign,from,full,function,' + + 'generator,grant,group,having,if,in,inactive,index,inner,insert,into,is,' + + 'isolation,join,key,left,level,like,merge,names,no,not,null,of,on,only,' + + 'or,order,outer,parameter,password,plan,position,primary,privileges,' + + 'procedure,protected,read,retain,returns,revoke,right,rollback,schema,' + + 'select,set,shadow,shared,snapshot,some,suspend,table,then,to,' + + 'transaction,trigger,uncommitted,union,unique,update,user,using,view,' + + 'wait,when,where,while,with,work'; + + WordChars = ['a'..'z', 'A'..'Z', '0'..'9', '_']; + +type + THackScrollBar = class(TScrollBar) + end; + +{ TfrSyntaxMemo } + +constructor TfqbSyntaxMemo.Create(AOwner: TComponent); +var + m: TMenuItem; + i: integer; +begin + inherited Create(AOwner); + + FVScroll := TScrollBar.Create(Self); + + FCommentAttr := TFont.Create; + FCommentAttr.Color := clNavy; + FCommentAttr.Style := [fsItalic]; + + FKeywordAttr := TFont.Create; + FKeywordAttr.Color := clWindowText; + FKeywordAttr.Style := [fsBold]; + + FStringAttr := TFont.Create; + FStringAttr.Color := clNavy; + FStringAttr.Style := []; + + FTextAttr := TFont.Create; + FTextAttr.Color := clWindowText; + FTextAttr.Style := []; + + + if AOwner is TWinControl then + Parent := AOwner as TWinControl; + + OnDragOver := DOver; + OnDragDrop := DDrop; + +{$IFDEF Delphi4} + OnMouseWheelUp := MouseWheelUp; + OnMouseWheelDown := MouseWheelDown; + KWheel := 1; +{$ENDIF} + + FText := TStringList.Create; + FUndo := TStringList.Create; + FSynStrings := TStringList.Create; + FText.Add(''); + FText.OnChange := LinesChange; + FMaxLength := 1024; + SyntaxType := stPascal; + FMoved := True; + SetPos(1, 1); + + Cursor := crIBeam; + FBlockColor := clHighlight; + FBlockFontColor := clHighlightText; + + Font.Size := 10; + Font.Name := 'Courier New'; + + FPopupMenu := TPopupMenu.Create(Self); + m := TMenuItem.Create(FPopupMenu); + m.Caption := 'Cut'; + m.OnClick := CutPopup; + FPopupMenu.Items.Add(m); + m := TMenuItem.Create(FPopupMenu); + m.Caption := 'Copy'; + m.OnClick := CopyPopup; + FPopupMenu.Items.Add(m); + m := TMenuItem.Create(FPopupMenu); + m.Caption := 'Paste'; + m.OnClick := PastePopup; + FPopupMenu.Items.Add(m); + + LastSearch := ''; +{$IFDEF Delphi4} + Setlength(Bookmarks, 10); + for i := 0 to Length(Bookmarks)-1 do +{$ELSE} + for i := 0 to 9 do +{$ENDIF} + Bookmarks[i] := -1; + + FActiveLine := -1; + + Height := 200; + Width := 200; + +end; + +destructor TfqbSyntaxMemo.Destroy; +begin + FPopupMenu.Free; + FCommentAttr.Free; + FKeywordAttr.Free; + FStringAttr.Free; + FTextAttr.Free; + FText.Free; + FUndo.Free; + FSynStrings.Free; + FVScroll.Free; + inherited; +end; + +{ Windows-specific stuff } + +procedure TfqbSyntaxMemo.WMKillFocus(var Msg: TWMKillFocus); +begin + inherited; + HideCaret(Handle); + DestroyCaret; +end; + +procedure TfqbSyntaxMemo.WMSetFocus(var Msg: TWMSetFocus); +begin + inherited; + CreateCaret(Handle, 0, 2, FCharHeight); + ShowCaretPos; +end; + +procedure TfqbSyntaxMemo.ShowCaretPos; +begin + SetCaretPos(FCharWidth * (FPos.X - 1 - FOffset.X) + FGutterWidth, + FCharHeight * (FPos.Y - 1 - FOffset.Y)); + ShowCaret(Handle); + ShowPos; +end; + +procedure TfqbSyntaxMemo.ShowPos; +begin + if FFooterHeight > 0 then + with Canvas do + begin + Font.Name := 'Tahoma'; + Font.Color := clBlack; + Font.Style := []; + Font.Size := 8; + Brush.Color := clBtnFace; + TextOut(FGutterWidth + 4, Height - TextHeight('|') - 5, IntToStr(FPos.y) + ' : ' + IntToStr(FPos.x) + ' '); + end; +end; + +procedure TfqbSyntaxMemo.WMGetDlgCode(var Message: TWMGetDlgCode); +begin + Message.Result := DLGC_WANTARROWS or DLGC_WANTTAB; +end; + +procedure TfqbSyntaxMemo.CMFontChanged(var Message: TMessage); +var + b: TBitmap; +begin + FCommentAttr.Size := Font.Size; + FCommentAttr.Name := Font.Name; + FKeywordAttr.Size := Font.Size; + FKeywordAttr.Name := Font.Name; + FStringAttr.Size := Font.Size; + FStringAttr.Name := Font.Name; + FTextAttr.Size := Font.Size; + FTextAttr.Name := Font.Name; + + b := TBitmap.Create; + with b.Canvas do + begin + Font.Assign(Self.Font); + Font.Style := [fsBold]; + FCharHeight := TextHeight('Wg'); + FCharWidth := TextWidth('W'); + FIsMonoType := Pos('COURIER NEW', AnsiUppercase(Self.Font.Name)) <> 0; + end; + b.Free; +end; + +{ End of stuff } + +procedure TfqbSyntaxMemo.SetParent(Value: TWinControl); +begin + inherited SetParent(Value); + if (Parent = nil) or (csDestroying in ComponentState) then Exit; + + ShowGutter := True; + ShowFooter := True; + FVScroll.Parent := Self; + FVScroll.Kind := sbVertical; + FVScroll.OnChange := ScrollClick; + FVScroll.OnEnter := ScrollEnter; + FVScroll.Ctl3D := False; + Color := clWindow; + TabStop := True; + +end; + + +function TfqbSyntaxMemo.GetClientRect: TRect; +begin + if FVScroll.Visible then + Result := Bounds(0, 0, Width - FVScroll.Width - 4, Height) else + Result := inherited GetClientRect; +end; + +procedure TfqbSyntaxMemo.SetBounds(ALeft, ATop, AWidth, AHeight: Integer); +begin + inherited; + if FCharWidth = 0 then exit; + FWindowSize := Point((ClientWidth - FGutterWidth) div FCharWidth, + (Height - FFooterHeight) div FCharHeight ); + FVScroll.SetBounds(Width - FVScroll.Width - 4, 0, FVScroll.Width, Height - 4); + UpdateScrollBar; +end; + +procedure TfqbSyntaxMemo.UpdateSyntax; +begin + CreateSynArray; + Repaint; +end; + +procedure TfqbSyntaxMemo.UpdateScrollBar; +begin + with FVScroll do + begin +// prevent OnScroll event + FUpdating := True; + Position := 0; +{$IFDEF Delphi4} + PageSize := 0; +{$ENDIF} + if Assigned(FText) then + Max := FText.Count + else + Max := 0; + SmallChange := 1; + if FWindowSize.Y < Max then + begin + Visible := True; +{$IFDEF Delphi4} + PageSize := FWindowSize.Y; +{$ENDIF} + end + else + Visible := False; + LargeChange := FWindowSize.Y; + Position := FOffset.Y; + +// need to do this due to bug in the VCL +// THackScrollBar(FVScroll).RecreateWnd; + FUpdating := False; + end; +end; + +function TfqbSyntaxMemo.GetText: TStrings; +var + i: Integer; +begin + for i := 0 to FText.Count - 1 do + FText[i] := LineAt(i); + Result := FText; + FAllowLinesChange := True; +end; + +procedure TfqbSyntaxMemo.SetText(Value: TStrings); +begin + FAllowLinesChange := True; + FText.Assign(Value); +end; + +procedure TfqbSyntaxMemo.SetSyntaxType(Value: TSyntaxType); +begin + FSyntaxType := Value; + if Value = stPascal then + FKeywords := PasKeywords + else if Value = stCpp then + FKeywords := CppKeywords + else if Value = stSQL then + FKeywords := SQLKeywords + else + FKeywords := ''; + UpdateSyntax; +end; + +function TfqbSyntaxMemo.GetPos: TPoint; +begin + Result := FPos; +end; + +procedure TfqbSyntaxMemo.DoChange; +begin + FModified := True; +end; + +procedure TfqbSyntaxMemo.LinesChange(Sender: TObject); +begin + if FAllowLinesChange then + begin + UpdateSyntax; + FAllowLinesChange := False; + if FText.Count = 0 then + FText.Add(''); + FMoved := True; + FUndo.Clear; + FPos := Point(1, 1); + FOffset := Point(0, 0); + ClearSel; + ShowCaretPos; + UpdateScrollBar; + end; +end; + +procedure TfqbSyntaxMemo.ShowMessage(s: String); +begin + FMessage := s; + Repaint; +end; + +procedure TfqbSyntaxMemo.CopyToClipboard; +begin + if FSelStart.X <> 0 then + Clipboard.AsText := SelText; +end; + +procedure TfqbSyntaxMemo.CutToClipboard; +begin + if not FReadOnly then + begin + if FSelStart.X <> 0 then + begin + Clipboard.AsText := SelText; + SelText := ''; + end; + CorrectBookmark(FSelStart.Y, FSelStart.Y - FSelEnd.Y); + Repaint; + end; +end; + +procedure TfqbSyntaxMemo.PasteFromClipboard; +begin + if not FReadOnly then + SelText := Clipboard.AsText; +end; + +function TfqbSyntaxMemo.LineAt(Index: Integer): String; +begin + if Index < FText.Count then + Result := TrimRight(FText[Index]) + else + Result := ''; +end; + +function TfqbSyntaxMemo.LineLength(Index: Integer): Integer; +begin + Result := Length(LineAt(Index)); +end; + +function TfqbSyntaxMemo.Pad(n: Integer): String; +begin + result := ''; + SetLength(result, n); + FillChar(result[1], n, ' '); +end; + +procedure TfqbSyntaxMemo.AddUndo; +begin + if not FMoved then exit; + FUndo.Add(Format('%5d%5d', [FPos.X, FPos.Y]) + FText.Text); + if FUndo.Count > 32 then + FUndo.Delete(0); +end; + +procedure TfqbSyntaxMemo.Undo; +var + s: String; +begin + FMoved := True; + if FUndo.Count = 0 then exit; + s := FUndo[FUndo.Count - 1]; + FPos.X := StrToInt(Copy(s, 1, 5)); + FPos.Y := StrToInt(Copy(s, 6, 5)); + FText.Text := Copy(s, 11, Length(s) - 10); + FUndo.Delete(FUndo.Count - 1); + SetPos(FPos.X, FPos.Y); + UpdateSyntax; + DoChange; +end; + +function TfqbSyntaxMemo.GetPlainTextPos(Pos: TPoint): Integer; +var + i: Integer; +begin + Result := 0; + for i := 0 to Pos.Y - 2 do + Result := Result + Length(FText[i]) + 2; + Result := Result + Pos.X; +end; + +function TfqbSyntaxMemo.GetPosPlainText(Pos: Integer): TPoint; +var + i: Integer; + s: String; +begin + Result := Point(0, 1); + s := FText.Text; + i := 1; + while i <= Pos do + if s[i] = #13 then + begin + Inc(i, 2); + if i <= Pos then + begin + Inc(Result.Y); + Result.X := 0; + end + else + Inc(Result.X); + end + else + begin + Inc(i); + Inc(Result.X); + end; +end; + +function TfqbSyntaxMemo.GetLineBegin(Index: Integer): Integer; +var + s: String; +begin + s := FText[Index]; + Result := 1; + if Trim(s) <> '' then + for Result := 1 to Length(s) do + if s[Result] <> ' ' then + break; +end; + +procedure TfqbSyntaxMemo.TabIndent; +var + i, n, res: Integer; + s: String; +begin + res := FPos.X; + i := FPos.Y - 2; + + while i >= 0 do + begin + res := FPos.X; + s := FText[i]; + n := LineLength(i); + + if res > n then + Dec(i) + else + begin + if s[res] = ' ' then + begin + while s[res] = ' ' do + Inc(res); + end + else + begin + while (res <= n) and (s[res] <> ' ') do + Inc(res); + + while (res <= n) and (s[res] = ' ') do + Inc(res); + end; + break; + end; + end; + + SelText := Pad(res - FPos.X); +end; + +procedure TfqbSyntaxMemo.EnterIndent; +var + res: Integer; +begin + if Trim(FText[FPos.Y - 1]) = '' then + res := FPos.X else + res := GetLineBegin(FPos.Y - 1); + + CorrectBookmark(FPos.Y, 1); + + FPos := Point(1, FPos.Y + 1); + SelText := Pad(res - 1); +end; + +procedure TfqbSyntaxMemo.UnIndent; +var + i, res: Integer; +begin + i := FPos.Y - 2; + res := FPos.X - 1; + CorrectBookmark(FPos.Y, -1); + while i >= 0 do + begin + res := GetLineBegin(i); + if (res < FPos.X) and (Trim(FText[i]) <> '') then + break else + Dec(i); + end; + FSelStart := FPos; + FSelEnd := FPos; + Dec(FSelEnd.X, FPos.X - res); + SelText := ''; +end; + +procedure TfqbSyntaxMemo.ShiftSelected(ShiftRight: Boolean); +var + i, ib, ie: Integer; + s: String; + Shift: Integer; +begin + if FReadOnly then exit; + AddUndo; + if FSelStart.X + FSelStart.Y * FMaxLength < FSelEnd.X + FSelEnd.Y * FMaxLength then + begin + ib := FSelStart.Y - 1; + ie := FSelEnd.Y - 1; + end + else + begin + ib := FSelEnd.Y - 1; + ie := FSelStart.Y - 1; + end; + if FSelEnd.X = 1 then + Dec(ie); + + Shift := 2; + if not ShiftRight then + for i := ib to ie do + begin + s := FText[i]; + if (Trim(s) <> '') and (GetLineBegin(i) - 1 < Shift) then + Shift := GetLineBegin(i) - 1; + end; + + for i := ib to ie do + begin + s := FText[i]; + if ShiftRight then + s := Pad(Shift) + s + else if Trim(s) <> '' then + Delete(s, 1, Shift); + FText[i] := s; + end; + UpdateSyntax; + DoChange; +end; + +function TfqbSyntaxMemo.GetSelText: String; +var + p1, p2: TPoint; + i: Integer; +begin + if FSelStart.X + FSelStart.Y * FMaxLength < FSelEnd.X + FSelEnd.Y * FMaxLength then + begin + p1 := FSelStart; + p2 := FSelEnd; + Dec(p2.X); + end + else + begin + p1 := FSelEnd; + p2 := FSelStart; + Dec(p2.X); + end; + + if LineLength(p1.Y - 1) < p1.X then + begin + Inc(p1.Y); + p1.X := 1; + end; + if LineLength(p2.Y - 1) < p2.X then + p2.X := LineLength(p2.Y - 1); + + i := GetPlainTextPos(p1); + Result := Copy(FText.Text, i, GetPlainTextPos(p2) - i + 1); +end; + +procedure TfqbSyntaxMemo.SetSelText(Value: String); +var + p1, p2, p3: TPoint; + i: Integer; + s: String; +begin + if FReadOnly then exit; + AddUndo; + if FSelStart.X = 0 then + begin + p1 := FPos; + p2 := p1; + Dec(p2.X); + end + else if FSelStart.X + FSelStart.Y * FMaxLength < FSelEnd.X + FSelEnd.Y * FMaxLength then + begin + p1 := FSelStart; + p2 := FSelEnd; + Dec(p2.X); + end + else + begin + p1 := FSelEnd; + p2 := FSelStart; + Dec(p2.X); + end; + + if LineLength(p1.Y - 1) < p1.X then + FText[p1.Y - 1] := FText[p1.Y - 1] + Pad(p1.X - LineLength(p1.Y - 1) + 1); + if LineLength(p2.Y - 1) < p2.X then + p2.X := LineLength(p2.Y - 1); + + i := GetPlainTextPos(p1); + s := FText.Text; + Delete(s, i, GetPlainTextPos(p2) - i + 1); + Insert(Value, s, i); + FText.Text := s; + p3 := GetPosPlainText(i + Length(Value)); + + CorrectBookmark(FPos.Y, p3.y-FPos.Y); + + SetPos(p3.X, p3.Y); + FSelStart.X := 0; + DoChange; + UpdateSyntax; +end; + +procedure TfqbSyntaxMemo.ClearSel; +begin + if FSelStart.X <> 0 then + begin + FSelStart := Point(0, 0); + Repaint; + end; +end; + +procedure TfqbSyntaxMemo.AddSel; +begin + if FSelStart.X = 0 then + FSelStart := FTempPos; + FSelEnd := FPos; + Repaint; +end; + +procedure TfqbSyntaxMemo.SetPos(x, y: Integer); +begin + if FMessage <> '' then + begin + FMessage := ''; + Repaint; + end; + + if x > FMaxLength then x := FMaxLength; + if x < 1 then x := 1; + if y > FText.Count then y := FText.Count; + if y < 1 then y := 1; + + FPos := Point(x, y); + if (FWindowSize.X = 0) or (FWindowSize.Y = 0) then exit; + + if FOffset.Y >= FText.Count then + FOffset.Y := FText.Count - 1; + + if FPos.X > FOffset.X + FWindowSize.X then + begin + Inc(FOffset.X, FPos.X - (FOffset.X + FWindowSize.X)); + Repaint; + end + else if FPos.X <= FOffset.X then + begin + Dec(FOffset.X, FOffset.X - FPos.X + 1); + Repaint; + end + else if FPos.Y > FOffset.Y + FWindowSize.Y then + begin + Inc(FOffset.Y, FPos.Y - (FOffset.Y + FWindowSize.Y)); + Repaint; + end + else if FPos.Y <= FOffset.Y then + begin + Dec(FOffset.Y, FOffset.Y - FPos.Y + 1); + Repaint; + end; + + ShowCaretPos; + UpdateScrollBar; + +end; + +procedure TfqbSyntaxMemo.ScrollClick(Sender: TObject); +begin + if FUpdating then exit; + FOffset.Y := FVScroll.Position; + if FOffset.Y > FText.Count then + FOffset.Y := FText.Count; + ShowCaretPos; + Repaint; +end; + +procedure TfqbSyntaxMemo.ScrollEnter(Sender: TObject); +begin + SetFocus; +end; + +procedure TfqbSyntaxMemo.DblClick; +var + s: String; +begin + FDoubleClicked := True; + DoCtrlL; + FSelStart := FPos; + s := LineAt(FPos.Y - 1); + if s <> '' then + while s[FPos.X] in WordChars do + Inc(FPos.X); + FSelEnd := FPos; + Repaint; +end; + +procedure TfqbSyntaxMemo.MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + if FDoubleClicked then + begin + FDoubleClicked := False; + Exit; + end; + if (Button = mbRight) and (PopupMenu = nil) then +{$IFDEF Delphi4} + FPopUpMenu.Popup(Mouse.CursorPos.x, Mouse.CursorPos.y) +{$ENDIF} + else + begin + FMoved := True; + if not Focused then + SetFocus; + FDown := True; + SetPos((X - FGutterWidth) div FCharWidth + 1 + FOffset.X, + Y div FCharHeight + 1 + FOffset.Y); + ClearSel; + end; +end; + +procedure TfqbSyntaxMemo.MouseMove(Shift: TShiftState; X, Y: Integer); +begin + if FDown then + begin + FTempPos := FPos; + FPos.X := (X - FGutterWidth) div FCharWidth + 1 + FOffset.X; + FPos.Y := Y div FCharHeight + 1 + FOffset.Y; + if (FPos.X <> FTempPos.X) or (FPos.Y <> FTempPos.Y) then + begin + SetPos(FPos.X, FPos.Y); + AddSel; + end; + end; +end; + +procedure TfqbSyntaxMemo.MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + FDown := False; +end; + +procedure TfqbSyntaxMemo.KeyDown(var Key: Word; Shift: TShiftState); +var + MyKey: Boolean; +begin + inherited; + FAllowLinesChange := False; + + FTempPos := FPos; + MyKey := True; + case Key of + vk_Left: + if ssCtrl in Shift then + DoCtrlL else + DoLeft; + + vk_Right: + if ssCtrl in Shift then + DoCtrlR else + DoRight; + + vk_Up: + DoUp; + + vk_Down: + DoDown; + + vk_Home: + DoHome(ssCtrl in Shift); + + vk_End: + DoEnd(ssCtrl in Shift); + + vk_Prior: + DoPgUp; + + vk_Next: + DoPgDn; + + vk_Return: + if Shift = [] then + DoReturn; + + vk_Delete: + if ssShift in Shift then + CutToClipboard else + DoDel; + + vk_Back: + DoBackspace; + + vk_Insert: + if ssCtrl in Shift then + CopyToClipboard + else if ssShift in Shift then + PasteFromClipboard; + + vk_Tab: + TabIndent; + + vk_F3: + Find(LastSearch); // F3 Repeat search + + else + MyKey := False; + end; + + if Shift = [ssCtrl] then + if Key = 65 then // Ctrl+A Select all + begin + SetPos(0, 0); + FSelStart := FPos; + SetPos(LineLength(FText.Count - 1) + 1, FText.Count); + FSelEnd := FPos; + Repaint; + end + else + if Key = 70 then // Ctrl+F Search + begin + fqbSynMemoSearch := TfqbSynMemoSearch.Create(nil); + if fqbSynMemoSearch.ShowModal = mrOk then + Find(fqbSynMemoSearch.Edit1.Text); + LastSearch := fqbSynMemoSearch.Edit1.Text; + fqbSynMemoSearch.Free; + end + else + if Key = 89 then // Ctrl+Y Delete line + begin + if FText.Count > FPos.Y then + begin + FMoved := True; + AddUndo; + FText.Delete(FPos.Y - 1); + CorrectBookmark(FPos.Y, -1); + UpdateSyntax; + end + else + if FText.Count = FPos.Y then + begin + FMoved := True; + AddUndo; + FText[FPos.Y - 1] := ''; + FPos.X := 1; + SetPos(FPos.X, FPos.Y); + UpdateSyntax; + end + end + else + if Key in [48..57] then + GotoBookmark(Key-48); + + if Shift = [ssCtrl, ssShift] then + if Key in [48..57] then + if IsBookmark(FPos.Y - 1) < 0 then + AddBookmark(FPos.Y - 1, Key-48) + else + if IsBookmark(FPos.Y - 1) = (Key-48) then + DeleteBookmark(Key-48); + + + if Key in [vk_Left, vk_Right, vk_Up, vk_Down, vk_Home, vk_End, vk_Prior, vk_Next] then + begin + FMoved := True; + if ssShift in Shift then + AddSel else + ClearSel; + end + else if Key in [vk_Return, vk_Delete, vk_Back, vk_Insert, vk_Tab] then + FMoved := True; + + if MyKey then + Key := 0; +end; + +procedure TfqbSyntaxMemo.KeyPress(var Key: Char); +var + MyKey: Boolean; +begin + inherited; + + MyKey := True; + case Key of + #3: + CopyToClipboard; + + #9: + DoCtrlI; + + #21: + DoCtrlU; + + #22: + PasteFromClipboard; + + #24: + CutToClipboard; + + #26: + Undo; + + #32..#255: + begin + DoChar(Key); + FMoved := True; + end; + else + MyKey := False; + end; + + if MyKey then + Key := #0; +end; + +procedure TfqbSyntaxMemo.DoLeft; +begin + Dec(FPos.X); + if FPos.X < 1 then + FPos.X := 1; + SetPos(FPos.X, FPos.Y); +end; + +procedure TfqbSyntaxMemo.DoRight; +begin + Inc(FPos.X); + if FPos.X > FMaxLength then + FPos.X := FMaxLength; + SetPos(FPos.X, FPos.Y); +end; + +procedure TfqbSyntaxMemo.DoUp; +begin + Dec(FPos.Y); + if FPos.Y < 1 then + FPos.Y := 1; + SetPos(FPos.X, FPos.Y); +end; + +procedure TfqbSyntaxMemo.DoDown; +begin + Inc(FPos.Y); + if FPos.Y > FText.Count then + FPos.Y := FText.Count; + SetPos(FPos.X, FPos.Y); +end; + +procedure TfqbSyntaxMemo.DoHome(Ctrl: Boolean); +begin + if Ctrl then + SetPos(1, 1) else + SetPos(1, FPos.Y); +end; + +procedure TfqbSyntaxMemo.DoEnd(Ctrl: Boolean); +begin + if Ctrl then + SetPos(LineLength(FText.Count - 1) + 1, FText.Count) else + SetPos(LineLength(FPos.Y - 1) + 1, FPos.Y); +end; + +procedure TfqbSyntaxMemo.DoPgUp; +begin + if FOffset.Y > FWindowSize.Y then + begin + Dec(FOffset.Y, FWindowSize.Y - 1); + Dec(FPos.Y, FWindowSize.Y - 1); + end + else + begin + if FOffset.Y > 0 then + begin + Dec(FPos.Y, FOffset.Y); + FOffset.Y := 0; + end + else + FPos.Y := 1; + end; + SetPos(FPos.X, FPos.Y); + Repaint; +end; + +procedure TfqbSyntaxMemo.DoPgDn; +begin + if FOffset.Y + FWindowSize.Y < FText.Count then + begin + Inc(FOffset.Y, FWindowSize.Y - 1); + Inc(FPos.Y, FWindowSize.Y - 1); + end + else + begin + FOffset.Y := FText.Count; + FPos.Y := FText.Count; + end; + SetPos(FPos.X, FPos.Y); + Repaint; +end; + +procedure TfqbSyntaxMemo.DoReturn; +var + s: String; +begin + if FReadOnly then exit; + s := LineAt(FPos.Y - 1); + FText[FPos.Y - 1] := Copy(s, 1, FPos.X - 1); + FText.Insert(FPos.Y, Copy(s, FPos.X, FMaxLength)); + EnterIndent; +end; + +procedure TfqbSyntaxMemo.DoDel; +var + s: String; +begin + if FReadOnly then exit; + FMessage := ''; + if FSelStart.X <> 0 then + SelText := '' + else + begin + s := FText[FPos.Y - 1]; + AddUndo; + if FPos.X <= LineLength(FPos.Y - 1) then + begin + Delete(s, FPos.X, 1); + FText[FPos.Y - 1] := s; + end + else if FPos.Y < FText.Count then + begin + s := s + Pad(FPos.X - Length(s) - 1) + LineAt(FPos.Y); + FText[FPos.Y - 1] := s; + FText.Delete(FPos.Y); + CorrectBookmark(FSelStart.Y, -1); + end; + UpdateScrollBar; + UpdateSyntax; + DoChange; + end; +end; + +procedure TfqbSyntaxMemo.DoBackspace; +var + s: String; +begin + if FReadOnly then exit; + FMessage := ''; + if FSelStart.X <> 0 then + SelText := '' + else + begin + s := FText[FPos.Y - 1]; + if FPos.X > 1 then + begin + if (GetLineBegin(FPos.Y - 1) = FPos.X) or (Trim(s) = '') then + UnIndent + else + begin + AddUndo; + if Trim(s) <> '' then + begin + Delete(s, FPos.X - 1, 1); + FText[FPos.Y - 1] := s; + DoLeft; + end + else + DoHome(False); + UpdateSyntax; + DoChange; + end; + end + else if FPos.Y > 1 then + begin + AddUndo; + CorrectBookmark(FPos.Y, -1); + s := LineAt(FPos.Y - 2); + FText[FPos.Y - 2] := s + FText[FPos.Y - 1]; + FText.Delete(FPos.Y - 1); + SetPos(Length(s) + 1, FPos.Y - 1); + UpdateSyntax; + DoChange; + end; + end; +end; + +procedure TfqbSyntaxMemo.DoCtrlI; +begin + if FSelStart.X <> 0 then + ShiftSelected(True); +end; + +procedure TfqbSyntaxMemo.DoCtrlU; +begin + if FSelStart.X <> 0 then + ShiftSelected(False); +end; + +procedure TfqbSyntaxMemo.DoCtrlL; +var + i: Integer; + s: String; +begin + s := FText.Text; + i := Length(LineAt(FPos.Y - 1)); + if FPos.X > i then + FPos.X := i; + + i := GetPlainTextPos(FPos); + + Dec(i); + while (i > 0) and not (s[i] in WordChars) do + if s[i] = #13 then + break else + Dec(i); + while (i > 0) and (s[i] in WordChars) do + Dec(i); + Inc(i); + + FPos := GetPosPlainText(i); + SetPos(FPos.X, FPos.Y); +end; + +procedure TfqbSyntaxMemo.DoCtrlR; +var + i: Integer; + s: String; +begin + s := FText.Text; + i := Length(LineAt(FPos.Y - 1)); + if FPos.X > i then + begin + DoDown; + DoHome(False); + FPos.X := 0; + end; + + i := GetPlainTextPos(FPos); + + while (i < Length(s)) and (s[i] in WordChars) do + Inc(i); + while (i < Length(s)) and not (s[i] in WordChars) do + if s[i] = #13 then + break else + Inc(i); + + FPos := GetPosPlainText(i); + SetPos(FPos.X, FPos.Y); +end; + +procedure TfqbSyntaxMemo.DoChar(Ch: Char); +begin + SelText := Ch; +end; + +function TfqbSyntaxMemo.GetCharAttr(Pos: TPoint): TCharAttributes; + + function IsBlock: Boolean; + var + p1, p2, p3: Integer; + begin + Result := False; + if FSelStart.X = 0 then exit; + + p1 := FSelStart.X + FSelStart.Y * FMaxLength; + p2 := FSelEnd.X + FSelEnd.Y * FMaxLength; + if p1 > p2 then + begin + p3 := p1; + p1 := p2; + p2 := p3; + end; + p3 := Pos.X + Pos.Y * FMaxLength; + Result := (p3 >= p1) and (p3 < p2); + end; + + function CharAttr: TCharAttr; + var + s: String; + begin + if Pos.Y - 1 < FSynStrings.Count then + begin + s := FSynStrings[Pos.Y - 1]; + if Pos.X <= Length(s) then + Result := TCharAttr(Ord(s[Pos.X])) else + Result := caText; + end + else + Result := caText; + end; + +begin + Result := [CharAttr]; + if IsBlock then + Result := Result + [caBlock]; +end; + +procedure TfqbSyntaxMemo.Paint; +var + i, j, j1: Integer; + a, a1: TCharAttributes; + s: String; + + procedure SetAttr(a: TCharAttributes); + begin + with Canvas do + begin + Brush.Color := Color; + + if caText in a then + Font.Assign(FTextAttr); + + if caComment in a then + Font.Assign(FCommentAttr); + + if caKeyword in a then + Font.Assign(FKeywordAttr); + + if caString in a then + Font.Assign(FStringAttr); + + if caBlock in a then + begin + Brush.Color := FBlockColor; + Font.Color := FBlockFontColor; + end; + + Font.Charset := Self.Font.Charset; + end; + end; + + procedure MyTextOut(x, y: Integer; const s: String); + var + i: Integer; + begin + if FIsMonoType then + Canvas.TextOut(x, y, s) + else + with Canvas do + begin + FillRect(Rect(x, y, x + Length(s) * FCharWidth, y + FCharHeight)); + for i := 1 to Length(s) do + TextOut(x + (i - 1) * FCharWidth, y, s[i]); + MoveTo(x + Length(s) * FCharWidth, y); + end; + end; + +begin + with Canvas do + begin + Brush.Color := clBtnFace; + FillRect(Rect(0, 0, FGutterWidth - 2, Height - FFooterHeight)); + FillRect(Rect(0, Height - FFooterHeight, Width, Height)); + Pen.Color := clBtnHighlight; + MoveTo(FGutterWidth - 4, 0); + LineTo(FGutterWidth - 4, Height - FFooterHeight + 1); + if FFooterHeight > 0 then + LineTo(Width, Height - FFooterHeight + 1); + + if FUpdatingSyntax then Exit; + + for i := FOffset.Y to FOffset.Y + FWindowSize.Y - 1 do + begin + if i >= FText.Count then break; + + s := FText[i]; + PenPos := Point(FGutterWidth, (i - FOffset.Y) * FCharHeight); + j1 := FOffset.X + 1; + a := GetCharAttr(Point(j1, i + 1)); + a1 := a; + + for j := j1 to FOffset.X + FWindowSize.X do + begin + if j > Length(s) then break; + + a1 := GetCharAttr(Point(j, i + 1)); + if a1 <> a then + begin + SetAttr(a); + MyTextOut(PenPos.X, PenPos.Y, Copy(FText[i], j1, j - j1)); + a := a1; + j1 := j; + end; + end; + + SetAttr(a); + MyTextOut(PenPos.X, PenPos.Y, Copy(s, j1, FMaxLength)); + if caBlock in GetCharAttr(Point(1, i + 1)) then + MyTextOut(PenPos.X, PenPos.Y, Pad(FWindowSize.X - Length(s) - FOffset.X + 3)); + + BookmarkDraw(PenPos.Y, i); + ActiveLineDraw(PenPos.Y, i); + end; + + if FMessage <> '' then + begin + Font.Name := 'Tahoma'; + Font.Color := clWhite; + Font.Style := [fsBold]; + Font.Size := 8; + Brush.Color := clMaroon; + FillRect(Rect(0, Height - TextHeight('|') - 6, Width, Height)); + TextOut(6, Height - TextHeight('|') - 5, FMessage); + end + else + ShowPos; + end; +end; + +procedure TfqbSyntaxMemo.CreateSynArray; +var + i, n, Pos: Integer; + ch: Char; + FSyn: String; + + procedure SkipSpaces; + begin + while (Pos <= Length(FSyn)) and + ((FSyn[Pos] in [#1..#32]) or + not (FSyn[Pos] in ['_', 'A'..'Z', 'a'..'z', '''', '"', '/', '{', '(', '-'])) do + Inc(Pos); + end; + + function IsKeyWord(const s: String): Boolean; + begin + Result := False; + if FKeywords = '' then exit; + + if FKeywords[1] <> ',' then + FKeywords := ',' + FKeywords; + if FKeywords[Length(FKeywords)] <> ',' then + FKeywords := FKeywords + ','; + + Result := System.Pos(',' + AnsiLowerCase(s) + ',', FKeywords) <> 0; + end; + + function GetIdent: TCharAttr; + var + i: Integer; + cm1, cm2, cm3, cm4, st1: Char; + begin + i := Pos; + Result := caText; + + if FSyntaxType = stPascal then + begin + cm1 := '/'; + cm2 := '{'; + cm3 := '('; + cm4 := ')'; + st1 := ''''; + end + else if FSyntaxType = stCpp then + begin + cm1 := '/'; + cm2 := ' '; + cm3 := '/'; + cm4 := '/'; + st1 := '"'; + end + else if FSyntaxType = stSQL then + begin + cm1 := '-'; + cm2 := ' '; + cm3 := '/'; + cm4 := '/'; + st1 := '"'; + end + else + begin + cm1 := ' '; + cm2 := ' '; + cm3 := ' '; + cm4 := ' '; + st1 := ' '; + end; + + if FSyn[Pos] in ['_', 'A'..'Z', 'a'..'z'] then + begin + while FSyn[Pos] in ['_', 'A'..'Z', 'a'..'z', '0'..'9'] do + Inc(Pos); + if IsKeyWord(Copy(FSyn, i, Pos - i)) then + Result := caKeyword; + Dec(Pos); + end + else if (FSyn[Pos] = cm1) and (FSyn[Pos + 1] = cm1) then + begin + while (Pos <= Length(FSyn)) and not (FSyn[Pos] in [#10, #13]) do + Inc(Pos); + Result := caComment; + end + else if FSyn[Pos] = cm2 then + begin + while (Pos <= Length(FSyn)) and (FSyn[Pos] <> '}') do + Inc(Pos); + Result := caComment; + end + else if (FSyn[Pos] = cm3) and (FSyn[Pos + 1] = '*') then + begin + while (Pos < Length(FSyn)) and not ((FSyn[Pos] = '*') and (FSyn[Pos + 1] = cm4)) do + Inc(Pos); + Inc(Pos, 2); + Result := caComment; + end + else if FSyn[Pos] = st1 then + begin + Inc(Pos); + while (Pos < Length(FSyn)) and (FSyn[Pos] <> st1) and not (FSyn[Pos] in [#10, #13]) do + Inc(Pos); + Result := caString; + end; + Inc(Pos); + end; + +begin + FSyn := FText.Text + #0#0#0#0#0#0#0#0#0#0#0; + FAllowLinesChange := False; + Pos := 1; + + while Pos < Length(FSyn) do + begin + n := Pos; + SkipSpaces; + for i := n to Pos - 1 do + if FSyn[i] > #31 then + FSyn[i] := Chr(Ord(caText)); + + n := Pos; + ch := Chr(Ord(GetIdent)); + for i := n to Pos - 1 do + if FSyn[i] > #31 then + FSyn[i] := ch; + end; + + FUpdatingSyntax := True; + FSynStrings.Text := FSyn; + FSynStrings.Add(' '); + FUpdatingSyntax := False; +end; + +procedure TfqbSyntaxMemo.UpdateView; +begin + UpdateSyntax; + Invalidate; +end; + +procedure TfqbSyntaxMemo.CopyPopup(Sender: TObject); +begin + CopyToClipboard; +end; + +procedure TfqbSyntaxMemo.PastePopup(Sender: TObject); +begin + PasteFromClipboard; +end; + +procedure TfqbSyntaxMemo.CutPopup(Sender: TObject); +begin + CutToClipboard; +end; + +{$IFDEF Delphi4} +procedure TfqbSyntaxMemo.MouseWheelUp(Sender: TObject; + Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); +begin + FVScroll.Position := FVScroll.Position - FVScroll.SmallChange * KWheel; +end; + +procedure TfqbSyntaxMemo.MouseWheelDown(Sender: TObject; + Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); +begin + FVScroll.Position := FVScroll.Position + FVScroll.SmallChange * KWheel; +end; +{$ENDIF} + +procedure TfqbSyntaxMemo.SetShowGutter(Value: boolean); +begin + FShowGutter := Value; + if Value then + FGutterWidth := 20 + else + FGutterWidth := 0; + Repaint; +end; + +procedure TfqbSyntaxMemo.SetShowFooter(Value: boolean); +begin + FShowFooter := Value; + if Value then + FFooterHeight := 20 + else + FFooterHeight := 0; + Repaint; +end; + +function TfqbSyntaxMemo.FMemoFind(Text: String; var Position : TPoint): boolean; +var + i, j : integer; +begin + j := 0; + result := False; + if FText.Count > 1 then + begin + Text := UpperCase(Text); + for i := Position.Y to FText.Count - 1 do + begin + j := Pos( Text, UpperCase(FText[i])); + if j > 0 then + begin + Result := True; + break; + end + end; + Position.X := j; + Position.Y := i + 1; + end; +end; + +function TfqbSyntaxMemo.Find(Text: String): boolean; +var + Position: TPoint; +begin + Position := FPos; + if FMemoFind(Text, Position) then + begin + SetPos(Position.X, Position.Y); + result := true; + end + else + begin + ShowMessage('Text "'+Text+'" not found.'); + result := false; + end; +end; + +procedure TfqbSyntaxMemo.ActiveLineDraw(Y : integer; line : integer); +begin + if ShowGutter then + with Canvas do + if line = FActiveLine then + begin + Brush.Color := clRed; + Pen.Color := clBlack; + Ellipse(4, Y+4, 11, Y+11); + end; +end; + +procedure TfqbSyntaxMemo.BookmarkDraw(Y : integer; line : integer); +var + bm : integer; +begin + if ShowGutter then + with Canvas do + begin + bm := IsBookmark(Line); + if bm >= 0 then + begin + Brush.Color := clBlack; + FillRect(Rect(3, Y + 1, 13, Y + 12)); + Brush.Color := clGreen; + FillRect(Rect(2, Y + 2, 12, Y + 13)); + Font.Name := 'Tahoma'; + Font.Color := clWhite; + Font.Style := [fsBold]; + Font.Size := 7; + TextOut(4, Y + 2, IntToStr(bm)); + end + else + begin + Brush.Color := clBtnFace; + FillRect(Rect(2, Y + 2, 13, Y + 13)); + end; + end; +end; + +function TfqbSyntaxMemo.IsBookmark(Line : integer): integer; +var + Pos : integer; +begin + Result := -1; +{$IFDEF Delphi4} + for Pos := 0 to Length(Bookmarks) - 1 do +{$ELSE} + for Pos := 0 to 9 do +{$ENDIF} + if Bookmarks[Pos] = Line then + begin + Result := Pos; + break; + end; +end; + +procedure TfqbSyntaxMemo.AddBookmark(Line, Number : integer); +begin +{$IFDEF Delphi4} + if Number < Length(Bookmarks) then +{$ELSE} + if Number < 10 then +{$ENDIF} + begin + Bookmarks[Number] := Line; + Repaint; + end; +end; + +procedure TfqbSyntaxMemo.DeleteBookmark(Number : integer); +begin +{$IFDEF Delphi4} + if Number < Length(Bookmarks) then +{$ELSE} + if Number < 10 then +{$ENDIF} + begin + Bookmarks[Number] := -1; + Repaint; + end; +end; + +procedure TfqbSyntaxMemo.CorrectBookmark(Line : integer; delta : integer); +var + i : integer; +begin +{$IFDEF Delphi4} + for i := 0 to Length(Bookmarks) - 1 do +{$ELSE} + for i := 0 to 9 do +{$ENDIF} + if Bookmarks[i] >= Line then + Inc(Bookmarks[i], Delta); +end; + +procedure TfqbSyntaxMemo.GotoBookmark(Number : integer); +begin +{$IFDEF Delphi4} + if Number < Length(Bookmarks) then +{$ELSE} + if Number < 10 then +{$ENDIF} + if Bookmarks[Number] >= 0 then + SetPos(0, Bookmarks[Number] + 1); +end; + +procedure TfqbSyntaxMemo.DOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); +begin + Accept := Source is TTreeView; +end; + +procedure TfqbSyntaxMemo.DDrop(Sender, Source: TObject; X, Y: Integer); +begin + if Source is TTreeView then + begin + SetPos((X - FGutterWidth) div FCharWidth + 1 + FOffset.X, + Y div FCharHeight + 1 + FOffset.Y); + SetSelText(TTreeView(Source).Selected.Text); + end; +end; + +procedure TfqbSyntaxMemo.SetKeywordAttr(Value: TFont); +begin + FKeywordAttr.Assign(Value); + UpdateSyntax; +end; + +procedure TfqbSyntaxMemo.SetStringAttr(Value: TFont); +begin + FStringAttr.Assign(Value); + UpdateSyntax; +end; + +procedure TfqbSyntaxMemo.SetTextAttr(Value: TFont); +begin + FTextAttr.Assign(Value); + UpdateSyntax; +end; + +procedure TfqbSyntaxMemo.SetCommentAttr(Value: TFont); +begin + FCommentAttr.Assign(Value); + UpdateSyntax; +end; + +procedure TfqbSyntaxMemo.SetActiveLine(Line : Integer); +begin + FActiveLine := Line; + Repaint; +end; + +function TfqbSyntaxMemo.GetActiveLine: Integer; +begin + Result := FActiveLine; +end; + +// + +procedure TfqbSynMemoSearch.FormKeyPress(Sender: TObject; var Key: Char); +begin + if Key = #13 then + ModalResult := mrOk; +end; + +end. + diff --git a/official/4.2/LibD11/fqbUtils.pas b/official/4.2/LibD11/fqbUtils.pas new file mode 100644 index 0000000..c42a21d --- /dev/null +++ b/official/4.2/LibD11/fqbUtils.pas @@ -0,0 +1,334 @@ +{*******************************************} +{ } +{ FastQueryBuilder 1.03 } +{ } +{ Copyright (c) 2005 } +{ Fast Reports Inc. } +{ } +{*******************************************} + +{$I fqb.inc} + +unit fqbUtils; + +interface + +uses Windows, Messages, Classes, SysUtils, fqbZLib; + +function fqbStringCRC32(const Str: string): Cardinal; +function fqbGetUniqueFileName(const Prefix: String): string; +function fqbTrim(const Input: string; EArray: TSysCharSet):string; +function fqbParse(Char, S: string; Count: Integer; Last: Boolean = False): string; +function fqbBase64Decode(const S: String): String; +function fqbBase64Encode(const S: String): String; +function fqbCompress(const S: String): String; +function fqbDeCompress(const S: String): String; +procedure fqbDeflateStream(Source, Dest: TStream; Compression: TZCompressionLevel = zcDefault); +procedure fqbInflateStream(Source, Dest: TStream); + + +implementation + +const + Base64Charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + + CRCTable: array [0..255] of Cardinal = ( + 0000000000, 1996959894, 3993919788, 2567524794, + 0124634137, 1886057615, 3915621685, 2657392035, + 0249268274, 2044508324, 3772115230, 2547177864, + 0162941995, 2125561021, 3887607047, 2428444049, + 0498536548, 1789927666, 4089016648, 2227061214, + 0450548861, 1843258603, 4107580753, 2211677639, + 0325883990, 1684777152, 4251122042, 2321926636, + 0335633487, 1661365465, 4195302755, 2366115317, + 0997073096, 1281953886, 3579855332, 2724688242, + 1006888145, 1258607687, 3524101629, 2768942443, + 0901097722, 1119000684, 3686517206, 2898065728, + 0853044451, 1172266101, 3705015759, 2882616665, + 0651767980, 1373503546, 3369554304, 3218104598, + 0565507253, 1454621731, 3485111705, 3099436303, + 0671266974, 1594198024, 3322730930, 2970347812, + 0795835527, 1483230225, 3244367275, 3060149565, + 1994146192, 0031158534, 2563907772, 4023717930, + 1907459465, 0112637215, 2680153253, 3904427059, + 2013776290, 0251722036, 2517215374, 3775830040, + 2137656763, 0141376813, 2439277719, 3865271297, + 1802195444, 0476864866, 2238001368, 4066508878, + 1812370925, 0453092731, 2181625025, 4111451223, + 1706088902, 0314042704, 2344532202, 4240017532, + 1658658271, 0366619977, 2362670323, 4224994405, + 1303535960, 0984961486, 2747007092, 3569037538, + 1256170817, 1037604311, 2765210733, 3554079995, + 1131014506, 0879679996, 2909243462, 3663771856, + 1141124467, 0855842277, 2852801631, 3708648649, + 1342533948, 0654459306, 3188396048, 3373015174, + 1466479909, 0544179635, 3110523913, 3462522015, + 1591671054, 0702138776, 2966460450, 3352799412, + 1504918807, 0783551873, 3082640443, 3233442989, + 3988292384, 2596254646, 0062317068, 1957810842, + 3939845945, 2647816111, 0081470997, 1943803523, + 3814918930, 2489596804, 0225274430, 2053790376, + 3826175755, 2466906013, 0167816743, 2097651377, + 4027552580, 2265490386, 0503444072, 1762050814, + 4150417245, 2154129355, 0426522225, 1852507879, + 4275313526, 2312317920, 0282753626, 1742555852, + 4189708143, 2394877945, 0397917763, 1622183637, + 3604390888, 2714866558, 0953729732, 1340076626, + 3518719985, 2797360999, 1068828381, 1219638859, + 3624741850, 2936675148, 0906185462, 1090812512, + 3747672003, 2825379669, 0829329135, 1181335161, + 3412177804, 3160834842, 0628085408, 1382605366, + 3423369109, 3138078467, 0570562233, 1426400815, + 3317316542, 2998733608, 0733239954, 1555261956, + 3268935591, 3050360625, 0752459403, 1541320221, + 2607071920, 3965973030, 1969922972, 0040735498, + 2617837225, 3943577151, 1913087877, 0083908371, + 2512341634, 3803740692, 2075208622, 0213261112, + 2463272603, 3855990285, 2094854071, 0198958881, + 2262029012, 4057260610, 1759359992, 0534414190, + 2176718541, 4139329115, 1873836001, 0414664567, + 2282248934, 4279200368, 1711684554, 0285281116, + 2405801727, 4167216745, 1634467795, 0376229701, + 2685067896, 3608007406, 1308918612, 0956543938, + 2808555105, 3495958263, 1231636301, 1047427035, + 2932959818, 3654703836, 1088359270, 0936918000, + 2847714899, 3736837829, 1202900863, 0817233897, + 3183342108, 3401237130, 1404277552, 0615818150, + 3134207493, 3453421203, 1423857449, 0601450431, + 3009837614, 3294710456, 1567103746, 0711928724, + 3020668471, 3272380065, 1510334235, 0755167117); + + +function fqbStringCRC32(const Str: string): Cardinal; + var + i: Integer; + b: Byte; + c: Cardinal; +begin + c := $ffffffff; + for i := 1 to Length(Str) do + begin + b := Byte(Str[i]); + c := CrcTable[(c xor Cardinal(b)) and $ff] xor (c shr 8) + end; + Result := c xor $ffffffff +end; + +function fqbGetUniqueFileName(const Prefix: String): string; + var + TempPath: array[0..MAX_PATH] of Char; + FileName: String[255]; +begin + GetTempPath(SizeOf(TempPath) - 1, TempPath); + GetTempFileName(TempPath, PChar(Prefix), 0, @FileName[1]); + Result := StrPas(@FileName[1]) +end; + +function fqbTrim(const Input: string; EArray: TSysCharSet):string; + var + tmp: string; +begin + Result := ''; + tmp := Input; + while Length(tmp) <> 0 do + if tmp[1] in EArray then + Delete(tmp, 1, 1) + else + begin + Result := Result + tmp[1]; + Delete(tmp, 1, 1) + end; + repeat + if Pos(' ', Result) > 0 then + Delete(Result, Pos(' ', Result) + 1, 1) + until Pos(' ', Result) = 0; +end; + +function fqbParse(Char, S: string; Count: Integer; Last: Boolean = False): string; + var + i: Integer; + t: string; +begin + if S[Length(S)] <> Char then + S := S + Char; + for i := 1 to Count do + begin + if Last then + t := Copy(S, 0, Length(S) - 1) + else + t := Copy(S, 0, Pos(Char, S) - 1); + S := Copy(S, Pos(Char, S) + 1, Length(S)) + end; + Result := t +end; + + +function fqbBase64Decode(const S: String): String; + var + F, L, M, P: Integer; + B, OutPos: Byte; + OutB: Array[1..3] of Byte; + Lookup: Array[Char] of Byte; + R: PChar; +begin + L := Length(S); + P := 0; + while (L - P > 0) and (S[L - P] = '=') do Inc(P); + M := L - P; + if M <> 0 then + begin + SetLength(Result, (M * 3) div 4); + FillChar(Lookup, Sizeof(Lookup), #0); + for F := 0 to 63 do + Lookup[Base64Charset[F + 1]] := F; + R := Pointer(Result); + OutPos := 0; + for F := 1 to L - P do + begin + B := Lookup[S[F]]; + case OutPos of + 0 : OutB[1] := B shl 2; + 1 : begin + OutB[1] := OutB[1] or (B shr 4); + R^ := Char(OutB[1]); + Inc(R); + OutB[2] := (B shl 4) and $FF + end; + 2 : begin + OutB[2] := OutB[2] or (B shr 2); + R^ := Char(OutB[2]); + Inc(R); + OutB[3] := (B shl 6) and $FF + end; + 3 : begin + OutB[3] := OutB[3] or B; + R^ := Char(OutB[3]); + Inc(R) + end + end; + OutPos := (OutPos + 1) mod 4 + end; + if (OutPos > 0) and (P = 0) then + if OutB[OutPos] <> 0 then + Result := Result + Char(OutB[OutPos]) + end else + Result := '' +end; + +function fqbBase64Encode(const S: String): String; + var + R, C : Byte; + F, L, M, N, U : Integer; + P : PChar; +begin + L := Length(S); + if L > 0 then + begin + M := L mod 3; + N := (L div 3) * 4 + M; + if M > 0 then Inc(N); + U := N mod 4; + if U > 0 then + begin + U := 4 - U; + Inc(N, U) + end; + SetLength(Result, N); + P := Pointer(Result); + R := 0; + for F := 0 to L - 1 do + begin + C := Byte(S [F + 1]); + case F mod 3 of + 0 : begin + P^ := Base64Charset[C shr 2 + 1]; + Inc(P); + R := (C and 3) shl 4 + end; + 1 : begin + P^ := Base64Charset[C shr 4 + R + 1]; + Inc(P); + R := (C and $0F) shl 2 + end; + 2 : begin + P^ := Base64Charset[C shr 6 + R + 1]; + Inc(P); + P^ := Base64Charset[C and $3F + 1]; + Inc(P) + end + end + end; + if M > 0 then + begin + P^ := Base64Charset[R + 1]; + Inc(P) + end; + for F := 1 to U do + begin + P^ := '='; + Inc(P) + end; + end else + Result := '' +end; + +function fqbCompress(const S: String): String; + var + st, stres: TStringStream; +begin + st := TStringStream.Create(s); + stres := TStringStream.Create(''); + + fqbDeflateStream(st, stres, zcMax); + Result := fqbBase64Encode(stres.DataString); + + stres.Free; + st.Free +end; + +function fqbDeCompress(const S: String): String; + var + st, stres: TStringStream; +begin + + st := TStringStream.Create(fqbBase64Decode(s)); + stres := TStringStream.Create(''); + + fqbInflateStream(st, stres); + Result := stres.DataString; + + stres.Free; + st.Free +end; + +procedure fqbDeflateStream(Source, Dest: TStream; Compression: TZCompressionLevel = zcDefault); +var + Compressor: TZCompressionStream; +begin + Compressor := TZCompressionStream.Create(Dest, TZCompressionLevel(Compression)); + try + Compressor.CopyFrom(Source, 0) + finally + Compressor.Free + end +end; + +procedure fqbInflateStream(Source, Dest: TStream); +var + FTempStream: TMemoryStream; + UnknownPtr: Pointer; + NewSize: Integer; +begin + FTempStream := TMemoryStream.Create; + try + FTempStream.CopyFrom(Source, 0); + // uncompress data and save it to the Dest + ZDeCompress(FTempStream.Memory, FTempStream.Size, UnknownPtr, NewSize); + Dest.Write(UnknownPtr^, NewSize); + FreeMem(UnknownPtr, NewSize) + finally + FTempStream.Free + end +end; + +end. diff --git a/official/4.2/LibD11/fqbZLib.pas b/official/4.2/LibD11/fqbZLib.pas new file mode 100644 index 0000000..00d6d33 --- /dev/null +++ b/official/4.2/LibD11/fqbZLib.pas @@ -0,0 +1,616 @@ +{***************************************************************************** +* ZLibEx.pas (zlib 1.2.1) * +* * +* copyright (c) 2002-2003 Roberto Della Pasqua (www.dellapasqua.com) * +* copyright (c) 2000-2002 base2 technologies (www.base2ti.com) * +* copyright (c) 1997 Borland International (www.borland.com) * +* * +* revision history * +* 2003.12.18 updated with latest zlib 1.2.1 (see www.zlib.org) * +* obj's compiled with fastest speed optimizations (bcc 5.6.4) * +* (hint:see basm newsgroup about a Move RTL fast replacement) * +* Thanks to Cosmin Truta for the pascal zlib reference * +* * +* 2002.11.02 ZSendToBrowser: deflate algorithm for HTTP1.1 compression * +* 2002.10.24 ZFastCompressString and ZFastDecompressString:300% faster * +* 2002.10.15 recompiled zlib 1.1.4 c sources with speed optimizations * +* (and targeting 686+ cpu) and changes to accomodate Borland * +* standards (C++ v5.6 compiler) * +* 2002.10.15 optimized move mem for not aligned structures (strings,etc)* +* 2002.10.15 little changes to avoid system unique string calls * +* * +* 2002.03.15 updated to zlib version 1.1.4 * +* 2001.11.27 enhanced TZDecompressionStream.Read to adjust source * +* stream position upon end of compression data * +* fixed endless loop in TZDecompressionStream.Read when * +* destination count was greater than uncompressed data * +* 2001.10.26 renamed unit to integrate "nicely" with delphi 6 * +* 2000.11.24 added soFromEnd condition to TZDecompressionStream.Seek * +* added ZCompressStream and ZDecompressStream * +* 2000.06.13 optimized, fixed, rewrote, and enhanced the zlib.pas unit * +* included on the delphi cd (zlib version 1.1.3) * +* * +* acknowledgements * +* erik turner Z*Stream routines * +* david bennion finding the nastly little endless loop quirk with the * +* TZDecompressionStream.Read method * +* burak kalayci informing me about the zlib 1.1.4 update * +*****************************************************************************} + +unit fqbZLib; + +interface + +uses + Windows, + Sysutils, + Classes; + +const + ZLIB_VERSION = '1.2.1'; + +type + TZAlloc = function(opaque: Pointer; items, size: Integer): Pointer; + TZFree = procedure(opaque, block: Pointer); + TZCompressionLevel = (zcNone, zcFastest, zcDefault, zcMax); + + {** TZStreamRec ***********************************************************} + + TZStreamRec = packed record + next_in: PChar; // next input byte + avail_in: Longint; // number of bytes available at next_in + total_in: Longint; // total nb of input bytes read so far + next_out: PChar; // next output byte should be put here + avail_out: Longint; // remaining free space at next_out + total_out: Longint; // total nb of bytes output so far + msg: PChar; // last error message, NULL if no error + state: Pointer; // not visible by applications + zalloc: TZAlloc; // used to allocate the internal state + zfree: TZFree; // used to free the internal state + opaque: Pointer; // private data object passed to zalloc and zfree + data_type: Integer; // best guess about the data type: ascii or binary + adler: Longint; // adler32 value of the uncompressed data + reserved: Longint; // reserved for future use + end; + + {** TCustomZStream ********************************************************} + + TCustomZStream = class(TStream) + private + FStream: TStream; + FStreamPos: Integer; + FOnProgress: TNotifyEvent; + FZStream: TZStreamRec; + FBuffer: array[Word] of Char; + protected + constructor Create(stream: TStream); + procedure DoProgress; dynamic; + property OnProgress: TNotifyEvent read FOnProgress write FOnProgress; + end; + + {** TZCompressionStream ***************************************************} + + TZCompressionStream = class(TCustomZStream) + private + function GetCompressionRate: Single; + public + constructor Create(dest: TStream; compressionLevel: TZCompressionLevel = zcDefault); + destructor Destroy; override; + function Read(var buffer; count: Longint): Longint; override; + function Write(const buffer; count: Longint): Longint; override; + function Seek(offset: Longint; origin: Word): Longint; override; + property CompressionRate: Single read GetCompressionRate; + property OnProgress; + end; + + {** TZDecompressionStream *************************************************} + + TZDecompressionStream = class(TCustomZStream) + public + constructor Create(source: TStream); + destructor Destroy; override; + function Read(var buffer; count: Longint): Longint; override; + function Write(const buffer; count: Longint): Longint; override; + function Seek(offset: Longint; origin: Word): Longint; override; + property OnProgress; + end; + +{** zlib public routines ****************************************************} + +{***************************************************************************** +* ZCompress * +* * +* pre-conditions * +* inBuffer = pointer to uncompressed data * +* inSize = size of inBuffer (bytes) * +* outBuffer = pointer (unallocated) * +* level = compression level * +* * +* post-conditions * +* outBuffer = pointer to compressed data (allocated) * +* outSize = size of outBuffer (bytes) * +*****************************************************************************} + +procedure ZCompress(const inBuffer: Pointer; inSize: Integer; + out outBuffer: Pointer; out outSize: Integer; + level: TZCompressionLevel = zcDefault); + +{***************************************************************************** +* ZDecompress * +* * +* pre-conditions * +* inBuffer = pointer to compressed data * +* inSize = size of inBuffer (bytes) * +* outBuffer = pointer (unallocated) * +* outEstimate = estimated size of uncompressed data (bytes) * +* * +* post-conditions * +* outBuffer = pointer to decompressed data (allocated) * +* outSize = size of outBuffer (bytes) * +*****************************************************************************} + +procedure ZDecompress(const inBuffer: Pointer; inSize: Integer; + out outBuffer: Pointer; out outSize: Integer; outEstimate: Integer = 0); + +{** utility routines ********************************************************} + +function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; +function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt; +function compressBound(sourceLen: LongInt): LongInt; + +{****************************************************************************} + + +type + EZLibError = class(Exception); + EZCompressionError = class(EZLibError); + EZDecompressionError = class(EZLibError); + +implementation + +{** link zlib 1.2.1 **************************************************************} +{** bcc32 flags: -c -6 -O2 -Ve -X- -pr -a8 -b -d -k- -vi -tWM -r -RT- -DFASTEST **} + +{$L adler32.zobj} +{$L compress.zobj} +{$L crc32.zobj} +{$L deflate.zobj} +{$L infback.zobj} +{$L inffast.zobj} +{$L inflate.zobj} +{$L inftrees.zobj} +{$L trees.zobj} + +{***************************************************************************** +* note: do not reorder the above -- doing so will result in external * +* functions being undefined * +*****************************************************************************} + +const + {** flush constants *******************************************************} + + Z_NO_FLUSH = 0; + Z_FINISH = 4; + + {** return codes **********************************************************} + + Z_OK = 0; + Z_STREAM_END = 1; + Z_NEED_DICT = 2; + Z_ERRNO = (-1); + Z_STREAM_ERROR = (-2); + Z_DATA_ERROR = (-3); + Z_MEM_ERROR = (-4); + Z_BUF_ERROR = (-5); + Z_VERSION_ERROR = (-6); + + {** compression levels ****************************************************} + + Z_NO_COMPRESSION = 0; + Z_BEST_SPEED = 1; + Z_BEST_COMPRESSION = 9; + Z_DEFAULT_COMPRESSION = (-1); + + {** compression methods ***************************************************} + + Z_DEFLATED = 8; + + {** return code messages **************************************************} + + _z_errmsg: array[0..9] of PChar = ( + 'need dictionary', // Z_NEED_DICT (2) + 'stream end', // Z_STREAM_END (1) + '', // Z_OK (0) + 'file error', // Z_ERRNO (-1) + 'stream error', // Z_STREAM_ERROR (-2) + 'data error', // Z_DATA_ERROR (-3) + 'insufficient memory', // Z_MEM_ERROR (-4) + 'buffer error', // Z_BUF_ERROR (-5) + 'incompatible version', // Z_VERSION_ERROR (-6) + '' + ); + + ZLevels: array[TZCompressionLevel] of Shortint = ( + Z_NO_COMPRESSION, + Z_BEST_SPEED, + Z_DEFAULT_COMPRESSION, + Z_BEST_COMPRESSION + ); + + SZInvalid = 'Invalid ZStream operation!'; + +{** deflate routines ********************************************************} + +function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; + recsize: Integer): Integer; external; + +function deflate(var strm: TZStreamRec; flush: Integer): Integer; + external; + +function deflateEnd(var strm: TZStreamRec): Integer; external; + +{** inflate routines ********************************************************} + +function inflateInit_(var strm: TZStreamRec; version: PChar; + recsize: Integer): Integer; external; + +function inflate(var strm: TZStreamRec; flush: Integer): Integer; + external; + +function inflateEnd(var strm: TZStreamRec): Integer; external; + +function inflateReset(var strm: TZStreamRec): Integer; external; + +{** utility routines *******************************************************} + +function adler32; external; +function crc32; external; +function compressBound; external; + +{** zlib function implementations *******************************************} + +function zcalloc(opaque: Pointer; items, size: Integer): Pointer; +begin + GetMem(result, items * size); +end; + +procedure zcfree(opaque, block: Pointer); +begin + FreeMem(block); +end; + +{** c function implementations **********************************************} + +procedure _memset(p: Pointer; b: Byte; count: Integer); cdecl; +begin + FillChar(p^, count, b); +end; + +procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; +begin + Move(source^, dest^, count); +end; + +{** custom zlib routines ****************************************************} + +function DeflateInit(var stream: TZStreamRec; level: Integer): Integer; +begin + result := DeflateInit_(stream, level, ZLIB_VERSION, SizeOf(TZStreamRec)); +end; + +function InflateInit(var stream: TZStreamRec): Integer; +begin + result := InflateInit_(stream, ZLIB_VERSION, SizeOf(TZStreamRec)); +end; + +{****************************************************************************} + +function ZCompressCheck(code: Integer): Integer; +begin + result := code; + + if code < 0 then + begin + raise EZCompressionError.Create(_z_errmsg[2 - code]); + end; +end; + +function ZDecompressCheck(code: Integer): Integer; +begin + Result := code; + + if code < 0 then + begin + raise EZDecompressionError.Create(_z_errmsg[2 - code]); + end; +end; + +procedure ZCompress(const inBuffer: Pointer; inSize: Integer; + out outBuffer: Pointer; out outSize: Integer; + level: TZCompressionLevel); +const + delta = 256; +var + zstream: TZStreamRec; +begin + FillChar(zstream, SizeOf(TZStreamRec), 0); + + outSize := ((inSize + (inSize div 10) + 12) + 255) and not 255; + GetMem(outBuffer, outSize); + + try + zstream.next_in := inBuffer; + zstream.avail_in := inSize; + zstream.next_out := outBuffer; + zstream.avail_out := outSize; + + ZCompressCheck(DeflateInit(zstream, ZLevels[level])); + + try + while ZCompressCheck(deflate(zstream, Z_FINISH)) <> Z_STREAM_END do + begin + Inc(outSize, delta); + ReallocMem(outBuffer, outSize); + + zstream.next_out := PChar(Integer(outBuffer) + zstream.total_out); + zstream.avail_out := delta; + end; + finally + ZCompressCheck(deflateEnd(zstream)); + end; + + ReallocMem(outBuffer, zstream.total_out); + outSize := zstream.total_out; + except + FreeMem(outBuffer); + raise; + end; +end; + +procedure ZDecompress(const inBuffer: Pointer; inSize: Integer; + out outBuffer: Pointer; out outSize: Integer; outEstimate: Integer); +var + zstream: TZStreamRec; + delta: Integer; +begin + FillChar(zstream, SizeOf(TZStreamRec), 0); + + delta := (inSize + 255) and not 255; + + if outEstimate = 0 then outSize := delta + else outSize := outEstimate; + + GetMem(outBuffer, outSize); + + try + zstream.next_in := inBuffer; + zstream.avail_in := inSize; + zstream.next_out := outBuffer; + zstream.avail_out := outSize; + + ZDecompressCheck(InflateInit(zstream)); + + try + while ZDecompressCheck(inflate(zstream, Z_NO_FLUSH)) <> Z_STREAM_END do + begin + Inc(outSize, delta); + ReallocMem(outBuffer, outSize); + + zstream.next_out := PChar(Integer(outBuffer) + zstream.total_out); + zstream.avail_out := delta; + end; + finally + ZDecompressCheck(inflateEnd(zstream)); + end; + + ReallocMem(outBuffer, zstream.total_out); + outSize := zstream.total_out; + except + FreeMem(outBuffer); + raise; + end; +end; + +{** TCustomZStream **********************************************************} + +constructor TCustomZStream.Create(stream: TStream); +begin + inherited Create; + FStream := stream; + FStreamPos := stream.Position; +end; + +procedure TCustomZStream.DoProgress; +begin + if Assigned(FOnProgress) then FOnProgress(Self); +end; + +{** TZCompressionStream *****************************************************} + +constructor TZCompressionStream.Create(dest: TStream; + compressionLevel: TZCompressionLevel); +begin + inherited Create(dest); + + FZStream.next_out := FBuffer; + FZStream.avail_out := SizeOf(FBuffer); + + ZCompressCheck(DeflateInit(FZStream, ZLevels[compressionLevel])); +end; + +destructor TZCompressionStream.Destroy; +begin + FZStream.next_in := nil; + FZStream.avail_in := 0; + + try + if FStream.Position <> FStreamPos then FStream.Position := FStreamPos; + + while ZCompressCheck(deflate(FZStream, Z_FINISH)) <> Z_STREAM_END do + begin + FStream.WriteBuffer(FBuffer, SizeOf(FBuffer) - FZStream.avail_out); + + FZStream.next_out := FBuffer; + FZStream.avail_out := SizeOf(FBuffer); + end; + + if FZStream.avail_out < SizeOf(FBuffer) then + begin + FStream.WriteBuffer(FBuffer, SizeOf(FBuffer) - FZStream.avail_out); + end; + finally + deflateEnd(FZStream); + end; + + inherited Destroy; +end; + +function TZCompressionStream.Read(var buffer; count: Longint): Longint; +begin + raise EZCompressionError.Create(SZInvalid); +end; + +function TZCompressionStream.Write(const buffer; count: Longint): Longint; +begin + FZStream.next_in := @buffer; + FZStream.avail_in := count; + + if FStream.Position <> FStreamPos then FStream.Position := FStreamPos; + + while FZStream.avail_in > 0 do + begin + ZCompressCheck(deflate(FZStream, Z_NO_FLUSH)); + + if FZStream.avail_out = 0 then + begin + FStream.WriteBuffer(FBuffer, SizeOf(FBuffer)); + + FZStream.next_out := FBuffer; + FZStream.avail_out := SizeOf(FBuffer); + + FStreamPos := FStream.Position; + + DoProgress; + end; + end; + + result := Count; +end; + +function TZCompressionStream.Seek(offset: Longint; origin: Word): Longint; +begin + if (offset = 0) and (origin = soFromCurrent) then + begin + result := FZStream.total_in; + end + else raise EZCompressionError.Create(SZInvalid); +end; + +function TZCompressionStream.GetCompressionRate: Single; +begin + if FZStream.total_in = 0 then result := 0 + else result := (1.0 - (FZStream.total_out / FZStream.total_in)) * 100.0; +end; + +{** TZDecompressionStream ***************************************************} + +constructor TZDecompressionStream.Create(source: TStream); +begin + inherited Create(source); + FZStream.next_in := FBuffer; + FZStream.avail_in := 0; + ZDecompressCheck(InflateInit(FZStream)); +end; + +destructor TZDecompressionStream.Destroy; +begin + inflateEnd(FZStream); + inherited Destroy; +end; + +function TZDecompressionStream.Read(var buffer; count: Longint): Longint; +var + zresult: Integer; +begin + FZStream.next_out := @buffer; + FZStream.avail_out := count; + + if FStream.Position <> FStreamPos then FStream.Position := FStreamPos; + + zresult := Z_OK; + + while (FZStream.avail_out > 0) and (zresult <> Z_STREAM_END) do + begin + if FZStream.avail_in = 0 then + begin + FZStream.avail_in := FStream.Read(FBuffer, SizeOf(FBuffer)); + + if FZStream.avail_in = 0 then + begin + result := count - FZStream.avail_out; + + Exit; + end; + + FZStream.next_in := FBuffer; + FStreamPos := FStream.Position; + + DoProgress; + end; + + zresult := ZDecompressCheck(inflate(FZStream, Z_NO_FLUSH)); + end; + + if (zresult = Z_STREAM_END) and (FZStream.avail_in > 0) then + begin + FStream.Position := FStream.Position - FZStream.avail_in; + FStreamPos := FStream.Position; + + FZStream.avail_in := 0; + end; + + result := count - FZStream.avail_out; +end; + +function TZDecompressionStream.Write(const Buffer; Count: Longint): Longint; +begin + raise EZDecompressionError.Create(SZInvalid); +end; + +function TZDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; +var + buf: array[0..8191] of Char; + i: Integer; +begin + if (offset = 0) and (origin = soFromBeginning) then + begin + ZDecompressCheck(inflateReset(FZStream)); + + FZStream.next_in := FBuffer; + FZStream.avail_in := 0; + + FStream.Position := 0; + FStreamPos := 0; + end + else if ((offset >= 0) and (origin = soFromCurrent)) or + (((offset - FZStream.total_out) > 0) and (origin = soFromBeginning)) then + begin + if origin = soFromBeginning then Dec(offset, FZStream.total_out); + + if offset > 0 then + begin + for i := 1 to offset div SizeOf(buf) do ReadBuffer(buf, SizeOf(buf)); + ReadBuffer(buf, offset mod SizeOf(buf)); + end; + end + else if (offset = 0) and (origin = soFromEnd) then + begin + while Read(buf, SizeOf(buf)) > 0 do ; + end + else raise EZDecompressionError.Create(SZInvalid); + + result := FZStream.total_out; +end; + +end. + diff --git a/official/4.2/LibD11/fqbrcDesign.pas b/official/4.2/LibD11/fqbrcDesign.pas new file mode 100644 index 0000000..18b0839 --- /dev/null +++ b/official/4.2/LibD11/fqbrcDesign.pas @@ -0,0 +1,48 @@ +{******************************************} +{ } +{ FastQueryBuilder } +{ Language resource file } +{ } +{ Copyright (c) 1998-2005 } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit fqbrcDesign; + +interface + +implementation + +uses fqbRes; + +const resStr = +'1=Ok' + #13#10 + +'2=Cancel' + #13#10 + +'1803=Clear' + #13#10 + +'1804=Save to file' + #13#10 + +'1805=Load from file' + #13#10 + +'1806=Model' + #13#10 + +'1807=SQL' + #13#10 + +'1808=Result' + #13#10 + +'-------TfqbGrid-------' + #13#10 + +'1820=Collumn' + #13#10 + +'1821=Visible' + #13#10 + +'1822=Where' + #13#10 + +'1823=Sort' + #13#10 + +'1824=Function' + #13#10 + +'1825=Group' + #13#10 + +'1826=Move up' + #13#10 + +'1827=Move down' + #13#10 + +'1828=Visible' + #13#10 + +'1829=Not Visible' + #13#10 + +'1830=No' + #13#10 + +'1831=Ascending' + #13#10 + +'1832=Descending' + #13#10 + +'1833=Grouping' + #13#10 + +''; + +initialization + fqbResources.AddStrings(resStr); + +end. diff --git a/official/4.2/LibD11/frx.inc b/official/4.2/LibD11/frx.inc new file mode 100644 index 0000000..e9e6819 --- /dev/null +++ b/official/4.2/LibD11/frx.inc @@ -0,0 +1,201 @@ +{$DEFINE QBUILDER} +{******************************************} +{ } +{ FastReport v4.0 } +{ Include file } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + + +{$B-} {- Complete Boolean Evaluation } +{$R-} {- Range-Checking } +{$T-} {- Typed @ operator } +{$P+} {- Open string params } +{$H+} {- Use long strings by default } + +{$IFNDEF FPC} + {$V-} {- Var-String Checking } + {$X+} {- Extended syntax } + {$J+} {- Writeable structured consts } +{$ENDIF} + +{$IFDEF VER120} // Delphi 4.0 + {$DEFINE Delphi4} +{$ENDIF} + +{$IFDEF VER130} // Delphi 5.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} +{$ENDIF} + +{$IFDEF VER140} // Delphi 6.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$WARN SYMBOL_PLATFORM OFF} + {$WARN UNIT_PLATFORM OFF} +{$ENDIF} + +{$IFDEF VER150} // Delphi 7.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN SYMBOL_PLATFORM OFF} + {$WARN UNIT_PLATFORM OFF} +{$ENDIF} + +{$IFDEF VER170} // Delphi 9.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN SYMBOL_PLATFORM OFF} + {$WARN UNIT_PLATFORM OFF} + {$WARN SYMBOL_DEPRECATED OFF} + {$WARN UNIT_DEPRECATED OFF} +{$ENDIF} + +{$IFDEF VER180} // Delphi 10.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$DEFINE Delphi10} + {$DEFINE RICHBCB} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN SYMBOL_PLATFORM OFF} + {$WARN UNIT_PLATFORM OFF} + {$WARN SYMBOL_DEPRECATED OFF} + {$WARN UNIT_DEPRECATED OFF} +{$ENDIF} + +{$IFDEF VER185} // Delphi 11.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$DEFINE Delphi10} + {$DEFINE Delphi11} + {$DEFINE RICHBCB} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN SYMBOL_PLATFORM OFF} + {$WARN UNIT_PLATFORM OFF} + {$WARN SYMBOL_DEPRECATED OFF} + {$WARN UNIT_DEPRECATED OFF} +{$ENDIF} + +{$IFDEF VER190} // Delphi 11.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$DEFINE Delphi10} + {$DEFINE Delphi11} + {$DEFINE RICHBCB} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN SYMBOL_PLATFORM OFF} + {$WARN UNIT_PLATFORM OFF} + {$WARN SYMBOL_DEPRECATED OFF} + {$WARN UNIT_DEPRECATED OFF} +{$ENDIF} + +{$IFDEF VER125} // Borland C++ Builder 4.0 + {$DEFINE Delphi4} + {$ObjExportAll On} + {$DEFINE BCB} + {$DEFINE RICHBCB} +{$ENDIF} + +{$IFDEF VER130} // Borland C++ Builder 5.0 + {$IFDEF BCB} + {$ObjExportAll On} + {$DEFINE RICHBCB} + {$ENDIF} +{$ENDIF} + +{$IFDEF VER140} // Borland C++ Builder 6.0 + {$IFDEF BCB} + {$ObjExportAll On} + {$DEFINE RICHBCB} + {$ENDIF} +{$ENDIF} + +{$IFDEF FPC} // Free pascal compiler + {$MODE DELPHI} + + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} +{$ENDIF} + +// Uncomment the following line if you don't want to include component editors +// into your exe (in case if you don't use designer) +//{$DEFINE NO_EDITORS} + +//-------------------------Additional components---------------------------- + +//------------------- JPEG images ----------------------------------- +// JPEG images. Adds approximately 100Kb to your EXE. +// If you want to show jpeg images in "Picture" object, uncomment +// the following line: +{$DEFINE JPEG} + +//------------------- PNG images ----------------------------------- +// PNG images. If you want to show png images in "Picture" object, uncomment +// the following line: +//{$DEFINE PNG} + +//------------------- "Open Picture" dialog ------------------------- +// Adds approximately 60Kb to your EXE. +// If you want to use standard "Open picture" dialog in picture editor, +// uncomment the following line: +//{$DEFINE OPENPICTUREDLG} + +//------------------- Visual Query builder -------------------------- +// To use visual query builder, you should install FastQBuilder component. +// It is included in FR3 Pro and FR3 EE by default. +//{$DEFINE QBUILDER} + +//------------------- TTabSet control ------------------------------- +// In Delphi2005 and BDS2006 you can use TTabSet control instead of TTabControl +// to make a report designer more soft-looked. +{$DEFINE UseTabset} + + +{$IFDEF FR_COM} + {$IFDEF FR_LITE} + {$DEFINE FR_VER_BASIC} + {$ENDIF} +{$ENDIF} + +{$IFNDEF Delphi9} + {$UNDEF UseTabset} +{$ENDIF} + +{$IFDEF Delphi4} + {$IFDEF FR_VER_BASIC} + {$DEFINE NO_CRITICAL_SECTION} + {$ENDIF} +{$ENDIF} + diff --git a/official/4.2/LibD11/frx10.bdsproj b/official/4.2/LibD11/frx10.bdsproj new file mode 100644 index 0000000..578d955 --- /dev/null +++ b/official/4.2/LibD11/frx10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frx10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frx10.dpk b/official/4.2/LibD11/frx10.dpk new file mode 100644 index 0000000..05b964b --- /dev/null +++ b/official/4.2/LibD11/frx10.dpk @@ -0,0 +1,146 @@ +// Package file for Delphi 2006 + +package frx10; + +{$I frx.inc} +//{$I frxReg.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF JPEG} + VCLJPG, +{$ENDIF} +{$IFDEF QBUILDER} + fqb100, +{$ENDIF} + fs10; + +contains + { core files } + frxAggregate in 'frxAggregate.pas', + frxChm in 'frxChm.pas', + frxClass in 'frxClass.pas', + frxClassRTTI in 'frxClassRTTI.pas', + frxCtrls in 'frxCtrls.pas', + frxDialogForm in 'frxDialogForm.pas', + frxDMPClass in 'frxDMPClass.pas', + frxDMPExport in 'frxDMPExport.pas', + frxDock in 'frxDock.pas', + frxEngine in 'frxEngine.pas', + frxGraphicUtils in 'frxGraphicUtils.pas', + frxPassw in 'frxPassw.pas', + frxPictureCache in 'frxPictureCache.pas', + frxPreview in 'frxPreview.pas', + frxPreviewPages in 'frxPreviewPages.pas', + frxPreviewPageSettings in 'frxPreviewPageSettings.pas', + frxPrintDialog in 'frxPrintDialog.pas', + frxPrinter in 'frxPrinter.pas', + frxProgress in 'frxProgress.pas', + frxrcClass in 'frxrcClass.pas', + frxRes in 'frxRes.pas', + frxSearchDialog in 'frxSearchDialog.pas', + frxUnicodeUtils in 'frxUnicodeUtils.pas', + frxUtils in 'frxUtils.pas', + frxVariables in 'frxVariables.pas', + frxXML in 'frxXML.pas', + frxXMLSerializer in 'frxXMLSerializer.pas', + + { designer } + frxAbout in 'frxAbout.pas', + frxCodeUtils in 'frxCodeUtils.pas', + frxConnEditor in 'frxConnEditor.pas', + frxCustomEditors in 'frxCustomEditors.pas', + frxDataTree in 'frxDataTree.pas', + frxDesgn in 'frxDesgn.pas', + frxDesgnCtrls in 'frxDesgnCtrls.pas', + frxDesgnEditors in 'frxDesgnEditors.pas', + frxDesgnWorkspace in 'frxDesgnWorkspace.pas', + frxDesgnWorkspace1 in 'frxDesgnWorkspace1.pas', + frxDsgnIntf in 'frxDsgnIntf.pas', + frxEditAliases in 'frxEditAliases.pas', + frxEditDataBand in 'frxEditDataBand.pas', + frxEditExpr in 'frxEditExpr.pas', + frxEditFormat in 'frxEditFormat.pas', + frxEditFrame in 'frxEditFrame.pas', + frxEditGroup in 'frxEditGroup.pas', + frxEditHighlight in 'frxEditHighlight.pas', + frxEditMemo in 'frxEditMemo.pas', + frxEditOptions in 'frxEditOptions.pas', + frxEditPage in 'frxEditPage.pas', + frxEditPicture in 'frxEditPicture.pas', + frxEditReport in 'frxEditReport.pas', + frxEditReportData in 'frxEditReportData.pas', + frxEditStrings in 'frxEditStrings.pas', + frxEditStyle in 'frxEditStyle.pas', + frxEditSysMemo in 'frxEditSysMemo.pas', + frxEditTabOrder in 'frxEditTabOrder.pas', + frxEditVar in 'frxEditVar.pas', + frxEvaluateForm in 'frxEvaluateForm.pas', + frxInheritError in 'frxInheritError.pas', + frxInsp in 'frxInsp.pas', + frxNewItem in 'frxNewItem.pas', + frxPopupForm in 'frxPopupForm.pas', + frxrcDesgn in 'frxrcDesgn.pas', + frxrcInsp in 'frxrcInsp.pas', + frxReportTree in 'frxReportTree.pas', + frxStdWizard in 'frxStdWizard.pas', + frxSynMemo in 'frxSynMemo.pas', + frxUnicodeCtrls in 'frxUnicodeCtrls.pas', + frxWatchForm in 'frxWatchForm.pas', + + { add-in objects } + frxBarcod in 'frxBarcod.pas', + frxBarcode in 'frxBarcode.pas', + frxBarcodeEditor in 'frxBarcodeEditor.pas', + frxBarcodeRTTI in 'frxBarcodeRTTI.pas', + frxChBox in 'frxChBox.pas', + frxChBoxRTTI in 'frxChBoxRTTI.pas', + frxCross in 'frxCross.pas', + frxCrossEditor in 'frxCrossEditor.pas', + frxCrossRTTI in 'frxCrossRTTI.pas', +{$IFNDEF FR_VER_BASIC} + frxDCtrl in 'frxDCtrl.pas', + frxDCtrlRTTI in 'frxDCtrlRTTI.pas', +{$ENDIF} + frxGradient in 'frxGradient.pas', + frxGradientRTTI in 'frxGradientRTTI.pas', + frxOLE in 'frxOLE.pas', + frxOLEEditor in 'frxOLEEditor.pas', + frxOLERTTI in 'frxOLERTTI.pas', + frxRich in 'frxRich.pas', + frxRichEdit in 'frxRichEdit.pas', + frxRichEditor in 'frxRichEditor.pas', + frxRichRTTI in 'frxRichRTTI.pas', + + frxGZip in 'frxGZip.pas', + frxZLib in 'frxZLib.pas', + frxCrypt in 'frxCrypt.pas', + rc_AlgRef in 'rc_AlgRef.pas', + rc_ApiRef in 'rc_ApiRef.pas', + rc_Crypt in 'rc_Crypt.pas'; + +end. diff --git a/official/4.2/LibD11/frx11.bdsproj b/official/4.2/LibD11/frx11.bdsproj new file mode 100644 index 0000000..0c421fc --- /dev/null +++ b/official/4.2/LibD11/frx11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frx11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frx11.dpk b/official/4.2/LibD11/frx11.dpk new file mode 100644 index 0000000..5db9dbd --- /dev/null +++ b/official/4.2/LibD11/frx11.dpk @@ -0,0 +1,146 @@ +// Package file for Delphi 2007 + +package frx11; + +{$I frx.inc} +//{$I frxReg.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF JPEG} + VCLJPG, +{$ENDIF} +{$IFDEF QBUILDER} + fqb110, +{$ENDIF} + fs11; + +contains + { core files } + frxAggregate in 'frxAggregate.pas', + frxChm in 'frxChm.pas', + frxClass in 'frxClass.pas', + frxClassRTTI in 'frxClassRTTI.pas', + frxCtrls in 'frxCtrls.pas', + frxDialogForm in 'frxDialogForm.pas', + frxDMPClass in 'frxDMPClass.pas', + frxDMPExport in 'frxDMPExport.pas', + frxDock in 'frxDock.pas', + frxEngine in 'frxEngine.pas', + frxGraphicUtils in 'frxGraphicUtils.pas', + frxPassw in 'frxPassw.pas', + frxPictureCache in 'frxPictureCache.pas', + frxPreview in 'frxPreview.pas', + frxPreviewPages in 'frxPreviewPages.pas', + frxPreviewPageSettings in 'frxPreviewPageSettings.pas', + frxPrintDialog in 'frxPrintDialog.pas', + frxPrinter in 'frxPrinter.pas', + frxProgress in 'frxProgress.pas', + frxrcClass in 'frxrcClass.pas', + frxRes in 'frxRes.pas', + frxSearchDialog in 'frxSearchDialog.pas', + frxUnicodeUtils in 'frxUnicodeUtils.pas', + frxUtils in 'frxUtils.pas', + frxVariables in 'frxVariables.pas', + frxXML in 'frxXML.pas', + frxXMLSerializer in 'frxXMLSerializer.pas', + + { designer } + frxAbout in 'frxAbout.pas', + frxCodeUtils in 'frxCodeUtils.pas', + frxConnEditor in 'frxConnEditor.pas', + frxCustomEditors in 'frxCustomEditors.pas', + frxDataTree in 'frxDataTree.pas', + frxDesgn in 'frxDesgn.pas', + frxDesgnCtrls in 'frxDesgnCtrls.pas', + frxDesgnEditors in 'frxDesgnEditors.pas', + frxDesgnWorkspace in 'frxDesgnWorkspace.pas', + frxDesgnWorkspace1 in 'frxDesgnWorkspace1.pas', + frxDsgnIntf in 'frxDsgnIntf.pas', + frxEditAliases in 'frxEditAliases.pas', + frxEditDataBand in 'frxEditDataBand.pas', + frxEditExpr in 'frxEditExpr.pas', + frxEditFormat in 'frxEditFormat.pas', + frxEditFrame in 'frxEditFrame.pas', + frxEditGroup in 'frxEditGroup.pas', + frxEditHighlight in 'frxEditHighlight.pas', + frxEditMemo in 'frxEditMemo.pas', + frxEditOptions in 'frxEditOptions.pas', + frxEditPage in 'frxEditPage.pas', + frxEditPicture in 'frxEditPicture.pas', + frxEditReport in 'frxEditReport.pas', + frxEditReportData in 'frxEditReportData.pas', + frxEditStrings in 'frxEditStrings.pas', + frxEditStyle in 'frxEditStyle.pas', + frxEditSysMemo in 'frxEditSysMemo.pas', + frxEditTabOrder in 'frxEditTabOrder.pas', + frxEditVar in 'frxEditVar.pas', + frxEvaluateForm in 'frxEvaluateForm.pas', + frxInheritError in 'frxInheritError.pas', + frxInsp in 'frxInsp.pas', + frxNewItem in 'frxNewItem.pas', + frxPopupForm in 'frxPopupForm.pas', + frxrcDesgn in 'frxrcDesgn.pas', + frxrcInsp in 'frxrcInsp.pas', + frxReportTree in 'frxReportTree.pas', + frxStdWizard in 'frxStdWizard.pas', + frxSynMemo in 'frxSynMemo.pas', + frxUnicodeCtrls in 'frxUnicodeCtrls.pas', + frxWatchForm in 'frxWatchForm.pas', + + { add-in objects } + frxBarcod in 'frxBarcod.pas', + frxBarcode in 'frxBarcode.pas', + frxBarcodeEditor in 'frxBarcodeEditor.pas', + frxBarcodeRTTI in 'frxBarcodeRTTI.pas', + frxChBox in 'frxChBox.pas', + frxChBoxRTTI in 'frxChBoxRTTI.pas', + frxCross in 'frxCross.pas', + frxCrossEditor in 'frxCrossEditor.pas', + frxCrossRTTI in 'frxCrossRTTI.pas', +{$IFNDEF FR_VER_BASIC} + frxDCtrl in 'frxDCtrl.pas', + frxDCtrlRTTI in 'frxDCtrlRTTI.pas', +{$ENDIF} + frxGradient in 'frxGradient.pas', + frxGradientRTTI in 'frxGradientRTTI.pas', + frxOLE in 'frxOLE.pas', + frxOLEEditor in 'frxOLEEditor.pas', + frxOLERTTI in 'frxOLERTTI.pas', + frxRich in 'frxRich.pas', + frxRichEdit in 'frxRichEdit.pas', + frxRichEditor in 'frxRichEditor.pas', + frxRichRTTI in 'frxRichRTTI.pas', + + frxGZip in 'frxGZip.pas', + frxZLib in 'frxZLib.pas', + frxCrypt in 'frxCrypt.pas', + rc_AlgRef in 'rc_AlgRef.pas', + rc_ApiRef in 'rc_ApiRef.pas', + rc_Crypt in 'rc_Crypt.pas'; + +end. diff --git a/official/4.2/LibD11/frx2xto30.pas b/official/4.2/LibD11/frx2xto30.pas new file mode 100644 index 0000000..57bb08f --- /dev/null +++ b/official/4.2/LibD11/frx2xto30.pas @@ -0,0 +1,2771 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ FR2.x importer } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frx2xto30; + +interface + +{$I frx.inc} + +implementation + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ComCtrls, Printers, TypInfo, Jpeg, DB, + frxClass, frxVariables, frxPrinter, frxDCtrl, frxBarcode, frxBarcod, + TeeProcs, TeEngine, Chart, Series, frxChart, frxChBox, frxOLE, frxRich, + frxCross, frxDBSet, frxUnicodeUtils, frxUtils, fs_ipascal, + frxCustomDB, frxBDEComponents, frxADOComponents, frxIBXComponents +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxFR2EventsNew = class(TObject) + private + FReport: TfrxReport; + procedure DoGetValue(const Expr: String; var Value: Variant); + procedure DoPrepareScript(Sender: TObject); + function GetScriptValue(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant; + function DoLoad(Sender: TfrxReport; Stream: TStream): Boolean; + function DoGetScriptValue(var Params: Variant): Variant; + end; + + TfrPageType = (ptReport, ptDialog); + TfrBandType = (btReportTitle, btReportSummary, + btPageHeader, btPageFooter, + btMasterHeader, btMasterData, btMasterFooter, + btDetailHeader, btDetailData, btDetailFooter, + btSubDetailHeader, btSubDetailData, btSubDetailFooter, + btOverlay, btColumnHeader, btColumnFooter, + btGroupHeader, btGroupFooter, + btCrossHeader, btCrossData, btCrossFooter, + btChild, btNone); + + TfrxFixupItem = class(TObject) + public + Obj: TPersistent; + PropInfo: PPropInfo; + Value: String; + end; + + TfrHighlightAttr = packed record + FontStyle: Word; + FontColor, FillColor: TColor; + end; + + TfrBarCodeRec = packed record + cCheckSum : Boolean; + cShowText : Boolean; + cCadr : Boolean; + cBarType : TfrxBarcodeType; + cModul : Integer; + cRatio : Double; + cAngle : Double; + end; + + TChartOptions = packed record + ChartType: Byte; + Dim3D, IsSingle, ShowLegend, ShowAxis, ShowMarks, Colored: Boolean; + MarksStyle: Byte; + Top10Num: Integer; + Reserved: array[0..35] of Byte; + end; + + TfrRoundRect = packed record + SdColor: TColor; // Color of Shadow + wShadow: Integer; // Width of shadow + Cadre : Boolean; // Frame On/Off - not used /TZ/ + sCurve : Boolean; // RoundRect On/Off + wCurve : Integer; // Curve size + end; + + THackControl = class(TControl) + end; + + TSeriesClass = class of TChartSeries; + +const + gtMemo = 0; + gtPicture = 1; + gtBand = 2; + gtSubReport = 3; + gtLine = 4; + gtCross = 5; + gtAddIn = 10; + + frftNone = 0; + frftRight = 1; + frftBottom = 2; + frftLeft = 4; + frftTop = 8; + + frtaLeft = 0; + frtaRight = 1; + frtaCenter = 2; + frtaVertical = 4; + frtaMiddle = 8; + frtaDown = 16; + + flStretched = 1; + flWordWrap = 2; + flWordBreak = 4; + flAutoSize = 8; + flTextOnly = $10; + flSuppressRepeated = $20; + flHideZeros = $40; + flUnderlines = $80; + flRTLReading = $100; + flBandNewPageAfter = 2; + flBandPrintifSubsetEmpty = 4; + flBandBreaked = 8; + flBandOnFirstPage = $10; + flBandOnLastPage = $20; + flBandRepeatHeader = $40; + flBandPrintChildIfInvisible = $80; + flPictCenter = 2; + flPictRatio = 4; + flWantHook = $8000; + flDontUndo = $4000; + flOnePerPage = $2000; + + pkNone = 0; + pkBitmap = 1; + pkMetafile = 2; + pkIcon = 3; + pkJPEG = 4; + +var + frVersion: Byte; + Report: TfrxReport; + Stream: TStream; + Page: TfrxPage; + Fixups: TList; + offsx, offsy: Integer; + frxFR2EventsNew: TfrxFR2EventsNew; + +const + frSpecCount = 9; + frSpecFuncs: array[0..frSpecCount - 1] of String = + ('PAGE#', '', 'DATE', 'TIME', 'LINE#', 'LINETHROUGH#', 'COLUMN#', + 'CURRENT#', 'TOTALPAGES'); + Bands: array[TfrBandType] of TfrxBandClass = + (TfrxReportTitle, TfrxReportSummary, + TfrxPageHeader, TfrxPageFooter, + TfrxHeader, TfrxMasterData, TfrxFooter, + TfrxHeader, TfrxDetailData, TfrxFooter, + TfrxHeader, TfrxSubDetailData, TfrxFooter, + TfrxOverlay, TfrxColumnHeader, TfrxColumnFooter, + TfrxGroupHeader, TfrxGroupFooter, + TfrxHeader, TfrxMasterData, TfrxFooter, + TfrxChild, nil); + cbDefaultText = '12345678'; + ChartTypes: array[0..5] of TSeriesClass = + (TLineSeries, TAreaSeries, TPointSeries, + TBarSeries, THorizBarSeries, TPieSeries); + frRepInfoCount = 9; + frRepInfo: array[0..frRepInfoCount-1] of String = + ('REPORTCOMMENT', 'REPORTNAME', 'REPORTAUTOR', + 'VMAJOR', 'VMINOR', 'VRELEASE', 'VBUILD', 'REPORTDATE', 'REPORTLASTCHANGE'); + ParamTypes: array[0..10] of TFieldType = + (ftBCD, ftBoolean, ftCurrency, ftDate, ftDateTime, ftInteger, + ftFloat, ftSmallint, ftString, ftTime, ftWord); + + +procedure frGetDataSetAndField(ComplexName: String; var DataSet: TDataSet; + var Field: String); forward; +function frGetFieldValue(F: TField): Variant; forward; +procedure LoadFromFR2Stream(AReport: TfrxReport; AStream: TStream); forward; +function ConvertDatasetAndField(s: String): String; forward; + +{ ------------------ hack FR events --------------------------------------- } +{ TfrxFR2EventsNew } + +procedure TfrxFR2EventsNew.DoGetValue(const Expr: String; var Value: Variant); +var + Dataset: TDataset; + s, Field: String; + tf: TField; + ds: TfrxDataSet; + fld: String; +begin + Dataset := nil; + Field := ''; + + if CompareText(Expr, 'COLUMN#') = 0 then + Value := Report.Engine.CurLine + else + begin + s := Expr; + if Pos('DialogForm.', s) = 1 then + begin + Delete(s, 1, Length('DialogForm.')); + Report.GetDataSetAndField(s, ds, fld); + if (ds <> nil) and (fld <> '') then + begin + Value := ds.Value[fld]; + if Report.EngineOptions.ConvertNulls and (Value = Null) then + case ds.FieldType[fld] of + fftNumeric: + Value := 0; + fftString: + Value := ''; + fftBoolean: + Value := False; + end; + Exit; + end; + end; + + frGetDataSetAndField(s, Dataset, Field); + if (Dataset <> nil) and (Field <> '') then + begin + tf := Dataset.FieldByName(Field); + Value := frGetFieldValue(tf); + end; + end; +end; + +procedure TfrxFR2EventsNew.DoPrepareScript(Sender: TObject); +var + i: Integer; +begin + FReport := TfrxReport(Sender); + Report := FReport; + for i := 0 to FReport.Variables.Count - 1 do + if IsValidIdent(FReport.Variables.Items[i].Name) then + FReport.Script.AddMethod('function ' + FReport.Variables.Items[i].Name + ': Variant', GetScriptValue); +end; + +function TfrxFR2EventsNew.GetScriptValue(Instance: TObject; + ClassType: TClass; const MethodName: String; + var Params: Variant): Variant; +var + i: Integer; + val: Variant; +begin + i := FReport.Variables.IndexOf(MethodName); + if i <> -1 then + begin + val := FReport.Variables.Items[i].Value; + if (TVarData(val).VType = varString) or (TVarData(val).VType = varOleStr) then + begin + if Pos(#13#10, val) <> 0 then + Result := val + else + Result := FReport.Calc(val); + end + else + Result := val; + end; +end; + +function TfrxFR2EventsNew.DoLoad(Sender: TfrxReport; Stream: TStream): Boolean; +begin + Result := False; + Stream.Read(frVersion, 1); + Stream.Seek(-1, soFromCurrent); + if frVersion < 30 then + begin + LoadFromFR2Stream(Sender, Stream); + Result := True; + end; +end; + +function TfrxFR2EventsNew.DoGetScriptValue(var Params: Variant): Variant; +begin + Result := FReport.Calc('`' + Params[0] + '`', FReport.Script.ProgRunning); +end; + + +{ ------------------ fixups ----------------------------------------------- } +procedure ClearFixups; +begin + while Fixups.Count > 0 do + begin + TfrxFixupItem(Fixups[0]).Free; + Fixups.Delete(0); + end; +end; + +procedure FixupReferences; +var + i: Integer; + Item: TfrxFixupItem; + Ref: TObject; +begin + for i := 0 to Fixups.Count - 1 do + begin + Item := Fixups[i]; + Ref := Report.FindObject(Item.Value); + if Ref <> nil then + SetOrdProp(Item.Obj, Item.PropInfo, Integer(Ref)); + end; + + ClearFixups; +end; + +procedure AddFixup(Obj: TPersistent; Name, Value: String); +var + Item: TfrxFixupItem; +begin + Item := TfrxFixupItem.Create; + Item.Obj := Obj; + Item.PropInfo := GetPropInfo(Obj.ClassInfo, Name); + Item.Value := Value; + Fixups.Add(Item); +end; + +{ ------------------ stream readers -------------------------------------- } +function frSetFontStyle(Style: Integer): TFontStyles; +begin + Result := []; + if (Style and $1) <> 0 then Result := Result + [fsItalic]; + if (Style and $2) <> 0 then Result := Result + [fsBold]; + if (Style and $4) <> 0 then Result := Result + [fsUnderLine]; + if (Style and $8) <> 0 then Result := Result + [fsStrikeOut]; +end; + +procedure frReadMemo(Stream: TStream; l: TStrings); +var + s: String; + b: Byte; + n: Word; +begin + l.Clear; + Stream.Read(n, 2); + if n > 0 then + repeat + Stream.Read(n, 2); + SetLength(s, n); + if n > 0 then + Stream.Read(s[1], n); + l.Add(s); + Stream.Read(b, 1); + until b = 0 + else + Stream.Read(b, 1); +end; + +function frReadString(Stream: TStream): String; +var + s: String; + n: Word; + b: Byte; +begin + Stream.Read(n, 2); + SetLength(s, n); + if n > 0 then + Stream.Read(s[1], n); + Stream.Read(b, 1); + Result := s; +end; + +procedure frReadMemo22(Stream: TStream; l: TStrings); +var + s: String; + i: Integer; + b: Byte; +begin + SetLength(s, 4096); + l.Clear; + i := 1; + repeat + Stream.Read(b,1); + if (b = 13) or (b = 0) then + begin + SetLength(s, i - 1); + if not ((b = 0) and (i = 1)) then l.Add(s); + SetLength(s, 4096); + i := 1; + end + else if b <> 0 then + begin + s[i] := Chr(b); + Inc(i); + if i > 4096 then + SetLength(s, Length(s) + 4096); + end; + until b = 0; +end; + +function frReadString22(Stream: TStream): String; +var + s: String; + i: Integer; + b: Byte; +begin + SetLength(s, 4096); + i := 1; + repeat + Stream.Read(b, 1); + if b = 0 then + SetLength(s, i - 1) + else + begin + s[i] := Chr(b); + Inc(i); + if i > 4096 then + SetLength(s, Length(s) + 4096); + end; + until b = 0; + Result := s; +end; + +function frReadBoolean(Stream: TStream): Boolean; +begin + Stream.Read(Result, 1); +end; + +function frReadByte(Stream: TStream): Byte; +begin + Stream.Read(Result, 1); +end; + +function frReadWord(Stream: TStream): Word; +begin + Stream.Read(Result, 2); +end; + +function frReadInteger(Stream: TStream): Integer; +begin + Stream.Read(Result, 4); +end; + +procedure frReadFont(Stream: TStream; Font: TFont); +var + w: Word; +begin + Font.Name := frReadString(Stream); + Font.Size := frReadInteger(Stream); + Font.Style := frSetFontStyle(frReadWord(Stream)); + Font.Color := frReadInteger(Stream); + w := frReadWord(Stream); + Font.Charset := w; +end; + +function ReadString(Stream: TStream): String; +begin + if frVersion >= 23 then + Result := frReadString(Stream) else + Result := frReadString22(Stream); +end; + +procedure ReadMemo(Stream: TStream; Memo: TStrings); +begin + if frVersion >= 23 then + frReadMemo(Stream, Memo) else + frReadMemo22(Stream, Memo); +end; + +{ --------------------------- utils -------------------------------- } +function frFindComponent(Owner: TComponent; Name: String): TComponent; +var + n: Integer; + s1, s2: String; +begin + Result := nil; + n := Pos('.', Name); + try + if n = 0 then + Result := Owner.FindComponent(Name) + else + begin + s1 := Copy(Name, 1, n - 1); // module name + s2 := Copy(Name, n + 1, 255); // component name + Owner := FindGlobalComponent(s1); + if Owner <> nil then + begin + n := Pos('.', s2); + if n <> 0 then // frame name - Delphi5 + begin + s1 := Copy(s2, 1, n - 1); + s2 := Copy(s2, n + 1, 255); + Owner := Owner.FindComponent(s1); + if Owner <> nil then + Result := Owner.FindComponent(s2); + end + else + Result := Owner.FindComponent(s2); + end; + end; + except + on Exception do + raise EClassNotFound.Create('Missing ' + Name); + end; +end; + +function frRemoveQuotes(const s: String): String; +begin + if (Length(s) > 2) and (s[1] = '"') and (s[Length(s)] = '"') then + Result := Copy(s, 2, Length(s) - 2) else + Result := s; +end; + +function frRemoveQuotes1(const s: String): String; +begin + if (Length(s) > 2) and (s[1] = '''') and (s[Length(s)] = '''') then + Result := Copy(s, 2, Length(s) - 2) else + Result := s; +end; + +procedure frGetFieldNames(DataSet: TDataSet; List: TStrings); +begin + try + DataSet.GetFieldNames(List); + except; + end; +end; + +procedure frGetDataSetAndField(ComplexName: String; var DataSet: TDataSet; + var Field: String); +var + i, j, n: Integer; + f: TComponent; + sl: TStringList; + s: String; + c: Char; + cn: TControl; + + function FindField(ds: TDataSet; FName: String): String; + var + sl: TStringList; + begin + Result := ''; + if ds <> nil then + begin + sl := TStringList.Create; + frGetFieldNames(ds, sl); + if sl.IndexOf(FName) <> -1 then + Result := FName; + sl.Free; + end; + end; + +begin + Field := ''; + f := Report.Owner; + sl := TStringList.Create; + + n := 0; j := 1; + for i := 1 to Length(ComplexName) do + begin + c := ComplexName[i]; + if c = '"' then + begin + sl.Add(Copy(ComplexName, i, 255)); + j := i; + break; + end + else if c = '.' then + begin + sl.Add(Copy(ComplexName, j, i - j)); + j := i + 1; + Inc(n); + end; + end; + if j <> i then + sl.Add(Copy(ComplexName, j, 255)); + + case n of + 0: // field name only + begin + if DataSet <> nil then + begin + s := frRemoveQuotes(ComplexName); + Field := FindField(DataSet, s); + end; + end; + 1: // DatasetName.FieldName + begin + if sl.Count > 1 then + begin + DataSet := TDataSet(frFindComponent(f, sl[0])); + s := frRemoveQuotes(sl[1]); + Field := FindField(DataSet, s); + end; + end; + 2: // FormName.DatasetName.FieldName + begin + f := FindGlobalComponent(sl[0]); + if f <> nil then + begin + DataSet := TDataSet(f.FindComponent(sl[1])); + s := frRemoveQuotes(sl[2]); + Field := FindField(DataSet, s); + end; + end; + 3: // FormName.FrameName.DatasetName.FieldName - Delphi5 + begin + f := FindGlobalComponent(sl[0]); + if f <> nil then + begin + cn := TControl(f.FindComponent(sl[1])); + DataSet := TDataSet(cn.FindComponent(sl[2])); + s := frRemoveQuotes(sl[3]); + Field := FindField(DataSet, s); + end; + end; + end; + + sl.Free; +end; + +function frGetFieldValue(F: TField): Variant; +begin + if not F.DataSet.Active then + F.DataSet.Open; + if Assigned(F.OnGetText) then + Result := F.DisplayText + else if F.DataType in [ftLargeint] then + Result := F.DisplayText + else + Result := F.AsVariant; + + if Result = Null then + if F.DataType = ftString then + Result := '' + else if F.DataType = ftWideString then + Result := '' + else if F.DataType = ftBoolean then + Result := False + else + Result := 0; +end; + +function FindTfrxDataset(ds: TDataset): TfrxDataset; +var + i: Integer; + sl: TStringList; + ds1: TfrxDataset; +begin + Result := nil; + sl := TStringList.Create; + frxGetDatasetList(sl); + for i := 0 to sl.Count - 1 do + begin + ds1 := TfrxDataset(sl.Objects[i]); + if (ds1 is TfrxDBDataset) and (TfrxDBDataset(ds1).GetDataSet = ds) then + begin + Result := ds1; + break; + end; + end; + sl.Free; +end; + +function GetBrackedVariable(const s: String; var i, j: Integer): String; +var + c: Integer; + fl1, fl2: Boolean; +begin + j := i; fl1 := True; fl2 := True; c := 0; + Result := ''; + if (s = '') or (j > Length(s)) then Exit; + Dec(j); + repeat + Inc(j); + if fl1 and fl2 then + if s[j] = '[' then + begin + if c = 0 then i := j; + Inc(c); + end + else if s[j] = ']' then Dec(c); + if fl1 then + if s[j] = '"' then fl2 := not fl2; + if fl2 then + if s[j] = '''' then fl1 := not fl1; + until (c = 0) or (j >= Length(s)); + Result := Copy(s, i + 1, j - i - 1); +end; + +function Substitute(const ParName: String): String; +begin + Result := ParName; + if CompareText(ParName, frRepInfo[0]) = 0 then + Result := 'Report.ReportOptions.Description' + else if CompareText(ParName, frRepInfo[1]) = 0 then + Result := 'Report.ReportOptions.Name' + else if CompareText(ParName, frRepInfo[2]) = 0 then + Result := 'Report.ReportOptions.Author' + else if CompareText(ParName, frRepInfo[3]) = 0 then + Result := 'Report.ReportOptions.VersionMajor' + else if CompareText(ParName, frRepInfo[4]) = 0 then + Result := 'Report.ReportOptions.VersionMinor' + else if CompareText(ParName, frRepInfo[5]) = 0 then + Result := 'Report.ReportOptions.VersionRelease' + else if CompareText(ParName, frRepInfo[6]) = 0 then + Result := 'Report.ReportOptions.VersionBuild' + else if CompareText(ParName, frRepInfo[7]) = 0 then + Result := 'Report.ReportOptions.CreateDate' + else if CompareText(ParName, frRepInfo[8]) = 0 then + Result := 'Report.ReportOptions.LastChange' + + else if CompareText(ParName, 'CURY') = 0 then + Result := 'Engine.CurY' + else if CompareText(ParName, 'FREESPACE') = 0 then + Result := 'Engine.FreeSpace' + else if CompareText(ParName, 'FINALPASS') = 0 then + Result := 'Engine.FinalPass' + else if CompareText(ParName, 'PAGEHEIGHT') = 0 then + Result := 'Engine.PageHeight' + else if CompareText(ParName, 'PAGEWIDTH') = 0 then + Result := 'Engine.PageWidth' +end; + +procedure DoExpression(const Expr: String; var Value: String); +begin + Value := Substitute(Expr); + if ConvertDatasetAndField(Expr) <> Expr then + Value := ConvertDatasetAndField(Expr); +end; + +procedure ExpandVariables(var s: String); +var + i, j: Integer; + s1, s2: String; +begin + i := 1; + repeat + while (i < Length(s)) and (s[i] <> '[') do Inc(i); + s1 := GetBrackedVariable(s, i, j); + if i <> j then + begin + Delete(s, i, j - i + 1); + s2 := s1; + DoExpression(s1, s2); + s2 := '[' + s2 + ']'; + Insert(s2, s, i); + Inc(i, Length(s2)); + j := 0; + end; + until i = j; +end; + +procedure ExpandVariables1(var s: String); +var + i, j: Integer; + s1, s2: String; +begin + i := 1; + repeat + while (i < Length(s)) and (s[i] <> '[') do Inc(i); + s1 := GetBrackedVariable(s, i, j); + if i <> j then + begin + Delete(s, i, j - i + 1); + s2 := s1; + DoExpression(s1, s2); + Insert(s2, s, i); + Inc(i, Length(s2)); + j := 0; + end; + until i = j; +end; + +procedure ConvertMemoExpressions(m: TfrxCustomMemoView; s: String); +begin + ExpandVariables(s); + m.Memo.Text := AnsiToUnicode(s, m.Font.Charset); +end; + +{ --------------------------- report items -------------------------------- } +var + Name: String; + HVersion, LVersion: Byte; + x, y, dx, dy: Integer; + Flags: Word; + FrameTyp: Word; + FrameWidth: Single; + FrameColor: TColor; + FrameStyle: Word; + FillColor: TColor; + Format: Integer; + FormatStr: String; + Visible: WordBool; + gapx, gapy: Integer; + Restrictions: Word; + Tag: String; + Memo, Script: TStringList; + BandAlign: Byte; + NeedCreateName: Boolean; + +procedure AddScript(c: TfrxComponent; const ScriptName: String); +var + i: Integer; + vName: String; +begin + vName := c.Name; + if Script.Count <> 0 then + begin + Report.ScriptText.Add('procedure ' + vName + scriptName); + Report.ScriptText.Add('begin'); + Report.ScriptText.Add(' with ' + vName + ', Engine do'); + Report.ScriptText.Add(' begin'); + if Script[0] <> 'begin' then + Report.ScriptText.Add(Script[0]); + + for i := 1 to Script.Count - 2 do + Report.ScriptText.Add(Script[i]); + + if Script[0] <> 'begin' then + begin + if Script.Count <> 1 then + Report.ScriptText.Add(Script[Script.Count - 1]); + Report.ScriptText.Add(' end'); + Report.ScriptText.Add('end;'); + end + else + begin + Report.ScriptText.Add(' end'); + Report.ScriptText.Add(Script[Script.Count - 1] + ';'); + end; + Report.ScriptText.Add(''); + + if c is TfrxDialogPage then + TfrxDialogPage(c).OnShow := vName + 'OnShow' + else if c is TfrxDialogControl then + TfrxDialogControl(c).OnClick := vName + 'OnClick' + else if c is TfrxReportComponent then + TfrxReportComponent(c).OnBeforePrint := vName + 'OnBeforePrint'; + end; +end; + +procedure SetfrxComponent(c: TfrxComponent); + + procedure SetValidIdent(var Ident: string); + const + Alpha = ['A'..'Z', 'a'..'z', '_']; + AlphaNumeric = Alpha + ['0'..'9']; + var + I: Integer; + begin + if (Length(Ident) > 0) and not (Ident[1] in Alpha) then + Ident[1] := '_'; + for I := 2 to Length(Ident) do + if not (Ident[I] in AlphaNumeric) then + Ident[I] := '_'; + end; + +begin + SetValidIdent(Name); + c.Name := Name; + if NeedCreateName then + c.CreateUniqueName; + + c.Left := x + offsx; + c.Top := y + offsy; + c.Width := dx; + c.Height := dy; + c.Visible := Visible; +end; + +procedure SetfrxView(c: TfrxView); +begin + if (FrameTyp and frftRight) <> 0 then + c.Frame.Typ := c.Frame.Typ + [ftRight]; + if (FrameTyp and frftBottom) <> 0 then + c.Frame.Typ := c.Frame.Typ + [ftBottom]; + if (FrameTyp and frftLeft) <> 0 then + c.Frame.Typ := c.Frame.Typ + [ftLeft]; + if (FrameTyp and frftTop) <> 0 then + c.Frame.Typ := c.Frame.Typ + [ftTop]; + c.Frame.Width := FrameWidth; + c.Frame.Color := FrameColor; + c.Frame.Style := TfrxFrameStyle(FrameStyle); + c.Color := FillColor; + if BandAlign = 6 then + BandAlign := 0; + if BandAlign = 7 then + BandAlign := 6; + c.Align := TfrxAlign(BandAlign); + c.TagStr := Tag; + AddScript(c, 'OnBeforePrint(Sender: TfrxComponent);'); +end; + +procedure TfrViewLoadFromStream; +var + w: Integer; +begin + with Stream do + begin + NeedCreateName := False; + if frVersion >= 23 then + Name := ReadString(Stream) else + NeedCreateName := True; + if frVersion > 23 then + begin + Read(HVersion, 1); + Read(LVersion, 1); + end; + Read(x, 4); Read(y, 4); Read(dx, 4); Read(dy, 4); + Read(Flags, 2); Read(FrameTyp, 2); Read(FrameWidth, 4); + Read(FrameColor, 4); Read(FrameStyle, 2); + Read(FillColor, 4); + Read(Format, 4); + FormatStr := ReadString(Stream); + ReadMemo(Stream, Memo); + if frVersion >= 23 then + begin + ReadMemo(Stream, Script); + Read(Visible, 2); + end; + if frVersion >= 24 then + begin + Read(Restrictions, 2); + Tag := ReadString(Stream); + Read(gapx, 4); + Read(gapy, 4); + end; + w := PInteger(@FrameWidth)^; + if w <= 10 then + w := w * 1000; + if HVersion > 1 then + Read(BandAlign, 1); + FrameWidth := w / 1000; + end; +end; + +procedure TfrMemoViewLoadFromStream; +var + w: Word; + i: Integer; + Alignment: Integer; + Highlight: TfrHighlightAttr; + HighlightStr: String; + LineSpacing, CharacterSpacing: Integer; + m: TfrxMemoView; + + procedure DecodeDisplayFormat; + var + LCategory: Byte; + LType: Byte; + LNoOfDecimals: Byte; + LSeparator: Char; + begin + LCategory := (Format and $0F000000) shr 24; + LType := (Format and $00FF0000) shr 16; + LNoOfDecimals := (Format and $0000FF00) shr 8; + LSeparator := Chr(Format and $000000FF); + + case LCategory of + 0: { text } + m.DisplayFormat.Kind := fkText; + + 1: { number } + begin + m.DisplayFormat.Kind := fkNumeric; + m.DisplayFormat.DecimalSeparator := LSeparator; + case LType of + 0: m.DisplayFormat.FormatStr := '%2.' + IntToStr(LNoOfDecimals) + 'g'; + 1: m.DisplayFormat.FormatStr := '%g'; + 2: m.DisplayFormat.FormatStr := '%2.' + IntToStr(LNoOfDecimals) + 'f'; + 3: m.DisplayFormat.FormatStr := '%2.' + IntToStr(LNoOfDecimals) + 'n'; + else + m.DisplayFormat.FormatStr := '%g' { can't convert custom format string }; + end; + end; + + 2: { date } + begin + m.DisplayFormat.Kind := fkDateTime; + case LType of + 0: m.DisplayFormat.FormatStr := 'dd.mm.yy'; + 1: m.DisplayFormat.FormatStr := 'dd.mm.yyyy'; + 2: m.DisplayFormat.FormatStr := 'd mmm yyyy'; + 3: m.DisplayFormat.FormatStr := LongDateFormat; + 4: m.DisplayFormat.FormatStr := FormatStr; + end; + end; + + 3: { time } + begin + m.DisplayFormat.Kind := fkDateTime; + case LType of + 0: m.DisplayFormat.FormatStr := 'hh:nn:ss'; + 1: m.DisplayFormat.FormatStr := 'h:nn:ss'; + 2: m.DisplayFormat.FormatStr := 'hh:nn'; + 3: m.DisplayFormat.FormatStr := 'h:nn'; + 4: m.DisplayFormat.FormatStr := FormatStr; + end; + end; + + 4: { boolean } + begin + m.DisplayFormat.Kind := fkBoolean; + case LType of + 0: m.DisplayFormat.FormatStr := '0,1'; + 1: m.DisplayFormat.FormatStr := ','; + 2: m.DisplayFormat.FormatStr := '_,X'; + 3: m.DisplayFormat.FormatStr := 'False,True'; + 4: m.DisplayFormat.FormatStr := FormatStr; + end; + end; + end; + end; + +begin + TfrViewLoadFromStream; + m := TfrxMemoView.Create(Page); + SetfrxComponent(m); + SetfrxView(m); + + with Stream do + begin + { font info } + m.Font.Name := ReadString(Stream); + Read(i, 4); + m.Font.Size := i; + Read(w, 2); + m.Font.Style := frSetFontStyle(w); + Read(i, 4); + m.Font.Color := i; + + { text align, rotation } + Read(Alignment, 4); + if (Alignment and frtaRight) <> 0 then + m.HAlign := haRight; + if (Alignment and frtaCenter) <> 0 then + m.HAlign := haCenter; + if (Alignment and 3) = 3 then + m.HAlign := haBlock; + if (Alignment and frtaVertical) <> 0 then + m.Rotation := 90; + if (Alignment and frtaMiddle) <> 0 then + m.VAlign := vaCenter; + if (Alignment and frtaDown) <> 0 then + m.VAlign := vaBottom; + + { charset } + Read(w, 2); + if frVersion < 23 then + w := DEFAULT_CHARSET; + m.Font.Charset := w; + + Read(Highlight, 10); + HighlightStr := ReadString(Stream); + + m.Highlight.Condition := HighlightStr; + m.Highlight.Color := Highlight.FillColor; + m.Highlight.Font.Color := Highlight.FontColor; + m.Highlight.Font.Style := frSetFontStyle(Highlight.FontStyle); + + if frVersion >= 24 then + begin + Read(LineSpacing, 4); + m.LineSpacing := LineSpacing; + Read(CharacterSpacing, 4); + m.CharSpacing := CharacterSpacing; + end; + end; + + if frVersion = 21 then + Flags := Flags or flWordWrap; + + if (Flags and flStretched) <> 0 then + m.StretchMode := smMaxHeight; + m.WordWrap := (Flags and flWordWrap) <> 0; + m.WordBreak := (Flags and flWordBreak) <> 0; + m.AutoWidth := (Flags and flAutoSize) <> 0; + m.AllowExpressions := (Flags and flTextOnly) = 0; + m.SuppressRepeated := (Flags and flSuppressRepeated) <> 0; + m.HideZeros := (Flags and flHideZeros) <> 0; + m.Underlines := (Flags and flUnderlines) <> 0; + m.RTLReading := (Flags and flRTLReading) <> 0; + + DecodeDisplayFormat; + + ConvertMemoExpressions(m, Memo.Text); +end; + +procedure TfrPictureViewLoadFromStream; +var + b, BlobType: Byte; + n: Integer; + Graphic: TGraphic; + TempStream: TMemoryStream; + p: TfrxPictureView; +begin + TfrViewLoadFromStream; + p := TfrxPictureView.Create(Page); + SetfrxComponent(p); + SetfrxView(p); + + Stream.Read(b, 1); + if HVersion * 10 + LVersion > 10 then + Stream.Read(BlobType, 1); + Stream.Read(n, 4); + Graphic := nil; + case b of + pkBitmap: Graphic := TBitmap.Create; + pkMetafile: Graphic := TMetafile.Create; + pkIcon: Graphic := TIcon.Create; + pkJPEG: Graphic := TJPEGImage.Create; + end; + p.Picture.Graphic := Graphic; + if Graphic <> nil then + begin + Graphic.Free; + TempStream := TMemoryStream.Create; + TempStream.CopyFrom(Stream, n - Stream.Position); + TempStream.Position := 0; + p.Picture.Graphic.LoadFromStream(TempStream); + TempStream.Free; + end; + Stream.Seek(n, soFromBeginning); + + p.Stretched := (Flags and flStretched) <> 0; + p.Center := (Flags and flPictCenter) <> 0; + p.KeepAspectRatio := (Flags and flPictRatio) <> 0; + if Memo.Count > 0 then + p.DataField := Memo[0]; +end; + +procedure TfrBandViewLoadFromStream; +var + ChildBand, Master: String; + Columns: Integer; + ColumnWidth: Integer; + ColumnGap: Integer; + NewColumnAfter: Integer; + BandType: TfrBandType; + Band: TfrxBand; +begin + TfrViewLoadFromStream; + + BandType := TfrBandType(FrameTyp); + Band := TfrxBand(Bands[BandType].NewInstance); + Band.Create(Page); + if BandType in [btCrossHeader..btCrossFooter] then + Band.Vertical := True; + SetfrxComponent(Band); + AddScript(Band, 'OnBeforePrint(Sender: TfrxComponent);'); + + if frVersion > 23 then + begin + ChildBand := frReadString(Stream); + if ChildBand <> '' then + AddFixup(Band, 'Child', ChildBand); + Stream.Read(Columns, 4); + Stream.Read(ColumnWidth, 4); + Stream.Read(ColumnGap, 4); + { not implemented } + Stream.Read(NewColumnAfter, 4); + { not implemented } + if HVersion * 10 + LVersion > 20 then + Master := frReadString(Stream); + if Band is TfrxDataBand then + begin + TfrxDataBand(Band).Columns := Columns; + TfrxDataBand(Band).ColumnWidth := ColumnWidth; + TfrxDataBand(Band).ColumnGap := ColumnGap; + if (FormatStr <> '') and (FormatStr[1] in ['1'..'9']) then + TfrxDataBand(Band).RowCount := StrToInt(FormatStr) + else + TfrxDataBand(Band).DatasetName := FormatStr; + end; + end; + + Band.Stretched := (Flags and flStretched) <> 0; + Band.StartNewPage := (Flags and flBandNewPageAfter) <> 0; + Band.PrintChildIfInvisible := (Flags and flBandPrintChildIfInvisible) <> 0; + Band.AllowSplit := (Flags and flBandBreaked) <> 0; + if Band is TfrxDataBand then + TfrxDataBand(Band).PrintifDetailEmpty := (Flags and flBandPrintifSubsetEmpty) <> 0; + if Band is TfrxPageHeader then + TfrxPageHeader(Band).PrintOnFirstPage := (Flags and flBandOnFirstPage) <> 0; + if Band is TfrxPageFooter then + begin + TfrxPageFooter(Band).PrintOnFirstPage := (Flags and flBandOnFirstPage) <> 0; + TfrxPageFooter(Band).PrintOnLastPage := (Flags and flBandOnLastPage) <> 0; + end; + if Band is TfrxHeader then + TfrxHeader(Band).ReprintOnNewPage := (Flags and flBandRepeatHeader) <> 0; + if Band is TfrxGroupHeader then + begin + TfrxGroupHeader(Band).ReprintOnNewPage := (Flags and flBandRepeatHeader) <> 0; + DoExpression(FormatStr, FormatStr); + TfrxGroupHeader(Band).Condition := FormatStr; + end; +end; + +procedure TfrSubreportLoadFromStream; +var + s: TfrxSubreport; + SubPage: Integer; +begin + TfrViewLoadFromStream; + s := TfrxSubreport.Create(Page); + SetfrxComponent(s); + Stream.Read(SubPage, 4); + s.Page := TfrxReportPage(Report.Pages[SubPage]); + with s.Page do + begin + if Name = '' then + CreateUniqueName; + LeftMargin := 0; + RightMargin := 0; + TopMargin := 0; + BottomMargin := 0; + end; +end; + +procedure TfrLineViewLoadFromStream; +var + Line: TfrxLineView; +begin + TfrViewLoadFromStream; + Line := TfrxLineView.Create(Page); + SetfrxComponent(Line); + SetfrxView(Line); + if (Flags and flStretched) <> 0 then + Line.StretchMode := smMaxHeight; +end; + +procedure ReadStdCtrl(c: TfrxDialogControl); +begin + TfrViewLoadFromStream; + SetfrxComponent(c); + THackControl(c.Control).Color := frReadInteger(Stream); + c.Control.Enabled := frReadBoolean(Stream); + frReadFont(Stream, c.Font); + AddScript(c, 'OnClick(Sender: TfrxComponent);'); +end; + +procedure ReadTfrLabelControl; +var + l: TfrxLabelControl; +begin + l := TfrxLabelControl.Create(Page); + ReadStdCtrl(l); + l.Alignment := TAlignment(frReadByte(Stream)); + l.AutoSize := frReadBoolean(Stream); + l.Caption := frReadString(Stream); + l.WordWrap := frReadBoolean(Stream); +end; + +procedure ReadTfrEditControl; +var + e: TfrxEditControl; +begin + e := TfrxEditControl.Create(Page); + ReadStdCtrl(e); + e.Text := frReadString(Stream); + e.ReadOnly := frReadBoolean(Stream); +end; + +procedure ReadTfrMemoControl; +var + m: TfrxMemoControl; +begin + m := TfrxMemoControl.Create(Page); + ReadStdCtrl(m); + m.Text := frReadString(Stream); + m.ReadOnly := frReadBoolean(Stream); +end; + +procedure ReadTfrButtonControl; +var + b: TfrxButtonControl; +begin + b := TfrxButtonControl.Create(Page); + ReadStdCtrl(b); + b.Caption := frReadString(Stream); + b.ModalResult := frReadWord(Stream); + b.Cancel := b.ModalResult = mrCancel; + b.Default := b.ModalResult = mrOk; +end; + +procedure ReadTfrCheckBoxControl; +var + b: TfrxCheckBoxControl; +begin + b := TfrxCheckBoxControl.Create(Page); + ReadStdCtrl(b); + b.Alignment := TAlignment(frReadByte(Stream)); + b.Checked := frReadBoolean(Stream); + b.Caption := frReadString(Stream); +end; + +procedure ReadTfrRadioButtonControl; +var + b: TfrxRadioButtonControl; +begin + b := TfrxRadioButtonControl.Create(Page); + ReadStdCtrl(b); + b.Alignment := TAlignment(frReadByte(Stream)); + b.Checked := frReadBoolean(Stream); + b.Caption := frReadString(Stream); +end; + +procedure ReadTfrListBoxControl; +var + b: TfrxListBoxControl; +begin + b := TfrxListBoxControl.Create(Page); + ReadStdCtrl(b); + frReadMemo(Stream, b.Items); +end; + +procedure ReadTfrComboBoxControl; +var + c: TfrxComboBoxControl; + b: Byte; +begin + c := TfrxComboBoxControl.Create(Page); + ReadStdCtrl(c); + frReadMemo(Stream, c.Items); + if HVersion * 10 + LVersion > 10 then + begin + b := frReadByte(Stream); + if (HVersion * 10 + LVersion <= 20) and (b > 0) then + Inc(b); + c.Style := TComboBoxStyle(b); + end; +end; + +procedure ReadTfrDateEditControl; +var + b: TfrxDateEditControl; +begin + b := TfrxDateEditControl.Create(Page); + ReadStdCtrl(b); + b.DateFormat := TDTDateFormat(frReadByte(Stream)); +end; + +procedure ReadTfrBarcodeView; +var + v: TfrxBarcodeView; + Param: TfrBarcodeRec; +begin + v := TfrxBarcodeView.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + SetfrxView(v); + + Stream.Read(Param, SizeOf(Param)); + if Param.cModul = 1 then + begin + Param.cRatio := Param.cRatio / 2; + Param.cModul := 2; + end; + + if (Memo.Count > 0) and (Memo[0][1] <> '[') then + v.Text := Memo[0] else + v.Expression := Memo[0]; + + v.Rotation := Round(Param.cAngle); + v.CalcChecksum := Param.cCheckSum; + v.BarType := Param.cBarType; + v.Zoom := Param.cRatio; + v.ShowText := Param.cShowText; +end; + +procedure ReadTfrChartView; +var + v: TfrxChartView; + b: Byte; + ChartOptions: TChartOptions; + LegendObj, ValueObj, Top10Label: String; + Ser: TChartSeries; + dser: TfrxSeriesItem; +begin + v := TfrxChartView.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + SetfrxView(v); + + Stream.Read(b, 1); + if b <> 1 then + with Stream do + begin + Read(ChartOptions, SizeOf(ChartOptions)); + LegendObj := frReadString(Stream); + ValueObj := frReadString(Stream); + Top10Label := frReadString(Stream); + end; + + v.Chart.Frame.Visible := False; + v.Chart.LeftWall.Brush.Style := bsClear; + v.Chart.BottomWall.Brush.Style := bsClear; + + v.Chart.View3D := ChartOptions.Dim3D; + v.Chart.Legend.Visible := ChartOptions.ShowLegend; + v.Chart.AxisVisible := ChartOptions.ShowAxis; + v.Chart.View3DWalls := ChartOptions.ChartType <> 5; + v.Chart.BackWall.Brush.Style := bsClear; + v.Chart.View3DOptions.Elevation := 315; + v.Chart.View3DOptions.Rotation := 360; + v.Chart.View3DOptions.Orthogonal := ChartOptions.ChartType <> 5; + + Ser := ChartTypes[ChartOptions.ChartType].Create(v.Chart); + v.Chart.AddSeries(Ser); + if ChartOptions.Colored then + Ser.ColorEachPoint := True; + Ser.Marks.Visible := ChartOptions.ShowMarks; + Ser.Marks.Style := TSeriesMarksStyle(ChartOptions.MarksStyle); + + dser := v.SeriesData.Add; + dser.DataType := dtBandData; + dser.XSource := LegendObj; + dser.YSource := ValueObj; + dser.TopN := ChartOptions.Top10Num; + dser.TopNCaption := Top10Label; +end; + +procedure ReadTfrCheckBoxView; +var + v: TfrxCheckBoxView; + CheckStyle: Byte; + CheckColor: TColor; +begin + v := TfrxCheckBoxView.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + SetfrxView(v); + + if frVersion > 23 then + begin + Stream.Read(CheckStyle, 1); + v.CheckStyle := TfrxCheckStyle(CheckStyle); + Stream.Read(CheckColor, 4); + v.CheckColor := CheckColor; + end; + if Memo.Count > 0 then + v.Expression := Memo[0]; +end; + +procedure ReadTfrOLEView; +var + v: TfrxOLEView; + b: Byte; +begin + v := TfrxOLEView.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + SetfrxView(v); + + Stream.Read(b, 1); + if b <> 0 then + v.OleContainer.LoadFromStream(Stream); + if Memo.Count > 0 then + v.DataField := Memo[0]; +end; + +procedure ReadTfrRichView; +var + v: TfrxRichView; + b: Byte; + n: Integer; +begin + v := TfrxRichView.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + SetfrxView(v); + + if (Flags and flStretched) <> 0 then + v.StretchMode := smMaxHeight; + Stream.Read(b, 1); + Stream.Read(n, 4); + if b <> 0 then + v.RichEdit.Lines.LoadFromStream(Stream); + Stream.Seek(n, soFromBeginning); + if Memo.Count > 0 then + v.DataField := Memo[0]; +end; + +procedure ReadTfrShapeView; +var + v: TfrxShapeView; + ShapeType: Byte; +begin + v := TfrxShapeView.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + SetfrxView(v); + + Stream.Read(ShapeType, 1); + v.Shape := TfrxShapeKind(ShapeType); +end; + +procedure ReadTfrRoundRectView; +var + v: TfrxShapeView; + Cadre: TfrRoundRect; +begin + v := TfrxShapeView.Create(Page); + v.Shape := skRoundRectangle; + TfrViewLoadFromStream; + SetfrxComponent(v); + SetfrxView(v); + + Stream.Read(Cadre, SizeOf(Cadre)); +end; + +procedure ReadTfrCrossView; +var + v: TfrxDBCrossView; + sl: TStringList; + s: String; + i: Integer; + + function PureName1(const s: String): String; + begin + if Pos('+', s) <> 0 then + Result := Copy(s, 1, Pos('+', s) - 1) else + Result := s; + end; + + function HasTotal(s: String): Boolean; + begin + Result := Pos('+', s) <> 0; + end; + + function FuncName(s: String): String; + begin + if HasTotal(s) then + begin + Result := LowerCase(Copy(s, Pos('+', s) + 1, 255)); + if Result = '' then + Result := 'sum'; + end + else + Result := ''; + end; + +begin + v := TfrxDBCrossView.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + SetfrxView(v); + + v.Border := frReadBoolean(Stream); + v.RepeatHeaders := frReadBoolean(Stream); + v.GapY := 1; + v.Visible := True; + { show header, not used } + frReadBoolean(Stream); + if LVersion > 0 then + begin + v.ShowColumnTotal := frReadBoolean(Stream); + v.ShowRowTotal := v.ShowColumnTotal; + v.MaxWidth := frReadInteger(Stream); + {FHeaderWidth := }frReadInteger(Stream); + end; + if LVersion > 1 then + begin + {FDictionary.Text := }frReadString(Stream); + {FMaxNameLen := }frReadInteger(Stream); + end; + if LVersion > 2 then + {FDataCaption := }frReadString(Stream); + + sl := TStringList.Create; + + if Memo.Count >= 4 then + begin + v.DataSetName := Memo[0]; + + frxSetCommaText(Memo[1], sl); + v.RowLevels := sl.Count; + v.RowFields.Clear; + for i := 0 to sl.Count - 1 do + begin + s := PureName1(sl[i]); {row field name } + v.RowFields.Add(s); + v.RowTotalMemos[i + 1].Visible := s <> sl[i]; + end; + + frxSetCommaText(Memo[2], sl); + v.ColumnLevels := sl.Count; + v.ColumnFields.Clear; + for i := 0 to sl.Count - 1 do + begin + s := PureName1(sl[i]); {column field name } + v.ColumnFields.Add(s); + v.ColumnTotalMemos[i + 1].Visible := s <> sl[i]; + end; + + frxSetCommaText(Memo[3], sl); + v.CellLevels := sl.Count; + v.CellFields.Clear; + for i := 0 to sl.Count - 1 do + begin + s := PureName1(sl[i]); {column field name } + v.CellFields.Add(s); + s := FuncName(sl[i]); + if s = 'sum' then + v.CellFunctions[i] := cfSum + else if s = 'avg' then + v.CellFunctions[i] := cfAvg + else if s = 'min' then + v.CellFunctions[i] := cfMin + else if s = 'max' then + v.CellFunctions[i] := cfMax + else if s = 'count' then + v.CellFunctions[i] := cfCount + end; + end; + + sl.Free; +end; + + +{------------------------- datacontrols --------------------------------------} +procedure ReadTfrBDEDatabase; +var + v: TfrxBDEDatabase; + s: String; +begin + v := TfrxBDEDatabase.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + + v.DatabaseName := frReadString(Stream); + s := frReadString(Stream); + if s <> '' then + v.AliasName := s; + s := frReadString(Stream); + if s <> '' then + v.DriverName := s; + v.LoginPrompt := frReadBoolean(Stream); + frReadMemo(Stream, v.Params); + v.Connected := frReadBoolean(Stream); +end; + +{ field list is not stored in FR3, just skip } +procedure TfrXXXDataSetReadFields; +var + i: Integer; + n: Word; + fLookup: Boolean; + b: Byte; +begin + Stream.Read(n, 2); // FieldCount + for i := 0 to n - 1 do + begin + +// Old version of BDEComponents stores fieldlist wrongfully + if HVersion * 10 + LVersion <= 10 then + begin + b := frReadByte(Stream); // islookup + frReadString(Stream); // fieldname + if b = 1 then + begin + frReadByte(Stream); // datatype + frReadWord(Stream); // size + frReadString(Stream); // KeyFields + frReadString(Stream); // LookupDataset + frReadString(Stream); // LookupKeyFields + frReadString(Stream); // LookupResultField + end; + continue; + end; + + frReadByte(Stream); // DataType + frReadString(Stream); // FieldName + fLookup := frReadBoolean(Stream); // Lookup + frReadWord(Stream); // Size + + if fLookup then + begin + frReadString(Stream); // KeyFields + frReadString(Stream); // LookupDataset + frReadString(Stream); // LookupKeyFields + frReadString(Stream); // LookupResultField + end; + end; +end; + +procedure ReadTfrBDETable; +var + v: TfrxBDETable; +begin + v := TfrxBDETable.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + v.SetBounds(-1000, -1000, 0, 0); + + v.DatabaseName := frReadString(Stream); + v.Filter := frReadString(Stream); + v.Filtered := Trim(v.Filter) <> ''; + v.IndexName := frReadString(Stream); + v.MasterFields := frReadString(Stream); + AddFixup(v, 'Master', frReadString(Stream)); + v.TableName := frReadString(Stream); + frReadBoolean(Stream); // active + TfrXXXDataSetReadFields; + Report.Datasets.Add(v); +end; + +procedure TfrXXXQueryReadParams(Query: TfrxCustomQuery); +var + i: Integer; + w, n: Word; +begin + Stream.Read(n, 2); + for i := 0 to n - 1 do + with Query.Params[i] do + begin + Stream.Read(w, 2); + DataType := ParamTypes[w]; + Stream.Read(w, 2); + Expression := frReadString(Stream); + end; +end; + +procedure ReadTfrBDEQuery; +var + v: TfrxBDEQuery; +begin + v := TfrxBDEQuery.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + v.SetBounds(-1000, -1000, 0, 0); + + v.DatabaseName := frReadString(Stream); + v.Filter := frReadString(Stream); + v.Filtered := Trim(v.Filter) <> ''; + AddFixup(v, 'Master', frReadString(Stream)); + frReadMemo(Stream, v.SQL); + + frReadBoolean(Stream); + TfrXXXDataSetReadFields; + TfrXXXQueryReadParams(v); + v.IsLoading := True; + v.UpdateParams; + v.IsLoading := False; +end; + +procedure ReadTfrADODatabase; +var + v: TfrxADODatabase; +begin + v := TfrxADODatabase.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + + v.DatabaseName := frReadString(Stream); + v.LoginPrompt := frReadBoolean(Stream); + v.Connected := frReadBoolean(Stream); +end; + +procedure ReadTfrADOTable; +var + v: TfrxADOTable; +begin + v := TfrxADOTable.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + v.SetBounds(-1000, -1000, 0, 0); + + AddFixup(v, 'Database', frReadString(Stream)); + v.Filter := frReadString(Stream); + v.Filtered := Trim(v.Filter) <> ''; + v.IndexName := frReadString(Stream); + v.MasterFields := frReadString(Stream); + AddFixup(v, 'Master', frReadString(Stream)); + v.TableName := frReadString(Stream); + frReadBoolean(Stream); // active + if LVersion >= 2 then + frReadBoolean(Stream); // enableBCD + TfrXXXDataSetReadFields; + Report.Datasets.Add(v); +end; + +procedure ReadTfrADOQuery; +var + v: TfrxADOQuery; +begin + v := TfrxADOQuery.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + v.SetBounds(-1000, -1000, 0, 0); + + AddFixup(v, 'Database', frReadString(Stream)); + v.Filter := frReadString(Stream); + v.Filtered := Trim(v.Filter) <> ''; + AddFixup(v, 'Master', frReadString(Stream)); + frReadMemo(Stream, v.SQL); + + frReadBoolean(Stream); // active + if LVersion >= 2 then + frReadBoolean(Stream); // enableBCD + + TfrXXXDataSetReadFields; + TfrXXXQueryReadParams(v); + v.IsLoading := True; + v.UpdateParams; + v.IsLoading := False; +end; + +procedure ReadTfrIBXDatabase; +var + v: TfrxIBXDatabase; +begin + v := TfrxIBXDatabase.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + + v.DatabaseName := frReadString(Stream); + v.LoginPrompt := frReadBoolean(Stream); + if HVersion * 10 + LVersion > 20 then + v.SQLDialect := frReadInteger(Stream); + frReadMemo(Stream, v.Params); + v.Connected := frReadBoolean(Stream); +end; + +procedure ReadTfrIBXTable; +var + v: TfrxIBXTable; +begin + v := TfrxIBXTable.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + v.SetBounds(-1000, -1000, 0, 0); + + AddFixup(v, 'Database', frReadString(Stream)); + v.TableName := frReadString(Stream); + v.Filter := frReadString(Stream); + v.Filtered := Trim(v.Filter) <> ''; + v.IndexName := frReadString(Stream); + v.IndexFieldNames := frReadString(Stream); + v.MasterFields := frReadString(Stream); + AddFixup(v, 'Master', frReadString(Stream)); + frReadBoolean(Stream); // active + TfrXXXDataSetReadFields; + Report.Datasets.Add(v); +end; + +procedure ReadTfrIBXQuery; +var + v: TfrxIBXQuery; +begin + v := TfrxIBXQuery.Create(Page); + TfrViewLoadFromStream; + SetfrxComponent(v); + v.SetBounds(-1000, -1000, 0, 0); + + AddFixup(v, 'Database', frReadString(Stream)); + v.Filter := frReadString(Stream); + v.Filtered := Trim(v.Filter) <> ''; + AddFixup(v, 'Master', frReadString(Stream)); + frReadMemo(Stream, v.SQL); + frReadBoolean(Stream); // active + + TfrXXXDataSetReadFields; + TfrXXXQueryReadParams(v); + v.IsLoading := True; + v.UpdateParams; + v.IsLoading := False; +end; + + + +{----------------------------------------------------------------------------} +procedure TfrDictionaryLoadFromStream; +var + w: Word; + NewVersion: Boolean; + Variables, FieldAliases, BandDatasources: TfrxVariables; + SMemo: TStringList; + + procedure LoadFRVariables(Value: TfrxVariables); + var + i, n: Integer; + s: String; + begin + Stream.Read(n, 4); + for i := 0 to n - 1 do + begin + s := frReadString(Stream); + Value[s] := frReadString(Stream); + end; + end; + + procedure LoadOldVariables; + var + i, n, d: Integer; + b: Byte; + s, s1, s2: String; + + function ReadStr: String; + var + n: Byte; + begin + Stream.Read(n, 1); + SetLength(Result, n); + Stream.Read(Result[1], n); + end; + + begin + with Stream do + begin + ReadBuffer(n, SizeOf(n)); + for i := 0 to n - 1 do + begin + Read(b, 1); // typ + Read(d, 4); // otherkind + s1 := ReadStr; // dataset + s2 := ReadStr; // field + s := ReadStr; // var name + if b = 2 then // it's system variable or expression + if d = 1 then + s1 := s2 else + s1 := frSpecFuncs[d] + else if b = 1 then // it's data field + s1 := s1 + '."' + s2 + '"' + else + s1 := ''; + FieldAliases[' ' + s] := s1; + end; + end; + + ReadMemo(Stream, SMemo); + for i := 0 to SMemo.Count - 1 do + begin + s := SMemo[i]; + if (s <> '') and (s[1] <> ' ') then + Variables[s] := '' else + Variables[s] := FieldAliases[s]; + end; + FieldAliases.Clear; + end; + + procedure ConvertToNewFormat; + var + i: Integer; + s: String; + begin + for i := 0 to Variables.Count - 1 do + begin + s := Variables.Items[i].Name; + if s <> '' then + if s[1] = ' ' then + s := Copy(s, 2, 255) else + s := ' ' + s; + Variables.Items[i].Name := s; + end; + end; + +begin + Variables := TfrxVariables.Create; + FieldAliases := TfrxVariables.Create; + BandDatasources := TfrxVariables.Create; + SMemo := TStringList.Create; + + w := frReadWord(Stream); + NewVersion := (w = $FFFF) or (w = $FFFE); + if NewVersion then + begin + LoadFRVariables(Variables); + LoadFRVariables(FieldAliases); + LoadFRVariables(BandDatasources); + end + else + begin + Stream.Seek(-2, soFromCurrent); + LoadOldVariables; + end; + if (Variables.Count > 0) and (Variables.Items[0].Name <> '') and (Variables.Items[0].Name[1] <> ' ') then + ConvertToNewFormat; +{ if w = $FFFF then + ConvertAliases;} + + Report.Variables.Assign(Variables); + Variables.Free; + FieldAliases.Free; + BandDatasources.Free; + SMemo.Free; +end; + +procedure TfrPageLoadFromStream; +var + i: Integer; + b: Byte; + s: String[6]; + + pgSize, pgWidth, pgHeight: Integer; + pgMargins: TRect; + pgOr: TPrinterOrientation; + pgBin: Integer; + PrintToPrevPage, UseMargins: WordBool; + ColCount, ColGap: Integer; + PageType: TfrPageType; + // dialog properties + BorderStyle: Byte; + Color: TColor; + Left, Top, Width, Height: Integer; + + ReportPage: TfrxReportPage; + DialogPage: TfrxDialogPage; + ColWidth: Extended; +begin + ReportPage := TfrxReportPage.Create(nil); + DialogPage := TfrxDialogPage.Create(nil); + PageType := ptReport; + + with Stream do + begin + { paper size } + Read(i, 4); + if i = -1 then + Read(pgSize, 4) else + pgSize := i; + ReportPage.PaperSize := pgSize; + + { width } + Read(pgWidth, 4); + + { height } + Read(pgHeight, 4); + + { margins } + Read(pgMargins, Sizeof(pgMargins)); + pgMargins.Left := pgMargins.Left * 5 div 18; + pgMargins.Top := pgMargins.Top * 5 div 18; + pgMargins.Right := pgMargins.Right * 5 div 18; + pgMargins.Bottom := pgMargins.Bottom * 5 div 18; + if (pgMargins.Left = 0) and (pgMargins.Top = 0) and + (pgMargins.Right = 0) and (pgMargins.Bottom = 0) then + begin + pgMargins.Left := Round(frxPrinters.Printer.LeftMargin); + pgMargins.Top := Round(frxPrinters.Printer.TopMargin); + pgMargins.Right := Round(frxPrinters.Printer.RightMargin); + pgMargins.Bottom := Round(frxPrinters.Printer.BottomMargin); + end; + ReportPage.LeftMargin := pgMargins.Left; + ReportPage.TopMargin := pgMargins.Top; + ReportPage.RightMargin := pgMargins.Right; + ReportPage.BottomMargin := pgMargins.Bottom; + + { orientation } + Read(b, 1); + pgOr := TPrinterOrientation(b); + ReportPage.Orientation := pgOr; + + ReportPage.PaperWidth := pgWidth / 10; + ReportPage.PaperHeight := pgHeight / 10; + + if frVersion < 23 then + Read(s[1], 6); + + { bin } + pgBin := -1; + if frVersion > 23 then + Read(pgBin, 4); + ReportPage.Bin := pgBin; + ReportPage.BinOtherPages := pgBin; + + { print to prevpage } + Read(PrintToPrevPage, 2); + ReportPage.PrintOnPreviousPage := PrintToPrevPage; + + { not used } + Read(UseMargins, 2); + + { columns } + Read(ColCount, 4); + ReportPage.Columns := ColCount; + + { not used } + Read(ColGap, 4); + + if ColGap <> 0 then + begin + ColGap := Round(ColGap / 18 * 5); + ReportPage.ColumnPositions.Clear; + if ColCount > 0 then + begin + ColWidth := (ReportPage.PaperWidth - ReportPage.LeftMargin - ReportPage.RightMargin + ColGap) / ColCount; + ReportPage.ColumnWidth := ColWidth - ColGap; + while ReportPage.ColumnPositions.Count < ColCount do + ReportPage.ColumnPositions.Add(FloatToStr(ReportPage.ColumnPositions.Count * ColWidth)); + end; + end; + + if frVersion > 23 then + begin + { page type } + Read(PageType, 1); + + { name } + ReportPage.Name := frReadString(Stream); + DialogPage.Name := ReportPage.Name; + + { border style } + Read(BorderStyle, 1); + if BorderStyle = 0 then + BorderStyle := Byte(bsDialog) + else if BorderStyle = 1 then + BorderStyle := Byte(bsSizeable); + DialogPage.BorderStyle := TFormBorderStyle(BorderStyle); + + { caption } + DialogPage.Caption := frReadString(Stream); + + { color } + Read(Color, 4); + DialogPage.Color := Color; + + { left-top-width-height } + Read(Left, 4); + Read(Top, 4); + Read(Width, 4); + Read(Height, 4); + DialogPage.Left := Left; + DialogPage.Top := Top; + DialogPage.Width := Width; + DialogPage.Height := Height; + + { position } + Read(b, 1); + if b <> 0 then + b := Byte(poScreenCenter); + DialogPage.Position := TPosition(b); + + if i = -1 then + begin + Script := TStringList.Create; + frReadMemo(Stream, Script); + end; + end + else + ReportPage.CreateUniqueName; + end; + + if PageType = ptReport then + begin + ReportPage.Parent := Report; + DialogPage.Free; + AddScript(ReportPage, 'OnBeforePrint(Sender: TfrxComponent);'); + end + else + begin + DialogPage.Parent := Report; + ReportPage.Free; + AddScript(DialogPage, 'OnShow(Sender: TfrxComponent);'); + end; +end; + +procedure ReadReportOptions; +var + l: Word; + buf: String; + + ReportComment, ReportName, ReportAuthor : String; + ReportCreateDate, ReportLastChange : TDateTime; + ReportVersionMajor : String; + ReportVersionMinor : String; + ReportVersionRelease : String; + ReportVersionBuild : String; + ReportPasswordProtected : Boolean; + ReportPassword : String; + ReportGeneratorVersion : Byte; + + function HexChar1(Ch : Char) : Byte; + begin + Ch := UpCase(Ch); + if (Ch <= '9') then + Result := Ord(Ch) - Ord('0') + else + Result := Ord(Ch) - Ord('A') + 10; + end; + + function HexToStr(const s : String) : String; + var + Len, i : Integer; + Ch : Byte; + NibbleH, NibbleL : Byte; + begin + Len := Length(s); + SetLength(Result, Len shr 1); + for i := 1 to Len shr 1 do begin + NibbleH := HexChar1(s[i shl 1 - 1]); + NibbleL := HexChar1(s[i shl 1]); + Ch := NibbleH shl 4 or NibbleL; + Result[i] := Chr(Ch); + end; + end; + +begin + Stream.Read(l, 2); + if l>0 then + begin + SetLength(ReportComment, l); + Stream.Read(ReportComment[1], l); + Report.ReportOptions.Description.Text := ReportComment; + end; + Stream.Read(l, 2); + if l>0 then + begin + SetLength(ReportName, l); + Stream.Read(ReportName[1], l); + Report.ReportOptions.Name := ReportName; + end; + Stream.Read(l, 2); + if l>0 then + begin + SetLength(ReportAuthor, l); + Stream.Read(ReportAuthor[1], l); + Report.ReportOptions.Author := ReportAuthor; + end; + Stream.Read(l, 2); + if l>0 then + begin + SetLength(ReportVersionMajor, l); + Stream.Read(ReportVersionMajor[1], l); + Report.ReportOptions.VersionMajor := ReportVersionMajor; + end; + Stream.Read(l, 2); + if l>0 then + begin + SetLength(ReportVersionMinor, l); + Stream.Read(ReportVersionMinor[1], l); + Report.ReportOptions.VersionMinor := ReportVersionMinor; + end; + Stream.Read(l, 2); + if l>0 then + begin + SetLength(ReportVersionRelease, l); + Stream.Read(ReportVersionRelease[1], l); + Report.ReportOptions.VersionRelease := ReportVersionRelease; + end; + Stream.Read(l, 2); + if l>0 then + begin + SetLength(ReportVersionBuild, l); + Stream.Read(ReportVersionBuild[1], l); + Report.ReportOptions.VersionBuild := ReportVersionBuild; + end; + Stream.Read(l, 2); + if l>0 then + begin + SetLength(Buf, l); + Stream.Read(Buf[1], l); + ReportPassword := HexToStr(buf); + Report.ReportOptions.Password := ReportPassword; + end; + Stream.Read(ReportGeneratorVersion, 1); + Stream.Read(ReportPasswordProtected, SizeOf(Boolean)); + Stream.Read(ReportCreateDate, SizeOf(TDateTime)); + Report.ReportOptions.CreateDate := ReportCreateDate; + Stream.Read(ReportLastChange, SizeOf(TDateTime)); + Report.ReportOptions.LastChange := ReportLastChange; +end; + +procedure TfrPagesLoadFromStream; +var + b, b1: Byte; + w: Word; + n: Integer; + s: String; + buf: String[8]; + PrintToDefault: Boolean; +begin + Stream.Read(w{Parent.PrintToDefault}, 2); + PrintToDefault := w <> 0; + Stream.Read(w{Parent.DoublePass}, 2); + Report.EngineOptions.DoublePass := w <> 0; + s := ReadString(Stream); + if (s = #1) or PrintToDefault then + s := 'Default'; + Report.PrintOptions.Printer := s; + + while Stream.Position < Stream.Size do + begin + Stream.Read(b, 1); + if b = $FF then // page info + TfrPageLoadFromStream + else if b = $FE then // data dictionary + TfrDictionaryLoadFromStream + else if b = $FD then // data manager, not supported + begin + break; + end + else if b = $FC then // extra report data + begin + ReadReportOptions; + break; + end + else + begin + if b > Integer(gtAddIn) then + begin + raise Exception.Create('Error in frf file'); + break; + end; + s := ''; n := 0; + try + if b = gtAddIn then + begin + s := ReadString(Stream); + if (AnsiUpperCase(s) = 'TFRBDELOOKUPCONTROL') or + (AnsiUpperCase(s) = 'TFRIBXLOOKUPCONTROL') then + s := 'TfrDBLookupControl'; + if AnsiUpperCase(s) = 'TFRFRAMEDMEMOVIEW' then + b := gtMemo; + end; + + { object's page } + Stream.Read(b1, 1); + Page := Report.Pages[b1]; + if Page is TfrxReportPage then + begin + offsx := Round(-TfrxReportPage(Page).LeftMargin * fr01cm); + offsy := Round(-TfrxReportPage(Page).TopMargin * fr01cm); + end + else + begin + offsx := 0; + offsy := 0; + end; + + if frVersion > 23 then + Stream.Read(n, 4); + + case b of + gtMemo: TfrMemoViewLoadFromStream; + gtPicture: TfrPictureViewLoadFromStream; + gtBand: TfrBandViewLoadFromStream; + gtSubReport: TfrSubreportLoadFromStream; + gtLine: TfrLineViewLoadFromStream; + gtAddIn: + begin + if CompareText(s, 'TfrLabelControl') = 0 then + ReadTfrLabelControl + else if CompareText(s, 'TfrEditControl') = 0 then + ReadTfrEditControl + else if CompareText(s, 'TfrMemoControl') = 0 then + ReadTfrMemoControl + else if CompareText(s, 'TfrButtonControl') = 0 then + ReadTfrButtonControl + else if CompareText(s, 'TfrCheckBoxControl') = 0 then + ReadTfrCheckBoxControl + else if CompareText(s, 'TfrRadioButtonControl') = 0 then + ReadTfrRadioButtonControl + else if CompareText(s, 'TfrListBoxControl') = 0 then + ReadTfrListBoxControl + else if CompareText(s, 'TfrComboBoxControl') = 0 then + ReadTfrComboBoxControl + else if CompareText(s, 'TfrDateEditControl') = 0 then + ReadTfrDateEditControl +{ else if CompareText(s, 'TfrDBLookupControl') = 0 then + ReadTfrDBLookupControl +} + else if CompareText(s, 'TfrBarCodeView') = 0 then + ReadTfrBarCodeView + else if CompareText(s, 'TfrChartView') = 0 then + ReadTfrChartView + else if CompareText(s, 'TfrCheckBoxView') = 0 then + ReadTfrCheckBoxView + else if CompareText(s, 'TfrCrossView') = 0 then + ReadTfrCrossView + else if CompareText(s, 'TfrOLEView') = 0 then + ReadTfrOLEView + else if CompareText(s, 'TfrRichView') = 0 then + ReadTfrRichView + else if CompareText(s, 'TfrRxRichView') = 0 then + ReadTfrRichView + else if CompareText(s, 'TfrRoundRectView') = 0 then + ReadTfrRoundRectView + else if CompareText(s, 'TfrShapeView') = 0 then + ReadTfrShapeView + + else if CompareText(s, 'TfrBDEDatabase') = 0 then + ReadTfrBDEDatabase + else if CompareText(s, 'TfrBDETable') = 0 then + ReadTfrBDETable + else if CompareText(s, 'TfrBDEQuery') = 0 then + ReadTfrBDEQuery + + else if CompareText(s, 'TfrADODatabase') = 0 then + ReadTfrADODatabase + else if CompareText(s, 'TfrADOTable') = 0 then + ReadTfrADOTable + else if CompareText(s, 'TfrADOQuery') = 0 then + ReadTfrADOQuery + + else if CompareText(s, 'TfrIBXDatabase') = 0 then + ReadTfrIBXDatabase + else if CompareText(s, 'TfrIBXTable') = 0 then + ReadTfrIBXTable + else if CompareText(s, 'TfrIBXQuery') = 0 then + ReadTfrIBXQuery + end; + end; + + if AnsiUpperCase(s) = 'TFRFRAMEDMEMOVIEW' then + Stream.Read(buf[1], 8); + if n <> 0 then + Stream.Position := n; + except + if frVersion > 23 then + begin + if n = 0 then + Stream.Read(n, 4); + Stream.Seek(n, soFromBeginning); + end; + end; + end; + end; +end; + +procedure TfrReportLoadFromStream; +begin + Stream.Read(frVersion, 1); + TfrPagesLoadFromStream; +end; + +procedure AdjustBands; +var + i, j: Integer; + FObjects: TList; + + procedure TossObjects(Bnd: TfrxBand); + var + i: Integer; + c: TfrxComponent; + SaveRestrictions: TfrxRestrictions; + begin + if Bnd.Vertical then Exit; + + while Bnd.Objects.Count > 0 do + begin + c := Bnd.Objects[0]; + SaveRestrictions := c.Restrictions; + c.Restrictions := []; + c.Top := c.AbsTop; + c.Restrictions := SaveRestrictions; + c.Parent := Bnd.Parent; + end; + + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if (c is TfrxView) and (c.AbsTop >= Bnd.Top - 1e-4) and (c.AbsTop < Bnd.Top + Bnd.Height + 1e-4) then + begin + SaveRestrictions := c.Restrictions; + c.Restrictions := []; + c.Top := c.AbsTop - Bnd.Top; + c.Restrictions := SaveRestrictions; + c.Parent := Bnd; + if c is TfrxStretcheable then + if (TfrxStretcheable(c).StretchMode = smMaxHeight) and not Bnd.Stretched then + TfrxStretcheable(c).StretchMode := smDontStretch; + end; + end; + end; + +begin + FObjects := TList.Create; + for i := 0 to Report.PagesCount - 1 do + begin + Page := Report.Pages[i]; + FObjects.Clear; + for j := 0 to Page.AllObjects.Count - 1 do + FObjects.Add(Page.AllObjects[j]); + for j := 0 to FObjects.Count - 1 do + if TObject(FObjects[j]) is TfrxBand then + TossObjects(FObjects[j]); + end; + FObjects.Free; +end; + +procedure ConnectDatasets; +var + l: TList; + i: Integer; + c: TfrxComponent; + d: TfrxDataband; + ds: TfrxDataset; + cr: TfrxDBCrossView; + c1: TComponent; + s: String; +begin + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxDataband then + begin + d := l[i]; + + s := d.DatasetName; + if Pos('DialogForm._', s) = 1 then + begin + Delete(s, 1, Length('DialogForm._')); + d.DatasetName := s; + ds := d.DataSet; + end + else + ds := frFindComponent(Report.Owner, d.DatasetName) as TfrxDataset; + + if ds <> nil then + begin + d.Dataset := ds; + if Report.Datasets.Find(ds) = nil then + Report.Datasets.Add(ds); + end; + end; + if c is TfrxDBCrossView then + begin + cr := l[i]; + c1 := frFindComponent(Report.Owner, cr.DatasetName); + if c1 is TDataSet then + begin + ds := FindTfrxDataset(TDataSet(c1)); + if ds <> nil then + begin + cr.Dataset := ds; + if Report.Datasets.Find(ds) = nil then + Report.Datasets.Add(ds); + end; + end; + end; + end; +end; + +function ConvertDatasetAndField(s: String): String; +var + ds: TDataset; + ds1: TfrxDataset; + fld: String; +begin + ds := nil; + fld := ''; + + if Pos(AnsiUppercase('DialogForm.'), AnsiUppercase(s)) = 1 then + s := Copy(s, Length('DialogForm.') + 1, 255); + + Result := s; + frGetDatasetAndField(s, ds, fld); + if (ds <> nil) and (fld <> '') then + begin + ds1 := FindTfrxDataset(ds); + if ds1 <> nil then + Result := ds1.UserName + '."' + fld + '"'; + end; +end; + +procedure ConvertVariables; +var + i: Integer; + v: TfrxVariable; +begin + for i := 0 to Report.Variables.Count - 1 do + begin + v := Report.Variables.Items[i]; + v.Value := ConvertDatasetAndField(v.Value); + end; +end; + +procedure CheckCrosses; +var + l, l1: TList; + i, j: Integer; + c: TfrxComponent; + cr: TfrxDBCrossView; + v: TfrxMemoView; + + procedure AssignMemo(m, m1: TfrxCustomMemoView); + var + s: String; + begin + m.Visible := True; + m.StretchMode := smDontStretch; + s := m.Highlight.Condition; + ExpandVariables1(s); + m.Highlight.Condition := s; + m1.Assign(m); + if l1.IndexOf(m) = -1 then + l1.Add(m); + end; + +begin + l := Report.AllObjects; + l1 := TList.Create; + + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxDBCrossView then + begin + cr := l[i]; + v := TfrxMemoView(Report.FindObject('ColumnHeaderMemo' + cr.Name)); + if v <> nil then + begin + for j := 0 to cr.ColumnLevels - 1 do + AssignMemo(v, cr.ColumnMemos[j]); + end; + v := TfrxMemoView(Report.FindObject('RowHeaderMemo' + cr.Name)); + if v <> nil then + begin + for j := 0 to cr.RowLevels - 1 do + AssignMemo(v, cr.RowMemos[j]); + end; + v := TfrxMemoView(Report.FindObject('ColumnTotalMemo' + cr.Name)); + if v <> nil then + begin + for j := 0 to cr.ColumnLevels - 1 do + AssignMemo(v, cr.ColumnTotalMemos[j]); + end; + v := TfrxMemoView(Report.FindObject('RowTotalMemo' + cr.Name)); + if v <> nil then + begin + for j := 0 to cr.RowLevels - 1 do + AssignMemo(v, cr.RowTotalMemos[j]); + end; + v := TfrxMemoView(Report.FindObject('GrandColumnTotalMemo' + cr.Name)); + if v <> nil then + begin + AssignMemo(v, cr.ColumnTotalMemos[0]); + end; + v := TfrxMemoView(Report.FindObject('GrandRowTotalMemo' + cr.Name)); + if v <> nil then + begin + AssignMemo(v, cr.RowTotalMemos[0]); + end; + v := TfrxMemoView(Report.FindObject('CellMemo' + cr.Name)); + if v <> nil then + begin + if not cr.Border then + v.Frame.Typ := [ftLeft, ftRight]; + for j := 0 to cr.CellLevels - 1 do + begin + AssignMemo(v, cr.CellMemos[j]); + if j <> 0 then + cr.CellMemos[j].Frame.Typ := cr.CellMemos[j].Frame.Typ - [ftTop]; + if j <> cr.CellLevels - 1 then + cr.CellMemos[j].Frame.Typ := cr.CellMemos[j].Frame.Typ - [ftBottom]; + end; + cr.Border := True; + end; + end; + end; + + for i := 0 to l1.Count - 1 do + TObject(l1[i]).Free; + l1.Free; +end; + +procedure CheckCharts; +var + l: TList; + i: Integer; + c, c1: TfrxComponent; + ch: TfrxChartView; + dser: TfrxSeriesItem; +begin + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxChartView then + begin + ch := l[i]; + dser := ch.SeriesData[0]; + c1 := Report.FindObject(dser.XSource) as TfrxComponent; + if (c1 is TfrxMemoView) and (c1.Parent is TfrxDataBand) then + begin + dser.Databand := TfrxDataBand(c1.Parent); + dser.XSource := TfrxMemoView(c1).Text; + c1 := Report.FindObject(dser.YSource) as TfrxComponent; + if c1 is TfrxMemoView then + dser.YSource := TfrxMemoView(c1).Text; + end; + end; + end; +end; + +procedure CheckViews; +var + l: TList; + i: Integer; + c: TfrxComponent; + v: TfrxView; + s: String; + ds: TfrxDataSet; + fld: String; +begin + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxView then + begin + v := l[i]; + if v.DataField <> '' then + if v.DataField[1] = '[' then + begin + s := Copy(v.DataField, 2, Length(v.DataField) - 2); + if Report.Variables.IndexOf(s) <> -1 then + s := Report.Variables[s] + else + s := ConvertDatasetAndField(s); + ds := nil; + fld := ''; + Report.GetDatasetAndField(s, ds, fld); + if (ds <> nil) and (fld <> '') then + begin + v.Dataset := ds; + v.DataField := fld; + end; + end; + end; + end; +end; + +procedure LoadFromFR2Stream(AReport: TfrxReport; AStream: TStream); +begin + Report := AReport; + Stream := AStream; + ClearFixups; + Report.Clear; + Report.ScriptText.Clear; + TfrReportLoadFromStream; + Report.ScriptText.Add('begin'); + Report.ScriptText.Add(''); + Report.ScriptText.Add('end.'); + AdjustBands; + FixupReferences; + ConnectDatasets; + ConvertVariables; + CheckCrosses; + CheckCharts; + CheckViews; +end; + + +initialization + Memo := TStringList.Create; + Script := TStringList.Create; + Fixups := TList.Create; + fsModifyPascalForFR2; + frxFR2EventsNew := TfrxFR2EventsNew.Create; + frxFR2Events.OnGetValue := frxFR2EventsNew.DoGetValue; + frxFR2Events.OnPrepareScript := frxFR2EventsNew.DoPrepareScript; + frxFR2Events.OnLoad := frxFR2EventsNew.DoLoad; + frxFR2Events.OnGetScriptValue := frxFR2EventsNew.DoGetScriptValue; + +finalization + Memo.Free; + Script.Free; + Fixups.Free; + frxFR2EventsNew.Free; + + +end. + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frx4.bpk b/official/4.2/LibD11/frx4.bpk new file mode 100644 index 0000000..39486b7 --- /dev/null +++ b/official/4.2/LibD11/frx4.bpk @@ -0,0 +1,189 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = frx4.bpl +OBJFILES = frxReg.obj frx4.obj frxrcClass.obj frxrcDesgn.obj frxrcInsp.obj +RESFILES = frx4.res frxReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +LIBRARIES = +SPARELIBS = VCL40.lib +PACKAGES = vcl40.bpi vclsmp40.bpi vcljpg40.bpi vclx40.bpi fs4.bpi fqb40.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release;..\FastScript;..\FastQB +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -D"FastReport 4.0 Components" -aa \ + -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName=Fast Reports Inc. +FileDescription=FastReport +FileVersion=4.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=4.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frx4.cpp b/official/4.2/LibD11/frx4.cpp new file mode 100644 index 0000000..0629ae2 --- /dev/null +++ b/official/4.2/LibD11/frx4.cpp @@ -0,0 +1,25 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frx4.res"); +USEPACKAGE("vcl40.bpi"); +USEUNIT("frxReg.pas"); +USEUNIT("frxrcClass.pas"); +USEUNIT("frxrcDesgn.pas"); +USEUNIT("frxrcInsp.pas"); +USERES("frxReg.dcr"); +USEPACKAGE("vclsmp40.bpi"); +USEPACKAGE("vclx40.bpi"); +USEPACKAGE("vcljpg40.bpi"); +USEPACKAGE("fs4.bpi"); +USEPACKAGE("fqb40.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frx4.dpk b/official/4.2/LibD11/frx4.dpk new file mode 100644 index 0000000..f4d5e6f --- /dev/null +++ b/official/4.2/LibD11/frx4.dpk @@ -0,0 +1,146 @@ +// Package file for Delphi 4 + +package frx4; + +{$I frx.inc} +//{$I frxReg.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, +{$IFDEF JPEG} + VCLJPG40, +{$ENDIF} +{$IFDEF QBUILDER} + fqb40, +{$ENDIF} + fs4; + +contains + { core files } + frxAggregate in 'frxAggregate.pas', + frxChm in 'frxChm.pas', + frxClass in 'frxClass.pas', + frxClassRTTI in 'frxClassRTTI.pas', + frxCtrls in 'frxCtrls.pas', + frxDialogForm in 'frxDialogForm.pas', + frxDMPClass in 'frxDMPClass.pas', + frxDMPExport in 'frxDMPExport.pas', + frxDock in 'frxDock.pas', + frxEngine in 'frxEngine.pas', + frxGraphicUtils in 'frxGraphicUtils.pas', + frxPassw in 'frxPassw.pas', + frxPictureCache in 'frxPictureCache.pas', + frxPreview in 'frxPreview.pas', + frxPreviewPages in 'frxPreviewPages.pas', + frxPreviewPageSettings in 'frxPreviewPageSettings.pas', + frxPrintDialog in 'frxPrintDialog.pas', + frxPrinter in 'frxPrinter.pas', + frxProgress in 'frxProgress.pas', + frxrcClass in 'frxrcClass.pas', + frxRes in 'frxRes.pas', + frxSearchDialog in 'frxSearchDialog.pas', + frxUnicodeUtils in 'frxUnicodeUtils.pas', + frxUtils in 'frxUtils.pas', + frxVariables in 'frxVariables.pas', + frxXML in 'frxXML.pas', + frxXMLSerializer in 'frxXMLSerializer.pas', + + { designer } + frxAbout in 'frxAbout.pas', + frxCodeUtils in 'frxCodeUtils.pas', + frxConnEditor in 'frxConnEditor.pas', + frxCustomEditors in 'frxCustomEditors.pas', + frxDataTree in 'frxDataTree.pas', + frxDesgn in 'frxDesgn.pas', + frxDesgnCtrls in 'frxDesgnCtrls.pas', + frxDesgnEditors in 'frxDesgnEditors.pas', + frxDesgnWorkspace in 'frxDesgnWorkspace.pas', + frxDesgnWorkspace1 in 'frxDesgnWorkspace1.pas', + frxDsgnIntf in 'frxDsgnIntf.pas', + frxEditAliases in 'frxEditAliases.pas', + frxEditDataBand in 'frxEditDataBand.pas', + frxEditExpr in 'frxEditExpr.pas', + frxEditFormat in 'frxEditFormat.pas', + frxEditFrame in 'frxEditFrame.pas', + frxEditGroup in 'frxEditGroup.pas', + frxEditHighlight in 'frxEditHighlight.pas', + frxEditMemo in 'frxEditMemo.pas', + frxEditOptions in 'frxEditOptions.pas', + frxEditPage in 'frxEditPage.pas', + frxEditPicture in 'frxEditPicture.pas', + frxEditReport in 'frxEditReport.pas', + frxEditReportData in 'frxEditReportData.pas', + frxEditStrings in 'frxEditStrings.pas', + frxEditStyle in 'frxEditStyle.pas', + frxEditSysMemo in 'frxEditSysMemo.pas', + frxEditTabOrder in 'frxEditTabOrder.pas', + frxEditVar in 'frxEditVar.pas', + frxEvaluateForm in 'frxEvaluateForm.pas', + frxInheritError in 'frxInheritError.pas', + frxInsp in 'frxInsp.pas', + frxNewItem in 'frxNewItem.pas', + frxPopupForm in 'frxPopupForm.pas', + frxrcDesgn in 'frxrcDesgn.pas', + frxrcInsp in 'frxrcInsp.pas', + frxReportTree in 'frxReportTree.pas', + frxStdWizard in 'frxStdWizard.pas', + frxSynMemo in 'frxSynMemo.pas', + frxUnicodeCtrls in 'frxUnicodeCtrls.pas', + frxWatchForm in 'frxWatchForm.pas', + + { add-in objects } + frxBarcod in 'frxBarcod.pas', + frxBarcode in 'frxBarcode.pas', + frxBarcodeEditor in 'frxBarcodeEditor.pas', + frxBarcodeRTTI in 'frxBarcodeRTTI.pas', + frxChBox in 'frxChBox.pas', + frxChBoxRTTI in 'frxChBoxRTTI.pas', + frxCross in 'frxCross.pas', + frxCrossEditor in 'frxCrossEditor.pas', + frxCrossRTTI in 'frxCrossRTTI.pas', +{$IFNDEF FR_VER_BASIC} + frxDCtrl in 'frxDCtrl.pas', + frxDCtrlRTTI in 'frxDCtrlRTTI.pas', +{$ENDIF} + frxGradient in 'frxGradient.pas', + frxGradientRTTI in 'frxGradientRTTI.pas', + frxOLE in 'frxOLE.pas', + frxOLEEditor in 'frxOLEEditor.pas', + frxOLERTTI in 'frxOLERTTI.pas', + frxRich in 'frxRich.pas', + frxRichEdit in 'frxRichEdit.pas', + frxRichEditor in 'frxRichEditor.pas', + frxRichRTTI in 'frxRichRTTI.pas', + + frxGZip in 'frxGZip.pas', + frxZLib in 'frxZLib.pas', + frxCrypt in 'frxCrypt.pas', + rc_AlgRef in 'rc_AlgRef.pas', + rc_ApiRef in 'rc_ApiRef.pas', + rc_Crypt in 'rc_Crypt.pas'; + +end. diff --git a/official/4.2/LibD11/frx4.res b/official/4.2/LibD11/frx4.res new file mode 100644 index 0000000..eb2597a Binary files /dev/null and b/official/4.2/LibD11/frx4.res differ diff --git a/official/4.2/LibD11/frx5.bpk b/official/4.2/LibD11/frx5.bpk new file mode 100644 index 0000000..48c81ef --- /dev/null +++ b/official/4.2/LibD11/frx5.bpk @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName=Fast Reports Inc. +FileDescription=FastReport +FileVersion=4.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=4.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + + \ No newline at end of file diff --git a/official/4.2/LibD11/frx5.cpp b/official/4.2/LibD11/frx5.cpp new file mode 100644 index 0000000..268c926 --- /dev/null +++ b/official/4.2/LibD11/frx5.cpp @@ -0,0 +1,25 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frx5.res"); +USEUNIT("frxReg.pas"); +USEUNIT("frxrcClass.pas"); +USEUNIT("frxrcDesgn.pas"); +USEUNIT("frxrcInsp.pas"); +USERES("frxReg.dcr"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vclsmp50.bpi"); +USEPACKAGE("vclx50.bpi"); +USEPACKAGE("vcljpg50.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("fqb50.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frx5.dpk b/official/4.2/LibD11/frx5.dpk new file mode 100644 index 0000000..74a6f78 --- /dev/null +++ b/official/4.2/LibD11/frx5.dpk @@ -0,0 +1,146 @@ +// Package file for Delphi 5 + +package frx5; + +{$I frx.inc} +//{$I frxReg.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, +{$IFDEF JPEG} + VCLJPG50, +{$ENDIF} +{$IFDEF QBUILDER} + fqb50, +{$ENDIF} + fs5; + +contains + { core files } + frxAggregate in 'frxAggregate.pas', + frxChm in 'frxChm.pas', + frxClass in 'frxClass.pas', + frxClassRTTI in 'frxClassRTTI.pas', + frxCtrls in 'frxCtrls.pas', + frxDialogForm in 'frxDialogForm.pas', + frxDMPClass in 'frxDMPClass.pas', + frxDMPExport in 'frxDMPExport.pas', + frxDock in 'frxDock.pas', + frxEngine in 'frxEngine.pas', + frxGraphicUtils in 'frxGraphicUtils.pas', + frxPassw in 'frxPassw.pas', + frxPictureCache in 'frxPictureCache.pas', + frxPreview in 'frxPreview.pas', + frxPreviewPages in 'frxPreviewPages.pas', + frxPreviewPageSettings in 'frxPreviewPageSettings.pas', + frxPrintDialog in 'frxPrintDialog.pas', + frxPrinter in 'frxPrinter.pas', + frxProgress in 'frxProgress.pas', + frxrcClass in 'frxrcClass.pas', + frxRes in 'frxRes.pas', + frxSearchDialog in 'frxSearchDialog.pas', + frxUnicodeUtils in 'frxUnicodeUtils.pas', + frxUtils in 'frxUtils.pas', + frxVariables in 'frxVariables.pas', + frxXML in 'frxXML.pas', + frxXMLSerializer in 'frxXMLSerializer.pas', + + { designer } + frxAbout in 'frxAbout.pas', + frxCodeUtils in 'frxCodeUtils.pas', + frxConnEditor in 'frxConnEditor.pas', + frxCustomEditors in 'frxCustomEditors.pas', + frxDataTree in 'frxDataTree.pas', + frxDesgn in 'frxDesgn.pas', + frxDesgnCtrls in 'frxDesgnCtrls.pas', + frxDesgnEditors in 'frxDesgnEditors.pas', + frxDesgnWorkspace in 'frxDesgnWorkspace.pas', + frxDesgnWorkspace1 in 'frxDesgnWorkspace1.pas', + frxDsgnIntf in 'frxDsgnIntf.pas', + frxEditAliases in 'frxEditAliases.pas', + frxEditDataBand in 'frxEditDataBand.pas', + frxEditExpr in 'frxEditExpr.pas', + frxEditFormat in 'frxEditFormat.pas', + frxEditFrame in 'frxEditFrame.pas', + frxEditGroup in 'frxEditGroup.pas', + frxEditHighlight in 'frxEditHighlight.pas', + frxEditMemo in 'frxEditMemo.pas', + frxEditOptions in 'frxEditOptions.pas', + frxEditPage in 'frxEditPage.pas', + frxEditPicture in 'frxEditPicture.pas', + frxEditReport in 'frxEditReport.pas', + frxEditReportData in 'frxEditReportData.pas', + frxEditStrings in 'frxEditStrings.pas', + frxEditStyle in 'frxEditStyle.pas', + frxEditSysMemo in 'frxEditSysMemo.pas', + frxEditTabOrder in 'frxEditTabOrder.pas', + frxEditVar in 'frxEditVar.pas', + frxEvaluateForm in 'frxEvaluateForm.pas', + frxInheritError in 'frxInheritError.pas', + frxInsp in 'frxInsp.pas', + frxNewItem in 'frxNewItem.pas', + frxPopupForm in 'frxPopupForm.pas', + frxrcDesgn in 'frxrcDesgn.pas', + frxrcInsp in 'frxrcInsp.pas', + frxReportTree in 'frxReportTree.pas', + frxStdWizard in 'frxStdWizard.pas', + frxSynMemo in 'frxSynMemo.pas', + frxUnicodeCtrls in 'frxUnicodeCtrls.pas', + frxWatchForm in 'frxWatchForm.pas', + + { add-in objects } + frxBarcod in 'frxBarcod.pas', + frxBarcode in 'frxBarcode.pas', + frxBarcodeEditor in 'frxBarcodeEditor.pas', + frxBarcodeRTTI in 'frxBarcodeRTTI.pas', + frxChBox in 'frxChBox.pas', + frxChBoxRTTI in 'frxChBoxRTTI.pas', + frxCross in 'frxCross.pas', + frxCrossEditor in 'frxCrossEditor.pas', + frxCrossRTTI in 'frxCrossRTTI.pas', +{$IFNDEF FR_VER_BASIC} + frxDCtrl in 'frxDCtrl.pas', + frxDCtrlRTTI in 'frxDCtrlRTTI.pas', +{$ENDIF} + frxGradient in 'frxGradient.pas', + frxGradientRTTI in 'frxGradientRTTI.pas', + frxOLE in 'frxOLE.pas', + frxOLEEditor in 'frxOLEEditor.pas', + frxOLERTTI in 'frxOLERTTI.pas', + frxRich in 'frxRich.pas', + frxRichEdit in 'frxRichEdit.pas', + frxRichEditor in 'frxRichEditor.pas', + frxRichRTTI in 'frxRichRTTI.pas', + + frxGZip in 'frxGZip.pas', + frxZLib in 'frxZLib.pas', + frxCrypt in 'frxCrypt.pas', + rc_AlgRef in 'rc_AlgRef.pas', + rc_ApiRef in 'rc_ApiRef.pas', + rc_Crypt in 'rc_Crypt.pas'; + +end. diff --git a/official/4.2/LibD11/frx5.res b/official/4.2/LibD11/frx5.res new file mode 100644 index 0000000..eb2597a Binary files /dev/null and b/official/4.2/LibD11/frx5.res differ diff --git a/official/4.2/LibD11/frx6.bpk b/official/4.2/LibD11/frx6.bpk new file mode 100644 index 0000000..b97938f --- /dev/null +++ b/official/4.2/LibD11/frx6.bpk @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName=Fast Reports Inc. +FileDescription=FastReport +FileVersion=4.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=4.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frx6.cpp b/official/4.2/LibD11/frx6.cpp new file mode 100644 index 0000000..48ce892 --- /dev/null +++ b/official/4.2/LibD11/frx6.cpp @@ -0,0 +1,18 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frx6.dpk b/official/4.2/LibD11/frx6.dpk new file mode 100644 index 0000000..cf93f99 --- /dev/null +++ b/official/4.2/LibD11/frx6.dpk @@ -0,0 +1,146 @@ +// Package file for Delphi 6 + +package frx6; + +{$I frx.inc} +//{$I frxReg.inc} + +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF JPEG} + VCLJPG, +{$ENDIF} +{$IFDEF QBUILDER} + fqb60, +{$ENDIF} + fs6; + +contains + { core files } + frxAggregate in 'frxAggregate.pas', + frxChm in 'frxChm.pas', + frxClass in 'frxClass.pas', + frxClassRTTI in 'frxClassRTTI.pas', + frxCtrls in 'frxCtrls.pas', + frxDialogForm in 'frxDialogForm.pas', + frxDMPClass in 'frxDMPClass.pas', + frxDMPExport in 'frxDMPExport.pas', + frxDock in 'frxDock.pas', + frxEngine in 'frxEngine.pas', + frxGraphicUtils in 'frxGraphicUtils.pas', + frxPassw in 'frxPassw.pas', + frxPictureCache in 'frxPictureCache.pas', + frxPreview in 'frxPreview.pas', + frxPreviewPages in 'frxPreviewPages.pas', + frxPreviewPageSettings in 'frxPreviewPageSettings.pas', + frxPrintDialog in 'frxPrintDialog.pas', + frxPrinter in 'frxPrinter.pas', + frxProgress in 'frxProgress.pas', + frxrcClass in 'frxrcClass.pas', + frxRes in 'frxRes.pas', + frxSearchDialog in 'frxSearchDialog.pas', + frxUnicodeUtils in 'frxUnicodeUtils.pas', + frxUtils in 'frxUtils.pas', + frxVariables in 'frxVariables.pas', + frxXML in 'frxXML.pas', + frxXMLSerializer in 'frxXMLSerializer.pas', + + { designer } + frxAbout in 'frxAbout.pas', + frxCodeUtils in 'frxCodeUtils.pas', + frxConnEditor in 'frxConnEditor.pas', + frxCustomEditors in 'frxCustomEditors.pas', + frxDataTree in 'frxDataTree.pas', + frxDesgn in 'frxDesgn.pas', + frxDesgnCtrls in 'frxDesgnCtrls.pas', + frxDesgnEditors in 'frxDesgnEditors.pas', + frxDesgnWorkspace in 'frxDesgnWorkspace.pas', + frxDesgnWorkspace1 in 'frxDesgnWorkspace1.pas', + frxDsgnIntf in 'frxDsgnIntf.pas', + frxEditAliases in 'frxEditAliases.pas', + frxEditDataBand in 'frxEditDataBand.pas', + frxEditExpr in 'frxEditExpr.pas', + frxEditFormat in 'frxEditFormat.pas', + frxEditFrame in 'frxEditFrame.pas', + frxEditGroup in 'frxEditGroup.pas', + frxEditHighlight in 'frxEditHighlight.pas', + frxEditMemo in 'frxEditMemo.pas', + frxEditOptions in 'frxEditOptions.pas', + frxEditPage in 'frxEditPage.pas', + frxEditPicture in 'frxEditPicture.pas', + frxEditReport in 'frxEditReport.pas', + frxEditReportData in 'frxEditReportData.pas', + frxEditStrings in 'frxEditStrings.pas', + frxEditStyle in 'frxEditStyle.pas', + frxEditSysMemo in 'frxEditSysMemo.pas', + frxEditTabOrder in 'frxEditTabOrder.pas', + frxEditVar in 'frxEditVar.pas', + frxEvaluateForm in 'frxEvaluateForm.pas', + frxInheritError in 'frxInheritError.pas', + frxInsp in 'frxInsp.pas', + frxNewItem in 'frxNewItem.pas', + frxPopupForm in 'frxPopupForm.pas', + frxrcDesgn in 'frxrcDesgn.pas', + frxrcInsp in 'frxrcInsp.pas', + frxReportTree in 'frxReportTree.pas', + frxStdWizard in 'frxStdWizard.pas', + frxSynMemo in 'frxSynMemo.pas', + frxUnicodeCtrls in 'frxUnicodeCtrls.pas', + frxWatchForm in 'frxWatchForm.pas', + + { add-in objects } + frxBarcod in 'frxBarcod.pas', + frxBarcode in 'frxBarcode.pas', + frxBarcodeEditor in 'frxBarcodeEditor.pas', + frxBarcodeRTTI in 'frxBarcodeRTTI.pas', + frxChBox in 'frxChBox.pas', + frxChBoxRTTI in 'frxChBoxRTTI.pas', + frxCross in 'frxCross.pas', + frxCrossEditor in 'frxCrossEditor.pas', + frxCrossRTTI in 'frxCrossRTTI.pas', +{$IFNDEF FR_VER_BASIC} + frxDCtrl in 'frxDCtrl.pas', + frxDCtrlRTTI in 'frxDCtrlRTTI.pas', +{$ENDIF} + frxGradient in 'frxGradient.pas', + frxGradientRTTI in 'frxGradientRTTI.pas', + frxOLE in 'frxOLE.pas', + frxOLEEditor in 'frxOLEEditor.pas', + frxOLERTTI in 'frxOLERTTI.pas', + frxRich in 'frxRich.pas', + frxRichEdit in 'frxRichEdit.pas', + frxRichEditor in 'frxRichEditor.pas', + frxRichRTTI in 'frxRichRTTI.pas', + + frxGZip in 'frxGZip.pas', + frxZLib in 'frxZLib.pas', + frxCrypt in 'frxCrypt.pas', + rc_AlgRef in 'rc_AlgRef.pas', + rc_ApiRef in 'rc_ApiRef.pas', + rc_Crypt in 'rc_Crypt.pas'; + +end. diff --git a/official/4.2/LibD11/frx6.res b/official/4.2/LibD11/frx6.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frx6.res differ diff --git a/official/4.2/LibD11/frx7.dpk b/official/4.2/LibD11/frx7.dpk new file mode 100644 index 0000000..a800a50 --- /dev/null +++ b/official/4.2/LibD11/frx7.dpk @@ -0,0 +1,146 @@ +// Package file for Delphi 7 + +package frx7; + +{$I frx.inc} +//{$I frxReg.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF JPEG} + VCLJPG, +{$ENDIF} +{$IFDEF QBUILDER} + fqb70, +{$ENDIF} + fs7; + +contains + { core files } + frxAggregate in 'frxAggregate.pas', + frxChm in 'frxChm.pas', + frxClass in 'frxClass.pas', + frxClassRTTI in 'frxClassRTTI.pas', + frxCtrls in 'frxCtrls.pas', + frxDialogForm in 'frxDialogForm.pas', + frxDMPClass in 'frxDMPClass.pas', + frxDMPExport in 'frxDMPExport.pas', + frxDock in 'frxDock.pas', + frxEngine in 'frxEngine.pas', + frxGraphicUtils in 'frxGraphicUtils.pas', + frxPassw in 'frxPassw.pas', + frxPictureCache in 'frxPictureCache.pas', + frxPreview in 'frxPreview.pas', + frxPreviewPages in 'frxPreviewPages.pas', + frxPreviewPageSettings in 'frxPreviewPageSettings.pas', + frxPrintDialog in 'frxPrintDialog.pas', + frxPrinter in 'frxPrinter.pas', + frxProgress in 'frxProgress.pas', + frxrcClass in 'frxrcClass.pas', + frxRes in 'frxRes.pas', + frxSearchDialog in 'frxSearchDialog.pas', + frxUnicodeUtils in 'frxUnicodeUtils.pas', + frxUtils in 'frxUtils.pas', + frxVariables in 'frxVariables.pas', + frxXML in 'frxXML.pas', + frxXMLSerializer in 'frxXMLSerializer.pas', + + { designer } + frxAbout in 'frxAbout.pas', + frxCodeUtils in 'frxCodeUtils.pas', + frxConnEditor in 'frxConnEditor.pas', + frxCustomEditors in 'frxCustomEditors.pas', + frxDataTree in 'frxDataTree.pas', + frxDesgn in 'frxDesgn.pas', + frxDesgnCtrls in 'frxDesgnCtrls.pas', + frxDesgnEditors in 'frxDesgnEditors.pas', + frxDesgnWorkspace in 'frxDesgnWorkspace.pas', + frxDesgnWorkspace1 in 'frxDesgnWorkspace1.pas', + frxDsgnIntf in 'frxDsgnIntf.pas', + frxEditAliases in 'frxEditAliases.pas', + frxEditDataBand in 'frxEditDataBand.pas', + frxEditExpr in 'frxEditExpr.pas', + frxEditFormat in 'frxEditFormat.pas', + frxEditFrame in 'frxEditFrame.pas', + frxEditGroup in 'frxEditGroup.pas', + frxEditHighlight in 'frxEditHighlight.pas', + frxEditMemo in 'frxEditMemo.pas', + frxEditOptions in 'frxEditOptions.pas', + frxEditPage in 'frxEditPage.pas', + frxEditPicture in 'frxEditPicture.pas', + frxEditReport in 'frxEditReport.pas', + frxEditReportData in 'frxEditReportData.pas', + frxEditStrings in 'frxEditStrings.pas', + frxEditStyle in 'frxEditStyle.pas', + frxEditSysMemo in 'frxEditSysMemo.pas', + frxEditTabOrder in 'frxEditTabOrder.pas', + frxEditVar in 'frxEditVar.pas', + frxEvaluateForm in 'frxEvaluateForm.pas', + frxInheritError in 'frxInheritError.pas', + frxInsp in 'frxInsp.pas', + frxNewItem in 'frxNewItem.pas', + frxPopupForm in 'frxPopupForm.pas', + frxrcDesgn in 'frxrcDesgn.pas', + frxrcInsp in 'frxrcInsp.pas', + frxReportTree in 'frxReportTree.pas', + frxStdWizard in 'frxStdWizard.pas', + frxSynMemo in 'frxSynMemo.pas', + frxUnicodeCtrls in 'frxUnicodeCtrls.pas', + frxWatchForm in 'frxWatchForm.pas', + + { add-in objects } + frxBarcod in 'frxBarcod.pas', + frxBarcode in 'frxBarcode.pas', + frxBarcodeEditor in 'frxBarcodeEditor.pas', + frxBarcodeRTTI in 'frxBarcodeRTTI.pas', + frxChBox in 'frxChBox.pas', + frxChBoxRTTI in 'frxChBoxRTTI.pas', + frxCross in 'frxCross.pas', + frxCrossEditor in 'frxCrossEditor.pas', + frxCrossRTTI in 'frxCrossRTTI.pas', +{$IFNDEF FR_VER_BASIC} + frxDCtrl in 'frxDCtrl.pas', + frxDCtrlRTTI in 'frxDCtrlRTTI.pas', +{$ENDIF} + frxGradient in 'frxGradient.pas', + frxGradientRTTI in 'frxGradientRTTI.pas', + frxOLE in 'frxOLE.pas', + frxOLEEditor in 'frxOLEEditor.pas', + frxOLERTTI in 'frxOLERTTI.pas', + frxRich in 'frxRich.pas', + frxRichEdit in 'frxRichEdit.pas', + frxRichEditor in 'frxRichEditor.pas', + frxRichRTTI in 'frxRichRTTI.pas', + + frxGZip in 'frxGZip.pas', + frxZLib in 'frxZLib.pas', + frxCrypt in 'frxCrypt.pas', + rc_AlgRef in 'rc_AlgRef.pas', + rc_ApiRef in 'rc_ApiRef.pas', + rc_Crypt in 'rc_Crypt.pas'; + +end. diff --git a/official/4.2/LibD11/frx9.bdsproj b/official/4.2/LibD11/frx9.bdsproj new file mode 100644 index 0000000..46e6881 --- /dev/null +++ b/official/4.2/LibD11/frx9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frx9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frx9.dpk b/official/4.2/LibD11/frx9.dpk new file mode 100644 index 0000000..e1a9767 --- /dev/null +++ b/official/4.2/LibD11/frx9.dpk @@ -0,0 +1,146 @@ +// Package file for Delphi 2005 + +package frx9; + +{$I frx.inc} +//{$I frxReg.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF JPEG} + VCLJPG, +{$ENDIF} +{$IFDEF QBUILDER} + fqb90, +{$ENDIF} + fs9; + +contains + { core files } + frxAggregate in 'frxAggregate.pas', + frxChm in 'frxChm.pas', + frxClass in 'frxClass.pas', + frxClassRTTI in 'frxClassRTTI.pas', + frxCtrls in 'frxCtrls.pas', + frxDialogForm in 'frxDialogForm.pas', + frxDMPClass in 'frxDMPClass.pas', + frxDMPExport in 'frxDMPExport.pas', + frxDock in 'frxDock.pas', + frxEngine in 'frxEngine.pas', + frxGraphicUtils in 'frxGraphicUtils.pas', + frxPassw in 'frxPassw.pas', + frxPictureCache in 'frxPictureCache.pas', + frxPreview in 'frxPreview.pas', + frxPreviewPages in 'frxPreviewPages.pas', + frxPreviewPageSettings in 'frxPreviewPageSettings.pas', + frxPrintDialog in 'frxPrintDialog.pas', + frxPrinter in 'frxPrinter.pas', + frxProgress in 'frxProgress.pas', + frxrcClass in 'frxrcClass.pas', + frxRes in 'frxRes.pas', + frxSearchDialog in 'frxSearchDialog.pas', + frxUnicodeUtils in 'frxUnicodeUtils.pas', + frxUtils in 'frxUtils.pas', + frxVariables in 'frxVariables.pas', + frxXML in 'frxXML.pas', + frxXMLSerializer in 'frxXMLSerializer.pas', + + { designer } + frxAbout in 'frxAbout.pas', + frxCodeUtils in 'frxCodeUtils.pas', + frxConnEditor in 'frxConnEditor.pas', + frxCustomEditors in 'frxCustomEditors.pas', + frxDataTree in 'frxDataTree.pas', + frxDesgn in 'frxDesgn.pas', + frxDesgnCtrls in 'frxDesgnCtrls.pas', + frxDesgnEditors in 'frxDesgnEditors.pas', + frxDesgnWorkspace in 'frxDesgnWorkspace.pas', + frxDesgnWorkspace1 in 'frxDesgnWorkspace1.pas', + frxDsgnIntf in 'frxDsgnIntf.pas', + frxEditAliases in 'frxEditAliases.pas', + frxEditDataBand in 'frxEditDataBand.pas', + frxEditExpr in 'frxEditExpr.pas', + frxEditFormat in 'frxEditFormat.pas', + frxEditFrame in 'frxEditFrame.pas', + frxEditGroup in 'frxEditGroup.pas', + frxEditHighlight in 'frxEditHighlight.pas', + frxEditMemo in 'frxEditMemo.pas', + frxEditOptions in 'frxEditOptions.pas', + frxEditPage in 'frxEditPage.pas', + frxEditPicture in 'frxEditPicture.pas', + frxEditReport in 'frxEditReport.pas', + frxEditReportData in 'frxEditReportData.pas', + frxEditStrings in 'frxEditStrings.pas', + frxEditStyle in 'frxEditStyle.pas', + frxEditSysMemo in 'frxEditSysMemo.pas', + frxEditTabOrder in 'frxEditTabOrder.pas', + frxEditVar in 'frxEditVar.pas', + frxEvaluateForm in 'frxEvaluateForm.pas', + frxInheritError in 'frxInheritError.pas', + frxInsp in 'frxInsp.pas', + frxNewItem in 'frxNewItem.pas', + frxPopupForm in 'frxPopupForm.pas', + frxrcDesgn in 'frxrcDesgn.pas', + frxrcInsp in 'frxrcInsp.pas', + frxReportTree in 'frxReportTree.pas', + frxStdWizard in 'frxStdWizard.pas', + frxSynMemo in 'frxSynMemo.pas', + frxUnicodeCtrls in 'frxUnicodeCtrls.pas', + frxWatchForm in 'frxWatchForm.pas', + + { add-in objects } + frxBarcod in 'frxBarcod.pas', + frxBarcode in 'frxBarcode.pas', + frxBarcodeEditor in 'frxBarcodeEditor.pas', + frxBarcodeRTTI in 'frxBarcodeRTTI.pas', + frxChBox in 'frxChBox.pas', + frxChBoxRTTI in 'frxChBoxRTTI.pas', + frxCross in 'frxCross.pas', + frxCrossEditor in 'frxCrossEditor.pas', + frxCrossRTTI in 'frxCrossRTTI.pas', +{$IFNDEF FR_VER_BASIC} + frxDCtrl in 'frxDCtrl.pas', + frxDCtrlRTTI in 'frxDCtrlRTTI.pas', +{$ENDIF} + frxGradient in 'frxGradient.pas', + frxGradientRTTI in 'frxGradientRTTI.pas', + frxOLE in 'frxOLE.pas', + frxOLEEditor in 'frxOLEEditor.pas', + frxOLERTTI in 'frxOLERTTI.pas', + frxRich in 'frxRich.pas', + frxRichEdit in 'frxRichEdit.pas', + frxRichEditor in 'frxRichEditor.pas', + frxRichRTTI in 'frxRichRTTI.pas', + + frxGZip in 'frxGZip.pas', + frxZLib in 'frxZLib.pas', + frxCrypt in 'frxCrypt.pas', + rc_AlgRef in 'rc_AlgRef.pas', + rc_ApiRef in 'rc_ApiRef.pas', + rc_Crypt in 'rc_Crypt.pas'; + +end. diff --git a/official/4.2/LibD11/frxADO10.bdsproj b/official/4.2/LibD11/frxADO10.bdsproj new file mode 100644 index 0000000..61a4b00 --- /dev/null +++ b/official/4.2/LibD11/frxADO10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxADO10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxADO10.dpk b/official/4.2/LibD11/frxADO10.dpk new file mode 100644 index 0000000..905f9e3 --- /dev/null +++ b/official/4.2/LibD11/frxADO10.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2006 + +package frxADO10; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + frx10, + frxDB10, +{$IFDEF QBUILDER} + fqb100, +{$ENDIF} + fs10, + fsADO10; + +contains + frxADOComponents in 'frxADOComponents.pas', + frxADOEditor in 'frxADOEditor.pas', + frxADORTTI in 'frxADORTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxADO11.bdsproj b/official/4.2/LibD11/frxADO11.bdsproj new file mode 100644 index 0000000..3b7c15c --- /dev/null +++ b/official/4.2/LibD11/frxADO11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxADO11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxADO11.dpk b/official/4.2/LibD11/frxADO11.dpk new file mode 100644 index 0000000..e7d1209 --- /dev/null +++ b/official/4.2/LibD11/frxADO11.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2007 + +package frxADO11; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + frx11, + frxDB11, +{$IFDEF QBUILDER} + fqb110, +{$ENDIF} + fs11, + fsADO11; + +contains + frxADOComponents in 'frxADOComponents.pas', + frxADOEditor in 'frxADOEditor.pas', + frxADORTTI in 'frxADORTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxADO5.bpk b/official/4.2/LibD11/frxADO5.bpk new file mode 100644 index 0000000..936b3f0 --- /dev/null +++ b/official/4.2/LibD11/frxADO5.bpk @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxADO5.cpp b/official/4.2/LibD11/frxADO5.cpp new file mode 100644 index 0000000..c41081d --- /dev/null +++ b/official/4.2/LibD11/frxADO5.cpp @@ -0,0 +1,28 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("frxADO5.res"); +USEPACKAGE("vcl50.bpi"); +USEUNIT("frxADOReg.pas"); +USERES("frxADOReg.dcr"); +USEPACKAGE("vcldb50.bpi"); +USEPACKAGE("vclado50.bpi"); +USEPACKAGE("frx5.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("frxDB5.bpi"); +USEPACKAGE("fsADO5.bpi"); +USEPACKAGE("fqb50.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxADO5.dpk b/official/4.2/LibD11/frxADO5.dpk new file mode 100644 index 0000000..cdd262e --- /dev/null +++ b/official/4.2/LibD11/frxADO5.dpk @@ -0,0 +1,48 @@ +// Package file for Delphi 5 + +package frxADO5; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + VCLDB50, + VCLADO50, + frx5, + frxDB5, +{$IFDEF QBUILDER} + fqb50, +{$ENDIF} + fs5, + fsADO5; + +contains + frxADOComponents in 'frxADOComponents.pas', + frxADOEditor in 'frxADOEditor.pas', + frxADORTTI in 'frxADORTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxADO5.res b/official/4.2/LibD11/frxADO5.res new file mode 100644 index 0000000..da3d366 Binary files /dev/null and b/official/4.2/LibD11/frxADO5.res differ diff --git a/official/4.2/LibD11/frxADO6.bpk b/official/4.2/LibD11/frxADO6.bpk new file mode 100644 index 0000000..ee90eaa --- /dev/null +++ b/official/4.2/LibD11/frxADO6.bpk @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=1 +Item0=_DEBUG + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxADO6.cpp b/official/4.2/LibD11/frxADO6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/frxADO6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frxADO6.dpk b/official/4.2/LibD11/frxADO6.dpk new file mode 100644 index 0000000..6fad173 --- /dev/null +++ b/official/4.2/LibD11/frxADO6.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 6 + +package frxADO6; + +{$I frx.inc} + +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + frx6, + frxDB6, +{$IFDEF QBUILDER} + fqb60, +{$ENDIF} + fs6, + fsADO6; + +contains + frxADOComponents in 'frxADOComponents.pas', + frxADOEditor in 'frxADOEditor.pas', + frxADORTTI in 'frxADORTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxADO6.res b/official/4.2/LibD11/frxADO6.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frxADO6.res differ diff --git a/official/4.2/LibD11/frxADO7.dpk b/official/4.2/LibD11/frxADO7.dpk new file mode 100644 index 0000000..6a22998 --- /dev/null +++ b/official/4.2/LibD11/frxADO7.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 7 + +package frxADO7; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + frx7, + frxDB7, +{$IFDEF QBUILDER} + fqb70, +{$ENDIF} + fs7, + fsADO7; + +contains + frxADOComponents in 'frxADOComponents.pas', + frxADOEditor in 'frxADOEditor.pas', + frxADORTTI in 'frxADORTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxADO9.bdsproj b/official/4.2/LibD11/frxADO9.bdsproj new file mode 100644 index 0000000..258e614 --- /dev/null +++ b/official/4.2/LibD11/frxADO9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxADO9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxADO9.dpk b/official/4.2/LibD11/frxADO9.dpk new file mode 100644 index 0000000..25725ef --- /dev/null +++ b/official/4.2/LibD11/frxADO9.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2005 + +package frxADO9; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + frx9, + frxDB9, +{$IFDEF QBUILDER} + fqb90, +{$ENDIF} + fs9, + fsADO9; + +contains + frxADOComponents in 'frxADOComponents.pas', + frxADOEditor in 'frxADOEditor.pas', + frxADORTTI in 'frxADORTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxADOComponents.pas b/official/4.2/LibD11/frxADOComponents.pas new file mode 100644 index 0000000..cac5785 --- /dev/null +++ b/official/4.2/LibD11/frxADOComponents.pas @@ -0,0 +1,898 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ ADO enduser components } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxADOComponents; + +interface + +{$I frx.inc} + +uses + Windows, Classes, SysUtils, frxClass, frxCustomDB, DB, ADODB, ADOInt +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF QBUILDER} +, fqbClass +{$ENDIF} +{$IFDEF FR_COM} +, VclCOM, ComObj, ComServ +, FastReport_TLB +{$ENDIF} +; + +{$IFDEF FR_COM} +const + CLASS_TfrxADODatabase: TGUID = '{4B15360C-223C-4F3E-A306-8E5C19E2EA98}'; + CLASS_TfrxADOTable: TGUID = '{75AE7A73-E752-4DE6-A326-9C18C8D753F4}'; + CLASS_TfrxADOQuery: TGUID = '{6B1A7A66-07F6-4B4C-A454-BAA59FC951FA}'; +{$ENDIF} + +type + TfrxADOComponents = class(TfrxDBComponents) + private + FDefaultDatabase: TADOConnection; + FOldComponents: TfrxADOComponents; + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDescription: String; override; + published + property DefaultDatabase: TADOConnection read FDefaultDatabase write FDefaultDatabase; + end; + +{$IFDEF FR_COM} + TfrxADODatabase = class(TfrxCustomDatabase, IfrxADODatabase) +{$ELSE} + TfrxADODatabase = class(TfrxCustomDatabase) +{$ENDIF} + private + FDatabase: TADOConnection; + protected + procedure SetConnected(Value: Boolean); override; + procedure SetDatabaseName(const Value: String); override; + procedure SetLoginPrompt(Value: Boolean); override; + function GetConnected: Boolean; override; + function GetDatabaseName: String; override; + function GetLoginPrompt: Boolean; override; +{$IFDEF FR_COM} + function Get_ConnectionString(out Value: WideString): HResult; stdcall; + function Set_ConnectionString(const Value: WideString): HResult; stdcall; + function Get_LoginPrompt(out Value: WordBool): HResult; stdcall; + function Set_LoginPrompt(Value: WordBool): HResult; stdcall; + function Get_Connected(out Value: WordBool): HResult; stdcall; + function Set_Connected(Value: WordBool): HResult; stdcall; + function Get_ConnectionTimeout(out Value: Integer): HResult; stdcall; + function Set_ConnectionTimeout(Value: Integer): HResult; stdcall; + function Get_CommandTimeout(out Value: Integer): HResult; stdcall; + function Set_CommandTimeout(Value: Integer): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + procedure SetLogin(const Login, Password: String); override; + property Database: TADOConnection read FDatabase; + published + property DatabaseName; + property LoginPrompt; + property Connected; + end; + +{$IFDEF FR_COM} + TfrxADOTable = class(TfrxCustomTable, IfrxADOTable) +{$ELSE} + TfrxADOTable = class(TfrxCustomTable) +{$ENDIF} + private + FDatabase: TfrxADODatabase; + FTable: TADOTable; + procedure SetDatabase(Value: TfrxADODatabase); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure SetMaster(const Value: TDataSource); override; + procedure SetMasterFields(const Value: String); override; + procedure SetIndexFieldNames(const Value: String); override; + procedure SetIndexName(const Value: String); override; + procedure SetTableName(const Value: String); override; + function GetIndexFieldNames: String; override; + function GetIndexName: String; override; + function GetTableName: String; override; +{$IFDEF FR_COM} + function Get_DataBase(out Value: IfrxADODatabase): HResult; stdcall; + function Set_DataBase(const Value: IfrxADODatabase): HResult; stdcall; + function Get_IndexName(out Value: WideString): HResult; stdcall; + function Set_IndexName(const Value: WideString): HResult; stdcall; + function Get_TableName(out Value: WideString): HResult; stdcall; + function Set_TableName(const Value: WideString): HResult; stdcall; + function Get_Name(out Value: WideString): HResult; stdcall; + function Set_Name(const Value: WideString): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + constructor DesignCreate(AOwner: TComponent; Flags: Word); override; + class function GetDescription: String; override; + procedure BeforeStartReport; override; + property Table: TADOTable read FTable; + published + property Database: TfrxADODatabase read FDatabase write SetDatabase; + end; + +{$IFDEF FR_COM} + TfrxADOQuery = class(TfrxCustomQuery, IfrxADOQuery) +{$ELSE} + TfrxADOQuery = class(TfrxCustomQuery) +{$ENDIF} + private + FDatabase: TfrxADODatabase; + FQuery: TADOQuery; + FStrings: TStrings; + FLock: Boolean; + procedure SetDatabase(Value: TfrxADODatabase); + function GetCommandTimeout: Integer; + procedure SetCommandTimeout(const Value: Integer); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure OnChangeSQL(Sender: TObject); override; + procedure SetMaster(const Value: TDataSource); override; + procedure SetSQL(Value: TStrings); override; + function GetSQL: TStrings; override; +{$IFDEF FR_COM} + function Get_DataBase(out Value: IfrxADODatabase): HResult; stdcall; + function Set_DataBase(const Value: IfrxADODatabase): HResult; stdcall; + function Get_Query(out Value: WideString): HResult; stdcall; + function Set_Query(const Value: WideString): HResult; stdcall; + function Get_Name(out Value: WideString): HResult; stdcall; + function Set_Name(const Value: WideString): HResult; stdcall; + function ParamByName(const Name: WideString; out Param: IfrxParamItem): HResult; stdcall; + function Get_CommandTimeout(out Value: Integer): HResult; stdcall; + function Set_CommandTimeout(Value: Integer): HResult; stdcall; + function Get_Filter(out Value: WideString): HResult; stdcall; + function Set_Filter(const Value: WideString): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + constructor DesignCreate(AOwner: TComponent; Flags: Word); override; + destructor Destroy; override; + class function GetDescription: String; override; + procedure BeforeStartReport; override; + procedure UpdateParams; override; +{$IFDEF QBUILDER} + function QBEngine: TfqbEngine; override; +{$ENDIF} + property Query: TADOQuery read FQuery; + published + property CommandTimeout: Integer read GetCommandTimeout write SetCommandTimeout; + property Database: TfrxADODatabase read FDatabase write SetDatabase; + end; + +{$IFDEF QBUILDER} + TfrxEngineADO = class(TfqbEngine) + private + FQuery: TADOQuery; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure ReadTableList(ATableList: TStrings); override; + procedure ReadFieldList(const ATableName: string; var AFieldList: TfqbFieldList); override; + function ResultDataSet: TDataSet; override; + procedure SetSQL(const Value: string); override; + end; +{$ENDIF} + +procedure frxParamsToTParameters(Query: TfrxCustomQuery; Params: TParameters); +procedure frxADOGetTableNames(conADO: TADOConnection; List: TStrings; SystemTables: Boolean); + +var + ADOComponents: TfrxADOComponents; + +implementation + +uses + frxADORTTI, +{$IFNDEF NO_EDITORS} + frxADOEditor, +{$ENDIF} + frxDsgnIntf, frxRes; + +type + THackQuery = class(TADOQuery); + + +{ frxParamsToTParameters } + +procedure frxParamsToTParameters(Query: TfrxCustomQuery; Params: TParameters); +var + i: Integer; + Item: TfrxParamItem; +begin + for i := 0 to Params.Count - 1 do + if Query.Params.IndexOf(Params[i].Name) <> -1 then + begin + Item := Query.Params[Query.Params.IndexOf(Params[i].Name)]; + Params[i].DataType := Item.DataType; + Params[i].Attributes := [paNullable]; + if Trim(Item.Expression) <> '' then + if not (Query.IsLoading or Query.IsDesigning) then + begin + Query.Report.CurObject := Query.Name; + Item.Value := Query.Report.Calc(Item.Expression); + end; + Params[i].Value := Item.Value; + end; +end; + +procedure frxADOGetTableNames(conADO: TADOConnection; List: TStrings; SystemTables: Boolean); +var + tbl: TADODataSet; + s: string; +begin + tbl := TADODataSet.Create(nil); + List.Clear; + try + conADO.OpenSchema(siTables, EmptyParam, EmptyParam, tbl); + tbl.First; + while not tbl.Eof do + begin + s := Trim(tbl.FieldByName('TABLE_SCHEMA').AsString); + if s <> '' then + List.Add(s + '.' + tbl.FieldByName('TABLE_NAME').AsString) + else + List.Add(tbl.FieldByName('TABLE_NAME').AsString); + tbl.Next; + end; + finally + tbl.Free; + end; +end; + + +{ TfrxDBComponents } + +constructor TfrxADOComponents.Create(AOwner: TComponent); +begin + inherited; + FOldComponents := ADOComponents; + ADOComponents := Self; +end; + +destructor TfrxADOComponents.Destroy; +begin + if ADOComponents = Self then + ADOComponents := FOldComponents; + inherited; +end; + +function TfrxADOComponents.GetDescription: String; +begin + Result := 'ADO'; +end; + +procedure TfrxADOComponents.Notification(AComponent: TComponent; + Operation: TOperation); +begin + inherited; + if (AComponent = FDefaultDatabase) and (Operation = opRemove) then + FDefaultDatabase := nil; +end; + + +{ TfrxADODatabase } + +constructor TfrxADODatabase.Create(AOwner: TComponent); +begin + inherited; + FDatabase := TADOConnection.Create(nil); + Component := FDatabase; +end; + +class function TfrxADODatabase.GetDescription: String; +begin + Result := frxResources.Get('obADODB'); +end; + +function TfrxADODatabase.GetConnected: Boolean; +begin + Result := FDatabase.Connected; +end; + +function TfrxADODatabase.GetDatabaseName: String; +begin + Result := FDatabase.ConnectionString; +end; + +function TfrxADODatabase.GetLoginPrompt: Boolean; +begin + Result := FDatabase.LoginPrompt; +end; + +procedure TfrxADODatabase.SetConnected(Value: Boolean); +begin + BeforeConnect(Value); + FDatabase.Connected := Value; +end; + +procedure TfrxADODatabase.SetDatabaseName(const Value: String); +begin + FDatabase.ConnectionString := Value; +end; + +procedure TfrxADODatabase.SetLoginPrompt(Value: Boolean); +begin + FDatabase.LoginPrompt := Value; +end; + +procedure TfrxADODatabase.SetLogin(const Login, Password: String); +var + i, j: Integer; + s: String; +begin + s := DatabaseName; + i := Pos('USER ID=', AnsiUppercase(s)); + if i <> 0 then + begin + for j := i to Length(s) do + if s[j] = ';' then + break; + Delete(s, i, j - i); + Insert('User ID=' + Login, s, i); + end + else + s := s + ';User ID=' + Login; + + i := Pos('PASSWORD=', AnsiUppercase(s)); + if i <> 0 then + begin + for j := i to Length(s) do + if s[j] = ';' then + break; + Delete(s, i, j - i); + Insert('Password=' + Password, s, i); + end + else + s := s + ';Password=' + Password; + + DatabaseName := s; +end; +{$IFDEF FR_COM} +function TfrxADODatabase.Get_ConnectionString(out Value: WideString): HResult; +begin + Value := PChar(DatabaseName); + Result := S_OK; +end; + +function TfrxADODatabase.Set_ConnectionString( + const Value: WideString): HResult; stdcall; +begin + DatabaseName := Value; + Result := S_OK; +end; + +function TfrxADODatabase.Get_LoginPrompt(out Value: WordBool): HResult; stdcall; +begin + Value := LoginPrompt; + Result := S_OK; +end; + +function TfrxADODatabase.Set_LoginPrompt(Value: WordBool): HResult; stdcall; +begin + LoginPrompt := Value; + Result := S_OK; +end; + +function TfrxADODatabase.Get_Connected(out Value: WordBool): HResult; stdcall; +begin + Value := Connected; + Result := S_OK; +end; + +function TfrxADODatabase.Set_Connected(Value: WordBool): HResult; stdcall; +begin + Result := S_OK; + try + Connected := Value; + except + on E: EOleException do Result := E.ErrorCode; + end; +end; + +function TfrxADODatabase.Get_ConnectionTimeout(out Value: Integer): HResult; stdcall; +begin + Value := FDatabase.ConnectionTimeout; + Result := S_OK; +end; + +function TfrxADODatabase.Set_ConnectionTimeout(Value: Integer): HResult; stdcall; +begin + FDatabase.ConnectionTimeout := Value; + Result := S_OK; +end; + +function TfrxADODatabase.Get_CommandTimeout(out Value: Integer): HResult; stdcall; +begin + Value := FDatabase.CommandTimeout; + Result := S_OK; +end; + +function TfrxADODatabase.Set_CommandTimeout(Value: Integer): HResult; stdcall; +begin + FDatabase.CommandTimeout := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxADOTable } + +constructor TfrxADOTable.Create(AOwner: TComponent); +begin + FTable := TADOTable.Create(nil); + DataSet := FTable; + SetDatabase(nil); + inherited; +end; + +constructor TfrxADOTable.DesignCreate(AOwner: TComponent; Flags: Word); +var + i: Integer; + l: TList; +begin + inherited; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + if TObject(l[i]) is TfrxADODatabase then + begin + SetDatabase(TfrxADODatabase(l[i])); + break; + end; +end; + +class function TfrxADOTable.GetDescription: String; +begin + Result := frxResources.Get('obADOTb'); +end; + +procedure TfrxADOTable.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FDatabase) then + SetDatabase(nil); +end; + +procedure TfrxADOTable.SetDatabase(Value: TfrxADODatabase); +begin + FDatabase := Value; + if Value <> nil then + FTable.Connection := Value.Database + else if ADOComponents <> nil then + FTable.Connection := ADOComponents.DefaultDatabase + else + FTable.Connection := nil; + DBConnected := FTable.Connection <> nil; +end; + +function TfrxADOTable.GetIndexFieldNames: String; +begin + Result := FTable.IndexFieldNames; +end; + +function TfrxADOTable.GetIndexName: String; +begin + Result := FTable.IndexName; +end; + +function TfrxADOTable.GetTableName: String; +begin + Result := FTable.TableName; +end; + +procedure TfrxADOTable.SetIndexFieldNames(const Value: String); +begin + FTable.IndexFieldNames := Value; +end; + +procedure TfrxADOTable.SetIndexName(const Value: String); +begin + FTable.IndexName := Value; +end; + +procedure TfrxADOTable.SetTableName(const Value: String); +begin + FTable.TableName := Value; +end; + +procedure TfrxADOTable.SetMaster(const Value: TDataSource); +begin + FTable.MasterSource := Value; +end; + +procedure TfrxADOTable.SetMasterFields(const Value: String); +begin + FTable.MasterFields := Value; +end; + +procedure TfrxADOTable.BeforeStartReport; +begin + SetDatabase(FDatabase); +end; + +{$IFDEF FR_COM} +function TfrxADOTable.Get_DataBase(out Value: IfrxADODatabase): HResult; stdcall; +begin + Value := Database; + Result := S_OK; +end; + +function TfrxADOTable.Set_DataBase(const Value: IfrxADODatabase): HResult; stdcall; +var + idsp : IInterfaceComponentReference; +begin + if Value <> nil then + begin + Result := Value.QueryInterface( IInterfaceComponentReference, idsp); + if Result = S_OK then + Database := TfrxADODatabase( idsp.GetComponent ); + end + else + begin + Database := nil; + Result := S_OK; + end; +end; + +function TfrxADOTable.Get_IndexName(out Value: WideString): HResult; stdcall; +begin + Value := FTable.IndexName; + Result := S_OK; +end; + +function TfrxADOTable.Set_IndexName(const Value: WideString): HResult; stdcall; +begin + FTable.IndexName := Value; + Result := S_OK; +end; + +function TfrxADOTable.Get_TableName( out Value : WideString): HResult; stdcall; +begin + Value := FTable.TableName; + Result := S_OK; +end; + +function TfrxADOTable.Set_TableName(const Value: WideString): HResult; stdcall; +begin + FTable.TableName := Value; + Result := S_OK; +end; + +function TfrxADOTable.Get_Name(out Value: WideString): HResult; stdcall; +begin + Value := Name; + Result := S_OK; +end; + +function TfrxADOTable.Set_Name(const Value: WideString): HResult; stdcall; +begin + Name := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxADOQuery } + +constructor TfrxADOQuery.Create(AOwner: TComponent); +begin + FStrings := TStringList.Create; + FQuery := TADOQuery.Create(nil); + Dataset := FQuery; + SetDatabase(nil); + FLock := False; + inherited; +end; + +constructor TfrxADOQuery.DesignCreate(AOwner: TComponent; Flags: Word); +var + i: Integer; + l: TList; +begin + inherited; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + if TObject(l[i]) is TfrxADODatabase then + begin + SetDatabase(TfrxADODatabase(l[i])); + break; + end; +end; + +destructor TfrxADOQuery.Destroy; +begin + FStrings.Free; + inherited; +end; + +class function TfrxADOQuery.GetDescription: String; +begin + Result := frxResources.Get('obADOQ'); +end; + +procedure TfrxADOQuery.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FDatabase) then + SetDatabase(nil); +end; + +function TfrxADOQuery.GetSQL: TStrings; +begin + FLock := True; + FStrings.Assign(FQuery.SQL); + FLock := False; + Result := FStrings; +end; + +procedure TfrxADOQuery.SetSQL(Value: TStrings); +begin + FQuery.SQL.Assign(Value); + FStrings.Assign(FQuery.SQL); +end; + +procedure TfrxADOQuery.SetDatabase(Value: TfrxADODatabase); +begin + FDatabase := Value; + if Value <> nil then + FQuery.Connection := Value.Database + else if ADOComponents <> nil then + FQuery.Connection := ADOComponents.DefaultDatabase + else + FQuery.Connection := nil; + DBConnected := FQuery.Connection <> nil; +end; + +procedure TfrxADOQuery.SetMaster(const Value: TDataSource); +begin + FQuery.DataSource := Value; +end; + +function TfrxADOQuery.GetCommandTimeout: Integer; +begin + Result := THackQuery(FQuery).CommandTimeout; +end; + +procedure TfrxADOQuery.SetCommandTimeout(const Value: Integer); +begin + THackQuery(FQuery).CommandTimeout := Value; +end; + +procedure TfrxADOQuery.UpdateParams; +begin + frxParamsToTParameters(Self, FQuery.Parameters); +end; + +procedure TfrxADOQuery.OnChangeSQL(Sender: TObject); +var + i, ind: Integer; + Param: TfrxParamItem; + QParam: TParameter; +begin + if not FLock then + begin + { needed to update parameters } + FQuery.SQL.Text := ''; + FQuery.SQL.Assign(FStrings); + inherited; + + { fill datatype automatically, if possible } + for i := 0 to FQuery.Parameters.Count - 1 do + begin + QParam := FQuery.Parameters[i]; + ind := Params.IndexOf(QParam.Name); + if ind <> -1 then + begin + Param := Params[ind]; + if (Param.DataType = ftUnknown) and (QParam.DataType <> ftUnknown) then + Param.DataType := QParam.DataType; + end; + end; + end; +end; + +procedure TfrxADOQuery.BeforeStartReport; +begin + SetDatabase(FDatabase); + { needed to update parameters } + SQL.Text := SQL.Text; +end; + +{$IFDEF QBUILDER} +function TfrxADOQuery.QBEngine: TfqbEngine; +begin + Result := TfrxEngineADO.Create(nil); + TfrxEngineADO(Result).FQuery.Connection := FQuery.Connection; +end; +{$ENDIF} + +{$IFDEF FR_COM} +function TfrxADOQuery.Get_DataBase(out Value: IfrxADODatabase): HResult; stdcall; +begin + Value := Database; + Result := S_OK; +end; + +function TfrxADOQuery.Set_DataBase(const Value: IfrxADODatabase): HResult; stdcall; +var + idsp : IInterfaceComponentReference; +begin + if Value <> nil then + begin + Result := Value.QueryInterface( IInterfaceComponentReference, idsp ); + if Result = S_OK then Database := TfrxADODatabase( idsp.GetComponent ); + end + else + begin + Database := nil; + Result := S_OK; + end +end; + +function TfrxADOQuery.Get_Query(out Value: WideString): HResult; stdcall; +begin + Value := String(SQL.GetText); + Result := S_OK; +end; + +function TfrxADOQuery.Set_Query(const Value: WideString): HResult; stdcall; +begin + SQL.Text := Value; + Result := S_OK; +end; + +function TfrxADOQuery.Get_Name(out Value: WideString): HResult; stdcall; +begin + Value := Name; + Result := S_OK; +end; + +function TfrxADOQuery.Set_Name(const Value: WideString): HResult; stdcall; +begin + Name := Value; + Result := S_OK; +end; + +function TfrxADOQuery.Get_CommandTimeout(out Value: Integer): HResult; stdcall; +begin + Value := CommandTimeout; + Result := S_OK; +end; + +function TfrxADOQuery.Set_CommandTimeout(Value: Integer): HResult; stdcall; +begin + CommandTimeout := Value; + Result := S_OK; +end; + + +function TfrxADOQuery.ParamByName(const Name: WideString; out Param: IfrxParamItem): HResult; stdcall; +var + par: TfrxParamItem; +begin + par := inherited ParamByName(Name); + if par <> nil then + begin + Param := par; + Result := S_OK; + end + else Result := E_INVALIDARG; + +end; + +function TfrxADOQuery.Get_Filter(out Value: WideString): HResult; stdcall; +begin + Value := Query.Filter; + Result := S_OK; +end; + +function TfrxADOQuery.Set_Filter(const Value: WideString): HResult; stdcall; +begin + if Value <> '' then begin + Query.Filtered := False; + Query.Filter := Value; + Query.Filtered := True; + end else begin + Query.Filtered := False; + end; + Result := S_OK; +end; +{$ENDIF} + +{$IFDEF QBUILDER} +constructor TfrxEngineADO.Create(AOwner: TComponent); +begin + inherited; + FQuery := TADOQuery.Create(Self); +end; + +destructor TfrxEngineADO.Destroy; +begin + FQuery.Free; + inherited; +end; + +procedure TfrxEngineADO.ReadFieldList(const ATableName: string; + var AFieldList: TfqbFieldList); +var + TempTable: TADOTable; + Fields: TFieldDefs; + i: Integer; + tmpField: TfqbField; +begin + AFieldList.Clear; + TempTable := TADOTable.Create(Self); + TempTable.Connection := FQuery.Connection; + TempTable.TableName := ATableName; + Fields := TempTable.FieldDefs; + try + try + TempTable.Active := True; + tmpField:= TfqbField(AFieldList.Add); + tmpField.FieldName := '*'; + for i := 0 to Fields.Count - 1 do + begin + tmpField := TfqbField(AFieldList.Add); + tmpField.FieldName := Fields.Items[i].Name; + tmpField.FieldType := Ord(Fields.Items[i].DataType) + end; + except + end; + finally + TempTable.Free; + end; +end; + +procedure TfrxEngineADO.ReadTableList(ATableList: TStrings); +begin + ATableList.Clear; + frxADOGetTableNames(FQuery.Connection, ATableList, ShowSystemTables); +// FQuery.Connection.GetTableNames(ATableList, ShowSystemTables); +end; + +function TfrxEngineADO.ResultDataSet: TDataSet; +begin + Result := FQuery; +end; + +procedure TfrxEngineADO.SetSQL(const Value: string); +begin + FQuery.SQL.Text := Value; +end; +{$ENDIF} + + +initialization + frxObjects.RegisterObject1(TfrxADODataBase, nil, '', '', 0, {$IFDEF FR_COM}37{$ELSE}51{$ENDIF}); + frxObjects.RegisterObject1(TfrxADOTable, nil, '', '', 0, {$IFDEF FR_COM}38{$ELSE}52{$ENDIF}); + frxObjects.RegisterObject1(TfrxADOQuery, nil, '', '', 0, {$IFDEF FR_COM}39{$ELSE}53{$ENDIF}); + +{$IFDEF FR_COM} +try + TComponentFactory.Create(ComServer, TfrxADODatabase, Class_TfrxADODatabase, ciMultiInstance, tmApartment); + TComponentFactory.Create(ComServer, TfrxADOTable, CLASS_TfrxADOTable, ciMultiInstance, tmApartment); + TComponentFactory.Create(ComServer, TfrxADOQuery, CLASS_TfrxADOQuery, ciMultiInstance, tmApartment); +except +end; +{$ENDIF} + +finalization + frxObjects.UnRegister(TfrxADODataBase); + frxObjects.UnRegister(TfrxADOTable); + frxObjects.UnRegister(TfrxADOQuery); + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxADOEditor.pas b/official/4.2/LibD11/frxADOEditor.pas new file mode 100644 index 0000000..de9d663 --- /dev/null +++ b/official/4.2/LibD11/frxADOEditor.pas @@ -0,0 +1,159 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ ADO components design editors } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxADOEditor; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, frxADOComponents, frxCustomDB, + frxDsgnIntf, frxRes, DB, ADODB, ADOInt +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxDatabaseNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxDatabaseProperty = class(TfrxComponentProperty) + public + function GetValue: String; override; + end; + + TfrxTableNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxIndexNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + +{ TfrxDatabaseNameProperty } + +function TfrxDatabaseNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog]; +end; + +function TfrxDatabaseNameProperty.Edit: Boolean; +var + SaveConnected: Boolean; + db: TADOConnection; + fName: String; +begin + db := TfrxADODatabase(Component).Database; + + SaveConnected := db.Connected; + db.Connected := False; + fName := PromptDataSource(Application.Handle, db.ConnectionString); + Result := fName <> ''; + if Result then + db.ConnectionString := fName; + db.Connected := SaveConnected; +end; + + +{ TfrxDatabaseProperty } + +function TfrxDatabaseProperty.GetValue: String; +var + db: TfrxADODatabase; +begin + db := TfrxADODatabase(GetOrdValue); + if db = nil then + begin + if (ADOComponents <> nil) and (ADOComponents.DefaultDatabase <> nil) then + Result := ADOComponents.DefaultDatabase.Name + else + Result := frxResources.Get('prNotAssigned'); + end + else + Result := inherited GetValue; +end; + + +{ TfrxTableNameProperty } + +function TfrxTableNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +procedure TfrxTableNameProperty.GetValues; +begin + inherited; + with TfrxADOTable(Component).Table do + if Connection <> nil then + frxADOGetTableNames(Connection, Values, False); +end; + +procedure TfrxTableNameProperty.SetValue(const Value: String); +begin + inherited; + Designer.UpdateDataTree; +end; + + +{ TfrxIndexProperty } + +function TfrxIndexNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +procedure TfrxIndexNameProperty.GetValues; +var + i: Integer; +begin + inherited; + try + with TfrxADOTable(Component).Table do + if (TableName <> '') and (IndexDefs <> nil) then + begin + IndexDefs.Update; + for i := 0 to IndexDefs.Count - 1 do + if IndexDefs[i].Name <> '' then + Values.Add(IndexDefs[i].Name); + end; + except + end; +end; + + +initialization + frxPropertyEditors.Register(TypeInfo(String), TfrxADODataBase, 'DatabaseName', + TfrxDataBaseNameProperty); + frxPropertyEditors.Register(TypeInfo(TfrxADODatabase), TfrxADOTable, 'Database', + TfrxDatabaseProperty); + frxPropertyEditors.Register(TypeInfo(TfrxADODatabase), TfrxADOQuery, 'Database', + TfrxDatabaseProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxADOTable, 'TableName', + TfrxTableNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxADOTable, 'IndexName', + TfrxIndexNameProperty); + +end. diff --git a/official/4.2/LibD11/frxADORTTI.pas b/official/4.2/LibD11/frxADORTTI.pas new file mode 100644 index 0000000..0e5996f --- /dev/null +++ b/official/4.2/LibD11/frxADORTTI.pas @@ -0,0 +1,101 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ ADO components RTTI } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxADORTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, fs_iinterpreter, frxADOComponents, fs_iadortti +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + with AddClass(TfrxADODatabase, 'TfrxCustomDatabase') do + AddProperty('Database', 'TADOConnection', GetProp, nil); + with AddClass(TfrxADOTable, 'TfrxCustomTable') do + AddProperty('Table', 'TADOTable', GetProp, nil); + with AddClass(TfrxADOQuery, 'TfrxCustomQuery') do + begin + AddMethod('procedure ExecSQL', CallMethod); + AddProperty('Query', 'TADOQuery', GetProp, nil); + end; + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TfrxADOQuery then + begin + if MethodName = 'EXECSQL' then + TfrxADOQuery(Instance).Query.ExecSQL + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TfrxADODatabase then + begin + if PropName = 'DATABASE' then + Result := Integer(TfrxADODatabase(Instance).Database) + end + else if ClassType = TfrxADOTable then + begin + if PropName = 'TABLE' then + Result := Integer(TfrxADOTable(Instance).Table) + end + else if ClassType = TfrxADOQuery then + begin + if PropName = 'QUERY' then + Result := Integer(TfrxADOQuery(Instance).Query) + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/frxADOReg.dcr b/official/4.2/LibD11/frxADOReg.dcr new file mode 100644 index 0000000..998caa3 Binary files /dev/null and b/official/4.2/LibD11/frxADOReg.dcr differ diff --git a/official/4.2/LibD11/frxADOReg.pas b/official/4.2/LibD11/frxADOReg.pas new file mode 100644 index 0000000..cb61885 --- /dev/null +++ b/official/4.2/LibD11/frxADOReg.pas @@ -0,0 +1,37 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ ADO components registration } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxADOReg; + +interface + +{$I frx.inc} + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes +{$IFNDEF Delphi6} +, DsgnIntf +{$ELSE} +, DesignIntf, DesignEditors +{$ENDIF} +, frxADOComponents; + +procedure Register; +begin + RegisterComponents('FastReport 4.0', [TfrxADOComponents]); +end; + +end. diff --git a/official/4.2/LibD11/frxAbout.dfm b/official/4.2/LibD11/frxAbout.dfm new file mode 100644 index 0000000..4912b31 Binary files /dev/null and b/official/4.2/LibD11/frxAbout.dfm differ diff --git a/official/4.2/LibD11/frxAbout.pas b/official/4.2/LibD11/frxAbout.pas new file mode 100644 index 0000000..33565a4 --- /dev/null +++ b/official/4.2/LibD11/frxAbout.pas @@ -0,0 +1,93 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ About window } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxAbout; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ExtCtrls, StdCtrls; + +type + TfrxAboutForm = class(TForm) + Button1: TButton; + Label2: TLabel; + Label3: TLabel; + Image1: TImage; + Bevel2: TBevel; + Label5: TLabel; + Shape1: TShape; + Label1: TLabel; + Label4: TLabel; + Label6: TLabel; + Label7: TLabel; + Label8: TLabel; + Label9: TLabel; + Label10: TLabel; + procedure FormCreate(Sender: TObject); + procedure LabelClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + public + { Public declarations } + end; + + +implementation + +uses frxClass, frxUtils, frxRes, ShellApi; + +{$R *.DFM} + +procedure TfrxAboutForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(2600); + Label4.Caption := frxGet(2601); + Label6.Caption := frxGet(2602); + Label8.Caption := frxGet(2603); + Label2.Caption := 'Version ' + FR_VERSION; + Label10.Caption := #174; + {$IFDEF FR_LITE} + Label1.Caption := 'FreeReport'; + {$ENDIF} + Label3.Caption := '(c) 1998-' + FormatDateTime('YYYY', Now) + ' by Alexander Tzyganenko, Fast Reports Inc.'; + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxAboutForm.LabelClick(Sender: TObject); +begin + case TLabel(Sender).Tag of + 1: ShellExecute(GetDesktopWindow, 'open', + PChar(TLabel(Sender).Caption), nil, nil, sw_ShowNormal); + 2: ShellExecute(GetDesktopWindow, 'open', + PChar('mailto:' + TLabel(Sender).Caption), nil, nil, sw_ShowNormal); + end; +end; + +procedure TfrxAboutForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_ESCAPE then + ModalResult := mrCancel; +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxAdoWizard.dfm b/official/4.2/LibD11/frxAdoWizard.dfm new file mode 100644 index 0000000..f096ef7 Binary files /dev/null and b/official/4.2/LibD11/frxAdoWizard.dfm differ diff --git a/official/4.2/LibD11/frxAdoWizard.pas b/official/4.2/LibD11/frxAdoWizard.pas new file mode 100644 index 0000000..0fc13e4 --- /dev/null +++ b/official/4.2/LibD11/frxAdoWizard.pas @@ -0,0 +1,1114 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Standard Report wizard for ADO } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxAdoWizard; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Buttons, ComCtrls, ExtCtrls, frxClass, frxDesgn; + +type + TfrxStdWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxDotMatrixWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxStdEmptyWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxDMPEmptyWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxStdWizardForm = class(TForm) + Pages: TPageControl; + FieldsTab: TTabSheet; + GroupsTab: TTabSheet; + LayoutTab: TTabSheet; + FieldsLB: TListBox; + AddFieldB: TSpeedButton; + AddAllFieldsB: TSpeedButton; + RemoveFieldB: TSpeedButton; + RemoveAllFieldsB: TSpeedButton; + SelectedFieldsLB: TListBox; + SelectedFieldsL: TLabel; + FieldUpB: TSpeedButton; + FieldDownB: TSpeedButton; + AvailableFieldsLB: TListBox; + AddGroupB: TSpeedButton; + RemoveGroupB: TSpeedButton; + GroupsLB: TListBox; + GroupsL: TLabel; + GroupUpB: TSpeedButton; + GroupDownB: TSpeedButton; + AvailableFieldsL: TLabel; + BackB: TButton; + NextB: TButton; + FinishB: TButton; + FitWidthCB: TCheckBox; + Step2L: TLabel; + Step3L: TLabel; + Step4L: TLabel; + StyleTab: TTabSheet; + Step5L: TLabel; + ScrollBox1: TScrollBox; + StylePB: TPaintBox; + StyleLB: TListBox; + OrientationL: TGroupBox; + LayoutL: TGroupBox; + PortraitImg: TImage; + LandscapeImg: TImage; + PortraitRB: TRadioButton; + LandscapeRB: TRadioButton; + TabularRB: TRadioButton; + ColumnarRB: TRadioButton; + ScrollBox2: TScrollBox; + LayoutPB: TPaintBox; + AvailableFieldsL1: TLabel; + DataTab: TTabSheet; + Step1L: TLabel; + ConnectionCB: TComboBox; + TableL: TLabel; + TablesLB: TListBox; + orL: TLabel; + CreateQueryB: TButton; + ConnectionL: TLabel; + ConfigureConnB: TSpeedButton; + procedure FormCreate(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure AddFieldBClick(Sender: TObject); + procedure AddAllFieldsBClick(Sender: TObject); + procedure RemoveFieldBClick(Sender: TObject); + procedure RemoveAllFieldsBClick(Sender: TObject); + procedure AddGroupBClick(Sender: TObject); + procedure RemoveGroupBClick(Sender: TObject); + procedure FieldUpBClick(Sender: TObject); + procedure FieldDownBClick(Sender: TObject); + procedure GroupUpBClick(Sender: TObject); + procedure GroupDownBClick(Sender: TObject); + procedure NextBClick(Sender: TObject); + procedure BackBClick(Sender: TObject); + procedure GroupsTabShow(Sender: TObject); + procedure StylePBPaint(Sender: TObject); + procedure PortraitRBClick(Sender: TObject); + procedure PagesChange(Sender: TObject); + procedure StyleLBClick(Sender: TObject); + procedure FinishBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure LayoutPBPaint(Sender: TObject); + procedure TabularRBClick(Sender: TObject); + procedure ConnectionCBClick(Sender: TObject); + procedure ConfigureConnBClick(Sender: TObject); + procedure TablesLBClick(Sender: TObject); + procedure CreateQueryBClick(Sender: TObject); + private + FDataset: TfrxDataset; + FDesigner: TfrxDesignerForm; + FDotMatrix: Boolean; + FLayoutReport: TfrxReport; + FReport: TfrxReport; + FStyleReport: TfrxReport; + FStyleSheet: TfrxStyleSheet; + procedure DrawSample(PaintBox: TPaintBox; Report: TfrxReport); + procedure FillConnections; + procedure FillFields; + procedure FillTables; + procedure UpdateAvailableFields; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + + +implementation + +{$R *.DFM} +{$R *.RES} + +uses + frxEditReportData, frxDsgnIntf, frxRes, frxUtils, frxDMPClass, + IniFiles, Registry, Printers, frxADOComponents, frxConnEditor; + +const + StyleReport = +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +''; + + LayoutTabularReport = +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +''; + + LayoutColumnarReport = +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +''; + + + Style = +'' + +'' + +'' + +'' + +'' + +'' + +''; + + + +{ TfrxStdWizard } + +class function TfrxStdWizard.GetDescription: String; +begin + Result := frxResources.Get('wzStd'); +end; + +function TfrxStdWizard.Execute: Boolean; +begin + with TfrxStdWizardForm.Create(Owner) do + begin + FDesigner := TfrxDesignerForm(Self.Designer); + FReport := Report; + Result := ShowModal = mrOk; + Free; + end; +end; + + +{ TfrxDotMatrixWizard } + +class function TfrxDotMatrixWizard.GetDescription: String; +begin + Result := frxResources.Get('wzDMP'); +end; + +function TfrxDotMatrixWizard.Execute: Boolean; +begin + with TfrxStdWizardForm.Create(Owner) do + begin + FDesigner := TfrxDesignerForm(Self.Designer); + FDotMatrix := True; + FReport := Report; + Result := ShowModal = mrOk; + Free; + end; +end; + + +{ TfrxStdEmptyWizard } + +class function TfrxStdEmptyWizard.GetDescription: String; +begin + Result := frxResources.Get('wzStdEmpty'); +end; + +function TfrxStdEmptyWizard.Execute: Boolean; +var + Page: TfrxReportPage; +begin + Result := True; + try + Designer.Lock; + Report.Clear; + Report.FileName := ''; + Report.DotMatrixReport := False; + + Page := TfrxReportPage.Create(Report); + Page.Name := 'Page1'; + Page.SetDefaults; + finally + Designer.ReloadReport; + end; +end; + + +{ TfrxDMPEmptyWizard } + +class function TfrxDMPEmptyWizard.GetDescription: String; +begin + Result := frxResources.Get('wzDMPEmpty'); +end; + +function TfrxDMPEmptyWizard.Execute: Boolean; +var + Page: TfrxReportPage; +begin + Result := True; + try + Designer.Lock; + Report.Clear; + Report.FileName := ''; + Report.DotMatrixReport := True; + + Page := TfrxDMPPage.Create(Report); + Page.Name := 'Page1'; + Page.SetDefaults; + finally + Designer.ReloadReport; + end; +end; + + +{ TfrxStdWizardForm } + +constructor TfrxStdWizardForm.Create(AOwner: TComponent); +var + s: TStringStream; +begin + inherited; + FStyleReport := TfrxReport.Create(nil); + s := TStringStream.Create(StyleReport); + FStyleReport.LoadFromStream(s); + s.Free; + FLayoutReport := TfrxReport.Create(nil); + + FStyleSheet := TfrxStyleSheet.Create; + if FileExists(ExtractFilePath(Application.ExeName) + 'wizstyle.xml') then + FStyleSheet.LoadFromFile(ExtractFilePath(Application.ExeName) + 'wizstyle.xml') + else + begin + s := TStringStream.Create(Style); + FStyleSheet.LoadFromStream(s); + s.Free; + end; +end; + +destructor TfrxStdWizardForm.Destroy; +begin + FStyleReport.Free; + FLayoutReport.Free; + FStyleSheet.Free; + inherited; +end; + +procedure TfrxStdWizardForm.FormCreate(Sender: TObject); +var + bmp: TBitmap; +begin + Caption := frxGet(5600); + DataTab.Caption := frxGet(5601); + FieldsTab.Caption := frxGet(5602); + GroupsTab.Caption := frxGet(5603); + LayoutTab.Caption := frxGet(5604); + StyleTab.Caption := frxGet(5605); + Step1L.Caption := frxGet(5606); + Step2L.Caption := frxGet(5607); + Step3L.Caption := frxGet(5608); + Step4L.Caption := frxGet(5609); + Step5L.Caption := frxGet(5610); + AddFieldB.Caption := frxGet(5611); + AddAllFieldsB.Caption := frxGet(5612); + RemoveFieldB.Caption := frxGet(5613); + RemoveAllFieldsB.Caption := frxGet(5614); + AddGroupB.Caption := frxGet(5615); + RemoveGroupB.Caption := frxGet(5616); + SelectedFieldsL.Caption := frxGet(5617); + AvailableFieldsL.Caption := frxGet(5618); + AvailableFieldsL1.Caption := frxGet(5618); + GroupsL.Caption := frxGet(5619); + OrientationL.Caption := frxGet(5620); + LayoutL.Caption := frxGet(5621); + PortraitRB.Caption := frxGet(5622); + LandscapeRB.Caption := frxGet(5623); + TabularRB.Caption := frxGet(5624); + ColumnarRB.Caption := frxGet(5625); + FitWidthCB.Caption := frxGet(5626); + BackB.Caption := frxGet(5627); + NextB.Caption := frxGet(5628); + FinishB.Caption := frxGet(5629); + + ConnectionL.Caption := frxGet(5632); + TableL.Caption := frxGet(5633); + orL.Caption := frxGet(5634); + CreateQueryB.Caption := frxGet(5635); + ConfigureConnB.Hint := frxGet(5636); + + bmp := TBitmap.Create; + bmp.Width := 16; + bmp.Height := 16; + bmp.Canvas.Brush.Color := clOlive; + bmp.Canvas.FillRect(Rect(0, 0, 16, 16)); + frxResources.MainButtonImages.Draw(bmp.Canvas, 0, 0, 69); + ConfigureConnB.Glyph := bmp; + bmp.Free; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxStdWizardForm.FormShow(Sender: TObject); +var + Page: TfrxReportPage; +begin + FDesigner.Lock; + FReport.Clear; + if FDotMatrix then + Page := TfrxDMPPage.Create(FReport) else + Page := TfrxReportPage.Create(FReport); + Page.Name := 'Page1'; + Page.SetDefaults; + FDesigner.ReloadReport; + + FillConnections; + ConnectionCB.ItemIndex := 0; + ConnectionCBClick(nil); + + FStyleSheet.GetList(StyleLB.Items); + StyleLB.ItemIndex := 0; + StyleLBClick(nil); + + TabularRBClick(nil); + if FDotMatrix then + StyleTab.Free; +end; + +procedure TfrxStdWizardForm.FillConnections; +var + ini: TRegistry; +begin + ConnectionCB.Items.Clear; + ini := TRegistry.Create; + try + ini.RootKey := HKEY_LOCAL_MACHINE; + if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS, False) then + begin + ini.GetValueNames(ConnectionCB.Items); + ini.CloseKey; + end + ini.RootKey := HKEY_CURRENT_USER; + if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS, False) then + begin + ini.GetValueNames(ConnectionCB.Items); + ini.CloseKey; + end + ini.RootKey := HKEY_CURRENT_USER; + finally + ini.Free; + end; +end; + +procedure TfrxStdWizardForm.FillFields; +begin + FieldsLB.Clear; + SelectedFieldsLB.Clear; + UpdateAvailableFields; + + if FDataset <> nil then + FDataset.GetFieldList(FieldsLB.Items); + + if FieldsLB.Items.Count <> 0 then + begin + FieldsLB.ItemIndex := 0; + FieldsLB.Selected[0] := True; + end; +end; + +procedure TfrxStdWizardForm.FillTables; +begin + frxADOGetTableNames(ADOComponents.DefaultDatabase, TablesLB.Items, False); +end; + +procedure TfrxStdWizardForm.UpdateAvailableFields; +begin + AvailableFieldsLB.Items := SelectedFieldsLB.Items; + GroupsLB.Clear; +end; + +procedure TfrxStdWizardForm.DrawSample(PaintBox: TPaintBox; Report: TfrxReport); +var + i: Integer; + c: TfrxComponent; +begin + with PaintBox do + begin + Canvas.Pen.Color := clBlack; + Canvas.Brush.Color := clWindow; + Canvas.Rectangle(0, 0, Width, Height); + + for i := 0 to Report.AllObjects.Count - 1 do + begin + c := Report.AllObjects[i]; + if c is TfrxCustomMemoView then + with TfrxCustomMemoView(c) do + Draw(Canvas, 1, 1, 10, 10); + end; + end; +end; + +procedure TfrxStdWizardForm.ConnectionCBClick(Sender: TObject); +begin + FReport.ReportOptions.ConnectionName := ConnectionCB.Items[ConnectionCB.ItemIndex]; + FillTables; +end; + +procedure TfrxStdWizardForm.ConfigureConnBClick(Sender: TObject); +begin + with TfrxConnEditorForm.Create(nil) do + begin + Report := FReport; + ShowModal; + Free; + end; + + FillConnections; + ConnectionCB.ItemIndex := 0; + ConnectionCBClick(nil); +end; + +procedure TfrxStdWizardForm.TablesLBClick(Sender: TObject); +begin + if FDataset <> nil then + FDataset.Free; + + FDataset := TfrxADOTable.DesignCreate(FReport.Pages[0], 0); + FDataset.CreateUniqueName; + TfrxADOTable(FDataset).TableName := TablesLB.Items[TablesLB.ItemIndex]; + TfrxADOTable(FDataset).UserName := TfrxADOTable(FDataset).TableName; + + FillFields; +end; + +procedure TfrxStdWizardForm.CreateQueryBClick(Sender: TObject); +var + ed: TfrxComponentEditor; +begin + if FDataset <> nil then + FDataset.Free; + + FDataset := TfrxADOQuery.DesignCreate(FReport.Pages[0], 0); + FDataset.CreateUniqueName; + + ed := frxComponentEditors.GetComponentEditor(FDataset, FDesigner, nil); + try + ed.Edit; + finally + ed.Free; + end; + + FillFields; +end; + +procedure TfrxStdWizardForm.AddFieldBClick(Sender: TObject); +var + i, j: Integer; +begin + if FieldsLB.ItemIndex = -1 then Exit; + + i := 0; + j := -1; + while i < FieldsLB.Items.Count do + if FieldsLB.Selected[i] then + begin + if j = -1 then + j := i; + SelectedFieldsLB.Items.Add(FieldsLB.Items[i]); + FieldsLB.Items.Delete(i); + end + else + Inc(i); + + if j = FieldsLB.Items.Count then + Dec(j); + if j <> -1 then + begin + FieldsLB.ItemIndex := j; + FieldsLB.Selected[j] := True; + end; + + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.AddAllFieldsBClick(Sender: TObject); +begin + if FieldsLB.Items.Count = 0 then Exit; + FillFields; + SelectedFieldsLB.Items := FieldsLB.Items; + FieldsLB.Items.Clear; + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.RemoveFieldBClick(Sender: TObject); +var + i, j: Integer; +begin + if SelectedFieldsLB.ItemIndex = -1 then Exit; + + i := 0; + j := -1; + while i < SelectedFieldsLB.Items.Count do + if SelectedFieldsLB.Selected[i] then + begin + if j = -1 then + j := i; + FieldsLB.Items.Add(SelectedFieldsLB.Items[i]); + SelectedFieldsLB.Items.Delete(i); + end + else + Inc(i); + + if j = SelectedFieldsLB.Items.Count then + Dec(j); + if j <> -1 then + begin + SelectedFieldsLB.ItemIndex := j; + SelectedFieldsLB.Selected[j] := True; + end; + + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.RemoveAllFieldsBClick(Sender: TObject); +begin + FillFields; +end; + +procedure TfrxStdWizardForm.AddGroupBClick(Sender: TObject); +var + i: Integer; +begin + i := AvailableFieldsLB.ItemIndex; + if i = -1 then Exit; + GroupsLB.Items.Add(AvailableFieldsLB.Items[i]); + AvailableFieldsLB.Items.Delete(i); + AvailableFieldsLB.ItemIndex := i; +end; + +procedure TfrxStdWizardForm.RemoveGroupBClick(Sender: TObject); +var + i: Integer; +begin + i := GroupsLB.ItemIndex; + if i = -1 then Exit; + AvailableFieldsLB.Items.Add(GroupsLB.Items[i]); + GroupsLB.Items.Delete(i); + GroupsLB.ItemIndex := i; +end; + +procedure TfrxStdWizardForm.FieldUpBClick(Sender: TObject); +var + i: Integer; +begin + i := SelectedFieldsLB.ItemIndex; + if i < 1 then Exit; + SelectedFieldsLB.Items.Exchange(i, i - 1); + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.FieldDownBClick(Sender: TObject); +var + i: Integer; +begin + i := SelectedFieldsLB.ItemIndex; + if (i = -1) or (SelectedFieldsLB.Items.Count = 0) or + (i = SelectedFieldsLB.Items.Count - 1) then Exit; + SelectedFieldsLB.Items.Exchange(i, i + 1); + SelectedFieldsLB.ItemIndex := i + 1; + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.GroupUpBClick(Sender: TObject); +var + i: Integer; +begin + i := GroupsLB.ItemIndex; + if i < 1 then Exit; + GroupsLB.Items.Exchange(i, i - 1); +end; + +procedure TfrxStdWizardForm.GroupDownBClick(Sender: TObject); +var + i: Integer; +begin + i := GroupsLB.ItemIndex; + if (i = -1) or (i = GroupsLB.Items.Count - 1) then Exit; + GroupsLB.Items.Exchange(i, i + 1); + GroupsLB.ItemIndex := i + 1; +end; + +procedure TfrxStdWizardForm.NextBClick(Sender: TObject); +begin + Pages.SelectNextPage(True); + PagesChange(nil); +end; + +procedure TfrxStdWizardForm.BackBClick(Sender: TObject); +begin + Pages.SelectNextPage(False); + PagesChange(nil); +end; + +procedure TfrxStdWizardForm.PagesChange(Sender: TObject); +begin + if not FDotMatrix then + NextB.Enabled := Pages.ActivePage <> StyleTab else + NextB.Enabled := Pages.ActivePage <> LayoutTab; + BackB.Enabled := Pages.ActivePage <> DataTab; +end; + +procedure TfrxStdWizardForm.GroupsTabShow(Sender: TObject); +begin + AvailableFieldsLB.ItemIndex := 0; +end; + +procedure TfrxStdWizardForm.StylePBPaint(Sender: TObject); +begin + DrawSample(StylePB, FStyleReport); +end; + +procedure TfrxStdWizardForm.LayoutPBPaint(Sender: TObject); +begin + DrawSample(LayoutPB, FLayoutReport); +end; + +procedure TfrxStdWizardForm.PortraitRBClick(Sender: TObject); +begin + PortraitImg.Visible := PortraitRB.Checked; + LandscapeImg.Visible := LandscapeRB.Checked; +end; + +procedure TfrxStdWizardForm.StyleLBClick(Sender: TObject); +begin + FStyleReport.Styles := FStyleSheet.Find(StyleLB.Items[StyleLB.ItemIndex]); + StylePBPaint(nil); +end; + +procedure TfrxStdWizardForm.TabularRBClick(Sender: TObject); +var + s: TStringStream; +begin + if TabularRB.Checked then + s := TStringStream.Create(LayoutTabularReport) + else + s := TStringStream.Create(LayoutColumnarReport); + FLayoutReport.LoadFromStream(s); + s.Free; + FLayoutReport.Styles := FStyleSheet[0]; + LayoutPBPaint(nil); +end; + +procedure TfrxStdWizardForm.FinishBClick(Sender: TObject); +var + Page: TfrxReportPage; + Band: TfrxBand; + Memo: TfrxCustomMemoView; + CurY, PageWidth, MaxHeaderWidth: Extended; + Widths, HeaderWidths, DataWidths: array of Extended; + + function Duplicate(n: Integer): String; + begin + Result := ''; + SetLength(Result, n); + FillChar(Result[1], n, '0'); + end; + + function CreateMemo(Parent: TfrxComponent): TfrxCustomMemoView; + begin + if FDotMatrix then + Result := TfrxDMPMemoView.Create(Parent) else + Result := TfrxMemoView.Create(Parent); + if Parent <> nil then + Result.CreateUniqueName; + end; + + procedure CreatePage; + begin + Page := TfrxReportPage(FReport.Pages[0]); + if PortraitRB.Checked then + Page.Orientation := poPortrait else + Page.Orientation := poLandscape; + PageWidth := (Page.PaperWidth - Page.LeftMargin - Page.RightMargin) * 96 / 25.4; + end; + + procedure CreateWidthsArray; + var + i, FieldsCount: Integer; + HeaderMemo, DataMemo: TfrxCustomMemoView; + MaxWidth, HeadersWidth, GapWidth: Extended; + Style: TfrxStyles; + begin + FieldsCount := AvailableFieldsLB.Items.Count; + SetLength(Widths, FieldsCount); + SetLength(HeaderWidths, FieldsCount); + SetLength(DataWidths, FieldsCount); + + HeaderMemo := CreateMemo(nil); + DataMemo := CreateMemo(nil); + if not FDotMatrix then + begin + Style := FStyleSheet.Find(StyleLB.Items[StyleLB.ItemIndex]); + HeaderMemo.ApplyStyle(Style.Find('Header')); + DataMemo.ApplyStyle(Style.Find('Data')); + end; + + MaxWidth := 0; + HeadersWidth := 0; + MaxHeaderWidth := 0; + GapWidth := 0; + for i := 0 to FieldsCount - 1 do + begin + HeaderMemo.Text := AvailableFieldsLB.Items[i]; + DataMemo.Text := Duplicate(FDataSet.DisplayWidth[AvailableFieldsLB.Items[i]]); + HeaderWidths[i] := HeaderMemo.CalcWidth; + DataWidths[i] := DataMemo.CalcWidth; + if HeaderWidths[i] > DataWidths[i] then + Widths[i] := HeaderWidths[i] + else + begin + Widths[i] := DataWidths[i]; + GapWidth := GapWidth + DataWidths[i] - HeaderWidths[i]; + end; + MaxWidth := MaxWidth + Widths[i]; + HeadersWidth := HeadersWidth + HeaderWidths[i]; + if HeaderWidths[i] > MaxHeaderWidth then + MaxHeaderWidth := HeaderWidths[i]; + end; + + if FitWidthCB.Checked and (MaxWidth > PageWidth) then + begin + if HeadersWidth > PageWidth then + begin + for i := 0 to FieldsCount - 1 do + Widths[i] := HeaderWidths[i] / (HeadersWidth / PageWidth); + end + else + begin + for i := 0 to FieldsCount - 1 do + if HeaderWidths[i] < DataWidths[i] then + Widths[i] := Widths[i] - (DataWidths[i] - HeaderWidths[i]) / + GapWidth * (MaxWidth - PageWidth); + end; + end; + + HeaderMemo.Free; + DataMemo.Free; + end; + + procedure CreateTitle; + begin + Band := TfrxReportTitle.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, 0, 0, fr01cm * 7); + CurY := 30; + + Memo := CreateMemo(Band); + Memo.SetBounds(0, 0, 0, fr01cm * 6); + Memo.Align := baWidth; + Memo.HAlign := haCenter; + Memo.VAlign := vaCenter; + Memo.Text := 'Report'; + Memo.Style := 'Title'; + end; + + procedure CreateHeader; + var + i: Integer; + X, Y: Extended; + HeaderMemo: TfrxCustomMemoView; + begin + if ColumnarRB.Checked then Exit; + + Band := TfrxPageHeader.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, CurY, 0, fr01cm * 7); + + HeaderMemo := CreateMemo(Band); + HeaderMemo.SetBounds(0, 0, PageWidth, 0); + HeaderMemo.Style := 'Header line'; + + X := 0; + Y := 0; + for i := 0 to AvailableFieldsLB.Items.Count - 1 do + begin + if X + Widths[i] > PageWidth + 1 then + begin + X := 0; + Y := Y + fr01cm * 6; + end; + + Memo := CreateMemo(Band); + Memo.SetBounds(X, Y, Widths[i], fr01cm * 6); + Memo.Text := AvailableFieldsLB.Items[i]; + Memo.Style := 'Header'; + + X := X + Widths[i]; + end; + + Band.Height := Y + fr01cm * 6; + HeaderMemo.Height := Band.Height; + if FDotMatrix then + HeaderMemo.Free; + CurY := CurY + Band.Height; + end; + + procedure CreateGroupHeaders; + var + i: Integer; + begin + for i := 0 to GroupsLB.Items.Count - 1 do + begin + Band := TfrxGroupHeader.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, CurY, 0, fr01cm * 7); + TfrxGroupHeader(Band).Condition := FDataSet.UserName + '."' + GroupsLB.Items[i] + '"'; + CurY := CurY + 30; + + Memo := CreateMemo(Band); + Memo.SetBounds(0, 0, 0, fr01cm * 6); + Memo.Align := baWidth; + Memo.VAlign := vaCenter; + Memo.DataSet := FDataSet; + Memo.DataField := GroupsLB.Items[i]; + Memo.Style := 'Group header'; + end; + end; + + procedure CreateData; + var + i: Integer; + X, Y: Extended; + begin + Band := TfrxMasterData.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, CurY, 0, 0); + TfrxMasterData(Band).DataSet := FDataSet; + CurY := CurY + 30; + + X := 0; + Y := 0; + for i := 0 to AvailableFieldsLB.Items.Count - 1 do + begin + if ColumnarRB.Checked then + begin + Memo := CreateMemo(Band); + Memo.SetBounds(0, Y, MaxHeaderWidth, fr01cm * 5); + Memo.Text := AvailableFieldsLB.Items[i]; + Memo.Style := 'Header'; + + Memo := CreateMemo(Band); + Memo.SetBounds(MaxHeaderWidth + fr01cm * 5, Y, DataWidths[i], fr01cm * 5); + Memo.DataSet := FDataSet; + Memo.DataField := AvailableFieldsLB.Items[i]; + Memo.Style := 'Data'; + + Y := Y + fr01cm * 5; + end + else + begin + if X + Widths[i] > PageWidth + 1 then + begin + X := 0; + Y := Y + fr01cm * 5; + end; + + Memo := CreateMemo(Band); + Memo.SetBounds(X, Y, Widths[i], fr01cm * 5); + Memo.DataSet := FDataSet; + Memo.DataField := AvailableFieldsLB.Items[i]; + Memo.Style := 'Data'; + + X := X + Widths[i]; + end; + end; + + Band.Height := Y + fr01cm * 5; + CurY := CurY + Band.Height; + end; + + procedure CreateGroupFooters; + var + i: Integer; + begin + CurY := 1000; + for i := GroupsLB.Items.Count - 1 downto 0 do + begin + Band := TfrxGroupFooter.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, CurY, 0, 0); + CurY := CurY - 30; + end; + end; + + procedure CreateFooter; + begin + Band := TfrxPageFooter.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, 1000, 0, fr01cm * 7); + + Memo := CreateMemo(Band); + Memo.Align := baWidth; + Memo.Frame.Typ := [ftTop]; + Memo.Frame.Width := 2; + + Memo := CreateMemo(Band); + Memo.SetBounds(0, 1, 0, fr01cm * 6); + Memo.AutoWidth := True; + Memo.Text := '[Date] [Time]'; + + Memo := CreateMemo(Band); + Memo.SetBounds(100, 1, fr1cm * 2, fr01cm * 6); + Memo.Align := baRight; + Memo.HAlign := haRight; + Memo.Text := 'Page [Page#]'; + end; + +begin + try + FDesigner.Lock; + FReport.FileName := ''; + FReport.DotMatrixReport := FDotMatrix; + + FReport.DataSets.Clear; + if FDataset <> nil then + FReport.DataSets.Add(FDataSet); + + CreatePage; + CreateWidthsArray; + CreateTitle; + CreateHeader; + CreateGroupHeaders; + CreateData; + CreateGroupFooters; + CreateFooter; + + if not FDotMatrix then + FReport.Styles := FStyleSheet.Find(StyleLB.Items[StyleLB.ItemIndex]); + + finally + FDesigner.ReloadReport; + Widths := nil; + HeaderWidths := nil; + DataWidths := nil; + end; +end; + +procedure TfrxStdWizardForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + + +initialization + frxWizards.Register1(TfrxStdWizard, 1); + frxWizards.Register1(TfrxStdEmptyWizard, 0); +{$IFNDEF FR_LITE} + frxWizards.Register1(TfrxDotMatrixWizard, 1); + frxWizards.Register1(TfrxDMPEmptyWizard, 0); +{$ENDIF} + +finalization + frxWizards.Unregister(TfrxStdWizard); + frxWizards.Unregister(TfrxStdEmptyWizard); +{$IFNDEF FR_LITE} + frxWizards.Unregister(TfrxDotMatrixWizard); + frxWizards.Unregister(TfrxDMPEmptyWizard); +{$ENDIF} + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxAdoWizard.res b/official/4.2/LibD11/frxAdoWizard.res new file mode 100644 index 0000000..cee610b Binary files /dev/null and b/official/4.2/LibD11/frxAdoWizard.res differ diff --git a/official/4.2/LibD11/frxAggregate.pas b/official/4.2/LibD11/frxAggregate.pas new file mode 100644 index 0000000..e15d8a2 --- /dev/null +++ b/official/4.2/LibD11/frxAggregate.pas @@ -0,0 +1,696 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Aggregate Functions } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxAggregate; + +interface + +{$I frx.inc} + +uses + Windows, SysUtils, Classes, Dialogs, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxAggregateFunction = (agSum, agAvg, agMin, agMax, agCount); + + TfrxAggregateItem = class(TObject) + private + FAggregateFunction: TfrxAggregateFunction; + FBand: TfrxDataBand; + FCountInvisibleBands: Boolean; + FDontReset: Boolean; + FExpression: String; + FIsPageFooter: Boolean; + FItemsArray: Variant; { used for vbands } + FItemsCount: Integer; + FItemsCountArray: Variant; { used for vbands } + FItemsValue: Variant; + FKeeping: Boolean; + FLastCount: Integer; + FLastValue: Variant; + FMemoName: String; + FOriginalName: String; + FParentBand: TfrxBand; + FReport: TfrxReport; + FTempItemsCount: Integer; + FTempItemsValue: Variant; + FVColumn: Integer; { used for vbands } + public + procedure Calc; + procedure DeleteValue; + procedure Reset; + procedure StartKeep; + procedure EndKeep; + function Value: Variant; + end; + + TfrxAggregateList = class(TObject) + private + FList: TList; + FReport: TfrxReport; + function GetItem(Index: Integer): TfrxAggregateItem; + procedure FindAggregates(Memo: TfrxCustomMemoView; DataBand: TfrxDataBand); + procedure ParseName(const ComplexName: String; var Func: TfrxAggregateFunction; + var Expr: String; var Band: TfrxDataBand; var CountInvisible, DontReset: Boolean); + property Items[Index: Integer]: TfrxAggregateItem read GetItem; default; + public + constructor Create(AReport: TfrxReport); + destructor Destroy; override; + procedure Clear; + procedure ClearValues; + + procedure AddItems(Page: TfrxReportPage); + procedure AddValue(Band: TfrxBand; VColumn: Integer = 0); + procedure DeleteValue(Band: TfrxBand); + procedure EndKeep; + procedure Reset(ParentBand: TfrxBand); + procedure StartKeep; + function GetValue(ParentBand: TfrxBand; const ComplexName: String; + VColumn: Integer = 0): Variant; overload; + function GetValue(ParentBand: TfrxBand; VColumn: Integer; + const Name, Expression: String; Band: TfrxBand; Flags: Integer): Variant; overload; + end; + + +implementation + +uses frxVariables, frxUtils; + +type + THackComponent = class(TfrxComponent); + +procedure Get3Params(const s: String; var i: Integer; + var s1, s2, s3: String); +var + c, d, oi, ci: Integer; +begin + s1 := ''; s2 := ''; s3 := ''; + c := 1; d := 1; oi := i + 1; ci := 1; + repeat + Inc(i); + if s[i] = '''' then + if d = 1 then Inc(d) else d := 1; + if d = 1 then + begin + if s[i] = '(' then + Inc(c) else + if s[i] = ')' then Dec(c); + if (s[i] = ',') and (c = 1) then + begin + if ci = 1 then + s1 := Copy(s, oi, i - oi) else + s2 := Copy(s, oi, i - oi); + oi := i + 1; Inc(ci); + end; + end; + until (c = 0) or (i >= Length(s)); + case ci of + 1: s1 := Copy(s, oi, i - oi); + 2: s2 := Copy(s, oi, i - oi); + 3: s3 := Copy(s, oi, i - oi); + end; + Inc(i); +end; + + +{ TfrxAggregateItem } + +procedure TfrxAggregateItem.Calc; +var + Value: Variant; + i: Integer; +begin + if not FBand.Visible and not FCountInvisibleBands then Exit; + + FReport.CurObject := FMemoName; + if FAggregateFunction <> agCount then + Value := FReport.Calc(FExpression) else + Value := Null; + + if VarType(Value) = varBoolean then + if Value = True then + Value := 1; + + { process vbands } + if FVColumn > 0 then + begin + if VarIsNull(FItemsArray) then + begin + FItemsArray := VarArrayCreate([0, 1000], varVariant); + FItemsCountArray := VarArrayCreate([0, 1000], varVariant); + for i := 0 to 1000 do + begin + FItemsArray[i] := Null; + FItemsCountArray[i] := 0; + end; + end; + + if (FAggregateFunction <> agAvg) or (Value <> Null) then + FItemsCountArray[FVColumn] := FItemsCountArray[FVColumn] + 1; + if FItemsArray[FVColumn] = Null then + FItemsArray[FVColumn] := Value + else if Value <> Null then + case FAggregateFunction of + agSum, agAvg: + FItemsArray[FVColumn] := FItemsArray[FVColumn] + Value; + agMin: + if Value < FItemsArray[FVColumn] then + FItemsArray[FVColumn] := Value; + agMax: + if Value > FItemsArray[FVColumn] then + FItemsArray[FVColumn] := Value; + end; + end + else if FKeeping then + begin + if (FAggregateFunction <> agAvg) or (Value <> Null) then + Inc(FTempItemsCount); + if FTempItemsValue = Null then + FTempItemsValue := Value + else if Value <> Null then + case FAggregateFunction of + agSum, agAvg: + FTempItemsValue := FTempItemsValue + Value; + agMin: + if Value < FTempItemsValue then + FTempItemsValue := Value; + agMax: + if Value > FTempItemsValue then + FTempItemsValue := Value; + end; + end + else + begin + FLastCount := FItemsCount; + FLastValue := FItemsValue; + if (FAggregateFunction <> agAvg) or (Value <> Null) then + Inc(FItemsCount); + if FItemsValue = Null then + FItemsValue := Value + else if Value <> Null then + case FAggregateFunction of + agSum, agAvg: + FItemsValue := FItemsValue + Value; + agMin: + if Value < FItemsValue then + FItemsValue := Value; + agMax: + if Value > FItemsValue then + FItemsValue := Value; + end; + end; +end; + +procedure TfrxAggregateItem.DeleteValue; +begin + FItemsCount := FLastCount; + FItemsValue := FLastValue; +end; + +procedure TfrxAggregateItem.Reset; +begin + if FDontReset and (FItemsCount <> 0) then Exit; + + FItemsCount := 0; + FItemsValue := Null; + FItemsArray := Null; + FItemsCountArray := Null; +end; + +procedure TfrxAggregateItem.StartKeep; +begin + if not FIsPageFooter or FKeeping then Exit; + FKeeping := True; + + FTempItemsCount := 0; + FTempItemsValue := Null; +end; + +procedure TfrxAggregateItem.EndKeep; +begin + if not FIsPageFooter or not FKeeping then Exit; + FKeeping := False; + + FItemsCount := FItemsCount + FTempItemsCount; + if FTempItemsValue <> Null then + case FAggregateFunction of + agMin: + if FTempItemsValue < FItemsValue then + FItemsValue := FTempItemsValue; + agMax: + if FTempItemsValue > FItemsValue then + FItemsValue := FTempItemsValue; + else + FItemsValue := FItemsValue + FTempItemsValue; + end; +end; + +function TfrxAggregateItem.Value: Variant; +begin + Result := Null; + if not VarIsNull(FItemsArray) then + begin + case FAggregateFunction of + agSum, agMin, agMax: + Result := FItemsArray[FVColumn]; + agAvg: + Result := FItemsArray[FVColumn] / FItemsCountArray[FVColumn]; + agCount: + Result := FItemsCountArray[FVColumn]; + end + end + else + case FAggregateFunction of + agSum, agMin, agMax: + Result := FItemsValue; + agAvg: + Result := FItemsValue / FItemsCount; + agCount: + Result := FItemsCount; + end; + + if VarIsNull(Result) then + Result := 0; +end; + + +{ TfrxAggregateList } + +constructor TfrxAggregateList.Create(AReport: TfrxReport); +begin + FList := TList.Create; + FReport := AReport; +end; + +destructor TfrxAggregateList.Destroy; +begin + Clear; + FList.Free; + inherited; +end; + +procedure TfrxAggregateList.Clear; +begin + while FList.Count > 0 do + begin + TObject(FList[0]).Free; + FList.Delete(0); + end; +end; + +function TfrxAggregateList.GetItem(Index: Integer): TfrxAggregateItem; +begin + Result := FList[Index]; +end; + +procedure TfrxAggregateList.ParseName(const ComplexName: String; + var Func: TfrxAggregateFunction; var Expr: String; var Band: TfrxDataBand; + var CountInvisible, DontReset: Boolean); +var + i: Integer; + Name, Param1, Param2, Param3: String; +begin + i := Pos('(', ComplexName); + Name := UpperCase(Trim(Copy(ComplexName, 1, i - 1))); + Get3Params(ComplexName, i, Param1, Param2, Param3); + Param1 := Trim(Param1); + Param2 := Trim(Param2); + Param3 := Trim(Param3); + + if Name = 'SUM' then + Func := agSum + else if Name = 'MIN' then + Func := agMin + else if Name = 'MAX' then + Func := agMax + else if Name = 'AVG' then + Func := agAvg + else //if Name = 'COUNT' then + Func := agCount; + + if Name <> 'COUNT' then + begin + Expr := Param1; + if Param2 <> '' then + Band := TfrxDataBand(FReport.FindObject(Param2)) else + Band := nil; + if Param3 <> '' then + i := StrToInt(Param3) else + i := 0; + end + else + begin + Expr := ''; + Band := TfrxDataBand(FReport.FindObject(Param1)); + if Param2 <> '' then + i := StrToInt(Param2) else + i := 0; + end; + + CountInvisible := (i and 1) <> 0; + DontReset := (i and 2) <> 0; +end; + +procedure TfrxAggregateList.FindAggregates(Memo: TfrxCustomMemoView; + DataBand: TfrxDataBand); +const + Spaces = [#1..#32, '!', '#', '$', '%', '^', '&', '|', '+', '-', '*', '/', + '=', '.', ',', '[', ']', '0'..'9']; + IdentSpaces = Spaces - ['0'..'9'] + ['(']; +var + i, j: Integer; + s, s1, dc1, dc2: String; + Report: TfrxReport; + + procedure FindIn(const s: String); forward; + + procedure SkipString(const s: String; var i: Integer); + var + ch: Char; + begin + ch := s[i]; + Inc(i); + while (i <= Length(s)) and (s[i] <> ch) do + Inc(i); + Inc(i); + end; + + function Check(s: String): Boolean; + var + i: Integer; + ds: TfrxDataSet; + s1: String; + VarVal: Variant; + begin + Result := False; + if s = '' then Exit; + + { searching in the variables } + i := Report.Variables.IndexOf(s); + if i <> -1 then + begin + VarVal := Report.Variables.Items[i].Value; + if VarIsNull(VarVal) then + s := '' + else + s := VarVal; + FindIn(s); + Result := True; + Exit; + end; + + { maybe it's a dataset/field? } + Report.GetDataSetAndField(s, ds, s1); + if (ds <> nil) and (s1 <> '') then + Result := True; + end; + + procedure AddAggregate(const ComplexName: String); + var + Item: TfrxAggregateItem; + begin + Item := TfrxAggregateItem.Create; + FList.Add(Item); + + ParseName(ComplexName, Item.FAggregateFunction, Item.FExpression, + Item.FBand, Item.FCountInvisibleBands, Item.FDontReset); + if Item.FBand = nil then + Item.FBand := DataBand; + + Item.FReport := FReport; + Item.FParentBand := TfrxBand(Memo.Parent); + if Item.FParentBand.Vertical and (THackComponent(Memo).FOriginalBand <> nil) and + (TfrxBand(THackComponent(Memo).FOriginalBand).BandNumber in [1, 3, 5, 13]) then + Item.FParentBand := TfrxBand(THackComponent(Memo).FOriginalBand); + Item.FIsPageFooter := Item.FParentBand is TfrxPageFooter; + Item.FOriginalName := Trim(ComplexName); + Item.FMemoName := Memo.Name; + Item.Reset; + end; + + procedure FindIn(const s: String); + var + i, j: Integer; + s1, s2, s3, s4: String; + begin + if Check(s) then + Exit; + + { this is an expression } + i := 1; + while i <= Length(s) do + begin + { skip non-significant chars } + while (i <= Length(s)) and (s[i] in Spaces) do + Inc(i); + + case s[i] of + '<': + begin + FindIn(frxGetBrackedVariable(s, '<', '>', i, j)); + i := j; + end; + + '''', '"': + SkipString(s, i); + + '(': + begin + FindIn(frxGetBrackedVariable(s, '(', ')', i, j)); + if i = j then + Inc(i) else + i := j; + end; + else + begin + j := i; + while (i <= Length(s)) and not (s[i] in IdentSpaces) do + Inc(i); + s1 := UpperCase(Copy(s, j, i - j)); + + if (s1 = 'SUM') or (s1 = 'MIN') or (s1 = 'MAX') or + (s1 = 'AVG') or (s1 = 'COUNT') then + begin + if (i < Length(s)) and (s[i] = '(') then + begin + Get3Params(s, i, s2, s3, s4); + AddAggregate(Copy(s, j, i - j)); + end; + end + else + Check(s1); + end; + end; + end; + end; + +begin + Report := Memo.Report; + if Memo.AllowExpressions then + begin + s := Memo.Text; + i := 1; + dc1 := Memo.ExpressionDelimiters; + dc2 := Copy(dc1, Pos(',', dc1) + 1, 255); + dc1 := Copy(dc1, 1, Pos(',', dc1) - 1); + + repeat + while (i < Length(s)) and (Copy(s, i, Length(dc1)) <> dc1) do Inc(i); + s1 := frxGetBrackedVariable(s, dc1, dc2, i, j); + if i <> j then + begin + FindIn(s1); + i := j; + j := 0; + end; + until i = j; + end; +end; + +procedure TfrxAggregateList.AddItems(Page: TfrxReportPage); + + procedure EnumObjects(ParentBand: TfrxBand; DataBand: TfrxDataBand); + var + i: Integer; + c: TfrxComponent; + begin + if ParentBand = nil then Exit; + + for i := 0 to ParentBand.Objects.Count - 1 do + begin + c := ParentBand.Objects[i]; + if c is TfrxCustomMemoView then + FindAggregates(TfrxCustomMemoView(c), DataBand); + end; + + if ParentBand.Child <> nil then + EnumObjects(ParentBand.Child, DataBand); + end; + + procedure EnumGroups(GroupHeader: TfrxGroupHeader; DataBand: TfrxDataBand); + var + i: Integer; + g: TfrxGroupHeader; + begin + if GroupHeader = nil then Exit; + + for i := 0 to GroupHeader.FSubBands.Count - 1 do + begin + g := GroupHeader.FSubBands[i]; + EnumObjects(g.FFooter, DataBand); + end; + end; + + procedure EnumDataBands(List: TList); + var + i: Integer; + d: TfrxDataBand; + begin + for i := 0 to List.Count - 1 do + begin + d := List[i]; + EnumObjects(d.FFooter, d); + EnumGroups(TfrxGroupHeader(d.FGroup), d); + EnumDataBands(d.FSubBands); + if d.Vertical then + EnumObjects(d, d); + end; + end; + +begin + EnumDataBands(Page.FSubBands); + EnumDataBands(Page.FVSubBands); + if Page.FSubBands.Count > 0 then + begin + EnumObjects(Page.FindBand(TfrxPageFooter), Page.FSubBands[0]); + EnumObjects(Page.FindBand(TfrxColumnFooter), Page.FSubBands[0]); + EnumObjects(Page.FindBand(TfrxReportSummary), Page.FSubBands[0]); + end; +end; + +procedure TfrxAggregateList.AddValue(Band: TfrxBand; VColumn: Integer = 0); +var + i: Integer; +begin + for i := 0 to FList.Count - 1 do + if Items[i].FBand = Band then + begin + Items[i].FVColumn := VColumn; + Items[i].Calc; + end; +end; + +procedure TfrxAggregateList.DeleteValue(Band: TfrxBand); +var + i: Integer; +begin + for i := 0 to FList.Count - 1 do + if Items[i].FBand = Band then + Items[i].DeleteValue; +end; + +function TfrxAggregateList.GetValue(ParentBand: TfrxBand; + const ComplexName: String; VColumn: Integer = 0): Variant; +var + i: Integer; +begin + Result := Null; + + for i := 0 to FList.Count - 1 do + if (Items[i].FParentBand = ParentBand) and + (AnsiCompareText(Items[i].FOriginalName, Trim(ComplexName)) = 0) then + begin + Items[i].FVColumn := VColumn; + Result := Items[i].Value; + break; + end; +end; + +function TfrxAggregateList.GetValue(ParentBand: TfrxBand; VColumn: Integer; + const Name, Expression: String; Band: TfrxBand; Flags: Integer): Variant; +var + i: Integer; + fn: TfrxAggregateFunction; +begin + Result := Null; + if Name = 'SUM' then + fn := agSum + else if Name = 'AVG' then + fn := agAvg + else if Name = 'MIN' then + fn := agMin + else if Name = 'MAX' then + fn := agMax + else + fn := agCount; + + for i := 0 to FList.Count - 1 do + if (Items[i].FParentBand = ParentBand) and + (Items[i].FAggregateFunction = fn) and + (AnsiCompareText(Items[i].FExpression, Trim(Expression)) = 0) and + ((Band = nil) or (Items[i].FBand = Band)) and + (Items[i].FCountInvisibleBands = ((Flags and 1) <> 0)) and + (Items[i].FDontReset = ((Flags and 2) <> 0)) then + begin + Items[i].FVColumn := VColumn; + Result := Items[i].Value; + break; + end; +end; + +procedure TfrxAggregateList.Reset(ParentBand: TfrxBand); +var + i: Integer; +begin + for i := 0 to FList.Count - 1 do + if Items[i].FParentBand = ParentBand then + Items[i].Reset; +end; + +procedure TfrxAggregateList.StartKeep; +var + i: Integer; +begin + for i := 0 to FList.Count - 1 do + Items[i].StartKeep; +end; + +procedure TfrxAggregateList.EndKeep; +var + i: Integer; +begin + for i := 0 to FList.Count - 1 do + Items[i].EndKeep; +end; + +procedure TfrxAggregateList.ClearValues; +var + i: Integer; + SaveReset: Boolean; +begin + for i := 0 to FList.Count - 1 do + begin + SaveReset := Items[i].FDontReset; + Items[i].FDontReset := False; + Items[i].Reset; + Items[i].FDontReset := SaveReset; + end; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxBDE10.bdsproj b/official/4.2/LibD11/frxBDE10.bdsproj new file mode 100644 index 0000000..710eea2 --- /dev/null +++ b/official/4.2/LibD11/frxBDE10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxBDE10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxBDE10.dpk b/official/4.2/LibD11/frxBDE10.dpk new file mode 100644 index 0000000..e0fe150 --- /dev/null +++ b/official/4.2/LibD11/frxBDE10.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2006 + +package frxBDE10; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + frx10, + frxDB10, +{$IFDEF QBUILDER} + fqb100, +{$ENDIF} + fs10, + fsBDE10; + +contains + frxBDEComponents in 'frxBDEComponents.pas', + frxBDEEditor in 'frxBDEEditor.pas', + frxBDERTTI in 'frxBDERTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxBDE11.bdsproj b/official/4.2/LibD11/frxBDE11.bdsproj new file mode 100644 index 0000000..c9b15be --- /dev/null +++ b/official/4.2/LibD11/frxBDE11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxBDE11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxBDE11.dpk b/official/4.2/LibD11/frxBDE11.dpk new file mode 100644 index 0000000..64728a6 --- /dev/null +++ b/official/4.2/LibD11/frxBDE11.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2007 + +package frxBDE11; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + frx11, + frxDB11, +{$IFDEF QBUILDER} + fqb110, +{$ENDIF} + fs11, + fsBDE11; + +contains + frxBDEComponents in 'frxBDEComponents.pas', + frxBDEEditor in 'frxBDEEditor.pas', + frxBDERTTI in 'frxBDERTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxBDE4.bpk b/official/4.2/LibD11/frxBDE4.bpk new file mode 100644 index 0000000..5532d18 --- /dev/null +++ b/official/4.2/LibD11/frxBDE4.bpk @@ -0,0 +1,189 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = frxBDE4.bpl +OBJFILES = frxBDEReg.obj frxBDE4.obj +RESFILES = frxBDE4.res frxBDEReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +LIBRARIES = +SPARELIBS = VCL40.lib +PACKAGES = vcl40.bpi vcldb40.bpi frx4.bpi frxDB4.bpi fs4.bpi fsBDE4.bpi fqb40.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release;..\;..\..\FastScript;..\..\FastQB +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -D"FastReport 4.0 BDE Components" -aa \ + -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxBDE4.cpp b/official/4.2/LibD11/frxBDE4.cpp new file mode 100644 index 0000000..6ca5c81 --- /dev/null +++ b/official/4.2/LibD11/frxBDE4.cpp @@ -0,0 +1,23 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frxBDE4.res"); +USEPACKAGE("vcl40.bpi"); +USEUNIT("frxBDEReg.pas"); +USERES("frxBDEReg.dcr"); +USEPACKAGE("vcldb40.bpi"); +USEPACKAGE("frx4.bpi"); +USEPACKAGE("fs4.bpi"); +USEPACKAGE("frxDB4.bpi"); +USEPACKAGE("fsBDE4.bpi"); +USEPACKAGE("fqb40.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxBDE4.dpk b/official/4.2/LibD11/frxBDE4.dpk new file mode 100644 index 0000000..87754d8 --- /dev/null +++ b/official/4.2/LibD11/frxBDE4.dpk @@ -0,0 +1,47 @@ +// Package file for Delphi 4 + +package frxBDE4; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + VCLDB40, + frx4, + frxDB4, +{$IFDEF QBUILDER} + fqb40, +{$ENDIF} + fs4, + fsBDE4; + +contains + frxBDEComponents in 'frxBDEComponents.pas', + frxBDEEditor in 'frxBDEEditor.pas', + frxBDERTTI in 'frxBDERTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxBDE4.res b/official/4.2/LibD11/frxBDE4.res new file mode 100644 index 0000000..eb2597a Binary files /dev/null and b/official/4.2/LibD11/frxBDE4.res differ diff --git a/official/4.2/LibD11/frxBDE5.bpk b/official/4.2/LibD11/frxBDE5.bpk new file mode 100644 index 0000000..404a73c --- /dev/null +++ b/official/4.2/LibD11/frxBDE5.bpk @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxBDE5.cpp b/official/4.2/LibD11/frxBDE5.cpp new file mode 100644 index 0000000..c2b928e --- /dev/null +++ b/official/4.2/LibD11/frxBDE5.cpp @@ -0,0 +1,28 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("frxBDE5.res"); +USEPACKAGE("vcl50.bpi"); +USEUNIT("frxBDEReg.pas"); +USERES("frxBDEReg.dcr"); +USEPACKAGE("vcldb50.bpi"); +USEPACKAGE("vclbde50.bpi"); +USEPACKAGE("frx5.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("frxDB5.bpi"); +USEPACKAGE("fsBDE5.bpi"); +USEPACKAGE("fqb50.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxBDE5.dpk b/official/4.2/LibD11/frxBDE5.dpk new file mode 100644 index 0000000..2592100 --- /dev/null +++ b/official/4.2/LibD11/frxBDE5.dpk @@ -0,0 +1,48 @@ +// Package file for Delphi 5 + +package frxBDE5; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + VCLDB50, + VCLBDE50, + frx5, + frxDB5, +{$IFDEF QBUILDER} + fqb50, +{$ENDIF} + fs5, + fsBDE5; + +contains + frxBDEComponents in 'frxBDEComponents.pas', + frxBDEEditor in 'frxBDEEditor.pas', + frxBDERTTI in 'frxBDERTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxBDE5.res b/official/4.2/LibD11/frxBDE5.res new file mode 100644 index 0000000..da3d366 Binary files /dev/null and b/official/4.2/LibD11/frxBDE5.res differ diff --git a/official/4.2/LibD11/frxBDE6.bpk b/official/4.2/LibD11/frxBDE6.bpk new file mode 100644 index 0000000..2466756 --- /dev/null +++ b/official/4.2/LibD11/frxBDE6.bpk @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=1 +Item0=_DEBUG + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxBDE6.cpp b/official/4.2/LibD11/frxBDE6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/frxBDE6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frxBDE6.dpk b/official/4.2/LibD11/frxBDE6.dpk new file mode 100644 index 0000000..bd31789 --- /dev/null +++ b/official/4.2/LibD11/frxBDE6.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 6 + +package frxBDE6; + +{$I frx.inc} + +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + frx6, + frxDB6, +{$IFDEF QBUILDER} + fqb60, +{$ENDIF} + fs6, + fsBDE6; + +contains + frxBDEComponents in 'frxBDEComponents.pas', + frxBDEEditor in 'frxBDEEditor.pas', + frxBDERTTI in 'frxBDERTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxBDE6.res b/official/4.2/LibD11/frxBDE6.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frxBDE6.res differ diff --git a/official/4.2/LibD11/frxBDE7.dpk b/official/4.2/LibD11/frxBDE7.dpk new file mode 100644 index 0000000..a816162 --- /dev/null +++ b/official/4.2/LibD11/frxBDE7.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 7 + +package frxBDE7; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + frx7, + frxDB7, +{$IFDEF QBUILDER} + fqb70, +{$ENDIF} + fs7, + fsBDE7; + +contains + frxBDEComponents in 'frxBDEComponents.pas', + frxBDEEditor in 'frxBDEEditor.pas', + frxBDERTTI in 'frxBDERTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxBDE9.bdsproj b/official/4.2/LibD11/frxBDE9.bdsproj new file mode 100644 index 0000000..5f85553 --- /dev/null +++ b/official/4.2/LibD11/frxBDE9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxBDE9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxBDE9.dpk b/official/4.2/LibD11/frxBDE9.dpk new file mode 100644 index 0000000..b58b545 --- /dev/null +++ b/official/4.2/LibD11/frxBDE9.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2005 + +package frxBDE9; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + frx9, + frxDB9, +{$IFDEF QBUILDER} + fqb90, +{$ENDIF} + fs9, + fsBDE9; + +contains + frxBDEComponents in 'frxBDEComponents.pas', + frxBDEEditor in 'frxBDEEditor.pas', + frxBDERTTI in 'frxBDERTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxBDEComponents.pas b/official/4.2/LibD11/frxBDEComponents.pas new file mode 100644 index 0000000..02e3b04 --- /dev/null +++ b/official/4.2/LibD11/frxBDEComponents.pas @@ -0,0 +1,476 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ BDE enduser components } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxBDEComponents; + +interface + +{$I frx.inc} + +uses + Windows, Classes, SysUtils, frxClass, frxCustomDB, DB, DBTables +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF QBUILDER} +, fqbClass +{$ENDIF}; + + +type + TfrxBDEComponents = class(TfrxDBComponents) + private + FDefaultDatabase: String; + FDefaultSession: String; + FOldComponents: TfrxBDEComponents; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDescription: String; override; + published + property DefaultDatabase: String read FDefaultDatabase write FDefaultDatabase; + property DefaultSession: String read FDefaultSession write FDefaultSession; + end; + + TfrxBDEDatabase = class(TfrxCustomDatabase) + private + FDatabase: TDatabase; + procedure SetAliasName(const Value: String); + procedure SetDriverName(const Value: String); + function GetAliasName: String; + function GetDriverName: String; + protected + function GetConnected: Boolean; override; + function GetDatabaseName: String; override; + function GetLoginPrompt: Boolean; override; + function GetParams: TStrings; override; + procedure SetConnected(Value: Boolean); override; + procedure SetDatabaseName(const Value: String); override; + procedure SetLoginPrompt(Value: Boolean); override; + procedure SetParams(Value: TStrings); override; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property Database: TDatabase read FDatabase; + published + property AliasName: String read GetAliasName write SetAliasName; + property DatabaseName; + property DriverName: String read GetDriverName write SetDriverName; + property LoginPrompt; + property Params; + property Connected; + end; + + TfrxBDETable = class(TfrxCustomTable) + private + FTable: TTable; + procedure SetDatabaseName(const Value: String); + function GetDatabaseName: String; + procedure SetSessionName(const Value: String); + function GetSessionName: String; + protected + procedure SetMaster(const Value: TDataSource); override; + procedure SetMasterFields(const Value: String); override; + procedure SetIndexName(const Value: String); override; + procedure SetIndexFieldNames(const Value: String); override; + procedure SetTableName(const Value: String); override; + function GetIndexName: String; override; + function GetIndexFieldNames: String; override; + function GetTableName: String; override; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property Table: TTable read FTable; + published + property DatabaseName: String read GetDatabaseName write SetDatabaseName; + property SessionName: String read GetSessionName write SetSessionName; + end; + + TfrxBDEQuery = class(TfrxCustomQuery) + private + FQuery: TQuery; + procedure SetDatabaseName(const Value: String); + function GetDatabaseName: String; + procedure SetSessionName(const Value: String); + function GetSessionName: String; + protected + procedure SetMaster(const Value: TDataSource); override; + procedure SetSQL(Value: TStrings); override; + function GetSQL: TStrings; override; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + procedure UpdateParams; override; +{$IFDEF QBUILDER} + function QBEngine: TfqbEngine; override; +{$ENDIF} + property Query: TQuery read FQuery; + published + property DatabaseName: String read GetDatabaseName write SetDatabaseName; + property SessionName: String read GetSessionName write SetSessionName; + end; + +{$IFDEF QBUILDER} + TfrxEngineBDE = class(TfqbEngine) + private + FQuery: TQuery; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure ReadTableList(ATableList: TStrings); override; + procedure ReadFieldList(const ATableName: string; var AFieldList: TfqbFieldList); override; + function ResultDataSet: TDataSet; override; + procedure SetSQL(const Value: string); override; + end; +{$ENDIF} + +var + BDEComponents: TfrxBDEComponents; + + +implementation + +uses + frxBDERTTI, +{$IFNDEF NO_EDITORS} + frxBDEEditor, +{$ENDIF} + frxDsgnIntf, frxRes; + + +{ TfrxDBComponents } + +constructor TfrxBDEComponents.Create(AOwner: TComponent); +begin + inherited; + FDefaultSession := 'Default'; + FOldComponents := BDEComponents; + BDEComponents := Self; +end; + +destructor TfrxBDEComponents.Destroy; +begin + if BDEComponents = Self then + BDEComponents := FOldComponents; + inherited; +end; + +function TfrxBDEComponents.GetDescription: String; +begin + Result := 'BDE'; +end; + + +{ TfrxBDEDatabase } + +constructor TfrxBDEDatabase.Create(AOwner: TComponent); +begin + inherited; + FDatabase := TDatabase.Create(nil); + Component := FDatabase; +end; + +class function TfrxBDEDatabase.GetDescription: String; +begin + Result := frxResources.Get('obBDEDB'); +end; + +function TfrxBDEDatabase.GetAliasName: String; +begin + Result := FDatabase.AliasName; +end; + +function TfrxBDEDatabase.GetConnected: Boolean; +begin + Result := FDatabase.Connected; +end; + +function TfrxBDEDatabase.GetDatabaseName: String; +begin + Result := FDatabase.DatabaseName; +end; + +function TfrxBDEDatabase.GetDriverName: String; +begin + Result := FDatabase.DriverName; +end; + +function TfrxBDEDatabase.GetLoginPrompt: Boolean; +begin + Result := FDatabase.LoginPrompt; +end; + +function TfrxBDEDatabase.GetParams: TStrings; +begin + Result := FDatabase.Params; +end; + +procedure TfrxBDEDatabase.SetAliasName(const Value: String); +begin + FDatabase.AliasName := Value; +end; + +procedure TfrxBDEDatabase.SetConnected(Value: Boolean); +begin + BeforeConnect(Value); + FDatabase.Connected := Value; +end; + +procedure TfrxBDEDatabase.SetDatabaseName(const Value: String); +begin + FDatabase.DatabaseName := Value; +end; + +procedure TfrxBDEDatabase.SetDriverName(const Value: String); +begin + FDatabase.DriverName := Value; +end; + +procedure TfrxBDEDatabase.SetLoginPrompt(Value: Boolean); +begin + FDatabase.LoginPrompt := Value; +end; + +procedure TfrxBDEDatabase.SetParams(Value: TStrings); +begin + FDatabase.Params := Value; +end; + + +{ TfrxBDETable } + +constructor TfrxBDETable.Create(AOwner: TComponent); +begin + FTable := TTable.Create(nil); + DataSet := FTable; + if BDEComponents <> nil then + begin + DatabaseName := BDEComponents.DefaultDatabase; + SessionName := BDEComponents.DefaultSession; + end; + inherited; +end; + +class function TfrxBDETable.GetDescription: String; +begin + Result := frxResources.Get('obBDETb'); +end; + +function TfrxBDETable.GetDatabaseName: String; +begin + Result := FTable.DatabaseName; +end; + +function TfrxBDETable.GetSessionName: String; +begin + Result := FTable.SessionName; +end; + +procedure TfrxBDETable.SetDatabaseName(const Value: String); +begin + FTable.DatabaseName := Value; + DBConnected := True; +end; + +procedure TfrxBDETable.SetSessionName(const Value: String); +begin + FTable.SessionName := Value; +end; + +function TfrxBDETable.GetIndexName: String; +begin + Result := FTable.IndexName; +end; + +function TfrxBDETable.GetIndexFieldNames: String; +begin + Result := FTable.IndexFieldNames; +end; + +function TfrxBDETable.GetTableName: String; +begin + Result := FTable.TableName; +end; + +procedure TfrxBDETable.SetIndexName(const Value: String); +begin + FTable.IndexName := Value; +end; + +procedure TfrxBDETable.SetIndexFieldNames(const Value: String); +begin + FTable.IndexFieldNames := Value; +end; + +procedure TfrxBDETable.SetTableName(const Value: String); +begin + FTable.TableName := Value; +end; + +procedure TfrxBDETable.SetMaster(const Value: TDataSource); +begin + FTable.MasterSource := Value; +end; + +procedure TfrxBDETable.SetMasterFields(const Value: String); +begin + FTable.MasterFields := Value; +end; + + +{ TfrxBDEQuery } + +constructor TfrxBDEQuery.Create(AOwner: TComponent); +begin + FQuery := TQuery.Create(nil); + Dataset := FQuery; + if BDEComponents <> nil then + begin + DatabaseName := BDEComponents.DefaultDatabase; + SessionName := BDEComponents.DefaultSession; + end; + inherited; +end; + +class function TfrxBDEQuery.GetDescription: String; +begin + Result := frxResources.Get('obBDEQ'); +end; + +function TfrxBDEQuery.GetDatabaseName: String; +begin + Result := FQuery.DatabaseName; +end; + +function TfrxBDEQuery.GetSessionName: String; +begin + Result := FQuery.SessionName; +end; + +function TfrxBDEQuery.GetSQL: TStrings; +begin + Result := FQuery.SQL; +end; + +procedure TfrxBDEQuery.SetDatabaseName(const Value: String); +begin + FQuery.DatabaseName := Value; + DBConnected := True; +end; + +procedure TfrxBDEQuery.SetMaster(const Value: TDataSource); +begin + FQuery.DataSource := Value; +end; + +procedure TfrxBDEQuery.SetSessionName(const Value: String); +begin + FQuery.SessionName := Value; +end; + +procedure TfrxBDEQuery.SetSQL(Value: TStrings); +begin + FQuery.SQL := Value; +end; + +procedure TfrxBDEQuery.UpdateParams; +begin + frxParamsToTParams(Self, FQuery.Params); +end; + +{$IFDEF QBUILDER} +function TfrxBDEQuery.QBEngine: TfqbEngine; +begin + Result := TfrxEngineBDE.Create(nil); + TfrxEngineBDE(Result).FQuery.DatabaseName := FQuery.DatabaseName; +end; +{$ENDIF} + + +{$IFDEF QBUILDER} +constructor TfrxEngineBDE.Create(AOwner: TComponent); +begin + inherited; + FQuery := TQuery.Create(Self); +end; + +destructor TfrxEngineBDE.Destroy; +begin + FQuery.Free; + inherited +end; + +procedure TfrxEngineBDE.ReadFieldList(const ATableName: string; + var AFieldList: TfqbFieldList); +var + TempTable: TTable; + Fields: TFieldDefs; + i: Integer; + tmpField: TfqbField; +begin + AFieldList.Clear; + TempTable := TTable.Create(Self); + TempTable.DatabaseName := FQuery.DatabaseName; + TempTable.TableName := ATableName; + Fields := TempTable.FieldDefs; + try + try + TempTable.Active := True; + tmpField:= TfqbField(AFieldList.Add); + tmpField.FieldName := '*'; + for i := 0 to Fields.Count - 1 do + begin + tmpField := TfqbField(AFieldList.Add); + tmpField.FieldName := Fields.Items[i].Name; + tmpField.FieldType := Ord(Fields.Items[i].DataType) + end; + except + end; + finally + TempTable.Free; + end; +end; + +procedure TfrxEngineBDE.ReadTableList(ATableList: TStrings); +begin + ATableList.BeginUpdate; + ATableList.Clear; + try + Session.GetTableNames(FQuery.DatabaseName, '', True, ShowSystemTables, ATableList); + finally + ATableList.EndUpdate; + end; +end; + +function TfrxEngineBDE.ResultDataSet: TDataSet; +begin + Result := FQuery; +end; + +procedure TfrxEngineBDE.SetSQL(const Value: string); +begin + FQuery.SQL.Text := Value; +end; +{$ENDIF} + +initialization + frxObjects.RegisterObject1(TfrxBDEDataBase, nil, '', '', 0, 54); + frxObjects.RegisterObject1(TfrxBDETable, nil, '', '', 0, 55); + frxObjects.RegisterObject1(TfrxBDEQuery, nil, '', '', 0, 56); + +finalization + frxObjects.UnRegister(TfrxBDEDataBase); + frxObjects.UnRegister(TfrxBDETable); + frxObjects.UnRegister(TfrxBDEQuery); + + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxBDEEditor.pas b/official/4.2/LibD11/frxBDEEditor.pas new file mode 100644 index 0000000..73d37af --- /dev/null +++ b/official/4.2/LibD11/frxBDEEditor.pas @@ -0,0 +1,199 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ BDE components design editors } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxBDEEditor; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, frxBDEComponents, frxCustomDB, frxDsgnIntf, DB, DBTables +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxAliasNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + TfrxDriverNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + TfrxDataBaseNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + TfrxSessionNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + TfrxTableNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxIndexNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + +{ TfrxAliasNameProperty } + +function TfrxAliasNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +procedure TfrxAliasNameProperty.GetValues; +begin + inherited; + Session.GetAliasNames(Values); +end; + + +{ TfrxDriverNameProperty } + +function TfrxDriverNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +procedure TfrxDriverNameProperty.GetValues; +begin + inherited; + Session.GetDriverNames(Values); +end; + + +{ TfrxDataBaseNameProperty } + +function TfrxDataBaseNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +procedure TfrxDataBaseNameProperty.GetValues; +var + Session: TSession; +begin + inherited; + Session := Sessions.FindSession(TDBDataSet(TfrxCustomDataset(Component).DataSet).SessionName); + if Session <> nil then + Session.GetAliasNames(Values); +end; + + +{ TfrxSessionNameProperty } + +function TfrxSessionNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +procedure TfrxSessionNameProperty.GetValues; +begin + Sessions.GetSessionNames(Values); +end; + + +{ TfrxTableNameProperty } + +function TfrxTableNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +procedure TfrxTableNameProperty.GetValues; +var + t: TTable; + Session: TSession; +begin + inherited; + t := TfrxBDETable(Component).Table; + Session := Sessions.FindSession(t.SessionName); + if (Session <> nil) and (t.DatabaseName <> '') then + try + Session.GetTableNames(t.DatabaseName, '', True, False, Values); + except + end; +end; + +procedure TfrxTableNameProperty.SetValue(const Value: String); +begin + inherited; + Designer.UpdateDataTree; +end; + + +{ TfrxIndexProperty } + +function TfrxIndexNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +procedure TfrxIndexNameProperty.GetValues; +var + i: Integer; +begin + inherited; + try + with TfrxBDETable(Component).Table do + if (TableName <> '') and (IndexDefs <> nil) then + begin + IndexDefs.Update; + for i := 0 to IndexDefs.Count - 1 do + if IndexDefs[i].Name <> '' then + Values.Add(IndexDefs[i].Name); + end; + except + end; +end; + + +initialization + frxPropertyEditors.Register(TypeInfo(String), TfrxBDEDatabase, 'AliasName', + TfrxAliasNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxBDEDatabase, 'DriverName', + TfrxDriverNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxBDETable, 'DatabaseName', + TfrxDataBaseNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxBDETable, 'SessionName', + TfrxSessionNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxBDETable, 'TableName', + TfrxTableNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxBDETable, 'IndexName', + TfrxIndexNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxBDEQuery, 'DatabaseName', + TfrxDataBaseNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxBDEQuery, 'SessionName', + TfrxSessionNameProperty); + +end. diff --git a/official/4.2/LibD11/frxBDERTTI.pas b/official/4.2/LibD11/frxBDERTTI.pas new file mode 100644 index 0000000..3a53a15 --- /dev/null +++ b/official/4.2/LibD11/frxBDERTTI.pas @@ -0,0 +1,102 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ BDE components RTTI } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxBDERTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, frxBDEComponents, + fs_ibdertti +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + with AddClass(TfrxBDEDatabase, 'TfrxCustomDatabase') do + AddProperty('Database', 'TDatabase', GetProp, nil); + with AddClass(TfrxBDETable, 'TfrxCustomTable') do + AddProperty('Table', 'TTable', GetProp, nil); + with AddClass(TfrxBDEQuery, 'TfrxCustomQuery') do + begin + AddMethod('procedure ExecSQL', CallMethod); + AddProperty('Query', 'TQuery', GetProp, nil); + end; + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TfrxBDEQuery then + begin + if MethodName = 'EXECSQL' then + TfrxBDEQuery(Instance).Query.ExecSQL + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TfrxBDEDatabase then + begin + if PropName = 'DATABASE' then + Result := Integer(TfrxBDEDatabase(Instance).Database) + end + else if ClassType = TfrxBDETable then + begin + if PropName = 'TABLE' then + Result := Integer(TfrxBDETable(Instance).Table) + end + else if ClassType = TfrxBDEQuery then + begin + if PropName = 'QUERY' then + Result := Integer(TfrxBDEQuery(Instance).Query) + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/frxBDEReg.dcr b/official/4.2/LibD11/frxBDEReg.dcr new file mode 100644 index 0000000..ac480fb Binary files /dev/null and b/official/4.2/LibD11/frxBDEReg.dcr differ diff --git a/official/4.2/LibD11/frxBDEReg.pas b/official/4.2/LibD11/frxBDEReg.pas new file mode 100644 index 0000000..73ce1dc --- /dev/null +++ b/official/4.2/LibD11/frxBDEReg.pas @@ -0,0 +1,37 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ BDE components registration } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxBDEReg; + +interface + +{$I frx.inc} + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes +{$IFNDEF Delphi6} +, DsgnIntf +{$ELSE} +, DesignIntf, DesignEditors +{$ENDIF} +, frxBDEComponents; + +procedure Register; +begin + RegisterComponents('FastReport 4.0', [TfrxBDEComponents]); +end; + +end. diff --git a/official/4.2/LibD11/frxBarcod.pas b/official/4.2/LibD11/frxBarcod.pas new file mode 100644 index 0000000..0982ee1 --- /dev/null +++ b/official/4.2/LibD11/frxBarcod.pas @@ -0,0 +1,2014 @@ +unit frxBarcod; + +{ +Barcode Component +Version 1.25 (15.05.2003) +Copyright 1998-2003 Andreas Schmidt and friends +Adapted to FR: Alexander Tzyganenko + +for use with Delphi 1 - 7 +Delphi 1 not tested; better use Delphi 2 (or higher) + +Freeware +Feel free to distribute the component as +long as all files are unmodified and kept together. + +I'am not responsible for wrong barcodes. + +bug-reports, enhancements: +mailto:shmia@bizerba.de or a_j_schmidt@rocketmail.com + +please tell me wich version you are using, when mailing me. + + +get latest version from +http://members.tripod.de/AJSchmidt/index.html +http://mitglied.lycos.de/AJSchmidt/fbarcode.zip + + +many thanx and geetings to +Nikolay Simeonov, Wolfgang Koranda, Norbert Waas, +Richard Hugues, Olivier Guilbaud, Berend Tober, Jan Tungli, +Mauro Lemes, Norbert Kostka, Frank De Prins, Shane O'Dea, +Daniele Teti, Ignacio Trivino, Samuel J. Comstock, Roberto Parola, +Stefano Torricella and Mariusz Mialkon. + +i use tabs: 1 tab = 3 spaces + + +History: +---------------------------------------------------------------------- +Version 1.0: +- initial release +Version 1.1: +- more comments +- changed function Code_93Extended (now correct ?) +Version 1.2: +- Bugs (found by Nikolay Simeonov) removed +Version 1.3: +- EAN8/EAN13 added by Wolfgang Koranda (wkoranda@csi.com) +Version 1.4: +- Bug (found by Norbert Waas) removed + Component must save the Canvas-properties Font,Pen and Brush +Version 1.5: +- Bug (found by Richard Hugues) removed + Last line of barcode was 1 Pixel too wide +Version 1.6: +- new read-only property 'Width' +Version 1.7 +- check for numeric barcode types +- compatible with Delphi 1 (i hope) +Version 1.8 +- add Color and ColorBar properties +Version 1.9 +- Code 128 C added by Jan Tungli +Version 1.10 +- Bug in Code 39 Character I removed +Version 1.11 (06.07.1999) +- additional Code Types + CodeUPC_A, + CodeUPC_E0, + CodeUPC_E1, + CodeUPC_Supp2, + CodeUPC_Supp5 + by Jan Tungli +Version 1.12 (13.07.1999) +- improved ShowText property by Mauro Lemes + you must change your applications due changed interface of TBarcode. +Version 1.13 (23.07.1999) +- additional Code Types + CodeEAN128A, + CodeEAN128B, + CodeEAN128C + (support by Norbert Kostka) +- new property 'CheckSumMethod' +Version 1.14 (29.07.1999) +- checksum for EAN128 by Norbert Kostka +- bug fix for EAN128C +Version 1.15 (23.09.1999) +- bug fix for Code 39 with checksum by Frank De Prins +Version 1.16 (10.11.1999) +- width property is now writable (suggestion by Shane O'Dea) +Version 1.17 (27.06.2000) +- new OnChange property +- renamed TBarcode to TAsBarcode to avoid name conflicts +Version 1.18 (25.08.2000) +- some speed improvements (Code 93 and Code 128) +Version 1.19 (27.09.2000) + (thanks to Samuel J. Comstock) +- origin of the barcode (left upper edge) is moved so that + the barcode stays always on the canvas +- new (read only) properties 'CanvasWidth' and 'CanvasHeight' gives you + the size of the resulting image. +- a wrapper class for Quick Reports is now available. +Version 1.20 (13.09.2000) +- Assign procedure added +- support for scaling barcode to Printer (see Demo) +Version 1.21 (19.07.2001) + (thanks to Roberto Parola) +- new properties ShowTextFont and ShowTextPosition +Version 1.22 (26.10.2001) +- Code 128 Symbol #12 (=comma) fixed (thanks to Stefano Torricella) +Version 1.23 (13.11.2002) +- UPC_E0 and UPC_E1 stopcodes fixed (thanks to Duo Dreamer) +Version 1.24 (04.12.2002) +- Bugfix for Code93 Extended +Version 1.25 (15.05.2003) +- fixed a bug in procedure Assign (thanks to Mariusz Mialkon) + +Todo (missing features) +----------------------- + +- more CheckSum Methods +- user defined barcodes +- checksum event (fired when the checksum is calculated) +- rename the unit name (from 'barcode' to 'fbarcode') to avoid name conflicts +- I'am working on PDF417 barcode (has anybody some technical information about PDF417 + or a PDF417 reader ?) + + + +Known Bugs +--------- +- Top and Left properties must be set at runtime. +- comments not compatible with Delphi 1 +} + + + +interface + +{$I frx.inc} + +uses + WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs; + +type + TfrxBarcodeType = + ( + bcCode_2_5_interleaved, + bcCode_2_5_industrial, + bcCode_2_5_matrix, + bcCode39, + bcCode39Extended, + bcCode128A, + bcCode128B, + bcCode128C, + bcCode93, + bcCode93Extended, + bcCodeMSI, + bcCodePostNet, + bcCodeCodabar, + bcCodeEAN8, + bcCodeEAN13, + bcCodeUPC_A, + bcCodeUPC_E0, + bcCodeUPC_E1, + bcCodeUPC_Supp2, { UPC 2 digit supplemental } + bcCodeUPC_Supp5, { UPC 5 digit supplemental } + bcCodeEAN128A, + bcCodeEAN128B, + bcCodeEAN128C + ); + + + TfrxBarLineType = (white, black, black_half); {for internal use only} + { black_half means a black line with 2/5 height (used for PostNet) } + + + TfrxCheckSumMethod = + ( + csmNone, + csmModulo10 + ); + + + TfrxBarcode = class(TComponent) + private + FAngle: Double; + FColor: TColor; + FColorBar: TColor; + FCheckSum: Boolean; + FCheckSumMethod: TfrxCheckSumMethod; + FHeight: Integer; + FLeft: Integer; + FModul: Integer; + FRatio: Double; + FText: String; + FTop: Integer; + FTyp: TfrxBarcodeType; + modules: array[0..3] of ShortInt; + + procedure DoLines(data: String; Canvas: TCanvas); + procedure OneBarProps(code: Char; var Width: Integer; var lt: TfrxBarLineType); + function SetLen(pI: Byte): String; + function Code_2_5_interleaved: String; + function Code_2_5_industrial: String; + function Code_2_5_matrix: String; + function Code_39: String; + function Code_39Extended: String; + function Code_128: String; + function Code_93: String; + function Code_93Extended: String; + function Code_MSI: String; + function Code_PostNet: String; + function Code_Codabar: String; + function Code_EAN8: String; + function Code_EAN13: String; + function Code_UPC_A: String; + function Code_UPC_E0: String; + function Code_UPC_E1: String; + function Code_Supp5: String; + function Code_Supp2: String; + + procedure MakeModules; + function GetWidth : integer; + function DoCheckSumming(const data : string):string; + function MakeData : string; + public + constructor Create(Owner:TComponent); override; + procedure Assign(Source: TPersistent);override; + + procedure DrawBarcode(Canvas: TCanvas; ARect: TRect; ShowText: Boolean); + published + property Text : string read FText write FText; + property Modul : integer read FModul write FModul; + property Ratio : Double read FRatio write FRatio; + property Typ : TfrxBarcodeType read FTyp write FTyp; + property Checksum:boolean read FCheckSum write FCheckSum; + property CheckSumMethod:TfrxCheckSumMethod read FCheckSumMethod write FCheckSumMethod; + property Angle :double read FAngle write FAngle; + property Width : integer read GetWidth; + property Height: Integer read FHeight write FHeight; + property Color:TColor read FColor write FColor; + property ColorBar:TColor read FColorBar write FColorBar; + end; + + + TBCdata = packed record + Name:string; { Name of Barcode } + num :Boolean; { numeric data only } + end; + +const BCdata:array[bcCode_2_5_interleaved..bcCodeEAN128C] of TBCdata = + ( + (Name:'2_5_interleaved'; num:True), + (Name:'2_5_industrial'; num:True), + (Name:'2_5_matrix'; num:True), + (Name:'Code39'; num:False), + (Name:'Code39 Extended'; num:False), + (Name:'Code128A'; num:False), + (Name:'Code128B'; num:False), + (Name:'Code128C'; num:False), + (Name:'Code93'; num:False), + (Name:'Code93 Extended'; num:False), + (Name:'MSI'; num:True), + (Name:'PostNet'; num:True), + (Name:'Codebar'; num:False), + (Name:'EAN8'; num:True), + (Name:'EAN13'; num:True), + (Name:'UPC_A'; num:True), + (Name:'UPC_E0'; num:True), + (Name:'UPC_E1'; num:True), + (Name:'UPC Supp2'; num:True), + (Name:'UPC Supp5'; num:True), + (Name:'EAN128A'; num:False), + (Name:'EAN128B'; num:False), + (Name:'EAN128C'; num:True) + ); + + +implementation + + +function CheckSumModulo10(const data:string):string; + var i,fak,sum : Integer; +begin + sum := 0; + fak := Length(data); + for i:=1 to Length(data) do + begin + if (fak mod 2) = 0 then + sum := sum + (StrToInt(data[i])*1) + else + sum := sum + (StrToInt(data[i])*3); + dec(fak); + end; + if (sum mod 10) = 0 then + result := data+'0' + else + result := data+IntToStr(10-(sum mod 10)); +end; + +procedure Assert(Cond: Boolean; Text: String); +begin + if not Cond then + raise Exception.Create(Text); +end; + +{ + converts a string from '321' to the internal representation '715' + i need this function because some pattern tables have a different + format : + + '00111' + converts to '05161' +} +function Convert(const s:string):string; +var + i, v : integer; +begin + Result := s; { same Length as Input - string } + for i:=1 to Length(s) do + begin + v := ord(s[i]) - 1; + + if odd(i) then + Inc(v, 5); + Result[i] := Chr(v); + end; +end; + +(* + * Berechne die Quersumme aus einer Zahl x + * z.B.: Quersumme von 1234 ist 10 + *) +function quersumme(x:integer):integer; +var + sum:integer; +begin + sum := 0; + + while x > 0 do + begin + sum := sum + (x mod 10); + x := x div 10; + end; + result := sum; +end; + + +{ + Rotate a Point by Angle 'alpha' +} +function Rotate2D(p:TPoint; alpha:double): TPoint; +var + sinus, cosinus : Extended; +begin + sinus := sin(alpha); + cosinus := cos(alpha); + result.x := Round(p.x*cosinus + p.y*sinus); + result.y := Round(-p.x*sinus + p.y*cosinus); +end; + +{ + Move Point "a" by Vector "b" +} +function Translate2D(a, b:TPoint): TPoint; +begin + result.x := a.x + b.x; + result.y := a.y + b.y; +end; + + +{ + Move the orgin so that when point is rotated by alpha, the rect + between point and orgin stays in the visible quadrant. +} +function TranslateQuad2D(const alpha :double; const orgin, point :TPoint): TPoint; +var + alphacos: Extended; + alphasin: Extended; + moveby: TPoint; +begin + alphasin := sin(alpha); + alphacos := cos(alpha); + + if alphasin >= 0 then + begin + if alphacos >= 0 then + begin + // 1. Quadrant + moveby.x := 0; + moveby.y := Round(alphasin*point.x); + end + else + begin + // 2. Quadrant + moveby.x := -Round(alphacos*point.x); + moveby.y := Round(alphasin*point.x - alphacos*point.y); + end; + end + else + begin + if alphacos >= 0 then + begin + // 4. quadrant + moveby.x := -Round(alphasin*point.y); + moveby.y := 0; + end + else + begin + // 3. quadrant + moveby.x := -Round(alphacos*point.x) - Round(alphasin*point.y); + moveby.y := -Round(alphacos*point.y); + end; + end; + Result := Translate2D(orgin, moveby); +end; + + +constructor TfrxBarcode.Create(Owner:TComponent); +begin + inherited Create(owner); + FAngle := 0.0; + FRatio := 2.0; + FModul := 1; + FTyp := bcCodeEAN13; + FCheckSum := FALSE; + FCheckSumMethod := csmModulo10; + FColor := clWhite; + FColorBar := clBlack; +end; + + +procedure TfrxBarcode.Assign(Source: TPersistent); +var + BSource : TfrxBarcode; +begin + if Source is TfrxBarcode then + begin + BSource := TfrxBarcode(Source); + FHeight := BSource.FHeight; + FText := BSource.FText; + FTop := BSource.FTop; + FLeft := BSource.FLeft; + FModul := BSource.FModul; + FRatio := BSource.FRatio; + FTyp := BSource.FTyp; + FCheckSum := BSource.FCheckSum; + FAngle := BSource.FAngle; + FColor := BSource.FColor; + FColorBar := BSource.FColorBar; + FCheckSumMethod := BSource.FCheckSumMethod; + end; +end; + + + + +{ +calculate the width and the linetype of a sigle bar + + + Code Line-Color Width Height +------------------------------------------------------------------ + '0' white 100% full + '1' white 100%*Ratio full + '2' white 150%*Ratio full + '3' white 200%*Ratio full + '5' black 100% full + '6' black 100%*Ratio full + '7' black 150%*Ratio full + '8' black 200%*Ratio full + 'A' black 100% 2/5 (used for PostNet) + 'B' black 100%*Ratio 2/5 (used for PostNet) + 'C' black 150%*Ratio 2/5 (used for PostNet) + 'D' black 200%*Ratio 2/5 (used for PostNet) +} +procedure TfrxBarcode.OneBarProps(code:char; var Width:integer; var lt:TfrxBarLineType); +begin + case code of + '0': begin width := modules[0]; lt := white; end; + '1': begin width := modules[1]; lt := white; end; + '2': begin width := modules[2]; lt := white; end; + '3': begin width := modules[3]; lt := white; end; + + + '5': begin width := modules[0]; lt := black; end; + '6': begin width := modules[1]; lt := black; end; + '7': begin width := modules[2]; lt := black; end; + '8': begin width := modules[3]; lt := black; end; + + 'A': begin width := modules[0]; lt := black_half; end; + 'B': begin width := modules[1]; lt := black_half; end; + 'C': begin width := modules[2]; lt := black_half; end; + 'D': begin width := modules[3]; lt := black_half; end; + else + begin + {something went wrong :-( } + {mistyped pattern table} + raise Exception.CreateFmt('%s: internal Error', [self.ClassName]); + end; + end; +end; + + +function TfrxBarcode.MakeData : string; +var + i : integer; +begin + {calculate the with of the different lines (modules)} + MakeModules; + + + {numeric barcode type ?} + if BCdata[Typ].num then + begin + FText := Trim(FText); {remove blanks} + for i := 1 to Length(Ftext) do + if (FText[i] > '9') or (FText[i] < '0') then + raise Exception.Create('Barcode must be numeric'); + end; + + + {get the pattern of the barcode} + case Typ of + bcCode_2_5_interleaved: Result := Code_2_5_interleaved; + bcCode_2_5_industrial: Result := Code_2_5_industrial; + bcCode_2_5_matrix: Result := Code_2_5_matrix; + bcCode39: Result := Code_39; + bcCode39Extended: Result := Code_39Extended; + bcCode128A, + bcCode128B, + bcCode128C, + bcCodeEAN128A, + bcCodeEAN128B, + bcCodeEAN128C: Result := Code_128; + bcCode93: Result := Code_93; + bcCode93Extended: Result := Code_93Extended; + bcCodeMSI: Result := Code_MSI; + bcCodePostNet: Result := Code_PostNet; + bcCodeCodabar: Result := Code_Codabar; + bcCodeEAN8: Result := Code_EAN8; + bcCodeEAN13: Result := Code_EAN13; + bcCodeUPC_A: Result := Code_UPC_A; + bcCodeUPC_E0: Result := Code_UPC_E0; + bcCodeUPC_E1: Result := Code_UPC_E1; + bcCodeUPC_Supp2: Result := Code_Supp2; + bcCodeUPC_Supp5: Result := Code_Supp5; + else + raise Exception.CreateFmt('%s: wrong BarcodeType', [self.ClassName]); + end; + +{ +Showmessage(Format('Data <%s>', [Result])); +} +end; + + + +function TfrxBarcode.GetWidth:integer; +var + data : string; + i : integer; + w : integer; + lt : TfrxBarLineType; +begin + Result := 0; + + {get barcode pattern} + data := MakeData; + + for i:=1 to Length(data) do {examine the pattern string} + begin + OneBarProps(data[i], w, lt); + Inc(Result, w); + end; +end; + +function TfrxBarcode.DoCheckSumming(const data : string):string; +begin + case FCheckSumMethod of + + csmNone: + Result := data; + csmModulo10: + Result := CheckSumModulo10(data); + + end; +end; + + + + +{ +////////////////////////////// EAN ///////////////////////////////////////// +} + + +{ +////////////////////////////// EAN8 ///////////////////////////////////////// +} + +{Pattern for Barcode EAN Charset A} + {L1 S1 L2 S2} +const tabelle_EAN_A:array['0'..'9'] of string = + ( + ('2605'), { 0 } + ('1615'), { 1 } + ('1516'), { 2 } + ('0805'), { 3 } + ('0526'), { 4 } + ('0625'), { 5 } + ('0508'), { 6 } + ('0706'), { 7 } + ('0607'), { 8 } + ('2506') { 9 } + ); + +{Pattern for Barcode EAN Charset C} + {S1 L1 S2 L2} +const tabelle_EAN_C:array['0'..'9'] of string = + ( + ('7150' ), { 0 } + ('6160' ), { 1 } + ('6061' ), { 2 } + ('5350' ), { 3 } + ('5071' ), { 4 } + ('5170' ), { 5 } + ('5053' ), { 6 } + ('5251' ), { 7 } + ('5152' ), { 8 } + ('7051' ) { 9 } + ); + + +function TfrxBarcode.Code_EAN8:string; +var + i : integer; + tmp : String; +begin + if FCheckSum then + begin + tmp := SetLen(7); + tmp := DoCheckSumming(copy(tmp,length(tmp)-6,7)); + end + else + tmp := SetLen(8); + + Assert(Length(tmp)=8, 'Invalid Text len (EAN8)'); + result := '505'; {Startcode} + + for i:=1 to 4 do + result := result + tabelle_EAN_A[tmp[i]] ; + + result := result + '05050'; {Center Guard Pattern} + + for i:=5 to 8 do + result := result + tabelle_EAN_C[tmp[i]] ; + + result := result + '505'; {Stopcode} +end; + +{////////////////////////////// EAN13 ///////////////////////////////////////} + +{Pattern for Barcode EAN Zeichensatz B} + {L1 S1 L2 S2} +const tabelle_EAN_B:array['0'..'9'] of string = + ( + ('0517'), { 0 } + ('0616'), { 1 } + ('1606'), { 2 } + ('0535'), { 3 } + ('1705'), { 4 } + ('0715'), { 5 } + ('3505'), { 6 } + ('1525'), { 7 } + ('2515'), { 8 } + ('1507') { 9 } + ); + +{Zuordung der Paraitaetsfolgen fr EAN13} +const tabelle_ParityEAN13:array[0..9, 1..6] of char = + ( + ('A', 'A', 'A', 'A', 'A', 'A'), { 0 } + ('A', 'A', 'B', 'A', 'B', 'B'), { 1 } + ('A', 'A', 'B', 'B', 'A', 'B'), { 2 } + ('A', 'A', 'B', 'B', 'B', 'A'), { 3 } + ('A', 'B', 'A', 'A', 'B', 'B'), { 4 } + ('A', 'B', 'B', 'A', 'A', 'B'), { 5 } + ('A', 'B', 'B', 'B', 'A', 'A'), { 6 } + ('A', 'B', 'A', 'B', 'A', 'B'), { 7 } + ('A', 'B', 'A', 'B', 'B', 'A'), { 8 } + ('A', 'B', 'B', 'A', 'B', 'A') { 9 } + ); + +function TfrxBarcode.Code_EAN13:string; +var + i, LK: integer; + tmp : String; +begin + if Length(FText) <> 13 then + begin + FText := SetLen(13); + if FCheckSum then + tmp := DoCheckSumming(copy(FText,2,12)); + if FCheckSum then + FText := tmp + else + tmp := FText; + end + else + tmp := FText; + + Assert(Length(tmp) = 13, 'Invalid Text len (EAN13)'); + + LK := StrToInt(tmp[1]); + tmp := copy(tmp,2,12); + + result := '505'; {Startcode} + + for i:=1 to 6 do + begin + case tabelle_ParityEAN13[LK,i] of + 'A' : result := result + tabelle_EAN_A[tmp[i]]; + 'B' : result := result + tabelle_EAN_B[tmp[i]] ; + 'C' : result := result + tabelle_EAN_C[tmp[i]] ; + end; + end; + + result := result + '05050'; {Center Guard Pattern} + + for i:=7 to 12 do + result := result + tabelle_EAN_C[tmp[i]] ; + + result := result + '505'; {Stopcode} +end; + +{Pattern for Barcode 2 of 5} +const tabelle_2_5:array['0'..'9', 1..5] of char = + ( + ('0', '0', '1', '1', '0'), {'0'} + ('1', '0', '0', '0', '1'), {'1'} + ('0', '1', '0', '0', '1'), {'2'} + ('1', '1', '0', '0', '0'), {'3'} + ('0', '0', '1', '0', '1'), {'4'} + ('1', '0', '1', '0', '0'), {'5'} + ('0', '1', '1', '0', '0'), {'6'} + ('0', '0', '0', '1', '1'), {'7'} + ('1', '0', '0', '1', '0'), {'8'} + ('0', '1', '0', '1', '0') {'9'} + ); + +function TfrxBarcode.Code_2_5_interleaved:string; +var + i, j: integer; + c : char; + +begin + result := '5050'; {Startcode} + + for i:=1 to Length(FText) div 2 do + begin + for j:= 1 to 5 do + begin + if tabelle_2_5[FText[i*2-1], j] = '1' then + c := '6' + else + c := '5'; + result := result + c; + if tabelle_2_5[FText[i*2], j] = '1' then + c := '1' + else + c := '0'; + result := result + c; + end; + end; + + result := result + '605'; {Stopcode} +end; + + +function TfrxBarcode.Code_2_5_industrial:string; +var + i, j: integer; +begin + result := '606050'; {Startcode} + + for i:=1 to Length(FText) do + begin + for j:= 1 to 5 do + begin + if tabelle_2_5[FText[i], j] = '1' then + result := result + '60' + else + result := result + '50'; + end; + end; + + result := result + '605060'; {Stopcode} +end; + +function TfrxBarcode.Code_2_5_matrix:string; +var + i, j: integer; + c :char; +begin + result := '705050'; {Startcode} + + for i:=1 to Length(FText) do + begin + for j:= 1 to 5 do + begin + if tabelle_2_5[FText[i], j] = '1' then + c := '1' + else + c := '0'; + + {Falls i ungerade ist dann mache Lcke zu Strich} + if odd(j) then + c := chr(ord(c)+5); + result := result + c; + end; + result := result + '0'; {Lcke zwischen den Zeichen} + end; + + result := result + '70505'; {Stopcode} +end; + + +function TfrxBarcode.Code_39:string; + +type TCode39 = + record + c : char; + data : array[0..9] of char; + chk: shortint; + end; + +const tabelle_39: array[0..43] of TCode39 = ( + ( c:'0'; data:'505160605'; chk:0 ), + ( c:'1'; data:'605150506'; chk:1 ), + ( c:'2'; data:'506150506'; chk:2 ), + ( c:'3'; data:'606150505'; chk:3 ), + ( c:'4'; data:'505160506'; chk:4 ), + ( c:'5'; data:'605160505'; chk:5 ), + ( c:'6'; data:'506160505'; chk:6 ), + ( c:'7'; data:'505150606'; chk:7 ), + ( c:'8'; data:'605150605'; chk:8 ), + ( c:'9'; data:'506150605'; chk:9 ), + ( c:'A'; data:'605051506'; chk:10), + ( c:'B'; data:'506051506'; chk:11), + ( c:'C'; data:'606051505'; chk:12), + ( c:'D'; data:'505061506'; chk:13), + ( c:'E'; data:'605061505'; chk:14), + ( c:'F'; data:'506061505'; chk:15), + ( c:'G'; data:'505051606'; chk:16), + ( c:'H'; data:'605051605'; chk:17), + ( c:'I'; data:'506051605'; chk:18), + ( c:'J'; data:'505061605'; chk:19), + ( c:'K'; data:'605050516'; chk:20), + ( c:'L'; data:'506050516'; chk:21), + ( c:'M'; data:'606050515'; chk:22), + ( c:'N'; data:'505060516'; chk:23), + ( c:'O'; data:'605060515'; chk:24), + ( c:'P'; data:'506060515'; chk:25), + ( c:'Q'; data:'505050616'; chk:26), + ( c:'R'; data:'605050615'; chk:27), + ( c:'S'; data:'506050615'; chk:28), + ( c:'T'; data:'505060615'; chk:29), + ( c:'U'; data:'615050506'; chk:30), + ( c:'V'; data:'516050506'; chk:31), + ( c:'W'; data:'616050505'; chk:32), + ( c:'X'; data:'515060506'; chk:33), + ( c:'Y'; data:'615060505'; chk:34), + ( c:'Z'; data:'516060505'; chk:35), + ( c:'-'; data:'515050606'; chk:36), + ( c:'.'; data:'615050605'; chk:37), + ( c:' '; data:'516050605'; chk:38), + ( c:'*'; data:'515060605'; chk:0 ), + ( c:'$'; data:'515151505'; chk:39), + ( c:'/'; data:'515150515'; chk:40), + ( c:'+'; data:'515051515'; chk:41), + ( c:'%'; data:'505151515'; chk:42) + ); + + +function FindIdx(z:char):integer; +var + i:integer; +begin + for i:=0 to High(tabelle_39) do + begin + if z = tabelle_39[i].c then + begin + result := i; + exit; + end; + end; + result := -1; +end; + +var + i, idx : integer; + checksum:integer; + +begin + checksum := 0; + {Startcode} + result := tabelle_39[FindIdx('*')].data + '0'; + + for i:=1 to Length(FText) do + begin + idx := FindIdx(FText[i]); + if idx < 0 then + continue; + result := result + tabelle_39[idx].data + '0'; + Inc(checksum, tabelle_39[idx].chk); + end; + + {Calculate Checksum Data} + if FCheckSum then + begin + checksum := checksum mod 43; + for i:=0 to High(tabelle_39) do + if checksum = tabelle_39[i].chk then + begin + result := result + tabelle_39[i].data + '0'; + break; + end; + end; + + {Stopcode} + result := result + tabelle_39[FindIdx('*')].data; +end; + +function TfrxBarcode.Code_39Extended:string; + +const code39x : array[0..127] of string[2] = + ( + ('%U'), ('$A'), ('$B'), ('$C'), ('$D'), ('$E'), ('$F'), ('$G'), + ('$H'), ('$I'), ('$J'), ('$K'), ('$L'), ('$M'), ('$N'), ('$O'), + ('$P'), ('$Q'), ('$R'), ('$S'), ('$T'), ('$U'), ('$V'), ('$W'), + ('$X'), ('$Y'), ('$Z'), ('%A'), ('%B'), ('%C'), ('%D'), ('%E'), + (' '), ('/A'), ('/B'), ('/C'), ('/D'), ('/E'), ('/F'), ('/G'), + ('/H'), ('/I'), ('/J'), ('/K'), ('/L'), ('/M'), ('/N'), ('/O'), + ( '0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), + ('8'), ('9'), ('/Z'), ('%F'), ('%G'), ('%H'), ('%I'), ('%J'), + ('%V'), ('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), + ('H'), ('I'), ('J'), ('K'), ('L'), ('M'), ('N'), ('O'), + ('P'), ('Q'), ('R'), ('S'), ('T'), ('U'), ('V'), ('W'), + ('X'), ('Y'), ('Z'), ('%K'), ('%L'), ('%M'), ('%N'), ('%O'), + ('%W'), ('+A'), ('+B'), ('+C'), ('+D'), ('+E'), ('+F'), ('+G'), + ('+H'), ('+I'), ('+J'), ('+K'), ('+L'), ('+M'), ('+N'), ('+O'), + ('+P'), ('+Q'), ('+R'), ('+S'), ('+T'), ('+U'), ('+V'), ('+W'), + ('+X'), ('+Y'), ('+Z'), ('%P'), ('%Q'), ('%R'), ('%S'), ('%T') + ); + + +var + save:string; + i : integer; +begin + save := FText; + FText := ''; + + for i:=1 to Length(save) do + begin + if ord(save[i]) <= 127 then + FText := FText + code39x[ord(save[i])]; + end; + result := Code_39; + FText := save; +end; + + + +{ +Code 128 +} +function TfrxBarcode.Code_128:string; +type TCode128 = + record + a, b : char; + c : string[2]; + data : string[6]; + end; + +const tabelle_128: array[0..102] of TCode128 = ( + ( a:' '; b:' '; c:'00'; data:'212222' ), + ( a:'!'; b:'!'; c:'01'; data:'222122' ), + ( a:'"'; b:'"'; c:'02'; data:'222221' ), + ( a:'#'; b:'#'; c:'03'; data:'121223' ), + ( a:'$'; b:'$'; c:'04'; data:'121322' ), + ( a:'%'; b:'%'; c:'05'; data:'131222' ), + ( a:'&'; b:'&'; c:'06'; data:'122213' ), + ( a:''''; b:''''; c:'07'; data:'122312' ), + ( a:'('; b:'('; c:'08'; data:'132212' ), + ( a:')'; b:')'; c:'09'; data:'221213' ), + ( a:'*'; b:'*'; c:'10'; data:'221312' ), + ( a:'+'; b:'+'; c:'11'; data:'231212' ), + ( a:','; b:','; c:'12'; data:'112232' ), {23.10.2001 Stefano Torricella} + ( a:'-'; b:'-'; c:'13'; data:'122132' ), + ( a:'.'; b:'.'; c:'14'; data:'122231' ), + ( a:'/'; b:'/'; c:'15'; data:'113222' ), + ( a:'0'; b:'0'; c:'16'; data:'123122' ), + ( a:'1'; b:'1'; c:'17'; data:'123221' ), + ( a:'2'; b:'2'; c:'18'; data:'223211' ), + ( a:'3'; b:'3'; c:'19'; data:'221132' ), + ( a:'4'; b:'4'; c:'20'; data:'221231' ), + ( a:'5'; b:'5'; c:'21'; data:'213212' ), + ( a:'6'; b:'6'; c:'22'; data:'223112' ), + ( a:'7'; b:'7'; c:'23'; data:'312131' ), + ( a:'8'; b:'8'; c:'24'; data:'311222' ), + ( a:'9'; b:'9'; c:'25'; data:'321122' ), + ( a:':'; b:':'; c:'26'; data:'321221' ), + ( a:';'; b:';'; c:'27'; data:'312212' ), + ( a:'<'; b:'<'; c:'28'; data:'322112' ), + ( a:'='; b:'='; c:'29'; data:'322211' ), + ( a:'>'; b:'>'; c:'30'; data:'212123' ), + ( a:'?'; b:'?'; c:'31'; data:'212321' ), + ( a:'@'; b:'@'; c:'32'; data:'232121' ), + ( a:'A'; b:'A'; c:'33'; data:'111323' ), + ( a:'B'; b:'B'; c:'34'; data:'131123' ), + ( a:'C'; b:'C'; c:'35'; data:'131321' ), + ( a:'D'; b:'D'; c:'36'; data:'112313' ), + ( a:'E'; b:'E'; c:'37'; data:'132113' ), + ( a:'F'; b:'F'; c:'38'; data:'132311' ), + ( a:'G'; b:'G'; c:'39'; data:'211313' ), + ( a:'H'; b:'H'; c:'40'; data:'231113' ), + ( a:'I'; b:'I'; c:'41'; data:'231311' ), + ( a:'J'; b:'J'; c:'42'; data:'112133' ), + ( a:'K'; b:'K'; c:'43'; data:'112331' ), + ( a:'L'; b:'L'; c:'44'; data:'132131' ), + ( a:'M'; b:'M'; c:'45'; data:'113123' ), + ( a:'N'; b:'N'; c:'46'; data:'113321' ), + ( a:'O'; b:'O'; c:'47'; data:'133121' ), + ( a:'P'; b:'P'; c:'48'; data:'313121' ), + ( a:'Q'; b:'Q'; c:'49'; data:'211331' ), + ( a:'R'; b:'R'; c:'50'; data:'231131' ), + ( a:'S'; b:'S'; c:'51'; data:'213113' ), + ( a:'T'; b:'T'; c:'52'; data:'213311' ), + ( a:'U'; b:'U'; c:'53'; data:'213131' ), + ( a:'V'; b:'V'; c:'54'; data:'311123' ), + ( a:'W'; b:'W'; c:'55'; data:'311321' ), + ( a:'X'; b:'X'; c:'56'; data:'331121' ), + ( a:'Y'; b:'Y'; c:'57'; data:'312113' ), + ( a:'Z'; b:'Z'; c:'58'; data:'312311' ), + ( a:'['; b:'['; c:'59'; data:'332111' ), + ( a:'\'; b:'\'; c:'60'; data:'314111' ), + ( a:']'; b:']'; c:'61'; data:'221411' ), + ( a:'^'; b:'^'; c:'62'; data:'431111' ), + ( a:'_'; b:'_'; c:'63'; data:'111224' ), + ( a:' '; b:'`'; c:'64'; data:'111422' ), + ( a:' '; b:'a'; c:'65'; data:'121124' ), + ( a:' '; b:'b'; c:'66'; data:'121421' ), + ( a:' '; b:'c'; c:'67'; data:'141122' ), + ( a:' '; b:'d'; c:'68'; data:'141221' ), + ( a:' '; b:'e'; c:'69'; data:'112214' ), + ( a:' '; b:'f'; c:'70'; data:'112412' ), + ( a:' '; b:'g'; c:'71'; data:'122114' ), + ( a:' '; b:'h'; c:'72'; data:'122411' ), + ( a:' '; b:'i'; c:'73'; data:'142112' ), + ( a:' '; b:'j'; c:'74'; data:'142211' ), + ( a:' '; b:'k'; c:'75'; data:'241211' ), + ( a:' '; b:'l'; c:'76'; data:'221114' ), + ( a:' '; b:'m'; c:'77'; data:'413111' ), + ( a:' '; b:'n'; c:'78'; data:'241112' ), + ( a:' '; b:'o'; c:'79'; data:'134111' ), + ( a:' '; b:'p'; c:'80'; data:'111242' ), + ( a:' '; b:'q'; c:'81'; data:'121142' ), + ( a:' '; b:'r'; c:'82'; data:'121241' ), + ( a:' '; b:'s'; c:'83'; data:'114212' ), + ( a:' '; b:'t'; c:'84'; data:'124112' ), + ( a:' '; b:'u'; c:'85'; data:'124211' ), + ( a:' '; b:'v'; c:'86'; data:'411212' ), + ( a:' '; b:'w'; c:'87'; data:'421112' ), + ( a:' '; b:'x'; c:'88'; data:'421211' ), + ( a:' '; b:'y'; c:'89'; data:'212141' ), + ( a:' '; b:'z'; c:'90'; data:'214121' ), + ( a:' '; b:'{'; c:'91'; data:'412121' ), + ( a:' '; b:'|'; c:'92'; data:'111143' ), + ( a:' '; b:'}'; c:'93'; data:'111341' ), + ( a:' '; b:'~'; c:'94'; data:'131141' ), + ( a:' '; b:' '; c:'95'; data:'114113' ), + ( a:' '; b:' '; c:'96'; data:'114311' ), + ( a:' '; b:' '; c:'97'; data:'411113' ), + ( a:' '; b:' '; c:'98'; data:'411311' ), + ( a:' '; b:' '; c:'99'; data:'113141' ), + ( a:' '; b:' '; c:' '; data:'114131' ), + ( a:' '; b:' '; c:' '; data:'311141' ), + ( a:' '; b:' '; c:' '; data:'411131' ) { FNC1 } + ); + +StartA = '211412'; +StartB = '211214'; +StartC = '211232'; +Stop = '2331112'; + + + + +{find Code 128 Codeset A or B} +function Find_Code128AB(c:char):integer; +var + i:integer; + v:char; +begin + for i:=0 to High(tabelle_128) do + begin + if FTyp = bcCode128A then + v := tabelle_128[i].a + else + v := tabelle_128[i].b; + + if c = v then + begin + result := i; + exit; + end; + end; + result := -1; +end; + +{ find Code 128 Codeset C } +function Find_Code128C(c:string):integer; + var i:integer; + begin + for i:=0 to High(tabelle_128) do begin + if tabelle_128[i].c = c then begin + result := i; + exit; + end; + end; + result := -1; + end; + + + +var i, j, idx: integer; + startcode:string; + checksum : integer; + codeword_pos : integer; + +begin + case FTyp of + bcCode128A, bcCodeEAN128A: + begin checksum := 103; startcode:= StartA; end; + bcCode128B, bcCodeEAN128B: + begin checksum := 104; startcode:= StartB; end; + bcCode128C, bcCodeEAN128C: + begin checksum := 105; startcode:= StartC; end; + else + raise Exception.CreateFmt('%s: wrong BarcodeType in Code_128', [self.ClassName]); + end; + + result := startcode; {Startcode} + codeword_pos := 1; + + case FTyp of + bcCodeEAN128A, + bcCodeEAN128B, + bcCodeEAN128C: + begin + { + special identifier + FNC1 = function code 1 + for EAN 128 barcodes + } + result := result + tabelle_128[102].data; + Inc(checksum, 102*codeword_pos); + Inc(codeword_pos); + { + if there is no checksum at the end of the string + the EAN128 needs one (modulo 10) + } + if FCheckSum then FText:=DoCheckSumming(FTEXT); + end; + end; + + if (FTyp = bcCode128C) or (FTyp = bccodeEAN128C) then + begin + if (Length(FText) mod 2<>0) then FText:='0'+FText; + for i:=1 to (Length(FText) div 2) do + begin + j:=(i-1)*2+1; + idx:=Find_Code128C(copy(Ftext,j,2)); + if idx < 0 then idx := Find_Code128C('00'); + result := result + tabelle_128[idx].data; + Inc(checksum, idx*codeword_pos); + Inc(codeword_pos); + end; + end + else + for i:=1 to Length(FText) do + begin + idx := Find_Code128AB(FText[i]); + if idx < 0 then + idx := Find_Code128AB(' '); + result := result + tabelle_128[idx].data; + Inc(checksum, idx*codeword_pos); + Inc(codeword_pos); + end; + + checksum := checksum mod 103; + result := result + tabelle_128[checksum].data; + + result := result + Stop; {Stopcode} + Result := Convert(Result); +end; + + + + + +function TfrxBarcode.Code_93:string; +type TCode93 = + record + c : char; + data : array[0..5] of char; + end; + +const tabelle_93: array[0..46] of TCode93 = ( + ( c:'0'; data:'131112' ), + ( c:'1'; data:'111213' ), + ( c:'2'; data:'111312' ), + ( c:'3'; data:'111411' ), + ( c:'4'; data:'121113' ), + ( c:'5'; data:'121212' ), + ( c:'6'; data:'121311' ), + ( c:'7'; data:'111114' ), + ( c:'8'; data:'131211' ), + ( c:'9'; data:'141111' ), + ( c:'A'; data:'211113' ), + ( c:'B'; data:'211212' ), + ( c:'C'; data:'211311' ), + ( c:'D'; data:'221112' ), + ( c:'E'; data:'221211' ), + ( c:'F'; data:'231111' ), + ( c:'G'; data:'112113' ), + ( c:'H'; data:'112212' ), + ( c:'I'; data:'112311' ), + ( c:'J'; data:'122112' ), + ( c:'K'; data:'132111' ), + ( c:'L'; data:'111123' ), + ( c:'M'; data:'111222' ), + ( c:'N'; data:'111321' ), + ( c:'O'; data:'121122' ), + ( c:'P'; data:'131121' ), + ( c:'Q'; data:'212112' ), + ( c:'R'; data:'212211' ), + ( c:'S'; data:'211122' ), + ( c:'T'; data:'211221' ), + ( c:'U'; data:'221121' ), + ( c:'V'; data:'222111' ), + ( c:'W'; data:'112122' ), + ( c:'X'; data:'112221' ), + ( c:'Y'; data:'122121' ), + ( c:'Z'; data:'123111' ), + ( c:'-'; data:'121131' ), + ( c:'.'; data:'311112' ), + ( c:' '; data:'311211' ), + ( c:'$'; data:'321111' ), + ( c:'/'; data:'112131' ), + ( c:'+'; data:'113121' ), + ( c:'%'; data:'211131' ), + ( c:'['; data:'121221' ), {only used for Extended Code 93} + ( c:']'; data:'312111' ), {only used for Extended Code 93} + ( c:'{'; data:'311121' ), {only used for Extended Code 93} + ( c:'}'; data:'122211' ) {only used for Extended Code 93} + ); + + +{find Code 93} +function Find_Code93(c:char):integer; +var + i:integer; +begin + for i:=0 to High(tabelle_93) do + begin + if c = tabelle_93[i].c then + begin + result := i; + exit; + end; + end; + result := -1; +end; + + + + +var + i, idx : integer; + checkC, checkK, {Checksums} + weightC, weightK : integer; +begin + + result := '111141'; {Startcode} + + for i:=1 to Length(FText) do + begin + idx := Find_Code93(FText[i]); + if idx < 0 then + raise Exception.CreateFmt('%s:Code93 bad Data <%s>', [self.ClassName,FText]); + result := result + tabelle_93[idx].data; + end; + + checkC := 0; + checkK := 0; + + weightC := 1; + weightK := 2; + + for i:=Length(FText) downto 1 do + begin + idx := Find_Code93(FText[i]); + + Inc(checkC, idx*weightC); + Inc(checkK, idx*weightK); + + Inc(weightC); + if weightC > 20 then weightC := 1; + Inc(weightK); + if weightK > 15 then weightC := 1; + end; + + Inc(checkK, checkC); + + checkC := checkC mod 47; + checkK := checkK mod 47; + + result := result + tabelle_93[checkC].data + + tabelle_93[checkK].data; + + result := result + '1111411'; {Stopcode} + Result := Convert(Result); +end; + + + + + +function TfrxBarcode.Code_93Extended:string; +const code93x : array[0..127] of string[2] = + ( + (']U'), ('[A'), ('[B'), ('[C'), ('[D'), ('[E'), ('[F'), ('[G'), + ('[H'), ('[I'), ('[J'), ('[K'), ('[L'), ('[M'), ('[N'), ('[O'), + ('[P'), ('[Q'), ('[R'), ('[S'), ('[T'), ('[U'), ('[V'), ('[W'), + ('[X'), ('[Y'), ('[Z'), (']A'), (']B'), (']C'), (']D'), (']E'), + (' '), ('{A'), ('{B'), ('{C'), ('{D'), ('{E'), ('{F'), ('{G'), + ('{H'), ('{I'), ('{J'), ('{K'), ('{L'), ('{M'), ('{N'), ('{O'), + ( '0'), ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), ('7'), + ('8'), ('9'), ('{Z'), (']F'), (']G'), (']H'), (']I'), (']J'), + (']V'), ('A'), ('B'), ('C'), ('D'), ('E'), ('F'), ('G'), + ('H'), ('I'), ('J'), ('K'), ('L'), ('M'), ('N'), ('O'), + ('P'), ('Q'), ('R'), ('S'), ('T'), ('U'), ('V'), ('W'), + ('X'), ('Y'), ('Z'), (']K'), (']L'), (']M'), (']N'), (']O'), + (']W'), ('}A'), ('}B'), ('}C'), ('}D'), ('}E'), ('}F'), ('}G'), + ('}H'), ('}I'), ('}J'), ('}K'), ('}L'), ('}M'), ('}N'), ('}O'), + ('}P'), ('}Q'), ('}R'), ('}S'), ('}T'), ('}U'), ('}V'), ('}W'), + ('}X'), ('}Y'), ('}Z'), (']P'), (']Q'), (']R'), (']S'), (']T') + ); + +var + save : string; + i : integer; +begin + {CharToOem(PChar(FText), save);} + + save := FText; + FText := ''; + + + for i:=1 to Length(save) do + begin + if ord(save[i]) <= 127 then + FText := FText + code93x[ord(save[i])]; + end; + + {Showmessage(Format('Text: <%s>', [FText]));} + + result := Code_93; + FText := save; +end; + + + +function TfrxBarcode.Code_MSI:string; +const tabelle_MSI:array['0'..'9'] of string[8] = + ( + ( '51515151' ), {'0'} + ( '51515160' ), {'1'} + ( '51516051' ), {'2'} + ( '51516060' ), {'3'} + ( '51605151' ), {'4'} + ( '51605160' ), {'5'} + ( '51606051' ), {'6'} + ( '51606060' ), {'7'} + ( '60515151' ), {'8'} + ( '60515160' ) {'9'} + ); + +var + i:integer; + check_even, check_odd, checksum:integer; +begin + result := '60'; {Startcode} + check_even := 0; + check_odd := 0; + + for i:=1 to Length(FText) do + begin + if odd(i-1) then + check_odd := check_odd*10+ord(FText[i]) + else + check_even := check_even+ord(FText[i]); + + result := result + tabelle_MSI[FText[i]]; + end; + + checksum := quersumme(check_odd*2) + check_even; + + checksum := checksum mod 10; + if checksum > 0 then + checksum := 10-checksum; + + result := result + tabelle_MSI[chr(ord('0')+checksum)]; + + result := result + '515'; {Stopcode} +end; + + + +function TfrxBarcode.Code_PostNet:string; +const tabelle_PostNet:array['0'..'9'] of string[10] = + ( + ( '5151A1A1A1' ), {'0'} + ( 'A1A1A15151' ), {'1'} + ( 'A1A151A151' ), {'2'} + ( 'A1A15151A1' ), {'3'} + ( 'A151A1A151' ), {'4'} + ( 'A151A151A1' ), {'5'} + ( 'A15151A1A1' ), {'6'} + ( '51A1A1A151' ), {'7'} + ( '51A1A151A1' ), {'8'} + ( '51A151A1A1' ) {'9'} + ); +var + i:integer; +begin + result := '51'; + + for i:=1 to Length(FText) do + begin + result := result + tabelle_PostNet[FText[i]]; + end; + result := result + '5'; +end; + + +function TfrxBarcode.Code_Codabar:string; +type TCodabar = + record + c : char; + data : array[0..6] of char; + end; + +const tabelle_cb: array[0..19] of TCodabar = ( + ( c:'1'; data:'5050615' ), + ( c:'2'; data:'5051506' ), + ( c:'3'; data:'6150505' ), + ( c:'4'; data:'5060515' ), + ( c:'5'; data:'6050515' ), + ( c:'6'; data:'5150506' ), + ( c:'7'; data:'5150605' ), + ( c:'8'; data:'5160505' ), + ( c:'9'; data:'6051505' ), + ( c:'0'; data:'5050516' ), + ( c:'-'; data:'5051605' ), + ( c:'$'; data:'5061505' ), + ( c:':'; data:'6050606' ), + ( c:'/'; data:'6060506' ), + ( c:'.'; data:'6060605' ), + ( c:'+'; data:'5060606' ), + ( c:'A'; data:'5061515' ), + ( c:'B'; data:'5151506' ), + ( c:'C'; data:'5051516' ), + ( c:'D'; data:'5051615' ) + ); + + + +{find Codabar} +function Find_Codabar(c:char):integer; +var + i:integer; +begin + for i:=0 to High(tabelle_cb) do + begin + if c = tabelle_cb[i].c then + begin + result := i; + exit; + end; + end; + result := -1; +end; + +var + i, idx : integer; +begin + result := tabelle_cb[Find_Codabar('A')].data + '0'; + for i:=1 to Length(FText) do + begin + idx := Find_Codabar(FText[i]); + result := result + tabelle_cb[idx].data + '0'; + end; + result := result + tabelle_cb[Find_Codabar('B')].data; +end; + + + +{---------------} + +{Assist function} +function TfrxBarcode.SetLen(pI:byte):string; +begin + Result := StringOfChar('0', pI-Length(FText)) + FText; +end; + + + +function TfrxBarcode.Code_UPC_A:string; +var + i : integer; + tmp : String; +begin + FText := SetLen(12); + if FCheckSum then tmp:=DoCheckSumming(copy(FText,1,11)); + if FCheckSum then FText:=tmp else tmp:=FText; + result := '505'; {Startcode} + for i:=1 to 6 do + result := result + tabelle_EAN_A[tmp[i]]; + result := result + '05050'; {Trennzeichen} + for i:=7 to 12 do + result := result + tabelle_EAN_C[tmp[i]]; + result := result + '505'; {Stopcode} +end; + + +{UPC E Parity Pattern Table , Number System 0} +const tabelle_UPC_E0:array['0'..'9', 1..6] of char = + ( + ('E', 'E', 'E', 'o', 'o', 'o' ), { 0 } + ('E', 'E', 'o', 'E', 'o', 'o' ), { 1 } + ('E', 'E', 'o', 'o', 'E', 'o' ), { 2 } + ('E', 'E', 'o', 'o', 'o', 'E' ), { 3 } + ('E', 'o', 'E', 'E', 'o', 'o' ), { 4 } + ('E', 'o', 'o', 'E', 'E', 'o' ), { 5 } + ('E', 'o', 'o', 'o', 'E', 'E' ), { 6 } + ('E', 'o', 'E', 'o', 'E', 'o' ), { 7 } + ('E', 'o', 'E', 'o', 'o', 'E' ), { 8 } + ('E', 'o', 'o', 'E', 'o', 'E' ) { 9 } + ); + +function TfrxBarcode.Code_UPC_E0:string; +var i,j : integer; + tmp : String; + c : char; +begin + FText := SetLen(7); + tmp:=DoCheckSumming(copy(FText,1,6)); + c:=tmp[7]; + if FCheckSum then FText:=tmp else tmp := FText; + result := '505'; {Startcode} + for i:=1 to 6 do + begin + if tabelle_UPC_E0[c,i]='E' then + begin + for j:= 1 to 4 do result := result + tabelle_EAN_C[tmp[i],5-j]; + end + else + begin + result := result + tabelle_EAN_A[tmp[i]]; + end; + end; + result := result + '050505'; {Stopcode} +end; + +function TfrxBarcode.Code_UPC_E1:string; +var i,j : integer; + tmp : String; + c : char; +begin + FText := SetLen(7); + tmp:=DoCheckSumming(copy(FText,1,6)); + c:=tmp[7]; + if FCheckSum then FText:=tmp else tmp := FText; + result := '505'; {Startcode} + for i:=1 to 6 do + begin + if tabelle_UPC_E0[c,i]='E' then + begin + result := result + tabelle_EAN_A[tmp[i]]; + end + else + begin + for j:= 1 to 4 do result := result + tabelle_EAN_C[tmp[i],5-j]; + end; + end; + result := result + '050505'; {Stopcode} +end; + +{assist function} +function getSupp(Nr : String) : String; +var i,fak,sum : Integer; + tmp : String; +begin + sum := 0; + tmp := copy(nr,1,Length(Nr)-1); + fak := Length(tmp); + for i:=1 to length(tmp) do + begin + if (fak mod 2) = 0 then + sum := sum + (StrToInt(tmp[i])*9) + else + sum := sum + (StrToInt(tmp[i])*3); + dec(fak); + end; + sum:=((sum mod 10) mod 10) mod 10; + result := tmp+IntToStr(sum); +end; + +function TfrxBarcode.Code_Supp5:string; +var i,j : integer; + tmp : String; + c : char; +begin + FText := SetLen(5); + tmp:=getSupp(copy(FText,1,5)+'0'); + c:=tmp[6]; + if FCheckSum then FText:=tmp else tmp := FText; + result := '506'; {Startcode} + for i:=1 to 5 do + begin + if tabelle_UPC_E0[c,(6-5)+i]='E' then + begin + for j:= 1 to 4 do result := result + tabelle_EAN_C[tmp[i],5-j]; + end + else + begin + result := result + tabelle_EAN_A[tmp[i]]; + end; + if i<5 then result:=result+'05'; { character delineator } + end; +end; + +function TfrxBarcode.Code_Supp2:string; +var i,j : integer; + tmp,mS : String; +begin + FText := SetLen(2); + i:=StrToInt(Ftext); + case i mod 4 of + 3: mS:='EE'; + 2: mS:='Eo'; + 1: mS:='oE'; + 0: mS:='oo'; + end; + tmp:=getSupp(copy(FText,1,5)+'0'); + + if FCheckSum then FText:=tmp else tmp := FText; + result := '506'; {Startcode} + for i:=1 to 2 do + begin + if mS[i]='E' then + begin + for j:= 1 to 4 do result := result + tabelle_EAN_C[tmp[i],5-j]; + end + else + begin + result := result + tabelle_EAN_A[tmp[i]]; + end; + if i<2 then result:=result+'05'; { character delineator } + end; +end; + +{---------------} + + + + +procedure TfrxBarcode.MakeModules; +begin + case Typ of + bcCode_2_5_interleaved, + bcCode_2_5_industrial, + bcCode39, + bcCodeEAN8, + bcCodeEAN13, + bcCode39Extended, + bcCodeCodabar, + bcCodeUPC_A, + bcCodeUPC_E0, + bcCodeUPC_E1, + bcCodeUPC_Supp2, + bcCodeUPC_Supp5: + + begin + if Ratio < 2.0 then Ratio := 2.0; + if Ratio > 3.0 then Ratio := 3.0; + end; + + bcCode_2_5_matrix: + begin + if Ratio < 2.25 then Ratio := 2.25; + if Ratio > 3.0 then Ratio := 3.0; + end; + bcCode128A, + bcCode128B, + bcCode128C, + bcCode93, + bcCode93Extended, + bcCodeMSI, + bcCodePostNet: ; + end; + + + modules[0] := FModul; + modules[1] := Round(FModul*FRatio); + modules[2] := modules[1] * 3 div 2; + modules[3] := modules[1] * 2; +end; + + +{ +Draw the Barcode + +Parameter : +'data' holds the pattern for a Barcode. +A barcode begins always with a black line and +ends with a black line. + +The white Lines builds the space between the black Lines. + +A black line must always followed by a white Line and vica versa. + +Examples: + '50505' // 3 thin black Lines with 2 thin white Lines + '606' // 2 fat black Lines with 1 thin white Line + + '5605015' // Error + + +data[] : see procedure OneBarProps + +} +procedure TfrxBarcode.DoLines(data:string; Canvas:TCanvas); + +var i:integer; + lt : TfrxBarLineType; + xadd:integer; + width, height:integer; + a,b,c,d, {Edges of a line (we need 4 Point because the line} + {is a recangle} + orgin : TPoint; + alpha:double; +begin + xadd := 0; + orgin.x := FLeft; + orgin.y := FTop; + + alpha := FAngle/180.0*pi; + + { Move the orgin so the entire barcode ends up in the visible region. } + orgin := TranslateQuad2D(alpha,orgin,Point(Self.Width,Self.Height)); + + with Canvas do begin + Pen.Width := 1; + + for i:=1 to Length(data) do {examine the pattern string} + begin + + { + input: pattern code + output: Width and Linetype + } + OneBarProps(data[i], width, lt); + + if (lt = black) or (lt = black_half) then + begin + Pen.Color := FColorBar; + end + else + begin + Pen.Color := FColor; + end; + Brush.Color := Pen.Color; + + if lt = black_half then + height := FHeight * 2 div 5 + else + height := FHeight; + + + + + + a.x := xadd; + a.y := 0; + + b.x := xadd; + b.y := height; + + {c.x := xadd+width;} + c.x := xadd+Width-1; {23.04.1999 Line was 1 Pixel too wide} + c.y := Height; + + {d.x := xadd+width;} + d.x := xadd+Width-1; {23.04.1999 Line was 1 Pixel too wide} + d.y := 0; + + {a,b,c,d builds the rectangle we want to draw} + + + {rotate the rectangle} + a := Translate2D(Rotate2D(a, alpha), orgin); + b := Translate2D(Rotate2D(b, alpha), orgin); + c := Translate2D(Rotate2D(c, alpha), orgin); + d := Translate2D(Rotate2D(d, alpha), orgin); + + {draw the rectangle} + Polygon([a,b,c,d]); + + xadd := xadd + width; + end; + end; +end; + +procedure TfrxBarcode.DrawBarcode(Canvas: TCanvas; ARect: TRect; ShowText: Boolean); +const + TxtHeight = 14; +var + data : string; + w, h, BarWidth: Integer; + EMF: TMetafile; + EMFCanvas: TMetafileCanvas; + Zoom: Extended; + + function CreateRotatedFont(Font: TFont; Angle: Integer): HFont; + var + F: TLogFont; + begin + GetObject(Font.Handle, SizeOf(TLogFont), @F); + F.lfEscapement := Angle * 10; + F.lfOrientation := Angle * 10; + Result := CreateFontIndirect(F); + end; + + procedure TextOutR(x, x1, x2: Integer; s: String); + begin + with EMFCanvas do + case Round(FAngle) of + 90: + begin + FillRect(Rect(w - TxtHeight, h - x1, w, h - x2 - 1)); + TextOut(w - TxtHeight, h - x, s); + end; + 180: + begin + FillRect(Rect(w - x1, 0, w - x2 - 1, TxtHeight + 2)); + TextOut(w - x, TxtHeight, s); + end; + 270: + begin + FillRect(Rect(0, x1, TxtHeight, x2 + 1)); + TextOut(TxtHeight, x, s); + end; + else + begin + FillRect(Rect(x1, h - TxtHeight - 2, x2 + 1, h)); + TextOut(x, h - TxtHeight, s); + end; + end; + end; + + procedure OutText; + var + TxtWidth: Integer; + FontHandle, OldFontHandle: HFont; + begin + with EMFCanvas do + begin + Font.Name := 'Arial'; + Font.Size := 9; + FontHandle := CreateRotatedFont(Font, Round(FAngle)); + OldFontHandle := SelectObject(Handle, FontHandle); + Brush.Color := Color; + SetBkMode(Handle, Transparent); + + case FTyp of + bcCodeEAN8: // 8 digits, 4+4 + begin + TextOutR(3, 3, 30, Copy(FText, 1, 4)); + TextOutR(35, 35, BarWidth - 4, Copy(FText, 5, 4)); + end; + bcCodeEAN13: // 13 digits, 1+6+6 or 12 digits, 6+6 + begin + if FText[1] <> '0' then + TextOutR(-8, -8, -2, Copy(FText, 1, 1)); + TextOutR(3, 3, 44, Copy(FText, 2, 6)); + TextOutR(49, 49, BarWidth - 4, Copy(FText, 8, 6)); + end; + bcCodeUPC_A: // 12 digits, 1+5+5+1 + begin + TextOutR(-8, -8, -2, Copy(FText, 1, 1)); + TextOutR(10, 10, 44, Copy(FText, 2, 5)); + TextOutR(49, 49, 83, Copy(FText, 7, 5)); + TextOutR(BarWidth + 1, BarWidth + 1, BarWidth + 8, Copy(FText, 12, 1)); + end; + bcCodeUPC_E0, + bcCodeUPC_E1: // 7 digits, 6+1 + begin + TextOutR(3, 3, 44, Copy(FText, 1, 6)); + TextOutR(BarWidth + 1, BarWidth + 1, BarWidth + 8, Copy(FText, 7, 1)); + end; + else + begin + TxtWidth := TextWidth(FText); + TextOutR((BarWidth - TxtWidth) div 2, 0, BarWidth, FText); + end; + end; + + SelectObject(Handle, OldFontHandle); + DeleteObject(FontHandle); + end; + end; + +begin + data := MakeData; + BarWidth := Width; + + FLeft := 0; + FTop := 0; + + if (FAngle = 0) or (FAngle = 180) then + begin + Zoom := (ARect.Right - ARect.Left) / BarWidth; + w := BarWidth; + h := ARect.Bottom - ARect.Top; + h := Round(h / Zoom); + FHeight := h; + if ShowText then + if FTyp in [bcCodeEAN8, bcCodeEAN13, bcCodeUPC_A, bcCodeUPC_E0, bcCodeUPC_E1] then + begin + FHeight := h - TxtHeight div 2; + if FAngle = 180 then + FTop := (TxtHeight + 2) div 2; + end + else + begin + FHeight := h - TxtHeight - 2; + if FAngle = 180 then + FTop := TxtHeight + 2; + end; + end + else + begin + Zoom := (ARect.Bottom - ARect.Top) / BarWidth; + w := ARect.Right - ARect.Left; + h := BarWidth; + w := Round(w / Zoom); + FHeight := w; + if ShowText then + if FTyp in [bcCodeEAN8, bcCodeEAN13, bcCodeUPC_A, bcCodeUPC_E0, bcCodeUPC_E1] then + begin + FHeight := w - TxtHeight div 2; + if FAngle = 270 then + FLeft := (TxtHeight + 2) div 2; + end + else + begin + FHeight := w - TxtHeight - 2; + if FAngle = 270 then + FLeft := TxtHeight + 2; + end; + end; + + EMF := TMetafile.Create; + EMF.Width := w; + EMF.Height := h; + + try + EMFCanvas := TMetafileCanvas.Create(EMF, 0); + + try + DoLines(data, EMFCanvas); + if ShowText then + OutText; + finally + EMFCanvas.Free; + end; + + Canvas.StretchDraw(ARect, EMF); + finally + EMF.Free; + end; +end; + + +end. + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxBarcode.pas b/official/4.2/LibD11/frxBarcode.pas new file mode 100644 index 0000000..125eaf3 --- /dev/null +++ b/official/4.2/LibD11/frxBarcode.pas @@ -0,0 +1,243 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Barcode Add-in object } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxBarcode; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Menus, frxBarcod, frxClass, ExtCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxBarCodeObject = class(TComponent); // fake component + + TfrxBarCodeView = class(TfrxView) + private + FBarCode: TfrxBarCode; + FBarType: TfrxBarcodeType; + FCalcCheckSum: Boolean; + FExpression: String; + FHAlign: TfrxHAlign; + FRotation: Integer; + FShowText: Boolean; + FText: String; + FWideBarRatio: Extended; + FZoom: Extended; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure GetData; override; + class function GetDescription: String; override; + function GetRealBounds: TfrxRect; override; + property BarCode: TfrxBarCode read FBarCode; + published + property BarType: TfrxBarcodeType read FBarType write FBarType; + property BrushStyle; + property CalcCheckSum: Boolean read FCalcCheckSum write FCalcCheckSum default False; + property Color; + property Cursor; + property DataField; + property DataSet; + property DataSetName; + property Expression: String read FExpression write FExpression; + property Frame; + property HAlign: TfrxHAlign read FHAlign write FHAlign default haLeft; + property Rotation: Integer read FRotation write FRotation; + property ShowText: Boolean read FShowText write FShowText default True; + property TagStr; + property Text: String read FText write FText; + property URL; + property WideBarRatio: Extended read FWideBarRatio write FWideBarRatio; + property Zoom: Extended read FZoom write FZoom; + end; + + +implementation + +uses +{$IFNDEF NO_EDITORS} + frxBarcodeEditor, +{$ENDIF} + frxBarcodeRTTI, frxDsgnIntf, frxRes, frxUtils; + +const + cbDefaultText = '12345678'; + + +{ TfrxBarCodeView } + +constructor TfrxBarCodeView.Create(AOwner: TComponent); +begin + inherited; + + FBarCode := TfrxBarCode.Create(nil); + FBarType := bcCode39; + FShowText := True; + FZoom := 1; + FText := cbDefaultText; + FWideBarRatio := 2; +end; + +destructor TfrxBarCodeView.Destroy; +begin + FBarCode.Free; + inherited Destroy; +end; + +class function TfrxBarCodeView.GetDescription: String; +begin + Result := frxResources.Get('obBarC'); +end; + +procedure TfrxBarCodeView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +var + SaveWidth: Extended; + ErrorText: String; + DrawRect: TRect; +begin + FBarCode.Angle := FRotation; + FBarCode.Checksum := FCalcCheckSum; + FBarCode.Typ := FBarType; + FBarCode.Ratio := FWideBarRatio; + if Color = clNone then + FBarCode.Color := clWhite else + FBarCode.Color := Color; + + SaveWidth := Width; + + FBarCode.Text := FText; + ErrorText := ''; + if FZoom < 0.0001 then + FZoom := 1; + + try + if (FRotation = 0) or (FRotation = 180) then + Width := FBarCode.Width * FZoom + else + Height := FBarCode.Width * FZoom; + except + on e: Exception do + begin + FBarCode.Text := '12345678'; + ErrorText := e.Message; + end; + end; + + if FHAlign = haRight then + Left := Left + SaveWidth - Width + else if FHAlign = haCenter then + Left := Left + (SaveWidth - Width) / 2; + + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + + DrawBackground; + if ErrorText = '' then + FBarCode.DrawBarcode(Canvas, Rect(FX, FY, FX1, FY1), FShowText) + else + with Canvas do + begin + Font.Name := 'Arial'; + Font.Size := Round(8 * ScaleY); + Font.Color := clRed; + DrawRect := Rect(FX + 2, FY + 2, FX1, FY1); + DrawText(Handle, PChar(ErrorText), Length(ErrorText), + DrawRect, DT_WORDBREAK); + end; + DrawFrame; +end; + +procedure TfrxBarCodeView.GetData; +begin + inherited; + if IsDataField then + FText := VarToStr(DataSet.Value[DataField]) + else if FExpression <> '' then + FText := VarToStr(Report.Calc(FExpression)); +end; + +function TfrxBarCodeView.GetRealBounds: TfrxRect; +var + extra1, extra2, txtWidth: Integer; + bmp: TBitmap; +begin + bmp := TBitmap.Create; + Draw(bmp.Canvas, 1, 1, 0, 0); + + Result := inherited GetRealBounds; + extra1 := 0; + extra2 := 0; + + if (FRotation = 0) or (FRotation = 180) then + begin + with bmp.Canvas do + begin + Font.Name := 'Arial'; + Font.Size := 9; + Font.Style := []; + txtWidth := TextWidth(FBarcode.Text); + if Width < txtWidth then + begin + extra1 := Round((txtWidth - Width) / 2) + 2; + extra2 := extra1; + end; + end; + end; + + if FBarType in [bcCodeEAN13, bcCodeUPC_A] then + extra1 := 8; + if FBarType in [bcCodeUPC_A, bcCodeUPC_E0, bcCodeUPC_E1] then + extra2 := 8; + case FRotation of + 0: + begin + Result.Left := Result.Left - extra1; + Result.Right := Result.Right + extra2; + end; + 90: + begin + Result.Bottom := Result.Bottom + extra1; + Result.Top := Result.Top - extra2; + end; + 180: + begin + Result.Left := Result.Left - extra2; + Result.Right := Result.Right + extra1; + end; + 270: + begin + Result.Bottom := Result.Bottom + extra2; + Result.Top := Result.Top - extra1; + end; + end; + + bmp.Free; +end; + + +initialization + frxObjects.RegisterObject1(TfrxBarCodeView, nil, '', '', 0, 23); + + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxBarcodeEditor.dfm b/official/4.2/LibD11/frxBarcodeEditor.dfm new file mode 100644 index 0000000..50a77b7 Binary files /dev/null and b/official/4.2/LibD11/frxBarcodeEditor.dfm differ diff --git a/official/4.2/LibD11/frxBarcodeEditor.pas b/official/4.2/LibD11/frxBarcodeEditor.pas new file mode 100644 index 0000000..f5fdc31 --- /dev/null +++ b/official/4.2/LibD11/frxBarcodeEditor.pas @@ -0,0 +1,274 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Barcode design editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxBarcodeEditor; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Menus, ExtCtrls, Buttons, frxClass, frxBarcode, frxCustomEditors, + frxBarcod, frxCtrls, ComCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxBarcodeEditor = class(TfrxViewEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxBarcodeEditorForm = class(TForm) + CancelB: TButton; + OkB: TButton; + CodeE: TfrxComboEdit; + CodeLbl: TLabel; + TypeCB: TComboBox; + TypeLbl: TLabel; + ExampleBvl: TBevel; + ExamplePB: TPaintBox; + OptionsLbl: TGroupBox; + ZoomLbl: TLabel; + CalcCheckSumCB: TCheckBox; + ViewTextCB: TCheckBox; + ZoomE: TEdit; + UpDown1: TUpDown; + RotationLbl: TGroupBox; + Rotation0RB: TRadioButton; + Rotation90RB: TRadioButton; + Rotation180RB: TRadioButton; + Rotation270RB: TRadioButton; + procedure ExprBtnClick(Sender: TObject); + procedure UpBClick(Sender: TObject); + procedure DownBClick(Sender: TObject); + procedure ExamplePBPaint(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + FBarcode: TfrxBarcodeView; + public + { Public declarations } + property Barcode: TfrxBarcodeView read FBarcode write FBarcode; + end; + + +implementation + +uses frxDsgnIntf, frxRes, frxUtils; + +{$R *.DFM} + +const + cbDefaultText = '12345678'; + + +{ TfrxBarcodeEditor } + +function TfrxBarcodeEditor.HasEditor: Boolean; +begin + Result := True; +end; + +function TfrxBarcodeEditor.Edit: Boolean; +begin + with TfrxBarcodeEditorForm.Create(Designer) do + begin + Barcode := TfrxBarcodeView(Component); + Result := ShowModal = mrOk; + Free; + end; +end; + +function TfrxBarcodeEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + i: Integer; + c: TfrxComponent; + v: TfrxBarcodeView; +begin + Result := inherited Execute(Tag, Checked); + for i := 0 to Designer.SelectedObjects.Count - 1 do + begin + c := Designer.SelectedObjects[i]; + if (c is TfrxBarcodeView) and not (rfDontModify in c.Restrictions) then + begin + v := TfrxBarcodeView(c); + if Tag = 1 then + v.CalcCheckSum := Checked + else if Tag = 2 then + v.ShowText := Checked; + Result := True; + end; + end; +end; + +procedure TfrxBarcodeEditor.GetMenuItems; +var + v: TfrxBarcodeView; +begin + v := TfrxBarcodeView(Component); + AddItem(frxResources.Get('bcCalcChecksum'), 1, v.CalcCheckSum); + AddItem(frxResources.Get('bcShowText'), 2, v.ShowText); + inherited; +end; + + +{ TfrxBarcodeEditorForm } + +procedure TfrxBarcodeEditorForm.FormShow(Sender: TObject); +var + i: TfrxBarcodeType; +begin + TypeCB.Items.Clear; + for i := bcCode_2_5_interleaved to bcCodeEAN128C do + TypeCB.Items.Add(bcData[i].Name); + + CodeE.Text := FBarcode.Expression; + TypeCB.ItemIndex := Integer(FBarcode.BarType); + CalcCheckSumCB.Checked := FBarcode.CalcCheckSum; + ViewTextCB.Checked := FBarcode.ShowText; + ZoomE.Text := FloatToStr(FBarcode.Zoom); + + case FBarcode.Rotation of + 90: Rotation90RB.Checked := True; + 180: Rotation180RB.Checked := True; + 270: Rotation270RB.Checked := True; + else Rotation0RB.Checked := True; + end; + + ExamplePBPaint(nil); +end; + +procedure TfrxBarcodeEditorForm.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + begin + FBarcode.Expression := CodeE.Text; + FBarcode.BarType := TfrxBarcodeType(TypeCB.ItemIndex); + FBarcode.CalcCheckSum := CalcCheckSumCB.Checked; + FBarcode.ShowText := ViewTextCB.Checked; + FBarcode.Zoom := frxStrToFloat(ZoomE.Text); + + if Rotation90RB.Checked then + FBarcode.Rotation := 90 + else if Rotation180RB.Checked then + FBarcode.Rotation := 180 + else if Rotation270RB.Checked then + FBarcode.Rotation := 270 + else + FBarcode.Rotation := 0; + end; +end; + +procedure TfrxBarcodeEditorForm.ExprBtnClick(Sender: TObject); +var + s: String; +begin + s := TfrxCustomDesigner(Owner).InsertExpression(CodeE.Text); + if s <> '' then + CodeE.Text := s; +end; + +procedure TfrxBarcodeEditorForm.UpBClick(Sender: TObject); +var + i: Double; +begin + i := frxStrToFloat(ZoomE.Text); + i := i + 0.1; + ZoomE.Text := FloatToStr(i); +end; + +procedure TfrxBarcodeEditorForm.DownBClick(Sender: TObject); +var + i: Double; +begin + i := frxStrToFloat(ZoomE.Text); + i := i - 0.1; + if i <= 0 then i := 1; + ZoomE.Text := FloatToStr(i); +end; + +procedure TfrxBarcodeEditorForm.ExamplePBPaint(Sender: TObject); +var + Barcode: TfrxBarcode; +begin + Barcode := TfrxBarcode.Create(Self); + Barcode.Typ := TfrxBarcodeType(TypeCB.ItemIndex); + Barcode.Text := '12345678'; + if Rotation0RB.Checked then + Barcode.Angle := 0 + else if Rotation90RB.Checked then + Barcode.Angle := 90 + else if Rotation180RB.Checked then + Barcode.Angle := 180 + else + Barcode.Angle := 270; + Barcode.CheckSum := CalcCheckSumCB.Checked; + + with ExamplePB.Canvas do + begin + Brush.Color := clWhite; + FillRect(Rect(0, 0, ExamplePB.Width, ExamplePB.Height)); + Barcode.DrawBarcode(ExamplePB.Canvas, Rect(40, 20, ExamplePB.Width - 40, 200), + ViewTextCB.Checked); + end; + + Barcode.Free; +end; + +procedure TfrxBarcodeEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(3500); + CodeLbl.Caption := frxGet(3501); + TypeLbl.Caption := frxGet(3502); + ZoomLbl.Caption := frxGet(3503); + OptionsLbl.Caption := frxGet(3504); + RotationLbl.Caption := frxGet(3505); + CancelB.Caption := frxGet(2); + OkB.Caption := frxGet(1); + CalcCheckSumCB.Caption := frxGet(3506); + ViewTextCB.Caption := frxGet(3507); + Rotation0RB.Caption := frxGet(3508); + Rotation90RB.Caption := frxGet(3509); + Rotation180RB.Caption := frxGet(3510); + Rotation270RB.Caption := frxGet(3511); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + + +procedure TfrxBarcodeEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +initialization + frxComponentEditors.Register(TfrxBarcodeView, TfrxBarcodeEditor); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxBarcodeRTTI.pas b/official/4.2/LibD11/frxBarcodeRTTI.pas new file mode 100644 index 0000000..3b23c24 --- /dev/null +++ b/official/4.2/LibD11/frxBarcodeRTTI.pas @@ -0,0 +1,59 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Barcode RTTI } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxBarcodeRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, frxBarcode, frxClassRTTI +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TFunctions = class(TfsRTTIModule) + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnum('TfrxBarcodeType', 'bcCode_2_5_interleaved, bcCode_2_5_industrial,' + + 'bcCode_2_5_matrix, bcCode39, bcCode39Extended, bcCode128A, bcCode128B,' + + 'bcCode128C, bcCode93, bcCode93Extended, bcCodeMSI, bcCodePostNet,' + + 'bcCodeCodabar, bcCodeEAN8, bcCodeEAN13, bcCodeUPC_A, bcCodeUPC_E0,' + + 'bcCodeUPC_E1, bcCodeUPC_Supp2, bcCodeUPC_Supp5, bcCodeEAN128A,' + + 'bcCodeEAN128B, bcCodeEAN128C'); + AddClass(TfrxBarcodeView, 'TfrxView'); + end; +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCGIClient.pas b/official/4.2/LibD11/frxCGIClient.pas new file mode 100644 index 0000000..5d8db2d --- /dev/null +++ b/official/4.2/LibD11/frxCGIClient.pas @@ -0,0 +1,671 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ CGI wrapper client unit } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCGIClient; + +{$I frx.inc} + +interface + +uses + Windows, SysUtils, Classes, ScktComp, frxServerUtils, frxNetUtils +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxCGIServerFields = class; + TfrxCGIClientFields = class; + TfrxClientThread = class; + + TfrxCGIClient = class(TObject) + private + FActive: Boolean; + FAnswer: TStrings; + FBreaked: Boolean; + FClientFields: TfrxCGIClientFields; + FErrors: TStrings; + FHeader: TStrings; + FHost: String; + FPort: Integer; + FProxyHost: String; + FProxyPort: Integer; + FRetryCount: Integer; + FRetryTimeOut: Integer; + FServerFields: TfrxCGIServerFields; + FStream: TMemoryStream; + FTempStream: TMemoryStream; + FThread: TfrxClientThread; + FTimeOut: Integer; + F_QUERY_STRING: String; + F_REMOTE_HOST: String; + F_SERVER_NAME: String; + F_SERVER_PORT: String; + F_HTTP_REFERER: String; + F_HTTP_USER_AGENT: String; + F_CGI_FILENAME: String; + OutStream: THandleStream; + IsHTML: Boolean; + procedure DoConnect(Sender: TObject; Socket: TCustomWinSocket); + procedure DoDisconnect(Sender: TObject; Socket: TCustomWinSocket); + procedure DoError(Sender: TObject; Socket: TCustomWinSocket; + ErrorEvent: TErrorEvent; var ErrorCode: Integer); + procedure DoRead(Sender: TObject; Socket: TCustomWinSocket); + procedure SetActive(const Value: Boolean); + procedure SetClientFields(const Value: TfrxCGIClientFields); + procedure SetServerFields(const Value: TfrxCGIServerFields); + procedure PrepareCGIStream(IStream: TStream; OStream: TStream); + procedure ReplaceCGIReps(Sign1: String; Sign2: String; IStream: TStream; OStream: TStream); + procedure DeleteCGIReps(Sign: String; IStream: TStream; OStream: TStream); + procedure InsertCGIHref(Sign: String; IStream: TStream; OStream: TStream); + public + ParentThread: TThread; + StreamSize: Cardinal; + constructor Create; + destructor Destroy; override; + procedure Connect; + procedure Disconnect; + procedure Open; + procedure Close; + property Answer: TStrings read FAnswer write FAnswer; + property Breaked: Boolean read FBreaked; + property Errors: TStrings read FErrors write Ferrors; + property Header: TStrings read FHeader write FHeader; + property Stream: TMemoryStream read FStream write FStream; + property ClientFields: TfrxCGIClientFields read FClientFields write SetClientFields; + property ServerFields: TfrxCGIServerFields read FServerFields write SetServerFields; + + property Active: Boolean read FActive write SetActive; + property Host: String read FHost write FHost; + property Port: Integer read FPort write FPort; + property ProxyHost: String read FProxyHost write FProxyHost; + property ProxyPort: Integer read FProxyPort write FProxyPort; + property RetryCount: Integer read FRetryCount write FRetryCount; + property RetryTimeOut: Integer read FRetryTimeOut write FRetryTimeOut; + property TimeOut: Integer read FTimeOut write FTimeOut; + end; + + TfrxCGIServerFields = class (TPersistent) + private + FAnswerCode: Integer; + FContentEncoding: String; + FContentLength: Integer; + FLocation: String; + FSessionId: String; + public + constructor Create; + procedure Assign(Source: TPersistent); override; + + property AnswerCode: Integer read FAnswerCode write FAnswerCode; + property ContentEncoding: String read FContentEncoding write FContentEncoding; + property ContentLength: Integer read FContentLength write FContentLength; + property Location: String read FLocation write FLocation; + property SessionId: String read FSessionId write FSessionId; + end; + + TfrxCGIClientFields = class (TPersistent) + private + FAcceptEncoding: String; + FHost: String; + FHTTPVer: String; + FLogin: String; + FName: String; + FPassword: String; + FQueryType: TfrxHTTPQueryType; + FReferer: String; + FUserAgent: String; + public + constructor Create; + procedure Assign(Source: TPersistent); override; + + property AcceptEncoding: String read FAcceptEncoding write FAcceptEncoding; + property FileName: String read FName write FName; + property Host: String read FHost write FHost; + property HTTPVer: String read FHTTPVer write FHTTPVer; + property Login: String read FLogin write FLogin; + property Password: String read FPassword write FPassword; + property QueryType: TfrxHTTPQueryType read FQueryType write FQueryType; + property Referer: String read FReferer write FReferer; + property UserAgent: String read FUserAgent write FUserAgent; + end; + + TfrxClientThread = class (TThread) + protected + FClient: TfrxCGIClient; + procedure DoOpen; + procedure Execute; override; + public + FSocket: TClientSocket; + constructor Create(Client: TfrxCGIClient); + destructor Destroy; override; + end; + +implementation + +uses frxFileUtils; + +type + THackThread = class(TThread); + +{ TfrxCGIServerFields } + +constructor TfrxCGIServerFields.Create; +begin + FAnswerCode := 0; + FLocation := ''; + FContentEncoding := ''; + FContentLength := 0; +end; + +procedure TfrxCGIServerFields.Assign(Source: TPersistent); +begin + if Source is TfrxCGIServerFields then + begin + FAnswerCode := TfrxCGIServerFields(Source).AnswerCode; + FLocation := TfrxCGIServerFields(Source).Location; + FContentEncoding := TfrxCGIServerFields(Source).ContentEncoding; + FContentLength := TfrxCGIServerFields(Source).ContentLength; + end; +end; + +{ TfrxCGIClientFields } + +constructor TfrxCGIClientFields.Create; +begin + FQueryType := qtGet; + FHTTPVer := 'HTTP/1.1'; + FName := ''; + FUserAgent := 'FastReportCGI/3.0'; + FHost := ''; + FAcceptEncoding := ''; + FLogin := ''; + FPassword := ''; + FReferer := ''; +end; + +procedure TfrxCGIClientFields.Assign(Source: TPersistent); +begin + if Source is TfrxCGIClientFields then + begin + FQueryType := TfrxCGIClientFields(Source).QueryType; + FName := TfrxCGIClientFields(Source).FileName; + FHTTPVer := TfrxCGIClientFields(Source).HTTPVer; + FUserAgent := TfrxCGIClientFields(Source).UserAgent; + FHost := TfrxCGIClientFields(Source).Host; + FAcceptEncoding := TfrxCGIClientFields(Source).AcceptEncoding; + FLogin := TfrxCGIClientFields(Source).Login; + FPassword := TfrxCGIClientFields(Source).Password; + FReferer := TfrxCGIClientFields(Source).Referer; + end; +end; + +{ TfrxCGIClient } + +constructor TfrxCGIClient.Create; +begin + FHeader := TStringList.Create; + FAnswer := TStringList.Create; + FStream := TMemoryStream.Create; + FTempStream := TMemoryStream.Create; + FErrors := TStringList.Create; + FHost := '127.0.0.1'; + FPort := 8097; + FProxyHost := ''; + FProxyPort := 8080; + FActive := False; + FServerFields := TfrxCGIServerFields.Create; + FClientFields := TfrxCGIClientFields.Create; + FRetryTimeOut := 5; + FRetryCount := 3; + FTimeOut := 30; + FBreaked := False; + ParentThread := nil; + FThread := TfrxClientThread.Create(Self); + FThread.FSocket.OnConnect := DoConnect; + FThread.FSocket.OnRead := DoRead; + FThread.FSocket.OnDisconnect := DoDisconnect; + FThread.FSocket.OnError := DoError; +end; + +destructor TfrxCGIClient.Destroy; +begin + Close; + while FActive do + PMessages; + FThread.Free; + FClientFields.Free; + FServerFields.Free; + FHeader.Free; + FAnswer.Free; + FStream.Free; + FTempStream.Free; + FErrors.Free; + inherited; +end; + +procedure TfrxCGIClient.Connect; +var + ticks: Cardinal; + i: Integer; + s: String; +begin + IsHTML := False; + F_QUERY_STRING := GetEnvVar('QUERY_STRING'); + F_REMOTE_HOST := GetEnvVar('REMOTE_HOST'); + F_SERVER_NAME := GetEnvVar('SERVER_NAME'); + F_SERVER_PORT := GetEnvVar('SERVER_PORT'); + F_HTTP_REFERER := GetEnvVar('HTTP_REFERER'); + F_HTTP_USER_AGENT := GetEnvVar('HTTP_USER_AGENT'); + F_CGI_FILENAME := ExtractFileName(ParamStr(0)); + ClientFields.AcceptEncoding := ''; + if Pos('report', ClientFields.FileName) > 0 then + ClientFields.FileName := 'result?' + ClientFields.FileName; + ClientFields.FileName := F_QUERY_STRING; + ClientFields.Host := F_REMOTE_HOST; + ClientFields.UserAgent := F_HTTP_USER_AGENT; + ClientFields.Referer := F_HTTP_REFERER; + + OutStream := THandleStream.Create(GetStdHandle(STD_OUTPUT_HANDLE)); + try + i := FRetryCount; + FBreaked := False; + repeat + FErrors.Clear; + FTempStream.Clear; + FActive := True; + if Length(FProxyHost) > 0 then + begin + FThread.FSocket.Host := FProxyHost; + FThread.FSocket.Address := FProxyHost; + FThread.FSocket.Port := FProxyPort; + end else + begin + FThread.FSocket.Host := FHost; + FThread.FSocket.Address := FHost; + FThread.FSocket.Port := FPort; + end; + FThread.FSocket.ClientType := ctNonBlocking; + FThread.Execute; + try + ticks := GetTickCount; + while FActive and (not FBreaked) do + begin + PMessages; + if (GetTickCount - ticks) > Cardinal(FTimeOut * 1000) then + begin + Errors.Add('Timeout expired (' + IntToStr(FTimeOut) + ')'); + break; + end; + end; + finally + Disconnect; + end; + if not FBreaked then + begin + if (Errors.Count = 0) and ((FServerFields.AnswerCode = 301) or + (FServerFields.AnswerCode = 302) or (FServerFields.AnswerCode = 303)) then + begin + i := FRetryCount; + FClientFields.FileName := FServerFields.Location; + end + else if (Errors.Count > 0) + and (FServerFields.AnswerCode <> 401) + and (FServerFields.AnswerCode <> 403) + and (FServerFields.AnswerCode <> 404) then + begin + Dec(i); + if i > 0 then + Sleep(FRetryTimeOut * 1000) + else + if FRetryCount > 1 then + Errors.Add('Retry count (' + IntToStr(FRetryCount) + ') exceed') + end else + i := 0; + end; + until (i = 0) or FBreaked; + for i := 0 to Answer.Count - 1 do + if Pos('Content-type', Answer[i]) > 0 then + begin + s := Answer[i] + #13#10; + OutStream.Write(s[1], Length(s)); + IsHTML := Pos('text/html', s) > 0; + break; + end; + s := 'Status: ' + IntToStr(ServerFields.AnswerCode) + #13#10; + OutStream.Write(s[1], Length(s)); + s := 'Script-Control: no-abort'#13#10; + OutStream.Write(s[1], Length(s)); + OutStream.Write(#13#10, 2); + if IsHTML then + PrepareCGIStream(FStream, OutStream) + else + OutStream.CopyFrom(FStream, 0); + finally + OutStream.Free; + end; +end; + +procedure TfrxCGIClient.Disconnect; +begin + FThread.FSocket.Close; + FThread.Terminate; + FActive := False; +end; + +procedure TfrxCGIClient.DoConnect(Sender: TObject; + Socket: TCustomWinSocket); +var + s, s1: String; + m: TMemoryStream; +begin + FHeader.Clear; + if FClientFields.QueryType = qtGet then + s := 'GET' + else if FClientFields.QueryType = qtPost then + s := 'POST' + else + s := ''; + if Length(FProxyHost) > 0 then + s1 := 'http://' + Host + ':' + IntToStr(FPort) + '/' + FClientFields.FileName + else + s1 := '/' + FClientFields.FileName; + FHeader.Add(s + ' ' + s1 + ' ' + FClientFields.HTTPVer); + if Length(FClientFields.Host) = 0 then + s := Socket.LocalAddress + else + s := FClientFields.Host; + FHeader.Add('Host: ' + s); + if Length(FClientFields.UserAgent) > 0 then + FHeader.Add('User-Agent: ' + FClientFields.UserAgent); + if Length(FClientFields.AcceptEncoding) > 0 then + FHeader.Add('Accept-Encoding: ' + FClientFields.AcceptEncoding); + if Length(FClientFields.Login) > 0 then + FHeader.Add('Authorization: Basic ' + Base64Encode(FClientFields.Login + ':' + + FClientFields.Password)); + FHeader.Add('Connection: close'); + FHeader.Add(''); + try + m := TMemoryStream.Create; + try + m.Write(FHeader.Text[1], Length(FHeader.Text)); + if FStream.Size > 1 then + m.Write(FStream.Memory^, FStream.Size); + Socket.SendBuf(m.Memory^, m.Size); + finally + m.Free; + end + except + Errors.Add('Data send error'); + end; +end; + +procedure TfrxCGIClient.DoDisconnect(Sender: TObject; + Socket: TCustomWinSocket); +var + i, j, Len: Integer; + s, s1: String; +begin + FAnswer.Clear; + FStream.Clear; + if FTempStream.Size > 0 then + begin + FTempStream.Position := 0; + i := StreamSearch(FTempStream, 0, #13#10#13#10); + if i <> 0 then + begin + Len := i + 4; + StreamSize := FTempStream.Size - Len; + SetLength(s, Len); + FTempStream.Position := 0; + FTempStream.ReadBuffer(s[1], Len); + FAnswer.Text := s; + i := Pos(' ', s) + 1; + j := i; + while (i < Length(s)) and (s[i] <> ' ') and (s[i] <> #13) do + Inc(i); + s1 := Copy(s, j, i - j); + if Length(s1) > 0 then + FServerFields.FAnswerCode := StrToInt(s1); + s1 := ParseHeaderField('Location: ', s); + if (Length(s1) > 0) and (s1[1] = '/') then + Delete(s1, 1, 1); + FServerFields.Location := s1; + FServerFields.ContentEncoding := LowerCase(ParseHeaderField('Content-Encoding: ', s)); + s1 := ParseHeaderField('SessionId: ', s); + if Length(s1) > 0 then + FServerFields.SessionId := s1; + s1 := ParseHeaderField('Content-length: ', s); + if Length(s1) > 0 then + FServerFields.ContentLength := StrToInt(s1); + s1 := GetHTTPErrorText(FServerFields.AnswerCode); + if Length(s1) > 0 then + Errors.Add(s1); + if Errors.Count = 0 then + begin + if FServerFields.ContentLength > 0 then + if (FTempStream.Size - Len) <> FServerFields.ContentLength then + Errors.Add('Received data size mismatch'); + if Errors.Count = 0 then + FStream.CopyFrom(FTempStream, FTempStream.Size - Len); + end; + end else + Errors.Add('Bad header'); + FTempStream.Clear; + end + else if Errors.Count = 0 then + Errors.Add('Zero bytes received'); + if FStream.Size > 0 then + FStream.Position := 0; + FActive := False; +end; + +procedure TfrxCGIClient.DoError(Sender: TObject; Socket: TCustomWinSocket; + ErrorEvent: TErrorEvent; var ErrorCode: Integer); +begin + Errors.Add(GetSocketErrorText(ErrorCode)); + FActive := False; + ErrorCode := 0; +end; + +procedure TfrxCGIClient.DoRead(Sender: TObject; Socket: TCustomWinSocket); +var + buf: PChar; + i, j: Integer; +begin + i := Socket.ReceiveLength; + GetMem(buf, i); + j := i; + try + try + while j > 0 do + begin + j := Socket.ReceiveBuf(buf^, i); + FTempStream.Write(buf^, j); + end; + except + Errors.Add('Data receive error.') + end; + finally + FreeMem(buf); + end; +end; + +procedure TfrxCGIClient.SetActive(const Value: Boolean); +begin + if Value then Connect + else Disconnect; +end; + +procedure TfrxCGIClient.Close; +begin + FBreaked := True; + Active := False; +end; + +procedure TfrxCGIClient.Open; +begin + Active := True; +end; + +procedure TfrxCGIClient.SetServerFields(const Value: TfrxCGIServerFields); +begin + FServerFields.Assign(Value); +end; + +procedure TfrxCGIClient.SetClientFields(const Value: TfrxCGIClientFields); +begin + FClientFields.Assign(Value); +end; + +procedure TfrxCGIClient.InsertCGIHref(Sign: String; IStream: TStream; OStream: TStream); +var + i, j: Integer; + p, p1: Longint; + s, s1, buf: String; +begin + p := 0; + p1 := 0; + s := StringReplace(ExtractFileDir(StringReplace(ClientFields.FileName, '/', '\', [rfReplaceAll ])), '\', '/', [rfReplaceAll ]); + if s <> '' then + s := s + '/'; + s1 := F_CGI_FILENAME + '?' + s; + s := Sign; + SetLength(buf, 1); + while p <> -1 do + begin + p := StreamSearch(IStream, p, s); + if p <> -1 then + begin + i := StreamSearch(IStream, p, 'http:'); + j := StreamSearch(IStream, p, 'mailto:'); + if (i <> (p + Length(s))) and (j <> (p + Length(s))) then + begin + IStream.Position := p1; + OStream.CopyFrom(IStream, p - p1 + Length(s)); + IStream.Read(buf[1], 1); + if buf[1] in ['"', ''''] then + begin + OStream.Write(buf[1], 1); + p := p + 1; + end; + OStream.Write(s1[1], Length(s1)); + p1 := p + Length(s); + p := p + Length(s1); + end; + p := p + Length(s); + end; + end; + IStream.Position := p1; + OStream.CopyFrom(IStream, IStream.Size - p1); +end; + +procedure TfrxCGIClient.DeleteCGIReps(Sign: String; IStream: TStream; OStream: TStream); +var + p, p1: Longint; + s: String; +begin + p := 0; + p1 := 0; + s := Sign; + while p <> -1 do + begin + p := StreamSearch(IStream, p, s); + if p <> -1 then + begin + IStream.Position := p1; + OStream.CopyFrom(IStream, p - p1); + p := p + Length(s); + p1 := p; + end; + end; + IStream.Position := p1; + OStream.CopyFrom(IStream, IStream.Size - p1); +end; + +procedure TfrxCGIClient.ReplaceCGIReps(Sign1: String; Sign2: String; IStream: TStream; OStream: TStream); +var + p, p1: Longint; + s: String; +begin + p := 0; + p1 := 0; + s := Sign1; + while p <> -1 do + begin + p := StreamSearch(IStream, p, s); + if p <> -1 then + begin + IStream.Position := p1; + OStream.CopyFrom(IStream, p - p1); + OStream.Write(Sign2[1], Length(Sign2)); + p := p + Length(s); + p1 := p; + end; + end; + IStream.Position := p1; + OStream.CopyFrom(IStream, IStream.Size - p1); +end; + +procedure TfrxCGIClient.PrepareCGIStream(IStream: TStream; OStream: TStream); +var + TempStream: TMemoryStream; + TempStream1: TMemoryStream; +begin + TempStream := TMemoryStream.Create; + TempStream1 := TMemoryStream.Create; + try + TempStream.Clear; + InsertCGIHref(' href=', IStream, TempStream); + TempStream1.Clear; + InsertCGIHref(' src=', TempStream, TempStream1); + TempStream.Clear; + InsertCGIHref('frPrefix="', TempStream1, TempStream); + TempStream1.Clear; + InsertCGIHref('parent.location = "', TempStream, TempStream1); + TempStream.Clear; + DeleteCGIReps('result?', TempStream1, TempStream); + TempStream1.Clear; + ReplaceCGIReps('action="result"', 'action="' + F_CGI_FILENAME + '"', TempStream, TempStream1); + OStream.CopyFrom(TempStream1, 0); + finally + TempStream.Free; + TempStream1.Free; + end; +end; + +{ TfrxClientThread } + +constructor TfrxClientThread.Create(Client: TfrxCGIClient); +begin + inherited Create(True); + FClient := Client; + FreeOnTerminate := False; + FSocket := TClientSocket.Create(nil); +end; + +destructor TfrxClientThread.Destroy; +begin + FSocket.Free; + inherited; +end; + +procedure TfrxClientThread.DoOpen; +begin + FSocket.Open; +end; + +procedure TfrxClientThread.Execute; +begin + Synchronize(DoOpen); +end; + +end. diff --git a/official/4.2/LibD11/frxChBox.pas b/official/4.2/LibD11/frxChBox.pas new file mode 100644 index 0000000..b0a7d44 --- /dev/null +++ b/official/4.2/LibD11/frxChBox.pas @@ -0,0 +1,182 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Checkbox Add-In Object } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxChBox; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Menus, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxCheckStyle = (csCross, csCheck, csLineCross, csPlus); + TfrxUncheckStyle = (usEmpty, usCross, usLineCross, usMinus); + + TfrxCheckBoxObject = class(TComponent) // fake component + end; + + TfrxCheckBoxView = class(TfrxView) + private + FCheckColor: TColor; + FChecked: Boolean; + FCheckStyle: TfrxCheckStyle; + FUncheckStyle: TfrxUncheckStyle; + FExpression: String; + procedure DrawCheck(ARect: TRect); + public + constructor Create(AOwner: TComponent); override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure GetData; override; + class function GetDescription: String; override; + published + property BrushStyle; + property CheckColor: TColor read FCheckColor write FCheckColor; + property Checked: Boolean read FChecked write FChecked default True; + property CheckStyle: TfrxCheckStyle read FCheckStyle write FCheckStyle; + property Color; + property Cursor; + property DataField; + property DataSet; + property DataSetName; + property Expression: String read FExpression write FExpression; + property Frame; + property TagStr; + property UncheckStyle: TfrxUncheckStyle read FUncheckStyle write FUncheckStyle default usEmpty; + property URL; + end; + + +implementation + +uses frxChBoxRTTI, frxDsgnIntf, frxRes; + + +constructor TfrxCheckBoxView.Create(AOwner: TComponent); +begin + inherited; + FChecked := True; + Height := fr01cm * 5; + Width := fr01cm * 5; +end; + +class function TfrxCheckBoxView.GetDescription: String; +begin + Result := frxResources.Get('obChBox'); +end; + +procedure TfrxCheckBoxView.DrawCheck(ARect: TRect); +var + s: String; +begin + with FCanvas, ARect do + if FChecked then + begin + if FCheckStyle in [csCross, csCheck] then + begin + Font.Name := 'Wingdings'; + Font.Color := FCheckColor; + Font.Style := []; + Font.Height := - (Bottom - Top); + Font.CharSet := SYMBOL_CHARSET; + if FCheckStyle = csCross then + s := #251 else + s := #252; + SetBkMode(Handle, Transparent); + ExtTextOut(Handle, Left + (Right - Left - TextWidth(s)) div 2, + Top, ETO_CLIPPED, @ARect, PChar(s), 1, nil); + end + else if FCheckStyle = csLineCross then + begin + Pen.Style := psSolid; + Pen.Color := FCheckColor; + DrawLine(Left, Top, Right, Bottom, FFrameWidth); + DrawLine(Left, Bottom, Right, Top, FFrameWidth); + end + else if FCheckStyle = csPlus then + begin + Pen.Style := psSolid; + Pen.Color := FCheckColor; + DrawLine(Left + 3, Top + (Bottom - Top) div 2, Right - 2, Top + (Bottom - Top) div 2, FFrameWidth); + DrawLine(Left + (Right - Left) div 2, Top + 3, Left + (Right - Left) div 2, Bottom - 2, FFrameWidth); + end + end + else + begin + if FUncheckStyle = usCross then + begin + Font.Name := 'Wingdings'; + Font.Color := FCheckColor; + Font.Style := []; + Font.Height := - (Bottom - Top); + Font.CharSet := SYMBOL_CHARSET; + s := #251; + SetBkMode(Handle, Transparent); + ExtTextOut(Handle, Left + (Right - Left - TextWidth(s)) div 2, + Top, ETO_CLIPPED, @ARect, PChar(s), 1, nil); + end + else if FUncheckStyle = usLineCross then + begin + Pen.Style := psSolid; + Pen.Color := FCheckColor; + DrawLine(Left, Top, Right, Bottom, FFrameWidth); + DrawLine(Left, Bottom, Right, Top, FFrameWidth); + end + else if FUncheckStyle = usMinus then + begin + Pen.Style := psSolid; + Pen.Color := FCheckColor; + DrawLine(Left + 3, Top + (Bottom - Top) div 2, Right - 2, Top + (Bottom - Top) div 2, FFrameWidth); + end + end; +end; + +procedure TfrxCheckBoxView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +begin + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + + DrawBackground; + DrawCheck(Rect(FX, FY, FX1, FY1)); + DrawFrame; +end; + +procedure TfrxCheckBoxView.GetData; +var + v: Variant; +begin + inherited; + if IsDataField then + begin + v := DataSet.Value[DataField]; + if v = Null then + v := False; + FChecked := v; + end + else if FExpression <> '' then + FChecked := Report.Calc(FExpression); +end; + + +initialization + frxObjects.RegisterObject1(TfrxCheckBoxView, nil, '', '', 0, 24); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxChBoxRTTI.pas b/official/4.2/LibD11/frxChBoxRTTI.pas new file mode 100644 index 0000000..d9783b5 --- /dev/null +++ b/official/4.2/LibD11/frxChBoxRTTI.pas @@ -0,0 +1,56 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ CheckBox RTTI } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxChBoxRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, frxChBox, frxClassRTTI +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnum('TfrxCheckStyle', 'csCross, csCheck, csLineCross, csPlus'); + AddEnum('TfrxUncheckStyle', 'usEmpty, usCross, usLineCross, usMinus'); + AddClass(TfrxCheckBoxView, 'TfrxView'); + end; +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxChart.pas b/official/4.2/LibD11/frxChart.pas new file mode 100644 index 0000000..e91dedf --- /dev/null +++ b/official/4.2/LibD11/frxChart.pas @@ -0,0 +1,1242 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ TeeChart Add-In Object } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxChart; + +interface + +{$I frx.inc} +{$I tee.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Menus, Controls, +{$IFDEF FR_COM} + FastReport_TLB, ComObj, +{$ENDIF} + frxClass, + TeeProcs, TeEngine, Chart, Series, TeCanvas +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxChartObject = class(TComponent); // fake component + + TfrxSeriesDataType = (dtDBData, dtBandData, dtFixedData); + TfrxSeriesSortOrder = (soNone, soAscending, soDescending); + TfrxSeriesXType = (xtText, xtNumber, xtDate); + TSeriesClass = class of TChartSeries; + TfrxChartSeries = (csLine, csArea, csPoint, csBar, csHorizBar, + csPie, csGantt, csFastLine, csArrow, csBubble, csChartShape, csHorizArea, + csHorizLine, csPolar, csRadar, csPolarBar, csGauge, csSmith, csPyramid, + csDonut, csBezier, csCandle, csVolume, csPointFigure, csHistogram, + csHorizHistogram, csErrorBar, csError, csHighLow, csFunnel, csBox, + csHorizBox, csSurface, csContour, csWaterFall, csColorGrid, csVector3D, + csTower, csTriSurface, csPoint3D, csBubble3D, csMyPoint, csBarJoin, csBar3D); + + +{$IFDEF FR_COM} + TfrxSeriesItem = class(TCollectionItem, IfrxSeriesItem, IUnknown ) + private + FRefCount: Integer; + FSeries: TChartSeries; +{$ELSE} + TfrxSeriesItem = class(TCollectionItem) + private +{$ENDIF} + FDataBand: TfrxDataBand; + FDataSet: TfrxDataSet; + FDataSetName: String; + FDataType: TfrxSeriesDataType; + FSortOrder: TfrxSeriesSortOrder; + FTopN: Integer; + FTopNCaption: String; + FSource1: String; + FSource2: String; + FSource3: String; + FSource4: String; + FSource5: String; + FSource6: String; + FXType: TfrxSeriesXType; + FValues1: String; + FValues2: String; + FValues3: String; + FValues4: String; + FValues5: String; + FValues6: String; + procedure FillSeries(Series: TChartSeries); + procedure SetDataSet(const Value: TfrxDataSet); + procedure SetDataSetName(const Value: String); + function GetDataSetName: String; +{$IFDEF FR_COM} + { IUnknown } + function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; + function _AddRef: Integer; stdcall; + function _Release: Integer; stdcall; + { IfrxSeriesItem } + function Get_DataBand(out Value: IfrxDataBand): HResult; stdcall; + function Set_DataBand(const Value: IfrxDataBand): HResult; stdcall; + function Get_DataSet(out Value: IfrxDataSet): HResult; stdcall; + function Set_DataSet(const Value: IfrxDataSet): HResult; stdcall; + function Get_DataSetName(out Value: WideString): HResult; stdcall; + function Set_DataSetName(const Value: WideString): HResult; stdcall; + function Get_XSource(out Value: WideString): HResult; stdcall; + function Set_XSource(const Value: WideString): HResult; stdcall; + function Get_YSource(out Value: WideString): HResult; stdcall; + function Set_YSource(const Value: WideString): HResult; stdcall; + function Get_XValues(out Value: WideString): HResult; stdcall; + function Set_XValues(const Value: WideString): HResult; stdcall; + function Get_YValues(out Value: WideString): HResult; stdcall; + function Set_YValues(const Value: WideString): HResult; stdcall; + function Get_TopNCaption(out Value: WideString): HResult; stdcall; + function Set_TopNCaption(const Value: WideString): HResult; stdcall; + function Get_Title(out Value: WideString): HResult; stdcall; + function Set_Title(const Value: WideString): HResult; stdcall; + function Get_ZSource(out Value: WideString): HResult; stdcall; + function Set_ZSource(const Value: WideString): HResult; stdcall; + function Get_ZValues(out Value: WideString): HResult; stdcall; + function Set_ZValues(const Value: WideString): HResult; stdcall; + function Get_FourthSource(out Value: WideString): HResult; stdcall; + function Set_FourthSource(const Value: WideString): HResult; stdcall; + function Get_FourthValues(out Value: WideString): HResult; stdcall; + function Set_FourthValues(const Value: WideString): HResult; stdcall; + function Get_FifthSource(out Value: WideString): HResult; stdcall; + function Set_FifthSource(const Value: WideString): HResult; stdcall; + function Get_FifthValues(out Value: WideString): HResult; stdcall; + function Set_FifthValues(const Value: WideString): HResult; stdcall; + function Get_SixthSource(out Value: WideString): HResult; stdcall; + function Set_SixthSource(const Value: WideString): HResult; stdcall; + function Get_SixthValues(out Value: WideString): HResult; stdcall; + function Set_SixthValues(const Value: WideString): HResult; stdcall; + function Get_XAxisType(out Value: frxSeriesXType): HResult; stdcall; + function Set_XAxisType(Value: frxSeriesXType): HResult; stdcall; +{$ENDIF} + published + property DataType: TfrxSeriesDataType read FDataType write FDataType; + property DataBand: TfrxDataBand read FDataBand write FDataBand; + property DataSet: TfrxDataSet read FDataSet write SetDataSet; + property DataSetName: String read GetDataSetName write SetDataSetName; + property SortOrder: TfrxSeriesSortOrder read FSortOrder write FSortOrder; + property TopN: Integer read FTopN write FTopN; + property TopNCaption: String read FTopNCaption write FTopNCaption; + property XType: TfrxSeriesXType read FXType write FXType; + + { source expressions } + property Source1: String read FSource1 write FSource1; + property Source2: String read FSource2 write FSource2; + property Source3: String read FSource3 write FSource3; + property Source4: String read FSource4 write FSource4; + property Source5: String read FSource5 write FSource5; + property Source6: String read FSource6 write FSource6; + + { ready values. For internal use only. } + property Values1: String read FValues1 write FValues1; + property Values2: String read FValues2 write FValues2; + property Values3: String read FValues3 write FValues3; + property Values4: String read FValues4 write FValues4; + property Values5: String read FValues5 write FValues5; + property Values6: String read FValues6 write FValues6; + + { backward compatibility } + property XSource: String read FSource1 write FSource1; + property YSource: String read FSource2 write FSource2; + property XValues: String read FValues1 write FValues1; + property YValues: String read FValues2 write FValues2; + {} +{$IFDEF FR_COM} + property Series: TChartSeries read FSeries write FSeries; +{$ENDIF} + end; + + TfrxSeriesData = class(TCollection) + private + FReport: TfrxReport; + function GetSeries(Index: Integer): TfrxSeriesItem; + public + constructor Create(Report: TfrxReport); + function Add: TfrxSeriesItem; + property Items[Index: Integer]: TfrxSeriesItem read GetSeries; default; + end; + +{$IFDEF FR_COM} + TfrxChartAxis = class(TAutoObject, IfrxChartAxis) + FAxis: TChartAxis; + private + function Get_Automatic(out Value: WordBool): HResult; stdcall; + function Set_Automatic(Value: WordBool): HResult; stdcall; + function Get_Minimum(out Value: Double): HResult; stdcall; + function Set_Minimum(Value: Double): HResult; stdcall; + function Get_Maximum(out Value: Double): HResult; stdcall; + function Set_Maximum(Value: Double): HResult; stdcall; + function Get_AutomaticMaximum(out Value: WordBool): HResult; stdcall; + function Set_AutomaticMaximum(Value: WordBool): HResult; stdcall; + function Get_AutomaticMinimum(out Value: WordBool): HResult; stdcall; + function Set_AutomaticMinimum(Value: WordBool): HResult; stdcall; + function Get_AxisValuesFormat(out Value: WideString): HResult; stdcall; + function Set_AxisValuesFormat(const Value: WideString): HResult; stdcall; + function Get_EndPosition(out Value: Double): HResult; stdcall; + function Set_EndPosition(Value: Double): HResult; stdcall; + function Get_Width(out Value: Integer): HResult; stdcall; + function Set_Width(Value: Integer): HResult; stdcall; + function Get_Color(out Value: Integer): HResult; stdcall; + function Set_Color(Value: Integer): HResult; stdcall; + function Get_Labels(out Value: WordBool): HResult; stdcall; + function Set_Labels(Value: WordBool): HResult; stdcall; + function Get_LabelsExponent(out Value: WordBool): HResult; stdcall; + function Set_LabelsExponent(Value: WordBool): HResult; stdcall; + function Get_LabelsSeparation(out Value: Integer): HResult; stdcall; + function Set_LabelsSeparation(Value: Integer): HResult; stdcall; + function Get_LabelStyle(out Value: Integer): HResult; stdcall; + function Set_LabelStyle(Value: Integer): HResult; stdcall; + function Get_Logarithmic(out Value: WordBool): HResult; stdcall; + function Set_Logarithmic(Value: WordBool): HResult; stdcall; + public + constructor Create(Axis: TChartAxis); + end; + + TfrxChartView = class(TfrxView, IfrxChartView) + private + FLeftAxis: TfrxChartAxis; + FBottomAxis: TfrxChartAxis; +{$ELSE} + TfrxChartView = class(TfrxView) +{$ENDIF} + private + FChart: TChart; + FSeriesData: TfrxSeriesData; + procedure CreateChart; + procedure FillChart; + procedure ReadData(Stream: TStream); + procedure ReadData1(Reader: TReader); + procedure ReadData2(Reader: TReader); + procedure WriteData(Stream: TStream); + procedure WriteData1(Writer: TWriter); + procedure WriteData2(Writer: TWriter); + protected + procedure DefineProperties(Filer: TFiler); override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + {$IFDEF FR_COM} + function GetSeriesItem(Index: Integer; out Value: IfrxSeriesItem): HResult; stdcall; + function AddSeriesItem(Type_: frxSeriesType; out NewItem: IfrxSeriesItem): HResult; stdcall; + function SeriesCount(out Value: Integer): HResult; stdcall; + function Get_View3D(out Value: WordBool): HResult; stdcall; + function Set_View3D(Value: WordBool): HResult; stdcall; + function Get_View3dWalls(out Value: WordBool): HResult; stdcall; + function Set_View3dWalls(Value: WordBool): HResult; stdcall; + function Get_LeftAxis(out Value: IfrxChartAxis): HResult; stdcall; + function Get_BottomAxis(out Value: IfrxChartAxis): HResult; stdcall; + {$ENDIF} + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure AfterPrint; override; + procedure GetData; override; + procedure BeforeStartReport; override; + procedure OnNotify(Sender: TObject); override; + procedure ClearSeries; + procedure AddSeries(Series: TfrxChartSeries); + + property Chart: TChart read FChart; + property SeriesData: TfrxSeriesData read FSeriesData; + published + property BrushStyle; + property Color; + property Cursor; + property Frame; + property TagStr; + property URL; + end; + + +implementation + +uses + frxChartHelpers, frxChartRTTI, +{$IFNDEF NO_EDITORS} + frxChartEditor, +{$ENDIF} + frxDsgnIntf, frxUtils, frxRes; + + +{ TfrxSeriesItem } + +procedure TfrxSeriesItem.SetDataSet(const Value: TfrxDataSet); +begin + FDataSet := Value; + if FDataSet = nil then + FDataSetName := '' else + FDataSetName := FDataSet.UserName; +end; + +procedure TfrxSeriesItem.SetDataSetName(const Value: String); +begin + FDataSetName := Value; + FDataSet := frxFindDataSet(FDataSet, FDataSetName, + TfrxSeriesData(Collection).FReport); +end; + +function TfrxSeriesItem.GetDataSetName: String; +begin + if FDataSet = nil then + Result := FDataSetName else + Result := FDataSet.UserName; +end; + +procedure TfrxSeriesItem.FillSeries(Series: TChartSeries); +var + i: Integer; + sl1, sl2, sl3, sl4, sl5, sl6: TStringList; + v1, v2, v3, v4, v5, v6: String; + Helper: TfrxSeriesHelper; + + procedure Sort; + var + i: Integer; + sl: TStringList; + s: String; + begin + if sl1.Count <> sl2.Count then exit; + + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupAccept; + + for i := 0 to sl2.Count - 1 do + begin + s := sl2[i]; + if not frxIsValidFloat(s) then + s := '0'; + sl.Add(Format('%18.2f', [frxStrToFloat(s)]) + '=' + sl1[i]); + end; + + sl1.Clear; + sl2.Clear; + if FSortOrder = soAscending then + for i := 0 to sl.Count - 1 do + begin + sl1.Add(Trim(Copy(sl[i], Pos('=', sl[i]) + 1, 255))); + sl2.Add(Trim(Copy(sl[i], 1, Pos('=', sl[i]) - 1))); + end + else + for i := sl.Count - 1 downto 0 do + begin + sl1.Add(Trim(Copy(sl[i], Pos('=', sl[i]) + 1, 255))); + sl2.Add(Trim(Copy(sl[i], 1, Pos('=', sl[i]) - 1))); + end; + + sl.Free; + end; + + procedure MakeTopN; + var + i: Integer; + d: Double; + sl: TStringList; + s: String; + begin + if sl1.Count <> sl2.Count then exit; + + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupAccept; + + for i := 0 to sl2.Count - 1 do + begin + s := sl2[i]; + if not frxIsValidFloat(s) then + s := '0'; + sl.Add(Format('%18.2f', [frxStrToFloat(s)]) + '=' + sl1[i]); + end; + + sl1.Clear; + sl2.Clear; + for i := sl.Count - 1 downto sl.Count - FTopN do + begin + sl1.Add(Trim(Copy(sl[i], Pos('=', sl[i]) + 1, 255))); + sl2.Add(Trim(Copy(sl[i], 1, Pos('=', sl[i]) - 1))); + end; + + d := 0; + for i := sl.Count - FTopN - 1 downto 0 do + d := d + frxStrToFloat(Trim(Copy(sl[i], 1, Pos('=', sl[i]) - 1))); + + sl1.Add(FTopNCaption); + sl2.Add(FloatToStr(d)); + + sl.Free; + end; + +begin + sl1 := TStringList.Create; + sl2 := TStringList.Create; + sl3 := TStringList.Create; + sl4 := TStringList.Create; + sl5 := TStringList.Create; + sl6 := TStringList.Create; + Series.Clear; + + v1 := FValues1; + if (v1 <> '') and (v1[1] = ';') then + Delete(v1, 1, 1); + v2 := FValues2; + if (v2 <> '') and (v2[1] = ';') then + Delete(v2, 1, 1); + v3 := FValues3; + if (v3 <> '') and (v3[1] = ';') then + Delete(v3, 1, 1); + v4 := FValues4; + if (v4 <> '') and (v4[1] = ';') then + Delete(v4, 1, 1); + v5 := FValues5; + if (v5 <> '') and (v5[1] = ';') then + Delete(v5, 1, 1); + v6 := FValues6; + if (v6 <> '') and (v6[1] = ';') then + Delete(v6, 1, 1); + + frxSetCommaText(v1, sl1); + frxSetCommaText(v2, sl2); + frxSetCommaText(v3, sl3); + frxSetCommaText(v4, sl4); + frxSetCommaText(v5, sl5); + frxSetCommaText(v6, sl6); + + Helper := frxFindSeriesHelper(Series); + + try + if sl2.Count > 0 then + begin + if (FTopN > 0) and (FTopN < sl2.Count) then + MakeTopN + else if FSortOrder <> soNone then + Sort; + + for i := 0 to sl2.Count - 1 do + begin + if i < sl1.Count then v1 := sl1[i] else v1 := ''; + if i < sl2.Count then v2 := sl2[i] else v2 := ''; + if i < sl3.Count then v3 := sl3[i] else v3 := ''; + if i < sl4.Count then v4 := sl4[i] else v4 := ''; + if i < sl5.Count then v5 := sl5[i] else v5 := ''; + if i < sl6.Count then v6 := sl6[i] else v6 := ''; + Helper.AddValues(Series, v1, v2, v3, v4, v5, v6, FXType); + end; + end; + + finally + Helper.Free; + sl1.Free; + sl2.Free; + sl3.Free; + sl4.Free; + sl5.Free; + sl6.Free; + end; +end; + +{$IFDEF FR_COM} +function TfrxSeriesItem.QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; +begin + if GetInterface(IID, Obj) then + Result := S_OK + else + Result := E_NOINTERFACE; +end; + +function TfrxSeriesItem._AddRef: Integer; stdcall; +begin + Result := InterlockedIncrement(FRefCount); +end; + +function TfrxSeriesItem._Release: Integer; stdcall; +begin + Result := InterlockedDecrement(FRefCount); + if Result = 0 then Destroy; +end; + +function TfrxSeriesItem.Get_DataBand(out Value: IfrxDataBand): HResult; stdcall; +begin + Value := DataBand; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_DataBand(const Value: IfrxDataBand): HResult; stdcall; +var + idsp: {IfrxComponentSelf}IInterfaceComponentReference; +begin + Result := Value.QueryInterface({IfrxComponentSelf}IInterfaceComponentReference, idsp); + if Result = S_OK then + begin + DataBand := TfrxDataBand(idsp.{Get_Object} GetComponent); + idsp._Release; + end; +end; + +function TfrxSeriesItem.Get_DataSet(out Value: IfrxDataSet): HResult; stdcall; +begin + Value := DataSet; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_DataSet(const Value: IfrxDataSet): HResult; stdcall; +var + idsp: {IfrxComponentSelf} IInterfaceComponentReference; +begin + Result := Value.QueryInterface({IfrxComponentSelf}IInterfaceComponentReference, idsp); + if Result = S_OK then + begin + DataSet := TfrxDataSet(idsp.GetComponent{Get_Object}); + end; +end; + +function TfrxSeriesItem.Get_DataSetName(out Value: WideString): HResult; stdcall; +begin + Value := DataSetName; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_DataSetName(const Value: WideString): HResult; stdcall; +begin + DataSetName := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_XSource(out Value: WideString): HResult; stdcall; +begin + Value := XSource; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_XSource(const Value: WideString): HResult; stdcall; +begin + XSource := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_YSource(out Value: WideString): HResult; stdcall; +begin + Value := YSource; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_YSource(const Value: WideString): HResult; stdcall; +begin + YSource := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_XValues(out Value: WideString): HResult; stdcall; +begin + Value := XValues; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_XValues(const Value: WideString): HResult; stdcall; +begin + XValues := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_YValues(out Value: WideString): HResult; stdcall; +begin + Value := YValues; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_YValues(const Value: WideString): HResult; stdcall; +begin + YValues := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_TopNCaption(out Value: WideString): HResult; stdcall; +begin + Value := TopNCaption; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_TopNCaption(const Value: WideString): HResult; stdcall; +begin + TopNCaption := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_Title(out Value: WideString): HResult; stdcall; +begin + Value := Series.Title; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_Title(const Value: WideString): HResult; stdcall; +begin + Series.Title := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_ZSource(out Value: WideString): HResult; stdcall; +begin + Value := Source3; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_ZSource(const Value: WideString): HResult; stdcall; +begin + Source3 := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_ZValues(out Value: WideString): HResult; stdcall; +begin + Value := Values3; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_ZValues(const Value: WideString): HResult; stdcall; +begin + Values3 := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_FourthSource(out Value: WideString): HResult; stdcall; +begin + Value := Source4; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_FourthSource(const Value: WideString): HResult; stdcall; +begin + Source4 := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_FourthValues(out Value: WideString): HResult; stdcall; +begin + Value := Values4; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_FourthValues(const Value: WideString): HResult; stdcall; +begin + Values4 := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_FifthSource(out Value: WideString): HResult; stdcall; +begin + Value := Source5; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_FifthSource(const Value: WideString): HResult; stdcall; +begin + Source5 := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_FifthValues(out Value: WideString): HResult; stdcall; +begin + Value := Values5; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_FifthValues(const Value: WideString): HResult; stdcall; +begin + Values5 := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_SixthSource(out Value: WideString): HResult; stdcall; +begin + Value := Source6; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_SixthSource(const Value: WideString): HResult; stdcall; +begin + Source6 := Value; + Result := S_OK; +end; + +function TfrxSeriesItem.Get_SixthValues(out Value: WideString): HResult; stdcall; +begin + Value := Values6; + Result := S_OK; +end; + +function TfrxSeriesItem.Set_SixthValues(const Value: WideString): HResult; stdcall; +begin + Values6 := Value; + Result := S_OK; +end; +function TfrxSeriesItem.Get_XAxisType(out Value: frxSeriesXType): HResult; stdcall; +begin + Value := frxSeriesXType(XType); + Result := S_OK; +end; + +function TfrxSeriesItem.Set_XAxisType(Value: frxSeriesXType): HResult; stdcall; +begin + XType := TfrxSeriesXType(Value); + Result := S_OK; +end; +{$ENDIF} + +{ TfrxSeriesData } + +constructor TfrxSeriesData.Create(Report: TfrxReport); +begin + inherited Create(TfrxSeriesItem); + FReport := Report; +end; + +function TfrxSeriesData.Add: TfrxSeriesItem; +begin + Result := TfrxSeriesItem(inherited Add); +end; + +function TfrxSeriesData.GetSeries(Index: Integer): TfrxSeriesItem; +begin + Result := TfrxSeriesItem(inherited Items[Index]); +end; + + +{ TfrxChartView } + +constructor TfrxChartView.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + CreateChart; + FSeriesData := TfrxSeriesData.Create(Report); +{$IFDEF FR_COM} + FLeftAxis := TfrxChartAxis.Create(Chart.LeftAxis); + FBottomAxis := TfrxChartAxis.Create(Chart.BottomAxis); +{$ENDIF} +end; + +destructor TfrxChartView.Destroy; +begin +{$IFDEF FR_COM} + FLeftAxis.Destroy; + FBottomAxis.Destroy; +{$ENDIF} + FChart.Free; + inherited Destroy; + FSeriesData.Free; +end; + +class function TfrxChartView.GetDescription: String; +begin + Result := frxResources.Get('obChart'); +end; + +procedure TfrxChartView.Notification(AComponent: TComponent; Operation: TOperation); +var + i: Integer; +begin + inherited; + if Operation = opRemove then + begin + for i := 0 to FSeriesData.Count - 1 do + if AComponent is TfrxDataSet then + begin + if FSeriesData[i].DataSet = AComponent then + FSeriesData[i].DataSet := nil; + end + else if AComponent is TfrxBand then + begin + if FSeriesData[i].DataBand = AComponent then + FSeriesData[i].DataBand := nil; + end; + end; +end; + +procedure TfrxChartView.CreateChart; +begin + FChart := TChart.Create(Self); + with FChart do + begin + Color := clWhite; + BevelInner := bvNone; + BevelOuter := bvNone; + Name := 'Chart'; + Frame.Visible := False; + View3DOptions.Rotation := 0; + Title.Text.Text := ''; + end; +end; + +procedure TfrxChartView.DefineProperties(Filer: TFiler); +begin + inherited; + Filer.DefineBinaryProperty('Chart', ReadData, WriteData, True); + Filer.DefineProperty('ChartElevation', ReadData1, WriteData1, True); + Filer.DefineProperty('SeriesData', ReadData2, WriteData2, True); +end; + +procedure TfrxChartView.ReadData(Stream: TStream); +begin + FChart.Free; + CreateChart; + Stream.ReadComponent(FChart); +end; + +procedure TfrxChartView.WriteData(Stream: TStream); +begin + Stream.WriteComponent(FChart); +end; + +procedure TfrxChartView.ReadData1(Reader: TReader); +begin + FChart.View3DOptions.Elevation := Reader.ReadInteger; +end; + +procedure TfrxChartView.WriteData1(Writer: TWriter); +begin + Writer.WriteInteger(FChart.View3DOptions.Elevation); +end; + +procedure TfrxChartView.ReadData2(Reader: TReader); +begin + frxReadCollection(FSeriesData, Reader, Self); +end; + +procedure TfrxChartView.WriteData2(Writer: TWriter); +begin + frxWriteCollection(FSeriesData, Writer, Self); +end; + +procedure TfrxChartView.FillChart; +var + i: Integer; +begin + for i := 0 to FSeriesData.Count - 1 do + FSeriesData[i].FillSeries(FChart.Series[i]); +end; + +procedure TfrxChartView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +var + EMF: TMetafile; +begin + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + DrawBackground; + + FillChart; + + if Color = clTransparent then + FChart.Color := clWhite else + FChart.Color := Color; + FChart.BufferedDisplay := True; + EMF := FChart.TeeCreateMetafile(False, Rect(0, 0, Round(Width), Round(Height))); + Canvas.StretchDraw(Rect(FX, FY, FX1, FY1), EMF); + EMF.Free; + + DrawFrame; +end; + +procedure TfrxChartView.AfterPrint; +var + i: Integer; +begin + for i := 0 to FSeriesData.Count - 1 do + with FSeriesData[i] do + begin + Values1 := ''; + Values2 := ''; + Values3 := ''; + Values4 := ''; + Values5 := ''; + Values6 := ''; + end; +end; + +procedure TfrxChartView.GetData; +var + i: Integer; +begin + inherited; + for i := 0 to FSeriesData.Count - 1 do + with FSeriesData[i] do + if (DataType = dtDBData) and (DataSet <> nil) then + begin + Values1 := ''; + Values2 := ''; + Values3 := ''; + Values4 := ''; + Values5 := ''; + Values6 := ''; + + DataSet.First; + while not DataSet.Eof do + begin + if Source1 <> '' then + Values1 := Values1 + ';' + VarToStr(Report.Calc(Source1)); + if Source2 <> '' then + Values2 := Values2 + ';' + VarToStr(Report.Calc(Source2)); + if Source3 <> '' then + Values3 := Values3 + ';' + VarToStr(Report.Calc(Source3)); + if Source4 <> '' then + Values4 := Values4 + ';' + VarToStr(Report.Calc(Source4)); + if Source5 <> '' then + Values5 := Values5 + ';' + VarToStr(Report.Calc(Source5)); + if Source6 <> '' then + Values6 := Values6 + ';' + VarToStr(Report.Calc(Source6)); + DataSet.Next; + end; + end + else if DataType = dtFixedData then + begin + Values1 := Source1; + Values2 := Source2; + Values3 := Source3; + Values4 := Source4; + Values5 := Source5; + Values6 := Source5; + end +end; + +procedure TfrxChartView.BeforeStartReport; +var + i: Integer; +begin + for i := 0 to FSeriesData.Count - 1 do + with FSeriesData[i] do + begin + Values1 := ''; + Values2 := ''; + Values3 := ''; + Values4 := ''; + Values5 := ''; + Values6 := ''; + end; + Report.Engine.NotifyList.Add(Self); +end; + +procedure TfrxChartView.OnNotify(Sender: TObject); +var + i: Integer; +begin + inherited; + for i := 0 to FSeriesData.Count - 1 do + with FSeriesData[i] do + if (DataType = dtBandData) and (DataBand = Sender) then + begin + Report.CurObject := Self.Name; + if Source1 <> '' then + Values1 := Values1 + ';' + VarToStr(Report.Calc(Source1)); + if Source2 <> '' then + Values2 := Values2 + ';' + VarToStr(Report.Calc(Source2)); + if Source3 <> '' then + Values3 := Values3 + ';' + VarToStr(Report.Calc(Source3)); + if Source4 <> '' then + Values4 := Values4 + ';' + VarToStr(Report.Calc(Source4)); + if Source5 <> '' then + Values5 := Values5 + ';' + VarToStr(Report.Calc(Source5)); + if Source6 <> '' then + Values6 := Values6 + ';' + VarToStr(Report.Calc(Source6)); + end; +end; + +procedure TfrxChartView.AddSeries(Series: TfrxChartSeries); +var + sc: TSeriesClass; + s: TChartSeries; + b: Boolean; +{$IFDEF FR_COM} + item: TfrxSeriesItem; +{$ENDIF} +begin + sc := frxChartSeries[Integer(Series)]; + s := TChartSeries(sc.NewInstance); + s.Create(Chart); + Chart.AddSeries(s); +{$IFNDEF FR_COM} + SeriesData.Add; +{$ELSE} + item := SeriesData.Add; + item.Series := s; +{$ENDIF} + + with Chart do + begin + b := not (s is TPieSeries); + View3DOptions.Orthogonal := b; + AxisVisible := b; + View3DWalls := b; + end; +end; + +procedure TfrxChartView.ClearSeries; +begin + FChart.Free; + CreateChart; + SeriesData.Clear; +end; + +{$IFDEF FR_COM} +function TfrxChartView.GetSeriesItem(Index: Integer; out Value: IfrxSeriesItem): HResult; stdcall; +begin + Value := SeriesData.Items[Index] as IfrxSeriesItem; + Value._AddRef(); + Result := S_OK; +end; + +function TfrxChartView.AddSeriesItem(Type_: frxSeriesType; out NewItem: IfrxSeriesItem): HResult; stdcall; +begin + AddSeries( TfrxChartSeries(Type_) ); + Result := GetSeriesItem(SeriesData.Count-1, NewItem); +end; + +function TfrxChartView.SeriesCount(out Value: Integer): HResult; stdcall; +begin + Value := SeriesData.Count; + Result := S_OK; +end; + +function TfrxChartView.Get_View3D(out Value: WordBool): HResult; stdcall; +begin + Value := Chart.View3D; + Result := S_OK; +end; + +function TfrxChartView.Set_View3D(Value: WordBool): HResult; stdcall; +begin + Chart.View3D := Value; + Result := S_OK; +end; + +function TfrxChartView.Get_View3dWalls(out Value: WordBool): HResult; stdcall; +begin + Value := Chart.View3DWalls; + Result := S_OK; +end; + +function TfrxChartView.Set_View3dWalls(Value: WordBool): HResult; stdcall; +begin + Chart.View3dWalls := Value; + Result := S_OK; +end; + +function TfrxChartView.Get_LeftAxis(out Value: IfrxChartAxis): HResult; stdcall; +begin + Value := FLeftAxis; + FLeftAxis._AddRef; + Result := S_OK; +end; + +function TfrxChartView.Get_BottomAxis(out Value: IfrxChartAxis): HResult; stdcall; +begin + Value := FBottomAxis; + FBottomAxis._AddRef; + Result := S_OK; +end; + +{$ENDIF} + +{$IFDEF FR_COM} +{ TfrxChartAxis } + +constructor TfrxChartAxis.Create(Axis: TChartAxis); +begin + FAxis := Axis; +end; + +function TfrxChartAxis.Get_Automatic(out Value: WordBool): HResult; stdcall; +begin + Value := FAxis.Automatic; + Result := S_OK; +end; + +function TfrxChartAxis.Set_Automatic(Value: WordBool): HResult; stdcall; +begin + FAxis.Automatic := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_Minimum(out Value: Double): HResult; stdcall; +begin + Value := FAxis.Minimum; + Result := S_OK; +end; + +function TfrxChartAxis.Set_Minimum(Value: Double): HResult; stdcall; +begin + FAxis.Minimum := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_Maximum(out Value: Double): HResult; stdcall; +begin + Value := FAxis.Maximum; + Result := S_OK; +end; + +function TfrxChartAxis.Set_Maximum(Value: Double): HResult; stdcall; +begin + FAxis.Maximum := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_AutomaticMaximum(out Value: WordBool): HResult; stdcall; +begin + Value := FAxis.AutomaticMaximum; + Result := S_OK; +end; + +function TfrxChartAxis.Set_AutomaticMaximum(Value: WordBool): HResult; stdcall; +begin + FAxis.AutomaticMaximum := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_AutomaticMinimum(out Value: WordBool): HResult; stdcall; +begin + Value := FAxis.AutomaticMinimum; + Result := S_OK; +end; + +function TfrxChartAxis.Set_AutomaticMinimum(Value: WordBool): HResult; stdcall; +begin + FAxis.AutomaticMinimum := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_AxisValuesFormat(out Value: WideString): HResult; stdcall; +begin + Value := FAxis.AxisValuesFormat; + Result := S_OK; +end; + +function TfrxChartAxis.Set_AxisValuesFormat(const Value: WideString): HResult; stdcall; +begin + FAxis.AxisValuesFormat := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_EndPosition(out Value: Double): HResult; stdcall; +begin + Value := FAxis.EndPosition; + Result := S_OK; +end; + +function TfrxChartAxis.Set_EndPosition(Value: Double): HResult; stdcall; +begin + FAxis.EndPosition := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_Width(out Value: Integer): HResult; stdcall; +begin + Value := FAxis.Axis.Width; + Result := S_OK; +end; + +function TfrxChartAxis.Set_Width(Value: Integer): HResult; stdcall; +begin + FAxis.Axis.Width := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_Color(out Value: Integer): HResult; stdcall; +begin + Value := FAxis.Axis.Color; + Result := S_OK; +end; + +function TfrxChartAxis.Set_Color(Value: Integer): HResult; stdcall; +begin + FAxis.Axis.Color := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_Labels(out Value: WordBool): HResult; stdcall; +begin + Value := FAxis.Labels; + Result := S_OK; +end; + +function TfrxChartAxis.Set_Labels(Value: WordBool): HResult; stdcall; +begin + FAxis.Labels := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_LabelsExponent(out Value: WordBool): HResult; stdcall; +begin + Value := FAxis.LabelsExponent; + Result := S_OK; +end; + +function TfrxChartAxis.Set_LabelsExponent(Value: WordBool): HResult; stdcall; +begin + FAxis.LabelsExponent := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_LabelsSeparation(out Value: Integer): HResult; stdcall; +begin + Value := FAxis.LabelsSeparation; + Result := S_OK; +end; + +function TfrxChartAxis.Set_LabelsSeparation(Value: Integer): HResult; stdcall; +begin + FAxis.LabelsSeparation := Value; + Result := S_OK; +end; + +function TfrxChartAxis.Get_LabelStyle(out Value: Integer): HResult; stdcall; +begin + Value := Integer(FAxis.LabelStyle); + Result := S_OK; +end; + +function TfrxChartAxis.Set_LabelStyle(Value: Integer): HResult; stdcall; +begin + FAxis.LabelStyle := TAxisLabelStyle(Value); + Result := S_OK; +end; + +function TfrxChartAxis.Get_Logarithmic(out Value: WordBool): HResult; stdcall; +begin + Value := FAxis.Logarithmic; + Result := S_OK; +end; + +function TfrxChartAxis.Set_Logarithmic(Value: WordBool): HResult; stdcall; +begin + FAxis.Logarithmic := Value; + Result := S_OK; +end; +{$ENDIF} + + +initialization +{$IFNDEF TeeChartStd} +{$IFNDEF TeeChartStd7} +{$IFNDEF TeeChart4} + RegisterTeeStandardSeries; +{$ENDIF} +{$ENDIF} +{$ENDIF} + frxObjects.RegisterObject1(TfrxChartView, nil, '', '', 0, 25); + +finalization + frxObjects.UnRegister(TfrxChartView); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxChartEditor.dfm b/official/4.2/LibD11/frxChartEditor.dfm new file mode 100644 index 0000000..6c08698 Binary files /dev/null and b/official/4.2/LibD11/frxChartEditor.dfm differ diff --git a/official/4.2/LibD11/frxChartEditor.pas b/official/4.2/LibD11/frxChartEditor.pas new file mode 100644 index 0000000..2f3ff9e --- /dev/null +++ b/official/4.2/LibD11/frxChartEditor.pas @@ -0,0 +1,675 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Chart design editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxChartEditor; + +interface + +{$I frx.inc} +{$I tee.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Menus, ExtCtrls, Buttons, frxClass, frxChart, frxCustomEditors, + frxCtrls, frxInsp, frxDock, TeeProcs, TeEngine, Chart, Series, ComCtrls, + ImgList +{$IFDEF Delphi11} +, TeeGalleryAlternate +{$ELSE} +, TeeGally +{$ENDIF} +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxChartEditor = class(TfrxViewEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxChartEditorForm = class(TForm) + OkB: TButton; + Panel1: TPanel; + ChartTree: TTreeView; + Panel2: TPanel; + ChartImages: TImageList; + TreePanel: TPanel; + AddB: TSpeedButton; + DeleteB: TSpeedButton; + CancelB: TButton; + SourcePanel: TPanel; + DataSourceGB: TGroupBox; + DBSourceRB: TRadioButton; + BandSourceRB: TRadioButton; + FixedDataRB: TRadioButton; + DatasetsCB: TComboBox; + DatabandsCB: TComboBox; + ValuesGB: TGroupBox; + Values1CB: TComboBox; + Values1L: TLabel; + Values2L: TLabel; + Values2CB: TComboBox; + Values3L: TLabel; + Values3CB: TComboBox; + Values4L: TLabel; + Values4CB: TComboBox; + OptionsGB: TGroupBox; + ShowTopLbl: TLabel; + CaptionLbl: TLabel; + SortLbl: TLabel; + XLbl: TLabel; + TopNE: TEdit; + TopNCaptionE: TEdit; + SortCB: TComboBox; + UpDown1: TUpDown; + XTypeCB: TComboBox; + InspSite: TPanel; + Values5L: TLabel; + Values5CB: TComboBox; + HintL: TLabel; + Values6L: TLabel; + Values6CB: TComboBox; + EditB: TSpeedButton; + procedure FormShow(Sender: TObject); + procedure ChartTreeClick(Sender: TObject); + procedure AddBClick(Sender: TObject); + procedure DeleteBClick(Sender: TObject); + procedure DoClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure UpDown1Click(Sender: TObject; Button: TUDBtnType); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure DatasetsCBClick(Sender: TObject); + procedure DatabandsCBClick(Sender: TObject); + procedure DBSourceRBClick(Sender: TObject); + procedure OkBClick(Sender: TObject); + procedure EditBClick(Sender: TObject); + private + { Private declarations } + FChart: TfrxChartView; + FCurSeries: TfrxSeriesItem; + FInspector: TfrxObjectInspector; + FModified: Boolean; + FReport: TfrxReport; + FUpdating: Boolean; + FValuesGBHeight: Integer; + procedure FillDropDownLists(ds: TfrxDataset); + procedure SetCurSeries(const Value: TfrxSeriesItem); + procedure SetModified(const Value: Boolean); + procedure ShowSeriesData; + procedure UpdateSeriesData; + property Modified: Boolean read FModified write SetModified; + property CurSeries: TfrxSeriesItem read FCurSeries write SetCurSeries; + public + { Public declarations } + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + property Chart: TfrxChartView read FChart write FChart; + end; + + +implementation + +uses frxDsgnIntf, frxUtils, frxRes, frxChartHelpers +{$IFDEF TeeChartPro}, TeeEdit{$IFNDEF TeeChart4}, TeeEditCha{$ENDIF} {$ENDIF}; + +{$R *.DFM} + +type + THackWinControl = class(TWinControl); + + +{ TfrxChartEditor } + +function TfrxChartEditor.HasEditor: Boolean; +begin + Result := True; +end; + +function TfrxChartEditor.Edit: Boolean; +begin + with TfrxChartEditorForm.Create(Designer) do + begin + Chart.Assign(TfrxChartView(Component)); + Result := ShowModal = mrOk; + if Result then + TfrxChartView(Component).Assign(Chart); + Free; + end; +end; + +function TfrxChartEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + i: Integer; + c: TfrxComponent; + v: TfrxChartView; +begin + Result := inherited Execute(Tag, Checked); + for i := 0 to Designer.SelectedObjects.Count - 1 do + begin + c := Designer.SelectedObjects[i]; + if (c is TfrxChartView) and not (rfDontModify in c.Restrictions) then + begin + v := TfrxChartView(c); + if Tag = 1 then + v.Chart.View3D := Checked + else if Tag = 2 then + v.Chart.AxisVisible := Checked; + Result := True; + end; + end; +end; + +procedure TfrxChartEditor.GetMenuItems; +var + v: TfrxChartView; +begin + v := TfrxChartView(Component); + AddItem(frxResources.Get('ch3D'), 1, v.Chart.View3D); + AddItem(frxResources.Get('chAxis'), 2, v.Chart.AxisVisible); + inherited; +end; + + +{ TfrxChartEditorForm } + +constructor TfrxChartEditorForm.Create(AOwner: TComponent); +var + bmp: TBitmap; +begin + inherited; + FReport := TfrxCustomDesigner(AOwner).Report; + FChart := TfrxChartView.Create(FReport); + FInspector := TfrxObjectInspector.Create(Owner); + with FInspector do + begin + SplitterPos := InspSite.Width div 2; + Box.Parent := InspSite; + Box.Align := alClient; + end; + OnMouseWheelDown := FInspector.FormMouseWheelDown; + OnMouseWheelUp := FInspector.FormMouseWheelUp; +{$IFDEF UseTabset} + ChartTree.BevelKind := bkFlat; +{$ELSE} + ChartTree.BorderStyle := bsSingle; +{$ENDIF} + + { add chart image } + bmp := TBitmap.Create; + bmp.Width := 24; + bmp.Height := 24; + frxResources.ObjectImages.Draw(bmp.Canvas, 0, 0, 25); + frxAssignImages(bmp, 24, 24, ChartImages); + bmp.Free; + FValuesGBHeight := ValuesGB.Height; +{$IFDEF TeeChartPro} + EditB.Visible := True; +{$ENDIF} +end; + +destructor TfrxChartEditorForm.Destroy; +begin + FChart.Free; + inherited; +end; + +procedure TfrxChartEditorForm.FormShow(Sender: TObject); + + procedure FillChartTree; + var + i: Integer; + n: TTreeNode; + begin + for i := 0 to FChart.Chart.SeriesCount - 1 do + begin + n := ChartTree.Items.AddChild(ChartTree.Items[0], GetGallerySeriesName(FChart.Chart.Series[i])); + + n.ImageIndex := 0; + n.SelectedIndex := 0; + n.StateIndex := 0; + end; + + ChartTree.FullExpand; + ChartTree.Selected := ChartTree.Items[0]; + end; + + procedure FillBandsList; + var + i: Integer; + c: TfrxComponent; + begin + for i := 0 to FReport.Designer.Objects.Count - 1 do + begin + c := FReport.Designer.Objects[i]; + if c is TfrxDataBand then + DatabandsCB.Items.Add(c.Name); + end; + end; + +begin + FReport.GetDatasetList(DatasetsCB.Items); + FillBandsList; + FillChartTree; + CurSeries := nil; +end; + +procedure TfrxChartEditorForm.ShowSeriesData; +var + Helper: TfrxSeriesHelper; + sl: TStrings; + NewHeight: Integer; +begin + FUpdating := True; + + if FCurSeries <> nil then + with FCurSeries do + begin + if DataType = dtDBData then + DBSourceRB.Checked := True + else if DataType = dtBandData then + BandSourceRB.Checked := True + else if DataType = dtFixedData then + FixedDataRB.Checked := True; + + Values1CB.Text := FCurSeries.Source1; + Values2CB.Text := FCurSeries.Source2; + Values3CB.Text := FCurSeries.Source3; + Values4CB.Text := FCurSeries.Source4; + Values5CB.Text := FCurSeries.Source5; + Values6CB.Text := FCurSeries.Source6; + + Helper := frxFindSeriesHelper(FChart.Chart.Series[FCurSeries.Index]); + sl := TStringList.Create; + frxSetCommaText(Helper.GetParamNames, sl); + + NewHeight := FValuesGBHeight; + Values2CB.Visible := sl.Count >= 2; + Values2L.Visible := sl.Count >= 2; + if not Values2CB.Visible then + Dec(NewHeight, Values2CB.Height + 4); + Values3CB.Visible := sl.Count >= 3; + Values3L.Visible := sl.Count >= 3; + if not Values3CB.Visible then + Dec(NewHeight, Values3CB.Height + 4); + Values4CB.Visible := sl.Count >= 4; + Values4L.Visible := sl.Count >= 4; + if not Values4CB.Visible then + Dec(NewHeight, Values4CB.Height + 4); + Values5CB.Visible := sl.Count >= 5; + Values5L.Visible := sl.Count >= 5; + if not Values5CB.Visible then + Dec(NewHeight, Values5CB.Height + 4); + Values6CB.Visible := sl.Count >= 6; + Values6L.Visible := sl.Count >= 6; + if not Values6CB.Visible then + Dec(NewHeight, Values6CB.Height + 4); + + ValuesGB.Height := NewHeight; + OptionsGB.Top := ValuesGB.Top + ValuesGB.Height + 8; + + if sl.Count > 0 then + Values1L.Caption := sl[0]; + if sl.Count > 1 then + Values2L.Caption := sl[1]; + if sl.Count > 2 then + Values3L.Caption := sl[2]; + if sl.Count > 3 then + Values4L.Caption := sl[3]; + if sl.Count > 4 then + Values5L.Caption := sl[4]; + if sl.Count > 5 then + Values6L.Caption := sl[5]; + + sl.Free; + Helper.Free; + + + if DataSet = nil then + DatasetsCB.ItemIndex := -1 + else + begin + DatasetsCB.ItemIndex := DatasetsCB.Items.IndexOf(FReport.GetAlias(DataSet)); + DatasetsCBClick(nil); + end; + + if DataBand = nil then + DatabandsCB.ItemIndex := -1 + else + begin + DatabandsCB.ItemIndex := DatabandsCB.Items.IndexOf(DataBand.Name); + DatabandsCBClick(nil); + end; + + TopNE.Text := IntToStr(TopN); + TopNCaptionE.Text := TopNCaption; + SortCB.ItemIndex := Integer(SortOrder); + XTypeCB.ItemIndex := Integer(XType); + end; + + FUpdating := False; +end; + +procedure TfrxChartEditorForm.UpdateSeriesData; +begin + if FCurSeries <> nil then + with FCurSeries do + begin + if DBSourceRB.Checked then + DataType := dtDBData + else if BandSourceRB.Checked then + DataType := dtBandData + else if FixedDataRB.Checked then + DataType := dtFixedData; + + if DatabandsCB.ItemIndex <> -1 then + DataBand := TfrxDataBand(FReport.FindObject(DatabandsCB.Items[DatabandsCB.ItemIndex])) + else + DataBand := nil; + if DatasetsCB.ItemIndex <> -1 then + DataSet := FReport.GetDataSet(DatasetsCB.Items[DatasetsCB.ItemIndex]) + else + DataSet := nil; + + Source1 := Values1CB.Text; + Source2 := Values2CB.Text; + Source3 := Values3CB.Text; + Source4 := Values4CB.Text; + Source5 := Values5CB.Text; + Source6 := Values6CB.Text; + + SortOrder := TfrxSeriesSortOrder(SortCB.ItemIndex); + TopN := StrToInt(TopNE.Text); + TopNCaption := TopNCaptionE.Text; + XType := TfrxSeriesXType(XTypeCB.ItemIndex); + end; + + Modified := False; +end; + +procedure TfrxChartEditorForm.SetCurSeries(const Value: TfrxSeriesItem); +var + InspectObj: TPersistent; +begin + if Modified then + UpdateSeriesData; + FCurSeries := Value; + + if FCurSeries = nil then + InspectObj := FChart.Chart + else + InspectObj := FChart.Chart.Series[FCurSeries.Index]; + FInspector.Inspect([InspectObj]); + SourcePanel.Visible := FCurSeries <> nil; + HintL.Visible := not SourcePanel.Visible; + DeleteB.Enabled := FCurSeries <> nil; + ShowSeriesData; +end; + +procedure TfrxChartEditorForm.SetModified(const Value: Boolean); +begin + if not FUpdating then + FModified := Value; +end; + +procedure TfrxChartEditorForm.FillDropDownLists(ds: TfrxDataset); +var + l: TStringList; + i: Integer; +begin + if ds = nil then + begin + Values1CB.Items.Clear; + Values2CB.Items.Clear; + Values3CB.Items.Clear; + Values4CB.Items.Clear; + Values5CB.Items.Clear; + Values6CB.Items.Clear; + end + else + begin + l := TStringList.Create; + try + ds.GetFieldList(l); + for i := 0 to l.Count - 1 do + l[i] := FReport.GetAlias(ds) + '."' + l[i] + '"'; + + Values1CB.Items := l; + Values2CB.Items := l; + Values3CB.Items := l; + Values4CB.Items := l; + Values5CB.Items := l; + Values6CB.Items := l; + finally + l.Free; + end; + end; +end; + +procedure TfrxChartEditorForm.ChartTreeClick(Sender: TObject); +var + i: Integer; +begin + i := ChartTree.Selected.AbsoluteIndex - 1; + if i >= 0 then + CurSeries := FChart.SeriesData[i] else + CurSeries := nil; +end; + +{$HINTS OFF} +procedure TfrxChartEditorForm.AddBClick(Sender: TObject); +var + s: TChartSeries; + n: TTreeNode; + b: Boolean; + ind: Integer; +{$IFDEF Delphi11} + TeeGalleryForm: TTeeGalleryForm; + ChartSeriesClass : TChartSeriesClass; + TeeFunctionClass : TTeeFunctionClass; +{$ENDIF} +begin + ind := 0; +{$IFDEF TeeChartStd7} + s := CreateNewSeriesGallery(nil, nil, FChart.Chart, False, False, ind); +{$ELSE} + +{$IFDEF Delphi11} + s := nil; + TeeGalleryForm := TTeeGalleryForm.Create(nil); + TeeGalleryForm.Position := poScreenCenter; + if TeeGalleryForm.ShowModal = mrOk then + if TeeGalleryForm.ChartGalleryPanel1.GetSeriesClass(ChartSeriesClass, TeeFunctionClass, ind) then + s := CreateNewSeries(nil, FChart.Chart, ChartSeriesClass, TeeFunctionClass); +{$ELSE} + s := CreateNewSeriesGallery(nil, nil, FChart.Chart, False, False{$IFNDEF TeeChart4}{$IFDEF TeeChartPro}, ind{$ENDIF}{$ENDIF}); +{$ENDIF} + +{$ENDIF} + if s = nil then + Exit; + FChart.SeriesData.Add; + + with FChart.Chart do + begin + b := not (s is TPieSeries); + View3DOptions.Orthogonal := b; + AxisVisible := b; + View3DWalls := b; + end; + + n := ChartTree.Items.AddChild(ChartTree.Items[0], GetGallerySeriesName(s)); + + n.ImageIndex := 0; + n.SelectedIndex := 0; + n.StateIndex := 0; + + ChartTree.Selected := n; + +{$IFDEF Delphi11} + TeeGalleryForm.Free; +{$ENDIF} + + ChartTreeClick(nil); +end; +{$HINTS ON} + +procedure TfrxChartEditorForm.DeleteBClick(Sender: TObject); +var + s: TChartSeries; +begin + s := FChart.Chart.Series[FCurSeries.Index]; + s.Free; + FCurSeries.Free; + ChartTree.Selected.Free; + + ChartTree.SetFocus; + ChartTree.Selected := ChartTree.Items[0]; + ChartTreeClick(nil); +end; + +procedure TfrxChartEditorForm.EditBClick(Sender: TObject); +begin +{$IFDEF TeeChartPro} + with TChartEditor.Create(nil) do + begin + Chart := FChart.Chart; +{$IFDEF TeeChart7} + if FCurSeries <> nil then + Series := FChart.Chart.Series[FCurSeries.Index]; +{$ENDIF} +{$IFNDEF TeeChart4} + HideTabs := [cetGeneral, cetTitles, cetPaging, cetSeriesData, cetMain, + cetExport, {$IFDEF TeeChart7}cetExportNative,{$ENDIF} cetTools, cetPrintPreview]; + Options := Options - [ceDataSource, ceHelp, ceClone, ceTitle, ceAdd]; +{$ENDIF} + Execute; + Free; + end; +{$ENDIF} +end; + +procedure TfrxChartEditorForm.DoClick(Sender: TObject); +begin + if not FUpdating then + Modified := True; +end; + +procedure TfrxChartEditorForm.UpDown1Click(Sender: TObject; Button: TUDBtnType); +begin + DoClick(Sender); +end; + +procedure TfrxChartEditorForm.DatasetsCBClick(Sender: TObject); +var + ds: TfrxDataSet; +begin + ds := FReport.GetDataSet(DatasetsCB.Items[DatasetsCB.ItemIndex]); + FillDropDownLists(ds); + DoClick(nil); +end; + +procedure TfrxChartEditorForm.DatabandsCBClick(Sender: TObject); +var + db: TfrxDataBand; + ds: TfrxDataSet; +begin + db := TfrxDataBand(FReport.FindObject(DatabandsCB.Items[DatabandsCB.ItemIndex])); + if db <> nil then + ds := db.DataSet + else + ds := nil; + FillDropDownLists(ds); + DoClick(nil); +end; + +procedure TfrxChartEditorForm.DBSourceRBClick(Sender: TObject); +begin + DatasetsCB.ItemIndex := -1; + DatabandsCB.ItemIndex := -1; + FillDropDownLists(nil); + DoClick(nil); +end; + +procedure TfrxChartEditorForm.OkBClick(Sender: TObject); +begin + CurSeries := nil; +end; + +procedure TfrxChartEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(4100); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + AddB.Hint := frxGet(4101); + DeleteB.Hint := frxGet(4102); + EditB.Hint := frxGet(4103); + + DatasourceGB.Caption := frxGet(4107); + DBSourceRB.Caption := frxGet(4106); + BandSourceRB.Caption := frxGet(4104); + FixedDataRB.Caption := frxGet(4105); + + ValuesGB.Caption := frxGet(4108); + HintL.Caption := frxGet(4109); + + OptionsGB.Caption := frxGet(4114); + ShowTopLbl.Caption := frxGet(4115); + CaptionLbl.Caption := frxGet(4116); + SortLbl.Caption := frxGet(4117); + XLbl.Caption := frxGet(4126); + + XTypeCB.Items.Clear; + XTypeCB.Items.Add(frxResources.Get('chxtText')); + XTypeCB.Items.Add(frxResources.Get('chxtNumber')); + XTypeCB.Items.Add(frxResources.Get('chxtDate')); + SortCB.Items.Clear; + SortCB.Items.Add(frxResources.Get('chsoNone')); + SortCB.Items.Add(frxResources.Get('chsoAscending')); + SortCB.Items.Add(frxResources.Get('chsoDescending')); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxChartEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + + +initialization + frxComponentEditors.Register(TfrxChartView, TfrxChartEditor); + frxHideProperties(TChart, 'Align;AllowPanning;AllowZoom;Anchors;AnimatedZoom;' + + 'AnimatedZoomSteps;AutoSize;BackImage;BackImageInside;BackImageMode;' + + 'BevelInner;BevelOuter;BevelWidth;BorderStyle;BorderWidth;ClipPoints;Color;' + + 'Constraints;Cursor;DragCursor;DragKind;DragMode;DockSite;Enabled;Foot;Frame;Height;' + + 'HelpContext;HelpType;HelpKeyword;Hint;Left;Locked;MarginBottom;MarginLeft;MarginRight;MarginTop;' + + 'MaxPointsPerPage;Name;Page;ParentColor;ParentShowHint;PopupMenu;PrintProportional;' + + 'ScaleLastPage;ScrollMouseButton;SeriesList;ShowHint;TabOrder;TabStop;Tag;Top;UseDockManager;' + + 'Visible;Width'); + frxHideProperties(TChartSeries, 'ColorSource;Cursor;DataSource;Name;' + + 'ParentChart;Tag;XLabelsSource'); + frxHideProperties(TfrxChartView, 'SeriesData;BrushStyle'); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxChartHelpers.pas b/official/4.2/LibD11/frxChartHelpers.pas new file mode 100644 index 0000000..7f62f08 --- /dev/null +++ b/official/4.2/LibD11/frxChartHelpers.pas @@ -0,0 +1,534 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ TeeChart series helpers } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxChartHelpers; + +interface + +{$I frx.inc} +{$I tee.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Menus, Controls, frxChart, + TeeProcs, TeEngine, Chart, Series, TeCanvas, GanttCh, TeeShape, + BubbleCh, ArrowCha +{$IFDEF TeeChartPro} +, TeePolar, +{$IFNDEF TeeChart4} + TeeSmith, TeePyramid, TeeDonut, TeeFunnel, TeeBoxPlot, TeeTriSurface,{$ENDIF} + TeeBezie, OHLChart, CandleCh, StatChar, ErrorBar, + TeeSurfa, TeePoin3, MyPoint, Bar3D +{$IFDEF TeeChart7} +, TeeGauges, TeePointFigure +{$ENDIF} +{$ENDIF} +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxSeriesHelper = class(TObject) + public + function GetParamNames: String; virtual; abstract; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); virtual; abstract; + end; + + TfrxStdSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxPieSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxGanttSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxArrowSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxBubbleSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + +{$IFDEF TeeChartPro} + TfrxPolarSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxGaugeSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxSmithSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxCandleSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxErrorSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxHiLoSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxFunnelSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxSurfaceSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxVector3DSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxBubble3DSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; + + TfrxBar3DSeriesHelper = class(TfrxSeriesHelper) + public + function GetParamNames: String; override; + procedure AddValues(Series: TChartSeries; const v1, v2, v3, v4, v5, v6: String; + XType: TfrxSeriesXType); override; + end; +{$ENDIF} + + TfrxSeriesHelperClass = class of TfrxSeriesHelper; + + +const +{$IFDEF TeeChartPro} + frxNumSeries = 44; +{$ELSE} + frxNumSeries = 11; +{$ENDIF} + frxChartSeries: array[0..frxNumSeries - 1] of TSeriesClass = + (TLineSeries, TAreaSeries, TPointSeries, + TBarSeries, THorizBarSeries, TPieSeries, + TGanttSeries, TFastLineSeries, TArrowSeries, + TBubbleSeries, TChartShape +{$IFDEF TeeChartPro} + , {$IFDEF TeeChart7}THorizAreaSeries{$ELSE}nil{$ENDIF}, {$IFNDEF TeeChart4}THorizLineSeries{$ELSE}nil{$ENDIF}, TPolarSeries, + TRadarSeries, {$IFDEF TeeChart7}TPolarBarSeries{$ELSE}nil{$ENDIF}, {$IFDEF TeeChart7}TGaugeSeries{$ELSE}nil{$ENDIF}, + {$IFNDEF TeeChart4}TSmithSeries, TPyramidSeries, TDonutSeries{$ELSE}nil, nil, nil{$ENDIF}, + TBezierSeries, TCandleSeries, TVolumeSeries, + {$IFDEF TeeChart7}TPointFigureSeries{$ELSE}nil{$ENDIF}, {$IFNDEF TeeChart4}THistogramSeries{$ELSE}nil{$ENDIF}, {$IFDEF TeeChart7}THorizHistogramSeries{$ELSE}nil{$ENDIF}, + TErrorBarSeries, TErrorSeries, {$IFNDEF TeeChart4}THighLowSeries{$ELSE}nil{$ENDIF}, + {$IFNDEF TeeChart4}TFunnelSeries, TBoxSeries, THorizBoxSeries{$ELSE}nil, nil, nil{$ENDIF}, + TSurfaceSeries, TContourSeries, {$IFNDEF TeeChart4}TWaterFallSeries, + TColorGridSeries{$ELSE}nil, nil{$ENDIF}, {$IFDEF TeeChart7}TVector3DSeries{$ELSE}nil{$ENDIF}, {$IFDEF TeeChart7}TTowerSeries{$ELSE}nil{$ENDIF}, + {$IFNDEF TeeChart4}TTriSurfaceSeries{$ELSE}nil{$ENDIF}, TPoint3DSeries, {$IFDEF TeeChart7}TBubble3DSeries{$ELSE}nil{$ENDIF}, + TMyPointSeries, {$IFNDEF TeeChart4}TBarJoinSeries{$ELSE}nil{$ENDIF}, TBar3DSeries +{$ENDIF} + ); + frxSeriesHelpers: array[0..frxNumSeries - 1] of TfrxSeriesHelperClass = + (TfrxStdSeriesHelper, TfrxStdSeriesHelper, TfrxStdSeriesHelper, + TfrxStdSeriesHelper, TfrxStdSeriesHelper, TfrxPieSeriesHelper, + TfrxGanttSeriesHelper, TfrxStdSeriesHelper, TfrxArrowSeriesHelper, + TfrxBubbleSeriesHelper, TfrxStdSeriesHelper +{$IFDEF TeeChartPro} + , TfrxStdSeriesHelper, TfrxStdSeriesHelper, TfrxPolarSeriesHelper, + TfrxPolarSeriesHelper, TfrxPolarSeriesHelper, TfrxGaugeSeriesHelper, + TfrxSmithSeriesHelper, TfrxStdSeriesHelper, TfrxPieSeriesHelper, + TfrxStdSeriesHelper, TfrxCandleSeriesHelper, TfrxStdSeriesHelper, + TfrxCandleSeriesHelper, TfrxStdSeriesHelper, TfrxStdSeriesHelper, + TfrxErrorSeriesHelper, TfrxErrorSeriesHelper, TfrxHiLoSeriesHelper, + TfrxFunnelSeriesHelper, TfrxStdSeriesHelper, TfrxStdSeriesHelper, + TfrxSurfaceSeriesHelper, TfrxSurfaceSeriesHelper, TfrxSurfaceSeriesHelper, + TfrxSurfaceSeriesHelper, TfrxVector3DSeriesHelper, TfrxSurfaceSeriesHelper, + TfrxSurfaceSeriesHelper, TfrxSurfaceSeriesHelper, TfrxBubble3DSeriesHelper, + TfrxStdSeriesHelper, TfrxStdSeriesHelper, TfrxBar3DSeriesHelper +{$ENDIF} + ); + + +function frxFindSeriesHelper(Series: TChartSeries): TfrxSeriesHelper; + + +implementation + +uses frxDsgnIntf, frxUtils, frxRes; + + +function frxFindSeriesHelper(Series: TChartSeries): TfrxSeriesHelper; +var + i: Integer; +begin + Result := nil; + for i := 0 to frxNumSeries - 1 do + if Series.ClassType = frxChartSeries[i] then + begin + Result := TfrxSeriesHelper(frxSeriesHelpers[i].NewInstance); + Result.Create; + break; + end; + + if Result = nil then + Result := TfrxStdSeriesHelper.Create; +end; + + +{ TfrxStdSeriesHelper } + +procedure TfrxStdSeriesHelper.AddValues(Series: TChartSeries; const v1, v2, + v3, v4, v5, v6: String; XType: TfrxSeriesXType); +var + d: Double; + s: String; +begin + d := 0; + if Series.YValues.DateTime then + d := StrToDateTime(v2) + else if frxIsValidFloat(v2) then + d := frxStrToFloat(v2); + if v3 <> '' then + s := v3 + else + s := v1; + case XType of + xtText: + Series.Add(d, v1, clTeeColor); + xtNumber: + Series.AddXY(frxStrToFloat(s), d, v1, clTeeColor); + xtDate: + Series.AddXY(StrToDateTime(s), d, v1, clTeeColor); + end; +end; + +function TfrxStdSeriesHelper.GetParamNames: String; +begin + Result := 'Label;Y;X (optional)'; +end; + + +{ TfrxPieSeriesHelper } + +procedure TfrxPieSeriesHelper.AddValues(Series: TChartSeries; const v1, v2, + v3, v4, v5, v6: String; XType: TfrxSeriesXType); +var + d: Double; + c: TColor; +begin + if Series.YValues.DateTime then + d := StrToDateTime(v2) + else + d := frxStrToFloat(v2); + + c := clTeeColor; + if v3 <> '' then + try + c := StringToColor(v3); + except + end; + + Series.Add(d, v1, c); +end; + +function TfrxPieSeriesHelper.GetParamNames: String; +begin + Result := 'Label;Pie;Color (optional)'; +end; + + +{ TfrxGanttSeriesHelper } + +procedure TfrxGanttSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +var + d1, d2: Double; +begin + if TGanttSeries(Series).StartValues.DateTime then + d1 := StrToDateTime(v2) + else + d1 := frxStrToFloat(v2); + if TGanttSeries(Series).EndValues.DateTime then + d2 := StrToDateTime(v3) + else + d2 := frxStrToFloat(v3); + TGanttSeries(Series).AddGantt(d1, d2, frxStrToFloat(v4), v1); + if v5 <> '' then + TGanttSeries(Series).NextTask[TGanttSeries(Series).NextTask.Count - 1] := StrToInt(v5); +end; + +function TfrxGanttSeriesHelper.GetParamNames: String; +begin + Result := 'Label;Start;End;Y;Next task'; +end; + + +{ TfrxArrowSeriesHelper } + +procedure TfrxArrowSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin + TArrowSeries(Series).AddArrow(frxStrToFloat(v2), frxStrToFloat(v3), + frxStrToFloat(v4), frxStrToFloat(v5), v1, clTeeColor); +end; + +function TfrxArrowSeriesHelper.GetParamNames: String; +begin + Result := 'Label;X0;Y0;X1;Y1'; +end; + + +{ TfrxBubbleSeriesHelper } + +procedure TfrxBubbleSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin + TBubbleSeries(Series).AddBubble(frxStrToFloat(v2), frxStrToFloat(v3), + frxStrToFloat(v4), v1, clTeeColor); +end; + +function TfrxBubbleSeriesHelper.GetParamNames: String; +begin + Result := 'Label;X;Y;Radius'; +end; + + +{$IFDEF TeeChartPro} +{ TfrxPolarSeriesHelper } + +procedure TfrxPolarSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin + Series.AddXY(frxStrToFloat(v2), frxStrToFloat(v3), v1, clTeeColor); +end; + +function TfrxPolarSeriesHelper.GetParamNames: String; +begin + Result := 'Label;Angle;Value'; +end; + +{ TfrxGaugeSeriesHelper } + +procedure TfrxGaugeSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin + Series.Clear; + Series.Add(frxStrToFloat(v2), v1, clTeeColor); +end; + +function TfrxGaugeSeriesHelper.GetParamNames: String; +begin + Result := 'Label (optional);Value'; +end; + + +{ TfrxSmithSeriesHelper } + +procedure TfrxSmithSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin +{$IFNDEF TeeChart4} + TSmithSeries(Series).AddPoint(frxStrToFloat(v2), frxStrToFloat(v3), v1); +{$ENDIF} +end; + +function TfrxSmithSeriesHelper.GetParamNames: String; +begin + Result := 'Label;Resistance;Reactance'; +end; + + +{ TfrxCandleSeriesHelper } + +procedure TfrxCandleSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin + TOHLCSeries(Series).AddOHLC(StrToDateTime(v1), + frxStrToFloat(v2), frxStrToFloat(v3), frxStrToFloat(v4), frxStrToFloat(v5)); +end; + +function TfrxCandleSeriesHelper.GetParamNames: String; +begin + Result := 'Date;Open;High;Low;Close'; +end; + + +{ TfrxErrorSeriesHelper } + +procedure TfrxErrorSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin + TCustomErrorSeries(Series).AddErrorBar(frxStrToFloat(v2), frxStrToFloat(v3), + frxStrToFloat(v4), v1); +end; + +function TfrxErrorSeriesHelper.GetParamNames: String; +begin + Result := 'Label;X;Y;Error'; +end; + + +{ TfrxHiLoSeriesHelper } + +procedure TfrxHiLoSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin +{$IFNDEF TeeChart4} + THighLowSeries(Series).AddHighLow(frxStrToFloat(v2), frxStrToFloat(v3), + frxStrToFloat(v4), v1); +{$ENDIF} +end; + +function TfrxHiLoSeriesHelper.GetParamNames: String; +begin + Result := 'Label;X;High;Low'; +end; + + +{ TfrxFunnelSeriesHelper } + +procedure TfrxFunnelSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin +{$IFNDEF TeeChart4} + TFunnelSeries(Series).AddSegment(frxStrToFloat(v2), frxStrToFloat(v3), v1, clTeeColor); +{$ENDIF} +end; + +function TfrxFunnelSeriesHelper.GetParamNames: String; +begin + Result := 'Label;Quote;Opportunity'; +end; + + +{ TfrxSurfaceSeriesHelper } + +procedure TfrxSurfaceSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin +{$IFDEF TeeChart4} + TCustom3DSeries(Series).AddXYZ(Round(frxStrToFloat(v2)), frxStrToFloat(v3), + Round(frxStrToFloat(v4)), v1, clTeeColor); +{$ELSE} + TCustom3DSeries(Series).AddXYZ(frxStrToFloat(v2), frxStrToFloat(v3), + frxStrToFloat(v4), v1, clTeeColor); +{$ENDIF} +end; + +function TfrxSurfaceSeriesHelper.GetParamNames: String; +begin + Result := 'Label;X;Y;Z'; +end; + + +{ TfrxVector3DSeriesHelper } + +procedure TfrxVector3DSeriesHelper.AddValues(Series: TChartSeries; + const v1, v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin +{$IFDEF TeeChart7} + TVector3DSeries(Series).AddVector(frxStrToFloat(v1), frxStrToFloat(v2), + frxStrToFloat(v3), frxStrToFloat(v4), frxStrToFloat(v5), frxStrToFloat(v6)); +{$ENDIF} +end; + +function TfrxVector3DSeriesHelper.GetParamNames: String; +begin + Result := 'X1;Y1;Z1;X2;Y2;Z2'; +end; + + +{ TfrxBubble3DSeriesHelper } + +procedure TfrxBubble3DSeriesHelper.AddValues(Series: TChartSeries; + const v1, v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin +{$IFDEF TeeChart7} + TBubble3DSeries(Series).AddBubble(frxStrToFloat(v2), frxStrToFloat(v3), + frxStrToFloat(v4), frxStrToFloat(v5), v1, clTeeColor); +{$ENDIF} +end; + +function TfrxBubble3DSeriesHelper.GetParamNames: String; +begin + Result := 'Label;X;Y;Z;Radius'; +end; + + +{ TfrxBar3DSeriesHelper } + +procedure TfrxBar3DSeriesHelper.AddValues(Series: TChartSeries; const v1, + v2, v3, v4, v5, v6: String; XType: TfrxSeriesXType); +begin + TBar3DSeries(Series).AddBar(frxStrToFloat(v2), frxStrToFloat(v3), + frxStrToFloat(v4), v1, clTeeColor); +end; + +function TfrxBar3DSeriesHelper.GetParamNames: String; +begin + Result := 'Label;X;Y;Offset'; +end; +{$ENDIF} + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxChartRTTI.pas b/official/4.2/LibD11/frxChartRTTI.pas new file mode 100644 index 0000000..4d4cfe0 --- /dev/null +++ b/official/4.2/LibD11/frxChartRTTI.pas @@ -0,0 +1,107 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Chart RTTI } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxChartRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, frxChart, fs_ichartrtti +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnum('TfrxSeriesDataType', 'dtDBData, dtBandData, dtFixedData'); + AddClass(TfrxSeriesItem, 'TPersistent'); + with AddClass(TfrxSeriesData, 'TPersistent') do + begin + AddMethod('function Add: TfrxSeriesItem', CallMethod); + AddDefaultProperty('Items', 'Integer', 'TfrxSeriesItem', CallMethod, True); + end; + with AddClass(TfrxChartView, 'TfrxView') do + begin + AddProperty('Chart', 'TChart', GetProp, nil); + AddIndexProperty('Series', 'Integer', 'TChartSeries', CallMethod, True); + AddProperty('SeriesData', 'TfrxSeriesData', GetProp, nil); + end; + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TfrxSeriesData then + begin + if MethodName = 'ADD' then + Result := Integer(TfrxSeriesData(Instance).Add) + else if MethodName = 'ITEMS.GET' then + Result := Integer(TfrxSeriesData(Instance).Items[Caller.Params[0]]) + end + else if ClassType = TfrxChartView then + begin + if MethodName = 'SERIES.GET' then + Result := Integer(TfrxChartView(Instance).Chart.Series[Caller.Params[0]]) + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TfrxChartView then + begin + if PropName = 'CHART' then + Result := Integer(TfrxChartView(Instance).Chart) + else if PropName = 'SERIESDATA' then + Result := Integer(TfrxChartView(Instance).SeriesData) + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxChm.pas b/official/4.2/LibD11/frxChm.pas new file mode 100644 index 0000000..d1c9ee6 --- /dev/null +++ b/official/4.2/LibD11/frxChm.pas @@ -0,0 +1,62 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Chm help viewer } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxChm; + +interface + +{$I frx.inc} + +uses Windows, Graphics; + +procedure frxDisplayHHTopic(Handle: THandle; const topic: String); + + +implementation + +const + HH_DISPLAY_TOPIC = $0000; + HH_DISPLAY_TOC = $0001; + +type + THtmlHelpA = function(hwndCaller: THandle; pszFile: PChar; + uCommand: Cardinal; dwData: Longint): THandle; stdcall; + +var + HtmlHelpA: THtmlHelpA = nil; + OCXHandle: THandle = 0; + +function HtmlHelpInstalled: Boolean; +begin + Result := (Assigned(HtmlHelpA)); +end; + +procedure frxDisplayHHTopic(Handle: THandle; const topic: String); +begin + if (Assigned(HtmlHelpA)) then + HtmlHelpA(Handle, PChar(topic), HH_DISPLAY_TOC, 0); +end; + + +initialization + HtmlHelpA := nil; + OCXHandle := LoadLibrary('HHCtrl.OCX'); + if (OCXHandle <> 0) then + HtmlHelpA := GetProcAddress(OCXHandle, 'HtmlHelpA'); + +finalization + if (OCXHandle <> 0) then + FreeLibrary(OCXHandle); +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxClass.pas b/official/4.2/LibD11/frxClass.pas new file mode 100644 index 0000000..9b26ed8 --- /dev/null +++ b/official/4.2/LibD11/frxClass.pas @@ -0,0 +1,14573 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report classes } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxClass; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs, + IniFiles, ExtCtrls, Printers, frxVariables, frxXML, frxProgress, + fs_iinterpreter, frxUnicodeUtils +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFNDEF NO_CRITICAL_SECTION} +, SyncObjs +{$ENDIF} +{$IFDEF FR_COM} +, ActiveX, AxCtrls +, VCLCom, ComObj, ComServ +, ClrStream +, frxFont +, FastReport_TLB +, DispatchablePersistent +{$IFDEF ACTIVATION} + , aspr_api +{$ENDIF} +{$ENDIF}; + +const + fr01cm: Extended = 3.77953; + fr1cm: Extended = 37.7953; + fr01in: Extended = 9.6; + fr1in: Integer = 96; + fr1CharX: Extended = 9.6; + fr1CharY: Integer = 17; + clTransparent: TColor = clNone; + crHand: Integer = 150; + crZoom: Integer = 151; + crFormat: Integer = 152; + DEF_REG_CONNECTIONS: String = '\Software\Fast Reports\Connections'; + WM_CREATEHANDLE = WM_USER + 1; + WM_DESTROYHANDLE = WM_USER + 2; + +type + TfrxReport = class; + TfrxPage = class; + TfrxReportPage = class; + TfrxDialogPage = class; + TfrxCustomEngine = class; + TfrxCustomDesigner = class; + TfrxCustomPreview = class; + TfrxCustomPreviewPages = class; + TfrxComponent = class; + TfrxReportComponent = class; + TfrxView = class; + TfrxStyleItem = class; + TfrxCustomExportFilter = class; + TfrxCustomCompressor = class; + TfrxCustomDatabase = class; + TfrxFrame = class; + + TfrxNotifyEvent = type String; + TfrxCloseQueryEvent = type String; + TfrxKeyEvent = type String; + TfrxKeyPressEvent = type String; + TfrxMouseEvent = type String; + TfrxMouseMoveEvent = type String; + TfrxPreviewClickEvent = type String; + TfrxRunDialogsEvent = type String; + + SYSINT = Integer; + + TfrxComponentStyle = set of (csContainer, csPreviewVisible, csDefaultDiff); + TfrxStretchMode = (smDontStretch, smActualHeight, smMaxHeight); + TfrxShiftMode = (smDontShift, smAlways, smWhenOverlapped); + TfrxDuplexMode = (dmNone, dmVertical, dmHorizontal, dmSimplex); + + TfrxAlign = (baNone, baLeft, baRight, baCenter, baWidth, baBottom, baClient); + + TfrxFrameStyle = (fsSolid, fsDash, fsDot, fsDashDot, fsDashDotDot, fsDouble); + + TfrxFrameType = (ftLeft, ftRight, ftTop, ftBottom); + TfrxFrameTypes = set of TfrxFrameType; + + TfrxFormatKind = (fkText, fkNumeric, fkDateTime, fkBoolean); + + TfrxHAlign = (haLeft, haRight, haCenter, haBlock); + TfrxVAlign = (vaTop, vaBottom, vaCenter); + + TfrxSilentMode = (simMessageBoxes, simSilent, simReThrow); + TfrxRestriction = (rfDontModify, rfDontSize, rfDontMove, rfDontDelete, rfDontEdit); + TfrxRestrictions = set of TfrxRestriction; + + TfrxShapeKind = (skRectangle, skRoundRectangle, skEllipse, skTriangle, + skDiamond, skDiagonal1, skDiagonal2); + + TfrxPreviewButton = (pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, + pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick, + pbNoClose, pbNoFullScreen, pbNoEmail); + TfrxPreviewButtons = set of TfrxPreviewButton; + TfrxZoomMode = (zmDefault, zmWholePage, zmPageWidth, zmManyPages); + TfrxPrintPages = (ppAll, ppOdd, ppEven); + TfrxAddPageAction = (apWriteOver, apAdd); + TfrxRangeBegin = (rbFirst, rbCurrent); + TfrxRangeEnd = (reLast, reCurrent, reCount); + TfrxFieldType = (fftNumeric, fftString, fftBoolean); + TfrxProgressType = (ptRunning, ptExporting, ptPrinting); + TfrxPrintMode = (pmDefault, pmSplit, pmJoin, pmScale); + + TfrxRect = packed record + Left, Top, Right, Bottom: Extended; + end; + + TfrxPoint = packed record + X, Y: Extended; + end; + + TfrxProgressEvent = procedure(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer) of object; + TfrxBeforePrintEvent = procedure(Sender: TfrxReportComponent) of object; + TfrxGetValueEvent = procedure(const VarName: String; var Value: Variant) of object; + TfrxUserFunctionEvent = function(const MethodName: String; + var Params: Variant): Variant of object; + TfrxManualBuildEvent = procedure(Page: TfrxPage) of object; + TfrxClickObjectEvent = procedure(Sender: TfrxView; + Button: TMouseButton; Shift: TShiftState; var Modified: Boolean) of object; + TfrxMouseOverObjectEvent = procedure(Sender: TfrxView) of object; + TfrxCheckEOFEvent = procedure(Sender: TObject; var Eof: Boolean) of object; + TfrxRunDialogEvent = procedure(Page: TfrxDialogPage) of object; + TfrxEditConnectionEvent = function(const ConnString: String): String of object; + TfrxSetConnectionEvent = procedure(const ConnString: String) of object; + TfrxBeforeConnectEvent = procedure(Sender: TfrxCustomDatabase; var Connected: Boolean) of object; + TfrxPrintPageEvent = procedure(Page: TfrxReportPage; CopyNo: Integer) of object; + TfrxLoadTemplateEvent = procedure(Report: TfrxReport; const TemplateName: String) of object; + +{ Root classes } + +{$IFDEF FR_COM} + TfrxComponent = class(TComponent, IfrxComponent ) + private + FFont: TfrxFont; +{$ELSE} + TfrxComponent = class(TComponent) + private + FFont: TFont; +{$ENDIF} + FObjects: TList; + FAllObjects: TList; + FParent: TfrxComponent; + FLeft: Extended; + FTop: Extended; + FWidth: Extended; + FHeight: Extended; + FParentFont: Boolean; + FGroupIndex: Integer; + FIsDesigning: Boolean; + FIsLoading: Boolean; + FIsPrinting: Boolean; + FIsWriting: Boolean; + FRestrictions: TfrxRestrictions; + FVisible: Boolean; + FDescription: String; + FAncestor: Boolean; + FComponentStyle: TfrxComponentStyle; + function GetAbsTop: Extended; + function GetPage: TfrxPage; + function GetReport: TfrxReport; + function IsFontStored: Boolean; + function GetAllObjects: TList; + function GetAbsLeft: Extended; + function GetIsLoading: Boolean; + function GetIsAncestor: Boolean; + protected + FAliasName: String; + FBaseName: String; + FOriginalComponent: TfrxComponent; + FOriginalRect: TfrxRect; + FOriginalBand: TfrxComponent; + procedure SetParent(AParent: TfrxComponent); virtual; + procedure SetLeft(Value: Extended); virtual; + procedure SetTop(Value: Extended); virtual; + procedure SetWidth(Value: Extended); virtual; + procedure SetHeight(Value: Extended); virtual; + procedure SetName(const AName: TComponentName); override; + procedure SetFont(Value: TFont); virtual; + procedure SetParentFont(const Value: Boolean); virtual; + procedure SetVisible(Value: Boolean); virtual; + procedure FontChanged(Sender: TObject); virtual; + function DiffFont(f1, f2: TFont; const Add: String): String; + function InternalDiff(AComponent: TfrxComponent): String; + function GetContainerObjects: TList; virtual; + + procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override; + function GetChildOwner: TComponent; override; + public + constructor Create(AOwner: TComponent); override; + constructor DesignCreate(AOwner: TComponent; Flags: Word); virtual; + destructor Destroy; override; + class function GetDescription: String; virtual; + procedure AlignChildren; virtual; + procedure Assign(Source: TPersistent); override; + procedure AssignAll(Source: TfrxComponent); + procedure BeforeStartReport; virtual; + procedure Clear; virtual; + procedure CreateUniqueName; + procedure LoadFromStream(Stream: TStream); virtual; + procedure SaveToStream(Stream: TStream; SaveChildren: Boolean = True; + SaveDefaultValues: Boolean = False); virtual; + procedure SetBounds(ALeft, ATop, AWidth, AHeight: Extended); + procedure OnNotify(Sender: TObject); virtual; + procedure OnPaste; virtual; + function AllDiff(AComponent: TfrxComponent): String; + function Diff(AComponent: TfrxComponent): String; virtual; + function FindObject(const AName: String): TfrxComponent; + function ContainerAdd(Obj: TfrxComponent): Boolean; virtual; + function ContainerMouseDown(Sender: TObject; X, Y: Integer): Boolean; virtual; + procedure ContainerMouseMove(Sender: TObject; X, Y: Integer); virtual; + procedure ContainerMouseUp(Sender: TObject; X, Y: Integer); virtual; + + property Objects: TList read FObjects; + property AllObjects: TList read GetAllObjects; + property ContainerObjects: TList read GetContainerObjects; + property Parent: TfrxComponent read FParent write SetParent; + property Page: TfrxPage read GetPage; + property Report: TfrxReport read GetReport; + property IsAncestor: Boolean read GetIsAncestor; + property IsDesigning: Boolean read FIsDesigning write FIsDesigning; + property IsLoading: Boolean read GetIsLoading write FIsLoading; + property IsPrinting: Boolean read FIsPrinting write FIsPrinting; + property IsWriting: Boolean read FIsWriting write FIsWriting; + property BaseName: String read FBaseName; + property GroupIndex: Integer read FGroupIndex write FGroupIndex default 0; + property frComponentStyle: TfrxComponentStyle read FComponentStyle write FComponentStyle; + + property Left: Extended read FLeft write SetLeft; + property Top: Extended read FTop write SetTop; + property Width: Extended read FWidth write SetWidth; + property Height: Extended read FHeight write SetHeight; + property AbsLeft: Extended read GetAbsLeft; + property AbsTop: Extended read GetAbsTop; + + property Description: String read FDescription write FDescription; + property ParentFont: Boolean read FParentFont write SetParentFont default True; + property Restrictions: TfrxRestrictions read FRestrictions write FRestrictions default []; + property Visible: Boolean read FVisible write SetVisible default True; +{$IFNDEF FR_COM} + property Font: TFont read FFont write SetFont stored IsFontStored; +{$ELSE} + function GetFont: TFont; + property Font: TFont read GetFont write SetFont stored IsFontStored; + { IfrxComponent } + function IfrxComponent.GetObject = IfrxComponent_GetObject; + function IfrxComponent.Get_Description = IfrxComponent_Get_Description; + function IfrxComponent.Get_BaseName = IfrxComponent_Get_BaseName; + function IfrxComponent.Get_ObjectsCount = IfrxComponent_Get_ObjectsCount; + function IfrxComponent.Get_Left = IfrxComponent_Get_Left; + function IfrxComponent.Set_Left = IfrxComponent_Set_Left; + function IfrxComponent.Get_Top = IfrxComponent_Get_Top; + function IfrxComponent.Set_Top = IfrxComponent_Set_Top; + function IfrxComponent.Get_Width = IfrxComponent_Get_Width; + function IfrxComponent.Set_Width = IfrxComponent_Set_Width; + function IfrxComponent.Get_Height = IfrxComponent_Get_Height; + function IfrxComponent.Set_Height = IfrxComponent_Set_Height; + function IfrxComponent.FindObject = IfrxComponent_FindObject; + function IfrxComponent.Get_AliasName = IfrxComponent_Get_AliasName; + function IfrxComponent.Get_Name = IfrxComponent_Get_Name; + + function IfrxComponent_GetObject(Index: Integer; out Component: IfrxComponent): HResult; stdcall; + function IfrxComponent_Get_Description(out Value: WideString): HResult; stdcall; + function IfrxComponent_Get_BaseName(out Value: WideString): HResult; stdcall; + function IfrxComponent_Get_ObjectsCount(out Value: Integer): HResult; stdcall; + function IfrxComponent_Get_Left(out Value: Double): HResult; stdcall; + function IfrxComponent_Set_Left(Value: Double): HResult; stdcall; + function IfrxComponent_Get_Top(out Value: Double): HResult; stdcall; + function IfrxComponent_Set_Top(Value: Double): HResult; stdcall; + function IfrxComponent_Get_Width(out Value: Double): HResult; stdcall; + function IfrxComponent_Set_Width(Value: Double): HResult; stdcall; + function IfrxComponent_Get_Height(out Value: Double): HResult; stdcall; + function IfrxComponent_Set_Height(Value: Double): HResult; stdcall; + function IfrxComponent_FindObject(const ObjectName: WideString; out Object_: IfrxComponent): HResult; stdcall; + function IfrxComponent_Get_AliasName(out Value: WideString): HResult; stdcall; + function IfrxComponent_Get_Name(out Value: WideString): HResult; stdcall; + function Get_Restrictions(out Value: frxRestrictions): HResult; stdcall; + function Set_Restrictions(Value: frxRestrictions): HResult; stdcall; +{$ENDIF} + end; + + TfrxReportComponent = class(TfrxComponent) + private + FOnAfterData: TfrxNotifyEvent; + FOnAfterPrint: TfrxNotifyEvent; + FOnBeforePrint: TfrxNotifyEvent; + FOnPreviewClick: TfrxPreviewClickEvent; + public + FShiftAmount: Extended; + FShiftChildren: TList; + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); + virtual; abstract; + procedure BeforePrint; virtual; + procedure GetData; virtual; + procedure AfterPrint; virtual; + function GetComponentText: String; virtual; + function GetRealBounds: TfrxRect; virtual; + property OnAfterData: TfrxNotifyEvent read FOnAfterData write FOnAfterData; + property OnAfterPrint: TfrxNotifyEvent read FOnAfterPrint write FOnAfterPrint; + property OnBeforePrint: TfrxNotifyEvent read FOnBeforePrint write FOnBeforePrint; + property OnPreviewClick: TfrxPreviewClickEvent read FOnPreviewClick write FOnPreviewClick; + published + property Description; + end; + + TfrxDialogComponent = class(TfrxReportComponent) + private + FComponent: TComponent; + procedure ReadLeft(Reader: TReader); + procedure ReadTop(Reader: TReader); + procedure WriteLeft(Writer: TWriter); + procedure WriteTop(Writer: TWriter); + protected + FImageIndex: Integer; + procedure DefineProperties(Filer: TFiler); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + property Component: TComponent read FComponent write FComponent; + end; + + TfrxDialogControl = class(TfrxReportComponent) + private + FControl: TControl; + FOnClick: TfrxNotifyEvent; + FOnDblClick: TfrxNotifyEvent; + FOnEnter: TfrxNotifyEvent; + FOnExit: TfrxNotifyEvent; + FOnKeyDown: TfrxKeyEvent; + FOnKeyPress: TfrxKeyPressEvent; + FOnKeyUp: TfrxKeyEvent; + FOnMouseDown: TfrxMouseEvent; + FOnMouseMove: TfrxMouseMoveEvent; + FOnMouseUp: TfrxMouseEvent; + function GetColor: TColor; + function GetEnabled: Boolean; + procedure DoOnClick(Sender: TObject); + procedure DoOnDblClick(Sender: TObject); + procedure DoOnEnter(Sender: TObject); + procedure DoOnExit(Sender: TObject); + procedure DoOnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure DoOnKeyPress(Sender: TObject; var Key: Char); + procedure DoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure DoOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure DoOnMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); + procedure DoOnMouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); + procedure SetColor(const Value: TColor); + procedure SetEnabled(const Value: Boolean); + function GetCaption: String; + procedure SetCaption(const Value: String); + function GetHint: String; + procedure SetHint(const Value: String); + function GetTabStop: Boolean; + procedure SetTabStop(const Value: Boolean); + protected + procedure SetLeft(Value: Extended); override; + procedure SetTop(Value: Extended); override; + procedure SetWidth(Value: Extended); override; + procedure SetHeight(Value: Extended); override; + procedure SetParentFont(const Value: Boolean); override; + procedure SetVisible(Value: Boolean); override; + procedure SetParent(AParent: TfrxComponent); override; + procedure FontChanged(Sender: TObject); override; + procedure InitControl(AControl: TControl); + procedure SetName(const AName: TComponentName); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + + property Caption: String read GetCaption write SetCaption; + property Color: TColor read GetColor write SetColor; + property Control: TControl read FControl write FControl; + property TabStop: Boolean read GetTabStop write SetTabStop default True; + property OnClick: TfrxNotifyEvent read FOnClick write FOnClick; + property OnDblClick: TfrxNotifyEvent read FOnDblClick write FOnDblClick; + property OnEnter: TfrxNotifyEvent read FOnEnter write FOnEnter; + property OnExit: TfrxNotifyEvent read FOnExit write FOnExit; + property OnKeyDown: TfrxKeyEvent read FOnKeyDown write FOnKeyDown; + property OnKeyPress: TfrxKeyPressEvent read FOnKeyPress write FOnKeyPress; + property OnKeyUp: TfrxKeyEvent read FOnKeyUp write FOnKeyUp; + property OnMouseDown: TfrxMouseEvent read FOnMouseDown write FOnMouseDown; + property OnMouseMove: TfrxMouseMoveEvent read FOnMouseMove write FOnMouseMove; + property OnMouseUp: TfrxMouseEvent read FOnMouseUp write FOnMouseUp; + published + property Left; + property Top; + property Width; + property Height; + property Font; + property GroupIndex; + property ParentFont; + property Enabled: Boolean read GetEnabled write SetEnabled default True; + property Hint: String read GetHint write SetHint; + property Visible; + end; + +{$IFDEF FR_COM} + TfrxDataSet = class(TfrxDialogComponent, IfrxDataSet) +{$ELSE} + TfrxDataSet = class(TfrxDialogComponent) +{$ENDIF} + private + FCloseDataSource: Boolean; + FEnabled: Boolean; + FEof: Boolean; + FOpenDataSource: Boolean; + FRangeBegin: TfrxRangeBegin; + FRangeEnd: TfrxRangeEnd; + FRangeEndCount: Integer; + FReportRef: TfrxReport; + FUserName: String; + FOnCheckEOF: TfrxCheckEOFEvent; + FOnFirst: TNotifyEvent; + FOnNext: TNotifyEvent; + FOnPrior: TNotifyEvent; + FOnOpen: TNotifyEvent; + FOnClose: TNotifyEvent; + protected + FInitialized: Boolean; + FRecNo: Integer; + function GetDisplayText(Index: String): WideString; virtual; + function GetDisplayWidth(Index: String): Integer; virtual; + function GetFieldType(Index: String): TfrxFieldType; virtual; + function GetValue(Index: String): Variant; virtual; + procedure SetName(const NewName: TComponentName); override; + procedure SetUserName(const Value: String); virtual; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + + { Navigation methods } + procedure Initialize; virtual; + procedure Finalize; virtual; + procedure Open; virtual; + procedure Close; virtual; + procedure First; virtual; + procedure Next; virtual; + procedure Prior; virtual; + function Eof: Boolean; virtual; + + { Data access } + function FieldsCount: Integer; virtual; + function HasField(const fName: String): Boolean; + function IsBlobField(const fName: String): Boolean; virtual; + function RecordCount: Integer; virtual; + procedure AssignBlobTo(const fName: String; Obj: TObject); virtual; + procedure GetFieldList(List: TStrings); virtual; + property DisplayText[Index: String]: WideString read GetDisplayText; + property DisplayWidth[Index: String]: Integer read GetDisplayWidth; + property FieldType[Index: String]: TfrxFieldType read GetFieldType; + property Value[Index: String]: Variant read GetValue; + + property CloseDataSource: Boolean read FCloseDataSource write FCloseDataSource; + { OpenDataSource is kept for backward compatibility only } + property OpenDataSource: Boolean read FOpenDataSource write FOpenDataSource default True; + property RecNo: Integer read FRecNo; + property ReportRef: TfrxReport read FReportRef write FReportRef; + property OnClose: TNotifyEvent read FOnClose write FOnClose; + property OnOpen: TNotifyEvent read FOnOpen write FOnOpen; + published + property Enabled: Boolean read FEnabled write FEnabled default True; + property RangeBegin: TfrxRangeBegin read FRangeBegin write FRangeBegin default rbFirst; + property RangeEnd: TfrxRangeEnd read FRangeEnd write FRangeEnd default reLast; + property RangeEndCount: Integer read FRangeEndCount write FRangeEndCount default 0; + property UserName: String read FUserName write SetUserName; + property OnCheckEOF: TfrxCheckEOFEvent read FOnCheckEOF write FOnCheckEOF; + property OnFirst: TNotifyEvent read FOnFirst write FOnFirst; + property OnNext: TNotifyEvent read FOnNext write FOnNext; + property OnPrior: TNotifyEvent read FOnPrior write FOnPrior; +{$IFDEF FR_COM} + private { Interface section } + function Get_UserName(out Value: WideString): HResult; stdcall; + function Set_UserName(const Value: WideString): HResult; stdcall; + function Get_RangeBegin(out Value: frxRangeBegin): HResult; stdcall; + function Set_RangeBegin(Value: frxRangeBegin): HResult; stdcall; + function Get_RangeEndCount(out Value: Integer): HResult; stdcall; + function Set_RangeEndCount(Value: Integer): HResult; stdcall; + function Get_RangeEnd(out Value: frxRangeEnd): HResult; stdcall; + function Set_RangeEnd(Value: frxRangeEnd): HResult; stdcall; + function Get_FieldsCount(out Value: Integer): HResult; stdcall; + function Get_RecordsCount(out Value: Integer): HResult; stdcall; + function ValueOfField(const FieldName: WideString; out Value: OleVariant): HResult; stdcall; + function Get_CurrentRecordNo(out Value: Integer): HResult; stdcall; + function GoFirst: HResult; stdcall; + function GoNext: HResult; stdcall; + function GoPrior: HResult; stdcall; +{$ENDIF} + end; + +{$IFDEF FR_COM} + TfrxUserDataSet = class(TfrxDataset, IfrxUserDataSet, IConnectionPointContainer) + private + FConnectionPoints: TConnectionPoints; + FConnectionPoint: TConnectionPoint; + FEvent: IfrxUserDataSetEvents; +{$ELSE} + TfrxUserDataSet = class(TfrxDataset) + private +{$ENDIF} + FFields: TStrings; + FOnGetValue: TfrxGetValueEvent; + procedure SetFields(const Value: TStrings); + protected + function GetDisplayText(Index: String): WideString; override; + function GetValue(Index: String): Variant; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function FieldsCount: Integer; override; + procedure GetFieldList(List: TStrings); override; + published + property Fields: TStrings read FFields write SetFields; + property OnGetValue: TfrxGetValueEvent read FOnGetValue write FOnGetValue; +{$IFDEF FR_COM} + private + function IfrxUserDataSet.Get_Fields = IfrxUserDataSet_Get_Fields; + function IfrxUserDataSet.Set_Fields = IfrxUserDataSet_Set_Fields; + function IfrxUserDataSet.Get_Name = IfrxUserDataSet_Get_Name; + function IfrxUserDataSet.Set_Name = IfrxUserDataSet_Set_Name; + + function IfrxUserDataSet_Get_Fields(out Value: WideString): HResult; stdcall; + function IfrxUserDataSet_Set_Fields(const Value: WideString): HResult; stdcall; + function IfrxUserDataSet_Get_Name(out Value: WideString): HResult; stdcall; + function IfrxUserDataSet_Set_Name(const Value: WideString): HResult; stdcall; + + procedure EventSinkChanged(const Sink: IUnknown; Connecting: Boolean); + { COM proxy event functions } + procedure COM_OnGetValueHandler(const VarName: String; var Value: Variant); + procedure COM_OnCheckEOFHandler(Sender: TObject; var EOF : Boolean); + procedure COM_OnFirstHandler(Sender: TObject); + procedure COM_OnNextHandler(Sender: TObject); + procedure COM_OnPrevHandler(Sender: TObject); +public + property ConnectionPoints: TConnectionPoints read FConnectionPoints implements IConnectionPointContainer; + +{$ENDIF} + end; + + TfrxCustomDBDataSet = class(TfrxDataSet) + private + FAliases: TStrings; + FFields: TStringList; + procedure SetFieldAliases(const Value: TStrings); + protected + property Fields: TStringList read FFields; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function ConvertAlias(const fName: String): String; + function GetAlias(const fName: String): String; + function FieldsCount: Integer; override; + published + property CloseDataSource; + property FieldAliases: TStrings read FAliases write SetFieldAliases; + property OpenDataSource; + property OnClose; + property OnOpen; + end; + + + TfrxDBComponents = class(TComponent) + public + function GetDescription: String; virtual; + end; + + TfrxCustomDatabase = class(TfrxDialogComponent) + protected + procedure BeforeConnect(var Value: Boolean); + procedure SetConnected(Value: Boolean); virtual; + procedure SetDatabaseName(const Value: String); virtual; + procedure SetLoginPrompt(Value: Boolean); virtual; + procedure SetParams(Value: TStrings); virtual; + function GetConnected: Boolean; virtual; + function GetDatabaseName: String; virtual; + function GetLoginPrompt: Boolean; virtual; + function GetParams: TStrings; virtual; + public + procedure SetLogin(const Login, Password: String); virtual; + property Connected: Boolean read GetConnected write SetConnected default False; + property DatabaseName: String read GetDatabaseName write SetDatabaseName; + property LoginPrompt: Boolean read GetLoginPrompt write SetLoginPrompt default True; + property Params: TStrings read GetParams write SetParams; + end; + + + TfrxComponentClass = class of TfrxComponent; + +{ Report Objects } + + TfrxFrameLine = class(TPersistent) + private + FFrame: TfrxFrame; + FColor: TColor; + FStyle: TfrxFrameStyle; + FWidth: Extended; + function IsColorStored: Boolean; + function IsStyleStored: Boolean; + function IsWidthStored: Boolean; + public + constructor Create(AFrame: TfrxFrame); + procedure Assign(Source: TPersistent); override; + function Diff(ALine: TfrxFrameLine; const LineName: String; + ColorChanged, StyleChanged, WidthChanged: Boolean): String; + published + property Color: TColor read FColor write FColor stored IsColorStored; + property Style: TfrxFrameStyle read FStyle write FStyle stored IsStyleStored; + property Width: Extended read FWidth write FWidth stored IsWidthStored; + end; + +{$IFDEF FR_COM} + TfrxFrame = class(TDispatchablePersistent, IfrxFrame) +{$ELSE} + TfrxFrame = class(TPersistent) +{$ENDIF} + private + FLeftLine: TfrxFrameLine; + FTopLine: TfrxFrameLine; + FRightLine: TfrxFrameLine; + FBottomLine: TfrxFrameLine; + FColor: TColor; + FDropShadow: Boolean; + FShadowWidth: Extended; + FShadowColor: TColor; + FStyle: TfrxFrameStyle; + FTyp: TfrxFrameTypes; + FWidth: Extended; + function IsShadowWidthStored: Boolean; + function IsTypStored: Boolean; + function IsWidthStored: Boolean; + procedure SetBottomLine(const Value: TfrxFrameLine); + procedure SetLeftLine(const Value: TfrxFrameLine); + procedure SetRightLine(const Value: TfrxFrameLine); + procedure SetTopLine(const Value: TfrxFrameLine); + procedure SetColor(const Value: TColor); + procedure SetStyle(const Value: TfrxFrameStyle); + procedure SetWidth(const Value: Extended); +{$IFDEF FR_COM} + { IfrxFrame } + function Get_Color(out Value: Integer): HResult; stdcall; + function Set_Color(Value: Integer): HResult; stdcall; + function Get_DropShadow(out Value: WordBool): HResult; stdcall; + function Set_DropShadow(Value: WordBool): HResult; stdcall; + function Get_ShadowColor(out Value: Integer): HResult; stdcall; + function Set_ShadowColor(Value: Integer): HResult; stdcall; + function Get_ShadowWidth(out Value: Double): HResult; stdcall; + function Set_ShadowWidth(Value: Double): HResult; stdcall; + function Get_Style(out Value: frxFrameStyle): HResult; stdcall; + function Set_Style(Value: frxFrameStyle): HResult; stdcall; + function Get_FrameType(out Value: Integer): HResult; stdcall; + function Set_FrameType(Value: Integer): HResult; stdcall; + function Get_Width(out Value: Double): HResult; stdcall; + function Set_Width(Value: Double): HResult; stdcall; +{$ENDIF} + public + constructor Create; + destructor Destroy; override; + procedure Assign(Source: TPersistent); override; + function Diff(AFrame: TfrxFrame): String; + published + property Color: TColor read FColor write SetColor default clBlack; + property DropShadow: Boolean read FDropShadow write FDropShadow default False; + property ShadowColor: TColor read FShadowColor write FShadowColor default clBlack; + property ShadowWidth: Extended read FShadowWidth write FShadowWidth stored IsShadowWidthStored; + property Style: TfrxFrameStyle read FStyle write SetStyle default fsSolid; + property Typ: TfrxFrameTypes read FTyp write FTyp stored IsTypStored; + property Width: Extended read FWidth write SetWidth stored IsWidthStored; + property LeftLine: TfrxFrameLine read FLeftLine write SetLeftLine; + property TopLine: TfrxFrameLine read FTopLine write SetTopLine; + property RightLine: TfrxFrameLine read FRightLine write SetRightLine; + property BottomLine: TfrxFrameLine read FBottomLine write SetBottomLine; + end; + +{$IFDEF FR_COM} + TfrxView = class(TfrxReportComponent, IfrxView) +{$ELSE} + TfrxView = class(TfrxReportComponent) +{$ENDIF} + private + FAlign: TfrxAlign; + FBrushStyle: TBrushStyle; + FColor: TColor; + FCursor: TCursor; + FDataField: String; + FDataSet: TfrxDataSet; + FDataSetName: String; + FFrame: TfrxFrame; + FPrintable: Boolean; + FShiftMode: TfrxShiftMode; + FTagStr: String; + FTempTag: String; + FTempURL: String; + FURL: String; + FPlainText: Boolean; + procedure SetFrame(const Value: TfrxFrame); + procedure SetDataSet(const Value: TfrxDataSet); + procedure SetDataSetName(const Value: String); + function GetDataSetName: String; + protected + FX: Integer; + FY: Integer; + FX1: Integer; + FY1: Integer; + FDX: Integer; + FDY: Integer; + FFrameWidth: Integer; + FScaleX: Extended; + FScaleY: Extended; + FOffsetX: Extended; + FOffsetY: Extended; + FCanvas: TCanvas; + procedure BeginDraw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); virtual; + procedure DrawBackground; virtual; + procedure DrawFrame; virtual; + procedure DrawLine(x, y, x1, y1, w: Integer); + procedure ExpandVariables(var Expr: String); + procedure Notification(AComponent: TComponent; Operation: TOperation); override; +{$IFDEF FR_COM} + function Get_DataField(out Value: WideString): HResult; stdcall; + function Set_DataField(const Value: WideString): HResult; stdcall; + function Get_TagStr(out Value: WideString): HResult; stdcall; + function Set_TagStr(const Value: WideString): HResult; stdcall; + function Get_URL(out Value: WideString): HResult; stdcall; + function Set_URL(const Value: WideString): HResult; stdcall; + function Get_DataSetName(out Value: WideString): HResult; stdcall; + function Set_DataSetName(const Value: WideString): HResult; stdcall; + function Get_Name(out Value: WideString): HResult; stdcall; + function Get_Frame(out Value: IfrxFrame): HResult; stdcall; + function Get_ShiftMode(out Value: frxShiftMode): HResult; stdcall; + function Set_ShiftMode(Value: frxShiftMode): HResult; stdcall; + function Get_Align(out Value: frxAlign): HResult; stdcall; + function Set_Align(Value: frxAlign): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function Diff(AComponent: TfrxComponent): String; override; + function IsDataField: Boolean; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure BeforePrint; override; + procedure GetData; override; + procedure AfterPrint; override; + property BrushStyle: TBrushStyle read FBrushStyle write FBrushStyle default bsSolid; + property Color: TColor read FColor write FColor default clNone; + property DataField: String read FDataField write FDataField; + property DataSet: TfrxDataSet read FDataSet write SetDataSet; + property DataSetName: String read GetDataSetName write SetDataSetName; + property Frame: TfrxFrame read FFrame write SetFrame; + property PlainText: Boolean read FPlainText write FPlainText; + property Cursor: TCursor read FCursor write FCursor default crDefault; + property TagStr: String read FTagStr write FTagStr; + property URL: String read FURL write FURL; + published + property Align: TfrxAlign read FAlign write FAlign default baNone; + property Printable: Boolean read FPrintable write FPrintable default True; + property ShiftMode: TfrxShiftMode read FShiftMode write FShiftMode default smAlways; + property Left; + property Top; + property Width; + property Height; + property GroupIndex; + property Restrictions; + property Visible; + property OnAfterData; + property OnAfterPrint; + property OnBeforePrint; + property OnPreviewClick; + end; + +{$IFDEF FR_COM} + TfrxStretcheable = class(TfrxView, IfrxStretcheable) +{$ELSE} + TfrxStretcheable = class(TfrxView) +{$ENDIF} + private + FStretchMode: TfrxStretchMode; +{$IFDEF FR_COM} + function Get_StretchMode(out Value: frxStretchMode): HResult; stdcall; + function Set_StretchMode(Value: frxStretchMode): HResult; stdcall; +{$ENDIF} + public + FSaveHeight: Extended; + constructor Create(AOwner: TComponent); override; + function CalcHeight: Extended; virtual; + function DrawPart: Extended; virtual; + procedure InitPart; virtual; + published + property StretchMode: TfrxStretchMode read FStretchMode write FStretchMode + default smDontStretch; + end; + +{$IFDEF FR_COM} + TfrxHighlight = class(TDispatchablePersistent, IfrxHighlight) +{$ELSE} + TfrxHighlight = class(TPersistent) +{$ENDIF} + private + FActive: Boolean; + FColor: TColor; + FCondition: String; +{$IFNDEF FR_COM} + FFont: TFont; +{$ELSE} + FFont: TfrxFont; + function GetFont: TFont; +{$ENDIF} + procedure SetFont(const Value: TFont); +{$IFDEF FR_COM} + { IfrxHighlight } + function Get_Active(out Value: WordBool): HResult; stdcall; + function Set_Active(Value: WordBool): HResult; stdcall; + function Get_Color(out Value: Integer): HResult; stdcall; + function Set_Color(Value: Integer): HResult; stdcall; + function Get_Font(out Value: IfrxFont): HResult; stdcall; +{$ENDIF} + public + constructor Create; + destructor Destroy; override; + procedure Assign(Source: TPersistent); override; + published + property Active: Boolean read FActive write FActive default False; +{$IFNDEF FR_COM} + property Font: TFont read FFont write SetFont; +{$ELSE} + property Font: TFont read GetFont write SetFont; +{$ENDIF} + property Color: TColor read FColor write FColor default clNone; + property Condition: String read FCondition write FCondition; + end; + +{$IFDEF FR_COM} + TfrxFormat = class(TDispatchablePersistent, IfrxDisplayFormat) +{$ELSE} + TfrxFormat = class(TPersistent) +{$ENDIF} + private + FDecimalSeparator: String; + FFormatStr: String; + FKind: TfrxFormatKind; +{$IFDEF FR_COM} + { IfrxDisplayFormat } + function Get_DecimalSeparator(out Value: WideString): HResult; stdcall; + function Set_DecimalSeparator(const Value: WideString): HResult; stdcall; + function Get_FormatStr(out Value: WideString): HResult; stdcall; + function Set_FormatStr(const Value: WideString): HResult; stdcall; + function Get_Kind(out Value: frxFormatKind): HResult; stdcall; + function Set_Kind(Value: frxFormatKind): HResult; stdcall; +{$ENDIF} + public +{$IFDEF FR_COM} + constructor Create; +{$ENDIF} + procedure Assign(Source: TPersistent); override; + published + property DecimalSeparator: String read FDecimalSeparator write FDecimalSeparator; + property FormatStr: String read FFormatStr write FFormatStr; + property Kind: TfrxFormatKind read FKind write FKind default fkText; + end; + +{$IFDEF FR_COM} + TfrxCustomMemoView = class(TfrxStretcheable, IfrxCustomMemoView) +{$ELSE} + TfrxCustomMemoView = class(TfrxStretcheable) +{$ENDIF} + private + FAllowExpressions: Boolean; + FAllowHTMLTags: Boolean; + FAutoWidth: Boolean; + FCharSpacing: Extended; + FClipped: Boolean; + FDisplayFormat: TfrxFormat; + FExpressionDelimiters: String; + FFlowTo: TfrxCustomMemoView; + FFirstParaBreak: Boolean; + FGapX: Extended; + FGapY: Extended; + FHAlign: TfrxHAlign; + FHideZeros: Boolean; + FHighlight: TfrxHighlight; + FLastParaBreak: Boolean; + FLineSpacing: Extended; + FMemo: TWideStrings; + FParagraphGap: Extended; + FPartMemo: WideString; + FRotation: Integer; + FRTLReading: Boolean; + FStyle: String; + FSuppressRepeated: Boolean; + FTempMemo: WideString; + FUnderlines: Boolean; + FVAlign: TfrxVAlign; + FValue: Variant; + FWordBreak: Boolean; + FWordWrap: Boolean; + FWysiwyg: Boolean; + procedure SetMemo(const Value: TWideStrings); + procedure SetRotation(Value: Integer); + procedure SetText(const Value: WideString); + function AdjustCalcHeight: Extended; + function AdjustCalcWidth: Extended; + function GetText: WideString; + function IsExprDelimitersStored: Boolean; + function IsLineSpacingStored: Boolean; + function IsGapXStored: Boolean; + function IsGapYStored: Boolean; + function IsHighlightStored: Boolean; + function IsParagraphGapStored: Boolean; + procedure SetHighlight(const Value: TfrxHighlight); + procedure SetDisplayFormat(const Value: TfrxFormat); + procedure SetStyle(const Value: String); + function IsCharSpacingStored: Boolean; + protected + FLastValue: Variant; + FTotalPages: Integer; + FCopyNo: Integer; + FTextRect: TRect; + FPrintScale: Extended; + function CalcAndFormat(const Expr: WideString): WideString; + procedure BeginDraw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure SetDrawParams(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + function Diff(AComponent: TfrxComponent): String; override; + function CalcHeight: Extended; override; + function CalcWidth: Extended; virtual; + function DrawPart: Extended; override; + function GetComponentText: String; override; + function FormatData(const Value: Variant; AFormat: TfrxFormat = nil): WideString; + function WrapText(WrapWords: Boolean): WideString; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure BeforePrint; override; + procedure GetData; override; + procedure AfterPrint; override; + procedure InitPart; override; + procedure ApplyStyle(Style: TfrxStyleItem); + procedure ExtractMacros; + procedure ResetSuppress; + property Text: WideString read GetText write SetText; + property Value: Variant read FValue write FValue; + // analogue of Memo property + property Lines: TWideStrings read FMemo write SetMemo; + + property AllowExpressions: Boolean read FAllowExpressions write FAllowExpressions default True; + property AllowHTMLTags: Boolean read FAllowHTMLTags write FAllowHTMLTags default False; + property AutoWidth: Boolean read FAutoWidth write FAutoWidth default False; + property CharSpacing: Extended read FCharSpacing write FCharSpacing stored IsCharSpacingStored; + property Clipped: Boolean read FClipped write FClipped default True; + property DisplayFormat: TfrxFormat read FDisplayFormat write SetDisplayFormat; + property ExpressionDelimiters: String read FExpressionDelimiters + write FExpressionDelimiters stored IsExprDelimitersStored; + property FlowTo: TfrxCustomMemoView read FFlowTo write FFlowTo; + property GapX: Extended read FGapX write FGapX stored IsGapXStored; + property GapY: Extended read FGapY write FGapY stored IsGapYStored; + property HAlign: TfrxHAlign read FHAlign write FHAlign default haLeft; + property HideZeros: Boolean read FHideZeros write FHideZeros default False; + property Highlight: TfrxHighlight read FHighlight write SetHighlight + stored IsHighlightStored; + property LineSpacing: Extended read FLineSpacing write FLineSpacing stored IsLineSpacingStored; + property Memo: TWideStrings read FMemo write SetMemo; + property ParagraphGap: Extended read FParagraphGap write FParagraphGap stored IsParagraphGapStored; + property Rotation: Integer read FRotation write SetRotation default 0; + property RTLReading: Boolean read FRTLReading write FRTLReading default False; + property Style: String read FStyle write SetStyle; + property SuppressRepeated: Boolean read FSuppressRepeated write FSuppressRepeated default False; + property Underlines: Boolean read FUnderlines write FUnderlines default False; + property WordBreak: Boolean read FWordBreak write FWordBreak default False; + property WordWrap: Boolean read FWordWrap write FWordWrap default True; + property Wysiwyg: Boolean read FWysiwyg write FWysiwyg default True; + property VAlign: TfrxVAlign read FVAlign write FVAlign default vaTop; +{$IFDEF FR_COM} + { IfrxCustomMemoView } + function IfrxCustomMemoView.Get_Text = IfrxCustomMemoView_Get_Text; + function IfrxCustomMemoView.Set_Text = IfrxCustomMemoView_Set_Text; + + function IfrxCustomMemoView_Get_Text(out Value: WideString): HResult; stdcall; + function IfrxCustomMemoView_Set_Text(const Value: WideString): HResult; stdcall; +{$ENDIF} + published + property FirstParaBreak: Boolean read FFirstParaBreak write FFirstParaBreak default False; + property LastParaBreak: Boolean read FLastParaBreak write FLastParaBreak default False; + property Cursor; + property TagStr; + property URL; + end; + +{$IFDEF FR_COM} + TfrxMemoView = class(TfrxCustomMemoView, IfrxMemoView) + protected + function Get_AutoWidth(out Value: WordBool): HResult; stdcall; + function Set_AutoWidth(Value: WordBool): HResult; stdcall; + function Get_AllowExpressions(out Value: WordBool): HResult; stdcall; + function Set_AllowExpressions(Value: WordBool): HResult; stdcall; + function Get_AllowHTMLTags(out Value: WordBool): HResult; stdcall; + function Set_AllowHTMLTags(Value: WordBool): HResult; stdcall; + function Get_BrushStyle(out Value: frxBrushStyle): HResult; stdcall; + function Set_BrushStyle(Value: frxBrushStyle): HResult; stdcall; + function Get_CharSpacing(out Value: Double): HResult; stdcall; + function Set_CharSpacing(Value: Double): HResult; stdcall; + function Get_Clipped(out Value: WordBool): HResult; stdcall; + function Set_Clipped(Value: WordBool): HResult; stdcall; + function Get_Color(out Value: Integer): HResult; stdcall; + function Set_Color(Value: Integer): HResult; stdcall; + function Get_DataField(out Value: WideString): HResult; stdcall; + function Set_DataField(const Value: WideString): HResult; stdcall; + function Get_DataSet(out Value: IfrxDataSet): HResult; stdcall; + function Set_DataSet(const Value: IfrxDataSet): HResult; stdcall; + function Get_DataSetName(out Value: WideString): HResult; stdcall; + function Set_DataSetName(const Value: WideString): HResult; stdcall; + function Get_DisplayFormat(out Value: IfrxDisplayFormat): HResult; stdcall; + function Get_ExpressionDelimiters(out Value: WideString): HResult; stdcall; + function Set_ExpressionDelimiters(const Value: WideString): HResult; stdcall; + function Get_FlowTo(out Value: IfrxCustomMemoView): HResult; stdcall; + function Set_FlowTo(const Value: IfrxCustomMemoView): HResult; stdcall; + function Get_Font(out Value: IfrxFont): HResult; stdcall; + function Get_Frame(out Value: IfrxFrame): HResult; stdcall; + function Get_GapX(out Value: Double): HResult; stdcall; + function Set_GapX(Value: Double): HResult; stdcall; + function Get_GapY(out Value: Double): HResult; stdcall; + function Set_GapY(Value: Double): HResult; stdcall; + function Get_HAlign(out Value: frxHAlign): HResult; stdcall; + function Set_HAlign(Value: frxHAlign): HResult; stdcall; + function Get_HideZeros(out Value: WordBool): HResult; stdcall; + function Set_HideZeros(Value: WordBool): HResult; stdcall; + function Get_Highlight(out Value: IfrxHighlight): HResult; stdcall; + function Get_LineSpacing(out Value: Double): HResult; stdcall; + function Set_LineSpacing(Value: Double): HResult; stdcall; + function Get_Memo(out Value: WideString): HResult; stdcall; + function Set_Memo(const Value: WideString): HResult; stdcall; + function Get_ParagraphGap(out Value: Double): HResult; stdcall; + function Set_ParagraphGap(Value: Double): HResult; stdcall; + function Get_ParentFont(out Value: WordBool): HResult; stdcall; + function Set_ParentFont(Value: WordBool): HResult; stdcall; + function Get_Rotation(out Value: Integer): HResult; stdcall; + function Set_Rotation(Value: Integer): HResult; stdcall; + function Get_RTLReading(out Value: WordBool): HResult; stdcall; + function Set_RTLReading(Value: WordBool): HResult; stdcall; + function Get_Style(out Value: WideString): HResult; stdcall; + function Set_Style(const Value: WideString): HResult; stdcall; + function Get_SuppressRepeated(out Value: WordBool): HResult; stdcall; + function Set_SuppressRepeated(Value: WordBool): HResult; stdcall; + function Get_Underlines(out Value: WordBool): HResult; stdcall; + function Set_Underlines(Value: WordBool): HResult; stdcall; + function Get_WordBreak(out Value: WordBool): HResult; stdcall; + function Set_WordBreak(Value: WordBool): HResult; stdcall; + function Get_WordWrap(out Value: WordBool): HResult; stdcall; + function Set_WordWrap(Value: WordBool): HResult; stdcall; + function Get_VAlign(out Value: frxVAlign): HResult; stdcall; + function Set_VAlign(Value: frxVAlign): HResult; stdcall; +{$ELSE} + TfrxMemoView = class(TfrxCustomMemoView) +{$ENDIF} + published + property AutoWidth; + property AllowExpressions; + property AllowHTMLTags; + property BrushStyle; + property CharSpacing; + property Clipped; + property Color; + property DataField; + property DataSet; + property DataSetName; + property DisplayFormat; + property ExpressionDelimiters; + property FlowTo; + property Font; + property Frame; + property GapX; + property GapY; + property HAlign; + property HideZeros; + property Highlight; + property LineSpacing; + property Memo; + property ParagraphGap; + property ParentFont; + property Rotation; + property RTLReading; + property Style; + property SuppressRepeated; + property Underlines; + property WordBreak; + property WordWrap; + property Wysiwyg; + property VAlign; + end; + + TfrxSysMemoView = class(TfrxCustomMemoView) + public + class function GetDescription: String; override; + published + property AutoWidth; + property BrushStyle; + property CharSpacing; + property Color; + property DisplayFormat; + property Font; + property Frame; + property GapX; + property GapY; + property HAlign; + property HideZeros; + property Highlight; + property Memo; + property ParentFont; + property Rotation; + property RTLReading; + property Style; + property SuppressRepeated; + property VAlign; + property WordWrap; + end; + + TfrxCustomLineView = class(TfrxStretcheable) + private + FDiagonal: Boolean; + FArrowEnd: Boolean; + FArrowLength: Integer; + FArrowSolid: Boolean; + FArrowStart: Boolean; + FArrowWidth: Integer; + procedure DrawArrow(x1, y1, x2, y2: Integer); + procedure DrawDiagonalLine; + public + constructor Create(AOwner: TComponent); override; + constructor DesignCreate(AOwner: TComponent; Flags: Word); override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + property ArrowEnd: Boolean read FArrowEnd write FArrowEnd default False; + property ArrowLength: Integer read FArrowLength write FArrowLength default 20; + property ArrowSolid: Boolean read FArrowSolid write FArrowSolid default False; + property ArrowStart: Boolean read FArrowStart write FArrowStart default False; + property ArrowWidth: Integer read FArrowWidth write FArrowWidth default 5; + property Diagonal: Boolean read FDiagonal write FDiagonal default False; + published + property TagStr; + end; + + TfrxLineView = class(TfrxCustomLineView) + public + class function GetDescription: String; override; + published + property ArrowEnd; + property ArrowLength; + property ArrowSolid; + property ArrowStart; + property ArrowWidth; + property Frame; + property Diagonal; + end; + +{$IFDEF FR_COM} + TfrxPictureView = class(TfrxView, IfrxPictureView) +{$ELSE} + TfrxPictureView = class(TfrxView) +{$ENDIF} + private + FAutoSize: Boolean; + FCenter: Boolean; + FFileLink: String; + FImageIndex: Integer; + FIsImageIndexStored: Boolean; + FIsPictureStored: Boolean; + FKeepAspectRatio: Boolean; + FPicture: TPicture; + FPictureChanged: Boolean; + FStretched: Boolean; + procedure SetPicture(const Value: TPicture); + procedure PictureChanged(Sender: TObject); + procedure SetAutoSize(const Value: Boolean); +{$IFDEF FR_COM} + protected + function Get_Picture(out Value: OLE_HANDLE): HResult; stdcall; + function Set_Picture(Value: OLE_HANDLE): HResult; stdcall; + function Get_Metafile(out Value: OLE_HANDLE): HResult; stdcall; + function Set_Metafile(Value: OLE_HANDLE): HResult; stdcall; + function LoadViewFromStream(const Stream: IUnknown): HResult; stdcall; + function SaveViewToStream(const Stream: IUnknown): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + function Diff(AComponent: TfrxComponent): String; override; + function LoadPictureFromStream(s: TStream): HResult; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure GetData; override; + property IsImageIndexStored: Boolean read FIsImageIndexStored write FIsImageIndexStored; + property IsPictureStored: Boolean read FIsPictureStored write FIsPictureStored; + published + property Cursor; + property AutoSize: Boolean read FAutoSize write SetAutoSize default False; + property Center: Boolean read FCenter write FCenter default False; + property DataField; + property DataSet; + property DataSetName; + property Frame; + property FileLink: String read FFileLink write FFileLink; + property ImageIndex: Integer read FImageIndex write FImageIndex stored FIsImageIndexStored; + property KeepAspectRatio: Boolean read FKeepAspectRatio write FKeepAspectRatio default True; + property Picture: TPicture read FPicture write SetPicture stored FIsPictureStored; + property Stretched: Boolean read FStretched write FStretched default True; + property TagStr; + property URL; + end; + +{$IFDEF FR_COM} + TfrxShapeView = class(TfrxView, IfrxShapeView) +{$ELSE} + TfrxShapeView = class(TfrxView) +{$ENDIF} + private + FCurve: Integer; + FShape: TfrxShapeKind; +{$IFDEF FR_COM} + function Get_Curve(out Value: Integer): HResult; stdcall; + function Set_Curve(Value: Integer): HResult; stdcall; + function Get_ShapeType(out Value: frxShapeType): HResult; stdcall; + function Set_ShapeType(Value: frxShapeType): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + constructor DesignCreate(AOwner: TComponent; Flags: Word); override; + function Diff(AComponent: TfrxComponent): String; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + class function GetDescription: String; override; + published + property BrushStyle; + property Color; + property Cursor; + property Curve: Integer read FCurve write FCurve default 0; + property Frame; + property Shape: TfrxShapeKind read FShape write FShape default skRectangle; + property TagStr; + property URL; + end; + +{$IFDEF FR_COM} + TfrxSubreport = class(TfrxView, IfrxSubreport) +{$ELSE} + TfrxSubreport = class(TfrxView) +{$ENDIF} + private + FPage: TfrxReportPage; + FPrintOnParent: Boolean; + procedure SetPage(const Value: TfrxReportPage); +{$IFDEF FR_COM} + function Get_Page(out Value: IfrxReportPage): HResult; stdcall; + function Set_Page(const Value: IfrxReportPage): HResult; stdcall; + function Get_PrintOnparent(out Value: WordBool): HResult; stdcall; + function Set_PrintOnparent(Value: WordBool): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + class function GetDescription: String; override; + published + property Page: TfrxReportPage read FPage write SetPage; + property PrintOnParent: Boolean read FPrintOnParent write FPrintOnParent + default False; + end; + + +{ Bands } + TfrxChild = class; + +{$IFDEF FR_COM} + TfrxBand = class(TfrxReportComponent, IfrxBand) +{$ELSE} + TfrxBand = class(TfrxReportComponent) +{$ENDIF} + private + FAllowSplit: Boolean; + FChild: TfrxChild; + FKeepChild: Boolean; + FOnAfterCalcHeight: TfrxNotifyEvent; + FOutlineText: String; + FOverflow: Boolean; + FStartNewPage: Boolean; + FStretched: Boolean; + FPrintChildIfInvisible: Boolean; + FVertical: Boolean; + function GetBandName: String; + procedure SetChild(Value: TfrxChild); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure SetLeft(Value: Extended); override; + procedure SetTop(Value: Extended); override; + procedure SetHeight(Value: Extended); override; +{$IFDEF FR_COM} + { IfrxBand } + function IfrxBand.Get_AllowSplit = IfrxBand_Get_AllowSplit; + function IfrxBand.Set_AllowSplit = IfrxBand_Set_AllowSplit; + function IfrxBand.Get_KeepChild = IfrxBand_Get_KeepChild; + function IfrxBand.Set_KeepChild = IfrxBand_Set_KeepChild; + function IfrxBand.Get_OutlineText = IfrxBand_Get_OutlineText; + function IfrxBand.Set_OutlineText = IfrxBand_Set_OutlineText; + function IfrxBand.Get_Overflow = IfrxBand_Get_Overflow; + function IfrxBand.Set_Overflow = IfrxBand_Set_Overflow; + function IfrxBand.Get_StartNewPage = IfrxBand_Get_StartNewPage; + function IfrxBand.Set_StartNewPage = IfrxBand_Set_StartNewPage; + function IfrxBand.Get_Stretched = IfrxBand_Get_Stretched; + function IfrxBand.Set_Stretched = IfrxBand_Set_Stretched; + function IfrxBand.Get_PrintChildIfInvisible = IfrxBand_Get_PrintChildIfInvisible; + function IfrxBand.Set_PrintChildIfInvisible = IfrxBand_Set_PrintChildIfInvisible; + function IfrxBand.Get_Vertical = IfrxBand_Get_Vertical; + function IfrxBand.Set_Vertical = IfrxBand_Set_Vertical; + function IfrxBand.Get_BandName = IfrxBand_Get_BandName; + + function IfrxBand_Get_AllowSplit(out Value: WordBool): HResult; stdcall; + function IfrxBand_Set_AllowSplit(Value: WordBool): HResult; stdcall; + function IfrxBand_Get_KeepChild(out Value: WordBool): HResult; stdcall; + function IfrxBand_Set_KeepChild(Value: WordBool): HResult; stdcall; + function IfrxBand_Get_OutlineText(out Value: WideString): HResult; stdcall; + function IfrxBand_Set_OutlineText(const Value: WideString): HResult; stdcall; + function IfrxBand_Get_Overflow(out Value: WordBool): HResult; stdcall; + function IfrxBand_Set_Overflow(Value: WordBool): HResult; stdcall; + function IfrxBand_Get_StartNewPage(out Value: WordBool): HResult; stdcall; + function IfrxBand_Set_StartNewPage(Value: WordBool): HResult; stdcall; + function IfrxBand_Get_Stretched(out Value: WordBool): HResult; stdcall; + function IfrxBand_Set_Stretched(Value: WordBool): HResult; stdcall; + function IfrxBand_Get_PrintChildIfInvisible(out Value: WordBool): HResult; stdcall; + function IfrxBand_Set_PrintChildIfInvisible(Value: WordBool): HResult; stdcall; + function IfrxBand_Get_Vertical(out Value: WordBool): HResult; stdcall; + function IfrxBand_Set_Vertical(Value: WordBool): HResult; stdcall; + function IfrxBand_Get_BandName(out Value: WideString): HResult; stdcall; + function Get_Child(out Value: IfrxChild): HResult; stdcall; + function Set_Child(const Value: IfrxChild): HResult; stdcall; +{$ENDIF} + public + FSubBands: TList; { list of subbands } + FHeader, FFooter, FGroup: TfrxBand; { h./f./g. bands } + FLineN: Integer; { used for Line# } + FLineThrough: Integer; { used for LineThrough# } + FOriginalObjectsCount: Integer; { used for TfrxSubReport.PrintOnParent } + FHasVBands: Boolean; { whether the band should show vbands } + FStretchedHeight: Extended; + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function BandNumber: Integer; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + class function GetDescription: String; override; + property AllowSplit: Boolean read FAllowSplit write FAllowSplit default False; + property BandName: String read GetBandName; + property Child: TfrxChild read FChild write SetChild; + property KeepChild: Boolean read FKeepChild write FKeepChild default False; + property OutlineText: String read FOutlineText write FOutlineText; + property Overflow: Boolean read FOverflow write FOverflow; + property PrintChildIfInvisible: Boolean read FPrintChildIfInvisible + write FPrintChildIfInvisible default False; + property StartNewPage: Boolean read FStartNewPage write FStartNewPage default False; + property Stretched: Boolean read FStretched write FStretched default False; + published + property Font; + property Height; + property Left; + property ParentFont; + property Restrictions; + property Top; + property Vertical: Boolean read FVertical write FVertical default False; + property Visible; + property Width; + property OnAfterCalcHeight: TfrxNotifyEvent read FOnAfterCalcHeight + write FOnAfterCalcHeight; + property OnAfterPrint; + property OnBeforePrint; + end; + + TfrxBandClass = class of TfrxBand; + +{$IFDEF FR_COM} + TfrxDataBand = class(TfrxBand, IfrxDataBand) +{$ELSE} + TfrxDataBand = class(TfrxBand) +{$ENDIF} + private + FColumnGap: Extended; + FColumnWidth: Extended; + FColumns: Integer; + FCurColumn: Integer; + FDataSet: TfrxDataSet; + FDataSetName: String; + FFooterAfterEach: Boolean; + FKeepFooter: Boolean; + FKeepHeader: Boolean; + FKeepTogether: Boolean; + FPrintIfDetailEmpty: Boolean; + FRowCount: Integer; + FOnMasterDetail: TfrxNotifyEvent; + FVirtualDataSet: TfrxUserDataSet; + procedure SetCurColumn(Value: Integer); + procedure SetRowCount(const Value: Integer); + procedure SetDataSet(const Value: TfrxDataSet); + procedure SetDataSetName(const Value: String); + function GetDataSetName: String; + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; +{$IFDEF FR_COM} + {IfrxDataBand} + function Get_ColumnGap(out Value: Double): HResult; stdcall; + function Set_ColumnGap(Value: Double): HResult; stdcall; + function Get_ColumnWidth(out Value: Double): HResult; stdcall; + function Set_ColumnWidth(Value: Double): HResult; stdcall; + function Get_ColumnsCount(out Value: Integer): HResult; stdcall; + function Set_ColumnsCount(Value: Integer): HResult; stdcall; + function Get_CurrentColumn(out Value: Integer): HResult; stdcall; + function Set_CurrentColumn(Value: Integer): HResult; stdcall; + function Get_DataSet(out Value: IfrxDataSet): HResult; stdcall; + function Set_DataSet(const Value: IfrxDataSet): HResult; stdcall; + function Get_FooterAfterEach(out Value: WordBool): HResult; stdcall; + function Set_FooterAfterEach(Value: WordBool): HResult; stdcall; + function Get_KeepFooter(out Value: WordBool): HResult; stdcall; + function Set_KeepFooter(Value: WordBool): HResult; stdcall; + function Get_KeepHeader(out Value: WordBool): HResult; stdcall; + function Set_KeepHeader(Value: WordBool): HResult; stdcall; + function Get_KeepTogether(out Value: WordBool): HResult; stdcall; + function Set_KeepTogether(Value: WordBool): HResult; stdcall; + function Get_PrintIfDetailEmpty(out Value: WordBool): HResult; stdcall; + function Set_PrintIfDetailEmpty(Value: WordBool): HResult; stdcall; + function Get_RowCount(out Value: Integer): HResult; stdcall; + function Set_RowCount(Value: Integer): HResult; stdcall; + function ResetDataSet: HResult; stdcall; +{$ENDIF} + public + FMaxY: Extended; { used for columns } + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + property CurColumn: Integer read FCurColumn write SetCurColumn; + property VirtualDataSet: TfrxUserDataSet read FVirtualDataSet; + published + property AllowSplit; + property Child; + property Columns: Integer read FColumns write FColumns default 0; + property ColumnWidth: Extended read FColumnWidth write FColumnWidth; + property ColumnGap: Extended read FColumnGap write FColumnGap; + property DataSet: TfrxDataSet read FDataSet write SetDataSet; + property DataSetName: String read GetDataSetName write SetDataSetName; + property FooterAfterEach: Boolean read FFooterAfterEach write FFooterAfterEach default False; + property KeepChild; + property KeepFooter: Boolean read FKeepFooter write FKeepFooter default False; + property KeepHeader: Boolean read FKeepHeader write FKeepHeader default False; + property KeepTogether: Boolean read FKeepTogether write FKeepTogether default False; + property OutlineText; + property PrintChildIfInvisible; + property PrintIfDetailEmpty: Boolean read FPrintIfDetailEmpty + write FPrintIfDetailEmpty default False; + property RowCount: Integer read FRowCount write SetRowCount; + property StartNewPage; + property Stretched; + property OnMasterDetail: TfrxNotifyEvent read FOnMasterDetail write FOnMasterDetail; + end; + +{$IFDEF FR_COM} + TfrxHeader = class(TfrxBand, IfrxHeader) +{$ELSE} + TfrxHeader = class(TfrxBand) +{$ENDIF} + private + FReprintOnNewPage: Boolean; +{$IFDEF FR_COM} + function Get_ReprintOnNewPage(out Value: WordBool): HResult; stdcall; + function Set_ReprintOnNewPage(Value: WordBool): HResult; stdcall; +{$ENDIF} + published + property AllowSplit; + property Child; + property KeepChild; + property PrintChildIfInvisible; + property ReprintOnNewPage: Boolean read FReprintOnNewPage write FReprintOnNewPage default False; + property StartNewPage; + property Stretched; + end; + +{$IFDEF FR_COM} + TfrxFooter = class(TfrxBand, IfrxFooter) +{$ELSE} + TfrxFooter = class(TfrxBand) +{$ENDIF} + private + public + published + property AllowSplit; + property Child; + property KeepChild; + property PrintChildIfInvisible; + property Stretched; + end; + +{$IFDEF FR_COM} + TfrxMasterData = class(TfrxDataBand, IfrxMasterData) +{$ELSE} + TfrxMasterData = class(TfrxDataBand) +{$ENDIF} + private + public + published + end; + +{$IFDEF FR_COM} + TfrxDetailData = class(TfrxDataBand, IfrxDetailData) +{$ELSE} + TfrxDetailData = class(TfrxDataBand) +{$ENDIF} + private + public + published + end; + +{$IFDEF FR_COM} + TfrxSubdetailData = class(TfrxDataBand, IfrxSubdetailData) +{$ELSE} + TfrxSubdetailData = class(TfrxDataBand) +{$ENDIF} + private + public + published + end; + +{$IFDEF FR_COM} + TfrxDataBand4 = class(TfrxDataBand, IfrxDataBand4) +{$ELSE} + TfrxDataBand4 = class(TfrxDataBand) +{$ENDIF} + private + public + published + end; + +{$IFDEF FR_COM} + TfrxDataBand5 = class(TfrxDataBand, IfrxDataBand6) +{$ELSE} + TfrxDataBand5 = class(TfrxDataBand) +{$ENDIF} + private + public + published + end; + +{$IFDEF FR_COM} + TfrxDataBand6 = class(TfrxDataBand, IfrxDataBand6) +{$ELSE} + TfrxDataBand6 = class(TfrxDataBand) +{$ENDIF} + private + public + published + end; + +{$IFDEF FR_COM} + TfrxPageHeader = class(TfrxBand, IfrxPageHeader) +{$ELSE} + TfrxPageHeader = class(TfrxBand) +{$ENDIF} + private + FPrintOnFirstPage: Boolean; +{$IFDEF FR_COM} + function Get_PrintOnFirstPage(out Value: WordBool): HResult; stdcall; + function Set_PrintOnFirstPage(Value: WordBool): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + published + property Child; + property PrintChildIfInvisible; + property PrintOnFirstPage: Boolean read FPrintOnFirstPage write FPrintOnFirstPage default True; + property Stretched; + end; + +{$IFDEF FR_COM} + TfrxPageFooter = class(TfrxBand, IfrxPageFooter) +{$ELSE} + TfrxPageFooter = class(TfrxBand) +{$ENDIF} + private + FPrintOnFirstPage: Boolean; + FPrintOnLastPage: Boolean; +{$IFDEF FR_COM} + function Get_PrintOnFirstPage(out Value: WordBool): HResult; stdcall; + function Set_PrintOnFirstPage(Value: WordBool): HResult; stdcall; + function Get_PrintOnLastPage(out Value: WordBool): HResult; stdcall; + function Set_PrintOnLastPage(Value: WordBool): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + published + property PrintOnFirstPage: Boolean read FPrintOnFirstPage write FPrintOnFirstPage default True; + property PrintOnLastPage: Boolean read FPrintOnLastPage write FPrintOnLastPage default True; + end; + +{$IFDEF FR_COM} + TfrxColumnHeader = class(TfrxBand, IfrxColumnHeader) +{$ELSE} + TfrxColumnHeader = class(TfrxBand) +{$ENDIF} + private + public + published + property Child; + property Stretched; + end; + +{$IFDEF FR_COM} + TfrxColumnFooter = class(TfrxBand, IfrxColumnFooter) +{$ELSE} + TfrxColumnFooter = class(TfrxBand) +{$ENDIF} + private + public + published + end; + +{$IFDEF FR_COM} + TfrxGroupHeader = class(TfrxBand, IfrxGroupHeader) +{$ELSE} + TfrxGroupHeader = class(TfrxBand) +{$ENDIF} + private + FCondition: String; + FDrillDown: Boolean; + FExpandDrillDown: Boolean; + FShowFooterIfDrillDown: Boolean; + FKeepTogether: Boolean; + FReprintOnNewPage: Boolean; + FResetPageNumbers: Boolean; +{$IFDEF FR_COM} + function Get_Condition(out Value: WideString): HResult; stdcall; + function Set_Condition(const Value: WideString): HResult; stdcall; + function Get_KeepTogether(out Value: WordBool): HResult; stdcall; + function Set_KeepTogether(Value: WordBool): HResult; stdcall; + function Get_ReprintOnNewPage(out Value: WordBool): HResult; stdcall; + function Set_ReprintOnNewPage(Value: WordBool): HResult; stdcall; + function Get_LastValue(out Value: OleVariant): HResult; stdcall; +{$ENDIF} + public + FLastValue: Variant; + function Diff(AComponent: TfrxComponent): String; override; + published + property AllowSplit; + property Child; + property Condition: String read FCondition write FCondition; + property DrillDown: Boolean read FDrillDown write FDrillDown default False; + property ExpandDrillDown: Boolean read FExpandDrillDown write FExpandDrillDown default False; + property KeepChild; + property KeepTogether: Boolean read FKeepTogether write FKeepTogether default False; + property ReprintOnNewPage: Boolean read FReprintOnNewPage write FReprintOnNewPage default False; + property OutlineText; + property PrintChildIfInvisible; + property ResetPageNumbers: Boolean read FResetPageNumbers write FResetPageNumbers default False; + property ShowFooterIfDrillDown: Boolean read FShowFooterIfDrillDown + write FShowFooterIfDrillDown default False; + property StartNewPage; + property Stretched; + end; + +{$IFDEF FR_COM} + TfrxGroupFooter = class(TfrxBand, IfrxGroupFooter) +{$ELSE} + TfrxGroupFooter = class(TfrxBand) +{$ENDIF} + private + FHideIfSingleDataRecord: Boolean; +{$IFDEF FR_COM} + function Get_HideIfSingledatarecord(out Value: WordBool): HResult; stdcall; + function Set_HideIfSingledatarecord(Value: WordBool): HResult; stdcall; +{$ENDIF} + public + published + property AllowSplit; + property Child; + property HideIfSingleDataRecord: Boolean read FHideIfSingleDataRecord + write FHideIfSingleDataRecord default False; + property KeepChild; + property PrintChildIfInvisible; + property Stretched; + end; + +{$IFDEF FR_COM} + TfrxReportTitle = class(TfrxBand, IfrxReportTitle) +{$ELSE} + TfrxReportTitle = class(TfrxBand) +{$ENDIF} + private + public + published + property AllowSplit; + property Child; + property KeepChild; + property PrintChildIfInvisible; + property StartNewPage; + property Stretched; + end; + +{$IFDEF FR_COM} + TfrxReportSummary = class(TfrxBand, IfrxReportSummary) +{$ELSE} + TfrxReportSummary = class(TfrxBand) +{$ENDIF} + private + public + published + property AllowSplit; + property Child; + property KeepChild; + property PrintChildIfInvisible; + property StartNewPage; + property Stretched; + end; + +{$IFDEF FR_COM} + TfrxChild = class(TfrxBand, IfrxChild) +{$ELSE} + TfrxChild = class(TfrxBand) +{$ENDIF} + private + public + published + property AllowSplit; + property Child; + property KeepChild; + property PrintChildIfInvisible; + property StartNewPage; + property Stretched; + end; + +{$IFDEF FR_COM} + TfrxOverlay = class(TfrxBand, IfrxOverlay) +{$ELSE} + TfrxOverlay = class(TfrxBand) +{$ENDIF} + private + FPrintOnTop: Boolean; + public + published + property PrintOnTop: Boolean read FPrintOnTop write FPrintOnTop default False; + end; + + TfrxNullBand = class(TfrxBand); + + +{ Pages } + +{$IFDEF FR_COM} + TfrxPage = class(TfrxComponent, IfrxPage) +{$ELSE} + TfrxPage = class(TfrxComponent) +{$ENDIF} + private + protected +{$IFDEF FR_COM} + function Get_Visible(out Value: WordBool): HResult; stdcall; + function Set_Visible(Value: WordBool): HResult; stdcall; +{$ENDIF} + public + published + property Font; + property Visible; + end; + +{$IFDEF FR_COM} + TfrxReportPage = class(TfrxPage, IfrxReportPage) +{$ELSE} + TfrxReportPage = class(TfrxPage) +{$ENDIF} + private + FBackPicture: TfrxPictureView; + FBin: Integer; + FBinOtherPages: Integer; + FBottomMargin: Extended; + FColumns: Integer; + FColumnWidth: Extended; + FColumnPositions: TStrings; + FDataSet: TfrxDataSet; + FDuplex: TfrxDuplexMode; + FEndlessHeight: Boolean; + FEndlessWidth: Boolean; + FHGuides: TStrings; + FLargeDesignHeight: Boolean; + FLeftMargin: Extended; + FMirrorMargins: Boolean; + FOrientation: TPrinterOrientation; + FOutlineText: String; + FPrintIfEmpty: Boolean; + FPrintOnPreviousPage: Boolean; + FResetPageNumbers: Boolean; + FRightMargin: Extended; + FSubReport: TfrxSubReport; + FTitleBeforeHeader: Boolean; + FTopMargin: Extended; + FVGuides: TStrings; + FOnAfterPrint: TfrxNotifyEvent; + FOnBeforePrint: TfrxNotifyEvent; + FOnManualBuild: TfrxNotifyEvent; + FDataSetName: String; + procedure SetColumns(const Value: Integer); + procedure SetOrientation(Value: TPrinterOrientation); + procedure SetHGuides(const Value: TStrings); + procedure SetVGuides(const Value: TStrings); + procedure SetColumnPositions(const Value: TStrings); + procedure SetFrame(const Value: TfrxFrame); + function GetFrame: TfrxFrame; + function GetColor: TColor; + procedure SetColor(const Value: TColor); + function GetBackPicture: TPicture; + procedure SetBackPicture(const Value: TPicture); + procedure SetDataSet(const Value: TfrxDataSet); + procedure SetDataSetName(const Value: String); + function GetDataSetName: String; + protected + FPaperHeight: Extended; + FPaperSize: Integer; + FPaperWidth: Extended; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure SetPaperHeight(const Value: Extended); virtual; + procedure SetPaperWidth(const Value: Extended); virtual; + procedure SetPaperSize(const Value: Integer); virtual; + procedure UpdateDimensions; + public + FSubBands: TList; { list of master bands } + FVSubBands: TList; { list of vertical master bands } + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + function FindBand(Band: TfrxBandClass): TfrxBand; + function IsSubReport: Boolean; + procedure AlignChildren; override; + procedure ClearGuides; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); + procedure SetDefaults; virtual; + procedure SetSizeAndDimensions(ASize: Integer; AWidth, AHeight: Extended); + property SubReport: TfrxSubReport read FSubReport; + published + { paper } + property Orientation: TPrinterOrientation read FOrientation + write SetOrientation default poPortrait; + property PaperWidth: Extended read FPaperWidth write SetPaperWidth; + property PaperHeight: Extended read FPaperHeight write SetPaperHeight; + property PaperSize: Integer read FPaperSize write SetPaperSize; + { margins } + property LeftMargin: Extended read FLeftMargin write FLeftMargin; + property RightMargin: Extended read FRightMargin write FRightMargin; + property TopMargin: Extended read FTopMargin write FTopMargin; + property BottomMargin: Extended read FBottomMargin write FBottomMargin; + property MirrorMargins: Boolean read FMirrorMargins write FMirrorMargins + default False; + { columns } + property Columns: Integer read FColumns write SetColumns default 0; + property ColumnWidth: Extended read FColumnWidth write FColumnWidth; + property ColumnPositions: TStrings read FColumnPositions write SetColumnPositions; + { bins } + property Bin: Integer read FBin write FBin default DMBIN_AUTO; + property BinOtherPages: Integer read FBinOtherPages write FBinOtherPages + default DMBIN_AUTO; + { other } + property BackPicture: TPicture read GetBackPicture write SetBackPicture; + property Color: TColor read GetColor write SetColor default clNone; + property DataSet: TfrxDataSet read FDataSet write SetDataSet; + property DataSetName: String read GetDataSetName write SetDataSetName; + property Duplex: TfrxDuplexMode read FDuplex write FDuplex default dmNone; + property Frame: TfrxFrame read GetFrame write SetFrame; + property EndlessHeight: Boolean read FEndlessHeight write FEndlessHeight default False; + property EndlessWidth: Boolean read FEndlessWidth write FEndlessWidth default False; + property LargeDesignHeight: Boolean read FLargeDesignHeight + write FLargeDesignHeight default False; + property OutlineText: String read FOutlineText write FOutlineText; + property PrintIfEmpty: Boolean read FPrintIfEmpty write FPrintIfEmpty default True; + property PrintOnPreviousPage: Boolean read FPrintOnPreviousPage + write FPrintOnPreviousPage default False; + property ResetPageNumbers: Boolean read FResetPageNumbers + write FResetPageNumbers default False; + property TitleBeforeHeader: Boolean read FTitleBeforeHeader + write FTitleBeforeHeader default True; + property HGuides: TStrings read FHGuides write SetHGuides; + property VGuides: TStrings read FVGuides write SetVGuides; + property OnAfterPrint: TfrxNotifyEvent read FOnAfterPrint write FOnAfterPrint; + property OnBeforePrint: TfrxNotifyEvent read FOnBeforePrint write FOnBeforePrint; + property OnManualBuild: TfrxNotifyEvent read FOnManualBuild write FOnManualBuild; +{$IFDEF FR_COM} + { IfrxReportPage } + function IfrxReportPage.SetDefaults = IfrxReportPage_SetDefaults; + function IfrxReportPage.Get_Bin = IfrxReportPage_Get_Bin; + function IfrxReportPage.Set_Bin = IfrxReportPage_Set_Bin; + function IfrxReportPage.Get_BinOtherPages = IfrxReportPage_Get_BinOtherPages; + function IfrxReportPage.Set_BinOtherPages = IfrxReportPage_Set_BinOtherPages; + function IfrxReportPage.Get_BottomMargin = IfrxReportPage_Get_BottomMargin; + function IfrxReportPage.Set_BottomMargin = IfrxReportPage_Set_BottomMargin; + function IfrxReportPage.Get_Columns = IfrxReportPage_Get_Columns; + function IfrxReportPage.Set_Columns = IfrxReportPage_Set_Columns; + function IfrxReportPage.Get_ColumnWidth = IfrxReportPage_Get_ColumnWidth; + function IfrxReportPage.Set_ColumnWidth = IfrxReportPage_Set_ColumnWidth; + function IfrxReportPage.Get_ColumnPositions = IfrxReportPage_Get_ColumnPosition; + function IfrxReportPage.Set_ColumnPositions = IfrxReportPage_Set_ColumnPosition; + function IfrxReportPage.Get_DataSet = IfrxReportPage_Get_DataSet; + function IfrxReportPage.Set_DataSet = IfrxReportPage_Set_DataSet; + function IfrxReportPage.Get_Duplex = IfrxReportPage_Get_Duplex; + function IfrxReportPage.Set_Duplex = IfrxReportPage_Set_Duplex; + function IfrxReportPage.Get_HGuides = IfrxReportPage_Get_HGuides; + function IfrxReportPage.Set_HGuides = IfrxReportPage_Set_HGuides; + function IfrxReportPage.Get_LargeDesignHeight = IfrxReportPage_Get_LargeDesignHeight; + function IfrxReportPage.Set_LargeDesignHeight = IfrxReportPage_Set_LargeDesignHeight; + function IfrxReportPage.Get_LeftMargin = IfrxReportPage_Get_LeftMargin; + function IfrxReportPage.Set_LeftMargin = IfrxReportPage_Set_LeftMargin; + function IfrxReportPage.Get_MirrorMargins = IfrxReportPage_Get_MirrorMargins; + function IfrxReportPage.Set_MirrorMargins = IfrxReportPage_Set_MirrorMargins; + function IfrxReportPage.Get_Orientation = IfrxReportPage_Get_Orientation; + function IfrxReportPage.Set_Orientation = IfrxReportPage_Set_Orientation; + function IfrxReportPage.Get_OutlineText = IfrxReportPage_Get_OutlineText; + function IfrxReportPage.Set_OutlineText = IfrxReportPage_Set_OutlineText; + function IfrxReportPage.Get_PrintIfEmpty = IfrxReportPage_Get_PrintIfEmpty; + function IfrxReportPage.Set_PrintIfEmpty = IfrxReportPage_Set_PrintIfEmpty; + function IfrxReportPage.Get_PrintOnPreviousPage = IfrxReportPage_Get_PrintOnPreviousPage; + function IfrxReportPage.Set_PrintOnPreviousPage = IfrxReportPage_Set_PrintOnPreviousPage; + function IfrxReportPage.Get_RightMargin = IfrxReportPage_Get_RightMargin; + function IfrxReportPage.Set_RightMargin = IfrxReportPage_Set_RightMargin; + function IfrxReportPage.Get_SubReport = IfrxReportPage_Get_SubReport; + function IfrxReportPage.Set_SubReport = IfrxReportPage_Set_SubReport; + function IfrxReportPage.Get_TitleBeforeHeader = IfrxReportPage_Get_TitleBeforeHeader; + function IfrxReportPage.Set_TitleBeforeHeader = IfrxReportPage_Set_TitleBeforeHeader; + function IfrxReportPage.Get_TopMargin = IfrxReportPage_Get_TopMargin; + function IfrxReportPage.Set_TopMargin = IfrxReportPage_Set_TopMargin; + function IfrxReportPage.Get_VGuides = IfrxReportPage_Get_VGuides; + function IfrxReportPage.Set_VGuides = IfrxReportPage_Set_VGuides; + function IfrxReportPage.Get_BackPickture = IfrxReportPage_Get_BackPickture; + function IfrxReportPage.Set_BackPickture = IfrxReportPage_Set_BackPickture; + + function IfrxReportPage_SetDefaults: HResult; stdcall; + function IfrxReportPage_Get_Bin(out Value: SYSINT): HResult; stdcall; + function IfrxReportPage_Set_Bin(Value: SYSINT): HResult; stdcall; + function IfrxReportPage_Get_BinOtherPages(out Value: SYSINT): HResult; stdcall; + function IfrxReportPage_Set_BinOtherPages(Value: SYSINT): HResult; stdcall; + function IfrxReportPage_Get_BottomMargin(out Value: Double): HResult; stdcall; + function IfrxReportPage_Set_BottomMargin(Value: Double): HResult; stdcall; + function IfrxReportPage_Get_Columns(out Value: SYSINT): HResult; stdcall; + function IfrxReportPage_Set_Columns(Value: SYSINT): HResult; stdcall; + function IfrxReportPage_Get_ColumnWidth(out Value: Double): HResult; stdcall; + function IfrxReportPage_Set_ColumnWidth(Value: Double): HResult; stdcall; + function IfrxReportPage_Get_ColumnPosition(out Value: WideString): HResult; stdcall; + function IfrxReportPage_Set_ColumnPosition(const Value: WideString): HResult; stdcall; + function IfrxReportPage_Get_DataSet(out Value: IfrxDataSet): HResult; stdcall; + function IfrxReportPage_Set_DataSet(const Value: IfrxDataSet): HResult; stdcall; + function IfrxReportPage_Get_Duplex(out Value: frxDuplexMode): HResult; stdcall; + function IfrxReportPage_Set_Duplex(Value: frxDuplexMode): HResult; stdcall; + function IfrxReportPage_Get_HGuides(out Value: WideString): HResult; stdcall; + function IfrxReportPage_Set_HGuides(const Value: WideString): HResult; stdcall; + function IfrxReportPage_Get_LargeDesignHeight(out Value: WordBool): HResult; stdcall; + function IfrxReportPage_Set_LargeDesignHeight(Value: WordBool): HResult; stdcall; + function IfrxReportPage_Get_LeftMargin(out Value: Double): HResult; stdcall; + function IfrxReportPage_Set_LeftMargin(Value: Double): HResult; stdcall; + function IfrxReportPage_Get_MirrorMargins(out Value: WordBool): HResult; stdcall; + function IfrxReportPage_Set_MirrorMargins(Value: WordBool): HResult; stdcall; + function IfrxReportPage_Get_Orientation(out Value: frxPrinterOrientation): HResult; stdcall; + function IfrxReportPage_Set_Orientation(Value: frxPrinterOrientation): HResult; stdcall; + function IfrxReportPage_Get_OutlineText(out Value: WideString): HResult; stdcall; + function IfrxReportPage_Set_OutlineText(const Value: WideString): HResult; stdcall; + function IfrxReportPage_Get_PrintIfEmpty(out Value: WordBool): HResult; stdcall; + function IfrxReportPage_Set_PrintIfEmpty(Value: WordBool): HResult; stdcall; + function IfrxReportPage_Get_PrintOnPreviousPage(out Value: WordBool): HResult; stdcall; + function IfrxReportPage_Set_PrintOnPreviousPage(Value: WordBool): HResult; stdcall; + function IfrxReportPage_Get_RightMargin(out Value: Double): HResult; stdcall; + function IfrxReportPage_Set_RightMargin(Value: Double): HResult; stdcall; + function IfrxReportPage_Get_SubReport(out Value: IfrxSubreport): HResult; stdcall; + function IfrxReportPage_Set_SubReport(const Value: IfrxSubreport): HResult; stdcall; + function IfrxReportPage_Get_TitleBeforeHeader(out Value: WordBool): HResult; stdcall; + function IfrxReportPage_Set_TitleBeforeHeader(Value: WordBool): HResult; stdcall; + function IfrxReportPage_Get_TopMargin(out Value: Double): HResult; stdcall; + function IfrxReportPage_Set_TopMargin(Value: Double): HResult; stdcall; + function IfrxReportPage_Get_VGuides(out Value: WideString): HResult; stdcall; + function IfrxReportPage_Set_VGuides(const Value: WideString): HResult; stdcall; + function IfrxReportPage_Get_BackPickture(out Value: OLE_HANDLE): HResult; stdcall; + function IfrxReportPage_Set_BackPickture(Value: OLE_HANDLE): HResult; stdcall; + + function Get_PaperWidth(out Value: Double): HResult; stdcall; + function Set_PaperWidth(Value: Double): HResult; stdcall; + function Get_PaperHeight(out Value: Double): HResult; stdcall; + function Set_PaperHeight(Value: Double): HResult; stdcall; +{$ENDIF} + end; + + TfrxDialogPage = class(TfrxPage) + private + FBorderStyle: TFormBorderStyle; + FCaption: String; + FColor: TColor; + FForm: TForm; + FOnActivate: TfrxNotifyEvent; + FOnClick: TfrxNotifyEvent; + FOnDeactivate: TfrxNotifyEvent; + FOnHide: TfrxNotifyEvent; + FOnKeyDown: TfrxKeyEvent; + FOnKeyPress: TfrxKeyPressEvent; + FOnKeyUp: TfrxKeyEvent; + FOnResize: TfrxNotifyEvent; + FOnShow: TfrxNotifyEvent; + FOnCloseQuery: TfrxCloseQueryEvent; + FPosition: TPosition; + FWindowState: TWindowState; + procedure DoInitialize; + procedure DoOnActivate(Sender: TObject); + procedure DoOnClick(Sender: TObject); + procedure DoOnCloseQuery(Sender: TObject; var CanClose: Boolean); + procedure DoOnDeactivate(Sender: TObject); + procedure DoOnHide(Sender: TObject); + procedure DoOnKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure DoOnKeyPress(Sender: TObject; var Key: Char); + procedure DoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure DoOnShow(Sender: TObject); + procedure DoOnResize(Sender: TObject); + procedure DoModify(Sender: TObject); + procedure SetBorderStyle(const Value: TFormBorderStyle); + procedure SetCaption(const Value: String); + procedure SetColor(const Value: TColor); + function GetModalResult: TModalResult; + procedure SetModalResult(const Value: TModalResult); + protected + procedure SetLeft(Value: Extended); override; + procedure SetTop(Value: Extended); override; + procedure SetWidth(Value: Extended); override; + procedure SetHeight(Value: Extended); override; + procedure FontChanged(Sender: TObject); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + procedure Initialize; + function ShowModal: TModalResult; + property DialogForm: TForm read FForm; + property ModalResult: TModalResult read GetModalResult write SetModalResult; + published + property BorderStyle: TFormBorderStyle read FBorderStyle write SetBorderStyle default bsSizeable; + property Caption: String read FCaption write SetCaption; + property Color: TColor read FColor write SetColor default clBtnFace; + property Height; + property Left; + property Position: TPosition read FPosition write FPosition default poScreenCenter; + property Top; + property Width; + property WindowState: TWindowState read FWindowState write FWindowState default wsNormal; + property OnActivate: TfrxNotifyEvent read FOnActivate write FOnActivate; + property OnClick: TfrxNotifyEvent read FOnClick write FOnClick; + property OnCloseQuery: TfrxCloseQueryEvent read FOnCloseQuery write FOnCloseQuery; + property OnDeactivate: TfrxNotifyEvent read FOnDeactivate write FOnDeactivate; + property OnHide: TfrxNotifyEvent read FOnHide write FOnHide; + property OnKeyDown: TfrxKeyEvent read FOnKeyDown write FOnKeyDown; + property OnKeyPress: TfrxKeyPressEvent read FOnKeyPress write FOnKeyPress; + property OnKeyUp: TfrxKeyEvent read FOnKeyUp write FOnKeyUp; + property OnShow: TfrxNotifyEvent read FOnShow write FOnShow; + property OnResize: TfrxNotifyEvent read FOnResize write FOnResize; + end; + + TfrxDataPage = class(TfrxPage) + private + protected + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + published + property Height; + property Left; + property Top; + property Width; + end; + + +{ Report } + +{$IFDEF FR_COM} + TfrxEngineOptions = class(TDispatchablePersistent, IfrxEngineOptions) +{$ELSE} + TfrxEngineOptions = class(TPersistent) +{$ENDIF} + private + FConvertNulls: Boolean; + FDestroyForms: Boolean; + FDoublePass: Boolean; + FMaxMemSize: Integer; + FPrintIfEmpty: Boolean; +{$IFNDEF FR_COM} + FReportThread: TThread; +{$ENDIF} + FEnableThreadSafe: Boolean; + FSilentMode: TfrxSilentMode; + FTempDir: String; + FUseFileCache: Boolean; + + procedure SetSilentMode(Mode: Boolean); + function GetSilentMode: Boolean; + public + constructor Create; + procedure Assign(Source: TPersistent); override; + procedure Clear; +{$IFNDEF FR_COM} + property ReportThread: TThread read FReportThread write FReportThread; +{$ENDIF} + property DestroyForms: Boolean read FDestroyForms write FDestroyForms; + property EnableThreadSafe: Boolean read FEnableThreadSafe write FEnableThreadSafe; + published + property ConvertNulls: Boolean read FConvertNulls write FConvertNulls default True; + property DoublePass: Boolean read FDoublePass write FDoublePass default False; + property MaxMemSize: Integer read FMaxMemSize write FMaxMemSize default 10; + property PrintIfEmpty: Boolean read FPrintIfEmpty write FPrintIfEmpty default True; + property SilentMode: Boolean read GetSilentMode write SetSilentMode default False; + property NewSilentMode: TfrxSilentMode read FSilentMode write FSilentMode default simMessageBoxes; + property TempDir: String read FTempDir write FTempDir; + property UseFileCache: Boolean read FUseFileCache write FUseFileCache default False; +{$IFDEF FR_COM} + { IfrxEngineOptions } + function IfrxEngineOptions.Get_ConvertNulls = IfrxEngineOptions_Get_ConvertNulls; + function IfrxEngineOptions.Set_ConvertNulls = IfrxEngineOptions_Set_ConvertNulls; + function IfrxEngineOptions.Get_DestroyForms = IfrxEngineOptions_Get_DestroyForms; + function IfrxEngineOptions.Set_DestroyForms = IfrxEngineOptions_Set_DestroyForms; + function IfrxEngineOptions.Get_DoublePass = IfrxEngineOptions_Get_DoublePass; + function IfrxEngineOptions.Set_DoublePass = IfrxEngineOptions_Set_DoublePass; + function IfrxEngineOptions.Get_MaxMemSize = IfrxEngineOptions_Get_MaxMemSize; + function IfrxEngineOptions.Set_MaxMemSize = IfrxEngineOptions_Set_MaxMemSize; + function IfrxEngineOptions.Get_PrintIfEmpty = IfrxEngineOptions_Get_PrintIfEmpty; + function IfrxEngineOptions.Set_PrintIfEmpty = IfrxEngineOptions_Set_PrintIfEmpty; + function IfrxEngineOptions.Get_SilentMode = IfrxEngineOptions_Get_SilentMode; + function IfrxEngineOptions.Set_SilentMode = IfrxEngineOptions_Set_SilentMode; + function IfrxEngineOptions.Get_TempDir = IfrxEngineOptions_Get_TempDir; + function IfrxEngineOptions.Set_TempDir = IfrxEngineOptions_Set_TempDir; + function IfrxEngineOptions.Get_UseFilecache = IfrxEngineOptions_Get_UseFilecache; + function IfrxEngineOptions.Set_UseFilecache = IfrxEngineOptions_Set_UseFilecache; + + function IfrxEngineOptions_Get_ConvertNulls(out Value: WordBool): HResult; stdcall; + function IfrxEngineOptions_Set_ConvertNulls(Value: WordBool): HResult; stdcall; + function IfrxEngineOptions_Get_DestroyForms(out Value: WordBool): HResult; stdcall; + function IfrxEngineOptions_Set_DestroyForms(Value: WordBool): HResult; stdcall; + function IfrxEngineOptions_Get_DoublePass(out Value: WordBool): HResult; stdcall; + function IfrxEngineOptions_Set_DoublePass(Value: WordBool): HResult; stdcall; + function IfrxEngineOptions_Get_MaxMemSize(out Value: SYSINT): HResult; stdcall; + function IfrxEngineOptions_Set_MaxMemSize(Value: SYSINT): HResult; stdcall; + function IfrxEngineOptions_Get_PrintIfEmpty(out Value: WordBool): HResult; stdcall; + function IfrxEngineOptions_Set_PrintIfEmpty(Value: WordBool): HResult; stdcall; + function IfrxEngineOptions_Get_SilentMode(out Value: frxSilentMode): HResult; stdcall; + function IfrxEngineOptions_Set_SilentMode(Value: frxSilentMode): HResult; stdcall; + function IfrxEngineOptions_Get_TempDir(out Value: WideString): HResult; stdcall; + function IfrxEngineOptions_Set_TempDir(const Value: WideString): HResult; stdcall; + function IfrxEngineOptions_Get_UseFilecache(out Value: WordBool): HResult; stdcall; + function IfrxEngineOptions_Set_UseFilecache(Value: WordBool): HResult; stdcall; +{$ENDIF} + end; + +{$IFDEF FR_COM} + TfrxPrintOptions = class(TDispatchablePersistent, IfrxPrintOptions) +{$ELSE} + TfrxPrintOptions = class(TPersistent) +{$ENDIF} + private + FCopies: Integer; + FCollate: Boolean; + FPageNumbers: String; + FPagesOnSheet: Integer; + FPrinter: String; + FPrintMode: TfrxPrintMode; + FPrintOnSheet: Integer; + FPrintPages: TfrxPrintPages; + FReverse: Boolean; + FShowDialog: Boolean; +{$IFDEF FR_COM} + protected + { IfrxPrintOptions } + function IfrxPrintOptions.Get_Copies = IfrxPrintOptions_Get_Copies; + function IfrxPrintOptions.Set_Copies = IfrxPrintOptions_Set_Copies; + function IfrxPrintOptions.Get_Collate = IfrxPrintOptions_Get_Collate; + function IfrxPrintOptions.Set_Collate = IfrxPrintOptions_Set_Collate; + function IfrxPrintOptions.Get_PageNumbers = IfrxPrintOptions_Get_PageNumbers; + function IfrxPrintOptions.Set_PageNumbers = IfrxPrintOptions_Set_PageNumbers; + function IfrxPrintOptions.Get_Printer = IfrxPrintOptions_Get_Printer; + function IfrxPrintOptions.Set_Printer = IfrxPrintOptions_Set_Printer; + function IfrxPrintOptions.Get_PrintPages = IfrxPrintOptions_Get_PrintPages; + function IfrxPrintOptions.Set_PrintPages = IfrxPrintOptions_Set_PrintPages; + function IfrxPrintOptions.Get_Reverse = IfrxPrintOptions_Get_Reverse; + function IfrxPrintOptions.Set_Reverse = IfrxPrintOptions_Set_Reverse; + function IfrxPrintOptions.Get_ShowDialog = IfrxPrintOptions_Get_ShowDialog; + function IfrxPrintOptions.Set_ShowDialog = IfrxPrintOptions_Set_ShowDialog; + + function IfrxPrintOptions_Get_Copies(out Value: SYSINT): HResult; stdcall; + function IfrxPrintOptions_Set_Copies(Value: SYSINT): HResult; stdcall; + function IfrxPrintOptions_Get_Collate(out Value: WordBool): HResult; stdcall; + function IfrxPrintOptions_Set_Collate(Value: WordBool): HResult; stdcall; + function IfrxPrintOptions_Get_PageNumbers(out Value: WideString): HResult; stdcall; + function IfrxPrintOptions_Set_PageNumbers(const Value: WideString): HResult; stdcall; + function IfrxPrintOptions_Get_Printer(out Value: WideString): HResult; stdcall; + function IfrxPrintOptions_Set_Printer(const Value: WideString): HResult; stdcall; + function IfrxPrintOptions_Get_PrintPages(out Value: frxPrintPages): HResult; stdcall; + function IfrxPrintOptions_Set_PrintPages(Value: frxPrintPages): HResult; stdcall; + function IfrxPrintOptions_Get_Reverse(out Value: WordBool): HResult; stdcall; + function IfrxPrintOptions_Set_Reverse(Value: WordBool): HResult; stdcall; + function IfrxPrintOptions_Get_ShowDialog(out Value: WordBool): HResult; stdcall; + function IfrxPrintOptions_Set_ShowDialog(Value: WordBool): HResult; stdcall; +{$ENDIF} + public + constructor Create; +{$IFDEF FR_COM} + destructor Destroy; override; +{$ENDIF} + procedure Assign(Source: TPersistent); override; + procedure Clear; + published + property Copies: Integer read FCopies write FCopies default 1; + property Collate: Boolean read FCollate write FCollate default True; + property PageNumbers: String read FPageNumbers write FPageNumbers; + property Printer: String read FPrinter write FPrinter; + property PrintMode: TfrxPrintMode read FPrintMode write FPrintMode default pmDefault; + property PrintOnSheet: Integer read FPrintOnSheet write FPrintOnSheet; + property PrintPages: TfrxPrintPages read FPrintPages write FPrintPages default ppAll; + property Reverse: Boolean read FReverse write FReverse default False; + property ShowDialog: Boolean read FShowDialog write FShowDialog default True; + end; + +{$IFDEF FR_COM} + TfrxPreviewOptions = class(TDispatchablePersistent, IfrxPreviewOptions) +{$ELSE} + TfrxPreviewOptions = class(TPersistent) +{$ENDIF} + private + FAllowEdit: Boolean; + FButtons: TfrxPreviewButtons; + FDoubleBuffered: Boolean; + FMaximized: Boolean; + FMDIChild: Boolean; + FModal: Boolean; + FOutlineExpand: Boolean; + FOutlineVisible: Boolean; + FOutlineWidth: Integer; + FPagesInCache: Integer; + FShowCaptions: Boolean; + FThumbnailVisible: Boolean; + FZoom: Extended; + FZoomMode: TfrxZoomMode; + public + constructor Create; + procedure Assign(Source: TPersistent); override; + procedure Clear; + published + property AllowEdit: Boolean read FAllowEdit write FAllowEdit default True; + property Buttons: TfrxPreviewButtons read FButtons write FButtons; + property DoubleBuffered: Boolean read FDoubleBuffered write FDoubleBuffered default True; + property Maximized: Boolean read FMaximized write FMaximized default True; + property MDIChild: Boolean read FMDIChild write FMDIChild default False; + property Modal: Boolean read FModal write FModal default True; + property OutlineExpand: Boolean read FOutlineExpand write FOutlineExpand default True; + property OutlineVisible: Boolean read FOutlineVisible write FOutlineVisible default False; + property OutlineWidth: Integer read FOutlineWidth write FOutlineWidth default 120; + property PagesInCache: Integer read FPagesInCache write FPagesInCache default 50; + property ThumbnailVisible: Boolean read FThumbnailVisible write FThumbnailVisible default False; + property ShowCaptions: Boolean read FShowCaptions write FShowCaptions default False; + property Zoom: Extended read FZoom write FZoom; + property ZoomMode: TfrxZoomMode read FZoomMode write FZoomMode default zmDefault; +{$IFDEF FR_COM} + { IfrxPreviewOptions } + function IfrxPreviewOptions.Get_AllowEdit = IfrxPreviewOptions_Get_AllowEdit; + function IfrxPreviewOptions.Set_AllowEdit = IfrxPreviewOptions_Set_AllowEdit; + function IfrxPreviewOptions.Get_Buttons = IfrxPreviewOptions_Get_Buttons; + function IfrxPreviewOptions.Set_Buttons = IfrxPreviewOptions_Set_Buttons; + function IfrxPreviewOptions.Get_DoubleBuffered = IfrxPreviewOptions_Get_DoubleBuffered; + function IfrxPreviewOptions.Set_DoubleBuffered = IfrxPreviewOptions_Set_DoubleBuffered; + function IfrxPreviewOptions.Get_Maximized = IfrxPreviewOptions_Get_Maximazed; + function IfrxPreviewOptions.Set_Maximized = IfrxPreviewOptions_Set_Maximazed; + function IfrxPreviewOptions.Get_MDIChild = IfrxPreviewOptions_Get_MDIChild; + function IfrxPreviewOptions.Set_MDIChild = IfrxPreviewOptions_Set_MDIChild; + function IfrxPreviewOptions.Get_Modal = IfrxPreviewOptions_Get_Modal; + function IfrxPreviewOptions.Set_Modal = IfrxPreviewOptions_Set_Modal; + function IfrxPreviewOptions.Get_OutlineExpand = IfrxPreviewOptions_Get_OutlineExpand; + function IfrxPreviewOptions.Set_OutlineExpand = IfrxPreviewOptions_Set_OutlineExpand; + function IfrxPreviewOptions.Get_OutlineVisible = IfrxPreviewOptions_Get_OutlineVisible; + function IfrxPreviewOptions.Set_OutlineVisible = IfrxPreviewOptions_Set_OutlineVisible; + function IfrxPreviewOptions.Get_OutlineWidth = IfrxPreviewOptions_Get_OutlineWidth; + function IfrxPreviewOptions.Set_OutlineWidth = IfrxPreviewOptions_Set_OutlineWidth; + function IfrxPreviewOptions.Get_ShowCaptions = IfrxPreviewOptions_Get_ShowCaptions; + function IfrxPreviewOptions.Set_ShowCaptions = IfrxPreviewOptions_Set_ShowCaptions; + function IfrxPreviewOptions.Get_Zoom = IfrxPreviewOptions_Get_Zoom; + function IfrxPreviewOptions.Set_Zoom = IfrxPreviewOptions_Set_Zoom; + function IfrxPreviewOptions.Get_ZoomMode = IfrxPreviewOptions_Get_ZoomMode; + function IfrxPreviewOptions.Set_ZoomMode = IfrxPreviewOptions_Set_ZoomMode; + + function IfrxPreviewOptions_Get_AllowEdit(out Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Set_AllowEdit(Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Get_Buttons(out Value: frxPreviewButtons): HResult; stdcall; + function IfrxPreviewOptions_Set_Buttons(Value: frxPreviewButtons): HResult; stdcall; + function IfrxPreviewOptions_Get_DoubleBuffered(out Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Set_DoubleBuffered(Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Get_Maximazed(out Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Set_Maximazed(Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Get_MDIChild(out Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Set_MDIChild(Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Get_Modal(out Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Set_Modal(Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Get_OutlineExpand(out Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Set_OutlineExpand(Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Get_OutlineVisible(out Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Set_OutlineVisible(Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Get_OutlineWidth(out Value: SYSINT): HResult; stdcall; + function IfrxPreviewOptions_Set_OutlineWidth(Value: SYSINT): HResult; stdcall; + function IfrxPreviewOptions_Get_ShowCaptions(out Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Set_ShowCaptions(Value: WordBool): HResult; stdcall; + function IfrxPreviewOptions_Get_Zoom(out Value: Double): HResult; stdcall; + function IfrxPreviewOptions_Set_Zoom(Value: Double): HResult; stdcall; + function IfrxPreviewOptions_Get_ZoomMode(out Value: frxZoomMode): HResult; stdcall; + function IfrxPreviewOptions_Set_ZoomMode(Value: frxZoomMode): HResult; stdcall; +{$ENDIF} + end; + +{$IFDEF FR_COM} + TfrxReportOptions = class(TDispatchablePersistent, IfrxReportOptions) +{$ELSE} + TfrxReportOptions = class(TPersistent) +{$ENDIF} + private + FAuthor: String; + FCompressed: Boolean; + FConnectionName: String; + FCreateDate: TDateTime; + FDescription: TStrings; + FInitString: String; + FName: String; + FLastChange: TDateTime; + FPassword: String; + FPicture: TPicture; + FReport: TfrxReport; + FVersionBuild: String; + FVersionMajor: String; + FVersionMinor: String; + FVersionRelease: String; + FPrevPassword: String; + FInfo: Boolean; + procedure SetDescription(const Value: TStrings); + procedure SetPicture(const Value: TPicture); + procedure SetConnectionName(const Value: String); + public + constructor Create(AOwner: TComponent); + destructor Destroy; override; + procedure Assign(Source: TPersistent); override; + procedure Clear; + function CheckPassword: Boolean; + property PrevPassword: String write FPrevPassword; + property Info: Boolean read FInfo write FInfo; + published + property Author: String read FAuthor write FAuthor; + property Compressed: Boolean read FCompressed write FCompressed default False; + property ConnectionName: String read FConnectionName write SetConnectionName; + property CreateDate: TDateTime read FCreateDate write FCreateDate; + property Description: TStrings read FDescription write SetDescription; + property InitString: String read FInitString write FInitString; + property Name: String read FName write FName; + property LastChange: TDateTime read FLastChange write FLastChange; + property Password: String read FPassword write FPassword; + property Picture: TPicture read FPicture write SetPicture; + property VersionBuild: String read FVersionBuild write FVersionBuild; + property VersionMajor: String read FVersionMajor write FVersionMajor; + property VersionMinor: String read FVersionMinor write FVersionMinor; + property VersionRelease: String read FVersionRelease write FVersionRelease; +{$IFDEF FR_COM} + {IfrxReportOptions} + function IfrxReportOptions.Get_Author = IfrxReportOptions_Get_Author; + function IfrxReportOptions.Set_Author = IfrxReportOptions_Set_Author; + function IfrxReportOptions.Get_Compressed = IfrxReportOptions_Get_Compressed; + function IfrxReportOptions.Set_Compressed = IfrxReportOptions_Set_Compressed; + function IfrxReportOptions.Get_ConnectionName = IfrxReportOptions_Get_ConnectionName; + function IfrxReportOptions.Set_ConnectionName = IfrxReportOptions_Set_ConnectionName; + function IfrxReportOptions.Get_CreationDate = IfrxReportOptions_Get_CreationDate; + function IfrxReportOptions.Set_CreationDate = IfrxReportOptions_Set_CreationDate; + function IfrxReportOptions.Get_Description = IfrxReportOptions_Get_Description; + function IfrxReportOptions.Set_Description = IfrxReportOptions_Set_Description; + function IfrxReportOptions.Get_InitString = IfrxReportOptions_Get_InitString; + function IfrxReportOptions.Set_InitString = IfrxReportOptions_Set_InitString; + function IfrxReportOptions.Get_Name = IfrxReportOptions_Get_Name; + function IfrxReportOptions.Set_Name = IfrxReportOptions_Set_Name; + function IfrxReportOptions.Get_LastChange = IfrxReportOptions_Get_LastChange; + function IfrxReportOptions.Set_LastChange = IfrxReportOptions_Set_LastChange; + function IfrxReportOptions.Get_Password = IfrxReportOptions_Get_Password; + function IfrxReportOptions.Set_Password = IfrxReportOptions_Set_Password; + function IfrxReportOptions.Get_Picture = IfrxReportOptions_Get_Picture; + function IfrxReportOptions.Set_Picture = IfrxReportOptions_Set_Picture; + function IfrxReportOptions.Get_VersionBuild = IfrxReportOptions_Get_VersionBuild; + function IfrxReportOptions.Set_VersionBuild = IfrxReportOptions_Set_VersionBuild; + function IfrxReportOptions.Get_VersionMajor = IfrxReportOptions_Get_VersionMajor; + function IfrxReportOptions.Set_VersionMajor = IfrxReportOptions_Set_VersionMajor; + function IfrxReportOptions.Get_VersionMinor = IfrxReportOptions_Get_VersionMinor; + function IfrxReportOptions.Set_VersionMinor = IfrxReportOptions_Set_VersionMinor; + function IfrxReportOptions.Get_VersionRelease = IfrxReportOptions_Get_VersionRelease; + function IfrxReportOptions.Set_VersionRelease = IfrxReportOptions_Set_VersionRelease; + + function IfrxReportOptions_Get_Author(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_Author(const Value: WideString): HResult; stdcall; + function IfrxReportOptions_Get_Compressed(out Value: WordBool): HResult; stdcall; + function IfrxReportOptions_Set_Compressed(Value: WordBool): HResult; stdcall; + function IfrxReportOptions_Get_ConnectionName(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_ConnectionName(const Value: WideString): HResult; stdcall; + function IfrxReportOptions_Get_CreationDate(out Value: TDateTime): HResult; stdcall; + function IfrxReportOptions_Set_CreationDate(Value: TDateTime): HResult; stdcall; + function IfrxReportOptions_Get_Description(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_Description(const Value: WideString): HResult; stdcall; + function IfrxReportOptions_Get_InitString(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_InitString(const Value: WideString): HResult; stdcall; + function IfrxReportOptions_Get_Name(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_Name(const Value: WideString): HResult; stdcall; + function IfrxReportOptions_Get_LastChange(out Value: TDateTime): HResult; stdcall; + function IfrxReportOptions_Set_LastChange(Value: TDateTime): HResult; stdcall; + function IfrxReportOptions_Get_Password(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_Password(const Value: WideString): HResult; stdcall; + function IfrxReportOptions_Get_Picture(out Value: IUnknown): HResult; stdcall; + function IfrxReportOptions_Set_Picture(const Value: IUnknown): HResult; stdcall; + function IfrxReportOptions_Get_VersionBuild(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_VersionBuild(const Value: WideString): HResult; stdcall; + function IfrxReportOptions_Get_VersionMajor(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_VersionMajor(const Value: WideString): HResult; stdcall; + function IfrxReportOptions_Get_VersionMinor(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_VersionMinor(const Value: WideString): HResult; stdcall; + function IfrxReportOptions_Get_VersionRelease(out Value: WideString): HResult; stdcall; + function IfrxReportOptions_Set_VersionRelease(const Value: WideString): HResult; stdcall; +{$ENDIF} + end; + + + TfrxExpressionCache = class(TObject) + private + FExpressions: TStringList; + FMainScript: TfsScript; + FScript: TfsScript; + FScriptLanguage: String; + public + constructor Create(AScript: TfsScript); + destructor Destroy; override; + procedure Clear; + function Calc(const Expression: String; var ErrorMsg: String; + AScript: TfsScript): Variant; + end; + + TfrxDataSetItem = class(TCollectionItem) + private + FDataSet: TfrxDataSet; + FDataSetName: String; + procedure SetDataSet(const Value: TfrxDataSet); + procedure SetDataSetName(const Value: String); + function GetDataSetName: String; + published + property DataSet: TfrxDataSet read FDataSet write SetDataSet; + property DataSetName: String read GetDataSetName write SetDataSetName; + end; + + TfrxReportDataSets = class(TCollection) + private + FReport: TfrxReport; + function GetItem(Index: Integer): TfrxDataSetItem; + public + constructor Create(AReport: TfrxReport); + procedure Initialize; + procedure Finalize; + procedure Add(ds: TfrxDataSet); + function Find(ds: TfrxDataSet): TfrxDataSetItem; overload; + function Find(const Name: String): TfrxDataSetItem; overload; + procedure Delete(const Name: String); overload; + property Items[Index: Integer]: TfrxDataSetItem read GetItem; default; + end; + + TfrxStyleItem = class(TCollectionItem) + private + FName: String; + FColor: TColor; + FFont: TFont; + FFrame: TfrxFrame; + procedure SetFont(const Value: TFont); + procedure SetFrame(const Value: TfrxFrame); + procedure SetName(const Value: String); + public + constructor Create(Collection: TCollection); override; + destructor Destroy; override; + procedure Assign(Source: TPersistent); override; + procedure CreateUniqueName; + published + property Name: String read FName write SetName; + property Color: TColor read FColor write FColor; + property Font: TFont read FFont write SetFont; + property Frame: TfrxFrame read FFrame write SetFrame; + end; + + TfrxStyles = class(TCollection) + private + FName: String; + FReport: TfrxReport; + function GetItem(Index: Integer): TfrxStyleItem; + public + constructor Create(AReport: TfrxReport); + function Add: TfrxStyleItem; + function Find(const Name: String): TfrxStyleItem; + procedure Apply; + procedure GetList(List: TStrings); + procedure LoadFromFile(const FileName: String); + procedure LoadFromStream(Stream: TStream); + procedure LoadFromXMLItem(Item: TfrxXMLItem); + procedure SaveToFile(const FileName: String); + procedure SaveToStream(Stream: TStream); + procedure SaveToXMLItem(Item: TfrxXMLItem); + property Items[Index: Integer]: TfrxStyleItem read GetItem; default; + property Name: String read FName write FName; + end; + + TfrxStyleSheet = class(TObject) + private + FItems: TList; + function GetItems(Index: Integer): TfrxStyles; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + procedure Delete(Index: Integer); + procedure GetList(List: TStrings); + procedure LoadFromFile(const FileName: String); + procedure LoadFromStream(Stream: TStream); + procedure SaveToFile(const FileName: String); + procedure SaveToStream(Stream: TStream); + function Add: TfrxStyles; + function Count: Integer; + function Find(const Name: String): TfrxStyles; + function IndexOf(const Name: String): Integer; + property Items[Index: Integer]: TfrxStyles read GetItems; default; + end; + +{$IFDEF FR_COM} + TfrxReport = class(TfrxComponent, IfrxReport, IfrxBuiltinExports, IConnectionPointContainer) + FConnectionPoints: TConnectionPoints; + FConnectionPoint: TConnectionPoint; + FEvent: IfrxReportEvents; + private + FUseDispatchableEvents: Boolean; +{$ELSE} + TfrxReport = class(TfrxComponent) + private +{$ENDIF} + FCurObject: String; + FDataSet: TfrxDataSet; + FDataSetName: String; + FDataSets: TfrxReportDatasets; + FDesigner: TfrxCustomDesigner; + FDotMatrixReport: Boolean; + FDrawText: Pointer; + FDrillState: TStrings; + FEnabledDataSets: TfrxReportDataSets; + FEngine: TfrxCustomEngine; + FEngineOptions: TfrxEngineOptions; + FErrors: TStrings; + FExpressionCache: TfrxExpressionCache; + FFileName: String; + FIniFile: String; + FLoadStream: TStream; + FLocalValue: TfsCustomVariable; + FModified: Boolean; + FOldStyleProgress: Boolean; + FParentForm: TForm; + FParentReport: String; + FParentReportObject: TfrxReport; + FPreviewPages: TfrxCustomPreviewPages; + FPreview: TfrxCustomPreview; + FPreviewForm: TForm; + FPreviewOptions: TfrxPreviewOptions; + FPrintOptions: TfrxPrintOptions; + FProgress: TfrxProgress; + FReloading: Boolean; + FReportOptions: TfrxReportOptions; + FScript: TfsScript; + FScriptLanguage: String; + FScriptText: TStrings; + FShowProgress: Boolean; + FStoreInDFM: Boolean; + FStyles: TfrxStyles; + FSysVariables: TStrings; + FTerminated: Boolean; + FTimer: TTimer; + FVariables: TfrxVariables; + FVersion: String; + FXMLSerializer: TObject; + + FOnAfterPrint: TfrxBeforePrintEvent; + FOnAfterPrintReport: TNotifyEvent; + FOnBeforeConnect: TfrxBeforeConnectEvent; + FOnBeforePrint: TfrxBeforePrintEvent; + FOnBeginDoc: TNotifyEvent; + FOnClickObject: TfrxClickObjectEvent; + FOnEditConnection: TfrxEditConnectionEvent; + FOnEndDoc: TNotifyEvent; + FOnGetValue: TfrxGetValueEvent; + FOnLoadTemplate: TfrxLoadTemplateEvent; + FOnManualBuild: TfrxManualBuildEvent; + FOnMouseOverObject: TfrxMouseOverObjectEvent; + FOnPreview: TNotifyEvent; + FOnPrintPage: TfrxPrintPageEvent; + FOnPrintReport: TNotifyEvent; + FOnProgressStart: TfrxProgressEvent; + FOnProgress: TfrxProgressEvent; + FOnProgressStop: TfrxProgressEvent; + FOnRunDialogs: TfrxRunDialogsEvent; + FOnSetConnection: TfrxSetConnectionEvent; + FOnStartReport: TfrxNotifyEvent; + FOnStopReport: TfrxNotifyEvent; + FOnUserFunction: TfrxUserFunctionEvent; + FOnClosePreview: TNotifyEvent; + + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant; + function DoGetValue(const Expr: String; var Value: Variant): Boolean; + function GetScriptValue(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant; + function SetScriptValue(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant; + function DoUserFunction(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant; + function GetDataSetName: String; + function GetLocalValue: Variant; + function GetPages(Index: Integer): TfrxPage; + function GetPagesCount: Integer; + procedure AncestorNotFound(Reader: TReader; const ComponentName: string; + ComponentClass: TPersistentClass; var Component: TComponent); + procedure DoClear; + procedure DoGetAncestor(const Name: String; var Ancestor: TPersistent); + procedure DoLoadFromStream; + procedure OnTimer(Sender: TObject); + procedure ReadDatasets(Reader: TReader); + procedure ReadStyle(Reader: TReader); + procedure ReadVariables(Reader: TReader); + procedure SetDataSet(const Value: TfrxDataSet); + procedure SetDataSetName(const Value: String); + procedure SetEngineOptions(const Value: TfrxEngineOptions); + procedure SetLocalValue(const Value: Variant); + procedure SetParentReport(const Value: String); + procedure SetPreviewOptions(const Value: TfrxPreviewOptions); + procedure SetPrintOptions(const Value: TfrxPrintOptions); + procedure SetReportOptions(const Value: TfrxReportOptions); + procedure SetScriptText(const Value: TStrings); + procedure SetStyles(const Value: TfrxStyles); + procedure SetTerminated(const Value: Boolean); + procedure WriteDatasets(Writer: TWriter); + procedure WriteStyle(Writer: TWriter); + procedure WriteVariables(Writer: TWriter); + procedure SetPreview(const Value: TfrxCustomPreview); + procedure SetVersion(const Value: String); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure DefineProperties(Filer: TFiler); override; +{$IFDEF FR_COM} + public +// + procedure EventSinkChanged(const Sink: IUnknown; Connecting: Boolean); + + procedure OnSetConnectionHandler(const ConnString: String); + function OnEditConnectionHandler(const ConnString: String): String; + + { COM proxy event functions } + procedure OnAfterPrintHandler(Sender: TfrxReportComponent); + procedure OnBeforePrintHandler(Sender: TfrxReportComponent); + procedure OnClickObjectHandler(Sender: TfrxView; Button: TMouseButton; Shift: TShiftState; var Modified: Boolean); + function OnUserFunctionHandler(const MethodName: String; var Params: Variant): Variant; + procedure OnBeforeConnectHandler(Sender: TfrxCustomDatabase; var Connected: Boolean); + + procedure OnBeginDocHandler(Sender: TObject); + procedure OnEndDocHandler(Sender: TObject); + procedure OnPrintReportHandler(Sender: TObject); + procedure OnAfterPrintReportHandler(Sender: TObject); + procedure OnProgressHandler(Sender: TfrxReport; ProgressType: TfrxProgressType; Progress: Integer); + procedure OnProgressStartHandler(Sender: TfrxReport; ProgressType: TfrxProgressType; Progress: Integer); + procedure OnProgressStopHandler(Sender: TfrxReport; ProgressType: TfrxProgressType; Progress: Integer); + procedure OnRunDialogsEvent(Page: TfrxDialogPage); + + {IfrxReport} + function LoadReportFromFile(const szFileName: WideString): HResult; stdcall; + function SaveReportToFile(const FileName: WideString): HResult; stdcall; + function LoadReportFromStream(const Stream: IUnknown): HResult; stdcall; + function SaveReportToStream(const Stream: IUnknown): HResult; stdcall; + + function LoadPreparedReportFromFile(const szFileName: WideString): HResult; stdcall; + function SavePreparedReportToFile(const szFileName: WideString): HResult; stdcall; + function ClearReport: HResult; stdcall; + function PrintReport: HResult; stdcall; + function ExportReport(const Filter: IfrxCustomExportFilter): HResult; stdcall; + + function Get_Errors(out Value: WideString): HResult; stdcall; + function Get_PreviewPages(out Value: IfrxCustomPreviewPages): HResult; stdcall; + function Get_ReportOptions(out Value: IfrxReportOptions): HResult; stdcall; + function Get_PreviewOptions(out Value: IfrxPreviewOptions): HResult; stdcall; + function Get_EngineOptions(out Value: IfrxEngineOptions): HResult; stdcall; + function Get_PrintOptions(out Value: IfrxPrintOptions): HResult; stdcall; + function Get_ScriptLanguage(out Value: WideString): HResult; stdcall; + function Set_ScriptLanguage(const Value: WideString): HResult; stdcall; + function Get_ScriptText(out Value: WideString): HResult; stdcall; + function Set_ScriptText(const Value: WideString): HResult; stdcall; + function Get_DisableDialogs(out Value: WordBool): HResult; stdcall; + function Set_DisableDialogs(Value: WordBool): HResult; stdcall; + function SetVariable(const Index: WideString; Value: OleVariant): HResult; stdcall; + function GetVariable(const Index: WideString; out Value: OleVariant): HResult; stdcall; + function AddVariable(const Category: WideString; const Name: WideString; Value: OleVariant): HResult; stdcall; + function DeleteCategory(const Name: WideString): HResult; stdcall; + function DeleteVariable(const Name: WideString): HResult; stdcall; + function SelectDataset(Selected: WordBool; const DataSet: IfrxDataSet): HResult; stdcall; + function LoadLanguageResourcesFromFile(const FileName: WideString): HResult; stdcall; + function GetResourceString(const ID: WideString; out ResourceString_: WideString): HResult; stdcall; + function Set_MainWindowHandle(Value: Integer): HResult; stdcall; + function Set_ShowProgress(Value: WordBool): HResult; stdcall; + function CreateReportObject(const ParentObject: IfrxComponent; ObjectType: TGUID; + const Name: WideString; out GeneratedObject: IfrxComponent): HResult; stdcall; + function SavePreparedReportToStream(const Stream: IUnknown): HResult; stdcall; + function Get_Resources(out Value: IfrxResources): HResult; stdcall; + function AddFunction(const FuncName: WideString; const Category: WideString; + const Description: WideString): HResult; stdcall; + function Get_Version(out Value: WideString): HResult; stdcall; + function BindObject(const Value: IfrxPlugin): HResult; stdcall; + function Get_Page(Index: Integer; out Value: IfrxPage): HResult; stdcall; + function Get_PagesCount(out Value: Integer): HResult; stdcall; + function CreateReportObjectEx(const ParentObject: IfrxComponent; const ObjectType: WideString; + const Name: WideString; out GeneratedObject: IfrxComponent): HResult; stdcall; + + function ClearDatasets: HResult; stdcall; + function FindCOMObject(const ObjectName: WideString; out Obj: IfrxComponent): HResult; stdcall; + function FindObjectEx(const ObjectName: WideString; out Obj: IfrxComponent): HResult; stdcall; + function IfrxReport.FindObject = FindCOMObject; + function Get_OldStyleProgress(out Value: WordBool): HResult; stdcall; + function Set_OldStyleProgress(Value: WordBool): HResult; stdcall; + function Get_Engine(out Value: IfrxCustomEngine): HResult; stdcall; + function Get_Script(out Value: IfsScript): HResult; stdcall; + function Get_Print(out Value: WordBool): HResult; stdcall; + function Set_UseDispatchableEvents(Value: WordBool): HResult; stdcall; + function Get_FileName(out Value: WideString): HResult; stdcall; + function Set_FileName(const Value: WideString): HResult; stdcall; + function Set_Terminated(Value: WordBool): HResult; stdcall; + {IfrxBuiltinExports} + function ExportToPDF(const FileName: WideString; Compressed, EmbeddedFonts, PrintOptimized: WordBool): HResult; stdcall; + function ExportToBMP(const FileName: WideString; Resolution: SYSINT; Monochrome, CropPages, SeparatePages: WordBool): HResult; stdcall; + function ExportToHTML(const FileName: WideString; Pictures, FixedWidth, Multipage, Navigator, PicsInSameFolder, Background: WordBool): HResult; stdcall; + function ExportToRTF(const FileName: WideString; Pictures, PageBreaks, WYSIWYG: WordBool): HResult; stdcall; + function ExportToTXT(const FileName: WideString; PageBreaks: WordBool; Frames: WordBool; + OEMCodepage: WordBool; EmptyLines: WordBool): HResult; stdcall; + function ExportToXLS(const szFileName: WideString; Pictures, PageBreaks, WYSIWYG, AsText, Background: WordBool): HResult; stdcall; + function ExportToXML(const FileName: WideString; Styles, PageBreaks, WYSIWYG, Background: WordBool): HResult; stdcall; + function ExportToJPEG(const FileName: WideString; Resolution, JpegQuality: SYSINT; Monochrome, CropPages, SeparatePages: WordBool): HResult; stdcall; + function ExportToTIFF(const FileName: WideString; Resolution: SYSINT; Monochrome, CropPages, SeparatePages: WordBool): HResult; stdcall; + function ExportToCSV(const FileName: WideString; const Separator: WideString; OEMCodepage: WordBool): HResult; stdcall; + function ExportToGIF(const FileName: WideString; Resolution: SYSINT; Monochrome, CropPages, SeparatePages: WordBool): HResult; stdcall; + function SendMail(const Server: WideString; Port: SYSINT; const User: WideString; + const Password: WideString; const From: WideString; const To_: WideString; + const Subject: WideString; const Text: WideString; + const FileName: WideString; const AttachName: WideString): HResult; stdcall; + function ExportToDMP(const FileName: WideString): HResult; stdcall; + + {IConnectionPointContainer} + property ConnectionPoints: TConnectionPoints read FConnectionPoints implements IConnectionPointContainer; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Clear; override; + class function GetDescription: String; override; + + { internal methods } + function Calc(const Expr: String; AScript: TfsScript = nil): Variant; + function DesignPreviewPage: Boolean; + function GetAlias(DataSet: TfrxDataSet): String; + function GetDataset(const Alias: String): TfrxDataset; + function GetIniFile: TCustomIniFile; + function GetApplicationFolder: String; + function PrepareScript: Boolean; + function InheritFromTemplate(const templName: String): Boolean; + procedure DesignReport(IDesigner: IUnknown; Editor: TObject); overload; + procedure DoNotifyEvent(Obj: TObject; const EventName: String; + RunAlways: Boolean = False); + procedure DoParamEvent(const EventName: String; var Params: Variant; + RunAlways: Boolean = False); + procedure DoAfterPrint(c: TfrxReportComponent); + procedure DoBeforePrint(c: TfrxReportComponent); + procedure DoPreviewClick(v: TfrxView; Button: TMouseButton; + Shift: TShiftState; var Modified: Boolean); + procedure GetDatasetAndField(const ComplexName: String; + var Dataset: TfrxDataset; var Field: String); + procedure GetDataSetList(List: TStrings; OnlyDB: Boolean = False); + procedure InternalOnProgressStart(ProgressType: TfrxProgressType); virtual; + procedure InternalOnProgress(ProgressType: TfrxProgressType; Progress: Integer); virtual; + procedure InternalOnProgressStop(ProgressType: TfrxProgressType); virtual; + procedure SelectPrinter; + procedure SetProgressMessage(const Value: String); + procedure CheckDataPage; + + { public methods } + function LoadFromFile(const FileName: String; + ExceptionIfNotFound: Boolean = False): Boolean; + procedure LoadFromStream(Stream: TStream); override; + procedure SaveToFile(const FileName: String); + procedure SaveToStream(Stream: TStream; SaveChildren: Boolean = True; + SaveDefaultValues: Boolean = False); override; +{$IFNDEF FR_COM} + procedure DesignReport(Modal: Boolean = True; MDIChild: Boolean = False); overload; stdcall; + function PrepareReport(ClearLastReport: Boolean = True): Boolean; + procedure ShowPreparedReport; stdcall; + procedure ShowReport(ClearLastReport: Boolean = True); stdcall; + procedure AddFunction(const FuncName: String; const Category: String = ''; + const Description: String = ''); +{$ELSE} + function DesignReport: HResult; overload; stdcall; + function DesignReportEx(Modal: WordBool; MDIChild: WordBool; ParentWindowHandle: Integer): HResult; stdcall; + function ShowReport: HResult; stdcall; + function PrepareReport(ClearLastReport: WordBool = True): HResult; stdcall; + function ShowPreparedReport: HResult; stdcall; + +{$ENDIF} + procedure DesignReportInPanel(Panel: TWinControl); + function Print: Boolean; stdcall; + function Export(Filter: TfrxCustomExportFilter): Boolean; + + { internals } + property CurObject: String read FCurObject write FCurObject; + property DrillState: TStrings read FDrillState; + property LocalValue: Variant read GetLocalValue write SetLocalValue; + property PreviewForm: TForm read FPreviewForm; + property XMLSerializer: TObject read FXMLSerializer; + property Reloading: Boolean read FReloading write FReloading; + + { public } + property DataSets: TfrxReportDataSets read FDataSets; + property Designer: TfrxCustomDesigner read FDesigner write FDesigner; + property EnabledDataSets: TfrxReportDataSets read FEnabledDataSets; + property Engine: TfrxCustomEngine read FEngine; + property Errors: TStrings read FErrors; + property FileName: String read FFileName write FFileName; + property Modified: Boolean read FModified write FModified; + property PreviewPages: TfrxCustomPreviewPages read FPreviewPages; + property Pages[Index: Integer]: TfrxPage read GetPages; + property PagesCount: Integer read GetPagesCount; + property Script: TfsScript read FScript; + property Styles: TfrxStyles read FStyles write SetStyles; + property Terminated: Boolean read FTerminated write SetTerminated; + property Variables: TfrxVariables read FVariables; + + property OnEditConnection: TfrxEditConnectionEvent read FOnEditConnection write FOnEditConnection; + property OnSetConnection: TfrxSetConnectionEvent read FOnSetConnection write FOnSetConnection; + published + property Version: String read FVersion write SetVersion; + property ParentReport: String read FParentReport write SetParentReport; + property DataSet: TfrxDataSet read FDataSet write SetDataSet; + property DataSetName: String read GetDataSetName write SetDataSetName; + property DotMatrixReport: Boolean read FDotMatrixReport write FDotMatrixReport; + property EngineOptions: TfrxEngineOptions read FEngineOptions write SetEngineOptions; + property IniFile: String read FIniFile write FIniFile; + property OldStyleProgress: Boolean read FOldStyleProgress write FOldStyleProgress default False; + property Preview: TfrxCustomPreview read FPreview write SetPreview; + property PreviewOptions: TfrxPreviewOptions read FPreviewOptions write SetPreviewOptions; + property PrintOptions: TfrxPrintOptions read FPrintOptions write SetPrintOptions; + property ReportOptions: TfrxReportOptions read FReportOptions write SetReportOptions; + property ScriptLanguage: String read FScriptLanguage write FScriptLanguage; + property ScriptText: TStrings read FScriptText write SetScriptText; + property ShowProgress: Boolean read FShowProgress write FShowProgress default True; + property StoreInDFM: Boolean read FStoreInDFM write FStoreInDFM default True; + + property OnAfterPrint: TfrxBeforePrintEvent read FOnAfterPrint write FOnAfterPrint; + property OnBeforeConnect: TfrxBeforeConnectEvent read FOnBeforeConnect write FOnBeforeConnect; + property OnBeforePrint: TfrxBeforePrintEvent read FOnBeforePrint write FOnBeforePrint; + property OnBeginDoc: TNotifyEvent read FOnBeginDoc write FOnBeginDoc; + property OnClickObject: TfrxClickObjectEvent read FOnClickObject write FOnClickObject; + property OnEndDoc: TNotifyEvent read FOnEndDoc write FOnEndDoc; + property OnGetValue: TfrxGetValueEvent read FOnGetValue write FOnGetValue; + property OnManualBuild: TfrxManualBuildEvent read FOnManualBuild write FOnManualBuild; + property OnMouseOverObject: TfrxMouseOverObjectEvent read FOnMouseOverObject + write FOnMouseOverObject; + property OnPreview: TNotifyEvent read FOnPreview write FOnPreview; + property OnPrintPage: TfrxPrintPageEvent read FOnPrintPage write FOnPrintPage; + property OnPrintReport: TNotifyEvent read FOnPrintReport write FOnPrintReport; + property OnAfterPrintReport: TNotifyEvent read FOnAfterPrintReport write FOnAfterPrintReport; + property OnProgressStart: TfrxProgressEvent read FOnProgressStart write FOnProgressStart; + property OnProgress: TfrxProgressEvent read FOnProgress write FOnProgress; + property OnProgressStop: TfrxProgressEvent read FOnProgressStop write FOnProgressStop; + property OnRunDialogs: TfrxRunDialogsEvent read FOnRunDialogs write FOnRunDialogs; + property OnStartReport: TfrxNotifyEvent read FOnStartReport write FOnStartReport; + property OnStopReport: TfrxNotifyEvent read FOnStopReport write FOnStopReport; + property OnUserFunction: TfrxUserFunctionEvent read FOnUserFunction write FOnUserFunction; + property OnLoadTemplate: TfrxLoadTemplateEvent read FOnLoadTemplate write FOnLoadTemplate; + property OnClosePreview: TNotifyEvent read FOnClosePreview write FOnClosePreview; + end; + + TfrxCustomDesigner = class(TForm) + private + FReport: TfrxReport; + FIsPreviewDesigner: Boolean; + FMemoFontName: String; + FMemoFontSize: Integer; + FUseObjectFont: Boolean; + protected + FModified: Boolean; + FObjects: TList; + FPage: TfrxPage; + FSelectedObjects: TList; + procedure SetModified(const Value: Boolean); virtual; + procedure SetPage(const Value: TfrxPage); virtual; + function GetCode: TStrings; virtual; abstract; + public + constructor CreateDesigner(AOwner: TComponent; AReport: TfrxReport; + APreviewDesigner: Boolean = False); + destructor Destroy; override; + function InsertExpression(const Expr: String): String; virtual; abstract; + procedure Lock; virtual; abstract; + procedure ReloadPages(Index: Integer); virtual; abstract; + procedure ReloadReport; virtual; abstract; + procedure UpdateDataTree; virtual; abstract; + procedure UpdatePage; virtual; abstract; + property IsPreviewDesigner: Boolean read FIsPreviewDesigner; + property Modified: Boolean read FModified write SetModified; + property Objects: TList read FObjects; + property Report: TfrxReport read FReport; + property SelectedObjects: TList read FSelectedObjects; + property Page: TfrxPage read FPage write SetPage; + property Code: TStrings read GetCode; + property UseObjectFont: Boolean read FUseObjectFont write FUseObjectFont; + property MemoFontName: String read FMemoFontName write FMemoFontName; + property MemoFontSize: Integer read FMemoFontSize write FMemoFontSize; + end; + + TfrxDesignerClass = class of TfrxCustomDesigner; + +{$IFDEF FR_COM} + TfrxCustomExportFilter = class(TComponent, IfrxCustomExportFilter) +{$ELSE} + TfrxCustomExportFilter = class(TComponent) +{$ENDIF} + private + FCurPage: Boolean; + FExportNotPrintable: Boolean; + FName: String; + FNoRegister: Boolean; + FPageNumbers: String; + FReport: TfrxReport; + FShowDialog: Boolean; + FStream: TStream; + FUseFileCache: Boolean; + FDefaultPath: String; + FSlaveExport: Boolean; + FShowProgress: Boolean; + FDefaultExt: String; + FFilterDesc: String; + FSuppressPageHeadersFooters: Boolean; + FTitle: String; + protected + public + constructor Create(AOwner: TComponent); override; + constructor CreateNoRegister; + destructor Destroy; override; + class function GetDescription: String; virtual; + function ShowModal: TModalResult; virtual; + function Start: Boolean; virtual; + procedure ExportObject(Obj: TfrxComponent); virtual; abstract; + procedure Finish; virtual; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); virtual; + procedure StartPage(Page: TfrxReportPage; Index: Integer); virtual; + + property CurPage: Boolean read FCurPage write FCurPage; + property PageNumbers: String read FPageNumbers write FPageNumbers; + property Report: TfrxReport read FReport write FReport; + property Stream: TStream read FStream write FStream; + property SlaveExport: Boolean read FSlaveExport write FSlaveExport; + property DefaultExt: String read FDefaultExt write FDefaultExt; + property FilterDesc: String read FFilterDesc write FFilterDesc; + property SuppressPageHeadersFooters: Boolean read FSuppressPageHeadersFooters + write FSuppressPageHeadersFooters; + property ExportTitle: String read FTitle write FTitle; + published + property ShowDialog: Boolean read FShowDialog write FShowDialog default True; + property FileName: String read FName write FName; + property ExportNotPrintable: Boolean read FExportNotPrintable write FExportNotPrintable default False; + property UseFileCache: Boolean read FUseFileCache write FUseFileCache; + property DefaultPath: String read FDefaultPath write FDefaultPath; + property ShowProgress: Boolean read FShowProgress write FShowProgress; + end; + + TfrxCustomWizard = class(TComponent) + private + FDesigner: TfrxCustomDesigner; + FReport: TfrxReport; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; virtual; + function Execute: Boolean; virtual; abstract; + property Designer: TfrxCustomDesigner read FDesigner; + property Report: TfrxReport read FReport; + end; + + TfrxWizardClass = class of TfrxCustomWizard; + +{$IFDEF FR_COM} + TfrxCustomEngine = class(TDispatchablePersistent, IfrxCustomEngine) +{$ELSE} + TfrxCustomEngine = class(TPersistent) +{$ENDIF} + private + FCurColumn: Integer; + FCurVColumn: Integer; + FCurLine: Integer; + FCurLineThrough: Integer; + FCurX: Extended; + FCurY: Extended; + FFinalPass: Boolean; + FNotifyList: TList; + FPageHeight: Extended; + FPageWidth: Extended; + FPreviewPages: TfrxCustomPreviewPages; + FReport: TfrxReport; + FRunning: Boolean; + FStartDate: TDateTime; + FStartTime: TDateTime; + FTotalPages: Integer; + FOnRunDialog: TfrxRunDialogEvent; + function GetDoublePass: Boolean; + protected +{$IFDEF FR_COM} + function Get_CurColumn(out Value: Integer): HResult; stdcall; + function Set_CurColumn(Value: Integer): HResult; stdcall; + function Get_CurVColumn(out Value: Integer): HResult; stdcall; + function Set_CurVColumn(Value: Integer): HResult; stdcall; + function Get_CurX(out Value: Double): HResult; stdcall; + function Set_CurX(Value: Double): HResult; stdcall; + function Get_CurY(out Value: Double): HResult; stdcall; + function Set_CurY(Value: Double): HResult; stdcall; + function Get_DoublePass(out Value: WordBool): HResult; stdcall; + function Get_FinalPass(out Value: WordBool): HResult; stdcall; + function Set_FinalPass(Value: WordBool): HResult; stdcall; + function Get_PageHeight(out Value: Double): HResult; stdcall; + function Set_PageHeight(Value: Double): HResult; stdcall; + function Get_PageWidth(out Value: Double): HResult; stdcall; + function Set_PageWidth(Value: Double): HResult; stdcall; + function Get_StartDate(out Value: TDateTime): HResult; stdcall; + function Set_StartDate(Value: TDateTime): HResult; stdcall; + function Get_TotalPages(out Value: Integer): HResult; stdcall; + function Set_TotalPages(Value: Integer): HResult; stdcall; +{$ENDIF} + public + constructor Create(AReport: TfrxReport); virtual; + destructor Destroy; override; + procedure EndPage; virtual; abstract; + procedure NewColumn; virtual; abstract; + procedure NewPage; virtual; abstract; + procedure ShowBand(Band: TfrxBand); overload; virtual; abstract; + procedure ShowBand(Band: TfrxBandClass); overload; virtual; abstract; + procedure ShowBandByName(const BandName: String); + procedure StopReport; + function HeaderHeight: Extended; virtual; abstract; + function FooterHeight: Extended; virtual; abstract; + function FreeSpace: Extended; virtual; abstract; + function GetAggregateValue(const Name, Expression: String; + Band: TfrxBand; Flags: Integer): Variant; virtual; abstract; + function Run: Boolean; virtual; abstract; + + property CurLine: Integer read FCurLine write FCurLine; + property CurLineThrough: Integer read FCurLineThrough write FCurLineThrough; + property NotifyList: TList read FNotifyList; + property PreviewPages: TfrxCustomPreviewPages read FPreviewPages; + property Report: TfrxReport read FReport; + property Running: Boolean read FRunning write FRunning; + property OnRunDialog: TfrxRunDialogEvent read FOnRunDialog write FOnRunDialog; + published + property CurColumn: Integer read FCurColumn write FCurColumn; + property CurVColumn: Integer read FCurVColumn write FCurVColumn; + property CurX: Extended read FCurX write FCurX; + property CurY: Extended read FCurY write FCurY; + property DoublePass: Boolean read GetDoublePass; + property FinalPass: Boolean read FFinalPass write FFinalPass; + property PageHeight: Extended read FPageHeight write FPageHeight; + property PageWidth: Extended read FPageWidth write FPageWidth; + property StartDate: TDateTime read FStartDate write FStartDate; + property StartTime: TDateTime read FStartTime write FStartTime; + property TotalPages: Integer read FTotalPages write FTotalPages; + end; + + TfrxCustomOutline = class(TPersistent) + private + FCurItem: TfrxXMLItem; + FPreviewPages: TfrxCustomPreviewPages; + protected + function GetCount: Integer; virtual; abstract; + public + constructor Create(APreviewPages: TfrxCustomPreviewPages); virtual; + procedure AddItem(const Text: String; Top: Integer); virtual; abstract; + procedure LevelDown(Index: Integer); virtual; abstract; + procedure LevelRoot; virtual; abstract; + procedure LevelUp; virtual; abstract; + procedure GetItem(Index: Integer; var Text: String; + var Page, Top: Integer); virtual; abstract; + procedure ShiftItems(From: TfrxXMLItem; NewTop: Integer); virtual; abstract; + function Engine: TfrxCustomEngine; + function GetCurPosition: TfrxXMLItem; virtual; abstract; + property Count: Integer read GetCount; + property CurItem: TfrxXMLItem read FCurItem write FCurItem; + property PreviewPages: TfrxCustomPreviewPages read FPreviewPages; + end; + +{$IFDEF FR_COM} + TfrxCustomPreviewPages = class(TAutoObject, IfrxCustomPreviewPages) +{$ELSE} + TfrxCustomPreviewPages = class(TObject) +{$ENDIF} + private + FAddPageAction: TfrxAddPageAction; { used in the cross-tab renderer } + FCurPage: Integer; + FCurPreviewPage: Integer; + FEngine: TfrxCustomEngine; + FFirstPage: Integer; { used in the composite reports } + FOutline: TfrxCustomOutline; + FReport: TfrxReport; + protected + function GetCount: Integer; virtual; abstract; + function GetPage(Index: Integer): TfrxReportPage; virtual; abstract; + function GetPageSize(Index: Integer): TPoint; virtual; abstract; +{$IFDEF FR_COM} + function IfrxCustomPreviewPages_AddObject(const Value: IfrxComponent): HResult; stdcall; + function IfrxCustomPreviewPages_AddPage(const Value: IfrxReportPage): HResult; stdcall; + function IfrxCustomPreviewPages_AddEmptyPage(Index: Integer): HResult; stdcall; + function IfrxCustomPreviewPages_DeletePage(Index: Integer): HResult; stdcall; + function IfrxCustomPreviewPages_Page(Index: Integer; out Value: IfrxReportPage): HResult; stdcall; + function IfrxCustomPreviewPages.AddObject = IfrxCustomPreviewPages_AddObject; + function IfrxCustomPreviewPages.AddPage = IfrxCustomPreviewPages_AddPage; + function IfrxCustomPreviewPages.AddEmptyPage = IfrxCustomPreviewPages_AddEmptyPage; + function IfrxCustomPreviewPages.DeletePage = IfrxCustomPreviewPages_DeletePage; + function IfrxCustomPreviewPages.Page = IfrxCustomPreviewPages_Page; + + function Get_Count(out Value: Integer): HResult; stdcall; + function Get_CurrentPage(out Value: Integer): HResult; stdcall; + function Set_CurrentPage(Value: Integer): HResult; stdcall; + function Get_CurPreviewPage(out Value: Integer): HResult; stdcall; + function Set_CurPreviewPage(Value: Integer): HResult; stdcall; +{$ENDIF} + public + constructor Create(AReport: TfrxReport); virtual; + destructor Destroy; override; + procedure Clear; virtual; abstract; +{$IFNDEF FR_COM} + procedure Initialize; virtual; abstract; +{$ENDIF} + + procedure AddObject(Obj: TfrxComponent); virtual; abstract; + procedure AddPage(Page: TfrxReportPage); virtual; abstract; + procedure AddSourcePage(Page: TfrxReportPage); virtual; abstract; + procedure AddToSourcePage(Obj: TfrxComponent); virtual; abstract; + procedure BeginPass; virtual; abstract; + procedure ClearFirstPassPages; virtual; abstract; + procedure CutObjects(APosition: Integer); virtual; abstract; + procedure Finish; virtual; abstract; + procedure IncLogicalPageNumber; virtual; abstract; + procedure ResetLogicalPageNumber; virtual; abstract; + procedure PasteObjects(X, Y: Extended); virtual; abstract; + procedure ShiftAnchors(From, NewTop: Integer); virtual; abstract; + procedure AddPicture(Picture: TfrxPictureView); virtual; abstract; + function BandExists(Band: TfrxBand): Boolean; virtual; abstract; + function GetCurPosition: Integer; virtual; abstract; + function GetAnchorCurPosition: Integer; virtual; abstract; + function GetLastY: Extended; virtual; abstract; + function GetLogicalPageNo: Integer; virtual; abstract; + function GetLogicalTotalPages: Integer; virtual; abstract; + + procedure AddEmptyPage(Index: Integer); virtual; abstract; + procedure DeletePage(Index: Integer); virtual; abstract; + procedure ModifyPage(Index: Integer; Page: TfrxReportPage); virtual; abstract; + procedure DrawPage(Index: Integer; Canvas: TCanvas; ScaleX, ScaleY, + OffsetX, OffsetY: Extended); virtual; abstract; + procedure ObjectOver(Index: Integer; X, Y: Integer; Button: TMouseButton; + Shift: TShiftState; Scale, OffsetX, OffsetY: Extended; + Click: Boolean; var Cursor: TCursor); virtual; abstract; + procedure AddFrom(Report: TfrxReport); virtual; abstract; + + procedure LoadFromStream(Stream: TStream; + AllowPartialLoading: Boolean = False); virtual; abstract; + procedure SaveToStream(Stream: TStream); virtual; abstract; + function LoadFromFile(const FileName: String; + ExceptionIfNotFound: Boolean = False): Boolean; virtual; abstract; + procedure SaveToFile(const FileName: String); virtual; abstract; + function Print: Boolean; virtual; abstract; + function Export(Filter: TfrxCustomExportFilter): Boolean; virtual; abstract; + + property AddPageAction: TfrxAddPageAction read FAddPageAction write FAddPageAction; + property Count: Integer read GetCount; + property CurPage: Integer read FCurPage write FCurPage; + property CurPreviewPage: Integer read FCurPreviewPage write FCurPreviewPage; + property Engine: TfrxCustomEngine read FEngine; + property FirstPage: Integer read FFirstPage write FFirstPage; + property Outline: TfrxCustomOutline read FOutline; + property Page[Index: Integer]: TfrxReportPage read GetPage; + property PageSize[Index: Integer]: TPoint read GetPageSize; + property Report: TfrxReport read FReport; + end; + + TfrxCustomPreview = class(TCustomControl) + private + FPreviewPages: TfrxCustomPreviewPages; + FReport: TfrxReport; + public + procedure Init; virtual; abstract; + procedure Lock; virtual; abstract; + procedure Unlock; virtual; abstract; + procedure RefreshReport; virtual; abstract; + procedure InternalOnProgressStart(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer); virtual; abstract; + procedure InternalOnProgress(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer); virtual; abstract; + procedure InternalOnProgressStop(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer); virtual; abstract; + + property PreviewPages: TfrxCustomPreviewPages read FPreviewPages write FPreviewPages; + property Report: TfrxReport read FReport write FReport; + end; + + TfrxCompressorClass = class of TfrxCustomCompressor; + +{$IFDEF FR_COM} + TfrxCustomCompressor = class(TComponent, IfrxCustomCompressor) +{$ELSE} + TfrxCustomCompressor = class(TComponent) +{$ENDIF} + private + FIsFR3File: Boolean; + FOldCompressor: TfrxCompressorClass; + FReport: TfrxReport; + FStream: TStream; + FTempFile: String; +{$IFDEF FR_COM} + protected + function CompressStream(const InputStream: IUnknown; const OutputStream: IUnknown; + Compression_: Integer; const FileName: WideString): HResult; stdcall; + function DecompressStream(const Stream: IUnknown): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function Decompress(Source: TStream): Boolean; virtual; abstract; + procedure Compress(Dest: TStream); virtual; abstract; + procedure CreateStream; + property IsFR3File: Boolean read FIsFR3File write FIsFR3File; + property Report: TfrxReport read FReport write FReport; + property Stream: TStream read FStream write FStream; + end; + + TfrxCrypterClass = class of TfrxCustomCrypter; + + TfrxCustomCrypter = class(TComponent) + private + FStream: TStream; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function Decrypt(Source: TStream; const Key: String): Boolean; virtual; abstract; + procedure Crypt(Dest: TStream; const Key: String); virtual; abstract; + procedure CreateStream; + property Stream: TStream read FStream write FStream; + end; + + TfrxLoadEvent = function(Sender: TfrxReport; Stream: TStream): Boolean of object; + TfrxGetScriptValueEvent = function(var Params: Variant): Variant of object; + + TfrxFR2Events = class(TObject) + private + FOnGetValue: TfrxGetValueEvent; + FOnPrepareScript: TNotifyEvent; + FOnLoad: TfrxLoadEvent; + FOnGetScriptValue: TfrxGetScriptValueEvent; + public + property OnGetValue: TfrxGetValueEvent read FOnGetValue write FOnGetValue; + property OnPrepareScript: TNotifyEvent read FOnPrepareScript write FOnPrepareScript; + property OnLoad: TfrxLoadEvent read FOnLoad write FOnLoad; + property OnGetScriptValue: TfrxGetScriptValueEvent read FOnGetScriptValue write FOnGetScriptValue; + end; + + TfrxGlobalDataSetList = class(TList) +{$IFNDEF NO_CRITICAL_SECTION} + FCriticalSection: TCriticalSection; +{$ENDIF} + public + constructor Create; + destructor Destroy; override; + procedure Lock; + procedure Unlock; + end; + + +function frxParentForm: TForm; +function frxFindDataSet(DataSet: TfrxDataSet; const Name: String; + Owner: TComponent): TfrxDataSet; +procedure frxGetDataSetList(List: TStrings); + +var + frxDesignerClass: TfrxDesignerClass; + frxDotMatrixExport: TfrxCustomExportFilter; + frxCompressorClass: TfrxCompressorClass; + frxCrypterClass: TfrxCrypterClass; + frxCharset: Integer = DEFAULT_CHARSET; + frxFR2Events: TfrxFR2Events; +{$IFNDEF NO_CRITICAL_SECTION} + frxCS: TCriticalSection; +{$ENDIF} + frxGlobalVariables: TfrxVariables; + +const + FR_VERSION = {$I frxVersion.inc}; + BND_COUNT = 18; + frxBands: array[0..BND_COUNT - 1] of TfrxComponentClass = + (TfrxReportTitle, TfrxReportSummary, TfrxPageHeader, TfrxPageFooter, + TfrxHeader, TfrxFooter, TfrxMasterData, TfrxDetailData, TfrxSubdetailData, + TfrxDataBand4, TfrxDataBand5, TfrxDataBand6, TfrxGroupHeader, TfrxGroupFooter, + TfrxChild, TfrxColumnHeader, TfrxColumnFooter, TfrxOverlay); + + +implementation + +{$R *.RES} +{$IFDEF FR_COM} +{$R frxDesgnIcon.res} +{$ENDIF} + +uses + Registry, frxEngine, frxPreviewPages, frxPreview, frxPrinter, frxUtils, + frxPassw, frxGraphicUtils, frxDialogForm, frxXMLSerializer, frxAggregate, + frxRes, frxDsgnIntf, frxrcClass, frxClassRTTI, frxInheritError, + fs_ipascal, fs_icpp, fs_ibasic, fs_ijs, fs_iclassesrtti, + fs_igraphicsrtti, fs_iformsrtti, fs_idialogsrtti, fs_iinirtti, frxDMPClass +{$IFDEF JPEG} +, jpeg +{$ENDIF} +{$IFDEF PNG} +, pngimage +{$ENDIF} +{$IFDEF FR_COM} +, + {$IFNDEF FR_LITE} + frxExportPDF, + frxExportXML, + frxExportXLS, + frxExportHTML, + frxDMPExport, + frxExportImage, + frxExportRTF, + frxExportMail, + frxCross, + frxBarcode, + frxRich, + frxChart, + frxDCtrl, + frxOLE, + frxGradient, + {$ENDIF} + frxExportText, + frxExportCSV, + frxChBox, + frxDesgn, + frxADOComponents, + ADODB, + frxGZIP, + frxNetDataTable +{$ENDIF}; + +var + FParentForm: TForm; + DatasetList: TfrxGlobalDataSetList; +{$IFDEF FR_COM} + frxDefaultConnection: TADOConnection = nil; + frxADOComponent: TfrxADOComponents = nil; + frxGZipCompressor: TfrxGZipCompressor = nil; + +{$IFNDEF EXT_EXPORTS} + {$IFNDEF FR_LITE} + Export2PDF: TfrxPDFExport; + Export2BMP: TfrxBMPExport; + Export2HTML: TfrxHTMLExport; + Export2RTF: TfrxRTFExport; + Export2XLS: TfrxXLSExport; + Export2XML: TfrxXMLExport; + Export2JPEG: TfrxJPEGExport; + Export2TIFF: TfrxTIFFExport; + Export2Mail: TfrxMailExport; + Export2Gif: TfrxGifExport; + Export2DMP: TfrxDotMatrixExport; + {$ENDIF} + Export2CSV: TfrxCSVExport; + Export2TXT: TfrxSimpleTextExport; +{$ENDIF} + DispatchableComponentFactory: TComponentFactory; +{$ENDIF} + +const + DefFontName = 'Arial'; + DefFontSize = 10; + +type + TByteSet = set of 0..7; + PByteSet = ^TByteSet; + + THackControl = class(TControl); + THackWinControl = class(TWinControl); + THackPersistent = class(TPersistent); + THackThread = class(TThread); + + TParentForm = class(TForm) + protected + procedure WndProc(var Message: TMessage); override; + end; + +procedure TParentForm.WndProc(var Message: TMessage); +begin + case Message.Msg of + WM_CREATEHANDLE: + TWinControl(Message.WParam).HandleNeeded; + WM_DESTROYHANDLE: + THackWinControl(Message.WParam).DestroyHandle; + else + inherited; + end; +end; + +function Round8(e: Extended): Extended; +begin + Result := Round(e * 100000000) / 100000000; +end; + +function frxParentForm: TForm; +begin + if FParentForm = nil then + begin + FParentForm := TParentForm.CreateNew(nil); + if not ModuleIsLib then // Access denied AV inside multithreaded (COM) environment + FParentForm.HandleNeeded; + end; + Result := FParentForm; +end; + +function frxFindDataSet(DataSet: TfrxDataSet; const Name: String; + Owner: TComponent): TfrxDataSet; +var + i: Integer; + ds: TfrxDataSet; +begin + Result := DataSet; + if Name = '' then + begin + Result := nil; + Exit; + end; + if Owner = nil then Exit; + DatasetList.Lock; + for i := 0 to DatasetList.Count - 1 do + begin + ds := DatasetList[i]; + if AnsiCompareText(ds.UserName, Name) = 0 then + if not ((Owner is TfrxReport) and (ds.Owner is TfrxReport) and + (ds.Owner <> Owner)) then + begin + Result := DatasetList[i]; + break; + end; + end; + DatasetList.Unlock; +end; + +procedure frxGetDataSetList(List: TStrings); +var + i: Integer; + ds: TfrxDataSet; +begin + DatasetList.Lock; + List.Clear; + for i := 0 to DatasetList.Count - 1 do + begin + ds := DatasetList[i]; + if (ds <> nil) and (ds.UserName <> '') and ds.Enabled then + List.AddObject(ds.UserName, ds); + end; + DatasetList.Unlock; +end; + +procedure EmptyParentForm; +begin + while FParentForm.ControlCount > 0 do + FParentForm.Controls[0].Parent := nil; +end; + + +function FloatDiff(const Val1, Val2: Extended): Boolean; +begin + Result := Abs(Val1 - Val2) > 1e-4; +end; + +function ShiftToByte(Value: TShiftState): Byte; +begin + Result := Byte(PByteSet(@Value)^); +end; + + +{ TfrxDataset } + +constructor TfrxDataSet.Create(AOwner: TComponent); +begin + inherited; + FEnabled := True; + FOpenDataSource := True; + FRangeBegin := rbFirst; + FRangeEnd := reLast; + DatasetList.Lock; + DatasetList.Add(Self); + DatasetList.Unlock; +end; + +destructor TfrxDataSet.Destroy; +begin + DatasetList.Lock; + DatasetList.Remove(Self); + inherited; + DatasetList.Unlock; +end; + +procedure TfrxDataSet.SetName(const NewName: TComponentName); +begin + if NewName <> '' then + if (FUserName = '') or (FUserName = Name) then + UserName := NewName; + inherited; +end; + +procedure TfrxDataSet.SetUserName(const Value: String); +begin + if Trim(Value) = '' then + raise Exception.Create(frxResources.Get('prInvProp')); + FUserName := Value; +end; + +procedure TfrxDataSet.Initialize; +begin +end; + +procedure TfrxDataSet.Finalize; +begin +end; + +procedure TfrxDataSet.Close; +begin + if Assigned(FOnClose) then FOnClose(Self); +end; + +procedure TfrxDataSet.Open; +begin + if Assigned(FOnOpen) then FOnOpen(Self); +end; + +procedure TfrxDataSet.First; +begin + FRecNo := 0; + FEof := False; + if Assigned(FOnFirst) then + FOnFirst(Self); +end; + +procedure TfrxDataSet.Next; +begin + FEof := False; + Inc(FRecNo); + if not ((FRangeEnd = reCount) and (FRecNo >= FRangeEndCount)) then + begin + if Assigned(FOnNext) then + FOnNext(Self); + end + else + begin + FRecNo := FRangeEndCount - 1; + FEof := True; + end; +end; + +procedure TfrxDataSet.Prior; +begin + Dec(FRecNo); + if Assigned(FOnPrior) then + FOnPrior(Self); +end; + +function TfrxDataSet.Eof: Boolean; +begin + Result := False; + if FRangeEnd = reCount then + if (FRecNo >= FRangeEndCount) or FEof then + Result := True; + if Assigned(FOnCheckEOF) then + FOnCheckEOF(Self, Result); +end; + +function TfrxDataSet.GetDisplayText(Index: String): WideString; +begin + Result := ''; +end; + +function TfrxDataSet.GetDisplayWidth(Index: String): Integer; +begin + Result := 10; +end; + +procedure TfrxDataSet.GetFieldList(List: TStrings); +begin + List.Clear; +end; + +function TfrxDataSet.GetValue(Index: String): Variant; +begin + Result := Null; +end; + +function TfrxDataSet.HasField(const fName: String): Boolean; +var + sl: TStringList; +begin + sl := TStringList.Create; + GetFieldList(sl); + Result := sl.IndexOf(fName) <> -1; + sl.Free; +end; + +procedure TfrxDataSet.AssignBlobTo(const fName: String; Obj: TObject); +begin +// empty method +end; + +function TfrxDataSet.IsBlobField(const fName: String): Boolean; +begin + Result := False; +end; + +function TfrxDataSet.FieldsCount: Integer; +begin + Result := 0; +end; + +function TfrxDataSet.GetFieldType(Index: String): TfrxFieldType; +begin + Result := fftNumeric; +end; + +function TfrxDataSet.RecordCount: Integer; +begin + if (RangeBegin = rbFirst) and (RangeEnd = reCount) then + Result := RangeEndCount + else + Result := 0; +end; + +{$IFDEF FR_COM} +function TfrxDataSet.Get_UserName(out Value: WideString): HResult; stdcall; +begin + Value := UserName; + Result := S_OK; +end; + +function TfrxDataSet.Set_UserName(const Value: WideString): HResult; stdcall; +begin + UserName := Value; + Result := S_OK; +end; + +function TfrxDataSet.Get_RangeBegin(out Value: frxRangeBegin): HResult; stdcall; +begin + Value := frxRangeBegin(RangeBegin); + Result := S_OK; +end; + +function TfrxDataSet.Set_RangeBegin(Value: frxRangeBegin): HResult; stdcall; +begin + RangeBegin := TfrxRangeBegin(Value); + Result := S_OK; +end; + +function TfrxDataSet.Get_RangeEndCount(out Value: Integer): HResult; stdcall; +begin + Value := RangeEndCount; + Result := S_OK; +end; + +function TfrxDataSet.Set_RangeEndCount(Value: Integer): HResult; stdcall; +begin + RangeEndCount := Value; + Result := S_OK; +end; + +function TfrxDataSet.Get_RangeEnd(out Value: frxRangeEnd): HResult; stdcall; +begin + Value := frxRangeEnd(RangeEnd); + Result := S_OK; +end; + +function TfrxDataSet.Set_RangeEnd(Value: frxRangeEnd): HResult; stdcall; +begin + RangeEnd := TfrxRangeEnd(Value); + Result := S_OK; +end; + +function TfrxDataSet.Get_FieldsCount(out Value: Integer): HResult; stdcall; +begin + Value := FieldsCount; + Result := S_OK; +end; + +function TfrxDataSet.Get_RecordsCount(out Value: Integer): HResult; stdcall; +begin + value := RecordCount; + Result := S_OK; +end; + +function TfrxDataSet.ValueOfField(const FieldName: WideString; out Value: OleVariant): HResult; stdcall; +begin + Value := Self.Value[FieldName]; + Result := S_OK; +end; + +function TfrxDataSet.Get_CurrentRecordNo(out Value: Integer): HResult; stdcall; +begin + Value := RecNo; + Result := S_OK; +end; + +function TfrxDataSet.GoFirst: HResult; stdcall; +begin + First; + Result := S_OK; +end; + +function TfrxDataSet.GoNext: HResult; stdcall; +begin + Next; + Result := S_OK; +end; + +function TfrxDataSet.GoPrior: HResult; stdcall; +begin + Prior; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxUserDataSet } + +constructor TfrxUserDataSet.Create(AOwner: TComponent); +begin + inherited; + FFields := TStringList.Create; +{$IFDEF FR_COM} + FEvent := nil; + OnGetValue := COM_OnGetValueHandler; + OnFirst := COM_OnFirstHandler; + OnNext := COM_OnNextHandler; + OnPrior := COM_OnPrevHandler; + OnCheckEOF := COM_OnCheckEOFHandler; + FConnectionPoints := TConnectionPoints.Create(Self); + FConnectionPoints.CreateConnectionPoint( IfrxUserDataSetEvents, ckSingle, EventSinkChanged ); + FConnectionPoint := FConnectionPoints.CreateConnectionPoint(IfrxUserDataSetEventDispatcher, ckMulti, nil); +{$ENDIF} +end; + +destructor TfrxUserDataSet.Destroy; +begin +{$IFDEF FR_COM} + FConnectionPoint.Free; + FConnectionPoints.Free; +{$ENDIF} + FFields.Free; + inherited; +end; + +procedure TfrxUserDataSet.SetFields(const Value: TStrings); +begin + FFields.Assign(Value); +end; + +procedure TfrxUserDataSet.GetFieldList(List: TStrings); +begin + List.Assign(FFields); +end; + +function TfrxUserDataSet.FieldsCount: Integer; +begin + Result := FFields.Count; +end; + +function TfrxUserDataSet.GetDisplayText(Index: String): WideString; +var + v: Variant; +begin + Result := ''; + if Assigned(FOnGetValue) then + begin + v := Null; + FOnGetValue(Index, v); + Result := VarToWideStr(v); + end; +end; + +function TfrxUserDataSet.GetValue(Index: String): Variant; +begin + Result := Null; + if Assigned(FOnGetValue) then + FOnGetValue(Index, Result); +end; + +{$IFDEF FR_COM} +procedure TfrxUserDataSet.EventSinkChanged(const Sink: IUnknown; Connecting: Boolean); +begin + if Connecting then FEvent := Sink as IfrxUserDataSetEvents else FEvent := nil; +end; + +function TfrxUserDataSet.IfrxUserDataSet_Get_Fields(out Value: WideString): HResult; stdcall; +begin + Value := WideString(String(Fields.GetText)); + Result := 0; +end; + +function TfrxUserDataSet.IfrxUserDataSet_Set_Fields(const Value: WideString): HResult; stdcall; +begin + Fields.SetText( PAnsiChar(String(Value)) ); + Result := 0; +end; + +function TfrxUserDataSet.IfrxUserDataSet_Get_Name(out Value: WideString): HResult; stdcall; +begin + Value := WideString(String(UserName)); + Result := 0; +end; + +function TfrxUserDataSet.IfrxUserDataSet_Set_Name(const Value: WideString): HResult; stdcall; +begin + UserName := ( PAnsiChar(String(Value)) ); + Result := 0; +end; + +procedure TfrxUserDataSet.COM_OnGetValueHandler(const VarName: String; var Value: Variant); +var + OleVal : OleVariant; + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + if FEvent <> nil then + begin + FEvent.OnGetValue( OleVariant(VarName), OleVal); + Value := OleVal; + end + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxUserDataSetEventDispatcher).OnGetValue(OleVariant(VarName), OleVal); + ConnectData.pUnk := nil; + if not VarIsEmpty(OleVal) then + begin + Value := OleVal; + Break; + end; + end; + end; +end; + +procedure TfrxUserDataSet.COM_OnCheckEOFHandler(Sender: TObject; var EOF: Boolean); +var + e : WordBool; + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + e := True; + + if FEvent <> nil then + begin + FEvent.OnCheckEOF(e); + EOF := Boolean(e); + end + else + begin + EOF := False; + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxUserDataSetEventDispatcher).OnCheckEOF(e); + ConnectData.pUnk := nil; + EOF := EOF or Boolean(e); + end; + end; +end; + +procedure TfrxUserDataSet.COM_OnFirstHandler(Sender: TObject); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + if FEvent <> nil then FEvent.OnFirst else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxUserDataSetEventDispatcher).OnFirst; + ConnectData.pUnk := nil; + end; + end; +end; + +procedure TfrxUserDataSet.COM_OnNextHandler(Sender: TObject); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + if FEvent <> nil then FEvent.OnNext else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxUserDataSetEventDispatcher).OnNext; + ConnectData.pUnk := nil; + end; + end; +end; + +procedure TfrxUserDataSet.COM_OnPrevHandler(Sender: TObject); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + if FEvent <> nil then FEvent.OnPrior else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxUserDataSetEventDispatcher).OnPrior; + ConnectData.pUnk := nil; + end; + end; +end; + +{$ENDIF} + +{ TfrxCustomDBDataSet } + +constructor TfrxCustomDBDataset.Create(AOwner: TComponent); +begin + FFields := TStringList.Create; + FFields.Sorted := True; + FFields.Duplicates := dupIgnore; + FAliases := TStringList.Create; + inherited; +end; + +destructor TfrxCustomDBDataset.Destroy; +begin + FFields.Free; + FAliases.Free; + inherited; +end; + +procedure TfrxCustomDBDataset.SetFieldAliases(const Value: TStrings); +begin + FAliases.Assign(Value); +end; + +function TfrxCustomDBDataset.ConvertAlias(const fName: String): String; +var + i: Integer; + s: String; +begin + Result := fName; + for i := 0 to FAliases.Count - 1 do + begin + s := FAliases[i]; + if AnsiCompareText(Copy(s, Pos('=', s) + 1, MaxInt), fName) = 0 then + begin + Result := FAliases.Names[i]; + break; + end; + end; +end; + +function TfrxCustomDBDataset.GetAlias(const fName: String): String; +var + i: Integer; +begin + Result := fName; + for i := 0 to FAliases.Count - 1 do + if AnsiCompareText(FAliases.Names[i], fName) = 0 then + begin + Result := FAliases[i]; + Result := Copy(Result, Pos('=', Result) + 1, MaxInt); + break; + end; +end; + +function TfrxCustomDBDataset.FieldsCount: Integer; +var + sl: TStrings; +begin + sl := TStringList.Create; + try + GetFieldList(sl); + finally + Result := sl.Count; + sl.Free; + end; +end; + + +{ TfrxDBComponents } + +function TfrxDBComponents.GetDescription: String; +begin + Result := ''; +end; + + +{ TfrxCustomDatabase } + +procedure TfrxCustomDatabase.BeforeConnect(var Value: Boolean); +begin + if (Report <> nil) and Assigned(Report.OnBeforeConnect) then + Report.OnBeforeConnect(Self, Value); +end; + +function TfrxCustomDatabase.GetConnected: Boolean; +begin + Result := False; +end; + +function TfrxCustomDatabase.GetDatabaseName: String; +begin + Result := ''; +end; + +function TfrxCustomDatabase.GetLoginPrompt: Boolean; +begin + Result := False; +end; + +function TfrxCustomDatabase.GetParams: TStrings; +begin + Result := nil; +end; + +procedure TfrxCustomDatabase.SetConnected(Value: Boolean); +begin +// empty +end; + +procedure TfrxCustomDatabase.SetDatabaseName(const Value: String); +begin +// empty +end; + +procedure TfrxCustomDatabase.SetLogin(const Login, Password: String); +begin +// empty +end; + +procedure TfrxCustomDatabase.SetLoginPrompt(Value: Boolean); +begin +// empty +end; + +procedure TfrxCustomDatabase.SetParams(Value: TStrings); +begin +// empty +end; + + +{ TfrxComponent } + +constructor TfrxComponent.Create(AOwner: TComponent); +begin + if AOwner is TfrxComponent then + inherited Create(TfrxComponent(AOwner).Report) + else + inherited Create(AOwner); + + FComponentStyle := [csPreviewVisible]; + FBaseName := ClassName; + Delete(FBaseName, Pos('Tfrx', FBaseName), 4); + Delete(FBaseName, Pos('View', FBaseName), 4); + FObjects := TList.Create; + FAllObjects := TList.Create; + +{$IFNDEF FR_COM} + FFont := TFont.Create; +{$ELSE} + FFont := TfrxFont.Create; +{$ENDIF} + with FFont do + begin + PixelsPerInch := 96; + Name := DefFontName; + Size := DefFontSize; + Color := clBlack; + Charset := frxCharset; + OnChange := FontChanged; + end; + + FVisible := True; + ParentFont := True; + if AOwner is TfrxComponent then + SetParent(TfrxComponent(AOwner)); +end; + +constructor TfrxComponent.DesignCreate(AOwner: TComponent; Flags: Word); +begin + FIsDesigning := True; + Create(AOwner); +end; + +destructor TfrxComponent.Destroy; +begin + SetParent(nil); + Clear; + FFont.Free; + FObjects.Free; + FAllObjects.Free; + inherited; +end; + +procedure TfrxComponent.Assign(Source: TPersistent); +var + s: TMemoryStream; +begin + if Source is TfrxComponent then + begin + s := TMemoryStream.Create; + try + TfrxComponent(Source).SaveToStream(s, False, True); + s.Position := 0; + LoadFromStream(s); + finally + s.Free; + end; + end; +end; + +procedure TfrxComponent.AssignAll(Source: TfrxComponent); +var + s: TMemoryStream; +begin + s := TMemoryStream.Create; + try + Source.SaveToStream(s, True, True); + s.Position := 0; + LoadFromStream(s); + finally + s.Free; + end; +end; + +procedure TfrxComponent.LoadFromStream(Stream: TStream); +var + Reader: TfrxXMLSerializer; +begin + Clear; + Reader := TfrxXMLSerializer.Create(Stream); + if Report <> nil then + Report.FXMLSerializer := Reader; + + try + Reader.Owner := Report; + if (Report <> nil) and Report.EngineOptions.EnableThreadSafe then + begin +{$IFNDEF NO_CRITICAL_SECTION} + frxCS.Enter; +{$ENDIF} + try + Reader.ReadRootComponent(Self, nil); + finally +{$IFNDEF NO_CRITICAL_SECTION} + frxCS.Leave; +{$ENDIF} + end; + end + else + Reader.ReadRootComponent(Self, nil); + + if Report <> nil then + Report.Errors.AddStrings(Reader.Errors); + + finally + Reader.Free; + if Report <> nil then + Report.FXMLSerializer := nil; + end; +end; + +procedure TfrxComponent.SaveToStream(Stream: TStream; SaveChildren: Boolean = True; + SaveDefaultValues: Boolean = False); +var + Writer: TfrxXMLSerializer; +begin + Writer := TfrxXMLSerializer.Create(Stream); + + try + Writer.Owner := Report; + Writer.SerializeDefaultValues := SaveDefaultValues; + if Self is TfrxReport then + Writer.OnGetAncestor := Report.DoGetAncestor; + Writer.WriteRootComponent(Self, SaveChildren); + finally + Writer.Free; + end; +end; + +procedure TfrxComponent.Clear; +var + i: Integer; + c: TfrxComponent; +begin + i := 0; + while i < FObjects.Count do + begin + c := FObjects[i]; + if (csAncestor in c.ComponentState) then + begin + c.Clear; + Inc(i); + end + else + c.Free; + end; +end; + +procedure TfrxComponent.SetParent(AParent: TfrxComponent); +begin + if FParent <> AParent then + begin + if FParent <> nil then + FParent.FObjects.Remove(Self); + if AParent <> nil then + AParent.FObjects.Add(Self); + end; + + FParent := AParent; + if FParent <> nil then + SetParentFont(FParentFont); +end; + +procedure TfrxComponent.SetBounds(ALeft, ATop, AWidth, AHeight: Extended); +begin + Left := ALeft; + Top := ATop; + Width := AWidth; + Height := AHeight; +end; + +function TfrxComponent.GetPage: TfrxPage; +var + p: TfrxComponent; +begin + if Self is TfrxPage then + begin + Result := TfrxPage(Self); + Exit; + end; + + Result := nil; + p := Parent; + while p <> nil do + begin + if p is TfrxPage then + begin + Result := TfrxPage(p); + Exit; + end; + p := p.Parent; + end; +end; + +function TfrxComponent.GetReport: TfrxReport; +var + p: TfrxComponent; +begin + if Self is TfrxReport then + begin + Result := TfrxReport(Self); + Exit; + end; + + Result := nil; + p := Parent; + while p <> nil do + begin + if p is TfrxReport then + begin + Result := TfrxReport(p); + Exit; + end; + p := p.Parent; + end; +end; + +function TfrxComponent.GetIsLoading: Boolean; +begin + Result := FIsLoading or (csLoading in ComponentState); +end; + +function TfrxComponent.GetAbsTop: Extended; +begin + if (Parent <> nil) and not (Parent is TfrxDialogPage) then + Result := Parent.AbsTop + Top else + Result := Top; +end; + +function TfrxComponent.GetAbsLeft: Extended; +begin + if (Parent <> nil) and not (Parent is TfrxDialogPage) then + Result := Parent.AbsLeft + Left else + Result := Left; +end; + +procedure TfrxComponent.SetLeft(Value: Extended); +begin + if not IsDesigning or not (rfDontMove in FRestrictions) then + FLeft := Value; +end; + +procedure TfrxComponent.SetTop(Value: Extended); +begin + if not IsDesigning or not (rfDontMove in FRestrictions) then + FTop := Value; +end; + +procedure TfrxComponent.SetWidth(Value: Extended); +begin + if not IsDesigning or not (rfDontSize in FRestrictions) then + FWidth := Value; +end; + +procedure TfrxComponent.SetHeight(Value: Extended); +begin + if not IsDesigning or not (rfDontSize in FRestrictions) then + FHeight := Value; +end; + +function TfrxComponent.IsFontStored: Boolean; +begin + Result := not FParentFont; +end; + +procedure TfrxComponent.SetFont(Value: TFont); +begin + FFont.Assign(Value); + FParentFont := False; +end; + +procedure TfrxComponent.SetParentFont(const Value: Boolean); +begin + if Value then + if Parent <> nil then + Font := Parent.Font; + FParentFont := Value; +end; + +procedure TfrxComponent.SetVisible(Value: Boolean); +begin + FVisible := Value; +end; + +procedure TfrxComponent.FontChanged(Sender: TObject); +var + i: Integer; + c: TfrxComponent; +begin + FParentFont := False; + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if c.ParentFont then + c.ParentFont := True; + end; +end; + +function TfrxComponent.GetAllObjects: TList; + + procedure EnumObjects(c: TfrxComponent); + var + i: Integer; + begin + if c <> Self then + FAllObjects.Add(c); + for i := 0 to c.FObjects.Count - 1 do + EnumObjects(c.FObjects[i]); + end; + +begin + FAllObjects.Clear; + EnumObjects(Self); + Result := FAllObjects; +end; + +procedure TfrxComponent.SetName(const AName: TComponentName); +var + c: TfrxComponent; +begin + if CompareText(AName, Name) = 0 then Exit; + + if (AName <> '') and (Report <> nil) then + begin + c := Report.FindObject(AName); + if (c <> nil) and (c <> Self) then + raise Exception.Create(frxResources.Get('prDupl')); + if IsAncestor then + raise Exception.Create('Could not rename ' + Name + ', it was introduced in the ancestor report'); + end; + inherited; +end; + +procedure TfrxComponent.CreateUniqueName; +var + i: Integer; + l: TList; + sl: TStringList; +begin + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupIgnore; + + if Report <> nil then + l := Report.AllObjects else + l := Parent.AllObjects; + for i := 0 to l.Count - 1 do + sl.Add(TfrxComponent(l[i]).Name); + + i := 1; + while sl.IndexOf(FBaseName + IntToStr(i)) <> -1 do + Inc(i); + + Name := FBaseName + IntToStr(i); + sl.Free; +end; + +function TfrxComponent.Diff(AComponent: TfrxComponent): String; +begin + Result := InternalDiff(AComponent); +end; + +function TfrxComponent.DiffFont(f1, f2: TFont; const Add: String): String; +var + fs: Integer; +begin + Result := ''; + + if f1.Name <> f2.Name then + Result := Result + Add + 'Font.Name="' + frxStrToXML(f1.Name) + '"'; + if f1.Size <> f2.Size then + Result := Result + Add + 'Font.Size="' + IntToStr(f1.Size) + '"'; + if f1.Color <> f2.Color then + Result := Result + Add + 'Font.Color="' + IntToStr(f1.Color) + '"'; + if f1.Style <> f2.Style then + begin + fs := 0; + if fsBold in f1.Style then fs := 1; + if fsItalic in f1.Style then fs := fs or 2; + if fsUnderline in f1.Style then fs := fs or 4; + if fsStrikeout in f1.Style then fs := fs or 8; + Result := Result + Add + 'Font.Style="' + IntToStr(fs) + '"'; + end; + if f1.Charset <> f2.Charset then + Result := Result + Add + 'Font.Charset="' + IntToStr(f1.Charset) + '"'; +end; + +function TfrxComponent.InternalDiff(AComponent: TfrxComponent): String; +begin + Result := ''; + + if FloatDiff(FLeft, AComponent.FLeft) then + Result := Result + ' l="' + FloatToStr(FLeft) + '"'; + if (Self is TfrxBand) or FloatDiff(FTop, AComponent.FTop) then + Result := Result + ' t="' + FloatToStr(FTop) + '"'; + if not ((Self is TfrxCustomMemoView) and TfrxCustomMemoView(Self).FAutoWidth) then + if FloatDiff(FWidth, AComponent.FWidth) then + Result := Result + ' w="' + FloatToStr(FWidth) + '"'; + if FloatDiff(FHeight, AComponent.FHeight) then + Result := Result + ' h="' + FloatToStr(FHeight) + '"'; + if FVisible <> AComponent.FVisible then + Result := Result + ' Visible="' + frxValueToXML(FVisible) + '"'; + if not FParentFont then + Result := Result + DiffFont(FFont, AComponent.FFont, ' '); + if FParentFont <> AComponent.FParentFont then + Result := Result + ' ParentFont="' + frxValueToXML(FParentFont) + '"'; + if Tag <> AComponent.Tag then + Result := Result + ' Tag="' + IntToStr(Tag) + '"'; +end; + +function TfrxComponent.AllDiff(AComponent: TfrxComponent): String; +var + s: TStringStream; + Writer: TfrxXMLSerializer; + i: Integer; +begin + s := TStringStream.Create(''); + Writer := TfrxXMLSerializer.Create(s); + Writer.Owner := Report; + Writer.WriteComponent(Self); + Writer.Free; + + Result := s.DataString; + i := Pos(' ', Result); + if i <> 0 then + begin + Delete(Result, 1, i); + Delete(Result, Length(Result) - 1, 2); + end + else + Result := ''; + if AComponent <> nil then + Result := Result + ' ' + InternalDiff(AComponent); + + s.Free; +end; + +procedure TfrxComponent.AlignChildren; +var + i: Integer; + c: TfrxComponent; + sl: TStringList; + + procedure DoAlign(v: TfrxView; n, dir: Integer); + var + i: Integer; + c, c0: TfrxComponent; + begin + c0 := nil; + i := n; + while (i >= 0) and (i < sl.Count) do + begin + c := TfrxComponent(sl.Objects[i]); + if c <> v then + if (c.AbsTop < v.AbsTop + v.Height - 1e-4) and + (v.AbsTop < c.AbsTop + c.Height - 1e-4) then + begin + { special case for baWidth } + if (v.Align = baWidth) and + (((dir = 1) and (c.Left > v.Left)) or + ((dir = -1) and (c.Left + c.Width < v.Left + v.Width))) then + begin + Dec(i, dir); + continue; + end; + c0 := c; + break; + end; + Dec(i, dir); + end; + + if (dir = 1) and (v.Align in [baLeft, baWidth]) then + if c0 = nil then + v.Left := 0 else + v.Left := c0.Left + c0.Width; + + if v.Align = baRight then + if c0 = nil then + v.Left := Width - v.Width else + v.Left := c0.Left - v.Width; + + if (dir = -1) and (v.Align = baWidth) then + if c0 = nil then + v.Width := Width - v.Left else + v.Width := c0.Left - v.Left; + end; + +begin + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupAccept; + + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if c is TfrxView then + if c.Left >= 0 then + sl.AddObject('1' + Format('%9.2f', [c.Left]), c) + else + sl.AddObject('0' + Format('%9.2f', [-c.Left]), c); + end; + + { process baLeft } + + for i := 0 to sl.Count - 1 do + begin + c := TfrxComponent(sl.Objects[i]); + if c is TfrxView then + if TfrxView(c).Align in [baLeft, baWidth] then + DoAlign(TfrxView(c), i, 1); + end; + + { process baRight } + + for i := sl.Count - 1 downto 0 do + begin + c := TfrxComponent(sl.Objects[i]); + if c is TfrxView then + if TfrxView(c).Align in [baRight, baWidth] then + DoAlign(TfrxView(c), i, -1); + end; + + { process others } + + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if c is TfrxView then + case TfrxView(c).Align of + baCenter: + c.Left := (Width - c.Width) / 2; + + baBottom: + c.Top := Height - c.Height; + + baClient: + begin + c.Left := 0; + c.Top := 0; + c.Width := Width; + c.Height := Height; + end; + end; + end; + + sl.Free; +end; + +function TfrxComponent.FindObject(const AName: String): TfrxComponent; +var + i: Integer; + l: TList; +begin + Result := nil; + l := AllObjects; + for i := 0 to l.Count - 1 do + if CompareText(AName, TfrxComponent(l[i]).Name) = 0 then + begin + Result := l[i]; + break; + end; +end; + +class function TfrxComponent.GetDescription: String; +begin + Result := ClassName; +end; + +function TfrxComponent.GetChildOwner: TComponent; +begin + Result := Self; +end; + +procedure TfrxComponent.GetChildren(Proc: TGetChildProc; Root: TComponent); +var + i: Integer; +begin + if (Self is TfrxReport) and not TfrxReport(Self).StoreInDFM then + Exit; + for i := 0 to FObjects.Count - 1 do + Proc(FObjects[i]); +end; + +procedure TfrxComponent.BeforeStartReport; +begin +// do nothing +end; + +procedure TfrxComponent.OnNotify(Sender: TObject); +begin +// do nothing +end; + +procedure TfrxComponent.OnPaste; +begin +// +end; + +function TfrxComponent.GetIsAncestor: Boolean; +begin + Result := (csAncestor in ComponentState) or FAncestor; +end; + +function TfrxComponent.GetContainerObjects: TList; +begin + Result := FObjects; +end; + +function TfrxComponent.ContainerAdd(Obj: TfrxComponent): Boolean; +begin + Result := False; +end; + +function TfrxComponent.ContainerMouseDown(Sender: TObject; X, Y: Integer): Boolean; +begin + Result := False; +end; + +procedure TfrxComponent.ContainerMouseMove(Sender: TObject; X, Y: Integer); +begin +end; + +procedure TfrxComponent.ContainerMouseUp(Sender: TObject; X, Y: Integer); +begin +end; + +{$IFDEF FR_COM} +function TfrxComponent.GetFont: TFont; +begin + Result := FFont; +end; + +{ IfrxComponent support } +function TfrxComponent.IfrxComponent_Get_Description(out Value: WideString): HResult; stdcall; +begin + Value := WideString(GetDescription); + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Get_ObjectsCount(out Value: Integer): HResult; stdcall; +begin + Value := FObjects.Count; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_GetObject(Index: Integer; out Component: IfrxComponent): HResult; stdcall; +begin + if (Index >= 0) and (Index < FObjects.Count) then + begin + Component := TfrxComponent(FObjects[Index]); + Result := S_OK; + end + else + Result := E_UNEXPECTED; +end; + +function TfrxComponent.IfrxComponent_Get_BaseName(out Value: WideString): HResult; stdcall; +begin + Value := BaseName; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Get_AliasName(out Value: WideString): HResult; stdcall; +begin + Value := FAliasName; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Get_Name(out Value: WideString): HResult; stdcall; +begin + Value := Name; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Get_Left(out Value: Double): HResult; stdcall; +begin + Value := Left; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Set_Left(Value: Double): HResult; stdcall; +begin + Left := Value; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Get_Top(out Value: Double): HResult; stdcall; +begin + Value := Top; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Set_Top(Value: Double): HResult; stdcall; +begin + Top := Value; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Get_Width(out Value: Double): HResult; stdcall; +begin + Value := Width; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Set_Width(Value: Double): HResult; stdcall; +begin + Width := Value; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Get_Height(out Value: Double): HResult; stdcall; +begin + Value := Height; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_Set_Height(Value: Double): HResult; stdcall; +begin + Height := Value; + Result := S_OK; +end; + +function TfrxComponent.IfrxComponent_FindObject(const ObjectName: WideString; out Object_: IfrxComponent): HResult; stdcall; +var + i: Integer; + TempStr: WideString; +begin + TempStr := ObjectName; + for i := 0 to length(ObjectName) - 1 do + if ObjectName[i] = ' ' then TempStr[i] := '_'; + + Object_ := FindObject(TempStr); + if Object_ <> nil then Result := S_OK else Result := S_FALSE; +end; + +function TfrxComponent.Get_Restrictions(out Value: frxRestrictions): HResult; stdcall; +begin + Value := PInteger( @Restrictions )^; + Result := S_OK; +end; + +function TfrxComponent.Set_Restrictions(Value: frxRestrictions): HResult; stdcall; +type + PfrxRestrictions = ^ TfrxRestrictions; +var + dst: TfrxRestrictions; + src: Integer; +begin + src := Value; + dst := PfrxRestrictions(@src)^; + Restrictions := dst; + Result := S_OK; +end; +{$ENDIF} + + +{ TfrxReportComponent } + +constructor TfrxReportComponent.Create(AOwner: TComponent); +begin + inherited; + FShiftChildren := TList.Create; +end; + +destructor TfrxReportComponent.Destroy; +begin + FShiftChildren.Free; + inherited; +end; + +procedure TfrxReportComponent.GetData; +begin +// do nothing +end; + +procedure TfrxReportComponent.BeforePrint; +begin + FOriginalRect := frxRect(Left, Top, Width, Height); +end; + +procedure TfrxReportComponent.AfterPrint; +begin + with FOriginalRect do + SetBounds(Left, Top, Right, Bottom); +end; + +function TfrxReportComponent.GetComponentText: String; +begin + Result := ''; +end; + +function TfrxReportComponent.GetRealBounds: TfrxRect; +begin + Result := frxRect(AbsLeft, AbsTop, AbsLeft + Width, AbsTop + Height); +end; + + +{ TfrxDialogComponent } + +constructor TfrxDialogComponent.Create(AOwner: TComponent); +begin + inherited; + frComponentStyle := frComponentStyle - [csPreviewVisible]; + Width := 28; + Height := 28; +end; + +destructor TfrxDialogComponent.Destroy; +begin + if FComponent <> nil then + FComponent.Free; + FComponent := nil; + inherited; +end; + +procedure TfrxDialogComponent.DefineProperties(Filer: TFiler); +begin + inherited; + Filer.DefineProperty('pLeft', ReadLeft, WriteLeft, Report <> nil); + Filer.DefineProperty('pTop', ReadTop, WriteTop, Report <> nil); +end; + +procedure TfrxDialogComponent.ReadLeft(Reader: TReader); +begin + Left := Reader.ReadInteger; +end; + +procedure TfrxDialogComponent.ReadTop(Reader: TReader); +begin + Top := Reader.ReadInteger; +end; + +procedure TfrxDialogComponent.WriteLeft(Writer: TWriter); +begin + Writer.WriteInteger(Round(Left)); +end; + +procedure TfrxDialogComponent.WriteTop(Writer: TWriter); +begin + Writer.WriteInteger(Round(Top)); +end; + +procedure TfrxDialogComponent.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +var + r: TRect; + i, w, ImageIndex: Integer; + Item: TfrxObjectItem; +begin + Width := 28; + Height := 28; + r := Rect(Round(Left), Round(Top), Round(Left + 28), Round(Top + 28)); + Canvas.Brush.Color := clBtnFace; + Canvas.FillRect(r); + DrawEdge(Canvas.Handle, r, EDGE_RAISED, BF_RECT); + + ImageIndex := -1; + for i := 0 to frxObjects.Count - 1 do + begin + Item := frxObjects[i]; + if Item.ClassRef = ClassType then + begin + ImageIndex := Item.ButtonImageIndex; + break; + end; + end; + + if ImageIndex <> -1 then + frxResources.ObjectImages.Draw(Canvas, r.Left + 6, r.Top + 6, ImageIndex); + + Canvas.Font.Name := 'Tahoma'; + Canvas.Font.Size := 8; + Canvas.Font.Color := clBlack; + Canvas.Font.Style := []; + w := Canvas.TextWidth(Name); + Canvas.Brush.Color := clWindow; + Canvas.TextOut(r.Left - (w - 28) div 2, r.Bottom + 4, Name); +end; + + +{ TfrxDialogControl } + +constructor TfrxDialogControl.Create(AOwner: TComponent); +begin + inherited; + FBaseName := ClassName; + Delete(FBaseName, Pos('Tfrx', FBaseName), 4); + Delete(FBaseName, Pos('Control', FBaseName), 7); +end; + +destructor TfrxDialogControl.Destroy; +begin + inherited; + if FControl <> nil then + FControl.Free; + FControl := nil; +end; + +procedure TfrxDialogControl.InitControl(AControl: TControl); +begin + FControl := AControl; + with THackControl(FControl) do + begin + OnClick := DoOnClick; + OnDblClick := DoOnDblClick; + OnMouseDown := DoOnMouseDown; + OnMouseMove := DoOnMouseMove; + OnMouseUp := DoOnMouseUp; + end; + if FControl is TWinControl then + with THackWinControl(FControl) do + begin + OnEnter := DoOnEnter; + OnExit := DoOnExit; + OnKeyDown := DoOnKeyDown; + OnKeyPress := DoOnKeyPress; + OnKeyUp := DoOnKeyUp; + end; + SetParent(Parent); +end; + +procedure TfrxDialogControl.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +var + Bmp: TBitmap; + MemDC: HDC; + OldBitmap: HBITMAP; +begin + Bmp := TBitmap.Create; + Bmp.Width := Round(Width); + Bmp.Height := Round(Height); + Bmp.Canvas.Brush.Color := clBtnFace; + Bmp.Canvas.FillRect(Rect(0, 0, Round(Width) + 1, Round(Height) + 1)); + + Canvas.Lock; + try + MemDC := CreateCompatibleDC(0); + OldBitmap := SelectObject(MemDC, Bmp.Handle); + if FControl is TWinControl then + TWinControl(FControl).PaintTo(MemDC, 0, 0) + else + begin + FControl.Perform(WM_ERASEBKGND, MemDC, 0); + FControl.Perform(WM_PAINT, MemDC, 0); + end; + SelectObject(MemDC, OldBitmap); + DeleteDC(MemDC); + finally + Canvas.Unlock; + end; + + Canvas.Draw(Round(AbsLeft), Round(AbsTop), Bmp); + Bmp.Free; +end; + +function TfrxDialogControl.GetCaption: String; +begin + Result := THackControl(FControl).Caption; +end; + +function TfrxDialogControl.GetColor: TColor; +begin + Result := THackControl(FControl).Color; +end; + +function TfrxDialogControl.GetEnabled: Boolean; +begin + Result := FControl.Enabled; +end; + +procedure TfrxDialogControl.SetLeft(Value: Extended); +begin + inherited; + FControl.Left := Round(Left); +end; + +procedure TfrxDialogControl.SetTop(Value: Extended); +begin + inherited; + FControl.Top := Round(Top); +end; + +procedure TfrxDialogControl.SetWidth(Value: Extended); +begin + inherited; + FControl.Width := Round(Width); +end; + +procedure TfrxDialogControl.SetHeight(Value: Extended); +begin + inherited; + FControl.Height := Round(Height); +end; + +procedure TfrxDialogControl.SetVisible(Value: Boolean); +begin + inherited; + FControl.Visible := Visible; +end; + +procedure TfrxDialogControl.SetCaption(const Value: String); +begin + THackControl(FControl).Caption := Value; +end; + +procedure TfrxDialogControl.SetColor(const Value: TColor); +begin + THackControl(FControl).Color := Value; +end; + +procedure TfrxDialogControl.SetEnabled(const Value: Boolean); +begin + FControl.Enabled := Value; +end; + +function TfrxDialogControl.GetHint: String; +begin + Result := FControl.Hint; +end; + +procedure TfrxDialogControl.SetHint(const Value: String); +begin + FControl.Hint := Value; +end; + +function TfrxDialogControl.GetTabStop: Boolean; +begin + Result := True; + if FControl is TWinControl then + Result := THackWinControl(FControl).TabStop; +end; + +procedure TfrxDialogControl.SetTabStop(const Value: Boolean); +begin + if FControl is TWinControl then + THackWinControl(FControl).TabStop := Value; +end; + +procedure TfrxDialogControl.FontChanged(Sender: TObject); +begin + inherited; + if FControl <> nil then + THackControl(FControl).Font.Assign(Font); +end; + +procedure TfrxDialogControl.SetParentFont(const Value: Boolean); +begin + inherited; + if FControl <> nil then + THackControl(FControl).ParentFont := Value; +end; + +procedure TfrxDialogControl.SetParent(AParent: TfrxComponent); +begin + inherited; + if FControl <> nil then + if AParent is TfrxDialogControl then + FControl.Parent := TWinControl(TfrxDialogControl(AParent).Control) + else if AParent is TfrxDialogPage then + FControl.Parent := TfrxDialogPage(AParent).DialogForm + else + FControl.Parent := frxParentForm; +end; + +procedure TfrxDialogControl.SetName(const AName: TComponentName); +var + ChangeText: Boolean; +begin + ChangeText := (csSetCaption in FControl.ControlStyle) and (Name = Caption) and + not IsLoading; + inherited SetName(AName); + if ChangeText then + Caption := AName; +end; + +procedure TfrxDialogControl.DoOnClick(Sender: TObject); +begin + if Report <> nil then + Report.DoNotifyEvent(Self, FOnClick); +end; + +procedure TfrxDialogControl.DoOnDblClick(Sender: TObject); +begin + if Report <> nil then + Report.DoNotifyEvent(Self, FOnDblClick); +end; + +procedure TfrxDialogControl.DoOnEnter(Sender: TObject); +begin + if Report <> nil then + Report.DoNotifyEvent(Self, FOnEnter); +end; + +procedure TfrxDialogControl.DoOnExit(Sender: TObject); +begin + if Report <> nil then + Report.DoNotifyEvent(Self, FOnExit); +end; + +procedure TfrxDialogControl.DoOnKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +var + v: Variant; +begin + v := VarArrayOf([Integer(Self), Key, ShiftToByte(Shift)]); + if (Report <> nil) and (FOnKeyDown <> '') then + begin + Report.DoParamEvent(FOnKeyDown, v); + Key := v[1]; + end; +end; + +procedure TfrxDialogControl.DoOnKeyPress(Sender: TObject; var Key: Char); +var + v: Variant; +begin + v := VarArrayOf([Integer(Self), Key]); + if (Report <> nil) and (FOnKeyPress <> '') then + begin + Report.DoParamEvent(FOnKeyPress, v); + if VarToStr(v[1]) <> '' then + Key := VarToStr(v[1])[1] + else + Key := Chr(0); + end; +end; + +procedure TfrxDialogControl.DoOnKeyUp(Sender: TObject; var Key: Word; + Shift: TShiftState); +var + v: Variant; +begin + v := VarArrayOf([Integer(Self), Key, ShiftToByte(Shift)]); + if (Report <> nil) and (FOnKeyUp <> '') then + begin + Report.DoParamEvent(FOnKeyUp, v); + Key := v[1]; + end; +end; + +procedure TfrxDialogControl.DoOnMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var + v: Variant; +begin + v := VarArrayOf([Integer(Self), Button, ShiftToByte(Shift), X, Y]); + if Report <> nil then + Report.DoParamEvent(FOnMouseDown, v); +end; + +procedure TfrxDialogControl.DoOnMouseMove(Sender: TObject; + Shift: TShiftState; X, Y: Integer); +var + v: Variant; +begin + v := VarArrayOf([Integer(Self), ShiftToByte(Shift), X, Y]); + if Report <> nil then + Report.DoParamEvent(FOnMouseMove, v); +end; + +procedure TfrxDialogControl.DoOnMouseUp(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var + v: Variant; +begin + v := VarArrayOf([Integer(Self), Button, ShiftToByte(Shift), X, Y]); + if Report <> nil then + Report.DoParamEvent(FOnMouseUp, v); +end; + + +{ TfrxFrameLine } + +constructor TfrxFrameLine.Create(AFrame: TfrxFrame); +begin + FColor := clBlack; + FStyle := fsSolid; + FWidth := 1; + FFrame := AFrame; +end; + +procedure TfrxFrameLine.Assign(Source: TPersistent); +begin + if Source is TfrxFrameLine then + begin + FColor := TfrxFrameLine(Source).Color; + FStyle := TfrxFrameLine(Source).Style; + FWidth := TfrxFrameLine(Source).Width; + end; +end; + +function TfrxFrameLine.IsColorStored: Boolean; +begin + Result := FColor <> FFrame.Color; +end; + +function TfrxFrameLine.IsStyleStored: Boolean; +begin + Result := FStyle <> FFrame.Style; +end; + +function TfrxFrameLine.IsWidthStored: Boolean; +begin + Result := FWidth <> FFrame.Width; +end; + +function TfrxFrameLine.Diff(ALine: TfrxFrameLine; const LineName: String; + ColorChanged, StyleChanged, WidthChanged: Boolean): String; +begin + Result := ''; + + if (ColorChanged and IsColorStored) or (not ColorChanged and (FColor <> ALine.Color)) then + Result := Result + ' ' + LineName + '.Color="' + IntToStr(FColor) + '"'; + if (StyleChanged and IsStyleStored) or (not StyleChanged and (FStyle <> ALine.Style)) then + Result := Result + ' ' + LineName + '.Style="' + frxValueToXML(FStyle) + '"'; + if (WidthChanged and IsWidthStored) or (not WidthChanged and FloatDiff(FWidth, ALine.Width)) then + Result := Result + ' ' + LineName + '.Width="' + FloatToStr(FWidth) + '"'; +end; + + +{ TfrxFrame } + +constructor TfrxFrame.Create; +begin + FColor := clBlack; + FShadowColor := clBlack; + FShadowWidth := 4; + FStyle := fsSolid; + FTyp := []; + FWidth := 1; + + FLeftLine := TfrxFrameLine.Create(Self); + FTopLine := TfrxFrameLine.Create(Self); + FRightLine := TfrxFrameLine.Create(Self); + FBottomLine := TfrxFrameLine.Create(Self); +{$IFDEF FR_COM} + inherited Create(IfrxFrame); +{$ENDIF} +end; + +destructor TfrxFrame.Destroy; +begin + FLeftLine.Free; + FTopLine.Free; + FRightLine.Free; + FBottomLine.Free; + inherited; +end; + +procedure TfrxFrame.Assign(Source: TPersistent); +begin + if Source is TfrxFrame then + begin + FColor := TfrxFrame(Source).Color; + FDropShadow := TfrxFrame(Source).DropShadow; + FShadowColor := TfrxFrame(Source).ShadowColor; + FShadowWidth := TfrxFrame(Source).ShadowWidth; + FStyle := TfrxFrame(Source).Style; + FTyp := TfrxFrame(Source).Typ; + FWidth := TfrxFrame(Source).Width; + + FLeftLine.Assign(TfrxFrame(Source).LeftLine); + FTopLine.Assign(TfrxFrame(Source).TopLine); + FRightLine.Assign(TfrxFrame(Source).RightLine); + FBottomLine.Assign(TfrxFrame(Source).BottomLine); + end; +end; + +function TfrxFrame.IsShadowWidthStored: Boolean; +begin + Result := FShadowWidth <> 4; +end; + +function TfrxFrame.IsTypStored: Boolean; +begin + Result := FTyp <> []; +end; + +function TfrxFrame.IsWidthStored: Boolean; +begin + Result := FWidth <> 1; +end; + +procedure TfrxFrame.SetBottomLine(const Value: TfrxFrameLine); +begin + FBottomLine.Assign(Value); +end; + +procedure TfrxFrame.SetLeftLine(const Value: TfrxFrameLine); +begin + FLeftLine.Assign(Value); +end; + +procedure TfrxFrame.SetRightLine(const Value: TfrxFrameLine); +begin + FRightLine.Assign(Value); +end; + +procedure TfrxFrame.SetTopLine(const Value: TfrxFrameLine); +begin + FTopLine.Assign(Value); +end; + +procedure TfrxFrame.SetColor(const Value: TColor); +begin + FColor := Value; + FLeftLine.Color := Value; + FTopLine.Color := Value; + FRightLine.Color := Value; + FBottomLine.Color := Value; +end; + +procedure TfrxFrame.SetStyle(const Value: TfrxFrameStyle); +begin + FStyle := Value; + FLeftLine.Style := Value; + FTopLine.Style := Value; + FRightLine.Style := Value; + FBottomLine.Style := Value; +end; + +procedure TfrxFrame.SetWidth(const Value: Extended); +begin + FWidth := Value; + FLeftLine.Width := Value; + FTopLine.Width := Value; + FRightLine.Width := Value; + FBottomLine.Width := Value; +end; + +function TfrxFrame.Diff(AFrame: TfrxFrame): String; +var + i: Integer; + ColorChanged, StyleChanged, WidthChanged: Boolean; +begin + Result := ''; + + ColorChanged := FColor <> AFrame.Color; + if ColorChanged then + Result := Result + ' Frame.Color="' + IntToStr(FColor) + '"'; + if FDropShadow <> AFrame.DropShadow then + Result := Result + ' Frame.DropShadow="' + frxValueToXML(FDropShadow) + '"'; + if FShadowColor <> AFrame.ShadowColor then + Result := Result + ' Frame.ShadowColor="' + IntToStr(FShadowColor) + '"'; + if FloatDiff(FShadowWidth, AFrame.ShadowWidth) then + Result := Result + ' Frame.ShadowWidth="' + FloatToStr(FShadowWidth) + '"'; + StyleChanged := FStyle <> AFrame.Style; + if StyleChanged then + Result := Result + ' Frame.Style="' + frxValueToXML(FStyle) + '"'; + if FTyp <> AFrame.Typ then + begin + i := 0; + if ftLeft in FTyp then i := i or 1; + if ftRight in FTyp then i := i or 2; + if ftTop in FTyp then i := i or 4; + if ftBottom in FTyp then i := i or 8; + Result := Result + ' Frame.Typ="' + IntToStr(i) + '"'; + end; + WidthChanged := FloatDiff(FWidth, AFrame.Width); + if WidthChanged then + Result := Result + ' Frame.Width="' + FloatToStr(FWidth) + '"'; + + Result := Result + FLeftLine.Diff(AFrame.LeftLine, 'Frame.LeftLine', + ColorChanged, StyleChanged, WidthChanged); + Result := Result + FTopLine.Diff(AFrame.TopLine, 'Frame.TopLine', + ColorChanged, StyleChanged, WidthChanged); + Result := Result + FRightLine.Diff(AFrame.RightLine, 'Frame.RightLine', + ColorChanged, StyleChanged, WidthChanged); + Result := Result + FBottomLine.Diff(AFrame.BottomLine, 'Frame.BottomLine', + ColorChanged, StyleChanged, WidthChanged); +end; + +{$IFDEF FR_COM} +function TfrxFrame.Get_Color(out Value: Integer): HResult; stdcall; +begin + Value := Color; + Result := S_OK; +end; + +function TfrxFrame.Set_Color(Value: Integer): HResult; stdcall; +begin + Color := Value; + Result := S_OK; +end; + +function TfrxFrame.Get_DropShadow(out Value: WordBool): HResult; stdcall; +begin + Value := DropShadow; + Result := S_OK; +end; + +function TfrxFrame.Set_DropShadow(Value: WordBool): HResult; stdcall; +begin + DropShadow := Value; + Result := S_OK; +end; + +function TfrxFrame.Get_ShadowColor(out Value: Integer): HResult; stdcall; +begin + Value := ShadowColor; + Result := S_OK; +end; + +function TfrxFrame.Set_ShadowColor(Value: Integer): HResult; stdcall; +begin + ShadowColor := Value; + Result := S_OK; +end; + +function TfrxFrame.Get_ShadowWidth(out Value: Double): HResult; stdcall; +begin + Value := ShadowWidth; + Result := S_OK; +end; + +function TfrxFrame.Set_ShadowWidth(Value: Double): HResult; stdcall; +begin + ShadowWidth := Value; + Result := S_OK; +end; + +function TfrxFrame.Get_Style(out Value: frxFrameStyle): HResult; stdcall; +begin + Value := frxFrameStyle(Style); + Result := S_OK; +end; + +function TfrxFrame.Set_Style(Value: frxFrameStyle): HResult; stdcall; +begin + Style := TfrxFrameStyle(Value); + Result := S_OK; +end; + +function TfrxFrame.Get_FrameType(out Value: Integer): HResult; stdcall; +begin + Value := PInteger(@Typ)^; + Result := S_OK; +end; + +function TfrxFrame.Set_FrameType(Value: Integer): HResult; stdcall; +type + PfrxFrameTypes = ^ TfrxFrameTypes; +var + dst: TfrxFrameTypes; + src: Integer; +begin + src := Value; + dst := PfrxFrameTypes(@src)^; + Typ := dst; + Result := S_OK; +end; + +function TfrxFrame.Get_Width(out Value: Double): HResult; stdcall; +begin + Value := Width; + Result := S_OK; +end; + +function TfrxFrame.Set_Width(Value: Double): HResult; stdcall; +begin + Width := Value; + Result := S_OK; +end; +{$ENDIF} + + +{ TfrxView } + +constructor TfrxView.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + frComponentStyle := frComponentStyle + [csDefaultDiff]; + FAlign := baNone; + FBrushStyle := bsSolid; + FColor := clTransparent; + FFrame := TfrxFrame.Create; + FShiftMode := smAlways; + FPrintable := True; + FPlainText := False; +end; + +destructor TfrxView.Destroy; +begin + FFrame.Free; + inherited; +end; + +procedure TfrxView.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FDataSet) then + FDataSet := nil; +end; + +procedure TfrxView.SetDataSet(const Value: TfrxDataSet); +begin + FDataSet := Value; + if FDataSet = nil then + FDataSetName := '' else + FDataSetName := FDataSet.UserName; +end; + +procedure TfrxView.SetDataSetName(const Value: String); +begin + FDataSetName := Value; + FDataSet := frxFindDataSet(FDataSet, FDataSetName, Report); +end; + +function TfrxView.GetDataSetName: String; +begin + if FDataSet = nil then + Result := FDataSetName else + Result := FDataSet.UserName; +end; + +procedure TfrxView.SetFrame(const Value: TfrxFrame); +begin + FFrame.Assign(Value); +end; + +procedure TfrxView.BeginDraw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); +begin + FCanvas := Canvas; + FScaleX := ScaleX; + FScaleY := ScaleY; + FOffsetX := OffsetX; + FOffsetY := OffsetY; + FX := Round(AbsLeft * ScaleX + OffsetX); + FY := Round(AbsTop * ScaleY + OffsetY); + FX1 := Round((AbsLeft + Width) * ScaleX + OffsetX); + FY1 := Round((AbsTop + Height) * ScaleY + OffsetY); + + if Frame.DropShadow then + begin + FX1 := FX1 - Round(Frame.ShadowWidth * ScaleX); + FY1 := FY1 - Round(Frame.ShadowWidth * ScaleY); + end; + + FDX := FX1 - FX; + FDY := FY1 - FY; + FFrameWidth := Round(Frame.Width * ScaleX); +end; + +procedure TfrxView.DrawBackground; +var + br, oldbr: HBRUSH; +begin + with FCanvas do + begin + if FColor <> clNone then + begin + Brush.Color := FColor; + Brush.Style := bsSolid; + FillRect(Rect(FX, FY, FX1, FY1)); + end; + if FBrushStyle <> bsSolid then + begin + { Brush.Style := xxx does not work for some printers } + br := CreateHatchBrush(Integer(FBrushStyle) - 2, ColorToRGB(Frame.Color)); + oldbr := SelectObject(Handle, br); + Rectangle(FX, FY, FX1 + 1, FY1 + 1); + SelectObject(Handle, oldbr); + DeleteObject(br); + end; + end; +end; + +procedure TfrxView.DrawLine(x, y, x1, y1, w: Integer); +var + i, d: Integer; +begin + with FCanvas do + begin + if w = 0 then + w := 1; + if w mod 2 = 0 then + d := 1 else + d := 0; + + for i := (-w div 2) to (w div 2 - d) do + begin + if Abs(x1 - x) > Abs(y1 - y) then + begin + MoveTo(x, y + i); + LineTo(x1, y1 + i); + end + else + begin + MoveTo(x + i, y); + LineTo(x1 + i, y1); + end; + end; + end; +end; + +procedure TfrxView.DrawFrame; +var + d: Integer; + + procedure Line(x, y, x1, y1: Integer; Line: TfrxFrameLine; + Typ: TfrxFrameType; gap1, gap2: Boolean); + var + g1, g2, g3, g4, fw: Integer; + + procedure Line1(x, y, x1, y1: Integer); + begin + FCanvas.MoveTo(x, y); + FCanvas.LineTo(x1, y1); + end; + + begin + fw := Round(Line.Width * FScaleX); + if Line.Style = fsSolid then + Line1(x, y, x1, y1) + else if Line.Style = fsDouble then + begin + if gap1 then + g1 := fw else + g1 := 0; + if gap2 then + g2 := fw else + g2 := 0; + g3 := -g1; + g4 := -g2; + + if Typ in [ftLeft, ftTop] then + begin + g1 := -g1; + g2 := -g2; + g3 := -g3; + g4 := -g4; + end; + + if x = x1 then + Line1(x - fw, y + g1, x1 - fw, y1 - g2) else + Line1(x + g1, y - fw, x1 - g2, y1 - fw); + if Color <> clNone then + begin + FCanvas.Pen.Color := Color; + Line1(x, y, x1, y1); + end; + FCanvas.Pen.Color := Line.Color; + if x = x1 then + Line1(x + fw, y + g3, x1 + fw, y1 - g4) else + Line1(x + g3, y + fw, x1 - g4, y1 + fw); + end + else + DrawLine(x, y, x1, y1, fw); + end; + + procedure SetPen(Line: TfrxFrameLine); + begin + with FCanvas do + begin + Pen.Color := Line.Color; + if Line.Style in [fsSolid, fsDouble] then + begin + Pen.Style := psSolid; + Pen.Width := Round(Line.Width * FScaleX); + end + else + begin + Pen.Style := TPenStyle(Line.Style); + Pen.Width := 1; + end; + end; + end; + +begin + if Frame.DropShadow then + with FCanvas do + begin + Pen.Style := psSolid; + Pen.Color := Frame.ShadowColor; + d := Round(Frame.ShadowWidth * FScaleX); + DrawLine(FX1 + d div 2, FY + d, FX1 + d div 2, FY1, d); + d := Round(Frame.ShadowWidth * FScaleY); + DrawLine(FX + d, FY1 + d div 2, FX1 + d, FY1 + d div 2, d); + end; + + if (Frame.Typ <> []) and (Frame.Color <> clNone) and (Frame.Width <> 0) then + with FCanvas do + begin + Brush.Style := bsSolid; + if Frame.Style <> fsSolid then + if Color = clNone then + Brush.Style := bsClear else + Brush.Color := Color; + + if ftLeft in Frame.Typ then + begin + SetPen(FFrame.LeftLine); + if Pen.Width = 2 then + d := 1 else + d := 0; + Line(FX, FY - d, FX, FY1, FFrame.LeftLine, ftLeft, ftTop in Frame.Typ, ftBottom in Frame.Typ); + end; + if ftRight in Frame.Typ then + begin + SetPen(FFrame.RightLine); + Line(FX1, FY, FX1, FY1, FFrame.RightLine, ftRight, ftTop in Frame.Typ, ftBottom in Frame.Typ); + end; + if ftTop in Frame.Typ then + begin + SetPen(FFrame.TopLine); + Line(FX, FY, FX1, FY, FFrame.TopLine, ftTop, ftLeft in Frame.Typ, ftRight in Frame.Typ); + end; + if ftBottom in Frame.Typ then + begin + SetPen(FFrame.BottomLine); + if Pen.Width = 1 then + d := 1 else + d := 0; + Line(FX, FY1, FX1 + d, FY1, FFrame.BottomLine, ftBottom, ftLeft in Frame.Typ, ftRight in Frame.Typ); + end; + end; +end; + +procedure TfrxView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); +begin + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + DrawBackground; + DrawFrame; +end; + +function TfrxView.Diff(AComponent: TfrxComponent): String; +var + v: TfrxView; +begin + Result := inherited Diff(AComponent); + v := TfrxView(AComponent); + + if FBrushStyle <> v.FBrushStyle then + Result := Result + ' BrushStyle="' + frxValueToXML(FBrushStyle) + '"'; + if FAlign <> v.FAlign then + Result := Result + ' Align="' + frxValueToXML(FAlign) + '"'; + if FColor <> v.FColor then + Result := Result + ' Color="' + IntToStr(FColor) + '"'; + Result := Result + FFrame.Diff(v.FFrame); + if Cursor <> v.Cursor then + Result := Result + ' Cursor="' + frxValueToXML(Cursor) + '"'; + if FPrintable <> v.FPrintable then + Result := Result + ' Printable="' + frxValueToXML(FPrintable) + '"'; + if TagStr <> v.TagStr then + Result := Result + ' TagStr="' + frxStrToXML(TagStr) + '"'; + if URL <> v.URL then + Result := Result + ' URL="' + frxStrToXML(URL) + '"'; +end; + +function TfrxView.IsDataField: Boolean; +begin + Result := (DataSet <> nil) and (Length(DataField) <> 0); +end; + +procedure TfrxView.BeforePrint; +begin + inherited; + FTempTag := FTagStr; + FTempURL := FURL; +end; + +procedure TfrxView.ExpandVariables(var Expr: String); +var + i, j: Integer; + s: String; +begin + i := 1; + repeat + while i < Length(Expr) do + if isDBCSLeadByte(Byte(Expr[i])) then { if DBCS then skip 2 bytes } + Inc(i, 2) + else if (Expr[i] <> '[') then + Inc(i) + else + break; + + s := frxGetBrackedVariable(Expr, '[', ']', i, j); + if i <> j then + begin + Delete(Expr, i, j - i + 1); + s := VarToStr(Report.Calc(s)); + Insert(s, Expr, i); + Inc(i, Length(s)); + j := 0; + end; + until i = j; +end; + +procedure TfrxView.GetData; +begin + if (FTagStr <> '') and (Pos('[', FTagStr) <> 0) then + ExpandVariables(FTagStr); + if (FURL <> '') and (Pos('[', FURL) <> 0) then + ExpandVariables(FURL); +end; + +procedure TfrxView.AfterPrint; +begin + inherited; + FTagStr := FTempTag; + FURL := FTempURL; +end; + +{$IFDEF FR_COM} +function TfrxView.Get_DataField(out Value: WideString): HResult; stdcall; +begin + Value := FDataField; + Result := S_OK; +end; + +function TfrxView.Set_DataField(const Value: WideString): HResult; stdcall; +begin + FDataField := Value; + Result := S_OK; +end; + +function TfrxView.Get_TagStr(out Value: WideString): HResult; stdcall; +begin + Value := FTagStr; + Result := S_OK; +end; + +function TfrxView.Set_TagStr(const Value: WideString): HResult; stdcall; +begin + FTagStr := Value; + Result := S_OK; +end; + +function TfrxView.Get_URL(out Value: WideString): HResult; stdcall; +begin + Value := FURL; + Result := S_OK; +end; + +function TfrxView.Set_URL(const Value: WideString): HResult; stdcall; +begin + FURL := Value; + Result := S_OK; +end; + +function TfrxView.Get_DataSetName(out Value: WideString): HResult; stdcall; +begin + Value := GetDataSetName; + Result := S_OK; +end; + +function TfrxView.Set_DataSetName(const Value: WideString): HResult; stdcall; +begin + SetDataSetName(Value); + Result := S_OK; +end; + +function TfrxView.Get_Name(out Value: WideString): HResult; stdcall; +begin + Value := Name; + Result := S_OK; +end; + +function TfrxView.Get_Frame(out Value: IfrxFrame): HResult; stdcall; +begin + Value := Frame as IfrxFrame; + Result := S_OK; +end; + +function TfrxView.Get_ShiftMode(out Value: frxShiftMode): HResult; stdcall; +begin + Value := TOleEnum(ShiftMode); + Result := S_OK; +end; + +function TfrxView.Set_ShiftMode(Value: frxShiftMode): HResult; stdcall; +begin + ShiftMode := TfrxShiftMode(Value); + Result := S_OK; +end; + +function TfrxView.Get_Align(out Value: frxAlign): HResult; stdcall; +begin + Value := TOleEnum(Align); + Result := S_OK; +end; + +function TfrxView.Set_Align(Value: frxAlign): HResult; stdcall; +begin + Align := TfrxAlign(Value); + Result := S_OK; +end; +{$ENDIF} + + +{ TfrxShapeView } + +constructor TfrxShapeView.Create(AOwner: TComponent); +begin + inherited; + frComponentStyle := frComponentStyle - [csDefaultDiff]; +end; + +constructor TfrxShapeView.DesignCreate(AOwner: TComponent; Flags: Word); +begin + inherited; + FShape := TfrxShapeKind(Flags); +end; + +procedure TfrxShapeView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +var + SaveLeft, SaveTop, SaveWidth, SaveHeight: Extended; + + procedure DrawShape; + var + min: Integer; + begin + if FDY < FDX then + min := FDY else + min := FDX; + + with Canvas do + case FShape of + skRectangle: + Rectangle(FX, FY, FX1 + 1, FY1 + 1); + + skRoundRectangle: + begin + if FCurve = 0 then + min := min div 4 + else + min := Round(FCurve * FScaleX * 10); + RoundRect(FX, FY, FX1 + 1, FY1 + 1, min, min); + end; + + skEllipse: + Ellipse(FX, FY, FX1 + 1, FY1 + 1); + + skTriangle: + Polygon([Point(FX1, FY1), Point(FX, FY1), Point(FX + FDX div 2, FY), Point(FX1, FY1)]); + + skDiamond: + Polygon([Point(FX + FDX div 2, FY), Point(FX1, FY + FDY div 2), + Point(FX + FDX div 2, FY1), Point(FX, FY + FDY div 2)]); + + skDiagonal1: + DrawLine(FX, FY1, FX1, FY, FFrameWidth); + + skDiagonal2: + DrawLine(FX, FY, FX1, FY1, FFrameWidth); + end; + end; + + procedure DoDraw; + begin + with Canvas do + begin + Pen.Color := Frame.Color; + Pen.Width := FFrameWidth; + Brush.Style := bsSolid; + SetBkMode(Handle, Opaque); + + if FBrushStyle = bsSolid then + begin + Pen.Style := TPenStyle(Frame.Style); + if FColor <> clNone then + Brush.Color := FColor else + Brush.Style := bsClear; + DrawShape; + end + else + begin + Pen.Style := TPenStyle(Frame.Style); + if FColor <> clNone then + begin + Brush.Color := FColor; + DrawShape; + end; + Brush.Style := FBrushStyle; + Brush.Color := Frame.Color; + DrawShape; + end; + end; + end; + +begin + if Frame.Style = fsDouble then + begin + Frame.Style := fsSolid; + SaveLeft := Left; + SaveTop := Top; + SaveWidth := Width; + SaveHeight := Height; + + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + DoDraw; + + case FShape of + skRectangle, skRoundRectangle, skEllipse: + begin + Left := Left + 2 * Frame.Width; + Top := Top + 2 * Frame.Width; + Width := Width - 4 * Frame.Width; + Height := Height - 4 * Frame.Width; + end; + + skTriangle: + begin + Left := Left + 4 * Frame.Width; + Top := Top + 4 * Frame.Width; + Width := Width - 8 * Frame.Width; + Height := Height - 6 * Frame.Width; + end; + + skDiamond: + begin + Left := Left + 3 * Frame.Width; + Top := Top + 3 * Frame.Width; + Width := Width - 6 * Frame.Width; + Height := Height - 6 * Frame.Width; + end; + + skDiagonal1, skDiagonal2: + begin + Left := Left + 2 * Frame.Width; + end; + end; + + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + DoDraw; + + Frame.Style := fsDouble; + Left := SaveLeft; + Top := SaveTop; + Width := SaveWidth; + Height := SaveHeight; + end + else + begin + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + DoDraw; + end; +end; + +function TfrxShapeView.Diff(AComponent: TfrxComponent): String; +begin + Result := inherited Diff(AComponent); + + if FShape <> TfrxShapeView(AComponent).FShape then + Result := Result + ' Shape="' + frxValueToXML(FShape) + '"'; +end; + +class function TfrxShapeView.GetDescription: String; +begin + Result := frxResources.Get('obShape'); +end; + +{$IFDEF FR_COM} +function TfrxShapeView.Get_Curve(out Value: Integer): HResult; stdcall; +begin + Value := Curve; + Result := S_OK; +end; + +function TfrxShapeView.Set_Curve(Value: Integer): HResult; stdcall; +begin + Curve := Value; + Result := S_OK; +end; + +function TfrxShapeView.Get_ShapeType(out Value: frxShapeType): HResult; stdcall; +begin + Value := frxShapeType(Shape); + Result := S_OK; +end; + +function TfrxShapeView.Set_ShapeType(Value: frxShapeType): HResult; stdcall; +begin + Shape := TfrxShapeKind(Value); + Result := S_OK; +end; +{$ENDIF} + +{ TfrxHighlight } + +constructor TfrxHighlight.Create; +begin + FColor := clTransparent; +{$IFNDEF FR_COM} + FFont := TFont.Create; +{$ELSE} + inherited Create(IfrxHighlight); + FFont := TfrxFont.Create; +{$ENDIF} + with FFont do + begin + Name := DefFontName; + Size := DefFontSize; + Color := clRed; + Charset := frxCharset; + end; +end; + +destructor TfrxHighlight.Destroy; +begin + FFont.Free; + inherited; +end; + +procedure TfrxHighlight.Assign(Source: TPersistent); +begin + if Source is TfrxHighlight then + begin + FFont.Assign(TfrxHighlight(Source).Font); + FColor := TfrxHighlight(Source).Color; + FCondition := TfrxHighlight(Source).Condition; + end; +end; + +procedure TfrxHighlight.SetFont(const Value: TFont); +begin + FFont.Assign(Value); +end; + +{$IFDEF FR_COM} +function TfrxHighlight.GetFont: TFont; +begin + Result := FFont as TFont; +end; + +function TfrxHighlight.Get_Active(out Value: WordBool): HResult; stdcall; +begin + Value := Active; + Result := S_OK; +end; + +function TfrxHighlight.Set_Active(Value: WordBool): HResult; stdcall; +begin + Active := Value; + Result := S_OK; +end; + +function TfrxHighlight.Get_Color(out Value: Integer): HResult; stdcall; +begin + Value := Color; + Result := S_OK; +end; + +function TfrxHighlight.Set_Color(Value: Integer): HResult; stdcall; +begin + Color := Value; + Result := S_OK; +end; + +function TfrxHighlight.Get_Font(out Value: IfrxFont): HResult; stdcall; +begin + Value := FFont as IfrxFont; + Value._AddRef(); + Result := S_OK; +end; +{$ENDIF} + +{ TfrxFormat } + +procedure TfrxFormat.Assign(Source: TPersistent); +begin + if Source is TfrxFormat then + begin + FDecimalSeparator := TfrxFormat(Source).DecimalSeparator; + FFormatStr := TfrxFormat(Source).FormatStr; + FKind := TfrxFormat(Source).Kind; + end; +end; + +{$IFDEF FR_COM} +constructor TfrxFormat.Create; +begin + inherited Create(IfrxDisplayFormat); +end; + +function TfrxFormat.Get_DecimalSeparator(out Value: WideString): HResult; stdcall; +begin + Value := DecimalSeparator; + Result := S_OK; +end; + +function TfrxFormat.Set_DecimalSeparator(const Value: WideString): HResult; stdcall; +begin + DecimalSeparator := Value; + Result := S_OK; +end; + +function TfrxFormat.Get_FormatStr(out Value: WideString): HResult; stdcall; +begin + Value := FormatStr; + Result := S_OK; +end; + +function TfrxFormat.Set_FormatStr(const Value: WideString): HResult; stdcall; +begin + FormatStr := Value; + Result := S_OK; +end; + +function TfrxFormat.Get_Kind(out Value: frxFormatKind): HResult; stdcall; +begin + Value := frxFormatKind(Kind); + Result := S_OK; +end; + +function TfrxFormat.Set_Kind(Value: frxFormatKind): HResult; stdcall; +begin + Kind := TfrxFormatKind(Value); + Result := S_OK; +end; +{$ENDIF} + +{ TfrxStretcheable } + +constructor TfrxStretcheable.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FStretchMode := smDontStretch; +end; + +function TfrxStretcheable.CalcHeight: Extended; +begin + Result := Height; +end; + +function TfrxStretcheable.DrawPart: Extended; +begin + Result := 0; +end; + +procedure TfrxStretcheable.InitPart; +begin +// +end; + +{$IFDEF FR_COM} +function TfrxStretcheable.Get_StretchMode(out Value: frxStretchMode): HResult; stdcall; +begin + Value := frxStretchMode(StretchMode); + Result := S_OK; +end; + +function TfrxStretcheable.Set_StretchMode(Value: frxStretchMode): HResult; stdcall; +begin + StretchMode := TfrxStretchMode(Value); + Result := S_OK; +end; +{$ENDIF} + +{ TfrxCustomMemoView } + +constructor TfrxCustomMemoView.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + frComponentStyle := frComponentStyle - [csDefaultDiff]; + FHighlight := TfrxHighlight.Create; + FDisplayFormat := TfrxFormat.Create; + FMemo := TWideStrings.Create; + FAllowExpressions := True; + FClipped := True; + FExpressionDelimiters := '[,]'; + FGapX := 2; + FGapY := 1; + FHAlign := haLeft; + FVAlign := vaTop; + FLineSpacing := 2; + ParentFont := True; + FWordWrap := True; + FWysiwyg := True; + FLastValue := Null; +end; + +destructor TfrxCustomMemoView.Destroy; +begin + FHighlight.Free; + FDisplayFormat.Free; + FMemo.Free; + inherited; +end; + +class function TfrxCustomMemoView.GetDescription: String; +begin + Result := frxResources.Get('obText'); +end; + +procedure TfrxCustomMemoView.Notification(AComponent: TComponent; + Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FFlowTo) then + FFlowTo := nil; +end; + +function TfrxCustomMemoView.IsExprDelimitersStored: Boolean; +begin + Result := FExpressionDelimiters <> '[,]'; +end; + +function TfrxCustomMemoView.IsLineSpacingStored: Boolean; +begin + Result := FLineSpacing <> 2; +end; + +function TfrxCustomMemoView.IsGapXStored: Boolean; +begin + Result := FGapX <> 2; +end; + +function TfrxCustomMemoView.IsGapYStored: Boolean; +begin + Result := FGapY <> 1; +end; + +function TfrxCustomMemoView.IsParagraphGapStored: Boolean; +begin + Result := FParagraphGap <> 0; +end; + +function TfrxCustomMemoView.IsCharSpacingStored: Boolean; +begin + Result := FCharSpacing <> 0; +end; + +function TfrxCustomMemoView.IsHighlightStored: Boolean; +begin + Result := Trim(FHighlight.Condition) <> ''; +end; + +procedure TfrxCustomMemoView.SetRotation(Value: Integer); +begin + FRotation := Value mod 360; +end; + +procedure TfrxCustomMemoView.SetText(const Value: WideString); +begin + FMemo.Text := Value; +end; + +function TfrxCustomMemoView.GetText: WideString; +begin + Result := FMemo.Text; +end; + +procedure TfrxCustomMemoView.SetMemo(const Value: TWideStrings); +begin + FMemo.Assign(Value); +end; + +procedure TfrxCustomMemoView.SetHighlight(const Value: TfrxHighlight); +begin + FHighlight.Assign(Value); +end; + +procedure TfrxCustomMemoView.SetDisplayFormat(const Value: TfrxFormat); +begin + FDisplayFormat.Assign(Value); +end; + +procedure TfrxCustomMemoView.SetStyle(const Value: String); +begin + FStyle := Value; + if Report <> nil then + ApplyStyle(Report.Styles.Find(FStyle)); +end; + +function TfrxCustomMemoView.AdjustCalcHeight: Extended; +begin + Result := GapY * 2; + if ftTop in Frame.Typ then + Result := Result + (Frame.Width - 1) / 2; + if ftBottom in Frame.Typ then + Result := Result + Frame.Width / 2; + if Frame.DropShadow then + Result := Result + Frame.ShadowWidth; +end; + +function TfrxCustomMemoView.AdjustCalcWidth: Extended; +begin + Result := GapX * 2; + if ftLeft in Frame.Typ then + Result := Result + (Frame.Width - 1) / 2; + if ftRight in Frame.Typ then + Result := Result + Frame.Width / 2; + if Frame.DropShadow then + Result := Result + Frame.ShadowWidth; +end; + +procedure TfrxCustomMemoView.BeginDraw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); +var + bx, by, bx1, by1, wx1, wx2, wy1, wy2, gx1, gy1: Integer; +begin + inherited BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + + wx1 := Round((Frame.Width * ScaleX - 1) / 2); + wx2 := Round(Frame.Width * ScaleX / 2); + wy1 := Round((Frame.Width * ScaleY - 1) / 2); + wy2 := Round(Frame.Width * ScaleY / 2); + + bx := FX; + by := FY; + bx1 := FX1; + by1 := FY1; + if ftLeft in Frame.Typ then + Inc(bx, wx1); + if ftRight in Frame.Typ then + Dec(bx1, wx2); + if ftTop in Frame.Typ then + Inc(by, wy1); + if ftBottom in Frame.Typ then + Dec(by1, wy2); + gx1 := Round(GapX * ScaleX); + gy1 := Round(GapY * ScaleY); + + FTextRect := Rect(bx + gx1, by + gy1, bx1 - gx1 + 1, by1 - gy1 + 1); +end; + +procedure TfrxCustomMemoView.SetDrawParams(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); +var + ScaledRect: TRect; + SaveWidth: Extended; + FDrawText: TfrxDrawText; +begin + if Report <> nil then + FDrawText := Report.FDrawText else + FDrawText := frxDrawText; + + if FHighlight.Active then + begin + FDrawText.SetFont(FHighlight.Font); + FColor := FHighlight.Color; + end + else + FDrawText.SetFont(FFont); + FDrawText.SetOptions(FWordWrap, FAllowHTMLTags, FRTLReading, FWordBreak, + FClipped, FWysiwyg, FRotation); + FDrawText.SetGaps(FParagraphGap, FCharSpacing, FLineSpacing); + + if not IsDesigning then + if FAutoWidth then + begin + FDrawText.SetDimensions(1, 1, 1, Rect(0, 0, 10000, 10000), Rect(0, 0, 10000, 10000)); + FDrawText.SetText(FMemo); + SaveWidth := Width; + Width := FDrawText.CalcWidth + AdjustCalcWidth; + if FHAlign = haRight then + Left := Left + SaveWidth - Width + else if FHAlign = haCenter then + Left := Left + (SaveWidth - Width) / 2; + if Parent <> nil then + Parent.AlignChildren; + end; + + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + ScaledRect := FTextRect; + BeginDraw(Canvas, 1, 1, 0, 0); + + if not IsPrinting then + FPrintScale := 1; + FDrawText.SetDimensions(ScaleX, ScaleY, FPrintScale, FTextRect, ScaledRect); + FDrawText.SetText(FMemo); + FDrawText.SetParaBreaks(FFirstParaBreak, FLastParaBreak); +end; + +procedure TfrxCustomMemoView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +var + SaveColor: TColor; + FDrawText: TfrxDrawText; + + procedure DrawUnderlines; + var + dy, h: Extended; + begin + with Canvas do + begin + Pen.Color := Frame.Color; + Pen.Width := FFrameWidth; + Pen.Style := psSolid; + Pen.Mode := pmCopy; + end; + + h := FDrawText.LineHeight * ScaleY; + dy := FY + h + (GapY - LineSpacing + 1) * ScaleY; + while dy < FY1 do + begin + Canvas.MoveTo(FX, Round(dy)); + Canvas.LineTo(FX1, Round(dy)); + dy := dy + h; + end; + end; + +begin + if Report <> nil then + FDrawText := Report.FDrawText else + FDrawText := frxDrawText; + + if not IsDesigning then + ExtractMacros + else if IsDataField then + FMemo.Text := '[' + DataSet.UserName + '."' + DataField + '"]'; + + SaveColor := FColor; + + FDrawText.Lock; + try + SetDrawParams(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + inherited Draw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + + if FUnderlines and (FRotation = 0) then + DrawUnderlines; + FDrawText.DrawText(FCanvas, HAlign, VAlign); + + finally + FDrawText.Unlock; + end; + + FColor := SaveColor; +end; + +function TfrxCustomMemoView.CalcHeight: Extended; +var + FDrawText: TfrxDrawText; +begin + if Report <> nil then + FDrawText := Report.FDrawText else + FDrawText := frxDrawText; + + FDrawText.Lock; + try + if FHighlight.Active then + FDrawText.SetFont(FHighlight.Font) else + FDrawText.SetFont(FFont); + FDrawText.SetOptions(FWordWrap, FAllowHTMLTags, FRTLReading, FWordBreak, + FClipped, FWysiwyg, FRotation); + FDrawText.SetGaps(FParagraphGap, FCharSpacing, FLineSpacing); + + if FAutoWidth then + FDrawText.SetDimensions(1, 1, 1, Rect(0, 0, 10000, 10000), Rect(0, 0, 10000, 10000)) + else + begin + BeginDraw(nil, 1, 1, 0, 0); + FDrawText.SetDimensions(1, 1, 1, FTextRect, FTextRect); + end; + + FDrawText.SetText(FMemo); + Result := Round(FDrawText.CalcHeight + AdjustCalcHeight); + + finally + FDrawText.Unlock; + end; +end; + +function TfrxCustomMemoView.CalcWidth: Extended; +var + FDrawText: TfrxDrawText; +begin + if Report <> nil then + FDrawText := Report.FDrawText else + FDrawText := frxDrawText; + + FDrawText.Lock; + try + if FHighlight.Active then + FDrawText.SetFont(FHighlight.Font) else + FDrawText.SetFont(FFont); + FDrawText.SetOptions(FWordWrap, FAllowHTMLTags, FRTLReading, FWordBreak, + FClipped, FWysiwyg, FRotation); + FDrawText.SetGaps(FParagraphGap, FCharSpacing, FLineSpacing); + + FDrawText.SetDimensions(1, 1, 1, Rect(0, 0, 10000, 10000), Rect(0, 0, 10000, 10000)); + FDrawText.SetText(FMemo); + Result := Round(FDrawText.CalcWidth + AdjustCalcWidth); + + finally + FDrawText.Unlock; + end; +end; + +procedure TfrxCustomMemoView.InitPart; +begin + FPartMemo := FMemo.Text; + FFirstParaBreak := False; + FLastParaBreak := False; +end; + +function TfrxCustomMemoView.DrawPart: Extended; +var + SaveColor: TColor; + FDrawText: TfrxDrawText; + ParaBreak: Boolean; +begin + if Report <> nil then + FDrawText := Report.FDrawText else + FDrawText := frxDrawText; + + SaveColor := FColor; + + FDrawText.Lock; + try + FMemo.Text := FPartMemo; + SetDrawParams(nil, 1, 1, 0, 0); + FPartMemo := FDrawText.GetOutBoundsText(ParaBreak); + FMemo.Text := FDrawText.GetInBoundsText; + FLastParaBreak := ParaBreak; + + Result := FDrawText.UnusedSpace; + if Result = 0 then + Result := Height; + + finally + FDrawText.Unlock; + end; + + FColor := SaveColor; +end; + +function TfrxCustomMemoView.Diff(AComponent: TfrxComponent): String; +var + m: TfrxCustomMemoView; + s: WideString; + c: Integer; +begin + Result := inherited Diff(AComponent); + m := TfrxCustomMemoView(AComponent); + + if FAutoWidth <> m.FAutoWidth then + Result := Result + ' AutoWidth="' + frxValueToXML(FAutoWidth) + '"'; + if FloatDiff(FCharSpacing, m.FCharSpacing) then + Result := Result + ' CharSpacing="' + FloatToStr(FCharSpacing) + '"'; + if FloatDiff(FGapX, m.FGapX) then + Result := Result + ' GapX="' + FloatToStr(FGapX) + '"'; + if FloatDiff(FGapY, m.FGapY) then + Result := Result + ' GapY="' + FloatToStr(FGapY) + '"'; + if FHAlign <> m.FHAlign then + Result := Result + ' HAlign="' + frxValueToXML(FHAlign) + '"'; + if FHighlight.Active <> m.FHighlight.Active then + Result := Result + ' Highlight.Active="' + frxValueToXML(FHighlight.Active) + '"'; + if FloatDiff(FLineSpacing, m.FLineSpacing) then + Result := Result + ' LineSpacing="' + FloatToStr(FLineSpacing) + '"'; + + c := FMemo.Count; + if c = 0 then + Result := Result + ' u=""' + else + begin + if c = 1 then + Result := Result + ' u="' + frxStrToXML(Utf8Encode(FMemo[0])) + '"' + else + begin + s := Text; + SetLength(s, Length(s) - 2); + Result := Result + ' u="' + frxStrToXML(Utf8Encode(s)) + '"'; + end; + end; + + if FloatDiff(FParagraphGap, m.FParagraphGap) then + Result := Result + ' ParagraphGap="' + FloatToStr(FParagraphGap) + '"'; + if FRotation <> m.FRotation then + Result := Result + ' Rotation="' + IntToStr(FRotation) + '"'; + if FRTLReading <> m.FRTLReading then + Result := Result + ' RTLReading="' + frxValueToXML(FRTLReading) + '"'; + if FUnderlines <> m.FUnderlines then + Result := Result + ' Underlines="' + frxValueToXML(FUnderlines) + '"'; + if FVAlign <> m.FVAlign then + Result := Result + ' VAlign="' + frxValueToXML(FVAlign) + '"'; + if FWordWrap <> m.FWordWrap then + Result := Result + ' WordWrap="' + frxValueToXML(FWordWrap) + '"'; + + if FFirstParaBreak then + Result := Result + ' FirstParaBreak="1"'; + if FLastParaBreak then + Result := Result + ' LastParaBreak="1"'; + + FFirstParaBreak := FLastParaBreak; + FLastParaBreak := False; +end; + +procedure TfrxCustomMemoView.BeforePrint; +begin + inherited; + if not IsDataField then + FTempMemo := FMemo.Text; +end; + +procedure TfrxCustomMemoView.AfterPrint; +begin + if not IsDataField then + FMemo.Text := FTempMemo; + inherited; +end; + +procedure TfrxCustomMemoView.GetData; +var + i, j: Integer; + s, s1, s2, dc1, dc2: WideString; +begin + inherited; + if IsDataField then + begin + if DataSet.IsBlobField(DataField) then + DataSet.AssignBlobTo(DataField, FMemo) + else + begin + FValue := DataSet.Value[DataField]; + if FDisplayFormat.Kind = fkText then + FMemo.Text := DataSet.DisplayText[DataField] else + FMemo.Text := FormatData(FValue); + if FHideZeros and (TVarData(FValue).VType <> varString) and + (TVarData(FValue).VType <> varOleStr) and (FValue = 0) then + FMemo.Text := ''; + end + end + else if AllowExpressions then + begin + s := FMemo.Text; + i := 1; + dc1 := FExpressionDelimiters; + dc2 := Copy(dc1, Pos(',', dc1) + 1, 255); + dc1 := Copy(dc1, 1, Pos(',', dc1) - 1); + + if Pos(dc1, s) <> 0 then + begin + repeat + while (i < Length(s)) and (Copy(s, i, Length(dc1)) <> dc1) do Inc(i); + + s1 := frxGetBrackedVariableW(s, dc1, dc2, i, j); + if i <> j then + begin + Delete(s, i, j - i + 1); + s2 := CalcAndFormat(s1); + Insert(s2, s, i); + Inc(i, Length(s2)); + j := 0; + end; + until i = j; + + FMemo.Text := s; + end; + end; + + Report.LocalValue := FValue; + FHighlight.Active := False; + if FHighlight.Condition <> '' then + FHighlight.Active := Report.Calc(FHighlight.Condition); + + if FSuppressRepeated then + begin + if FLastValue = FMemo.Text then + FMemo.Text := '' else + FLastValue := FMemo.Text; + end; + + if FFlowTo <> nil then + begin + InitPart; + DrawPart; + FFlowTo.Text := FPartMemo; + FFlowTo.AllowExpressions := False; + end; +end; + +procedure TfrxCustomMemoView.ResetSuppress; +begin + FLastValue := ''; +end; + +function TfrxCustomMemoView.CalcAndFormat(const Expr: WideString): WideString; +var + i: Integer; + ExprStr, FormatStr: WideString; + Format: TfrxFormat; +begin + Result := ''; + Format := nil; + i := Pos(' #', Expr); + if i <> 0 then + begin + ExprStr := Copy(Expr, 1, i - 1); + FormatStr := Copy(Expr, i + 2, Length(Expr) - i - 1); + if Pos(')', FormatStr) = 0 then + begin + Format := TfrxFormat.Create; + + if FormatStr[1] in [WideChar('N'), WideChar('n')] then + begin + Format.Kind := fkNumeric; + for i := 1 to Length(FormatStr) do + if FormatStr[i] in [WideChar(','), WideChar('.'), WideChar('-')] then + begin + Format.DecimalSeparator := FormatStr[i]; + FormatStr[i] := '.'; + end; + end + else if FormatStr[1] in [WideChar('D'), WideChar('T'), WideChar('d'), WideChar('t')] then + Format.Kind := fkDateTime + else if FormatStr[1] in [WideChar('B'), WideChar('b')] then + Format.Kind := fkBoolean; + + Format.FormatStr := Copy(FormatStr, 2, 255); + end + else + ExprStr := Expr; + end + else + ExprStr := Expr; + + try + if CompareText(ExprStr, 'TOTALPAGES#') = 0 then + FValue := '[TotalPages#]' + else if CompareText(ExprStr, 'COPYNAME#') = 0 then + FValue := '[CopyName#]' + else + FValue := Report.Calc(ExprStr); + if FHideZeros and (TVarData(FValue).VType <> varString) and + (TVarData(FValue).VType <> varOleStr) and (FValue = 0) then + Result := '' else + Result := FormatData(FValue, Format); + finally + if Format <> nil then + Format.Free; + end; +end; + +function TfrxCustomMemoView.FormatData(const Value: Variant; + AFormat: TfrxFormat = nil): WideString; +var + i: Integer; +begin + if AFormat = nil then + AFormat := FDisplayFormat; + if VarIsNull(Value) then + Result := '' + else if AFormat.Kind = fkText then + Result := VarToWideStr(Value) + else + try + case AFormat.Kind of + fkNumeric: + begin + if Pos('#', AFormat.FormatStr) <> 0 then + Result := FormatFloat(AFormat.FormatStr, Extended(Value)) + else if Pos('d', AFormat.FormatStr) <> 0 then + Result := Format(AFormat.FormatStr, [Integer(Value)]) + else + Result := Format(AFormat.FormatStr, [Extended(Value)]); + if (Length(AFormat.DecimalSeparator) = 1) and + (DecimalSeparator <> AFormat.DecimalSeparator[1]) then + for i := 1 to Length(Result) do + if Result[i] = WideChar(DecimalSeparator) then + Result[i] := WideChar(AFormat.DecimalSeparator[1]); + end; + + fkDateTime: + Result := FormatDateTime(AFormat.FormatStr, Value); + + fkBoolean: + if Value = True then + Result := Copy(AFormat.FormatStr, Pos(',', AFormat.FormatStr) + 1, 255) else + Result := Copy(AFormat.FormatStr, 1, Pos(',', AFormat.FormatStr) - 1); + else + Result := VarToWideStr(Value) + end; + except + Result := VarToWideStr(Value); + end; +end; + +function TfrxCustomMemoView.GetComponentText: String; +var + i: Integer; +begin + Result := FMemo.Text; + if FAllowExpressions then { extract TOTALPAGES macro if any } + begin + i := Pos('[TOTALPAGES]', UpperCase(Result)); + if i <> 0 then + begin + Delete(Result, i, 12); + Insert(IntToStr(FTotalPages), Result, i); + end; + end; +end; + +procedure TfrxCustomMemoView.ApplyStyle(Style: TfrxStyleItem); +begin + if Style <> nil then + begin + Color := Style.Color; + Font := Style.Font; + Frame := Style.Frame; + end; +end; + +function TfrxCustomMemoView.WrapText(WrapWords: Boolean): WideString; +var + TempBMP: TBitmap; + FDrawText: TfrxDrawText; +begin + Result := ''; + TempBMP := TBitmap.Create; + if Report <> nil then + FDrawText := Report.FDrawText else + FDrawText := frxDrawText; + + FDrawText.Lock; + try + SetDrawParams(TempBMP.Canvas, 1, 1, 0, 0); + if WrapWords then + Result := FDrawText.WrappedText + else + Result := FDrawText.DeleteTags(Text); + finally + FDrawText.Unlock; + TempBMP.Free; + end; +end; + +procedure TfrxCustomMemoView.ExtractMacros; +var + s, s1: String; + i, j: Integer; +begin + if FAllowExpressions then + begin + s := FMemo.Text; + i := Pos('[TOTALPAGES#]', UpperCase(s)); + if i <> 0 then + begin + Delete(s, i, 13); + Insert(IntToStr(FTotalPages), s, i); + FMemo.Text := s; + end; + i := Pos('[COPYNAME#]', UpperCase(s)); + if i <> 0 then + begin + j := frxGlobalVariables.IndexOf('CopyName' + IntToStr(FCopyNo)); + if j <> -1 then + s1 := VarToStr(frxGlobalVariables.Items[j].Value) + else + s1 := ''; + Delete(s, i, 11); + Insert(s1, s, i); + FMemo.Text := s; + end; + end; +end; + +{$IFDEF FR_COM} +function TfrxCustomMemoView.IfrxCustomMemoView_Get_Text(out Value: WideString): HResult; stdcall; +begin + Value := WideString(FMemo.Text); + Result := 0; +end; + +function TfrxCustomMemoView.IfrxCustomMemoView_Set_Text(const Value: WideString): HResult; stdcall; +begin + FMemo.Text := String(Value); + Result := 0; +end; +{$ENDIF} + +{$IFDEF FR_COM} +{ TfrxMemoView } +function TfrxMemoView.Get_AutoWidth(out Value: WordBool): HResult; stdcall; +begin + Value := AutoWidth; + Result := S_OK; +end; + +function TfrxMemoView.Set_AutoWidth(Value: WordBool): HResult; stdcall; +begin + AutoWidth := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_AllowExpressions(out Value: WordBool): HResult; stdcall; +begin + Value := AllowExpressions; + Result := S_OK; +end; + +function TfrxMemoView.Set_AllowExpressions(Value: WordBool): HResult; stdcall; +begin + AllowExpressions := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_AllowHTMLTags(out Value: WordBool): HResult; stdcall; +begin + Value := AllowHTMLTags; + Result := S_OK; +end; + +function TfrxMemoView.Set_AllowHTMLTags(Value: WordBool): HResult; stdcall; +begin + AllowHTMLTags := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_BrushStyle(out Value: frxBrushStyle): HResult; stdcall; +begin + Value := frxBrushStyle(BrushStyle); + Result := S_OK; +end; + +function TfrxMemoView.Set_BrushStyle(Value: frxBrushStyle): HResult; stdcall; +begin + BrushStyle := TBrushStyle(Value); + Result := S_OK; +end; + +function TfrxMemoView.Get_CharSpacing(out Value: Double): HResult; stdcall; +begin + Value := CharSpacing; + Result := S_OK; +end; + +function TfrxMemoView.Set_CharSpacing(Value: Double): HResult; stdcall; +begin + CharSpacing := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_Clipped(out Value: WordBool): HResult; stdcall; +begin + Value := Clipped; + Result := S_OK; +end; + +function TfrxMemoView.Set_Clipped(Value: WordBool): HResult; stdcall; +begin + Clipped := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_Color(out Value: Integer): HResult; stdcall; +begin + Value := Color; + Result := S_OK; +end; + +function TfrxMemoView.Set_Color(Value: Integer): HResult; stdcall; +begin + Color := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_DataField(out Value: WideString): HResult; stdcall; +begin + Value := DataField; + Result := S_OK; +end; + +function TfrxMemoView.Set_DataField(const Value: WideString): HResult; stdcall; +begin + DataField := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_DataSet(out Value: IfrxDataSet): HResult; stdcall; +begin + Value := DataSet as IfrxDataset; + Result := S_OK; +end; + +function TfrxMemoView.Set_DataSet(const Value: IfrxDataSet): HResult; stdcall; +var + idsp: {IfrxComponentSelf} IInterfaceComponentReference; +begin + Result := Value.QueryInterface( {IfrxComponentSelf} IInterfaceComponentReference, idsp); + if Result = S_OK then + DataSet := TfrxDataSet(idsp.GetComponent{Get_Object}); +end; + +function TfrxMemoView.Get_DataSetName(out Value: WideString): HResult; stdcall; +begin + Value := DataSetName; + Result := S_OK; +end; + +function TfrxMemoView.Set_DataSetName(const Value: WideString): HResult; stdcall; +begin + DataSetName := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_DisplayFormat(out Value: IfrxDisplayFormat): HResult; stdcall; +begin + Value := DisplayFormat as IfrxDisplayFormat; + Result := S_OK; +end; + +function TfrxMemoView.Get_ExpressionDelimiters(out Value: WideString): HResult; stdcall; +begin + Value := ExpressionDelimiters; + Result := S_OK; +end; + +function TfrxMemoView.Set_ExpressionDelimiters(const Value: WideString): HResult; stdcall; +begin + ExpressionDelimiters := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_FlowTo(out Value: IfrxCustomMemoView): HResult; stdcall; +begin + Value := FlowTo as IfrxCustomMemoView; + Result := S_OK; +end; + +function TfrxMemoView.Set_FlowTo(const Value: IfrxCustomMemoView): HResult; stdcall; +var + idsp: {IfrxComponentSelf} IInterfaceComponentReference; +begin + Result := Value.QueryInterface({IfrxComponentSelf} IInterfaceComponentReference, idsp); + if Result = S_OK then + FlowTo := TfrxCustomMemoView(idsp.GetComponent{Get_Object}); +end; + +function TfrxMemoView.Get_Font(out Value: IfrxFont): HResult; stdcall; +begin + Result := S_OK; + Value := FFont as IfrxFont; + Value._AddRef(); +end; + +function TfrxMemoView.Get_Frame(out Value: IfrxFrame): HResult; stdcall; +begin + Value := Frame as IfrxFrame; + Result := S_OK; +end; + +function TfrxMemoView.Get_GapX(out Value: Double): HResult; stdcall; +begin + Value := GapX; + Result := S_OK; +end; + +function TfrxMemoView.Set_GapX(Value: Double): HResult; stdcall; +begin + GapX := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_GapY(out Value: Double): HResult; stdcall; +begin + Value := GapY; + Result := S_OK; +end; + +function TfrxMemoView.Set_GapY(Value: Double): HResult; stdcall; +begin + GapY := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_HAlign(out Value: frxHAlign): HResult; stdcall; +begin + Value := TOleEnum(HAlign); + Result := S_OK; +end; + +function TfrxMemoView.Set_HAlign(Value: frxHAlign): HResult; stdcall; +begin + HAlign := TfrxHAlign(Value); + Result := S_OK; +end; + +function TfrxMemoView.Get_HideZeros(out Value: WordBool): HResult; stdcall; +begin + Value := HideZeros; + Result := S_OK; +end; + +function TfrxMemoView.Set_HideZeros(Value: WordBool): HResult; stdcall; +begin + HideZeros := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_Highlight(out Value: IfrxHighlight): HResult; stdcall; +begin + Value := Highlight as IfrxHighlight; + Result := S_OK; +end; + +function TfrxMemoView.Get_LineSpacing(out Value: Double): HResult; stdcall; +begin + Value := LineSpacing; + Result := S_OK; +end; + +function TfrxMemoView.Set_LineSpacing(Value: Double): HResult; stdcall; +begin + LineSpacing := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_Memo(out Value: WideString): HResult; stdcall; +begin + Value := Memo.Text; + Result := S_OK; +end; + +function TfrxMemoView.Set_Memo(const Value: WideString): HResult; stdcall; +begin + Memo.Text := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_ParagraphGap(out Value: Double): HResult; stdcall; +begin + Value := ParagraphGap; + Result := S_OK; +end; + +function TfrxMemoView.Set_ParagraphGap(Value: Double): HResult; stdcall; +begin + ParagraphGap := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_ParentFont(out Value: WordBool): HResult; stdcall; +begin + Value := ParentFont; + Result := S_OK; +end; + +function TfrxMemoView.Set_ParentFont(Value: WordBool): HResult; stdcall; +begin + ParentFont := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_Rotation(out Value: Integer): HResult; stdcall; +begin + Value := Rotation; + Result := S_OK; +end; + +function TfrxMemoView.Set_Rotation(Value: Integer): HResult; stdcall; +begin + Rotation := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_RTLReading(out Value: WordBool): HResult; stdcall; +begin + Value := RTLReading; + Result := S_OK; +end; + +function TfrxMemoView.Set_RTLReading(Value: WordBool): HResult; stdcall; +begin + RTLReading := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_Style(out Value: WideString): HResult; stdcall; +begin + Value := Style; + Result := S_OK; +end; + +function TfrxMemoView.Set_Style(const Value: WideString): HResult; stdcall; +begin + Style := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_SuppressRepeated(out Value: WordBool): HResult; stdcall; +begin + Value := SuppressRepeated; + Result := S_OK; +end; + +function TfrxMemoView.Set_SuppressRepeated(Value: WordBool): HResult; stdcall; +begin + SuppressRepeated := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_Underlines(out Value: WordBool): HResult; stdcall; +begin + Value := Underlines; + Result := S_OK; +end; + +function TfrxMemoView.Set_Underlines(Value: WordBool): HResult; stdcall; +begin + Underlines := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_WordBreak(out Value: WordBool): HResult; stdcall; +begin + Value := WordBreak; + Result := S_OK; +end; + +function TfrxMemoView.Set_WordBreak(Value: WordBool): HResult; stdcall; +begin + WordBreak := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_WordWrap(out Value: WordBool): HResult; stdcall; +begin + Value := WordWrap; + Result := S_OK; +end; + +function TfrxMemoView.Set_WordWrap(Value: WordBool): HResult; stdcall; +begin + WordWrap := Value; + Result := S_OK; +end; + +function TfrxMemoView.Get_VAlign(out Value: frxVAlign): HResult; stdcall; +begin + Value := TOleEnum(VAlign); + Result := S_OK; +end; + +function TfrxMemoView.Set_VAlign(Value: frxVAlign): HResult; stdcall; +begin + VAlign := TfrxVAlign(Value); + Result := S_OK; +end; +{$ENDIF} + +{ TfrxSysMemoView } + +class function TfrxSysMemoView.GetDescription: String; +begin + Result := frxResources.Get('obSysText'); +end; + + +{ TfrxCustomLineView } + +constructor TfrxCustomLineView.Create(AOwner: TComponent); +begin + inherited; + frComponentStyle := frComponentStyle - [csDefaultDiff]; + FArrowWidth := 5; + FArrowLength := 20; +end; + +constructor TfrxCustomLineView.DesignCreate(AOwner: TComponent; Flags: Word); +begin + inherited; + FDiagonal := Flags <> 0; + FArrowEnd := Flags in [2, 4]; + FArrowStart := Flags in [3, 4]; +end; + +procedure TfrxCustomLineView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +begin + if not FDiagonal then + begin + if Width > Height then + begin + Height := 0; + Frame.Typ := [ftTop]; + end + else + begin + Width := 0; + Frame.Typ := [ftLeft]; + end; + end; + + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + if not FDiagonal then + begin + DrawFrame; + if FArrowStart then + DrawArrow(FX1, FY1, FX, FY); + if FArrowEnd then + DrawArrow(FX, FY, FX1, FY1); + end + else + DrawDiagonalLine; +end; + +procedure TfrxCustomLineView.DrawArrow(x1, y1, x2, y2: Integer); +var + k1, a, b, c, D: Double; + xp, yp, x3, y3, x4, y4: Integer; +begin + if abs(x2 - x1) > 8 then + begin + k1 := (y2 - y1) / (x2 - x1); + a := Sqr(k1) + 1; + b := 2 * k1 * (x2 * y1 - x1 * y2) / (x2 - x1) - 2 * y2 * k1 - 2 * x2; + c := Sqr(x2) + Sqr(y2) - Sqr(FArrowLength * FScaleX) + sqr((x2 * y1 - x1 * y2) / (x2 - x1)) - + 2 * y2 * (x2 * y1 - x1 * y2) / (x2 - x1); + D := Sqr(b) - 4 * a * c; + xp := Round((-b + Sqrt(D)) / (2 * a)); + if (xp > x1) and (xp > x2) or (xp < x1) and (xp < x2) then + xp := Round((-b - Sqrt(D)) / (2 * a)); + yp := Round(xp * k1 + (x2 * y1 - x1 * y2) / (x2 - x1)); + if y2 <> y1 then + begin + x3 := Round(xp + FArrowWidth * FScaleX * sin(ArcTan(k1))); + y3 := Round(yp - FArrowWidth * FScaleX * cos(ArcTan(k1))); + x4 := Round(xp - FArrowWidth * FScaleX * sin(ArcTan(k1))); + y4 := Round(yp + FArrowWidth * FScaleX * cos(ArcTan(k1))); + end + else + begin + x3 := xp; + y3 := yp - Round(FArrowWidth * FScaleX); + x4 := xp; + y4 := yp + Round(FArrowWidth * FScaleX); + end; + end + else + begin + xp := x2; + yp := y2 - Round(FArrowLength * FScaleX); + if (yp > y1) and (yp > y2) or (yp < y1) and (yp < y2) then + yp := y2 + Round(FArrowLength * FScaleX); + x3 := xp - Round(FArrowWidth * FScaleX); + y3 := yp; + x4 := xp + Round(FArrowWidth * FScaleX); + y4 := yp; + end; + + if FArrowSolid then + begin + FCanvas.Brush.Color := Frame.Color; + FCanvas.Polygon([Point(x2, y2), Point(x3, y3), Point(x4, y4), Point(x2, y2)]) + end + else + begin + FCanvas.Pen.Width := Round(FFrame.Width * FScaleX); + FCanvas.Polyline([Point(x3, y3), Point(x2, y2), Point(x4, y4)]); + end; +end; + +procedure TfrxCustomLineView.DrawDiagonalLine; +begin + if (Frame.Color = clNone) or (Frame.Width = 0) then exit; + with FCanvas do + begin + Brush.Style := bsSolid; + if Color = clNone then + Brush.Style := bsClear else + Brush.Color := Color; + Pen.Color := Frame.Color; + Pen.Width := 1; + if Frame.Style <> fsDouble then + Pen.Style := TPenStyle(Frame.Style) else + Pen.Style := psSolid; + + DrawLine(FX, FY, FX1, FY1, FFrameWidth); + + if FArrowStart then + DrawArrow(FX1, FY1, FX, FY); + if FArrowEnd then + DrawArrow(FX, FY, FX1, FY1); + end; +end; + + +{ TfrxLineView } + +class function TfrxLineView.GetDescription: String; +begin + Result := frxResources.Get('obLine'); +end; + + +{ TfrxPictureView } + +constructor TfrxPictureView.Create(AOwner: TComponent); +begin + inherited; + frComponentStyle := frComponentStyle - [csDefaultDiff]; + FPicture := TPicture.Create; + FPicture.OnChange := PictureChanged; + FKeepAspectRatio := True; + FStretched := True; + FColor := clWhite; + FIsPictureStored := True; +end; + +destructor TfrxPictureView.Destroy; +begin + FPicture.Free; + inherited; +end; + +class function TfrxPictureView.GetDescription: String; +begin + Result := frxResources.Get('obPicture'); +end; + +procedure TfrxPictureView.SetPicture(const Value: TPicture); +begin + FPicture.Assign(Value); +end; + +procedure TfrxPictureView.SetAutoSize(const Value: Boolean); +begin + FAutoSize := Value; + if FAutoSize and not (FPicture.Graphic = nil) then + begin + FWidth := FPicture.Width; + FHeight := FPicture.Height; + end; +end; + +procedure TfrxPictureView.PictureChanged(Sender: TObject); +begin + AutoSize := FAutoSize; + FPictureChanged := True; +end; + +procedure TfrxPictureView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); +var + r: TRect; + kx, ky: Extended; + rgn: HRGN; + + procedure PrintGraphic(Canvas: TCanvas; DestRect: TRect; aGraph: TGraphic); + begin + frxDrawGraphic(Canvas, DestRect, aGraph, IsPrinting); + end; + +begin + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + + with Canvas do + begin + DrawBackground; + r := Rect(FX, FY, FX1, FY1); + + if (FPicture.Graphic = nil) or FPicture.Graphic.Empty then + begin + if IsDesigning then + frxResources.ObjectImages.Draw(Canvas, FX + 1, FY + 2, 3); + end + else + begin + if FStretched then + begin + if FKeepAspectRatio then + begin + kx := FDX / FPicture.Width; + ky := FDY / FPicture.Height; + if kx < ky then + r.Bottom := r.Top + Round(FPicture.Height * kx) else + r.Right := r.Left + Round(FPicture.Width * ky); + + if FCenter then + OffsetRect(r, (FDX - (r.Right - r.Left)) div 2, + (FDY - (r.Bottom - r.Top)) div 2); + end; + + PrintGraphic(Canvas, r, FPicture.Graphic); + end + else + begin + rgn := CreateRectRgn(0, 0, 10000, 10000); + GetClipRgn(Canvas.Handle, rgn); + IntersectClipRect(Canvas.Handle, + Round(FX), + Round(FY), + Round(FX1), + Round(FY1)); + + if FCenter then + OffsetRect(r, (FDX - Round(ScaleX * FPicture.Width)) div 2, + (FDY - Round(ScaleY * FPicture.Height)) div 2); + r.Right := r.Left + Round(FPicture.Width * ScaleX); + r.Bottom := r.Top + Round(FPicture.Height * ScaleY); + PrintGraphic(Canvas, r, Picture.Graphic); + + SelectClipRgn(Canvas.Handle, rgn); + DeleteObject(rgn); + end; + end; + + DrawFrame; + end; +end; + +function TfrxPictureView.Diff(AComponent: TfrxComponent): String; +begin + if FPictureChanged then + begin + Report.PreviewPages.AddPicture(Self); + FPictureChanged := False; + end; + + Result := ' ' + inherited Diff(AComponent) + ' ImageIndex="' + + IntToStr(FImageIndex) + '"'; +end; + +{$IFDEF FR_COM} +function TfrxPictureView.Get_Picture(out Value: OLE_HANDLE): HResult; stdcall; +begin + Value := FPicture.Bitmap.Handle; + Result := S_OK; +end; + +function TfrxPictureView.Set_Picture(Value: OLE_HANDLE): HResult; stdcall; +begin + FPicture.Bitmap.Handle := Value; + Result := S_OK; +end; + +function TfrxPictureView.Get_Metafile(out Value: OLE_HANDLE): HResult; stdcall; +begin + Value := FPicture.Metafile.Handle; + Result := S_OK; +end; + +function TfrxPictureView.Set_Metafile(Value: OLE_HANDLE): HResult; stdcall; +begin + FPicture.Metafile.Handle := Value; + Result := S_OK; +end; + +function TfrxPictureView.LoadViewFromStream(const Stream: IUnknown): HResult; stdcall; +var + ComStream: IStream; + OleStream: TOleStream; + + NetStream: _Stream; + ClrStream: TClrStream; +begin + try + Result := Stream.QueryInterface(IStream, ComStream); + if Result = S_OK then + begin + OleStream := TOleStream.Create(ComStream); + LoadPictureFromStream(OleStream); + OleStream.Free; + ComStream := nil; + end + else + begin + Result := Stream.QueryInterface(_Stream, NetStream); + if Result = S_OK then + begin + ClrStream := TClrStream.Create(NetStream); + LoadPictureFromStream(ClrStream); + ClrStream.Free; + NetStream._Release(); + end; + end; + except + Result := E_FAIL; + end; +end; + +function TfrxPictureView.SaveViewToStream(const Stream: IUnknown): HResult; stdcall; +var + ComStream: IStream; + OleStream: TOleStream; + + NetStream: _Stream; + ClrStream: TClrStream; +begin + try + Result := Stream.QueryInterface(IStream, ComStream); + if Result = S_OK then + begin + OleStream := TOleStream.Create(ComStream); + FPicture.Bitmap.SaveToStream(OleStream); + OleStream.Free; + ComStream._Release(); + end + else + begin + Result := Stream.QueryInterface(_Stream, NetStream); + if Result = S_OK then + begin + ClrStream := TClrStream.Create(NetStream); + FPicture.Bitmap.SaveToStream(ClrStream); + ClrStream.Free; + NetStream._Release(); + end; + end; + except + Result := E_FAIL; + end; +end; +{$ENDIF} + +const + WMFKey = Integer($9AC6CDD7); + WMFWord = $CDD7; + rc3_StockIcon = 0; + rc3_Icon = 1; + rc3_Cursor = 2; + +type + TGraphicHeader = record + Count: Word; + HType: Word; + Size: Longint; + end; + + TMetafileHeader = packed record + Key: Longint; + Handle: SmallInt; + Box: TSmallRect; + Inch: Word; + Reserved: Longint; + CheckSum: Word; + end; + + TCursorOrIcon = packed record + Reserved: Word; + wType: Word; + Count: Word; + end; + +const + OriginalPngHeader: array[0..7] of Char = (#137, #80, #78, #71, #13, #10, #26, #10); + +function TfrxPictureView.LoadPictureFromStream(s: TStream): Hresult; +var + pos: Integer; + Header: TGraphicHeader; + BMPHeader: TBitmapFileHeader; +{$IFDEF JPEG} + JPEGHeader: array[0..1] of Byte; +{$ENDIF} +{$IFDEF PNG} + PNGHeader: array[0..7] of Char; +{$ENDIF} + EMFHeader: TEnhMetaHeader; + WMFHeader: TMetafileHeader; + ICOHeader: TCursorOrIcon; + NewGraphic: TGraphic; + bOK : Boolean; +begin + NewGraphic := nil; + + if s.Size > 0 then + begin + // skip Delphi blob-image header + if s.Size >= SizeOf(TGraphicHeader) then + begin + s.Read(Header, SizeOf(Header)); + if (Header.Count <> 1) or (Header.HType <> $0100) or + (Header.Size <> s.Size - SizeOf(Header)) then + s.Position := 0; + end; + pos := s.Position; + + bOK := False; + + if (s.Size-pos) >= SizeOf(BMPHeader) then + begin + // try bmp header + s.ReadBuffer(BMPHeader, SizeOf(BMPHeader)); + s.Position := pos; + if BMPHeader.bfType = $4D42 then + begin + NewGraphic := TBitmap.Create; + bOK := True; + end; + end; + + {$IFDEF JPEG} + if not bOK then + begin + if (s.Size-pos) >= SizeOf(JPEGHeader) then + begin + // try jpeg header + s.ReadBuffer(JPEGHeader, SizeOf(JPEGHeader)); + s.Position := pos; + if (JPEGHeader[0] = $FF) and (JPEGHeader[1] = $D8) then + begin + NewGraphic := TJPEGImage.Create; + bOK := True; + end; + end; + end; + {$ENDIF} + + {$IFDEF PNG} + if not bOK then + begin + if (s.Size-pos) >= SizeOf(PNGHeader) then + begin + // try png header + s.ReadBuffer(PNGHeader, SizeOf(PNGHeader)); + s.Position := pos; + if PNGHeader = OriginalPngHeader then + begin + NewGraphic := TPngObject.Create; + bOK := True; + end; + end; + end; + {$ENDIF} + + if not bOK then + begin + if (s.Size-pos) >= SizeOf(WMFHeader) then + begin + // try wmf header + s.ReadBuffer(WMFHeader, SizeOf(WMFHeader)); + s.Position := pos; + if WMFHeader.Key = WMFKEY then + begin + NewGraphic := TMetafile.Create; + bOK := True; + end; + end; + end; + + if not bOK then + begin + if (s.Size-pos) >= SizeOf(EMFHeader) then + begin + // try emf header + s.ReadBuffer(EMFHeader, SizeOf(EMFHeader)); + s.Position := pos; + if EMFHeader.dSignature = ENHMETA_SIGNATURE then + begin + NewGraphic := TMetafile.Create; + bOK := True; + end; + end; + end; + + if not bOK then + begin + if (s.Size-pos) >= SizeOf(ICOHeader) then + begin + // try icon header + s.ReadBuffer(ICOHeader, SizeOf(ICOHeader)); + s.Position := pos; + if ICOHeader.wType in [RC3_STOCKICON, RC3_ICON] then + NewGraphic := TIcon.Create; + end; + end; + end; + + if NewGraphic <> nil then + begin + FPicture.Graphic := NewGraphic; + NewGraphic.Free; + FPicture.Graphic.LoadFromStream(s); + Result := S_OK; + end + else + begin + FPicture.Assign(nil); + Result := E_INVALIDARG; + end; +// workaround pngimage bug +{$IFDEF PNG} + if FPicture.Graphic is TPngObject then + PictureChanged(nil); +{$ENDIF} +end; + +procedure TfrxPictureView.GetData; +var + m: TMemoryStream; + s: String; +begin + inherited; + if FFileLink <> '' then + begin + s := FFileLink; + if Pos('[', s) <> 0 then + ExpandVariables(s); + if FileExists(s) then + FPicture.LoadFromFile(s) + else + FPicture.Assign(nil); + end + else if IsDataField and DataSet.IsBlobField(DataField) then + begin + m := TMemoryStream.Create; + try + DataSet.AssignBlobTo(DataField, m); + LoadPictureFromStream(m); + finally + m.Free; + end; + end; +end; + + +{ TfrxBand } + +constructor TfrxBand.Create(AOwner: TComponent); +begin + inherited; + FSubBands := TList.Create; + FOriginalObjectsCount := -1; +end; + +destructor TfrxBand.Destroy; +begin + FSubBands.Free; + inherited; +end; + +procedure TfrxBand.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FChild) then + FChild := nil; +end; + +procedure TfrxBand.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); +begin +end; + +function TfrxBand.GetBandName: String; +begin + Result := ClassName; + Delete(Result, Pos('Tfrx', Result), 4); + Delete(Result, Pos('Band', Result), 4); +end; + +function TfrxBand.BandNumber: Integer; +var + i: Integer; +begin + Result := 0; + for i := 0 to BND_COUNT - 1 do + if Self is frxBands[i] then + Result := i; +end; + +class function TfrxBand.GetDescription: String; +begin + Result := frxResources.Get('obBand'); +end; + +procedure TfrxBand.SetLeft(Value: Extended); +begin + if Parent is TfrxDMPPage then + Value := Round(Value / fr1CharX) * fr1CharX; + inherited; +end; + +procedure TfrxBand.SetTop(Value: Extended); +begin + if Parent is TfrxDMPPage then + Value := Round(Value / fr1CharY) * fr1CharY; + inherited; +end; + +procedure TfrxBand.SetHeight(Value: Extended); +begin + if Parent is TfrxDMPPage then + Value := Round(Value / fr1CharY) * fr1CharY; + inherited; +end; + +procedure TfrxBand.SetChild(Value: TfrxChild); +var + b: TfrxBand; +begin + b := Value; + while b <> nil do + begin + b := b.Child; + if b = Self then + raise Exception.Create('Circular child reference is not allowed'); + end; + FChild := Value; +end; + +{$IFDEF FR_COM} +function TfrxBand.IfrxBand_Get_AllowSplit(out Value: WordBool): HResult; stdcall; +begin + Value := FAllowSplit; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Set_AllowSplit(Value: WordBool): HResult; stdcall; +begin + FAllowSplit := Value; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Get_KeepChild(out Value: WordBool): HResult; stdcall; +begin + Value := FKeepChild; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Set_KeepChild(Value: WordBool): HResult; stdcall; +begin + FKeepChild := Value; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Get_OutlineText(out Value: WideString): HResult; stdcall; +begin + Value := FOutlineText; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Set_OutlineText(const Value: WideString): HResult; stdcall; +begin + FOutlineText := Value; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Get_Overflow(out Value: WordBool): HResult; stdcall; +begin + Value := FOverflow; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Set_Overflow(Value: WordBool): HResult; stdcall; +begin + FOverflow := Value; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Get_StartNewPage(out Value: WordBool): HResult; stdcall; +begin + Value := FStartNewPage; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Set_StartNewPage(Value: WordBool): HResult; stdcall; +begin + FStartNewPage := Value; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Get_Stretched(out Value: WordBool): HResult; stdcall; +begin + Value := FStretched; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Set_Stretched(Value: WordBool): HResult; stdcall; +begin + FStretched := Value; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Get_PrintChildIfInvisible(out Value: WordBool): HResult; stdcall; +begin + Value := FPrintChildIfInvisible; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Set_PrintChildIfInvisible(Value: WordBool): HResult; stdcall; +begin + FPrintChildIfInvisible := Value; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Get_Vertical(out Value: WordBool): HResult; stdcall; +begin + Value := FVertical; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Set_Vertical(Value: WordBool): HResult; stdcall; +begin + FVertical := Value; + Result := S_OK; +end; + +function TfrxBand.IfrxBand_Get_BandName(out Value: WideString): HResult; stdcall; +begin + Value := GetBandName; + Result := S_OK; +end; + +function TfrxBand.Get_Child(out Value: IfrxChild): HResult; stdcall; +begin + Value := Child; + Result := S_OK; +end; + +function TfrxBand.Set_Child(const Value: IfrxChild): HResult; stdcall; +var + idsp: {IfrxComponentSelf} IInterfaceComponentReference; +begin + Result := Value.QueryInterface( {IfrxComponentSelf} IInterfaceComponentReference, idsp); + if Result = S_OK then + Child := TfrxChild(idsp.GetComponent {Get_Object}); +end; + +{ TfrxHeader } + +function TfrxHeader.Get_ReprintOnNewPage(out Value: WordBool): HResult; stdcall; +begin + Value := ReprintOnNewPage; + Result := S_OK; +end; + +function TfrxHeader.Set_ReprintOnNewPage(Value: WordBool): HResult; stdcall; +begin + ReprintOnNewPage := Value; + Result := S_OK; +end; + +{ TfrxPageHeader } + +function TfrxPageHeader.Get_PrintOnFirstPage(out Value: WordBool): HResult; stdcall; +begin + Value := PrintOnFirstPage; + Result := S_OK; +end; + +function TfrxPageHeader.Set_PrintOnFirstPage(Value: WordBool): HResult; stdcall; +begin + PrintOnFirstPage := Value; + Result := S_OK; +end; + +{ TfrxPageFooter } + +function TfrxPageFooter.Get_PrintOnFirstPage(out Value: WordBool): HResult; stdcall; +begin + Value := PrintOnFirstPage; + Result := S_OK; +end; + +function TfrxPageFooter.Set_PrintOnFirstPage(Value: WordBool): HResult; stdcall; +begin + PrintOnFirstPage := Value; + Result := S_OK; +end; + +function TfrxPageFooter.Get_PrintOnLastPage(out Value: WordBool): HResult; stdcall; +begin + Value := PrintOnLastPage; + Result := S_OK; +end; + +function TfrxPageFooter.Set_PrintOnLastPage(Value: WordBool): HResult; stdcall; +begin + PrintOnLastPage := Value; + Result := S_OK; +end; + +{ TfrxGroupHeader } + +function TfrxGroupHeader.Get_Condition(out Value: WideString): HResult; stdcall; +begin + Value := Condition; + Result := S_OK; +end; + +function TfrxGroupHeader.Set_Condition(const Value: WideString): HResult; stdcall; +begin + Condition := Value; + Result := S_OK; +end; + +function TfrxGroupHeader.Get_KeepTogether(out Value: WordBool): HResult; stdcall; +begin + Value := KeepTogether; + Result := S_OK; +end; + +function TfrxGroupHeader.Set_KeepTogether(Value: WordBool): HResult; stdcall; +begin + KeepTogether := Value; + Result := S_OK; +end; + +function TfrxGroupHeader.Get_ReprintOnNewPage(out Value: WordBool): HResult; stdcall; +begin + Value := ReprintOnNewPage; + Result := S_OK; +end; + +function TfrxGroupHeader.Set_ReprintOnNewPage(Value: WordBool): HResult; stdcall; +begin + ReprintOnNewPage := Value; + Result := S_OK; +end; + +function TfrxGroupHeader.Get_LastValue(out Value: OleVariant): HResult; stdcall; +begin + Value := FLastValue; + Result := S_OK; +end; + +{ TfrxGroupFooter } + +function TfrxGroupFooter.Get_HideIfSingledatarecord(out Value: WordBool): HResult; stdcall; +begin + Value := HideIfSingledatarecord; + Result := S_OK; +end; + +function TfrxGroupFooter.Set_HideIfSingledatarecord(Value: WordBool): HResult; stdcall; +begin + HideIfSingledatarecord := Value; + Result := S_OK; +end; +{$ENDIF} +{ TfrxDataBand } + +constructor TfrxDataBand.Create(AOwner: TComponent); +begin + inherited; + FVirtualDataSet := TfrxUserDataSet.Create(nil); + FVirtualDataSet.RangeEnd := reCount; +end; + +destructor TfrxDataBand.Destroy; +begin + FVirtualDataSet.Free; + inherited; +end; + +class function TfrxDataBand.GetDescription: String; +begin + Result := frxResources.Get('obDataBand'); +end; + +procedure TfrxDataBand.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FDataSet) then + FDataSet := nil; +end; + +procedure TfrxDataBand.SetCurColumn(Value: Integer); +begin + if Value > FColumns then + Value := 1; + FCurColumn := Value; + if FCurColumn = 1 then + FMaxY := 0; + FLeft := (FCurColumn - 1) * (FColumnWidth + FColumnGap); +end; + +procedure TfrxDataBand.SetDataSet(const Value: TfrxDataSet); +begin + FDataSet := Value; + if FDataSet = nil then + FDataSetName := '' else + FDataSetName := FDataSet.UserName; +end; + +procedure TfrxDataBand.SetDataSetName(const Value: String); +begin + FDataSetName := Value; + FDataSet := frxFindDataSet(FDataSet, FDataSetName, Report); +end; + +function TfrxDataBand.GetDataSetName: String; +begin + if FDataSet = nil then + Result := FDataSetName else + Result := FDataSet.UserName; +end; + +procedure TfrxDataBand.SetRowCount(const Value: Integer); +begin + FRowCount := Value; + FVirtualDataSet.RangeEndCount := Value; +end; + +{$IFDEF FR_COM} +function TfrxDataBand.Get_ColumnGap(out Value: Double): HResult; stdcall; +begin + Value := ColumnGap; + Result := S_OK; +end; + +function TfrxDataBand.Set_ColumnGap(Value: Double): HResult; stdcall; +begin + ColumnGap := Value; + Result := S_OK; +end; + +function TfrxDataBand.Get_ColumnWidth(out Value: Double): HResult; stdcall; +begin + Value := ColumnWidth; + Result := S_OK; +end; + +function TfrxDataBand.Set_ColumnWidth(Value: Double): HResult; stdcall; +begin + ColumnWidth := Value; + Result := S_OK; +end; + +function TfrxDataBand.Get_ColumnsCount(out Value: Integer): HResult; stdcall; +begin + Value := Columns; + Result := S_OK; +end; + +function TfrxDataBand.Set_ColumnsCount(Value: Integer): HResult; stdcall; +begin + Columns := Value; + Result := S_OK; +end; + +function TfrxDataBand.Get_CurrentColumn(out Value: Integer): HResult; stdcall; +begin + Value := CurColumn; + Result := S_OK; +end; + +function TfrxDataBand.Set_CurrentColumn(Value: Integer): HResult; stdcall; +begin + CurColumn := Value; + Result := S_OK; +end; + +function TfrxDataBand.Get_DataSet(out Value: IfrxDataSet): HResult; stdcall; +begin + Value := DataSet as IfrxDataSet; + Result := S_OK; +end; + +function TfrxDataBand.Set_DataSet(const Value: IfrxDataSet): HResult; stdcall; +var + idsp: {IfrxComponentSelf} IInterfaceComponentReference; +begin + Result := Value.QueryInterface( {IfrxComponentSelf} IInterfaceComponentReference, idsp); + if Result = S_OK then + DataSet := TfrxDataSet(idsp.GetComponent {Get_Object} ); +end; + +function TfrxDataBand.Get_FooterAfterEach(out Value: WordBool): HResult; stdcall; +begin + Value := FooterAfterEach; + Result := S_OK; +end; + +function TfrxDataBand.Set_FooterAfterEach(Value: WordBool): HResult; stdcall; +begin + FooterAfterEach := Value; + Result := S_OK; +end; + +function TfrxDataBand.Get_KeepFooter(out Value: WordBool): HResult; stdcall; +begin + Value := KeepFooter; + Result := S_OK; +end; + +function TfrxDataBand.Set_KeepFooter(Value: WordBool): HResult; stdcall; +begin + KeepFooter := Value; + Result := S_OK; +end; + +function TfrxDataBand.Get_KeepHeader(out Value: WordBool): HResult; stdcall; +begin + Value := KeepHeader; + Result := S_OK; +end; + +function TfrxDataBand.Set_KeepHeader(Value: WordBool): HResult; stdcall; +begin + KeepHeader := Value; + Result := S_OK; +end; + +function TfrxDataBand.Get_KeepTogether(out Value: WordBool): HResult; stdcall; +begin + Value := KeepTogether; + Result := S_OK; +end; + +function TfrxDataBand.Set_KeepTogether(Value: WordBool): HResult; stdcall; +begin + KeepTogether := Value; + Result := S_OK; +end; + +function TfrxDataBand.Get_PrintIfDetailEmpty(out Value: WordBool): HResult; stdcall; +begin + Value := PrintIfDetailEmpty; + Result := S_OK; +end; + +function TfrxDataBand.Set_PrintIfDetailEmpty(Value: WordBool): HResult; stdcall; +begin + PrintIfDetailEmpty := Value; + Result := S_OK; +end; + +function TfrxDataBand.Get_RowCount(out Value: Integer): HResult; stdcall; +begin + Value := RowCount; + Result := S_OK; +end; + +function TfrxDataBand.Set_RowCount(Value: Integer): HResult; stdcall; +begin + RowCount := Value; + Result := S_OK; +end; + +function TfrxDataBand.ResetDataSet: HResult; stdcall; +begin + Self.FDataSet := nil; + Result := S_OK; +end; + +{$ENDIF} + +{ TfrxPageHeader } + +constructor TfrxPageHeader.Create(AOwner: TComponent); +begin + inherited; + FPrintOnFirstPage := True; +end; + + +{ TfrxPageFooter } + +constructor TfrxPageFooter.Create(AOwner: TComponent); +begin + inherited; + FPrintOnFirstPage := True; + FPrintOnLastPage := True; +end; + + +{ TfrxGroupHeader } + +function TfrxGroupHeader.Diff(AComponent: TfrxComponent): String; +begin + Result := inherited Diff(AComponent); + if FDrillDown then + Result := Result + ' Tag="' + IntToStr(FLineThrough) + '"'; +end; + + +{ TfrxSubreport } + +constructor TfrxSubreport.Create(AOwner: TComponent); +begin + inherited; + frComponentStyle := frComponentStyle - [csPreviewVisible]; + FFrame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + FFont.Name := 'Tahoma'; + FFont.Size := 8; + FColor := clSilver; +end; + +destructor TfrxSubreport.Destroy; +begin + if FPage <> nil then + FPage.FSubReport := nil; + inherited; +end; + +procedure TfrxSubreport.SetPage(const Value: TfrxReportPage); +begin + FPage := Value; + if FPage <> nil then + FPage.FSubReport := Self; +end; + +procedure TfrxSubreport.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +begin + inherited; + + with Canvas do + begin + Font.Assign(FFont); + TextOut(FX + 2, FY + 2, Name); + end; +end; + +class function TfrxSubreport.GetDescription: String; +begin + Result := frxResources.Get('obSubRep'); +end; + + +{$IFDEF FR_COM} +function TfrxSubreport.Get_Page(out Value: IfrxReportPage): HResult; stdcall; +begin + Value := Page; + Result := S_OK; +end; + +function TfrxSubreport.Set_Page(const Value: IfrxReportPage): HResult; stdcall; +begin + Page := (Value as {IfrxComponentSelf} IInterfaceComponentReference).GetComponent{Get_Object} as TfrxReportPage; + Result := S_OK; +end; + +function TfrxSubreport.Get_PrintOnparent(out Value: WordBool): HResult; stdcall; +begin + Value := PrintOnParent; + Result := S_OK; +end; + +function TfrxSubreport.Set_PrintOnparent(Value: WordBool): HResult; stdcall; +begin + PrintOnParent := Value; + Result := S_OK; +end; + +{ TfrxPage } + +function TfrxPage.Get_Visible(out Value: WordBool): HResult; stdcall; +begin + Value := Visible; + Result := S_OK; +end; + +function TfrxPage.Set_Visible(Value: WordBool): HResult; stdcall; +begin + Visible := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxDialogPage } + +constructor TfrxDialogPage.Create(AOwner: TComponent); +var + FSaveTag: Integer; +begin + inherited; + FSaveTag := Tag; + if (Report <> nil) and Report.EngineOptions.EnableThreadSafe then + Tag := 318 + else + Tag := 0; + FForm := TfrxDialogForm.Create(Self); + Tag := FSaveTag; + FForm.KeyPreview := True; + Font.Name := 'Tahoma'; + Font.Size := 8; + BorderStyle := bsSizeable; + Position := poScreenCenter; + WindowState := wsNormal; + Color := clBtnFace; + FForm.ShowHint := True; +end; + +destructor TfrxDialogPage.Destroy; +begin +{$IFNDEF NO_CRITICAL_SECTION} + frxCS.Enter; +{$ENDIF} + try + inherited; + FForm.Free; + finally +{$IFNDEF NO_CRITICAL_SECTION} + frxCS.Leave; +{$ENDIF} + end; +end; + +class function TfrxDialogPage.GetDescription: String; +begin + Result := frxResources.Get('obDlgPage'); +end; + +procedure TfrxDialogPage.SetLeft(Value: Extended); +begin + inherited; + FForm.Left := Round(Value); +end; + +procedure TfrxDialogPage.SetTop(Value: Extended); +begin + inherited; + FForm.Top := Round(Value); +end; + +procedure TfrxDialogPage.SetWidth(Value: Extended); +begin + inherited; + FForm.Width := Round(Value); +end; + +procedure TfrxDialogPage.SetHeight(Value: Extended); +begin + inherited; + FForm.Height := Round(Value); +end; + +procedure TfrxDialogPage.SetBorderStyle(const Value: TFormBorderStyle); +begin + FBorderStyle := Value; +end; + +procedure TfrxDialogPage.SetCaption(const Value: String); +begin + FCaption := Value; + FForm.Caption := Value; +end; + +procedure TfrxDialogPage.SetColor(const Value: TColor); +begin + FColor := Value; + FForm.Color := Value; +end; + +function TfrxDialogPage.GetModalResult: TModalResult; +begin + Result := FForm.ModalResult; +end; + +procedure TfrxDialogPage.SetModalResult(const Value: TModalResult); +begin + FForm.ModalResult := Value; +end; + +procedure TfrxDialogPage.FontChanged(Sender: TObject); +begin + inherited; + FForm.Font := Font; +end; + +procedure TfrxDialogPage.DoInitialize; +begin + if FForm.Visible then + FForm.Hide; + FForm.Position := FPosition; + FForm.WindowState := FWindowState; + FForm.OnActivate := DoOnActivate; + FForm.OnClick := DoOnClick; + FForm.OnCloseQuery := DoOnCloseQuery; + FForm.OnDeactivate := DoOnDeactivate; + FForm.OnHide := DoOnHide; + FForm.OnKeyDown := DoOnKeyDown; + FForm.OnKeyPress := DoOnKeyPress; + FForm.OnKeyUp := DoOnKeyUp; + FForm.OnShow := DoOnShow; + FForm.OnResize := DoOnResize; +end; + +procedure TfrxDialogPage.Initialize; +begin +{$IFNDEF FR_COM} +// if (Report <> nil) and (Report.EngineOptions.ReportThread <> nil) then +// THackThread(Report.EngineOptions.ReportThread).Synchronize(DoInitialize) else +{$ENDIF} + DoInitialize; +end; + +function TfrxDialogPage.ShowModal: TModalResult; +begin + Initialize; + FForm.BorderStyle := FBorderStyle; + FForm.FormStyle := fsNormal; + try + TfrxDialogForm(FForm).OnModify := DoModify; + Result := FForm.ShowModal; + finally + FForm.FormStyle := fsStayOnTop; + end; +end; + +procedure TfrxDialogPage.DoModify(Sender: TObject); +begin + FLeft := FForm.Left; + FTop := FForm.Top; + FWidth := FForm.Width; + FHeight := FForm.Height; +end; + +procedure TfrxDialogPage.DoOnActivate(Sender: TObject); +begin + DoModify(nil); + Report.DoNotifyEvent(Sender, FOnActivate); +end; + +procedure TfrxDialogPage.DoOnClick(Sender: TObject); +begin + Report.DoNotifyEvent(Sender, FOnClick); +end; + +procedure TfrxDialogPage.DoOnCloseQuery(Sender: TObject; var CanClose: Boolean); +var + v: Variant; +begin + v := VarArrayOf([Integer(Sender), CanClose]); + Report.DoParamEvent(FOnCloseQuery, v); + CanClose := v[1]; +end; + +procedure TfrxDialogPage.DoOnDeactivate(Sender: TObject); +begin + Report.DoNotifyEvent(Sender, FOnDeactivate); +end; + +procedure TfrxDialogPage.DoOnHide(Sender: TObject); +begin + Report.DoNotifyEvent(Sender, FOnHide); +end; + +procedure TfrxDialogPage.DoOnKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +var + v: Variant; +begin + v := VarArrayOf([Integer(Sender), Key, ShiftToByte(Shift)]); + if Report <> nil then + Report.DoParamEvent(FOnKeyDown, v); + Key := v[1]; +end; + +procedure TfrxDialogPage.DoOnKeyPress(Sender: TObject; var Key: Char); +var + v: Variant; +begin + v := VarArrayOf([Integer(Sender), Key]); + if Report <> nil then + Report.DoParamEvent(FOnKeyPress, v); + if VarToStr(v[1]) <> '' then + Key := VarToStr(v[1])[1] + else + Key := Chr(0); +end; + +procedure TfrxDialogPage.DoOnKeyUp(Sender: TObject; var Key: Word; + Shift: TShiftState); +var + v: Variant; +begin + v := VarArrayOf([Integer(Sender), Key, ShiftToByte(Shift)]); + if Report <> nil then + Report.DoParamEvent(FOnKeyUp, v); + Key := v[1]; +end; + +procedure TfrxDialogPage.DoOnShow(Sender: TObject); +begin + FForm.Perform(CM_FOCUSCHANGED, 0, Longint(FForm.ActiveControl)); + Report.DoNotifyEvent(Sender, FOnShow); +end; + +procedure TfrxDialogPage.DoOnResize(Sender: TObject); +begin + Report.DoNotifyEvent(Sender, FOnResize); +end; + + +{ TfrxReportPage } + +constructor TfrxReportPage.Create(AOwner: TComponent); +begin + inherited; + FBackPicture := TfrxPictureView.Create(nil); + FBackPicture.Color := clTransparent; + FBackPicture.KeepAspectRatio := False; + FColumnPositions := TStringList.Create; + FOrientation := poPortrait; + PaperSize := DMPAPER_A4; + FBin := DMBIN_AUTO; + FBinOtherPages := DMBIN_AUTO; + FBaseName := 'Page'; + FSubBands := TList.Create; + FVSubBands := TList.Create; + FHGuides := TStringList.Create; + FVGuides := TStringList.Create; + FPrintIfEmpty := True; + FTitleBeforeHeader := True; +end; + +destructor TfrxReportPage.Destroy; +begin + FColumnPositions.Free; + FBackPicture.Free; + FSubBands.Free; + FVSubBands.Free; + FHGuides.Free; + FVGuides.Free; + inherited; +end; + +class function TfrxReportPage.GetDescription: String; +begin + Result := frxResources.Get('obRepPage'); +end; + +procedure TfrxReportPage.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FDataSet) then + FDataSet := nil; +end; + +procedure TfrxReportPage.SetDataSet(const Value: TfrxDataSet); +begin + FDataSet := Value; + if FDataSet = nil then + FDataSetName := '' else + FDataSetName := FDataSet.UserName; +end; + +procedure TfrxReportPage.SetDataSetName(const Value: String); +begin + FDataSetName := Value; + FDataSet := frxFindDataSet(FDataSet, FDataSetName, Report); +end; + +function TfrxReportPage.GetDataSetName: String; +begin + if FDataSet = nil then + Result := FDataSetName else + Result := FDataSet.UserName; +end; + +procedure TfrxReportPage.SetPaperHeight(const Value: Extended); +begin + FPaperHeight := Round8(Value); + FPaperSize := 256; + UpdateDimensions; +end; + +procedure TfrxReportPage.SetPaperWidth(const Value: Extended); +begin + FPaperWidth := Round8(Value); + FPaperSize := 256; + UpdateDimensions; +end; + +procedure TfrxReportPage.SetPaperSize(const Value: Integer); +var + e: Extended; +begin + FPaperSize := Value; + if FPaperSize < DMPAPER_USER then + begin + if frxGetPaperDimensions(FPaperSize, FPaperWidth, FPaperHeight) then + if FOrientation = poLandscape then + begin + e := FPaperWidth; + FPaperWidth := FPaperHeight; + FPaperHeight := e; + end; + UpdateDimensions; + end; +end; + +procedure TfrxReportPage.SetSizeAndDimensions(ASize: Integer; AWidth, + AHeight: Extended); +begin + FPaperSize := ASize; + FPaperWidth := Round8(AWidth); + FPaperHeight := Round8(AHeight); + UpdateDimensions; +end; + +procedure TfrxReportPage.SetColumns(const Value: Integer); +begin + FColumns := Value; + FColumnPositions.Clear; + if FColumns <= 0 then exit; + + FColumnWidth := (FPaperWidth - FLeftMargin - FRightMargin) / FColumns; + while FColumnPositions.Count < FColumns do + FColumnPositions.Add(FloatToStr(FColumnPositions.Count * FColumnWidth)); +end; + +procedure TfrxReportPage.SetOrientation(Value: TPrinterOrientation); +var + e, m1, m2, m3, m4: Extended; +begin + if FOrientation <> Value then + begin + e := FPaperWidth; + FPaperWidth := FPaperHeight; + FPaperHeight := e; + + m1 := FLeftMargin; + m2 := FRightMargin; + m3 := FTopMargin; + m4 := FBottomMargin; + + if Value = poLandscape then + begin + FLeftMargin := m3; + FRightMargin := m4; + FTopMargin := m2; + FBottomMargin := m1; + end + else + begin + FLeftMargin := m4; + FRightMargin := m3; + FTopMargin := m1; + FBottomMargin := m2; + end; + UpdateDimensions; + end; + + FOrientation := Value; +end; + +procedure TfrxReportPage.UpdateDimensions; +begin + Width := Round(FPaperWidth * fr01cm); + Height := Round(FPaperHeight * fr01cm); +end; + +procedure TfrxReportPage.ClearGuides; +begin + FHGuides.Clear; + FVGuides.Clear; +end; + +procedure TfrxReportPage.SetHGuides(const Value: TStrings); +begin + FHGuides.Assign(Value); +end; + +procedure TfrxReportPage.SetVGuides(const Value: TStrings); +begin + FVGuides.Assign(Value); +end; + +function TfrxReportPage.FindBand(Band: TfrxBandClass): TfrxBand; +var + i: Integer; +begin + Result := nil; + for i := 0 to FObjects.Count - 1 do + if TObject(FObjects[i]) is Band then + begin + Result := FObjects[i]; + break; + end; +end; + +function TfrxReportPage.IsSubReport: Boolean; +begin + Result := SubReport <> nil; +end; + +procedure TfrxReportPage.SetColumnPositions(const Value: TStrings); +begin + FColumnPositions.Assign(Value); +end; + +function TfrxReportPage.GetFrame: TfrxFrame; +begin + Result := FBackPicture.Frame; +end; + +procedure TfrxReportPage.SetFrame(const Value: TfrxFrame); +begin + FBackPicture.Frame := Value; +end; + +function TfrxReportPage.GetColor: TColor; +begin + Result := FBackPicture.Color; +end; + +procedure TfrxReportPage.SetColor(const Value: TColor); +begin + FBackPicture.Color := Value; +end; + +function TfrxReportPage.GetBackPicture: TPicture; +begin + Result := FBackPicture.Picture; +end; + +procedure TfrxReportPage.SetBackPicture(const Value: TPicture); +begin + FBackPicture.Picture := Value; +end; + +procedure TfrxReportPage.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +begin + FBackPicture.Width := (FPaperWidth - FLeftMargin - FRightMargin) * fr01cm; + FBackPicture.Height := (FPaperHeight - FTopMargin - FBottomMargin) * fr01cm; + FBackPicture.Draw(Canvas, ScaleX, ScaleY, + OffsetX + FLeftMargin * fr01cm * ScaleX, + OffsetY + FTopMargin * fr01cm * ScaleY); +end; + +procedure TfrxReportPage.SetDefaults; +begin + FLeftMargin := 10; + FRightMargin := 10; + FTopMargin := 10; + FBottomMargin := 10; + FPaperSize := frxPrinters.Printer.DefPaper; + FPaperWidth := frxPrinters.Printer.DefPaperWidth; + FPaperHeight := frxPrinters.Printer.DefPaperHeight; + FOrientation := frxPrinters.Printer.DefOrientation; + UpdateDimensions; +end; + +procedure TfrxReportPage.AlignChildren; +var + i: Integer; + c: TfrxComponent; +begin + Width := (FPaperWidth - FLeftMargin - FRightMargin) * fr01cm; + Height := (FPaperHeight - FTopMargin - FBottomMargin) * fr01cm; + inherited; + for i := 0 to Objects.Count - 1 do + begin + c := Objects[i]; + if c is TfrxBand then + begin + if TfrxBand(c).Vertical then + c.Height := (FPaperHeight - FTopMargin - FBottomMargin) * fr01cm - c.Top + else + c.Width := Width - c.Left; +// previous bugfix is wrong!!! +// if c.Width > Width then +// c.Width := Width; +// if c.Height > Height then +// c.Height := Height; + c.AlignChildren; + end; + end; + UpdateDimensions; +end; + +{$IFDEF FR_COM} +function TfrxReportPage.IfrxReportPage_SetDefaults: HResult; stdcall; +begin + SetDefaults; + Result := 0; +end; + +function TfrxReportPage.IfrxReportPage_Get_Bin(out Value: SYSINT): HResult; stdcall; +begin + Value := Bin; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_Bin(Value: SYSINT): HResult; stdcall; +begin + Bin := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_BinOtherPages(out Value: SYSINT): HResult; stdcall; +begin + Value := BinOtherPages; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_BinOtherPages(Value: SYSINT): HResult; stdcall; +begin + BinOtherPages := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_BottomMargin(out Value: Double): HResult; stdcall; +begin + Value := BottomMargin; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_BottomMargin(Value: Double): HResult; stdcall; +begin + BottomMargin := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_Columns(out Value: SYSINT): HResult; stdcall; +begin + Value := Columns; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_Columns(Value: SYSINT): HResult; stdcall; +begin + Columns := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_ColumnWidth(out Value: Double): HResult; stdcall; +begin + Value := ColumnWidth; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_ColumnWidth(Value: Double): HResult; stdcall; +begin + ColumnWidth := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_ColumnPosition(out Value: WideString): HResult; stdcall; +begin + Value := ColumnPositions.GetText; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_ColumnPosition(const Value: WideString): HResult; stdcall; +begin + ColumnPositions.SetText(PAnsiChar(String(Value))); + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_DataSet(out Value: IfrxDataSet): HResult; stdcall; +begin + if FDataSet <> nil then + Value := DataSet; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_DataSet(const Value: IfrxDataSet): HResult; stdcall; +var + idsp: {IfrxComponentSelf} IInterfaceComponentReference; + comp: TfrxComponent; +begin + Result := Value.QueryInterface({IfrxComponentSelf} IInterfaceComponentReference, idsp); + if Result = S_OK then + begin + comp := TfrxComponent(idsp.GetComponent {Get_Object}); + DataSet := TfrxDataSet(comp); + comp.Parent := Self; + end; +end; + +function TfrxReportPage.IfrxReportPage_Get_Duplex(out Value: frxDuplexMode): HResult; stdcall; +begin + Value := frxDuplexMode(Duplex); + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_Duplex(Value: frxDuplexMode): HResult; stdcall; +begin + Duplex := TfrxDuplexMode(Value); + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_HGuides(out Value: WideString): HResult; stdcall; +begin + Value := HGuides.GetText; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_HGuides(const Value: WideString): HResult; stdcall; +begin + HGuides.SetText(PAnsiChar(String(Value))); + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_LargeDesignHeight(out Value: WordBool): HResult; stdcall; +begin + Value := LargeDesignHeight; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_LargeDesignHeight(Value: WordBool): HResult; stdcall; +begin + LargeDesignHeight := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_LeftMargin(out Value: Double): HResult; stdcall; +begin + Value := LeftMargin; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_LeftMargin(Value: Double): HResult; stdcall; +begin + LeftMargin := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_MirrorMargins(out Value: WordBool): HResult; stdcall; +begin + Value := MirrorMargins; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_MirrorMargins(Value: WordBool): HResult; stdcall; +begin + MirrorMargins := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_Orientation(out Value: frxPrinterOrientation): HResult; stdcall; +begin + Value := frxPrinterOrientation(Orientation); + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_Orientation(Value: frxPrinterOrientation): HResult; stdcall; +begin + Orientation := TPrinterOrientation(Value); + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_OutlineText(out Value: WideString): HResult; stdcall; +begin + Value := OutlineText; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_OutlineText(const Value: WideString): HResult; stdcall; +begin + OutlineText := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_PrintIfEmpty(out Value: WordBool): HResult; stdcall; +begin + Value := PrintIfEmpty; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_PrintIfEmpty(Value: WordBool): HResult; stdcall; +begin + PrintIfEmpty := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_PrintOnPreviousPage(out Value: WordBool): HResult; stdcall; +begin + Value := PrintOnPreviousPage; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_PrintOnPreviousPage(Value: WordBool): HResult; stdcall; +begin + PrintOnPreviousPage := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_RightMargin(out Value: Double): HResult; stdcall; +begin + Value := RightMargin; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_RightMargin(Value: Double): HResult; stdcall; +begin + RightMargin := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_SubReport(out Value: IfrxSubreport): HResult; stdcall; +begin + Value := Subreport; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_SubReport(const Value: IfrxSubreport): HResult; stdcall; +begin + Value.Set_Page(Self); + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_TitleBeforeHeader(out Value: WordBool): HResult; stdcall; +begin + Value := FTitleBeforeHeader; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_TitleBeforeHeader(Value: WordBool): HResult; stdcall; +begin + FTitleBeforeHeader := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_TopMargin(out Value: Double): HResult; stdcall; +begin + Value := FTopMargin; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_TopMargin(Value: Double): HResult; stdcall; +begin + FTopMargin := Value; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_VGuides(out Value: WideString): HResult; stdcall; +begin + Value := FVGuides.GetText; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_VGuides(const Value: WideString): HResult; stdcall; +begin + FVGuides.SetText(PAnsiChar(String(Value))); + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Get_BackPickture(out Value: OLE_HANDLE): HResult; stdcall; +begin + Value := BackPicture.Bitmap.Handle; + Result := S_OK; +end; + +function TfrxReportPage.IfrxReportPage_Set_BackPickture(Value: OLE_HANDLE): HResult; stdcall; +begin + BackPicture.Bitmap.Handle := Value; + Result := S_OK; +end; + +function TfrxReportPage.Get_PaperWidth(out Value: Double): HResult; stdcall; +begin + Value := PaperWidth; + Result := S_OK; +end; + +function TfrxReportPage.Set_PaperWidth(Value: Double): HResult; stdcall; +begin + PaperWidth := Value; + Result := S_OK; +end; + +function TfrxReportPage.Get_PaperHeight(out Value: Double): HResult; stdcall; +begin + Value := PaperHeight; + Result := S_OK; +end; + +function TfrxReportPage.Set_PaperHeight(Value: Double): HResult; stdcall; +begin + PaperHeight := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxDataPage } + +constructor TfrxDataPage.Create(AOwner: TComponent); +begin + inherited; + Width := 1000; + Height := 1000; +end; + +class function TfrxDataPage.GetDescription: String; +begin + Result := frxResources.Get('obDataPage'); +end; + + +{ TfrxEngineOptions } + +constructor TfrxEngineOptions.Create; +begin + Clear; + FMaxMemSize := 10; + FPrintIfEmpty := True; + FSilentMode := simMessageBoxes; + FEnableThreadSafe := False; + FTempDir := ''; +{$IFDEF FR_COM} + inherited Create(IfrxEngineOptions); + FUseFileCache := True; +{$ELSE} + FUseFileCache := False; +{$ENDIF} + FDestroyForms := True; +end; + +procedure TfrxEngineOptions.Assign(Source: TPersistent); +begin + if Source is TfrxEngineOptions then + begin + FConvertNulls := TfrxEngineOptions(Source).ConvertNulls; + FDoublePass := TfrxEngineOptions(Source).DoublePass; + FMaxMemSize := TfrxEngineOptions(Source).MaxMemSize; + FPrintIfEmpty := TfrxEngineOptions(Source).PrintIfEmpty; + NewSilentMode := TfrxEngineOptions(Source).NewSilentMode; + FTempDir := TfrxEngineOptions(Source).TempDir; + FUseFileCache := TfrxEngineOptions(Source).UseFileCache; + end; +end; + +procedure TfrxEngineOptions.Clear; +begin + FConvertNulls := True; + FDoublePass := False; +end; + +procedure TfrxEngineOptions.SetSilentMode(Mode: Boolean); +begin + if Mode = True then + FSilentMode := simSilent + else + FSilentMode := simMessageBoxes; +end; + +function TfrxEngineOptions.GetSilentMode: Boolean; +begin + if FSilentMode = simSilent then + Result := True + else + Result := False; +end; + +{$IFDEF FR_COM} +function TfrxEngineOptions.IfrxEngineOptions_Get_ConvertNulls(out Value: WordBool): HResult; stdcall; +begin + Value := FConvertNulls; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Set_ConvertNulls(Value: WordBool): HResult; stdcall; +begin + FConvertNulls := Value; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Get_DestroyForms(out Value: WordBool): HResult; stdcall; +begin + Value := FDestroyForms; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Set_DestroyForms(Value: WordBool): HResult; stdcall; +begin + FDestroyForms := Value; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Get_DoublePass(out Value: WordBool): HResult; stdcall; +begin + Value := FDoublePass; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Set_DoublePass(Value: WordBool): HResult; stdcall; +begin + FDoublePass := Value; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Get_MaxMemSize(out Value: SYSINT): HResult; stdcall; +begin + Value := FMaxMemSize; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Set_MaxMemSize(Value: SYSINT): HResult; stdcall; +begin + FMaxMemSize := Value; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Get_PrintIfEmpty(out Value: WordBool): HResult; stdcall; +begin + Value := FPrintIfEmpty; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Set_PrintIfEmpty(Value: WordBool): HResult; stdcall; +begin + FPrintIfEmpty := Value; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Get_SilentMode(out Value: frxSilentMode): HResult; stdcall; +begin + Value := frxSilentMode(FSilentMode); + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Set_SilentMode(Value: frxSilentMode): HResult; stdcall; +begin + FSilentMode := TfrxSilentMode(Value); + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Get_TempDir(out Value: WideString): HResult; stdcall; +begin + Value := FTempDir; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Set_TempDir(const Value: WideString): HResult; stdcall; +begin + FTempDir := Value; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Get_UseFilecache(out Value: WordBool): HResult; stdcall; +begin + Value := FUseFilecache; + Result := S_OK; +end; + +function TfrxEngineOptions.IfrxEngineOptions_Set_UseFilecache(Value: WordBool): HResult; stdcall; +begin + FUseFilecache := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxPreviewOptions } + +constructor TfrxPreviewOptions.Create; +begin + Clear; + FAllowEdit := True; + FButtons := [pbPrint, pbLoad, pbSave, pbExport, pbZoom, pbFind, + pbOutline, pbPageSetup, pbTools, pbEdit, pbNavigator, pbExportQuick]; + FDoubleBuffered := True; + FMaximized := True; + FMDIChild := False; + FModal := True; + FPagesInCache := 50; + FShowCaptions := False; + FZoom := 1; + FZoomMode := zmDefault; +{$IFDEF FR_COM} + inherited Create(IfrxPreviewOptions); +{$ENDIF} +end; + +procedure TfrxPreviewOptions.Assign(Source: TPersistent); +begin + if Source is TfrxPreviewOptions then + begin + FAllowEdit := TfrxPreviewOptions(Source).AllowEdit; + FButtons := TfrxPreviewOptions(Source).Buttons; + FDoubleBuffered := TfrxPreviewOptions(Source).DoubleBuffered; + FMaximized := TfrxPreviewOptions(Source).Maximized; + FMDIChild := TfrxPreviewOptions(Source).MDIChild; + FModal := TfrxPreviewOptions(Source).Modal; + FOutlineExpand := TfrxPreviewOptions(Source).OutlineExpand; + FOutlineVisible := TfrxPreviewOptions(Source).OutlineVisible; + FOutlineWidth := TfrxPreviewOptions(Source).OutlineWidth; + FPagesInCache := TfrxPreviewOptions(Source).PagesInCache; + FShowCaptions := TfrxPreviewOptions(Source).ShowCaptions; + FThumbnailVisible := TfrxPreviewOptions(Source).ThumbnailVisible; + FZoom := TfrxPreviewOptions(Source).Zoom; + FZoomMode := TfrxPreviewOptions(Source).ZoomMode; + end; +end; + +procedure TfrxPreviewOptions.Clear; +begin + FOutlineExpand := True; + FOutlineVisible := False; + FOutlineWidth := 120; + FPagesInCache := 50; + FThumbnailVisible := False; +end; + +{$IFDEF FR_COM} +function TfrxPreviewOptions.IfrxPreviewOptions_Get_AllowEdit(out Value: WordBool): HResult; stdcall; +begin + Value := FAllowEdit; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_AllowEdit(Value: WordBool): HResult; stdcall; +begin + FAllowEdit := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_Buttons(out Value: frxPreviewButtons): HResult; stdcall; +begin + Value := TOleEnum(PInteger(@Buttons)^); + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_Buttons(Value: frxPreviewButtons): HResult; stdcall; +type + PfrxPreviewButtons = ^ TfrxPreviewButtons; +begin + Buttons := PfrxPreviewButtons(@Value)^; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_DoubleBuffered(out Value: WordBool): HResult; stdcall; +begin + Value := FDoubleBuffered; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_DoubleBuffered(Value: WordBool): HResult; stdcall; +begin + FDoubleBuffered := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_Maximazed(out Value: WordBool): HResult; stdcall; +begin + Value := FMaximized; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_Maximazed(Value: WordBool): HResult; stdcall; +begin + FMaximized := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_MDIChild(out Value: WordBool): HResult; stdcall; +begin + Value := FMDIChild; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_MDIChild(Value: WordBool): HResult; stdcall; +begin + FMDIChild := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_Modal(out Value: WordBool): HResult; stdcall; +begin + Value := FModal; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_Modal(Value: WordBool): HResult; stdcall; +begin + FModal := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_OutlineExpand(out Value: WordBool): HResult; stdcall; +begin + Value := FOutlineExpand; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_OutlineExpand(Value: WordBool): HResult; stdcall; +begin + FOutlineExpand := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_OutlineVisible(out Value: WordBool): HResult; stdcall; +begin + Value := FOutlineVisible; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_OutlineVisible(Value: WordBool): HResult; stdcall; +begin + FOutlineVisible := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_OutlineWidth(out Value: SYSINT): HResult; stdcall; +begin + Value := FOutlineWidth; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_OutlineWidth(Value: SYSINT): HResult; stdcall; +begin + FOutlineWidth := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_ShowCaptions(out Value: WordBool): HResult; stdcall; +begin + Value := FShowCaptions; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_ShowCaptions(Value: WordBool): HResult; stdcall; +begin + FShowCaptions := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_Zoom(out Value: Double): HResult; stdcall; +begin + Value := FZoom; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_Zoom(Value: Double): HResult; stdcall; +begin + FZoom := Value; + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Get_ZoomMode(out Value: frxZoomMode): HResult; stdcall; +begin + Value := frxZoomMode(FZoomMode); + Result := S_OK; +end; + +function TfrxPreviewOptions.IfrxPreviewOptions_Set_ZoomMode(Value: frxZoomMode): HResult; stdcall; +begin + FZoomMode := TfrxZoomMode(Value); + Result := S_OK; +end; +{$ENDIF} + +{ TfrxPrintOptions } + +constructor TfrxPrintOptions.Create; +begin +{$IFDEF FR_COM} + inherited Create(IfrxPrintOptions); +{$ENDIF} + Clear; +end; + +{$IFDEF FR_COM} +destructor TfrxPrintOptions.Destroy; +begin + inherited Destroy; +end; +{$ENDIF} + +procedure TfrxPrintOptions.Assign(Source: TPersistent); +begin + if Source is TfrxPrintOptions then + begin + FCopies := TfrxPrintOptions(Source).Copies; + FCollate := TfrxPrintOptions(Source).Collate; + FPageNumbers := TfrxPrintOptions(Source).PageNumbers; + FPrinter := TfrxPrintOptions(Source).Printer; + FPrintMode := TfrxPrintOptions(Source).PrintMode; + FPrintOnSheet := TfrxPrintOptions(Source).PrintOnSheet; + FPrintPages := TfrxPrintOptions(Source).PrintPages; + FReverse := TfrxPrintOptions(Source).Reverse; + FShowDialog := TfrxPrintOptions(Source).ShowDialog; + end; +end; + +procedure TfrxPrintOptions.Clear; +begin + FCopies := 1; + FCollate := True; + FPageNumbers := ''; + FPagesOnSheet := 0; + FPrinter := frxResources.Get('prDefault'); + FPrintMode := pmDefault; + FPrintOnSheet := 0; + FPrintPages := ppAll; + FReverse := False; + FShowDialog := True; +end; + +{$IFDEF FR_COM} +function TfrxPrintOptions.IfrxPrintOptions_Get_Copies(out Value: SYSINT): HResult; stdcall; +begin + Value := Copies; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Set_Copies(Value: SYSINT): HResult; stdcall; +begin + Copies := Value; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Get_Collate(out Value: WordBool): HResult; stdcall; +begin + Value := Collate; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Set_Collate(Value: WordBool): HResult; stdcall; +begin + Collate := Value; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Get_PageNumbers(out Value: WideString): HResult; stdcall; +begin + Value := PageNumbers; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Set_PageNumbers(const Value: WideString): HResult; stdcall; +begin + PageNumbers := Value; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Get_Printer(out Value: WideString): HResult; stdcall; +begin + Value := Printer; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Set_Printer(const Value: WideString): HResult; stdcall; +begin + Printer := Value; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Get_PrintPages(out Value: frxPrintPages): HResult; stdcall; +begin + Value := frxPrintPages(PrintPages); + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Set_PrintPages(Value: frxPrintPages): HResult; stdcall; +begin + PrintPages := TfrxPrintPages(Value); + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Get_Reverse(out Value: WordBool): HResult; stdcall; +begin + Value := Reverse; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Set_Reverse(Value: WordBool): HResult; stdcall; +begin + Reverse := Value; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Get_ShowDialog(out Value: WordBool): HResult; stdcall; +begin + Value := ShowDialog; + Result := S_OK; +end; + +function TfrxPrintOptions.IfrxPrintOptions_Set_ShowDialog(Value: WordBool): HResult; stdcall; +begin + ShowDialog := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxReportOptions } + +constructor TfrxReportOptions.Create; +begin + FDescription := TStringList.Create; + FPicture := TPicture.Create; + FCreateDate := Now; + FLastChange := Now; + FPrevPassword := ''; + FInfo := False; +{$IFDEF FR_COM} + inherited Create(IfrxReportOptions); +{$ENDIF} +end; + +destructor TfrxReportOptions.Destroy; +begin + FDescription.Free; + FPicture.Free; + inherited; +end; + +procedure TfrxReportOptions.Assign(Source: TPersistent); +begin + if Source is TfrxReportOptions then + begin + FAuthor := TfrxReportOptions(Source).Author; + FCompressed := TfrxReportOptions(Source).Compressed; + FConnectionName := TfrxReportOptions(Source).ConnectionName; + FCreateDate := TfrxReportOptions(Source).CreateDate; + Description := TfrxReportOptions(Source).Description; + FInitString := TfrxReportOptions(Source).InitString; + FLastChange := TfrxReportOptions(Source).LastChange; + FName := TfrxReportOptions(Source).Name; + FPassword := TfrxReportOptions(Source).Password; + Picture := TfrxReportOptions(Source).Picture; + FVersionBuild := TfrxReportOptions(Source).VersionBuild; + FVersionMajor := TfrxReportOptions(Source).VersionMajor; + FVersionMinor := TfrxReportOptions(Source).VersionMinor; + FVersionRelease := TfrxReportOptions(Source).VersionRelease; + end; +end; + +procedure TfrxReportOptions.Clear; +begin + if not FInfo then + begin + FAuthor := ''; + FCompressed := False; + FCreateDate := Now; + FDescription.Clear; + FLastChange := Now; + FPicture.Assign(nil); + FVersionBuild := ''; + FVersionMajor := ''; + FVersionMinor := ''; + FVersionRelease := ''; + end; + FConnectionName := ''; + FInitString := ''; + FName := ''; + FPassword := ''; + FPrevPassword := ''; +end; + +procedure TfrxReportOptions.SetDescription(const Value: TStrings); +begin + FDescription.Assign(Value); +end; + +procedure TfrxReportOptions.SetPicture(const Value: TPicture); +begin + FPicture.Assign(Value); +end; + +function TfrxReportOptions.CheckPassword: Boolean; +begin + Result := True; + if (FPassword <> '') and (FPassword <> FPrevPassword) then + with TfrxPasswordForm.Create(Application) do + begin + if (ShowModal <> mrOk) or (FPassword <> PasswordE.Text) then + Result := False + else + FPrevPassword := FPassword; + Free; + end; +end; + +procedure TfrxReportOptions.SetConnectionName(const Value: String); +var + ini: TRegistry; + conn: String; +begin + FConnectionName := Value; + if Value <> '' then + if Assigned(FReport.OnSetConnection) then + begin + ini := TRegistry.Create; + try + ini.RootKey := HKEY_LOCAL_MACHINE; + if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS) then + begin + conn := ini.ReadString(Value); + if conn <> '' then FReport.OnSetConnection( conn ); + ini.CloseKey; + end; + ini.RootKey := HKEY_CURRENT_USER; + if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS) then + begin + conn := ini.ReadString(Value); + if conn <> '' then FReport.OnSetConnection(conn); + ini.CloseKey; + end; + finally + ini.Free; + end; + end; +end; + +{$IFDEF FR_COM} +function TfrxReportOptions.IfrxReportOptions_Get_Author(out Value: WideString): HResult; stdcall; +begin + Value := FAuthor; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_Author(const Value: WideString): HResult; stdcall; +begin + FAuthor := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_Compressed(out Value: WordBool): HResult; stdcall; +begin + Value := FCompressed; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_Compressed(Value: WordBool): HResult; stdcall; +begin + FCompressed := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_ConnectionName(out Value: WideString): HResult; stdcall; +begin + Value := ConnectionName; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_ConnectionName(const Value: WideString): HResult; stdcall; +begin + ConnectionName := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_CreationDate(out Value: TDateTime): HResult; stdcall; +begin + Value := FCreateDate; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_CreationDate(Value: TDateTime): HResult; stdcall; +begin + FCreateDate := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_Description(out Value: WideString): HResult; stdcall; +begin + Value := FDescription.GetText; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_Description(const Value: WideString): HResult; stdcall; +begin + FDescription.SetText(PAnsiChar(String(Value))); + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_InitString(out Value: WideString): HResult; stdcall; +begin + Value := FInitString; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_InitString(const Value: WideString): HResult; stdcall; +begin + FInitString := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_Name(out Value: WideString): HResult; stdcall; +begin + Value := FName; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_Name(const Value: WideString): HResult; stdcall; +begin + FName := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_LastChange(out Value: TDateTime): HResult; stdcall; +begin + Value := FLastChange; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_LastChange(Value: TDateTime): HResult; stdcall; +begin + FLastChange := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_Password(out Value: WideString): HResult; stdcall; +begin + Value := FPassword; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_Password(const Value: WideString): HResult; stdcall; +begin + FPassword := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_Picture(out Value: IUnknown): HResult; stdcall; +begin + Result := E_NOTIMPL; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_Picture(const Value: IUnknown): HResult; stdcall; +begin + Result := E_NOTIMPL; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_VersionBuild(out Value: WideString): HResult; stdcall; +begin + Value := FVersionBuild; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_VersionBuild(const Value: WideString): HResult; stdcall; +begin + FVersionBuild := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_VersionMajor(out Value: WideString): HResult; stdcall; +begin + Value := FVersionMajor; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_VersionMajor(const Value: WideString): HResult; stdcall; +begin + FVersionMajor := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_VersionMinor(out Value: WideString): HResult; stdcall; +begin + Value := FVersionMinor; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_VersionMinor(const Value: WideString): HResult; stdcall; +begin + FVersionMinor := Value; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Get_VersionRelease(out Value: WideString): HResult; stdcall; +begin + Value := FVersionRelease; + Result := S_OK; +end; + +function TfrxReportOptions.IfrxReportOptions_Set_VersionRelease(const Value: WideString): HResult; stdcall; +begin + FVersionRelease := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxDataSetItem } + +procedure TfrxDataSetItem.SetDataSet(const Value: TfrxDataSet); +begin + FDataSet := Value; + if FDataSet = nil then + FDataSetName := '' else + FDataSetName := FDataSet.UserName; +end; + +procedure TfrxDataSetItem.SetDataSetName(const Value: String); +begin + FDataSetName := Value; + FDataSet := frxFindDataSet(FDataSet, FDataSetName, + TfrxReportDataSets(Collection).FReport); +end; + +function TfrxDataSetItem.GetDataSetName: String; +begin + if FDataSet = nil then + Result := FDataSetName else + Result := FDataSet.UserName; +end; + + +{ TfrxReportDatasets } + +constructor TfrxReportDatasets.Create(AReport: TfrxReport); +begin + inherited Create(TfrxDatasetItem); + FReport := AReport; +end; + +procedure TfrxReportDataSets.Initialize; +var + i: Integer; +begin + for i := 0 to Count - 1 do + if Items[i].DataSet <> nil then + begin + Items[i].DataSet.ReportRef := FReport; + Items[i].DataSet.Initialize; + end; +end; + +procedure TfrxReportDataSets.Finalize; +var + i: Integer; +begin + for i := 0 to Count - 1 do + if Items[i].DataSet <> nil then + Items[i].DataSet.Finalize; +end; + +procedure TfrxReportDatasets.Add(ds: TfrxDataSet); +begin + TfrxDatasetItem(inherited Add).DataSet := ds; +end; + +function TfrxReportDatasets.GetItem(Index: Integer): TfrxDatasetItem; +begin + Result := TfrxDatasetItem(inherited Items[Index]); +end; + +function TfrxReportDatasets.Find(ds: TfrxDataSet): TfrxDatasetItem; +var + i: Integer; +begin + Result := nil; + for i := 0 to Count - 1 do + if Items[i].DataSet = ds then + begin + Result := Items[i]; + Exit; + end; +end; + +function TfrxReportDatasets.Find(const Name: String): TfrxDatasetItem; +var + i: Integer; +begin + Result := nil; + for i := 0 to Count - 1 do + if Items[i].DataSet <> nil then + if CompareText(Items[i].DataSet.UserName, Name) = 0 then + begin + Result := Items[i]; + Exit; + end; +end; + +procedure TfrxReportDatasets.Delete(const Name: String); +var + i: Integer; +begin + for i := 0 to Count - 1 do + if Items[i].DataSet <> nil then + if CompareText(Items[i].DataSet.UserName, Name) = 0 then + begin + Items[i].Free; + Exit; + end; +end; + +{ TfrxStyleItem } + +constructor TfrxStyleItem.Create(Collection: TCollection); +begin + inherited; + FColor := clNone; + FFont := TFont.Create; + with FFont do + begin + Name := DefFontName; + Size := DefFontSize; + Charset := frxCharset; + end; + FFrame := TfrxFrame.Create; +end; + +destructor TfrxStyleItem.Destroy; +begin + FFont.Free; + FFrame.Free; + inherited; +end; + +procedure TfrxStyleItem.Assign(Source: TPersistent); +begin + if Source is TfrxStyleItem then + begin + FName := TfrxStyleItem(Source).Name; + FColor := TfrxStyleItem(Source).Color; + FFont.Assign(TfrxStyleItem(Source).Font); + FFrame.Assign(TfrxStyleItem(Source).Frame); + end; +end; + +procedure TfrxStyleItem.SetFont(const Value: TFont); +begin + FFont.Assign(Value); +end; + +procedure TfrxStyleItem.SetFrame(const Value: TfrxFrame); +begin + FFrame.Assign(Value); +end; + +procedure TfrxStyleItem.SetName(const Value: String); +var + Item: TfrxStyleItem; +begin + Item := TfrxStyles(Collection).Find(Value); + if (Item = nil) or (Item = Self) then + FName := Value else + raise Exception.Create('Duplicate name'); +end; + +procedure TfrxStyleItem.CreateUniqueName; +var + i: Integer; +begin + i := 1; + while TfrxStyles(Collection).Find('Style' + IntToStr(i)) <> nil do + Inc(i); + Name := 'Style' + IntToStr(i); +end; + + +{ TfrxStyles } + +constructor TfrxStyles.Create(AReport: TfrxReport); +begin + inherited Create(TfrxStyleItem); + FReport := AReport; +end; + +function TfrxStyles.Add: TfrxStyleItem; +begin + Result := TfrxStyleItem(inherited Add); +end; + +function TfrxStyles.Find(const Name: String): TfrxStyleItem; +var + i: Integer; +begin + Result := nil; + for i := 0 to Count - 1 do + if AnsiCompareText(Items[i].Name, Name) = 0 then + begin + Result := Items[i]; + break; + end; +end; + +function TfrxStyles.GetItem(Index: Integer): TfrxStyleItem; +begin + Result := TfrxStyleItem(inherited Items[Index]); +end; + +procedure TfrxStyles.GetList(List: TStrings); +var + i: Integer; +begin + List.Clear; + for i := 0 to Count - 1 do + List.Add(Items[i].Name); +end; + +procedure TfrxStyles.LoadFromXMLItem(Item: TfrxXMLItem); +var + xs: TfrxXMLSerializer; + i: Integer; +begin + Clear; + xs := TfrxXMLSerializer.Create(nil); + try + Name := Item.Prop['Name']; + for i := 0 to Item.Count - 1 do + if CompareText(Item[i].Name, 'item') = 0 then + xs.XMLToObj(Item[i].Text, Add); + finally + xs.Free; + end; + + Apply; +end; + +procedure TfrxStyles.SaveToXMLItem(Item: TfrxXMLItem); +var + xi: TfrxXMLItem; + xs: TfrxXMLSerializer; + i: Integer; +begin + xs := TfrxXMLSerializer.Create(nil); + try + Item.Name := 'style'; + Item.Prop['Name'] := Name; + for i := 0 to Count - 1 do + begin + xi := Item.Add; + xi.Name := 'item'; + xi.Text := xs.ObjToXML(Items[i]); + end; + finally + xs.Free; + end; +end; + +procedure TfrxStyles.LoadFromFile(const FileName: String); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmOpenRead); + try + LoadFromStream(f); + finally + f.Free; + end; +end; + +procedure TfrxStyles.LoadFromStream(Stream: TStream); +var + x: TfrxXMLDocument; +begin + Clear; + x := TfrxXMLDocument.Create; + try + x.LoadFromStream(Stream); + if CompareText(x.Root.Name, 'style') = 0 then + LoadFromXMLItem(x.Root); + finally + x.Free; + end; +end; + +procedure TfrxStyles.SaveToFile(const FileName: String); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmCreate); + try + SaveToStream(f); + finally + f.Free; + end; +end; + +procedure TfrxStyles.SaveToStream(Stream: TStream); +var + x: TfrxXMLDocument; +begin + x := TfrxXMLDocument.Create; + x.AutoIndent := True; + try + x.Root.Name := 'style'; + SaveToXMLItem(x.Root); + x.SaveToStream(Stream); + finally + x.Free; + end; +end; + +procedure TfrxStyles.Apply; +var + i: Integer; + l: TList; +begin + if FReport <> nil then + begin + l := FReport.AllObjects; + for i := 0 to l.Count - 1 do + if TObject(l[i]) is TfrxCustomMemoView then + if Find(TfrxCustomMemoView(l[i]).Style) = nil then + TfrxCustomMemoView(l[i]).Style := '' + else + TfrxCustomMemoView(l[i]).Style := TfrxCustomMemoView(l[i]).Style; + end; +end; + + +{ TfrxStyleSheet } + +constructor TfrxStyleSheet.Create; +begin + FItems := TList.Create; +end; + +destructor TfrxStyleSheet.Destroy; +begin + Clear; + FItems.Free; + inherited; +end; + +procedure TfrxStyleSheet.Clear; +begin + while Count > 0 do + Delete(0); +end; + +procedure TfrxStyleSheet.Delete(Index: Integer); +begin + Items[Index].Free; + FItems.Delete(Index); +end; + +function TfrxStyleSheet.Add: TfrxStyles; +begin + Result := TfrxStyles.Create(nil); + FItems.Add(Result); +end; + +function TfrxStyleSheet.Count: Integer; +begin + Result := FItems.Count; +end; + +function TfrxStyleSheet.GetItems(Index: Integer): TfrxStyles; +begin + Result := FItems[Index]; +end; + +function TfrxStyleSheet.Find(const Name: String): TfrxStyles; +var + i: Integer; +begin + Result := nil; + for i := 0 to Count - 1 do + if AnsiCompareText(Items[i].Name, Name) = 0 then + begin + Result := Items[i]; + break; + end; +end; + +function TfrxStyleSheet.IndexOf(const Name: String): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to Count - 1 do + if AnsiCompareText(Items[i].Name, Name) = 0 then + begin + Result := i; + break; + end; +end; + +procedure TfrxStyleSheet.GetList(List: TStrings); +var + i: Integer; +begin + List.Clear; + for i := 0 to Count - 1 do + List.Add(Items[i].Name); +end; + +procedure TfrxStyleSheet.LoadFromFile(const FileName: String); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmOpenRead); + try + LoadFromStream(f); + finally + f.Free; + end; +end; + +procedure TfrxStyleSheet.LoadFromStream(Stream: TStream); +var + x: TfrxXMLDocument; + i: Integer; +begin + Clear; + x := TfrxXMLDocument.Create; + try + x.LoadFromStream(Stream); + if CompareText(x.Root.Name, 'stylesheet') = 0 then + for i := 0 to x.Root.Count - 1 do + if CompareText(x.Root[i].Name, 'style') = 0 then + Add.LoadFromXMLItem(x.Root[i]); + finally + x.Free; + end; +end; + +procedure TfrxStyleSheet.SaveToFile(const FileName: String); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmCreate); + try + SaveToStream(f); + finally + f.Free; + end; +end; + +procedure TfrxStyleSheet.SaveToStream(Stream: TStream); +var + x: TfrxXMLDocument; + i: Integer; +begin + x := TfrxXMLDocument.Create; + x.AutoIndent := True; + try + x.Root.Name := 'stylesheet'; + for i := 0 to Count - 1 do + Items[i].SaveToXMLItem(x.Root.Add); + + x.SaveToStream(Stream); + finally + x.Free; + end; +end; + + +{ TfrxReport } + +constructor TfrxReport.Create(AOwner: TComponent); +begin + inherited; + FVersion := FR_VERSION; + FDatasets := TfrxReportDatasets.Create(Self); + FVariables := TfrxVariables.Create; + FScript := TfsScript.Create(nil); + FScript.ExtendedCharset := True; + FScript.AddRTTI; + + FTimer := TTimer.Create(nil); + FTimer.Interval := 50; + FTimer.Enabled := False; + FTimer.OnTimer := OnTimer; + + FEngineOptions := TfrxEngineOptions.Create; + FPreviewOptions := TfrxPreviewOptions.Create; + FPrintOptions := TfrxPrintOptions.Create; + FReportOptions := TfrxReportOptions.Create(Self); + FReportOptions.FReport := Self; + + FIniFile := '\Software\Fast Reports'; + FScriptText := TStringList.Create; + FExpressionCache := TfrxExpressionCache.Create(FScript); + FErrors := TStringList.Create; + TStringList(FErrors).Sorted := True; + TStringList(FErrors).Duplicates := dupIgnore; + FStyles := TfrxStyles.Create(Self); + FSysVariables := TStringList.Create; + FEnabledDataSets := TfrxReportDataSets.Create(Self); + FShowProgress := True; + FStoreInDFM := True; + + FEngine := TfrxEngine.Create(Self); + FPreviewPages := TfrxPreviewPages.Create(Self); + FEngine.FPreviewPages := FPreviewPages; + FPreviewPages.FEngine := FEngine; + FDrawText := TfrxDrawText.Create; + FDrillState := TStringList.Create; + Clear; +{$IFDEF FR_COM} + + FUseDispatchableEvents := False; + EngineOptions.DestroyForms := False; + Name := 'Report'; + + if not Assigned(frxDefaultConnection) then + begin + frxDefaultConnection := TADOConnection.Create(nil); + frxDefaultConnection.Name := 'DefaultConnection'; + frxDefaultConnection.LoginPrompt := False; + end; + + if not Assigned(frxADOComponent) then + begin + frxADOComponent := TfrxADOComponents.Create(nil); + frxADOComponent.DefaultDatabase := frxDefaultConnection; + end; + + OnSetConnection := OnSetConnectionHandler; + OnEditConnection := OnEditConnectionHandler; + + OnAfterPrint := OnAfterPrintHandler; + OnBeforePrint := OnBeforePrintHandler; + OnClickObject := OnClickObjectHandler; + OnUserFunction := OnUserFunctionHandler; + OnBeginDoc := OnBeginDocHandler; + OnEndDoc := OnEndDocHandler; + OnPrintReport := OnPrintReportHandler; + OnAfterPrintReport := OnAfterPrintReportHandler; + OnBeforeConnect := OnBeforeConnectHandler; + + OnProgress := OnProgressHandler; + OnProgressStart := OnProgressStartHandler; + OnProgressStop := OnProgressStopHandler; + +// Engine.OnRunDialog := OnRunDialogsEvent; + + FConnectionPoints := TConnectionPoints.Create(Self); + FConnectionPoint := FConnectionPoints.CreateConnectionPoint( IfrxReportEventDispatcher, ckMulti, nil ); + FEvent := nil; + FConnectionPoints.CreateConnectionPoint( IfrxReportEvents, ckSingle, EventSinkChanged ); +{$ENDIF} +end; + +destructor TfrxReport.Destroy; +begin + inherited; + Preview := nil; + + FDatasets.Free; + FEngineOptions.Free; + FPreviewOptions.Free; + FPrintOptions.Free; + FReportOptions.Free; + + FExpressionCache.Free; + FScript.Free; + FScriptText.Free; + FVariables.Free; + FEngine.Free; + FPreviewPages.Free; + FErrors.Free; + FStyles.Free; + FSysVariables.Free; + FEnabledDataSets.Free; + FTimer.Free; + TObject(FDrawText).Free; + FDrillState.Free; + + if FParentForm <> nil then + FParentForm.Free; +{$IFDEF FR_COM} + FConnectionPoint.Free; + FConnectionPoints.Free; +{$ENDIF} +end; + +class function TfrxReport.GetDescription: String; +begin + Result := frxResources.Get('obReport'); +end; + +procedure TfrxReport.DoClear; +begin + inherited Clear; + FDataSets.Clear; + FVariables.Clear; + FEngineOptions.Clear; + FPreviewOptions.Clear; + FPrintOptions.Clear; + FReportOptions.Clear; + FStyles.Clear; + FDataSet := nil; + FDataSetName := ''; + FDotMatrixReport := False; + ParentReport := ''; + + FScriptLanguage := 'PascalScript'; + with FScriptText do + begin + Clear; + Add('begin'); + Add(''); + Add('end.'); + end; + + with FSysVariables do + begin + Clear; + Add('Date'); + Add('Time'); + Add('Page'); + Add('Page#'); + Add('TotalPages'); + Add('TotalPages#'); + Add('Line'); + Add('Line#'); + Add('CopyName#'); + end; + + FOnRunDialogs := ''; + FOnStartReport := ''; + FOnStopReport := ''; +end; + +procedure TfrxReport.Clear; +begin +{$IFNDEF FR_COM} +// if FEngineOptions.ReportThread <> nil then +// THackThread(FEngineOptions.ReportThread).Synchronize(DoClear) else +{$ENDIF} + DoClear; +end; + +procedure TfrxReport.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if Operation = opRemove then + if AComponent is TfrxDataSet then + begin + if FDataSets.Find(TfrxDataSet(AComponent)) <> nil then + FDataSets.Find(TfrxDataSet(AComponent)).Free; + if FDataset = AComponent then + FDataset := nil; + if Designer <> nil then + Designer.UpdateDataTree; + end + else if AComponent is TfrxCustomPreview then + if FPreview = AComponent then + FPreview := nil; +end; + +procedure TfrxReport.AncestorNotFound(Reader: TReader; const ComponentName: string; + ComponentClass: TPersistentClass; var Component: TComponent); +begin + Component := FindObject(ComponentName); +end; + +procedure TfrxReport.DefineProperties(Filer: TFiler); +begin + inherited; + if (csWriting in ComponentState) and not FStoreInDFM then Exit; + + Filer.DefineProperty('Datasets', ReadDatasets, WriteDatasets, True); + Filer.DefineProperty('Variables', ReadVariables, WriteVariables, True); + Filer.DefineProperty('Style', ReadStyle, WriteStyle, True); + if Filer is TReader then + TReader(Filer).OnAncestorNotFound := AncestorNotFound; +end; + +procedure TfrxReport.ReadDatasets(Reader: TReader); +begin + frxReadCollection(FDatasets, Reader, Self); +end; + +procedure TfrxReport.ReadStyle(Reader: TReader); +begin + frxReadCollection(FStyles, Reader, Self); +end; + +procedure TfrxReport.ReadVariables(Reader: TReader); +begin + frxReadCollection(FVariables, Reader, Self); +end; + +procedure TfrxReport.WriteDatasets(Writer: TWriter); +begin + frxWriteCollection(FDatasets, Writer, Self); +end; + +procedure TfrxReport.WriteStyle(Writer: TWriter); +begin + frxWriteCollection(FStyles, Writer, Self); +end; + +procedure TfrxReport.WriteVariables(Writer: TWriter); +begin + frxWriteCollection(FVariables, Writer, Self); +end; + +function TfrxReport.GetPages(Index: Integer): TfrxPage; +begin + Result := TfrxPage(Objects[Index]); +end; + +function TfrxReport.GetPagesCount: Integer; +begin + Result := Objects.Count; +end; + +procedure TfrxReport.SetScriptText(const Value: TStrings); +begin + FScriptText.Assign(Value); +end; + +procedure TfrxReport.SetEngineOptions(const Value: TfrxEngineOptions); +begin + FEngineOptions.Assign(Value); +end; + +procedure TfrxReport.SetParentReport(const Value: String); +var + i: Integer; + list: TList; + c: TfrxComponent; + fName, SaveFileName: String; + SaveXMLSerializer: TObject; +begin + FParentReport := Value; + if FParentReportObject <> nil then + begin + FParentReportObject.Free; + FParentReportObject := nil; + end; + if Value = '' then + begin + list := AllObjects; + for i := 0 to list.Count - 1 do + begin + c := list[i]; + c.FAncestor := False; + end; + + FAncestor := False; + Exit; + end; + + SaveFileName := FFileName; + SaveXMLSerializer := FXMLSerializer; + if Assigned(FOnLoadTemplate) then + FOnLoadTemplate(Self, Value) + else + begin + fName := Value; + { check relative path } + if (Length(fName) > 1) and (fName[2] <> ':') then + fName := GetApplicationFolder + Value; + LoadFromFile(fName); + end; + + FFileName := SaveFileName; + FParentReportObject := TfrxReport.Create(nil); + FParentReportObject.AssignAll(Self); + + { set ancestor flag for parent objects } + list := AllObjects; + for i := 0 to list.Count - 1 do + begin + c := list[i]; + c.FAncestor := True; + end; + + FAncestor := True; + FParentReport := Value; + FXMLSerializer := SaveXMLSerializer; +end; + +function TfrxReport.InheritFromTemplate(const templName: String): Boolean; +var + tempReport: TfrxReport; + i: Integer; + l: TList; + c: TfrxComponent; + found, DeleteDuplicates: Boolean; + saveScript: String; + + procedure EnumObjects(ToParent, FromParent: TfrxComponent); + var + xs: TfrxXMLSerializer; + s: String; + i: Integer; + cFrom, cTo: TfrxComponent; + begin + xs := TfrxXMLSerializer.Create(nil); + { don't serialize ParentReport property! } + xs.SerializeDefaultValues := not (ToParent is TfrxReport); + s := xs.ObjToXML(FromParent); + xs.XMLToObj(s, ToParent); + xs.Free; + + for i := 0 to FromParent.Objects.Count - 1 do + begin + cFrom := FromParent.Objects[i]; + cTo := ToParent.Report.FindObject(cFrom.Name); + + if (cTo <> nil) and not (cTo is TfrxPage) then + begin + { skip duplicate object } + if DeleteDuplicates then continue; + { set empty name for duplicate object, rename later } + cFrom.Name := ''; + cTo := nil; + end; + + if cTo = nil then + begin + cTo := TfrxComponent(cFrom.NewInstance); + cTo.Create(ToParent); + cTo.Name := cFrom.Name; + end; + + EnumObjects(cTo, cFrom); + end; + end; + +begin + Result := True; + tempReport := TfrxReport.Create(nil); + tempReport.AssignAll(Self); + + { load the template } + ParentReport := ExtractRelativePath(GetApplicationFolder, templName); + + { find duplicate objects } + found := False; + l := tempReport.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if not (c is TfrxPage) and (FindObject(c.Name) <> nil) then + begin + found := True; + break; + end; + end; + + deleteDuplicates := False; + if found then + begin + with TfrxInheritErrorForm.Create(nil) do + begin + Result := ShowModal = mrOk; + if Result then + deleteDuplicates := DeleteRB.Checked; + Free; + end; + end; + + if Result then + begin + saveScript := ScriptText.Text; + EnumObjects(Self, tempReport); + ScriptText.Text := saveScript; + { create unique names for duplicates } + l := AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if not (c is TfrxPage) and (c.Name = '') then + c.CreateUniqueName; + end; + + end + else + AssignAll(tempReport); + + tempReport.Free; +end; + +procedure TfrxReport.SetPreviewOptions(const Value: TfrxPreviewOptions); +begin + FPreviewOptions.Assign(Value); +end; + +procedure TfrxReport.SetPrintOptions(const Value: TfrxPrintOptions); +begin + FPrintOptions.Assign(Value); +end; + +procedure TfrxReport.SetReportOptions(const Value: TfrxReportOptions); +begin + FReportOptions.Assign(Value); +end; + +procedure TfrxReport.SetStyles(const Value: TfrxStyles); +begin + if Value <> nil then + begin + FStyles.Assign(Value); + FStyles.Apply; + end + else + FStyles.Clear; +end; + +procedure TfrxReport.SetDataSet(const Value: TfrxDataSet); +begin + FDataSet := Value; + if FDataSet = nil then + FDataSetName := '' else + FDataSetName := FDataSet.UserName; +end; + +procedure TfrxReport.SetDataSetName(const Value: String); +begin + FDataSetName := Value; + FDataSet := frxFindDataSet(FDataSet, FDataSetName, Report); +end; + +function TfrxReport.GetDataSetName: String; +begin + if FDataSet = nil then + Result := FDataSetName else + Result := FDataSet.UserName; +end; + +function TfrxReport.Calc(const Expr: String; AScript: TfsScript = nil): Variant; +var + ErrorMsg: String; +begin + if AScript = nil then + AScript := FScript; + if not DoGetValue(Expr, Result) then + begin + Result := FExpressionCache.Calc(Expr, ErrorMsg, AScript); + if ErrorMsg <> '' then + begin + if FCurObject <> '' then + ErrorMsg := FCurObject + ': ' + ErrorMsg; + FErrors.Add(ErrorMsg); + raise Exception.Create(ErrorMsg); + end; + end; +end; + +function TfrxReport.GetAlias(DataSet: TfrxDataSet): String; +var + ds: TfrxDataSetItem; +begin + if DataSet = nil then + begin + Result := ''; + Exit; + end; + + ds := DataSets.Find(DataSet); + if ds <> nil then + Result := ds.DataSet.UserName else + Result := frxResources.Get('clDSNotIncl'); +end; + +function TfrxReport.GetDataset(const Alias: String): TfrxDataset; +var + ds: TfrxDataSetItem; +begin + ds := DataSets.Find(Alias); + if ds <> nil then + Result := ds.DataSet else + Result := nil; +end; + +procedure TfrxReport.GetDatasetAndField(const ComplexName: String; + var DataSet: TfrxDataSet; var Field: String); +var + i: Integer; + s: String; +begin + DataSet := nil; + Field := ''; + + { ComplexName has format: dataset name."field name" + Spaces are allowed in both parts of the complex name } + i := Pos('."', ComplexName); + if i <> 0 then + begin + s := Copy(ComplexName, 1, i - 1); { dataset name } + DataSet := GetDataSet(s); + Field := Copy(ComplexName, i + 2, Length(ComplexName) - i - 2); + end; +end; + +procedure TfrxReport.GetDataSetList(List: TStrings; OnlyDB: Boolean = False); +var + i: Integer; +begin + List.Clear; + for i := 0 to DataSets.Count - 1 do + if Datasets[i].DataSet <> nil then + if not OnlyDB or not (DataSets[i].DataSet is TfrxUserDataSet) then + List.AddObject(DataSets[i].DataSet.UserName, DataSets[i].DataSet); +end; + +procedure TfrxReport.DoLoadFromStream; +var + SaveLeftTop: Longint; + Loaded: Boolean; +begin + SaveLeftTop := DesignInfo; + Loaded := False; + + if Assigned(frxFR2Events.OnLoad) then + Loaded := frxFR2Events.OnLoad(Self, FLoadStream); + + if not Loaded then + inherited LoadFromStream(FLoadStream); + + DesignInfo := SaveLeftTop; +end; + +procedure TfrxReport.CheckDataPage; +var + i, x: Integer; + l: TList; + hasDataPage, hasDataObjects: Boolean; + p: TfrxDataPage; + c: TfrxComponent; +begin + { check if report has datapage and datacomponents } + hasDataPage := False; + hasDataObjects := False; + l := AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxDataPage then + hasDataPage := True; + if c is TfrxDialogComponent then + hasDataObjects := True; + end; + + if not hasDataPage then + begin + { create the datapage } + p := TfrxDataPage.Create(Self); + if FindObject('Data') = nil then + p.Name := 'Data' + else + p.CreateUniqueName; + + { make it the first page } + Objects.Delete(Objects.Count - 1); + Objects.Insert(0, p); + + { move existing datacomponents to this page } + if hasDataObjects then + begin + x := 60; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxDialogComponent then + begin + c.Parent := p; + c.Left := x; + c.Top := 20; + Inc(x, 64); + end; + end; + end; + end; +end; + +procedure TfrxReport.LoadFromStream(Stream: TStream); +var + Compressor: TfrxCustomCompressor; + Crypter: TfrxCustomCrypter; + SaveEngineOptions: TfrxEngineOptions; + SavePreviewOptions: TfrxPreviewOptions; + SaveConvertNulls: Boolean; + SaveDoublePass: Boolean; + SaveOutlineVisible, SaveOutlineExpand: Boolean; + SaveOutlineWidth, SavePagesInCache: Integer; + SaveIni: String; + SavePreview: TfrxCustomPreview; + SaveOldStyleProgress, SaveShowProgress, SaveStoreInDFM: Boolean; + Crypted: Boolean; + + function DecodePwd(const s: String): String; + var + i: Integer; + begin + Result := ''; + for i := 1 to Length(s) do + Result := Result + Chr(Ord(s[i]) + 10); + end; + +begin + FErrors.Clear; + + Compressor := nil; + if frxCompressorClass <> nil then + begin + Compressor := TfrxCustomCompressor(frxCompressorClass.NewInstance); + Compressor.Create(nil); + Compressor.Report := Self; + Compressor.IsFR3File := True; + try + Compressor.CreateStream; + if Compressor.Decompress(Stream) then + Stream := Compressor.Stream; + except + Compressor.Free; + FErrors.Add(frxResources.Get('clDecompressError')); + frxCommonErrorHandler(Self, frxResources.Get('clErrors') + #13#10 + FErrors.Text); + Exit; + end; + end; + + Crypter := nil; + Crypted := False; + if frxCrypterClass <> nil then + begin + Crypter := TfrxCustomCrypter(frxCrypterClass.NewInstance); + Crypter.Create(nil); + try + Crypter.CreateStream; + Crypted := Crypter.Decrypt(Stream, ReportOptions.Password); + if Crypted then + Stream := Crypter.Stream; + except + Crypter.Free; + FErrors.Add(frxResources.Get('clDecryptError')); + frxCommonErrorHandler(Self, frxResources.Get('clErrors') + #13#10 + FErrors.Text); + Exit; + end; + end; + + SaveEngineOptions := TfrxEngineOptions.Create; + SaveEngineOptions.Assign(FEngineOptions); + SavePreviewOptions := TfrxPreviewOptions.Create; + SavePreviewOptions.Assign(FPreviewOptions); + SaveIni := FIniFile; + SavePreview := FPreview; + SaveOldStyleProgress := FOldStyleProgress; + SaveShowProgress := FShowProgress; + SaveStoreInDFM := FStoreInDFM; + + try + FLoadStream := Stream; +{$IFNDEF FR_COM} +// if FEngineOptions.ReportThread <> nil then +// THackThread(FEngineOptions.ReportThread).Synchronize(DoLoadFromStream) else +{$ENDIF} + try + DoLoadFromStream; + except + on E: Exception do + begin + if (E is TfrxInvalidXMLException) and Crypted then + FErrors.Add('Invalid password') + else + FErrors.Add(E.Message) + end; + end; + finally + if Compressor <> nil then + Compressor.Free; + if Crypter <> nil then + Crypter.Free; + + CheckDataPage; + + SaveConvertNulls := FEngineOptions.ConvertNulls; + SaveDoublePass := FEngineOptions.DoublePass; + FEngineOptions.Assign(SaveEngineOptions); + FEngineOptions.ConvertNulls := SaveConvertNulls; + FEngineOptions.DoublePass := SaveDoublePass; + SaveEngineOptions.Free; + + SaveOutlineVisible := FPreviewOptions.OutlineVisible; + SaveOutlineWidth := FPreviewOptions.OutlineWidth; + SaveOutlineExpand := FPreviewOptions.OutlineExpand; + SavePagesInCache := FPreviewOptions.PagesInCache; + FPreviewOptions.Assign(SavePreviewOptions); + FPreviewOptions.OutlineVisible := SaveOutlineVisible; + FPreviewOptions.OutlineWidth := SaveOutlineWidth; + FPreviewOptions.OutlineExpand := SaveOutlineExpand; + FPreviewOptions.PagesInCache := SavePagesInCache; + SavePreviewOptions.Free; + + FIniFile := SaveIni; + FPreview := SavePreview; + FOldStyleProgress := SaveOldStyleProgress; + FShowProgress := SaveShowProgress; + FStoreInDFM := SaveStoreInDFM; + if not Crypted then + ReportOptions.Password := DecodePwd(ReportOptions.Password); + + if ReportOptions.Info or ((not FReloading) and +{$IFNDEF FR_COM} + (not FEngineOptions.EnableThreadSafe) and +{$ENDIF} + (not Crypted and not FReportOptions.CheckPassword)) then + + Clear + else if (FErrors.Count > 0) then + frxCommonErrorHandler(Self, frxResources.Get('clErrors') + #13#10 + FErrors.Text); + end; +end; + +procedure TfrxReport.SaveToStream(Stream: TStream; SaveChildren: Boolean = True; + SaveDefaultValues: Boolean = False); +var + Compressor: TfrxCustomCompressor; + Crypter: TfrxCustomCrypter; + StreamTo: TStream; + SavePwd: String; + SavePreview: TfrxCustomPreview; + + function EncodePwd(const s: String): String; + var + i: Integer; + begin + Result := ''; + for i := 1 to Length(s) do + Result := Result + Chr(Ord(s[i]) - 10); + end; + +begin + StreamTo := Stream; + + Compressor := nil; + if FReportOptions.Compressed and (frxCompressorClass <> nil) then + begin + Compressor := TfrxCustomCompressor(frxCompressorClass.NewInstance); + Compressor.Create(nil); + Compressor.Report := Self; + Compressor.IsFR3File := True; + Compressor.CreateStream; + StreamTo := Compressor.Stream; + end; + + Crypter := nil; + if (FReportOptions.Password <> '') and (frxCrypterClass <> nil) then + begin + Crypter := TfrxCustomCrypter(frxCrypterClass.NewInstance); + Crypter.Create(nil); + Crypter.CreateStream; + StreamTo := Crypter.Stream; + end; + + SavePwd := ReportOptions.Password; + ReportOptions.PrevPassword := SavePwd; + if Crypter = nil then + ReportOptions.Password := EncodePwd(SavePwd); + SavePreview := FPreview; + FPreview := nil; + + try + inherited SaveToStream(StreamTo, SaveChildren, SaveDefaultValues); + finally + FPreview := SavePreview; + ReportOptions.Password := SavePwd; + { crypt } + if Crypter <> nil then + begin + try + if Compressor <> nil then + Crypter.Crypt(Compressor.Stream, ReportOptions.Password) + else + Crypter.Crypt(Stream, ReportOptions.Password); + finally + Crypter.Free; + end; + end; + { compress } + if Compressor <> nil then + begin + try + Compressor.Compress(Stream); + finally + Compressor.Free; + end; + end; + end; +end; + +function TfrxReport.LoadFromFile(const FileName: String; + ExceptionIfNotFound: Boolean = False): Boolean; +var + f: TFileStream; +begin + Clear; + FFileName := ''; + Result := FileExists(FileName); + if Result or ExceptionIfNotFound then + begin + f := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); + try + LoadFromStream(f); + FFileName := FileName; + finally + f.Free; + end; + end; +end; + +procedure TfrxReport.SaveToFile(const FileName: String); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmCreate); + try + SaveToStream(f); + finally + f.Free; + end; +end; + +function TfrxReport.GetIniFile: TCustomIniFile; +begin + if Pos('\Software\', FIniFile) = 1 then + Result := TRegistryIniFile.Create(FIniFile) + else + Result := TIniFile.Create(FIniFile); +end; + +function TfrxReport.GetApplicationFolder: String; +begin + if csDesigning in ComponentState then + Result := GetCurrentDir + '\' + else + Result := ExtractFilePath(Application.ExeName); +end; + +procedure TfrxReport.SelectPrinter; +begin + if frxPrinters.IndexOf(FPrintOptions.Printer) <> -1 then + frxPrinters.PrinterIndex := frxPrinters.IndexOf(FPrintOptions.Printer); +end; + +procedure TfrxReport.DoNotifyEvent(Obj: TObject; const EventName: String; + RunAlways: Boolean = False); +begin +{$IFNDEF FR_VER_BASIC} + if FEngine.Running or RunAlways then + if EventName <> '' then + FScript.CallFunction(EventName, VarArrayOf([Integer(Obj)])); +{$ENDIF} +end; + +procedure TfrxReport.DoParamEvent(const EventName: String; var Params: Variant; + RunAlways: Boolean = False); +begin +{$IFNDEF FR_VER_BASIC} + if FEngine.Running or RunAlways then + if EventName <> '' then + FScript.CallFunction1(EventName, Params); +{$ENDIF} +end; + +procedure TfrxReport.DoBeforePrint(c: TfrxReportComponent); +begin + if Assigned(FOnBeforePrint) then + FOnBeforePrint(c); + DoNotifyEvent(c, c.OnBeforePrint); +end; + +procedure TfrxReport.DoAfterPrint(c: TfrxReportComponent); +begin + if Assigned(FOnAfterPrint) then + FOnAfterPrint(c); + DoNotifyEvent(c, c.OnAfterPrint); +end; + +procedure TfrxReport.DoPreviewClick(v: TfrxView; Button: TMouseButton; + Shift: TShiftState; var Modified: Boolean); +var + arr: Variant; +begin + arr := VarArrayOf([Integer(v), Button, ShiftToByte(Shift), Modified]); + DoParamEvent(v.OnPreviewClick, arr, True); + Modified := arr[3]; + if Assigned(FOnClickObject) then + FOnClickObject(v, Button, Shift, Modified); +end; + +procedure TfrxReport.DoGetAncestor(const Name: String; var Ancestor: TPersistent); +begin + if FParentReportObject <> nil then + begin + if Name = Self.Name then + Ancestor := FParentReportObject + else + Ancestor := FParentReportObject.FindObject(Name); + end; +end; + +function TfrxReport.DoGetValue(const Expr: String; var Value: Variant): Boolean; +var + i: Integer; + ds: TfrxDataSet; + fld: String; + val: Variant; + v: TfsCustomVariable; +begin + Result := False; + Value := Null; + + if Assigned(frxFR2Events.OnGetValue) then + begin + TVarData(val).VType := varEmpty; + frxFR2Events.OnGetValue(Expr, val); + if TVarData(val).VType <> varEmpty then + begin + Value := val; + Result := True; + Exit; + end; + end; + + { maybe it's a dataset/field? } + GetDataSetAndField(Expr, ds, fld); + if (ds <> nil) and (fld <> '') then + begin + Value := ds.Value[fld]; + if FEngineOptions.ConvertNulls and (Value = Null) then + case ds.FieldType[fld] of + fftNumeric: + Value := 0; + fftString: + Value := ''; + fftBoolean: + Value := False; + end; + Result := True; + Exit; + end; + + { searching in the sys variables } + i := FSysVariables.IndexOf(Expr); + if i <> -1 then + begin + case i of + 0: Value := FEngine.StartDate; { Date } + 1: Value := FEngine.StartTime; { Time } + 2: Value := FPreviewPages.GetLogicalPageNo; { Page } + 3: Value := FPreviewPages.CurPage + 1; { Page# } + 4: Value := FPreviewPages.GetLogicalTotalPages; { TotalPages } + 5: Value := FEngine.TotalPages; { TotalPages# } + 6: Value := FEngine.CurLine; { Line } + 7: Value := FEngine.CurLineThrough; { Line# } + 8: Value := frxGlobalVariables['CopyName0']; + end; + Result := True; + Exit; + end; + + { value supplied by OnGetValue event } + TVarData(val).VType := varEmpty; + if Assigned(FOnGetValue) then + FOnGetValue(Expr, val); + if TVarData(val).VType <> varEmpty then + begin + Value := val; + Result := True; + Exit; + end; + + { searching in the variables } + i := FVariables.IndexOf(Expr); + if i <> -1 then + begin + val := FVariables.Items[i].Value; + if (TVarData(val).VType = varString) or (TVarData(val).VType = varOleStr) then + begin + if Pos(#13#10, val) <> 0 then + Value := val + else + Value := Calc(val); + end + else + Value := val; + Result := True; + Exit; + end; + + { searching in the global variables } + i := frxGlobalVariables.IndexOf(Expr); + if i <> -1 then + begin + Value := frxGlobalVariables.Items[i].Value; + Result := True; + Exit; + end; + + if not Assigned(frxFR2Events.OnGetScriptValue) then + begin + { searching in the script } + v := FScript.FindLocal(Expr); + if v <> nil then + begin + Value := v.Value; + Result := True; + Exit; + end; + end; +end; + +function TfrxReport.GetScriptValue(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant; +var + i: Integer; + s: String; +begin + if not DoGetValue(Params[0], Result) then + begin + { checking aggregate functions } + s := VarToStr(Params[0]); + i := Pos('(', s); + if i <> 0 then + begin + s := UpperCase(Trim(Copy(s, 1, i - 1))); + if (s = 'SUM') or (s = 'MIN') or (s = 'MAX') or + (s = 'AVG') or (s = 'COUNT') then + begin + Result := Calc(Params[0]); + Exit; + end; + end; + + if Assigned(frxFR2Events.OnGetScriptValue) then + Result := frxFR2Events.OnGetScriptValue(Params) + else + FErrors.Add(frxResources.Get('clUnknownVar') + ' ' + VarToStr(Params[0])); + end; +end; + +function TfrxReport.SetScriptValue(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant; +begin + FVariables[Params[0]] := Params[1]; +end; + +function TfrxReport.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant; +var + p1, p2, p3: Variant; +begin + if MethodName = 'IIF' then + begin + p1 := Params[0]; + p2 := Params[1]; + p3 := Params[2]; + if Calc(p1, FScript.ProgRunning) = True then + Result := Calc(p2, FScript.ProgRunning) else + Result := Calc(p3, FScript.ProgRunning); + end + else if (MethodName = 'SUM') or (MethodName = 'AVG') or + (MethodName = 'MIN') or (MethodName = 'MAX') then + begin + p2 := Params[1]; + if Trim(VarToStr(p2)) = '' then + p2 := 0 + else + p2 := Calc(p2, FScript.ProgRunning); + p3 := Params[2]; + if Trim(VarToStr(p3)) = '' then + p3 := 0 + else + p3 := Calc(p3, FScript.ProgRunning); + Result := FEngine.GetAggregateValue(MethodName, Params[0], + TfrxBand(Integer(p2)), p3); + end + else if MethodName = 'COUNT' then + begin + p1 := Params[0]; + if Trim(VarToStr(p1)) = '' then + p1 := 0 + else + p1 := Calc(p1, FScript.ProgRunning); + p2 := Params[1]; + if Trim(VarToStr(p2)) = '' then + p2 := 0 + else + p2 := Calc(p2, FScript.ProgRunning); + Result := FEngine.GetAggregateValue(MethodName, '', + TfrxBand(Integer(p1)), p2); + end +end; + +function TfrxReport.DoUserFunction(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant; +begin + if Assigned(FOnUserFunction) then + Result := FOnUserFunction(MethodName, Params); +end; + +function TfrxReport.PrepareScript: Boolean; +var + i: Integer; + l: TList; + c: TfrxComponent; +begin + FExpressionCache.Clear; + FExpressionCache.FScriptLanguage := FScriptLanguage; + FEngine.NotifyList.Clear; + + FScript.ClearItems(Self); + FScript.AddedBy := Self; + FScript.MainProg := True; + + try + l := AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + c.IsDesigning := False; + c.BeforeStartReport; + if c is TfrxPictureView then + TfrxPictureView(c).FPictureChanged := True; + FScript.AddObject(c.Name, c); + end; + + FScript.AddObject('Report', Self); + FScript.AddObject('Engine', FEngine); + FScript.AddObject('Outline', FPreviewPages.Outline); + FScript.AddVariable('Value', 'Variant', Null); + FScript.AddMethod('function Get(Name: String): Variant', GetScriptValue); + FScript.AddMethod('procedure Set(Name: String; Value: Variant)', SetScriptValue); + FScript.AddMethod('macrofunction IIF(Expr: Boolean; TrueValue, FalseValue: Variant): Variant', + CallMethod); + FScript.AddMethod('macrofunction SUM(Expr: Variant; Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod); + FScript.AddMethod('macrofunction AVG(Expr: Variant; Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod); + FScript.AddMethod('macrofunction MIN(Expr: Variant; Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod); + FScript.AddMethod('macrofunction MAX(Expr: Variant; Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod); + FScript.AddMethod('macrofunction COUNT(Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod); + + if Assigned(frxFR2Events.OnPrepareScript) then + frxFR2Events.OnPrepareScript(Self); + FLocalValue := FScript.Find('Value'); + FScript.Lines := FScriptText; + FScript.SyntaxType := FScriptLanguage; + + {$IFNDEF FR_VER_BASIC} + Result := FScript.Compile; + if not Result then + FErrors.Add(Format(frxResources.Get('clScrError'), + [FScript.ErrorPos, FScript.ErrorMsg])); + {$ELSE} + Result := True; + {$ENDIF} + finally + FScript.AddedBy := nil; + end; +end; + +{$IFDEF FR_COM} +procedure TfrxReport.EventSinkChanged(const Sink: IUnknown; Connecting: Boolean); +begin + if Connecting + then FEvent := Sink as IfrxReportEvents + else + FEvent := nil; +end; + +function TfrxReport.PrepareReport(ClearLastReport: WordBool = True): HResult; stdcall; +var + TempStream: TStream; + ErrorsText: String; + ErrorMessage: String; + +begin + + if ClearLastReport then PreviewPages.Clear; + + FErrors.Clear; + FTerminated := False; +// FFinished := False; + Result := E_FAIL; + + if FEngineOptions.DestroyForms then + begin + TempStream := TMemoryStream.Create; + SaveToStream(TempStream); + end + else TempStream := nil; + + try + if Assigned(FOnBeginDoc) then FOnBeginDoc(Self); + + if PrepareScript then + begin + if FScript.Statement.Count > 0 then FScript.Execute; + if FEngine.Run then + begin + if Assigned(FOnEndDoc) then FOnEndDoc(Self); + Result := S_OK; + end + else if FPreviewForm <> nil then FPreviewForm.Close; + end; + + except + on e: Exception do FErrors.Add(e.Message); + end; + + if TempStream <> nil then + begin + ErrorsText := FErrors.Text; + TempStream.Position := 0; + FReloading := True; + try + LoadFromStream(TempStream); + finally + FReloading := False; + end; + TempStream.Free; + FErrors.Text := ErrorsText; + end; + + if FErrors.Text <> '' then + begin + Result := E_FAIL; + ErrorMessage := frxResources.Get('clErrors') + #13#10 + FErrors.Text; + frxCommonErrorHandler(Self, ErrorMessage); + end; + +end; + +{$ELSE} // FR_COM + +function TfrxReport.PrepareReport(ClearLastReport: Boolean = True): Boolean; +var + TempStream: TStream; + ErrorsText: String; + ErrorMessage: String; + SavePwd: String; + + function CheckDatasets: Boolean; + var + i: Integer; + begin + for i := 0 to FDataSets.Count - 1 do + if FDatasets[i].DataSet = nil then + FErrors.Add(Format(frxResources.Get('clDSNotExist'), [''])); + Result := FErrors.Count = 0; + end; + +begin + if ClearLastReport then + PreviewPages.Clear; + FErrors.Clear; + FTerminated := False; + Result := False; + + if CheckDatasets then + begin + TempStream := nil; + SavePwd := ReportOptions.Password; + + { save the report state } + if FEngineOptions.DestroyForms then + begin + TempStream := TMemoryStream.Create; + ReportOptions.Password := ''; + SaveToStream(TempStream); + end; + + try + if Assigned(FOnBeginDoc) then + FOnBeginDoc(Self); + if PrepareScript then + begin +{$IFNDEF FR_VER_BASIC} + if FScript.Statement.Count > 0 then + FScript.Execute; +{$ENDIF} + if FEngine.Run then + begin + if Assigned(FOnEndDoc) then + FOnEndDoc(Self); + Result := True + end + else if FPreviewForm <> nil then + FPreviewForm.Close; + end; + except + on e: Exception do + FErrors.Add(e.Message); + end; + + if FEngineOptions.DestroyForms then + begin + ErrorsText := FErrors.Text; + TempStream.Position := 0; + FReloading := True; + try +// if FEngineOptions.ReportThread = nil then + LoadFromStream(TempStream); + finally + FReloading := False; + ReportOptions.Password := SavePwd; + end; + TempStream.Free; + FErrors.Text := ErrorsText; + end; + end; + + if FErrors.Text <> '' then + begin + Result := False; + ErrorMessage := frxResources.Get('clErrors') + #13#10 + FErrors.Text; + frxCommonErrorHandler(Self, ErrorMessage); + end; +end; + +{$ENDIF} // FR_COM + +{$IFDEF FR_COM} +function TfrxReport.ShowPreparedReport: HResult; stdcall; +{$ELSE} +procedure TfrxReport.ShowPreparedReport; +{$ENDIF} +begin + FPreviewForm := nil; + if FPreview <> nil then + begin + FPreview.FReport := Self; + FPreview.FPreviewPages := FPreviewPages; + FPreview.Init; + end + else + begin + FPreviewForm := TfrxPreviewForm.Create(Application); + with TfrxPreviewForm(FPreviewForm) do + begin + Preview.FReport := Self; + Preview.FPreviewPages := FPreviewPages; + FPreview := Preview; + Init; + if Assigned(FOnPreview) then + FOnPreview(Self); + if PreviewOptions.Maximized then + Position := poDesigned; + if FPreviewOptions.Modal then + begin + ShowModal; + Free; + end + else + begin + FreeOnClose := True; + Show; + end; + end; + end; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxReport.ShowReport: HResult; stdcall; +const ClearLastReport: Boolean = True; +{$ELSE} +procedure TfrxReport.ShowReport(ClearLastReport: Boolean = True); +{$ENDIF} +begin + if ClearLastReport then + PreviewPages.Clear; + + if FOldStyleProgress then + begin +{$IFNDEF FR_COM} + if PrepareReport(False) then + ShowPreparedReport; +{$ELSE} + Result := PrepareReport(False); + if Result = S_OK then + Result := ShowPreparedReport; +{$ENDIF} + end + else + begin + FTimer.Enabled := True; +{$IFNDEF FR_COM} + ShowPreparedReport; +{$ELSE} + Result := ShowPreparedReport; +{$ENDIF} + end; +end; + +procedure TfrxReport.OnTimer(Sender: TObject); +begin + FTimer.Enabled := False; + PrepareReport(False); +end; + +{$HINTS OFF} + +{$UNDEF FR_RUN_DESIGNER} + +{$IFDEF FR_LITE} + {$DEFINE FR_RUN_DESIGNER} +{$ENDIF} + +{$IFNDEF FR_VER_BASIC} + {$DEFINE FR_RUN_DESIGNER} +{$ENDIF} + +{$IFDEF FR_COM} +function TfrxReport.DesignReport: HResult; stdcall; +{$IFDEF ACTIVATION} +const + CLASS_E_NOTLICENSED = HRESULT($80040112); +var + UserKey : PChar = nil; + UserName : PChar = nil; + + ModeName : PChar = nil; + ModeStatus : TModeStatus; + + TrialDaysTotal : Longword = Longword(-1); + TrialDaysLeft : Longword = Longword(-1); +{$ENDIF} +begin +{$IFDEF ACTIVATION} + {$I include\aspr_crypt_begin1.inc} + GetRegistrationInformation( 0, UserKey, UserName ); + if (UserKey <> nil) AND (StrLen(UserKey) > 0) then + begin + Result := DesignReportEx( True, False, Application.Handle ); + end + else + If GetTrialDays( 0, TrialDaysTotal, TrialDaysLeft ) then + begin + If TrialDaysLeft = 0 then + Result := CLASS_E_NOTLICENSED + else + Result := DesignReportEx( True, False, Application.Handle ); + end; + {$I include\aspr_crypt_end1.inc} +{$ELSE} + Result := DesignReportEx( True, False, Application.Handle ); +{$ENDIF} +end; + +function TfrxReport.DesignReportEx(Modal: WordBool; MDIChild: WordBool; ParentWindowHandle: Integer): HResult; stdcall; +{$ELSE} +procedure TfrxReport.DesignReport(Modal: Boolean = True; MDIChild: Boolean = False); +{$ENDIF} +var + l: TList; + i: Integer; + c: TfrxComponent; +begin +{$IFDEF FR_COM} + Result := S_OK; + Application.Handle := HWND(ParentWindowHandle); +{$ENDIF} +{$IFDEF FR_RUN_DESIGNER} + if FDesigner <> nil then Exit; + if frxDesignerClass <> nil then + begin + FScript.ClearItems(Self); + l := AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxCustomDBDataset then + c.BeforeStartReport; + end; + + FModified := False; + FDesigner := TfrxCustomDesigner(frxDesignerClass.NewInstance); + FDesigner.CreateDesigner(nil, Self); + if MDIChild then + FDesigner.FormStyle := fsMDIChild; + PostMessage(FDesigner.Handle, WM_USER + 1, 0, 0); + if Modal then + begin + FDesigner.ShowModal; + FDesigner.Free; + Application.ProcessMessages; + FDesigner := nil; + end + else + FDesigner.Show; + end + {$IFNDEF FR_COM} + ; + {$ELSE} + else Result := E_NOINTERFACE; + {$ENDIF} +{$ENDIF} +end; +{$HINTS ON} + +procedure TfrxReport.DesignReportInPanel(Panel: TWinControl); +{$IFDEF FR_RUN_DESIGNER} +var + l: TList; + i: Integer; + c: TfrxComponent; + ct: TControl; +{$ENDIF} +begin +{$IFDEF FR_RUN_DESIGNER} + if FDesigner <> nil then Exit; + if frxDesignerClass <> nil then + begin + FScript.ClearItems(Self); + l := AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxCustomDBDataset then + c.BeforeStartReport; + end; + + FModified := False; + FDesigner := TfrxCustomDesigner(frxDesignerClass.NewInstance); + FDesigner.CreateDesigner(nil, Self); + PostMessage(FDesigner.Handle, WM_USER + 1, 0, 0); + FDesigner.OnShow(FDesigner); + + while FDesigner.ControlCount > 0 do + begin + ct := FDesigner.Controls[0]; + ct.Parent := Panel; + end; + end; +{$ENDIF} +end; + + +procedure TfrxReport.DesignReport(IDesigner: IUnknown; Editor: TObject); +var + l: TList; + i: Integer; + c: TfrxComponent; +begin + if FDesigner <> nil then + begin + FDesigner.Activate; + Exit; + end; + if (IDesigner = nil) or (Editor.ClassName <> 'TfrxReportEditor') then Exit; + + l := AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxCustomDBDataset then + c.BeforeStartReport; + end; + + FDesigner := TfrxCustomDesigner(frxDesignerClass.NewInstance); + FDesigner.CreateDesigner(nil, Self); + FDesigner.ShowModal; +end; + +{$HINTS OFF} +function TfrxReport.DesignPreviewPage: Boolean; +begin + Result := False; +{$IFNDEF FR_VER_BASIC} + if FDesigner <> nil then Exit; + if frxDesignerClass <> nil then + begin + FDesigner := TfrxCustomDesigner(frxDesignerClass.NewInstance); + FDesigner.CreateDesigner(nil, Self, True); + FDesigner.ShowModal; + Result := FModified; + end; +{$ENDIF} +end; +{$HINTS ON} + +function TfrxReport.Export(Filter: TfrxCustomExportFilter): Boolean; +begin + Result := FPreviewPages.Export(Filter); +end; + +function TfrxReport.Print: Boolean; +begin + Result := FPreviewPages.Print; +end; + +{$IFDEF FR_COM} +function TfrxReport.AddFunction( + const FuncName: WideString; + const Category: WideString; + const Description: WideString): HResult; stdcall; +{$ELSE} +procedure TfrxReport.AddFunction(const FuncName: String; + const Category: String = ''; const Description: String = ''); +{$ENDIF} +begin + FScript.AddedBy := nil; + FScript.AddMethod(FuncName, DoUserFunction, Category, Description); +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +function TfrxReport.GetLocalValue: Variant; +begin + Result := FLocalValue.Value; +end; + +procedure TfrxReport.SetLocalValue(const Value: Variant); +begin + FLocalValue.Value := Value; +end; + +procedure TfrxReport.SetTerminated(const Value: Boolean); +begin + FTerminated := Value; + if Value then + FScript.Terminate; +end; + +procedure TfrxReport.SetPreview(const Value: TfrxCustomPreview); +begin + if (FPreview <> nil) and (Value = nil) then + begin + FPreview.FReport := nil; + FPreview.FPreviewPages := nil; + FPreviewForm := nil; + end; + + FPreview := Value; + + if FPreview <> nil then + begin + FPreview.FReport := Self; + FPreview.FPreviewPages := FPreviewPages; + FPreview.Init; + end; +end; + +procedure TfrxReport.InternalOnProgressStart(ProgressType: TfrxProgressType); +begin +{$IFNDEF FR_COM} + if (FEngineOptions.EnableThreadSafe) then Exit; //(FEngineOptions.ReportThread <> nil) or +{$ENDIF} + + if Assigned(FOnProgressStart) then + FOnProgressStart(Self, ProgressType, 0); + + if OldStyleProgress or (ProgressType <> ptRunning) then + begin + if FShowProgress then + begin + if FProgress <> nil then + FProgress.Free; + FProgress := TfrxProgress.Create(nil); + FProgress.Execute(0, '', True, False); + end; + end; + + if (FPreview <> nil) and (ProgressType = ptRunning) then + FPreview.InternalOnProgressStart(Self, ProgressType, 0); + Application.ProcessMessages; +end; + +procedure TfrxReport.InternalOnProgress(ProgressType: TfrxProgressType; + Progress: Integer); +begin +{$IFNDEF FR_COM} + if FEngineOptions.EnableThreadSafe then Exit; +// if FEngineOptions.ReportThread <> nil then Exit; +{$ENDIF} + + if Assigned(FOnProgress) then + FOnProgress(Self, ProgressType, Progress); + + if OldStyleProgress or (ProgressType <> ptRunning) then + begin + if FShowProgress then + begin + case ProgressType of + ptRunning: + if not Engine.FinalPass then + FProgress.Message := Format(frxResources.Get('prRunningFirst'), [Progress]) + else + FProgress.Message := Format(frxResources.Get('prRunning'), [Progress]); + ptPrinting: + FProgress.Message := Format(frxResources.Get('prPrinting'), [Progress]); + ptExporting: + FProgress.Message := Format(frxResources.Get('prExporting'), [Progress]); + end; + if FProgress.Terminated then + Terminated := True; + end; + end; + + if (FPreview <> nil) and (ProgressType = ptRunning) then + FPreview.InternalOnProgress(Self, ProgressType, Progress - 1); + Application.ProcessMessages; +end; + +procedure TfrxReport.InternalOnProgressStop(ProgressType: TfrxProgressType); +begin +{$IFNDEF FR_COM} + if FEngineOptions.EnableThreadSafe then Exit; +// if FEngineOptions.ReportThread <> nil then Exit; +{$ENDIF} + + if Assigned(FOnProgressStop) then + FOnProgressStop(Self, ProgressType, 0); + + if OldStyleProgress or (ProgressType <> ptRunning) then + begin + if FShowProgress then + begin + FProgress.Free; + FProgress := nil; + end; + end; + + if (FPreview <> nil) and (ProgressType = ptRunning) then + FPreview.InternalOnProgressStop(Self, ProgressType, 0); + Application.ProcessMessages; +end; + +procedure TfrxReport.SetProgressMessage(const Value: String); +begin +{$IFNDEF FR_COM} + if FEngineOptions.EnableThreadSafe then Exit; +// if FEngineOptions.ReportThread <> nil then Exit; +{$ENDIF} + + if OldStyleProgress and Engine.Running then + begin + if FShowProgress then + FProgress.Message := Value + end; + + if FPreviewForm <> nil then + TfrxPreviewForm(FPreviewForm).SetMessageText(Value); + Application.ProcessMessages; +end; + +procedure TfrxReport.SetVersion(const Value: String); +begin + FVersion := FR_VERSION; +end; + +{$IFDEF FR_COM} +procedure TfrxReport.OnSetConnectionHandler(const ConnString: String); +begin + frxDefaultConnection.Connected := False; + frxDefaultConnection.ConnectionString := ConnString; +end; + +function TfrxReport.OnEditConnectionHandler(const ConnString: String): String; +begin + Result := PromptDataSource(0, ConnString); +end; + +procedure TfrxReport.OnAfterPrintHandler(Sender: TfrxReportComponent); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; + Obj: IfrxComponent; +begin + if FEvent <> nil then + begin + if FUseDispatchableEvents = True then + begin + Obj := DispatchableComponentFactory.CreateComObject(Sender) as IfrxComponent; + FEvent.OnAfterPrint(Obj); + Obj._Release; + end + else + FEvent.OnAfterPrint(Sender) + end + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnAfterPrint(Sender); + ConnectData.pUnk := nil; + end; + end; +end; + +procedure TfrxReport.OnBeforePrintHandler(Sender: TfrxReportComponent); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; + Obj: IfrxComponent; +begin + if FEvent <> nil then + begin + if FUseDispatchableEvents = True then + begin + Obj := DispatchableComponentFactory.CreateComObject(Sender) as IfrxComponent; + FEvent.OnBeforePrint(Obj); + Obj._Release; + end + else + FEvent.OnBeforePrint(Sender); + end + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnBeforePrint(Sender); + ConnectData.pUnk := nil; + end; + end; +end; + +procedure TfrxReport.OnClickObjectHandler(Sender: TfrxView; Button: TMouseButton; Shift: TShiftState; var Modified: Boolean); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; + Obj: IfrxView; +begin + if FEvent <> nil then + begin + if FUseDispatchableEvents = True then + begin + Obj := DispatchableComponentFactory.CreateComObject(Sender) as IfrxView; + FEvent.OnClickObject( Obj, Integer(Button)); + Obj._Release; + end + else + FEvent.OnClickObject(Sender as IfrxView, Integer(Button)) + end + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnClickObject(Sender as IfrxView, Integer(Button)); + ConnectData.pUnk := nil; + end; + end; +end; + +function TfrxReport.OnUserFunctionHandler(const MethodName: String; var Params: Variant): Variant; +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; + ResultValue : OleVariant; +begin + if FEvent <> nil then + begin + FEvent.OnUserFunction(MethodName, Params, ResultValue); + Result := ResultValue; + end + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnUserFunction(MethodName, Params, ResultValue); + Result := ResultValue; + ConnectData.pUnk := nil; + end; + end; +end; + +procedure TfrxReport.OnBeginDocHandler(Sender: TObject); +var + Component: IfrxComponent; + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +// Obj: IfrxComponent; +begin + try + Sender.GetInterface(IfrxComponent, Component); + if FEvent <> nil then + begin +{ + if FUseDispatchableEvents = True then + begin + Obj := DispatchableComponentFactory.CreateComObject(Component) as IfrxComponent; + FEvent.OnBeginDoc(Obj); + Obj._Release; + end + else +} + FEvent.OnBeginDoc( Component ) + end + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnBeginDoc(Component); + ConnectData.pUnk := nil; + end; + end; + finally + Component := nil; + end; +end; + +procedure TfrxReport.OnBeforeConnectHandler(Sender: TfrxCustomDatabase; var Connected: Boolean); +var + Database: IfrxADODatabase; + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + try + Sender.GetInterface( IfrxADODatabase, Database ); + if FEvent <> nil then + FEvent.OnBeforeConnect( Database, Connected ) + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnBeforeConnect( Database, Connected ); + ConnectData.pUnk := nil; + end; + end; + finally + Database := nil; + end; +end; + +procedure TfrxReport.OnEndDocHandler(Sender: TObject); +var + Component: IfrxComponent; + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + try + Sender.GetInterface(IfrxComponent, Component); + if FEvent <> nil then + FEvent.OnEndDoc( Component ) + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnEndDoc(Component); + ConnectData.pUnk := nil; + end; + end; + finally + Component := nil; + end; +end; + +procedure TfrxReport.OnPrintReportHandler(Sender: TObject); +var + Component: IfrxComponent; + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + try + Sender.GetInterface(IfrxComponent, Component); + if FEvent <> nil then + FEvent.OnEndDoc( Component ) + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnPrintReport(Component); + ConnectData.pUnk := nil; + end; + end; + finally + Component := nil; + end; +end; + +procedure TfrxReport.OnAfterPrintReportHandler(Sender: TObject); +var + Component: IfrxComponent; + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + try + Sender.GetInterface(IfrxComponent, Component); + if FEvent <> nil then + FEvent.OnAfterPrintReport( Component ) + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnAfterPrintReport(Component); + ConnectData.pUnk := nil; + end; + end; + finally + Component := nil; + end; +end; + +procedure TfrxReport.OnProgressHandler(Sender: TfrxReport; ProgressType: TfrxProgressType; Progress: Integer); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + try + if FEvent <> nil then + FEvent.OnProgress( Sender, Integer(ProgressType), Progress ) + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnProgress(Sender, Integer(ProgressType), Progress); + ConnectData.pUnk := nil; + end; + end + except + end; +end; + +procedure TfrxReport.OnProgressStartHandler(Sender: TfrxReport; ProgressType: TfrxProgressType; Progress: Integer); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + try + if FEvent <> nil then + FEvent.OnProgressStart( ) + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnProgressStart(); + ConnectData.pUnk := nil; + end; + end + except + end; +end; + +procedure TfrxReport.OnProgressStopHandler(Sender: TfrxReport; ProgressType: TfrxProgressType; Progress: Integer); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + try + if FEvent <> nil then + FEvent.OnProgressStop( ) + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnProgressStop(); + ConnectData.pUnk := nil; + end; + end; + except end; +end; + +procedure TfrxReport.OnRunDialogsEvent(Page: TfrxDialogPage); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + try + if FEvent <> nil then + FEvent.OnRunDialogs( Page ) + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxReportEventDispatcher).OnRunDialogs(Page); + ConnectData.pUnk := nil; + end; + end; + except + end; +end; + +function TfrxReport.LoadReportFromFile(const szFileName: WideString): HResult; +begin + Result := S_OK; + try + if LoadFromFile(szFileName, False) <> True then + Result := E_INVALIDARG; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.SaveReportToFile(const FileName: WideString): HResult; +begin + try + SaveToFile(FileName); + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.LoadReportFromStream(const Stream: IUnknown): HResult; +var + ComStream: IStream; + OleStream: TOleStream; + + NetStream: _Stream; + ClrStream: TClrStream; +begin + try + Result := Stream.QueryInterface(IStream, ComStream); + if Result = S_OK then + begin + OleStream := TOleStream.Create(ComStream); + LoadFromStream(OleStream); + OleStream.Free; + ComStream := nil; + end + else + begin + Result := Stream.QueryInterface(_Stream, NetStream); + if Result = S_OK then + begin + ClrStream := TClrStream.Create(NetStream); + LoadFromStream(ClrStream); + ClrStream.Free; + NetStream._Release(); + end; + end; + except + Result := E_FAIL; + end; + // Result value now depends on errors count + if (FErrors.Count > 0) then Result := CONVERT10_E_OLESTREAM_FMT; + +end; + +function TfrxReport.SaveReportToStream(const Stream: IUnknown): HResult; +var + ComStream: IStream; + OleStream: TOleStream; + + NetStream: _Stream; + ClrStream: TClrStream; +begin + try + Result := Stream.QueryInterface(IStream, ComStream); + if Result = S_OK then + begin + OleStream := TOleStream.Create(ComStream); + SaveToStream(OleStream, True, False); + OleStream.Free; + ComStream := nil; + end + else + begin + Result := Stream.QueryInterface(_Stream, NetStream); + if Result = S_OK then + begin + ClrStream := TClrStream.Create(NetStream); + SaveToStream(ClrStream, True, False); + ClrStream.Free; + NetStream._Release(); + end; + end; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.LoadPreparedReportFromFile(const szFileName: WideString): HResult; +begin + try + Result := S_OK; + if PreviewPages.LoadFromFile( szFileName ) <> True then Result := E_FAIL; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.SavePreparedReportToFile(const szFileName: WideString): HResult; +begin + try + PreviewPages.SaveToFile( szFileName ); + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.SavePreparedReportToStream(const Stream: IUnknown): HResult; +var + S: IStream; + OleStream: TOleStream; + + NetStream: _Stream; + ClrStream: TClrStream; +begin + try + Result := Stream.QueryInterface(IStream, S); + if Result = S_OK then + begin + OleStream := TOleStream.Create(S); + PreviewPages.SaveToStream(OleStream); + OleStream.Free; + S._Release(); + end + else + begin + Result := Stream.QueryInterface(_Stream, NetStream); + if Result = S_OK then + begin + ClrStream := TClrStream.Create(NetStream); + PreviewPages.SaveToStream(ClrStream); + ClrStream.Free; + NetStream._Release(); + end; + end; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.ClearReport: HResult; +begin + try + Clear; + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.PrintReport: HResult; +var + printers: TfrxPrinters; +begin + try + printers := frxPrinters; + if printers.HasPhysicalPrinters then + begin + Print; + Result := S_OK; + end else begin + Errors.Add('There is no printer on system'); + Result := E_FAIL; + end; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.ExportReport(const Filter: IfrxCustomExportFilter): HResult; +begin + Result := E_NOTIMPL; +end; + +function TfrxReport.Get_Errors(out Value: WideString): HResult; +begin + try + if Errors <> nil then + Value := Errors.GetText + else + Value := ''; + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.Get_EngineOptions(out Value: IfrxEngineOptions): HResult; +begin + Value := EngineOptions as IfrxEngineOptions; + Result := S_OK; +end; + +function TfrxReport.Get_Script(out Value: IfsScript): HResult; stdcall; +begin + Value := Script as IfsScript; + Result := S_OK; +end; + +function TfrxReport.Get_Print(out Value: WordBool): HResult; stdcall; +begin + Value := Print; + Result := S_OK; +end; + +function TfrxReport.Set_UseDispatchableEvents(Value: WordBool): HResult; stdcall; +begin + FUseDispatchableEvents := Value; + Result := S_OK; +end; + +function TfrxReport.Get_FileName(out Value: WideString): HResult; stdcall; +begin + Value := FileName; + Result := S_OK; +end; + +function TfrxReport.Set_FileName(const Value: WideString): HResult; stdcall; +begin + FileName := Value; + Result := S_OK; +end; + +function TfrxReport.Set_Terminated(Value: WordBool): HResult; stdcall; +begin + Terminated := True; + Result := S_OK; +end; + +function TfrxReport.Get_PreviewPages(out Value: IfrxCustomPreviewPages): HResult; stdcall; +begin + Value := PreviewPages as IfrxCustomPreviewPages; + Value._AddRef; + Result := S_OK; +end; + +function TfrxReport.Get_ReportOptions(out Value: IfrxReportOptions): HResult; +begin + Value := ReportOptions as IfrxReportOptions; + Result := S_OK; +end; + +function TfrxReport.Get_PreviewOptions(out Value: IfrxPreviewOptions): HResult; +begin + Value := PreviewOptions as IfrxPreviewOptions; + Result := S_OK; +end; + +function TfrxReport.Get_PrintOptions( out Value: IfrxPrintOptions): HResult; +begin + Value := PrintOptions as IfrxPrintOptions; + Result := S_OK; +end; + +function TfrxReport.Get_ScriptLanguage(out Value: WideString): HResult; +begin + try + Value:= ScriptLanguage; + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.Set_ScriptLanguage(const Value: WideString): HResult; +begin + try + ScriptLanguage := Value; + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.Get_ScriptText(out Value: WideString): HResult; +begin + try + Value := ScriptText.GetText; + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.Set_ScriptText(const Value: WideString): HResult; +begin + try + ScriptText.SetText(PAnsiChar(String(Value))); + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.Get_DisableDialogs(out Value: WordBool): HResult; stdcall; +begin + if Assigned(Engine.OnRunDialog) then Value := True else Value := False; + Result := S_OK; +end; + +function TfrxReport.Set_DisableDialogs(Value: WordBool): HResult; stdcall; +begin + if Value = True then + Engine.OnRunDialog := nil + else + Engine.OnRunDialog := OnRunDialogsEvent; + Result := S_OK; +end; + +function TfrxReport.SetVariable(const Index: WideString; Value: OleVariant): HResult; stdcall; +begin + try + Variables[Index] := Variant(Value); + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.GetVariable(const Index: WideString; out Value: OleVariant): HResult; stdcall; +var + TempVal: Variant; +begin + try + DoGetValue(Index, TempVal); + Value := TempVal; + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.AddVariable(const Category: WideString; const Name: WideString; Value: OleVariant): HResult; stdcall; +var + i: Integer; + v: TfrxVariable; +begin + try + i := Variables.IndexOf(' ' + Category); + if i = -1 then + begin + v := Variables.Add(); + v.Name := ' ' + Category; + end; + Variables.AddVariable(Category, Name, Value); + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.DeleteCategory(const Name: WideString): HResult; stdcall; +begin + try + Variables.DeleteCategory(Name); + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.DeleteVariable(const Name: WideString): HResult; stdcall; +begin + try + Variables.DeleteVariable(Name); + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.SelectDataset(Selected: WordBool; + const DataSet: IfrxDataSet): HResult; +var +// idsp: IfrxComponentSelf; + ds: TfrxDataSet; + UserName: WideString; + i: Integer; + dsList: TStringList; +begin + try + dsList := TStringList.Create; + frxGetDataSetList(dsList); + UserName := (DataSet as IInterfaceComponentReference).GetComponent.Name; + + for i := 0 to dsList.Count - 1 do + begin + ds := TfrxDataSet(dsList.Objects[i]); + if ds.UserName = UserName then + begin + if Selected then Datasets.Add(ds) else Datasets.Delete(UserName); + end; + end; + dsList.Free; + + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.BindObject(const Value: IfrxPlugin): HResult; stdcall; +var + PluginType: frxPluginType; + ds: TfrxNetDataTable; +begin + try + Result := Value.Get_PluginType(PluginType); + if Result = S_OK then case PluginType of + ptDataSet: + begin + ds := TfrxNetDataTable.Create( nil ); + Result := ds.SetRemoteObject( Value ); + end + else + // put your plugin implementation here + Result := E_NOINTERFACE; + end; + + except + Result := E_NOINTERFACE; + end; +end; + +function TfrxReport.Set_ShowProgress(Value: WordBool): HResult; stdcall; +begin + try + ShowProgress := Value; + Result := S_OK; + except + Result := E_FAIL; + end +end; + +function TfrxReport.CreateReportObject( + const ParentObject: IfrxComponent; + ObjectType: TGUID; + const Name: WideString; + out GeneratedObject: IfrxComponent): HResult; stdcall; +var + Obj: TfrxComponent; + ParentObj: TfrxComponent; + idsp: IInterfaceComponentReference; + i: Integer; + TempStr: WideString; +begin + try + obj := nil; + Result := ParentObject.QueryInterface( IInterfaceComponentReference, idsp); + if Result = S_OK then + begin + ParentObj := TfrxComponent( idsp.GetComponent ); + if IsEqualGUID(ObjectType, IfrxReportPage) then obj := TfrxReportPage.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxReportTitle) then obj := TfrxReportTitle.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxMemoView) then obj := TfrxMemoView.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxReportSummary) then obj := TfrxReportSummary.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxDataBand) then obj := TfrxMasterData.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxPictureView) then obj := TfrxPictureView.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxShapeView) then obj := TfrxShapeView.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxSubreport) then obj := TfrxSubreport.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxHeader) then obj := TfrxHeader.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxFooter) then obj := TfrxFooter.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxMasterData) then obj := TfrxMasterData.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxDetailData) then obj := TfrxDetailData.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxSubdetailData) then obj := TfrxSubdetailData.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxDataBand4) then obj := TfrxDataBand4.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxDataBand5) then obj := TfrxDataBand5.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxDataBand6) then obj := TfrxDataBand6.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxPageHeader) then obj := TfrxPageHeader.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxPageFooter) then obj := TfrxPageFooter.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxColumnHeader) then obj := TfrxColumnHeader.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxColumnFooter) then obj := TfrxColumnFooter.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxGroupHeader) then obj := TfrxGroupHeader.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxGroupFooter) then obj := TfrxGroupFooter.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxChild) then obj := TfrxChild.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxOverlay) then obj := TfrxOverlay.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxCrossView) then obj := TfrxCrossView.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxDBCrossView) then obj := TfrxDBCrossView.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxRichView) then obj := TfrxRichView.Create(ParentObj) + + else if IsEqualGUID(ObjectType, IfrxADODatabase) then obj := TfrxADODatabase.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxADOTable) then obj := TfrxADOTable.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxADOQuery) then obj := TfrxADOQuery.Create(ParentObj) + + else if IsEqualGUID(ObjectType, IfrxDMPPage) then obj := TfrxDMPPage.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxDMPCommand) then obj := TfrxDMPCommand.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxDMPMemoView) then obj := TfrxDMPMemoView.Create(ParentObj) + else if IsEqualGUID(ObjectType, IfrxDMPLineView) then obj := TfrxDMPLineView.Create(ParentObj) + +{$IFNDEF FR_LITE} + else if IsEqualGUID(ObjectType, IfrxChartView) then obj := TfrxChartView.Create(ParentObj) +{$ENDIF} + else Result := E_INVALIDARG; + end; + + if Result = S_OK then + begin + TempStr := Name; + for i := 0 to length(Name) - 1 do + if Name[i] = ' ' then TempStr[i] := '_'; + obj.Name := String(TempStr); + GeneratedObject := obj as IfrxComponent; + end; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.CreateReportObjectEx( + const ParentObject: IfrxComponent; + const ObjectType: WideString; + const Name: WideString; + out GeneratedObject: IfrxComponent): HResult; stdcall; +begin + try + if ObjectType = 'TfrxPage' then + Result := CreateReportObject(ParentObject, IfrxReportPage, Name, GeneratedObject ) + else if ObjectType = 'TfrxMemoView' then + Result := CreateReportObject(ParentObject, IfrxMemoView, Name, GeneratedObject ) + else if ObjectType = 'TfrxReportTitle' then + Result := CreateReportObject(ParentObject, IfrxReportTitle, Name, GeneratedObject ) + else if ObjectType = 'TfrxReportSummary' then + Result := CreateReportObject(ParentObject, IfrxReportSummary, Name, GeneratedObject ) + else if ObjectType = 'TfrxDataBand' then + Result := CreateReportObject(ParentObject, IfrxDataBand, Name, GeneratedObject ) + else if ObjectType = 'TfrxPictureView' then + Result := CreateReportObject(ParentObject, IfrxPictureView, Name, GeneratedObject ) + else if ObjectType = 'TfrxShapeView' then + Result := CreateReportObject(ParentObject, IfrxShapeView, Name, GeneratedObject ) + else if ObjectType = 'TfrxChartView' then + Result := CreateReportObject(ParentObject, IfrxChartView, Name, GeneratedObject ) + else if ObjectType = 'TfrxSubreport' then + Result := CreateReportObject(ParentObject, IfrxSubreport, Name, GeneratedObject ) + else if ObjectType = 'TfrxHeader' then + Result := CreateReportObject(ParentObject, IfrxHeader, Name, GeneratedObject ) + else if ObjectType = 'TfrxFooter' then + Result := CreateReportObject(ParentObject, IfrxFooter, Name, GeneratedObject ) + else if ObjectType = 'TfrxMasterData' then + Result := CreateReportObject(ParentObject, IfrxMasterData, Name, GeneratedObject ) + else if ObjectType = 'TfrxDetailData' then + Result := CreateReportObject(ParentObject, IfrxDetailData, Name, GeneratedObject ) + else if ObjectType = 'TfrxSubdetailData' then + Result := CreateReportObject(ParentObject, IfrxSubdetailData, Name, GeneratedObject ) + else if ObjectType = 'TfrxDataBand4' then + Result := CreateReportObject(ParentObject, IfrxDataBand4, Name, GeneratedObject ) + else if ObjectType = 'TfrxDataBand5' then + Result := CreateReportObject(ParentObject, IfrxDataBand5, Name, GeneratedObject ) + else if ObjectType = 'TfrxDataBand6' then + Result := CreateReportObject(ParentObject, IfrxDataBand6, Name, GeneratedObject ) + else if ObjectType = 'TfrxPageHeader' then + Result := CreateReportObject(ParentObject, IfrxPageHeader, Name, GeneratedObject ) + else if ObjectType = 'TfrxPageFooter' then + Result := CreateReportObject(ParentObject, IfrxPageFooter, Name, GeneratedObject ) + else if ObjectType = 'TfrxColumnHeader' then + Result := CreateReportObject(ParentObject, IfrxColumnHeader, Name, GeneratedObject ) + else if ObjectType = 'TfrxColumnFooter' then + Result := CreateReportObject(ParentObject, IfrxColumnFooter, Name, GeneratedObject ) + else if ObjectType = 'TfrxGroupHeader' then + Result := CreateReportObject(ParentObject, IfrxGroupHeader, Name, GeneratedObject ) + else if ObjectType = 'TfrxGroupFooter' then + Result := CreateReportObject(ParentObject, IfrxGroupFooter, Name, GeneratedObject ) + else if ObjectType = 'TfrxChild' then + Result := CreateReportObject(ParentObject, IfrxChild, Name, GeneratedObject ) + else if ObjectType = 'TfrxOverlay' then + Result := CreateReportObject(ParentObject, IfrxOverlay, Name, GeneratedObject ) + else if ObjectType = 'TfrxCrossView' then + Result := CreateReportObject(ParentObject, IfrxCrossView, Name, GeneratedObject ) + else if ObjectType = 'TfrxDBCrossView' then + Result := CreateReportObject(ParentObject, IfrxDBCrossView, Name, GeneratedObject ) + else if ObjectType = 'TfrxRichView' then + Result := CreateReportObject(ParentObject, IfrxRichView, Name, GeneratedObject ) +{ Modified February, 2, 2007 } + else if ObjectType = 'TfrxADODatabase' then + Result := CreateReportObject(ParentObject, IfrxADODatabase, Name, GeneratedObject ) + else if ObjectType = 'TfrxADOTable' then + Result := CreateReportObject(ParentObject, IfrxADOTable, Name, GeneratedObject ) + else if ObjectType = 'TfrxADOQuery' then + Result := CreateReportObject(ParentObject, IfrxADOQuery, Name, GeneratedObject ) +{ Added October, 05, 2006 } + else if ObjectType = 'TfrxDMPPage' then + Result := CreateReportObject(ParentObject, IfrxDMPPage, Name, GeneratedObject ) + else if ObjectType = 'TfrxDMPCommand' then + Result := CreateReportObject(ParentObject, IfrxDMPCommand, Name, GeneratedObject ) + else if ObjectType = 'TfrxDMPMemoView' then + Result := CreateReportObject(ParentObject, IfrxDMPMemoView, Name, GeneratedObject ) + else if ObjectType = 'TfrxDMPLineView' then + Result := CreateReportObject(ParentObject, IfrxDMPLineView, Name, GeneratedObject ) +{} + else + Result := E_INVALIDARG; + + if Result = S_OK then + begin + GeneratedObject := DispatchableComponentFactory.CreateComObject(GeneratedObject) as IfrxComponent; + end + + except + Result := E_FAIL; + end; +end; + +function TfrxReport.FindCOMObject(const ObjectName: WideString; out Obj: IfrxComponent): HResult; stdcall; +begin + try + Result := (Self as IfrxComponent).FindObject(ObjectName, obj); + except + Result := E_FAIL; + end +end; + +function TfrxReport.FindObjectEx(const ObjectName: WideString; out Obj: IfrxComponent): HResult; stdcall; +begin + try + Result := (Self as IfrxComponent).FindObject(ObjectName, obj); + obj := DispatchableComponentFactory.CreateComObject(obj) as IfrxComponent; + except + Result := E_FAIL; + end +end; + +function TfrxReport.ClearDatasets: HResult; stdcall; +begin + Datasets.Clear; + DatasetList.Destroy; + DatasetList := TfrxGlobalDataSetList.Create; + Result := S_OK; +end; + +function TfrxReport.LoadLanguageResourcesFromFile(const FileName: WideString): HResult; stdcall; +begin + Application.MessageBox( + PChar('Deprecated Method. Use LoadLanguageResourcesFromFile method of IfrxResources interface.'), + 'Beta version message'); + Result := E_NOTIMPL; +end; + +function TfrxReport.GetResourceString(const ID: WideString; out ResourceString_: WideString): HResult; stdcall; +begin + Application.MessageBox( + PChar('Deprecated Method. Use LoadLanguageResourcesFromFile method of IfrxResources interface.'), + 'Beta version message'); + Result := E_NOTIMPL; +end; + +function TfrxReport.Set_MainWindowHandle(Value: Integer): HResult; stdcall; +begin + Application.Handle := HWND(Value); + Result := S_OK; +end; + +function TfrxReport.Get_Resources(out Value: IfrxResources): HResult; stdcall; +begin + Value := frxResources; + Result := S_OK; +end; + +function TfrxReport.Get_Version(out Value: WideString): HResult; stdcall; +begin + Value := Version; + Result := S_OK; +end; + +function TfrxReport.Get_Page(Index: Integer; out Value: IfrxPage): HResult; stdcall; +begin + Value := Pages[Index]; + Result := S_OK; +end; + +function TfrxReport.Get_PagesCount(out Value: Integer): HResult; stdcall; +begin + Value := PagesCount; + Result := S_OK; +end; + + +function TfrxReport.ExportToPDF(const FileName: WideString; Compressed, EmbeddedFonts, PrintOptimized: WordBool): HResult; +{$IFNDEF FR_LITE} +var + Export2PDF: TfrxPDFExport; +begin + try + Export2PDF := TfrxPDFExport.Create(nil); + Export2PDF.FileName := String(FileName); + Export2PDF.ShowDialog := False; + Export2PDF.Compressed := Compressed; + Export2PDF.EmbeddedFonts := EmbeddedFonts; + Export2PDF.PrintOptimized := PrintOptimized; + Export2PDF.ShowProgress := ShowProgress; + Export(Export2PDF); + Export2PDF.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToBMP(const FileName: WideString; + Resolution: SYSINT; Monochrome, CropPages, SeparatePages: WordBool): HResult; +{$IFNDEF FR_LITE} +var + Export2BMP: TfrxBMPExport; +begin + try + Export2BMP := TfrxBMPExport.Create(nil); + Export2BMP.FileName := String(FileName); + Export2BMP.ShowDialog := False; + Export2BMP.Resolution := Resolution; + Export2BMP.Monochrome := Monochrome; + Export2BMP.CropImages := CropPages; + Export2BMP.SeparateFiles := SeparatePages; + Export2BMP.ShowProgress := ShowProgress; + Export(Export2BMP); + Export2BMP.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToHTML(const FileName: WideString; Pictures, + FixedWidth, Multipage, Navigator, PicsInSameFolder, + Background: WordBool): HResult; +{$IFNDEF FR_LITE} +var + Export2HTML: TfrxHTMLExport; +begin + try + Export2HTML := TfrxHTMLExport.Create(nil); + Export2HTML.FileName := String(FileName); + Export2HTML.ShowDialog := False; + Export2HTML.ExportPictures := Pictures; + Export2HTML.FixedWidth := FixedWidth; + Export2HTML.Multipage := Multipage; + Export2HTML.Navigator := Navigator; + Export2HTML.PicsInSameFolder := PicsInSameFolder; + Export2HTML.Background := Background; + Export2HTML.ShowProgress := ShowProgress; + Export(Export2HTML); + Export2HTML.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToRTF(const FileName: WideString; Pictures, PageBreaks, WYSIWYG: WordBool): HResult; +{$IFNDEF FR_LITE} +var + Export2RTF: TfrxRTFExport; +begin + try + Export2RTF := TfrxRTFExport.Create(nil); + Export2RTF.FileName := String(FileName); + Export2RTF.ShowDialog := False; + Export2RTF.ExportPictures := Pictures; + Export2RTF.ExportPageBreaks := PageBreaks; + Export2RTF.Wysiwyg := WYSIWYG; + Export2RTF.ShowProgress := ShowProgress; + Export(Export2RTF); + Export2RTF.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToTXT( + const FileName: WideString; + PageBreaks: WordBool; + Frames: WordBool; + OEMCodepage: WordBool; + EmptyLines: WordBool): HResult; stdcall; +var + Export2TXT: TfrxSimpleTextExport; +begin + try + Export2TXT := TfrxSimpleTextExport.Create(nil); + Export2TXT.FileName := String(FileName); + Export2TXT.ShowDialog := False; + Export2TXT.ShowProgress := ShowProgress; + Export2TXT.PageBreaks := PageBreaks; + Export2TXT.Frames := Frames; + Export2TXT.OEMCodepage := OEMCodepage; + Export2TXT.EmptyLines := EmptyLines; + Export(Export2TXT); + Export2TXT.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.ExportToXLS(const szFileName: WideString; Pictures, + PageBreaks, WYSIWYG, AsText, Background: WordBool): HResult; +{$IFNDEF FR_LITE} +var + Export2XLS: TfrxXLSExport; +begin + try + Export2XLS := TfrxXLSExport.Create(nil); + Export2XLS.FileName := String(szFileName); + Export2XLS.ShowDialog := False; + Export2XLS.ExportPictures := Pictures; + Export2XLS.PageBreaks := PageBreaks; + Export2XLS.Wysiwyg := WYSIWYG; + Export2XLS.AsText := AsText; + Export2XLS.Background := Background; + Export2XLS.ShowProgress := ShowProgress; + Export(Export2XLS); + Export2XLS.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToXML(const FileName: WideString; Styles, PageBreaks, WYSIWYG, Background: WordBool): HResult; +{$IFNDEF FR_LITE} +var + Export2XML: TfrxXMLExport; +begin + try + Export2XML := TfrxXMLExport.Create(nil); + Export2XML.FileName := String(FileName); + Export2XML.ShowDialog := False; + Export2XML.ExportStyles := Styles; + Export2XML.ExportPageBreaks := PageBreaks; + Export2XML.Wysiwyg := WYSIWYG; + Export2XML.Background := Background; + Export2XML.ShowProgress := ShowProgress; + Export(Export2XML); + Export2XML.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToJPEG(const FileName: WideString; Resolution, JpegQuality: SYSINT; Monochrome, CropPages, + SeparatePages: WordBool): HResult; +{$IFNDEF FR_LITE} +var + Export2JPEG: TfrxJPEGExport; +begin + try + Export2JPEG := TfrxJPEGExport.Create(nil); + Export2JPEG.FileName := String(FileName); + Export2JPEG.ShowDialog := False; + Export2JPEG.Resolution := Resolution; + Export2JPEG.JPEGQuality := JpegQuality; + Export2JPEG.Monochrome := Monochrome; + Export2JPEG.CropImages := CropPages; + Export2JPEG.SeparateFiles := SeparatePages; + Export2JPEG.ShowProgress := ShowProgress; + Export(Export2JPEG); + Export2JPEG.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToTIFF(const FileName: WideString; + Resolution: SYSINT; Monochrome, CropPages, + SeparatePages: WordBool): HResult; +{$IFNDEF FR_LITE} +var + Export2TIFF: TfrxTIFFExport; +begin + try + Export2TIFF := TfrxTIFFExport.Create(nil); + Export2TIFF.FileName := FileName; + Export2TIFF.ShowDialog := False; + Export2TIFF.Resolution := Resolution; + Export2TIFF.Monochrome := Monochrome; + Export2TIFF.CropImages := CropPages; + Export2TIFF.SeparateFiles := SeparatePages; + Export2TIFF.ShowProgress := ShowProgress; + Export(Export2TIFF); + Export2TIFF.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToGIF(const FileName: WideString; Resolution: SYSINT; + Monochrome, CropPages, SeparatePages: WordBool): HResult; stdcall; +{$IFNDEF FR_LITE} +var + Export2GIF: TfrxGIFExport; +begin + try + Export2GIF := TfrxGIFExport.Create(nil); + Export2GIF.FileName := FileName; + Export2GIF.ShowDialog := False; + Export2GIF.Resolution := Resolution; + Export2GIF.Monochrome := Monochrome; + Export2GIF.CropImages := CropPages; + Export2GIF.SeparateFiles := SeparatePages; + Export2GIF.ShowProgress := ShowProgress; + Export(Export2GIF); + Export2GIF.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToCSV(const FileName: WideString; + const Separator: WideString; OEMCodepage: WordBool): HResult; stdcall; +var + Export2CSV: TfrxCSVExport; +begin + try + Export2CSV := TfrxCSVExport.Create(nil); + Export2CSV.FileName := FileName; + Export2CSV.Separator := Separator; + Export2CSV.OEMCodepage := OEMCodepage; + Export2CSV.ShowProgress := ShowProgress; + Export(Export2CSV); + Export2CSV.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; + +function TfrxReport.SendMail(const Server: WideString; Port: SYSINT; const User: WideString; + const Password: WideString; const From: WideString; const To_: WideString; + const Subject: WideString; const Text: WideString; + const FileName: WideString; const AttachName: WideString): HResult; stdcall; +{$IFNDEF FR_LITE} +begin + Export2Mail.ShowProgress := ShowProgress; + Export2Mail.Mail(Server, Port, User, Password, From, To_, Subject, Text, FileName, AttachName); + Result := S_OK; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.ExportToDMP(const FileName: WideString): HResult; stdcall; +{$IFNDEF FR_LITE} +var + Export2DMP: TfrxDotMatrixExport; +begin + try + Export2DMP := TfrxDotMatrixExport.Create(nil); + Export2DMP.FileName := FileName; + Export2DMP.ShowDialog := False; + Export2DMP.SaveToFile := True; + Export(Export2DMP); + Export2DMP.Destroy; + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ELSE} +begin + Result := E_NOTIMPL; +end; +{$ENDIF} + +function TfrxReport.Get_OldStyleProgress(out Value: WordBool): HResult; stdcall; +begin + Value := OldStyleProgress; + Result := S_OK; +end; + +function TfrxReport.Set_OldStyleProgress(Value: WordBool): HResult; stdcall; +begin + OldStyleProgress := Value; + Result := S_OK; +end; + +function TfrxReport.Get_Engine(out Value: IfrxCustomEngine): HResult; stdcall; +begin + Value := Engine; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxCustomDesigner } + +constructor TfrxCustomDesigner.CreateDesigner(AOwner: TComponent; + AReport: TfrxReport; APreviewDesigner: Boolean); +begin + inherited Create(AOwner); + FReport := AReport; + FIsPreviewDesigner := APreviewDesigner; + FObjects := TList.Create; + FSelectedObjects := TList.Create; +end; + +destructor TfrxCustomDesigner.Destroy; +begin + FObjects.Free; + FSelectedObjects.Free; + inherited; +end; + +procedure TfrxCustomDesigner.SetModified(const Value: Boolean); +begin + FModified := Value; + if Value then + FReport.Modified := True; +end; + +procedure TfrxCustomDesigner.SetPage(const Value: TfrxPage); +begin + FPage := Value; +end; + + +{ TfrxCustomEngine } + +constructor TfrxCustomEngine.Create(AReport: TfrxReport); +begin + FReport := AReport; + FNotifyList := TList.Create; +{$IFDEF FR_COM} + inherited Create(IfrxCustomEngine); +{$ENDIF} +end; + +destructor TfrxCustomEngine.Destroy; +begin + FNotifyList.Free; + inherited; +end; + +function TfrxCustomEngine.GetDoublePass: Boolean; +begin + Result := FReport.EngineOptions.DoublePass; +end; + +procedure TfrxCustomEngine.ShowBandByName(const BandName: String); +begin + ShowBand(TfrxBand(Report.FindObject(BandName))); +end; + +procedure TfrxCustomEngine.StopReport; +begin + Report.Terminated := True; +end; + +{$IFDEF FR_COM} +function TfrxCustomEngine.Get_CurColumn(out Value: Integer): HResult; stdcall; +begin + Value := CurColumn; + Result := S_OK; +end; + +function TfrxCustomEngine.Set_CurColumn(Value: Integer): HResult; stdcall; +begin + CurColumn := Value; + Result := S_OK; +end; + +function TfrxCustomEngine.Get_CurVColumn(out Value: Integer): HResult; stdcall; +begin + Value := CurVColumn; + Result := S_OK; +end; + +function TfrxCustomEngine.Set_CurVColumn(Value: Integer): HResult; stdcall; +begin + CurVColumn := Value; + Result := S_OK; +end; + +function TfrxCustomEngine.Get_CurX(out Value: Double): HResult; stdcall; +begin + Value := CurX; + Result := S_OK; +end; + +function TfrxCustomEngine.Set_CurX(Value: Double): HResult; stdcall; +begin + CurX := Value; + Result := S_OK; +end; + +function TfrxCustomEngine.Get_CurY(out Value: Double): HResult; stdcall; +begin + Value := CurY; + Result := S_OK; +end; + +function TfrxCustomEngine.Set_CurY(Value: Double): HResult; stdcall; +begin + CurY := Value; + Result := S_OK; +end; + +function TfrxCustomEngine.Get_DoublePass(out Value: WordBool): HResult; stdcall; +begin + Value := DoublePass; + Result := S_OK; +end; + +function TfrxCustomEngine.Get_FinalPass(out Value: WordBool): HResult; stdcall; +begin + Value := FinalPass; + Result := S_OK; +end; + +function TfrxCustomEngine.Set_FinalPass(Value: WordBool): HResult; stdcall; +begin + FinalPass := Value; + Result := S_OK; +end; + +function TfrxCustomEngine.Get_PageHeight(out Value: Double): HResult; stdcall; +begin + Value := PageHeight; + Result := S_OK; +end; + +function TfrxCustomEngine.Set_PageHeight(Value: Double): HResult; stdcall; +begin + PageHeight := Value; + Result := S_OK; +end; + +function TfrxCustomEngine.Get_PageWidth(out Value: Double): HResult; stdcall; +begin + Value := PageWidth; + Result := S_OK; +end; + +function TfrxCustomEngine.Set_PageWidth(Value: Double): HResult; stdcall; +begin + PageWIdth := Value; + Result := S_OK; +end; + +function TfrxCustomEngine.Get_StartDate(out Value: TDateTime): HResult; stdcall; +begin + Value := StartDate; + Result := S_OK; +end; + +function TfrxCustomEngine.Set_StartDate(Value: TDateTime): HResult; stdcall; +begin + StartDate := Value; + Result := S_OK; +end; + +function TfrxCustomEngine.Get_TotalPages(out Value: Integer): HResult; stdcall; +begin + Value := TotalPages; + Result := S_OK; +end; + +function TfrxCustomEngine.Set_TotalPages(Value: Integer): HResult; stdcall; +begin + TotalPages := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxCustomOutline } + +constructor TfrxCustomOutline.Create(APreviewPages: TfrxCustomPreviewPages); +begin + FPreviewPages := APreviewPages; +end; + +function TfrxCustomOutline.Engine: TfrxCustomEngine; +begin + Result := FPreviewPages.Engine; +end; + +{ TfrxCustomPreviewPages } + +constructor TfrxCustomPreviewPages.Create(AReport: TfrxReport); +begin + FReport := AReport; + FOutline := TfrxOutline.Create(Self); +end; + +destructor TfrxCustomPreviewPages.Destroy; +begin + FOutline.Free; + inherited; +end; + +{$IFDEF FR_COM} +function TfrxCustomPreviewPages.IfrxCustomPreviewPages_AddObject(const Value: IfrxComponent): HResult; stdcall; +var + idsp: {IfrxComponentSelf} IInterfaceComponentReference; +begin + try + Result := Value.QueryInterface( {IfrxComponentSelf} IInterfaceComponentReference, idsp); + if Result = S_OK then AddObject( TfrxComponent(idsp.GetComponent) {Get_Object} ); + except + Result := E_FAIL; + end; +end; + +function TfrxCustomPreviewPages.IfrxCustomPreviewPages_AddPage(const Value: IfrxReportPage): HResult; stdcall; +var + idsp: {IfrxComponentSelf} IInterfaceComponentReference; +begin + try + Result := Value.QueryInterface( {IfrxComponentSelf} IInterfaceComponentReference, idsp); + if Result = S_OK then AddPage( TfrxReportPage(idsp.GetComponent {Get_Object}) ); + except + Result := E_FAIL; + end; +end; + +function TfrxCustomPreviewPages.IfrxCustomPreviewPages_AddEmptyPage(Index: Integer): HResult; stdcall; +begin + AddEmptyPage(Index); + Result := S_OK; +end; + +function TfrxCustomPreviewPages.IfrxCustomPreviewPages_DeletePage(Index: Integer): HResult; stdcall; +begin + DeletePage(Index); + Result := S_OK; +end; + +function TfrxCustomPreviewPages.Get_Count(out Value: Integer): HResult; stdcall; +begin + Value := Count; + Result := S_OK; +end; + +function TfrxCustomPreviewPages.Get_CurrentPage(out Value: Integer): HResult; stdcall; +begin + Value := CurPage; + Result := S_OK; +end; + +function TfrxCustomPreviewPages.Set_CurrentPage(Value: Integer): HResult; stdcall; +begin + CurPage := Value; + Result := S_OK; +end; + +function TfrxCustomPreviewPages.Get_CurPreviewPage(out Value: Integer): HResult; stdcall; +begin + Value := CurPreviewPage; + Result := S_OK; +end; + +function TfrxCustomPreviewPages.Set_CurPreviewPage(Value: Integer): HResult; stdcall; +begin + CurPreviewPage := Value; + Result := S_OK; +end; + +function TfrxCustomPreviewPages.IfrxCustomPreviewPages_Page(Index: Integer; out Value: IfrxReportPage): HResult; stdcall; +begin + Value := Page[Index] as IfrxReportPage; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxExpressionCache } + +constructor TfrxExpressionCache.Create(AScript: TfsScript); +begin + FExpressions := TStringList.Create; + FExpressions.Sorted := True; + FScript := TfsScript.Create(nil); + FScript.ExtendedCharset := True; + FMainScript := AScript; +end; + +destructor TfrxExpressionCache.Destroy; +begin + FExpressions.Free; + FScript.Free; + inherited; +end; + +procedure TfrxExpressionCache.Clear; +begin + FExpressions.Clear; + FScript.Clear; +end; + +function TfrxExpressionCache.Calc(const Expression: String; + var ErrorMsg: String; AScript: TfsScript): Variant; +var + i: Integer; + v: TfsProcVariable; +begin + ErrorMsg := ''; + FScript.Parent := AScript; + i := FExpressions.IndexOf(Expression); + if i = -1 then + begin + i := FExpressions.Count; + FScript.SyntaxType := FScriptLanguage; + if CompareText(FScriptLanguage, 'PascalScript') = 0 then + FScript.Lines.Text := 'function fr3f' + IntToStr(i) + ': Variant; begin ' + + 'Result := ' + Expression + ' end; begin end.' + else if CompareText(FScriptLanguage, 'C++Script') = 0 then + FScript.Lines.Text := 'Variant fr3f' + IntToStr(i) + '() { ' + + 'return ' + Expression + '; } {}' + else if CompareText(FScriptLanguage, 'BasicScript') = 0 then + FScript.Lines.Text := 'function fr3f' + IntToStr(i) + #13#10 + + 'return ' + Expression + #13#10 + 'end function' + else if CompareText(FScriptLanguage, 'JScript') = 0 then + FScript.Lines.Text := 'function fr3f' + IntToStr(i) + '() { ' + + 'return ' + Expression + '; }'; + + if FScript.Compile then + v := TfsProcVariable(FScript.Find('fr3f' + IntToStr(i))) + else + begin + ErrorMsg := frxResources.Get('clExprError') + ' ''' + Expression + ''': ' + + FScript.ErrorMsg; + Result := Null; + Exit; + end; + + FExpressions.AddObject(Expression, v); + end + else + v := TfsProcVariable(FExpressions.Objects[i]); + + FMainScript.MainProg := False; + try + try + Result := v.Value; + except + on e: Exception do + ErrorMsg := e.Message; + end; + finally + FMainScript.MainProg := True; + end; +end; + + +{ TfrxCustomExportFilter } + +constructor TfrxCustomExportFilter.Create(AOwner: TComponent); +begin + inherited; + if not FNoRegister then + frxExportFilters.Register(Self); + FShowDialog := True; + FUseFileCache := True; + FDefaultPath := ''; + FShowProgress := True; + FSlaveExport := False; +end; + +constructor TfrxCustomExportFilter.CreateNoRegister; +begin + FNoRegister := True; + Create(nil); +end; + +destructor TfrxCustomExportFilter.Destroy; +begin + if not FNoRegister then + frxExportFilters.Unregister(Self); + inherited; +end; + +class function TfrxCustomExportFilter.GetDescription: String; +begin + Result := ''; +end; + +procedure TfrxCustomExportFilter.Finish; +begin +// +end; + +procedure TfrxCustomExportFilter.FinishPage(Page: TfrxReportPage; + Index: Integer); +begin +// +end; + +function TfrxCustomExportFilter.ShowModal: TModalResult; +begin + Result := mrOk; +end; + +function TfrxCustomExportFilter.Start: Boolean; +begin + Result := True; +end; + +procedure TfrxCustomExportFilter.StartPage(Page: TfrxReportPage; + Index: Integer); +begin +// +end; + + +{ TfrxCustomWizard } + +constructor TfrxCustomWizard.Create(AOwner: TComponent); +begin + inherited; + FDesigner := TfrxCustomDesigner(AOwner); + FReport := FDesigner.Report; +end; + +class function TfrxCustomWizard.GetDescription: String; +begin + Result := ''; +end; + + +{ TfrxCustomCompressor } + +constructor TfrxCustomCompressor.Create(AOwner: TComponent); +begin + inherited; + FOldCompressor := frxCompressorClass; + frxCompressorClass := TfrxCompressorClass(ClassType); +end; + +destructor TfrxCustomCompressor.Destroy; +begin + frxCompressorClass := FOldCompressor; + if FStream <> nil then + FStream.Free; + if FTempFile <> '' then + SysUtils.DeleteFile(FTempFile); + inherited; +end; + +procedure TfrxCustomCompressor.CreateStream; +begin + if FIsFR3File or not FReport.EngineOptions.UseFileCache then + FStream := TMemoryStream.Create + else + begin + FTempFile := frxCreateTempFile(FReport.EngineOptions.TempDir); + FStream := TFileStream.Create(FTempFile, fmCreate); + end; +end; + +{$IFDEF FR_COM} +function TfrxCustomCompressor.CompressStream( + const InputStream: IUnknown; + const OutputStream: IUnknown; + Compression_: Integer; + const FileName: WideString): HResult; stdcall; +var + ComStream: IStream; + OleInputStream: TOleStream; + OleOutputStream: TOleStream; + + NetStream: _Stream; + ClrInputStream: TClrStream; + ClrOutputStream: TClrStream; + + +begin + try + Result := InputStream.QueryInterface(IStream, ComStream); + if Result = S_OK then + begin + OleInputStream := TOleStream.Create(ComStream); + OleOutputStream := TOleStream.Create(OutputStream as IStream); + frxCompressStream(OleInputStream, OleOutputStream, gzMax, FileName); + OleInputStream.Free; + OleOutputStream.Free; + ComStream := nil; + end + else + begin + Result := InputStream.QueryInterface(_Stream, NetStream); + if Result = S_OK then + begin + ClrInputStream := TClrStream.Create(NetStream); + ClrOutputStream := TClrStream.Create(OutputStream as _Stream); + frxCompressStream(ClrInputStream, ClrOutputStream, gzMax, FileName); + ClrInputStream.Free; + ClrOutputStream.Free; + NetStream._Release(); + end; + end; + except + Result := E_FAIL; + end; + if FStream <> nil then + FStream.Free; + if FTempFile <> '' then + SysUtils.DeleteFile(FTempFile); +end; + +function TfrxCustomCompressor.DecompressStream(const Stream: IUnknown): HResult; stdcall; +var + ComStream: IStream; + OleStream: TOleStream; + + NetStream: _Stream; + ClrStream: TClrStream; +begin + try + Result := Stream.QueryInterface(IStream, ComStream); + if Result = S_OK then + begin + OleStream := TOleStream.Create(ComStream); + Decompress(OleStream); + OleStream.Free; + ComStream := nil; + end + else + begin + Result := Stream.QueryInterface(_Stream, NetStream); + if Result = S_OK then + begin + ClrStream := TClrStream.Create(NetStream); + Decompress(ClrStream); + ClrStream.Free; + NetStream._Release(); + end; + end; + except + Result := E_FAIL; + end; +end; +{$ENDIF} + + +{ TfrxCustomCrypter } + +constructor TfrxCustomCrypter.Create(AOwner: TComponent); +begin + inherited; + frxCrypterClass := TfrxCrypterClass(ClassType); +end; + +destructor TfrxCustomCrypter.Destroy; +begin + if FStream <> nil then + FStream.Free; + inherited; +end; + +procedure TfrxCustomCrypter.CreateStream; +begin + FStream := TMemoryStream.Create; +end; + + +{ TfrxGlobalDataSetList } + +constructor TfrxGlobalDataSetList.Create; +begin +{$IFNDEF NO_CRITICAL_SECTION} + FCriticalSection := TCriticalSection.Create; +{$ENDIF} + inherited; +end; + +destructor TfrxGlobalDataSetList.Destroy; +begin +{$IFNDEF NO_CRITICAL_SECTION} + FCriticalSection.Free; + FCriticalSection := nil; +{$ENDIF} + inherited; +end; + +procedure TfrxGlobalDataSetList.Lock; +begin +{$IFNDEF NO_CRITICAL_SECTION} + if FCriticalSection <> nil then + FCriticalSection.Enter; +{$ENDIF} +end; + +procedure TfrxGlobalDataSetList.Unlock; +begin +{$IFNDEF NO_CRITICAL_SECTION} + if FCriticalSection <> nil then + FCriticalSection.Leave; +{$ENDIF} +end; + + +initialization +{$IFNDEF NO_CRITICAL_SECTION} + frxCS := TCriticalSection.Create; +{$ENDIF} + DatasetList := TfrxGlobalDataSetList.Create; + frxGlobalVariables := TfrxVariables.Create; + { create parent form for OLE and RICH controls in the main thread } + frxParentForm; + + Screen.Cursors[crHand] := LoadCursor(hInstance, 'frxHAND'); + Screen.Cursors[crZoom] := LoadCursor(hInstance, 'frxZOOM'); + Screen.Cursors[crFormat] := LoadCursor(hInstance, 'frxFORMAT'); + + RegisterClasses([ + TfrxChild, TfrxColumnFooter, TfrxColumnHeader, TfrxCustomMemoView, TfrxMasterData, + TfrxDetailData, TfrxSubDetailData, TfrxDataBand4, TfrxDataBand5, TfrxDataBand6, + TfrxDialogPage, TfrxFooter, TfrxFrame, TfrxGroupFooter, TfrxGroupHeader, + TfrxHeader, TfrxHighlight, TfrxLineView, TfrxMemoView, TfrxOverlay, TfrxPageFooter, + TfrxPageHeader, TfrxPictureView, TfrxReport, TfrxReportPage, TfrxReportSummary, + TfrxReportTitle, TfrxShapeView, TfrxSubreport, TfrxSysMemoView, TfrxStyleItem, + TfrxNullBand, TfrxCustomLineView, TfrxDataPage]); + + frxResources.UpdateFSResources; + frxFR2Events := TfrxFR2Events.Create; +{$IFDEF FR_COM} + frxGZipCompressor := TfrxGZipCompressor.Create(nil); + +{$IFNDEF EXT_EXPORTS} + {$IFNDEF FR_LITE} + Export2PDF := TfrxPDFExport.Create(nil); + Export2XLS := TfrxXLSExport.Create(nil); + Export2XML := TfrxXMLExport.Create(nil); + Export2RTF := TfrxRTFExport.Create(nil); + Export2HTML := TfrxHTMLExport.Create(nil); + Export2BMP := TfrxBMPExport.Create(nil); + Export2JPEG := TfrxJPEGExport.Create(nil); + Export2TIFF := TfrxTIFFExport.Create(nil); + Export2GIF := TfrxGIFExport.Create(nil); + Export2Mail := TfrxMailExport.Create(nil); + Export2DMP := TfrxDotMatrixExport.Create(nil); + {$ENDIF} + Export2TXT := TfrxSimpleTextExport.Create(nil); + Export2CSV := TfrxCSVExport.Create(nil); +{$ENDIF} + +try + TComponentFactory.Create(ComServer, TfrxReport, Class_TfrxReport, ciMultiInstance, tmApartment); + TComponentFactory.Create(ComServer, TfrxUserDataSet, CLASS_TfrxUserDataSet, ciMultiInstance, tmApartment); + TComponentFactory.Create(ComServer, TfrxGZipCompressor, CLASS_TfrxGZipCompressor, ciMultiInstance, tmApartment); + + DispatchableComponentFactory := TComponentFactory.Create(ComServer, TfrxComponent, CLASS_TfrxDispatchableComponent, ciMultiInstance, tmApartment); +except +end; +{$ENDIF} + + +finalization +{$IFNDEF NO_CRITICAL_SECTION} + frxCS.Free; +{$ENDIF} + +{$IFDEF FR_COM} +// if frxDefaultConnection <> nil then frxDefaultConnection.Free; + if frxADOComponent <> nil then frxADOComponent.Free; + +{$IFNDEF EXT_EXPORTS} + {$IFNDEF FR_LITE} + Export2Gif.Destroy; + Export2Mail.Destroy; + Export2TIFF.Destroy; + Export2JPEG.Destroy; + Export2XML.Destroy; + Export2XLS.Destroy; + Export2RTF.Destroy; + Export2HTML.Destroy; + Export2BMP.Destroy; + Export2PDF.Destroy; + Export2DMP.Destroy; + {$ENDIF} + Export2CSV.Destroy; + Export2TXT.Destroy; +{$ENDIF} + if frxGZipCompressor <> nil then frxGZipCompressor.Destroy; +{$ENDIF} + + frxGlobalVariables.Free; + DatasetList.Free; + if FParentForm <> nil then + begin + EmptyParentForm; + FParentForm.Free; + end; + FParentForm := nil; + frxFR2Events.Free; + + +end. + + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxClass.res b/official/4.2/LibD11/frxClass.res new file mode 100644 index 0000000..d097bbf Binary files /dev/null and b/official/4.2/LibD11/frxClass.res differ diff --git a/official/4.2/LibD11/frxClassRTTI.pas b/official/4.2/LibD11/frxClassRTTI.pas new file mode 100644 index 0000000..984537c --- /dev/null +++ b/official/4.2/LibD11/frxClassRTTI.pas @@ -0,0 +1,565 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Publish all classes defined in } +{ frxClass } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxClassRTTI; + +interface + +{$I frx.inc} + + +implementation + +uses + SysUtils, Classes, Controls, fs_iinterpreter, frxClass, frxCtrls, + frxPreviewPages, frxEngine, frxDMPClass, frxVariables, fs_iformsrtti, + frxUnicodeUtils +{$IFDEF JPEG} +, jpeg +{$ENDIF} +{$IFDEF PNG} +, pngimage +{$ENDIF} +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddConst('fr01cm', 'Extended', fr01cm); + AddConst('fr1cm', 'Extended', fr1cm); + AddConst('fr01in', 'Extended', fr01in); + AddConst('fr1in', 'Extended', fr1in); + AddConst('fr1CharX', 'Extended', fr1CharX); + AddConst('fr1CharY', 'Extended', fr1CharY); + AddConst('clTransparent', 'Integer', clTransparent); + AddConst('crHand', 'Integer', crHand); + AddConst('crZoom', 'Integer', crZoom); + AddConst('crFormat', 'Integer', crFormat); + AddEnum('TfrxStretchMode', 'smDontStretch, smActualHeight, smMaxHeight'); + AddEnum('TfrxShiftMode', 'smDontShift, smAlways, smWhenOverlapped'); + AddEnum('TfrxDuplexMode', 'dmNone, dmVertical, dmHorizontal, dmSimplex'); + AddEnum('TfrxAlign', 'baNone, baLeft, baRight, baCenter, baWidth, baBottom'); + AddEnum('TfrxFrameStyle', 'fsSolid, fsDash, fsDot, fsDashDot, fsDashDotDot, fsDouble'); + AddEnumSet('TfrxFrameTypes', 'ftLeft, ftRight, ftTop, ftBottom'); + AddEnum('TfrxHAlign', 'haLeft, haRight, haCenter, haBlock'); + AddEnum('TfrxVAlign', 'vaTop, vaBottom, vaCenter'); + AddEnumSet('TfrxRestrictions', 'rfDontModify, rfDontSize, rfDontMove, rfDontDelete'); + AddEnum('TfrxShapeKind', 'skRectangle, skRoundRectangle, skEllipse, skTriangle, skDiagonal1, skDiagonal2'); + AddEnumSet('TfrxPreviewButtons', 'pbPrint, pbLoad, pbSave, pbExport, ' + + 'pbZoom, pbFind, pbTree, pbPageSetup, pbRefresh, pbTools, pbEdit, pbNavigator, pbExportQuick'); + AddEnum('TfrxZoomMode', 'zmDefault, zmWholePage, zmPageWidth, zmManyPages'); + AddEnum('TfrxPrintPages', 'ppAll, ppOdd, ppEven'); + AddEnumSet('TfrxDMPFontStyles', 'fsxBold, fsxItalic, fsxUnderline, fsxSuperScript, ' + + 'fsxSubScript, fsxCondensed, fsxWide, fsx12cpi, fsx15cpi'); + AddEnum('TfrxRangeBegin', 'rbFirst, rbCurrent'); + AddEnum('TfrxRangeEnd', 'reLast, reCurrent, reCount'); + AddEnum('TfrxFieldType', 'fftNumeric, fftString, fftBoolean'); + AddEnum('TfrxFormatKind', 'fkText, fkNumeric, fkDateTime, fkBoolean'); + +{$IFDEF JPEG} + AddClass(TJPEGImage, 'TGraphic'); +{$ENDIF} +{$IFDEF PNG} + AddClass(TPngObject, 'TGraphic'); +{$ENDIF} + + with AddClass(TWideStrings, 'TPersistent') do + begin + AddMethod('function Add(const S: string): Integer', CallMethod); + AddMethod('function AddObject(const S: string; AObject: TObject): Integer', CallMethod); + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure Delete(Index: Integer)', CallMethod); + AddMethod('function IndexOf(const S: string): Integer', CallMethod); + AddMethod('procedure Insert(Index: Integer; const S: string)', CallMethod); + AddMethod('procedure LoadFromFile(const FileName: string)', CallMethod); + AddMethod('procedure LoadFromStream(Stream: TStream)', CallMethod); + AddMethod('procedure SaveToFile(const FileName: string)', CallMethod); + AddMethod('procedure SaveToStream(Stream: TStream)', CallMethod); + + AddProperty('Count', 'Integer', GetProp, nil); + AddIndexProperty('Objects', 'Integer', 'TObject', CallMethod); + AddDefaultProperty('Strings', 'Integer', 'string', CallMethod); + AddProperty('Text', 'string', GetProp, SetProp); + end; + + with AddClass(TfrxDataSet, 'TComponent') do + begin + AddMethod('procedure Open', CallMethod); + AddMethod('procedure Close', CallMethod); + AddMethod('procedure First', CallMethod); + AddMethod('procedure Next', CallMethod); + AddMethod('procedure Prior', CallMethod); + AddMethod('function Eof: Boolean', CallMethod); + AddMethod('function FieldsCount: Integer', CallMethod); + AddMethod('function HasField(const fName: String): Boolean', CallMethod); + AddMethod('function IsBlobField(const fName: String): Boolean', CallMethod); + AddMethod('function RecordCount: Integer', CallMethod); + AddMethod('procedure GetFieldList(List: TStrings)', CallMethod); + AddProperty('RecNo', 'Integer', GetProp, nil); + AddIndexProperty('DisplayText', 'String', 'String', CallMethod, True); + AddIndexProperty('DisplayWidth', 'String', 'Integer', CallMethod, True); + AddIndexProperty('FieldType', 'String', 'TfrxFieldType', CallMethod, True); + AddIndexProperty('Value', 'String', 'Variant', CallMethod, True); + end; + AddClass(TfrxUserDataSet, 'TfrxDataSet'); + AddClass(TfrxCustomDBDataSet, 'TfrxDataSet'); + + with AddClass(TfrxComponent, 'TComponent') do + begin + AddMethod('procedure Clear', CallMethod); + AddMethod('function FindObject(s: String): TfrxComponent', CallMethod); + AddMethod('procedure LoadFromStream(Stream: TStream)', CallMethod); + AddMethod('procedure SaveToStream(Stream: TStream; SaveChildren: Boolean = True)', CallMethod); + AddMethod('procedure SetBounds(ALeft, ATop, AWidth, AHeight: Extended)', CallMethod); + AddProperty('Objects', 'TList', GetProp, nil); + AddProperty('AllObjects', 'TList', GetProp, nil); + AddProperty('Parent', 'TfrxComponent', GetProp, SetProp); + AddProperty('Page', 'TfrxPage', GetProp, nil); + AddProperty('AbsLeft', 'Extended', GetProp, nil); + AddProperty('AbsTop', 'Extended', GetProp, nil); + end; + AddClass(TfrxReportComponent, 'TfrxComponent'); + AddClass(TfrxDialogComponent, 'TfrxReportComponent'); + with AddClass(TfrxDialogControl, 'TfrxReportComponent') do + AddMethod('procedure SetFocus', CallMethod); + AddClass(TfrxFrameLine, 'TPersistent'); + AddClass(TfrxFrame, 'TPersistent'); + with AddClass(TfrxView, 'TfrxReportComponent') do + AddProperty('TagStr', 'String', GetProp, SetProp); + AddClass(TfrxShapeView, 'TfrxView'); + with AddClass(TfrxStretcheable, 'TfrxView') do + AddMethod('function CalcHeight: Extended', CallMethod); + AddClass(TfrxHighlight, 'TPersistent'); + AddClass(TfrxFormat, 'TPersistent'); + with AddClass(TfrxCustomMemoView, 'TfrxStretcheable') do + begin + AddMethod('function CalcWidth: Extended', CallMethod); + AddProperty('Text', 'String', GetProp, SetProp); + AddProperty('Lines', 'TWideStrings', GetProp, SetProp); + AddProperty('Value', 'Variant', GetProp, nil); + end; + AddClass(TfrxMemoView, 'TfrxCustomMemoView'); + AddClass(TfrxSysMemoView, 'TfrxCustomMemoView'); + AddClass(TfrxDMPMemoView, 'TfrxCustomMemoView'); + AddClass(TfrxCustomLineView, 'TfrxStretcheable'); + AddClass(TfrxLineView, 'TfrxCustomLineView'); + AddClass(TfrxDMPLineView, 'TfrxCustomLineView'); + AddClass(TfrxDMPCommand, 'TfrxView'); + with AddClass(TfrxPictureView, 'TfrxView') do + AddMethod('procedure LoadFromFile(filename: String)', CallMethod); + AddClass(TfrxSubreport, 'TfrxView'); + with AddClass(TfrxBand, 'TfrxReportComponent') do + AddProperty('Overflow', 'Boolean', GetProp, nil); + AddClass(TfrxDataBand, 'TfrxBand'); + AddClass(TfrxHeader, 'TfrxBand'); + AddClass(TfrxFooter, 'TfrxBand'); + AddClass(TfrxMasterData, 'TfrxDataBand'); + AddClass(TfrxDetailData, 'TfrxDataBand'); + AddClass(TfrxSubDetailData, 'TfrxDataBand'); + AddClass(TfrxDataBand4, 'TfrxDataBand'); + AddClass(TfrxDataBand5, 'TfrxDataBand'); + AddClass(TfrxDataBand6, 'TfrxDataBand'); + AddClass(TfrxPageHeader, 'TfrxBand'); + AddClass(TfrxPageFooter, 'TfrxBand'); + AddClass(TfrxColumnHeader, 'TfrxBand'); + AddClass(TfrxColumnFooter, 'TfrxBand'); + AddClass(TfrxGroupHeader, 'TfrxBand'); + AddClass(TfrxGroupFooter, 'TfrxBand'); + AddClass(TfrxReportTitle, 'TfrxBand'); + AddClass(TfrxReportSummary, 'TfrxBand'); + AddClass(TfrxChild, 'TfrxBand'); + AddClass(TfrxOverlay, 'TfrxBand'); + AddClass(TfrxPage, 'TfrxComponent'); + AddClass(TfrxReportPage, 'TfrxPage'); + with AddClass(TfrxDialogPage, 'TfrxPage') do + begin + AddMethod('function ShowModal: Integer', CallMethod); + AddProperty('ModalResult', 'Integer', GetProp, SetProp); + end; + AddClass(TfrxDMPPage, 'TfrxReportPage'); + AddClass(TfrxDataPage, 'TfrxPage'); + AddClass(TfrxEngineOptions, 'TPersistent'); + AddClass(TfrxPrintOptions, 'TPersistent'); + AddClass(TfrxPreviewOptions, 'TPersistent'); + AddClass(TfrxReportOptions, 'TPersistent'); + AddClass(TfrxVariable, 'TCollectionItem'); + with AddClass(TfrxVariables, 'TCollection') do + begin + AddConstructor('constructor Create', CallMethod); + AddDefaultProperty('Variables', 'String', 'Variant', CallMethod); + end; + with AddClass(TfrxArray, 'TCollection') do + begin + AddConstructor('constructor Create', CallMethod); + AddDefaultProperty('Variables', 'Variant', 'Variant', CallMethod); + end; + AddObject('frxGlobalVariables', frxGlobalVariables); + with AddClass(TfrxReport, 'TfrxComponent') do + begin + AddMethod('function Calc(const Expr: String): Variant', CallMethod); + AddMethod('function GetDataset(const Alias: String): TfrxDataset', CallMethod); + AddMethod('function LoadFromFile(const FileName: String): Boolean', CallMethod); + AddMethod('procedure SaveToFile(const FileName: String)', CallMethod); + AddMethod('procedure ShowReport', CallMethod); + AddProperty('Terminated', 'Boolean', GetProp, SetProp); + AddProperty('Variables', 'TfrxVariables', GetProp, nil); + end; + with AddClass(TfrxCustomEngine, 'TPersistent') do + begin + AddMethod('procedure AddAnchor(const Text: String)', CallMethod); + AddMethod('procedure NewPage', CallMethod); + AddMethod('procedure NewColumn', CallMethod); + AddMethod('procedure ShowBand(Band: TfrxBand)', CallMethod); + AddMethod('procedure StopReport', CallMethod); + AddMethod('function FreeSpace: Extended', CallMethod); + AddMethod('function GetAnchorPage(const Text: String): Integer', CallMethod); + end; + AddClass(TfrxEngine, 'TfrxCustomEngine'); + with AddClass(TfrxCustomOutline, 'TPersistent') do + begin + AddMethod('procedure AddItem(const Text: String)', CallMethod); + AddMethod('procedure LevelRoot', CallMethod); + AddMethod('procedure LevelUp', CallMethod); + end; + AddClass(TfrxOutline, 'TfrxCustomOutline'); + + AddMethod('function DayOf(Date: TDateTime): Integer', CallMethod, 'ctDate'); + AddMethod('function MonthOf(Date: TDateTime): Integer', CallMethod, 'ctDate'); + AddMethod('function YearOf(Date: TDateTime): Integer', CallMethod, 'ctDate'); + + { note: these functions don't have implementation here. They are implemented + in the frxClass.pas unit } + AddMethod('function IIF(Expr: Boolean; TrueValue, FalseValue: Variant): Variant', + CallMethod, 'ctOther'); + AddMethod('function SUM(Expr: Variant; Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod, 'ctAggregate'); + AddMethod('function AVG(Expr: Variant; Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod, 'ctAggregate'); + AddMethod('function MIN(Expr: Variant; Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod, 'ctAggregate'); + AddMethod('function MAX(Expr: Variant; Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod, 'ctAggregate'); + AddMethod('function COUNT(Band: Variant = 0; Flags: Integer = 0): Variant', + CallMethod, 'ctAggregate'); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +var + _TfrxDataSet: TfrxDataSet; + _TStrings: TWideStrings; +begin + Result := 0; + if ClassType = TWideStrings then + begin + _TStrings := TWideStrings(Instance); + if MethodName = 'ADD' then + Result := _TStrings.Add(Caller.Params[0]) + else if MethodName = 'ADDOBJECT' then + Result := _TStrings.AddObject(Caller.Params[0], TObject(Integer(Caller.Params[1]))) + else if MethodName = 'CLEAR' then + _TStrings.Clear + else if MethodName = 'DELETE' then + _TStrings.Delete(Caller.Params[0]) + else if MethodName = 'INDEXOF' then + Result := _TStrings.IndexOf(Caller.Params[0]) + else if MethodName = 'INSERT' then + _TStrings.Insert(Caller.Params[0], Caller.Params[1]) + else if MethodName = 'LOADFROMFILE' then + _TStrings.LoadFromFile(Caller.Params[0]) + else if MethodName = 'LOADFROMSTREAM' then + _TStrings.LoadFromStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'SAVETOFILE' then + _TStrings.SaveToFile(Caller.Params[0]) + else if MethodName = 'SAVETOSTREAM' then + _TStrings.SaveToStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'OBJECTS.GET' then + Result := Integer(_TStrings.Objects[Caller.Params[0]]) + else if MethodName = 'OBJECTS.SET' then + _TStrings.Objects[Caller.Params[0]] := TObject(Integer(Caller.Params[1])) + else if MethodName = 'STRINGS.GET' then + Result := _TStrings.Strings[Caller.Params[0]] + else if MethodName = 'STRINGS.SET' then + _TStrings.Strings[Caller.Params[0]] := Caller.Params[1] + end + else if ClassType = TfrxDataSet then + begin + _TfrxDataSet := TfrxDataSet(Instance); + if MethodName = 'OPEN' then + _TfrxDataSet.Open + else if MethodName = 'CLOSE' then + _TfrxDataSet.Close + else if MethodName = 'FIRST' then + _TfrxDataSet.First + else if MethodName = 'NEXT' then + _TfrxDataSet.Next + else if MethodName = 'PRIOR' then + _TfrxDataSet.Prior + else if MethodName = 'EOF' then + Result := _TfrxDataSet.Eof + else if MethodName = 'FIELDSCOUNT' then + Result := _TfrxDataSet.FieldsCount + else if MethodName = 'RECORDCOUNT' then + Result := _TfrxDataSet.RecordCount + else if MethodName = 'HASFIELD' then + Result := _TfrxDataSet.HasField(Caller.Params[0]) + else if MethodName = 'ISBLOBFIELD' then + Result := _TfrxDataSet.IsBlobField(Caller.Params[0]) + else if MethodName = 'GETFIELDLIST' then + _TfrxDataSet.GetFieldList(TStrings(Integer(Caller.Params[0]))) + else if MethodName = 'DISPLAYTEXT.GET' then + Result := _TfrxDataSet.DisplayText[Caller.Params[0]] + else if MethodName = 'DISPLAYWIDTH.GET' then + Result := _TfrxDataSet.DisplayWidth[Caller.Params[0]] + else if MethodName = 'FIELDTYPE.GET' then + Result := _TfrxDataSet.FieldType[Caller.Params[0]] + else if MethodName = 'VALUE.GET' then + Result := _TfrxDataSet.Value[Caller.Params[0]] + end + else if ClassType = TfrxComponent then + begin + if MethodName = 'CLEAR' then + TfrxComponent(Instance).Clear + else if MethodName = 'FINDOBJECT' then + Result := Integer(TfrxComponent(Instance).FindObject(Caller.Params[0])) + else if MethodName = 'LOADFROMSTREAM' then + TfrxComponent(Instance).LoadFromStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'SAVETOSTREAM' then + TfrxComponent(Instance).SaveToStream(TStream(Integer(Caller.Params[0])), Caller.Params[1]) + else if MethodName = 'SETBOUNDS' then + TfrxComponent(Instance).SetBounds(Caller.Params[0], Caller.Params[1], Caller.Params[2], Caller.Params[3]) + end + else if ClassType = TfrxDialogControl then + begin + if MethodName = 'SETFOCUS' then + if TfrxDialogControl(Instance).Control is TWinControl then + TWinControl(TfrxDialogControl(Instance).Control).SetFocus; + end + else if ClassType = TfrxStretcheable then + begin + if MethodName = 'CALCHEIGHT' then + Result := TfrxStretcheable(Instance).CalcHeight + end + else if ClassType = TfrxCustomMemoView then + begin + if MethodName = 'CALCWIDTH' then + Result := TfrxCustomMemoView(Instance).CalcWidth + end + else if ClassType = TfrxPictureView then + begin + if MethodName = 'LOADFROMFILE' then + TfrxPictureView(Instance).Picture.LoadFromFile(Caller.Params[0]) + end + else if ClassType = TfrxDialogPage then + begin + if MethodName = 'SHOWMODAL' then + Result := TfrxDialogPage(Instance).ShowModal + end + else if ClassType = TfrxVariables then + begin + if MethodName = 'CREATE' then + Result := Integer(TfrxVariables(Instance).Create) + else if MethodName = 'VARIABLES.GET' then + Result := TfrxVariables(Instance).Variables[Caller.Params[0]] + else if MethodName = 'VARIABLES.SET' then + TfrxVariables(Instance).Variables[Caller.Params[0]] := Caller.Params[1] + end + else if ClassType = TfrxArray then + begin + if MethodName = 'CREATE' then + Result := Integer(TfrxArray(Instance).Create) + else if MethodName = 'VARIABLES.GET' then + Result := TfrxArray(Instance).Variables[Caller.Params[0]] + else if MethodName = 'VARIABLES.SET' then + TfrxArray(Instance).Variables[Caller.Params[0]] := Caller.Params[1] + end + else if ClassType = TfrxReport then + begin + if MethodName = 'CALC' then + Result := TfrxReport(Instance).Calc(Caller.Params[0]) + else if MethodName = 'GETDATASET' then + Result := Integer(TfrxReport(Instance).GetDataset(Caller.Params[0])) + else if MethodName = 'LOADFROMFILE' then + Result := TfrxReport(Instance).LoadFromFile(Caller.Params[0]) + else if MethodName = 'SAVETOFILE' then + TfrxReport(Instance).SaveToFile(Caller.Params[0]) + else if MethodName = 'SHOWREPORT' then + TfrxReport(Instance).ShowReport + end + else if ClassType = TfrxCustomEngine then + begin + if MethodName = 'ADDANCHOR' then + TfrxPreviewPages(TfrxCustomEngine(Instance).PreviewPages).AddAnchor(Caller.Params[0]) + else if MethodName = 'GETANCHORPAGE' then + Result := TfrxPreviewPages(TfrxCustomEngine(Instance).PreviewPages).GetAnchorPage(Caller.Params[0]) + else if MethodName = 'NEWPAGE' then + TfrxCustomEngine(Instance).NewPage + else if MethodName = 'NEWCOLUMN' then + TfrxCustomEngine(Instance).NewColumn + else if MethodName = 'FREESPACE' then + Result := TfrxCustomEngine(Instance).FreeSpace + else if MethodName = 'SHOWBAND' then + TfrxCustomEngine(Instance).ShowBand(TfrxBand(Integer(Caller.Params[0]))) + else if MethodName = 'STOPREPORT' then + TfrxCustomEngine(Instance).StopReport + end + else if ClassType = TfrxCustomOutline then + begin + if MethodName = 'ADDITEM' then + TfrxCustomOutline(Instance).AddItem(Caller.Params[0], + Round(TfrxCustomOutline(Instance).Engine.CurY)) + else if MethodName = 'LEVELROOT' then + TfrxCustomOutline(Instance).LevelRoot + else if MethodName = 'LEVELUP' then + TfrxCustomOutline(Instance).LevelUp + end + else if MethodName = 'DAYOF' then + Result := StrToInt(FormatDateTime('d', Caller.Params[0])) + else if MethodName = 'MONTHOF' then + Result := StrToInt(FormatDateTime('m', Caller.Params[0])) + else if MethodName = 'YEAROF' then + Result := StrToInt(FormatDateTime('yyyy', Caller.Params[0])) +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TWideStrings then + begin + if PropName = 'COUNT' then + Result := TWideStrings(Instance).Count + else if PropName = 'TEXT' then + Result := TWideStrings(Instance).Text + end + else if ClassType = TfrxDataSet then + begin + if PropName = 'RECNO' then + Result := TfrxDataSet(Instance).RecNo + end + else if ClassType = TfrxComponent then + begin + if PropName = 'OBJECTS' then + Result := Integer(TfrxComponent(Instance).Objects) + else if PropName = 'ALLOBJECTS' then + Result := Integer(TfrxComponent(Instance).AllObjects) + else if PropName = 'PARENT' then + Result := Integer(TfrxComponent(Instance).Parent) + else if PropName = 'PAGE' then + Result := Integer(TfrxComponent(Instance).Page) + else if PropName = 'ABSLEFT' then + Result := TfrxComponent(Instance).AbsLeft + else if PropName = 'ABSTOP' then + Result := TfrxComponent(Instance).AbsTop + end + else if ClassType = TfrxView then + begin + if PropName = 'TAGSTR' then + Result := TfrxView(Instance).TagStr + end + else if ClassType = TfrxCustomMemoView then + begin + if PropName = 'TEXT' then + Result := TfrxMemoView(Instance).Text + else if PropName = 'LINES' then + Result := Integer(TfrxMemoView(Instance).Memo) + else if PropName = 'VALUE' then + Result := TfrxMemoView(Instance).Value + end + else if ClassType = TfrxBand then + begin + if PropName = 'OVERFLOW' then + Result := TfrxBand(Instance).Overflow + end + else if ClassType = TfrxDialogPage then + begin + if PropName = 'MODALRESULT' then + Result := TfrxDialogPage(Instance).ModalResult + end + else if ClassType = TfrxReport then + begin + if PropName = 'TERMINATED' then + Result := TfrxReport(Instance).Terminated + else if PropName = 'VARIABLES' then + Result := Integer(TfrxReport(Instance).Variables) + end +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin + if ClassType = TWideStrings then + begin + if PropName = 'TEXT' then + TWideStrings(Instance).Text := Value + end + else if ClassType = TfrxComponent then + begin + if PropName = 'PARENT' then + TfrxComponent(Instance).Parent := TfrxComponent(Integer(Value)) + end + else if ClassType = TfrxView then + begin + if PropName = 'TAGSTR' then + TfrxView(Instance).TagStr := Value + end + else if ClassType = TfrxCustomMemoView then + begin + if PropName = 'TEXT' then + TfrxMemoView(Instance).Text := Value + else if PropName = 'LINES' then + TfrxMemoView(Instance).Memo.Assign(TStrings(Integer(Value))); + end + else if ClassType = TfrxDialogPage then + begin + if PropName = 'MODALRESULT' then + TfrxDialogPage(Instance).ModalResult := Value + end + else if ClassType = TfrxReport then + begin + if PropName = 'TERMINATED' then + TfrxReport(Instance).Terminated := Value + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCodeUtils.pas b/official/4.2/LibD11/frxCodeUtils.pas new file mode 100644 index 0000000..761012f --- /dev/null +++ b/official/4.2/LibD11/frxCodeUtils.pas @@ -0,0 +1,247 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Code window utils } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCodeUtils; + +interface + +{$I frx.inc} + +uses + Windows, Classes, SysUtils, TypInfo +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +procedure frxGetEventHandlersList(Code: TStrings; const Language: String; + EventType: PTypeInfo; List: TStrings); +function frxLocateEventHandler(Code: TStrings; const Language, + EventName: String): Integer; +function frxLocateMainProc(Code: TStrings; const Language: String): Integer; +function frxAddEvent(Code: TStrings; const Language: String; + EventType: PTypeInfo; const EventName: String): Integer; +procedure frxEmptyCode(Code: TStrings; const Language: String); +procedure frxAddCodeRes; + +implementation + +uses frxRes; + +procedure frxAddCodeRes; +begin + with frxResources do + begin + Add('PascalScript', + 'proc="procedure" begin="begin" end="end;" lastend="end."'); + Add('C++Script', + 'proc="void" begin="{" end="}" lastend="}"'); + Add('BasicScript', + 'proc="sub" begin="" end="end sub" lastend=""'); + Add('JScript', + 'proc="function" begin="{" end="}" lastend=""'); + + Add('TfrxNotifyEvent', + 'PascalScript=(Sender: TfrxComponent);' + #13#10 + + 'C++Script=(TfrxComponent Sender)' + #13#10 + + 'BasicScript=(Sender)' + #13#10 + + 'JScript=(Sender)'); + Add('TfrxCloseQueryEvent', + 'PascalScript=(Sender: TfrxComponent; var CanClose: Boolean);' + #13#10 + + 'C++Script=(TfrxComponent Sender, bool &CanClose)' + #13#10 + + 'BasicScript=(Sender, byref CanClose)' + #13#10 + + 'JScript=(Sender, &CanClose)'); + Add('TfrxKeyEvent', + 'PascalScript=(Sender: TfrxComponent; var Key: Word; Shift: Integer);' + #13#10 + + 'C++Script=(TfrxComponent Sender, word &Key, int Shift)' + #13#10 + + 'BasicScript=(Sender, byref Key, Shift)' + #13#10 + + 'JScript=(Sender, &Key, Shift)'); + Add('TfrxKeyPressEvent', + 'PascalScript=(Sender: TfrxComponent; var Key: Char);' + #13#10 + + 'C++Script=(TfrxComponent Sender, char &Key)' + #13#10 + + 'BasicScript=(Sender, byref Key)' + #13#10 + + 'JScript=(Sender, &Key)'); + Add('TfrxMouseEvent', + 'PascalScript=(Sender: TfrxComponent; Button: TMouseButton; Shift: Integer; X, Y: Integer);' + #13#10 + + 'C++Script=(TfrxComponent Sender, TMouseButton Button, int Shift, int X, int Y)' + #13#10 + + 'BasicScript=(Sender, Button, Shift, X, Y)' + #13#10 + + 'JScript=(Sender, Button, Shift, X, Y)'); + Add('TfrxMouseMoveEvent', + 'PascalScript=(Sender: TfrxComponent; Shift: Integer; X, Y: Integer);' + #13#10 + + 'C++Script=(TfrxComponent Sender, int Shift, int X, int Y)' + #13#10 + + 'BasicScript=(Sender, Shift, X, Y)' + #13#10 + + 'JScript=(Sender, Shift, X, Y)'); + Add('TfrxPreviewClickEvent', + 'PascalScript=(Sender: TfrxView; Button: TMouseButton; Shift: Integer; var Modified: Boolean);' + #13#10 + + 'C++Script=(TfrxView Sender, TMouseButton Button, int Shift, bool &Modified)' + #13#10 + + 'BasicScript=(Sender, Button, Shift, byref Modified)' + #13#10 + + 'JScript=(Sender, Button, Shift, &Modified)'); + Add('TfrxRunDialogsEvent', + 'PascalScript=(var Result: Boolean);' + #13#10 + + 'C++Script=(bool &Result)' + #13#10 + + 'BasicScript=(byref Result)' + #13#10 + + 'JScript=(&Result)'); + end; +end; + +function GetLangParam(const Language, Param: String): String; +var + s: String; + i: Integer; +begin + Result := ''; + s := frxResources.Get(Language); + if s = Language then Exit; + + i := Pos(AnsiUppercase(Param) + '="', AnsiUppercase(s)); + if (i <> 0) and ((i = 1) or (s[i - 1] = ' ')) then + begin + Result := Copy(s, i + Length(Param + '="'), MaxInt); + Result := Copy(Result, 1, Pos('"', Result) - 1); + end; +end; + +function GetEventParams(EventType: PTypeInfo; const Language: String): String; +var + s: String; + sl: TStringList; +begin + Result := ''; + s := frxResources.Get(EventType.Name); + if s = EventType.Name then Exit; + + sl := TStringList.Create; + sl.Text := s; + Result := sl.Values[Language]; + sl.Free; +end; + +procedure frxGetEventHandlersList(Code: TStrings; const Language: String; + EventType: PTypeInfo; List: TStrings); +var + i: Integer; + s, EventName, EventWord, EventParams: String; +begin + List.Clear; + EventParams := GetEventParams(EventType, Language); + EventWord := AnsiUppercase(GetLangParam(Language, 'proc')); + + for i := 0 to Code.Count - 1 do + begin + s := Code[i]; + if Pos(EventWord, AnsiUppercase(s)) = 1 then + begin + { delete the "procedure" word } + Delete(s, 1, Length(EventWord)); + { extract the event name and params } + EventName := Trim(Copy(s, 1, Pos('(', s) - 1)); + s := Trim(Copy(s, Pos('(', s), 255)); + { compare the params } + if AnsiCompareText(s, EventParams) = 0 then + List.Add(EventName); + end; + end; +end; + +function frxLocateEventHandler(Code: TStrings; const Language, + EventName: String): Integer; +var + i: Integer; + s: String; +begin + Result := -1; + s := UpperCase(GetLangParam(Language, 'proc') + ' ' + EventName + '('); + + for i := 0 to Code.Count - 1 do + if Pos(s, UpperCase(Code[i])) = 1 then + begin + Result := i; + break; + end; +end; + +function frxLocateMainProc(Code: TStrings; const Language: String): Integer; +var + i, endCount: Integer; + s, BeginStr, EndStr: String; +begin + Result := -1; + + BeginStr := GetLangParam(Language, 'begin'); + EndStr := GetLangParam(Language, 'lastend'); + if EndStr = '' then + begin + Result := Code.Count - 1; + Exit; + end; + + i := Code.Count - 1; + while i >= 0 do + begin + s := AnsiUpperCase(Code[i]); + Dec(i); + if Pos(AnsiUpperCase(EndStr), s) <> 0 then + break; + end; + + if i < 0 then Exit; + + EndStr := GetLangParam(Language, 'end'); + endCount := 1; + while (i >= 0) and (endCount <> 0) do + begin + s := AnsiUpperCase(Code[i]); + if Pos(AnsiUpperCase(EndStr), s) <> 0 then + Inc(endCount); + if Pos(AnsiUpperCase(BeginStr), s) <> 0 then + Dec(endCount); + Dec(i); + end; + + Result := i + 1; +end; + +function frxAddEvent(Code: TStrings; const Language: String; + EventType: PTypeInfo; const EventName: String): Integer; +var + MainProcIndex: Integer; +begin + MainProcIndex := frxLocateMainProc(Code, Language); + if MainProcIndex = -1 then + raise Exception.Create(frxResources.Get('dsCantFindProc')); + + Code.Insert(MainProcIndex, GetLangParam(Language, 'proc') + ' ' + EventName + + GetEventParams(EventType, Language)); + Code.Insert(MainProcIndex + 1, GetLangParam(Language, 'begin')); + Code.Insert(MainProcIndex + 2, ''); + Code.Insert(MainProcIndex + 3, GetLangParam(Language, 'end')); + Code.Insert(MainProcIndex + 4, ''); + Result := MainProcIndex + 3; +end; + +procedure frxEmptyCode(Code: TStrings; const Language: String); +begin + Code.Clear; + if GetLangParam(Language, 'lastend') <> '' then + begin + Code.Add(GetLangParam(Language, 'begin')); + Code.Add(''); + Code.Add(GetLangParam(Language, 'lastend')); + end; +end; + + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxConnEditor.dfm b/official/4.2/LibD11/frxConnEditor.dfm new file mode 100644 index 0000000..10e4ad5 Binary files /dev/null and b/official/4.2/LibD11/frxConnEditor.dfm differ diff --git a/official/4.2/LibD11/frxConnEditor.pas b/official/4.2/LibD11/frxConnEditor.pas new file mode 100644 index 0000000..9a4e067 --- /dev/null +++ b/official/4.2/LibD11/frxConnEditor.pas @@ -0,0 +1,209 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Connection list editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxConnEditor; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ComCtrls, StdCtrls, Buttons, ExtCtrls, frxClass; + +type + TfrxConnEditorForm = class(TForm) + NewB: TButton; + DeleteB: TButton; + ConnLV: TListView; + OKB: TButton; + Panel: TPanel; + ExpressionB: TSpeedButton; + CancelB: TButton; + NameE: TEdit; + ConnE: TEdit; + OwnerE: TEdit; + procedure ConnLVSelectItem(Sender: TObject; Item: TListItem; + Selected: Boolean); + procedure NewBClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure DeleteBClick(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure ExpressionBClick(Sender: TObject); + procedure OKBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + public + { Public declarations } + Report: TfrxReport; + end; + + +implementation + +{$R *.DFM} + +uses frxDesgn, frxRes, IniFiles, Registry; + + +procedure TfrxConnEditorForm.FormShow(Sender: TObject); +var + i: Integer; + ini: TRegistry; + sl: TStringList; + li: TListItem; +begin + Caption := frxGet(5800); + NewB.Caption := frxGet(5801); + DeleteB.Caption := frxGet(5802); + OKB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + ConnLV.Columns[0].Caption := frxResources.Get('cpName'); + ConnLV.Columns[2].Caption := frxResources.Get('cpConnStr'); + + NameE.Height := 19; + ConnE.Height := 19; + OwnerE.Height := 19; + Panel.Visible := False; + + ini := TRegistry.Create; + try + ini.RootKey := HKEY_LOCAL_MACHINE; + sl := TStringList.Create; + try + if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS) then + begin + ini.GetValueNames(sl); + for i := 0 to sl.Count - 1 do + begin + li := ConnLV.Items.Add; + li.Caption := sl[i]; + li.SubItems.Add('System'); + li.SubItems.Add(Ini.ReadString(sl[i])); + end; + end; + ini.RootKey := HKEY_CURRENT_USER; + if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS) then + begin + ini.GetValueNames(sl); + for i := 0 to sl.Count - 1 do + begin + li := ConnLV.Items.Add; + li.Caption := sl[i]; + li.SubItems.Add('User'); + li.SubItems.Add(Ini.ReadString(sl[i])); + end; + end; + finally + sl.Free; + end; + finally + ini.Free; + end; +end; + +procedure TfrxConnEditorForm.FormHide(Sender: TObject); +var + i: Integer; + ini: TRegistry; + li: TListItem; +begin + if ModalResult <> mrOk then Exit; + ini := TRegistry.Create; + try + ini.RootKey := HKEY_CURRENT_USER; // HKEY_LOCAL_MACHINE; + ini.DeleteKey(DEF_REG_CONNECTIONS); + if ini.OpenKey(DEF_REG_CONNECTIONS, true) then + for i := 0 to ConnLV.Items.Count - 1 do + begin + li := ConnLV.Items[i]; + if li.SubItems[0] <> 'System' then + ini.WriteString(li.Caption, li.SubItems[1]); + end; + finally + ini.Free; + end; +end; + +procedure TfrxConnEditorForm.NewBClick(Sender: TObject); +var + li: TListItem; +begin + li := ConnLV.Items.Add; + li.Caption := 'New name'; + li.SubItems.Add('User'); + li.SubItems.Add(''); + ConnLV.Selected := li; + NameE.SetFocus; +end; + +procedure TfrxConnEditorForm.DeleteBClick(Sender: TObject); +begin + ConnLV.Selected.Free; +end; + +procedure TfrxConnEditorForm.ConnLVSelectItem(Sender: TObject; + Item: TListItem; Selected: Boolean); +begin + if Selected then + begin + Panel.Visible := True; + Panel.Top := ConnLV.Top + Item.Top; + NameE.Text := Item.Caption; + OwnerE.Text := Item.SubItems[0]; + ConnE.Text := Item.SubItems[1]; + if OwnerE.Text = 'System' then + begin + DeleteB.Enabled := false; + ExpressionB.Visible := false; + ConnE.Width := 300; + end + else + begin + DeleteB.Enabled := true; + ExpressionB.Visible := true; + ConnE.Width := 281; + end + end + else + begin + Panel.Visible := False; + Item.Caption := NameE.Text; + Item.SubItems[0] := OwnerE.Text; + Item.SubItems[1] := ConnE.Text; + end; +end; + +procedure TfrxConnEditorForm.ExpressionBClick(Sender: TObject); +begin + if Assigned(Report) and Assigned(Report.OnEditConnection) then + ConnE.Text := Report.OnEditConnection(ConnE.Text); +end; + +procedure TfrxConnEditorForm.OKBClick(Sender: TObject); +begin + ConnLV.Selected := nil; +end; + +procedure TfrxConnEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxConnWizard.dfm b/official/4.2/LibD11/frxConnWizard.dfm new file mode 100644 index 0000000..639dd1e Binary files /dev/null and b/official/4.2/LibD11/frxConnWizard.dfm differ diff --git a/official/4.2/LibD11/frxConnWizard.pas b/official/4.2/LibD11/frxConnWizard.pas new file mode 100644 index 0000000..5d0a7ca --- /dev/null +++ b/official/4.2/LibD11/frxConnWizard.pas @@ -0,0 +1,538 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ DB Connection wizard } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxConnWizard; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, Buttons, StdCtrls, ComCtrls, ToolWin, + frxClass, frxSynMemo, frxCustomDB +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF QBUILDER} +, fqbClass +{$ENDIF}; + +type + TfrxDBConnWizard = class(TfrxCustomWizard) + private + FDatabase: TfrxCustomDatabase; + public + class function GetDescription: String; override; + function Execute: Boolean; override; + property Database: TfrxCustomDatabase read FDatabase write FDatabase; + end; + + TfrxDBTableWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxDBQueryWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxConnectionWizardForm = class(TForm) + OKB: TButton; + CancelB: TButton; + PageControl1: TPageControl; + ConnTS: TTabSheet; + TableTS: TTabSheet; + ConnL1: TLabel; + DBL: TLabel; + LoginL: TLabel; + PasswordL: TLabel; + ChooseB: TSpeedButton; + ConnCB: TComboBox; + DatabaseE: TEdit; + LoginE: TEdit; + PasswordE: TEdit; + PromptRB: TRadioButton; + LoginRB: TRadioButton; + ConnL2: TLabel; + ConnCB1: TComboBox; + TableL: TLabel; + TableCB: TComboBox; + FilterCB: TCheckBox; + FilterE: TEdit; + QueryTS: TTabSheet; + ConnL3: TLabel; + ConnCB2: TComboBox; + QueryL: TLabel; + ToolBar1: TToolBar; + BuildSQLB: TToolButton; + ParamsB: TToolButton; + procedure FormCreate(Sender: TObject); + procedure ChooseBClick(Sender: TObject); + procedure ConnCBClick(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure ConnCB1Click(Sender: TObject); + procedure ConnCB2Click(Sender: TObject); + procedure BuildSQLBClick(Sender: TObject); + procedure ParamsBClick(Sender: TObject); + procedure OKBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FComponent: TfrxComponent; + FDatabase: TfrxCustomDatabase; + FDesigner: TfrxCustomDesigner; + FItem: Integer; + FItemIndex: Integer; + FMemo: TfrxSyntaxMemo; + FOldItem: Integer; + FPage: TfrxPage; + FQuery: TfrxCustomQuery; + FReport: TfrxReport; + FTable: TfrxCustomTable; + public + { Public declarations } + end; + + +implementation + +{$R *.DFM} +{$R *.RES} + +uses frxUtils, frxDsgnIntf, frxRes, frxEditQueryParams; + +const + dbiConnection = 0; + dbiTable = 1; + dbiQuery = 2; + + +{ TfrxDBConnWizard } + +class function TfrxDBConnWizard.GetDescription: String; +begin + Result := frxResources.Get('wzDBConn'); +end; + +function TfrxDBConnWizard.Execute: Boolean; +begin + with TfrxConnectionWizardForm.Create(Owner) do + begin + FDesigner := Self.Designer; + FReport := Report; + FItem := dbiConnection; + FDatabase := Self.FDatabase; + Result := ShowModal = mrOk; + Free; + end; +end; + + +{ TfrxDBTableWizard } + +class function TfrxDBTableWizard.GetDescription: String; +begin + Result := frxResources.Get('wzDBTable'); +end; + +function TfrxDBTableWizard.Execute: Boolean; +begin + with TfrxConnectionWizardForm.Create(Owner) do + begin + FDesigner := Self.Designer; + FReport := Report; + FItem := dbiTable; + Result := ShowModal = mrOk; + Free; + end; +end; + + +{ TfrxDBQueryWizard } + +class function TfrxDBQueryWizard.GetDescription: String; +begin + Result := frxResources.Get('wzDBQuery'); +end; + +function TfrxDBQueryWizard.Execute: Boolean; +begin + with TfrxConnectionWizardForm.Create(Owner) do + begin + FDesigner := Self.Designer; + FReport := Report; + FItem := dbiQuery; + Result := ShowModal = mrOk; + Free; + end; +end; + + +{ TfrxConnectionWizardForm } + +procedure TfrxConnectionWizardForm.FormCreate(Sender: TObject); +var + i: Integer; +begin + Caption := frxGet(5700); + OKB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + ConnTS.Caption := frxGet(5701); + ConnL1.Caption := frxGet(5702); + ConnL2.Caption := ConnL1.Caption; + ConnL3.Caption := ConnL1.Caption; + DBL.Caption := frxGet(5703); + LoginL.Caption := frxGet(5704); + PasswordL.Caption := frxGet(5705); + PromptRB.Caption := frxGet(5706); + LoginRB.Caption := frxGet(5707); + TableTS.Caption := frxGet(5708); + TableL.Caption := frxGet(5709); + FilterCB.Caption := frxGet(5710); + QueryTS.Caption := frxGet(5711); + QueryL.Caption := frxGet(5712); + BuildSQLB.Hint := frxGet(5713); + ParamsB.Hint := frxGet(5714); + + Toolbar1.Images := frxResources.MainButtonImages; + FOldItem := dbiConnection; + FMemo := TfrxSyntaxMemo.Create(Self); + with FMemo do + begin + Parent := QueryTS; + SetBounds(16, 80, 265, 153); + Syntax := 'SQL'; + ShowGutter := False; + Color := clWindow; +{$IFDEF UseTabset} + BevelKind := bkFlat; +{$ELSE} + BorderStyle := bsSingle; +{$ENDIF} + +{$I frxEditSQL.inc} + end; + +{$IFNDEF QBUILDER} + BuildSQLB.Visible := False; +{$ENDIF} + + ConnCB1.Items.Add(frxResources.Get('prNotAssigned')); + ConnCB2.Items.Add(frxResources.Get('prNotAssigned')); + for i := 0 to frxObjects.Count - 1 do + if frxObjects[i].ClassRef <> nil then + if frxObjects[i].ClassRef.InheritsFrom(TfrxCustomDatabase) then + ConnCB.Items.AddObject(frxObjects[i].ClassRef.GetDescription, Pointer(i)) + else if frxObjects[i].ClassRef.InheritsFrom(TfrxCustomTable) then + ConnCB1.Items.AddObject(frxObjects[i].ClassRef.GetDescription, Pointer(i)) + else if frxObjects[i].ClassRef.InheritsFrom(TfrxCustomQuery) then + ConnCB2.Items.AddObject(frxObjects[i].ClassRef.GetDescription, Pointer(i)); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxConnectionWizardForm.FormShow(Sender: TObject); +var + i: Integer; +begin + FPage := FReport.Pages[0]; + + if FItem = dbiConnection then + begin + PageControl1.ActivePage := ConnTS; + ConnTS.TabVisible := True; + TableTS.TabVisible := False; + QueryTS.TabVisible := False; + if FDatabase <> nil then + begin + for i := 0 to ConnCB.Items.Count - 1 do + if frxObjects[Integer(ConnCB.Items.Objects[i])].ClassRef = FDatabase.ClassType then + begin + ConnCB.ItemIndex := i; + break; + end; + ConnCB.Enabled := False; + DatabaseE.Text := FDatabase.DatabaseName; + end + else + begin + if ConnCB.Items.Count > 1 then + ConnCB.ItemIndex := 1 + else + ConnCB.ItemIndex := 0; + ConnCBClick(nil); + end; + end + else if FItem = dbiTable then + begin + PageControl1.ActivePage := TableTS; + ConnTS.TabVisible := False; + TableTS.TabVisible := True; + QueryTS.TabVisible := False; + if FItemIndex <> 0 then + ConnCB1.ItemIndex := FItemIndex + else if ConnCB1.Items.Count > 1 then + ConnCB1.ItemIndex := 1 + else + ConnCB1.ItemIndex := 0; + ConnCB1Click(nil); + end + else if FItem = dbiQuery then + begin + PageControl1.ActivePage := QueryTS; + ConnTS.TabVisible := False; + TableTS.TabVisible := False; + QueryTS.TabVisible := True; + if FItemIndex <> 0 then + ConnCB2.ItemIndex := FItemIndex + else if ConnCB2.Items.Count > 1 then + ConnCB2.ItemIndex := 1 + else + ConnCB2.ItemIndex := 0; + ConnCB2Click(nil); + end; +end; + +procedure TfrxConnectionWizardForm.FormHide(Sender: TObject); +begin + if FItem = dbiConnection then + begin + FComponent := FDatabase; + if ConnCB.Enabled = False then + FComponent := nil; + end + else if FItem = dbiTable then + FComponent := FTable + else if FItem = dbiQuery then + FComponent := FQuery; + + if FComponent <> nil then + if ModalResult = mrCancel then + FComponent.Free + else + begin + FComponent.CreateUniqueName; + FDesigner.ReloadReport; + end; +end; + +procedure TfrxConnectionWizardForm.OKBClick(Sender: TObject); +begin + if FItem = dbiConnection then + begin + if FDatabase = nil then Exit; + FDatabase.DatabaseName := DatabaseE.Text; + if PromptRB.Checked then + FDatabase.LoginPrompt := True + else + begin + FDatabase.LoginPrompt := False; + FDatabase.SetLogin(LoginE.Text, PasswordE.Text); + end; + FComponent := FDatabase; + end + else if FItem = dbiTable then + begin + if FTable = nil then Exit; + FTable.TableName := TableCB.Text; + FTable.Filter := FilterE.Text; + FTable.Filtered := FilterCB.Checked; + FComponent := FTable; + end + else if FItem = dbiQuery then + begin + if FQuery = nil then Exit; + FQuery.SQL.Assign(FMemo.Lines); + FComponent := FQuery; + end; + + if FOldItem <> dbiConnection then + begin + FComponent.CreateUniqueName; + FItem := FOldItem; + FOldItem := dbiConnection; + ModalResult := mrNone; + FormShow(nil); + end; +end; + +procedure TfrxConnectionWizardForm.ConnCBClick(Sender: TObject); +var + ClassRef: TClass; +begin + if FDatabase <> nil then + begin + FDatabase.Free; + FDatabase := nil; + end; + ClassRef := frxObjects[Integer(ConnCB.Items.Objects[ConnCB.ItemIndex])].ClassRef; + FDatabase := TfrxCustomDatabase(ClassRef.NewInstance); + FDatabase.Create(FPage); + FDatabase.SetBounds((FPage.Objects.Count - 1) * 100 + 30, 20, 32, 32); +end; + +procedure TfrxConnectionWizardForm.ConnCB1Click(Sender: TObject); +var + i: Integer; + ClassRef: TClass; + propList: TfrxPropertyList; +begin + if FTable <> nil then + begin + FTable.Free; + FTable := nil; + end; + if ConnCB1.ItemIndex = 0 then Exit; + + ClassRef := frxObjects[Integer(ConnCB1.Items.Objects[ConnCB1.ItemIndex])].ClassRef; + FTable := TfrxCustomTable(ClassRef.NewInstance); + FTable.DesignCreate(FPage, 0); + FTable.SetBounds((FPage.Objects.Count - 1) * 100 + 30, 20, 32, 32); + + propList := TfrxPropertyList.Create(nil); + propList.Component := FTable; + for i := 0 to propList.Count - 1 do + if propList[i].Editor.GetName = 'TableName' then + begin + propList[i].Editor.GetValues; + TableCB.Items := propList[i].Editor.Values; + end; + propList.Free; + + if not FTable.DBConnected then + begin + FTable.Free; + FTable := nil; + FOldItem := FItem; + FItem := dbiConnection; + FItemIndex := ConnCB1.ItemIndex; + FormShow(nil); + end; +end; + +procedure TfrxConnectionWizardForm.ConnCB2Click(Sender: TObject); +var + ClassRef: TClass; +begin + if FQuery <> nil then + begin + FQuery.Free; + FQuery := nil; + end; + if ConnCB2.ItemIndex = 0 then Exit; + + ClassRef := frxObjects[Integer(ConnCB2.Items.Objects[ConnCB2.ItemIndex])].ClassRef; + FQuery := TfrxCustomQuery(ClassRef.NewInstance); + FQuery.DesignCreate(FPage, 0); + FQuery.SetBounds((FPage.Objects.Count - 1) * 100 + 30, 20, 32, 32); + + if not FQuery.DBConnected then + begin + FQuery.Free; + FQuery := nil; + FOldItem := FItem; + FItem := dbiConnection; + FItemIndex := ConnCB2.ItemIndex; + FormShow(nil); + end; +end; + +procedure TfrxConnectionWizardForm.ChooseBClick(Sender: TObject); +var + i: Integer; + propList: TfrxPropertyList; +begin + propList := TfrxPropertyList.Create(nil); + propList.Component := FDatabase; + for i := 0 to propList.Count - 1 do + if (CompareText(propList[i].Editor.GetName, 'DatabaseName') = 0) or + (CompareText(propList[i].Editor.GetName, 'ConnectionName') = 0) then + begin + propList[i].Editor.Edit; + DatabaseE.Text := FDatabase.DatabaseName; + break; + end; + propList.Free; + + DatabaseE.SetFocus; +end; + +procedure TfrxConnectionWizardForm.BuildSQLBClick(Sender: TObject); +{$IFDEF QBUILDER} +var + fqbDialog: TfqbDialog; +{$ENDIF} +begin +{$IFDEF QBUILDER} + if FQuery = nil then Exit; + fqbDialog := TfqbDialog.Create(nil); + try + fqbDialog.Engine := FQuery.QBEngine; + fqbDialog.SchemaInsideSQL := False; + fqbDialog.SQL := FMemo.Lines.Text; + fqbDialog.SQLSchema := FQuery.SQLSchema; + + if fqbDialog.Execute then + begin + FMemo.Lines.Text := fqbDialog.SQL; + FQuery.SQLSchema := fqbDialog.SQLSchema; + end; + finally + fqbDialog.Free; + end; +{$ENDIF} +end; + +procedure TfrxConnectionWizardForm.ParamsBClick(Sender: TObject); +begin + if FQuery <> nil then + begin + FQuery.SQL.Assign(FMemo.Lines); + if FQuery.Params.Count <> 0 then + with TfrxParamsEditorForm.Create(FDesigner) do + begin + Params := FQuery.Params; + if ShowModal = mrOk then + FQuery.UpdateParams; + Free; + end; + end; +end; + +procedure TfrxConnectionWizardForm.FormKeyDown(Sender: TObject; + var Key: Word; Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + + +initialization + frxWizards.Register1(TfrxDBConnWizard, 2); + frxWizards.Register1(TfrxDBTableWizard, 3); + frxWizards.Register1(TfrxDBQueryWizard, 4); + +finalization + frxWizards.Unregister(TfrxDBConnWizard); + frxWizards.Unregister(TfrxDBTableWizard); + frxWizards.Unregister(TfrxDBQueryWizard); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxConnWizard.res b/official/4.2/LibD11/frxConnWizard.res new file mode 100644 index 0000000..bc19066 Binary files /dev/null and b/official/4.2/LibD11/frxConnWizard.res differ diff --git a/official/4.2/LibD11/frxCross.pas b/official/4.2/LibD11/frxCross.pas new file mode 100644 index 0000000..f9a5b14 --- /dev/null +++ b/official/4.2/LibD11/frxCross.pas @@ -0,0 +1,4623 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Cross object } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCross; + +interface + +{$I frx.inc} + +uses + Windows, SysUtils, Classes, Controls, Graphics, Forms, + frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF FR_COM} +, FastReport_TLB +, ActiveX +{$ENDIF}; + +type + TfrxCrossObject = class(TComponent); // fake component + + TfrxPrintCellEvent = type String; + TfrxPrintHeaderEvent = type String; + TfrxCalcWidthEvent = type String; + TfrxCalcHeightEvent = type String; + TfrxOnPrintCellEvent = procedure (Memo: TfrxCustomMemoView; + RowIndex, ColumnIndex, CellIndex: Integer; + const RowValues, ColumnValues, Value: Variant) of object; + TfrxOnPrintHeaderEvent = procedure (Memo: TfrxCustomMemoView; + const HeaderIndexes, HeaderValues, Value: Variant) of object; + TfrxOnCalcWidthEvent = procedure (ColumnIndex: Integer; + const ColumnValues: Variant; var Width: Extended) of object; + TfrxOnCalcHeightEvent = procedure (RowIndex: Integer; + const RowValues: Variant; var Height: Extended) of object; + + { the record represents one cell of cross matrix } + PfrCrossCell = ^TfrxCrossCell; + TfrxCrossCell = packed record + Value: Variant; + Count: Integer; + Next: PfrCrossCell; { pointer to the next value in the same cell } + end; + + TfrxCrossSortOrder = (soAscending, soDescending, soNone); + TfrxCrossFunction = (cfNone, cfSum, cfMin, cfMax, cfAvg, cfCount); + TfrxVariantArray = array of Variant; + TfrxSortArray = array [0..31] of TfrxCrossSortOrder; + + { the base class for column/row item. Contains Indexes array that + identifies a column/row } + TfrxIndexItem = class(TCollectionItem) + private + FIndexes: TfrxVariantArray; + public + destructor Destroy; override; + property Indexes: TfrxVariantArray read FIndexes write FIndexes; + end; + + { the base collection for column/row items. Contains methods for working + with Indexes and sorting them } + TfrxIndexCollection = class(TCollection) + private + FIndexesCount: Integer; + FSortOrder: TfrxSortArray; + function GetItems(Index: Integer): TfrxIndexItem; + public + function Find(const Indexes: array of Variant; var Index: Integer): Boolean; + function InsertItem(Index: Integer; const Indexes: array of Variant): TfrxIndexItem; virtual; + property Items[Index: Integer]: TfrxIndexItem read GetItems; default; + end; + + { the class representing a single row item } + TfrxCrossRow = class(TfrxIndexItem) + private + FCellLevels: Integer; + FCells: TList; + procedure CreateCell(Index: Integer); + public + constructor Create(Collection: TCollection); override; + destructor Destroy; override; + function GetCell(Index: Integer): PfrCrossCell; + function GetCellValue(Index1, Index2: Integer): Variant; + procedure SetCellValue(Index1, Index2: Integer; const Value: Variant); + end; + + { the class representing row items } + TfrxCrossRows = class(TfrxIndexCollection) + private + FCellLevels: Integer; + function GetItems(Index: Integer): TfrxCrossRow; + public + constructor Create; + function InsertItem(Index: Integer; const Indexes: array of Variant): TfrxIndexItem; override; + function Row(const Indexes: array of Variant): TfrxCrossRow; + property Items[Index: Integer]: TfrxCrossRow read GetItems; default; + end; + + { the class representing a single column item } + TfrxCrossColumn = class(TfrxIndexItem) + private + FCellIndex: Integer; + public + property CellIndex: Integer read FCellIndex write FCellIndex; + end; + + { the class representing column items } + TfrxCrossColumns = class(TfrxIndexCollection) + private + function GetItems(Index: Integer): TfrxCrossColumn; + public + constructor Create; + function Column(const Indexes: array of Variant): TfrxCrossColumn; + function InsertItem(Index: Integer; const Indexes: array of Variant): TfrxIndexItem; override; + property Items[Index: Integer]: TfrxCrossColumn read GetItems; default; + end; + + { TfrxCrossHeader represents one cell of a cross header. The cell has a value, + position, size and list of subcells } + TfrxCrossHeader = class(TObject) + private + FBounds: TfrxRect; { bounds of the cell } + FMemos: TList; + FTotalMemos: TList; + FCounts: TfrxVariantArray; + FCellIndex: Integer; { help to determine cell index for cell header } + FCellLevels: Integer; + FFuncValues: TfrxVariantArray; + FHasCellHeaders: Boolean; { top level item only } + FIndex: Integer; { index of the item } + FIsCellHeader: Boolean; + FIsIndex: Boolean; { used in IndexItems to determine if item is index } + FIsTotal: Boolean; { is this cell a total cell } + FItems: TList; { subcells } + FLevelsCount: Integer; { number of header levels } + FMemo: TfrxCustomMemoView; { memo for this cell } + FNoLevels: Boolean; { true if no items in row/column header } + FParent: TfrxCrossHeader; { parent of the cell } + FSize: TfrxPoint; + FTotalIndex: Integer; { will help to choose which header memo to use } + FValue: Variant; { value (text) of the cell } + FVisible: Boolean; { visibility of the cell } + + function AddCellHeader(Memos: TList; Index, CellIndex: Integer): TfrxCrossHeader; + function AddChild(Memo: TfrxCustomMemoView): TfrxCrossHeader; + procedure AddFuncValues(const Values, Counts: array of Variant; + const CellFunctions: array of TfrxCrossFunction); + procedure AddValues(const Values: array of Variant); + procedure Reset(const CellFunctions: array of TfrxCrossFunction); + + function GetCount: Integer; + function GetItems(Index: Integer): TfrxCrossHeader; + function GetLevel: Integer; + function GetHeight: Extended; + function GetWidth: Extended; + public + constructor Create(CellLevels: Integer); + destructor Destroy; override; + procedure CalcBounds; virtual; abstract; + procedure CalcSizes(MaxWidth, MinWidth: Integer; AutoSize: Boolean); virtual; abstract; + + function AllItems: TList; + function Find(Value: Variant): Integer; + function GetIndexes: Variant; + function GetValues: Variant; + function TerminalItems: TList; + function IndexItems: TList; + + property Bounds: TfrxRect read FBounds write FBounds; + property Count: Integer read GetCount; + property HasCellHeaders: Boolean read FHasCellHeaders write FHasCellHeaders; + property Height: Extended read GetHeight; + property IsTotal: Boolean read FIsTotal; + property Items[Index: Integer]: TfrxCrossHeader read GetItems; default; + property Level: Integer read GetLevel; + property Memo: TfrxCustomMemoView read FMemo; + property Parent: TfrxCrossHeader read FParent; + property Value: Variant read FValue write FValue; + property Visible: Boolean read FVisible write FVisible; + property Width: Extended read GetWidth; + end; + + { the cross columns } + TfrxCrossColumnHeader = class(TfrxCrossHeader) + private + FCorner: TfrxCrossHeader; + public + procedure CalcBounds; override; + procedure CalcSizes(MaxWidth, MinWidth: Integer; AutoSize: Boolean); override; + end; + + { the cross rows } + TfrxCrossRowHeader = class(TfrxCrossHeader) + private + FCorner: TfrxCrossHeader; + public + procedure CalcBounds; override; + procedure CalcSizes(MaxWidth, MinWidth: Integer; AutoSize: Boolean); override; + end; + + { the cross corner } + TfrxCrossCorner = class(TfrxCrossColumnHeader) + end; + + + { cutted bands } + TfrxCutBandItem = class(TCollectionItem) + public + Band: TfrxBand; + FromIndex: Integer; + ToIndex: Integer; + destructor Destroy; override; + end; + + TfrxCutBands = class(TCollection) + private + function GetItems(Index: Integer): TfrxCutBandItem; + public + constructor Create; + procedure Add(ABand: TfrxBand; AFromIndex, AToIndex: Integer); + property Items[Index: Integer]: TfrxCutBandItem read GetItems; default; + end; + + { design-time grid resize support } + TfrxGridLineItem = class(TCollectionItem) + public + Coord: Extended; + Objects: TList; + constructor Create(Collection: TCollection); override; + destructor Destroy; override; + end; + + TfrxGridLines = class(TCollection) + private + function GetItems(Index: Integer): TfrxGridLineItem; + public + constructor Create; + procedure Add(AObj: TObject; ACoord: Extended); + property Items[Index: Integer]: TfrxGridLineItem read GetItems; default; + end; + + + { custom cross object } +{$IFDEF FR_COM} + TfrxCustomCrossView = class(TfrxView, IfrxCustomCrossView) +{$ELSE} + TfrxCustomCrossView = class(TfrxView) +{$ENDIF} + private + FAddHeight: Extended; + FAddWidth: Extended; + FAllowDuplicates: Boolean; + FAutoSize: Boolean; + FBorder: Boolean; + FCellFields: TStrings; + FCellFunctions: array[0..31] of TfrxCrossFunction; + FCellLevels: Integer; + FClearBeforePrint: Boolean; + FColumnBands: TfrxCutBands; + FColumnFields: TStrings; + FColumnHeader: TfrxCrossColumnHeader; + FColumnLevels: Integer; + FColumns: TfrxCrossColumns; + FColumnSort: TfrxSortArray; + FCorner: TfrxCrossCorner; + FDefHeight: Integer; + FDotMatrix: Boolean; + FDownThenAcross: Boolean; + FFirstMousePos: TPoint; + FGapX: Integer; + FGapY: Integer; + FGridUsed: TfrxGridLines; + FGridX: TfrxGridLines; + FGridY: TfrxGridLines; + FJoinEqualCells: Boolean; + FKeepTogether: Boolean; + FLastMousePos: TPoint; + FMaxWidth: Integer; + FMinWidth: Integer; + FMouseDown: Boolean; + FMovingObjects: Integer; + FNextCross: TfrxCustomCrossView; + FNextCrossGap: Extended; + FNoColumns: Boolean; + FNoRows: Boolean; + FPlainCells: Boolean; + FRepeatHeaders: Boolean; + FRowBands: TfrxCutBands; + FRowFields: TStrings; + FRowHeader: TfrxCrossRowHeader; + FRowLevels: Integer; + FRows: TfrxCrossRows; + FRowSort: TfrxSortArray; + FShowColumnHeader: Boolean; + FShowColumnTotal: Boolean; + FShowCorner: Boolean; + FShowRowHeader: Boolean; + FShowRowTotal: Boolean; + FShowTitle: Boolean; + FSuppressNullRecords: Boolean; + + FAllMemos: TList; + FCellMemos: TList; + FCellHeaderMemos: TList; + FColumnMemos: TList; + FColumnTotalMemos: TList; + FCornerMemos: TList; + FRowMemos: TList; + FRowTotalMemos: TList; + + FOnCalcHeight: TfrxCalcHeightEvent; { script event } + FOnCalcWidth: TfrxCalcWidthEvent; { script event } + FOnPrintCell: TfrxPrintCellEvent; { script event } + FOnPrintColumnHeader: TfrxPrintHeaderEvent; { script event } + FOnPrintRowHeader: TfrxPrintHeaderEvent; { script event } + FOnBeforeCalcHeight: TfrxOnCalcHeightEvent; { Delphi event } + FOnBeforeCalcWidth: TfrxOnCalcWidthEvent; { Delphi event } + FOnBeforePrintCell: TfrxOnPrintCellEvent; { Delphi event } + FOnBeforePrintColumnHeader: TfrxOnPrintHeaderEvent; { Delphi event } + FOnBeforePrintRowHeader: TfrxOnPrintHeaderEvent; { Delphi event } + + procedure CalcBounds(addWidth, addHeight: Extended); + procedure CalcTotal(Header: TfrxCrossHeader; Source: TfrxIndexCollection); + procedure CalcTotals; + procedure CreateHeader(Header: TfrxCrossHeader; Source: TfrxIndexCollection; + Totals: TList; TotalVisible: Boolean); + procedure CreateHeaders; + + procedure AddSourceObjects; + procedure BuildColumnBands; + procedure BuildRowBands; + procedure ClearMatrix; + procedure ClearMemos; + procedure CreateCellHeaderMemos(NewCount: Integer); + procedure CreateCellMemos(NewCount: Integer); + procedure CreateColumnMemos(NewCount: Integer); + procedure CreateCornerMemos(NewCount: Integer); + procedure CreateRowMemos(NewCount: Integer); + procedure CorrectDMPBounds(Memo: TfrxCustomMemoView); + procedure DoCalcHeight(Row: Integer; var Height: Extended); + procedure DoCalcWidth(Column: Integer; var Width: Extended); + procedure DoOnCell(Memo: TfrxCustomMemoView; Row, Column, Cell: Integer; + const Value: Variant); + procedure DoOnColumnHeader(Memo: TfrxCustomMemoView; Header: TfrxCrossHeader); + procedure DoOnRowHeader(Memo: TfrxCustomMemoView; Header: TfrxCrossHeader); + procedure InitMatrix; + procedure InitMemos(AddToScript: Boolean); + procedure ReadMemos(Stream: TStream); + procedure RenderMatrix; + procedure SetCellFields(const Value: TStrings); + procedure SetCellFunctions(Index: Integer; const Value: TfrxCrossFunction); + procedure SetColumnFields(const Value: TStrings); + procedure SetColumnSort(Index: Integer; Value: TfrxCrossSortOrder); + procedure SetDotMatrix(const Value: Boolean); + procedure SetRowFields(const Value: TStrings); + procedure SetRowSort(Index: Integer; Value: TfrxCrossSortOrder); + procedure SetupOriginalComponent(Obj1, Obj2: TfrxComponent); + procedure UpdateVisibility; + procedure WriteMemos(Stream: TStream); + function CreateMemo(Parent: TfrxComponent): TfrxCustomMemoView; + function GetCellFunctions(Index: Integer): TfrxCrossFunction; + function GetCellHeaderMemos(Index: Integer): TfrxCustomMemoView; + function GetCellMemos(Index: Integer): TfrxCustomMemoView; + function GetColumnMemos(Index: Integer): TfrxCustomMemoView; + function GetColumnSort(Index: Integer): TfrxCrossSortOrder; + function GetColumnTotalMemos(Index: Integer): TfrxCustomMemoView; + function GetCornerMemos(Index: Integer): TfrxCustomMemoView; + function GetNestedObjects: TList; + function GetRowMemos(Index: Integer): TfrxCustomMemoView; + function GetRowSort(Index: Integer): TfrxCrossSortOrder; + function GetRowTotalMemos(Index: Integer): TfrxCustomMemoView; + protected + procedure DefineProperties(Filer: TFiler); override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure SetCellLevels(const Value: Integer); virtual; + procedure SetColumnLevels(const Value: Integer); virtual; + procedure SetRowLevels(const Value: Integer); virtual; + function GetContainerObjects: TList; override; +{$IFDEF FR_COM} + function Get_CellFields(out Value: WideString): HResult; stdcall; + function Set_CellFields(const Value: WideString): HResult; stdcall; + function Get_CellFunctions(Index: Integer; out Value: frxCrossFunction): HResult; stdcall; + function Set_CellFunctions(Index: Integer; Value: frxCrossFunction): HResult; stdcall; + function Get_CellMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; + function Get_ColumnFields(out Value: WideString): HResult; stdcall; + function Set_ColumnFields(const Value: WideString): HResult; stdcall; + function Get_ColumnMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; + function Get_ColumnSort(Index: Integer; out Value: frxCrossSortOrder): HResult; stdcall; + function Set_ColumnSort(Index: Integer; Value: frxCrossSortOrder): HResult; stdcall; + function Get_ColumnTotalMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; + function Get_RowFields(out Value: WideString): HResult; stdcall; + function Set_RowFields(const Value: WideString): HResult; stdcall; + function Get_RowMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; + function Get_RowSort(Index: Integer; out Value: frxCrossSortOrder): HResult; stdcall; + function Set_RowSort(Index: Integer; Value: frxCrossSortOrder): HResult; stdcall; + function Get_RowTotalMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; + function Get_MaxWidth(out Value: Integer): HResult; stdcall; + function Set_MaxWidth(Value: Integer): HResult; stdcall; + function Get_MinWidth(out Value: Integer): HResult; stdcall; + function Set_MinWidth(Value: Integer): HResult; stdcall; + function AddValues(Rows: PSafeArray; Columns: PSafeArray; Cells: PSafeArray): HResult; stdcall; + function Get_GapX(out Value: Integer): HResult; stdcall; + function Set_GapX(Value: Integer): HResult; stdcall; + function Get_GapY(out Value: Integer): HResult; stdcall; + function Set_GapY(Value: Integer): HResult; stdcall; + function Get_PlainCells(out Value: WordBool): HResult; stdcall; + function Set_PlainCells(Value: WordBool): HResult; stdcall; + function Get_DownThenAcross(out Value: WordBool): HResult; stdcall; + function Set_DownThenAcross(Value: WordBool): HResult; stdcall; + function Get_RepeatHeaders(out Value: WordBool): HResult; stdcall; + function Set_RepeatHeaders(Value: WordBool): HResult; stdcall; + function Get_ShowColumnHeader(out Value: WordBool): HResult; stdcall; + function Set_ShowColumnHeader(Value: WordBool): HResult; stdcall; + function Get_ShowColumnTotal(out Value: WordBool): HResult; stdcall; + function Set_ShowColumnTotal(Value: WordBool): HResult; stdcall; + function Get_ShowRowHeader(out Value: WordBool): HResult; stdcall; + function Set_ShowRowHeader(Value: WordBool): HResult; stdcall; + function Get_ShowRowTotal(out Value: WordBool): HResult; stdcall; + function Set_ShowRowTotal(Value: WordBool): HResult; stdcall; + function AddValuesVB6(Rows: OleVariant; Columns: OleVariant; Cells: OleVariant): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure BeforePrint; override; + procedure BeforeStartReport; override; + procedure GetData; override; + function ContainerAdd(Obj: TfrxComponent): Boolean; override; + function ContainerMouseDown(Sender: TObject; X, Y: Integer): Boolean; override; + procedure ContainerMouseMove(Sender: TObject; X, Y: Integer); override; + procedure ContainerMouseUp(Sender: TObject; X, Y: Integer); override; + + procedure AddValue(const Rows, Columns, Cells: array of Variant); + procedure ApplyStyle(Style: TfrxStyles); + procedure BeginMatrix; + procedure EndMatrix; + procedure FillMatrix; virtual; + procedure GetStyle(Style: TfrxStyles); + + function ColCount: Integer; + function DrawCross(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended): TfrxPoint; + function GetColumnIndexes(AColumn: Integer): Variant; + function GetRowIndexes(ARow: Integer): Variant; + function GetValue(ARow, AColumn, ACell: Integer): Variant; + function IsCrossValid: Boolean; virtual; + function IsGrandTotalColumn(Index: Integer): Boolean; + function IsGrandTotalRow(Index: Integer): Boolean; + function IsTotalColumn(Index: Integer): Boolean; + function IsTotalRow(Index: Integer): Boolean; + function RowCount: Integer; + function RowHeaderWidth: Extended; + function ColumnHeaderHeight: Extended; + + property ColumnHeader: TfrxCrossColumnHeader read FColumnHeader; + property RowHeader: TfrxCrossRowHeader read FRowHeader; + property Corner: TfrxCrossCorner read FCorner; + property NoColumns: Boolean read FNoColumns; + property NoRows: Boolean read FNoRows; + + property CellFields: TStrings read FCellFields write SetCellFields; + property CellFunctions[Index: Integer]: TfrxCrossFunction read GetCellFunctions + write SetCellFunctions; + property CellMemos[Index: Integer]: TfrxCustomMemoView read GetCellMemos; + property CellHeaderMemos[Index: Integer]: TfrxCustomMemoView read GetCellHeaderMemos; + property ClearBeforePrint: Boolean read FClearBeforePrint write FClearBeforePrint; + property ColumnFields: TStrings read FColumnFields write SetColumnFields; + property ColumnMemos[Index: Integer]: TfrxCustomMemoView read GetColumnMemos; + property ColumnSort[Index: Integer]: TfrxCrossSortOrder read GetColumnSort + write SetColumnSort; + property ColumnTotalMemos[Index: Integer]: TfrxCustomMemoView read GetColumnTotalMemos; + property CornerMemos[Index: Integer]: TfrxCustomMemoView read GetCornerMemos; + property DotMatrix: Boolean read FDotMatrix; + property RowFields: TStrings read FRowFields write SetRowFields; + property RowMemos[Index: Integer]: TfrxCustomMemoView read GetRowMemos; + property RowSort[Index: Integer]: TfrxCrossSortOrder read GetRowSort + write SetRowSort; + property RowTotalMemos[Index: Integer]: TfrxCustomMemoView read GetRowTotalMemos; + property OnBeforeCalcHeight: TfrxOnCalcHeightEvent + read FOnBeforeCalcHeight write FOnBeforeCalcHeight; + property OnBeforeCalcWidth: TfrxOnCalcWidthEvent + read FOnBeforeCalcWidth write FOnBeforeCalcWidth; + property OnBeforePrintCell: TfrxOnPrintCellEvent + read FOnBeforePrintCell write FOnBeforePrintCell; + property OnBeforePrintColumnHeader: TfrxOnPrintHeaderEvent + read FOnBeforePrintColumnHeader write FOnBeforePrintColumnHeader; + property OnBeforePrintRowHeader: TfrxOnPrintHeaderEvent + read FOnBeforePrintRowHeader write FOnBeforePrintRowHeader; + published + property AddHeight: Extended read FAddHeight write FAddHeight; + property AddWidth: Extended read FAddWidth write FAddWidth; + property AllowDuplicates: Boolean read FAllowDuplicates write FAllowDuplicates default True; + property AutoSize: Boolean read FAutoSize write FAutoSize default True; + property Border: Boolean read FBorder write FBorder default True; + property CellLevels: Integer read FCellLevels write SetCellLevels default 1; + property ColumnLevels: Integer read FColumnLevels write SetColumnLevels default 1; + property DefHeight: Integer read FDefHeight write FDefHeight default 0; + property DownThenAcross: Boolean read FDownThenAcross write FDownThenAcross; + property GapX: Integer read FGapX write FGapX default 3; + property GapY: Integer read FGapY write FGapY default 3; + property JoinEqualCells: Boolean read FJoinEqualCells write FJoinEqualCells default False; + property KeepTogether: Boolean read FKeepTogether write FKeepTogether default False; + property MaxWidth: Integer read FMaxWidth write FMaxWidth default 200; + property MinWidth: Integer read FMinWidth write FMinWidth default 0; + property NextCross: TfrxCustomCrossView read FNextCross write FNextCross; + property NextCrossGap: Extended read FNextCrossGap write FNextCrossGap; + property PlainCells: Boolean read FPlainCells write FPlainCells default False; + property RepeatHeaders: Boolean read FRepeatHeaders write FRepeatHeaders default True; + property RowLevels: Integer read FRowLevels write SetRowLevels default 1; + property ShowColumnHeader: Boolean read FShowColumnHeader write FShowColumnHeader default True; + property ShowColumnTotal: Boolean read FShowColumnTotal write FShowColumnTotal default True; + property ShowCorner: Boolean read FShowCorner write FShowCorner default True; + property ShowRowHeader: Boolean read FShowRowHeader write FShowRowHeader default True; + property ShowRowTotal: Boolean read FShowRowTotal write FShowRowTotal default True; + property ShowTitle: Boolean read FShowTitle write FShowTitle default True; + property SuppressNullRecords: Boolean read FSuppressNullRecords write FSuppressNullRecords default True; + property OnCalcHeight: TfrxCalcHeightEvent read FOnCalcHeight write FOnCalcHeight; + property OnCalcWidth: TfrxCalcWidthEvent read FOnCalcWidth write FOnCalcWidth; + property OnPrintCell: TfrxPrintCellEvent read FOnPrintCell write FOnPrintCell; + property OnPrintColumnHeader: TfrxPrintHeaderEvent + read FOnPrintColumnHeader write FOnPrintColumnHeader; + property OnPrintRowHeader: TfrxPrintHeaderEvent + read FOnPrintRowHeader write FOnPrintRowHeader; + end; + +{$IFDEF FR_COM} + TfrxCrossView = class(TfrxCustomCrossView, IfrxCrossView) +{$ELSE} + TfrxCrossView = class(TfrxCustomCrossView) +{$ENDIF} + protected + procedure SetCellLevels(const Value: Integer); override; + procedure SetColumnLevels(const Value: Integer); override; + procedure SetRowLevels(const Value: Integer); override; + public + class function GetDescription: String; override; + function IsCrossValid: Boolean; override; + published + end; + +{$IFDEF FR_COM} + TfrxDBCrossView = class(TfrxCustomCrossView, IfrxDBCrossView) +{$ELSE} + TfrxDBCrossView = class(TfrxCustomCrossView) +{$ENDIF} + private + public + class function GetDescription: String; override; + function IsCrossValid: Boolean; override; + procedure FillMatrix; override; + published + property CellFields; + property ColumnFields; + property DataSet; + property DataSetName; + property RowFields; + end; + + +implementation + +uses +{$IFNDEF NO_EDITORS} + frxCrossEditor, +{$ENDIF} + frxCrossRTTI, frxDsgnIntf, frxXML, frxUtils, frxXMLSerializer, frxRes, + frxDMPClass, frxVariables, frxUnicodeUtils; + +type + THackComponent = class(TfrxComponent); + THackMemoView = class(TfrxCustomMemoView); + + +function CalcSize(m: TfrxCustomMemoView): TfrxPoint; +var + e, SaveHeight: Extended; +begin + SaveHeight := m.Height; + m.Height := 10000; + + Result.X := m.CalcWidth; + Result.Y := m.CalcHeight; + + if m is TfrxDMPMemoView then + begin + Result.X := Result.X + fr1CharX; + Result.Y := Result.Y + fr1CharY; + end; + + if (m.Rotation = 90) or (m.Rotation = 270) then + begin + e := Result.X; + Result.X := Result.Y; + Result.Y := e; + end; + + m.Height := SaveHeight; +end; + + +{ TfrxIndexItem } + +destructor TfrxIndexItem.Destroy; +begin + FIndexes := nil; + inherited; +end; + + +{ TfrxIndexCollection } + +function TfrxIndexCollection.GetItems(Index: Integer): TfrxIndexItem; +begin + Result := TfrxIndexItem(inherited Items[Index]); +end; + +function TfrxIndexCollection.Find(const Indexes: array of Variant; + var Index: Integer): Boolean; +var + i, i0, i1, c: Integer; + Item: TfrxIndexItem; + + function Compare: Integer; + var + i: Integer; + begin + Result := 0; + for i := 0 to FIndexesCount - 1 do + if Item.Indexes[i] = Indexes[i] then + begin + if (VarType(Indexes[i]) = varString) or (VarType(Indexes[i]) = varOleStr) then + if VarToWideStr(Item.Indexes[i]) = VarToWideStr(Indexes[i]) then + Result := 0 + else + begin + Result := -1; + break; + end + else + Result := 0; + end + else if VarIsNull(Indexes[i]) then + begin + if FSortOrder[i] = soAscending then + Result := 1 else + Result := -1; + break; + end + else if VarIsNull(Item.Indexes[i]) then + begin + if FSortOrder[i] = soAscending then + Result := -1 else + Result := 1; + break; + end + else if Item.Indexes[i] > Indexes[i] then + begin + if FSortOrder[i] = soAscending then + Result := 1 else + Result := -1; + break; + end + else if Item.Indexes[i] < Indexes[i] then + begin + if FSortOrder[i] = soAscending then + Result := -1 else + Result := 1; + break; + end; + end; + +begin + Result := False; + + if FSortOrder[0] = soNone then + begin + for i := 0 to Count - 1 do + begin + Item := TfrxIndexItem(Items[i]); + if Compare = 0 then + begin + Result := True; + Index := i; + Exit; + end; + end; + + Index := Count; + Exit; + end; + + { quick find } + i0 := 0; + i1 := Count - 1; + + while i0 <= i1 do + begin + i := (i0 + i1) div 2; + Item := TfrxIndexItem(Items[i]); + c := Compare; + + if c < 0 then + i0 := i + 1 + else + begin + i1 := i - 1; + if c = 0 then + begin + Result := True; + i0 := i; + end; + end; + end; + + Index := i0; +end; + +function TfrxIndexCollection.InsertItem(Index: Integer; + const Indexes: array of Variant): TfrxIndexItem; +var + i: Integer; +begin + if Index < Count then + Result := TfrxIndexItem(Insert(Index)) else + Result := TfrxIndexItem(Add); + SetLength(Result.FIndexes, FIndexesCount); + for i := 0 to FIndexesCount - 1 do + Result.FIndexes[i] := Indexes[i]; +end; + + +{ TfrxCrossRow } + +constructor TfrxCrossRow.Create; +begin + inherited; + FCells := TList.Create; +end; + +destructor TfrxCrossRow.Destroy; +var + i: Integer; + c, c1: PfrCrossCell; +begin + for i := 0 to FCells.Count - 1 do + begin + c := FCells[i]; + while c <> nil do + begin + c1 := c; + c := c.Next; + VarClear(c1.Value); + Dispose(c1); + end; + end; + + FCells.Free; + inherited; +end; + +procedure TfrxCrossRow.CreateCell(Index: Integer); +var + i: Integer; + c, c1: PfrCrossCell; +begin + while Index >= FCells.Count do + begin + c1 := nil; + for i := 0 to FCellLevels - 1 do + begin + New(c); + c.Value := Null; + c.Count := 1; + c.Next := nil; + if c1 <> nil then + c1.Next := c else + FCells.Add(c); + c1 := c; + end; + end; +end; + +function TfrxCrossRow.GetCellValue(Index1, Index2: Integer): Variant; +var + c: PfrCrossCell; +begin + Result := Null; + if (Index1 < 0) or (Index1 >= FCells.Count) then Exit; + + c := FCells[Index1]; + while (c <> nil) and (Index2 > 0) do + begin + c := c.Next; + Dec(Index2); + end; + + if c <> nil then + Result := c.Value; +end; + +procedure TfrxCrossRow.SetCellValue(Index1, Index2: Integer; const Value: Variant); +var + c: PfrCrossCell; +begin + if Index1 < 0 then Exit; + if Index1 >= FCells.Count then + CreateCell(Index1); + + c := FCells[Index1]; + while (c <> nil) and (Index2 > 0) do + begin + c := c.Next; + Dec(Index2); + end; + if c <> nil then + if c.Value = Null then + c.Value := Value else + c.Value := c.Value + Value; +end; + +function TfrxCrossRow.GetCell(Index: Integer): PfrCrossCell; +begin + Result := nil; + if Index < 0 then Exit; + + if Index >= FCells.Count then + CreateCell(Index); + + Result := FCells[Index]; +end; + + +{ TfrxCrossRows } + +constructor TfrxCrossRows.Create; +begin + inherited Create(TfrxCrossRow); +end; + +function TfrxCrossRows.GetItems(Index: Integer): TfrxCrossRow; +begin + Result := TfrxCrossRow(inherited Items[Index]); +end; + +function TfrxCrossRows.InsertItem(Index: Integer; + const Indexes: array of Variant): TfrxIndexItem; +begin + Result := inherited InsertItem(Index, Indexes); + TfrxCrossRow(Result).FCellLevels := FCellLevels; +end; + +function TfrxCrossRows.Row(const Indexes: array of Variant): TfrxCrossRow; +var + i: Integer; +begin + if Find(Indexes, i) then + Result := Items[i] else + Result := TfrxCrossRow(InsertItem(i, Indexes)); +end; + + +{ TfrxCrossColumns } + +constructor TfrxCrossColumns.Create; +begin + inherited Create(TfrxCrossColumn); +end; + +function TfrxCrossColumns.GetItems(Index: Integer): TfrxCrossColumn; +begin + Result := TfrxCrossColumn(inherited Items[Index]); +end; + +function TfrxCrossColumns.Column(const Indexes: array of Variant): TfrxCrossColumn; +var + i: Integer; +begin + if Find(Indexes, i) then + Result := Items[i] else + Result := TfrxCrossColumn(InsertItem(i, Indexes)); +end; + +function TfrxCrossColumns.InsertItem(Index: Integer; + const Indexes: array of Variant): TfrxIndexItem; +begin + Result := inherited InsertItem(Index, Indexes); + TfrxCrossColumn(Result).FCellIndex := Count - 1; +end; + + +{ TfrxCrossHeader } + +constructor TfrxCrossHeader.Create(CellLevels: Integer); +begin + FItems := TList.Create; + FCellLevels := CellLevels; + FValue := Null; + FVisible := True; + + SetLength(FFuncValues, FCellLevels); + SetLength(FCounts, FCellLevels); +end; + +destructor TfrxCrossHeader.Destroy; +begin + FFuncValues := nil; + FCounts := nil; + + while FItems.Count > 0 do + begin + TfrxCrossHeader(FItems[0]).Free; + FItems.Delete(0); + end; + + FItems.Free; + inherited; +end; + +function TfrxCrossHeader.GetItems(Index: Integer): TfrxCrossHeader; +begin + Result := TfrxCrossHeader(FItems[Index]); +end; + +function TfrxCrossHeader.GetCount: Integer; +begin + Result := FItems.Count; +end; + +function TfrxCrossHeader.GetLevel: Integer; +var + h: TfrxCrossHeader; +begin + Result := -2; + h := Self; + + while h <> nil do + begin + h := h.Parent; + Inc(Result); + end; +end; + +function TfrxCrossHeader.Find(Value: Variant): Integer; +var + i: Integer; +begin + { find the cell containing the given value } + Result := -1; + for i := 0 to Count - 1 do + if VarToWideStr(Items[i].Value) = VarToWideStr(Value) then + begin + Result := i; + Exit; + end; +end; + +function TfrxCrossHeader.AddChild(Memo: TfrxCustomMemoView): TfrxCrossHeader; +begin + Result := TfrxCrossHeader(NewInstance); + Result.Create(FCellLevels); + { link it to the parent } + FItems.Add(Result); + Result.FParent := Self; + + Result.FLevelsCount := FLevelsCount; + Result.FMemo := Memo; + Result.FValue := Memo.Text; +end; + +function TfrxCrossHeader.AddCellHeader(Memos: TList; Index, CellIndex: Integer): TfrxCrossHeader; +begin + Result := TfrxCrossHeader(NewInstance); + Result.Create(FCellLevels); + { link it to the parent } + FItems.Add(Result); + Result.FParent := Self; + + Result.FIndex := Index; + Result.FCellIndex := CellIndex; + Result.FLevelsCount := FLevelsCount; + Result.FIsTotal := FIsTotal; + Result.FTotalIndex := FTotalIndex; + Result.FMemo := Memos[FTotalIndex * FCellLevels + CellIndex]; + Result.FValue := Result.FMemo.Text; + Result.FIsCellHeader := True; +end; + +procedure TfrxCrossHeader.AddValues(const Values: array of Variant); +var + i, j: Integer; + Header, Header1: TfrxCrossHeader; + v: Variant; + s: String; +begin + { create the header tree. For example, subsequent calls + AddValues([1998,1]); + AddValues([1998,2]); + AddValues([1999,1]); + will create the header + 1998 | 1999 + --+--+----- + 1 |2 | 1 } + + + Header := Self; + + for i := Low(Values) to High(Values) do + begin + j := Header.Find(Values[i]); + if j <> -1 then + Header := Header.Items[j] { find existing item... } + else + begin + { ...or create new one } + Header1 := TfrxCrossHeader(NewInstance); + Header1.Create(FCellLevels); + Header1.FLevelsCount := FLevelsCount; + { link it to the parent } + Header.FItems.Add(Header1); + Header1.FParent := Header; + + v := Values[i]; + s := VarToStr(v); + { this is subtotal item } + if Pos('@@@', s) = 1 then + begin + { remove @@@ } + s := Copy(s, 4, Length(s) - 5); + v := s; + Header1.FIsTotal := True; + Header1.FMemo := FTotalMemos[i]; + Header1.FTotalIndex := FLevelsCount - i; + end + else + Header1.FMemo := FMemos[i]; + + Header1.FValue := v; + Header := Header1; + + if Header.FIsTotal then break; + end; + end; +end; + +procedure TfrxCrossHeader.Reset(const CellFunctions: array of TfrxCrossFunction); +var + i: Integer; + h: TfrxCrossHeader; +begin + { reset aggregate values for this cell and all its parent cells } + h := Self; + + while h <> nil do + begin + for i := 0 to FCellLevels - 1 do + begin + case CellFunctions[i] of + cfNone, cfMin, cfMax: + h.FFuncValues[i] := Null; + + cfSum, cfAvg, cfCount: + h.FFuncValues[i] := 0; + end; + + h.FCounts[i] := 0; + end; + + h := h.Parent; + end; +end; + +procedure TfrxCrossHeader.AddFuncValues(const Values, Counts: array of Variant; + const CellFunctions: array of TfrxCrossFunction); +var + i: Integer; + h: TfrxCrossHeader; +begin + { add aggregate values for this cell and all its parent cells } + h := Self; + + while h <> nil do + begin + for i := 0 to FCellLevels - 1 do + if Values[i] <> Null then + case CellFunctions[i] of + cfNone:; + + cfSum: + h.FFuncValues[i] := h.FFuncValues[i] + Values[i]; + + cfMin: + if (h.FFuncValues[i] = Null) or (Values[i] < h.FFuncValues[i]) then + h.FFuncValues[i] := Values[i]; + + cfMax: + if (h.FFuncValues[i] = Null) or (Values[i] > h.FFuncValues[i]) then + h.FFuncValues[i] := Values[i]; + + cfAvg: + begin + h.FFuncValues[i] := h.FFuncValues[i] + Values[i]; + h.FCounts[i] := h.FCounts[i] + Counts[i]; + end; + + cfCount: + h.FFuncValues[i] := h.FFuncValues[i] + Values[i];// + Counts[i]; + end; + + h := h.Parent; + end; +end; + +function TfrxCrossHeader.AllItems: TList; + + procedure EnumItems(Item: TfrxCrossHeader); + var + i: Integer; + begin + if Item.Memo <> nil then + Result.Add(Item); + for i := 0 to Item.Count - 1 do + EnumItems(Item[i]); + end; + +begin + { list all items in the header } + Result := TList.Create; + EnumItems(Self); +end; + +function TfrxCrossHeader.TerminalItems: TList; +var + i: Integer; + Item: TfrxCrossHeader; +begin + { list all terminal items in the header } + Result := AllItems; + i := 0; + while i < Result.Count do + begin + Item := Result[i]; + if Item.Count = 0 then + Inc(i) + else + Result.Delete(i); + end; +end; + +function TfrxCrossHeader.IndexItems: TList; +var + i: Integer; + Item: TfrxCrossHeader; +begin + { list all terminal items in the header } + Result := AllItems; + i := 0; + while i < Result.Count do + begin + Item := Result[i]; + if Item.FIsIndex then + Inc(i) + else + Result.Delete(i); + end; +end; + +function TfrxCrossHeader.GetIndexes: Variant; +var + ar: array of Variant; + i, n: Integer; + h, h1: TfrxCrossHeader; +begin + SetLength(ar, FLevelsCount + 1); + n := 0; + h := Parent; + h1 := Self; + while h <> nil do + begin + ar[n] := h.FItems.IndexOf(h1); + Inc(n); + h1 := h; + h := h.Parent; + end; + + Result := VarArrayCreate([0, FLevelsCount - 1], varVariant); + for i := 0 to FLevelsCount - 1 do + if i < n then + Result[i] := ar[n - i - 1] else + Result[i] := Null; + ar := nil; +end; + +function TfrxCrossHeader.GetValues: Variant; +var + ar: array of Variant; + i, n: Integer; + h: TfrxCrossHeader; +begin + SetLength(ar, FLevelsCount + 1); + n := 0; + h := Self; + while h.Parent <> nil do + begin + ar[n] := h.Value; + Inc(n); + h := h.Parent; + end; + + Result := VarArrayCreate([0, FLevelsCount - 1], varVariant); + for i := 0 to FLevelsCount - 1 do + if i < n then + Result[i] := ar[n - i - 1] else + Result[i] := Null; + ar := nil; +end; + +function TfrxCrossHeader.GetHeight: Extended; +var + Items: TList; +begin + Items := TerminalItems; + + if (Items.Count > 0) and FVisible then + Result := TfrxCrossHeader(Items[Items.Count - 1]).Bounds.Top + + TfrxCrossHeader(Items[Items.Count - 1]).Bounds.Bottom + else + Result := 0; + + Items.Free; +end; + +function TfrxCrossHeader.GetWidth: Extended; +var + Items: TList; +begin + Items := TerminalItems; + + if (Items.Count > 0) and FVisible then + Result := TfrxCrossHeader(Items[Items.Count - 1]).Bounds.Left + + TfrxCrossHeader(Items[Items.Count - 1]).Bounds.Right + else + Result := 0; + + Items.Free; +end; + + +{ TfrxCrossColumnHeader } + +procedure TfrxCrossColumnHeader.CalcBounds; +var + i, j, l: Integer; + h: Extended; + Items: TList; + Item: TfrxCrossHeader; + LevelHeights: array of Extended; + + function DoAdjust(Item: TfrxCrossHeader): Extended; + var + i: Integer; + Width: Extended; + begin + if Item.Count = 0 then + begin + Result := Item.FSize.X; + Exit; + end; + + Width := 0; + for i := 0 to Item.Count - 1 do + Width := Width + DoAdjust(Item[i]); + + if Item.FSize.X < Width then + Item.FSize.X := Width + else + begin + Item[Item.Count - 1].FSize.X := Item[Item.Count - 1].FSize.X + Item.FSize.X - Width; + DoAdjust(Item[Item.Count - 1]); + end; + + Result := Item.FSize.X; + end; + + procedure FillBounds(Item: TfrxCrossHeader; Offset: TfrxPoint); + var + i, j, l: Integer; + h: Extended; + begin + l := Item.Level; + if l <> -1 then + h := LevelHeights[l] else + h := Item.FSize.Y; + + if Item.FIsCellHeader then + h := LevelHeights[FLevelsCount] + else if Item.IsTotal then + for j := l + 1 to FLevelsCount - 1 do + h := h + LevelHeights[j]; + + Item.FBounds := frxRect(Offset.X, Offset.Y, Item.FSize.X, h); + Offset.Y := Offset.Y + h; + + for i := 0 to Item.Count - 1 do + begin + FillBounds(Item[i], Offset); + Offset.X := Offset.X + Item[i].FSize.X; + end; + end; + +begin + DoAdjust(Self); + + SetLength(LevelHeights, FLevelsCount + 1); + + Items := AllItems; + +// calculate height of each row + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + l := Item.Level; + + // cell headers always adjust the last level height + if Item.FIsCellHeader then + l := FLevelsCount + // don't count total elemens unless they are on last level. + // such elements will be adjusted later + else if Item.IsTotal then + if l <> FLevelsCount - 1 then continue; + + if l >= 0 then + if Item.FSize.Y > LevelHeights[l] then + LevelHeights[l] := Item.FSize.Y; + end; + + if FNoLevels then + LevelHeights[0] := 0; + +// adjust level height - count totals that not on the last level + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + l := Item.Level; + + if Item.IsTotal and (l < FLevelsCount - 1) then + begin + h := 0; + for j := l to FLevelsCount - 1 do + h := h + LevelHeights[j]; + + if Item.FSize.Y > h then + LevelHeights[FLevelsCount - 1] := LevelHeights[FLevelsCount - 1] + Item.FSize.Y - h; + end; + end; + + { syncronize height of CornerMemos[0] and [1] } + if FCorner <> nil then + begin + if not FMemo.Visible then + FSize.Y := 0; + if not FCorner.FMemo.Visible then + FCorner.FSize.Y := 0; + h := FSize.Y; + if FCorner.FSize.Y > h then + h := FCorner.FSize.Y; + FSize.Y := h; + if not FNoLevels then + FCorner.FSize.Y := h; + end; + + FillBounds(Self, frxPoint(0, 0)); + + { update height of CornerMemos[2..n] } + if FCorner <> nil then + begin + h := 0; + l := FLevelsCount - 1; + if HasCellHeaders then + Inc(l); + for i := 0 to l do + h := h + LevelHeights[i]; + if FNoLevels then + h := h + FSize.Y; + for i := 0 to FCorner.Count - 1 do + FCorner[i].FSize.Y := h; + end; + + Items.Free; + LevelHeights := nil; +end; + +procedure TfrxCrossColumnHeader.CalcSizes(MaxWidth, MinWidth: Integer; AutoSize: Boolean); +var + i: Integer; + Items: TList; + Item: TfrxCrossHeader; + s: String; + m: TfrxCustomMemoView; +begin + Items := AllItems; + + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + m := Item.FMemo; + if m <> nil then + begin + if AutoSize or (m.Width = 0) or (m.Height = 0) then + begin + m.Width := MaxWidth; + s := m.Text; + m.Text := m.FormatData(Item.Value); + if m.Lines.Count = 0 then + m.Text := ' '; + Item.FSize := CalcSize(m); + m.Text := s; + end + else + begin + if Item.Count = 0 then + Item.FSize.X := m.Width; + if not Item.IsTotal then + Item.FSize.Y := m.Height; + end; + + if Item.FSize.X < MinWidth then + Item.FSize.X := MinWidth; + if Item.FSize.X > MaxWidth then + Item.FSize.X := MaxWidth; + end; + end; + + Items.Free; +end; + + +{ TfrxCrossRowHeader } + +procedure TfrxCrossRowHeader.CalcBounds; +var + i, j, l: Integer; + w: Extended; + Items: TList; + Item: TfrxCrossHeader; + LevelWidths: array of Extended; + + function DoAdjust(Item: TfrxCrossHeader): Extended; + var + i: Integer; + Height: Extended; + begin + if Item.Count = 0 then + begin + Result := Item.FSize.Y; + Exit; + end; + + Height := 0; + for i := 0 to Item.Count - 1 do + Height := Height + DoAdjust(Item[i]); + + if Item.FSize.Y < Height then + Item.FSize.Y := Height + else + begin + Item[Item.Count - 1].FSize.Y := Item[Item.Count - 1].FSize.Y + Item.FSize.Y - Height; + DoAdjust(Item[Item.Count - 1]); + end; + + Result := Item.FSize.Y; + end; + + procedure FillBounds(Item: TfrxCrossHeader; Offset: TfrxPoint); + var + i, j, l: Integer; + w: Extended; + begin + l := Item.Level; + if l <> -1 then + w := LevelWidths[l] else + w := Item.FSize.X; + + if Item.FIsCellHeader then + w := LevelWidths[FLevelsCount] + else if Item.IsTotal then + for j := l + 1 to FLevelsCount - 1 do + w := w + LevelWidths[j]; + + Item.FBounds := frxRect(Offset.X, Offset.Y, w, Item.FSize.Y); + Offset.X := Offset.X + w; + + for i := 0 to Item.Count - 1 do + begin + FillBounds(Item[i], Offset); + Offset.Y := Offset.Y + Item[i].FSize.Y; + end; + end; + +begin + DoAdjust(Self); + + SetLength(LevelWidths, FLevelsCount + 1); + + Items := AllItems; + +// calculate maxwidth of each row + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + l := Item.Level; + + // cell headers always adjust the last level width + if Item.FIsCellHeader then + l := FLevelsCount + // don't count total elemens unless they are on last level. + // such elements will be adjusted later + else if Item.IsTotal then + if l <> FLevelsCount - 1 then continue; + + if l >= 0 then + if Item.FSize.X > LevelWidths[l] then + LevelWidths[l] := Item.FSize.X; + end; + +// adjust totals + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + l := Item.Level; + + if Item.IsTotal and (l < FLevelsCount - 1) then + begin + w := 0; + for j := l to FLevelsCount - 1 do + w := w + LevelWidths[j]; + + if Item.FSize.X > w then + LevelWidths[FLevelsCount - 1] := LevelWidths[FLevelsCount - 1] + Item.FSize.X - w; + end; + end; + +// adjust corner + for i := 0 to FCorner.Count - 1 do + if FCorner[i].FSize.X > LevelWidths[i] then + LevelWidths[i] := FCorner[i].FSize.X + else + FCorner[i].FSize.X := LevelWidths[i]; + + FillBounds(Self, frxPoint(0, 0)); + + Items.Free; + LevelWidths := nil; +end; + +procedure TfrxCrossRowHeader.CalcSizes(MaxWidth, MinWidth: Integer; AutoSize: Boolean); +var + i: Integer; + Items: TList; + Item: TfrxCrossHeader; + s: String; + m: TfrxCustomMemoView; +begin + Items := AllItems; + + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + m := Item.FMemo; + if m <> nil then + begin + if AutoSize or (m.Width = 0) or (m.Height = 0) then + begin + m.Width := MaxWidth; + s := m.Text; + m.Text := m.FormatData(Item.Value); + if m.Lines.Count = 0 then + m.Text := ' '; + Item.FSize := CalcSize(m); + m.Text := s; + end + else + begin + if Item.Count = 0 then + Item.FSize.Y := m.Height; + if not Item.IsTotal then + Item.FSize.X := m.Width; + end; + + if Item.FSize.X < MinWidth then + Item.FSize.X := MinWidth; + if Item.FSize.X > MaxWidth then + Item.FSize.X := MaxWidth; + end; + end; + + Items.Free; +end; + + +{ TfrxCutBandItem } + +destructor TfrxCutBandItem.Destroy; +begin + Band.Free; + inherited; +end; + + +{ TfrxCutBands } + +constructor TfrxCutBands.Create; +begin + inherited Create(TfrxCutBandItem); +end; + +procedure TfrxCutBands.Add(ABand: TfrxBand; AFromIndex, AToIndex: Integer); +begin + with TfrxCutBandItem(inherited Add) do + begin + Band := ABand; + FromIndex := AFromIndex; + ToIndex := AToIndex; + end; +end; + +function TfrxCutBands.GetItems(Index: Integer): TfrxCutBandItem; +begin + Result := TfrxCutBandItem(inherited Items[Index]); +end; + + +{ TfrxGridLineItem } + +constructor TfrxGridLineItem.Create(Collection: TCollection); +begin + inherited; + Objects := TList.Create; +end; + +destructor TfrxGridLineItem.Destroy; +begin + Objects.Free; + inherited; +end; + + +{ TfrxGridLines } + +constructor TfrxGridLines.Create; +begin + inherited Create(TfrxGridLineItem); +end; + +procedure TfrxGridLines.Add(AObj: TObject; ACoord: Extended); +var + i: Integer; + Item: TfrxGridLineItem; +begin + Item := nil; + for i := 0 to Count - 1 do + if Abs(Items[i].Coord - ACoord) < 1 then + begin + Item := Items[i]; + break; + end; + + if Item = nil then + Item := TfrxGridLineItem(inherited Add); + + Item.Coord := ACoord; + Item.Objects.Add(AObj); +end; + +function TfrxGridLines.GetItems(Index: Integer): TfrxGridLineItem; +begin + Result := TfrxGridLineItem(inherited Items[Index]); +end; + + +{ TfrxCustomCrossView } + +constructor TfrxCustomCrossView.Create(AOwner: TComponent); +var + i: Integer; +begin + inherited; + Frame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + Color := clWhite; + frComponentStyle := frComponentStyle - [csPreviewVisible] + [csContainer]; + + FAllMemos := TList.Create; + FCellMemos := TList.Create; + FCellHeaderMemos := TList.Create; + FColumnMemos := TList.Create; + FColumnTotalMemos := TList.Create; + FCornerMemos := TList.Create; + FRowMemos := TList.Create; + FRowTotalMemos := TList.Create; + + FCellFields := TStringList.Create; + FColumnFields := TStringList.Create; + FRowFields := TStringList.Create; + FColumnBands := TfrxCutBands.Create; + FRowBands := TfrxCutBands.Create; + + FGridX := TfrxGridLines.Create; + FGridY := TfrxGridLines.Create; + + FAutoSize := True; + FBorder := True; + FGapX := 3; + FGapY := 3; + FMaxWidth := 200; + FRepeatHeaders := True; + FShowColumnHeader := True; + FShowColumnTotal := True; + FShowRowHeader := True; + FShowRowTotal := True; + FShowCorner := True; + FShowTitle := True; + FAllowDuplicates := True; + FClearBeforePrint := True; + FSuppressNullRecords := True; + + SetDotMatrix(Page is TfrxDMPPage); + CreateCornerMemos(3); + CellLevels := 1; + ColumnLevels := 1; + RowLevels := 1; + + for i := 0 to 31 do + begin + FCellFunctions[i] := cfSum; + FColumnSort[i] := soAscending; + FRowSort[i] := soAscending; + end; +end; + +destructor TfrxCustomCrossView.Destroy; +begin + ClearMemos; + FAllMemos.Free; + FCellMemos.Free; + FCellHeaderMemos.Free; + FColumnMemos.Free; + FColumnTotalMemos.Free; + FCornerMemos.Free; + FRowMemos.Free; + FRowTotalMemos.Free; + + FCellFields.Free; + FColumnFields.Free; + FRowFields.Free; + + FColumnBands.Free; + FRowBands.Free; + FGridX.Free; + FGridY.Free; + + ClearMatrix; + inherited; +end; + +function TfrxCustomCrossView.GetCellFunctions(Index: Integer): TfrxCrossFunction; +begin + Result := FCellFunctions[Index]; +end; + +function TfrxCustomCrossView.GetCellMemos(Index: Integer): TfrxCustomMemoView; +begin + Result := FCellMemos[Index]; +end; + +function TfrxCustomCrossView.GetCellHeaderMemos(Index: Integer): TfrxCustomMemoView; +begin + Result := FCellHeaderMemos[Index]; +end; + +function TfrxCustomCrossView.GetColumnMemos(Index: Integer): TfrxCustomMemoView; +begin + Result := FColumnMemos[Index]; +end; + +function TfrxCustomCrossView.GetColumnTotalMemos(Index: Integer): TfrxCustomMemoView; +begin + Result := FColumnTotalMemos[Index]; +end; + +function TfrxCustomCrossView.GetCornerMemos(Index: Integer): TfrxCustomMemoView; +begin + Result := FCornerMemos[Index]; +end; + +function TfrxCustomCrossView.GetRowMemos(Index: Integer): TfrxCustomMemoView; +begin + Result := FRowMemos[Index]; +end; + +function TfrxCustomCrossView.GetRowTotalMemos(Index: Integer): TfrxCustomMemoView; +begin + Result := FRowTotalMemos[Index]; +end; + +function TfrxCustomCrossView.GetColumnSort(Index: Integer): TfrxCrossSortOrder; +begin + Result := FColumnSort[Index]; +end; + +function TfrxCustomCrossView.GetRowSort(Index: Integer): TfrxCrossSortOrder; +begin + Result := FRowSort[Index]; +end; + +procedure TfrxCustomCrossView.SetCellFunctions(Index: Integer; + const Value: TfrxCrossFunction); +begin + FCellFunctions[Index] := Value; +end; + +procedure TfrxCustomCrossView.SetColumnSort(Index: Integer; Value: TfrxCrossSortOrder); +begin + FColumnSort[Index] := Value; +end; + +procedure TfrxCustomCrossView.SetRowSort(Index: Integer; Value: TfrxCrossSortOrder); +begin + FRowSort[Index] := Value; +end; + +function TfrxCustomCrossView.ColCount: Integer; +begin + Result := FColumns.Count; +end; + +function TfrxCustomCrossView.RowCount: Integer; +begin + Result := FRows.Count; +end; + +function TfrxCustomCrossView.IsGrandTotalColumn(Index: Integer): Boolean; +begin + Result := Index = FColumns.Count - 1; +end; + +function TfrxCustomCrossView.IsGrandTotalRow(Index: Integer): Boolean; +begin + Result := Index = FRows.Count - 1; +end; + +function TfrxCustomCrossView.IsTotalColumn(Index: Integer): Boolean; +var + i: Integer; +begin + Result := False; + + for i := 0 to FColumns.FIndexesCount - 1 do + if VarToStr(FColumns[Index].Indexes[i]) = '@@@' then + Result := True; +end; + +function TfrxCustomCrossView.IsTotalRow(Index: Integer): Boolean; +var + i: Integer; +begin + Result := False; + + for i := 0 to FRows.FIndexesCount - 1 do + if VarToStr(FRows[Index].Indexes[i]) = '@@@' then + Result := True; +end; + +function TfrxCustomCrossView.GetColumnIndexes(AColumn: Integer): Variant; +begin + Result := FColumns[AColumn].Indexes; +end; + +function TfrxCustomCrossView.GetRowIndexes(ARow: Integer): Variant; +begin + Result := FRows[ARow].Indexes; +end; + +procedure TfrxCustomCrossView.SetCellFields(const Value: TStrings); +begin + FCellFields.Assign(Value); +end; + +procedure TfrxCustomCrossView.SetColumnFields(const Value: TStrings); +begin + FColumnFields.Assign(Value); +end; + +procedure TfrxCustomCrossView.SetRowFields(const Value: TStrings); +begin + FRowFields.Assign(Value); +end; + +procedure TfrxCustomCrossView.SetCellLevels(const Value: Integer); +var + max: Integer; +begin + FCellLevels := Value; + CreateCellMemos(FCellLevels * (FRowLevels + 1) * (FColumnLevels + 1)); + max := FRowLevels; + if FColumnLevels > max then + max := FColumnLevels; + CreateCellHeaderMemos(FCellLevels * (max + 1)); +end; + +procedure TfrxCustomCrossView.SetColumnLevels(const Value: Integer); +var + max, lvl: Integer; +begin + FColumnLevels := Value; + lvl := FColumnLevels; + if lvl = 0 then + lvl := 1; + CreateColumnMemos(lvl); + CreateCellMemos(FCellLevels * (FRowLevels + 1) * (FColumnLevels + 1)); + max := FRowLevels; + if FColumnLevels > max then + max := FColumnLevels; + CreateCellHeaderMemos(FCellLevels * (max + 1)); +end; + +procedure TfrxCustomCrossView.SetRowLevels(const Value: Integer); +var + max, lvl: Integer; +begin + FRowLevels := Value; + lvl := FRowLevels; + if lvl = 0 then + lvl := 1; + CreateRowMemos(lvl); + CreateCornerMemos(FRowLevels + 3); + CreateCellMemos(FCellLevels * (FRowLevels + 1) * (FColumnLevels + 1)); + max := FRowLevels; + if FColumnLevels > max then + max := FColumnLevels; + CreateCellHeaderMemos(FCellLevels * (max + 1)); +end; + +procedure TfrxCustomCrossView.SetDotMatrix(const Value: Boolean); +begin + FDotMatrix := Value; + if FDotMatrix then + begin + FGapX := 0; + FGapY := 0; + end; +end; + +function TfrxCustomCrossView.IsCrossValid: Boolean; +begin + Result := True; +end; + +function TfrxCustomCrossView.ColumnHeaderHeight: Extended; +begin + Result := ColumnHeader.Height; +end; + +function TfrxCustomCrossView.RowHeaderWidth: Extended; +begin + Result := RowHeader.Width; + if FNoRows then + Result := 0; +end; + +procedure TfrxCustomCrossView.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FNextCross) then + FNextCross := nil; +end; + +procedure TfrxCustomCrossView.DefineProperties(Filer: TFiler); +begin + inherited; + Filer.DefineBinaryProperty('Memos', ReadMemos, WriteMemos, True); +end; + +procedure TfrxCustomCrossView.ReadMemos(Stream: TStream); +var + x: TfrxXMLDocument; + i: Integer; + + procedure GetItem(m: TfrxCustomMemoView; const Name: String; Index: Integer); + var + xs: TfrxXMLSerializer; + Item: TfrxXMLItem; + begin + Item := x.Root.FindItem(Name); + if Index >= Item.Count then Exit; + Item := Item[Index]; + + xs := TfrxXMLSerializer.Create(nil); + m.Color := clNone; + m.Frame.Color := clBlack; + m.Frame.Width := 1; + m.Frame.Typ := []; + m.Font.Style := []; + m.HAlign := haLeft; + m.VAlign := vaTop; + xs.ReadRootComponent(m, Item); + xs.Free; + end; + + function GetItem1(const Name: String; Index: Integer): TfrxCrossFunction; + var + Item: TfrxXMLItem; + begin + Result := cfNone; + Item := x.Root.FindItem(Name); + if Index >= Item.Count then Exit; + Item := Item[Index]; + Result := TfrxCrossFunction(StrToInt(Item.Text)); + end; + + function GetItem2(const Name: String; Index: Integer): TfrxCrossSortOrder; + var + Item: TfrxXMLItem; + begin + Result := soAscending; + Item := x.Root.FindItem(Name); + if Index >= Item.Count then Exit; + Item := Item[Index]; + Result := TfrxCrossSortOrder(StrToInt(Item.Text)); + end; + +begin + x := TfrxXMLDocument.Create; + try + x.LoadFromStream(Stream); + + for i := 0 to FCellLevels - 1 do + CellFunctions[i] := GetItem1('cellfunctions', i); + + for i := 0 to FCellHeaderMemos.Count - 1 do + GetItem(CellHeaderMemos[i], 'cellheadermemos', i); + + for i := 0 to FCellMemos.Count - 1 do + GetItem(CellMemos[i], 'cellmemos', i); + + for i := 0 to FColumnMemos.Count - 1 do + begin + GetItem(ColumnMemos[i], 'columnmemos', i); + GetItem(ColumnTotalMemos[i], 'columntotalmemos', i); + ColumnSort[i] := GetItem2('columnsort', i); + end; + + for i := 0 to FRowMemos.Count - 1 do + begin + GetItem(RowMemos[i], 'rowmemos', i); + GetItem(RowTotalMemos[i], 'rowtotalmemos', i); + RowSort[i] := GetItem2('rowsort', i); + end; + + for i := 0 to FCornerMemos.Count - 1 do + GetItem(CornerMemos[i], 'cornermemos', i); + + finally + x.Free; + end; +end; + +procedure TfrxCustomCrossView.WriteMemos(Stream: TStream); +var + x: TfrxXMLDocument; + i: Integer; + + procedure AddItem(m: TfrxCustomMemoView; const Name: String); + var + xs: TfrxXMLSerializer; + begin + xs := TfrxXMLSerializer.Create(nil); + xs.WriteRootComponent(m, True, x.Root.FindItem(Name).Add); + xs.Free; + end; + + procedure AddItem1(f: TfrxCrossFunction; const Name: String); + var + Item: TfrxXMLItem; + begin + Item := x.Root.FindItem(Name); + Item := Item.Add; + Item.Name := 'item'; + Item.Text := IntToStr(Integer(f)); + end; + + procedure AddItem2(f: TfrxCrossSortOrder; const Name: String); + var + Item: TfrxXMLItem; + begin + Item := x.Root.FindItem(Name); + Item := Item.Add; + Item.Name := 'item'; + Item.Text := IntToStr(Integer(f)); + end; + +begin + x := TfrxXMLDocument.Create; + x.Root.Name := 'cross'; + + try + x.Root.Add.Name := 'cellmemos'; + x.Root.Add.Name := 'cellheadermemos'; + x.Root.Add.Name := 'columnmemos'; + x.Root.Add.Name := 'columntotalmemos'; + x.Root.Add.Name := 'cornermemos'; + x.Root.Add.Name := 'rowmemos'; + x.Root.Add.Name := 'rowtotalmemos'; + x.Root.Add.Name := 'cellfunctions'; + x.Root.Add.Name := 'columnsort'; + x.Root.Add.Name := 'rowsort'; + + for i := 0 to FCellLevels - 1 do + AddItem1(CellFunctions[i], 'cellfunctions'); + + for i := 0 to FCellHeaderMemos.Count - 1 do + AddItem(CellHeaderMemos[i], 'cellheadermemos'); + + for i := 0 to FCellMemos.Count - 1 do + AddItem(CellMemos[i], 'cellmemos'); + + for i := 0 to FColumnMemos.Count - 1 {FColumnLevels - 1} do + begin + AddItem(ColumnMemos[i], 'columnmemos'); + AddItem(ColumnTotalMemos[i], 'columntotalmemos'); + AddItem2(ColumnSort[i], 'columnsort'); + end; + + for i := 0 to FRowMemos.Count - 1 {FRowLevels - 1} do + begin + AddItem(RowMemos[i], 'rowmemos'); + AddItem(RowTotalMemos[i], 'rowtotalmemos'); + AddItem2(RowSort[i], 'rowsort'); + end; + + for i := 0 to FCornerMemos.Count - 1 do + AddItem(CornerMemos[i], 'cornermemos'); + + x.SaveToStream(Stream); + finally + x.Free; + end; +end; + +procedure TfrxCustomCrossView.CreateCellHeaderMemos(NewCount: Integer); +var + i: Integer; + m: TfrxCustomMemoView; +begin + for i := FCellHeaderMemos.Count to NewCount - 1 do + begin + m := CreateMemo(nil); + FCellHeaderMemos.Add(m); + m.Restrictions := [rfDontDelete]; + m.VAlign := vaCenter; + m.Frame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + end; +end; + +procedure TfrxCustomCrossView.CreateCellMemos(NewCount: Integer); +var + i: Integer; + m: TfrxCustomMemoView; +begin + for i := FCellMemos.Count to NewCount - 1 do + begin + m := CreateMemo(nil); + FCellMemos.Add(m); + m.Restrictions := [rfDontDelete]; + m.HAlign := haRight; + m.VAlign := vaCenter; + m.Frame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + end; +end; + +procedure TfrxCustomCrossView.CreateColumnMemos(NewCount: Integer); +var + i: Integer; + m: TfrxCustomMemoView; +begin + for i := FColumnMemos.Count to NewCount - 1 do + begin + m := CreateMemo(nil); + FColumnMemos.Add(m); + m.Restrictions := [rfDontDelete, rfDontEdit]; + m.HAlign := haCenter; + m.VAlign := vaCenter; + m.Frame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + + m := CreateMemo(nil); + FColumnTotalMemos.Add(m); + m.Restrictions := [rfDontDelete]; + if i = 0 then + m.Text := 'Grand Total' + else + m.Text := 'Total'; + m.Font.Style := [fsBold]; + m.HAlign := haCenter; + m.VAlign := vaCenter; + m.Frame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + end; +end; + +procedure TfrxCustomCrossView.CreateRowMemos(NewCount: Integer); +var + i: Integer; + m: TfrxCustomMemoView; +begin + for i := FRowMemos.Count to NewCount - 1 do + begin + m := CreateMemo(nil); + FRowMemos.Add(m); + m.Restrictions := [rfDontDelete, rfDontEdit]; + m.HAlign := haCenter; + m.VAlign := vaCenter; + m.Frame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + + m := CreateMemo(nil); + FRowTotalMemos.Add(m); + m.Restrictions := [rfDontDelete]; + if i = 0 then + m.Text := 'Grand Total' + else + m.Text := 'Total'; + m.Font.Style := [fsBold]; + m.HAlign := haCenter; + m.VAlign := vaCenter; + m.Frame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + end; +end; + +procedure TfrxCustomCrossView.CreateCornerMemos(NewCount: Integer); +var + i: Integer; + m: TfrxCustomMemoView; +begin + for i := FCornerMemos.Count to NewCount - 1 do + begin + m := CreateMemo(nil); + FCornerMemos.Add(m); + m.Restrictions := [rfDontDelete]; + m.HAlign := haCenter; + m.VAlign := vaCenter; + m.Frame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + end; +end; + +procedure TfrxCustomCrossView.ClearMemos; +begin + while FCellHeaderMemos.Count > 0 do + begin + CellHeaderMemos[0].Free; + FCellHeaderMemos.Delete(0); + end; + while FCellMemos.Count > 0 do + begin + CellMemos[0].Free; + FCellMemos.Delete(0); + end; + while FColumnMemos.Count > 0 do + begin + ColumnMemos[0].Free; + FColumnMemos.Delete(0); + ColumnTotalMemos[0].Free; + FColumnTotalMemos.Delete(0); + end; + while FRowMemos.Count > 0 do + begin + RowMemos[0].Free; + FRowMemos.Delete(0); + RowTotalMemos[0].Free; + FRowTotalMemos.Delete(0); + end; + while FCornerMemos.Count > 0 do + begin + CornerMemos[0].Free; + FCornerMemos.Delete(0); + end; +end; + +procedure TfrxCustomCrossView.InitMatrix; +var + ColL, RowL: Integer; +begin + ClearMatrix; + + RowL := FRowLevels; + FNoRows := FRowLevels = 0; + if FNoRows then + RowL := 1; + ColL := FColumnLevels; + FNoColumns := FColumnLevels = 0; + if FNoColumns then + ColL := 1; + + FRows := TfrxCrossRows.Create; + FRows.FIndexesCount := RowL; + FRows.FSortOrder := FRowSort; + FRows.FCellLevels := FCellLevels; + + FColumns := TfrxCrossColumns.Create; + FColumns.FIndexesCount := ColL; + FColumns.FSortOrder := FColumnSort; + + FCorner := TfrxCrossCorner.Create(1); + FCorner.FMemo := CornerMemos[0]; + FCorner.Value := CornerMemos[0].Text; + FCorner.FLevelsCount := 1; + + FRowHeader := TfrxCrossRowHeader.Create(FCellLevels); + FRowHeader.FMemos := FRowMemos; + FRowHeader.FTotalMemos := FRowTotalMemos; + FRowHeader.FLevelsCount := RowL; + FRowHeader.HasCellHeaders := (FCellLevels > 1) and not FPlainCells; + FRowHeader.FCorner := FCorner; + FRowHeader.FNoLevels := FNoRows; + + FColumnHeader := TfrxCrossColumnHeader.Create(FCellLevels); + FColumnHeader.FMemos := FColumnMemos; + FColumnHeader.FTotalMemos := FColumnTotalMemos; + FColumnHeader.FMemo := CornerMemos[1]; + FColumnHeader.Value := CornerMemos[1].Text; + FColumnHeader.FLevelsCount := ColL; + FColumnHeader.HasCellHeaders := (FCellLevels > 1) and FPlainCells; + FColumnHeader.FCorner := FCorner; + FColumnHeader.FNoLevels := FNoColumns; +end; + +function TfrxCustomCrossView.GetNestedObjects: TList; +var + i: Integer; + NestedObjects: TList; + + procedure DoNested(Memo: TfrxCustomMemoView); + var + i: Integer; + c: TfrxComponent; + begin + for i := 0 to Memo.Objects.Count - 1 do + begin + c := Memo.Objects[i]; + NestedObjects.Add(c); + end; + end; + +begin + NestedObjects := TList.Create; + + for i := 0 to FCellHeaderMemos.Count - 1 do + DoNested(CellHeaderMemos[i]); + + for i := 0 to FCellMemos.Count - 1 do + DoNested(CellMemos[i]); + + for i := 0 to FColumnMemos.Count - 1 do + begin + DoNested(ColumnMemos[i]); + DoNested(ColumnTotalMemos[i]); + end; + + for i := 0 to FRowMemos.Count - 1 do + begin + DoNested(RowMemos[i]); + DoNested(RowTotalMemos[i]); + end; + + for i := 0 to FCornerMemos.Count - 1 do + DoNested(CornerMemos[i]); + + Result := NestedObjects; +end; + +procedure TfrxCustomCrossView.InitMemos(AddToScript: Boolean); +var + i: Integer; + m: TfrxCustomMemoView; + NestedObjects: TList; +begin + for i := 0 to FCellHeaderMemos.Count - 1 do + begin + m := CellHeaderMemos[i]; + m.GapX := FGapX; + m.GapY := FGapY; + m.AllowExpressions := False; + m.Name := Name + 'CellHeader' + IntToStr(i); + if AddToScript then + Report.Script.AddObject(m.Name, m); + end; + + for i := 0 to FCellMemos.Count - 1 do + begin + m := CellMemos[i]; + m.GapX := FGapX; + m.GapY := FGapY; + m.AllowExpressions := False; + m.Name := Name + 'Cell' + IntToStr(i); + if AddToScript then + Report.Script.AddObject(m.Name, m); + end; + + for i := 0 to FColumnMemos.Count - 1 do + begin + m := ColumnMemos[i]; + m.GapX := FGapX; + m.GapY := FGapY; + m.AllowExpressions := False; + m.Name := Name + 'Column' + IntToStr(i); + if AddToScript then + Report.Script.AddObject(m.Name, m); + + m := ColumnTotalMemos[i]; + m.GapX := FGapX; + m.GapY := FGapY; + m.AllowExpressions := False; + m.Name := Name + 'ColumnTotal' + IntToStr(i); + if AddToScript then + Report.Script.AddObject(m.Name, m); + end; + + for i := 0 to FRowMemos.Count - 1 do + begin + m := RowMemos[i]; + m.GapX := FGapX; + m.GapY := FGapY; + m.AllowExpressions := False; + m.Name := Name + 'Row' + IntToStr(i); + if AddToScript then + Report.Script.AddObject(m.Name, m); + + m := RowTotalMemos[i]; + m.GapX := FGapX; + m.GapY := FGapY; + m.AllowExpressions := False; + m.Name := Name + 'RowTotal' + IntToStr(i); + if AddToScript then + Report.Script.AddObject(m.Name, m); + end; + + for i := 0 to FCornerMemos.Count - 1 do + begin + m := CornerMemos[i]; + m.GapX := FGapX; + m.GapY := FGapY; + m.AllowExpressions := False; + m.Name := Name + 'Corner' + IntToStr(i); + if AddToScript then + Report.Script.AddObject(m.Name, m); + end; + + NestedObjects := GetNestedObjects; + + for i := 0 to NestedObjects.Count - 1 do + begin + m := NestedObjects[i]; + m.Name := Name + 'Object' + IntToStr(m.Tag); + if AddToScript then + Report.Script.AddObject(m.Name, m); + end; + + NestedObjects.Free; +end; + +procedure TfrxCustomCrossView.ClearMatrix; +begin + FRows.Free; + FRows := nil; + FColumns.Free; + FColumns := nil; + FCorner.Free; + FCorner := nil; + FRowHeader.Free; + FRowHeader := nil; + FColumnHeader.Free; + FColumnHeader := nil; +end; + +procedure TfrxCustomCrossView.AddValue(const Rows, Columns, Cells: array of Variant); +var + i: Integer; + Row: TfrxCrossRow; + Column: TfrxCrossColumn; + Cell: PfrCrossCell; + Value, v: Variant; + isNull: Boolean; +begin + if not IsCrossValid then + raise Exception.Create('Cross-tab is not valid'); + if FRows = nil then Exit; + + { check for all nulls } + isNull := True; + for i := Low(Rows) to High(Rows) do + if not VarIsNull(Rows[i]) then + isNull := False; + if isNull then + begin + for i := Low(Columns) to High(Columns) do + if not VarIsNull(Columns[i]) then + isNull := False; + if isNull then + begin + for i := Low(Cells) to High(Cells) do + if not VarIsNull(Cells[i]) then + isNull := False; + end; + end; + + if isNull and FSuppressNullRecords then Exit; + + if FNoColumns then + Column := FColumns.Column([Null]) else + Column := FColumns.Column(Columns); + if FNoRows then + Row := FRows.Row([Null]) else + Row := FRows.Row(Rows); + + Cell := Row.GetCell(Column.CellIndex); + + for i := 0 to FCellLevels - 1 do + begin + Value := Cell.Value; + v := Cells[i]; + + if FCellFunctions[i] = cfCount then + begin + if v = Null then + v := 0 + else + v := 1; + end; + + if Value = Null then + Cell.Value := v + else if (TVarData(Value).VType = varString) or (TVarData(Value).VType = varOleStr) then + begin + if FAllowDuplicates or + (Pos(#13#10 + v + #13#10, #13#10 + Cell.Value + #13#10) = 0) then + Cell.Value := Value + #13#10 + v + end + else + Cell.Value := Value + v; + + Cell := Cell.Next; + end; +end; + +function TfrxCustomCrossView.GetValue(ARow, AColumn, ACell: Integer): Variant; +var + Row: TfrxCrossRow; + Column: TfrxCrossColumn; + Cell: PfrCrossCell; +begin + Result := Null; + Column := FColumns[AColumn]; + Row := FRows[ARow]; + Cell := Row.GetCell(Column.CellIndex); + + while (Cell <> nil) and (ACell > 0) do + begin + Cell := Cell.Next; + Dec(ACell); + end; + + if Cell <> nil then + Result := Cell.Value; +end; + +procedure TfrxCustomCrossView.CreateHeader(Header: TfrxCrossHeader; + Source: TfrxIndexCollection; Totals: TList; TotalVisible: Boolean); +var + i, j, IndexesCount: Integer; + LastValues, CurValues: TfrxVariantArray; + + function ExpandVariable(s: String; const Value: Variant): String; + var + i: Integer; + begin + { expand the [Value] macro if any (eg. if total memo contains + the text: 'Total of [Value]' } + i := Pos('[VALUE]', AnsiUppercase(s)); + if i <> 0 then + begin + Delete(s, i, 7); + Insert(VarToStr(Value), s, i); + end; + Result := s; + end; + + procedure AddTotals; + var + j, k: Integer; + begin + for j := 0 to IndexesCount - 1 do + { if value changed... } + if LastValues[j] <> CurValues[j] then + begin + { ...create subtotals for all down-level values } + for k := IndexesCount - 1 downto j + 1 do + if TfrxCustomMemoView(Totals[k]).Visible then + begin + { '@@@' means that this is subtotal cell } + LastValues[k] := '@@@' + + ExpandVariable(TfrxCustomMemoView(Totals[k]).Text, LastValues[k - 1]); + { create header cells... } + Header.AddValues(LastValues); + LastValues[k] := '@@@'; + { ...and row/column item } + Source.InsertItem(i, LastValues); + Inc(i); + end; + break; + end; + end; + +begin + if Source.Count = 0 then Exit; + IndexesCount := Source.FIndexesCount; + { copy first indexes to lastvalues } + LastValues := Copy(Source.Items[0].Indexes, 0, IndexesCount); + i := 0; + + while i < Source.Count do + begin + { copy current indexes to curvalues } + CurValues := Copy(Source.Items[i].Indexes, 0, IndexesCount); + { if lastvalues <> curvalues, make a subtotal item } + AddTotals; + { add header cells } + Header.AddValues(CurValues); + + LastValues := CurValues; + Inc(i); + end; + + { create last subtotal item } + CurValues := Copy(Source.Items[0].Indexes, 0, IndexesCount); + for j := 0 to IndexesCount - 1 do + CurValues[j] := Null; + AddTotals; + + { create grand total } + if TotalVisible and TfrxCustomMemoView(Totals[0]).Visible then + begin + LastValues[0] := '@@@' + TfrxCustomMemoView(Totals[0]).Text; + Header.AddValues(LastValues); + LastValues[0] := '@@@'; + Source.InsertItem(i, LastValues); + end; +end; + +procedure TfrxCustomCrossView.CreateHeaders; +var + i: Integer; +begin + CreateHeader(FColumnHeader, FColumns, FColumnTotalMemos, not FNoColumns); + CreateHeader(FRowHeader, FRows, FRowTotalMemos, not FNoRows); + + { add corner elements } + for i := 0 to FRowLevels - 1 do + FCorner.AddChild(FCornerMemos[3 + i]); + if FRowHeader.HasCellHeaders then + FCorner.AddChild(FCornerMemos[2]); +end; + +procedure TfrxCustomCrossView.CalcTotal(Header: TfrxCrossHeader; + Source: TfrxIndexCollection); +var + i, j: Integer; + Items: TList; + Values, Counts: TfrxVariantArray; + Item: TfrxCrossHeader; + p: PfrCrossCell; + FinalPass: Boolean; + + procedure CellToArrays(p: PfrCrossCell); + var + i: Integer; + begin + for i := 0 to FCellLevels - 1 do + begin + Values[i] := p.Value; + Counts[i] := p.Count; + + if (FCellFunctions[i] = cfAvg) and FinalPass and (p.Count <> 0) then + p.Value := p.Value / p.Count; + + p := p.Next; + end; + end; + + procedure ArraysToCell(p: PfrCrossCell); + var + i: Integer; + begin + for i := 0 to FCellLevels - 1 do + begin + p.Value := Item.FFuncValues[i]; + p.Count := Item.FCounts[i]; + + if (FCellFunctions[i] = cfAvg) and FinalPass then + if p.Count <> 0 then + p.Value := p.Value / p.Count else + p.Value := 0; + + if (FCellFunctions[i] = cfCount) and not FinalPass then + p.Count := p.Value; + + p := p.Next; + end; + end; + +begin + Items := Header.TerminalItems; + SetLength(Values, FCellLevels); + SetLength(Counts, FCellLevels); + FinalPass := Source = FColumns; + + { scan the matrix } + for i := 0 to Source.Count - 1 do + begin + for j := 0 to Items.Count - 1 do + TfrxCrossHeader(Items[j]).Reset(FCellFunctions); + + for j := 0 to Items.Count - 1 do + begin + Item := Items[j]; + if Source = FRows then + p := FRows[i].GetCell(FColumns[j].CellIndex) else + p := FRows[j].GetCell(FColumns[i].CellIndex); + + if not Item.IsTotal then + begin + { convert cell values to Values and Counts arrays } + CellToArrays(p); + { accumulate values in the header items } + Item.AddFuncValues(Values, Counts, FCellFunctions); + end + else + begin + { get the accumulated values from the item's parent } + Item := Item.Parent; + { and convert it to the cell } + ArraysToCell(p); + end; + end; + end; + + Items.Free; + Values := nil; + Counts := nil; +end; + +procedure TfrxCustomCrossView.CalcTotals; +begin + { scan the matrix from left to right, then from top to bottom } + CalcTotal(FColumnHeader, FRows); + { final pass, scan the matrix from top to bottom, then from left to right } + CalcTotal(FRowHeader, FColumns); +end; + +procedure TfrxCustomCrossView.CalcBounds; +var + i, j, k: Integer; + ColumnItems, RowItems: TList; + ColumnItem, RowItem: TfrxCrossHeader; + Cell: PfrCrossCell; + m: TfrxCustomMemoView; + NewHeight: Extended; + Size: TfrxPoint; + + procedure DoCalc(const Value: Variant); + var + i, r: Integer; + s: String; + Width, NewWidth: Extended; + WidthChanged: Boolean; + begin + s := m.Text; + m.Text := m.FormatData(Value, CellMemos[k].DisplayFormat); + r := m.Rotation; + m.Rotation := 0; + + Width := FMaxWidth; + NewWidth := Width; + DoCalcWidth(j, NewWidth); + m.Width := NewWidth; + WidthChanged := NewWidth <> Width; + + Size := CalcSize(m); + Size.X := Size.X + FAddWidth; + Size.Y := Size.Y + FAddHeight; + if Size.X > FMaxWidth then + Size.X := FMaxWidth; + if Size.X < FMinWidth then + Size.X := FMinWidth; + if WidthChanged then + begin + Size.X := NewWidth; + ColumnItem.FSize.X := Size.X; + for i := 0 to ColumnItem.Count - 1 do + ColumnItem[i].FSize.X := NewWidth; + end; + if FDefHeight <> 0 then + Size.Y := FDefHeight; + if NewWidth = 0 then + Size.Y := 0; + + m.Rotation := r; + m.Text := s; + end; + +begin + ColumnItems := FColumnHeader.TerminalItems; + RowItems := FRowHeader.TerminalItems; + + { create cell headers } + if FCellLevels > 1 then + if FPlainCells then + begin + for i := 0 to ColumnItems.Count - 1 do + begin + ColumnItem := ColumnItems[i]; + for j := 0 to FCellLevels - 1 do + ColumnItem.AddCellHeader(FCellHeaderMemos, i, j); + end; + end + else + begin + for i := 0 to RowItems.Count - 1 do + begin + RowItem := RowItems[i]; + for j := 0 to FCellLevels - 1 do + RowItem.AddCellHeader(FCellHeaderMemos, i, j); + end; + end; + + { calculate the widths of columns and the heights of rows } + FColumnHeader.CalcSizes(FMaxWidth, FMinWidth, FAutoSize); + FRowHeader.CalcSizes(FMaxWidth, FMinWidth, FAutoSize); + FCorner.CalcSizes(FMaxWidth, FMinWidth, FAutoSize); + + { scanning the matrix cells and update calculated widths and heights } + for i := 0 to RowItems.Count - 1 do + begin + RowItem := RowItems[i]; + RowItem.FIsIndex := True; + RowItem.FIndex := i; + + for j := 0 to ColumnItems.Count - 1 do + begin + ColumnItem := ColumnItems[j]; + ColumnItem.FIsIndex := True; + ColumnItem.FIndex := j; + if not FAutoSize then continue; + + Cell := FRows[i].GetCell(FColumns[j].CellIndex); + + for k := 0 to FCellLevels - 1 do + begin + m := CellMemos[ColumnItem.FTotalIndex * ((FRowLevels + 1) * FCellLevels) + + RowItem.FTotalIndex * FCellLevels + k]; + + DoCalc(Cell.Value); + + if FCellLevels > 1 then + if FPlainCells then + begin + if ColumnItem[k].FSize.X < Size.X then + ColumnItem[k].FSize.X := Size.X; + if RowItem.FSize.Y < Size.Y then + RowItem.FSize.Y := Size.Y; + end + else + begin + if RowItem[k].FSize.Y < Size.Y then + RowItem[k].FSize.Y := Size.Y; + if ColumnItem.FSize.X < Size.X then + ColumnItem.FSize.X := Size.X; + end + else + begin + if RowItem.FSize.Y < Size.Y then + RowItem.FSize.Y := Size.Y; + if ColumnItem.FSize.X < Size.X then + ColumnItem.FSize.X := Size.X; + end; + + Cell := Cell.Next; + end; + end; + + NewHeight := RowItem.FSize.Y; + DoCalcHeight(i, NewHeight); + RowItem.FSize.Y := NewHeight; + end; + + { calculate the positions and sizes of the header cells } + FCorner.CalcBounds; + FColumnHeader.CalcBounds; + FRowHeader.CalcBounds; + { recalc corner again - it may be adjusted in rowheader } + FCorner.CalcBounds; + + ColumnItems.Free; + RowItems.Free; +end; + +function TfrxCustomCrossView.CreateMemo(Parent: TfrxComponent): TfrxCustomMemoView; +begin + if FDotMatrix then + Result := TfrxDMPMemoView.Create(Parent) + else + Result := TfrxMemoView.Create(Parent); +end; + +procedure TfrxCustomCrossView.CorrectDMPBounds(Memo: TfrxCustomMemoView); +begin + if Memo is TfrxDMPMemoView then + begin + Memo.Left := Memo.Left + fr1CharX; + Memo.Top := Memo.Top + fr1CharY; + Memo.Width := Memo.Width - fr1CharX; + Memo.Height := Memo.Height - fr1CharY; + end; +end; + +function TfrxCustomCrossView.GetContainerObjects: TList; +begin + Result := FAllMemos; +end; + +function TfrxCustomCrossView.ContainerAdd(Obj: TfrxComponent): Boolean; +var + i, j, n: Integer; + c: TfrxComponent; + Offset: TfrxPoint; + NestedObjects: TList; + Found: Boolean; +begin + Result := False; + if (Obj is TfrxCustomCrossView) or (Obj is TfrxSubreport) then Exit; + + Offset := frxPoint(20, 20); + if FDotMatrix then + Offset := frxPoint(fr1CharX * 2, fr1CharY); + { call DrawCross to calc visible memos and their bounds } + DrawCross(nil, FScaleX, FScaleY, AbsLeft + Offset.X, AbsTop + Offset.Y); + + { find parent memo for added object } + for i := 0 to FAllMemos.Count - 1 do + begin + c := FAllMemos[i]; + if (Obj.Left >= c.Left) and (Obj.Top >= c.Top) and + (Obj.Left <= c.Left + c.Width) and + (Obj.Top <= c.Top + c.Height) then + begin + Obj.Left := Obj.Left - c.Left; + Obj.Top := Obj.Top - c.Top; + Obj.Owner.RemoveComponent(Obj); + Obj.Parent := c; + + { create unique tag for it - it will be used for name creation } + NestedObjects := GetNestedObjects; + n := 0; + while True do + begin + Inc(n); + Found := False; + for j := 0 to NestedObjects.Count - 1 do + if TfrxComponent(NestedObjects[j]).Tag = n then + begin + Found := True; + break; + end; + if not Found then + begin + Obj.Tag := n; + Obj.Name := Name + 'Object' + IntToStr(n); + break; + end; + end; + + NestedObjects.Free; + Result := True; + break; + end; + end; +end; + +function TfrxCustomCrossView.ContainerMouseDown(Sender: TObject; X, Y: Integer): Boolean; +var + i, j: Integer; + c: TfrxComponent; + Offset: TfrxPoint; +begin + Offset := frxPoint(20, 20); + if FDotMatrix then + Offset := frxPoint(fr1CharX * 2, fr1CharY); + DrawCross(nil, FScaleX, FScaleY, AbsLeft + Offset.X, AbsTop + Offset.Y); + FGridUsed := nil; + FFirstMousePos := Point(X, Y); + FLastMousePos := Point(X, Y); + Result := False; + + for i := 0 to FGridX.Count - 1 do + for j := 0 to FGridX[i].Objects.Count - 1 do + begin + c := FGridX[i].Objects[j]; + if (Abs(c.AbsLeft + c.Width - X / FScaleX) < 2) and + (Y / FScaleY >= c.AbsTop) and (Y / FScaleY <= c.AbsTop + c.Height) then + begin + FGridUsed := FGridX; + FMovingObjects := i; + Result := True; + break; + end; + end; + + for i := 0 to FGridY.Count - 1 do + for j := 0 to FGridY[i].Objects.Count - 1 do + begin + c := FGridY[i].Objects[j]; + if (Abs(c.AbsTop + c.Height - Y / FScaleY) < 2) and + (X / FScaleX >= c.AbsLeft) and (X / FScaleX <= c.AbsLeft + c.Width) then + begin + FGridUsed := FGridY; + FMovingObjects := i; + Result := True; + break; + end; + end; + + FMouseDown := Result; +end; + +procedure TfrxCustomCrossView.ContainerMouseMove(Sender: TObject; X, Y: Integer); +var + i, j: Integer; + c: TfrxComponent; + Offset: TfrxPoint; +begin + if (FScaleX = 0) or (FScaleY = 0) then Exit; + + if not FMouseDown then + begin + Offset := frxPoint(20, 20); + if FDotMatrix then + Offset := frxPoint(fr1CharX * 2, fr1CharY); + DrawCross(nil, FScaleX, FScaleY, AbsLeft + Offset.X, AbsTop + Offset.Y); + + for i := 0 to FGridX.Count - 1 do + for j := 0 to FGridX[i].Objects.Count - 1 do + begin + c := FGridX[i].Objects[j]; + if (Abs(c.AbsLeft + c.Width - X / FScaleX) < 2) and + (Y / FScaleY >= c.AbsTop) and (Y / FScaleY <= c.AbsTop + c.Height) then + begin + TWinControl(Sender).Cursor := crHSplit; + break; + end; + end; + + for i := 0 to FGridY.Count - 1 do + for j := 0 to FGridY[i].Objects.Count - 1 do + begin + c := FGridY[i].Objects[j]; + if (Abs(c.AbsTop + c.Height - Y / FScaleY) < 2) and + (X / FScaleX >= c.AbsLeft) and (X / FScaleX <= c.AbsLeft + c.Width) then + begin + TWinControl(Sender).Cursor := crVSplit; + break; + end; + end; + end + else + begin + if FGridUsed = FGridX then + begin + for i := 0 to FGridX[FMovingObjects].Objects.Count - 1 do + begin + c := FGridX[FMovingObjects].Objects[i]; + c.Width := c.Width + (X - FLastMousePos.X); + end; + end + else if FGridUsed = FGridY then + begin + for i := 0 to FGridY[FMovingObjects].Objects.Count - 1 do + begin + c := FGridY[FMovingObjects].Objects[i]; + c.Height := c.Height + (Y - FLastMousePos.Y); + end; + end; + FLastMousePos := Point(X, Y); + end; +end; + +procedure TfrxCustomCrossView.ContainerMouseUp(Sender: TObject; X, Y: Integer); +begin + FMouseDown := False; + if FAutoSize and ((Abs(X - FFirstMousePos.X) > 5) or (Abs(Y - FFirstMousePos.Y) > 5)) then + frxInfoMsg(frxResources.Get('crResize')); +end; + +function TfrxCustomCrossView.DrawCross(Canvas: TCanvas; ScaleX, ScaleY, + OffsetX, OffsetY: Extended): TfrxPoint; + + procedure FillMatrix; + var + i: Integer; + RowValues, ColumnValues, CellValues: array of Variant; + begin + BeginMatrix; + InitMemos(False); + SetLength(RowValues, RowLevels); + SetLength(ColumnValues, ColumnLevels); + SetLength(CellValues, CellLevels); + + for i := 0 to RowLevels - 1 do + RowValues[i] := '[' + RowFields[i] + ']'; + for i := 0 to ColumnLevels - 1 do + ColumnValues[i] := '[' + ColumnFields[i] + ']'; + for i := 0 to CellLevels - 1 do + CellValues[i] := 0; + AddValue(RowValues, ColumnValues, CellValues); + + RowValues := nil; + ColumnValues := nil; + CellValues := nil; + EndMatrix; + end; + + procedure DrawLine(x, y, dx, dy: Extended); + begin + Canvas.MoveTo(Round(x * ScaleX), Round(y * ScaleY)); + Canvas.LineTo(Round((x + dx) * ScaleX), Round((y + dy) * ScaleY)); + end; + + procedure DrawScriptSign(c: TfrxReportComponent); + begin + if (Canvas <> nil) and (c.OnBeforePrint <> '') then + with c, Canvas do + begin + Pen.Style := psSolid; + Pen.Color := clRed; + Pen.Width := 1; + DrawLine(AbsLeft + 2, AbsTop + 1, 0, 7); + DrawLine(AbsLeft + 3, AbsTop + 2, 0, 5); + DrawLine(AbsLeft + 4, AbsTop + 3, 0, 3); + DrawLine(AbsLeft + 5, AbsTop + 4, 0, 1); + end; + end; + + procedure DrawObj(Obj: TfrxReportComponent; Child: Boolean = False); + var + i: Integer; + begin + { don't let a child move outside parent } + if Child then + begin + if Obj.Left < 0 then + Obj.Left := 0; + if Obj.Left + Obj.Width > Obj.Parent.Width then + Obj.Left := Obj.Parent.Width - Obj.Width; + if Obj.Top < 0 then + Obj.Top := 0; + if Obj.Top + Obj.Height > Obj.Parent.Height then + Obj.Top := Obj.Parent.Height - Obj.Height; + end; + + if Canvas <> nil then + Obj.Draw(Canvas, ScaleX, ScaleY, 0, 0); + DrawScriptSign(Obj); + if not Child then + begin + FGridX.Add(Obj, Obj.AbsLeft + Obj.Width); + FGridY.Add(Obj, Obj.AbsTop + Obj.Height); + end; + FAllMemos.Add(Obj); + for i := 0 to Obj.Objects.Count - 1 do + DrawObj(Obj.Objects[i], True); + end; + + procedure DrawHeader(Header: TfrxCrossHeader; p: TfrxPoint); + var + i: Integer; + Items: TList; + Item: TfrxCrossHeader; + r: TfrxRect; + m: TfrxCustomMemoView; + SaveWidth, SaveHeight: Extended; // for dot-matrix + s: String; + begin + Items := Header.AllItems; + + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + m := Item.Memo; + r := Item.Bounds; + + s := m.Text; + m.Text := VarToStr(Item.Value); + m.SetBounds(r.Left + p.X, r.Top + p.Y, r.Right, r.Bottom); + SaveWidth := m.Width; + SaveHeight := m.Height; + CorrectDMPBounds(m); + if m.Left + m.Width > Result.X then + Result.X := m.Left + m.Width; + if m.Top + m.Height > Result.Y then + Result.Y := m.Top + m.Height; + + if m.Visible then + DrawObj(m); + + m.Text := s; + if m is TfrxDMPMemoView then + TfrxDMPMemoView(m).SetBoundsDirect(m.Left - fr1CharX / 2, + m.Top - fr1CharY / 2, SaveWidth, SaveHeight); + end; + + Items.Free; + end; + + procedure DrawCell(p: TfrxPoint); + var + i, j, CellIndex: Integer; + Cell: Variant; + ColumnItems, RowItems: TList; + ColumnItem, RowItem: TfrxCrossHeader; + m: TfrxCustomMemoView; + SaveWidth, SaveHeight: Extended; // for dot-matrix + begin + ColumnItems := ColumnHeader.TerminalItems; + RowItems := RowHeader.TerminalItems; + + for i := 0 to RowItems.Count - 1 do + begin + RowItem := RowItems[i]; + for j := 0 to ColumnItems.Count - 1 do + begin + ColumnItem := ColumnItems[j]; + + if FCellLevels > 1 then + if FPlainCells then + begin + CellIndex := ColumnItem.FCellIndex; + Cell := GetValue(i, ColumnItem.FIndex, CellIndex); + end + else + begin + CellIndex := RowItem.FCellIndex; + Cell := GetValue(RowItem.FIndex, j, CellIndex); + end + else + begin + CellIndex := 0; + Cell := GetValue(i, j, 0); + end; + + m := CellMemos[ColumnItem.FTotalIndex * ((FRowLevels + 1) * FCellLevels) + + RowItem.FTotalIndex * FCellLevels + CellIndex]; + m.Visible := True; + m.Restrictions := [rfDontDelete, rfDontEdit]; + m.Text := m.FormatData(Cell, CellMemos[CellIndex].DisplayFormat); + m.SetBounds(ColumnItem.Bounds.Left, RowItem.Bounds.Top, + ColumnItem.Bounds.Right, RowItem.Bounds.Bottom); + m.Left := m.Left + p.X; + m.Top := m.Top + p.Y; + SaveWidth := m.Width; + SaveHeight := m.Height; + CorrectDMPBounds(m); + if m.Left + m.Width > Result.X then + Result.X := m.Left + m.Width; + if m.Top + m.Height > Result.Y then + Result.Y := m.Top + m.Height; + + DrawObj(m); + if m is TfrxDMPMemoView then + TfrxDMPMemoView(m).SetBoundsDirect(m.Left - fr1CharX / 2, + m.Top - fr1CharY / 2, SaveWidth, SaveHeight); + end; + end; + + ColumnItems.Free; + RowItems.Free; + end; + +begin + Result := frxPoint(0, 0); + FGridX.Clear; + FGridY.Clear; + FAllMemos.Clear; + + if IsCrossValid then + begin + FillMatrix; + if Corner.Visible then + DrawHeader(Corner, frxPoint(OffsetX, OffsetY)); + if ColumnHeader.Visible then + DrawHeader(ColumnHeader, frxPoint(OffsetX + RowHeaderWidth, OffsetY)); + if RowHeader.Visible then + DrawHeader(RowHeader, frxPoint(OffsetX, OffsetY + ColumnHeaderHeight)); + DrawCell(frxPoint(OffsetX + RowHeaderWidth, OffsetY + ColumnHeaderHeight)); + end; + + Result.X := Result.X - OffsetX; + Result.Y := Result.Y - OffsetY; +end; + +procedure TfrxCustomCrossView.Draw(Canvas: TCanvas; ScaleX, ScaleY, + OffsetX, OffsetY: Extended); +var + img: Integer; + size, Offset: TfrxPoint; +begin + size := DrawCross(nil, ScaleX, ScaleY, AbsLeft, AbsTop); + if (size.X > 0) and (size.Y > 0) then + begin + Width := size.X + 40; + Height := size.Y + 40; + end; + + Color := clWhite; + Frame.Style := fsDot; + inherited; + + Offset := frxPoint(20, 20); + if FDotMatrix then + Offset := frxPoint(fr1CharX * 2, fr1CharY); + DrawCross(Canvas, ScaleX, ScaleY, AbsLeft + Offset.X, AbsTop + Offset.Y); + if Self is TfrxDBCrossView then + img := 49 + else + img := 42; + frxResources.ObjectImages.Draw(Canvas, FX + 2, FY + 2, img); +end; + +procedure TfrxCustomCrossView.ApplyStyle(Style: TfrxStyles); +var + i: Integer; + s: String; +begin + for i := 0 to FCellHeaderMemos.Count - 1 do + CellHeaderMemos[i].ApplyStyle(Style.Find('cellheader')); + + for i := 0 to FCellMemos.Count - 1 do + CellMemos[i].ApplyStyle(Style.Find('cell')); + + for i := 0 to FColumnMemos.Count - 1 do + begin + ColumnMemos[i].ApplyStyle(Style.Find('column')); + if i = 0 then + s := 'colgrand' + else + s := 'coltotal'; + ColumnTotalMemos[i].ApplyStyle(Style.Find(s)); + end; + + for i := 0 to FRowMemos.Count - 1 do + begin + RowMemos[i].ApplyStyle(Style.Find('row')); + if i = 0 then + s := 'rowgrand' + else + s := 'rowtotal'; + RowTotalMemos[i].ApplyStyle(Style.Find(s)); + end; + + for i := 0 to FCornerMemos.Count - 1 do + CornerMemos[i].ApplyStyle(Style.Find('corner')); +end; + +procedure TfrxCustomCrossView.GetStyle(Style: TfrxStyles); + + procedure DoStyle(m: TfrxCustomMemoView; const s: String); + var + stItem: TfrxStyleItem; + begin + stItem := Style.Find(s); + if stItem = nil then + stItem := Style.Add; + stItem.Name := s; + stItem.Color := m.Color; + stItem.Font := m.Font; + stItem.Frame := m.Frame; + end; + +begin + if FCellHeaderMemos.Count > 0 then + DoStyle(CellHeaderMemos[0], 'cellheader'); + + if FCellMemos.Count > 0 then + DoStyle(CellMemos[0], 'cell'); + + if FColumnMemos.Count > 0 then + begin + DoStyle(ColumnMemos[0], 'column'); + DoStyle(ColumnTotalMemos[0], 'colgrand'); + if FColumnTotalMemos.Count > 1 then + DoStyle(ColumnTotalMemos[1], 'coltotal'); + end; + + if FRowMemos.Count > 0 then + begin + DoStyle(RowMemos[0], 'row'); + DoStyle(RowTotalMemos[0], 'rowgrand'); + if FRowTotalMemos.Count > 1 then + DoStyle(RowTotalMemos[1], 'rowtotal'); + end; + + if FCornerMemos.Count > 0 then + DoStyle(CornerMemos[0], 'corner'); +end; + +procedure TfrxCustomCrossView.UpdateVisibility; +begin + Corner.Visible := FShowCorner and not FNoRows + and FShowColumnHeader and FShowRowHeader; + CornerMemos[0].Visible := Corner.Visible and not FNoColumns; + CornerMemos[2].Visible := Corner.Visible and (FCellLevels > 1) and not FPlainCells; + + ColumnHeader.Visible := FShowColumnHeader; + if FColumnTotalMemos.Count > 0 then + ColumnTotalMemos[0].Visible := FShowColumnTotal and not FNoColumns; + CornerMemos[1].Visible := FShowTitle and ColumnHeader.Visible; + ColumnMemos[0].Visible := ColumnHeader.Visible and not FNoColumns; + + RowHeader.Visible := not FNoRows and FShowRowHeader; + if FRowTotalMemos.Count > 0 then + RowTotalMemos[0].Visible := FShowRowTotal and not FNoRows; +end; + +procedure TfrxCustomCrossView.BeginMatrix; +begin + InitMatrix; + UpdateVisibility; +end; + +procedure TfrxCustomCrossView.EndMatrix; +begin + CreateHeaders; + CalcTotals; + CalcBounds(FAddWidth, FAddHeight); +end; + +procedure TfrxCustomCrossView.FillMatrix; +begin +end; + +procedure TfrxCustomCrossView.DoCalcHeight(Row: Integer; var Height: Extended); +var + v: Variant; +begin + if FOnCalcHeight <> '' then + begin + v := VarArrayOf([Row, GetRowIndexes(Row), Height]); + if Report <> nil then + Report.DoParamEvent(FOnCalcHeight, v); + Height := v[2]; + end; + if Assigned(FOnBeforeCalcHeight) then + FOnBeforeCalcHeight(Row, GetRowIndexes(Row), Height); +end; + +procedure TfrxCustomCrossView.DoCalcWidth(Column: Integer; var Width: Extended); +var + v: Variant; +begin + if FOnCalcWidth <> '' then + begin + v := VarArrayOf([Column, GetColumnIndexes(Column), Width]); + if Report <> nil then + Report.DoParamEvent(FOnCalcWidth, v); + Width := v[2]; + end; + if Assigned(FOnBeforeCalcWidth) then + FOnBeforeCalcWidth(Column, GetColumnIndexes(Column), Width); +end; + +procedure TfrxCustomCrossView.DoOnCell(Memo: TfrxCustomMemoView; + Row, Column, Cell: Integer; const Value: Variant); +var + v: Variant; +begin + if FOnPrintCell <> '' then + begin + v := VarArrayOf([Integer(Memo), Row, Column, Cell, GetRowIndexes(Row), + GetColumnIndexes(Column), Value]); + if Report <> nil then + Report.DoParamEvent(FOnPrintCell, v); + end; + if Assigned(FOnBeforePrintCell) then + FOnBeforePrintCell(Memo, Row, Column, Cell, GetRowIndexes(Row), + GetColumnIndexes(Column), Value); +end; + +procedure TfrxCustomCrossView.DoOnColumnHeader(Memo: TfrxCustomMemoView; + Header: TfrxCrossHeader); +var + v: Variant; +begin + if FOnPrintColumnHeader <> '' then + begin + v := VarArrayOf([Integer(Memo), Header.GetIndexes, Header.GetValues, Header.Value]); + if Report <> nil then + Report.DoParamEvent(FOnPrintColumnHeader, v); + end; + if Assigned(FOnBeforePrintColumnHeader) then + FOnBeforePrintColumnHeader(Memo, Header.GetIndexes, Header.GetValues, Header.Value); +end; + +procedure TfrxCustomCrossView.DoOnRowHeader(Memo: TfrxCustomMemoView; + Header: TfrxCrossHeader); +var + v: Variant; +begin + if FOnPrintRowHeader <> '' then + begin + v := VarArrayOf([Integer(Memo), Header.GetIndexes, Header.GetValues, Header.Value]); + if Report <> nil then + Report.DoParamEvent(FOnPrintRowHeader, v); + end; + if Assigned(FOnBeforePrintRowHeader) then + FOnBeforePrintRowHeader(Memo, Header.GetIndexes, Header.GetValues, Header.Value); +end; + +procedure TfrxCustomCrossView.BeforeStartReport; +begin + inherited; + InitMemos(True); +end; + +procedure TfrxCustomCrossView.BeforePrint; +begin + inherited; + if FClearBeforePrint then + BeginMatrix; +end; + +procedure TfrxCustomCrossView.GetData; +begin + inherited; + Report.SetProgressMessage(frxResources.Get('crFillMx')); + if IsCrossValid then + FillMatrix; + Report.SetProgressMessage(frxResources.Get('crBuildMx')); + EndMatrix; + RenderMatrix; +end; + +procedure TfrxCustomCrossView.RenderMatrix; +var + i, j, Page, SavePage: Integer; + CurY, SaveCurY, AddWidth, MaxX: Extended; + Band: TfrxBand; + ColumnItems: TList; + RowItems: TList; + VarRowIndex, VarColumnIndex: TfrxVariable; + + function GetCellBand(RowIndex, ColumnIndex: Integer): TfrxBand; + var + i, iFrom, iTo, j: Integer; + Cell: Variant; + CellIndex: Integer; + ColumnItem, RowItem: TfrxCrossHeader; + m, Memo: TfrxCustomMemoView; + LeftMargin, TopMargin: Extended; + SameMemos: array[0..31] of TfrxCustomMemoView; + c, c1: TfrxReportComponent; + begin + RowItem := RowItems[RowIndex]; + + Result := TfrxNullBand.Create(Report); + Result.Height := RowItem.Bounds.Bottom; + + iFrom := FColumnBands[ColumnIndex].FromIndex; + iTo := FColumnBands[ColumnIndex].ToIndex; + LeftMargin := TfrxCrossHeader(ColumnItems[iFrom]).Bounds.Left; + TopMargin := RowItem.Bounds.Top; + + for i := 0 to CellLevels - 1 do + SameMemos[i] := nil; + + for i := iFrom to iTo do + begin + ColumnItem := ColumnItems[i]; + + if FCellLevels > 1 then + if FPlainCells then + begin + CellIndex := ColumnItem.FCellIndex; + Cell := GetValue(RowIndex, ColumnItem.FIndex, CellIndex); + end + else + begin + CellIndex := RowItem.FCellIndex; + Cell := GetValue(RowItem.FIndex, i, CellIndex); + end + else + begin + CellIndex := 0; + Cell := GetValue(RowIndex, i, 0); + end; + + m := CellMemos[ColumnItem.FTotalIndex * ((FRowLevels + 1) * FCellLevels) + + RowItem.FTotalIndex * FCellLevels + CellIndex]; + Memo := CreateMemo(Result); + Memo.Assign(m); + SetupOriginalComponent(Memo, m); + if Cell <> Null then + THackMemoView(Memo).Value := Cell + else + THackMemoView(Memo).Value := 0; + + Memo.Text := Memo.FormatData(Cell, CellMemos[CellIndex].DisplayFormat); + Memo.Rotation := 0; + Memo.SetBounds(ColumnItem.Bounds.Left - LeftMargin + AddWidth, + RowItem.Bounds.Top - TopMargin, + ColumnItem.Bounds.Right, + RowItem.Bounds.Bottom); + CorrectDMPBounds(Memo); + if Memo.AbsLeft + Memo.Width > MaxX then + MaxX := Memo.AbsLeft + Memo.Width; + Memo.Visible := (Memo.Width <> 0) and (Memo.Height <> 0); + DoOnCell(Memo, RowItem.FIndex, ColumnItem.FIndex, CellIndex, Cell); + + if FBorder then + begin + if FPlainCells then + begin + if RowIndex = 0 then + Memo.Frame.Typ := Memo.Frame.Typ + [ftTop]; + if (i = 0) and (CellIndex = 0) then + Memo.Frame.Typ := Memo.Frame.Typ + [ftLeft]; + if (i = ColumnItems.Count - 1) and (CellIndex = CellLevels - 1) then + Memo.Frame.Typ := Memo.Frame.Typ + [ftRight]; + if RowIndex = RowItems.Count - 1 then + Memo.Frame.Typ := Memo.Frame.Typ + [ftBottom]; + end + else + begin + if (RowIndex = 0) and (CellIndex = 0) then + Memo.Frame.Typ := Memo.Frame.Typ + [ftTop]; + if i = 0 then + Memo.Frame.Typ := Memo.Frame.Typ + [ftLeft]; + if i = ColumnItems.Count - 1 then + Memo.Frame.Typ := Memo.Frame.Typ + [ftRight]; + if (RowIndex = RowItems.Count - 1) and (CellIndex = CellLevels - 1) then + Memo.Frame.Typ := Memo.Frame.Typ + [ftBottom]; + end; + end; + + { check if previous memo has the same value and JoinEqualCells is True } + if JoinEqualCells then + if RowItem.IsTotal or ColumnItem.IsTotal then + SameMemos[CellIndex] := nil + else if (SameMemos[CellIndex] = nil) or RowItem.IsTotal or ColumnItem.IsTotal or + (THackMemoView(SameMemos[CellIndex]).Value <> THackMemoView(Memo).Value) then + SameMemos[CellIndex] := Memo + else + begin + SameMemos[CellIndex].Width := SameMemos[CellIndex].Width + Memo.Width; + SameMemos[CellIndex].HAlign := haCenter; + Memo.Free; + Memo := SameMemos[CellIndex]; + end; + + VarRowIndex.Value := RowIndex; + VarColumnIndex.Value := i; + Report.LocalValue := THackMemoView(Memo).Value; + Report.CurObject := Memo.Name; + Report.DoBeforePrint(Memo); + + { process memo children if any } + for j := 0 to m.Objects.Count - 1 do + begin + c := m.Objects[j]; + c1 := TfrxReportComponent(c.NewInstance); + c1.Create(Result); + c1.Assign(c); + c1.Left := c1.Left + Memo.Left; + c1.Top := c1.Top + Memo.Top; + Report.CurObject := c.Name; + Report.DoBeforePrint(c1); + end; + end; + end; + + procedure DrawCorner(Offset: TfrxPoint); + var + i: Integer; + Items: TList; + Item: TfrxCrossHeader; + r: TfrxRect; + m: TfrxCustomMemoView; + begin + if not FShowRowHeader or not FShowColumnHeader or FNoRows or not FShowCorner then Exit; + + Items := Corner.AllItems; + + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + m := Item.Memo; + r := Item.Bounds; + m.BeforePrint; + m.Text := VarToStr(Item.Value); + m.SetBounds(r.Left + Offset.X, r.Top + Offset.Y, r.Right, r.Bottom); + CorrectDMPBounds(m); + Report.PreviewPages.AddObject(m); + m.AfterPrint; + end; + + Items.Free; + end; + + procedure DoPagination(i, j: Integer); + var + k, kFrom, kTo: Integer; + begin + if ShowColumnHeader and (FRepeatHeaders or (i = 0)) then + begin + Band := FColumnBands[j].Band; + Band.Top := CurY; + Report.Engine.ShowBand(Band); + end; + + if ShowRowHeader and (FRepeatHeaders or (j = 0)) and not FNoRows then + begin + Band := FRowBands[i].Band; + if j = 0 then + Band.Left := Left + else + Band.Left := 0; + Band.Top := Band.Top + CurY; + Report.Engine.ShowBand(Band); + Band.Top := Band.Top - CurY; + + if ShowColumnHeader and (FRepeatHeaders or (i = 0)) then + DrawCorner(frxPoint(Band.Left, Band.Top + CurY - ColumnHeaderHeight)); + end; + + if FRepeatHeaders or (i = 0) then + Report.Engine.CurY := CurY + ColumnHeaderHeight else + Report.Engine.CurY := CurY; + if FRepeatHeaders or (j = 0) then + begin + AddWidth := RowHeaderWidth; + if j = 0 then + AddWidth := AddWidth + Left; + end + else + AddWidth := 0; + + kFrom := FRowBands[i].FromIndex; + kTo := FRowBands[i].ToIndex; + + for k := kFrom to kTo do + begin + Band := GetCellBand(k, j); + Band.Top := Report.Engine.CurY; + Report.Engine.ShowBand(Band); + Band.Free; + end; + end; + +begin + AddSourceObjects; + BuildColumnBands; + BuildRowBands; + ColumnItems := ColumnHeader.TerminalItems; + RowItems := RowHeader.TerminalItems; + + SavePage := Report.PreviewPages.CurPage; + Page := SavePage; + SaveCurY := Report.Engine.CurY; + CurY := SaveCurY; + MaxX := 0; + + frxGlobalVariables['RowIndex'] := 0; + frxGlobalVariables['ColumnIndex'] := 0; + VarRowIndex := frxGlobalVariables.Items[frxGlobalVariables.IndexOf('RowIndex')]; + VarColumnIndex := frxGlobalVariables.Items[frxGlobalVariables.IndexOf('ColumnIndex')]; + + if FDownThenAcross then + for i := 0 to FColumnBands.Count - 1 do + begin + for j := 0 to FRowBands.Count - 1 do + begin + Report.PreviewPages.CurPage := Page + j; + DoPagination(j, i); + if j <> FRowBands.Count - 1 then + Report.Engine.NewPage; + end; + + if i <> FColumnBands.Count - 1 then + Report.Engine.NewPage; + CurY := Report.Engine.CurY; + Inc(Page, FRowBands.Count); + + Application.ProcessMessages; + if Report.Terminated then break; + end + else + for i := 0 to FRowBands.Count - 1 do + begin + for j := 0 to FColumnBands.Count - 1 do + begin + Report.PreviewPages.CurPage := Page + j; + MaxX := 0; + DoPagination(i, j); + if j <> FColumnBands.Count - 1 then + begin + Report.PreviewPages.AddPageAction := apWriteOver; + Report.Engine.NewPage; + end + else if NextCross <> nil then + NextCross.Left := MaxX + NextCrossGap; + end; + + if i <> FRowBands.Count - 1 then + begin + Report.PreviewPages.AddPageAction := apAdd; + Report.Engine.NewPage; + Page := Report.PreviewPages.CurPage; + end + else + Inc(Page, FColumnBands.Count); + CurY := Report.Engine.CurY; + + Application.ProcessMessages; + if Report.Terminated then break; + end; + + if Parent is TfrxBand then + CurY := CurY - Height; + { print last page footers } + if FColumnBands.Count > 1 then + Report.Engine.EndPage; + + if NextCross <> nil then + begin + { position to last column, first row page } + Report.PreviewPages.CurPage := SavePage + FColumnBands.Count - 1; + Report.PreviewPages.AddPageAction := apAdd; + Report.Engine.CurY := SaveCurY; + end + else + begin + { position to last row, first column page } + Report.PreviewPages.CurPage := Page - FColumnBands.Count; + Report.PreviewPages.AddPageAction := apAdd; + Report.Engine.CurY := CurY; + end; + + ColumnItems.Free; + RowItems.Free; + FColumnBands.Clear; + FRowBands.Clear; +end; + +procedure TfrxCustomCrossView.AddSourceObjects; +var + i: Integer; +begin + for i := 0 to FCellHeaderMemos.Count - 1 do + Report.PreviewPages.AddToSourcePage(CellHeaderMemos[i]); + for i := 0 to FCellMemos.Count - 1 do + Report.PreviewPages.AddToSourcePage(CellMemos[i]); + for i := 0 to FColumnMemos.Count - 1 do + begin + Report.PreviewPages.AddToSourcePage(ColumnMemos[i]); + Report.PreviewPages.AddToSourcePage(ColumnTotalMemos[i]); + end; + for i := 0 to FCornerMemos.Count - 1 do + Report.PreviewPages.AddToSourcePage(CornerMemos[i]); + for i := 0 to FRowMemos.Count - 1 do + begin + Report.PreviewPages.AddToSourcePage(RowMemos[i]); + Report.PreviewPages.AddToSourcePage(RowTotalMemos[i]); + end; +end; + +procedure TfrxCustomCrossView.SetupOriginalComponent(Obj1, Obj2: TfrxComponent); +begin + THackComponent(Obj1).FOriginalComponent := THackComponent(Obj2).FOriginalComponent; + THackComponent(Obj1).FAliasName := THackComponent(Obj2).FAliasName; +end; + +procedure TfrxCustomCrossView.BuildColumnBands; +var + i, j, LeftIndex, RightIndex: Integer; + Items: TList; + Item: TfrxCrossHeader; + Memo: TfrxCustomMemoView; + LargeBand: TfrxNullBand; + CurWidth, AddWidth, LeftMargin, RightMargin: Extended; + c: TfrxReportComponent; + + procedure CreateBand; + var + i: Integer; + Band: TfrxNullBand; + Memo, CutMemo: TfrxCustomMemoView; + CutSize: Extended; + begin + Band := TfrxNullBand.Create(Report); + Band.Left := AddWidth; + + { move in-bounds memos to the new band } + i := 0; + while i < LargeBand.Objects.Count do + begin + Memo := LargeBand.Objects[i]; + if Memo.Left < RightMargin then + begin + if Memo.Left + Memo.Width <= RightMargin + 5 then + begin + Memo.Parent := Band; + Memo.Visible := Memo.Width > 0; + Dec(i); + end + else { cut off the memo } + begin + CutSize := RightMargin - Memo.Left; + CutMemo := CreateMemo(Band); + CutMemo.AssignAll(Memo); + CutMemo.Width := CutSize; + //if CutMemo.CalcWidth > CutSize then + //CutMemo.Text := ''; + + SetupOriginalComponent(CutMemo, Memo); + Memo.Width := Memo.Width - CutSize; + Memo.Left := Memo.Left + CutSize; + if Memo is TfrxDMPMemoView then + begin + Memo.Left := Memo.Left + fr1CharX; + Memo.Width := Memo.Width - fr1CharX; + end; + CutMemo.Frame.Typ := CutMemo.Frame.Typ - [ftRight]; + Memo.Frame.Typ := Memo.Frame.Typ - [ftLeft]; + + //if Memo.CalcWidth > Memo.Width then + //Memo.Text := ''; + Memo := CutMemo; + end; + + Memo.Left := Memo.Left - LeftMargin; + end; + Inc(i); + end; + + FColumnBands.Add(Band, LeftIndex, RightIndex); + end; + +begin + FColumnBands.Clear; + { create one large band } + LargeBand := TfrxNullBand.Create(nil); + Items := ColumnHeader.AllItems; + + { add memos to band } + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + if (i = 0) and not FShowTitle then continue; + Memo := CreateMemo(LargeBand); + Memo.AssignAll(Item.Memo); + SetupOriginalComponent(Memo, Item.Memo); + Memo.Text := Memo.FormatData(Item.Value); + Memo.Highlight.Condition := ''; + with Item.Bounds do + Memo.SetBounds(Left, Top, Right, Bottom); + CorrectDMPBounds(Memo); + Memo.Visible := (Memo.Width <> 0) and (Memo.Height <> 0); + DoOnColumnHeader(Memo, Item); + + Report.LocalValue := Item.Value; + Report.CurObject := Memo.Name; + Report.DoBeforePrint(Memo); + + { process memo children if any } + for j := 0 to Memo.Objects.Count - 1 do + begin + c := Memo.Objects[j]; + Report.CurObject := c.Name; + Report.DoBeforePrint(c); + end; + end; + + Items.Free; + + { cut it to small bands for each page } + Items := ColumnHeader.TerminalItems; + AddWidth := RowHeaderWidth; + CurWidth := Report.Engine.PageWidth - AddWidth; + LeftMargin := -Left; + RightMargin := LeftMargin + CurWidth; + LeftIndex := 0; + RightIndex := Items.Count - 1; + + if not TfrxReportPage(Page).EndlessWidth then + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + { find right terminal item } + if Item.Bounds.Left + Item.Bounds.Right - LeftMargin > CurWidth then + begin + RightMargin := Item.Bounds.Left; + RightIndex := i - 1; + CreateBand; + LeftMargin := RightMargin; + if FRepeatHeaders then + AddWidth := RowHeaderWidth else + AddWidth := 0; + CurWidth := Report.Engine.PageWidth - AddWidth; + RightMargin := LeftMargin + CurWidth; + LeftIndex := RightIndex + 1; + RightIndex := Items.Count - 1; + end; + end; + + if TfrxReportPage(Page).EndlessWidth then + begin + Item := Items[Items.Count - 1]; + CurWidth := Item.Bounds.Left + Item.Bounds.Right - LeftMargin + AddWidth; + if Report.Engine.PageWidth < CurWidth then + Report.Engine.PageWidth := CurWidth; + RightMargin := 1e+6; + end; + + { add last band } + CreateBand; + + LargeBand.Free; + Items.Free; +end; + +procedure TfrxCustomCrossView.BuildRowBands; +var + i, j, TopIndex, BottomIndex: Integer; + Items: TList; + Item: TfrxCrossHeader; + Memo: TfrxCustomMemoView; + LargeBand: TfrxNullBand; + MaxHeight, CurHeight, AddHeight, TopMargin, BottomMargin: Extended; + c: TfrxReportComponent; + + procedure CreateBand; + var + i: Integer; + Band: TfrxNullBand; + Memo, CutMemo: TfrxCustomMemoView; + CutSize: Extended; + begin + Band := TfrxNullBand.Create(Report); + Band.Top := AddHeight; + + { move in-bounds memos to the new band } + i := 0; + while i < LargeBand.Objects.Count do + begin + Memo := LargeBand.Objects[i]; + if Memo.Top < BottomMargin then + begin + if Memo.Top + Memo.Height <= BottomMargin + 5 then + begin + Memo.Parent := Band; + Dec(i); + end + else { cut off the memo } + begin + CutSize := BottomMargin - Memo.Top; + CutMemo := CreateMemo(Band); + CutMemo.AssignAll(Memo); + CutMemo.Height := CutSize; + SetupOriginalComponent(CutMemo, Memo); + Memo.Height := Memo.Height - CutSize; + Memo.Top := Memo.Top + CutSize; + if Memo is TfrxDMPMemoView then + begin + Memo.Top := Memo.Top + fr1CharY; + Memo.Height := Memo.Height - fr1CharY; + end; + CutMemo.Frame.Typ := CutMemo.Frame.Typ - [ftBottom]; + Memo.Frame.Typ := Memo.Frame.Typ - [ftTop]; + Memo := CutMemo; + end; + + Memo.Top := Memo.Top - TopMargin; + end; + Inc(i); + end; + + FRowBands.Add(Band, TopIndex, BottomIndex); + end; + +begin + FRowBands.Clear; + LargeBand := TfrxNullBand.Create(nil); + Items := RowHeader.AllItems; + MaxHeight := 0; + + { create one large band } + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + Memo := CreateMemo(LargeBand); + Memo.AssignAll(Item.Memo); + SetupOriginalComponent(Memo, Item.Memo); + Memo.Text := Memo.FormatData(Item.Value); + Memo.Highlight.Condition := ''; + with Item.Bounds do + Memo.SetBounds(Left, Top, Right, Bottom); + CorrectDMPBounds(Memo); + Memo.Visible := (Memo.Width <> 0) and (Memo.Height <> 0); + DoOnRowHeader(Memo, Item); + if Item.Bounds.Top + Item.Bounds.Bottom > MaxHeight then + MaxHeight := Item.Bounds.Top + Item.Bounds.Bottom; + + Report.LocalValue := Item.Value; + Report.CurObject := Memo.Name; + Report.DoBeforePrint(Memo); + + { process memo children if any } + for j := 0 to Memo.Objects.Count - 1 do + begin + c := Memo.Objects[j]; + Report.CurObject := c.Name; + Report.DoBeforePrint(c); + end; + end; + + Items.Free; + + { cut it to small bands for each page } + Items := RowHeader.TerminalItems; + AddHeight := ColumnHeaderHeight; + CurHeight := Report.Engine.FreeSpace - AddHeight; + if (MaxHeight > CurHeight) and KeepTogether then + begin + Report.Engine.NewPage; + AddHeight := ColumnHeaderHeight; + CurHeight := Report.Engine.FreeSpace - AddHeight; + end; + + TopMargin := 0; + BottomMargin := TopMargin + CurHeight; + TopIndex := 0; + BottomIndex := Items.Count - 1; + + for i := 0 to Items.Count - 1 do + begin + Item := Items[i]; + { find right terminal item } + if Item.Bounds.Top + Item.Bounds.Bottom - TopMargin > CurHeight then + begin + BottomMargin := Item.Bounds.Top; + BottomIndex := i - 1; + CreateBand; + TopMargin := BottomMargin; + if FRepeatHeaders then + AddHeight := ColumnHeaderHeight else + AddHeight := 0; + CurHeight := Report.Engine.PageHeight - Report.Engine.HeaderHeight - + Report.Engine.FooterHeight - AddHeight; + BottomMargin := TopMargin + CurHeight; + TopIndex := BottomIndex + 1; + BottomIndex := Items.Count - 1; + end; + end; + + CreateBand; + + LargeBand.Free; + Items.Free; +end; + +{$IFDEF FR_COM} +function TfrxCustomCrossView.Get_CellFields(out Value: WideString): HResult; stdcall; +begin + Value := WideString(String(CellFields.GetText)); + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_CellFields(const Value: WideString): HResult; stdcall; +begin + CellFields.SetText( PAnsiChar(String(Value)) ); + CellLevels := CellFields.Count; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_CellFunctions(Index: Integer; out Value: frxCrossFunction): HResult; stdcall; +begin + Value := frxCrossFunction(CellFunctions[Index]); + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_CellFunctions(Index: Integer; Value: frxCrossFunction): HResult; stdcall; +begin + CellFunctions[Index] := TfrxCrossFunction(Value); + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_CellMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; +begin + Value := CellMemos[Index]; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_ColumnFields(out Value: WideString): HResult; stdcall; +begin + Value := WideString(String(ColumnFields.GetText)); + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_ColumnFields(const Value: WideString): HResult; stdcall; +begin + ColumnFields.SetText( PAnsiChar(String(Value)) ); + ColumnLevels := ColumnFields.Count; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_ColumnMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; +begin + Value := ColumnMemos[Index]; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_ColumnSort(Index: Integer; out Value: frxCrossSortOrder): HResult; stdcall; +begin + Value := frxCrossSortOrder(ColumnSort[Index]); + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_ColumnSort(Index: Integer; Value: frxCrossSortOrder): HResult; stdcall; +begin + ColumnSort[Index] := TfrxCrossSortOrder(Value); + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_ColumnTotalMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; +begin + Value := ColumnTotalMemos[Index]; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_RowFields(out Value: WideString): HResult; stdcall; +begin + Value := WideString(String(RowFields.GetText)); + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_RowFields(const Value: WideString): HResult; stdcall; +begin + RowFields.SetText( PAnsiChar(String(Value)) ); + RowLevels := RowFields.Count; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_RowMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; +begin + Value := RowMemos[Index]; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_RowSort(Index: Integer; out Value: frxCrossSortOrder): HResult; stdcall; +begin + Value := frxCrossSortOrder( RowSort[Index] ); + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_RowSort(Index: Integer; Value: frxCrossSortOrder): HResult; stdcall; +begin + RowSort[Index] := TfrxCrossSortOrder( Value ); + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_RowTotalMemos(Index: Integer; out Value: IfrxCustomMemoView): HResult; stdcall; +begin + Value := RowTotalMemos[Index]; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_MaxWidth(out Value: Integer): HResult; stdcall; +begin + Value := MaxWidth; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_MaxWidth(Value: Integer): HResult; stdcall; +begin + MaxWidth := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_MinWidth(out Value: Integer): HResult; stdcall; +begin + Value := MinWidth; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_MinWidth(Value: Integer): HResult; stdcall; +begin + MinWidth := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.AddValues(Rows: PSafeArray; Columns: PSafeArray; Cells: PSafeArray): HResult; stdcall; +type + VariantArray = array of Variant; +var + ArrayData: Pointer; + R: VariantArray; + C: VariantArray; + V: VariantArray; +begin + SafeArrayAccessData( Rows, ArrayData ); + R := VariantArray(ArrayData); + SafeArrayUnAccessData( Rows ); + + SafeArrayAccessData( Columns, ArrayData ); + C := VariantArray(ArrayData); + SafeArrayUnAccessData( Columns ); + + SafeArrayAccessData( Cells, ArrayData ); + V := VariantArray(ArrayData); + SafeArrayUnAccessData( Cells ); + + AddValue( R, C, V ); + Result := S_OK; +end; + +function TfrxCustomCrossView.AddValuesVB6(Rows: OleVariant; Columns: OleVariant; Cells: OleVariant): HResult; stdcall; +var + r: PSafeArray; + c: PSafeArray; + v: PSafeArray; +begin + Result := E_HANDLE; + repeat + if not VarIsArray(Rows) then break; + if not VarIsArray(Columns) then break; + if not VarIsArray(Cells) then break; + r := VarArrayLock(Rows); + c := VarArrayLock(Columns); + v := VarArrayLock(Cells); + Result := AddValues(r, c, v); + VarArrayUnlock(Cells); + VarArrayUnlock(Columns); + VarArrayUnlock(Rows); + until True; +end; + +function TfrxCustomCrossView.Get_GapX(out Value: Integer): HResult; stdcall; +begin + Value := GapX; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_GapX(Value: Integer): HResult; stdcall; +begin + GapX := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_GapY(out Value: Integer): HResult; stdcall; +begin + Value := GapY; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_GapY(Value: Integer): HResult; stdcall; +begin + GapY := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_PlainCells(out Value: WordBool): HResult; stdcall; +begin + Value := PlainCells; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_PlainCells(Value: WordBool): HResult; stdcall; +begin + PlainCells := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_DownThenAcross(out Value: WordBool): HResult; stdcall; +begin + Value := DownThenAcross; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_DownThenAcross(Value: WordBool): HResult; stdcall; +begin + DownThenAcross := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_RepeatHeaders(out Value: WordBool): HResult; stdcall; +begin + Value := RepeatHeaders; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_RepeatHeaders(Value: WordBool): HResult; stdcall; +begin + RepeatHeaders := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_ShowColumnHeader(out Value: WordBool): HResult; stdcall; +begin + Value := ShowColumnHeader; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_ShowColumnHeader(Value: WordBool): HResult; stdcall; +begin + ShowColumnHeader := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_ShowColumnTotal(out Value: WordBool): HResult; stdcall; +begin + Value := ShowColumnTotal; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_ShowColumnTotal(Value: WordBool): HResult; stdcall; +begin + ShowColumnTotal := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_ShowRowHeader(out Value: WordBool): HResult; stdcall; +begin + Value := ShowRowHeader; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_ShowRowHeader(Value: WordBool): HResult; stdcall; +begin + ShowRowHeader := Value; + Result := S_OK; +end; + +function TfrxCustomCrossView.Get_ShowRowTotal(out Value: WordBool): HResult; stdcall; +begin + Value := ShowRowTotal; + Result := S_OK; +end; + +function TfrxCustomCrossView.Set_ShowRowTotal(Value: WordBool): HResult; stdcall; +begin + ShowRowTotal := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxCrossView } + +class function TfrxCrossView.GetDescription: String; +begin + Result := frxResources.Get('obCross'); +end; + +function TfrxCrossView.IsCrossValid: Boolean; +begin + Result := (FCellLevels > 0) and (FRowLevels >= 0) and (FColumnLevels >= 0); +end; + +procedure TfrxCrossView.SetCellLevels(const Value: Integer); +var + i: Integer; +begin + inherited; + FCellFields.Clear; + if Value = 1 then + FCellFields.Add('Cell') + else + for i := 0 to Value - 1 do + FCellFields.Add('Cell' + IntToStr(i + 1)); +end; + +procedure TfrxCrossView.SetColumnLevels(const Value: Integer); +var + i: Integer; +begin + inherited; + FColumnFields.Clear; + if Value = 1 then + FColumnFields.Add('Column') + else + for i := 0 to Value - 1 do + FColumnFields.Add('Column' + IntToStr(i + 1)); +end; + +procedure TfrxCrossView.SetRowLevels(const Value: Integer); +var + i: Integer; +begin + inherited; + FRowFields.Clear; + if Value = 1 then + FRowFields.Add('Row') + else + for i := 0 to Value - 1 do + FRowFields.Add('Row' + IntToStr(i + 1)); +end; + + +{ TfrxDBCrossView } + +class function TfrxDBCrossView.GetDescription: String; +begin + Result := frxResources.Get('obDBCross'); +end; + +function TfrxDBCrossView.IsCrossValid: Boolean; +begin + Result := (DataSet <> nil) and (FCellLevels > 0) and + (FRowFields.Count = FRowLevels) and (FColumnFields.Count = FColumnLevels) and + (FCellFields.Count = FCellLevels); +end; + +procedure TfrxDBCrossView.FillMatrix; +var + i: Integer; + RowValues, ColumnValues, CellValues: array of Variant; + sl: TStringList; +begin + SetLength(RowValues, FRowLevels); + SetLength(ColumnValues, FColumnLevels); + SetLength(CellValues, FCellLevels); + + sl := TStringList.Create; + try + DataSet.GetFieldList(sl); + sl.Sorted := True; + + DataSet.First; + while not DataSet.Eof do + begin + for i := 0 to FRowLevels - 1 do + begin + if sl.IndexOf(FRowFields[i]) <> -1 then + RowValues[i] := DataSet.Value[FRowFields[i]] + else + RowValues[i] := Report.Calc(FRowFields[i]) + end; + for i := 0 to FColumnLevels - 1 do + begin + if sl.IndexOf(FColumnFields[i]) <> -1 then + ColumnValues[i] := DataSet.Value[FColumnFields[i]] + else + ColumnValues[i] := Report.Calc(FColumnFields[i]) + end; + for i := 0 to FCellLevels - 1 do + begin + if sl.IndexOf(FCellFields[i]) <> -1 then + CellValues[i] := DataSet.Value[FCellFields[i]] + else + CellValues[i] := Report.Calc(FCellFields[i]) + end; + AddValue(RowValues, ColumnValues, CellValues); + DataSet.Next; + end; + finally + sl.Free; + end; + + RowValues := nil; + ColumnValues := nil; + CellValues := nil; +end; + + +initialization + frxObjects.RegisterObject1(TfrxCrossView, nil, '', '', 0, 42, [ctReport, ctDMP]); + frxObjects.RegisterObject1(TfrxDBCrossView, nil, '', '', 0, 49, [ctReport, ctDMP]); + frxResources.Add('TfrxPrintCellEvent', + 'PascalScript=(Memo: TfrxMemoView; RowIndex, ColumnIndex, CellIndex: Integer; RowValues, ColumnValues, Value: Variant);' + #13#10 + + 'C++Script=(TfrxMemoView Memo, int RowIndex, int ColumnIndex, int CellIndex, variant RowValues, variant ColumnValues, variant Value)' + #13#10 + + 'BasicScript=(Memo, RowIndex, ColumnIndex, CellIndex, RowValues, ColumnValues, Value)' + #13#10 + + 'JScript=(Memo, RowIndex, ColumnIndex, CellIndex, RowValues, ColumnValues, Value)'); + frxResources.Add('TfrxPrintHeaderEvent', + 'PascalScript=(Memo: TfrxMemoView; HeaderIndexes, HeaderValues, Value: Variant);' + #13#10 + + 'C++Script=(TfrxMemoView Memo, variant HeaderIndexes, variant HeaderValues, variant Value)' + #13#10 + + 'BasicScript=(Memo, HeaderIndexes, HeaderValues, Value)' + #13#10 + + 'JScript=(Memo, HeaderIndexes, HeaderValues, Value)'); + frxResources.Add('TfrxCalcWidthEvent', + 'PascalScript=(ColumnIndex: Integer; ColumnValues: Variant; var Width: Extended);' + #13#10 + + 'C++Script=(int ColumnIndex, variant ColumnValues, float &Width)' + #13#10 + + 'BasicScript=(ColumnIndex, ColumnValues, byref Width)' + #13#10 + + 'JScript=(ColumnIndex, ColumnValues, &Width)'); + frxResources.Add('TfrxCalcHeightEvent', + 'PascalScript=(RowIndex: Integer; RowValues: Variant; var Height: Extended);' + #13#10 + + 'C++Script=(int RowIndex, variant RowValues, float &Height)' + #13#10 + + 'BasicScript=(RowIndex, RowValues, byref Height)' + #13#10 + + 'JScript=(RowIndex, RowValues, &Height)'); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCrossEditor.dfm b/official/4.2/LibD11/frxCrossEditor.dfm new file mode 100644 index 0000000..ae50c8e Binary files /dev/null and b/official/4.2/LibD11/frxCrossEditor.dfm differ diff --git a/official/4.2/LibD11/frxCrossEditor.pas b/official/4.2/LibD11/frxCrossEditor.pas new file mode 100644 index 0000000..4b189e0 --- /dev/null +++ b/official/4.2/LibD11/frxCrossEditor.pas @@ -0,0 +1,935 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Cross editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCrossEditor; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ImgList, Menus, ComCtrls, Buttons, ToolWin, ExtCtrls, frxDock, + frxCross, frxClass, frxCtrls, frxCustomEditors +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxCrossEditor = class(TfrxViewEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + end; + + TfrxCrossEditorForm = class(TForm) + FuncPopup: TPopupMenu; + Func1MI: TMenuItem; + Func2MI: TMenuItem; + Func3MI: TMenuItem; + Func4MI: TMenuItem; + Func5MI: TMenuItem; + Func6MI: TMenuItem; + SortPopup: TPopupMenu; + Sort1MI: TMenuItem; + Sort2MI: TMenuItem; + Sort3MI: TMenuItem; + DatasetL: TGroupBox; + DatasetCB: TComboBox; + FieldsLB: TListBox; + DimensionsL: TGroupBox; + RowsL: TLabel; + RowsE: TEdit; + ColumnsL: TLabel; + ColumnsE: TEdit; + CellsL: TLabel; + CellsE: TEdit; + UpDown1: TUpDown; + UpDown2: TUpDown; + UpDown3: TUpDown; + StructureL: TGroupBox; + Shape1: TShape; + Shape2: TShape; + SwapB: TSpeedButton; + RowsLB: TListBox; + ColumnsLB: TListBox; + CellsLB: TListBox; + OptionsL: TGroupBox; + RowHeaderCB: TCheckBox; + ColumnHeaderCB: TCheckBox; + RowTotalCB: TCheckBox; + ColumnTotalCB: TCheckBox; + TitleCB: TCheckBox; + CornerCB: TCheckBox; + AutoSizeCB: TCheckBox; + BorderCB: TCheckBox; + DownAcrossCB: TCheckBox; + PlainCB: TCheckBox; + JoinCB: TCheckBox; + Box: TScrollBox; + PaintBox: TPaintBox; + OkB: TButton; + CancelB: TButton; + RepeatCB: TCheckBox; + StylePopup: TPopupMenu; + Sep1: TMenuItem; + SaveStyleMI: TMenuItem; + ToolBar: TToolBar; + StyleB: TToolButton; + procedure FormCreate(Sender: TObject); + procedure CancelBClick(Sender: TObject); + procedure OkBClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure DatasetCBClick(Sender: TObject); + procedure DatasetCBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure FieldsLBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure LBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure CellsLBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure LBDragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure LBDragDrop(Sender, Source: TObject; X, Y: Integer); + procedure LBMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure LBClick(Sender: TObject); + procedure CBClick(Sender: TObject); + procedure FuncMIClick(Sender: TObject); + procedure CellsLBMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure SortMIClick(Sender: TObject); + procedure SwapBClick(Sender: TObject); + procedure DimensionsChange(Sender: TObject); + procedure LBDblClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure PaintBoxPaint(Sender: TObject); + procedure SaveStyleMIClick(Sender: TObject); + private + FCross: TfrxCustomCrossView; + FCurList: TListBox; + FFuncNames: array[TfrxCrossFunction] of String; + FImages: TImageList; + FSortNames: array[TfrxCrossSortOrder] of String; + FStyleSheet: TfrxStyleSheet; + FTempCross: TfrxDBCrossView; + FUpdating: Boolean; + procedure ReflectChanges(ChangesFrom: TObject); + procedure CreateStyleMenu; + procedure StyleClick(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + property Cross: TfrxCustomCrossView read FCross write FCross; + end; + + +implementation + +{$R *.DFM} + +uses + frxDsgnIntf, frxEditFormat, frxEditHighlight, frxEditMemo, + frxEditFrame, frxDesgnCtrls, frxRes, frxUtils; + +const + CrossStyles = +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +''; + +type + THackWinControl = class(TWinControl); + + +{ TfrxCrossEditor } + +function TfrxCrossEditor.Edit: Boolean; +begin + with TfrxCrossEditorForm.Create(Designer) do + begin + Cross := TfrxCustomCrossView(Component); + Result := ShowModal = mrOk; + Free; + end; +end; + +function TfrxCrossEditor.HasEditor: Boolean; +begin + Result := True; +end; + + +{ TfrxCrossEditorForm } + +constructor TfrxCrossEditorForm.Create(AOwner: TComponent); +var + TempStream: TStringStream; +begin + inherited; + + FStyleSheet := TfrxStyleSheet.Create; + if FileExists(ExtractFilePath(Application.ExeName) + 'crossstyles.xml') then + FStyleSheet.LoadFromFile(ExtractFilePath(Application.ExeName) + 'crossstyles.xml') + else + begin + TempStream := TStringStream.Create(CrossStyles); + FStyleSheet.LoadFromStream(TempStream); + TempStream.Free; + end; + + FImages := TImageList.Create(nil); + FTempCross := TfrxDBCrossView.Create(nil); + FFuncNames[cfNone] := frxResources.Get('crNone'); + FFuncNames[cfSum] := frxResources.Get('crSum'); + FFuncNames[cfMin] := frxResources.Get('crMin'); + FFuncNames[cfMax] := frxResources.Get('crMax'); + FFuncNames[cfAvg] := frxResources.Get('crAvg'); + FFuncNames[cfCount] := frxResources.Get('crCount'); + FSortNames[soAscending] := frxResources.Get('crAsc'); + FSortNames[soDescending] := frxResources.Get('crDesc'); + FSortNames[soNone] := frxResources.Get('crNone'); +{$IFDEF Delphi5} + StylePopup.AutoHotKeys := maManual; +{$ENDIF} +end; + +destructor TfrxCrossEditorForm.Destroy; +begin + FImages.Free; + FStyleSheet.Free; + FTempCross.Free; + inherited; +end; + +procedure TfrxCrossEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(4300); + DatasetL.Caption := frxGet(4301); + DimensionsL.Caption := frxGet(4302); + RowsL.Caption := frxGet(4303); + ColumnsL.Caption := frxGet(4304); + CellsL.Caption := frxGet(4305); + StructureL.Caption := frxGet(4306); + RowHeaderCB.Caption := frxGet(4307); + ColumnHeaderCB.Caption := frxGet(4308); + RowTotalCB.Caption := frxGet(4309); + ColumnTotalCB.Caption := frxGet(4310); + SwapB.Hint := frxGet(4311); + Func1MI.Caption := frxGet(4322); + Func2MI.Caption := frxGet(4323); + Func3MI.Caption := frxGet(4324); + Func4MI.Caption := frxGet(4325); + Func5MI.Caption := frxGet(4326); + Func6MI.Caption := frxGet(4327); + Sort1MI.Caption := frxGet(4328); + Sort2MI.Caption := frxGet(4329); + Sort3MI.Caption := frxGet(4330); + TitleCB.Caption := frxGet(4314); + CornerCB.Caption := frxGet(4315); + AutoSizeCB.Caption := frxGet(4317); + BorderCB.Caption := frxGet(4318); + DownAcrossCB.Caption := frxGet(4319); + RepeatCB.Caption := frxGet(4316); + PlainCB.Caption := frxGet(4320); + JoinCB.Caption := frxGet(4321); + StyleB.Caption := frxGet(4312); + SaveStyleMI.Caption := frxGet(4313); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + +{$IFDEF UseTabset} + Box.BevelKind := bkFlat; +{$ELSE} + Box.BorderStyle := bsSingle; +{$IFDEF Delphi7} + Box.ControlStyle := Box.ControlStyle + [csNeedsBorderPaint]; +{$ENDIF} +{$ENDIF} + CreateStyleMenu; + StylePopup.Images := FImages; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxCrossEditorForm.FormShow(Sender: TObject); + + procedure SelectDataset; + begin + DatasetCB.ItemIndex := DatasetCB.Items.IndexOfObject(FCross.DataSet); + if DatasetCB.ItemIndex = -1 then + DatasetCB.ItemIndex := 0; + DatasetCBClick(nil); + end; + + procedure SelectFields; + var + i: Integer; + begin + for i := 0 to FCross.RowFields.Count - 1 do + RowsLB.Items.Add(FCross.RowFields[i]); + + for i := 0 to FCross.ColumnFields.Count - 1 do + ColumnsLB.Items.Add(FCross.ColumnFields[i]); + + CellsLB.Items := FCross.CellFields; + end; + +begin + FTempCross.Assign(FCross); + FCross.Report.GetDataSetList(DatasetCB.Items); + SelectDataset; + SelectFields; + + FUpdating := True; + + if FCross is TfrxCrossView then + begin + ColumnsLB.DragMode := dmManual; + RowsLB.DragMode := dmManual; + CellsLB.DragMode := dmManual; + SwapB.Visible := False; + DimensionsL.Visible := True; + RowsE.Text := IntToStr(FCross.RowLevels); + ColumnsE.Text := IntToStr(FCross.ColumnLevels); + CellsE.Text := IntToStr(FCross.CellLevels); + end + else + DatasetL.Visible := True; + + TitleCB.Checked := FCross.ShowTitle; + CornerCB.Checked := FCross.ShowCorner; + ColumnHeaderCB.Checked := FCross.ShowColumnHeader; + RowHeaderCB.Checked := FCross.ShowRowHeader; + ColumnTotalCB.Checked := FCross.ShowColumnTotal; + RowTotalCB.Checked := FCross.ShowRowTotal; + + AutoSizeCB.Checked := FCross.AutoSize; + BorderCB.Checked := FCross.Border; + DownAcrossCB.Checked := FCross.DownThenAcross; + RepeatCB.Checked := FCross.RepeatHeaders; + PlainCB.Checked := FCross.PlainCells; + JoinCB.Checked := FCross.JoinEqualCells; + + StyleB.Visible := not FCross.DotMatrix; + + FUpdating := False; +end; + +procedure TfrxCrossEditorForm.FormHide(Sender: TObject); +begin + if ModalResult = mrCancel then + FCross.Assign(FTempCross); +end; + +procedure TfrxCrossEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxCrossEditorForm.CreateStyleMenu; +var + i: Integer; + sl: TStringList; + m: TMenuItem; + b: TBitmap; + Style: TfrxStyles; +begin + sl := TStringList.Create; + FStyleSheet.GetList(sl); + + FImages.Clear; + b := TBitmap.Create; + b.Width := 16; + b.Height := 16; + frxResources.MainButtonImages.Draw(b.Canvas, 0, 0, 2); + FImages.Add(b, nil); + + { create thumbnail images for each style } + for i := 0 to sl.Count - 1 do + begin + Style := FStyleSheet[i]; + with b.Canvas do + begin + Brush.Color := Style.Find('column').Color; + if Brush.Color = clNone then + Brush.Color := clWhite; + FillRect(Rect(0, 0, 16, 8)); + Brush.Color := Style.Find('cell').Color; + if Brush.Color = clNone then + Brush.Color := clWhite; + FillRect(Rect(0, 8, 16, 16)); + Pen.Color := clSilver; + Brush.Style := bsClear; + Rectangle(0, 0, 16, 16); + end; + FImages.Add(b, nil); + end; + + while StylePopup.Items[0] <> Sep1 do + StylePopup.Items[0].Free; + + for i := sl.Count - 1 downto 0 do + begin + m := TMenuItem.Create(StylePopup); + m.Caption := sl[i]; + m.ImageIndex := i + 1; + m.OnClick := StyleClick; + StylePopup.Items.Insert(0, m); + end; + + sl.Free; +end; + +procedure TfrxCrossEditorForm.ReflectChanges(ChangesFrom: TObject); +var + i, j: Integer; + s: String; +begin + if DatasetCB.ItemIndex = -1 then + FCross.DataSet := nil else + FCross.DataSet := TfrxCustomDBDataSet(DatasetCB.Items.Objects[DatasetCB.ItemIndex]); + if FCross is TfrxDBCrossView then + begin + FCross.RowFields := RowsLB.Items; + FCross.ColumnFields := ColumnsLB.Items; + FCross.CellFields := CellsLB.Items; + end; + FCross.RowLevels := FCross.RowFields.Count; + FCross.ColumnLevels := FCross.ColumnFields.Count; + FCross.CellLevels := FCross.CellFields.Count; + + if ChangesFrom = nil then // change all + begin + if FCross.CellLevels = 1 then + FCross.CornerMemos[0].Text := FCross.CellFields[0] + else + begin + FCross.CornerMemos[0].Text := ''; + FCross.CornerMemos[2].Text := 'Data'; + end; + + for i := 0 to FCross.RowLevels do + for j := 0 to FCross.CellLevels - 1 do + FCross.CellHeaderMemos[i * FCross.CellLevels + j].Text := FCross.CellFields[j]; + + s := ''; + for i := 0 to FCross.ColumnLevels - 1 do + s := s + FCross.ColumnFields[i] + ', '; + if s <> '' then + SetLength(s, Length(s) - 2); + FCross.CornerMemos[1].Text := s; + + for i := 0 to FCross.RowLevels - 1 do + FCross.CornerMemos[i + 3].Text := FCross.RowFields[i]; + end + else if (ChangesFrom = RowsLB) or (ChangesFrom = RowsE) then + begin + for i := 0 to FCross.RowLevels do + for j := 0 to FCross.CellLevels - 1 do + FCross.CellHeaderMemos[i * FCross.CellLevels + j].Text := FCross.CellFields[j]; + + for i := 0 to FCross.RowLevels - 1 do + FCross.CornerMemos[i + 3].Text := FCross.RowFields[i]; + end + else if (ChangesFrom = ColumnsLB) or (ChangesFrom = ColumnsE) then + begin + s := ''; + for i := 0 to FCross.ColumnLevels - 1 do + s := s + FCross.ColumnFields[i] + ', '; + if s <> '' then + SetLength(s, Length(s) - 2); + FCross.CornerMemos[1].Text := s; + end + else if (ChangesFrom = CellsLB) or (ChangesFrom = CellsE) then + begin + if FCross.CellLevels = 1 then + FCross.CornerMemos[0].Text := FCross.CellFields[0] + else + begin + FCross.CornerMemos[0].Text := ''; + FCross.CornerMemos[2].Text := 'Data'; + end; + + for i := 0 to FCross.RowLevels do + for j := 0 to FCross.CellLevels - 1 do + FCross.CellHeaderMemos[i * FCross.CellLevels + j].Text := FCross.CellFields[j]; + end; + + PaintBoxPaint(nil); +end; + +procedure TfrxCrossEditorForm.DatasetCBClick(Sender: TObject); +var + ds: TfrxCustomDBDataSet; +begin + if DatasetCB.ItemIndex = -1 then Exit; + ds := TfrxCustomDBDataSet(DatasetCB.Items.Objects[DatasetCB.ItemIndex]); + ds.GetFieldList(FieldsLB.Items); + RowsLB.Clear; + ColumnsLB.Clear; + CellsLB.Clear; + if Sender <> nil then + ReflectChanges(nil); +end; + +procedure TfrxCrossEditorForm.LBDragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + Accept := (Source is TListBox) and (TListBox(Source).Items.Count > 0); +end; + +procedure TfrxCrossEditorForm.LBDragDrop(Sender, Source: TObject; X, + Y: Integer); +var + s: String; + i: Integer; + SourceLB, SenderLB: TListBox; +begin + SourceLB := TListBox(Source); + SenderLB := TListBox(Sender); + if (Source = Sender) and (Source <> FieldsLB) then + begin + i := SourceLB.ItemAtPos(Point(X, Y), True); + if i = -1 then + i := SourceLB.Items.Count - 1; + SourceLB.Items.Exchange(SourceLB.ItemIndex, i); + end + else if Source <> Sender then + begin + if SourceLB.ItemIndex = -1 then Exit; + s := SourceLB.Items[SourceLB.ItemIndex]; + if Source <> FieldsLB then + SourceLB.Items.Delete(SourceLB.Items.IndexOf(s)); + if Sender <> FieldsLB then + SenderLB.Items.Add(s); + end; + + ReflectChanges(Source); + ReflectChanges(Sender); +end; + +procedure TfrxCrossEditorForm.LBClick(Sender: TObject); +begin + if Sender <> FieldsLB then + FieldsLB.ItemIndex := -1; + if Sender <> RowsLB then + RowsLB.ItemIndex := -1; + if Sender <> ColumnsLB then + ColumnsLB.ItemIndex := -1; + if Sender <> CellsLB then + CellsLB.ItemIndex := -1; +end; + +procedure TfrxCrossEditorForm.LBDblClick(Sender: TObject); +var + lb: TListBox; + s: String; +begin + lb := TListBox(Sender); + + s := Cross.Report.Designer.InsertExpression(lb.Items[lb.ItemIndex]); + if s <> '' then + begin + lb.Items[lb.ItemIndex] := s; + ReflectChanges(Sender); + end; +end; + +procedure TfrxCrossEditorForm.CancelBClick(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +procedure TfrxCrossEditorForm.OkBClick(Sender: TObject); +begin + ModalResult := mrOk; +end; + +procedure TfrxCrossEditorForm.LBMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var + Memo: TfrxCustomMemoView; + sort: TfrxCrossSortOrder; + i: Integer; + pt: TPoint; +begin + FCurList := TListBox(Sender); + if (X > 118) and (X < 133) then + begin + if FCurList = RowsLB then + Memo := FCross.RowTotalMemos[FCurList.ItemIndex + 1] else + Memo := FCross.ColumnTotalMemos[FCurList.ItemIndex + 1]; + Memo.Visible := not Memo.Visible; + end; + + if (X > 183) and (X < 198) then + begin + if FCurList = RowsLB then + sort := FCross.RowSort[FCurList.ItemIndex] else + sort := FCross.ColumnSort[FCurList.ItemIndex]; + + for i := 0 to SortPopup.Items.Count - 1 do + if SortPopup.Items[i].Tag = Integer(sort) then + SortPopup.Items[i].Checked := True; + pt := FCurList.ClientToScreen(Point(X, Y)); + SortPopup.Popup(pt.X, pt.Y); + end; + + FCurList.Invalidate; + ReflectChanges(Sender); +end; + +procedure TfrxCrossEditorForm.CBClick(Sender: TObject); +begin + if FUpdating then Exit; + + FCross.ShowTitle := TitleCB.Checked; + FCross.ShowCorner := CornerCB.Checked; + FCross.ShowColumnHeader := ColumnHeaderCB.Checked; + FCross.ShowRowHeader := RowHeaderCB.Checked; + FCross.ShowColumnTotal := ColumnTotalCB.Checked; + FCross.ShowRowTotal := RowTotalCB.Checked; + + FCross.AutoSize := AutoSizeCB.Checked; + FCross.Border := BorderCB.Checked; + FCross.DownThenAcross := DownAcrossCB.Checked; + FCross.RepeatHeaders := RepeatCB.Checked; + FCross.PlainCells := PlainCB.Checked; + FCross.JoinEqualCells := JoinCB.Checked; + ReflectChanges(Sender); +end; + +procedure TfrxCrossEditorForm.DimensionsChange(Sender: TObject); +begin + if FUpdating then Exit; + + case TControl(Sender).Tag of + 0: FCross.RowLevels := StrToInt(RowsE.Text); + 1: FCross.ColumnLevels := StrToInt(ColumnsE.Text); + 2: FCross.CellLevels := StrToInt(CellsE.Text); + end; + + RowsLB.Items := FCross.RowFields; + ColumnsLB.Items := FCross.ColumnFields; + CellsLB.Items := FCross.CellFields; + + ReflectChanges(Sender); +end; + +procedure TfrxCrossEditorForm.FuncMIClick(Sender: TObject); +begin + if CellsLB.ItemIndex = -1 then Exit; + FCross.CellFunctions[CellsLB.ItemIndex] := TfrxCrossFunction(TControl(Sender).Tag); + CellsLB.Invalidate; + CellsLB.EndDrag(False); +end; + +procedure TfrxCrossEditorForm.CellsLBMouseUp(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var + i: Integer; + f: TfrxCrossFunction; + pt: TPoint; +begin + if CellsLB.ItemIndex = -1 then Exit; + if (X > 183) and (X < 198) then + begin + f := FCross.CellFunctions[CellsLB.ItemIndex]; + for i := 0 to FuncPopup.Items.Count - 1 do + if FuncPopup.Items[i].Tag = Integer(f) then + FuncPopup.Items[i].Checked := True; + pt := CellsLB.ClientToScreen(Point(X, Y)); + FuncPopup.Popup(pt.X, pt.Y); + end; +end; + +procedure TfrxCrossEditorForm.SortMIClick(Sender: TObject); +begin + if FCurList.ItemIndex = -1 then Exit; + if FCurList = ColumnsLB then + FCross.ColumnSort[FCurList.ItemIndex] := TfrxCrossSortOrder(TControl(Sender).Tag) else + FCross.RowSort[FCurList.ItemIndex] := TfrxCrossSortOrder(TControl(Sender).Tag); + FCurList.Invalidate; + FCurList.EndDrag(False); +end; + +procedure TfrxCrossEditorForm.SwapBClick(Sender: TObject); +var + sl: TStrings; +begin + sl := TStringList.Create; + sl.Assign(RowsLB.Items); + RowsLB.Items := ColumnsLB.Items; + ColumnsLB.Items := sl; + sl.Free; + + ReflectChanges(nil); +end; + +procedure TfrxCrossEditorForm.StyleClick(Sender: TObject); +var + Style: TfrxStyles; +begin + Style := FStyleSheet.Find(TMenuItem(Sender).Caption); + if Style <> nil then + FCross.ApplyStyle(Style); + PaintBoxPaint(nil); +end; + +procedure TfrxCrossEditorForm.SaveStyleMIClick(Sender: TObject); +var + s: String; + Style: TfrxStyles; +begin + s := ''; + s := InputBox(frxGet(4313), frxResources.Get('crStName'), s); + if s <> '' then + begin + Style := FStyleSheet.Find(s); + if Style = nil then + Style := FStyleSheet.Add; + Style.Name := s; + FCross.GetStyle(Style); + FStyleSheet.SaveToFile(ExtractFilePath(Application.ExeName) + 'crossstyles.xml'); + CreateStyleMenu; + end; +end; + +procedure TfrxCrossEditorForm.PaintBoxPaint(Sender: TObject); +begin + with PaintBox.Canvas do + begin + Brush.Color := clWindow; + FillRect(Rect(0, 0, PaintBox.Width, PaintBox.Height)); + end; + FCross.DrawCross(PaintBox.Canvas, 1, 1, 0, 0); +end; + +procedure TfrxCrossEditorForm.DatasetCBDrawItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +begin + DatasetCB.Canvas.FillRect(ARect); + frxResources.MainButtonImages.Draw(DatasetCB.Canvas, ARect.Left, ARect.Top, 53); + DatasetCB.Canvas.TextOut(ARect.Left + 20, ARect.Top + 1, DatasetCB.Items[Index]); +end; + +procedure TfrxCrossEditorForm.FieldsLBDrawItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +begin + FieldsLB.Canvas.FillRect(ARect); + frxResources.MainButtonImages.Draw(FieldsLB.Canvas, ARect.Left, ARect.Top + 2, 54); + FieldsLB.Canvas.TextOut(ARect.Left + 20, ARect.Top + 1, FieldsLB.Items[Index]); +end; + +procedure TfrxCrossEditorForm.LBDrawItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +var + HasSubtotal: Boolean; + sort: String; +begin + with TListBox(Control), TListBox(Control).Canvas do + begin + FillRect(ARect); + TextOut(ARect.Left + 2, ARect.Top + 1, Items[Index]); + + if Control = RowsLB then + sort := FSortNames[FCross.RowSort[Index]] else + sort := FSortNames[FCross.ColumnSort[Index]]; + TextOut(ARect.Left + 200, ARect.Top + 1, sort); + + if Index <> Items.Count - 1 then + begin + TextOut(ARect.Left + 135, ARect.Top + 1, frxResources.Get('crSubtotal')); + Pen.Color := clGray; + Brush.Color := clWindow; + Rectangle(ARect.Left + 120, ARect.Top + 3, ARect.Left + 131, ARect.Top + 14); + + if Control = RowsLB then + HasSubtotal := FCross.RowTotalMemos[Index + 1].Visible else + HasSubtotal := FCross.ColumnTotalMemos[Index + 1].Visible; + + if HasSubtotal then + begin + Pen.Color := clBlack; + with ARect do + begin + PolyLine([Point(Left + 122, Top + 7), Point(Left + 124, Top + 9), Point(Left + 129, Top + 4)]); + PolyLine([Point(Left + 122, Top + 8), Point(Left + 124, Top + 10), Point(Left + 129, Top + 5)]); + PolyLine([Point(Left + 122, Top + 9), Point(Left + 124, Top + 11), Point(Left + 129, Top + 6)]); + end; + end; + end; + + Pen.Color := clGray; + Brush.Color := clWindow; + Rectangle(ARect.Left + 185, ARect.Top + 3, ARect.Left + 196, ARect.Top + 14); + + Pen.Color := clBlack; + with ARect do + begin + MoveTo(Left + 187, Top + 7); LineTo(Left + 194, Top + 7); + MoveTo(Left + 188, Top + 8); LineTo(Left + 193, Top + 8); + MoveTo(Left + 189, Top + 9); LineTo(Left + 192, Top + 9); + MoveTo(Left + 190, Top + 10); LineTo(Left + 191, Top + 10); + end; + end; +end; + +procedure TfrxCrossEditorForm.CellsLBDrawItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +begin + with TListBox(Control), TListBox(Control).Canvas do + begin + FillRect(ARect); + TextOut(ARect.Left + 2, ARect.Top + 1, Items[Index]); + TextOut(ARect.Left + 200, ARect.Top + 1, FFuncNames[FCross.CellFunctions[Index]]); + Pen.Color := clGray; + Brush.Color := clWindow; + Rectangle(ARect.Left + 185, ARect.Top + 3, ARect.Left + 196, ARect.Top + 14); + + Pen.Color := clBlack; + with ARect do + begin + MoveTo(Left + 187, Top + 7); LineTo(Left + 194, Top + 7); + MoveTo(Left + 188, Top + 8); LineTo(Left + 193, Top + 8); + MoveTo(Left + 189, Top + 9); LineTo(Left + 192, Top + 9); + MoveTo(Left + 190, Top + 10); LineTo(Left + 191, Top + 10); + end; + end; +end; + + +initialization + frxComponentEditors.Register(TfrxCrossView, TfrxCrossEditor); + frxComponentEditors.Register(TfrxDBCrossView, TfrxCrossEditor); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCrossRTTI.pas b/official/4.2/LibD11/frxCrossRTTI.pas new file mode 100644 index 0000000..776c3ee --- /dev/null +++ b/official/4.2/LibD11/frxCrossRTTI.pas @@ -0,0 +1,133 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Cross-tab RTTI } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCrossRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, frxCross, frxClassRTTI +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + with AddClass(TfrxCustomCrossView, 'TfrxView') do + begin + AddMethod('procedure AddValue(Rows, Columns, Cells: array)', CallMethod); + AddMethod('procedure BeginMatrix', CallMethod); + AddMethod('function ColCount: Integer', CallMethod); + AddMethod('function RowCount: Integer', CallMethod); + AddMethod('function IsGrandTotalColumn(Index: Integer): Boolean', CallMethod); + AddMethod('function IsGrandTotalRow(Index: Integer): Boolean', CallMethod); + AddMethod('function IsTotalColumn(Index: Integer): Boolean', CallMethod); + AddMethod('function IsTotalRow(Index: Integer): Boolean', CallMethod); + AddProperty('ClearBeforePrint', 'Boolean', GetProp, SetProp); + end; + + AddClass(TfrxCrossView, 'TfrxCustomCrossView'); + AddClass(TfrxDBCrossView, 'TfrxCustomCrossView'); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +var + ar: array[0..2] of array of Variant; + + procedure ConvertVariantToArray(v: Variant; Index: Integer); + var + i: Integer; + begin + SetLength(ar[Index], VarArrayHighBound(v, 1) + 1); + for i := 0 to VarArrayHighBound(v, 1) do + ar[Index][i] := v[i]; + end; + +begin + Result := 0; + + if MethodName = 'ADDVALUE' then + begin + ConvertVariantToArray(Caller.Params[0], 0); + ConvertVariantToArray(Caller.Params[1], 1); + ConvertVariantToArray(Caller.Params[2], 2); + TfrxCustomCrossView(Instance).AddValue(ar[0], ar[1], ar[2]); + ar[0] := nil; + ar[1] := nil; + ar[2] := nil; + end + else if MethodName = 'BEGINMATRIX' then + TfrxCustomCrossView(Instance).BeginMatrix + else if MethodName = 'COLCOUNT' then + Result := TfrxCustomCrossView(Instance).ColCount + else if MethodName = 'ROWCOUNT' then + Result := TfrxCustomCrossView(Instance).RowCount + else if MethodName = 'ISGRANDTOTALCOLUMN' then + Result := TfrxCustomCrossView(Instance).IsGrandTotalColumn(Caller.Params[0]) + else if MethodName = 'ISGRANDTOTALROW' then + Result := TfrxCustomCrossView(Instance).IsGrandTotalRow(Caller.Params[0]) + else if MethodName = 'ISTOTALCOLUMN' then + Result := TfrxCustomCrossView(Instance).IsTotalColumn(Caller.Params[0]) + else if MethodName = 'ISTOTALROW' then + Result := TfrxCustomCrossView(Instance).IsTotalRow(Caller.Params[0]) +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if PropName = 'CLEARBEFOREPRINT' then + Result := TfrxCustomCrossView(Instance).ClearBeforePrint +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin + if PropName = 'CLEARBEFOREPRINT' then + TfrxCustomCrossView(Instance).ClearBeforePrint := Value; +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCrypt.pas b/official/4.2/LibD11/frxCrypt.pas new file mode 100644 index 0000000..0b0257c --- /dev/null +++ b/official/4.2/LibD11/frxCrypt.pas @@ -0,0 +1,121 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report encrypt/decrypt } +{ } +{ Copyright (c) 2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCrypt; + +interface + +{$I frx.inc} + +uses Windows, Classes, SysUtils, Forms, Controls, frxClass; + +type + TfrxCrypt = class(TfrxCustomCrypter) + private + function AskKey(const Key: String): String; + public + procedure Crypt(Dest: TStream; const Key: String); override; + function Decrypt(Source: TStream; const Key: String): Boolean; override; + end; + + +procedure frxCryptStream(Source, Dest: TStream; const Key: String); +procedure frxDecryptStream(Source, Dest: TStream; const Key: String); + + +implementation + +uses frxUtils, rc_Crypt, frxPassw; + + +function MakeKey(const Key: String): String; +begin + Result := ''; + if (Key <> '') then + begin + SetLength(Result, Length(Key) * 2); + BinToHex(@Key[1], @Result[1], Length(Key)); + end; + Result := ExpandKey(Result, _KEYLength); +end; + +procedure frxCryptStream(Source, Dest: TStream; const Key: String); +var + s: String; + header: array [0..2] of byte; +begin + Source.Position := 0; + SetLength(s, Source.Size); + Source.Read(s[1], Source.Size); + + s := EncryptString(s, MakeKey(Key)); + + header[0] := Ord('r'); + header[1] := Ord('i'); + header[2] := Ord('j'); + Dest.Write(header, 3); + Dest.Write(s[1], Length(s)); +end; + +procedure frxDecryptStream(Source, Dest: TStream; const Key: String); +var + s: String; +begin + SetLength(s, Source.Size); + Source.Read(s[1], Source.Size); + + if (s <> '') and (s[1] = 'r') and (s[2] = 'i') and (s[3] = 'j') then + begin + Delete(s, 1, 3); + s := DecryptString(s, MakeKey(Key)); + end; + + Dest.Write(s[1], Length(s)); +end; + + +{ TfrxCrypt } + +function TfrxCrypt.AskKey(const Key: String): String; +begin + Result := Key; + if Result = '' then + with TfrxPasswordForm.Create(Application) do + begin + if ShowModal = mrOk then + Result := PasswordE.Text; + Free; + end; +end; + +procedure TfrxCrypt.Crypt(Dest: TStream; const Key: String); +begin + frxCryptStream(Stream, Dest, Key); +end; + +function TfrxCrypt.Decrypt(Source: TStream; const Key: String): Boolean; +var + Signature: array[0..2] of Byte; +begin + Source.Read(Signature, 3); + Source.Seek(-3, soFromCurrent); + Result := (Signature[0] = Ord('r')) and (Signature[1] = Ord('i')) and (Signature[2] = Ord('j')); + if Result then + frxDecryptStream(Source, Stream, AskKey(Key)); + Stream.Position := 0; +end; + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCtrls.pas b/official/4.2/LibD11/frxCtrls.pas new file mode 100644 index 0000000..1e0bec4 --- /dev/null +++ b/official/4.2/LibD11/frxCtrls.pas @@ -0,0 +1,1354 @@ +{***************************************************} +{ } +{ FastReport v4.0 } +{ Tool controls } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{ } +{ Flat ComboBox, FontComboBox v1.2 } +{ For Delphi 2,3,4,5. Freeware. } +{ } +{ Copyright (c) 1999 by: } +{ Dmitry Statilko (dima_misc@hotbox.ru) } +{ - Main idea and realisation of Flat ComboBox } +{ inherited from TCustomComboBox } +{ } +{ Vladislav Necheporenko (vlad_n@ua.fm) } +{ - Help in bug fixes } +{ - Adaptation to work on Delphi 2 } +{ - MRU list in FontComboBox that stored values } +{ in regitry } +{ - Font preview box in FontComboBox } +{ - New look style, like in Office XP } +{ } +{***************************************************} + +unit frxCtrls; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, CommCtrl, ExtCtrls, Buttons, Registry, ActiveX +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxCustomComboBox = class(TCustomComboBox) + private + FUpDropdown: Boolean; + FButtonWidth: Integer; + msMouseInControl: Boolean; + FListHandle: HWND; + FListInstance: Pointer; + FDefListProc: Pointer; + FChildHandle: HWND; + FSolidBorder: Boolean; + FReadOnly: Boolean; + FEditOffset: Integer; + FListWidth: Integer; + procedure ListWndProc(var Message: TMessage); + procedure WMPaint(var Message: TWMPaint); message WM_PAINT; + procedure CNCommand(var Message: TWMCommand); message CN_COMMAND; + procedure CMEnabledChanged(var Msg: TMessage); message CM_ENABLEDCHANGED; + procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER; + procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE; + procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED; + procedure PaintButtonGlyph(DC: HDC; X: Integer; Y: Integer; Color: TColor); + procedure PaintButton(ButtonStyle: Integer); + procedure PaintBorder(DC: HDC; const SolidBorder: Boolean); + procedure PaintDisabled; + function GetSolidBorder: Boolean; + function GetListHeight: Integer; + procedure SetReadOnly(Value: Boolean); + protected + procedure CreateParams(var Params: TCreateParams); override; + procedure ComboWndProc(var Message: TMessage; ComboWnd: HWnd; ComboProc: Pointer); override; + procedure WndProc(var Message: TMessage); override; + procedure CreateWnd; override; + procedure DrawImage(DC: HDC; Index: Integer; R: TRect); dynamic; + property ListWidth: Integer read FListWidth write FListWidth; + property ReadOnly: Boolean read FReadOnly write SetReadOnly default False; + property SolidBorder: Boolean read FSolidBorder; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + + TfrxComboBox = class(TfrxCustomComboBox) + published + property Color; + property DragMode; + property DragCursor; + property DropDownCount; + property Enabled; + property Font; + property ItemHeight; + property Items; + property ListWidth; + property MaxLength; + property ParentColor; + property ParentFont; + property ParentShowHint; + property PopupMenu; + property ShowHint; + property Sorted; + property TabOrder; + property TabStop; + property Text; + property ReadOnly; + property Visible; + property ItemIndex; + property OnChange; + property OnClick; + property OnDblClick; + property OnDragDrop; + property OnDragOver; + property OnDrawItem; + property OnDropDown; + property OnEndDrag; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnStartDrag; +{$IFDEF Delphi4} + property Anchors; + property BiDiMode; + property Constraints; + property DragKind; + property ParentBiDiMode; + property OnEndDock; + property OnStartDock; +{$ENDIF} + end; + + TfrxFontPreview = class(TWinControl) + private + FPanel: TPanel; + protected + procedure CreateParams(var Params: TCreateParams); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + + TfrxFontComboBox = class(TfrxCustomComboBox) + private + frFontViewForm: TfrxFontPreview; + FRegKey: String; + FTrueTypeBMP: TBitmap; + FDeviceBMP: TBitmap; + FOnClick: TNotifyEvent; + FUpdate: Boolean; + FShowMRU: Boolean; + Numused: Integer; + procedure CNCommand(var Message: TWMCommand); message CN_COMMAND; + procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED; + procedure CMFontChange(var Message: TMessage); message CM_FONTCHANGE; + procedure SetRegKey(Value: String); + protected + procedure Loaded; override; + procedure Init; + procedure Reset; + procedure Click; override; + procedure DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); override; + procedure DrawImage(DC: HDC; Index: Integer; R: TRect); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure PopulateList; virtual; + published + property ShowMRU: Boolean read FShowMRU write FShowMRU default True; + property MRURegKey: String read FRegKey write SetRegKey; + property Text; + property Color; + property DragMode; + property DragCursor; + property DropDownCount; + property Enabled; + property Font; +{$IFDEF Delphi4} + property Anchors; + property BiDiMode; + property Constraints; + property DragKind; + property ParentBiDiMode; +{$ENDIF} + property ItemHeight; + property ParentColor; + property ParentFont; + property ParentShowHint; + property PopupMenu; + property ShowHint; + property TabOrder; + property TabStop; + property Visible; + property OnChange; + property OnClick: TNotifyEvent read FOnClick write FOnClick; + property OnDblClick; + property OnDragDrop; + property OnDragOver; + property OnDropDown; + property OnEndDrag; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnStartDrag; +{$IFDEF Delphi4} + property OnEndDock; + property OnStartDock; +{$ENDIF} + end; + + TfrxComboEdit = class(TComboBox) + private + FPanel: TWinControl; + FButton: TSpeedButton; + FButtonEnabled: Boolean; + FOnButtonClick: TNotifyEvent; + function GetGlyph: TBitmap; + procedure SetGlyph(Value: TBitmap); + function GetButtonHint: String; + procedure SetButtonHint(Value: String); + procedure SetButtonEnabled(Value: Boolean); + procedure ButtonClick(Sender: TObject); + procedure WMSize(var Message: TWMSize); message WM_SIZE; + procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED; + procedure SetPos; + public + constructor Create(AOwner: TComponent); override; + procedure CreateWnd; override; + procedure KeyPress(var Key: Char); override; + published + property Glyph: TBitmap read GetGlyph write SetGlyph; + property ButtonEnabled: Boolean read FButtonEnabled write SetButtonEnabled default True; + property ButtonHint: String read GetButtonHint write SetButtonHint; + property OnButtonClick: TNotifyEvent read FOnButtonClick write FOnButtonClick; + end; + + TfrxScrollWin = class(TCustomControl) + private + FBorderStyle: TBorderStyle; + FHorzPage: Integer; + FHorzPosition: Integer; + FHorzRange: Integer; + FLargeChange: Integer; + FSmallChange: Integer; + FVertPage: Integer; + FVertPosition: Integer; + FVertRange: Integer; + function GetLongPosition(DefValue: Integer; Code: Word): Integer; + procedure SetHorzPosition(Value: Integer); + procedure SetHorzRange(Value: Integer); + procedure SetPosition(Value: Integer; Code: Word); + procedure SetVertPosition(Value: Integer); + procedure SetVertRange(Value: Integer); + procedure UpdateScrollBar(Max, Page, Pos: Integer; Code: Word); + procedure WMEraseBackground(var Message: TMessage); message WM_ERASEBKGND; + procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE; + procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL; + procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL; + procedure SetHorzPage(const Value: Integer); + procedure SetVertPage(const Value: Integer); + procedure SetBorderStyle(const Value: TBorderStyle); + protected + procedure CreateParams(var Params: TCreateParams); override; + procedure OnHScrollChange(Sender: TObject); virtual; + procedure OnVScrollChange(Sender: TObject); virtual; + public + constructor Create(AOwner: TComponent); override; + procedure Paint; override; + property BevelKind; + property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle; + property HorzPage: Integer read FHorzPage write SetHorzPage; + property HorzPosition: Integer read FHorzPosition write SetHorzPosition; + property HorzRange: Integer read FHorzRange write SetHorzRange; + property LargeChange: Integer read FLargeChange write FLargeChange; + property SmallChange: Integer read FSmallChange write FSmallChange; + property VertPage: Integer read FVertPage write SetVertPage; + property VertPosition: Integer read FVertPosition write SetVertPosition; + property VertRange: Integer read FVertRange write SetVertRange; + end; + + +implementation + +{$R *.RES} +{$IFDEF Delphi6} +{$WARN SYMBOL_DEPRECATED OFF} +{$ENDIF} + +uses frxPrinter, frxClass; + +const + fr01cm = 3.77953; + fr01in = 96 / 10; + +type + THackScrollBar = class(TScrollBar); + + +{ Additional functions } + +function Min(val1, val2: Word): Word; +begin + Result := val1; + if val1 > val2 then + Result := val2; +end; + +function GetFontMetrics(Font: TFont): TTextMetric; +var + DC: HDC; + SaveFont: HFont; +begin + DC := GetDC(0); + SaveFont := SelectObject(DC, Font.Handle); + GetTextMetrics(DC, Result); + SelectObject(DC, SaveFont); + ReleaseDC(0, DC); +end; + +function GetFontHeight(Font: TFont): Integer; +begin + Result := GetFontMetrics(Font).tmHeight; +end; + +function Blend(C1, C2: TColor; W1: Integer): TColor; +var + W2, A1, A2, D, F, G: Integer; +begin + if C1 < 0 then C1 := GetSysColor(C1 and $FF); + if C2 < 0 then C2 := GetSysColor(C2 and $FF); + + if W1 >= 100 then D := 1000 + else D := 100; + + W2 := D - W1; + F := D div 2; + + A2 := C2 shr 16 * W2; + A1 := C1 shr 16 * W1; + G := (A1 + A2 + F) div D and $FF; + Result := G shl 16; + + A2 := (C2 shr 8 and $FF) * W2; + A1 := (C1 shr 8 and $FF) * W1; + G := (A1 + A2 + F) div D and $FF; + Result := Result or G shl 8; + + A2 := (C2 and $FF) * W2; + A1 := (C1 and $FF) * W1; + G := (A1 + A2 + F) div D and $FF; + Result := Result or G; +end; + +{ TfrxCustomComboBox } + +constructor TfrxCustomComboBox.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FListInstance := MakeObjectInstance(ListWndProc); + FDefListProc := nil; + FButtonWidth := 11; + ItemHeight := GetFontHeight(Font); + Width := 100; + FEditOffset := 0; +end; + +destructor TfrxCustomComboBox.Destroy; +begin + inherited Destroy; + FreeObjectInstance(FListInstance); +end; + +procedure TfrxCustomComboBox.SetReadOnly(Value: Boolean); +begin + if FReadOnly <> Value then + begin + FReadOnly := Value; + if HandleAllocated then + SendMessage(EditHandle, EM_SETREADONLY, Ord(Value), 0); + end; +end; + +procedure TfrxCustomComboBox.CreateParams(var Params: TCreateParams); +begin + inherited CreateParams(Params); + with Params do + Style := (Style and not CBS_DROPDOWNLIST) or CBS_OWNERDRAWFIXED or CBS_DROPDOWN; +end; + +procedure TfrxCustomComboBox.CreateWnd; +begin + inherited; + SendMessage(EditHandle, EM_SETREADONLY, Ord(FReadOnly), 0); + // Desiding, which of the handles is DropDown list handle... + if FChildHandle <> EditHandle then + FListHandle := FChildHandle; + //.. and superclassing it + FDefListProc := Pointer(GetWindowLong(FListHandle, GWL_WNDPROC)); + SetWindowLong(FListHandle, GWL_WNDPROC, Longint(FListInstance)); +end; + + +procedure TfrxCustomComboBox.ListWndProc(var Message: TMessage); +var + p: TPoint; + + procedure CallDefaultProc; + begin + with Message do + Result := CallWindowProc(FDefListProc, FListHandle, Msg, WParam, LParam); + end; + +begin + case Message.Msg of + LB_SETTOPINDEX: + begin + if ItemIndex > DropDownCount then + CallDefaultProc; + end; + WM_WINDOWPOSCHANGING: + with TWMWindowPosMsg(Message).WindowPos^ do + begin + // calculating the size of the drop down list + if FListWidth <> 0 then + cx := FListWidth else + cx := Width; + cy := GetListHeight; + p.x := cx; + p.y := cy + GetFontHeight(Font) + 6; + p := ClientToScreen(p); + FUpDropdown := False; + if p.y > Screen.Height then //if DropDownList showing below + begin + FUpDropdown := True; + end; + end; + else + CallDefaultProc; + end; +end; + +procedure TfrxCustomComboBox.WndProc(var Message: TMessage); +begin + case Message.Msg of + WM_SETTEXT: + Invalidate; + WM_PARENTNOTIFY: + if LoWord(Message.wParam)=WM_CREATE then begin + if FDefListProc <> nil then + begin + // This check is necessary to be sure that combo is created, not + // RECREATED (somehow CM_RECREATEWND does not work) + SetWindowLong(FListHandle, GWL_WNDPROC, Longint(FDefListProc)); + FDefListProc := nil; + FChildHandle := Message.lParam; + end + else + begin + // WM_Create is the only event I found where I can get the ListBox handle. + // The fact that combo box usually creates more then 1 handle complicates the + // things, so I have to have the FChildHandle to resolve it later (in CreateWnd). + if FChildHandle = 0 then + FChildHandle := Message.lParam + else + FListHandle := Message.lParam; + end; + end; + WM_WINDOWPOSCHANGING: + MoveWindow(EditHandle, 3+FEditOffset, 3, Width-FButtonWidth-8-FEditOffset, + Height-6, True); + end; + inherited; +end; + +procedure TfrxCustomComboBox.WMPaint(var Message: TWMPaint); +var + PS, PSE: TPaintStruct; +begin + BeginPaint(Handle,PS); + try + if Enabled then + begin + DrawImage(PS.HDC, ItemIndex ,Rect(3, 3, FEditOffset + 3, Height - 3)); + if GetSolidBorder then + begin + PaintBorder(PS.HDC, True); + if DroppedDown then + PaintButton(2) + else + PaintButton(1); + end else + begin + PaintBorder(PS.HDC, False); + PaintButton(0); + end; + end else + begin + BeginPaint(EditHandle, PSE); + try + PaintDisabled; + finally + EndPaint(EditHandle, PSE); + end; + end; + finally + EndPaint(Handle,PS); + end; + Message.Result := 0; +end; + +procedure TfrxCustomComboBox.DrawImage(DC: HDC; Index: Integer; R: TRect); +begin + if FEditOffset > 0 then + FillRect(DC, R, GetSysColorBrush(COLOR_WINDOW)); +end; + +procedure TfrxCustomComboBox.ComboWndProc(var Message: TMessage; ComboWnd: HWnd; + ComboProc: Pointer); +var + DC: HDC; +begin + inherited; + if (ComboWnd = EditHandle) then + case Message.Msg of + WM_SETFOCUS: + begin + DC:=GetWindowDC(Handle); + PaintBorder(DC,True); + PaintButton(1); + ReleaseDC(Handle,DC); + end; + WM_KILLFOCUS: + begin + DC:=GetWindowDC(Handle); + PaintBorder(DC,False); + PaintButton(0); + ReleaseDC(Handle,DC); + end; + end; +end; + +procedure TfrxCustomComboBox.CNCommand(var Message: TWMCommand); +begin + inherited; + if (Message.NotifyCode in [CBN_CLOSEUP]) then + PaintButton(1); +end; + +procedure TfrxCustomComboBox.PaintBorder(DC: HDC; const SolidBorder: Boolean); +var + R: TRect; +begin + GetWindowRect(Handle, R); + OffsetRect(R, -R.Left, -R.Top); + if SolidBorder then + FrameRect(DC, R, GetSysColorBrush(COLOR_HIGHLIGHT)) + else + FrameRect(DC, R, GetSysColorBrush(COLOR_BTNFACE)); + InflateRect(R, -1, -1); + FrameRect(DC, R, GetSysColorBrush(COLOR_WINDOW)); + InflateRect(R, -1, -1); + R.Right:=R.Right - FButtonWidth - 2; + FrameRect(DC, R, GetSysColorBrush(COLOR_WINDOW)); +end; + +procedure TfrxCustomComboBox.PaintButtonGlyph(DC: HDC; X: Integer; Y: Integer; Color: TColor); +var + Pen, SavePen: HPEN; +begin + Pen := CreatePen(PS_SOLID, 1, ColorToRGB(Color)); + SavePen := SelectObject(DC, Pen); + MoveToEx(DC, X, Y, nil); + LineTo(DC, X + 5, Y); + MoveToEx(DC, X + 1, Y + 1, nil); + LineTo(DC, X + 4, Y + 1); + MoveToEx(DC, x + 2, Y + 2, nil); + LineTo(DC, X + 3, Y + 2); + SelectObject(DC, SavePen); + DeleteObject(Pen); +end; + +procedure TfrxCustomComboBox.PaintButton(ButtonStyle: Integer); +var + R: TRect; + DC: HDC; + X, Y: Integer; + + procedure FillButton(DC: HDC; R: TRect; Color: TColor); + var + Brush, SaveBrush: HBRUSH; + begin + Brush := CreateSolidBrush(ColorToRGB(Color)); + SaveBrush := SelectObject(DC, Brush); + FillRect(DC, R, Brush); + SelectObject(DC, SaveBrush); + DeleteObject(Brush); + end; + + procedure PaintButtonLine(DC: HDC; Color: TColor); + var + Pen, SavePen: HPEN; + R: TRect; + begin + GetWindowRect(Handle, R); + OffsetRect (R, -R.Left, -R.Top); + InflateRect(R, -FButtonWidth - 4, -1); + Pen := CreatePen(PS_SOLID, 1, ColorToRGB(Color)); + SavePen := SelectObject(DC, Pen); + MoveToEx(DC, R.Right, R.Top, nil); + LineTo(DC, R.Right, R.Bottom); + SelectObject(DC, SavePen); + DeleteObject(Pen); + end; + +begin + DC := GetWindowDC(Handle); + X := Trunc(FButtonWidth / 2) + Width - FButtonWidth - 4; + Y := Trunc((Height - 4) / 2) + 1; + SetRect(R, Width - FButtonWidth - 3, 1, Width - 1, Height - 1); + if ButtonStyle = 0 then //No 3D border + begin + FillButton(DC, R, clBtnFace); + FrameRect(DC, R, GetSysColorBrush(COLOR_WINDOW)); + PaintButtonLine(DC, clWindow); + PaintButtonGlyph(DC, X, Y, clBtnText); + end; + if ButtonStyle = 1 then //3D up border + begin + FillButton(DC, R, Blend(clHighlight, clWindow, 30)); + PaintButtonLine(DC, clHighlight); + PaintButtonGlyph(DC, X, Y, clBtnText); + end; + if ButtonStyle = 2 then //3D down border + begin + FillButton(DC, R, Blend(clHighlight, clWindow, 50)); + PaintButtonLine(DC, clHighlight); + PaintButtonGlyph(DC, X, Y, clCaptionText); + end; + ReleaseDC(Handle, DC); +end; + +procedure TfrxCustomComboBox.PaintDisabled; +var + R: TRect; + Brush, SaveBrush: HBRUSH; + DC: HDC; + BtnShadowBrush: HBRUSH; +begin + BtnShadowBrush := GetSysColorBrush(COLOR_BTNSHADOW); + DC := GetWindowDC(Handle); + Brush := CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); + SaveBrush := SelectObject(DC, Brush); + FillRect(DC, ClientRect, Brush); + SelectObject(DC, SaveBrush); + DeleteObject(Brush); + GetWindowRect(Handle, R); + OffsetRect(R, -R.Left, -R.Top); + FrameRect(DC, R, BtnShadowBrush); + PaintButtonGlyph(DC, Trunc(FButtonWidth / 2) + Width - FButtonWidth - 4, + Trunc((Height - 4) / 2) + 1, clGrayText); + ReleaseDC(Handle,DC); +end; + +procedure TfrxCustomComboBox.CMEnabledChanged(var Msg: TMessage); +begin + inherited; + Invalidate; +end; + +procedure TfrxCustomComboBox.CMMouseEnter(var Message: TMessage); +var + DC: HDC; +begin + inherited; + msMouseInControl := True; + if Enabled and not (GetFocus = EditHandle) and not DroppedDown then + begin + DC:=GetWindowDC(Handle); + PaintBorder(DC, True); + PaintButton(1); + ReleaseDC(Handle, DC); + end; +end; + +procedure TfrxCustomComboBox.CMMouseLeave(var Message: TMessage); +var + DC: HDC; +begin + inherited; + msMouseInControl := False; + if Enabled and not (GetFocus = EditHandle) and not DroppedDown then + begin + DC:=GetWindowDC(Handle); + PaintBorder(DC, False); + PaintButton(0); + ReleaseDC(Handle, DC); + end; +end; + +function TfrxCustomComboBox.GetSolidBorder: Boolean; +begin + Result := ((csDesigning in ComponentState)) or + (DroppedDown or (GetFocus = EditHandle) or msMouseInControl); +end; + +function TfrxCustomComboBox.GetListHeight: Integer; +begin + Result := ItemHeight * Min(DropDownCount, Items.Count) + 2; + if (DropDownCount <= 0) or (Items.Count = 0) then + Result := ItemHeight + 2; +end; + +procedure TfrxCustomComboBox.CMFontChanged(var Message: TMessage); +begin + inherited; + ItemHeight := GetFontHeight(Font); + RecreateWnd; +end; + + +{ TfrxFontComboBox } + +function CreateBitmap(ResName: PChar): TBitmap; +begin + Result := TBitmap.Create; + Result.Handle := LoadBitmap(HInstance, ResName); + if Result.Handle = 0 then + begin + Result.Free; + Result := nil; + end; +end; + +function EnumFontsProc(var LogFont: TLogFont; var TextMetric: TTextMetric; + FontType: Integer; Data: Pointer): Integer; stdcall; +begin + if (TStrings(Data).IndexOf(LogFont.lfFaceName) < 0) then + TStrings(Data).AddObject(LogFont.lfFaceName, TObject(FontType)); + Result := 1; +end; + +constructor TfrxFontComboBox.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + if not (csDesigning in ComponentState) then + frFontViewForm := TfrxFontPreview.Create(Self); + FTrueTypeBMP := CreateBitmap('FRXTRUETYPE_FNT'); + FDeviceBMP := CreateBitmap('FRXDEVICE_FNT'); + DropDownCount := 12; + Width := 150; + FEditOffset := 16; + FReadOnly := True; + FShowMRU := True; + Numused := -1; + MRURegKey := ''; +end; + +destructor TfrxFontComboBox.Destroy; +begin + FTrueTypeBMP.Free; + FDeviceBMP.Free; + if not (csDesigning in ComponentState) then + frFontViewForm.Destroy; + inherited Destroy; +end; + +procedure TfrxFontComboBox.Loaded; +begin + inherited Loaded; + if csDesigning in ComponentState then exit; + FUpdate := True; + try + PopulateList; + if Items.IndexOf(Text) = -1 then + ItemIndex:=0; + finally + FUpdate := False; + end; +end; + +procedure TfrxFontComboBox.SetRegKey(Value: String); +begin + if Value = '' then + FRegKey := '\Software\Fast Reports\MRUFont' else + FRegKey := Value; +end; + +procedure TfrxFontComboBox.PopulateList; +var + LFont: TLogFont; + DC: HDC; + Reg: TRegistry; + s: String; + i: Integer; + str: TStringList; +begin + Sorted:=True; + Items.BeginUpdate; + str := TStringList.Create; + str.Sorted := True; + try + Clear; + DC := GetDC(0); + try + FillChar(LFont, sizeof(LFont), 0); + LFont.lfCharset := DEFAULT_CHARSET; + EnumFontFamiliesEx(DC, LFont, @EnumFontsProc, LongInt(str), 0); + finally + ReleaseDC(0, DC); + end; + if frxPrinters.HasPhysicalPrinters then + try + FillChar(LFont, sizeof(LFont), 0); + LFont.lfCharset := DEFAULT_CHARSET; + EnumFontFamiliesEx(frxPrinters.Printer.Canvas.Handle, LFont, @EnumFontsProc, LongInt(str), 0); + except; + end; + finally + Items.Assign(str); + Items.EndUpdate; + end; + str.Free; + Sorted := False; + if FShowMRU then + begin + NumUsed := -1; + Items.BeginUpdate; + Reg:=TRegistry.Create; + try + Reg.OpenKey(FRegKey, True); + for i := 4 downto 0 do + begin + s := Reg.ReadString('Font' + IntToStr(i)); + if (s <> '') and (Items.IndexOf(s) <> -1) then + begin + Items.InsertObject(0, s, TObject(Reg.ReadInteger('FontType' + IntToStr(i)))); + Inc(Numused); + end else + begin + Reg.WriteString('Font' + IntToStr(i), ''); + Reg.WriteInteger('FontType' + IntToStr(i), 0); + end; + end; + finally + Reg.Free; + Items.EndUpdate; + end; + end; +end; + +procedure TfrxFontComboBox.DrawImage(DC: HDC; Index: Integer; R: TRect); +var + C: TCanvas; + Bitmap: TBitmap; +begin + inherited; + Index := Items.IndexOf(Text); + if Index = -1 then exit; + C := TCanvas.Create; + C.Handle := DC; + if (Integer(Items.Objects[Index]) and TRUETYPE_FONTTYPE) <> 0 then + Bitmap := FTrueTypeBMP + else if (Integer(Items.Objects[Index]) and DEVICE_FONTTYPE) <> 0 then + Bitmap := FDeviceBMP + else + Bitmap := nil; + if Bitmap <> nil then + begin + C.Brush.Color := clWindow; + C.BrushCopy(Bounds(R.Left, (R.Top + R.Bottom - Bitmap.Height) + div 2, Bitmap.Width, Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width, + Bitmap.Height), Bitmap.TransparentColor); + end; + C.Free; +end; + + +procedure TfrxFontComboBox.DrawItem(Index: Integer; Rect: TRect; + State: TOwnerDrawState); +var + Bitmap: TBitmap; + BmpWidth: Integer; + Text: array[0..255] of Char; +begin + if odSelected in State then + begin + frFontViewForm.FPanel.Caption:=self.Items[index]; + frFontViewForm.FPanel.Font.Name:=self.Items[index]; + end; + with Canvas do + begin + BmpWidth := 15; + FillRect(Rect); + if (Integer(Items.Objects[Index]) and TRUETYPE_FONTTYPE) <> 0 then + Bitmap := FTrueTypeBMP + else if (Integer(Items.Objects[Index]) and DEVICE_FONTTYPE) <> 0 then + Bitmap := FDeviceBMP + else + Bitmap := nil; + + if Bitmap <> nil then + begin + BmpWidth := Bitmap.Width; + BrushCopy(Bounds(Rect.Left+1 , (Rect.Top + Rect.Bottom - Bitmap.Height) + div 2, Bitmap.Width, Bitmap.Height), Bitmap, Bounds(0, 0, Bitmap.Width, + Bitmap.Height), Bitmap.TransparentColor); + end; + StrPCopy(Text, Items[Index]); + Rect.Left := Rect.Left + BmpWidth + 2; + DrawText(Canvas.Handle, Text, StrLen(Text), Rect, +{$IFDEF Delphi4} + DrawTextBiDiModeFlags(DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX)); +{$ELSE} + DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX); +{$ENDIF} + if (Index = Numused) then + begin + Pen.Color := clBtnShadow; + MoveTo(0,Rect.Bottom - 2); + LineTo(width, Rect.Bottom - 2); + end; + if (Index = Numused + 1) and (Numused <> -1) then + begin + Pen.Color := clBtnShadow; + MoveTo(0, Rect.Top); + LineTo(width, Rect.Top); + end; + end; +end; + +procedure TfrxFontComboBox.CMFontChanged(var Message: TMessage); +begin + inherited; + Init; +end; + +procedure TfrxFontComboBox.CMFontChange(var Message: TMessage); +begin + inherited; + Reset; +end; + +procedure TfrxFontComboBox.Init; +begin + if GetFontHeight(Font) > FTrueTypeBMP.Height then + ItemHeight := GetFontHeight(Font) + else + ItemHeight := FTrueTypeBMP.Height + 1; + RecreateWnd; +end; + +procedure TfrxFontComboBox.Click; +begin + inherited Click; + if not (csReading in ComponentState) then + if not FUpdate and Assigned(FOnClick) then FOnClick(Self); +end; + +procedure TfrxFontComboBox.Reset; +begin + if csDesigning in ComponentState then exit; + FUpdate := True; + try + PopulateList; + if Items.IndexOf(Text) = -1 then + ItemIndex := 0; + finally + FUpdate := False; + end; +end; + +procedure TfrxFontComboBox.CNCommand(var Message: TWMCommand); +var + pnt:TPoint; + ind,i:integer; + Reg: TRegistry; +begin + inherited; + if (Message.NotifyCode in [CBN_CLOSEUP]) then + begin + frFontViewForm.Visible := False; + ind := itemindex; + if (ItemIndex = -1) or (ItemIndex = 0) then exit; + if FShowMRU then + begin + Items.BeginUpdate; + if Items.IndexOf(Items[ind]) <= Numused then + begin + Items.Move(Items.IndexOf(Items[ind]), 0); + ItemIndex := 0; + end else + begin + Items.InsertObject(0, Items[ItemIndex], Items.Objects[ItemIndex]); + Itemindex := 0; + if Numused < 4 then + Inc(Numused) + else + Items.Delete(5); + end; + Items.EndUpdate; + Reg := TRegistry.Create; + try + Reg.OpenKey(FRegKey,True); + for i := 0 to 4 do + if i <= Numused then + begin + Reg.WriteString('Font' + IntToStr(i), Items[i]); + Reg.WriteInteger('FontType' + IntToStr(i), Integer(Items.Objects[i])); + end else + begin + Reg.WriteString('Font' + IntToStr(i), ''); + Reg.WriteInteger('FontType' + IntToStr(i), 0); + end; + finally + Reg.Free; + end; + end; + end; + if (Message.NotifyCode in [CBN_DROPDOWN]) then + begin + if ItemIndex < 5 then + PostMessage(FListHandle, LB_SETCURSEL, 0, 0); + pnt.x := Self.Left + Self.Width; + pnt.y := Self.Top + Self.Height; + pnt := Parent.ClientToScreen(pnt); + frFontViewForm.Top := pnt.y; + frFontViewForm.Left := pnt.x + 1; + + if frFontViewForm.Left+frFontViewForm.Width > Screen.Width then + begin + pnt.x := Self.Left; + pnt := Parent.ClientToScreen(pnt); + frFontViewForm.Left := pnt.x - frFontViewForm.Width - 1; + end; + if FUpDropdown then + begin + pnt.y := Self.Top; + pnt := Parent.ClientToScreen(pnt); + frFontViewForm.Top := pnt.y - frFontViewForm.Height; + end; + frFontViewForm.Visible := True; + end; +end; + + +{ TfrxFontPreview } + +constructor TfrxFontPreview.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Width := 200; + Height := 50; + Visible := False; + Parent := AOwner as TWinControl; + + FPanel := TPanel.Create(Self); + with FPanel do + begin + Parent := Self; + Color := clWindow; + Ctl3D := False; + ParentCtl3D := False; + BorderStyle := bsSingle; + BevelInner := bvNone; + BevelOuter := bvNone; + Font.Color := clWindowText; + Font.Size := 18; + Align := alClient; + end; +end; + +destructor TfrxFontPreview.Destroy; +begin + FPanel.Free; + FPanel := nil; + inherited Destroy; +end; + +procedure TfrxFontPreview.CreateParams(var Params: TCreateParams); +begin + inherited CreateParams( Params); + with Params do begin + Style := WS_POPUP or WS_CLIPCHILDREN; + ExStyle := WS_EX_TOOLWINDOW; + WindowClass.Style := WindowClass.Style or CS_SAVEBITS; + end; +end; + + +{ TfrxComboEdit } + +constructor TfrxComboEdit.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Style := csSimple; + Height := 21; + FPanel := TPanel.Create(Self); + FPanel.Parent := Self; + FPanel.SetBounds(Width - Height + 2, 2, Height - 4, Height - 4); + FButton := TSpeedButton.Create(Self); + FButton.Parent := FPanel; + FButton.SetBounds(0, 0, FPanel.Width, FPanel.Height); + FButton.OnClick := ButtonClick; + FButtonEnabled := True; +end; + +procedure TfrxComboEdit.SetPos; +begin + SetWindowPos(EditHandle, 0, 0, 0, Width - Height - 4, ItemHeight, + SWP_NOMOVE or SWP_NOZORDER or SWP_NOACTIVATE) +end; + +procedure TfrxComboEdit.CreateWnd; +begin + inherited CreateWnd; + SetPos; +end; + +procedure TfrxComboEdit.WMSize(var Message: TWMSize); +begin + inherited; + FPanel.SetBounds(Width - Height + 2, 2, Height - 4, Height - 4); +end; + +procedure TfrxComboEdit.CMEnabledChanged(var Message: TMessage); +begin + inherited; + FButton.Enabled := Enabled; +end; + +procedure TfrxComboEdit.KeyPress(var Key: Char); +begin + if (Key = Char(vk_Return)) or (Key = Char(vk_Escape)) then + GetParentForm(Self).Perform(CM_DIALOGKEY, Byte(Key), 0); + inherited KeyPress(Key); +end; + +function TfrxComboEdit.GetGlyph: TBitmap; +begin + Result := FButton.Glyph; +end; + +procedure TfrxComboEdit.SetGlyph(Value: TBitmap); +begin + FButton.Glyph := Value; +end; + +function TfrxComboEdit.GetButtonHint: String; +begin + Result := FButton.Hint; +end; + +procedure TfrxComboEdit.SetButtonHint(Value: String); +begin + FButton.Hint := Value; +end; + +procedure TfrxComboEdit.SetButtonEnabled(Value: Boolean); +begin + FButtonEnabled := Value; + FButton.Enabled := Value; +end; + +procedure TfrxComboEdit.ButtonClick(Sender: TObject); +begin + SetFocus; + if Assigned(FOnButtonClick) then + FOnButtonClick(Self); +end; + + +{ TfrxScrollWin } + +constructor TfrxScrollWin.Create(AOwner: TComponent); +begin + inherited; + FSmallChange := 1; + FLargeChange := 10; +{$IFDEF Delphi7} + ControlStyle := ControlStyle + [csNeedsBorderPaint]; +{$ENDIF} +end; + +procedure TfrxScrollWin.CreateParams(var Params: TCreateParams); +const + BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER); +begin + inherited; + with Params do + begin + Style := Style or WS_CLIPCHILDREN or WS_HSCROLL or + WS_VSCROLL or BorderStyles[FBorderStyle]; + if Ctl3D and NewStyleControls and (FBorderStyle = bsSingle) then + begin + Style := Style and not WS_BORDER; + ExStyle := ExStyle or WS_EX_CLIENTEDGE; + end; + end; +end; + +procedure TfrxScrollWin.SetBorderStyle(const Value: TBorderStyle); +begin + FBorderStyle := Value; + RecreateWnd; +end; + +procedure TfrxScrollWin.WMEraseBackground(var Message: TMessage); +begin +end; + +procedure TfrxScrollWin.WMGetDlgCode(var Message: TWMGetDlgCode); +begin + Message.Result := DLGC_WANTARROWS or DLGC_WANTTAB or DLGC_WANTALLKEYS; +end; + +function TfrxScrollWin.GetLongPosition(DefValue: Integer; Code: Word): Integer; +var + ScrollInfo: TScrollInfo; +begin + ScrollInfo.cbSize := SizeOf(TScrollInfo); + ScrollInfo.fMask := SIF_TRACKPOS; + Result := DefValue; + if FlatSB_GetScrollInfo(Handle, Code, ScrollInfo) then + Result := ScrollInfo.nTrackPos; +end; + +procedure TfrxScrollWin.SetHorzPage(const Value: Integer); +begin + FHorzPage := Value; + HorzRange := HorzRange; +end; + +procedure TfrxScrollWin.SetHorzPosition(Value: Integer); +begin + if Value > FHorzRange - FHorzPage then + Value := FHorzRange - FHorzPage; + if Value < 0 then + Value := 0; + if Value <> FHorzPosition then + begin + FHorzPosition := Value; + SetPosition(Value, SB_HORZ); + OnHScrollChange(Self); + end; +end; + +procedure TfrxScrollWin.SetHorzRange(Value: Integer); +begin + FHorzRange := Value; + UpdateScrollBar(Value, HorzPage, HorzPosition, SB_HORZ); +end; + +procedure TfrxScrollWin.SetVertPage(const Value: Integer); +begin + FVertPage := Value; + VertRange := VertRange; +end; + +procedure TfrxScrollWin.SetVertPosition(Value: Integer); +begin + if Value > FVertRange - FVertPage then + Value := FVertRange - FVertPage; + if Value < 0 then + Value := 0; + if Value <> FVertPosition then + begin + FVertPosition := Value; + SetPosition(Value, SB_VERT); + OnVScrollChange(Self); + end; +end; + +procedure TfrxScrollWin.SetVertRange(Value: Integer); +begin + FVertRange := Value; + UpdateScrollBar(Value, VertPage, VertPosition, SB_VERT); +end; + +procedure TfrxScrollWin.SetPosition(Value: Integer; Code: Word); +begin + FlatSB_SetScrollPos(Handle, Code, Value, True); +end; + +procedure TfrxScrollWin.UpdateScrollBar(Max, Page, Pos: Integer; Code: Word); +var + ScrollInfo: TScrollInfo; +begin + ScrollInfo.cbSize := SizeOf(ScrollInfo); + ScrollInfo.fMask := SIF_ALL; + ScrollInfo.nMin := 0; + if Max < Page then + Max := 0; + ScrollInfo.nMax := Max; + ScrollInfo.nPage := Page; + ScrollInfo.nPos := Pos; + ScrollInfo.nTrackPos := Pos; + FlatSB_SetScrollInfo(Handle, Code, ScrollInfo, True); +end; + +procedure TfrxScrollWin.Paint; +begin + with Canvas do + begin + Brush.Color := Color; + FillRect(Rect(0, 0, ClientWidth, ClientHeight)); + end; +end; + +procedure TfrxScrollWin.WMHScroll(var Message: TWMHScroll); +begin + case Message.ScrollCode of + SB_LINEUP: HorzPosition := HorzPosition - FSmallChange; + SB_LINEDOWN: HorzPosition := HorzPosition + FSmallChange; + SB_PAGEUP: HorzPosition := HorzPosition - FLargeChange; + SB_PAGEDOWN: HorzPosition := HorzPosition + FLargeChange; + SB_THUMBPOSITION, SB_THUMBTRACK: + HorzPosition := GetLongPosition(Message.Pos, SB_HORZ); + SB_TOP: HorzPosition := 0; + SB_BOTTOM: HorzPosition := HorzRange; + end; +end; + +procedure TfrxScrollWin.WMVScroll(var Message: TWMVScroll); +begin + case Message.ScrollCode of + SB_LINEUP: VertPosition := VertPosition - FSmallChange; + SB_LINEDOWN: VertPosition := VertPosition + FSmallChange; + SB_PAGEUP: VertPosition := VertPosition - FLargeChange; + SB_PAGEDOWN: VertPosition := VertPosition + FLargeChange; + SB_THUMBPOSITION, SB_THUMBTRACK: + VertPosition := GetLongPosition(Message.Pos, SB_VERT); + SB_TOP: VertPosition := 0; + SB_BOTTOM: VertPosition := VertRange; + end; +end; + +procedure TfrxScrollWin.OnHScrollChange(Sender: TObject); +begin +end; + +procedure TfrxScrollWin.OnVScrollChange(Sender: TObject); +begin +end; + + +end. + + +//82e9985cec73d6900794b78cc3da874d + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCtrls.res b/official/4.2/LibD11/frxCtrls.res new file mode 100644 index 0000000..ab2dcf5 Binary files /dev/null and b/official/4.2/LibD11/frxCtrls.res differ diff --git a/official/4.2/LibD11/frxCustomDB.pas b/official/4.2/LibD11/frxCustomDB.pas new file mode 100644 index 0000000..89616f8 --- /dev/null +++ b/official/4.2/LibD11/frxCustomDB.pas @@ -0,0 +1,793 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Custom TDataSet-based classes } +{ for enduser DB components } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCustomDB; + +interface + +{$I frx.inc} + +uses + Windows, Classes, SysUtils, DB, frxClass, frxDBSet, DBCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF QBUILDER} +, fqbClass +{$ENDIF} +{$IFDEF FR_COM} +, FastReport_TLB +{$ENDIF}; + + +type + TfrxCustomDataset = class(TfrxDBDataSet) + private + FDBConnected: Boolean; + FDataSource: TDataSource; + FMaster: TfrxDBDataSet; + FMasterFields: String; + procedure SetActive(Value: Boolean); + procedure SetFilter(const Value: String); + procedure SetFiltered(Value: Boolean); + function GetActive: Boolean; + function GetFields: TFields; + function GetFilter: String; + function GetFiltered: Boolean; + procedure InternalSetMaster(const Value: TfrxDBDataSet); + procedure InternalSetMasterFields(const Value: String); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure SetParent(AParent: TfrxComponent); override; + procedure SetUserName(const Value: String); override; + procedure SetMaster(const Value: TDataSource); virtual; + procedure SetMasterFields(const Value: String); virtual; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure OnPaste; override; + property DBConnected: Boolean read FDBConnected write FDBConnected; + property Fields: TFields read GetFields; + property MasterFields: String read FMasterFields write InternalSetMasterFields; + property Active: Boolean read GetActive write SetActive default False; + published + property Filter: String read GetFilter write SetFilter; + property Filtered: Boolean read GetFiltered write SetFiltered default False; + property Master: TfrxDBDataSet read FMaster write InternalSetMaster; + end; + + TfrxCustomTable = class(TfrxCustomDataset) + protected + function GetIndexFieldNames: String; virtual; + function GetIndexName: String; virtual; + function GetTableName: String; virtual; + procedure SetIndexFieldNames(const Value: String); virtual; + procedure SetIndexName(const Value: String); virtual; + procedure SetTableName(const Value: String); virtual; + published + property MasterFields; + property TableName: String read GetTableName write SetTableName; + property IndexName: String read GetIndexName write SetIndexName; + property IndexFieldNames: String read GetIndexFieldNames write SetIndexFieldNames; + end; + +{$IFDEF FR_COM} + TfrxParamItem = class(TCollectionItem, IUnknown, IfrxParamItem) + private + FRefCount: Integer; +{$ELSE} + TfrxParamItem = class(TCollectionItem) + private +{$ENDIF} + FDataType: TFieldType; + FExpression: String; + FName: String; + FValue: Variant; +{$IFDEF FR_COM} + { IUnknown } + function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; + function _AddRef: Integer; stdcall; + function _Release: Integer; stdcall; + { IfrxParamItem } + function Get_Name(out Value: WideString): HResult; stdcall; + function Set_Name(const Value: WideString): HResult; stdcall; + function Get_Value(out Value: OleVariant): HResult; stdcall; + function Set_Value(Value: OleVariant): HResult; stdcall; + function Get_Expression(out Value: WideString): HResult; stdcall; + function Set_Expression(const Value: WideString): HResult; stdcall; + function Get_FieldType(out Value: frxFieldType): HResult; stdcall; + function Set_FieldType(Value: frxFieldType): HResult; stdcall; +{$ENDIF} + public + procedure Assign(Source: TPersistent); override; + property Value: Variant read FValue write FValue; + published + property Name: String read FName write FName; + property DataType: TFieldType read FDataType write FDataType; + property Expression: String read FExpression write FExpression; + end; + + TfrxParams = class(TCollection) + private + function GetParam(Index: Integer): TfrxParamItem; + public + constructor Create; + function Add: TfrxParamItem; + function Find(const Name: String): TfrxParamItem; + function IndexOf(const Name: String): Integer; + procedure UpdateParams(const SQL: String); + property Items[Index: Integer]: TfrxParamItem read GetParam; default; + end; + + TfrxCustomQuery = class(TfrxCustomDataset) + private + FParams: TfrxParams; + FSaveOnBeforeOpen: TDataSetNotifyEvent; + FSaveOnChange: TNotifyEvent; + FSQLSchema: String; + procedure ReadData(Reader: TReader); + procedure SetParams(Value: TfrxParams); + procedure WriteData(Writer: TWriter); + protected + procedure DefineProperties(Filer: TFiler); override; + procedure OnBeforeOpen(DataSet: TDataSet); virtual; + procedure OnChangeSQL(Sender: TObject); virtual; + procedure SetSQL(Value: TStrings); virtual; + function GetSQL: TStrings; virtual; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure UpdateParams; virtual; + function ParamByName(const Value: String): TfrxParamItem; +{$IFDEF QBUILDER} + function QBEngine: TfqbEngine; virtual; +{$ENDIF} + published + property Params: TfrxParams read FParams write SetParams; + property SQL: TStrings read GetSQL write SetSQL; + property SQLSchema: String read FSQLSchema write FSQLSchema; + end; + + TfrxDBLookupComboBox = class(TfrxDialogControl) + private + FDataSet: TfrxDBDataSet; + FDataSetName: String; + FDataSource: TDataSource; + FDBLookupComboBox: TDBLookupComboBox; + function GetDataSetName: String; + function GetKeyField: String; + function GetKeyValue: Variant; + function GetListField: String; + function GetText: String; + procedure SetDataSet(const Value: TfrxDBDataSet); + procedure SetDataSetName(const Value: String); + procedure SetKeyField(Value: String); + procedure SetKeyValue(const Value: Variant); + procedure SetListField(Value: String); + procedure UpdateDataSet; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + procedure BeforeStartReport; override; + property DBLookupComboBox: TDBLookupComboBox read FDBLookupComboBox; + property KeyValue: Variant read GetKeyValue write SetKeyValue; + property Text: String read GetText; + published + property ListField: String read GetListField write SetListField; + property DataSet: TfrxDBDataSet read FDataSet write SetDataSet; + property DataSetName: String read GetDataSetName write SetDataSetName; + property KeyField: String read GetKeyField write SetKeyField; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + +procedure frxParamsToTParams(Query: TfrxCustomQuery; Params: TParams); + + +implementation + +uses +{$IFNDEF NO_EDITORS} + frxCustomDBEditor, +{$ENDIF} + frxCustomDBRTTI, frxDsgnIntf, frxUtils, frxRes; + + +{ TfrxParamItem } + +procedure TfrxParamItem.Assign(Source: TPersistent); +begin + if Source is TfrxParamItem then + begin + FName := TfrxParamItem(Source).Name; + FDataType := TfrxParamItem(Source).DataType; + FExpression := TfrxParamItem(Source).Expression; + FValue := TfrxParamItem(Source).Value; + end; +end; + +{$IFDEF FR_COM} +function TfrxParamItem.QueryInterface(const IID: TGUID; out Obj): HResult; stdcall; +begin + if GetInterface(IID, Obj) then Result := S_OK else Result := E_NOINTERFACE; +end; + +function TfrxParamItem._AddRef: Integer; stdcall; +begin + Result := InterlockedIncrement(FRefCount); +end; + +function TfrxParamItem._Release: Integer; stdcall; +begin + Result := InterlockedDecrement(FRefCount); +// if Result = 0 then Destroy; +end; + +function TfrxParamItem.Get_Name(out Value: WideString): HResult; stdcall; +begin + Value := Name; + Result := S_OK; +end; + +function TfrxParamItem.Set_Name(const Value: WideString): HResult; stdcall; +begin + Name := Value; + Result := S_OK; +end; + +function TfrxParamItem.Get_Value(out Value: OleVariant): HResult; stdcall; +begin + Value := Self.Value; + Result := S_OK; +end; + +function TfrxParamItem.Set_Value(Value: OleVariant): HResult; stdcall; +begin + Self.Value := Value; + Result := S_OK; +end; + +function TfrxParamItem.Get_Expression(out Value: WideString): HResult; stdcall; +begin + Value := Expression; + Result := S_OK; +end; + +function TfrxParamItem.Set_Expression(const Value: WideString): HResult; stdcall; +begin + Expression := Value; + Result := S_OK; +end; + +function TfrxParamItem.Get_FieldType(out Value: frxFieldType): HResult; stdcall; +begin + Value := OleVariant(DataType); + Result := S_OK; +end; + +function TfrxParamItem.Set_FieldType(Value: frxFieldType): HResult; stdcall; +begin + DataType := TFieldType(Value); + Result := S_OK; +end; +{$ENDIF} + +{ TfrxParams } + +constructor TfrxParams.Create; +begin + inherited Create(TfrxParamItem); +end; + +function TfrxParams.Add: TfrxParamItem; +begin + Result := TfrxParamItem(inherited Add); +end; + +function TfrxParams.GetParam(Index: Integer): TfrxParamItem; +begin + Result := TfrxParamItem(inherited Items[Index]); +end; + +function TfrxParams.Find(const Name: String): TfrxParamItem; +var + i: Integer; +begin + i := IndexOf(Name); + if i <> -1 then + Result := Items[i] else + Result := nil; +end; + +function TfrxParams.IndexOf(const Name: String): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to Count - 1 do + if CompareText(Items[i].Name, Name) = 0 then + begin + Result := i; + break; + end; +end; + +procedure TfrxParams.UpdateParams(const SQL: String); +var + i, j: Integer; + QParams: TParams; + NewParams: TfrxParams; +begin + { parse query params } + QParams := TParams.Create; + QParams.ParseSQL(SQL, True); + + { create new TfrxParams object and copy all params to it } + NewParams := TfrxParams.Create; + for i := 0 to QParams.Count - 1 do + with NewParams.Add do + begin + Name := QParams[i].Name; + j := IndexOf(Name); + if j <> -1 then + begin + DataType := Items[j].DataType; + Value := Items[j].Value; + Expression := Items[j].Expression; + end; + end; + + Assign(NewParams); + QParams.Free; + NewParams.Free; +end; + + +{ TfrxCustomDataset } + +constructor TfrxCustomDataset.Create(AOwner: TComponent); +begin + Component := Dataset; + inherited; + CloseDataSource := True; + FDataSource := TDataSource.Create(nil); + SetMaster(FDataSource); +end; + +destructor TfrxCustomDataset.Destroy; +begin + FDataSource.Free; + inherited; +end; + +procedure TfrxCustomDataset.Notification(AComponent: TComponent; + Operation: TOperation); +begin + inherited; + if Operation = opRemove then + if AComponent = FMaster then + Master := nil +end; + +procedure TfrxCustomDataset.SetParent(AParent: TfrxComponent); +begin + inherited; + if (AParent <> nil) and (Report <> nil) then + begin + if IsDesigning and (Report.DataSets.Find(Self) = nil) then + begin + Report.DataSets.Add(Self); + if Report.Designer <> nil then + Report.Designer.UpdateDataTree; + end; + end; +end; + +procedure TfrxCustomDataset.SetUserName(const Value: String); +begin + inherited; + if (Report <> nil) and (Report.Designer <> nil) then + Report.Designer.UpdateDataTree; +end; + +procedure TfrxCustomDataset.OnPaste; +var + i: Integer; + sl: TStringList; +begin + if Report.DataSets.Find(Self) = nil then + Report.DataSets.Add(Self); + + sl := TStringList.Create; + if Report <> nil then + Report.GetDatasetList(sl); + for i := 0 to sl.Count - 1 do + if (sl.Objects[i] <> Self) and (CompareText(sl[i], UserName) = 0) then + begin + if Name <> '' then + UserName := Name; + break; + end; + sl.Free; + + Report.Designer.UpdateDataTree; +end; + +procedure TfrxCustomDataset.SetActive(Value: Boolean); +begin + Dataset.Active := Value; +end; + +procedure TfrxCustomDataset.SetFilter(const Value: String); +begin + Dataset.Filter := Value; +end; + +function TfrxCustomDataset.GetActive: Boolean; +begin + Result := Dataset.Active; +end; + +function TfrxCustomDataset.GetFields: TFields; +begin + Result := Dataset.Fields; +end; + +function TfrxCustomDataset.GetFilter: String; +begin + Result := Dataset.Filter; +end; + +function TfrxCustomDataset.GetFiltered: Boolean; +begin + Result := Dataset.Filtered; +end; + +procedure TfrxCustomDataset.SetFiltered(Value: Boolean); +begin + Dataset.Filtered := Value; +end; + +procedure TfrxCustomDataset.InternalSetMaster(const Value: TfrxDBDataSet); +begin + FMaster := Value; + if FMaster <> nil then + FDataSource.DataSet := FMaster.GetDataSet + else + FDataSource.DataSet := nil; +end; + +procedure TfrxCustomDataset.InternalSetMasterFields(const Value: String); +var + sl: TStringList; + s: String; + i: Integer; + + function ConvertAlias(const s: String): String; + begin + if FMaster <> nil then + Result := FMaster.ConvertAlias(s) + else + Result := s; + end; + +begin + FMasterFields := Value; + + sl := TStringList.Create; + frxSetCommaText(Value, sl); + s := ''; + for i := 0 to sl.Count - 1 do + s := s + ConvertAlias(sl.Values[sl.Names[i]]) + ';'; + s := Copy(s, 1, Length(s) - 1); + + SetMasterFields(s); + + s := ''; + for i := 0 to sl.Count - 1 do + s := s + ConvertAlias(sl.Names[i]) + ';'; + s := Copy(s, 1, Length(s) - 1); + + if Self is TfrxCustomTable then + TfrxCustomTable(Self).SetIndexFieldNames(s); + + sl.Free; +end; + +procedure TfrxCustomDataset.SetMaster(const Value: TDataSource); +begin +// do nothing +end; + +procedure TfrxCustomDataset.SetMasterFields(const Value: String); +begin +// do nothing +end; + + +{ TfrxCustomTable } + +function TfrxCustomTable.GetIndexFieldNames: String; +begin + Result := ''; +end; + +function TfrxCustomTable.GetIndexName: String; +begin + Result := ''; +end; + +function TfrxCustomTable.GetTableName: String; +begin + Result := ''; +end; + +procedure TfrxCustomTable.SetIndexFieldNames(const Value: String); +begin +// do nothing +end; + +procedure TfrxCustomTable.SetIndexName(const Value: String); +begin +// do nothing +end; + +procedure TfrxCustomTable.SetTableName(const Value: String); +begin +// do nothing +end; + + +{ TfrxCustomQuery } + +constructor TfrxCustomQuery.Create(AOwner: TComponent); +begin + inherited; + FParams := TfrxParams.Create; + FSaveOnBeforeOpen := DataSet.BeforeOpen; + DataSet.BeforeOpen := OnBeforeOpen; + FSaveOnChange := TStringList(SQL).OnChange; + TStringList(SQL).OnChange := OnChangeSQL; +end; + +destructor TfrxCustomQuery.Destroy; +begin + FParams.Free; + inherited; +end; + +procedure TfrxCustomQuery.DefineProperties(Filer: TFiler); +begin + inherited; + Filer.DefineProperty('Parameters', ReadData, WriteData, True); +end; + +procedure TfrxCustomQuery.ReadData(Reader: TReader); +begin + frxReadCollection(FParams, Reader, Self); + UpdateParams; +end; + +procedure TfrxCustomQuery.WriteData(Writer: TWriter); +begin + frxWriteCollection(FParams, Writer, Self); +end; + +procedure TfrxCustomQuery.OnBeforeOpen(DataSet: TDataSet); +begin + UpdateParams; + if Assigned(FSaveOnBeforeOpen) then + FSaveOnBeforeOpen(DataSet); +end; + +procedure TfrxCustomQuery.OnChangeSQL(Sender: TObject); +begin + if Assigned(FSaveOnChange) then + FSaveOnChange(Sender); + FParams.UpdateParams(SQL.Text); +end; + +procedure TfrxCustomQuery.SetParams(Value: TfrxParams); +begin + FParams.Assign(Value); +end; + +function TfrxCustomQuery.ParamByName(const Value: String): TfrxParamItem; +begin + Result := FParams.Find(Value); + if Result = nil then + raise Exception.Create('Parameter "' + Value + '" not found'); +end; + +procedure TfrxCustomQuery.SetSQL(Value: TStrings); +begin +// +end; + +function TfrxCustomQuery.GetSQL: TStrings; +begin + Result := nil; +end; + +procedure TfrxCustomQuery.UpdateParams; +begin +// +end; + +{$IFDEF QBUILDER} +function TfrxCustomQuery.QBEngine: TfqbEngine; +begin + Result := nil; +end; +{$ENDIF} + + +{ frxParamsToTParams } + +procedure frxParamsToTParams(Query: TfrxCustomQuery; Params: TParams); +var + i: Integer; + Item: TfrxParamItem; +begin + for i := 0 to Params.Count - 1 do + if Query.Params.IndexOf(Params[i].Name) <> -1 then + begin + Item := Query.Params[Query.Params.IndexOf(Params[i].Name)]; + Params[i].Clear; + { Bound should be True in design mode } + if not (Query.IsLoading or Query.IsDesigning) then + Params[i].Bound := False + else + Params[i].Bound := True; + Params[i].DataType := Item.DataType; + if Trim(Item.Expression) <> '' then + if not (Query.IsLoading or Query.IsDesigning) then + if Query.Report <> nil then + begin + Query.Report.CurObject := Query.Name; + Item.Value := Query.Report.Calc(Item.Expression); + end; + if not VarIsEmpty(Item.Value) then + begin + Params[i].Bound := True; + if Params[i].DataType in [ftDate, ftTime, ftDateTime] then + Params[i].Value := Item.Value + else + Params[i].Text := VarToStr(Item.Value); + end; + end; +end; + + +{ TfrxDBLookupComboBox } + +constructor TfrxDBLookupComboBox.Create(AOwner: TComponent); +begin + inherited; + FDBLookupComboBox := TDBLookupComboBox.Create(nil); + InitControl(FDBLookupComboBox); + Width := 145; + Height := 21; + FDataSource := TDataSource.Create(nil); + FDBLookupComboBox.ListSource := FDataSource; +end; + +destructor TfrxDBLookupComboBox.Destroy; +begin + FDataSource.Free; + inherited; +end; + +class function TfrxDBLookupComboBox.GetDescription: String; +begin + Result := frxResources.Get('obDBLookup'); +end; + +function TfrxDBLookupComboBox.GetDataSetName: String; +begin + if FDataSet = nil then + Result := FDataSetName else + Result := FDataSet.UserName; +end; + +function TfrxDBLookupComboBox.GetKeyField: String; +begin + Result := FDBLookupComboBox.KeyField; + if FDataSet <> nil then + Result := FDataSet.GetAlias(Result); +end; + +function TfrxDBLookupComboBox.GetKeyValue: Variant; +begin + Result := FDBLookupComboBox.KeyValue; +end; + +function TfrxDBLookupComboBox.GetListField: String; +begin + Result := FDBLookupComboBox.ListField; + if FDataSet <> nil then + Result := FDataSet.GetAlias(Result); +end; + +function TfrxDBLookupComboBox.GetText: String; +begin + Result := FDBLookupComboBox.Text; +end; + +procedure TfrxDBLookupComboBox.SetDataSet(const Value: TfrxDBDataSet); +begin + FDataSet := Value; + if FDataSet = nil then + FDataSetName := '' else + FDataSetName := FDataSet.UserName; + UpdateDataSet; +end; + +procedure TfrxDBLookupComboBox.SetDataSetName(const Value: String); +begin + FDataSetName := Value; + FDataSet := TfrxDBDataSet(frxFindDataSet(FDataSet, FDataSetName, Report)); + UpdateDataSet; +end; + +procedure TfrxDBLookupComboBox.SetKeyField(Value: String); +begin + if FDataSet <> nil then + Value := FDataSet.ConvertAlias(Value); + FDBLookupComboBox.KeyField := Value; +end; + +procedure TfrxDBLookupComboBox.SetKeyValue(const Value: Variant); +begin + FDBLookupComboBox.KeyValue := Value; +end; + +procedure TfrxDBLookupComboBox.SetListField(Value: String); +begin + if FDataSet <> nil then + Value := FDataSet.ConvertAlias(Value); + FDBLookupComboBox.ListField := Value; +end; + +procedure TfrxDBLookupComboBox.UpdateDataSet; +begin + if FDataSet <> nil then + FDataSource.DataSet := FDataSet.GetDataSet else + FDataSource.DataSet := nil; +end; + +procedure TfrxDBLookupComboBox.BeforeStartReport; +begin + SetListField(FDBLookupComboBox.ListField); + SetKeyField(FDBLookupComboBox.KeyField); +end; + + +initialization + frxObjects.RegisterObject1(TfrxDBLookupComboBox, nil, '', '', 0, 41); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCustomDBEditor.pas b/official/4.2/LibD11/frxCustomDBEditor.pas new file mode 100644 index 0000000..682c94e --- /dev/null +++ b/official/4.2/LibD11/frxCustomDBEditor.pas @@ -0,0 +1,353 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Enduser DB components design editors } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCustomDBEditor; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, Controls, frxClass, frxCustomDB, + frxDsgnIntf, frxEditMD, frxEditAliases, frxEditQueryParams, frxEditSQL, + frxDBSet, frxRes, frxConnWizard +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF QBUILDER} +, fqbClass +{$ENDIF}; + +type + TfrxCustomDatabaseEditor = class(TfrxComponentEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + end; + + TfrxCustomDataSetEditor = class(TfrxComponentEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + end; + + TfrxCustomQueryEditor = class(TfrxComponentEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + end; + + TfrxFieldAliasesProperty = class(TfrxClassProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxDataSetProperty = class(TfrxComponentProperty) + public + function GetValue: String; override; + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxDataFieldProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxMasterFieldsProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxSQLProperty = class(TfrxClassProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxParamsProperty = class(TfrxClassProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + +{ TfrxCustomDatabaseEditor } + +function TfrxCustomDatabaseEditor.HasEditor: Boolean; +begin + Result := True; +end; + +function TfrxCustomDatabaseEditor.Edit: Boolean; +var + i: Integer; + wiz: TfrxCustomWizard; +begin + Result := False; + for i := 0 to frxWizards.Count - 1 do + if frxWizards[i].ClassRef = TfrxDBConnWizard then + begin + wiz := TfrxCustomWizard(frxWizards[i].ClassRef.NewInstance); + wiz.Create(Designer); + try + TfrxDBConnWizard(wiz).Database := TfrxCustomDatabase(Component); + Result := wiz.Execute; + finally + wiz.Free; + end; + break; + end; +end; + + +{ TfrxCustomDataSetEditor } + +function TfrxCustomDataSetEditor.Edit: Boolean; +begin + with TfrxAliasesEditorForm.Create(Application) do + begin + DataSet := TfrxCustomDataSet(Component); + Result := ShowModal = mrOk; + if Result then + Self.Designer.UpdateDataTree; + Free; + end; +end; + +function TfrxCustomDataSetEditor.HasEditor: Boolean; +begin + Result := True; +end; + + +{ TfrxCustomQueryEditor } + +function TfrxCustomQueryEditor.Edit: Boolean; +begin + with TfrxSQLEditorForm.Create(Designer) do + begin + Query := TfrxCustomQuery(Component); + Result := ShowModal = mrOk; + if Result then + Self.Designer.UpdateDataTree; + Free; + end; +end; + +function TfrxCustomQueryEditor.HasEditor: Boolean; +begin + Result := True; +end; + + +{ TfrxFieldAliasesProperty } + +function TfrxFieldAliasesProperty.Edit: Boolean; +begin + with TfrxAliasesEditorForm.Create(Application) do + begin + DataSet := TfrxCustomDataSet(Component); + Result := ShowModal = mrOk; + if Result then + Self.Designer.UpdateDataTree; + Free; + end; +end; + +function TfrxFieldAliasesProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog, paReadOnly]; +end; + + +{ TfrxDataSetProperty } + +function TfrxDataSetProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +function TfrxDataSetProperty.GetValue: String; +var + ds: TfrxDataSet; +begin + ds := TfrxDataSet(GetOrdValue); + if ds <> nil then + Result := frComponent.Report.GetAlias(ds) else + Result := frxResources.Get('prNotAssigned'); +end; + +procedure TfrxDataSetProperty.GetValues; +var + i: Integer; +begin + frComponent.Report.GetDataSetList(Values, True); + if Component is TfrxDataSet then + begin + i := Values.IndexOf(TfrxDataSet(Component).UserName); + if i <> -1 then + Values.Delete(i); + end; +end; + +procedure TfrxDataSetProperty.SetValue(const Value: String); +var + ds: TfrxDataSet; +begin + if Value = '' then + SetOrdValue(0) + else + begin + ds := frComponent.Report.GetDataSet(Value); + if ds <> nil then + SetOrdValue(Integer(ds)) else + raise Exception.Create(frxResources.Get('prInvProp')); + end; +end; + + +{ TfrxDataFieldProperty } + +function TfrxDataFieldProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +function TfrxDataFieldProperty.GetValue: String; +begin + Result := GetStrValue; +end; + +procedure TfrxDataFieldProperty.SetValue(const Value: String); +begin + SetStrValue(Value); +end; + +procedure TfrxDataFieldProperty.GetValues; +var + ds: TfrxDataSet; +begin + inherited; + ds := TfrxDBLookupComboBox(Component).DataSet; + if ds <> nil then + ds.GetFieldList(Values); +end; + + +{ TfrxMasterFieldsProperty } + +function TfrxMasterFieldsProperty.Edit: Boolean; +var + ds: TfrxCustomDataSet; +begin + Result := False; + ds := TfrxCustomDataSet(Component); + if ds.Master <> nil then + with TfrxMDEditorForm.Create(Application) do + begin + DataSet := ds; + Result := ShowModal = mrOk; + Free; + end; +end; + +function TfrxMasterFieldsProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog, paReadOnly]; +end; + + +{ TfrxSQLProperty } + +function TfrxSQLProperty.Edit: Boolean; +begin + with TfrxSQLEditorForm.Create(Designer) do + begin + Query := TfrxCustomQuery(Component); + Result := ShowModal = mrOk; + if Result then + Self.Designer.UpdateDataTree; + Free; + end; +end; + +function TfrxSQLProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog, paReadOnly]; +end; + + +{ TfrxParamsProperty } + +function TfrxParamsProperty.Edit: Boolean; +var + q: TfrxCustomQuery; +begin + Result := False; + q := TfrxCustomQuery(Component); + if q.Params.Count <> 0 then + with TfrxParamsEditorForm.Create(Designer) do + begin + Params := q.Params; + Result := ShowModal = mrOk; + if Result then + begin + q.UpdateParams; + Self.Designer.UpdateDataTree; + end; + Free; + end; +end; + +function TfrxParamsProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog, paReadOnly]; +end; + + +initialization + frxComponentEditors.Register(TfrxCustomDatabase, TfrxCustomDatabaseEditor); + frxComponentEditors.Register(TfrxCustomDataSet, TfrxCustomDataSetEditor); + frxComponentEditors.Register(TfrxCustomQuery, TfrxCustomQueryEditor); + frxPropertyEditors.Register(TypeInfo(TStrings), TfrxCustomDataSet, 'FieldAliases', + TfrxFieldAliasesProperty); + frxPropertyEditors.Register(TypeInfo(TfrxCustomDBDataSet), TfrxCustomDataSet, + 'Master', TfrxDataSetProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxCustomDataSet, 'MasterFields', + TfrxMasterFieldsProperty); + frxPropertyEditors.Register(TypeInfo(TStrings), TfrxCustomQuery, 'SQL', + TfrxSQLProperty); + frxPropertyEditors.Register(TypeInfo(TfrxParams), TfrxCustomQuery, 'Params', + TfrxParamsProperty); + frxPropertyEditors.Register(TypeInfo(TfrxDBDataSet), TfrxDBLookupComboBox, + 'DataSet', TfrxDataSetProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxDBLookupComboBox, + 'KeyField', TfrxDataFieldProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxDBLookupComboBox, + 'ListField', TfrxDataFieldProperty); + frxHideProperties(TfrxCustomDataset, 'DataSet;DataSource;Enabled;OpenDataSource;Tag'); + frxHideProperties(TfrxCustomQuery, 'SQLSchema'); + frxHideProperties(TfrxDBLookupComboBox, 'DataSetName'); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCustomDBRTTI.pas b/official/4.2/LibD11/frxCustomDBRTTI.pas new file mode 100644 index 0000000..777fdaf --- /dev/null +++ b/official/4.2/LibD11/frxCustomDBRTTI.pas @@ -0,0 +1,188 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ DB components RTTI } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCustomDBRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, DB, fs_iinterpreter, frxClass, frxCustomDB, + frxDBSet, fs_idbrtti +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + with AddClass(TfrxDBDataset, 'TfrxCustomDBDataSet') do + begin + AddMethod('function Locate(const KeyFields: string; const KeyValues: Variant;' + + 'Options: TLocateOptions): Boolean', CallMethod); + AddMethod('function IsEmpty: Boolean', CallMethod); + AddMethod('function RecordCount: Integer', CallMethod); + end; + AddClass(TfrxCustomDatabase, 'TfrxComponent'); + with AddClass(TfrxCustomDataset, 'TfrxDBDataSet') do + begin + AddMethod('procedure Last', CallMethod); + AddMethod('function FieldByName(Name: String): TField', CallMethod); + AddProperty('DataSet', 'TDataSet', GetProp, nil); + AddProperty('Active', 'Boolean', GetProp, SetProp); + AddProperty('Fields', 'TFields', GetProp, nil); + end; + AddClass(TfrxCustomTable, 'TfrxCustomDataset'); + with AddClass(TfrxParamItem, 'TCollectionItem') do + AddProperty('Value', 'Variant', GetProp, SetProp); + with AddClass(TfrxParams, 'TCollection') do + begin + AddMethod('function IndexOf(Name: String): Integer', CallMethod); + AddDefaultProperty('Items', 'Integer', 'TfrxParamItem', CallMethod, True); + end; + with AddClass(TfrxCustomQuery, 'TfrxCustomDataset') do + AddMethod('function ParamByName(Name: string): TfrxParamItem', CallMethod); + with AddClass(TfrxDBLookupComboBox, 'TfrxDialogControl') do + begin + AddProperty('KeyValue', 'Variant', GetProp, SetProp); + AddProperty('Text', 'String', GetProp, nil); + end; + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + + function IntToLocateOptions(i: Integer): TLocateOptions; + begin + Result := []; + if (i and 1) <> 0 then + Result := Result + [loCaseInsensitive]; + if (i and 2) <> 0 then + Result := Result + [loPartialKey]; + end; + +begin + Result := 0; + + if ClassType = TfrxParams then + begin + if MethodName = 'INDEXOF' then + Result := TfrxParams(Instance).IndexOf(Caller.Params[0]) + else if MethodName = 'ITEMS.GET' then + Result := Integer(TfrxParams(Instance).Items[Caller.Params[0]]) + end + else if ClassType = TfrxDBDataSet then + begin + if MethodName = 'LOCATE' then + Result := TfrxDBDataSet(Instance).GetDataSet.Locate(Caller.Params[0], Caller.Params[1], IntToLocateOptions(Caller.Params[2])) + else if MethodName = 'ISEMPTY' then + Result := TfrxDBDataSet(Instance).GetDataSet.IsEmpty + else if MethodName = 'RECORDCOUNT' then + Result := TfrxDBDataSet(Instance).GetDataSet.RecordCount + end + else if ClassType = TfrxCustomDataSet then + begin + if MethodName = 'LAST' then + TfrxCustomDataSet(Instance).GetDataSet.Last + else if MethodName = 'FIELDBYNAME' then + Result := Integer(TfrxCustomDataset(Instance).GetDataSet.FieldByName(Caller.Params[0])) + end + else if ClassType = TfrxCustomQuery then + begin + if MethodName = 'PARAMBYNAME' then + Result := Integer(TfrxCustomQuery(Instance).ParamByName(Caller.Params[0])) + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TfrxCustomDataset then + begin + if PropName = 'DATASET' then + Result := Integer(TfrxCustomDataset(Instance).DataSet) + else if PropName = 'ACTIVE' then + Result := TfrxCustomDataset(Instance).Active + else if PropName = 'FIELDS' then + Result := Integer(TfrxCustomDataset(Instance).Fields) + end + else if ClassType = TfrxParamItem then + begin + if PropName = 'VALUE' then + Result := TfrxParamItem(Instance).Value + end + else if ClassType = TfrxDBLookupComboBox then + begin + if PropName = 'KEYVALUE' then + Result := TfrxDBLookupComboBox(Instance).KeyValue + else if PropName = 'TEXT' then + Result := TfrxDBLookupComboBox(Instance).Text + end +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin + if ClassType = TfrxCustomDataset then + begin + if PropName = 'ACTIVE' then + TfrxCustomDataset(Instance).Active := Value; + end + else if ClassType = TfrxParamItem then + begin + if PropName = 'VALUE' then + TfrxParamItem(Instance).Value := Value + end + else if ClassType = TfrxDBLookupComboBox then + begin + if PropName = 'KEYVALUE' then + TfrxDBLookupComboBox(Instance).KeyValue := Value + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxCustomEditors.pas b/official/4.2/LibD11/frxCustomEditors.pas new file mode 100644 index 0000000..86eb1e8 --- /dev/null +++ b/official/4.2/LibD11/frxCustomEditors.pas @@ -0,0 +1,177 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Property editors for Designer } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxCustomEditors; + +interface + +{$I frx.inc} + +uses + Windows, Classes, SysUtils, Graphics, Controls, StdCtrls, Forms, Menus, + Dialogs, frxClass, frxDMPClass, frxDsgnIntf +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxViewEditor = class(TfrxComponentEditor) + public + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxCustomMemoEditor = class(TfrxViewEditor) + public + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + +implementation + +uses frxEditMemo, frxEditFormat, frxRes; + + +{ TfrxViewEditor } + +function TfrxViewEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + i: Integer; + c: TfrxComponent; + v: TfrxView; +begin + Result := False; + for i := 0 to Designer.SelectedObjects.Count - 1 do + begin + c := Designer.SelectedObjects[i]; + if (c is TfrxView) and not (rfDontModify in c.Restrictions) and (Tag in [50..53]) then + begin + v := TfrxView(c); + case Tag of + 50: if Checked then + v.ShiftMode := smAlways else + v.ShiftMode := smDontShift; + 51: if Checked then + v.ShiftMode := smWhenOverlapped else + v.ShiftMode := smDontShift; + 52: v.Visible := Checked; + 53: v.Printable := Checked; + end; + + Result := True; + end; + end; +end; + +procedure TfrxViewEditor.GetMenuItems; +var + v: TfrxView; +begin + v := TfrxView(Component); + + AddItem(frxResources.Get('mvShift'), 50, v.ShiftMode = smAlways); + AddItem(frxResources.Get('mvShiftOver'), 51, v.ShiftMode = smWhenOverlapped); + AddItem(frxResources.Get('mvVisible'), 52, v.Visible); + AddItem(frxResources.Get('mvPrintable'), 53, v.Printable); +end; + + +{ TfrxCustomMemoEditor } + +function TfrxCustomMemoEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + i: Integer; + c: TfrxComponent; + m: TfrxCustomMemoView; + DisplayFormat: TfrxFormat; + + function EditFormat: Boolean; + begin + with TfrxFormatEditorForm.Create(Designer) do + begin + Format.Assign(TfrxCustomMemoView(Component).DisplayFormat); + Result := ShowModal = mrOk; + if Result then + DisplayFormat.Assign(Format); + Free; + end; + end; + +begin + Result := inherited Execute(Tag, Checked); + + DisplayFormat := TfrxFormat.Create; + try + if Tag = 1 then + if not EditFormat then Exit; + + for i := 0 to Designer.SelectedObjects.Count - 1 do + begin + c := Designer.SelectedObjects[i]; + if (c is TfrxCustomMemoView) and not (rfDontModify in c.Restrictions) then + begin + m := TfrxCustomMemoView(c); + case Tag of + 1: m.DisplayFormat := DisplayFormat; + 2: m.Memo.Clear; + 3: m.AutoWidth := Checked; + 4: m.WordWrap := Checked; + 5: m.SuppressRepeated := Checked; + 6: m.HideZeros := Checked; + 7: m.AllowExpressions := Checked; + 8: m.AllowHTMLTags := Checked; + 40: if Checked then + m.StretchMode := smActualHeight else + m.StretchMode := smDontStretch; + 41: if Checked then + m.StretchMode := smMaxHeight else + m.StretchMode := smDontStretch; + end; + + Result := True; + end; + end; + finally + DisplayFormat.Free; + end; +end; + +procedure TfrxCustomMemoEditor.GetMenuItems; +var + m: TfrxCustomMemoView; +begin + m := TfrxCustomMemoView(Component); + + AddItem(frxResources.Get('mvFormat'), 1); + AddItem(frxResources.Get('mvClear'), 2); + AddItem('-', -1); + AddItem(frxResources.Get('mvAutoWidth'), 3, m.AutoWidth); + AddItem(frxResources.Get('mvWWrap'), 4, m.WordWrap); + AddItem(frxResources.Get('mvSuppress'), 5, m.SuppressRepeated); + AddItem(frxResources.Get('mvHideZ'), 6, m.HideZeros); + AddItem(frxResources.Get('mvExpr'), 7, m.AllowExpressions); + if not (m is TfrxDMPMemoView) then + AddItem(frxResources.Get('mvHTML'), 8, m.AllowHTMLTags); + AddItem('-', -1); + AddItem(frxResources.Get('mvStretch'), 40, m.StretchMode = smActualHeight); + AddItem(frxResources.Get('mvStretchToMax'), 41, m.StretchMode = smMaxHeight); + + inherited; +end; + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDB10.bdsproj b/official/4.2/LibD11/frxDB10.bdsproj new file mode 100644 index 0000000..4899f55 --- /dev/null +++ b/official/4.2/LibD11/frxDB10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxDB10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxDB10.dpk b/official/4.2/LibD11/frxDB10.dpk new file mode 100644 index 0000000..dfab1a3 --- /dev/null +++ b/official/4.2/LibD11/frxDB10.dpk @@ -0,0 +1,51 @@ +// Package file for Delphi 2006 + +package frxDB10; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + frx10, +{$IFDEF QBUILDER} + fqb100, +{$ENDIF} + fs10, + fsDB10; + +contains + frxDBSet in 'frxDBSet.pas', + frxConnWizard in 'frxConnWizard.pas', + frxCustomDB in 'frxCustomDB.pas', + frxCustomDBEditor in 'frxCustomDBEditor.pas', + frxCustomDBRTTI in 'frxCustomDBRTTI.pas', + frxEditMD in 'frxEditMD.pas', + frxEditQueryParams in 'frxEditQueryParams.pas', + frxEditSQL in 'frxEditSQL.pas'; + +end. diff --git a/official/4.2/LibD11/frxDB11.bdsproj b/official/4.2/LibD11/frxDB11.bdsproj new file mode 100644 index 0000000..8dcab0d --- /dev/null +++ b/official/4.2/LibD11/frxDB11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxDB11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxDB11.dpk b/official/4.2/LibD11/frxDB11.dpk new file mode 100644 index 0000000..92d1f47 --- /dev/null +++ b/official/4.2/LibD11/frxDB11.dpk @@ -0,0 +1,51 @@ +// Package file for Delphi 2007 + +package frxDB11; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + frx11, +{$IFDEF QBUILDER} + fqb110, +{$ENDIF} + fs11, + fsDB11; + +contains + frxDBSet in 'frxDBSet.pas', + frxConnWizard in 'frxConnWizard.pas', + frxCustomDB in 'frxCustomDB.pas', + frxCustomDBEditor in 'frxCustomDBEditor.pas', + frxCustomDBRTTI in 'frxCustomDBRTTI.pas', + frxEditMD in 'frxEditMD.pas', + frxEditQueryParams in 'frxEditQueryParams.pas', + frxEditSQL in 'frxEditSQL.pas'; + +end. diff --git a/official/4.2/LibD11/frxDB4.bpk b/official/4.2/LibD11/frxDB4.bpk new file mode 100644 index 0000000..0bee0e2 --- /dev/null +++ b/official/4.2/LibD11/frxDB4.bpk @@ -0,0 +1,189 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = frxDB4.bpl +OBJFILES = frxRegDB.obj frxDB4.obj +RESFILES = frx4.res frxReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +LIBRARIES = +SPARELIBS = VCL40.lib +PACKAGES = vcl40.bpi vclsmp40.bpi vcldb40.bpi fs4.bpi fsDB4.bpi frx4.bpi fqb40.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release;..\FastScript;..\FastQB +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -D"FastReport 4.0 DB Components" -aa \ + -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxDB4.cpp b/official/4.2/LibD11/frxDB4.cpp new file mode 100644 index 0000000..b8d9abe --- /dev/null +++ b/official/4.2/LibD11/frxDB4.cpp @@ -0,0 +1,22 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frx4.res"); +USEPACKAGE("vcl40.bpi"); +USEUNIT("frxRegDB.pas"); +USERES("frxReg.dcr"); +USEPACKAGE("vcldb40.bpi"); +USEPACKAGE("fs4.bpi"); +USEPACKAGE("fsDB4.bpi"); +USEPACKAGE("frx4.bpi"); +USEPACKAGE("fqb40.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxDB4.dpk b/official/4.2/LibD11/frxDB4.dpk new file mode 100644 index 0000000..ec00a3d --- /dev/null +++ b/official/4.2/LibD11/frxDB4.dpk @@ -0,0 +1,51 @@ +// Package file for Delphi 4 + +package frxDB4; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + VCLDB40, + frx4, +{$IFDEF QBUILDER} + fqb40, +{$ENDIF} + fs4, + fsDB4; + +contains + frxDBSet in 'frxDBSet.pas', + frxConnWizard in 'frxConnWizard.pas', + frxCustomDB in 'frxCustomDB.pas', + frxCustomDBEditor in 'frxCustomDBEditor.pas', + frxCustomDBRTTI in 'frxCustomDBRTTI.pas', + frxEditMD in 'frxEditMD.pas', + frxEditQueryParams in 'frxEditQueryParams.pas', + frxEditSQL in 'frxEditSQL.pas'; + +end. diff --git a/official/4.2/LibD11/frxDB5.bpk b/official/4.2/LibD11/frxDB5.bpk new file mode 100644 index 0000000..4988948 --- /dev/null +++ b/official/4.2/LibD11/frxDB5.bpk @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxDB5.cpp b/official/4.2/LibD11/frxDB5.cpp new file mode 100644 index 0000000..95b5292 --- /dev/null +++ b/official/4.2/LibD11/frxDB5.cpp @@ -0,0 +1,22 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frx5.res"); +USEUNIT("frxRegDB.pas"); +USERES("frxReg.dcr"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vcldb50.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("fsDB5.bpi"); +USEPACKAGE("frx5.bpi"); +USEPACKAGE("fqb50.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxDB5.dpk b/official/4.2/LibD11/frxDB5.dpk new file mode 100644 index 0000000..7648453 --- /dev/null +++ b/official/4.2/LibD11/frxDB5.dpk @@ -0,0 +1,51 @@ +// Package file for Delphi 5 + +package frxDB5; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + VCLDB50, + frx5, +{$IFDEF QBUILDER} + fqb50, +{$ENDIF} + fs5, + fsDB5; + +contains + frxDBSet in 'frxDBSet.pas', + frxConnWizard in 'frxConnWizard.pas', + frxCustomDB in 'frxCustomDB.pas', + frxCustomDBEditor in 'frxCustomDBEditor.pas', + frxCustomDBRTTI in 'frxCustomDBRTTI.pas', + frxEditMD in 'frxEditMD.pas', + frxEditQueryParams in 'frxEditQueryParams.pas', + frxEditSQL in 'frxEditSQL.pas'; + +end. diff --git a/official/4.2/LibD11/frxDB6.bpk b/official/4.2/LibD11/frxDB6.bpk new file mode 100644 index 0000000..604c9da --- /dev/null +++ b/official/4.2/LibD11/frxDB6.bpk @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxDB6.cpp b/official/4.2/LibD11/frxDB6.cpp new file mode 100644 index 0000000..48ce892 --- /dev/null +++ b/official/4.2/LibD11/frxDB6.cpp @@ -0,0 +1,18 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frxDB6.dpk b/official/4.2/LibD11/frxDB6.dpk new file mode 100644 index 0000000..ce3edca --- /dev/null +++ b/official/4.2/LibD11/frxDB6.dpk @@ -0,0 +1,51 @@ +// Package file for Delphi 6 + +package frxDB6; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + frx6, +{$IFDEF QBUILDER} + fqb60, +{$ENDIF} + fs6, + fsDB6; + +contains + frxDBSet in 'frxDBSet.pas', + frxConnWizard in 'frxConnWizard.pas', + frxCustomDB in 'frxCustomDB.pas', + frxCustomDBEditor in 'frxCustomDBEditor.pas', + frxCustomDBRTTI in 'frxCustomDBRTTI.pas', + frxEditMD in 'frxEditMD.pas', + frxEditQueryParams in 'frxEditQueryParams.pas', + frxEditSQL in 'frxEditSQL.pas'; + +end. diff --git a/official/4.2/LibD11/frxDB7.dpk b/official/4.2/LibD11/frxDB7.dpk new file mode 100644 index 0000000..c4ad7c8 --- /dev/null +++ b/official/4.2/LibD11/frxDB7.dpk @@ -0,0 +1,51 @@ +// Package file for Delphi 7 + +package frxDB7; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + frx7, +{$IFDEF QBUILDER} + fqb70, +{$ENDIF} + fs7, + fsDB7; + +contains + frxDBSet in 'frxDBSet.pas', + frxConnWizard in 'frxConnWizard.pas', + frxCustomDB in 'frxCustomDB.pas', + frxCustomDBEditor in 'frxCustomDBEditor.pas', + frxCustomDBRTTI in 'frxCustomDBRTTI.pas', + frxEditMD in 'frxEditMD.pas', + frxEditQueryParams in 'frxEditQueryParams.pas', + frxEditSQL in 'frxEditSQL.pas'; + +end. diff --git a/official/4.2/LibD11/frxDB9.bdsproj b/official/4.2/LibD11/frxDB9.bdsproj new file mode 100644 index 0000000..0670073 --- /dev/null +++ b/official/4.2/LibD11/frxDB9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxDB9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxDB9.dpk b/official/4.2/LibD11/frxDB9.dpk new file mode 100644 index 0000000..cbe434c --- /dev/null +++ b/official/4.2/LibD11/frxDB9.dpk @@ -0,0 +1,51 @@ +// Package file for Delphi 2005 + +package frxDB9; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + frx9, +{$IFDEF QBUILDER} + fqb90, +{$ENDIF} + fs9, + fsDB9; + +contains + frxDBSet in 'frxDBSet.pas', + frxConnWizard in 'frxConnWizard.pas', + frxCustomDB in 'frxCustomDB.pas', + frxCustomDBEditor in 'frxCustomDBEditor.pas', + frxCustomDBRTTI in 'frxCustomDBRTTI.pas', + frxEditMD in 'frxEditMD.pas', + frxEditQueryParams in 'frxEditQueryParams.pas', + frxEditSQL in 'frxEditSQL.pas'; + +end. diff --git a/official/4.2/LibD11/frxDBSet.pas b/official/4.2/LibD11/frxDBSet.pas new file mode 100644 index 0000000..63a25b6 --- /dev/null +++ b/official/4.2/LibD11/frxDBSet.pas @@ -0,0 +1,460 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ DB dataset } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDBSet; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, frxClass, DB +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxDBDataset = class(TfrxCustomDBDataset) + private + FBookmark: TBookmark; + FDataSet: TDataSet; + FDataSource: TDataSource; + FDS: TDataSet; + FEof: Boolean; + FSaveOpenEvent: TDatasetNotifyEvent; + FSaveCloseEvent: TDatasetNotifyEvent; + procedure BeforeClose(Sender: TDataSet); + procedure AfterOpen(Sender: TDataset); + procedure SetDataSet(Value: TDataSet); + procedure SetDataSource(Value: TDataSource); + function DataSetActive: Boolean; + function IsDataSetStored: Boolean; + protected + function GetDisplayText(Index: String): WideString; override; + function GetDisplayWidth(Index: String): Integer; override; + function GetFieldType(Index: String): TfrxFieldType; override; + function GetValue(Index: String): Variant; override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + procedure Initialize; override; + procedure Finalize; override; + procedure First; override; + procedure Next; override; + procedure Prior; override; + procedure Open; override; + procedure Close; override; + function Eof: Boolean; override; + + function GetDataSet: TDataSet; + function IsBlobField(const fName: String): Boolean; override; + function RecordCount: Integer; override; + procedure AssignBlobTo(const fName: String; Obj: TObject); override; + procedure GetFieldList(List: TStrings); override; + published + property DataSet: TDataSet read FDataSet write SetDataSet stored IsDataSetStored; + property DataSource: TDataSource read FDataSource write SetDataSource stored IsDataSetStored; + end; + + +implementation + +uses frxUtils, frxRes, frxUnicodeUtils; + +type + EDSError = class(Exception); + + +{ TfrxDBDataset } + +procedure TfrxDBDataset.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if Operation = opRemove then + if AComponent = FDataSource then + DataSource := nil + else if AComponent = FDataSet then + DataSet := nil +end; + +procedure TfrxDBDataset.SetDataSet(Value: TDataSet); +begin + FDataSet := Value; + if Value <> nil then + FDataSource := nil; + FDS := GetDataSet; +end; + +procedure TfrxDBDataset.SetDataSource(Value: TDataSource); +begin + FDataSource := Value; + if Value <> nil then + FDataSet := nil; + FDS := GetDataSet; +end; + +function TfrxDBDataset.DataSetActive: Boolean; +begin + Result := (FDS <> nil) and FDS.Active; +end; + +function TfrxDBDataset.GetDataset: TDataSet; +begin + if FDataSet <> nil then + Result := FDataSet + else if (FDataSource <> nil) and (FDataSource.DataSet <> nil) then + Result := FDataSource.DataSet + else + Result := nil; +end; + +function TfrxDBDataset.IsDataSetStored: Boolean; +begin + Result := Report = nil; +end; + +procedure TfrxDBDataset.Initialize; +begin + FDS := GetDataSet; + if FDS = nil then + raise Exception.Create(Format(frxResources.Get('dbNotConn'), [Name])); + + FSaveOpenEvent := FDS.AfterOpen; + FDS.AfterOpen := AfterOpen; + FSaveCloseEvent := FDS.BeforeClose; + FDS.BeforeClose := BeforeClose; + FEof := False; + FInitialized := False; +end; + +procedure TfrxDBDataset.Finalize; +begin + if FDS = nil then Exit; + if FBookMark <> nil then + begin + FDS.GotoBookmark(FBookmark); + FDS.FreeBookmark(FBookmark); + end; + FBookMark := nil; + + if CloseDataSource then + Close; + FDS.AfterOpen := FSaveOpenEvent; + FDS.BeforeClose := FSaveCloseEvent; + FSaveOpenEvent := nil; + FSaveCloseEvent := nil; + FInitialized := False; +end; + +procedure TfrxDBDataSet.Open; +begin + if FInitialized then + Exit; + + FInitialized := True; + FDS.Open; + AfterOpen(nil); + if (RangeBegin = rbCurrent) or (RangeEnd = reCurrent) then + FBookmark := FDS.GetBookmark else + FBookmark := nil; + + inherited; +end; + +procedure TfrxDBDataSet.Close; +begin + inherited; + BeforeClose(nil); + FDS.Close; +end; + +procedure TfrxDBDataset.AfterOpen(Sender: TDataset); +var + i: Integer; +begin + GetFieldList(Fields); + for i := 0 to Fields.Count - 1 do + Fields.Objects[i] := FDS.FindField(ConvertAlias(Fields[i])); + + if Assigned(FSaveOpenEvent) and (Sender <> nil) then + FSaveOpenEvent(Sender); +end; + +procedure TfrxDBDataset.BeforeClose(Sender: TDataSet); +begin + if Assigned(FSaveCloseEvent) and (Sender <> nil) then + FSaveCloseEvent(Sender); + + if FBookMark <> nil then + FDS.FreeBookmark(FBookmark); + FBookMark := nil; + + FInitialized := False; +end; + +procedure TfrxDBDataSet.First; +begin + if not FInitialized then + Open; + if RangeBegin = rbFirst then + FDS.First else + FDS.GotoBookmark(FBookmark); + FEof := False; + inherited First; +end; + +procedure TfrxDBDataSet.Next; +var + b: TBookmark; +begin + if not FInitialized then + Open; + FEof := False; + if RangeEnd = reCurrent then + begin + b := FDS.GetBookmark; + if FDS.CompareBookmarks(b, FBookmark) = 0 then + FEof := True; + FDS.FreeBookmark(b); + Exit; + end; + FDS.Next; + inherited Next; +end; + +procedure TfrxDBDataSet.Prior; +begin + if not FInitialized then + Open; + FDS.Prior; + inherited Prior; +end; + +function TfrxDBDataSet.Eof: Boolean; +begin + if not FInitialized then + Open; + Result := inherited Eof or FDS.Eof or FEof; +end; + +function TfrxDBDataset.GetDisplayText(Index: String): WideString; +var + i: Integer; + s: WideString; +begin + s := ''; + if not FInitialized then + Open; + if DataSetActive then + if Fields.Count = 0 then + s := FDS.FieldByName(Index).DisplayText + else + begin + i := Fields.IndexOf(Index); + if i <> -1 then + begin +{$IFDEF Delphi5} + if TField(Fields.Objects[i]) is TWideStringField then + s := VarToWideStr(TField(Fields.Objects[i]).Value) + else +{$ENDIF} + s := TField(Fields.Objects[i]).DisplayText; + end + else + begin + s := frxResources.Get('dbFldNotFound') + ' ' + UserName + '."' + + Index + '"'; + ReportRef.Errors.Add(ReportRef.CurObject + ': ' + s); + end; + end + else + s := UserName + '."' + Index + '"'; + Result := s; +end; + +function TfrxDBDataset.GetValue(Index: String): Variant; +var + i: Integer; + v: Variant; +begin + if not FInitialized then + Open; + i := Fields.IndexOf(Index); + if i <> -1 then + begin +{$IFDEF Delphi6} + if TField(Fields.Objects[i]) is TFMTBCDField then + begin + if TField(Fields.Objects[i]).IsNull then + v := Null + else + v := TField(Fields.Objects[i]).AsCurrency + end + else +{$ENDIF} + if TField(Fields.Objects[i]) is TLargeIntField then + begin + { TLargeIntField.AsVariant converts value to vt_decimal variant type + which is not supported by Delphi } + if TField(Fields.Objects[i]).IsNull then + v := Null + else +{$IFDEF Delphi6} + v := TLargeIntField(Fields.Objects[i]).AsLargeInt +{$ELSE} + v := TField(Fields.Objects[i]).AsInteger +{$ENDIF} + end + else + v := TField(Fields.Objects[i]).Value + end + else + begin + v := Null; + ReportRef.Errors.Add(ReportRef.CurObject + ': ' + + frxResources.Get('dbFldNotFound') + ' ' + UserName + '."' + Index + '"'); + end; + Result := v; +end; + +function TfrxDBDataset.GetDisplayWidth(Index: String): Integer; +var + f: TField; + fDef: TFieldDef; +begin + Result := 10; + Index := ConvertAlias(Index); + f := FDS.FindField(Index); + if f <> nil then + Result := f.DisplayWidth + else + begin + try + if not FDS.FieldDefs.Updated then + FDS.FieldDefs.Update; + except + end; + fDef := FDS.FieldDefs.Find(Index); + if fDef <> nil then + case fDef.DataType of + ftString, ftWideString: Result := fDef.Size; + ftLargeInt: Result := 15; + ftDateTime: Result := 20; + end; + end; +end; + +function TfrxDBDataset.GetFieldType(Index: String): TfrxFieldType; +var + f: TField; +begin + Result := fftNumeric; + f := FDS.FindField(ConvertAlias(Index)); + if f <> nil then + case f.DataType of + ftString, ftWideString, ftMemo: + Result := fftString; + ftBoolean: + Result := fftBoolean; + end; +end; + +procedure TfrxDBDataset.AssignBlobTo(const fName: String; Obj: TObject); +var + Field: TField; + BlobStream: TStream; + sl: TStringList; +begin + if not FInitialized then + Open; + Field := TField(Fields.Objects[Fields.IndexOf(fName)]); + if (Field <> nil) and Field.IsBlob then +// if Field is TBlobField then + begin + if Obj is TWideStrings then + begin + BlobStream := TMemoryStream.Create; + sl := TStringList.Create; + try + TBlobField(Field).SaveToStream(BlobStream); + BlobStream.Position := 0; +{$IFDEF Delphi10} + if Field is TWideMemoField then + TWideStrings(Obj).LoadFromWStream(BlobStream) + else +{$ENDIF} + begin + sl.LoadFromStream(BlobStream); + TWideStrings(Obj).Assign(sl); + end; + finally + BlobStream.Free; + sl.Free; + end; + end + else if Obj is TStream then + begin + TBlobField(Field).SaveToStream(TStream(Obj)); + TStream(Obj).Position := 0; + end; + end; +end; + +procedure TfrxDBDataset.GetFieldList(List: TStrings); +var + i: Integer; +begin + List.Clear; + if FieldAliases.Count = 0 then + begin + try + if FDS <> nil then + FDS.GetFieldNames(List); + except + end; + end + else + begin + for i := 0 to FieldAliases.Count - 1 do + if Pos('-', FieldAliases.Names[i]) <> 1 then + List.Add(FieldAliases.Values[FieldAliases.Names[i]]); + end; +end; + +function TfrxDBDataset.IsBlobField(const fName: String): Boolean; +var + Field: TField; + i: Integer; +begin + if not FInitialized then + Open; + Result := False; + i := Fields.IndexOf(fName); + if i <> -1 then + begin + Field := TField(Fields.Objects[i]); + Result := (Field <> nil) and Field.IsBlob; + end; +end; + +function TfrxDBDataset.RecordCount: Integer; +begin + if not FInitialized then + Open; + Result := FDS.RecordCount; +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDBX10.bdsproj b/official/4.2/LibD11/frxDBX10.bdsproj new file mode 100644 index 0000000..dc2144d --- /dev/null +++ b/official/4.2/LibD11/frxDBX10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxDBX10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxDBX10.dpk b/official/4.2/LibD11/frxDBX10.dpk new file mode 100644 index 0000000..68a6656 --- /dev/null +++ b/official/4.2/LibD11/frxDBX10.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2006 + +package frxDBX10; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + DBEXPRESS, + DBXCDS, + frx10, + frxDB10, +{$IFDEF QBUILDER} + fqb100, +{$ENDIF} + fs10; + +contains + frxDBXComponents in 'frxDBXComponents.pas', + frxDBXEditor in 'frxDBXEditor.pas', + frxDBXRTTI in 'frxDBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxDBX11.bdsproj b/official/4.2/LibD11/frxDBX11.bdsproj new file mode 100644 index 0000000..5bc9223 --- /dev/null +++ b/official/4.2/LibD11/frxDBX11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxDBX11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxDBX11.dpk b/official/4.2/LibD11/frxDBX11.dpk new file mode 100644 index 0000000..c989a2e --- /dev/null +++ b/official/4.2/LibD11/frxDBX11.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2007 + +package frxDBX11; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + DBEXPRESS, + DBXCDS, + frx11, + frxDB11, +{$IFDEF QBUILDER} + fqb110, +{$ENDIF} + fs11; + +contains + frxDBXComponents in 'frxDBXComponents.pas', + frxDBXEditor in 'frxDBXEditor.pas', + frxDBXRTTI in 'frxDBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxDBX6.bpk b/official/4.2/LibD11/frxDBX6.bpk new file mode 100644 index 0000000..a634c74 --- /dev/null +++ b/official/4.2/LibD11/frxDBX6.bpk @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=1 +Item0=_DEBUG + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxDBX6.cpp b/official/4.2/LibD11/frxDBX6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/frxDBX6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frxDBX6.dpk b/official/4.2/LibD11/frxDBX6.dpk new file mode 100644 index 0000000..930d9d3 --- /dev/null +++ b/official/4.2/LibD11/frxDBX6.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 6 + +package frxDBX6; + +{$I frx.inc} + +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + DBEXPRESS, + DBXCDS, + frx6, + frxDB6, +{$IFDEF QBUILDER} + fqb60, +{$ENDIF} + fs6; + +contains + frxDBXComponents in 'frxDBXComponents.pas', + frxDBXEditor in 'frxDBXEditor.pas', + frxDBXRTTI in 'frxDBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxDBX6.res b/official/4.2/LibD11/frxDBX6.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frxDBX6.res differ diff --git a/official/4.2/LibD11/frxDBX7.dpk b/official/4.2/LibD11/frxDBX7.dpk new file mode 100644 index 0000000..fd14b14 --- /dev/null +++ b/official/4.2/LibD11/frxDBX7.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 7 + +package frxDBX7; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + DBEXPRESS, + DBXCDS, + frx7, + frxDB7, +{$IFDEF QBUILDER} + fqb70, +{$ENDIF} + fs7; + +contains + frxDBXComponents in 'frxDBXComponents.pas', + frxDBXEditor in 'frxDBXEditor.pas', + frxDBXRTTI in 'frxDBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxDBX9.bdsproj b/official/4.2/LibD11/frxDBX9.bdsproj new file mode 100644 index 0000000..c126608 --- /dev/null +++ b/official/4.2/LibD11/frxDBX9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxDBX9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxDBX9.dpk b/official/4.2/LibD11/frxDBX9.dpk new file mode 100644 index 0000000..13f1d49 --- /dev/null +++ b/official/4.2/LibD11/frxDBX9.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2005 + +package frxDBX9; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + DBEXPRESS, + DBXCDS, + frx9, + frxDB9, +{$IFDEF QBUILDER} + fqb90, +{$ENDIF} + fs9; + +contains + frxDBXComponents in 'frxDBXComponents.pas', + frxDBXEditor in 'frxDBXEditor.pas', + frxDBXRTTI in 'frxDBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxDBXComponents.pas b/official/4.2/LibD11/frxDBXComponents.pas new file mode 100644 index 0000000..2f4fa0f --- /dev/null +++ b/official/4.2/LibD11/frxDBXComponents.pas @@ -0,0 +1,635 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ DBX enduser components } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDBXComponents; + +interface + +{$I frx.inc} + +uses + Windows, Classes, frxClass, frxCustomDB, DB, DBXpress, SqlExpr, + Provider, DBClient +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF QBUILDER} +, fqbClass +{$ENDIF}; + + +type + TfrxDBXDataset = class(TCustomClientDataset) + private + FDataSet: TDataSet; + FProvider: TDataSetProvider; + procedure SetDataset(const Value: TDataset); + protected + procedure OpenCursor(InfoQuery: Boolean); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + property Dataset: TDataset read FDataset write SetDataset; + end; + + TfrxDBXComponents = class(TfrxDBComponents) + private + FDefaultDatabase: TSQLConnection; + FOldComponents: TfrxDBXComponents; + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDescription: String; override; + published + property DefaultDatabase: TSQLConnection read FDefaultDatabase write FDefaultDatabase; + end; + + TfrxDBXDatabase = class(TfrxCustomDatabase) + private + FDatabase: TSQLConnection; + FStrings: TStrings; + FLock: Boolean; + function GetDriverName: String; + function GetGetDriverFunc: String; + function GetLibraryName: String; + function GetVendorLib: String; + procedure SetDriverName(const Value: String); + procedure SetGetDriverFunc(const Value: String); + procedure SetLibraryName(const Value: String); + procedure SetVendorLib(const Value: String); + procedure OnChange(Sender: TObject); + protected + procedure SetConnected(Value: Boolean); override; + procedure SetDatabaseName(const Value: String); override; + procedure SetLoginPrompt(Value: Boolean); override; + procedure SetParams(Value: TStrings); override; + function GetConnected: Boolean; override; + function GetDatabaseName: String; override; + function GetLoginPrompt: Boolean; override; + function GetParams: TStrings; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + property Database: TSQLConnection read FDatabase; + published + property ConnectionName: String read GetDatabaseName write SetDatabaseName; + property DriverName: String read GetDriverName write SetDriverName; + property GetDriverFunc: String read GetGetDriverFunc write SetGetDriverFunc; + property LibraryName: String read GetLibraryName write SetLibraryName; + property LoginPrompt; + property Params; + property VendorLib: String read GetVendorLib write SetVendorLib; + property Connected; + end; + + TfrxDBXTable = class(TfrxCustomTable) + private + FDatabase: TfrxDBXDatabase; + FTable: TSQLTable; + procedure SetDatabase(const Value: TfrxDBXDatabase); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure SetMaster(const Value: TDataSource); override; + procedure SetMasterFields(const Value: String); override; + procedure SetIndexName(const Value: String); override; + procedure SetIndexFieldNames(const Value: String); override; + procedure SetTableName(const Value: String); override; + function GetIndexName: String; override; + function GetIndexFieldNames: String; override; + function GetTableName: String; override; + public + constructor Create(AOwner: TComponent); override; + constructor DesignCreate(AOwner: TComponent; Flags: Word); override; + destructor Destroy; override; + class function GetDescription: String; override; + procedure BeforeStartReport; override; + property Table: TSQLTable read FTable; + published + property Database: TfrxDBXDatabase read FDatabase write SetDatabase; + end; + + TfrxDBXQuery = class(TfrxCustomQuery) + private + FDatabase: TfrxDBXDatabase; + FQuery: TSQLQuery; + FStrings: TStrings; + FLock: Boolean; + procedure SetDatabase(const Value: TfrxDBXDatabase); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure SetMaster(const Value: TDataSource); override; + procedure SetSQL(Value: TStrings); override; + function GetSQL: TStrings; override; + procedure OnChangeSQL(Sender: TObject); override; + public + constructor Create(AOwner: TComponent); override; + constructor DesignCreate(AOwner: TComponent; Flags: Word); override; + destructor Destroy; override; + class function GetDescription: String; override; + procedure BeforeStartReport; override; + procedure UpdateParams; override; +{$IFDEF QBUILDER} + function QBEngine: TfqbEngine; override; +{$ENDIF} + property Query: TSQLQuery read FQuery; + published + property Database: TfrxDBXDatabase read FDatabase write SetDatabase; + end; + +{$IFDEF QBUILDER} + TfrxEngineDBX = class(TfqbEngine) + private + FQuery: TSQLQuery; + FDBXDataset: TfrxDBXDataset; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure ReadTableList(ATableList: TStrings); override; + procedure ReadFieldList(const ATableName: string; var AFieldList: TfqbFieldList); override; + function ResultDataSet: TDataSet; override; + procedure SetSQL(const Value: string); override; + end; +{$ENDIF} + +var + DBXComponents: TfrxDBXComponents; + + +implementation + +uses + frxDBXRTTI, +{$IFNDEF NO_EDITORS} + frxDBXEditor, +{$ENDIF} + frxDsgnIntf, frxRes; + +type + THackSQLConnection = class(TSQLConnection); + + +{ TfrxDBXDataset } + +constructor TfrxDBXDataset.Create(AOwner: TComponent); +begin + inherited; + FProvider := TDatasetProvider.Create(nil); +end; + +destructor TfrxDBXDataset.Destroy; +begin + FProvider.Free; + inherited; +end; + +procedure TfrxDBXDataset.OpenCursor(InfoQuery: Boolean); +begin + SetProvider(FProvider); + inherited; +end; + +procedure TfrxDBXDataset.SetDataset(const Value: TDataset); +begin + FDataset := Value; + FProvider.Dataset := FDataset; +end; + + +{ TfrxDBXComponents } + +constructor TfrxDBXComponents.Create(AOwner: TComponent); +begin + inherited; + FOldComponents := DBXComponents; + DBXComponents := Self; +end; + +destructor TfrxDBXComponents.Destroy; +begin + if DBXComponents = Self then + DBXComponents := FOldComponents; + inherited; +end; + +function TfrxDBXComponents.GetDescription: String; +begin + Result := 'DBX'; +end; + +procedure TfrxDBXComponents.Notification(AComponent: TComponent; + Operation: TOperation); +begin + inherited; + if (AComponent = FDefaultDatabase) and (Operation = opRemove) then + FDefaultDatabase := nil; +end; + + +{ TfrxDBXDatabase } + +constructor TfrxDBXDatabase.Create(AOwner: TComponent); +begin + inherited; + FStrings := TStringList.Create; + TStringList(FStrings).OnChange := OnChange; + FDatabase := TSQLConnection.Create(nil); +// set ComponentState := csDesigning to obtain Params automatically + THackSQLConnection(FDataBase).SetDesigning(True, False); + Component := FDatabase; +end; + +destructor TfrxDBXDatabase.Destroy; +begin + FStrings.Free; + inherited; +end; + +class function TfrxDBXDatabase.GetDescription: String; +begin + Result := frxResources.Get('obDBXDB'); +end; + +function TfrxDBXDatabase.GetConnected: Boolean; +begin + Result := FDatabase.Connected; +end; + +function TfrxDBXDatabase.GetDatabaseName: String; +begin + Result := FDatabase.ConnectionName; +end; + +function TfrxDBXDatabase.GetDriverName: String; +begin + Result := FDatabase.DriverName; +end; + +function TfrxDBXDatabase.GetGetDriverFunc: String; +begin + Result := FDatabase.GetDriverFunc; +end; + +function TfrxDBXDatabase.GetLibraryName: String; +begin + Result := FDatabase.LibraryName; +end; + +function TfrxDBXDatabase.GetLoginPrompt: Boolean; +begin + Result := FDatabase.LoginPrompt; +end; + +function TfrxDBXDatabase.GetParams: TStrings; +begin + FLock := True; + FStrings.Assign(FDatabase.Params); + FLock := False; + Result := FStrings; +end; + +function TfrxDBXDatabase.GetVendorLib: String; +begin + Result := FDatabase.VendorLib; +end; + +procedure TfrxDBXDatabase.SetConnected(Value: Boolean); +begin + BeforeConnect(Value); + FDatabase.Connected := Value; +end; + +procedure TfrxDBXDatabase.SetDatabaseName(const Value: String); +begin + FDatabase.ConnectionName := Value; +end; + +procedure TfrxDBXDatabase.SetDriverName(const Value: String); +begin + FDatabase.DriverName := Value; +end; + +procedure TfrxDBXDatabase.SetGetDriverFunc(const Value: String); +begin + FDatabase.GetDriverFunc := Value; +end; + +procedure TfrxDBXDatabase.SetLibraryName(const Value: String); +begin + FDatabase.LibraryName := Value; +end; + +procedure TfrxDBXDatabase.SetLoginPrompt(Value: Boolean); +begin + FDatabase.LoginPrompt := Value; +end; + +procedure TfrxDBXDatabase.SetParams(Value: TStrings); +begin + FStrings.Assign(Value); +end; + +procedure TfrxDBXDatabase.SetVendorLib(const Value: String); +begin + FDatabase.VendorLib := Value; +end; + +procedure TfrxDBXDatabase.OnChange(Sender: TObject); +begin + if not FLock then + FDatabase.Params.Assign(FStrings); +end; + + +{ TfrxDBXTable } + +constructor TfrxDBXTable.Create(AOwner: TComponent); +begin + FTable := TSQLTable.Create(nil); + DataSet := FTable; + SetDatabase(nil); + inherited; +end; + +destructor TfrxDBXTable.Destroy; +begin + inherited; +end; + +constructor TfrxDBXTable.DesignCreate(AOwner: TComponent; Flags: Word); +var + i: Integer; + l: TList; +begin + inherited; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + if TObject(l[i]) is TfrxDBXDatabase then + begin + SetDatabase(TfrxDBXDatabase(l[i])); + break; + end; +end; + +class function TfrxDBXTable.GetDescription: String; +begin + Result := frxResources.Get('obDBXTb'); +end; + +procedure TfrxDBXTable.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FDatabase) then + SetDatabase(nil); +end; + +procedure TfrxDBXTable.SetDatabase(const Value: TfrxDBXDatabase); +begin + FDatabase := Value; + if Value <> nil then + FTable.SQLConnection := Value.Database + else if DBXComponents <> nil then + FTable.SQLConnection := DBXComponents.DefaultDatabase + else + FTable.SQLConnection := nil; + DBConnected := FTable.SQLConnection <> nil; +end; + +function TfrxDBXTable.GetIndexName: String; +begin + Result := FTable.IndexName; +end; + +function TfrxDBXTable.GetIndexFieldNames: String; +begin + Result := FTable.IndexFieldNames; +end; + +function TfrxDBXTable.GetTableName: String; +begin + Result := FTable.TableName; +end; + +procedure TfrxDBXTable.SetIndexName(const Value: String); +begin + FTable.IndexName := Value; +end; + +procedure TfrxDBXTable.SetIndexFieldNames(const Value: String); +begin + FTable.IndexFieldNames := Value; +end; + +procedure TfrxDBXTable.SetTableName(const Value: String); +begin + FTable.TableName := Value; +end; + +procedure TfrxDBXTable.SetMaster(const Value: TDataSource); +begin + FTable.MasterSource := Value; +end; + +procedure TfrxDBXTable.SetMasterFields(const Value: String); +begin + FTable.MasterFields := Value; +end; + +procedure TfrxDBXTable.BeforeStartReport; +begin + SetDatabase(FDatabase); +end; + + +{ TfrxDBXQuery } + +constructor TfrxDBXQuery.Create(AOwner: TComponent); +begin + FStrings := TStringList.Create; + FQuery := TSQLQuery.Create(nil); + DataSet := FQuery; + SetDatabase(nil); + inherited; +end; + +destructor TfrxDBXQuery.Destroy; +begin + FStrings.Free; + inherited; +end; + +constructor TfrxDBXQuery.DesignCreate(AOwner: TComponent; Flags: Word); +var + i: Integer; + l: TList; +begin + inherited; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + if TObject(l[i]) is TfrxDBXDatabase then + begin + SetDatabase(TfrxDBXDatabase(l[i])); + break; + end; +end; + +class function TfrxDBXQuery.GetDescription: String; +begin + Result := frxResources.Get('obDBXQ'); +end; + +procedure TfrxDBXQuery.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FDatabase) then + SetDatabase(nil); +end; + +procedure TfrxDBXQuery.SetDatabase(const Value: TfrxDBXDatabase); +begin + FDatabase := Value; + if Value <> nil then + FQuery.SQLConnection := Value.Database + else if DBXComponents <> nil then + FQuery.SQLConnection := DBXComponents.DefaultDatabase + else + FQuery.SQLConnection := nil; + DBConnected := FQuery.SQLConnection <> nil; +end; + +function TfrxDBXQuery.GetSQL: TStrings; +begin + FLock := True; + FStrings.Assign(FQuery.SQL); + FLock := False; + Result := FStrings; +end; + +procedure TfrxDBXQuery.SetSQL(Value: TStrings); +begin + FQuery.SQL.Assign(Value); + FStrings.Assign(Value); +end; + +procedure TfrxDBXQuery.SetMaster(const Value: TDataSource); +begin + FQuery.DataSource := Value; +end; + +procedure TfrxDBXQuery.UpdateParams; +begin + frxParamsToTParams(Self, FQuery.Params); +end; + +procedure TfrxDBXQuery.BeforeStartReport; +begin + SetDatabase(FDatabase); +end; + +procedure TfrxDBXQuery.OnChangeSQL(Sender: TObject); +begin + if not FLock then + begin + FQuery.SQL.Assign(FStrings); + inherited; + end; +end; + +{$IFDEF QBUILDER} +function TfrxDBXQuery.QBEngine: TfqbEngine; +begin + Result := TfrxEngineDBX.Create(nil); + TfrxEngineDBX(Result).FQuery.SQLConnection := FQuery.SQLConnection; +end; +{$ENDIF} + + +{$IFDEF QBUILDER} +constructor TfrxEngineDBX.Create(AOwner: TComponent); +begin + inherited; + FQuery := TSQLQuery.Create(nil); + FDBXDataset := TfrxDBXDataset.Create(nil); + FDBXDataset.Dataset := FQuery; +end; + +destructor TfrxEngineDBX.Destroy; +begin + FQuery.Free; + FDBXDataset.Free; + inherited; +end; + +procedure TfrxEngineDBX.ReadFieldList(const ATableName: string; + var AFieldList: TfqbFieldList); +var + TempTable: TSQLTable; + Fields: TFieldDefs; + i: Integer; + tmpField: TfqbField; +begin + AFieldList.Clear; + TempTable := TSQLTable.Create(Self); + TempTable.SQLConnection := FQuery.SQLConnection; + TempTable.TableName := ATableName; + Fields := TempTable.FieldDefs; + try + try + TempTable.Active := True; + tmpField:= TfqbField(AFieldList.Add); + tmpField.FieldName := '*'; + for i := 0 to Fields.Count - 1 do + begin + tmpField := TfqbField(AFieldList.Add); + tmpField.FieldName := Fields.Items[i].Name; + tmpField.FieldType := Ord(Fields.Items[i].DataType) + end; + except + end; + finally + TempTable.Free; + end; +end; + +procedure TfrxEngineDBX.ReadTableList(ATableList: TStrings); +begin + ATableList.Clear; + FQuery.SQLConnection.GetTableNames(ATableList, ShowSystemTables); +end; + +function TfrxEngineDBX.ResultDataSet: TDataSet; +begin + Result := FDBXDataset; +end; + +procedure TfrxEngineDBX.SetSQL(const Value: string); +begin + FQuery.SQL.Text := Value; +end; +{$ENDIF} + + + +initialization + frxObjects.RegisterObject1(TfrxDBXDataBase, nil, '', '', 0, 57); + frxObjects.RegisterObject1(TfrxDBXTable, nil, '', '', 0, 58); + frxObjects.RegisterObject1(TfrxDBXQuery, nil, '', '', 0, 59); + +finalization + frxObjects.UnRegister(TfrxDBXDataBase); + frxObjects.UnRegister(TfrxDBXTable); + frxObjects.UnRegister(TfrxDBXQuery); + + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxDBXEditor.pas b/official/4.2/LibD11/frxDBXEditor.pas new file mode 100644 index 0000000..88024f8 --- /dev/null +++ b/official/4.2/LibD11/frxDBXEditor.pas @@ -0,0 +1,170 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ DBX components design editors } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDBXEditor; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, Dialogs, frxDBXComponents, frxCustomDB, + frxDsgnIntf, frxRes, DBXpress, SqlExpr +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxConnectionNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + TfrxDriverNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + TfrxDatabaseProperty = class(TfrxComponentProperty) + public + function GetValue: String; override; + end; + + TfrxTableNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxIndexNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + +{ TfrxConnectionNameProperty } + +function TfrxConnectionNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +procedure TfrxConnectionNameProperty.GetValues; +begin + inherited; + GetConnectionNames(Values); +end; + + +{ TfrxDriverNameProperty } + +function TfrxDriverNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +procedure TfrxDriverNameProperty.GetValues; +begin + inherited; + GetDriverNames(Values); +end; + + +{ TfrxDatabaseProperty } + +function TfrxDatabaseProperty.GetValue: String; +var + db: TfrxDBXDatabase; +begin + db := TfrxDBXDatabase(GetOrdValue); + if db = nil then + begin + if (DBXComponents <> nil) and (DBXComponents.DefaultDatabase <> nil) then + Result := DBXComponents.DefaultDatabase.Name + else + Result := frxResources.Get('prNotAssigned'); + end + else + Result := inherited GetValue; +end; + + +{ TfrxTableNameProperty } + +function TfrxTableNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +procedure TfrxTableNameProperty.GetValues; +begin + inherited; + with TfrxDBXTable(Component).Table do + if SQLConnection <> nil then + SQLConnection.GetTableNames(Values, False); +end; + +procedure TfrxTableNameProperty.SetValue(const Value: String); +begin + inherited; + Designer.UpdateDataTree; +end; + + +{ TfrxIndexProperty } + +function TfrxIndexNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +procedure TfrxIndexNameProperty.GetValues; +var + i: Integer; +begin + inherited; + try + with TfrxDBXTable(Component).Table do + if (TableName <> '') and (IndexDefs <> nil) then + begin + IndexDefs.Update; + for i := 0 to IndexDefs.Count - 1 do + if IndexDefs[i].Name <> '' then + Values.Add(IndexDefs[i].Name); + end; + except + end; +end; + + +initialization + frxPropertyEditors.Register(TypeInfo(String), TfrxDBXDataBase, 'ConnectionName', + TfrxConnectionNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxDBXDataBase, 'DriverName', + TfrxDriverNameProperty); + frxPropertyEditors.Register(TypeInfo(TfrxDBXDatabase), TfrxDBXTable, 'Database', + TfrxDatabaseProperty); + frxPropertyEditors.Register(TypeInfo(TfrxDBXDatabase), TfrxDBXQuery, 'Database', + TfrxDatabaseProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxDBXTable, 'TableName', + TfrxTableNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxDBXTable, 'IndexName', + TfrxIndexNameProperty); + +end. diff --git a/official/4.2/LibD11/frxDBXRTTI.pas b/official/4.2/LibD11/frxDBXRTTI.pas new file mode 100644 index 0000000..a8970a3 --- /dev/null +++ b/official/4.2/LibD11/frxDBXRTTI.pas @@ -0,0 +1,72 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ DBX components RTTI } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDBXRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, fs_iinterpreter, frxDBXComponents +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddClass(TfrxDBXDatabase, 'TfrxCustomDatabase'); + AddClass(TfrxDBXTable, 'TfrxCustomTable'); + with AddClass(TfrxDBXQuery, 'TfrxCustomQuery') do + AddMethod('procedure ExecSQL', CallMethod); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TfrxDBXQuery then + begin + if MethodName = 'EXECSQL' then + TfrxDBXQuery(Instance).Query.ExecSQL + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/frxDBXReg.dcr b/official/4.2/LibD11/frxDBXReg.dcr new file mode 100644 index 0000000..413e70c Binary files /dev/null and b/official/4.2/LibD11/frxDBXReg.dcr differ diff --git a/official/4.2/LibD11/frxDBXReg.pas b/official/4.2/LibD11/frxDBXReg.pas new file mode 100644 index 0000000..8bb36e8 --- /dev/null +++ b/official/4.2/LibD11/frxDBXReg.pas @@ -0,0 +1,37 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ DBX components registration } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDBXReg; + +interface + +{$I frx.inc} + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes +{$IFNDEF Delphi6} +, DsgnIntf +{$ELSE} +, DesignIntf, DesignEditors +{$ENDIF} +, frxDBXComponents; + +procedure Register; +begin + RegisterComponents('FastReport 4.0', [TfrxDBXComponents]); +end; + +end. diff --git a/official/4.2/LibD11/frxDCtrl.pas b/official/4.2/LibD11/frxDCtrl.pas new file mode 100644 index 0000000..a8c485a --- /dev/null +++ b/official/4.2/LibD11/frxDCtrl.pas @@ -0,0 +1,1624 @@ + +{******************************************} +{ } +{ FastReport v2.4 - Dialog designer } +{ Standard Dialog controls } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDCtrl; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls, + ExtCtrls, Forms, Menus, Dialogs, Comctrls, Buttons, Mask, CheckLst, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxDialogControls = class(TComponent) // fake component + end; + + TfrxLabelControl = class(TfrxDialogControl) + private + FLabel: TLabel; + function GetAlignment: TAlignment; + function GetAutoSize: Boolean; + function GetWordWrap: Boolean; + procedure SetAlignment(const Value: TAlignment); + procedure SetAutoSize(const Value: Boolean); + procedure SetWordWrap(const Value: Boolean); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + procedure BeforeStartReport; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + property LabelCtl: TLabel read FLabel; + published + property Alignment: TAlignment read GetAlignment write SetAlignment + default taLeftJustify; + property AutoSize: Boolean read GetAutoSize write SetAutoSize default True; + property Caption; + property Color; + property WordWrap: Boolean read GetWordWrap write SetWordWrap default False; + + property OnClick; + property OnDblClick; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxCustomEditControl = class(TfrxDialogControl) + private + FOnChange: TfrxNotifyEvent; + function GetMaxLength: Integer; + function GetPasswordChar: Char; + function GetReadOnly: Boolean; + function GetText: String; + procedure DoOnChange(Sender: TObject); + procedure SetMaxLength(const Value: Integer); + procedure SetPasswordChar(const Value: Char); + procedure SetReadOnly(const Value: Boolean); + procedure SetText(const Value: String); + protected + FCustomEdit: TCustomEdit; + public + constructor Create(AOwner: TComponent); override; + property MaxLength: Integer read GetMaxLength write SetMaxLength; + property PasswordChar: Char read GetPasswordChar write SetPasswordChar; + property ReadOnly: Boolean read GetReadOnly write SetReadOnly default False; + property Text: String read GetText write SetText; + property OnChange: TfrxNotifyEvent read FOnChange write FOnChange; + end; + + TfrxEditControl = class(TfrxCustomEditControl) + private + FEdit: TEdit; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property Edit: TEdit read FEdit; + published + property Color; + property MaxLength; + property PasswordChar; + property ReadOnly; + property TabStop; + property Text; + property OnChange; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxMemoControl = class(TfrxCustomEditControl) + private + FMemo: TMemo; + function GetLines: TStrings; + procedure SetLines(const Value: TStrings); + function GetScrollStyle: TScrollStyle; + function GetWordWrap: Boolean; + procedure SetScrollStyle(const Value: TScrollStyle); + procedure SetWordWrap(const Value: Boolean); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property Memo: TMemo read FMemo; + published + property Color; + property Lines: TStrings read GetLines write SetLines; + property MaxLength; + property ReadOnly; + property ScrollBars: TScrollStyle read GetScrollStyle write SetScrollStyle default ssNone; + property TabStop; + property WordWrap: Boolean read GetWordWrap write SetWordWrap default True; + property OnChange; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxButtonControl = class(TfrxDialogControl) + private + FButton: TButton; + function GetCancel: Boolean; + function GetDefault: Boolean; + function GetModalResult: TModalResult; + procedure SetCancel(const Value: Boolean); + procedure SetDefault(const Value: Boolean); + procedure SetModalResult(const Value: TModalResult); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property Button: TButton read FButton; + published + property Cancel: Boolean read GetCancel write SetCancel default False; + property Caption; + property Default: Boolean read GetDefault write SetDefault default False; + property ModalResult: TModalResult read GetModalResult write SetModalResult default mrNone; + property TabStop; + property OnClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxCheckBoxControl = class(TfrxDialogControl) + private + FCheckBox: TCheckBox; + function GetAlignment: TAlignment; + function GetAllowGrayed: Boolean; + function GetChecked: Boolean; + function GetState: TCheckBoxState; + procedure SetAlignment(const Value: TAlignment); + procedure SetAllowGrayed(const Value: Boolean); + procedure SetChecked(const Value: Boolean); + procedure SetState(const Value: TCheckBoxState); +{$IFDEF Delphi7} + function GetWordWrap: Boolean; + procedure SetWordWrap(const Value: Boolean); +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property CheckBox: TCheckBox read FCheckBox; + published + property Alignment: TAlignment read GetAlignment write SetAlignment + default taRightJustify; + property Caption; + property Checked: Boolean read GetChecked write SetChecked default False; + property AllowGrayed: Boolean read GetAllowGrayed write SetAllowGrayed default False; + property State: TCheckBoxState read GetState write SetState default cbUnchecked; + property TabStop; +{$IFDEF Delphi7} + property WordWrap: Boolean read GetWordWrap write SetWordWrap default False; +{$ENDIF} + property Color; + property OnClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxRadioButtonControl = class(TfrxDialogControl) + private + FRadioButton: TRadioButton; + function GetAlignment: TAlignment; + function GetChecked: Boolean; + procedure SetAlignment(const Value: TAlignment); + procedure SetChecked(const Value: Boolean); +{$IFDEF Delphi7} + function GetWordWrap: Boolean; + procedure SetWordWrap(const Value: Boolean); +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property RadioButton: TRadioButton read FRadioButton; + published + property Alignment: TAlignment read GetAlignment write SetAlignment + default taRightJustify; + property Caption; + property Checked: Boolean read GetChecked write SetChecked default False; + property TabStop; +{$IFDEF Delphi7} + property WordWrap: Boolean read GetWordWrap write SetWordWrap default False; +{$ENDIF} + property Color; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxListBoxControl = class(TfrxDialogControl) + private + FListBox: TListBox; + function GetItems: TStrings; + procedure SetItems(const Value: TStrings); + function GetItemIndex: Integer; + procedure SetItemIndex(const Value: Integer); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property ListBox: TListBox read FListBox; + property ItemIndex: Integer read GetItemIndex write SetItemIndex; + published + property Color; + property Items: TStrings read GetItems write SetItems; + property TabStop; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxComboBoxControl = class(TfrxDialogControl) + private + FComboBox: TComboBox; + FOnChange: TfrxNotifyEvent; + function GetItemIndex: Integer; + function GetItems: TStrings; + function GetStyle: TComboBoxStyle; + function GetText: String; + procedure DoOnChange(Sender: TObject); + procedure SetItemIndex(const Value: Integer); + procedure SetItems(const Value: TStrings); + procedure SetStyle(const Value: TComboBoxStyle); + procedure SetText(const Value: String); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property ComboBox: TComboBox read FComboBox; + published + property Color; + property Items: TStrings read GetItems write SetItems; + property Style: TComboBoxStyle read GetStyle write SetStyle default csDropDown; + property TabStop; + property Text: String read GetText write SetText; + property ItemIndex: Integer read GetItemIndex write SetItemIndex; + property OnChange: TfrxNotifyEvent read FOnChange write FOnChange; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + end; + + TfrxPanelControl = class(TfrxDialogControl) + private + FPanel: TPanel; + function GetAlignment: TAlignment; + function GetBevelInner: TPanelBevel; + function GetBevelOuter: TPanelBevel; + function GetBevelWidth: Integer; + procedure SetAlignment(const Value: TAlignment); + procedure SetBevelInner(const Value: TPanelBevel); + procedure SetBevelOuter(const Value: TPanelBevel); + procedure SetBevelWidth(const Value: Integer); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property Panel: TPanel read FPanel; + published + property Alignment: TAlignment read GetAlignment write SetAlignment default taCenter; + property BevelInner: TPanelBevel read GetBevelInner write SetBevelInner default bvNone; + property BevelOuter: TPanelBevel read GetBevelOuter write SetBevelOuter default bvRaised; + property BevelWidth: Integer read GetBevelWidth write SetBevelWidth default 1; + property Caption; + property Color; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxGroupBoxControl = class(TfrxDialogControl) + private + FGroupBox: TGroupBox; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property GroupBox: TGroupBox read FGroupBox; + published + property Caption; + property Color; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxDateEditControl = class(TfrxDialogControl) + private + FDateEdit: TDateTimePicker; + FOnChange: TfrxNotifyEvent; + function GetDate: TDate; + function GetTime: TTime; + function GetDateFormat: TDTDateFormat; + function GetKind: TDateTimeKind; + procedure DoOnChange(Sender: TObject); + procedure SetDate(const Value: TDate); + procedure SetTime(const Value: TTime); + procedure SetDateFormat(const Value: TDTDateFormat); + procedure SetKind(const Value: TDateTimeKind); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property DateEdit: TDateTimePicker read FDateEdit; + published + property Color; + property Date: TDate read GetDate write SetDate; + property DateFormat: TDTDateFormat read GetDateFormat write SetDateFormat + default dfShort; + property Kind: TDateTimeKind read GetKind write SetKind default dtkDate; + property TabStop; + property Time: TTime read GetTime write SetTime; + property OnChange: TfrxNotifyEvent read FOnChange write FOnChange; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + end; + + TfrxImageControl = class(TfrxDialogControl) + private + FImage: TImage; + function GetAutoSize: Boolean; + function GetCenter: Boolean; + function GetPicture: TPicture; + function GetStretch: Boolean; + procedure SetAutoSize(const Value: Boolean); + procedure SetCenter(const Value: Boolean); + procedure SetPicture(const Value: TPicture); + procedure SetStretch(const Value: Boolean); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property Image: TImage read FImage; + published + property AutoSize: Boolean read GetAutoSize write SetAutoSize default False; + property Center: Boolean read GetCenter write SetCenter default False; + property Picture: TPicture read GetPicture write SetPicture; + property Stretch: Boolean read GetStretch write SetStretch default False; + property OnClick; + property OnDblClick; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxBevelControl = class(TfrxDialogControl) + private + FBevel: TBevel; + function GetBevelShape: TBevelShape; + function GetBevelStyle: TBevelStyle; + procedure SetBevelShape(const Value: TBevelShape); + procedure SetBevelStyle(const Value: TBevelStyle); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property Bevel: TBevel read FBevel; + published + property Shape: TBevelShape read GetBevelShape write SetBevelShape default bsBox; + property Style: TBevelStyle read GetBevelStyle write SetBevelStyle default bsLowered; + end; + + TfrxBitBtnControl = class(TfrxDialogControl) + private + FBitBtn: TBitBtn; + function GetGlyph: TBitmap; + function GetKind: TBitBtnKind; + function GetLayout: TButtonLayout; + function GetMargin: Integer; + function GetModalResult: TModalResult; + function GetSpacing: Integer; + procedure SetGlyph(const Value: TBitmap); + procedure SetKind(const Value: TBitBtnKind); + procedure SetLayout(const Value: TButtonLayout); + procedure SetMargin(const Value: Integer); + procedure SetModalResult(const Value: TModalResult); + procedure SetSpacing(const Value: Integer); + function GetNumGlyphs: Integer; + procedure SetNumGlyphs(const Value: Integer); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property BitBtn: TBitBtn read FBitBtn; + published + property Glyph: TBitmap read GetGlyph write SetGlyph; + property Kind: TBitBtnKind read GetKind write SetKind default bkCustom; + property Caption; // should be after Kind prop + property Layout: TButtonLayout read GetLayout write SetLayout default blGlyphLeft; + property Margin: Integer read GetMargin write SetMargin default -1; + property ModalResult: TModalResult read GetModalResult write SetModalResult default mrNone; + property NumGlyphs: Integer read GetNumGlyphs write SetNumGlyphs default 1; + property Spacing: Integer read GetSpacing write SetSpacing default 4; + property TabStop; + property OnClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxSpeedButtonControl = class(TfrxDialogControl) + private + FSpeedButton: TSpeedButton; + function GetAllowAllUp: Boolean; + function GetDown: Boolean; + function GetFlat: Boolean; + function GetGlyph: TBitmap; + function GetGroupIndex: Integer; + function GetLayout: TButtonLayout; + function GetMargin: Integer; + function GetSpacing: Integer; + procedure SetAllowAllUp(const Value: Boolean); + procedure SetDown(const Value: Boolean); + procedure SetFlat(const Value: Boolean); + procedure SetGlyph(const Value: TBitmap); + procedure SetGroupIndex(const Value: Integer); + procedure SetLayout(const Value: TButtonLayout); + procedure SetMargin(const Value: Integer); + procedure SetSpacing(const Value: Integer); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property SpeedButton: TSpeedButton read FSpeedButton; + published + property AllowAllUp: Boolean read GetAllowAllUp write SetAllowAllUp default False; + property Caption; + property Down: Boolean read GetDown write SetDown default False; + property Flat: Boolean read GetFlat write SetFlat default False; + property Glyph: TBitmap read GetGlyph write SetGlyph; + property GroupIndex: Integer read GetGroupIndex write SetGroupIndex; + property Layout: TButtonLayout read GetLayout write SetLayout default blGlyphLeft; + property Margin: Integer read GetMargin write SetMargin default -1; + property Spacing: Integer read GetSpacing write SetSpacing default 4; + property OnClick; + property OnDblClick; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxMaskEditControl = class(TfrxCustomEditControl) + private + FMaskEdit: TMaskEdit; + function GetEditMask: String; + procedure SetEditMask(const Value: String); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property MaskEdit: TMaskEdit read FMaskEdit; + published + property Color; + property EditMask: String read GetEditMask write SetEditMask; + property MaxLength; + property ReadOnly; + property TabStop; + property Text; + property OnChange; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + TfrxCheckListBoxControl = class(TfrxDialogControl) + private + FCheckListBox: TCheckListBox; + function GetAllowGrayed: Boolean; + function GetItems: TStrings; + function GetSorted: Boolean; + function GetChecked(Index: Integer): Boolean; + function GetState(Index: Integer): TCheckBoxState; + procedure SetAllowGrayed(const Value: Boolean); + procedure SetItems(const Value: TStrings); + procedure SetSorted(const Value: Boolean); + procedure SetChecked(Index: Integer; const Value: Boolean); + procedure SetState(Index: Integer; const Value: TCheckBoxState); + function GetItemIndex: Integer; + procedure SetItemIndex(const Value: Integer); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property CheckListBox: TCheckListBox read FCheckListBox; + property Checked[Index: Integer]: Boolean read GetChecked write SetChecked; + property ItemIndex: Integer read GetItemIndex write SetItemIndex; + property State[Index: Integer]: TCheckBoxState read GetState write SetState; + published + property AllowGrayed: Boolean read GetAllowGrayed write SetAllowGrayed default False; + property Color; + property Items: TStrings read GetItems write SetItems; + property Sorted: Boolean read GetSorted write SetSorted default False; + property TabStop; + property OnClick; + property OnDblClick; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + end; + + + +implementation + +uses frxDCtrlRTTI, frxUtils, frxDsgnIntf, frxRes; + +type + THackCustomEdit = class(TCustomEdit); + + +{ TfrxLabelControl } + +constructor TfrxLabelControl.Create(AOwner: TComponent); +begin + inherited; + FLabel := TLabel.Create(nil); + InitControl(FLabel); +end; + +class function TfrxLabelControl.GetDescription: String; +begin + Result := frxResources.Get('obLabel'); +end; + +procedure TfrxLabelControl.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +begin + if FLabel.AutoSize then + begin + Width := FLabel.Width; + Height := FLabel.Height; + end + else + begin + FLabel.Width := Round(Width); + FLabel.Height := Round(Height); + end; + inherited; +end; + +function TfrxLabelControl.GetAlignment: TAlignment; +begin + Result := FLabel.Alignment; +end; + +function TfrxLabelControl.GetAutoSize: Boolean; +begin + Result := FLabel.AutoSize; +end; + +function TfrxLabelControl.GetWordWrap: Boolean; +begin + Result := FLabel.WordWrap; +end; + +procedure TfrxLabelControl.SetAlignment(const Value: TAlignment); +begin + FLabel.Alignment := Value; +end; + +procedure TfrxLabelControl.SetAutoSize(const Value: Boolean); +begin + FLabel.AutoSize := Value; +end; + +procedure TfrxLabelControl.SetWordWrap(const Value: Boolean); +begin + FLabel.WordWrap := Value; +end; + +procedure TfrxLabelControl.BeforeStartReport; +begin + if not FLabel.AutoSize then + begin + FLabel.Width := Round(Width); + FLabel.Height := Round(Height); + end; +end; + + +{ TfrxCustomEditControl } + +constructor TfrxCustomEditControl.Create(AOwner: TComponent); +begin + inherited; + THackCustomEdit(FCustomEdit).OnChange := DoOnChange; + InitControl(FCustomEdit); +end; + +function TfrxCustomEditControl.GetMaxLength: Integer; +begin + Result := THackCustomEdit(FCustomEdit).MaxLength; +end; + +function TfrxCustomEditControl.GetPasswordChar: Char; +begin + Result := THackCustomEdit(FCustomEdit).PasswordChar; +end; + +function TfrxCustomEditControl.GetReadOnly: Boolean; +begin + Result := THackCustomEdit(FCustomEdit).ReadOnly; +end; + +function TfrxCustomEditControl.GetText: String; +begin + Result := THackCustomEdit(FCustomEdit).Text; +end; + +procedure TfrxCustomEditControl.SetMaxLength(const Value: Integer); +begin + THackCustomEdit(FCustomEdit).MaxLength := Value; +end; + +procedure TfrxCustomEditControl.SetPasswordChar(const Value: Char); +begin + THackCustomEdit(FCustomEdit).PasswordChar := Value; +end; + +procedure TfrxCustomEditControl.SetReadOnly(const Value: Boolean); +begin + THackCustomEdit(FCustomEdit).ReadOnly := Value; +end; + +procedure TfrxCustomEditControl.SetText(const Value: String); +begin + THackCustomEdit(FCustomEdit).Text := Value; +end; + +procedure TfrxCustomEditControl.DoOnChange(Sender: TObject); +begin + if Report <> nil then + Report.DoNotifyEvent(Self, FOnChange); +end; + + +{ TfrxEditControl } + +constructor TfrxEditControl.Create(AOwner: TComponent); +begin + FEdit := TEdit.Create(nil); + FCustomEdit := FEdit; + inherited; + + Width := 121; + Height := 21; +end; + +class function TfrxEditControl.GetDescription: String; +begin + Result := frxResources.Get('obEdit'); +end; + + +{ TfrxMemoControl } + +constructor TfrxMemoControl.Create(AOwner: TComponent); +begin + FMemo := TMemo.Create(nil); + FCustomEdit := FMemo; + inherited; + + Width := 185; + Height := 89; +end; + +class function TfrxMemoControl.GetDescription: String; +begin + Result := frxResources.Get('obMemoC'); +end; + +function TfrxMemoControl.GetLines: TStrings; +begin + Result := FMemo.Lines; +end; + +function TfrxMemoControl.GetScrollStyle: TScrollStyle; +begin + Result := FMemo.ScrollBars; +end; + +function TfrxMemoControl.GetWordWrap: Boolean; +begin + Result := FMemo.WordWrap; +end; + +procedure TfrxMemoControl.SetLines(const Value: TStrings); +begin + FMemo.Lines := Value; +end; + +procedure TfrxMemoControl.SetScrollStyle(const Value: TScrollStyle); +begin + FMemo.ScrollBars := Value; +end; + +procedure TfrxMemoControl.SetWordWrap(const Value: Boolean); +begin + FMemo.WordWrap := Value; +end; + + +{ TfrxButtonControl } + +constructor TfrxButtonControl.Create(AOwner: TComponent); +begin + inherited; + FButton := TButton.Create(nil); + InitControl(FButton); + + Width := 75; + Height := 25; +end; + +class function TfrxButtonControl.GetDescription: String; +begin + Result := frxResources.Get('obButton'); +end; + +function TfrxButtonControl.GetCancel: Boolean; +begin + Result := FButton.Cancel; +end; + +function TfrxButtonControl.GetDefault: Boolean; +begin + Result := FButton.Default; +end; + +function TfrxButtonControl.GetModalResult: TModalResult; +begin + Result := FButton.ModalResult; +end; + +procedure TfrxButtonControl.SetCancel(const Value: Boolean); +begin + FButton.Cancel := Value; +end; + +procedure TfrxButtonControl.SetDefault(const Value: Boolean); +begin + FButton.Default := Value; +end; + +procedure TfrxButtonControl.SetModalResult(const Value: TModalResult); +begin + FButton.ModalResult := Value; +end; + + +{ TfrxCheckBoxControl } + +constructor TfrxCheckBoxControl.Create(AOwner: TComponent); +begin + inherited; + FCheckBox := TCheckBox.Create(nil); + InitControl(FCheckBox); + + Width := 97; + Height := 17; + Alignment := taRightJustify; +end; + +class function TfrxCheckBoxControl.GetDescription: String; +begin + Result := frxResources.Get('obChBoxC'); +end; + +function TfrxCheckBoxControl.GetAlignment: TAlignment; +begin + Result := FCheckBox.Alignment; +end; + +function TfrxCheckBoxControl.GetAllowGrayed: Boolean; +begin + Result := FCheckBox.AllowGrayed; +end; + +function TfrxCheckBoxControl.GetChecked: Boolean; +begin + Result := FCheckBox.Checked; +end; + +function TfrxCheckBoxControl.GetState: TCheckBoxState; +begin + Result := FCheckBox.State; +end; + +procedure TfrxCheckBoxControl.SetAlignment(const Value: TAlignment); +begin + FCheckBox.Alignment := Value; +end; + +procedure TfrxCheckBoxControl.SetAllowGrayed(const Value: Boolean); +begin + FCheckBox.AllowGrayed := Value; +end; + +procedure TfrxCheckBoxControl.SetChecked(const Value: Boolean); +begin + FCheckBox.Checked := Value; +end; + +procedure TfrxCheckBoxControl.SetState(const Value: TCheckBoxState); +begin + FCheckBox.State := Value; +end; + +{$IFDEF Delphi7} +function TfrxCheckBoxControl.GetWordWrap: Boolean; +begin + Result := FCheckBox.WordWrap; +end; + +procedure TfrxCheckBoxControl.SetWordWrap(const Value: Boolean); +begin + FCheckBox.WordWrap := Value; +end; +{$ENDIF} + + +{ TfrxRadioButtonControl } + +constructor TfrxRadioButtonControl.Create(AOwner: TComponent); +begin + inherited; + FRadioButton := TRadioButton.Create(nil); + InitControl(FRadioButton); + + Width := 113; + Height := 17; + Alignment := taRightJustify; +end; + +class function TfrxRadioButtonControl.GetDescription: String; +begin + Result := frxResources.Get('obRButton'); +end; + +function TfrxRadioButtonControl.GetAlignment: TAlignment; +begin + Result := FRadioButton.Alignment; +end; + +function TfrxRadioButtonControl.GetChecked: Boolean; +begin + Result := FRadioButton.Checked; +end; + +procedure TfrxRadioButtonControl.SetAlignment(const Value: TAlignment); +begin + FRadioButton.Alignment := Value; +end; + +procedure TfrxRadioButtonControl.SetChecked(const Value: Boolean); +begin + FRadioButton.Checked := Value; +end; + +{$IFDEF Delphi7} +function TfrxRadioButtonControl.GetWordWrap: Boolean; +begin + Result := FRadioButton.WordWrap; +end; + +procedure TfrxRadioButtonControl.SetWordWrap(const Value: Boolean); +begin + FRadioButton.WordWrap := Value; +end; +{$ENDIF} + + +{ TfrxListBoxControl } + +constructor TfrxListBoxControl.Create(AOwner: TComponent); +begin + inherited; + FListBox := TListBox.Create(nil); + InitControl(FListBox); + + Width := 121; + Height := 97; +end; + +class function TfrxListBoxControl.GetDescription: String; +begin + Result := frxResources.Get('obLBox'); +end; + +function TfrxListBoxControl.GetItems: TStrings; +begin + Result := FListBox.Items; +end; + +function TfrxListBoxControl.GetItemIndex: Integer; +begin + Result := FListBox.ItemIndex; +end; + +procedure TfrxListBoxControl.SetItems(const Value: TStrings); +begin + FListBox.Items := Value; +end; + +procedure TfrxListBoxControl.SetItemIndex(const Value: Integer); +begin + FListBox.ItemIndex := Value; +end; + + +{ TfrxComboBoxControl } + +constructor TfrxComboBoxControl.Create(AOwner: TComponent); +begin + inherited; + FComboBox := TComboBox.Create(nil); + FComboBox.OnChange := DoOnChange; + InitControl(FComboBox); + + Width := 145; + Height := 21; +end; + +class function TfrxComboBoxControl.GetDescription: String; +begin + Result := frxResources.Get('obCBox'); +end; + +function TfrxComboBoxControl.GetItems: TStrings; +begin + Result := FComboBox.Items; +end; + +function TfrxComboBoxControl.GetItemIndex: Integer; +begin + Result := FComboBox.ItemIndex; +end; + +function TfrxComboBoxControl.GetStyle: TComboBoxStyle; +begin + Result := FComboBox.Style; +end; + +function TfrxComboBoxControl.GetText: String; +begin + Result := FComboBox.Text; +end; + +procedure TfrxComboBoxControl.SetItems(const Value: TStrings); +begin + FComboBox.Items := Value; +end; + +procedure TfrxComboBoxControl.SetItemIndex(const Value: Integer); +begin + FComboBox.ItemIndex := Value; +end; + +procedure TfrxComboBoxControl.SetStyle(const Value: TComboBoxStyle); +begin + FComboBox.Style := Value; +end; + +procedure TfrxComboBoxControl.SetText(const Value: String); +begin + FComboBox.Text := Value; +end; + +procedure TfrxComboBoxControl.DoOnChange(Sender: TObject); +begin + if Report <> nil then + Report.DoNotifyEvent(Self, FOnChange); +end; + + +{ TfrxDateEditControl } + +constructor TfrxDateEditControl.Create(AOwner: TComponent); +begin + inherited; + FDateEdit := TDateTimePicker.Create(nil); + FDateEdit.OnChange := DoOnChange; + InitControl(FDateEdit); + + Width := 145; + Height := 21; +end; + +class function TfrxDateEditControl.GetDescription: String; +begin + Result := frxResources.Get('obDateEdit'); +end; + +function TfrxDateEditControl.GetDate: TDate; +begin + Result := FDateEdit.Date; +end; + +function TfrxDateEditControl.GetTime: TTime; +begin + Result := FDateEdit.Time; +end; + +function TfrxDateEditControl.GetDateFormat: TDTDateFormat; +begin + Result := FDateEdit.DateFormat; +end; + +function TfrxDateEditControl.GetKind: TDateTimeKind; +begin + Result := FDateEdit.Kind; +end; + +procedure TfrxDateEditControl.SetDate(const Value: TDate); +begin + FDateEdit.Date := Value; +end; + +procedure TfrxDateEditControl.SetTime(const Value: TTime); +begin + FDateEdit.Time := Value; +end; + +procedure TfrxDateEditControl.SetDateFormat(const Value: TDTDateFormat); +begin + FDateEdit.DateFormat := Value; +end; + +procedure TfrxDateEditControl.SetKind(const Value: TDateTimeKind); +begin + FDateEdit.Kind := Value; +end; + +procedure TfrxDateEditControl.DoOnChange(Sender: TObject); +begin + if Report <> nil then + Report.DoNotifyEvent(Self, FOnChange); +end; + + +{ TfrxImageControl } + +constructor TfrxImageControl.Create(AOwner: TComponent); +begin + inherited; + FImage := TImage.Create(nil); + InitControl(FImage); + + Width := 100; + Height := 100; +end; + +class function TfrxImageControl.GetDescription: String; +begin + Result := frxResources.Get('obImageC'); +end; + +function TfrxImageControl.GetAutoSize: Boolean; +begin + Result := FImage.AutoSize; +end; + +function TfrxImageControl.GetCenter: Boolean; +begin + Result := FImage.Center; +end; + +function TfrxImageControl.GetPicture: TPicture; +begin + Result := FImage.Picture; +end; + +function TfrxImageControl.GetStretch: Boolean; +begin + Result := FImage.Stretch; +end; + +procedure TfrxImageControl.SetAutoSize(const Value: Boolean); +begin + FImage.AutoSize := Value; +end; + +procedure TfrxImageControl.SetCenter(const Value: Boolean); +begin + FImage.Center := Value; +end; + +procedure TfrxImageControl.SetPicture(const Value: TPicture); +begin + FImage.Picture.Assign(Value); +end; + +procedure TfrxImageControl.SetStretch(const Value: Boolean); +begin + FImage.Stretch := Value; +end; + + +{ TfrxBevelControl } + +constructor TfrxBevelControl.Create(AOwner: TComponent); +begin + inherited; + FBevel := TBevel.Create(nil); + InitControl(FBevel); + + Width := 50; + Height := 50; +end; + +class function TfrxBevelControl.GetDescription: String; +begin + Result := frxResources.Get('obBevel'); +end; + +function TfrxBevelControl.GetBevelShape: TBevelShape; +begin + Result := FBevel.Shape; +end; + +function TfrxBevelControl.GetBevelStyle: TBevelStyle; +begin + Result := FBevel.Style; +end; + +procedure TfrxBevelControl.SetBevelShape(const Value: TBevelShape); +begin + FBevel.Shape := Value; +end; + +procedure TfrxBevelControl.SetBevelStyle(const Value: TBevelStyle); +begin + FBevel.Style := Value; +end; + + +{ TfrxPanelControl } + +constructor TfrxPanelControl.Create(AOwner: TComponent); +begin + inherited; + FPanel := TPanel.Create(nil); + InitControl(FPanel); + + Width := 185; + Height := 41; +end; + +class function TfrxPanelControl.GetDescription: String; +begin + Result := frxResources.Get('obPanel'); +end; + +function TfrxPanelControl.GetAlignment: TAlignment; +begin + Result := FPanel.Alignment; +end; + +function TfrxPanelControl.GetBevelInner: TPanelBevel; +begin + Result := FPanel.BevelInner; +end; + +function TfrxPanelControl.GetBevelOuter: TPanelBevel; +begin + Result := FPanel.BevelOuter; +end; + +function TfrxPanelControl.GetBevelWidth: Integer; +begin + Result := FPanel.BevelWidth; +end; + +procedure TfrxPanelControl.SetAlignment(const Value: TAlignment); +begin + FPanel.Alignment := Value; +end; + +procedure TfrxPanelControl.SetBevelInner(const Value: TPanelBevel); +begin + FPanel.BevelInner := Value; +end; + +procedure TfrxPanelControl.SetBevelOuter(const Value: TPanelBevel); +begin + FPanel.BevelOuter := Value; +end; + +procedure TfrxPanelControl.SetBevelWidth(const Value: Integer); +begin + FPanel.BevelWidth := Value; +end; + + +{ TfrxGroupBoxControl } + +constructor TfrxGroupBoxControl.Create(AOwner: TComponent); +begin + inherited; + FGroupBox := TGroupBox.Create(nil); + InitControl(FGroupBox); + + Width := 185; + Height := 105; +end; + +class function TfrxGroupBoxControl.GetDescription: String; +begin + Result := frxResources.Get('obGrBox'); +end; + + +{ TfrxBitBtnControl } + +constructor TfrxBitBtnControl.Create(AOwner: TComponent); +begin + inherited; + FBitBtn := TBitBtn.Create(nil); + InitControl(FBitBtn); + + Width := 75; + Height := 25; +end; + +class function TfrxBitBtnControl.GetDescription: String; +begin + Result := frxResources.Get('obBBtn'); +end; + +function TfrxBitBtnControl.GetGlyph: TBitmap; +begin + Result := FBitBtn.Glyph; +end; + +function TfrxBitBtnControl.GetKind: TBitBtnKind; +begin + Result := FBitBtn.Kind; +end; + +function TfrxBitBtnControl.GetLayout: TButtonLayout; +begin + Result := FBitBtn.Layout; +end; + +function TfrxBitBtnControl.GetMargin: Integer; +begin + Result := FBitBtn.Margin; +end; + +function TfrxBitBtnControl.GetModalResult: TModalResult; +begin + Result := FBitBtn.ModalResult; +end; + +function TfrxBitBtnControl.GetNumGlyphs: Integer; +begin + Result := FBitBtn.NumGlyphs; +end; + +function TfrxBitBtnControl.GetSpacing: Integer; +begin + Result := FBitBtn.Spacing; +end; + +procedure TfrxBitBtnControl.SetGlyph(const Value: TBitmap); +begin + FBitBtn.Glyph := Value; +end; + +procedure TfrxBitBtnControl.SetKind(const Value: TBitBtnKind); +begin + FBitBtn.Kind := Value; +end; + +procedure TfrxBitBtnControl.SetLayout(const Value: TButtonLayout); +begin + FBitBtn.Layout := Value; +end; + +procedure TfrxBitBtnControl.SetMargin(const Value: Integer); +begin + FBitBtn.Margin := Value; +end; + +procedure TfrxBitBtnControl.SetModalResult(const Value: TModalResult); +begin + FBitBtn.ModalResult := Value; +end; + +procedure TfrxBitBtnControl.SetNumGlyphs(const Value: Integer); +begin + FBitBtn.NumGlyphs := Value; +end; + +procedure TfrxBitBtnControl.SetSpacing(const Value: Integer); +begin + FBitBtn.Spacing := Value; +end; + + +{ TfrxSpeedButtonControl } + +constructor TfrxSpeedButtonControl.Create(AOwner: TComponent); +begin + inherited; + FSpeedButton := TSpeedButton.Create(nil); + InitControl(FSpeedButton); + + Width := 22; + Height := 22; +end; + +class function TfrxSpeedButtonControl.GetDescription: String; +begin + Result := frxResources.Get('obSBtn'); +end; + +function TfrxSpeedButtonControl.GetAllowAllUp: Boolean; +begin + Result := FSpeedButton.AllowAllUp; +end; + +function TfrxSpeedButtonControl.GetDown: Boolean; +begin + Result := FSpeedButton.Down; +end; + +function TfrxSpeedButtonControl.GetFlat: Boolean; +begin + Result := FSpeedButton.Flat; +end; + +function TfrxSpeedButtonControl.GetGlyph: TBitmap; +begin + Result := FSpeedButton.Glyph; +end; + +function TfrxSpeedButtonControl.GetGroupIndex: Integer; +begin + Result := FSpeedButton.GroupIndex; +end; + +function TfrxSpeedButtonControl.GetLayout: TButtonLayout; +begin + Result := FSpeedButton.Layout; +end; + +function TfrxSpeedButtonControl.GetMargin: Integer; +begin + Result := FSpeedButton.Margin; +end; + +function TfrxSpeedButtonControl.GetSpacing: Integer; +begin + Result := FSpeedButton.Spacing; +end; + +procedure TfrxSpeedButtonControl.SetAllowAllUp(const Value: Boolean); +begin + FSpeedButton.AllowAllUp := Value; +end; + +procedure TfrxSpeedButtonControl.SetDown(const Value: Boolean); +begin + FSpeedButton.Down := Value; +end; + +procedure TfrxSpeedButtonControl.SetFlat(const Value: Boolean); +begin + FSpeedButton.Flat := Value; +end; + +procedure TfrxSpeedButtonControl.SetGlyph(const Value: TBitmap); +begin + FSpeedButton.Glyph := Value; +end; + +procedure TfrxSpeedButtonControl.SetGroupIndex(const Value: Integer); +begin + FSpeedButton.GroupIndex := Value; +end; + +procedure TfrxSpeedButtonControl.SetLayout(const Value: TButtonLayout); +begin + FSpeedButton.Layout := Value; +end; + +procedure TfrxSpeedButtonControl.SetMargin(const Value: Integer); +begin + FSpeedButton.Margin := Value; +end; + +procedure TfrxSpeedButtonControl.SetSpacing(const Value: Integer); +begin + FSpeedButton.Spacing := Value; +end; + + +{ TfrxMaskEditControl } + +constructor TfrxMaskEditControl.Create(AOwner: TComponent); +begin + FMaskEdit := TMaskEdit.Create(nil); + FCustomEdit := FMaskEdit; + inherited; + + Width := 121; + Height := 21; +end; + +class function TfrxMaskEditControl.GetDescription: String; +begin + Result := frxResources.Get('obMEdit'); +end; + +function TfrxMaskEditControl.GetEditMask: String; +begin + Result := FMaskEdit.EditMask; +end; + +procedure TfrxMaskEditControl.SetEditMask(const Value: String); +begin + FMaskEdit.EditMask := Value; +end; + + +{ TfrxCheckListBoxControl } + +constructor TfrxCheckListBoxControl.Create(AOwner: TComponent); +begin + inherited; + FCheckListBox := TCheckListBox.Create(nil); + InitControl(FCheckListBox); + + Width := 121; + Height := 97; +end; + +class function TfrxCheckListBoxControl.GetDescription: String; +begin + Result := frxResources.Get('obChLB'); +end; + +function TfrxCheckListBoxControl.GetAllowGrayed: Boolean; +begin + Result := FCheckListBox.AllowGrayed; +end; + +function TfrxCheckListBoxControl.GetItems: TStrings; +begin + Result := FCheckListBox.Items; +end; + +function TfrxCheckListBoxControl.GetSorted: Boolean; +begin + Result := FCheckListBox.Sorted; +end; + +function TfrxCheckListBoxControl.GetChecked(Index: Integer): Boolean; +begin + Result := FCheckListBox.Checked[Index]; +end; + +function TfrxCheckListBoxControl.GetState(Index: Integer): TCheckBoxState; +begin + Result := FCheckListBox.State[Index]; +end; + +procedure TfrxCheckListBoxControl.SetAllowGrayed(const Value: Boolean); +begin + FCheckListBox.AllowGrayed := Value; +end; + +procedure TfrxCheckListBoxControl.SetItems(const Value: TStrings); +begin + FCheckListBox.Items := Value; +end; + +procedure TfrxCheckListBoxControl.SetSorted(const Value: Boolean); +begin + FCheckListBox.Sorted := Value; +end; + +procedure TfrxCheckListBoxControl.SetChecked(Index: Integer; const Value: Boolean); +begin + FCheckListBox.Checked[Index] := Value; +end; + +procedure TfrxCheckListBoxControl.SetState(Index: Integer; const Value: TCheckBoxState); +begin + FCheckListBox.State[Index] := Value; +end; + +function TfrxCheckListBoxControl.GetItemIndex: Integer; +begin + Result := FCheckListBox.ItemIndex; +end; + +procedure TfrxCheckListBoxControl.SetItemIndex(const Value: Integer); +begin + FCheckListBox.ItemIndex := Value; +end; + + +initialization + frxObjects.RegisterObject1(TfrxLabelControl, nil, '', '', 0, 12); + frxObjects.RegisterObject1(TfrxEditControl, nil, '', '', 0, 13); + frxObjects.RegisterObject1(TfrxMemoControl, nil, '', '', 0, 14); + frxObjects.RegisterObject1(TfrxButtonControl, nil, '', '', 0, 15); + frxObjects.RegisterObject1(TfrxCheckBoxControl, nil, '', '', 0, 16); + frxObjects.RegisterObject1(TfrxRadioButtonControl, nil, '', '', 0, 17); + frxObjects.RegisterObject1(TfrxListBoxControl, nil, '', '', 0, 18); + frxObjects.RegisterObject1(TfrxComboBoxControl, nil, '', '', 0, 19); + frxObjects.RegisterObject1(TfrxPanelControl, nil, '', '', 0, 44); + frxObjects.RegisterObject1(TfrxGroupBoxControl, nil, '', '', 0, 43); + + frxObjects.RegisterObject1(TfrxDateEditControl, nil, '', '', 0, 20); + frxObjects.RegisterObject1(TfrxImageControl, nil, '', '', 0, 3); + frxObjects.RegisterObject1(TfrxBevelControl, nil, '', '', 0, 33); + frxObjects.RegisterObject1(TfrxBitBtnControl, nil, '', '', 0, 45); + frxObjects.RegisterObject1(TfrxSpeedButtonControl, nil, '', '', 0, 46); + frxObjects.RegisterObject1(TfrxMaskEditControl, nil, '', '', 0, 47); + frxObjects.RegisterObject1(TfrxCheckListBoxControl, nil, '', '', 0, 48); + + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDCtrlRTTI.pas b/official/4.2/LibD11/frxDCtrlRTTI.pas new file mode 100644 index 0000000..d401654 --- /dev/null +++ b/official/4.2/LibD11/frxDCtrlRTTI.pas @@ -0,0 +1,133 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Dialog controls RTTI } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDCtrlRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, fs_iformsrtti, + frxDCtrl, frxClassRTTI +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddClass(TfrxLabelControl, 'TfrxDialogControl'); + AddClass(TfrxEditControl, 'TfrxDialogControl'); + AddClass(TfrxMemoControl, 'TfrxDialogControl'); + AddClass(TfrxButtonControl, 'TfrxDialogControl'); + AddClass(TfrxCheckBoxControl, 'TfrxDialogControl'); + AddClass(TfrxRadioButtonControl, 'TfrxDialogControl'); + with AddClass(TfrxListBoxControl, 'TfrxDialogControl') do + AddProperty('ItemIndex', 'Integer', GetProp, SetProp); + AddClass(TfrxComboBoxControl, 'TfrxDialogControl'); + AddClass(TfrxDateEditControl, 'TfrxDialogControl'); + AddClass(TfrxImageControl, 'TfrxDialogControl'); + AddClass(TfrxBevelControl, 'TfrxDialogControl'); + AddClass(TfrxPanelControl, 'TfrxDialogControl'); + AddClass(TfrxGroupBoxControl, 'TfrxDialogControl'); + AddClass(TfrxBitBtnControl, 'TfrxDialogControl'); + AddClass(TfrxSpeedButtonControl, 'TfrxDialogControl'); + AddClass(TfrxMaskEditControl, 'TfrxDialogControl'); + with AddClass(TfrxCheckListBoxControl, 'TfrxDialogControl') do + begin + AddIndexProperty('Checked', 'Integer', 'Boolean', CallMethod); + AddIndexProperty('State', 'Integer', 'TCheckBoxState', CallMethod); + AddProperty('ItemIndex', 'Integer', GetProp, SetProp); + end; + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TfrxCheckListBoxControl then + begin + if MethodName = 'CHECKED.GET' then + Result := TfrxCheckListBoxControl(Instance).Checked[Caller.Params[0]] + else if MethodName = 'CHECKED.SET' then + TfrxCheckListBoxControl(Instance).Checked[Caller.Params[0]] := Caller.Params[1] + else if MethodName = 'STATE.GET' then + Result := TfrxCheckListBoxControl(Instance).State[Caller.Params[0]] + else if MethodName = 'STATE.SET' then + TfrxCheckListBoxControl(Instance).State[Caller.Params[0]] := Caller.Params[1] + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TfrxListBoxControl then + begin + if PropName = 'ITEMINDEX' then + Result := TfrxListBoxControl(Instance).ItemIndex + end + else if ClassType = TfrxCheckListBoxControl then + begin + if PropName = 'ITEMINDEX' then + Result := TfrxCheckListBoxControl(Instance).ItemIndex + end +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin + if ClassType = TfrxListBoxControl then + begin + if PropName = 'ITEMINDEX' then + TfrxListBoxControl(Instance).ItemIndex := Value; + end + else if ClassType = TfrxCheckListBoxControl then + begin + if PropName = 'ITEMINDEX' then + TfrxCheckListBoxControl(Instance).ItemIndex := Value; + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDMPClass.pas b/official/4.2/LibD11/frxDMPClass.pas new file mode 100644 index 0000000..4b065b8 --- /dev/null +++ b/official/4.2/LibD11/frxDMPClass.pas @@ -0,0 +1,581 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ DotMatrix printers stuff } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDMPClass; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs, + frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF FR_COM} +, FastReport_TLB +{$ENDIF} +; + +type + TfrxDMPFontStyle = (fsxBold, fsxItalic, fsxUnderline, fsxSuperScript, + fsxSubScript, fsxCondensed, fsxWide, fsx12cpi, fsx15cpi); + TfrxDMPFontStyles = set of TfrxDMPFontStyle; + +{$IFDEF FR_COM} + TfrxDMPMemoView = class(TfrxCustomMemoView, IfrxDMPMemoView) +{$ELSE} + TfrxDMPMemoView = class(TfrxCustomMemoView) +{$ENDIF} + private + FFontStyle: TfrxDMPFontStyles; + procedure SetFontStyle(const Value: TfrxDMPFontStyles); +{$IFDEF FR_COM} + function Get_FontStyle(out Value: frxFontStyle): HResult; stdcall; + function Set_FontStyle(Value: frxFontStyle): HResult; stdcall; +{$ENDIF} + function IsFontStyleStored: Boolean; + protected + procedure DrawFrame; override; + procedure SetLeft(Value: Extended); override; + procedure SetTop(Value: Extended); override; + procedure SetWidth(Value: Extended); override; + procedure SetHeight(Value: Extended); override; + procedure SetParentFont(const Value: Boolean); override; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + procedure ResetFontOptions; + procedure SetBoundsDirect(ALeft, ATop, AWidth, AHeight: Extended); + function CalcHeight: Extended; override; + function CalcWidth: Extended; override; + function Diff(AComponent: TfrxComponent): String; override; + published + property AutoWidth; + property AllowExpressions; + property DataField; + property DataSet; + property DataSetName; + property DisplayFormat; + property ExpressionDelimiters; + property FlowTo; + property FontStyle: TfrxDMPFontStyles read FFontStyle write SetFontStyle + stored IsFontStyleStored; + property Frame; + property HAlign; + property HideZeros; + property Memo; + property ParentFont; + property RTLReading; + property SuppressRepeated; + property WordWrap; + property VAlign; + end; + +{$IFDEF FR_COM} + TfrxDMPLineView = class(TfrxCustomLineView, IfrxDMPLineView) +{$ELSE} + TfrxDMPLineView = class(TfrxCustomLineView) +{$ENDIF} + private + FFontStyle: TfrxDMPFontStyles; + procedure SetFontStyle(const Value: TfrxDMPFontStyles); + function IsFontStyleStored: Boolean; +{$IFDEF FR_COM} + function Get_FontStyle(out Value: frxFontStyle): HResult; stdcall; + function Set_FontStyle(Value: frxFontStyle): HResult; stdcall; +{$ENDIF} + protected + procedure SetLeft(Value: Extended); override; + procedure SetTop(Value: Extended); override; + procedure SetWidth(Value: Extended); override; + procedure SetParentFont(const Value: Boolean); override; + public + class function GetDescription: String; override; + function Diff(AComponent: TfrxComponent): String; override; + published + property FontStyle: TfrxDMPFontStyles read FFontStyle write SetFontStyle + stored IsFontStyleStored; + property ParentFont; + end; + +{$IFDEF FR_COM} + TfrxDMPCommand = class(TfrxView, IfrxDMPCommand) +{$ELSE} + TfrxDMPCommand = class(TfrxView) +{$ENDIF} + private + FCommand: String; +{$IFDEF FR_COM} + function Get_Command(out Value: WideString): HResult; stdcall; + function Set_Command(const Value: WideString): HResult; stdcall; +{$ENDIF} + protected + procedure SetLeft(Value: Extended); override; + procedure SetTop(Value: Extended); override; + public + class function GetDescription: String; override; + function Diff(AComponent: TfrxComponent): String; override; + function ToChr: String; + published + property Command: String read FCommand write FCommand; + end; + +{$IFDEF FR_COM} + TfrxDMPPage = class(TfrxReportPage, IfrxDMPPage) +{$ELSE} + TfrxDMPPage = class(TfrxReportPage) +{$ENDIF} + private + FFontStyle: TfrxDMPFontStyles; + procedure SetFontStyle(const Value: TfrxDMPFontStyles); +{$IFDEF FR_COM} + function Get_FontStyle(out Value: frxFontStyle): HResult; stdcall; + function Set_FontStyle(Value: frxFontStyle): HResult; stdcall; +{$ENDIF} + protected + procedure SetPaperHeight(const Value: Extended); override; + procedure SetPaperWidth(const Value: Extended); override; + procedure SetPaperSize(const Value: Integer); override; + public + constructor Create(AOwner: TComponent); override; + procedure SetDefaults; override; + procedure ResetFontOptions; + published + property FontStyle: TfrxDMPFontStyles read FFontStyle write SetFontStyle; + end; + + +implementation + +uses frxRes, frxDsgnIntf, frxXML; + + +function DiffFontStyle(f: TfrxDMPFontStyles): String; +var + fs: Integer; +begin + fs := 0; + if fsxBold in f then fs := 1; + if fsxItalic in f then fs := fs or 2; + if fsxUnderline in f then fs := fs or 4; + if fsxSuperScript in f then fs := fs or 8; + if fsxSubScript in f then fs := fs or 16; + if fsxCondensed in f then fs := fs or 32; + if fsxWide in f then fs := fs or 64; + if fsx12cpi in f then fs := fs or 128; + if fsx15cpi in f then fs := fs or 256; + Result := ' FontStyle="' + IntToStr(fs) + '"'; +end; + + +{ TfrxDMPMemoView } + +constructor TfrxDMPMemoView.Create(AOwner: TComponent); +begin + inherited; + ResetFontOptions; +end; + +class function TfrxDMPMemoView.GetDescription: String; +begin + Result := frxResources.Get('obDMPText'); +end; + +procedure TfrxDMPMemoView.ResetFontOptions; +begin + Font.OnChange := nil; + Font.Name := 'Courier New'; + Font.Size := 12; + Font.Style := []; + if fsxBold in FFontStyle then + Font.Style := Font.Style + [fsBold]; + if fsxItalic in FFontStyle then + Font.Style := Font.Style + [fsItalic]; + if fsxUnderline in FFontStyle then + Font.Style := Font.Style + [fsUnderline]; + CharSpacing := 0; + LineSpacing := 1; + GapX := 0; + GapY := 0; +end; + +procedure TfrxDMPMemoView.SetHeight(Value: Extended); +begin + Value := Round(Value / fr1CharY) * fr1CharY; + inherited; +end; + +procedure TfrxDMPMemoView.SetLeft(Value: Extended); +begin + if Align = baRight then + Value := Trunc(Value / fr1CharX) * fr1CharX else + Value := Round(Value / fr1CharX) * fr1CharX; + inherited; +end; + +procedure TfrxDMPMemoView.SetTop(Value: Extended); +begin + Value := Round(Value / fr1CharY) * fr1CharY; + inherited; +end; + +procedure TfrxDMPMemoView.SetWidth(Value: Extended); +begin + Value := Round(Value / fr1CharX) * fr1CharX; + inherited; +end; + +procedure TfrxDMPMemoView.SetFontStyle(const Value: TfrxDMPFontStyles); +begin + FFontStyle := Value; + ParentFont := False; + ResetFontOptions; +end; + +procedure TfrxDMPMemoView.SetParentFont(const Value: Boolean); +begin + inherited; + if Value then + if Page is TfrxDMPPage then + FFontStyle := TfrxDMPPage(Page).FontStyle; +end; + +function TfrxDMPMemoView.IsFontStyleStored: Boolean; +begin + Result := not ParentFont; +end; + +procedure TfrxDMPMemoView.DrawFrame; +begin + FX := Round((AbsLeft - fr1CharX / 2) * FScaleX + FOffsetX); + FY := Round((AbsTop - fr1CharY / 2) * FScaleY + FOffsetY); + FX1 := Round((AbsLeft + Width + fr1CharX / 2) * FScaleX + FOffsetX); + FY1 := Round((AbsTop + Height + fr1CharY / 2) * FScaleY + FOffsetY); + inherited; +end; + +function TfrxDMPMemoView.CalcHeight: Extended; +begin + Result := inherited CalcHeight; + Result := Round(Result / fr1CharY) * fr1CharY; +end; + +function TfrxDMPMemoView.CalcWidth: Extended; +begin + Result := inherited CalcWidth; + Result := Round(Result / fr1CharX) * fr1CharX; +end; + +function TfrxDMPMemoView.Diff(AComponent: TfrxComponent): String; +var + m: TfrxDMPMemoView; +begin + Result := inherited Diff(AComponent); + m := TfrxDMPMemoView(AComponent); + if FFontStyle <> m.FontStyle then + Result := Result + DiffFontStyle(FFontStyle); +end; + +procedure TfrxDMPMemoView.SetBoundsDirect(ALeft, ATop, AWidth, AHeight: Extended); +begin + inherited SetLeft(ALeft); + inherited SetTop(ATop); + inherited SetWidth(AWidth); + inherited SetHeight(AHeight); +end; + +{$IFDEF FR_COM} +function TfrxDMPMemoView.Get_FontStyle(out Value: frxFontStyle): HResult; +begin + Value := PInteger(@FontStyle)^; + Result := S_OK; +end; + +function TfrxDMPMemoView.Set_FontStyle(Value: frxFontStyle): HResult; stdcall; +type + PfrxDMPFontStyles = ^ TfrxDMPFontStyles; +var + dst: TfrxDMPFontStyles; + src: Integer; +begin + src := Value; + dst := PfrxDMPFontStyles(@src)^; + FontStyle := dst; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxDMPLineView } + +class function TfrxDMPLineView.GetDescription: String; +begin + Result := frxResources.Get('obDMPLine'); +end; + +procedure TfrxDMPLineView.SetLeft(Value: Extended); +begin + if Value < 0 then + Value := Trunc(Value / fr1CharX) * fr1CharX - fr1CharX / 2 + else if Align = baRight then + Value := Round(Value / fr1CharX) * fr1CharX - fr1CharX / 2 + else + Value := Trunc(Value / fr1CharX) * fr1CharX + fr1CharX / 2; + inherited; +end; + +procedure TfrxDMPLineView.SetTop(Value: Extended); +begin + Value := Trunc(Value / fr1CharY) * fr1CharY + fr1CharY / 2; + inherited; +end; + +procedure TfrxDMPLineView.SetWidth(Value: Extended); +begin + if Align = baWidth then + Value := Trunc(Value / fr1CharX) * fr1CharX + else + Value := Round(Value / fr1CharX) * fr1CharX; + inherited; +end; + +procedure TfrxDMPLineView.SetFontStyle(const Value: TfrxDMPFontStyles); +begin + FFontStyle := Value; + ParentFont := False; +end; + +procedure TfrxDMPLineView.SetParentFont(const Value: Boolean); +begin + inherited; + if Value then + if Page is TfrxDMPPage then + FFontStyle := TfrxDMPPage(Page).FontStyle; +end; + +function TfrxDMPLineView.IsFontStyleStored: Boolean; +begin + Result := not ParentFont; +end; + +function TfrxDMPLineView.Diff(AComponent: TfrxComponent): String; +var + l: TfrxDMPLineView; +begin + Result := inherited Diff(AComponent); + l := TfrxDMPLineView(AComponent); + if FFontStyle <> l.FontStyle then + Result := Result + DiffFontStyle(FFontStyle); +end; + +{$IFDEF FR_COM} +function TfrxDMPLineView.Get_FontStyle(out Value: frxFontStyle): HResult; +begin + Value := PInteger(@FontStyle)^; + Result := S_OK; +end; + +function TfrxDMPLineView.Set_FontStyle(Value: frxFontStyle): HResult; stdcall; +type + PfrxDMPFontStyles = ^ TfrxDMPFontStyles; +var + dst: TfrxDMPFontStyles; + src: Integer; +begin + src := Value; + dst := PfrxDMPFontStyles(@src)^; + FontStyle := dst; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxDMPCommand } + +class function TfrxDMPCommand.GetDescription: String; +begin + Result := frxResources.Get('obDMPCmd'); +end; + +procedure TfrxDMPCommand.SetLeft(Value: Extended); +begin + Value := Round(Value / fr1CharX) * fr1CharX; + inherited; +end; + +procedure TfrxDMPCommand.SetTop(Value: Extended); +begin + Value := Round(Value / fr1CharY) * fr1CharY; + inherited; +end; + +function TfrxDMPCommand.Diff(AComponent: TfrxComponent): String; +begin + Result := inherited Diff(AComponent); + if FCommand <> TfrxDMPCommand(AComponent).Command then + Result := Result + frxStrToXML(FCommand); +end; + +function TfrxDMPCommand.ToChr: String; +var + i: Integer; + s, s1: String; +begin + Result := ''; + s := FCommand; + s1 := ''; + if Pos('#', s) = 1 then + begin + s := s + '#'; + for i := 2 to Length(s) do + if s[i] = '#' then + begin + Result := Result + Chr(StrToInt(s1)); + s1 := ''; + end + else + s1 := s1 + s[i]; + end + else + begin + for i := 1 to Length(s) do + begin + s1 := s1 + s[i]; + if i mod 2 = 0 then + begin + Result := Result + Chr(StrToInt('$' + s1)); + s1 := ''; + end; + end; + end; +end; + +{$IFDEF FR_COM} +function TfrxDMPCommand.Get_Command(out Value: WideString): HResult; +begin + Value := Command; + Result := S_OK; +end; + +function TfrxDMPCommand.Set_Command(const Value: WideString): HResult; +begin + Command := Value; + Result := S_OK; +end; +{$ENDIF} + +{ TfrxDMPPage } + +constructor TfrxDMPPage.Create(AOwner: TComponent); +begin + inherited; + ResetFontOptions; +end; + +procedure TfrxDMPPage.ResetFontOptions; +begin + Font.OnChange := nil; + Font.Name := 'Courier New'; + Font.Size := 12; + Font.Style := []; + if fsxBold in FFontStyle then + Font.Style := Font.Style + [fsBold]; + if fsxItalic in FFontStyle then + Font.Style := Font.Style + [fsItalic]; + if fsxUnderline in FFontStyle then + Font.Style := Font.Style + [fsUnderline]; +end; + +procedure TfrxDMPPage.SetDefaults; +begin + inherited; + LeftMargin := fr1CharX / fr01cm; + RightMargin := fr1CharX / fr01cm; + TopMargin := fr1CharY / fr01cm; + BottomMargin := fr1CharY / fr01cm; + FPaperWidth := Trunc(FPaperWidth * fr01cm / fr1CharX) * fr1CharX / fr01cm; + FPaperHeight := Trunc(FPaperHeight * fr01cm / fr1CharY) * fr1CharY / fr01cm; + UpdateDimensions; +end; + +procedure TfrxDMPPage.SetFontStyle(const Value: TfrxDMPFontStyles); +var + i: Integer; + l: TList; + c: TfrxComponent; +begin + FFontStyle := Value; + ResetFontOptions; + + l := AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c.ParentFont then + c.ParentFont := True; + end; +end; + +procedure TfrxDMPPage.SetPaperHeight(const Value: Extended); +begin + inherited; + FPaperHeight := Round(FPaperHeight * fr01cm / fr1CharY) * fr1CharY / fr01cm; + UpdateDimensions; +end; + +procedure TfrxDMPPage.SetPaperSize(const Value: Integer); +begin + inherited; + FPaperWidth := Round(FPaperWidth * fr01cm / fr1CharX) * fr1CharX / fr01cm; + FPaperHeight := Round(FPaperHeight * fr01cm / fr1CharY) * fr1CharY / fr01cm; + UpdateDimensions; +end; + +procedure TfrxDMPPage.SetPaperWidth(const Value: Extended); +begin + inherited; + FPaperWidth := Round(FPaperWidth * fr01cm / fr1CharX) * fr1CharX / fr01cm; + UpdateDimensions; +end; + +{$IFDEF FR_COM} +function TfrxDMPPage.Get_FontStyle(out Value: frxFontStyle): HResult; +begin + Value := PInteger(@FontStyle)^; + Result := S_OK; +end; + +function TfrxDMPPage.Set_FontStyle(Value: frxFontStyle): HResult; stdcall; +type + PfrxDMPFontStyles = ^ TfrxDMPFontStyles; +var + dst: TfrxDMPFontStyles; + src: Integer; +begin + src := Value; + dst := PfrxDMPFontStyles(@src)^; + FontStyle := dst; + Result := S_OK; +end; +{$ENDIF} + +initialization + RegisterClasses([TfrxDMPPage]); + frxObjects.RegisterObject1(TfrxDMPMemoView, nil, '', '', 0, 2, [ctDMP]); + frxObjects.RegisterObject1(TfrxDMPLineView, nil, '', '', 0, 5, [ctDMP]); + frxObjects.RegisterObject1(TfrxDMPCommand, nil, '', '', 0, 21, [ctDMP]); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDMPExport.dfm b/official/4.2/LibD11/frxDMPExport.dfm new file mode 100644 index 0000000..b303383 Binary files /dev/null and b/official/4.2/LibD11/frxDMPExport.dfm differ diff --git a/official/4.2/LibD11/frxDMPExport.pas b/official/4.2/LibD11/frxDMPExport.pas new file mode 100644 index 0000000..978462c --- /dev/null +++ b/official/4.2/LibD11/frxDMPExport.pas @@ -0,0 +1,1021 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Dot-matrix export filter } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDMPExport; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxClass, Buttons, ComCtrls, frxDMPClass, frxXML +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxTranslateEvent = procedure(Sender: TObject; var s: String) of object; + + TfrxDotMatrixExport = class(TfrxCustomExportFilter) + private + FBufWidth: Integer; + FBufHeight: Integer; + FCharBuf: array of Char; + FCopies: Integer; + FCustomFrameSet: String; + FEscModel: Integer; + FFrameBuf: array of Byte; + FGraphicFrames: Boolean; + FMaxHeight: Integer; + FOEMConvert: Boolean; + FPageBreaks: Boolean; + FPageStyle: Integer; + FPrinterInitString: String; + FSaveToFile: Boolean; + FStream: TStream; + FStyleBuf: array of Integer; + FUseIniSettings: Boolean; + FOnTranslate: TfrxTranslateEvent; + + function GetTempFName: String; + function IntToStyle(i: Integer): TfrxDMPFontStyles; + function StyleChange(OldStyle, NewStyle: Integer): String; + function StyleOff(Style: Integer): String; + function StyleOn(Style: Integer): String; + function StyleToInt(Style: TfrxDMPFontStyles): Integer; + + procedure CreateBuf(Width, Height: Integer); + procedure DrawFrame(x, y, dx, dy: Integer; Style: Integer); + procedure DrawMemo(x, y, dx, dy: Integer; Memo: TfrxDMPMemoView); + procedure FlushBuf; + procedure FormFeed; + procedure FreeBuf; + procedure Landscape; + procedure Portrait; + procedure Reset; + procedure SetFrame(x, y: Integer; typ: Byte); + procedure SetString(x, y: Integer; s: String); + procedure SetStyle(x, y, Style: Integer); + procedure SpoolFile(const FileName: String); + procedure WriteStrLn(const str: String); + procedure WriteStr(const str: String); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure ExportObject(Obj: TfrxComponent); override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + published + property CustomFrameSet: String read FCustomFrameSet write FCustomFrameSet; + property EscModel: Integer read FEscModel write FEscModel; + property GraphicFrames: Boolean read FGraphicFrames write FGraphicFrames; + property InitString: String read FPrinterInitString write FPrinterInitString; + property OEMConvert: Boolean read FOEMConvert write FOEMConvert default True; + property PageBreaks: Boolean read FPageBreaks write FPageBreaks default True; + property SaveToFile: Boolean read FSaveToFile write FSaveToFile; + property UseIniSettings: Boolean read FUseIniSettings write FUseIniSettings; + property OnTranslate: TfrxTranslateEvent read FOnTranslate write FOnTranslate; + end; + + TfrxDMPExportDialog = class(TForm) + OK: TButton; + Cancel: TButton; + SaveDialog1: TSaveDialog; + Image1: TImage; + PrinterL: TGroupBox; + PrinterCB: TComboBox; + EscL: TGroupBox; + EscCB: TComboBox; + CopiesL: TGroupBox; + CopiesNL: TLabel; + CopiesE: TEdit; + CopiesUD: TUpDown; + PagesL: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + RangeE: TEdit; + OptionsL: TGroupBox; + SaveToFileCB: TCheckBox; + PageBreaksCB: TCheckBox; + OemCB: TCheckBox; + PseudoCB: TCheckBox; + procedure FormCreate(Sender: TObject); + procedure PrinterCBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure PrinterCBClick(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure RangeEEnter(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + OldIndex: Integer; + end; + +const + cmdName = 1; + cmdReset = 2; + cmdFormFeed = 3; + cmdLandscape = 4; + cmdPortrait = 5; + cmdBoldOn = 6; + cmdBoldOff = 7; + cmdItalicOn = 8; + cmdItalicOff = 9; + cmdUnderlineOn = 10; + cmdUnderlineOff = 11; + cmdSuperscriptOn = 12; + cmdSuperscriptOff = 13; + cmdSubscriptOn = 14; + cmdSubscriptOff = 15; + cmdCondensedOn = 16; + cmdCondensedOff = 17; + cmdWideOn = 18; + cmdWideOff = 19; + cmd12cpiOn = 20; + cmd12cpiOff = 21; + cmd15cpiOn = 22; + cmd15cpiOff = 23; + + CommandCount = 23; + CommandNames: array[1..CommandCount] of String = ( + 'Name', 'Reset', 'FormFeed', 'Landscape', 'Portrait', + 'BoldOn', 'BoldOff', 'ItalicOn', 'ItalicOff', 'UnderlineOn', 'UnderlineOff', + 'SuperscriptOn', 'SuperscriptOff', 'SubscriptOn', 'SubscriptOff', + 'CondensedOn', 'CondensedOff', 'WideOn', 'WideOff', + 'cpi12On', 'cpi12Off', 'cpi15On', 'cpi15Off'); + +type + TfrxDMPrinter = class(TCollectionItem) + public + Commands: array[1..CommandCount] of String; + procedure Assign(Source: TPersistent); override; + end; + + TfrxDMPrinters = class(TCollection) + private + function GetItem(Index: Integer): TfrxDMPrinter; + public + constructor Create; + function Add: TfrxDMPrinter; + procedure ReadDefaultPrinters; + procedure ReadExtPrinters; + procedure ReadPrinters(x: TfrxXMLDocument); + property Items[Index: Integer]: TfrxDMPrinter read GetItem; default; + end; + +var + frxDMPrinters: TfrxDMPrinters; + + +implementation + +uses frxUtils, frxPrinter, Printers, frxRes, IniFiles, Winspool; + +{$R *.dfm} + +const + FrameSet: array[1..2] of String = ( + ' + |++ +-+++++', + #32#32#192#32#179#218#195#32#217#196#193#191#180#194#197); + DefaultPrinters: String = +'' + +'' + +' ' + +' ' + +' ' + +' ' + +''; + +type + TWordSet = set of 0..15; + PWordSet = ^TWordSet; + PfrxDMPFontStyles = ^TfrxDMPFontStyles; + + +{ TfrxDMPrinter } + +procedure TfrxDMPrinter.Assign(Source: TPersistent); +begin + if Source is TfrxDMPrinter then + Commands := TfrxDMPrinter(Source).Commands; +end; + + +{ TfrxDMPrinters } + +constructor TfrxDMPrinters.Create; +begin + inherited Create(TfrxDMPrinter); +end; + +function TfrxDMPrinters.Add: TfrxDMPrinter; +begin + Result := TfrxDMPrinter(inherited Add); +end; + +function TfrxDMPrinters.GetItem(Index: Integer): TfrxDMPrinter; +begin + Result := TfrxDMPrinter(inherited Items[Index]); +end; + +procedure TfrxDMPrinters.ReadDefaultPrinters; +var + x: TfrxXMLDocument; + s: TStringStream; +begin + x := TfrxXMLDocument.Create; + s := TStringStream.Create(DefaultPrinters); + try + x.LoadFromStream(s); + ReadPrinters(x); + finally + s.Free; + x.Free; + end; +end; + +procedure TfrxDMPrinters.ReadExtPrinters; +var + x: TfrxXMLDocument; +begin + if not FileExists(ExtractFilePath(Application.ExeName) + 'printers.xml') then + Exit; + x := TfrxXMLDocument.Create; + try + x.LoadFromFile(ExtractFilePath(Application.ExeName) + 'printers.xml'); + ReadPrinters(x); + except + ShowMessage('Error in file printers.xml'); + end; + + x.Free; +end; + +procedure TfrxDMPrinters.ReadPrinters(x: TfrxXMLDocument); +var + i, j: Integer; + xi: TfrxXMLItem; + Item: TfrxDMPrinter; + + function ConvertProp(s: String): String; + var + i: Integer; + s1: String; + begin + Result := ''; + s1 := ''; + if Pos('#', s) = 1 then + begin + s := s + '#'; + for i := 2 to Length(s) do + if s[i] = '#' then + begin + Result := Result + Chr(StrToInt(s1)); + s1 := ''; + end + else + s1 := s1 + s[i]; + end + else + begin + for i := 1 to Length(s) do + begin + s1 := s1 + s[i]; + if i mod 2 = 0 then + begin + Result := Result + Chr(StrToInt('$' + s1)); + s1 := ''; + end; + end; + end; + end; + +begin + Clear; + for i := 0 to x.Root.Count - 1 do + begin + Item := Add; + xi := x.Root[i]; + if xi.Prop['Inherit'] <> '' then + Item.Assign(Items[StrToInt(xi.Prop['Inherit'])]); + for j := 1 to CommandCount do + if xi.PropExists(CommandNames[j]) then + if j = 1 then + Item.Commands[j] := xi.Prop[CommandNames[j]] else + Item.Commands[j] := ConvertProp(xi.Prop[CommandNames[j]]); + end; +end; + + +{ TfrxDotMatrixExport } + +constructor TfrxDotMatrixExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + frxDotMatrixExport := Self; + FCopies := 1; + FOEMConvert := True; + FPageBreaks := True; + FUseIniSettings := True; +end; + +destructor TfrxDotMatrixExport.Destroy; +begin + FreeBuf; + frxDotMatrixExport := nil; + inherited; +end; + +function TfrxDotMatrixExport.GetTempFName: String; +var + Path: String; + FileName: String; +begin + Path := Report.EngineOptions.TempDir; + if Path = '' then + begin + SetLength(Path, MAX_PATH); + SetLength(Path, GetTempPath(MAX_PATH, @Path[1])); + end + else + Path := Path + #0; + SetLength(FileName, MAX_PATH); + GetTempFileName(@Path[1], PChar('fr'), 0, @FileName[1]); + Result := StrPas(@FileName[1]); +end; + +function TfrxDotMatrixExport.IntToStyle(i: Integer): TfrxDMPFontStyles; +begin + Result := TfrxDMPFontStyles(PfrxDMPFontStyles(@i)^); +end; + +function TfrxDotMatrixExport.StyleToInt(Style: TfrxDMPFontStyles): Integer; +begin + Result := Word(PWordSet(@Style)^); +end; + +procedure TfrxDotMatrixExport.SpoolFile(const FileName: String); +const + BUF_SIZE = 1024; +var + f: TFileStream; + buf: String; + l: longint; +begin + if Report.ReportOptions.Name <> '' then + frxPrinters.Printer.Title := Report.ReportOptions.Name else + frxPrinters.Printer.Title := Report.FileName; + frxPrinters.Printer.BeginRAWDoc; + + f := TFileStream.Create(FileName, fmOpenRead); + SetLength(buf, BUF_SIZE); + l := BUF_SIZE; + while l = BUF_SIZE do + begin + l := f.Read(buf[1], BUF_SIZE); + SetLength(buf, l); + frxPrinters.Printer.WriteRAWDoc(buf); + end; + + f.Free; + frxPrinters.Printer.EndRAWDoc; +end; + +procedure TfrxDotMatrixExport.FormFeed; +begin + WriteStr(frxDMPrinters[FEscModel].Commands[cmdFormFeed]); +end; + +procedure TfrxDotMatrixExport.Landscape; +begin + WriteStr(frxDMPrinters[FEscModel].Commands[cmdLandscape]); +end; + +procedure TfrxDotMatrixExport.Portrait; +begin + WriteStr(frxDMPrinters[FEscModel].Commands[cmdPortrait]); +end; + +procedure TfrxDotMatrixExport.Reset; +begin + WriteStr(frxDMPrinters[FEscModel].Commands[cmdReset]); +end; + +function TfrxDotMatrixExport.StyleOff(Style: Integer): String; +var + st: TfrxDMPFontStyles; +begin + st := IntToStyle(Style); + Result := ''; + if fsxBold in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdBoldOff]; + if fsxItalic in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdItalicOff]; + if fsxUnderline in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdUnderlineOff]; + if fsxSuperScript in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdSuperscriptOff]; + if fsxSubScript in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdSubscriptOff]; + if fsxCondensed in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdCondensedOff]; + if fsxWide in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdWideOff]; + if fsx12cpi in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmd12cpiOff]; + if fsx15cpi in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmd15cpiOff]; +end; + +function TfrxDotMatrixExport.StyleOn(Style: Integer): String; +var + st: TfrxDMPFontStyles; +begin + st := IntToStyle(Style); + Result := ''; + if fsxBold in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdBoldOn]; + if fsxItalic in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdItalicOn]; + if fsxUnderline in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdUnderlineOn]; + if fsxSuperScript in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdSuperscriptOn]; + if fsxSubScript in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdSubscriptOn]; + if fsxCondensed in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdCondensedOn]; + if fsxWide in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmdWideOn]; + if fsx12cpi in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmd12cpiOn]; + if fsx15cpi in st then + Result := Result + frxDMPrinters[FEscModel].Commands[cmd15cpiOn]; +end; + +function TfrxDotMatrixExport.StyleChange(OldStyle, NewStyle: Integer): String; +begin + Result := StyleOff(OldStyle) + StyleOn(NewStyle); +end; + +procedure TfrxDotMatrixExport.SetFrame(x, y: Integer; typ: Byte); +begin + if (x < 0) or (y < 0) or (x >= FBufWidth) or (y >= FBufHeight) then Exit; + FFrameBuf[FBufWidth * y + x] := FFrameBuf[FBufWidth * y + x] or typ; +end; + +procedure TfrxDotMatrixExport.SetString(x, y: Integer; s: String); +var + i, j: Integer; + c: Char; +begin + if (x < 0) or (y < 0) or (y >= FBufHeight) then Exit; + if Assigned(FOnTranslate) then + FOnTranslate(Self, s); + for i := 1 to Length(s) do + begin + if x + i - 1 >= FBufWidth then break; + c := s[i]; + j := FBufWidth * y + x + i - 1; + FCharBuf[j] := c; + end; +end; + +procedure TfrxDotMatrixExport.SetStyle(x, y, Style: Integer); +begin + if (x < 0) or (y < 0) or (x >= FBufWidth) or (y >= FBufHeight) then Exit; + FStyleBuf[FBufWidth * y + x] := Style; +end; + +procedure TfrxDotMatrixExport.WriteStr(const str: String); +begin + if Length(str) > 0 then + FStream.Write(str[1], Length(str)) +end; + +procedure TfrxDotMatrixExport.WriteStrLn(const str: String); +begin + WriteStr(str); + WriteStr(#13#10); +end; + +procedure TfrxDotMatrixExport.DrawFrame(x, y, dx, dy: Integer; Style: Integer); +var + i, j: Integer; +begin + if dx = 1 then + begin + SetFrame(x, y, 4); + for i := y + 1 to y + dy - 2 do + SetFrame(x, i, 5); + SetFrame(x, y + dy - 1, 1); + end + else + begin + SetFrame(x, y, 2); + for i := x + 1 to x + dx - 2 do + SetFrame(i, y, 10); + SetFrame(x + dx - 1, y, 8); + end; + + for i := x to x + dx - 1 do + for j := y to y + dy - 1 do + SetStyle(i, j, Style); + + if y + dy > FMaxHeight then + FMaxHeight := y + dy; +end; + +procedure TfrxDotMatrixExport.DrawMemo(x, y, dx, dy: Integer; Memo: TfrxDMPMemoView); +var + i, sx, sy: Integer; + Lines: TStringList; + Text: String; + Style: Integer; + + function StrToOem(const AnsiStr: String): String; + begin + SetLength(Result, Length(AnsiStr)); + if Length(Result) > 0 then + CharToOemBuff(PChar(AnsiStr), PChar(Result), Length(Result)); + end; + + function MakeStr(C: Char; N: Integer): String; + begin + if N < 1 then + Result := '' + else + begin + SetLength(Result, N); + FillChar(Result[1], Length(Result), C); + end; + end; + + function AddChar(C: Char; const S: String; N: Integer): String; + begin + if Length(S) < N then + Result := MakeStr(C, N - Length(S)) + S else + Result := S; + end; + + function AddCharR(C: Char; const S: String; N: Integer): String; + begin + if Length(S) < N then + Result := S + MakeStr(C, N - Length(S)) else + Result := S; + end; + + function LeftStr(const S: String; N: Integer): String; + begin + Result := AddCharR(' ', S, N); + end; + + function RightStr(const S: String; N: Integer): String; + begin + Result := AddChar(' ', S, N); + end; + + function CenterStr(const S: String; Len: Integer): String; + begin + if Length(S) < Len then + begin + Result := MakeStr(' ', (Len div 2) - (Length(S) div 2)) + S; + Result := Result + MakeStr(' ', Len - Length(Result)); + end + else + Result := S; + end; + + function AlignBuf(const buf: String): String; + begin + if (Memo.HAlign = haLeft) then + Result := LeftStr(buf, dx) + else if (Memo.HAlign = haRight) then + Result := RightStr(buf, dx) + else if (Memo.HAlign = haCenter) then + Result := CenterStr(buf, dx) + else + Result := LeftStr(buf, dx); + end; + +begin + Lines := TStringList.Create; + + Text := Memo.WrapText(True); + if FOEMConvert then + Text := StrToOem(Text); + Lines.Text := Text; + + if dy > Lines.Count then + begin + if (Memo.VAlign = vaBottom) then + sy := y + dy - Lines.Count + else if (Memo.VAlign = vaCenter) then + sy := y + (dy - Lines.Count) div 2 + else + sy := y + end + else + sy := y; + + for i := 0 to Lines.Count - 1 do + begin + if i > dy - 1 then + break; + SetString(x, sy + i, AlignBuf(Lines[i])); + end; + Lines.Free; + + Style := StyleToInt(Memo.FontStyle); + for sx := x to x + dx - 1 do + for sy := y to y + dy - 1 do + SetStyle(sx, sy, Style); + + if y + dy > FMaxHeight then + FMaxHeight := y + dy; +end; + +procedure TfrxDotMatrixExport.CreateBuf(Width, Height: Integer); +var + i, j: Integer; +begin + FBufWidth := Width; + FBufHeight := Height; + SetLength(FCharBuf, FBufWidth * FBufHeight); + SetLength(FStyleBuf, FBufWidth * FBufHeight); + SetLength(FFrameBuf, FBufWidth * FBufHeight); + for i := 0 to FBufHeight - 1 do + for j := 0 to FBufWidth - 1 do + begin + FCharBuf[i * FBufWidth + j] := ' '; + FStyleBuf[i * FBufWidth + j] := FPageStyle; + FFrameBuf[i * FBufWidth + j] := 0; + end; +end; + +procedure TfrxDotMatrixExport.FreeBuf; +begin + FFrameBuf := nil; + FStyleBuf := nil; + FCharBuf := nil; + FBufHeight := 0; + FBufWidth := 0; +end; + +procedure TfrxDotMatrixExport.FlushBuf; +var + i, j, Style, CurrentStyle: Integer; + buf: String; + Frames: String; + + function Trim_Right(const s: String): String; + var + i: Integer; + begin + Result := s; + for i := Length(Result) downto 1 do + if Result[i] <> ' ' then + break; + SetLength(Result, i); + end; + +begin + if Length(CustomFrameSet) = 15 then + Frames := CustomFrameSet + else if FGraphicFrames then + Frames := FrameSet[2] + else + Frames := FrameSet[1]; + + CurrentStyle := FPageStyle; + for i := 0 to FMaxHeight - 1 do + begin + buf := StyleOn(CurrentStyle); + for j := 0 to FBufWidth - 1 do + begin + Style := FStyleBuf[i * FBufWidth + j]; + if Style <> CurrentStyle then + begin + buf := buf + StyleChange(CurrentStyle, Style); + CurrentStyle := Style; + end; + if FFrameBuf[i * FBufWidth + j] <> 0 then + buf := buf + Frames[FFrameBuf[i * FBufWidth + j]] else + buf := buf + FCharBuf[i * FBufWidth + j]; + end; + buf := Trim_Right(buf) + StyleOff(CurrentStyle); + WriteStrLn(buf); + end; +end; + + +function TfrxDotMatrixExport.ShowModal: TModalResult; +var + Ini: TCustomIniFile; +begin + Ini := Report.GetIniFile; + with TfrxDMPExportDialog.Create(nil) do + begin + if FUseIniSettings then + begin + FPageBreaks := Ini.ReadBool('DMP', 'PageBreaks', True); + FOEMConvert := Ini.ReadBool('DMP', 'OEM', True); + FGraphicFrames := Ini.ReadBool('DMP', 'GraphFrame', False); + FEscModel := Ini.ReadInteger('DMP', 'PrinterType', 0); + end; + if FEscModel >= frxDMPrinters.Count then + FEscModel := 0; + + PageBreaksCB.Checked := FPageBreaks; + OemCB.Checked := FOEMConvert; + PseudoCB.Checked := FGraphicFrames; + SaveToFileCB.Checked := FSaveToFile; + EscCB.ItemIndex := FEscModel; + CopiesUD.Position := Report.PrintOptions.Copies; + + Result := ShowModal; + if Result = mrOk then + begin + FSaveToFile := SaveToFileCB.Checked; + if FSaveToFile then + if SaveDialog1.Execute then + FileName := SaveDialog1.Filename else + Result := mrCancel; + + CurPage := False; + if PageNumbersRB.Checked then + PageNumbers := RangeE.Text + else if CurPageRB.Checked then + CurPage := True + else + PageNumbers := ''; + FCopies := StrToInt(CopiesE.Text); + FPageBreaks := PageBreaksCB.Checked; + FOEMConvert := OemCB.Checked; + FGraphicFrames := PseudoCB.Checked; + FEscModel := EscCB.ItemIndex; + + Ini.WriteBool('DMP', 'OEM', FOEMConvert); + Ini.WriteBool('DMP', 'GraphFrame', FGraphicFrames); + Ini.WriteBool('DMP', 'PageBreaks', FPageBreaks); + Ini.WriteInteger('DMP', 'PrinterType', FEscModel); + end; + Free; + end; + Ini.Free; +end; + +function TfrxDotMatrixExport.Start: Boolean; +begin + if not ShowDialog then + FCopies := Report.PrintOptions.Copies; + + if Assigned(Stream) then + FStream := Stream + else + begin + if not FSaveToFile then + FileName := GetTempFName; + + if FileName <> '' then + FStream := TFileStream.Create(FileName, fmCreate) + else + FStream := nil; + end; + + if Assigned(FStream) then + begin + Reset; + WriteStr(FPrinterInitString); + WriteStr(Report.ReportOptions.InitString); + Result := True + end + else + Result := False; +end; + +procedure TfrxDotMatrixExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + FMaxHeight := 0; + FPageStyle := StyleToInt(TfrxDMPPage(Page).FontStyle); + CreateBuf(Round(Page.Width / fr1CharX) + 1, Round(Page.Height / fr1CharY) + 1); + if Page.Orientation = poLandscape then + Landscape else + Portrait; +end; + +procedure TfrxDotMatrixExport.ExportObject(Obj: TfrxComponent); +var + Style: Integer; + Memo: TfrxDMPMemoView; +begin + if (Obj is TfrxView) and not TfrxView(Obj).Printable then Exit; + if Obj is TfrxDMPMemoView then + begin + Memo := TfrxDMPMemoView(Obj); + Style := StyleToInt(Memo.FontStyle); + DrawMemo(Round(Memo.AbsLeft / fr1CharX), Round(Memo.AbsTop / fr1CharY), + Round(Memo.Width / fr1CharX), Round(Memo.Height / fr1CharY), Memo); + if (ftLeft in Memo.Frame.Typ) then + DrawFrame(Round(Memo.AbsLeft / fr1CharX) - 1, + Round(Memo.AbsTop / fr1CharY) - 1, 1, Round(Memo.Height / fr1CharY) + 2, Style); + if (ftRight in Memo.Frame.Typ) then + DrawFrame(Round((Memo.AbsLeft + Memo.Width) / fr1CharX), + Round(Memo.AbsTop / fr1CharY) - 1, 1, Round(Memo.Height / fr1CharY) + 2, Style); + if (ftTop in Memo.Frame.Typ) then + DrawFrame(Round(Memo.AbsLeft / fr1CharX) - 1, + Round(Memo.AbsTop / fr1CharY) - 1, Round(Memo.Width / fr1CharX) + 2, 1, Style); + if (ftBottom in Memo.Frame.Typ) then + DrawFrame(Round(Memo.AbsLeft / fr1CharX) - 1, + Round((Memo.AbsTop + Memo.Height) / fr1CharY), + Round(Memo.Width / fr1CharX) + 2, 1, Style); + end + else if Obj is TfrxDMPLineView then + begin + Style := StyleToInt(TfrxDMPLineView(Obj).FontStyle); + if Obj.Width = 0 then + DrawFrame(Trunc(Obj.AbsLeft / fr1CharX), Trunc(Obj.AbsTop / fr1CharY), + 1, Round(Obj.Height / fr1CharY) + 1, Style) + else if Obj.Height = 0 then + begin + if TfrxDMPLineView(Obj).Align = baWidth then + DrawFrame(Trunc(Obj.AbsLeft / fr1CharX) - 1, Trunc(Obj.AbsTop / fr1CharY), + Round(Obj.Width / fr1CharX) + 3, 1, Style) + else if TfrxDMPLineView(Obj).Align = baLeft then + DrawFrame(Trunc(Obj.AbsLeft / fr1CharX) - 1, Trunc(Obj.AbsTop / fr1CharY), + Round(Obj.Width / fr1CharX) + 1, 1, Style) + else if TfrxDMPLineView(Obj).Align = baRight then + DrawFrame(Trunc(Obj.AbsLeft / fr1CharX), Trunc(Obj.AbsTop / fr1CharY), + Round(Obj.Width / fr1CharX) + 2, 1, Style) + else + DrawFrame(Trunc(Obj.AbsLeft / fr1CharX), Trunc(Obj.AbsTop / fr1CharY), + Round(Obj.Width / fr1CharX) + 1, 1, Style); + end; + end + else if Obj is TfrxDMPCommand then + begin + SetString(Round(Obj.AbsLeft / fr1CharX), Round(Obj.AbsTop / fr1CharY), + TfrxDMPCommand(Obj).ToChr); + end; +end; + +procedure TfrxDotMatrixExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + FlushBuf; + FreeBuf; + if FPageBreaks then + FormFeed; +end; + +procedure TfrxDotMatrixExport.Finish; +var + i: Integer; + fname: String; + f, ffrom: TFileStream; +begin + if FStream <> Stream then + begin + FStream.Free; + if not frxPrinters.HasPhysicalPrinters then Exit; + + if not FSaveToFile then + begin + fname := GetTempFName; + f := TFileStream.Create(fname, fmCreate); + ffrom := TFileStream.Create(FileName, fmOpenRead); + f.Write(FPrinterInitString[1], Length(FPrinterInitString)); + f.CopyFrom(ffrom, 0); + f.Free; + ffrom.Free; + f := TFileStream.Create(FileName, fmCreate); + ffrom := TFileStream.Create(fname, fmOpenRead); + f.CopyFrom(ffrom, 0); + f.Free; + ffrom.Free; + DeleteFile(fname); + for i := 1 to FCopies do + SpoolFile(FileName); + DeleteFile(FileName); + end; + end; +end; + + +{ TfrxTXTExportDialog } + +procedure TfrxDMPExportDialog.FormCreate(Sender: TObject); +var + i: Integer; +begin + Caption := frxGet(500); + PrinterL.Caption := frxGet(501); + PagesL.Caption := frxGet(502); + CopiesL.Caption := frxGet(503); + CopiesNL.Caption := frxGet(504); + DescrL.Caption := frxGet(9); + OptionsL.Caption := frxGet(505); + EscL.Caption := frxGet(506); + OK.Caption := frxGet(1); + Cancel.Caption := frxGet(2); + SaveToFileCB.Caption := frxGet(507); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + PageBreaksCB.Caption := frxGet(6); + OemCB.Caption := frxGet(508); + PseudoCB.Caption := frxGet(509); + SaveDialog1.Filter := frxGet(510); + + PrinterCB.Items := frxPrinters.Printers; + PrinterCB.ItemIndex := frxPrinters.PrinterIndex; + OldIndex := frxPrinters.PrinterIndex; + for i := 0 to frxDMPrinters.Count - 1 do + EscCB.Items.Add(frxDMPrinters[i].Commands[cmdName]); + + SetWindowLong(CopiesE.Handle, GWL_STYLE, GetWindowLong(CopiesE.Handle, GWL_STYLE) or ES_NUMBER); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxDMPExportDialog.FormHide(Sender: TObject); +begin + if ModalResult <> mrOk then + frxPrinters.PrinterIndex := OldIndex; +end; + +procedure TfrxDMPExportDialog.PrinterCBClick(Sender: TObject); +begin + frxPrinters.PrinterIndex := PrinterCB.ItemIndex; +end; + +procedure TfrxDMPExportDialog.PrinterCBDrawItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +var + r: TRect; +begin + r := ARect; + r.Right := r.Left + 18; + r.Bottom := r.Top + 16; + OffsetRect(r, 2, 0); + with PrinterCB.Canvas do + begin + FillRect(ARect); + BrushCopy(r, Image1.Picture.Bitmap, Rect(0, 0, 18, 16), clOlive); + TextOut(ARect.Left + 24, ARect.Top + 1, PrinterCB.Items[Index]); + end; +end; + +procedure TfrxDMPExportDialog.RangeEEnter(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + + +procedure TfrxDMPExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +initialization + frxDMPrinters := TfrxDMPrinters.Create; + frxDMPrinters.ReadDefaultPrinters; + frxDMPrinters.ReadExtPrinters; + +finalization + frxDMPrinters.Free; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDataTree.dfm b/official/4.2/LibD11/frxDataTree.dfm new file mode 100644 index 0000000..f1f2370 Binary files /dev/null and b/official/4.2/LibD11/frxDataTree.dfm differ diff --git a/official/4.2/LibD11/frxDataTree.pas b/official/4.2/LibD11/frxDataTree.pas new file mode 100644 index 0000000..d83e7fc --- /dev/null +++ b/official/4.2/LibD11/frxDataTree.pas @@ -0,0 +1,684 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Data Tree tool window } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDataTree; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxClass, fs_xml, ComCtrls +{$IFDEF UseTabset} +, Tabs +{$ENDIF} +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxDataTreeForm = class(TForm) + DataPn: TPanel; + DataTree: TTreeView; + CBPanel: TPanel; + InsFieldCB: TCheckBox; + InsCaptionCB: TCheckBox; + VariablesPn: TPanel; + VariablesTree: TTreeView; + FunctionsPn: TPanel; + Splitter1: TSplitter; + HintPanel: TScrollBox; + FunctionDescL: TLabel; + FunctionNameL: TLabel; + FunctionsTree: TTreeView; + ClassesPn: TPanel; + ClassesTree: TTreeView; + NoDataPn: TScrollBox; + NoDataL: TLabel; + procedure FormResize(Sender: TObject); + procedure DataTreeCustomDrawItem(Sender: TCustomTreeView; + Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); + procedure FunctionsTreeChange(Sender: TObject; Node: TTreeNode); + procedure DataTreeDblClick(Sender: TObject); + procedure ClassesTreeExpanding(Sender: TObject; Node: TTreeNode; + var AllowExpansion: Boolean); + procedure ClassesTreeCustomDrawItem(Sender: TCustomTreeView; + Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); + private + { Private declarations } + FXML: TfsXMLDocument; + FImages: TImageList; + FReport: TfrxReport; + FUpdating: Boolean; + FFirstTime: Boolean; +{$IFDEF UseTabset} + FTabs: TTabSet; +{$ELSE} + FTabs: TTabControl; +{$ENDIF} + procedure FillClassesTree; + procedure FillDataTree; + procedure FillFunctionsTree; + procedure FillVariablesTree; + procedure TabsChange(Sender: TObject); + function GetCollapsedNodes: String; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure SetColor(Color: TColor); + procedure SetControlsParent(AParent: TWinControl); + procedure SetLastPosition(p: TPoint); + procedure ShowTab(Index: Integer); + procedure UpdateItems; + procedure UpdateSelection; + procedure UpdateSize; + function GetActivePage: Integer; + function GetFieldName: String; + function GetLastPosition: TPoint; + function IsDataField: Boolean; + property Report: TfrxReport read FReport write FReport; + end; + + +implementation + +{$R *.DFM} + +uses fs_iinterpreter, fs_itools, frxRes; + +var + CollapsedNodes: String; + +type + THackWinControl = class(TWinControl); + + +procedure SetImageIndex(Node: TTreeNode; Index: Integer); +begin + Node.ImageIndex := Index; + Node.StateIndex := Index; + Node.SelectedIndex := Index; +end; + + +{ TfrxDataTreeForm } + +constructor TfrxDataTreeForm.Create(AOwner: TComponent); +begin + inherited; + FImages := frxResources.MainButtonImages; + DataTree.Images := FImages; + VariablesTree.Images := FImages; + FunctionsTree.Images := FImages; + ClassesTree.Images := FImages; +{$IFDEF UseTabset} + DataTree.BevelKind := bkFlat; + VariablesTree.BevelKind := bkFlat; + FunctionsTree.BevelKind := bkFlat; + ClassesTree.BevelKind := bkFlat; +{$ELSE} + DataTree.BorderStyle := bsSingle; + VariablesTree.BorderStyle := bsSingle; + FunctionsTree.BorderStyle := bsSingle; + ClassesTree.BorderStyle := bsSingle; +{$ENDIF} + FXML := TfsXMLDocument.Create; + FFirstTime := True; +{$IFDEF UseTabset} + FTabs := TTabSet.Create(Self); + FTabs.ShrinkToFit := True; + FTabs.Style := tsSoftTabs; + FTabs.TabPosition := tpTop; +{$ELSE} + FTabs := TTabControl.Create(Self); +{$ENDIF} + FTabs.Parent := Self; + FTabs.SendToBack; + + Caption := frxGet(2100); + FTabs.Tabs.AddObject(frxGet(2101), DataPn); + FTabs.Tabs.AddObject(frxGet(2102), VariablesPn); + FTabs.Tabs.AddObject(frxGet(2103), FunctionsPn); + FTabs.Tabs.AddObject(frxGet(2106), ClassesPn); + FTabs.TabIndex := 0; + InsFieldCB.Caption := frxGet(2104); + InsCaptionCB.Caption := frxGet(2105); +{$IFDEF UseTabset} + FTabs.OnClick := TabsChange; +{$ELSE} + FTabs.OnChange := TabsChange; +{$ENDIF} +end; + +destructor TfrxDataTreeForm.Destroy; +begin + if Owner is TfrxCustomDesigner then + CollapsedNodes := GetCollapsedNodes; + FUpdating := True; + FXML.Free; + inherited; +end; + +procedure TfrxDataTreeForm.FillDataTree; +var + ds: TfrxDataSet; + DatasetsList, FieldsList: TStrings; + i, j: Integer; + Root, Node1, Node2: TTreeNode; + s, Collapsed: String; +begin + DatasetsList := TStringList.Create; + FieldsList := TStringList.Create; + FReport.GetDataSetList(DatasetsList); + + try + if FFirstTime then + Collapsed := CollapsedNodes + else + Collapsed := GetCollapsedNodes; + + DataTree.Items.BeginUpdate; + DataTree.Items.Clear; + if DatasetsList.Count = 0 then + begin + NoDataL.Caption := frxResources.Get('dtNoData') + '.' + #13#10#13#10 + + frxResources.Get('dtNoData1'); + NoDataPn.Visible := True; + end + else + begin + NoDataPn.Visible := False; + s := frxResources.Get('dtData'); + Root := DataTree.Items.AddChild(nil, s); + SetImageIndex(Root, 53); + + for i := 0 to DatasetsList.Count - 1 do + begin + ds := TfrxDataSet(DatasetsList.Objects[i]); + if ds = nil then continue; + try + ds.GetFieldList(FieldsList); + except + end; + + Node1 := DataTree.Items.AddChild(Root, FReport.GetAlias(ds)); + Node1.Data := ds; + SetImageIndex(Node1, 72); + + for j := 0 to FieldsList.Count - 1 do + begin + Node2 := DataTree.Items.AddChild(Node1, FieldsList[j]); + Node2.Data := ds; + SetImageIndex(Node2, 54); + end; + end; + + DataTree.Items[0].Expanded := True; + for i := 0 to DataTree.Items[0].Count - 1 do + begin + s := DataTree.Items[0][i].Text; + if Pos(s + ',', Collapsed) = 0 then + DataTree.Items[0][i].Expanded := True; + end; + end; + finally + DataTree.Items.EndUpdate; + DatasetsList.Free; + FieldsList.Free; + end; +end; + +procedure TfrxDataTreeForm.FillVariablesTree; +var + CategoriesList, VariablesList: TStrings; + i: Integer; + Root, Node: TTreeNode; + + procedure AddVariables(Node: TTreeNode); + var + i: Integer; + Node1: TTreeNode; + begin + for i := 0 to VariablesList.Count - 1 do + begin + Node1 := VariablesTree.Items.AddChild(Node, VariablesList[i]); + SetImageIndex(Node1, 80); + end; + end; + + procedure AddSystemVariables; + var + SysNode: TTreeNode; + + procedure AddNode(const s: String); + var + Node: TTreeNode; + begin + Node := VariablesTree.Items.AddChild(SysNode, s); + SetImageIndex(Node, 80); + end; + + begin + SysNode := VariablesTree.Items.AddChild(Root, frxResources.Get('dtSysVar')); + SetImageIndex(SysNode, 66); + + AddNode('Date'); + AddNode('Time'); + AddNode('Page'); + AddNode('Page#'); + AddNode('TotalPages'); + AddNode('TotalPages#'); + AddNode('Line'); + AddNode('Line#'); + AddNode('CopyName#'); + end; + +begin + CategoriesList := TStringList.Create; + VariablesList := TStringList.Create; + FReport.Variables.GetCategoriesList(CategoriesList); + + VariablesTree.Items.BeginUpdate; + VariablesTree.Items.Clear; + Root := VariablesTree.Items.AddChild(nil, frxResources.Get('dtVar')); + SetImageIndex(Root, 66); + + for i := 0 to CategoriesList.Count - 1 do + begin + FReport.Variables.GetVariablesList(CategoriesList[i], VariablesList); + Node := VariablesTree.Items.AddChild(Root, CategoriesList[i]); + SetImageIndex(Node, 66); + AddVariables(Node); + end; + + if CategoriesList.Count = 0 then + begin + FReport.Variables.GetVariablesList('', VariablesList); + AddVariables(Root); + end; + + AddSystemVariables; + + VariablesTree.FullExpand; + VariablesTree.TopItem := Root; + VariablesTree.Items.EndUpdate; + CategoriesList.Free; + VariablesList.Free; +end; + +procedure TfrxDataTreeForm.FillFunctionsTree; + + procedure AddFunctions(xi: TfsXMLItem; Root: TTreeNode); + var + i: Integer; + Node: TTreeNode; + s: String; + begin + s := xi.Prop['text']; + if xi.Count = 0 then + s := Copy(s, Pos(' ', s) + 1, 255) else { function } + s := frxResources.Get(s); { category } + + if CompareText(s, 'hidden') = 0 then Exit; + Node := FunctionsTree.Items.AddChild(Root, s); + if xi.Count = 0 then + Node.Data := xi; + if Root = nil then + Node.Text := frxResources.Get('dtFunc'); + if xi.Count = 0 then + SetImageIndex(Node, 52) else + SetImageIndex(Node, 66); + + for i := 0 to xi.Count - 1 do + AddFunctions(xi[i], Node); + end; + +begin + FUpdating := True; + + FunctionsTree.Items.BeginUpdate; + FunctionsTree.Items.Clear; + AddFunctions(FXML.Root.FindItem('Functions'), nil); + + FunctionsTree.FullExpand; + FunctionsTree.TopItem := FunctionsTree.Items[0]; + FunctionsTree.Items.EndUpdate; + FUpdating := False; +end; + +procedure TfrxDataTreeForm.FillClassesTree; + + procedure AddClasses(xi: TfsXMLItem; Root: TTreeNode); + var + i: Integer; + Node: TTreeNode; + s: String; + begin + s := xi.Prop['text']; + + Node := ClassesTree.Items.AddChild(Root, s); + Node.Data := xi; + if Root = nil then + begin + Node.Text := frxResources.Get('2106'); + SetImageIndex(Node, 66); + end + else + SetImageIndex(Node, 78); + + if Root = nil then + begin + for i := 0 to xi.Count - 1 do + AddClasses(xi[i], Node); + end + else + ClassesTree.Items.AddChild(Node, 'more...'); // do not localize + end; + +begin + FUpdating := True; + + ClassesTree.Items.BeginUpdate; + ClassesTree.Items.Clear; + AddClasses(FXML.Root.FindItem('Classes'), nil); + + ClassesTree.TopItem := ClassesTree.Items[0]; + ClassesTree.TopItem.Expand(False); + ClassesTree.Items.EndUpdate; + FUpdating := False; +end; + +function TfrxDataTreeForm.GetCollapsedNodes: String; +var + i: Integer; + s: String; +begin + Result := ''; + if DataTree.Items.Count > 0 then + for i := 0 to DataTree.Items[0].Count - 1 do + begin + s := DataTree.Items[0][i].Text; + if not DataTree.Items[0][i].Expanded then + Result := Result + s + ','; + end; +end; + +function TfrxDataTreeForm.GetFieldName: String; +var + i, n: Integer; + s: String; + Node: TTreeNode; +begin + Result := ''; + if FTabs.TabIndex = 0 then // data + begin + Node := DataTree.Selected; + if (Node <> nil) and (Node.Count = 0) and (Node.Data <> nil) then + Result := '<' + FReport.GetAlias(TfrxDataSet(Node.Data)) + + '."' + Node.Text + '"' + '>'; + end + else if FTabs.TabIndex = 1 then // variables + begin + Node := VariablesTree.Selected; + if (Node <> nil) and (Node.Count = 0) then + if Node.Data <> nil then + Result := Node.Text else + Result := '<' + Node.Text + '>'; + end + else if FTabs.TabIndex = 2 then // functions + begin + if (FunctionsTree.Selected <> nil) and (FunctionsTree.Selected.Count = 0) then + begin + s := FunctionsTree.Selected.Text; + if Pos('(', s) <> 0 then + n := 1 else + n := 0; + for i := 1 to Length(s) do + if s[i] in [',', ';'] then + Inc(n); + + if n = 0 then + s := Copy(s, 1, Pos(':', s) - 1) + else + begin + s := Copy(s, 1, Pos('(', s)); + for i := 1 to n - 1 do + s := s + ','; + s := s + ')'; + end; + Result := s; + end; + end; +end; + +function TfrxDataTreeForm.IsDataField: Boolean; +begin + Result := FTabs.TabIndex = 0; +end; + +procedure TfrxDataTreeForm.UpdateItems; +begin + FillDataTree; + FillVariablesTree; + FFirstTime := False; +end; + +procedure TfrxDataTreeForm.SetColor(Color: TColor); +begin + DataTree.Color := Color; + VariablesTree.Color := Color; + FunctionsTree.Color := Color; + ClassesTree.Color := Color; +end; + +procedure TfrxDataTreeForm.FormResize(Sender: TObject); +begin + UpdateSize; +end; + +procedure TfrxDataTreeForm.DataTreeCustomDrawItem(Sender: TCustomTreeView; + Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); +begin + if Node.Count <> 0 then + Sender.Canvas.Font.Style := [fsBold]; +end; + +procedure TfrxDataTreeForm.ClassesTreeCustomDrawItem(Sender: TCustomTreeView; + Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean); +begin + if Node.Level = 0 then + Sender.Canvas.Font.Style := [fsBold]; +end; + +procedure TfrxDataTreeForm.FunctionsTreeChange(Sender: TObject; + Node: TTreeNode); +var + xi: TfsXMLItem; +begin + if FUpdating then Exit; + Node := FunctionsTree.Selected; + if (Node = nil) or (Node.Data = nil) then + begin + FunctionNameL.Caption := ''; + FunctionDescL.Caption := ''; + Exit; + end + else + begin + xi := Node.Data; + FunctionNameL.Caption := xi.Prop['text']; + FunctionDescL.Caption := frxResources.Get(xi.Prop['description']); + FunctionNameL.AutoSize := True; + end; +end; + +procedure TfrxDataTreeForm.DataTreeDblClick(Sender: TObject); +begin + if Assigned(OnDblClick) then + OnDblClick(Sender); +end; + +procedure TfrxDataTreeForm.ClassesTreeExpanding(Sender: TObject; + Node: TTreeNode; var AllowExpansion: Boolean); +var + i: Integer; + xi: TfsXMLItem; + s: String; + n: TTreeNode; +begin + if (Node.Level = 1) and (Node.Data <> nil) then + begin + FUpdating := True; + ClassesTree.Items.BeginUpdate; + + Node.DeleteChildren; + xi := TfsXMLItem(Node.Data); + Node.Data := nil; + + for i := 0 to xi.Count - 1 do + begin + s := xi[i].Prop['text']; + n := ClassesTree.Items.AddChild(Node, s); + if Pos('property', s) = 1 then + SetImageIndex(n, 73) + else if Pos('event', s) = 1 then + SetImageIndex(n, 79) + else + SetImageIndex(n, 74); + end; + + ClassesTree.Items.EndUpdate; + FUpdating := False; + end; +end; + +function TfrxDataTreeForm.GetLastPosition: TPoint; +var + Item: TTreeNode; +begin + Result.X := FTabs.TabIndex; + Result.Y := 0; + Item := nil; + case Result.X of + 0: Item := DataTree.TopItem; + 1: Item := VariablesTree.TopItem; + 2: Item := FunctionsTree.TopItem; + 3: Item := ClassesTree.TopItem; + end; + if Item <> nil then + Result.Y := Item.AbsoluteIndex; +end; + +procedure TfrxDataTreeForm.SetLastPosition(p: TPoint); +begin + ShowTab(p.X); + case p.X of + 0: if DataTree.Items.Count > 0 then DataTree.TopItem := DataTree.Items[p.Y]; + 1: if VariablesTree.Items.Count > 0 then VariablesTree.TopItem := VariablesTree.Items[p.Y]; + 2: if FunctionsTree.Items.Count > 0 then FunctionsTree.TopItem := FunctionsTree.Items[p.Y]; + 3: if ClassesTree.Items.Count > 0 then ClassesTree.TopItem := ClassesTree.Items[p.Y]; + end; +end; + +procedure TfrxDataTreeForm.TabsChange(Sender: TObject); +begin + ShowTab(FTabs.TabIndex); +end; + +procedure TfrxDataTreeForm.ShowTab(Index: Integer); +var + i: Integer; +begin + if (Index < 0) or (Index > FTabs.Tabs.Count - 1) then Exit; + FTabs.TabIndex := Index; + for i := 0 to FTabs.Tabs.Count - 1 do + TControl(FTabs.Tabs.Objects[i]).Visible := i = Index; + + if FXML.Root.Count = 0 then + begin + FReport.Script.AddRTTI; + GenerateXMLContents(FReport.Script, FXML.Root); + end; + + if (Index = 2) and (FunctionsTree.Items.Count = 0) then + FillFunctionsTree; + if (Index = 3) and (ClassesTree.Items.Count = 0) then + FillClassesTree; +end; + +procedure TfrxDataTreeForm.SetControlsParent(AParent: TWinControl); +begin + FTabs.Parent := AParent; + DataPn.Parent := AParent; + VariablesPn.Parent := AParent; + FunctionsPn.Parent := AParent; + ClassesPn.Parent := AParent; +end; + +procedure TfrxDataTreeForm.UpdateSize; +var + Y: Integer; +begin + AutoScroll := False; + with FTabs.Parent do + begin + if Screen.PixelsPerInch > 96 then + Y := 26 + else + Y := 22; + FTabs.SetBounds(0, 0, ClientWidth, Y); +{$IFDEF UseTabset} + Y := FTabs.Height - 1; +{$ELSE} + Y := FTabs.Height - 2; +{$ENDIF} + DataPn.SetBounds(0, Y, ClientWidth, ClientHeight - Y); + VariablesPn.SetBounds(0, Y, ClientWidth, ClientHeight - Y); + FunctionsPn.SetBounds(0, Y, ClientWidth, ClientHeight - Y); + ClassesPn.SetBounds(0, Y, ClientWidth, ClientHeight - Y); + NoDataPn.SetBounds(10, 20, DataPn.Width - 20, 140); + end; + FunctionNameL.AutoSize := False; + FunctionNameL.AutoSize := True; +end; + +function TfrxDataTreeForm.GetActivePage: Integer; +begin + Result := FTabs.TabIndex; +end; + +procedure TfrxDataTreeForm.UpdateSelection; +var + i: Integer; +begin + if GetActivePage = 0 then + begin + DataTree.Selected := nil; + if (Report.Designer.SelectedObjects.Count = 1) and + (TObject(Report.Designer.SelectedObjects[0]) is TfrxDataset) then + begin + for i := 0 to DataTree.Items.Count - 1 do + if DataTree.Items[i].Data = Report.Designer.SelectedObjects[0] then + begin + DataTree.Selected := DataTree.Items[i]; + break; + end; + end; + end; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDesgn.dfm b/official/4.2/LibD11/frxDesgn.dfm new file mode 100644 index 0000000..76eca85 Binary files /dev/null and b/official/4.2/LibD11/frxDesgn.dfm differ diff --git a/official/4.2/LibD11/frxDesgn.inc b/official/4.2/LibD11/frxDesgn.inc new file mode 100644 index 0000000..22fdd34 --- /dev/null +++ b/official/4.2/LibD11/frxDesgn.inc @@ -0,0 +1,18 @@ +{ custom color settings for code window } + +{ + property BlockColor: TColor; + property BlockFontColor: TColor; + property Color; + property CommentAttr: TFont; + property Font; + property KeywordAttr: TFont; + property NumberAttr: TFont; + property StringAttr: TFont; + property TextAttr: TFont; +} + +{ example: + Color := clBlack; + TextAttr.Color := clGreen; +} diff --git a/official/4.2/LibD11/frxDesgn.pas b/official/4.2/LibD11/frxDesgn.pas new file mode 100644 index 0000000..b8d833e --- /dev/null +++ b/official/4.2/LibD11/frxDesgn.pas @@ -0,0 +1,5821 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Designer } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDesgn; + +interface + +{$I frx.inc} + +uses +{$IFDEF FR_COM} + FastReport_TLB, +{$ENDIF} + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ComCtrls, ImgList, Menus, Buttons, StdCtrls, ToolWin, ExtCtrls, ActnList, + CommCtrl, frxClass, frxDock, frxCtrls, frxDesgnCtrls, frxDesgnWorkspace, + frxInsp, frxDialogForm, frxDataTree, frxReportTree, frxSynMemo, + fs_iinterpreter, Printers, frxWatchForm, frxPictureCache +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF Delphi9} +, GraphUtil, Tabs +{$ENDIF} +{$IFDEF FR_COM} +, ActiveX, AxCtrls +, VCLCom, ComObj, ComServ +//, FastReport_TLB +{$ENDIF} +; + +{$IFDEF FR_COM} +const + CLASS_TfrxDesigner: TGUID = '{48C4E65F-53A7-4382-A3C4-482972D8623B}'; +{$ENDIF} + +type + TfrxDesignerUnits = (duCM, duInches, duPixels, duChars); + TfrxLoadReportEvent = function(Report: TfrxReport): Boolean of object; + TfrxSaveReportEvent = function(Report: TfrxReport; SaveAs: Boolean): Boolean of object; + TfrxGetTemplateListEvent = procedure(List: TStrings) of object; + TfrxDesignerRestriction = + (drDontInsertObject, drDontDeletePage, drDontCreatePage, drDontChangePageOptions, + drDontCreateReport, drDontLoadReport, drDontSaveReport, + drDontPreviewReport, drDontEditVariables, drDontChangeReportOptions, + drDontEditReportData, drDontShowRecentFiles); + TfrxDesignerRestrictions = set of TfrxDesignerRestriction; + TSampleFormat = class; + +{$IFDEF FR_COM} + TfrxDesignerForm = class; + + TfrxDesigner = class(TComponent, IfrxDesigner, IConnectionPointContainer ) + FConnectionPoints: TConnectionPoints; + FConnectionPoint: TConnectionPoint; + FEvent: IfrxDesignerEvents; + private + FForm: TfrxDesignerForm; +{$ELSE} + TfrxDesigner = class(TComponent) + private +{$ENDIF} + FCloseQuery: Boolean; + FDefaultScriptLanguage: String; + FDefaultFont: TFont; + FDefaultLeftMargin: Extended; + FDefaultBottomMargin: Extended; + FDefaultRightMargin: Extended; + FDefaultTopMargin: Extended; + FDefaultPaperSize: Integer; + FDefaultOrientation: TPrinterOrientation; +{$IFDEF Delphi10} + FGradient: Boolean; + FGradientEnd: TColor; + FGradientStart: TColor; +{$ENDIF} + FOpenDir: String; + FSaveDir: String; + FTemplateDir: String; + FStandalone: Boolean; + FRestrictions: TfrxDesignerRestrictions; + FRTLLanguage: Boolean; + FOnLoadReport: TfrxLoadReportEvent; + FOnSaveReport: TfrxSaveReportEvent; + FOnShow: TNotifyEvent; + FOnInsertObject: TNotifyEvent; + FOnGetTemplateList: TfrxGetTemplateListEvent; + FOnShowStartupScreen: TNotifyEvent; + procedure SetDefaultFont(const Value: TFont); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure GetTemplateList(List: TStrings); + published + property CloseQuery: Boolean read FCloseQuery write FCloseQuery default True; + property DefaultScriptLanguage: String read FDefaultScriptLanguage write FDefaultScriptLanguage; + property DefaultFont: TFont read FDefaultFont write SetDefaultFont; + property DefaultLeftMargin: Extended read FDefaultLeftMargin write FDefaultLeftMargin; + property DefaultRightMargin: Extended read FDefaultRightMargin write FDefaultRightMargin; + property DefaultTopMargin: Extended read FDefaultTopMargin write FDefaultTopMargin; + property DefaultBottomMargin: Extended read FDefaultBottomMargin write FDefaultBottomMargin; + property DefaultPaperSize: Integer read FDefaultPaperSize write FDefaultPaperSize; + property DefaultOrientation: TPrinterOrientation read FDefaultOrientation write FDefaultOrientation; +{$IFDEF Delphi10} + property Gradient: Boolean read FGradient write FGradient default False; + property GradientEnd: TColor read FGradientEnd write FGradientEnd; + property GradientStart: TColor read FGradientStart write FGradientStart; +{$ENDIF} + property OpenDir: String read FOpenDir write FOpenDir; + property SaveDir: String read FSaveDir write FSaveDir; + property TemplateDir: String read FTemplateDir write FTemplateDir; + property Standalone: Boolean read FStandalone write FStandalone default False; + property Restrictions: TfrxDesignerRestrictions read FRestrictions write FRestrictions; + property RTLLanguage: Boolean read FRTLLanguage write FRTLLanguage; + property OnLoadReport: TfrxLoadReportEvent read FOnLoadReport write FOnLoadReport; + property OnSaveReport: TfrxSaveReportEvent read FOnSaveReport write FOnSaveReport; + property OnShow: TNotifyEvent read FOnShow write FOnShow; + property OnInsertObject: TNotifyEvent read FOnInsertObject write FOnInsertObject; + property OnShowStartupScreen: TNotifyEvent read FOnShowStartupScreen write FOnShowStartupScreen; + property OnGetTemplateList: TfrxGetTemplateListEvent read FOnGetTemplateList write FOnGetTemplateList; + +{$IFDEF FR_COM} + procedure EventSinkChanged(const Sink: IUnknown; Connecting: Boolean); + function Set_Standalone(Param: WordBool): HResult; stdcall; + function ShowWizards(Form: Integer): HResult; stdcall; + function OpenLastReport(Form: Integer): HResult; stdcall; + function OpenReport(Form: Integer): HResult; stdcall; + function EditConnectionAliases(Form: Integer): HResult; stdcall; + function Set_DefaultScriptLanguage(const Value: WideString): HResult; stdcall; + function Get_EnableStartupWindow(out Value: WordBool): HResult; stdcall; + function Set_EnableStartupWindow(Value: WordBool): HResult; stdcall; + function Set_EnableLoadEvent(Value: WordBool): HResult; stdcall; + function Set_EnableSaveEvent(Value: WordBool): HResult; stdcall; + function Get_Restrictions(out Value: frxDesignerRestrictions): HResult; stdcall; + function Set_Restrictions(Value: frxDesignerRestrictions): HResult; stdcall; + function Get_TemplateModified(out Value: WordBool): HResult; stdcall; + function Set_TemplateModified(Value: WordBool): HResult; stdcall; + { COM proxy event functions } + procedure OnDesignerStartupHandler(Sender: TObject); + function OnLoadReportHandler(Report: TfrxReport): Boolean ; + function OnSaveReportHandler(Report: TfrxReport; SaveAs: Boolean): Boolean; + {IConnectionPointContainer} + property ConnectionPoints: TConnectionPoints read FConnectionPoints implements IConnectionPointContainer; +{$ENDIF} + end; + + TfrxDesignerForm = class(TfrxCustomDesigner) + Bevel1: TBevel; + StatusBar: TStatusBar; + DockBottom: TControlBar; + DockTop: TControlBar; + TextTB: TToolBar; + PanelTB1: TfrxTBPanel; + FontSizeCB: TfrxComboBox; + FontNameCB: TfrxFontComboBox; + BoldB: TToolButton; + ItalicB: TToolButton; + UnderlineB: TToolButton; + SepTB8: TToolButton; + FontColorB: TToolButton; + HighlightB: TToolButton; + SepTB9: TToolButton; + TextAlignLeftB: TToolButton; + TextAlignCenterB: TToolButton; + TextAlignRightB: TToolButton; + TextAlignBlockB: TToolButton; + SepTB10: TToolButton; + TextAlignTopB: TToolButton; + TextAlignMiddleB: TToolButton; + TextAlignBottomB: TToolButton; + FrameTB: TToolBar; + FrameTopB: TToolButton; + FrameBottomB: TToolButton; + FrameLeftB: TToolButton; + FrameRightB: TToolButton; + SepTB11: TToolButton; + FrameAllB: TToolButton; + FrameNoB: TToolButton; + SepTB12: TToolButton; + FillColorB: TToolButton; + FrameColorB: TToolButton; + FrameStyleB: TToolButton; + PanelTB2: TfrxTBPanel; + FrameWidthCB: TfrxComboBox; + StandardTB: TToolBar; + NewB: TToolButton; + OpenB: TToolButton; + SaveB: TToolButton; + PreviewB: TToolButton; + SepTB1: TToolButton; + CutB: TToolButton; + CopyB: TToolButton; + PasteB: TToolButton; + SepTB2: TToolButton; + UndoB: TToolButton; + RedoB: TToolButton; + SepTB3: TToolButton; + SepTB4: TToolButton; + NewPageB: TToolButton; + NewDialogB: TToolButton; + DeletePageB: TToolButton; + PageSettingsB: TToolButton; + ShowGridB: TToolButton; + AlignToGridB: TToolButton; + ExtraToolsTB: TToolBar; + PagePopup: TPopupMenu; + CutMI1: TMenuItem; + CopyMI1: TMenuItem; + PasteMI1: TMenuItem; + DeleteMI1: TMenuItem; + SelectAllMI1: TMenuItem; + SepMI8: TMenuItem; + EditMI1: TMenuItem; + MainMenu: TMainMenu; + FileMenu: TMenuItem; + EditMenu: TMenuItem; + ViewMenu: TMenuItem; + ToolbarsMI: TMenuItem; + StandardMI: TMenuItem; + TextMI: TMenuItem; + FrameMI: TMenuItem; + AlignmentMI: TMenuItem; + ToolsMI: TMenuItem; + InspectorMI: TMenuItem; + DataTreeMI: TMenuItem; + OptionsMI: TMenuItem; + HelpMenu: TMenuItem; + HelpContentsMI: TMenuItem; + SepMI7: TMenuItem; + AboutMI: TMenuItem; + OpenDialog: TOpenDialog; + SaveDialog: TSaveDialog; + TabPopup: TPopupMenu; + NewPageMI1: TMenuItem; + NewDialogMI1: TMenuItem; + DeletePageMI1: TMenuItem; + PageSettingsMI1: TMenuItem; + ActionList: TActionList; + ExitCmd: TAction; + CutCmd: TAction; + CopyCmd: TAction; + PasteCmd: TAction; + UndoCmd: TAction; + RedoCmd: TAction; + DeleteCmd: TAction; + SelectAllCmd: TAction; + EditCmd: TAction; + BringToFrontCmd: TAction; + SendToBackCmd: TAction; + DeletePageCmd: TAction; + NewItemCmd: TAction; + NewPageCmd: TAction; + NewDialogCmd: TAction; + NewReportCmd: TAction; + OpenCmd: TAction; + SaveCmd: TAction; + SaveAsCmd: TAction; + VariablesCmd: TAction; + PageSettingsCmd: TAction; + PreviewCmd: TAction; + NewMI: TMenuItem; + NewReportMI: TMenuItem; + NewPageMI: TMenuItem; + NewDialogMI: TMenuItem; + SepMI1: TMenuItem; + OpenMI: TMenuItem; + SaveMI: TMenuItem; + SaveAsMI: TMenuItem; + VariablesMI: TMenuItem; + SepMI3: TMenuItem; + PreviewMI: TMenuItem; + SepMI4: TMenuItem; + ExitMI: TMenuItem; + UndoMI: TMenuItem; + RedoMI: TMenuItem; + SepMI5: TMenuItem; + CutMI: TMenuItem; + CopyMI: TMenuItem; + PasteMI: TMenuItem; + DeleteMI: TMenuItem; + DeletePageMI: TMenuItem; + SelectAllMI: TMenuItem; + SepMI6: TMenuItem; + BringtoFrontMI: TMenuItem; + SendtoBackMI: TMenuItem; + EditMI: TMenuItem; + PanelTB3: TfrxTBPanel; + ScaleCB: TfrxComboBox; + ObjectsTB1: TToolBar; + BandsPopup: TPopupMenu; + ReportTitleMI: TMenuItem; + ReportSummaryMI: TMenuItem; + PageHeaderMI: TMenuItem; + PageFooterMI: TMenuItem; + HeaderMI: TMenuItem; + FooterMI: TMenuItem; + MasterDataMI: TMenuItem; + DetailDataMI: TMenuItem; + SubdetailDataMI: TMenuItem; + GroupHeaderMI: TMenuItem; + GroupFooterMI: TMenuItem; + ColumnHeaderMI: TMenuItem; + ColumnFooterMI: TMenuItem; + ChildMI: TMenuItem; + LeftDockSite1: TfrxDockSite; + VariablesB: TToolButton; + SepTB13: TToolButton; + PageSettingsMI: TMenuItem; + Timer: TTimer; + ReportSettingsMI: TMenuItem; + Data4levelMI: TMenuItem; + Data5levelMI: TMenuItem; + Data6levelMI: TMenuItem; + SepMI10: TMenuItem; + SepMI9: TMenuItem; + ShowGuidesMI: TMenuItem; + ShowRulersMI: TMenuItem; + DeleteGuidesMI: TMenuItem; + SepMI11: TMenuItem; + N1: TMenuItem; + BringtoFrontMI1: TMenuItem; + SendtoBackMI1: TMenuItem; + SepMI12: TMenuItem; + RotateB: TToolButton; + RotationPopup: TPopupMenu; + R0MI: TMenuItem; + R45MI: TMenuItem; + R90MI: TMenuItem; + R180MI: TMenuItem; + R270MI: TMenuItem; + SetToGridB: TToolButton; + ShadowB: TToolButton; + ReportMenu: TMenuItem; + ReportDataMI: TMenuItem; + OpenScriptDialog: TOpenDialog; + SaveScriptDialog: TSaveDialog; + ReportTreeMI: TMenuItem; + ObjectsPopup: TPopupMenu; + AlignTB: TToolBar; + AlignLeftsB: TToolButton; + AlignHorzCentersB: TToolButton; + AlignRightsB: TToolButton; + AlignTopsB: TToolButton; + AlignVertCentersB: TToolButton; + AlignBottomsB: TToolButton; + SpaceHorzB: TToolButton; + SpaceVertB: TToolButton; + CenterHorzB: TToolButton; + CenterVertB: TToolButton; + SameWidthB: TToolButton; + SameHeightB: TToolButton; + SepTB15: TToolButton; + SepTB16: TToolButton; + SepTB18: TToolButton; + SepTB17: TToolButton; + OverlayMI: TMenuItem; + StyleCB: TfrxComboBox; + ReportStylesMI: TMenuItem; + TabOrderMI: TMenuItem; + N2: TMenuItem; + FindMI: TMenuItem; + FindNextMI: TMenuItem; + ReplaceMI: TMenuItem; + DMPPopup: TPopupMenu; + BoldMI: TMenuItem; + ItalicMI: TMenuItem; + UnderlineMI: TMenuItem; + SuperScriptMI: TMenuItem; + SubScriptMI: TMenuItem; + CondensedMI: TMenuItem; + WideMI: TMenuItem; + N12cpiMI: TMenuItem; + N15cpiMI: TMenuItem; + FontB: TToolButton; + VerticalbandsMI: TMenuItem; + HeaderMI1: TMenuItem; + FooterMI1: TMenuItem; + MasterDataMI1: TMenuItem; + DetailDataMI1: TMenuItem; + SubdetailDataMI1: TMenuItem; + GroupHeaderMI1: TMenuItem; + GroupFooterMI1: TMenuItem; + ChildMI1: TMenuItem; + N3: TMenuItem; + GroupB: TToolButton; + UngroupB: TToolButton; + SepTB20: TToolButton; + GroupCmd: TAction; + UngroupCmd: TAction; + GroupMI: TMenuItem; + UngroupMI: TMenuItem; + ConnectionsMI: TMenuItem; + BackPanel: TPanel; + ScrollBoxPanel: TPanel; + ScrollBox: TfrxScrollBox; + LeftRuler: TfrxRuler; + TopRuler: TfrxRuler; + CodePanel: TPanel; + CodeTB: TToolBar; + frTBPanel1: TfrxTBPanel; + LangL: TLabel; + LangCB: TfrxComboBox; + OpenScriptB: TToolButton; + SaveScriptB: TToolButton; + SepTB19: TToolButton; + RunScriptB: TToolButton; + RunToCursorB: TToolButton; + StepScriptB: TToolButton; + StopScriptB: TToolButton; + EvaluateB: TToolButton; + BreakPointB: TToolButton; + CodeDockSite: TfrxDockSite; + LeftDockSite2: TfrxDockSite; + RightDockSite: TfrxDockSite; + TabPanel: TPanel; + Panel1: TPanel; + AddChildMI: TMenuItem; + FindCmd: TAction; + ReplaceCmd: TAction; + FindNextCmd: TAction; + ReportDataCmd: TAction; + ReportStylesCmd: TAction; + ReportOptionsCmd: TAction; + ShowRulersCmd: TAction; + ShowGuidesCmd: TAction; + DeleteGuidesCmd: TAction; + OptionsCmd: TAction; + HelpContentsCmd: TAction; + AboutCmd: TAction; + StandardTBCmd: TAction; + TextTBCmd: TAction; + FrameTBCmd: TAction; + AlignTBCmd: TAction; + ExtraTBCmd: TAction; + InspectorTBCmd: TAction; + DataTreeTBCmd: TAction; + ReportTreeTBCmd: TAction; + ToolbarsCmd: TAction; + procedure ExitCmdExecute(Sender: TObject); + procedure ObjectsButtonClick(Sender: TObject); + procedure StatusBarDrawPanel(StatusBar: TStatusBar; + Panel: TStatusPanel; const ARect: TRect); + procedure ScrollBoxMouseWheelUp(Sender: TObject; Shift: TShiftState; + MousePos: TPoint; var Handled: Boolean); + procedure ScrollBoxMouseWheelDown(Sender: TObject; Shift: TShiftState; + MousePos: TPoint; var Handled: Boolean); + procedure ScrollBoxResize(Sender: TObject); + procedure ScaleCBClick(Sender: TObject); + procedure ShowGridBClick(Sender: TObject); + procedure AlignToGridBClick(Sender: TObject); + procedure StatusBarDblClick(Sender: TObject); + procedure StatusBarMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure InsertBandClick(Sender: TObject); + procedure BandsPopupPopup(Sender: TObject); + procedure FormClose(Sender: TObject; var Action: TCloseAction); + procedure NewReportCmdExecute(Sender: TObject); + procedure ToolButtonClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure FontColorBClick(Sender: TObject); + procedure FrameStyleBClick(Sender: TObject); + procedure TabChange(Sender: TObject); + procedure UndoCmdExecute(Sender: TObject); + procedure RedoCmdExecute(Sender: TObject); + procedure CutCmdExecute(Sender: TObject); + procedure CopyCmdExecute(Sender: TObject); + procedure PasteCmdExecute(Sender: TObject); + procedure TimerTimer(Sender: TObject); + procedure DeletePageCmdExecute(Sender: TObject); + procedure NewDialogCmdExecute(Sender: TObject); + procedure NewPageCmdExecute(Sender: TObject); + procedure SaveCmdExecute(Sender: TObject); + procedure SaveAsCmdExecute(Sender: TObject); + procedure OpenCmdExecute(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + procedure DeleteCmdExecute(Sender: TObject); + procedure SelectAllCmdExecute(Sender: TObject); + procedure EditCmdExecute(Sender: TObject); + procedure TabChanging(Sender: TObject; var AllowChange: Boolean); + procedure PageSettingsCmdExecute(Sender: TObject); + procedure TopRulerDragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure AlignLeftsBClick(Sender: TObject); + procedure AlignRightsBClick(Sender: TObject); + procedure AlignTopsBClick(Sender: TObject); + procedure AlignBottomsBClick(Sender: TObject); + procedure AlignHorzCentersBClick(Sender: TObject); + procedure AlignVertCentersBClick(Sender: TObject); + procedure CenterHorzBClick(Sender: TObject); + procedure CenterVertBClick(Sender: TObject); + procedure SpaceHorzBClick(Sender: TObject); + procedure SpaceVertBClick(Sender: TObject); + procedure SelectToolBClick(Sender: TObject); + procedure PagePopupPopup(Sender: TObject); + procedure BringToFrontCmdExecute(Sender: TObject); + procedure SendToBackCmdExecute(Sender: TObject); + procedure LangCBClick(Sender: TObject); + procedure OpenScriptBClick(Sender: TObject); + procedure SaveScriptBClick(Sender: TObject); + procedure CodeWindowDragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure CodeWindowDragDrop(Sender, Source: TObject; X, Y: Integer); + procedure VariablesCmdExecute(Sender: TObject); + procedure ObjectBandBClick(Sender: TObject); + procedure PreviewCmdExecute(Sender: TObject); + procedure HighlightBClick(Sender: TObject); + procedure TabMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure TabMouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); + procedure TabMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure TabDragDrop(Sender, Source: TObject; X, Y: Integer); + procedure TabDragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure SameWidthBClick(Sender: TObject); + procedure SameHeightBClick(Sender: TObject); + procedure NewItemCmdExecute(Sender: TObject); + procedure TabOrderMIClick(Sender: TObject); + procedure RunScriptBClick(Sender: TObject); + procedure StopScriptBClick(Sender: TObject); + procedure EvaluateBClick(Sender: TObject); + procedure GroupCmdExecute(Sender: TObject); + procedure UngroupCmdExecute(Sender: TObject); + procedure ConnectionsMIClick(Sender: TObject); + procedure LangSelectClick(Sender: TObject); + procedure BreakPointBClick(Sender: TObject); + procedure RunToCursorBClick(Sender: TObject); + procedure CodeDockSiteDockOver(Sender: TObject; + Source: TDragDockObject; X, Y: Integer; State: TDragState; + var Accept: Boolean); + procedure TabSetChange(Sender: TObject; NewTab: Integer; + var AllowChange: Boolean); + procedure FormShow(Sender: TObject); + procedure AddChildMIClick(Sender: TObject); + procedure FindCmdExecute(Sender: TObject); + procedure ReplaceCmdExecute(Sender: TObject); + procedure FindNextCmdExecute(Sender: TObject); + procedure ReportDataCmdExecute(Sender: TObject); + procedure ReportStylesCmdExecute(Sender: TObject); + procedure ReportOptionsCmdExecute(Sender: TObject); + procedure ShowRulersCmdExecute(Sender: TObject); + procedure ShowGuidesCmdExecute(Sender: TObject); + procedure DeleteGuidesCmdExecute(Sender: TObject); + procedure OptionsCmdExecute(Sender: TObject); + procedure HelpContentsCmdExecute(Sender: TObject); + procedure AboutCmdExecute(Sender: TObject); + procedure StandardTBCmdExecute(Sender: TObject); + procedure TextTBCmdExecute(Sender: TObject); + procedure FrameTBCmdExecute(Sender: TObject); + procedure AlignTBCmdExecute(Sender: TObject); + procedure ExtraTBCmdExecute(Sender: TObject); + procedure InspectorTBCmdExecute(Sender: TObject); + procedure DataTreeTBCmdExecute(Sender: TObject); + procedure ReportTreeTBCmdExecute(Sender: TObject); + procedure ToolbarsCmdExecute(Sender: TObject); + private + { Private declarations } + ObjectSelectB: TToolButton; + HandToolB: TToolButton; + ZoomToolB: TToolButton; + TextToolB: TToolButton; + FormatToolB: TToolButton; + ObjectBandB: TToolButton; + + FClipboard: TfrxClipboard; + FCodeWindow: TfrxSyntaxMemo; + FColor: TColor; + FCoord1: String; + FCoord2: String; + FCoord3: String; + FDialogForm: TfrxDialogForm; + FEditAfterInsert: Boolean; + FDataTree: TfrxDataTreeForm; + FDropFields: Boolean; + FGridAlign: Boolean; + FGridSize1: Extended; + FGridSize2: Extended; + FGridSize3: Extended; + FGridSize4: Extended; + FInspector: TfrxObjectInspector; + FLineStyle: TfrxFrameStyle; + FLocalizedOI: Boolean; + FModifiedBy: TObject; + FMouseDown: Boolean; + FOldDesignerComp: TfrxDesigner; + FOldUnits: TfrxDesignerUnits; + FPagePositions: TStrings; + FPictureCache: TfrxPictureCache; + FRecentFiles: TStringList; + FRecentMenuIndex: Integer; + FReportTree: TfrxReportTreeForm; + FSampleFormat: TSampleFormat; + FScale: Extended; + FScriptFirstTime: Boolean; + FScriptRunning: Boolean; + FScriptStep: Boolean; + FScriptStopped: Boolean; + FSearchCase: Boolean; + FSearchIndex: Integer; + FSearchReplace: Boolean; + FSearchReplaceText: String; + FSearchText: String; + FShowGrid: Boolean; + FShowGuides: Boolean; + FShowRulers: Boolean; + FShowStartup: Boolean; +{$IFDEF UseTabset} + FTabs: TTabSet; +{$ELSE} + FTabs: TTabControl; +{$ENDIF} + FToolsColor: TColor; + FUndoBuffer: TfrxUndoBuffer; + FUnits: TfrxDesignerUnits; + FUnitsDblClicked: Boolean; + FUpdatingControls: Boolean; + FWatchList: TfrxWatchForm; + FWorkspace: TfrxDesignerWorkspace; + FWorkspaceColor: TColor; + + procedure AttachDialogFormEvents(Attach: Boolean); + procedure CreateColorSelector(Sender: TToolButton); + procedure CreateExtraToolbar; + procedure CreateToolWindows; + procedure CreateObjectsToolbar; + procedure CreateWorkspace; + procedure DialogFormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure DialogFormKeyPress(Sender: TObject; var Key: Char); + procedure DialogFormKeyUp(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure DialogFormModify(Sender: TObject); + procedure Done; + procedure DoTopmosts(Enable: Boolean); + procedure FindOrReplace(replace: Boolean); + procedure FindText; + procedure Init; + procedure NormalizeTopmosts; + procedure OnCodeChanged(Sender: TObject); + procedure OnCodeCompletion(const Name: String; List: TStrings); + procedure OnColorChanged(Sender: TObject); + procedure OnComponentMenuClick(Sender: TObject); + procedure OnChangePosition(Sender: TObject); + procedure OnDataTreeDblClick(Sender: TObject); + procedure OnDisableDock(Sender: TObject; var DragObject: TDragDockObject); + procedure OnEditObject(Sender: TObject); + procedure OnEnableDock(Sender, Target: TObject; X, Y: Integer); + procedure OnExtraToolClick(Sender: TObject); + procedure OnInsertObject(Sender: TObject); + procedure OnModify(Sender: TObject); + procedure OnNotifyPosition(ARect: TfrxRect); + procedure OnRunLine(Sender: TfsScript; const UnitName, SourcePos: String); + procedure OnSelectionChanged(Sender: TObject); + procedure OnStyleChanged(Sender: TObject); + procedure OpenRecentFile(Sender: TObject); + procedure ReadButtonImages; + procedure ReloadObjects; + procedure RestorePagePosition; + procedure RestoreTopmosts; + procedure SavePagePosition; + procedure SaveState; + procedure SetScale(Value: Extended); + procedure SetGridAlign(const Value: Boolean); + procedure SetShowGrid(const Value: Boolean); + procedure SetShowRulers(const Value: Boolean); + procedure SetToolsColor(const Value: TColor); + procedure SetUnits(const Value: TfrxDesignerUnits); + procedure SetWorkspaceColor(const Value: TColor); + procedure SwitchToolbar; + procedure UpdateCaption; + procedure UpdateControls; + procedure UpdatePageDimensions; + procedure UpdateRecentFiles(NewFile: String); + procedure UpdateStyles; + procedure UpdateSyntaxType; + function AskSave: Word; + function GetPageIndex: Integer; + function GetReportName: String; + procedure SetShowGuides(const Value: Boolean); + procedure Localize; + procedure CreateLangMenu; + procedure CMStartup(var Message: TMessage); message WM_USER + 1; + procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND; + procedure WMEnable(var Message: TMessage); message WM_ENABLE; + procedure WMActivateApp(var Message: TWMActivateApp); message WM_ACTIVATEAPP; + protected + procedure SetModified(const Value: Boolean); override; + procedure SetPage(const Value: TfrxPage); override; + function GetCode: TStrings; override; + public + { Public declarations } + function CheckOp(Op: TfrxDesignerRestriction): Boolean; + function InsertExpression(const Expr: String): String; override; + procedure LoadFile(FileName: String; UseOnLoadEvent: Boolean); + procedure Lock; override; + procedure ReloadPages(Index: Integer); override; + procedure ReloadReport; override; + procedure RestoreState(RestoreDefault: Boolean = False; + RestoreMainForm: Boolean = False); + function SaveFile(SaveAs: Boolean; UseOnSaveEvent: Boolean): Boolean; + procedure SetReportDefaults; + procedure SwitchToCodeWindow; + procedure UpdateDataTree; override; + procedure UpdatePage; override; + function GetDefaultObjectSize: TfrxPoint; + function mmToUnits(mm: Extended; X: Boolean = True): Extended; + function UnitsTomm(mm: Extended; X: Boolean = True): Extended; + + property CodeWindow: TfrxSyntaxMemo read FCodeWindow; + property DataTree: TfrxDataTreeForm read FDataTree; + property DropFields: Boolean read FDropFields write FDropFields; + property EditAfterInsert: Boolean read FEditAfterInsert write FEditAfterInsert; + property GridAlign: Boolean read FGridAlign write SetGridAlign; + property GridSize1: Extended read FGridSize1 write FGridSize1; + property GridSize2: Extended read FGridSize2 write FGridSize2; + property GridSize3: Extended read FGridSize3 write FGridSize3; + property GridSize4: Extended read FGridSize4 write FGridSize4; + property Inspector: TfrxObjectInspector read FInspector; + property PictureCache: TfrxPictureCache read FPictureCache; + property RecentFiles: TStringList read FRecentFiles; + property ReportTree: TfrxReportTreeForm read FReportTree; + property SampleFormat: TSampleFormat read FSampleFormat; + property Scale: Extended read FScale write SetScale; + property ShowGrid: Boolean read FShowGrid write SetShowGrid; + property ShowGuides: Boolean read FShowGuides write SetShowGuides; + property ShowRulers: Boolean read FShowRulers write SetShowRulers; + property ShowStartup: Boolean read FShowStartup write FShowStartup; + property ToolsColor: TColor read FToolsColor write SetToolsColor; + property Units: TfrxDesignerUnits read FUnits write SetUnits; + property Workspace: TfrxDesignerWorkspace read FWorkspace; + property WorkspaceColor: TColor read FWorkspaceColor write SetWorkspaceColor; + end; + + TSampleFormat = class(TObject) + private + FMemo: TfrxCustomMemoView; + procedure Clear; + public + constructor Create; + destructor Destroy; override; + procedure ApplySample(Memo: TfrxCustomMemoView); + procedure SetAsSample(Memo: TfrxCustomMemoView); + property Memo: TfrxCustomMemoView read FMemo; + end; + +var + frxDesignerComp: TfrxDesigner; + +implementation + +{$R *.DFM} +{$R *.RES} + +uses + TypInfo, IniFiles, Registry, + frxDsgnIntf, frxUtils, frxPopupForm, frxDesgnWorkspace1, + frxDesgnEditors, frxEditOptions, frxEditReport, frxEditPage, frxAbout, + fs_itools, frxXML, frxEditReportData, frxEditVar, frxEditExpr, + frxEditHighlight, frxEditStyle, frxNewItem, + {$IFDEF FR_COM}frxStdWizard{frxAdoWizard},{$ELSE}frxStdWizard,{$ENDIF} + frxEditTabOrder, frxCodeUtils, frxRes, frxrcDesgn, frxDMPClass, + frxEvaluateForm, frxSearchDialog, frxConnEditor, fs_xml, frxVariables; + +type + THackControl = class(TWinControl); + + + +{ TSampleFormat } + +constructor TSampleFormat.Create; +begin + Clear; +end; + +destructor TSampleFormat.Destroy; +begin + FMemo.Free; + inherited; +end; + +procedure TSampleFormat.Clear; +begin + if FMemo <> nil then + FMemo.Free; + FMemo := TfrxMemoView.Create(nil); + if frxDesignerComp <> nil then + begin + FMemo.Font := frxDesignerComp.DefaultFont; + FMemo.RTLReading := frxDesignerComp.RTLLanguage; + end; +end; + +procedure TSampleFormat.ApplySample(Memo: TfrxCustomMemoView); +begin + Memo.Color := FMemo.Color; + if not (Memo is TfrxDMPMemoView) then + Memo.Font := FMemo.Font; + Memo.Frame.Assign(FMemo.Frame); + Memo.HAlign := FMemo.HAlign; + Memo.VAlign := FMemo.VAlign; + Memo.RTLReading := FMemo.RTLReading; +end; + +procedure TSampleFormat.SetAsSample(Memo: TfrxCustomMemoView); +begin + FMemo.Color := Memo.Color; + if not (Memo is TfrxDMPMemoView) then + FMemo.Font := Memo.Font; + FMemo.Frame.Assign(Memo.Frame); + FMemo.HAlign := Memo.HAlign; + FMemo.VAlign := Memo.VAlign; + FMemo.RTLReading := Memo.RTLReading; +end; + + +{ TfrxDesigner } + +constructor TfrxDesigner.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + + FCloseQuery := True; + FDefaultFont := TFont.Create; + with FDefaultFont do + begin + Name := 'Arial'; + Size := 10; + end; + FDefaultScriptLanguage := 'PascalScript'; + FDefaultLeftMargin := 10; + FDefaultBottomMargin := 10; + FDefaultRightMargin := 10; + FDefaultTopMargin := 10; + FDefaultPaperSize := DMPAPER_A4; + FDefaultOrientation := poPortrait; + frxDesignerComp := Self; +{$IFDEF Delphi10} + FGradientStart := clWindow; + FGradientEnd := $00B6D6DA; +{$ENDIF} + +{$IFDEF FR_COM} + FEvent := nil; + FConnectionPoints := TConnectionPoints.Create(Self); + FConnectionPoints.CreateConnectionPoint( IfrxDesignerEvents, ckSingle, EventSinkChanged ); + FConnectionPoint := FConnectionPoints.CreateConnectionPoint( IfrxDesignerEventDispatcher, ckMulti, nil ); + + OnShowStartupScreen := OnDesignerStartupHandler; +{$ENDIF} +end; + +destructor TfrxDesigner.Destroy; +begin + FDefaultFont.Free; + frxDesignerComp := nil; + inherited Destroy; +end; + +procedure TfrxDesigner.SetDefaultFont(const Value: TFont); +begin + FDefaultFont.Assign(Value); +end; + +procedure TfrxDesigner.GetTemplateList(List: TStrings); +var + sr: TSearchRec; + dir: String; + + function NormalDir(const DirName: string): string; + begin + Result := DirName; + if (Result <> '') and + not (Result[Length(Result)] in [':', '\']) then + begin + if (Length(Result) = 1) and (UpCase(Result[1]) in ['A'..'Z']) then + Result := Result + ':\' + else Result := Result + '\'; + end; + end; + +begin + List.Clear; + if Assigned(FOnGetTemplateList) then + FOnGetTemplateList(List) + else + begin + dir := FTemplateDir; + if (Trim(dir) = '') or (Trim(dir) = '.') then + if csDesigning in ComponentState then + dir := GetCurrentDir + else + dir := ExtractFilePath(Application.ExeName); + dir := NormalDir(dir); + if FindFirst(dir + '*.fr3', faAnyFile, sr) = 0 then + begin + repeat + List.Add(dir + sr.Name); + until FindNext(sr) <> 0; + FindClose(sr); + end; + end; +end; + +{$IFDEF FR_COM} +procedure TfrxDesigner.EventSinkChanged(const Sink: IUnknown; Connecting: Boolean); +begin + if Connecting + then FEvent := Sink as IfrxDesignerEvents + else + FEvent := nil; +end; + + +function TfrxDesigner.Set_Standalone(Param: WordBool): HResult; stdcall; +begin + Standalone := Param; + Result := S_OK; +end; + +function TfrxDesigner.Set_DefaultScriptLanguage(const Value: WideString): HResult; stdcall; +begin + FDefaultScriptLanguage := Value; + Result := S_OK; +end; + +function TfrxDesigner.Get_EnableStartupWindow(out Value: WordBool): HResult; stdcall; +begin + Value := FForm.ShowStartup; + Result := S_OK; +end; + +function TfrxDesigner.Set_EnableStartupWindow(Value: WordBool): HResult; stdcall; +begin + FForm.ShowStartup := Value; + Result := S_OK; +end; + +function TfrxDesigner.Set_EnableLoadEvent(Value: WordBool): HResult; stdcall; +begin + if Value = True then + FOnLoadReport := OnLoadReportHandler + else + FOnLoadReport := nil; + Result := S_OK; +end; + +function TfrxDesigner.Set_EnableSaveEvent(Value: WordBool): HResult; stdcall; +begin + if Value = True then + FOnSaveReport := OnSaveReportHandler + else + FOnSaveReport := nil; + Result := S_OK; +end; + +function TfrxDesigner.Get_Restrictions(out Value: frxDesignerRestrictions): HResult; stdcall; +begin + Value := PInteger( @Restrictions )^; + Result := S_OK; +end; + +function TfrxDesigner.Set_Restrictions(Value: frxDesignerRestrictions): HResult; stdcall; +type + PfrxDesignerRestrictions = ^ TfrxDesignerRestrictions; +var + dst: TfrxDesignerRestrictions; + src: Integer; +begin + src := Value; + dst := PfrxDesignerRestrictions(@src)^; + Restrictions := dst; + Result := S_OK; +end; + +function TfrxDesigner.Get_TemplateModified(out Value: WordBool): HResult; stdcall; +begin + if Assigned(FForm) then + Value := FForm.Modified + else + Value := False; + Result := S_OK; +end; + +function TfrxDesigner.Set_TemplateModified(Value: WordBool): HResult; stdcall; +begin + if Assigned(FForm) then + begin + FForm.Modified := Value; + FForm.UpdateCaption; + end; + Result := S_OK; +end; + +function TfrxDesigner.ShowWizards(Form: Integer): HResult; stdcall; +var + DesignerForm: TfrxDesignerForm; +begin + DesignerForm := TfrxDesignerForm(Pointer(Form)); + with TfrxNewItemForm.Create(DesignerForm) do + begin + ShowModal; + Free; + end; + Result := S_OK; +end; + +function TfrxDesigner.OpenReport(Form: Integer): HResult; stdcall; +var + DesignerForm: TfrxDesignerForm; +begin + DesignerForm := TfrxDesignerForm(Pointer(Form)); + DesignerForm.OpenCmdExecute(Self); + Result := S_OK; +end; + +function TfrxDesigner.OpenLastReport(Form: Integer): HResult; stdcall; +var + DesignerForm: TfrxDesignerForm; + RecentList: TStringList; + s: String; +begin + DesignerForm := TfrxDesignerForm(Pointer(Form)); + RecentList := DesignerForm.RecentFiles; + if RecentList.Count <> 0 then + begin + s := RecentList[RecentList.Count - 1]; + DesignerForm.Lock; + DesignerForm.Report.LoadFromFile(s); + DesignerForm.ReloadReport; + end; + Result := S_OK; +end; + +function TfrxDesigner.EditConnectionAliases(Form: Integer): HResult; stdcall; +var + DesignerForm: TfrxDesignerForm; +begin + DesignerForm := TfrxDesignerForm(Pointer(Form)); + DesignerForm.ConnectionsMIClick(Self); + Result := S_OK; +end; + +procedure TfrxDesigner.OnDesignerStartupHandler(Sender: TObject); +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + FForm := TfrxDesignerForm(Sender); + + if FEvent <> nil then + FEvent.OnDesignerStartup( Integer(Pointer(Sender)), FForm.Handle ) + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxDesignerEventDispatcher).OnDesignerStartup( + Integer(Pointer(Sender)), + FForm.Handle); + ConnectData.pUnk := nil; + end; + end; +end; + +function TfrxDesigner.OnLoadReportHandler(Report: TfrxReport): Boolean; +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; +begin + Result := False; + if FEvent <> nil then FEvent.OnLoadReport(Report) else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + (ConnectData.pUnk as IfrxDesignerEventDispatcher).OnLoadReport(Report); + Result := True; + ConnectData.pUnk := nil; + end; + end; +end; + +function TfrxDesigner.OnSaveReportHandler( + Report: TfrxReport; + SaveAs: Boolean): Boolean; +var + Enum : IEnumConnections; + ConnectData : TConnectData; + Fetched : Longint; + Aborted : WordBool; +begin + Result := False; + if FEvent <> nil then case FEvent.OnSaveReport(Report, SaveAs, Aborted) of + S_OK: Result := not Aborted; + else + Result := False; + end + else + begin + OleCheck((FConnectionPoint as IConnectionPoint).EnumConnections(Enum)); + while Enum.Next (1, ConnectData, @Fetched) = S_OK do + begin + Aborted := True; + (ConnectData.pUnk as IfrxDesignerEventDispatcher).OnSaveReport(Report, SaveAs, Aborted); + Result := not Aborted; + ConnectData.pUnk := nil; + end; + end; +end; + +{$ENDIF} + +{ TfrxDesignerForm } + +{ Form events } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.FormShow(Sender: TObject); +begin +{$IFDEF FR_COM} + Icon.Handle := LoadIcon(hInstance, 'SDESGNICON'); +{$ENDIF} + ReadButtonImages; + CreateObjectsToolbar; + CreateWorkspace; + CreateToolWindows; + Init; + CreateExtraToolbar; + + Localize; + CreateLangMenu; + + with ScaleCB.Items do + begin + Clear; + Add('25%'); + Add('50%'); + Add('75%'); + Add('100%'); + Add('150%'); + Add('200%'); + Add(frxResources.Get('zmPageWidth')); + Add(frxResources.Get('zmWholePage')); + end; + + if Screen.PixelsPerInch > 96 then + begin + StyleCB.Font.Height := -11; + FontNameCB.Font.Height := -11; + FontSizeCB.Font.Height := -11; + ScaleCB.Font.Height := -11; + FrameWidthCB.Font.Height := -11; + LangL.Font.Height := -11; + LangCB.Font.Height := -11; + end; + + RestoreState; + ToolsMI.Visible := ExtraToolsTB.ButtonCount > 0; + ExtraToolsTB.Visible := ExtraToolsTB.ButtonCount > 0; + ReloadReport; + RestoreState(False, True); + + ConnectionsMI.Visible := False; + if frxDesignerComp <> nil then + begin + ConnectionsMI.Visible := frxDesignerComp.Standalone; + if Assigned(frxDesignerComp.FOnShow) then + frxDesignerComp.FOnShow(Self); + end; +end; + +procedure TfrxDesignerForm.FormClose(Sender: TObject; var Action: TCloseAction); +begin + SaveState; + Done; + Report.Modified := Modified; + Report.Designer := nil; + Action := caFree; +end; + +procedure TfrxDesignerForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +var + w: Word; +begin + if FScriptRunning then + begin + CanClose := False; + Exit; + end; + + CanClose := True; + Report.ScriptText := CodeWindow.Lines; + + if (frxDesignerComp <> nil) and not frxDesignerComp.CloseQuery then + Exit; + + if Modified and not (csDesigning in Report.ComponentState) and CheckOp(drDontSaveReport) then + begin + w := AskSave; + + if IsPreviewDesigner then + begin + if w = mrNo then + Modified := False + end + else if w = mrYes then + if not SaveFile(False, True) then + CanClose := False; + + if not IsPreviewDesigner then + begin + if w = mrNo then + Modified := False + else + Modified := True; + end; + + if w = mrCancel then + CanClose := False; + end; +end; + +procedure TfrxDesignerForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if ((FDialogForm <> nil) or (FPage is TfrxDataPage)) and + (ActiveControl <> FInspector.Edit1) then + THackControl(FWorkspace).KeyDown(Key, Shift); + + if Key = vk_Return then + if ActiveControl = FontSizeCB then + ToolButtonClick(FontSizeCB) + else if ActiveControl = ScaleCB then + ScaleCBClick(Self); + + if (Page <> nil) and (ActiveControl <> FInspector.Edit1) then + if Key = vk_Insert then + if Shift = [ssShift] then + PasteCmdExecute(nil) + else if Shift = [ssCtrl] then + CopyCmdExecute(nil); + + if (Page <> nil) and (ActiveControl <> FInspector.Edit1) then + if Key = vk_Delete then + if Shift = [ssShift] then + CutCmdExecute(nil); + + if (Key = Ord('E')) and (Shift = [ssCtrl]) then + Page := nil; + + if ((Key = vk_F4) or (Key = vk_F5)) and (Shift = []) and (Page = nil) then + begin + if Key = vk_F4 then + RunToCursorBClick(nil) + else + BreakPointBClick(nil); + end + else if (Key = vk_F2) and (Shift = [ssCtrl]) then + StopScriptBClick(StopScriptB) + else if (Key = vk_F7) and (Shift = [ssCtrl]) and (Page = nil) then + EvaluateBClick(EvaluateB) + else if Key = vk_F9 then + RunScriptBClick(RunScriptB) + else if ((Key = vk_F7) or (Key = vk_F8)) and (Page = nil) then + RunScriptBClick(StepScriptB); +end; + +procedure TfrxDesignerForm.CMStartup(var Message: TMessage); +begin +{$IFNDEF FR_COM} + if FShowStartup then +{$ENDIF} + if (frxDesignerComp <> nil) and Assigned(frxDesignerComp.FOnShowStartupScreen) then + frxDesignerComp.FOnShowStartupScreen(Self); +end; + +procedure TfrxDesignerForm.WMSysCommand(var Message: TWMSysCommand); +begin + if (Message.CmdType and $FFF0 = SC_MINIMIZE) and (FormStyle <> fsMDIChild) then + Application.Minimize + else + inherited; +end; + +procedure TfrxDesignerForm.DoTopmosts(Enable: Boolean); +var + fStyle: UINT; + + procedure SetFormStyle(Control: TWinControl); + begin + if Control is TToolBar then + if Control.Floating then + Control := Control.Parent + else + Exit; + SetWindowPos(Control.Handle, fStyle, 0, 0, 0, 0, SWP_NOMOVE or + SWP_NOSIZE or SWP_NOACTIVATE or SWP_NOOWNERZORDER); + end; + +begin + if Enable then + fStyle := HWND_TOPMOST + else + fStyle := HWND_NOTOPMOST; + + SetFormStyle(FReportTree); + SetFormStyle(FDataTree); + SetFormStyle(FInspector); + + SetFormStyle(StandardTB); + SetFormStyle(TextTB); + SetFormStyle(FrameTB); + SetFormStyle(AlignTB); + SetFormStyle(ExtraToolsTB); +end; + +procedure TfrxDesignerForm.NormalizeTopmosts; +begin + DoTopmosts(False); +end; + +procedure TfrxDesignerForm.RestoreTopmosts; +begin + DoTopmosts(True); +end; + +procedure TfrxDesignerForm.WMEnable(var Message: TMessage); +begin + inherited; + { workaround for ShowModal bug. If form with fsStayOnTop style is visible + before ShowModal call, it will be topmost } + if Message.WParam <> 0 then + RestoreTopmosts + else + NormalizeTopmosts; +end; + +procedure TfrxDesignerForm.WMActivateApp(var Message: TWMActivateApp); +begin + inherited; + if Message.Active then + RestoreTopmosts + else + NormalizeTopmosts; +end; + + +{ Get/Set methods } +{------------------------------------------------------------------------------} + +function TfrxDesignerForm.GetDefaultObjectSize: TfrxPoint; +begin + case FUnits of + duCM: Result := frxPoint(fr1cm * 2.5, fr1cm * 0.5); + duInches: Result := frxPoint(fr1in, fr1in * 0.2); + duPixels: Result := frxPoint(80, 16); + duChars: Result := frxPoint(fr1CharX * 10, fr1CharY); + end; +end; + +function TfrxDesignerForm.GetCode: TStrings; +begin + Result := CodeWindow.Lines; +end; + +procedure TfrxDesignerForm.SetGridAlign(const Value: Boolean); +begin + FGridAlign := Value; + AlignToGridB.Down := FGridAlign; + FWorkspace.GridAlign := FGridAlign; +end; + +procedure TfrxDesignerForm.SetModified(const Value: Boolean); +var + i: Integer; +begin + inherited; + Report.ScriptText := CodeWindow.Lines; + FUndoBuffer.AddUndo(Report); + FUndoBuffer.ClearRedo; + SaveCmd.Enabled := Modified; + + if FModifiedBy <> Self then + UpdateControls; + + if FModifiedBy = FInspector then + if (FSelectedObjects[0] = FPage) or + (TObject(FSelectedObjects[0]) is TfrxSubreport) then + begin + i := Report.Objects.IndexOf(FPage); + if i >= 0 then + ReloadPages(i); + end; + + if FModifiedBy <> FWorkspace then + begin + FWorkspace.UpdateView; + FWorkspace.AdjustBands; + end; + + if FModifiedBy <> FInspector then + FInspector.UpdateProperties; + + FReportTree.UpdateItems; + FModifiedBy := nil; +end; + +procedure TfrxDesignerForm.SetPage(const Value: TfrxPage); +begin + inherited; + + FTabs.TabIndex := Report.Objects.IndexOf(FPage) + 1; + AttachDialogFormEvents(False); + ScrollBoxPanel.Visible := FPage <> nil; + CodePanel.Visible := FPage = nil; + + SwitchToolbar; + UpdateControls; + + if FPage = nil then + begin + CodeWindow.SetFocus; + Exit; + end + else if FPage is TfrxReportPage then + begin + with FWorkspace do + begin + Parent := ScrollBox; + Align := alNone; + Color := FWorkspaceColor; + Scale := Self.Scale; + end; + + if FPage is TfrxDMPPage then + Units := duChars else + Units := FOldUnits; + UpdatePageDimensions; + if Visible then + ScrollBox.SetFocus; + end + else if FPage is TfrxDialogPage then + begin + Units := duPixels; + FDialogForm := TfrxDialogForm(TfrxDialogPage(FPage).DialogForm); + + with FWorkspace do + begin + Parent := FDialogForm; + Align := alClient; + GridType := gtDialog; + GridX := FGridSize4; + GridY := FGridSize4; + Color := TfrxDialogPage(FPage).Color; + Scale := 1; + SetPageDimensions(0, 0, Rect(0, 0, 0, 0)); + end; + + if FDialogForm <> nil then + with FDialogForm do + begin + Position := poDesigned; + BorderStyle := bsSizeable; + AttachDialogFormEvents(True); + Show; + end; + end + else if FPage is TfrxDataPage then + begin + Units := duPixels; + with FWorkspace do + begin + Parent := ScrollBox; + Align := alNone; + Color := FWorkspaceColor; + Scale := 1; + GridType := gtNone; + GridX := FGridSize4; + GridY := FGridSize4; + end; + + UpdatePageDimensions; + if Visible then + ScrollBox.SetFocus; + end + else + begin + Report.Errors.Add('Page object is not page'); + end; + + ReloadObjects; + RestorePagePosition; +end; + +procedure TfrxDesignerForm.SetScale(Value: Extended); +begin + ScrollBox.AutoScroll := False; + if Value = 0 then + Value := 1; + if Value > 20 then + Value := 20; + FScale := Value; + TopRuler.Scale := Value; + LeftRuler.Scale := Value; + FWorkspace.Scale := Value; + ScaleCB.Text := IntToStr(Round(FScale * 100)) + '%'; + UpdatePageDimensions; + ScrollBox.AutoScroll := True; +end; + +procedure TfrxDesignerForm.SetShowGrid(const Value: Boolean); +begin + FShowGrid := Value; + ShowGridB.Down := FShowGrid; + FWorkspace.ShowGrid := FShowGrid; +end; + +procedure TfrxDesignerForm.SetShowRulers(const Value: Boolean); +begin + FShowRulers := Value; + TopRuler.Visible := FShowRulers; + LeftRuler.Visible := FShowRulers; + ShowRulersCmd.Checked := FShowRulers; +end; + +procedure TfrxDesignerForm.SetShowGuides(const Value: Boolean); +begin + FShowGuides := Value; + TDesignerWorkspace(FWorkspace).ShowGuides := FShowGuides; + ShowGuidesCmd.Checked := FShowGuides; +end; + +procedure TfrxDesignerForm.SetUnits(const Value: TfrxDesignerUnits); +var + s: String; + gType: TfrxGridType; + gSizeX, gSizeY: Extended; +begin + FUnits := Value; + s := ''; + if FUnits = duCM then + begin + s := frxResources.Get('dsCm'); + gType := gt1cm; + gSizeX := FGridSize1 * fr1cm; + gSizeY := gSizeX; + end + else if FUnits = duInches then + begin + s := frxResources.Get('dsInch'); + gType := gt1in; + gSizeX := FGridSize2 * fr1in; + gSizeY := gSizeX; + end + else if FUnits = duPixels then + begin + s := frxResources.Get('dsPix'); + gType := gt1pt; + gSizeX := FGridSize3; + gSizeY := gSizeX; + end + else {if FUnits = duChars then} + begin + s := frxResources.Get('dsChars'); + gType := gtChar; + gSizeX := fr1CharX; + gSizeY := fr1CharY; + end; + + StatusBar.Panels[0].Text := s; + TopRuler.Units := TfrxRulerUnits(FUnits); + LeftRuler.Units := TfrxRulerUnits(FUnits); + + with FWorkspace do + begin + GridType := gType; + GridX := gSizeX; + GridY := gSizeY; + AdjustBands; + end; + + if FSelectedObjects.Count <> 0 then + OnSelectionChanged(Self); +end; + +procedure TfrxDesignerForm.SetToolsColor(const Value: TColor); +begin + FToolsColor := Value; + FInspector.SetColor(Value); + FDataTree.SetColor(Value); + FReportTree.SetColor(Value); +end; + +procedure TfrxDesignerForm.SetWorkspaceColor(const Value: TColor); +begin + FWorkspaceColor := Value; + if not (FPage is TfrxDialogPage) then + FWorkspace.Color := Value; +end; + + +{ Service methods } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.Init; +var + i: Integer; +begin + FPictureCache := TfrxPictureCache.Create; + FScale := 1; + ScrollBoxPanel.Align := alClient; + CodePanel.Align := alClient; + if Screen.PixelsPerInch > 96 then + begin + StatusBar.Panels[0].Width := 100; + StatusBar.Panels[1].Width := 280; + StatusBar.Height := 24; + end; + + fsGetLanguageList(LangCB.Items); + frxAddCodeRes; + + FUndoBuffer := TfrxUndoBuffer.Create; + FUndoBuffer.PictureCache := FPictureCache; + + FClipboard := TfrxClipboard.Create(Self); + FClipboard.PictureCache := FPictureCache; + Timer.Enabled := True; + + FRecentFiles := TStringList.Create; + FRecentMenuIndex := FileMenu.IndexOf(SepMI4); +{$IFDEF Delphi5} + MainMenu.AutoHotKeys := maManual; +{$ENDIF} + + FSampleFormat := TSampleFormat.Create; + FPagePositions := TStringList.Create; + for i := 1 to 256 do + FPagePositions.Add(''); + + if IsPreviewDesigner then + begin + FOldDesignerComp := frxDesignerComp; + TfrxDesigner.Create(nil); + frxDesignerComp.Restrictions := [drDontDeletePage, drDontCreatePage, + drDontCreateReport, drDontLoadReport, drDontPreviewReport, + drDontEditVariables, drDontChangeReportOptions]; + ObjectBandB.Enabled := False; + end; + + Report.SelectPrinter; + FontNameCB.PopulateList; + +{$IFDEF FR_VER_BASIC} + NewDialogCmd.Enabled := False; +{$ENDIF} + + NewReportCmd.Enabled := CheckOp(drDontCreateReport); + NewItemCmd.Enabled := CheckOp(drDontCreateReport); + NewPageCmd.Enabled := CheckOp(drDontCreatePage); + NewDialogCmd.Enabled := NewDialogCmd.Enabled and CheckOp(drDontCreatePage); + SaveAsCmd.Enabled := CheckOp(drDontSaveReport); + OpenCmd.Enabled := CheckOp(drDontLoadReport); + ReportOptionsCmd.Enabled := CheckOp(drDontChangeReportOptions); + ReportStylesCmd.Enabled := CheckOp(drDontChangeReportOptions); + ReportDataCmd.Enabled := CheckOp(drDontEditReportData); + VariablesCmd.Enabled := CheckOp(drDontEditVariables); + PreviewCmd.Enabled := CheckOp(drDontPreviewReport); +end; + +procedure TfrxDesignerForm.Done; +begin + AttachDialogFormEvents(False); + if IsPreviewDesigner then + begin + frxDesignerComp.Free; + frxDesignerComp := FOldDesignerComp; + end; + + FPictureCache.Free; + FUndoBuffer.Free; + FClipboard.Free; + FRecentFiles.Free; + FSampleFormat.Free; + FPagePositions.Free; +end; + +procedure TfrxDesignerForm.ReadButtonImages; +var + MainImages, DisabledImages, ObjectImages: TImageList; +begin + MainImages := frxResources.MainButtonImages; + DisabledImages := frxResources.DisabledButtonImages; + ObjectImages := frxResources.ObjectImages; + + CodeTB.Images := MainImages; + CodeTB.DisabledImages := DisabledImages; + + StandardTB.Images := MainImages; + StandardTB.DisabledImages := DisabledImages; + + TextTB.Images := MainImages; + TextTB.DisabledImages := DisabledImages; + + FrameTB.Images := MainImages; + FrameTB.DisabledImages := DisabledImages; + + AlignTB.Images := MainImages; + AlignTB.DisabledImages := DisabledImages; + + ExtraToolsTB.Images := MainImages; + ExtraToolsTB.DisabledImages := DisabledImages; + + ObjectsTB1.Images := ObjectImages; + ObjectsPopup.Images := ObjectImages; + MainMenu.Images := MainImages; + PagePopup.Images := MainImages; + TabPopup.Images := MainImages; + ActionList.Images := MainImages; + BandsPopup.Images := MainImages; + +{$IFDEF Delphi10} + if (frxDesignerComp <> nil) and (frxDesignerComp.Gradient) then + begin + StandardTB.DrawingStyle := ComCtrls.dsGradient; + StandardTB.GradientStartColor := frxDesignerComp.GradientStart; + StandardTB.GradientEndColor := frxDesignerComp.GradientEnd; + TextTB.DrawingStyle := ComCtrls.dsGradient; + TextTB.GradientStartColor := frxDesignerComp.GradientStart; + TextTB.GradientEndColor := frxDesignerComp.GradientEnd; + FrameTB.DrawingStyle := ComCtrls.dsGradient; + FrameTB.GradientStartColor := frxDesignerComp.GradientStart; + FrameTB.GradientEndColor := frxDesignerComp.GradientEnd; + AlignTB.DrawingStyle := ComCtrls.dsGradient; + AlignTB.GradientStartColor := frxDesignerComp.GradientStart; + AlignTB.GradientEndColor := frxDesignerComp.GradientEnd; + ExtraToolsTB.DrawingStyle := ComCtrls.dsGradient; + ExtraToolsTB.GradientStartColor := frxDesignerComp.GradientStart; + ExtraToolsTB.GradientEndColor := frxDesignerComp.GradientEnd; + ObjectsTB1.DrawingStyle := ComCtrls.dsGradient; + ObjectsTB1.GradientStartColor := frxDesignerComp.GradientStart; + ObjectsTB1.GradientEndColor := frxDesignerComp.GradientEnd; + DockTop.DrawingStyle := dsGradient; + DockTop.GradientStartColor := frxDesignerComp.GradientStart; + DockTop.GradientEndColor := frxDesignerComp.GradientEnd; + DockBottom.DrawingStyle := dsGradient; + DockBottom.GradientStartColor := frxDesignerComp.GradientStart; + DockBottom.GradientEndColor := frxDesignerComp.GradientEnd; + end; +{$ENDIF} +{$IFDEF Delphi11} + StandardTB.Transparent := False; + AlignTB.Transparent := False; + TextTB.Transparent := False; + FrameTB.Transparent := False; + ExtraToolsTB.Transparent := False; + ObjectsTB1.Transparent := False; +{$ENDIF} +end; + +procedure TfrxDesignerForm.CreateToolWindows; +begin + FInspector := TfrxObjectInspector.Create(Self); + with FInspector do + begin + OnModify := Self.OnModify; + OnSelectionChanged := Self.OnSelectionChanged; + OnStartDock := OnDisableDock; + OnEndDock := OnEnableDock; + SelectedObjects := FSelectedObjects; + end; + + FDataTree := TfrxDataTreeForm.Create(Self); + with FDataTree do + begin + Report := Self.Report; + CBPanel.Visible := True; + OnDblClick := OnDataTreeDblClick; + OnStartDock := OnDisableDock; + OnEndDock := OnEnableDock; + end; + UpdateDataTree; + + FReportTree := TfrxReportTreeForm.Create(Self); + FReportTree.OnSelectionChanged := OnSelectionChanged; + FReportTree.OnStartDock := OnDisableDock; + FReportTree.OnEndDock := OnEnableDock; + + FWatchList := TfrxWatchForm.Create(Self); + FWatchList.Script := Report.Script; +end; + +procedure TfrxDesignerForm.CreateWorkspace; +begin + FWorkspace := TDesignerWorkspace.Create(Self); + with FWorkspace do + begin + Parent := ScrollBox; + OnNotifyPosition := Self.OnNotifyPosition; + OnInsert := OnInsertObject; + OnEdit := OnEditObject; + OnModify := Self.OnModify; + OnSelectionChanged := Self.OnSelectionChanged; + OnTopLeftChanged := ScrollBoxResize; + PopupMenu := PagePopup; + Objects := FObjects; + SelectedObjects := FSelectedObjects; + end; + + FCodeWindow := TfrxSyntaxMemo.Create(Self); + with FCodeWindow do + begin + Parent := CodePanel; + Align := alClient; +{$IFDEF UseTabset} + BevelKind := bkFlat; +{$ELSE} + BorderStyle := bsSingle; +{$ENDIF} + Lines := Report.ScriptText; + Color := clWindow; + OnChangeText := OnCodeChanged; + OnChangePos := OnChangePosition; + OnDragOver := CodeWindowDragOver; + OnDragDrop := CodeWindowDragDrop; + OnCodeCompletion := Self.OnCodeCompletion; + end; + +{$IFDEF UseTabset} + FTabs := TTabSet.Create(Self); + FTabs.ShrinkToFit := True; + FTabs.Style := tsSoftTabs; + FTabs.TabPosition := tpTop; + FTabs.OnClick := TabChange; + FTabs.OnChange := TabSetChange; +{$ELSE} + FTabs := TTabControl.Create(Self); + FTabs.OnChange := TabChange; + FTabs.OnChanging := TabChanging; +{$ENDIF} + FTabs.OnDragDrop := TabDragDrop; + FTabs.OnDragOver := TabDragOver; + FTabs.OnMouseDown := TabMouseDown; + FTabs.OnMouseMove := TabMouseMove; + FTabs.OnMouseUp := TabMouseUp; + FTabs.Parent := TabPanel; + FTabs.Align := alTop; +{$IFDEF UseTabset} + FTabs.Height := 22; + Panel1.SetBounds(0, FTabs.Height, 2000, 2); +{$ELSE} + if Screen.PixelsPerInch > 96 then + FTabs.Height := 25 + else + FTabs.Height := 21; + Panel1.BringToFront; + Panel1.SetBounds(0, FTabs.Height, 2000, 2); + FTabs.Height := FTabs.Height + 2; +{$ENDIF} +end; + +procedure TfrxDesignerForm.CreateObjectsToolbar; +var + i: Integer; + Item: TfrxObjectItem; + + function HasButtons(Item: TfrxObjectItem): Boolean; + var + i: Integer; + Item1: TfrxObjectItem; + begin + Result := False; + for i := 0 to frxObjects.Count - 1 do + begin + Item1 := frxObjects[i]; + if (Item1.ClassRef <> nil) and (Item1.CategoryName = Item.CategoryName) then + Result := True; + end; + end; + + procedure CreateButton(Index: Integer; Item: TfrxObjectItem); + var + b: TToolButton; + s: String; + begin + b := TToolButton.Create(ObjectsTB1); + b.Parent := ObjectsTB1; + b.Style := tbsCheck; + b.ImageIndex := Item.ButtonImageIndex; + b.Grouped := True; + s := Item.ButtonHint; + if s = '' then + begin + if Item.ClassRef <> nil then + s := Item.ClassRef.GetDescription; + end + else + s := frxResources.Get(s); + b.Hint := s; + b.Tag := Index; + if Item.ClassRef = nil then { category } + if not HasButtons(Item) then + begin + b.Free; + Exit; + end; + b.OnClick := ObjectsButtonClick; + b.Wrap := True; + {$IFDEF FR_LITE} + if Item.CategoryName = 'Other' then + begin + b.Enabled := False; + b.Hint := b.Hint + #13#10 + 'This feature is not available in FreeReport'; + end; + {$ENDIF} + end; + +begin + { add category buttons } + for i := frxObjects.Count - 1 downto 0 do + begin + Item := frxObjects[i]; + if (Item.ButtonBmp <> nil) and (Item.ButtonImageIndex = -1) then + begin + frxResources.SetObjectImages(Item.ButtonBmp); + Item.ButtonImageIndex := frxResources.ObjectImages.Count - 1; + end; + if Item.ClassRef = nil then + CreateButton(i, Item); + end; + + { add object buttons } + for i := frxObjects.Count - 1 downto 0 do + begin + Item := frxObjects[i]; + if (Item.ButtonBmp <> nil) and (Item.ButtonImageIndex = -1) then + begin + frxResources.SetObjectImages(Item.ButtonBmp); + Item.ButtonImageIndex := frxResources.ObjectImages.Count - 1; + end; + + if (Item.ClassRef <> nil) and (Item.CategoryName = '') then + CreateButton(i, Item); + end; + + ObjectBandB := TToolButton.Create(Self); + with ObjectBandB do + begin + Parent := ObjectsTB1; + Tag := 1000; + Grouped := True; + ImageIndex := 1; + Style := tbsCheck; + OnClick := ObjectBandBClick; + Wrap := True; + end; + + FormatToolB := TToolButton.Create(Self); + with FormatToolB do + begin + Parent := ObjectsTB1; + Tag := 1000; + Grouped := True; + ImageIndex := 30; + Style := tbsCheck; + OnClick := SelectToolBClick; + Wrap := True; + end; + + TextToolB := TToolButton.Create(Self); + with TextToolB do + begin + Parent := ObjectsTB1; + Tag := 1000; + Grouped := True; + ImageIndex := 29; + Style := tbsCheck; + OnClick := SelectToolBClick; + Wrap := True; + end; + + ZoomToolB := TToolButton.Create(Self); + with ZoomToolB do + begin + Parent := ObjectsTB1; + Tag := 1000; + Grouped := True; + ImageIndex := 28; + Style := tbsCheck; + OnClick := SelectToolBClick; + Wrap := True; + end; + + HandToolB := TToolButton.Create(Self); + with HandToolB do + begin + Parent := ObjectsTB1; + Tag := 1000; + Grouped := True; + ImageIndex := 27; + Style := tbsCheck; + OnClick := SelectToolBClick; + Wrap := True; + end; + + ObjectSelectB := TToolButton.Create(Self); + with ObjectSelectB do + begin + Parent := ObjectsTB1; + Down := True; + Grouped := True; + ImageIndex := 0; + Style := tbsCheck; + OnClick := SelectToolBClick; + Wrap := True; + end; +end; + +procedure TfrxDesignerForm.CreateExtraToolbar; +var + i: Integer; + Item: TfrxWizardItem; + b: TToolButton; +begin + for i := 0 to frxWizards.Count - 1 do + begin + Item := frxWizards[i]; + if Item.IsToolbarWizard then + begin + b := TToolButton.Create(Self); + with b do + begin + Tag := i; + if (Item.ButtonBmp <> nil) and (Item.ButtonImageIndex = -1) then + begin + frxResources.SetButtonImages(Item.ButtonBmp); + Item.ButtonImageIndex := frxResources.MainButtonImages.Count - 1; + end; + ImageIndex := Item.ButtonImageIndex; + Hint := Item.ClassRef.GetDescription; + SetBounds(1000, 0, 22, 22); + Parent := ExtraToolsTB; + end; + b.OnClick := OnExtraToolClick; + end; + end; + + ExtraToolsTB.Height := 27; + ExtraToolsTB.Width := 27; +end; + +procedure TfrxDesignerForm.AttachDialogFormEvents(Attach: Boolean); +begin + if Attach then + begin + FDialogForm.Parent := GetParentForm(DockTop); + FDialogForm.OnModify := DialogFormModify; + FDialogForm.OnKeyDown := DialogFormKeyDown; + FDialogForm.OnKeyUp := DialogFormKeyUp; + FDialogForm.OnKeyPress := DialogFormKeyPress; + end + else + if FDialogForm <> nil then + begin + FWorkspace.Parent := nil; + FDialogForm.Parent := nil; + FDialogForm.Hide; + FDialogForm.OnModify := nil; + FDialogForm.OnKeyDown := nil; + FDialogForm.OnKeyUp := nil; + FDialogForm.OnKeyPress := nil; + FDialogForm := nil; + end; +end; + +procedure TfrxDesignerForm.ReloadReport; +var + i: Integer; + l: TList; + c: TfrxComponent; + p: TfrxPage; + isDMP: Boolean; +begin + if Report.PagesCount = 0 then + begin + isDMP := Report.DotMatrixReport; + p := TfrxDataPage.Create(Report); + p.Name := 'Data'; + if isDMP then + p := TfrxDMPPage.Create(Report) + else + p := TfrxReportPage.Create(Report); + p.Name := 'Page1'; + end; + + if not IsPreviewDesigner then + Report.CheckDataPage; + + LangCB.ItemIndex := LangCB.Items.IndexOf(Report.ScriptLanguage); + CodeWindow.Lines := Report.ScriptText; + UpdateSyntaxType; + ReloadPages(-2); + UpdateRecentFiles(Report.FileName); + UpdateCaption; + UpdateStyles; + + FPictureCache.Clear; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxPictureView then + FPictureCache.AddPicture(TfrxPictureView(c)); + end; + + FUndoBuffer.ClearUndo; + Modified := False; +end; + +procedure TfrxDesignerForm.ReloadPages(Index: Integer); +var + i: Integer; + c: TfrxPage; + s: String; +begin + FDialogForm := nil; + FTabs.Tabs.BeginUpdate; + FTabs.Tabs.Clear; + FTabs.Tabs.Add(frxResources.Get('dsCode')); + + for i := 0 to Report.PagesCount - 1 do + begin + c := Report.Pages[i]; + c.IsDesigning := True; + if (c is TfrxReportPage) and (TfrxReportPage(c).Subreport <> nil) then + s := TfrxReportPage(c).Subreport.Name + else if c is TfrxDataPage then + s := frxResources.Get('dsData') + else if c.Name = '' then + s := frxResources.Get('dsPage') + IntToStr(i + 1) else + s := c.Name; + FTabs.Tabs.Add(s); + end; + + FTabs.Tabs.EndUpdate; + + if Index = -1 then + Page := nil + else if Index = -2 then + begin + for i := 0 to Report.PagesCount - 1 do + begin + c := Report.Pages[i]; + if not (c is TfrxDataPage) then + begin + Page := c; + break; + end; + end; + end + else if Index < Report.PagesCount then + Page := Report.Pages[Index] else + Page := Report.Pages[0]; +end; + +procedure TfrxDesignerForm.ReloadObjects; +var + i: Integer; +begin + FObjects.Clear; + FSelectedObjects.Clear; + + for i := 0 to FPage.AllObjects.Count - 1 do + FObjects.Add(FPage.AllObjects[i]); + + FObjects.Add(Report); + FObjects.Add(FPage); + FSelectedObjects.Add(FPage); + FWorkspace.Page := FPage; + FWorkspace.EnableUpdate; + FWorkspace.AdjustBands; + + FInspector.EnableUpdate; + + UpdateDataTree; + FReportTree.UpdateItems; + OnSelectionChanged(Self); +end; + +procedure TfrxDesignerForm.SetReportDefaults; +begin + if frxDesignerComp <> nil then + begin + Report.ScriptLanguage := frxDesignerComp.DefaultScriptLanguage; + frxEmptyCode(CodeWindow.Lines, Report.ScriptLanguage); + UpdateSyntaxType; + LangCB.ItemIndex := LangCB.Items.IndexOf(Report.ScriptLanguage); + + with TfrxReportPage(Report.Pages[1]) do + begin + LeftMargin := frxDesignerComp.DefaultLeftMargin; + BottomMargin := frxDesignerComp.DefaultBottomMargin; + RightMargin := frxDesignerComp.DefaultRightMargin; + TopMargin := frxDesignerComp.DefaultTopMargin; + PaperSize := frxDesignerComp.DefaultPaperSize; + Orientation := frxDesignerComp.DefaultOrientation; + end; + end + else + begin + Report.ScriptLanguage := 'PascalScript'; + frxEmptyCode(CodeWindow.Lines, Report.ScriptLanguage); + UpdateSyntaxType; + LangCB.ItemIndex := LangCB.Items.IndexOf(Report.ScriptLanguage); + + TfrxReportPage(Report.Pages[1]).SetDefaults; + end; +end; + +procedure TfrxDesignerForm.UpdatePageDimensions; +var + h: Extended; +begin + if FPage is TfrxReportPage then + begin + with FPage as TfrxReportPage do + begin + ScrollBox.HorzScrollBar.Position := 0; + ScrollBox.VertScrollBar.Position := 0; + + FWorkspace.Origin := Point(10, 10); + h := PaperHeight; + if LargeDesignHeight then + h := h * 5; + FWorkspace.SetPageDimensions( + Round(PaperWidth * 96 / 25.4), + Round(h * 96 / 25.4), + Rect(Round(LeftMargin * 96 / 25.4), Round(TopMargin * 96 / 25.4), + Round(RightMargin * 96 / 25.4), Round(BottomMargin * 96 / 25.4))); + end; + end + else if FPage is TfrxDataPage then + begin + ScrollBox.HorzScrollBar.Position := 0; + ScrollBox.VertScrollBar.Position := 0; + + FWorkspace.Origin := Point(0, 0); + FWorkspace.SetPageDimensions( + Round(FPage.Width), + Round(FPage.Height), + Rect(0, 0, 0, 0)); + end; +end; + +procedure TfrxDesignerForm.UpdateControls; +var + c: TfrxComponent; + p1, p2, p3: PPropInfo; + Count: Integer; + FontEnabled, AlignEnabled, IsReportPage: Boolean; + Frame1Enabled, Frame2Enabled, Frame3Enabled, ObjSelected, DMPEnabled: Boolean; + s: String; + Frame: TfrxFrame; + DMPFontStyle: TfrxDMPFontStyles; + + procedure SetEnabled(cAr: array of TControl; Enabled: Boolean); + var + i: Integer; + begin + for i := 0 to High(cAr) do + begin + cAr[i].Enabled := Enabled; + if (cAr[i] is TToolButton) and not Enabled then + TToolButton(cAr[i]).Down := False; + end; + end; + + procedure ButtonUp(cAr: array of TToolButton); + var + i: Integer; + begin + for i := 0 to High(cAr) do + cAr[i].Down := False; + end; + +begin + FUpdatingControls := True; + + Count := FSelectedObjects.Count; + if Count > 0 then + begin + c := FSelectedObjects[0]; + p1 := GetPropInfo(PTypeInfo(c.ClassInfo), 'Font'); + p2 := GetPropInfo(PTypeInfo(c.ClassInfo), 'Frame'); + p3 := GetPropInfo(PTypeInfo(c.ClassInfo), 'Color'); + end + else + begin + c := nil; + p1 := nil; + p2 := nil; + p3 := nil; + end; + + if Count = 1 then + begin + FontNameCB.Text := c.Font.Name; + FontSizeCB.Text := IntToStr(c.Font.Size); + + BoldB.Down := fsBold in c.Font.Style; + ItalicB.Down := fsItalic in c.Font.Style; + UnderlineB.Down := fsUnderline in c.Font.Style; + + if c is TfrxCustomMemoView then + with TfrxCustomMemoView(c) do + begin + TextAlignLeftB.Down := HAlign = haLeft; + TextAlignCenterB.Down := HAlign = haCenter; + TextAlignRightB.Down := HAlign = haRight; + TextAlignBlockB.Down := HAlign = haBlock; + + TextAlignTopB.Down := VAlign = vaTop; + TextAlignMiddleB.Down := VAlign = vaCenter; + TextAlignBottomB.Down := VAlign = vaBottom; + if not (c is TfrxDMPMemoView) then + if Style = '' then + StyleCB.Text := StyleCB.Items[0] else + StyleCB.Text := Style; + end; + + Frame := nil; + if c is TfrxView then + Frame := TfrxView(c).Frame + else if c is TfrxReportPage then + Frame := TfrxReportPage(c).Frame; + + if Frame <> nil then + with Frame do + begin + FrameTopB.Down := ftTop in Typ; + FrameBottomB.Down := ftBottom in Typ; + FrameLeftB.Down := ftLeft in Typ; + FrameRightB.Down := ftRight in Typ; + ShadowB.Down := DropShadow; + + FrameWidthCB.Text := FloatToStr(Width); + end; + end + else + begin + FontNameCB.Text := ''; + FontSizeCB.Text := ''; + FrameWidthCB.Text := ''; + + ButtonUp([BoldB, ItalicB, UnderlineB, TextAlignLeftB, TextAlignCenterB, + TextAlignRightB, TextAlignBlockB, TextAlignTopB, TextAlignMiddleB, + TextAlignBottomB, FrameTopB, FrameBottomB, FrameLeftB, + FrameRightB, ShadowB]); + end; + + FontEnabled := (p1 <> nil) and not (c is TfrxDMPPage) and (FPage <> nil); + AlignEnabled := (c is TfrxCustomMemoView) and (FPage <> nil); + Frame1Enabled := (p2 <> nil) and not (c is TfrxLineView) and + not (c is TfrxShapeView) and not (c is TfrxDMPPage) and (FPage <> nil); + Frame2Enabled := (p2 <> nil) and not (c is TfrxDMPPage) and (FPage <> nil); + Frame3Enabled := (p3 <> nil) and not (c is TfrxDMPPage) and (FPage <> nil); + IsReportPage := FPage is TfrxReportPage; + ObjSelected := (Count <> 0) and (FPage <> nil) and (FSelectedObjects[0] <> FPage); + DMPEnabled := (c is TfrxDMPMemoView) or (c is TfrxDMPLineView) or + (c is TfrxDMPCommand) or (c is TfrxDMPPage); + + SetEnabled([FontNameCB, FontSizeCB, BoldB, ItalicB, UnderlineB, FontColorB], + (FontEnabled or (Count > 1)) and not (FPage is TfrxDMPPage)); + SetEnabled([FontB], (FontEnabled or DMPEnabled or (Count > 1))); + SetEnabled([TextAlignLeftB, TextAlignCenterB, TextAlignRightB, + TextAlignBlockB, TextAlignTopB, TextAlignMiddleB, TextAlignBottomB], + AlignEnabled or (Count > 1)); + SetEnabled([StyleCB, HighlightB, RotateB], + (AlignEnabled or (Count > 1)) and not (FPage is TfrxDMPPage)); + SetEnabled([FrameTopB, FrameBottomB, FrameLeftB, FrameRightB, FrameAllB, + FrameNoB, ShadowB], Frame1Enabled or (Count > 1)); + SetEnabled([FrameColorB, FrameStyleB, FrameWidthCB], + (Frame2Enabled or (Count > 1)) and not (FPage is TfrxDMPPage)); + SetEnabled([FillColorB], Frame3Enabled and not (FPage is TfrxDMPPage)); + if Report.DotMatrixReport then + begin + FontB.DropDownMenu := DMPPopup; + FontB.OnClick := nil; + end + else + begin + FontB.DropDownMenu := nil; + FontB.OnClick := ToolButtonClick; + end; + + DMPFontStyle := []; + if c is TfrxDMPMemoView then + DMPFontStyle := TfrxDMPMemoView(c).FontStyle; + if c is TfrxDMPLineView then + DMPFontStyle := TfrxDMPLineView(c).FontStyle; + if c is TfrxDMPPage then + DMPFontStyle := TfrxDMPPage(c).FontStyle; + + BoldMI.Checked := fsxBold in DMPFontStyle; + ItalicMI.Checked := fsxItalic in DMPFontStyle; + UnderlineMI.Checked := fsxUnderline in DMPFontStyle; + SuperScriptMI.Checked := fsxSuperScript in DMPFontStyle; + SubScriptMI.Checked := fsxSubScript in DMPFontStyle; + CondensedMI.Checked := fsxCondensed in DMPFontStyle; + WideMI.Checked := fsxWide in DMPFontStyle; + N12cpiMI.Checked := fsx12cpi in DMPFontStyle; + N15cpiMI.Checked := fsx15cpi in DMPFontStyle; + + UndoCmd.Enabled := (FUndoBuffer.UndoCount > 1) or (FPage = nil); + RedoCmd.Enabled := (FUndoBuffer.RedoCount > 0) and (FPage <> nil); + CutCmd.Enabled := ((Count <> 0) and (FSelectedObjects[0] <> FPage)) or (FPage = nil); + CopyCmd.Enabled := CutCmd.Enabled; + TimerTimer(nil); + + PageSettingsCmd.Enabled := IsReportPage and CheckOp(drDontChangePageOptions); + DeletePageCmd.Enabled := (Report.PagesCount > 2) and (FPage <> nil) and + not (FPage is TfrxDataPage) and CheckOp(drDontDeletePage) and + not Page.IsAncestor; + SaveCmd.Enabled := Modified and CheckOp(drDontSaveReport); + DeleteCmd.Enabled := ObjSelected; + SelectAllCmd.Enabled := (FObjects.Count > 2) or (FPage = nil); + EditCmd.Enabled := (Count = 1) and (FPage <> nil); + SetToGridB.Enabled := ObjSelected; + BringToFrontCmd.Enabled := ObjSelected; + SendToBackCmd.Enabled := ObjSelected; + GroupCmd.Enabled := ObjSelected and (FSelectedObjects[0] <> Report); + UngroupCmd.Enabled := GroupCmd.Enabled; + ScaleCB.Enabled := IsReportPage; + + SetEnabled([HandToolB, ZoomToolB, TextToolB], IsReportPage); + TabOrderMI.Visible := FPage is TfrxDialogPage; + + if Count <> 1 then + s := '' + else + begin + s := c.Name; + if c is TfrxView then + if TfrxView(c).IsDataField then + s := s + ': ' + Report.GetAlias(TfrxView(c).DataSet) + '."' + TfrxView(c).DataField + '"' + else if c is TfrxCustomMemoView then + s := s + ': ' + Copy(TfrxCustomMemoView(c).Text, 1, 128); + if c is TfrxDataBand then + if TfrxDataBand(c).DataSet <> nil then + s := s + ': ' + Report.GetAlias(TfrxDataBand(c).DataSet); + if c is TfrxGroupHeader then + s := s + ': ' + TfrxGroupHeader(c).Condition + end; + + StatusBar.Panels[2].Text := s; + + FUpdatingControls := False; +end; + +procedure TfrxDesignerForm.UpdateDataTree; +begin + FDataTree.UpdateItems; +end; + +procedure TfrxDesignerForm.UpdateStyles; +begin + Report.Styles.GetList(StyleCB.Items); + StyleCB.Items.Insert(0, frxResources.Get('dsNoStyle')); +end; + +procedure TfrxDesignerForm.UpdateSyntaxType; +begin + CodeWindow.Syntax := Report.ScriptLanguage; + if CompareText(Report.ScriptLanguage, 'PascalScript') = 0 then + begin + OpenScriptDialog.FilterIndex := 1; + OpenScriptDialog.DefaultExt := 'pas'; + SaveScriptDialog.FilterIndex := 1; + SaveScriptDialog.DefaultExt := 'pas'; + end + else if CompareText(Report.ScriptLanguage, 'C++Script') = 0 then + begin + OpenScriptDialog.FilterIndex := 2; + OpenScriptDialog.DefaultExt := 'cpp'; + SaveScriptDialog.FilterIndex := 2; + SaveScriptDialog.DefaultExt := 'cpp'; + end + else if CompareText(Report.ScriptLanguage, 'JScript') = 0 then + begin + OpenScriptDialog.FilterIndex := 3; + OpenScriptDialog.DefaultExt := 'js'; + SaveScriptDialog.FilterIndex := 3; + SaveScriptDialog.DefaultExt := 'js'; + end + else if CompareText(Report.ScriptLanguage, 'BasicScript') = 0 then + begin + OpenScriptDialog.FilterIndex := 4; + OpenScriptDialog.DefaultExt := 'vb'; + SaveScriptDialog.FilterIndex := 4; + SaveScriptDialog.DefaultExt := 'vb'; + end + else + begin + OpenScriptDialog.FilterIndex := 5; + OpenScriptDialog.DefaultExt := ''; + SaveScriptDialog.FilterIndex := 5; + SaveScriptDialog.DefaultExt := ''; + end +end; + +procedure TfrxDesignerForm.FindOrReplace(replace: Boolean); +begin + with TfrxSearchDialog.Create(Application) do + begin + FSearchReplace := replace; + if FSearchReplace then + ReplacePanel.Show; + if Page <> nil then + TopCB.Enabled := False; + if ShowModal = mrOk then + begin + FSearchText := TextE.Text; + FSearchReplaceText := ReplaceE.Text; + FSearchCase := CaseCB.Checked; + FSearchIndex := 0; + if (Page = nil) and not TopCB.Checked then + FSearchIndex := CodeWindow.GetPlainPos; + FindNextCmd.Enabled := True; + FindText; + end; + Free; + end; +end; + +procedure TfrxDesignerForm.Lock; +begin + FObjects.Clear; + FSelectedObjects.Clear; + AttachDialogFormEvents(False); + FWorkspace.DisableUpdate; + FInspector.DisableUpdate; +end; + +procedure TfrxDesignerForm.CreateColorSelector(Sender: TToolButton); +var + AColor: TColor; + i: Integer; +begin + AColor := clBlack; + for i := 0 to SelectedObjects.Count - 1 do + if TObject(SelectedObjects[i]) is TfrxView then + begin + if Sender = FontColorB then + AColor := TfrxView(SelectedObjects[i]).Font.Color + else if Sender = FrameColorB then + AColor := TfrxView(SelectedObjects[i]).Frame.Color + else + AColor := TfrxView(SelectedObjects[i]).Color; + break; + end; + + with TfrxColorSelector.Create(Sender) do + begin + Color := AColor; + OnColorChanged := Self.OnColorChanged; + end; +end; + +procedure TfrxDesignerForm.SwitchToCodeWindow; +begin + Page := nil; +end; + +function TfrxDesignerForm.AskSave: Word; +begin + if IsPreviewDesigner then + Result := frxConfirmMsg(frxResources.Get('dsSavePreviewChanges'), mb_YesNoCancel) + else + Result := frxConfirmMsg(frxResources.Get('dsSaveChangesTo') + ' ' + + GetReportName + '?', mb_YesNoCancel); +end; + +function TfrxDesignerForm.CheckOp(Op: TfrxDesignerRestriction): Boolean; +begin + Result := True; + if (frxDesignerComp <> nil) and (Op in frxDesignerComp.Restrictions) then + Result := False; +end; + +function TfrxDesignerForm.GetPageIndex: Integer; +begin + Result := Report.Objects.IndexOf(FPage); +end; + +function TfrxDesignerForm.GetReportName: String; +begin + if Report.FileName = '' then + Result := 'Untitled.fr3' else + Result := ExtractFileName(Report.FileName); +end; + +procedure TfrxDesignerForm.LoadFile(FileName: String; UseOnLoadEvent: Boolean); +var + SaveSilentMode: Boolean; + + function SaveCurrentFile: Boolean; + var + w: Word; + begin + Result := True; + if Modified then + begin + w := AskSave; + if w = mrYes then + SaveFile(False, UseOnLoadEvent) + else if w = mrCancel then + Result := False; + end; + end; + + procedure EmptyReport; + var + p: TfrxPage; + begin + Report.Clear; + p := TfrxDataPage.Create(Report); + p.Name := 'Data'; + p := TfrxReportPage.Create(Report); + p.Name := 'Page1'; + end; + + procedure Error; + begin + frxErrorMsg(frxResources.Get('dsCantLoad')); + end; + +begin + SaveSilentMode := Report.EngineOptions.SilentMode; + Report.EngineOptions.SilentMode := False; + + if FileName <> '' then // call from recent filelist + begin + if SaveCurrentFile then + begin + Lock; + try + if not Report.LoadFromFile(FileName) then + Error; + except + EmptyReport; + end; + end; + Report.EngineOptions.SilentMode := SaveSilentMode; + ReloadReport; + Exit; + end; + + if UseOnLoadEvent then + if (frxDesignerComp <> nil) and Assigned(frxDesignerComp.FOnLoadReport) then + begin + Lock; + if frxDesignerComp.FOnLoadReport(Report) then + ReloadReport else + ReloadPages(-2); + Report.EngineOptions.SilentMode := SaveSilentMode; + Exit; + end; + + if frxDesignerComp <> nil then + OpenDialog.InitialDir := frxDesignerComp.OpenDir; + if OpenDialog.Execute then + begin + if SaveCurrentFile then + begin + Lock; + try + Report.LoadFromFile(OpenDialog.FileName); + except + Error; + EmptyReport; + end; + end; + Report.EngineOptions.SilentMode := SaveSilentMode; + ReloadReport; + end; +end; + +function TfrxDesignerForm.SaveFile(SaveAs: Boolean; UseOnSaveEvent: Boolean): Boolean; +var + Saved: Boolean; +begin + Result := True; + Report.ScriptText := CodeWindow.Lines; + Report.ReportOptions.LastChange := Now; + + if UseOnSaveEvent then + if (frxDesignerComp <> nil) and Assigned(frxDesignerComp.FOnSaveReport) then + begin + if frxDesignerComp.FOnSaveReport(Report, SaveAs) then + begin + UpdateRecentFiles(Report.FileName); + UpdateCaption; + Modified := False; + end; + Exit; + end; + + Saved := True; + if SaveAs or (Report.FileName = '') then + begin + SaveDialog.DefaultExt := 'fr3'; + SaveDialog.Filter := frxResources.Get('dsRepFilter'); + if frxCompressorClass <> nil then + SaveDialog.Filter := SaveDialog.Filter + '|' + frxResources.Get('dsComprRepFilter'); + if Report.ReportOptions.Compressed then + SaveDialog.FilterIndex := 2 else + SaveDialog.FilterIndex := 1; + if frxDesignerComp <> nil then + SaveDialog.InitialDir := frxDesignerComp.SaveDir; + Saved := SaveDialog.Execute; + if Saved then + begin + Report.ReportOptions.Compressed := SaveDialog.FilterIndex = 2; + Report.FileName := SaveDialog.FileName; + Report.SaveToFile(Report.FileName); + end + end + else + Report.SaveToFile(Report.FileName); + + UpdateRecentFiles(Report.FileName); + UpdateCaption; + if Saved then + Modified := False; + Result := Saved; +end; + +procedure TfrxDesignerForm.UpdateCaption; +begin +{$IFDEF FR_LITE} + Caption := 'FreeReport - ' + GetReportName; +{$ELSE} + Caption := 'FastReport - ' + GetReportName; +{$ENDIF} +end; + +procedure TfrxDesignerForm.UpdateRecentFiles(NewFile: String); +var + i: Integer; + m: TMenuItem; +begin + if NewFile <> '' then + begin + if FRecentFiles.IndexOf(NewFile) <> -1 then + FRecentFiles.Delete(FRecentFiles.IndexOf(NewFile)); + FRecentFiles.Add(NewFile); + while FRecentFiles.Count > 8 do + FRecentFiles.Delete(0); + end; + + SepMI11.Visible := FRecentFiles.Count <> 0; + + for i := FileMenu.Count - 1 downto 0 do + begin + m := FileMenu.Items[i]; + if m.Tag = 100 then + m.Free; + end; + + if CheckOp(drDontShowRecentFiles) then + for i := FRecentFiles.Count - 1 downto 0 do + begin + m := TMenuItem.Create(FileMenu); + m.Caption := FRecentFiles[i]; + m.OnClick := OpenRecentFile; + m.Tag := 100; + FileMenu.Insert(FileMenu.IndexOf(SepMI4), m); + end; +end; + +procedure TfrxDesignerForm.SwitchToolbar; +var + i: Integer; + Item: TfrxObjectItem; + b: TToolButton; + Category: TfrxObjectCategories; + IsToolandBand: Boolean; + + function GetCategory(Category: Integer): TfrxObjectCategories; + var + i: Integer; + Item: TfrxObjectItem; + begin + Result := []; + for i := 0 to frxObjects.Count - 1 do + begin + Item := frxObjects[i]; + if (Item.ClassRef <> nil) and + (Item.CategoryName = frxObjects[Category].CategoryName) then + begin + Result := Item.Category; + break; + end; + end; + end; + +begin + ObjectSelectB.Down := True; + SelectToolBClick(nil); + + for i := ObjectsTB1.ControlCount - 1 downto 0 do + begin + b := TToolButton(ObjectsTB1.Controls[i]); + + if b <> ObjectSelectB then + begin + IsToolandBand := False; + Category := []; + + if b.Tag = 1000 then { tools and band } + IsToolandBand := True + else { object or category } + begin + Item := frxObjects[b.Tag]; + if Item.ClassRef <> nil then { object } + Category := Item.Category + else + Category := GetCategory(b.Tag); + end; + + if FPage is TfrxDialogPage then + b.Visible := ctDialog in Category + else if FPage is TfrxDMPPage then + b.Visible := (ctDMP in Category) or IsToolandBand + else if FPage is TfrxReportPage then + b.Visible := (ctReport in Category) or IsToolandBand + else if FPage is TfrxDataPage then + b.Visible := ctData in Category + else if FPage = nil then + b.Visible := False; + end; + end; +end; + +function TfrxDesignerForm.mmToUnits(mm: Extended; X: Boolean = True): Extended; +begin + Result := 0; + case FUnits of + duCM: + Result := mm / 10; + duInches: + Result := mm / 25.4; + duPixels: + Result := mm * 96 / 25.4; + duChars: + if X then + Result := Round(mm * fr01cm / fr1CharX) else + Result := Round(mm * fr01cm / fr1CharY); + end; +end; + +function TfrxDesignerForm.UnitsTomm(mm: Extended; X: Boolean = True): Extended; +begin + Result := 0; + case FUnits of + duCM: + Result := mm * 10; + duInches: + Result := mm * 25.4; + duPixels: + Result := mm / 96 * 25.4; + duChars: + if X then + Result := Round(mm) * fr1CharX / fr01cm else + Result := Round(mm) * fr1CharY / fr01cm; + end; +end; + +function TfrxDesignerForm.InsertExpression(const Expr: String): String; +begin + with TfrxExprEditorForm.Create(Self) do + begin + ExprMemo.Text := Expr; + if ShowModal = mrOk then + Result := ExprMemo.Text else + Result := ''; + Free; + end +end; + +procedure TfrxDesignerForm.UpdatePage; +begin + FWorkspace.Repaint; +end; + +procedure TfrxDesignerForm.FindText; +var + i: Integer; + c: TfrxComponent; + s: String; + Found, FoundOne: Boolean; + Flags: TReplaceFlags; + ReplaceAll: Boolean; + + function AskReplace: Boolean; + var + i: Integer; + begin + if not ReplaceAll then + i := MessageDlg(Format(frxResources.Get('dsReplace'), [FSearchText]), + mtConfirmation, [mbYes, mbNo, mbCancel, mbAll], 0) + else + i := mrAll; + Result := i in [mrYes, mrAll]; + ReplaceAll := i = mrAll; + +{ Result := Application.MessageBox( + PChar(Format(frxResources.Get('dsReplace'), [FSearchText])), + PChar(frxResources.Get('mbConfirm')), mb_IconQuestion + mb_YesNo) = mrYes;} + end; + +begin + ReplaceAll := False; + FoundOne := False; + + repeat + Found := False; + if FPage <> nil then + begin + c := nil; + for i := FSearchIndex to Objects.Count - 1 do + begin + c := Objects[i]; + if c is TfrxCustomMemoView then + begin + s := TfrxCustomMemoView(c).Text; + if FSearchCase then + begin + if Pos(FSearchText, s) <> 0 then + Found := True; + end + else if Pos(AnsiUpperCase(FSearchText), AnsiUpperCase(s)) <> 0 then + Found := True; + end; + if Found then break; + end; + + if Found then + begin + FSearchIndex := i + 1; + SelectedObjects.Clear; + SelectedObjects.Add(c); + OnSelectionChanged(Self); + if FSearchReplace then + if AskReplace then + begin + Flags := [rfReplaceAll]; + if not FSearchCase then + Flags := Flags + [rfIgnoreCase]; + TfrxCustomMemoView(c).Text := StringReplace(s, FSearchText, + FSearchReplaceText, Flags); + Modified := True; + end; + end; + end + else + begin + Found := CodeWindow.Find(FSearchText, FSearchCase, FSearchIndex); + if FSearchReplace then + if Found and AskReplace then + begin + CodeWindow.SelText := FSearchReplaceText; + Modified := True; + end; + end; + + if Found then + FoundOne := True; + until not ReplaceAll or not Found; + + if not FoundOne then + frxInfoMsg(Format(frxResources.Get('dsTextNotFound'), [FSearchText])); +end; + +procedure TfrxDesignerForm.RestorePagePosition; +var + pt: TPoint; +begin + if (FTabs.TabIndex > 0) and (FTabs.TabIndex < 255) then + begin + pt := fsPosToPoint(FPagePositions[FTabs.TabIndex]); + ScrollBox.VertScrollBar.Position := pt.X; + ScrollBox.HorzScrollBar.Position := pt.Y; + end; +end; + +procedure TfrxDesignerForm.SavePagePosition; +begin + if (FTabs.TabIndex > 0) and (FTabs.TabIndex < 255) then + FPagePositions[FTabs.TabIndex] := IntToStr(ScrollBox.HorzScrollBar.Position) + + ':' + IntToStr(ScrollBox.VertScrollBar.Position); +end; + + +{ Workspace/Inspector event handlers } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.OnModify(Sender: TObject); +begin + FModifiedBy := Sender; + Modified := True; +end; + +procedure TfrxDesignerForm.OnSelectionChanged(Sender: TObject); +var + c: TfrxComponent; +begin + if Sender = FReportTree then + begin + c := SelectedObjects[0]; + if (c <> Report) and (Page <> nil) then + if c.Page <> Page then + begin + Page := c.Page; + SelectedObjects[0] := c; + FReportTree.UpdateSelection; + end; + end + else + FReportTree.UpdateSelection; + + if Sender <> FWorkspace then + FWorkspace.UpdateView; + + if Sender <> FInspector then + begin + FInspector.Objects := FObjects; + FInspector.UpdateProperties; + end; + + FDataTree.UpdateSelection; + UpdateControls; +end; + +procedure TfrxDesignerForm.OnEditObject(Sender: TObject); +var + ed: TfrxComponentEditor; +begin + if FSelectedObjects[0] <> nil then + if rfDontEdit in TfrxComponent(FSelectedObjects[0]).Restrictions then + Exit; + + ed := frxComponentEditors.GetComponentEditor(FSelectedObjects[0], Self, nil); + if (ed <> nil) and ed.HasEditor then + if ed.Edit then + begin + Modified := True; + if FSelectedObjects[0] = FPage then + UpdatePageDimensions; + end; + ed.Free; +end; + +procedure TfrxDesignerForm.OnInsertObject(Sender: TObject); +var + c: TfrxComponent; + SaveLeft, SaveTop, SaveWidth, SaveHeight: Extended; + + function CheckContainers(Obj: TfrxComponent): Boolean; + var + i: Integer; + c: TfrxComponent; + begin + Result := False; + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if (c <> Obj) and (csContainer in c.frComponentStyle) then + if (Obj.Left >= c.AbsLeft) and (Obj.Top >= c.AbsTop) and + (Obj.Left + Obj.Width <= c.AbsLeft + c.Width) and + (Obj.Top + Obj.Height <= c.AbsTop + c.Height) then + begin + Result := c.ContainerAdd(Obj); + break; + end; + end; + end; + +begin + if not CheckOp(drDontInsertObject) or (FWorkspace.Insertion.Top < 0) then + begin + FWorkspace.SetInsertion(nil, 0, 0, 0); + ObjectSelectB.Down := True; + Exit; + end; + + with FWorkspace.Insertion do + begin + if (ComponentClass = nil) or ((Width = 0) and (Height = 0)) then Exit; + + SaveLeft := Left; + SaveTop := Top; + SaveWidth := Width; + SaveHeight := Height; + c := TfrxComponent(ComponentClass.NewInstance); + c.DesignCreate(FPage, Flags); + c.SetBounds(SaveLeft, SaveTop, SaveWidth, SaveHeight); + c.CreateUniqueName; + if c is TfrxCustomLineView then + FWorkspace.SetInsertion(ComponentClass, 0, 0, Flags) + else + begin + FWorkspace.SetInsertion(nil, 0, 0, 0); + if not TextToolB.Down then + ObjectSelectB.Down := True; + end; + + if c is TfrxCustomMemoView then + begin + FSampleFormat.ApplySample(TfrxCustomMemoView(c)); + if FPage is TfrxDataPage then + TfrxCustomMemoView(c).Wysiwyg := False; + end; + + if not CheckContainers(c) then + FObjects.Add(c); + FSelectedObjects.Clear; + FSelectedObjects.Add(c); + + if (frxDesignerComp <> nil) and Assigned(frxDesignerComp.FOnInsertObject) then + frxDesignerComp.FOnInsertObject(c); + + if c is TfrxSubreport then + begin + NewPageCmdExecute(Self); + TfrxSubreport(c).Page := TfrxReportPage(Report.Pages[Report.PagesCount - 1]); + ReloadPages(Report.PagesCount - 1); + end + else + begin + Modified := True; + if EditAfterInsert and not + ((c is TfrxDialogControl) or (c is TfrxDialogComponent)) then + OnEditObject(Self); + end; + + FWorkspace.BringToFront; + end; +end; + +procedure TfrxDesignerForm.OnNotifyPosition(ARect: TfrxRect); +var + dx, dy: Extended; +begin + with ARect do + begin + if FUnits = duCM then + begin + dx := 1 / 96 * 2.54; + dy := dx; + end + else if FUnits = duChars then + begin + dx := 1 / fr1CharX; + dy := 1 / fr1CharY; + end + else if FUnits = duPixels then + begin + dx := 1; + dy := dx; + end + else + begin + dx := 1 / 96; + dy := dx; + end; + + Left := Left * dx; + Top := Top * dy; + if FWorkspace.Mode <> dmScale then + begin + Right := Right * dx; + Bottom := Bottom * dy; + end; + + if FUnits = duChars then + begin + Left := Trunc(Left); + Top := Trunc(Top); + Right := Trunc(Right); + Bottom := Trunc(Bottom); + end; + + + FCoord1 := ''; + FCoord2 := ''; + FCoord3 := ''; + if (not FWorkspace.IsMouseDown) and (FWorkspace.Mode <> dmInsertObject) then + if (FSelectedObjects.Count > 0) and (FSelectedObjects[0] = FPage) then + FCoord1 := Format('%f; %f', [Left, Top]) + else + begin + FCoord1 := Format('%f; %f', [Left, Top]); + FCoord2 := Format('%f; %f', [Right, Bottom]); + end + else + case FWorkspace.Mode of + dmMove, dmSize, dmSizeBand, dmInsertObject, dmInsertLine: + begin + FCoord1 := Format('%f; %f', [Left, Top]); + FCoord2 := Format('%f; %f', [Right, Bottom]); + end; + + dmScale: + begin + FCoord1 := Format('%f; %f', [Left, Top]); + FCoord3 := Format('%s%f; %s%f', ['%', Right * 100, '%', Bottom * 100]); + end; + end; + end; + + LeftRuler.Position := ARect.Top; + TopRuler.Position := ARect.Left; + + if FPage = nil then + OnChangePosition(Self); + + StatusBar.Repaint; +end; + + +{ Toolbar buttons' events } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.SelectToolBClick(Sender: TObject); +var + t: TfrxDesignTool; +begin + t := dtSelect; + if HandToolB.Down then + t := dtHand + else if ZoomToolB.Down then + t := dtZoom + else if TextToolB.Down then + t := dtText + else if FormatToolB.Down then + t := dtFormat; + + TDesignerWorkspace(FWorkspace).Tool := t; + FWorkspace.SetInsertion(nil, 0, 0, 0); +end; + +procedure TfrxDesignerForm.ObjectBandBClick(Sender: TObject); +var + pt: TPoint; +begin + pt := TControl(Sender).ClientToScreen(Point(TControl(Sender).Width, 0)); + BandsPopup.Popup(pt.X, pt.Y); +end; + +procedure TfrxDesignerForm.ObjectsButtonClick(Sender: TObject); +var + i: Integer; + Obj, Item: TfrxObjectItem; + c: TfrxComponent; + dx, dy: Extended; + m: TMenuItem; + pt: TPoint; + s: String; +begin + SelectToolBClick(Sender); + if Page = nil then Exit; + Obj := frxObjects[TComponent(Sender).Tag]; + + if Obj.ClassRef = nil then { it's a category } + begin + while ObjectsPopup.Items.Count > 0 do + ObjectsPopup.Items[0].Free; + + for i := 0 to frxObjects.Count - 1 do + begin + Item := frxObjects[i]; + if (Item.ClassRef <> nil) and (Item.CategoryName = Obj.CategoryName) then + begin + if FPage is TfrxDMPPage then + if not ((Item.ClassRef.ClassName = 'TfrxCrossView') or + (Item.ClassRef.ClassName = 'TfrxDBCrossView') or + (Item.ClassRef.InheritsFrom(TfrxDialogComponent))) then continue; + + m := TMenuItem.Create(ObjectsPopup); + m.ImageIndex := Item.ButtonImageIndex; + s := Item.ButtonHint; + if s = '' then + s := Item.ClassRef.GetDescription else + s := frxResources.Get(s); + m.Caption := s; + m.OnClick := ObjectsButtonClick; + m.Tag := i; + ObjectsPopup.Items.Add(m); + end; + end; + + pt := TControl(Sender).ClientToScreen(Point(TControl(Sender).Width, 0)); + ObjectsPopup.Popup(pt.X, pt.Y); + end + else { it's a simple object } + begin + c := TfrxComponent(Obj.ClassRef.NewInstance); + c.Create(FPage); + dx := c.Width; + dy := c.Height; + c.Free; + + if (dx = 0) and (dy = 0) then + begin + dx := GetDefaultObjectSize.X; + dy := GetDefaultObjectSize.Y; + end; + + FWorkspace.SetInsertion(Obj.ClassRef, dx, dy, Obj.Flags); + end; +end; + +procedure TfrxDesignerForm.OnExtraToolClick(Sender: TObject); +var + w: TfrxCustomWizard; + Item: TfrxWizardItem; +begin + Item := frxWizards[TToolButton(Sender).Tag]; + w := TfrxCustomWizard(Item.ClassRef.NewInstance); + w.Create(Self); + if w.Execute then + Modified := True; + w.Free; +end; + +procedure TfrxDesignerForm.InsertBandClick(Sender: TObject); +var + i: Integer; + Band: TfrxBand; + Size: Extended; + + function FindFreeSpace: Extended; + var + i: Integer; + b: TfrxComponent; + begin + Result := 0; + for i := 0 to FPage.Objects.Count - 1 do + begin + b := FPage.Objects[i]; + if (b is TfrxBand) and not TfrxBand(b).Vertical then + if b.Top + b.Height > Result then + Result := b.Top + b.Height; + end; + + Result := Round((Result + Workspace.BandHeader + 4) / Workspace.GridY) * Workspace.GridY; + Result := Round(Result * 100000000) / 100000000; + end; + +begin + if Page = nil then Exit; + + i := (Sender as TMenuItem).Tag; + + Band := TfrxBand(frxBands[i mod 100].NewInstance); + Band.Create(FPage); + Band.CreateUniqueName; + if i >= 100 then + Band.Vertical := True; + + if not Band.Vertical then + if Workspace.FreeBandsPlacement then + Band.Top := FindFreeSpace else + Band.Top := 10000; + + Size := 0; + case FUnits of + duCM: Size := fr01cm * 6; + duInches: Size := fr01in * 3; + duPixels: Size := 20; + duChars: Size := fr1CharY; + end; + + if not Band.Vertical then + Band.Height := Size + else + begin + Band.Left := Size; + Band.Width := Size; + end; + + FObjects.Add(Band); + FSelectedObjects.Clear; + FSelectedObjects.Add(Band); + Modified := True; + OnSelectionChanged(Self); + + ObjectSelectB.Down := True; + SelectToolBClick(Sender); + + if EditAfterInsert then + OnEditObject(Self); +end; + +procedure TfrxDesignerForm.ToolButtonClick(Sender: TObject); +var + i: Integer; + c: TfrxComponent; + wasModified: Boolean; + gx, gy: Extended; + TheFont: TFont; + + procedure EditFont; + begin + with TFontDialog.Create(Application) do + begin + Font := TfrxComponent(FSelectedObjects[0]).Font; + Options := Options + [fdForceFontExist]; + if Execute then + begin + TheFont := TFont.Create; + TheFont.Assign(Font); + end; + Free; + end; + end; + + procedure SetFontStyle(c: TfrxComponent; fStyle: TFontStyle; Include: Boolean); + begin + with c.Font do + if Include then + Style := Style + [fStyle] else + Style := Style - [fStyle]; + end; + + procedure SetFrameType(c: TfrxComponent; fType: TfrxFrameType; Include: Boolean); + var + f: TfrxFrame; + begin + if c is TfrxView then + f := TfrxView(c).Frame + else if c is TfrxReportPage then + f := TfrxReportPage(c).Frame else + Exit; + + with f do + if Include then + Typ := Typ + [fType] else + Typ := Typ - [fType]; + end; + + procedure SetDMPFontStyle(c: TfrxComponent; fStyle: TfrxDMPFontStyle; + Include: Boolean); + var + Style: TfrxDMPFontStyles; + begin + Style := []; + if c is TfrxDMPMemoView then + Style := TfrxDMPMemoView(c).FontStyle; + if c is TfrxDMPLineView then + Style := TfrxDMPLineView(c).FontStyle; + if c is TfrxDMPPage then + Style := TfrxDMPPage(c).FontStyle; + if not Include then + Style := Style + [fStyle] else + Style := Style - [fStyle]; + if c is TfrxDMPMemoView then + TfrxDMPMemoView(c).FontStyle := Style; + if c is TfrxDMPLineView then + TfrxDMPLineView(c).FontStyle := Style; + if c is TfrxDMPPage then + TfrxDMPPage(c).FontStyle := Style; + end; + +begin + if FUpdatingControls then Exit; + + TheFont := nil; + wasModified := False; + if TComponent(Sender).Tag = 43 then + EditFont; + + for i := 0 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if rfDontModify in c.Restrictions then continue; + + case TComponent(Sender).Tag of + + 0: c.Font.Name := FontNameCB.Text; + + 1: c.Font.Size := StrToInt(FontSizeCB.Text); + + 2: SetFontStyle(c, fsBold, BoldB.Down); + + 3: SetFontStyle(c, fsItalic, ItalicB.Down); + + 4: SetFontStyle(c, fsUnderline, UnderlineB.Down); + + 5: c.Font.Color := FColor; + + 6:; + + 7..10: + if c is TfrxCustomMemoView then + with TfrxCustomMemoView(c) do + if TextAlignLeftB.Down then + HAlign := haLeft + else if TextAlignCenterB.Down then + HAlign := haCenter + else if TextAlignRightB.Down then + HAlign := haRight + else + HAlign := haBlock; + + 11..13: + if c is TfrxCustomMemoView then + with TfrxCustomMemoView(c) do + if TextAlignTopB.Down then + VAlign := vaTop + else if TextAlignMiddleB.Down then + VAlign := vaCenter + else + VAlign := vaBottom; + + 20: SetFrameType(c, ftTop, FrameTopB.Down); + + 21: SetFrameType(c, ftBottom, FrameBottomB.Down); + + 22: SetFrameType(c, ftLeft, FrameLeftB.Down); + + 23: SetFrameType(c, ftRight, FrameRightB.Down); + + 24: begin + SetFrameType(c, ftTop, True); + SetFrameType(c, ftBottom, True); + SetFrameType(c, ftLeft, True); + SetFrameType(c, ftRight, True); + end; + + 25: begin + SetFrameType(c, ftTop, False); + SetFrameType(c, ftBottom, False); + SetFrameType(c, ftLeft, False); + SetFrameType(c, ftRight, False); + end; + + 26: if c is TfrxView then + TfrxView(c).Color := FColor + else if c is TfrxReportPage then + TfrxReportPage(c).Color := FColor + else if c is TfrxDialogPage then + begin + TfrxDialogPage(c).Color := FColor; + FWorkspace.Color := FColor; + end + else if c is TfrxDialogControl then + TfrxDialogControl(c).Color := FColor; + + 27: if c is TfrxView then + TfrxView(c).Frame.Color := FColor + else if c is TfrxReportPage then + TfrxReportPage(c).Frame.Color := FColor; + + 28: if c is TfrxView then + TfrxView(c).Frame.Style := FLineStyle + else if c is TfrxReportPage then + TfrxReportPage(c).Frame.Style := FLineStyle; + + 29: if c is TfrxView then + TfrxView(c).Frame.Width := frxStrToFloat(FrameWidthCB.Text) + else if c is TfrxReportPage then + TfrxReportPage(c).Frame.Width := frxStrToFloat(FrameWidthCB.Text); + + 30: if c is TfrxCustomMemoView then + TfrxCustomMemoView(c).Rotation := TMenuItem(Sender).HelpContext; + + 31: + begin + gx := FWorkspace.GridX; + gy := FWorkspace.GridY; + c.Left := Round(c.Left / gx) * gx; + c.Top := Round(c.Top / gy) * gy; + c.Width := Round(c.Width / gx) * gx; + c.Height := Round(c.Height / gy) * gy; + if c.Width = 0 then + c.Width := gx; + if c.Height = 0 then + c.Height := gy; + end; + + 32: if c is TfrxView then + TfrxView(c).Frame.DropShadow := ShadowB.Down + else if c is TfrxReportPage then + TfrxReportPage(c).Frame.DropShadow := ShadowB.Down; + + 33: if c is TfrxCustomMemoView then + if StyleCB.ItemIndex = 0 then + TfrxCustomMemoView(c).Style := '' else + TfrxCustomMemoView(c).Style := StyleCB.Text; + + 34: SetDMPFontStyle(c, fsxBold, BoldMI.Checked); + + 35: SetDMPFontStyle(c, fsxItalic, ItalicMI.Checked); + + 36: SetDMPFontStyle(c, fsxUnderline, UnderlineMI.Checked); + + 37: SetDMPFontStyle(c, fsxSuperScript, SuperScriptMI.Checked); + + 38: SetDMPFontStyle(c, fsxSubScript, SubScriptMI.Checked); + + 39: SetDMPFontStyle(c, fsxCondensed, CondensedMI.Checked); + + 40: SetDMPFontStyle(c, fsxWide, WideMI.Checked); + + 41: SetDMPFontStyle(c, fsx12cpi, N12cpiMI.Checked); + + 42: SetDMPFontStyle(c, fsx15cpi, N15cpiMI.Checked); + + 43: if TheFont <> nil then + c.Font := TheFont; + end; + + if TComponent(Sender).Tag in [0..5, 20..29, 32] then + if c is TfrxCustomMemoView then + begin + TfrxCustomMemoView(c).Style := ''; + StyleCB.Text := StyleCB.Items[0]; + end; + + if c is TfrxCustomMemoView then + FSampleFormat.SetAsSample(TfrxCustomMemoView(c)); + wasModified := True; + end; + + if TheFont <> nil then + TheFont.Free; + + ScrollBox.SetFocus; + if wasModified then + begin + FModifiedBy := Self; + Modified := True; + + if TComponent(Sender).Tag in [24, 25, 34..43] then + UpdateControls; + end; +end; + +procedure TfrxDesignerForm.FontColorBClick(Sender: TObject); +begin + CreateColorSelector(Sender as TToolButton); +end; + +procedure TfrxDesignerForm.FrameStyleBClick(Sender: TObject); +begin + with TfrxLineSelector.Create(TComponent(Sender)) do + OnStyleChanged := Self.OnStyleChanged; +end; + +procedure TfrxDesignerForm.ScaleCBClick(Sender: TObject); +var + s: String; + dx, dy: Integer; +begin + if ScaleCB.ItemIndex = 6 then + s := IntToStr(Round((ScrollBox.Width - 40) / (TfrxReportPage(FPage).PaperWidth * 96 / 25.4) * 100)) + else if ScaleCB.ItemIndex = 7 then + begin + dx := Round(TfrxReportPage(FPage).PaperWidth * 96 / 25.4); + dy := Round(TfrxReportPage(FPage).PaperHeight * 96 / 25.4); + if (ScrollBox.Width - 20) / dx < (ScrollBox.Height - 20) / dy then + s := IntToStr(Round((ScrollBox.Width - 20) / dx * 100)) else + s := IntToStr(Round((ScrollBox.Height - 20) / dy * 100)); + end + else + s := ScaleCB.Text; + + if Pos('%', s) <> 0 then + s[Pos('%', s)] := ' '; + while Pos(' ', s) <> 0 do + Delete(s, Pos(' ', s), 1); + + if s <> '' then + begin + Scale := frxStrToFloat(s) / 100; + ScaleCB.Text := s + '%'; + ScrollBox.SetFocus; + end; +end; + +procedure TfrxDesignerForm.ShowGridBClick(Sender: TObject); +begin + ShowGrid := ShowGridB.Down; +end; + +procedure TfrxDesignerForm.AlignToGridBClick(Sender: TObject); +begin + GridAlign := AlignToGridB.Down; +end; + +procedure TfrxDesignerForm.LangCBClick(Sender: TObject); +begin + if frxConfirmMsg(frxResources.Get('dsClearScript'), mb_YesNo) <> mrYes then + begin + LangCB.ItemIndex := LangCB.Items.IndexOf(Report.ScriptLanguage); + Exit; + end; + + Report.ScriptLanguage := LangCB.Text; + frxEmptyCode(CodeWindow.Lines, Report.ScriptLanguage); + + UpdateSyntaxType; + Modified := True; + CodeWindow.SetFocus; +end; + +procedure TfrxDesignerForm.OpenScriptBClick(Sender: TObject); +begin + with OpenScriptDialog do + if Execute then + begin + CodeWindow.Lines.LoadFromFile(FileName); + Modified := True; + end; +end; + +procedure TfrxDesignerForm.SaveScriptBClick(Sender: TObject); +begin + with SaveScriptDialog do + if Execute then + CodeWindow.Lines.SaveToFile(FileName); +end; + +procedure TfrxDesignerForm.HighlightBClick(Sender: TObject); +var + i: Integer; +begin + with TfrxHighlightEditorForm.Create(Self) do + begin + MemoView := SelectedObjects[0]; + if ShowModal = mrOk then + begin + for i := 1 to SelectedObjects.Count - 1 do + if TObject(SelectedObjects[i]) is TfrxMemoView then + TfrxMemoView(SelectedObjects[i]).Highlight.Assign(MemoView.Highlight); + + Modified := True; + end; + Free; + end; +end; + + +{ Controls' event handlers } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.OnCodeChanged(Sender: TObject); +begin + if FPage = nil then + begin + FModified := True; + SaveCmd.Enabled := True; + end; +end; + +procedure TfrxDesignerForm.OnChangePosition(Sender: TObject); +begin + if FPage = nil then + begin + FCoord1 := Format('%d; %d', [CodeWindow.GetPos.Y, CodeWindow.GetPos.X]); + FCoord2 := ''; + FCoord3 := ''; + end; + StatusBar.Repaint; +end; + +procedure TfrxDesignerForm.OnColorChanged(Sender: TObject); +begin + with TfrxColorSelector(Sender) do + begin + FColor := Color; + ToolButtonClick(TfrxColorSelector(Sender)); + end; +end; + +procedure TfrxDesignerForm.OnStyleChanged(Sender: TObject); +begin + with TfrxLineSelector(Sender) do + begin + FLineStyle := TfrxFrameStyle(Style); + ToolButtonClick(TfrxLineSelector(Sender)); + end; +end; + +procedure TfrxDesignerForm.ScrollBoxMouseWheelUp(Sender: TObject; + Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); +begin + with ScrollBox.VertScrollBar do + Position := Position - 16; +end; + +procedure TfrxDesignerForm.ScrollBoxMouseWheelDown(Sender: TObject; + Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); +begin + with ScrollBox.VertScrollBar do + Position := Position + 16; +end; + +procedure TfrxDesignerForm.ScrollBoxResize(Sender: TObject); +var + ofs, st: Integer; +begin + if FWorkspace = nil then Exit; + if FWorkspace.Left < 0 then + begin + ofs := ScrollBox.Left + 2; + st := -FWorkspace.Left; + end + else + begin + ofs := ScrollBox.Left + 2 + FWorkspace.Left; + st := 0; + end; + + TopRuler.Offset := ofs; + TopRuler.Start := st; + + if FWorkspace.Top < 0 then + begin + ofs := 2; + st := -FWorkspace.Top; + end + else + begin + ofs := FWorkspace.Top + 2; + st := 0; + end; + + LeftRuler.Offset := ofs; + LeftRuler.Start := st; +end; + +procedure TfrxDesignerForm.StatusBarMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + FUnitsDblClicked := X < StatusBar.Panels[0].Width; +end; + +procedure TfrxDesignerForm.StatusBarDblClick(Sender: TObject); +var + i: Integer; +begin + if FUnitsDblClicked and not + ((FWorkspace.GridType = gtDialog) or (FWorkspace.GridType = gtChar)) then + begin + i := Integer(FUnits); + Inc(i); + if i > 2 then + i := 0; + Units := TfrxDesignerUnits(i); + FOldUnits := FUnits; + end; +end; + +procedure TfrxDesignerForm.StatusBarDrawPanel(StatusBar: TStatusBar; + Panel: TStatusPanel; const ARect: TRect); +begin + with StatusBar.Canvas do + begin + FillRect(ARect); + + if FCoord1 <> '' then + begin + frxResources.MainButtonImages.Draw(StatusBar.Canvas, ARect.Left + 2, ARect.Top - 1, 62); + TextOut(ARect.Left + 20, ARect.Top + 1, FCoord1); + end; + + if FCoord2 <> '' then + begin + frxResources.MainButtonImages.Draw(StatusBar.Canvas, ARect.Left + 110, ARect.Top - 1, 63); + TextOut(ARect.Left + 130, ARect.Top + 1, FCoord2); + end; + + if FCoord3 <> '' then + TextOut(ARect.Left + 110, ARect.Top + 1, FCoord3); + end; +end; + +procedure TfrxDesignerForm.TimerTimer(Sender: TObject); +begin + PasteCmd.Enabled := FClipboard.PasteAvailable or (FPage = nil); +end; + +procedure TfrxDesignerForm.BandsPopupPopup(Sender: TObject); + + function FindBand(Band: TfrxComponentClass): TfrxBand; + var + i: Integer; + begin + Result := nil; + if FPage = nil then Exit; + for i := 0 to FPage.Objects.Count - 1 do + if TObject(FPage.Objects[i]) is Band then + Result := FPage.Objects[i]; + end; + +begin + ReportTitleMI.Enabled := FindBand(TfrxReportTitle) = nil; + ReportSummaryMI.Enabled := FindBand(TfrxReportSummary) = nil; + PageHeaderMI.Enabled := FindBand(TfrxPageHeader) = nil; + PageFooterMI.Enabled := FindBand(TfrxPageFooter) = nil; + ColumnHeaderMI.Enabled := FindBand(TfrxColumnHeader) = nil; + ColumnFooterMI.Enabled := FindBand(TfrxColumnFooter) = nil; +end; + +procedure TfrxDesignerForm.ToolbarsCmdExecute(Sender: TObject); +begin + StandardTBCmd.Checked := StandardTB.Visible; + TextTBCmd.Checked := TextTB.Visible; + FrameTBCmd.Checked := FrameTB.Visible; + AlignTBCmd.Checked := AlignTB.Visible; + ExtraTBCmd.Checked := ExtraToolsTB.Visible; + InspectorTBCmd.Checked := FInspector.Visible; + DataTreeTBCmd.Checked := FDataTree.Visible; + ReportTreeTBCmd.Checked := FReportTree.Visible; +end; + +procedure TfrxDesignerForm.TopRulerDragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + Accept := Source is TfrxDesignerWorkspace; +end; + +procedure TfrxDesignerForm.PagePopupPopup(Sender: TObject); +var + i: Integer; + ed: TfrxComponentEditor; + p: TPopupMenu; + m: TMenuItem; +begin + while PagePopup.Items[3] <> SepMI8 do + PagePopup.Items[3].Free; + + AddChildMI.Visible := TObject(FSelectedObjects[0]) is TfrxBand; + p := TPopupMenu.Create(nil); + ed := frxComponentEditors.GetComponentEditor(FSelectedObjects[0], Self, p); + if ed <> nil then + begin + EditMI1.Enabled := ed.HasEditor; + EditMI1.Default := EditMI1.Enabled; + + ed.GetMenuItems; + + SepMI12.Visible := p.Items.Count > 0; + + for i := p.Items.Count - 1 downto 0 do + begin + m := TMenuItem.Create(PagePopup); + with p.Items[i] do + begin + m.Caption := Caption; + m.Tag := Tag; + m.Checked := Checked; + m.Bitmap := Bitmap; + end; + m.OnClick := OnComponentMenuClick; + PagePopup.Items.Insert(3, m); + end; + + ed.Free; + end + else + begin + EditMI1.Enabled := False; + SepMI12.Visible := False; + end; + + p.Free; +end; + +procedure TfrxDesignerForm.CodeWindowDragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + Accept := (Source is TTreeView) and (TTreeView(Source).Owner = FDataTree) and + (FDataTree.GetFieldName <> ''); +end; + +procedure TfrxDesignerForm.CodeWindowDragDrop(Sender, Source: TObject; X, + Y: Integer); +begin + CodeWindow.SelText := FDataTree.GetFieldName; + CodeWindow.SetFocus; +end; + +procedure TfrxDesignerForm.OnDataTreeDblClick(Sender: TObject); +begin + if Page = nil then + begin + CodeWindow.SelText := FDataTree.GetFieldName; + CodeWindow.SetFocus; + end + else if (FDataTree.GetActivePage = 0) and + (Report.DataSets.Count = 0) then + ReportDataCmdExecute(Self); +end; + +procedure TfrxDesignerForm.TabChanging(Sender: TObject; var AllowChange: Boolean); +begin + if IsPreviewDesigner or FScriptRunning then + AllowChange := False; + + if (FTabs.TabIndex = 0) and CodeWindow.Modified then + begin + Modified := True; + CodeWindow.Modified := False; + end; + + SavePagePosition; +end; + +procedure TfrxDesignerForm.TabSetChange(Sender: TObject; NewTab: Integer; + var AllowChange: Boolean); +begin + TabChanging(nil, AllowChange); +end; + +procedure TfrxDesignerForm.TabChange(Sender: TObject); +begin + if FTabs.TabIndex = 0 then +{$IFDEF FR_VER_BASIC} + FTabs.TabIndex := 1 else +{$ELSE} + Page := nil else +{$ENDIF} + Page := Report.Pages[FTabs.TabIndex - 1]; +end; + +procedure TfrxDesignerForm.TabMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var + p: TPoint; +begin + GetCursorPos(p); + if Button = mbRight then + TabPopup.Popup(p.X, p.Y) else + FMouseDown := True; +end; + +procedure TfrxDesignerForm.TabMouseUp(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var + pt: TPoint; +begin + FMouseDown := False; + if Button = mbRight then + begin + pt := TControl(Sender).ClientToScreen(Point(X, Y)); + TabPopup.Popup(pt.X, pt.Y); + end; +end; + +procedure TfrxDesignerForm.TabMouseMove(Sender: TObject; + Shift: TShiftState; X, Y: Integer); +begin + if FMouseDown then + FTabs.BeginDrag(False); +end; + +procedure TfrxDesignerForm.TabDragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + Accept := Source is Sender.ClassType; +end; + +{$IFDEF UseTabset} +procedure TfrxDesignerForm.TabDragDrop(Sender, Source: TObject; X, Y: Integer); +var + HitPage, CurPage: Integer; +begin + HitPage := FTabs.ItemAtPos(Point(X, Y)); + CurPage := Report.Objects.IndexOf(Page) + 1; + if (CurPage < 2) or (HitPage < 2) then Exit; + + FTabs.Tabs.Move(CurPage, HitPage); + Report.Objects.Move(CurPage - 1, HitPage - 1); + Modified := True; +end; +{$ELSE} +procedure TfrxDesignerForm.TabDragDrop(Sender, Source: TObject; X, Y: Integer); +var + HitPage, CurPage: Integer; + HitTestInfo: TTCHitTestInfo; +begin + HitTestInfo.pt := Point(X, Y); + HitPage := SendMessage(FTabs.Handle, TCM_HITTEST, 0, Longint(@HitTestInfo)); + CurPage := Report.Objects.IndexOf(Page) + 1; + if (CurPage < 2) or (HitPage < 2) then Exit; + + FTabs.Tabs.Move(CurPage, HitPage); + Report.Objects.Move(CurPage - 1, HitPage - 1); + Modified := True; +end; +{$ENDIF} + +{ Dialog form events } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.DialogFormModify(Sender: TObject); +begin + Page.Left := FDialogForm.Left; + Page.Top := FDialogForm.Top; + Page.Width := FDialogForm.Width; + Page.Height := FDialogForm.Height; + Modified := True; +end; + +procedure TfrxDesignerForm.DialogFormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Shift = [ssCtrl] then + if Key = Ord('C') then + CopyCmd.Execute + else if Key = Ord('V') then + PasteCmd.Execute + else if Key = Ord('X') then + CutCmd.Execute + else if Key = Ord('Z') then + UndoCmd.Execute + else if Key = Ord('Y') then + RedoCmd.Execute + else if Key = Ord('A') then + SelectAllCmd.Execute + else if Key = Ord('S') then + SaveCmd.Execute; + + THackControl(FWorkspace).KeyDown(Key, Shift); +end; + +procedure TfrxDesignerForm.DialogFormKeyUp(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + THackControl(FWorkspace).KeyUp(Key, Shift); +end; + +procedure TfrxDesignerForm.DialogFormKeyPress(Sender: TObject; var Key: Char); +begin + THackControl(FWorkspace).KeyPress(Key); +end; + + +{ Menu commands } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.ExitCmdExecute(Sender: TObject); +begin + Close; +end; + +procedure TfrxDesignerForm.ConnectionsMIClick(Sender: TObject); +begin + with TfrxConnEditorForm.Create(nil) do + begin + Report := Self.Report; + ShowModal; + Free; + end; +end; + +procedure TfrxDesignerForm.UndoCmdExecute(Sender: TObject); +var + i: Integer; +begin + if IsPreviewDesigner then Exit; + + if FPage = nil then + begin + CodeWindow.Undo; + Exit; + end; + + i := GetPageIndex; + Lock; + + Report.ScriptText := CodeWindow.Lines; + FUndoBuffer.AddRedo(Report); + FUndoBuffer.GetUndo(Report); + CodeWindow.Lines := Report.ScriptText; + + ReloadPages(i); +end; + +procedure TfrxDesignerForm.RedoCmdExecute(Sender: TObject); +var + i: Integer; +begin + if IsPreviewDesigner then Exit; + + i := GetPageIndex; + Lock; + + Report.Reloading := True; + FUndoBuffer.GetRedo(Report); + Report.Reloading := False; + FUndoBuffer.AddUndo(Report); + CodeWindow.Lines := Report.ScriptText; + + ReloadPages(i); +end; + +procedure TfrxDesignerForm.CutCmdExecute(Sender: TObject); +begin + if FPage = nil then + begin + CodeWindow.CutToClipboard; + Exit; + end; + + FClipboard.Copy; + FWorkspace.DeleteObjects; + FInspector.Objects := FObjects; + + Modified := True; +end; + +procedure TfrxDesignerForm.CopyCmdExecute(Sender: TObject); +begin + if FPage = nil then + begin + CodeWindow.CopyToClipboard; + Exit; + end; + + FClipboard.Copy; + TimerTimer(nil); +end; + +procedure TfrxDesignerForm.PasteCmdExecute(Sender: TObject); +begin + if FPage = nil then + begin + CodeWindow.PasteFromClipboard; + Exit; + end; + + FClipboard.Paste; + FWorkspace.BringToFront; + FInspector.Objects := FObjects; + FInspector.UpdateProperties; + + if TfrxComponent(FSelectedObjects[0]) is TfrxDialogComponent then + Modified := True + else if FSelectedObjects[0] <> FPage then + TDesignerWorkspace(FWorkspace).SimulateMove; +end; + +procedure TfrxDesignerForm.GroupCmdExecute(Sender: TObject); +begin + FWorkspace.GroupObjects; +end; + +procedure TfrxDesignerForm.UngroupCmdExecute(Sender: TObject); +begin + FWorkspace.UngroupObjects; +end; + +procedure TfrxDesignerForm.DeletePageCmdExecute(Sender: TObject); +begin + if not CheckOp(drDontDeletePage) then Exit; + + Lock; + if (FPage is TfrxReportPage) and (TfrxReportPage(FPage).Subreport <> nil) then + TfrxReportPage(FPage).Subreport.Free; + + FPage.Free; + ReloadPages(-2); + Modified := True; +end; + +procedure TfrxDesignerForm.NewPageCmdExecute(Sender: TObject); +begin + if not CheckOp(drDontCreatePage) then Exit; + + Lock; + if Report.DotMatrixReport then + FPage := TfrxDMPPage.Create(Report) + else + FPage := TfrxReportPage.Create(Report); + FPage.CreateUniqueName; + TfrxReportPage(FPage).SetDefaults; + ReloadPages(Report.PagesCount - 1); + Modified := True; +end; + +procedure TfrxDesignerForm.NewDialogCmdExecute(Sender: TObject); +begin + if not CheckOp(drDontCreatePage) then Exit; + + Lock; + FPage := TfrxDialogPage.Create(Report); + FPage.CreateUniqueName; + FPage.SetBounds(265, 150, 300, 200); + ReloadPages(Report.PagesCount - 1); + Modified := True; +end; + +procedure TfrxDesignerForm.NewReportCmdExecute(Sender: TObject); +var + dp: TfrxDataPage; + p: TfrxReportPage; + b: TfrxBand; + m: TfrxMemoView; + h, t: Extended; + w: Word; +begin + if not CheckOp(drDontCreateReport) then Exit; + + if Modified then + begin + w := AskSave; + if w = mrYes then + SaveCmdExecute(Self) + else if w = mrCancel then + Exit; + end; + + t := FWorkspace.BandHeader; + h := 0; + case FUnits of + duCM: h := fr01cm * 6; + duInches: h := fr01in * 3; + duPixels: h := 20; + duChars: h := fr1CharY; + end; + + ObjectSelectB.Down := True; + SelectToolBClick(Self); + + Lock; + Report.Clear; + Report.FileName := ''; + + dp := TfrxDataPage.Create(Report); + dp.Name := 'Data'; + + p := TfrxReportPage.Create(Report); + p.Name := 'Page1'; + SetReportDefaults; + + b := TfrxReportTitle.Create(p); + b.Name := 'ReportTitle1'; + b.Top := t; + b.Height := h; + + b := TfrxMasterData.Create(p); + b.Name := 'MasterData1'; + b.Height := h; + b.Top := t * 2 + h * 2; + + b := TfrxPageFooter.Create(p); + b.Name := 'PageFooter1'; + b.Height := h; + b.Top := t * 3 + h * 4; + + m := TfrxMemoView.Create(b); + m.Name := 'Memo1'; + m.SetBounds((p.PaperWidth - p.LeftMargin - p.RightMargin - 20) * fr01cm, 0, + 2 * fr1cm, 5 * fr01cm); + m.HAlign := haRight; + m.Memo.Text := '[Page#]'; + + ReloadPages(-2); + UpdateCaption; + Modified := False; +end; + +procedure TfrxDesignerForm.SaveCmdExecute(Sender: TObject); +begin + FInspector.ItemIndex := FInspector.ItemIndex; + if CheckOp(drDontSaveReport) then + SaveFile(False, Sender = SaveCmd); +end; + +procedure TfrxDesignerForm.SaveAsCmdExecute(Sender: TObject); +begin + FInspector.ItemIndex := FInspector.ItemIndex; + if CheckOp(drDontSaveReport) then + SaveFile(True, Sender = SaveAsCmd); +end; + +procedure TfrxDesignerForm.OpenCmdExecute(Sender: TObject); +begin + if CheckOp(drDontLoadReport) then + LoadFile('', Sender = OpenCmd); +end; + +procedure TfrxDesignerForm.OpenRecentFile(Sender: TObject); +begin + if CheckOp(drDontLoadReport) then + LoadFile(TMenuItem(Sender).Caption, True); +end; + +procedure TfrxDesignerForm.DeleteCmdExecute(Sender: TObject); +begin + FWorkspace.DeleteObjects; +end; + +procedure TfrxDesignerForm.SelectAllCmdExecute(Sender: TObject); +var + i: Integer; + Parent: TfrxComponent; +begin + if Page = nil then + begin + CodeWindow.SelectAll; + Exit; + end; + + Parent := FPage; + if FSelectedObjects.Count = 1 then + if TfrxComponent(FSelectedObjects[0]) is TfrxBand then + Parent := FSelectedObjects[0] + else if TfrxComponent(FSelectedObjects[0]).Parent is TfrxBand then + Parent := TfrxComponent(FSelectedObjects[0]).Parent; + + if Parent.Objects.Count <> 0 then + FSelectedObjects.Clear; + for i := 0 to Parent.Objects.Count - 1 do + FSelectedObjects.Add(Parent.Objects[i]); + OnSelectionChanged(Self); +end; + +procedure TfrxDesignerForm.EditCmdExecute(Sender: TObject); +begin + FWorkspace.EditObject; +end; + +procedure TfrxDesignerForm.BringToFrontCmdExecute(Sender: TObject); +var + i: Integer; + c: TfrxComponent; +begin + for i := 0 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if c.Parent <> nil then + if (c is TfrxReportComponent) and not (rfDontMove in c.Restrictions) then + begin + c.Parent.Objects.Remove(c); + c.Parent.Objects.Add(c); + end; + end; + + ReloadObjects; + Modified := True; +end; + +procedure TfrxDesignerForm.SendToBackCmdExecute(Sender: TObject); +var + i: Integer; + c: TfrxComponent; +begin + for i := 0 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if c.Parent <> nil then + if (c is TfrxReportComponent) and not (rfDontMove in c.Restrictions) then + begin + c.Parent.Objects.Remove(c); + c.Parent.Objects.Insert(0, c); + end; + end; + + ReloadObjects; + Modified := True; +end; + +procedure TfrxDesignerForm.TabOrderMIClick(Sender: TObject); +begin + with TfrxTabOrderEditorForm.Create(Self) do + begin + if ShowModal = mrOk then + Modified := True; + ReloadObjects; + Free; + end; +end; + +procedure TfrxDesignerForm.PageSettingsCmdExecute(Sender: TObject); +begin + if CheckOp(drDontChangePageOptions) then + if (FPage is TfrxReportPage) and (TfrxReportPage(FPage).Subreport = nil) then + with TfrxPageEditorForm.Create(Self) do + begin + if ShowModal = mrOk then + begin + Modified := True; + UpdatePageDimensions; + end; + Free; + end; +end; + +procedure TfrxDesignerForm.OnComponentMenuClick(Sender: TObject); +var + ed: TfrxComponentEditor; +begin + ed := frxComponentEditors.GetComponentEditor(FSelectedObjects[0], Self, nil); + if ed <> nil then + begin + if ed.Execute(TMenuItem(Sender).Tag, not TMenuItem(Sender).Checked) then + Modified := True; + ed.Free; + end; +end; + +procedure TfrxDesignerForm.ReportDataCmdExecute(Sender: TObject); +begin + if CheckOp(drDontEditReportData) then + with TfrxReportDataForm.Create(Self) do + begin + Report := Self.Report; + if ShowModal = mrOk then + begin + Modified := True; + UpdateDataTree; + end; + Free; + end; +end; + +procedure TfrxDesignerForm.ReportStylesCmdExecute(Sender: TObject); +begin + if CheckOp(drDontChangeReportOptions) then + with TfrxStyleEditorForm.Create(Self) do + begin + if ShowModal = mrOk then + begin + Modified := True; + UpdateStyles; + Report.Styles.Apply; + end; + Free; + end; +end; + +procedure TfrxDesignerForm.ReportOptionsCmdExecute(Sender: TObject); +begin + if CheckOp(drDontChangeReportOptions) then + with TfrxReportEditorForm.Create(Self) do + begin + if ShowModal = mrOk then + begin + { reload printer fonts } + FontNameCB.PopulateList; + Modified := True; + end; + Free; + end; +end; + +procedure TfrxDesignerForm.VariablesCmdExecute(Sender: TObject); +begin + if CheckOp(drDontEditVariables) then + with TfrxVarEditorForm.Create(Self) do + begin + if ShowModal = mrOk then + begin + Modified := True; + UpdateDataTree; + end; + Free; + end; +end; + +procedure TfrxDesignerForm.PreviewCmdExecute(Sender: TObject); +var + Preview: TfrxCustomPreview; + pt: TPoint; + SavePageNo: Integer; + SaveModalPreview: Boolean; + SaveDestroyForms: Boolean; + SaveMDIChild: Boolean; + SaveVariables: TfrxVariables; +begin + FInspector.ItemIndex := FInspector.ItemIndex; + if not CheckOp(drDontPreviewReport) then Exit; + + SavePagePosition; + Report.ScriptText := CodeWindow.Lines; + if not Report.PrepareScript then + begin + pt := fsPosToPoint(Report.Script.ErrorPos); + SwitchToCodeWindow; + FCodeWindow.SetPos(pt.X, pt.Y); + FCodeWindow.ShowMessage(Report.Script.ErrorMsg); + Exit; + end; + + AttachDialogFormEvents(False); + SavePageNo := GetPageIndex; + SaveModalPreview := Report.PreviewOptions.Modal; + SaveDestroyForms := Report.EngineOptions.DestroyForms; + SaveMDIChild := Report.PreviewOptions.MDIChild; + SaveVariables := TfrxVariables.Create; + SaveVariables.Assign(Report.Variables); + + FUndoBuffer.AddUndo(Report); + + Preview := Report.Preview; + try + Report.Preview := nil; + Report.PreviewOptions.Modal := True; + Report.EngineOptions.DestroyForms := False; + Report.PreviewOptions.MDIChild := False; + FWatchList.ScriptRunning := True; + Report.ShowReport; + except + end; + + FWatchList.ScriptRunning := False; + Lock; + FUndoBuffer.GetUndo(Report); + + Report.Script.ClearItems(Report); + Report.Preview := Preview; + Report.PreviewOptions.Modal := SaveModalPreview; + Report.EngineOptions.DestroyForms := SaveDestroyForms; + Report.PreviewOptions.MDIChild := SaveMDIChild; + Report.Variables.Assign(SaveVariables); + SaveVariables.Free; + + if SavePageNo <> -1 then + ReloadPages(SavePageNo) + else + begin + ReloadPages(-2); + Page := nil; + end; + + FWatchList.UpdateWatches; +end; + +procedure TfrxDesignerForm.NewItemCmdExecute(Sender: TObject); +begin + if CheckOp(drDontCreateReport) then + with TfrxNewItemForm.Create(Self) do + begin + ShowModal; + Free; + end; +end; + +procedure TfrxDesignerForm.FindCmdExecute(Sender: TObject); +begin + FindOrReplace(False); +end; + +procedure TfrxDesignerForm.ReplaceCmdExecute(Sender: TObject); +begin + FindOrReplace(True); +end; + +procedure TfrxDesignerForm.FindNextCmdExecute(Sender: TObject); +begin + FindText; +end; + +procedure TfrxDesignerForm.StandardTBCmdExecute(Sender: TObject); +begin + StandardTBCmd.Checked := not StandardTBCmd.Checked; + StandardTB.Visible := StandardTBCmd.Checked; +end; + +procedure TfrxDesignerForm.TextTBCmdExecute(Sender: TObject); +begin + TextTBCmd.Checked := not TextTBCmd.Checked; + TextTB.Visible := TextTBCmd.Checked; +end; + +procedure TfrxDesignerForm.FrameTBCmdExecute(Sender: TObject); +begin + FrameTBCmd.Checked := not FrameTBCmd.Checked; + FrameTB.Visible := FrameTBCmd.Checked; +end; + +procedure TfrxDesignerForm.AlignTBCmdExecute(Sender: TObject); +begin + AlignTBCmd.Checked := not AlignTBCmd.Checked; + AlignTB.Visible := AlignTBCmd.Checked; +end; + +procedure TfrxDesignerForm.ExtraTBCmdExecute(Sender: TObject); +begin + ExtraTBCmd.Checked := not ExtraTBCmd.Checked; + ExtraToolsTB.Visible := ExtraTBCmd.Checked; +end; + +procedure TfrxDesignerForm.InspectorTBCmdExecute(Sender: TObject); +begin + InspectorTBCmd.Checked := not InspectorTBCmd.Checked; + FInspector.Visible := InspectorTBCmd.Checked; +end; + +procedure TfrxDesignerForm.DataTreeTBCmdExecute(Sender: TObject); +begin + DataTreeTBCmd.Checked := not DataTreeTBCmd.Checked; + FDataTree.Visible := DataTreeTBCmd.Checked; +end; + +procedure TfrxDesignerForm.ReportTreeTBCmdExecute(Sender: TObject); +begin + ReportTreeTBCmd.Checked := not ReportTreeTBCmd.Checked; + FReportTree.Visible := ReportTreeTBCmd.Checked; +end; + +procedure TfrxDesignerForm.ShowRulersCmdExecute(Sender: TObject); +begin + ShowRulersCmd.Checked := not ShowRulersCmd.Checked; + ShowRulers := ShowRulersCmd.Checked; +end; + +procedure TfrxDesignerForm.ShowGuidesCmdExecute(Sender: TObject); +begin + ShowGuidesCmd.Checked := not ShowGuidesCmd.Checked; + ShowGuides := ShowGuidesCmd.Checked; +end; + +procedure TfrxDesignerForm.DeleteGuidesCmdExecute(Sender: TObject); +begin + if FPage is TfrxReportPage then + begin + TfrxReportPage(FPage).ClearGuides; + FWorkspace.Invalidate; + Modified := True; + end; +end; + +procedure TfrxDesignerForm.OptionsCmdExecute(Sender: TObject); +var + u: TfrxDesignerUnits; +begin + u := FUnits; + + with TfrxOptionsEditor.Create(Self) do + begin + ShowModal; + Free; + end; + + if u <> FUnits then + FOldUnits := FUnits; + + if FWorkspace.GridType = gtDialog then + begin + FWorkspace.GridX := FGridSize4; + FWorkspace.GridY := FGridSize4; + end; + + FWorkspace.UpdateView; + CodeWindow.Invalidate; +end; + +procedure TfrxDesignerForm.HelpContentsCmdExecute(Sender: TObject); +var + tempC: TfrxDialogComponent; +begin + if Page = nil then + frxResources.Help(FCodeWindow) + else if Page is TfrxDialogPage then + frxResources.Help(Page) + else if TObject(SelectedObjects[0]) is TfrxDialogComponent then + begin + tempC := TfrxDialogComponent.Create(nil); + frxResources.Help(tempC); + tempC.Free; + end + else + frxResources.Help(Self); +end; + +procedure TfrxDesignerForm.AboutCmdExecute(Sender: TObject); +begin + with TfrxAboutForm.Create(Self) do + begin + ShowModal; + Free; + end; +end; + +procedure TfrxDesignerForm.AddChildMIClick(Sender: TObject); +var + b, bc: TfrxBand; +begin + b := FSelectedObjects[0]; + bc := b.Child; + InsertBandClick(ChildMI); + b.Child := FSelectedObjects[0]; + b.Child.Child := TfrxChild(bc); + Modified := True; +end; + + +{ Debugging } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.RunScriptBClick(Sender: TObject); +begin + if FScriptRunning then + begin + FScriptStep := Sender = StepScriptB; + if (Sender = RunScriptB) and (CodeWindow.BreakPoints.Count = 0) then + Report.Script.OnRunLine := nil; + FScriptStopped := False; + Exit; + end; + + if (Sender = RunScriptB) and (CodeWindow.BreakPoints.Count = 0) then + Report.Script.OnRunLine := nil + else + Report.Script.OnRunLine := OnRunLine; + + try + FScriptRunning := True; + FScriptFirstTime := True; + PreviewCmdExecute(Self); + finally + FScriptRunning := False; + Report.Script.OnRunLine := nil; + CodeWindow.DeleteF4BreakPoints; + CodeWindow.ActiveLine := -1; + end; +end; + +procedure TfrxDesignerForm.StopScriptBClick(Sender: TObject); +begin + Report.Script.OnRunLine := nil; + Report.Script.Terminate; + Report.Terminated := True; + FScriptStopped := False; +end; + +procedure TfrxDesignerForm.EvaluateBClick(Sender: TObject); +begin + with TfrxEvaluateForm.Create(Self) do + begin + Script := Report.Script; + if CodeWindow.SelText <> '' then + ExpressionE.Text := CodeWindow.SelText; + ShowModal; + Free; + end; +end; + +procedure TfrxDesignerForm.BreakPointBClick(Sender: TObject); +begin + CodeWindow.ToggleBreakPoint(CodeWindow.GetPos.Y, ''); +end; + +procedure TfrxDesignerForm.RunToCursorBClick(Sender: TObject); +begin + CodeWindow.AddBreakPoint(CodeWindow.GetPos.Y, 'F4'); + RunScriptBClick(nil); +end; + +procedure TfrxDesignerForm.OnRunLine(Sender: TfsScript; const UnitName, + SourcePos: String); +var + p: TPoint; + SaveActiveForm: TForm; + Condition: String; + + procedure CreateLineMarks; + var + i: Integer; + begin + for i := 0 to Report.Script.Lines.Count - 1 do + CodeWindow.RunLine[i + 1] := Report.Script.IsExecutableLine(i + 1); + end; + +begin + p := fsPosToPoint(SourcePos); + if not FScriptStep and (CodeWindow.BreakPoints.Count > 0) then + if not CodeWindow.IsBreakPoint(p.Y) then + Exit; + + Condition := CodeWindow.GetBreakPointCondition(p.Y); + { F4 - run to line, remove the breakpoint } + if Condition = 'F4' then + CodeWindow.DeleteBreakPoint(p.Y); + + if FScriptFirstTime then + CreateLineMarks; + FScriptFirstTime := False; + + SaveActiveForm := Screen.ActiveForm; + EnableWindow(Handle, True); + SetFocus; + + CodeWindow.ActiveLine := p.Y; + CodeWindow.SetPos(p.X, p.Y); + FWatchList.UpdateWatches; + + FScriptStopped := True; + while FScriptStopped do + Application.ProcessMessages; + + if SaveActiveForm <> nil then + SaveActiveForm.SetFocus; +end; + + +{ Alignment palette } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.AlignLeftsBClick(Sender: TObject); +var + i: Integer; + c0, c: TfrxComponent; +begin + if FSelectedObjects.Count < 2 then Exit; + + c0 := FSelectedObjects[0]; + for i := 1 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontMove in c.Restrictions) then + c.Left := c0.Left; + end; + + Modified := True; +end; + +procedure TfrxDesignerForm.AlignRightsBClick(Sender: TObject); +var + i: Integer; + c0, c: TfrxComponent; +begin + if FSelectedObjects.Count < 2 then Exit; + + c0 := FSelectedObjects[0]; + for i := 1 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontMove in c.Restrictions) then + c.Left := c0.Left + c0.Width - c.Width; + end; + + Modified := True; +end; + +procedure TfrxDesignerForm.AlignTopsBClick(Sender: TObject); +var + i: Integer; + c0, c: TfrxComponent; +begin + if FSelectedObjects.Count < 2 then Exit; + + c0 := FSelectedObjects[0]; + for i := 1 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontMove in c.Restrictions) then + if Abs(c.Top - c.AbsTop) < 1e-4 then + c.Top := c0.AbsTop + else + c.Top := c0.AbsTop - c.AbsTop + c.Top; + end; + + Modified := True; +end; + +procedure TfrxDesignerForm.AlignBottomsBClick(Sender: TObject); +var + i: Integer; + c0, c: TfrxComponent; +begin + if FSelectedObjects.Count < 2 then Exit; + + c0 := FSelectedObjects[0]; + for i := 1 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontMove in c.Restrictions) then + if Abs(c.Top - c.AbsTop) < 1e-4 then + c.Top := c0.AbsTop + c0.Height - c.Height + else + c.Top := c0.AbsTop - c.AbsTop + c.Top + c0.Height - c.Height; + end; + + Modified := True; +end; + +procedure TfrxDesignerForm.AlignHorzCentersBClick(Sender: TObject); +var + i: Integer; + c0, c: TfrxComponent; +begin + if FSelectedObjects.Count < 2 then Exit; + + c0 := FSelectedObjects[0]; + for i := 1 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontMove in c.Restrictions) then + c.Left := c0.Left + c0.Width / 2 - c.Width / 2; + end; + + Modified := True; +end; + +procedure TfrxDesignerForm.AlignVertCentersBClick(Sender: TObject); +var + i: Integer; + c0, c: TfrxComponent; +begin + if FSelectedObjects.Count < 2 then Exit; + + c0 := FSelectedObjects[0]; + for i := 1 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontMove in c.Restrictions) then + c.Top := c0.Top + c0.Height / 2 - c.Height / 2; + end; + + Modified := True; +end; + +procedure TfrxDesignerForm.CenterHorzBClick(Sender: TObject); +var + i: Integer; + c: TfrxComponent; +begin + if FSelectedObjects.Count < 1 then Exit; + + for i := 0 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontMove in c.Restrictions) and (c is TfrxView) then + if c.Parent is TfrxBand then + c.Left := (c.Parent.Width - c.Width) / 2 else + c.Left := (FWorkspace.Width / Scale - c.Width) / 2; + end; + + Modified := True; +end; + +procedure TfrxDesignerForm.CenterVertBClick(Sender: TObject); +var + i: Integer; + c: TfrxComponent; +begin + if FSelectedObjects.Count < 1 then Exit; + + for i := 0 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontMove in c.Restrictions) and (c is TfrxView) then + if c.Parent is TfrxBand then + c.Top := (c.Parent.Height - c.Height) / 2 else + c.Top := (FWorkspace.Height / Scale - c.Height) / 2; + end; + + Modified := True; +end; + +procedure TfrxDesignerForm.SpaceHorzBClick(Sender: TObject); +var + i: Integer; + c: TfrxComponent; + sl: TStringList; + dx: Extended; +begin + if FSelectedObjects.Count < 3 then Exit; + + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupAccept; + + for i := 0 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + sl.AddObject(Format('%4.4d', [Round(c.Left)]), c); + end; + + dx := (TfrxComponent(sl.Objects[sl.Count - 1]).Left - + TfrxComponent(sl.Objects[0]).Left) / (sl.Count - 1); + + for i := 1 to sl.Count - 2 do + begin + c := TfrxComponent(sl.Objects[i]); + if not (rfDontMove in c.Restrictions) then + c.Left := TfrxComponent(sl.Objects[i - 1]).Left + dx; + end; + + sl.Free; + Modified := True; +end; + +procedure TfrxDesignerForm.SpaceVertBClick(Sender: TObject); +var + i: Integer; + c: TfrxComponent; + sl: TStringList; + dy: Extended; +begin + if FSelectedObjects.Count < 3 then Exit; + + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupAccept; + + for i := 0 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + sl.AddObject(Format('%4.4d', [Round(c.Top)]), c); + end; + + dy := (TfrxComponent(sl.Objects[sl.Count - 1]).Top - + TfrxComponent(sl.Objects[0]).Top) / (sl.Count - 1); + + for i := 1 to sl.Count - 2 do + begin + c := TfrxComponent(sl.Objects[i]); + if not (rfDontMove in c.Restrictions) then + c.Top := TfrxComponent(sl.Objects[i - 1]).Top + dy; + end; + + sl.Free; + Modified := True; +end; + +procedure TfrxDesignerForm.SameWidthBClick(Sender: TObject); +var + i: Integer; + c0, c: TfrxComponent; +begin + if FSelectedObjects.Count < 2 then Exit; + + c0 := FSelectedObjects[0]; + for i := 1 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontSize in c.Restrictions) then + c.Width := c0.Width; + end; + + Modified := True; +end; + +procedure TfrxDesignerForm.SameHeightBClick(Sender: TObject); +var + i: Integer; + c0, c: TfrxComponent; +begin + if FSelectedObjects.Count < 2 then Exit; + + c0 := FSelectedObjects[0]; + for i := 1 to FSelectedObjects.Count - 1 do + begin + c := FSelectedObjects[i]; + if not (rfDontSize in c.Restrictions) then + c.Height := c0.Height; + end; + + Modified := True; +end; + + +{ Save/restore state } +{------------------------------------------------------------------------------} + +procedure TfrxDesignerForm.SaveState; +var + Ini: TCustomIniFile; + Nm: String; + + procedure SaveToolbars(t: array of TToolBar); + var + i: Integer; + begin + for i := Low(t) to High(t) do + frxSaveToolbarPosition(Ini, t[i]); + end; + + procedure SaveDocks(t: array of TfrxDockSite); + var + i: Integer; + begin + for i := Low(t) to High(t) do + frxSaveDock(Ini, t[i]); + end; + +begin + if IsPreviewDesigner then Exit; + if WorkspaceColor = 0 then Exit; + + Ini := Report.GetIniFile; + Nm := 'Form4.TfrxDesignerForm'; + Ini.WriteInteger('Form4.TfrxObjectInspector', 'SplitPos', FInspector.SplitterPos); + Ini.WriteInteger('Form4.TfrxObjectInspector', 'Split1Pos', FInspector.Splitter1Pos); + Ini.WriteFloat(Nm, 'Scale', FScale); + Ini.WriteBool(Nm, 'ShowGrid', FShowGrid); + Ini.WriteBool(Nm, 'GridAlign', FGridAlign); + Ini.WriteBool(Nm, 'ShowRulers', FShowRulers); + Ini.WriteBool(Nm, 'ShowGuides', FShowGuides); + Ini.WriteFloat(Nm, 'Grid1', FGridSize1); + Ini.WriteFloat(Nm, 'Grid2', FGridSize2); + Ini.WriteFloat(Nm, 'Grid3', FGridSize3); + Ini.WriteFloat(Nm, 'Grid4', FGridSize4); + FUnits := FOldUnits; + Ini.WriteInteger(Nm, 'Units', Integer(FUnits)); + Ini.WriteString(Nm, 'ScriptFontName', CodeWindow.Font.Name); + Ini.WriteInteger(Nm, 'ScriptFontSize', CodeWindow.Font.Size); + Ini.WriteString(Nm, 'MemoFontName', MemoFontName); + Ini.WriteInteger(Nm, 'MemoFontSize', MemoFontSize); + Ini.WriteBool(Nm, 'UseObjectFont', UseObjectFont); + Ini.WriteInteger(Nm, 'WorkspaceColor', FWorkspaceColor); + Ini.WriteInteger(Nm, 'ToolsColor', FToolsColor); + Ini.WriteBool(Nm, 'GridLCD', FWorkspace.GridLCD); + Ini.WriteBool(Nm, 'EditAfterInsert', FEditAfterInsert); + Ini.WriteBool(Nm, 'LocalizedOI', FLocalizedOI); + Ini.WriteString(Nm, 'RecentFiles', FRecentFiles.CommaText); + Ini.WriteBool(Nm, 'FreeBands', FWorkspace.FreeBandsPlacement); + Ini.WriteInteger(Nm, 'BandsGap', FWorkspace.GapBetweenBands); + Ini.WriteBool(Nm, 'ShowBandCaptions', FWorkspace.ShowBandCaptions); + Ini.WriteBool(Nm, 'DropFields', FDropFields); + Ini.WriteBool(Nm, 'ShowStartup', FShowStartup); + Ini.WriteString(Nm, 'WatchList', FWatchList.Watches.Text); + + frxSaveFormPosition(Ini, Self); + frxSaveFormPosition(Ini, FInspector); + frxSaveFormPosition(Ini, FDataTree); + frxSaveFormPosition(Ini, FReportTree); + frxSaveFormPosition(Ini, FWatchList); + SaveToolbars([StandardTB, TextTB, FrameTB, AlignTB, ExtraToolsTB]); + SaveDocks([LeftDockSite1, LeftDockSite2, RightDockSite, CodeDockSite]); + + Ini.Free; +end; + +procedure TfrxDesignerForm.RestoreState(RestoreDefault: Boolean = False; + RestoreMainForm: Boolean = False); +const + DefIni = +'[Form4.TfrxObjectInspector];' + +'Width=159;' + +'SplitPos=75;' + +'Split1Pos=65;' + +'Dock=LeftDockSite2;' + +'[Form4.TfrxDesignerForm];' + +'EditAfterInsert=1;' + +'Maximized=1;' + +'[Form4.TfrxDataTreeForm];' + +'Width=143;' + +'Dock=RightDockSite;' + +'[Form4.TfrxReportTreeForm];' + +'Width=159;' + +'Dock=LeftDockSite2;' + +'[Form4.TfrxWatchForm];' + +'Height=100;' + +'Dock=CodeDockSite;' + +'[ToolBar4.StandardTB];' + +'Float=0;' + +'Visible=1;' + +'Left=0;' + +'Top=0;' + +'Width=576;' + +'Height=27;' + +'Dock=DockTop;' + +'[ToolBar4.TextTB];' + +'Float=0;' + +'Visible=1;' + +'Left=0;' + +'Top=27;' + +'Width=651;' + +'Height=27;' + +'Dock=DockTop;' + +'[ToolBar4.FrameTB];' + +'Float=0;' + +'Visible=1;' + +'Left=651;' + +'Top=27;' + +'Width=305;' + +'Height=27;' + +'Dock=DockTop;' + +'[ToolBar4.AlignTB];' + +'Visible=0;' + +'[ToolBar4.ExtraToolsTB];' + +'Visible=0;' + +'[Dock4.LeftDockSite2];' + +'Data=00000400000000004F0300000000000001A200000000000000010000000073000000110000006672785265706F727454726565466F726D01000000004F030000120000006672784F626A656374496E73706563746F72FFFFFFFF;' + +'Width=160;' + +'[Dock4.RightDockSite];' + +'Data=000004000000000000000000000000000000000000000000000100000000000000000F0000006672784461746154726565466F726DFFFFFFFF;' + +'Width=160'; + +var + Ini: TCustomIniFile; + Nm: String; + + procedure RestoreToolbars(t: array of TToolBar); + var + i: Integer; + begin + for i := Low(t) to High(t) do + frxRestoreToolbarPosition(Ini, t[i]); + end; + + procedure RestoreDocks(t: array of TfrxDockSite); + var + i: Integer; + begin + for i := Low(t) to High(t) do + frxRestoreDock(Ini, t[i]); + end; + + function Def(Value, DefValue: Extended): Extended; + begin + if Value = 0 then + Result := DefValue else + Result := Value; + end; + + procedure DoRestore; + begin + if not RestoreMainForm then + begin + FInspector.SplitterPos := Ini.ReadInteger('Form4.TfrxObjectInspector', + 'SplitPos', FInspector.Width div 2); + if FInspector.SplitterPos > FInspector.Width - 10 then + FInspector.SplitterPos := FInspector.Width div 2; + FInspector.Splitter1Pos := Ini.ReadInteger('Form4.TfrxObjectInspector', + 'Split1Pos', 65); + if FInspector.Splitter1Pos < 10 then + FInspector.Splitter1Pos := 65; + Scale := Ini.ReadFloat(Nm, 'Scale', 1); + ShowGrid := Ini.ReadBool(Nm, 'ShowGrid', True); + GridAlign := Ini.ReadBool(Nm, 'GridAlign', True); + ShowRulers := Ini.ReadBool(Nm, 'ShowRulers', True); + ShowGuides := Ini.ReadBool(Nm, 'ShowGuides', True); + FGridSize1 := Def(Ini.ReadFloat(Nm, 'Grid1', 0), 0.1); + FGridSize2 := Def(Ini.ReadFloat(Nm, 'Grid2', 0), 0.1); + FGridSize3 := Def(Ini.ReadFloat(Nm, 'Grid3', 0), 4); + FGridSize4 := Def(Ini.ReadFloat(Nm, 'Grid4', 0), 4); + Units := TfrxDesignerUnits(Ini.ReadInteger(Nm, 'Units', 0)); + FOldUnits := FUnits; + CodeWindow.Font.Name := Ini.ReadString(Nm, 'ScriptFontName', 'Courier New'); + CodeWindow.Font.Size := Ini.ReadInteger(Nm, 'ScriptFontSize', 10); + MemoFontName := Ini.ReadString(Nm, 'MemoFontName', 'Arial'); + MemoFontSize := Ini.ReadInteger(Nm, 'MemoFontSize', 10); + UseObjectFont := Ini.ReadBool(Nm, 'UseObjectFont', True); + WorkspaceColor := Ini.ReadInteger(Nm, 'WorkspaceColor', clWindow); + ToolsColor := Ini.ReadInteger(Nm, 'ToolsColor', clWindow); + FWorkspace.GridLCD := Ini.ReadBool(Nm, 'GridLCD', False); + FEditAfterInsert := Ini.ReadBool(Nm, 'EditAfterInsert', False); + FRecentFiles.CommaText := Ini.ReadString(Nm, 'RecentFiles', ''); + FWorkspace.FreeBandsPlacement := Ini.ReadBool(Nm, 'FreeBands', False); + FWorkspace.GapBetweenBands := Ini.ReadInteger(Nm, 'BandsGap', 4); + FWorkspace.ShowBandCaptions := Ini.ReadBool(Nm, 'ShowBandCaptions', True); + FDropFields := Ini.ReadBool(Nm, 'DropFields', True); + FShowStartup := Ini.ReadBool(Nm, 'ShowStartup', True); + FWatchList.Watches.Text := Ini.ReadString(Nm, 'WatchList', ''); + FWatchList.UpdateWatches; + + frxRestoreFormPosition(Ini, FInspector); + if not IsPreviewDesigner then + begin + frxRestoreFormPosition(Ini, FDataTree); + frxRestoreFormPosition(Ini, FReportTree); + frxRestoreFormPosition(Ini, FWatchList); + end; + RestoreToolbars([StandardTB, TextTB, FrameTB, AlignTB, ExtraToolsTB]); + if not IsPreviewDesigner then + RestoreDocks([LeftDockSite1, LeftDockSite2, RightDockSite, CodeDockSite]); + + FWatchList.Visible := True; + FWatchList.DragMode := dmManual; + if FWatchList.Floating then + FWatchList.ManualDock(CodeDockSite); + + with FCodeWindow do + begin + {$I frxDesgn.inc} + end; + end + else + frxRestoreFormPosition(Ini, Self); + end; + + procedure ReadDefIni; + var + MemIni: TMemIniFile; + sl: TStringList; + begin + Ini.Free; + MemIni := TMemIniFile.Create(''); + + sl := TStringList.Create; + frxSetCommaText(DefIni, sl); + MemIni.SetStrings(sl); + sl.Free; + Ini := MemIni; + end; + +begin + Ini := Report.GetIniFile; + Nm := 'Form4.TfrxDesignerForm'; + if RestoreDefault or (Ini.ReadFloat(Nm, 'Scale', 0) = 0) or + (Ini.ReadInteger(Nm, 'WorkspaceColor', clWindow) = 0) then + ReadDefIni; + + try + try + DoRestore; + except + ReadDefIni; + DoRestore; + end + finally + Ini.Free; + end; +end; + +procedure TfrxDesignerForm.Localize; +begin + OpenScriptB.Hint := frxGet(2300); + SaveScriptB.Hint := frxGet(2301); + RunScriptB.Hint := frxGet(2302); + StepScriptB.Hint := frxGet(2303); + StopScriptB.Hint := frxGet(2304); + EvaluateB.Hint := frxGet(2305); + LangL.Caption := frxGet(2306); + AlignTB.Caption := frxGet(2307); + AlignLeftsB.Hint := frxGet(2308); + AlignHorzCentersB.Hint := frxGet(2309); + AlignRightsB.Hint := frxGet(2310); + AlignTopsB.Hint := frxGet(2311); + AlignVertCentersB.Hint := frxGet(2312); + AlignBottomsB.Hint := frxGet(2313); + SpaceHorzB.Hint := frxGet(2314); + SpaceVertB.Hint := frxGet(2315); + CenterHorzB.Hint := frxGet(2316); + CenterVertB.Hint := frxGet(2317); + SameWidthB.Hint := frxGet(2318); + SameHeightB.Hint := frxGet(2319); + TextTB.Caption := frxGet(2320); + StyleCB.Hint := frxGet(2321); + FontNameCB.Hint := frxGet(2322); + FontSizeCB.Hint := frxGet(2323); + BoldB.Hint := frxGet(2324); + ItalicB.Hint := frxGet(2325); + UnderlineB.Hint := frxGet(2326); + FontColorB.Hint := frxGet(2327); + HighlightB.Hint := frxGet(2328); + RotateB.Hint := frxGet(2329); + TextAlignLeftB.Hint := frxGet(2330); + TextAlignCenterB.Hint := frxGet(2331); + TextAlignRightB.Hint := frxGet(2332); + TextAlignBlockB.Hint := frxGet(2333); + TextAlignTopB.Hint := frxGet(2334); + TextAlignMiddleB.Hint := frxGet(2335); + TextAlignBottomB.Hint := frxGet(2336); + FrameTB.Caption := frxGet(2337); + FrameTopB.Hint := frxGet(2338); + FrameBottomB.Hint := frxGet(2339); + FrameLeftB.Hint := frxGet(2340); + FrameRightB.Hint := frxGet(2341); + FrameAllB.Hint := frxGet(2342); + FrameNoB.Hint := frxGet(2343); + ShadowB.Hint := frxGet(2344); + FillColorB.Hint := frxGet(2345); + FrameColorB.Hint := frxGet(2346); + FrameStyleB.Hint := frxGet(2347); + FrameWidthCB.Hint := frxGet(2348); + StandardTB.Caption := frxGet(2349); + NewB.Hint := frxGet(2350); + OpenB.Hint := frxGet(2351); + SaveB.Hint := frxGet(2352); + PreviewB.Hint := frxGet(2353); + NewPageB.Hint := frxGet(2354); + NewDialogB.Hint := frxGet(2355); + DeletePageB.Hint := frxGet(2356); + PageSettingsB.Hint := frxGet(2357); + VariablesB.Hint := frxGet(2358); + CutB.Hint := frxGet(2359); + CopyB.Hint := frxGet(2360); + PasteB.Hint := frxGet(2361); + UndoB.Hint := frxGet(2363); + RedoB.Hint := frxGet(2364); + GroupB.Hint := frxGet(2365); + UngroupB.Hint := frxGet(2366); + ShowGridB.Hint := frxGet(2367); + AlignToGridB.Hint := frxGet(2368); + SetToGridB.Hint := frxGet(2369); + ScaleCB.Hint := frxGet(2370); + + ExtraToolsTB.Caption := frxGet(2371); + ObjectSelectB.Hint := frxGet(2372); + HandToolB.Hint := frxGet(2373); + ZoomToolB.Hint := frxGet(2374); + TextToolB.Hint := frxGet(2375); + FormatToolB.Hint := frxGet(2376); + ObjectBandB.Hint := frxGet(2377); + FileMenu.Caption := frxGet(2378); + EditMenu.Caption := frxGet(2379); + FindCmd.Caption := frxGet(2380); + FindNextCmd.Caption := frxGet(2381); + ReplaceCmd.Caption := frxGet(2382); + ReportMenu.Caption := frxGet(2383); + ReportDataCmd.Caption := frxGet(2384); + ReportOptionsCmd.Caption := frxGet(2385); + ReportStylesCmd.Caption := frxGet(2386); + ViewMenu.Caption := frxGet(2387); + ToolbarsCmd.Caption := frxGet(2388); + StandardTBCmd.Caption := frxGet(2389); + TextTBCmd.Caption := frxGet(2390); + FrameTBCmd.Caption := frxGet(2391); + AlignTBCmd.Caption := frxGet(2392); + ExtraTBCmd.Caption := frxGet(2393); + InspectorTBCmd.Caption := frxGet(2394); + DataTreeTBCmd.Caption := frxGet(2395); + ReportTreeTBCmd.Caption := frxGet(2396); + ShowRulersCmd.Caption := frxGet(2397); + ShowGuidesCmd.Caption := frxGet(2398); + DeleteGuidesCmd.Caption := frxGet(2399); + OptionsCmd.Caption := frxGet(2400); + HelpMenu.Caption := frxGet(2401); + HelpContentsCmd.Caption := frxGet(2402); +{$IFDEF FR_LITE} + AboutCmd.Caption := StringReplace(frxGet(2403), 'FastReport', 'FreeReport', []); +{$ELSE} + AboutCmd.Caption := frxGet(2403); +{$ENDIF} + TabOrderMI.Caption := frxGet(2404); + UndoCmd.Caption := frxGet(2405); + RedoCmd.Caption := frxGet(2406); + CutCmd.Caption := frxGet(2407); + CopyCmd.Caption := frxGet(2408); + PasteCmd.Caption := frxGet(2409); + GroupCmd.Caption := frxGet(2410); + UngroupCmd.Caption := frxGet(2411); + DeleteCmd.Caption := frxGet(2412); + DeletePageCmd.Caption := frxGet(2413); + SelectAllCmd.Caption := frxGet(2414); + EditCmd.Caption := frxGet(2415); + BringToFrontCmd.Caption := frxGet(2416); + SendToBackCmd.Caption := frxGet(2417); + NewItemCmd.Caption := frxGet(2418); + NewReportCmd.Caption := frxGet(2419); + NewPageCmd.Caption := frxGet(2420); + NewDialogCmd.Caption := frxGet(2421); + OpenCmd.Caption := frxGet(2422); + SaveCmd.Caption := frxGet(2423); + SaveAsCmd.Caption := frxGet(2424); + VariablesCmd.Caption := frxGet(2425); + PageSettingsCmd.Caption := frxGet(2426); + PreviewCmd.Caption := frxGet(2427); + ExitCmd.Caption := frxGet(2428); + ReportTitleMI.Caption := frxGet(2429); + ReportSummaryMI.Caption := frxGet(2430); + PageHeaderMI.Caption := frxGet(2431); + PageFooterMI.Caption := frxGet(2432); + HeaderMI.Caption := frxGet(2433); + FooterMI.Caption := frxGet(2434); + MasterDataMI.Caption := frxGet(2435); + DetailDataMI.Caption := frxGet(2436); + SubdetailDataMI.Caption := frxGet(2437); + Data4levelMI.Caption := frxGet(2438); + Data5levelMI.Caption := frxGet(2439); + Data6levelMI.Caption := frxGet(2440); + GroupHeaderMI.Caption := frxGet(2441); + GroupFooterMI.Caption := frxGet(2442); + ChildMI.Caption := frxGet(2443); + ColumnHeaderMI.Caption := frxGet(2444); + ColumnFooterMI.Caption := frxGet(2445); + OverlayMI.Caption := frxGet(2446); + VerticalbandsMI.Caption := frxGet(2447); + HeaderMI1.Caption := frxGet(2448); + FooterMI1.Caption := frxGet(2449); + MasterDataMI1.Caption := frxGet(2450); + DetailDataMI1.Caption := frxGet(2451); + SubdetailDataMI1.Caption := frxGet(2452); + GroupHeaderMI1.Caption := frxGet(2453); + GroupFooterMI1.Caption := frxGet(2454); + ChildMI1.Caption := frxGet(2455); + R0MI.Caption := frxGet(2456); + R45MI.Caption := frxGet(2457); + R90MI.Caption := frxGet(2458); + R180MI.Caption := frxGet(2459); + R270MI.Caption := frxGet(2460); + FontB.Hint := frxGet(2461); + BoldMI.Caption := frxGet(2462); + ItalicMI.Caption := frxGet(2463); + UnderlineMI.Caption := frxGet(2464); + SuperScriptMI.Caption := frxGet(2465); + SubScriptMI.Caption := frxGet(2466); + CondensedMI.Caption := frxGet(2467); + WideMI.Caption := frxGet(2468); + N12cpiMI.Caption := frxGet(2469); + N15cpiMI.Caption := frxGet(2470); + OpenDialog.Filter := frxGet(2471); + OpenScriptDialog.Filter := frxGet(2472); + SaveScriptDialog.Filter := frxGet(2473); + ConnectionsMI.Caption := frxGet(2474); + BreakPointB.Hint := frxGet(2476); + RunToCursorB.Hint := frxGet(2477); + AddChildMI.Caption := frxGet(2478); + + if Assigned(frxFR2Events.OnLoad) then + OpenDialog.Filter := 'Report (*.fr3, *.frf)|*.fr3;*.frf'; +end; + +procedure TfrxDesignerForm.CreateLangMenu; +var + m, t: TMenuItem; + i: Integer; + reg: TRegistry; + current: String; +begin + current := ''; + reg := TRegistry.Create; + try + reg.RootKey := HKEY_CURRENT_USER; + if reg.OpenKey('\Software\Fast Reports\Resources', false) then + current := reg.ReadString('Language'); + finally + reg.Free; + end; + if frxResources.Languages.Count > 0 then + begin + m := TMenuItem.Create(ViewMenu); + m.Caption := '-'; + ViewMenu.Add(m); + m := TMenuItem.Create(ViewMenu); + m.Caption := frxGet(2475); + ViewMenu.Add(m); + for i := 0 to frxResources.Languages.Count - 1 do + begin + t := TMenuItem.Create(m); + t.Caption := frxResources.Languages[i]; + t.RadioItem := True; + t.OnClick := LangSelectClick; + if UpperCase(t.Caption) = UpperCase(current) then + t.Checked := True; + m.Add(t); + end; + end; +end; + +procedure TfrxDesignerForm.LangSelectClick(Sender: TObject); +var + m: TMenuItem; + reg: TRegistry; +begin + m := Sender as TMenuItem; + m.Checked := True; + frxResources.LoadFromFile(GetAppPath + m.Caption + '.frc'); + Localize; + reg := TRegistry.Create; + try + reg.RootKey := HKEY_CURRENT_USER; + if reg.OpenKey('\Software\Fast Reports\Resources', false) then + reg.WriteString('Language', m.Caption); + finally + reg.Free; + end; +end; + +procedure TfrxDesignerForm.OnCodeCompletion(const Name: String; List: TStrings); +var + obj: TPersistent; + xd: TfsXMLDocument; + i, j: Integer; + sl, members: TStringList; + s: String; + clName: String; + clVar: TfsClassVariable; + clMethod: TfsCustomHelper; + cl: TClass; + l: TList; +begin + members := TStringList.Create; + frxSetCommaText(Name, members, '.'); + if members.Count = 0 then + begin + List.Clear; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + List.AddObject(TfrxComponent(l[i]).Name + ' : ' + TfrxComponent(l[i]).ClassName, nil); + + members.Free; + Exit; + end; + + for i := 0 to members.Count - 1 do + members[i] := Trim(members[i]); + + if CompareText('Report', members[0]) = 0 then + obj := Report + else if CompareText('Engine', members[0]) = 0 then + obj := Report.Engine + else if CompareText('Outline', members[0]) = 0 then + obj := Report.PreviewPages.Outline + else + obj := Report.FindObject(members[0]); + + clName := ''; + if obj <> nil then + clName := obj.ClassName; + + i := 1; + while (clName <> '') and (i < members.Count) do + begin + clVar := Report.Script.FindClass(clName); + clName := ''; + if clVar <> nil then + begin + clMethod := clVar.Find(members[i]); + if clMethod <> nil then + clName := clMethod.TypeName; + Inc(i); + end; + end; + + if clName <> '' then + begin + clVar := Report.Script.FindClass(clName); + if clVar <> nil then + begin + cl := Report.Script.FindClass(clName).ClassRef; + + xd := TfsXMLDocument.Create; + GenerateMembers(Report.Script, cl, xd.Root); + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupIgnore; + for i := 0 to xd.Root.Count - 1 do + begin + s := xd.Root[i].Prop['text']; + j := 0; + if Pos('property', s) = 1 then + begin + Delete(s, 1, 9); + j := 1; + end; + if Pos('index property', s) = 1 then + begin + Delete(s, 1, 15); + j := 1; + end; + if Pos('procedure', s) = 1 then + begin + Delete(s, 1, 10); + j := 2; + end; + if Pos('function', s) = 1 then + begin + Delete(s, 1, 9); + j := 3; + end; + + sl.AddObject(s, TObject(j)); + end; + List.Assign(sl); + sl.Free; + xd.Free; + end; + end; +end; + +procedure TfrxDesignerForm.CodeDockSiteDockOver(Sender: TObject; + Source: TDragDockObject; X, Y: Integer; State: TDragState; + var Accept: Boolean); +begin + Accept := not (Source.Control is TToolBar); +end; + +procedure TfrxDesignerForm.OnDisableDock(Sender: TObject; + var DragObject: TDragDockObject); +begin + DockTop.DockSite := False; + DockBottom.DockSite := False; +end; + +procedure TfrxDesignerForm.OnEnableDock(Sender, Target: TObject; X, Y: Integer); +begin + DockTop.DockSite := True; + DockBottom.DockSite := True; +end; + + +initialization + frxDesignerClass := TfrxDesignerForm; +{$IFDEF FR_COM} +try + TComponentFactory.Create(ComServer, TfrxDesigner, Class_TfrxDesigner, ciMultiInstance, tmApartment); +except +end; +{$ENDIF} + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDesgn.res b/official/4.2/LibD11/frxDesgn.res new file mode 100644 index 0000000..21ecd30 Binary files /dev/null and b/official/4.2/LibD11/frxDesgn.res differ diff --git a/official/4.2/LibD11/frxDesgnCtrls.pas b/official/4.2/LibD11/frxDesgnCtrls.pas new file mode 100644 index 0000000..7782578 --- /dev/null +++ b/official/4.2/LibD11/frxDesgnCtrls.pas @@ -0,0 +1,1070 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Designer controls } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDesgnCtrls; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Buttons, ExtCtrls, ComCtrls, ToolWin, ImgList, frxClass, + frxPictureCache +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxRulerUnits = (ruCM, ruInches, ruPixels, ruChars); + + TfrxRuler = class(TPanel) + private + FOffset: Integer; + FScale: Extended; + FStart: Integer; + FUnits: TfrxRulerUnits; + FPosition: Extended; + FSize: Integer; + procedure SetOffset(const Value: Integer); + procedure SetScale(const Value: Extended); + procedure SetStart(const Value: Integer); + procedure SetUnits(const Value: TfrxRulerUnits); + procedure SetPosition(const Value: Extended); + procedure WMEraseBackground(var Message: TMessage); message WM_ERASEBKGND; + procedure SetSize(const Value: Integer); + public + constructor Create(AOwner: TComponent); override; + procedure Paint; override; + published + property Offset: Integer read FOffset write SetOffset; + property Scale: Extended read FScale write SetScale; + property Start: Integer read FStart write SetStart; + property Units: TfrxRulerUnits read FUnits write SetUnits default ruPixels; + property Position: Extended read FPosition write SetPosition; + property Size: Integer read FSize write SetSize; + end; + + TfrxScrollBox = class(TScrollBox) + protected + procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE; + procedure KeyDown(var Key: Word; Shift: TShiftState); override; + procedure KeyUp(var Key: Word; Shift: TShiftState); override; + procedure KeyPress(var Key: Char); override; + end; + + TfrxCustomSelector = class(TPanel) + private + procedure WMEraseBackground(var Message: TMessage); message WM_ERASEBKGND; + protected + procedure DrawEdge(X, Y: Integer; IsDown: Boolean); virtual; abstract; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + public + procedure Paint; override; + constructor Create(AOwner: TComponent); override; + end; + + TfrxColorSelector = class(TfrxCustomSelector) + private + FColor: TColor; + FOnColorChanged: TNotifyEvent; + protected + procedure DrawEdge(X, Y: Integer; IsDown: Boolean); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + public + constructor Create(AOwner: TComponent); override; + procedure Paint; override; + property Color: TColor read FColor write FColor; + property OnColorChanged: TNotifyEvent read FOnColorChanged write FOnColorChanged; + end; + + TfrxLineSelector = class(TfrxCustomSelector) + private + FStyle: Byte; + FOnStyleChanged: TNotifyEvent; + protected + procedure DrawEdge(X, Y: Integer; IsDown: Boolean); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + public + constructor Create(AOwner: TComponent); override; + procedure Paint; override; + property Style: Byte read FStyle; + property OnStyleChanged: TNotifyEvent read FOnStyleChanged write FOnStyleChanged; + end; + + TfrxUndoBuffer = class(TObject) + private + FPictureCache: TfrxPictureCache; + FRedo: TList; + FUndo: TList; + function GetRedoCount: Integer; + function GetUndoCount: Integer; + procedure SetPictureFlag(Report: TfrxReport; Flag: Boolean); + procedure SetPictures(Report: TfrxReport); + public + constructor Create; + destructor Destroy; override; + procedure AddUndo(Report: TfrxReport); + procedure AddRedo(Report: TfrxReport); + procedure GetUndo(Report: TfrxReport); + procedure GetRedo(Report: TfrxReport); + procedure ClearUndo; + procedure ClearRedo; + property UndoCount: Integer read GetUndoCount; + property RedoCount: Integer read GetRedoCount; + property PictureCache: TfrxPictureCache read FPictureCache write FPictureCache; + end; + + TfrxClipboard = class(TObject) + private + FDesigner: TfrxCustomDesigner; + FPictureCache: TfrxPictureCache; + function GetPasteAvailable: Boolean; + public + constructor Create(ADesigner: TfrxCustomDesigner); + procedure Copy; + procedure Paste; + property PasteAvailable: Boolean read GetPasteAvailable; + property PictureCache: TfrxPictureCache read FPictureCache write FPictureCache; + end; + + +implementation + +uses + frxDMPClass, frxPopupForm, frxDsgnIntf, frxCtrls, frxXMLSerializer, Clipbrd, + frxUtils, frxXML; + +const + Colors: array[0..47] of TColor = + (clNone, clWhite, clBlack, clMaroon, clGreen, clOlive, clNavy, clPurple, + clGray, clSilver, clTeal, clRed, clLime, clYellow, clBlue, clFuchsia, + $CCCCCC, $E4E4E4, clAqua, $00CCFF, $00CC98, $98FFFF, $FFCC00, $FF98CC, + $D8D8D8, $F0F0F0, $FFFFDC, $CAE4FF, $CCFFCC, $CCFFFF, $FFF4CC, $CC98FF, + clBtnFace, $46DAFF, $9BEBFF, $00A47B, $FDBD97, $FED3BA, $6ACFFF, $FFF4CC, + clBtnFace, clBtnFace, clBtnFace, clBtnFace, clBtnFace, clBtnFace, clBtnFace, clBtnFace); + +type + THackControl = class(TWinControl); + + +{ TfrxRuler } + +constructor TfrxRuler.Create(AOwner: TComponent); +begin + inherited; + FScale := 1; + DoubleBuffered := True; +end; + +procedure TfrxRuler.WMEraseBackground(var Message: TMessage); +begin +// +end; + +procedure TfrxRuler.Paint; +var + fh, oldfh: HFont; + sz: Integer; + + function CreateRotatedFont(Font: TFont): HFont; + var + F: TLogFont; + begin + GetObject(Font.Handle, SizeOf(TLogFont), @F); + F.lfEscapement := 90 * 10; + F.lfOrientation := 90 * 10; + Result := CreateFontIndirect(F); + end; + + procedure Line(x, y, dx, dy: Integer); + begin + Canvas.MoveTo(x, y); + Canvas.LineTo(x + dx, y + dy); + end; + + procedure DrawLines; + var + i, dx, maxi: Extended; + i1, h, w, w5, w10, maxw, ofs: Integer; + s: String; + begin + with Canvas do + begin + Pen.Color := clBlack; + Brush.Style := bsClear; + w5 := 5; + w10 := 10; + if FUnits = ruCM then + dx := fr01cm * FScale + else if FUnits = ruInches then + dx := fr01in * FScale + else if FUnits = ruChars then + begin + if Align = alLeft then + dx := fr1CharY * FScale / 10 else + dx := fr1CharX * FScale / 10 + end + else + begin + dx := FScale; + w5 := 50; + w10 := 100; + end; + + if FSize = 0 then + begin + if Align = alLeft then + maxi := Height + FStart else + maxi := Width + FStart; + end + else + maxi := FSize; + + if FUnits = ruPixels then + s := IntToStr(FStart + Round(maxi / dx)) else + s := IntToStr((FStart + Round(maxi / dx)) div 10); + + maxw := TextWidth(s); + ofs := FOffset - FStart; + if FUnits = ruChars then + begin + if Align = alLeft then + Inc(ofs, Round(fr1CharY * FScale / 2)) else + Inc(ofs, Round(fr1CharX * FScale / 2)) + end; + + i := 0; + i1 := 0; + while i < maxi do + begin + h := 0; + if i1 = 0 then + h := 0 + else if i1 mod w10 = 0 then + h := 6 + else if i1 mod w5 = 0 then + h := 4 + else if FUnits <> ruPixels then + h := 2; + + if (h = 2) and (dx * w10 < 41) then + h := 0; + if (h = 4) and (dx * w10 < 21) then + h := 0; + + w := 0; + if h = 6 then + begin + if maxw > dx * w10 * 1.5 then + w := w10 * 4 + else if maxw > dx * w10 * 0.7 then + w := w10 * 2 + else + w := w10; + end; + + if FUnits = ruPixels then + s := IntToStr(i1) else + s := IntToStr(i1 div 10); + + if (w <> 0) and (i1 mod w = 0) and (ofs + i >= FOffset) then + if Align = alLeft then + TextOut(Width - TextHeight(s) - 6, ofs + Round(i) + TextWidth(s) div 2 + 1, s) else + TextOut(ofs + Round(i) - TextWidth(s) div 2 + 1, 4, s) + else if (h <> 0) and (ofs + i >= FOffset) then + if Align = alLeft then + Line(3 + (13 - h) div 2, ofs + Round(i), h, 0) else + Line(ofs + Round(i), 3 + (13 - h) div 2, 0, h); + + i := i + dx; + Inc(i1); + end; + + i := FPosition * dx; + if FUnits <> ruPixels then + i := i * 10; + if ofs + i >= FOffset then + if Align = alLeft then + Line(3, ofs + Round(i), 13, 0) else + Line(ofs + Round(i), 3, 0, 13); + end; + end; + +begin + fh := 0; oldfh := 0; + with Canvas do + begin + Brush.Color := clBtnFace; + Brush.Style := bsSolid; + FillRect(Rect(0, 0, Width, Height)); + Brush.Color := clWindow; + + Font.Name := 'Arial'; + Font.Size := 7; + if Align = alLeft then + begin + if FSize = 0 then + sz := Height + else + sz := FSize + FOffset; + FillRect(Rect(3, FOffset, Width - 5, sz)); + fh := CreateRotatedFont(Font); + oldfh := SelectObject(Handle, fh); + end + else + begin + if FSize = 0 then + sz := Width + else + sz := FSize + FOffset; + FillRect(Rect(FOffset, 3, sz, Height - 5)); + end; + end; + + DrawLines; + + if Align = alLeft then + begin + SelectObject(Canvas.Handle, oldfh); + DeleteObject(fh); + end; +end; + +procedure TfrxRuler.SetOffset(const Value: Integer); +begin + FOffset := Value; + Invalidate; +end; + +procedure TfrxRuler.SetPosition(const Value: Extended); +begin + FPosition := Value; + Invalidate; +end; + +procedure TfrxRuler.SetScale(const Value: Extended); +begin + FScale := Value; + Invalidate; +end; + +procedure TfrxRuler.SetStart(const Value: Integer); +begin + FStart := Value; + Invalidate; +end; + +procedure TfrxRuler.SetUnits(const Value: TfrxRulerUnits); +begin + FUnits := Value; + Invalidate; +end; + +procedure TfrxRuler.SetSize(const Value: Integer); +begin + FSize := Value; + Invalidate; +end; + + +{ TfrxScrollBox } + +procedure TfrxScrollBox.KeyDown(var Key: Word; Shift: TShiftState); +var + i: Integer; +begin + inherited; + for i := 0 to ControlCount - 1 do + if Controls[i] is TWinControl then + THackControl(Controls[i]).KeyDown(Key, Shift); +end; + +procedure TfrxScrollBox.KeyPress(var Key: Char); +var + i: Integer; +begin + inherited; + for i := 0 to ControlCount - 1 do + if Controls[i] is TWinControl then + THackControl(Controls[i]).KeyPress(Key); +end; + +procedure TfrxScrollBox.KeyUp(var Key: Word; Shift: TShiftState); +var + i: Integer; +begin + inherited; + for i := 0 to ControlCount - 1 do + if Controls[i] is TWinControl then + THackControl(Controls[i]).KeyUp(Key, Shift); +end; + +procedure TfrxScrollBox.WMGetDlgCode(var Message: TWMGetDlgCode); +begin + Message.Result := DLGC_WANTARROWS or DLGC_WANTTAB; +end; + + +{ TfrxCustomSelector } + +constructor TfrxCustomSelector.Create(AOwner: TComponent); +var + f: TfrxPopupForm; + p: TPoint; +begin + f := TfrxPopupForm.Create(nil); + f.AutoSize := True; + + inherited Create(f); + Parent := f; + DoubleBuffered := True; + Tag := AOwner.Tag; + + with TControl(AOwner) do + p := ClientToScreen(Point(0, Height + 2)); + f.SetBounds(p.X, p.Y, 20, 20); + f.Show; +end; + +procedure TfrxCustomSelector.MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + DrawEdge(X, Y, True); +end; + +procedure TfrxCustomSelector.MouseMove(Shift: TShiftState; X, Y: Integer); +begin + DrawEdge(X, Y, False); +end; + +procedure TfrxCustomSelector.Paint; +begin + with Canvas do + begin + Pen.Color := clBtnShadow; + Brush.Color := clWindow; + Rectangle(0, 0, ClientWidth, ClientHeight); + end; +end; + +procedure TfrxCustomSelector.WMEraseBackground(var Message: TMessage); +begin +// +end; + + +{ TfrxColorSelector } + +constructor TfrxColorSelector.Create(AOwner: TComponent); +begin + inherited; + Width := 155; + Height := 143; +end; + +procedure TfrxColorSelector.DrawEdge(X, Y: Integer; IsDown: Boolean); +var + r: TRect; +begin + X := (X - 5) div 18; + if X >= 8 then + X := 7; + Y := (Y - 5) div 18; + + Repaint; + if Y < 6 then + r := Rect(X * 18 + 5, Y * 18 + 5, X * 18 + 23, Y * 18 + 23) else + r := Rect(5, 113, Width - 6, Height - 6); + + with Canvas do + begin + Brush.Style := bsClear; + Pen.Color := $C56A31; + Rectangle(r.Left, r.Top, r.Right, r.Bottom); + InflateRect(r, -1, -1); + Pen.Color := $E8E6E2; + Rectangle(r.Left, r.Top, r.Right, r.Bottom); + InflateRect(r, -1, -1); + Rectangle(r.Left, r.Top, r.Right, r.Bottom); + end; +end; + +procedure TfrxColorSelector.MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +var + cd: TColorDialog; + + procedure AddCustomColor; + var + i: Integer; + Found: Boolean; + Empty: Integer; + begin + Found := False; + Empty := 0; + for i := 0 to 47 do + begin + if Colors[i] = FColor then + Found := True; + if (i > 37) and (Colors[i] = clBtnFace) and (Empty = 0) then + Empty := i; + end; + + if Found then exit; + + if Empty = 0 then + begin + for i := 40 to 46 do + Colors[i] := Colors[i + 1]; + Empty := 47; + end; + Colors[Empty] := FColor + end; + +begin + X := (X - 5) div 18; + if X >= 8 then + X := 7; + Y := (Y - 5) div 18; + + if Y < 6 then + FColor := Colors[X + Y * 8] + else + begin + TForm(Parent).AutoSize := False; + Parent.Height := 0; + cd := TColorDialog.Create(Self); + cd.Options := [cdFullOpen]; + cd.Color := FColor; + if cd.Execute then + FColor := cd.Color else + Exit; + + AddCustomColor; + end; + + Repaint; + if Assigned(FOnColorChanged) then + FOnColorChanged(Self); + Parent.Hide; +end; + +procedure TfrxColorSelector.Paint; +var + i, j: Integer; + s: String; +begin + inherited; + + with Canvas do + begin + for j := 0 to 5 do + for i := 0 to 7 do + begin + if (i = 0) and (j = 0) then + Brush.Color := clWhite else + Brush.Color := Colors[i + j * 8]; + Pen.Color := clGray; + Rectangle(i * 18 + 8, j * 18 + 8, i * 18 + 20, j * 18 + 20); + if (i = 0) and (j = 0) then + begin + MoveTo(i * 18 + 10, j * 18 + 10); + LineTo(i * 18 + 18, j * 18 + 18); + MoveTo(i * 18 + 17, j * 18 + 10); + LineTo(i * 18 + 9, j * 18 + 18); + end; + end; + + Pen.Color := clGray; + Brush.Color := clBtnFace; + Rectangle(8, 116, Width - 9, Height - 9); + s := 'Other...'; + Font := Self.Font; + TextOut((Width - TextWidth(s)) div 2, 118, s); + end; +end; + + +{ TfrxLineSelector } + +constructor TfrxLineSelector.Create(AOwner: TComponent); +begin + inherited; + Width := 98; + Height := 106; +end; + +procedure TfrxLineSelector.DrawEdge(X, Y: Integer; IsDown: Boolean); +var + r: TRect; +begin + Y := (Y - 5) div 16; + if Y > 5 then + Y := 5; + + Repaint; + + r := Rect(5, Y * 16 + 5, Width - 5, Y * 16 + 21); + if IsDown then + Frame3D(Canvas, r, clBtnShadow, clBtnShadow, 2) else + Frame3D(Canvas, r, clBtnShadow, clBtnShadow, 1); +end; + +procedure TfrxLineSelector.MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + Y := (Y - 5) div 16; + if Y > 5 then + Y := 5; + + FStyle := Y; + + Repaint; + if Assigned(FOnStyleChanged) then + FOnStyleChanged(Self); + Parent.Hide; +end; + +procedure TfrxLineSelector.Paint; +var + i: Integer; + + procedure DrawLine(Y, Style: Integer); + begin + if Style = 5 then + begin + Style := 0; + DrawLine(Y - 2, Style); + Inc(Y, 2); + end; + + with Canvas do + begin + Pen.Color := clBlack; + Pen.Style := TPenStyle(Style); + MoveTo(7, Y); + LineTo(Width - 8, Y); + MoveTo(7, Y + 1); + LineTo(Width - 8, Y + 1); + end; + end; + +begin + inherited; + + for i := 0 to 5 do + DrawLine(12 + i * 16, i); +end; + + +{ TfrxUndoBuffer } + +constructor TfrxUndoBuffer.Create; +begin + FRedo := TList.Create; + FUndo := TList.Create; +end; + +destructor TfrxUndoBuffer.Destroy; +begin + ClearUndo; + ClearRedo; + FUndo.Free; + FRedo.Free; + inherited; +end; + +procedure TfrxUndoBuffer.AddUndo(Report: TfrxReport); +var + m: TMemoryStream; +begin + m := TMemoryStream.Create; + FUndo.Add(m); + SetPictureFlag(Report, False); + try + Report.SaveToStream(m); + finally + SetPictureFlag(Report, True); + end; +end; + +procedure TfrxUndoBuffer.AddRedo(Report: TfrxReport); +var + m: TMemoryStream; +begin + m := TMemoryStream.Create; + FRedo.Add(m); + SetPictureFlag(Report, False); + try + Report.SaveToStream(m); + finally + SetPictureFlag(Report, True); + end; +end; + +procedure TfrxUndoBuffer.GetUndo(Report: TfrxReport); +var + m: TMemoryStream; +begin + m := FUndo[FUndo.Count - 2]; + m.Position := 0; + Report.Reloading := True; + try + Report.LoadFromStream(m); + finally + Report.Reloading := False; + end; + SetPictures(Report); + + m := FUndo[FUndo.Count - 1]; + m.Free; + FUndo.Delete(FUndo.Count - 1); +end; + +procedure TfrxUndoBuffer.GetRedo(Report: TfrxReport); +var + m: TMemoryStream; +begin + m := FRedo[FRedo.Count - 1]; + m.Position := 0; + Report.Reloading := True; + try + Report.LoadFromStream(m); + finally + Report.Reloading := False; + end; + SetPictures(Report); + + m.Free; + FRedo.Delete(FRedo.Count - 1); +end; + +procedure TfrxUndoBuffer.ClearUndo; +begin + while FUndo.Count > 0 do + begin + TMemoryStream(FUndo[0]).Free; + FUndo.Delete(0); + end; +end; + +procedure TfrxUndoBuffer.ClearRedo; +begin + while FRedo.Count > 0 do + begin + TMemoryStream(FRedo[0]).Free; + FRedo.Delete(0); + end; +end; + +function TfrxUndoBuffer.GetRedoCount: Integer; +begin + Result := FRedo.Count; +end; + +function TfrxUndoBuffer.GetUndoCount: Integer; +begin + Result := FUndo.Count; +end; + +procedure TfrxUndoBuffer.SetPictureFlag(Report: TfrxReport; Flag: Boolean); +var + i: Integer; + l: TList; + c: TfrxComponent; +begin + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxPictureView then + begin + TfrxPictureView(c).IsPictureStored := Flag; + TfrxPictureView(c).IsImageIndexStored := not Flag; + end; + end; +end; + +procedure TfrxUndoBuffer.SetPictures(Report: TfrxReport); +var + i: Integer; + l: TList; + c: TfrxComponent; +begin + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxPictureView then + FPictureCache.GetPicture(TfrxPictureView(c)); + end; +end; + + +{ TfrxClipboard } + +constructor TfrxClipboard.Create(ADesigner: TfrxCustomDesigner); +begin + FDesigner := ADesigner; +end; + +procedure TfrxClipboard.Copy; +var + c, c1: TfrxComponent; + i, j: Integer; + text: String; + minX, minY: Extended; + List: TList; + Flag: Boolean; + + procedure Write(c: TfrxComponent); + var + c1: TfrxComponent; + Writer: TfrxXMLSerializer; + begin + c1 := TfrxComponent(c.NewInstance); + c1.Create(FDesigner.Page); + + if c is TfrxPictureView then + begin + TfrxPictureView(c).IsPictureStored := False; + TfrxPictureView(c).IsImageIndexStored := True; + end; + + try + c1.Assign(c); + finally + if c is TfrxPictureView then + begin + TfrxPictureView(c).IsPictureStored := True; + TfrxPictureView(c).IsImageIndexStored := False; + TfrxPictureView(c1).IsImageIndexStored := True; + end; + end; + + c1.Left := c1.Left - minX; + c1.Top := c.AbsTop - minY; + + Writer := TfrxXMLSerializer.Create(nil); + Writer.Owner := c1.Report; + text := text + '<' + c1.ClassName + ' Name="' + c.Name + '"' + Writer.ObjToXML(c1) + '/>'; + Writer.Free; + + c1.Free; + end; + +begin + text := '#FR3 clipboard#' + #10#13; + + minX := 100000; + minY := 100000; + for i := 0 to FDesigner.SelectedObjects.Count - 1 do + begin + c := FDesigner.SelectedObjects[i]; + if c.AbsLeft < minX then + minX := c.AbsLeft; + if c.AbsTop < minY then + minY := c.AbsTop; + end; + + List := FDesigner.Page.AllObjects; + for i := 0 to List.Count - 1 do + begin + c := List[i]; + if FDesigner.SelectedObjects.IndexOf(c) <> -1 then + begin + Write(c); + if c is TfrxBand then + begin + Flag := False; + for j := 0 to c.Objects.Count - 1 do + begin + c1 := c.Objects[j]; + if FDesigner.SelectedObjects.IndexOf(c1) <> -1 then + Flag := True; + end; + + if not Flag then + for j := 0 to c.Objects.Count - 1 do + Write(c.Objects[j]); + end; + end; + end; + + Clipboard.AsText := text; +end; + +function TfrxClipboard.GetPasteAvailable: Boolean; +begin + try + Result := Clipboard.HasFormat(CF_TEXT) and + (Pos('#FR3 clipboard#', Clipboard.AsText) = 1); + except + Result := False; + end; +end; + +procedure TfrxClipboard.Paste; +var + c: TfrxComponent; + sl: TStrings; + s: TStream; + List: TList; + NewCompName: string; + NewComp: TfrxComponent; + + function ReadComponent_(AReader: TfrxXMLSerializer; Root: TfrxComponent): TfrxComponent; + var + rd: TfrxXMLReader; + RootItem: TfrxXMLItem; + begin + rd := TfrxXMLReader.Create(AReader.Stream); + RootItem := TfrxXMLItem.Create; + + try + rd.ReadRootItem(RootItem, False); + Result := AReader.ReadComponentStr(Root, RootItem.Name + ' ' + RootItem.Text); + + NewCompName := RootItem.Prop['Name']; + finally + rd.Free; + RootItem.Free; + end; + end; + + function ReadComponent: TfrxComponent; + var + Reader: TfrxXMLSerializer; + begin + Reader := TfrxXMLSerializer.Create(s); + Result := ReadComponent_(Reader, FDesigner.Report); + Reader.Free; + end; + + function FindBand(Band: TfrxComponent): Boolean; + var + i: Integer; + begin + Result := False; + for i := 0 to FDesigner.Page.Objects.Count - 1 do + if (FDesigner.Page.Objects[i] <> Band) and + (TObject(FDesigner.Page.Objects[i]) is Band.ClassType) then + Result := True; + end; + + function CanInsert(c: TfrxComponent): Boolean; + begin + Result := True; + if (c is TfrxDialogControl) and (FDesigner.Page is TfrxReportPage) then + Result := False; + if not (c is TfrxDialogComponent) and not (c is TfrxDialogControl) and + (FDesigner.Page is TfrxDialogPage) then + Result := False; + if ((c is TfrxDMPMemoView) or (c is TfrxDMPLineView) or (c is TfrxDMPCommand)) and + not (FDesigner.Page is TfrxDMPPage) then + Result := False; + if not ((c is TfrxBand) or (c is TfrxDMPMemoView) or (c is TfrxDMPLineView) or + (c is TfrxDMPCommand)) and (FDesigner.Page is TfrxDMPPage) then + Result := False; + if not ((c is TfrxCustomLineView) or (c is TfrxCustomMemoView) or + (c is TfrxShapeView) or (c is TfrxDialogComponent)) and + (FDesigner.Page is TfrxDataPage) then + Result := False; + end; + + procedure FindParent(c: TfrxComponent); + var + i: Integer; + Found: Boolean; + c1: TfrxComponent; + begin + Found := False; + if not (c is TfrxBand) then + for i := List.Count - 1 downto 0 do + begin + c1 := List[i]; + if c1 is TfrxBand then + if (c.Top >= c1.Top) and (c.Top < c1.Top + c1.Height) then + begin + c.Parent := c1; + c.Top := c.Top - c1.Top; + Found := True; + break; + end; + end; + if not Found then + c.Parent := FDesigner.Page; + end; + +begin + FDesigner.SelectedObjects.Clear; + + sl := TStringList.Create; + sl.Text := Clipboard.AsText; + sl.Delete(0); + + s := TMemoryStream.Create; + sl.SaveToStream(s); + sl.Free; + s.Position := 0; + + List := TList.Create; + + while s.Position < s.Size do + begin + c := ReadComponent; + if c = nil then break; + + if (((c is TfrxReportTitle) or (c is TfrxReportSummary) or + (c is TfrxPageHeader) or (c is TfrxPageFooter) or + (c is TfrxColumnHeader) or (c is TfrxColumnFooter)) and FindBand(c)) or + not CanInsert(c) then + c.Free + else + begin + if c is TfrxPictureView then + FPictureCache.GetPicture(TfrxPictureView(c)); + List.Add(c); + FindParent(c); + NewComp := FDesigner.Report.FindComponent(NewCompName) as TfrxComponent; + if ((NewComp <> nil) and (NewComp <> c)) or (NewCompName = '') then + c.CreateUniqueName + else + c.Name := NewCompName; + c.GroupIndex := 0; + FDesigner.Objects.Add(c); + if c.Parent = FDesigner.Page then + FDesigner.SelectedObjects.Add(c); + c.OnPaste; + end; + end; + + if FDesigner.SelectedObjects.Count = 0 then + FDesigner.SelectedObjects.Add(FDesigner.Page); + + List.Free; + s.Free; +end; + + +end. + + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDesgnEditors.pas b/official/4.2/LibD11/frxDesgnEditors.pas new file mode 100644 index 0000000..8baa587 --- /dev/null +++ b/official/4.2/LibD11/frxDesgnEditors.pas @@ -0,0 +1,1437 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Property editors for Designer } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDesgnEditors; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Graphics, Controls, StdCtrls, Forms, Menus, + Dialogs, frxClass, frxDMPClass, frxDesgn, frxDsgnIntf, frxUtils, + frxCtrls, frxCustomEditors, frxEditPage, frxEditMemo, + frxEditDataBand, frxEditStrings, frxEditFormat, frxEditGroup, frxEditSysMemo, + frxCodeUtils, frxEditPicture, frxEditFrame, frxRes, frxUnicodeCtrls, + frxUnicodeUtils, frxPrinter +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + + +type + { Component editors } + + TfrxPageEditor = class(TfrxComponentEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + end; + + TfrxMemoEditor = class(TfrxCustomMemoEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + end; + + TfrxSysMemoEditor = class(TfrxCustomMemoEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + end; + + TfrxLineEditor = class(TfrxViewEditor) + public + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxPictureEditor = class(TfrxViewEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxBandEditor = class(TfrxComponentEditor) + public + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxDataBandEditor = class(TfrxBandEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxHeaderEditor = class(TfrxBandEditor) + public + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxPageHeaderEditor = class(TfrxBandEditor) + public + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxPageFooterEditor = class(TfrxComponentEditor) + public + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxGroupHeaderEditor = class(TfrxBandEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxDialogControlEditor = class(TfrxComponentEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + end; + + TfrxSubreportEditor = class(TfrxComponentEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + { Property editors } + + TfrxMemoProperty = class(TfrxClassProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxFrameProperty = class(TfrxClassProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxPictureProperty = class(TfrxClassProperty) + public + function GetValue: String; override; + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxBitmapProperty = class(TfrxClassProperty) + public + function GetValue: String; override; + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxDataSetProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxDataFieldProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxEventProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + procedure GetValues; override; + end; + + TfrxLocSizeXProperty = class(TfrxFloatProperty) + protected + FRatio: Extended; + public + constructor Create(Designer: TfrxCustomDesigner); override; + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + + TfrxLocSizeYProperty = class(TfrxLocSizeXProperty) + public + constructor Create(Designer: TfrxCustomDesigner); override; + end; + + TfrxPaperXProperty = class(TfrxFloatProperty) + protected + FRatio: Extended; + public + constructor Create(Designer: TfrxCustomDesigner); override; + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + + TfrxPaperYProperty = class(TfrxPaperXProperty) + public + constructor Create(Designer: TfrxCustomDesigner); override; + end; + + TfrxStringsProperty = class(TfrxClassProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxBrushProperty = class(TfrxEnumProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure OnDrawLBItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); override; + procedure OnDrawItem(Canvas: TCanvas; ARect: TRect); override; + end; + + TfrxFrameStyleProperty = class(TfrxEnumProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetExtraLBSize: Integer; override; + procedure OnDrawLBItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); override; + procedure OnDrawItem(Canvas: TCanvas; ARect: TRect); override; + end; + + TfrxDisplayFormatProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxBooleanProperty = class(TfrxEnumProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure OnDrawLBItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); override; + procedure OnDrawItem(Canvas: TCanvas; ARect: TRect); override; + end; + + TfrxPrinterProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + TfrxPaperProperty = class(TfrxIntegerProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + + TfrxStyleProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + + +{ TfrxPageEditor } + +function TfrxPageEditor.Edit: Boolean; +begin + Result := False; + if (Component is TfrxReportPage) and + (TfrxReportPage(Component).Subreport = nil) then + with TfrxPageEditorForm.Create(Designer) do + begin + Result := ShowModal = mrOk; + Free; + end; +end; + +function TfrxPageEditor.HasEditor: Boolean; +begin + Result := True; +end; + + +{ TfrxMemoEditor } + +function TfrxMemoEditor.Edit: Boolean; +begin + with TfrxMemoEditorForm.Create(Designer) do + begin + MemoView := TfrxMemoView(Component); + Result := ShowModal = mrOk; + if Result then + begin + MemoView.Text := Text; + MemoView.DataField := ''; + end; + Free; + end; +end; + +function TfrxMemoEditor.HasEditor: Boolean; +begin + Result := True; +end; + + +{ TfrxSysMemoEditor } + +function TfrxSysMemoEditor.Edit: Boolean; +begin + with TfrxSysMemoEditorForm.Create(Designer) do + begin + Text := TfrxSysMemoView(Component).Text; + Result := ShowModal = mrOk; + if Result then + TfrxSysMemoView(Component).Text := Text; + Free; + end; +end; + +function TfrxSysMemoEditor.HasEditor: Boolean; +begin + Result := True; +end; + + +{ TfrxLineEditor } + +function TfrxLineEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + i: Integer; + c: TfrxComponent; + l: TfrxCustomLineView; +begin + Result := inherited Execute(Tag, Checked); + + for i := 0 to Designer.SelectedObjects.Count - 1 do + begin + c := Designer.SelectedObjects[i]; + if (c is TfrxCustomLineView) and not (rfDontModify in c.Restrictions) then + begin + l := TfrxCustomLineView(c); + case Tag of + 0: l.Diagonal := Checked; + 1: if Checked then + l.StretchMode := smMaxHeight else + l.StretchMode := smDontStretch; + end; + + Result := True; + end; + end; +end; + +procedure TfrxLineEditor.GetMenuItems; +var + l: TfrxCustomLineView; +begin + l := TfrxCustomLineView(Component); + + if l is TfrxLineView then + AddItem(frxResources.Get('lvDiagonal'), 0, l.Diagonal); + AddItem(frxResources.Get('mvStretch'), 1, l.StretchMode = smMaxHeight); + + inherited; +end; + + +{ TfrxPictureEditor } + +function TfrxPictureEditor.Edit: Boolean; +begin + with TfrxPictureEditorForm.Create(Designer) do + begin + Image.Picture.Assign(TfrxPictureView(Component).Picture); + Result := ShowModal = mrOk; + if Result then + begin + TfrxPictureView(Component).Picture.Assign(Image.Picture); + TfrxDesignerForm(Self.Designer).PictureCache.AddPicture(TfrxPictureView(Component)); + end; + Free; + end; +end; + +function TfrxPictureEditor.HasEditor: Boolean; +begin + Result := True; +end; + +function TfrxPictureEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + i: Integer; + c: TfrxComponent; + p: TfrxPictureView; +begin + Result := inherited Execute(Tag, Checked); + + for i := 0 to Designer.SelectedObjects.Count - 1 do + begin + c := Designer.SelectedObjects[i]; + if (c is TfrxPictureView) and not (rfDontModify in c.Restrictions) then + begin + p := TfrxPictureView(c); + case Tag of + 0: p.AutoSize := Checked; + 1: p.Stretched := Checked; + 2: p.Center := Checked; + 3: p.KeepAspectRatio := Checked; + end; + + Result := True; + end; + end; +end; + +procedure TfrxPictureEditor.GetMenuItems; +var + p: TfrxPictureView; +begin + p := TfrxPictureView(Component); + + AddItem(frxResources.Get('pvAutoSize'), 0, p.AutoSize); + AddItem(frxResources.Get('mvStretch'), 1, p.Stretched); + AddItem(frxResources.Get('pvCenter'), 2, p.Center); + AddItem(frxResources.Get('pvAspect'), 3, p.KeepAspectRatio); + AddItem('-', -1); + + inherited; +end; + + +{ TfrxBandEditor } + +function TfrxBandEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + b: TfrxBand; +begin + Result := False; + + b := Designer.SelectedObjects[0]; + if not (rfDontModify in b.Restrictions) then + begin + case Tag of + 10: b.Stretched := Checked; + 11: b.AllowSplit := Checked; + 12: b.KeepChild := Checked; + 13: b.PrintChildIfInvisible := Checked; + 14: b.StartNewPage := Checked; + end; + Result := True; + end; +end; + +procedure TfrxBandEditor.GetMenuItems; +var + b: TfrxBand; +begin + if Designer.SelectedObjects.Count > 1 then Exit; + b := TfrxBand(Component); + + if not b.Vertical then + begin + AddItem(frxResources.Get('mvStretch'), 10, b.Stretched); + if not (b.BandNumber in [2,3,15,16]) then + AddItem(frxResources.Get('bvSplit'), 11, b.AllowSplit); + if not (b.BandNumber in [2,15]) then + AddItem(frxResources.Get('bvKeepChild'), 12, b.KeepChild); + end; + AddItem(frxResources.Get('bvPrintChild'), 13, b.PrintChildIfInvisible); + if not (b.BandNumber in [2,3,5,13,15,16]) then + AddItem(frxResources.Get('bvStartPage'), 14, b.StartNewPage); +end; + + +{ TfrxDataBandEditor } + +function TfrxDataBandEditor.Edit: Boolean; +begin + with TfrxDataBandEditorForm.Create(Designer) do + begin + DataBand := TfrxDataBand(Component); + Result := ShowModal = mrOk; + Free; + end; +end; + +function TfrxDataBandEditor.HasEditor: Boolean; +begin + Result := True; +end; + +function TfrxDataBandEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + b: TfrxDataBand; +begin + Result := inherited Execute(Tag, Checked); + + b := Designer.SelectedObjects[0]; + if not (rfDontModify in b.Restrictions) then + begin + case Tag of + 0: b.PrintIfDetailEmpty := Checked; + 1: b.FooterAfterEach := Checked; + 2: b.KeepTogether := Checked; + 3: b.KeepFooter := Checked; + 4: b.KeepHeader := Checked; + end; + Result := True; + end; +end; + +procedure TfrxDataBandEditor.GetMenuItems; +var + b: TfrxDataBand; +begin + inherited; + if Designer.SelectedObjects.Count > 1 then Exit; + b := TfrxDataBand(Component); + + AddItem(frxResources.Get('bvPrintIfEmpty'), 0, b.PrintIfDetailEmpty); + AddItem(frxResources.Get('bvFooterAfterEach'), 1, b.FooterAfterEach); + if not b.Vertical then + begin + AddItem(frxResources.Get('bvKeepDetail'), 2, b.KeepTogether); + AddItem(frxResources.Get('bvKeepFooter'), 3, b.KeepFooter); + AddItem(frxResources.Get('bvKeepHeader'), 4, b.KeepHeader); + end; +end; + + +{ TfrxHeaderEditor } + +function TfrxHeaderEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + b: TfrxHeader; +begin + Result := inherited Execute(Tag, Checked); + + b := Designer.SelectedObjects[0]; + if not (rfDontModify in b.Restrictions) then + begin + if Tag = 0 then + b.ReprintOnNewPage := Checked; + Result := True; + end; +end; + +procedure TfrxHeaderEditor.GetMenuItems; +var + b: TfrxHeader; +begin + inherited; + if Designer.SelectedObjects.Count > 1 then Exit; + b := TfrxHeader(Component); + + AddItem(frxResources.Get('bvReprint'), 0, b.ReprintOnNewPage); +end; + + +{ TfrxPageHeaderEditor } + +function TfrxPageHeaderEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + b: TfrxPageHeader; +begin + Result := inherited Execute(Tag, Checked); + + b := Designer.SelectedObjects[0]; + if not (rfDontModify in b.Restrictions) then + begin + if Tag = 0 then + b.PrintOnFirstPage := Checked; + Result := True; + end; +end; + +procedure TfrxPageHeaderEditor.GetMenuItems; +var + b: TfrxPageHeader; +begin + inherited; + if Designer.SelectedObjects.Count > 1 then Exit; + b := TfrxPageHeader(Component); + + AddItem(frxResources.Get('bvOnFirst'), 0, b.PrintOnFirstPage); +end; + + +{ TfrxPageFooterEditor } + +function TfrxPageFooterEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + b: TfrxPageFooter; +begin + Result := False; + + b := Designer.SelectedObjects[0]; + if not (rfDontModify in b.Restrictions) then + begin + case Tag of + 0: b.PrintOnFirstPage := Checked; + 1: b.PrintOnLastPage := Checked; + end; + Result := True; + end; +end; + +procedure TfrxPageFooterEditor.GetMenuItems; +var + b: TfrxPageFooter; +begin + if Designer.SelectedObjects.Count > 1 then Exit; + b := TfrxPageFooter(Component); + + AddItem(frxResources.Get('bvOnFirst'), 0, b.PrintOnFirstPage); + AddItem(frxResources.Get('bvOnLast'), 1, b.PrintOnLastPage); +end; + + +{ TfrxGroupHeaderEditor } + +function TfrxGroupHeaderEditor.Edit: Boolean; +begin + with TfrxGroupEditorForm.Create(Designer) do + begin + GroupHeader := TfrxGroupHeader(Component); + Result := ShowModal = mrOk; + Free; + end; +end; + +function TfrxGroupHeaderEditor.HasEditor: Boolean; +begin + Result := True; +end; + +function TfrxGroupHeaderEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + b: TfrxGroupHeader; +begin + Result := inherited Execute(Tag, Checked); + + b := Designer.SelectedObjects[0]; + if not (rfDontModify in b.Restrictions) then + begin + if Tag = 0 then + b.KeepTogether := Checked + else if Tag = 1 then + b.ReprintOnNewPage := Checked + else if Tag = 2 then + b.DrillDown := Checked + else if Tag = 3 then + begin + b.ResetPageNumbers := Checked; + if Checked then + b.StartNewPage := True; + end; + Result := True; + end; +end; + +procedure TfrxGroupHeaderEditor.GetMenuItems; +var + b: TfrxGroupHeader; +begin + inherited; + if Designer.SelectedObjects.Count > 1 then Exit; + b := TfrxGroupHeader(Component); + + AddItem(frxResources.Get('bvKeepGroup'), 0, b.KeepTogether); + AddItem(frxResources.Get('bvReprint'), 1, b.ReprintOnNewPage); + AddItem(frxResources.Get('bvDrillDown'), 2, b.DrillDown); + AddItem(frxResources.Get('bvResetPageNo'), 3, b.ResetPageNumbers); +end; + + +{ TfrxDialogControlEditor } + +function TfrxDialogControlEditor.Edit: Boolean; +var + i: Integer; + c: TfrxDialogControl; + s: String; +begin + c := TfrxDialogControl(Component); + if c.OnClick = '' then + begin + s := c.Name + 'OnClick'; + c.OnClick := s; + i := frxLocateEventHandler(Designer.Code, Designer.Report.ScriptLanguage, s); + if i = -1 then + i := frxAddEvent(Designer.Code, Designer.Report.ScriptLanguage, + TypeInfo(TfrxNotifyEvent), s) else + Inc(i, 3); + + TfrxDesignerForm(Designer).SwitchToCodeWindow; + TfrxDesignerForm(Designer).CodeWindow.UpdateView; + TfrxDesignerForm(Designer).CodeWindow.SetPos(3, i); + Result := True; + end + else + begin + i := frxLocateEventHandler(Designer.Code, Designer.Report.ScriptLanguage, + c.OnClick); + + TfrxDesignerForm(Designer).SwitchToCodeWindow; + TfrxDesignerForm(Designer).CodeWindow.SetPos(1, i + 3); + Result := False; + end; +end; + +function TfrxDialogControlEditor.HasEditor: Boolean; +begin + Result := True; +end; + + +{ TfrxSubreportEditor } + +function TfrxSubreportEditor.Edit: Boolean; +var + s: TfrxSubReport; +begin + Result := False; + s := TfrxSubReport(Component); + if s.Page <> nil then + Designer.Page := s.Page; +end; + +function TfrxSubreportEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + s: TfrxSubReport; +begin + Result := inherited Execute(Tag, Checked); + + s := TfrxSubReport(Component); + if not (rfDontModify in s.Restrictions) then + begin + if Tag = 0 then + s.PrintOnParent := Checked; + Result := True; + end; +end; + +procedure TfrxSubreportEditor.GetMenuItems; +begin + inherited; + AddItem(frxResources.Get('srParent'), 0, TfrxSubReport(Component).PrintOnParent); +end; + +function TfrxSubreportEditor.HasEditor: Boolean; +begin + Result := True; +end; + + +{ TfrxMemoProperty } + +function TfrxMemoProperty.Edit: Boolean; +begin + with TfrxMemoEditorForm.Create(Designer) do + begin + MemoView := TfrxMemoView(Component); + Result := ShowModal = mrOk; + if Result then + MemoView.Text := TUnicodeMemo(Memo).Text; + Free; + end; +end; + +function TfrxMemoProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog, paReadOnly]; +end; + + +{ TfrxFrameProperty } + +function TfrxFrameProperty.Edit: Boolean; +begin + with TfrxFrameEditorForm.Create(Designer) do + begin + Frame.Assign(TfrxFrame(GetOrdValue)); + Result := ShowModal = mrOk; + if Result then + TfrxFrame(GetOrdValue).Assign(Frame); + Free; + end; +end; + +function TfrxFrameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paDialog, paReadOnly]; +end; + + +{ TfrxPictureProperty } + +function TfrxPictureProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog, paReadOnly]; +end; + +function TfrxPictureProperty.Edit: Boolean; +var + Pict: TPicture; +begin + with TfrxPictureEditorForm.Create(Designer) do + begin + Pict := TPicture(GetOrdValue); + Image.Picture.Assign(Pict); + Result := ShowModal = mrOk; + if Result then + Pict.Assign(Image.Picture); + Free; + end; +end; + +function TfrxPictureProperty.GetValue: String; +var + Pict: TPicture; +begin + Pict := TPicture(GetOrdValue); + if Pict.Graphic = nil then + Result := frxResources.Get('prNotAssigned') else + Result := frxResources.Get('prPict'); +end; + + +{ TfrxBitmapProperty } + +function TfrxBitmapProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog, paReadOnly]; +end; + +function TfrxBitmapProperty.Edit: Boolean; +var + Bmp: TBitmap; +begin + with TfrxPictureEditorForm.Create(Designer) do + begin + Bmp := TBitmap(GetOrdValue); + Image.Picture.Assign(Bmp); + Result := ShowModal = mrOk; + if Result then + Bmp.Assign(Image.Picture.Bitmap); + Free; + end; +end; + +function TfrxBitmapProperty.GetValue: String; +begin + Result := frxResources.Get('prPict'); +end; + + +{ TfrxDataSetProperty } + +function TfrxDataSetProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +function TfrxDataSetProperty.GetValue: String; +var + ds: TfrxDataSet; +begin + ds := TfrxDataSet(GetOrdValue); + if (ds <> nil) and (frComponent.Report <> nil) then + Result := frComponent.Report.GetAlias(ds) else + Result := frxResources.Get('prNotAssigned'); +end; + +procedure TfrxDataSetProperty.GetValues; +begin + if frComponent.Report = nil then Exit; + frComponent.Report.GetDataSetList(Values); + if Component is TfrxDataSet then + Values.Delete(Values.IndexOf(TfrxDataSet(Component).UserName)); +end; + +procedure TfrxDataSetProperty.SetValue(const Value: String); +var + ds: TfrxDataSet; +begin + if Value = '' then + SetOrdValue(0) + else + begin + ds := frComponent.Report.GetDataSet(Value); + if ds <> nil then + SetOrdValue(Integer(ds)) else + raise Exception.Create(frxResources.Get('prInvProp')); + + if Component is TfrxCustomMemoView then + with TfrxCustomMemoView(Component) do + if IsDataField then + Text := '[' + DataSet.UserName + '."' + DataField + '"]'; + end; +end; + + +{ TfrxDataFieldProperty } + +function TfrxDataFieldProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +function TfrxDataFieldProperty.GetValue: String; +begin + Result := GetStrValue; +end; + +procedure TfrxDataFieldProperty.SetValue(const Value: String); +begin + SetStrValue(Value); + if Component is TfrxCustomMemoView then + with TfrxCustomMemoView(Component) do + if IsDataField then + Text := '[' + DataSet.UserName + '."' + DataField + '"]'; +end; + +procedure TfrxDataFieldProperty.GetValues; +var + ds: TfrxDataSet; +begin + inherited; + ds := TfrxView(Component).DataSet; + if ds <> nil then + ds.GetFieldList(Values); +end; + + +{ TfrxLocSizeXProperty } + +constructor TfrxLocSizeXProperty.Create(Designer: TfrxCustomDesigner); +begin + inherited; + FRatio := fr1CharX; +end; + +function TfrxLocSizeXProperty.GetValue: String; +var + e: Extended; +begin + e := GetFloatValue; + case TfrxDesignerForm(Designer).Units of + duCM: e := e / 96 * 2.54; + duInches: e := e / 96; + duChars: e := e / FRatio; + end; + + if e = Int(e) then + Result := FloatToStr(e) else + Result := Format('%f', [e]); +end; + +procedure TfrxLocSizeXProperty.SetValue(const Value: String); +var + e: Extended; +begin + e := frxStrToFloat(Value); + case TfrxDesignerForm(Designer).Units of + duCM: e := e * 96 / 2.54; + duInches: e := e * 96; + duChars: e := e * FRatio; + end; + + SetFloatValue(e); +end; + + +{ TfrxLocSizeYProperty } + +constructor TfrxLocSizeYProperty.Create(Designer: TfrxCustomDesigner); +begin + inherited; + FRatio := fr1CharY; +end; + + +{ TfrxPaperXProperty } + +constructor TfrxPaperXProperty.Create(Designer: TfrxCustomDesigner); +begin + inherited; + FRatio := fr1CharX; +end; + +function TfrxPaperXProperty.GetValue: String; +var + e: Extended; +begin + e := GetFloatValue; + case TfrxDesignerForm(Designer).Units of + duCM: e := e / 10; + duInches: e := e / 25.4; + duPixels: e := e * 96 / 25.4; + duChars: e := e * 96 / 25.4 / FRatio; + end; + + if e = Int(e) then + Result := FloatToStr(e) else + Result := Format('%f', [e]); +end; + +procedure TfrxPaperXProperty.SetValue(const Value: String); +var + e: Extended; +begin + e := frxStrToFloat(Value); + case TfrxDesignerForm(Designer).Units of + duCM: e := e * 10; + duInches: e := e * 25.4; + duPixels: e := e * 25.4 / 96; + duChars: e := e * 25.4 / 96 * FRatio; + end; + + SetFloatValue(e); +end; + + +{ TfrxPaperYProperty } + +constructor TfrxPaperYProperty.Create(Designer: TfrxCustomDesigner); +begin + inherited; + FRatio := fr1CharY; +end; + + +{ TfrxEventProperty } + +function TfrxEventProperty.Edit: Boolean; +var + i: Integer; +begin + if Value = '' then + begin + Value := frComponent.Name + GetName; + i := frxLocateEventHandler(Designer.Code, Designer.Report.ScriptLanguage, + Value); + if i = -1 then + i := frxAddEvent(Designer.Code, Designer.Report.ScriptLanguage, + PropInfo.PropType^, Value) else + Inc(i, 3); + + TfrxDesignerForm(Designer).SwitchToCodeWindow; + TfrxDesignerForm(Designer).CodeWindow.UpdateView; + TfrxDesignerForm(Designer).CodeWindow.SetPos(3, i); + Result := True; + end + else + begin + i := frxLocateEventHandler(Designer.Code, Designer.Report.ScriptLanguage, + Value); + + TfrxDesignerForm(Designer).SwitchToCodeWindow; + TfrxDesignerForm(Designer).CodeWindow.SetPos(1, i + 3); + Result := False; + end; +end; + +function TfrxEventProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +procedure TfrxEventProperty.GetValues; +begin + inherited; + frxGetEventHandlersList(Designer.Code, Designer.Report.ScriptLanguage, + PropInfo.PropType^, Values); +end; + + +{ TfrxStringsProperty } + +function TfrxStringsProperty.Edit: Boolean; +var + l: TStrings; +begin + with TfrxStringsEditorForm.Create(Designer) do + begin + l := TStrings(GetOrdValue); + Memo.Lines.Assign(l); + Result := ShowModal = mrOk; + if Result then + l.Assign(Memo.Lines); + Free; + end; +end; + +function TfrxStringsProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog, paReadOnly]; +end; + + +{ TfrxBrushProperty } + +function TfrxBrushProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paOwnerDraw]; +end; + +procedure TfrxBrushProperty.OnDrawLBItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); +begin + inherited; + with TListBox(Control), TListBox(Control).Canvas do + begin + Brush.Style := TBrushStyle(Index); + Brush.Color := clBlack; + Rectangle(ARect.Left + 2, ARect.Top + 2, ARect.Left + (ARect.Bottom - ARect.Top - 2), ARect.Bottom - 2); + end; +end; + +procedure TfrxBrushProperty.OnDrawItem(Canvas: TCanvas; ARect: TRect); +begin + inherited; + with Canvas do + begin + Brush.Style := TBrushStyle(GetOrdValue); + Brush.Color := clBlack; + Rectangle(ARect.Left, ARect.Top + 1, ARect.Left + (ARect.Bottom - ARect.Top - 5), ARect.Bottom - 4); + end; +end; + + +{ TfrxFrameStyleProperty } + +function TfrxFrameStyleProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paOwnerDraw]; +end; + +procedure HLine(Canvas: TCanvas; X, Y, DX: Integer); +var + i: Integer; +begin + with Canvas do + begin + Pen.Color := clBlack; + if Pen.Style = psClear then + begin + Pen.Style := psSolid; + for i := 0 to 1 do + begin + MoveTo(X, Y - 2 + i * 2); + LineTo(X + DX, Y - 2 + i * 2); + end + end + else + for i := 0 to 1 do + begin + MoveTo(X, Y - 1 + i); + LineTo(X + DX, Y - 1 + i); + end; + end; +end; + +procedure TfrxFrameStyleProperty.OnDrawLBItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); +begin + with TListBox(Control), TListBox(Control).Canvas do + begin + FillRect(ARect); + TextOut(ARect.Left + 40, ARect.Top + 1, TListBox(Control).Items[Index]); + + Pen.Color := clGray; + Brush.Color := clWhite; + Rectangle(ARect.Left + 2, ARect.Top + 2, ARect.Left + 36, ARect.Bottom - 2); + + Pen.Style := TPenStyle(Index); + HLine(TListBox(Control).Canvas, ARect.Left + 3, ARect.Top + (ARect.Bottom - ARect.Top) div 2, 32); + Pen.Style := psSolid; + end; +end; + +procedure TfrxFrameStyleProperty.OnDrawItem(Canvas: TCanvas; ARect: TRect); +begin + with Canvas do + begin + TextOut(ARect.Left + 38, ARect.Top, Value); + + Pen.Color := clGray; + Brush.Color := clWhite; + Rectangle(ARect.Left, ARect.Top + 1, ARect.Left + 34, ARect.Bottom - 4); + + Pen.Color := clBlack; + Pen.Style := TPenStyle(GetOrdValue); + HLine(Canvas, ARect.Left + 1, ARect.Top + (ARect.Bottom - ARect.Top) div 2 - 1, 32); + Pen.Style := psSolid; + end; +end; + +function TfrxFrameStyleProperty.GetExtraLBSize: Integer; +begin + Result := 36; +end; + + +{ TfrxDisplayFormatProperty } + +function TfrxDisplayFormatProperty.Edit: Boolean; +var + i: Integer; + c: TfrxComponent; +begin + with TfrxFormatEditorForm.Create(Designer) do + begin + Format.Assign(TfrxCustomMemoView(Component).DisplayFormat); + Result := ShowModal = mrOk; + if Result then + for i := 0 to Self.Designer.SelectedObjects.Count - 1 do + begin + c := Self.Designer.SelectedObjects[i]; + if (c is TfrxCustomMemoView) and not (rfDontModify in c.Restrictions) then + TfrxCustomMemoView(c).DisplayFormat := Format; + end; + Free; + end; +end; + +function TfrxDisplayFormatProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog, paMultiSelect, paReadOnly]; +end; + + +{ TfrxBooleanProperty } + +function TfrxBooleanProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paOwnerDraw]; +end; + +procedure TfrxBooleanProperty.OnDrawItem(Canvas: TCanvas; ARect: TRect); +var + add: Integer; +begin + inherited; + with Canvas do + begin + Rectangle(ARect.Left, ARect.Top + 1, ARect.Left + (ARect.Bottom - ARect.Top - 5), ARect.Bottom - 4); + Pen.Color := clBlack; + if Screen.PixelsPerInch > 96 then + add := 2 + else + add := 0; + if Boolean(GetOrdValue) = True then + with ARect do + begin + PolyLine([Point(Left + 2 + add, Top + 5 + add), Point(Left + 4 + add, Top + 7 + add), Point(Left + 9 + add, Top + 2 + add)]); + PolyLine([Point(Left + 2 + add, Top + 6 + add), Point(Left + 4 + add, Top + 8 + add), Point(Left + 9 + add, Top + 3 + add)]); + PolyLine([Point(Left + 2 + add, Top + 7 + add), Point(Left + 4 + add, Top + 9 + add), Point(Left + 9 + add, Top + 4 + add)]); + end; + end; +end; + +procedure TfrxBooleanProperty.OnDrawLBItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +var + add: Integer; +begin + inherited; + with TListBox(Control), TListBox(Control).Canvas do + begin + Brush.Color := clWindow; + Rectangle(ARect.Left + 2, ARect.Top + 2, ARect.Left + (ARect.Bottom - ARect.Top - 2), ARect.Bottom - 2); + Pen.Color := clBlack; + if Screen.PixelsPerInch > 96 then + add := 2 + else + add := 0; + if Index = 1 then + with ARect do + begin + PolyLine([Point(Left + 5 + add, Top + 6 + add), Point(Left + 7 + add, Top + 8 + add), Point(Left + 12 + add, Top + 3 + add)]); + PolyLine([Point(Left + 5 + add, Top + 7 + add), Point(Left + 7 + add, Top + 9 + add), Point(Left + 12 + add, Top + 4 + add)]); + PolyLine([Point(Left + 5 + add, Top + 8 + add), Point(Left + 7 + add, Top + 10 + add), Point(Left + 12 + add, Top + 5 + add)]); + end; + end; +end; + + +{ TfrxPrinterProperty } + +function TfrxPrinterProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paValueList]; +end; + +procedure TfrxPrinterProperty.GetValues; +begin + inherited; + Values.Assign(frxPrinters.Printers); + Values.Insert(0, frxResources.Get('prDefault')); +end; + + +{ TfrxPaperProperty } + +function TfrxPaperProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paValueList]; +end; + +function TfrxPaperProperty.GetValue: String; +var + i: Integer; +begin + i := frxPrinters.Printer.PaperIndex(GetOrdValue); + if i = -1 then + i := frxPrinters.Printer.PaperIndex(256); + Result := frxPrinters.Printer.Papers[i]; +end; + +procedure TfrxPaperProperty.GetValues; +begin + inherited; + Values.Assign(frxPrinters.Printer.Papers); +end; + +procedure TfrxPaperProperty.SetValue(const Value: String); +begin + SetOrdValue(frxPrinters.Printer.PaperNameToNumber(Value)); +end; + + +{ TfrxStyleProperty } + +function TfrxStyleProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paValueList, paMultiSelect]; +end; + +procedure TfrxStyleProperty.GetValues; +begin + inherited; + Designer.Report.Styles.GetList(Values); +end; + + +initialization + frxObjects.RegisterObject1(TfrxMemoView, nil, '', '', 0, 2, [ctReport, ctData]); + frxObjects.RegisterObject1(TfrxPictureView, nil, '', '', 0, 3); + frxObjects.RegisterObject1(TfrxSubreport, nil, '', '', 0, 4, [ctReport, ctDMP]); + frxObjects.RegisterObject1(TfrxSysMemoView, nil, '', '', 0, 32); + frxObjects.RegisterCategory('Draw', nil, 'obCatDraw', 6); + frxObjects.RegisterCategory('Other', nil, 'obCatOther', 66); + frxObjects.RegisterObject1(TfrxLineView, nil, '', 'Draw', 0, 5, [ctReport, ctData]); + frxObjects.RegisterObject1(TfrxLineView, nil, 'obDiagLine', 'Draw', 1, 7); + frxObjects.RegisterObject1(TfrxLineView, nil, 'obDiagLine', 'Draw', 2, 63); + frxObjects.RegisterObject1(TfrxLineView, nil, 'obDiagLine', 'Draw', 3, 64); + frxObjects.RegisterObject1(TfrxLineView, nil, 'obDiagLine', 'Draw', 4, 65); + frxObjects.RegisterObject1(TfrxShapeView, nil, 'obRect', 'Draw', 0, 8); + frxObjects.RegisterObject1(TfrxShapeView, nil, 'obRoundRect', 'Draw', 1, 9); + frxObjects.RegisterObject1(TfrxShapeView, nil, 'obEllipse', 'Draw', 2, 10); + frxObjects.RegisterObject1(TfrxShapeView, nil, 'obTrian', 'Draw', 3, 11); + frxObjects.RegisterObject1(TfrxShapeView, nil, 'obDiamond', 'Draw', 4, 31); + + frxComponentEditors.Register(TfrxReportPage, TfrxPageEditor); + frxComponentEditors.Register(TfrxView, TfrxViewEditor); + frxComponentEditors.Register(TfrxMemoView, TfrxMemoEditor); + frxComponentEditors.Register(TfrxSysMemoView, TfrxSysMemoEditor); + frxComponentEditors.Register(TfrxDMPMemoView, TfrxMemoEditor); + frxComponentEditors.Register(TfrxLineView, TfrxLineEditor); + frxComponentEditors.Register(TfrxDMPLineView, TfrxLineEditor); + frxComponentEditors.Register(TfrxPictureView, TfrxPictureEditor); + frxComponentEditors.Register(TfrxBand, TfrxBandEditor); + frxComponentEditors.Register(TfrxDataBand, TfrxDataBandEditor); + frxComponentEditors.Register(TfrxHeader, TfrxHeaderEditor); + frxComponentEditors.Register(TfrxPageHeader, TfrxPageHeaderEditor); + frxComponentEditors.Register(TfrxPageFooter, TfrxPageFooterEditor); + frxComponentEditors.Register(TfrxGroupHeader, TfrxGroupHeaderEditor); + frxComponentEditors.Register(TfrxDialogControl, TfrxDialogControlEditor); + frxComponentEditors.Register(TfrxSubReport, TfrxSubreportEditor); + + frxPropertyEditors.Register(TypeInfo(Extended), TfrxComponent, 'Left', TfrxLocSizeXProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxComponent, 'Top', TfrxLocSizeYProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxComponent, 'Width', TfrxLocSizeXProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxComponent, 'Height', TfrxLocSizeYProperty); + + frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'PaperWidth', TfrxPaperXProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'PaperHeight', TfrxPaperYProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'LeftMargin', TfrxPaperXProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'RightMargin', TfrxPaperXProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'TopMargin', TfrxPaperYProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxReportPage, 'BottomMargin', TfrxPaperYProperty); + frxPropertyEditors.Register(TypeInfo(Integer), TfrxReportPage, 'PaperSize', TfrxPaperProperty); + + frxPropertyEditors.RegisterEventEditor(TfrxEventProperty); + + frxPropertyEditors.Register(TypeInfo(Boolean), nil, '', TfrxBooleanProperty); + frxPropertyEditors.Register(TypeInfo(TfrxFrame), nil, '', TfrxFrameProperty); + frxPropertyEditors.Register(TypeInfo(TPicture), nil, '', TfrxPictureProperty); + frxPropertyEditors.Register(TypeInfo(TBitmap), nil, '', TfrxBitmapProperty); + frxPropertyEditors.Register(TypeInfo(TfrxDataSet), nil, '', TfrxDataSetProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxView, 'DataField', TfrxDataFieldProperty); + frxPropertyEditors.Register(TypeInfo(TStrings), nil, '', TfrxStringsProperty); + frxPropertyEditors.Register(TypeInfo(TWideStrings), TfrxCustomMemoView, 'Memo', TfrxMemoProperty); + frxPropertyEditors.Register(TypeInfo(TBrushStyle), nil, '', TfrxBrushProperty); + frxPropertyEditors.Register(TypeInfo(TfrxFrameStyle), nil, '', TfrxFrameStyleProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxMemoView, 'DisplayFormat', TfrxDisplayFormatProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxMemoView, 'Style', TfrxStyleProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxDataBand, 'ColumnWidth', TfrxLocSizeXProperty); + frxPropertyEditors.Register(TypeInfo(Extended), TfrxDataBand, 'ColumnGap', TfrxLocSizeXProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxPrintOptions, 'Printer', TfrxPrinterProperty); + frxPropertyEditors.Register(TypeInfo(Integer), TfrxPrintOptions, 'PrintOnSheet', TfrxPaperProperty); + frxPropertyEditors.Register(TypeInfo(Extended), nil, 'NextCrossGap', TfrxLocSizeXProperty); + frxPropertyEditors.Register(TypeInfo(Extended), nil, 'AddWidth', TfrxLocSizeXProperty); + frxPropertyEditors.Register(TypeInfo(Extended), nil, 'AddHeight', TfrxLocSizeYProperty); + + frxHideProperties(TfrxReport, 'DefaultLanguage;IniFile;Name;Preview;ScriptLanguage;ScriptText;Tag;Variables;DataSetName;DotMatrixReport;OldStyleProgress;ShowProgress;StoreInDFM;ParentReport'); + frxHideProperties(TfrxEngineOptions, 'NewSilentMode;MaxMemSize;PrintIfEmpty;SilentMode;TempDir;UseFileCache'); + frxHideProperties(TfrxPreviewOptions, 'AllowEdit;Buttons;DoubleBuffered;Maximized;MDIChild;Modal;ShowCaptions;Zoom;ZoomMode'); + frxHideProperties(TfrxReportOptions, 'CreateDate;LastChange;Compressed;Password'); + frxHideProperties(TfrxReportPage, 'Bin;BinOtherPages;ColumnWidth;ColumnPositions;DataSetName;HGuides;VGuides'); + frxHideProperties(TfrxDMPPage, 'BackPicture;Color;Font;Frame'); + frxHideProperties(TfrxReportComponent, 'GroupIndex'); + frxHideProperties(TfrxView, 'DataSetName'); + frxHideProperties(TfrxBand, 'Vertical'); + frxHideProperties(TfrxDataBand, 'DataSetName'); + frxHideProperties(TFont, 'Height;Pitch'); + frxHideProperties(TfrxHighlight, 'Active'); + frxHideProperties(TfrxPictureView, 'ImageIndex'); + frxHideProperties(TfrxSubreport, 'Page'); + frxHideProperties(TfrxDataPage, 'Left;Tag;Top;Visible'); + frxHideProperties(TfrxCustomMemoView, 'FirstParaBreak;LastParaBreak'); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDesgnIcon.res b/official/4.2/LibD11/frxDesgnIcon.res new file mode 100644 index 0000000..371cee8 Binary files /dev/null and b/official/4.2/LibD11/frxDesgnIcon.res differ diff --git a/official/4.2/LibD11/frxDesgnWorkspace.pas b/official/4.2/LibD11/frxDesgnWorkspace.pas new file mode 100644 index 0000000..d3b67f5 --- /dev/null +++ b/official/4.2/LibD11/frxDesgnWorkspace.pas @@ -0,0 +1,3034 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Common designer workspace } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDesgnWorkspace; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls, Buttons, frxClass, frxUnicodeCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +const + crPencil = 11; + +type + TfrxDesignMode = (dmSelect, dmInsert, dmDrag); + TfrxDesignMode1 = (dmNone, dmMove, dmSize, dmSizeBand, dmScale, + dmInplaceEdit, dmSelectionRect, dmInsertObject, dmInsertLine, + dmMoveGuide, dmContainer); + TfrxGridType = (gt1pt, gt1cm, gt1in, gtDialog, gtChar, gtNone); + TfrxCursorType = (ct0, ct1, ct2, ct3, ct4, ct5, ct6, ct7, ct8, ct9, ct10); + TfrxNotifyPositionEvent = procedure (ARect: TfrxRect) of object; + + TfrxInsertion = packed record + ComponentClass: TfrxComponentClass; + Left: Extended; + Top: Extended; + Width: Extended; + Height: Extended; + OriginalWidth: Extended; + OriginalHeight: Extended; + Flags: Word; + end; + + TfrxDesignerWorkspace = class(TPanel) + protected + FBandHeader: Extended; + FCanvas: TCanvas; + FColor: TColor; + FCT: TfrxCursorType; + FDblClicked: Boolean; + FDisableUpdate: Boolean; + FFreeBandsPlacement: Boolean; + FGapBetweenBands: Integer; + FGridAlign: Boolean; + FGridLCD: Boolean; + FGridType: TfrxGridType; + FGridX: Extended; + FGridY: Extended; + FInplaceMemo: TUnicodeMemo; + FInplaceObject: TfrxCustomMemoView; + FInsertion: TfrxInsertion; + FLastMousePointX: Extended; + FLastMousePointY: Extended; + FMargins: TRect; + FMarginsPanel: TPanel; + FMode: TfrxDesignMode; + FMode1: TfrxDesignMode1; + FModifyFlag: Boolean; + FMouseDown: Boolean; + FObjects: TList; + FOffsetX: Extended; + FOffsetY: Extended; + FPage: TfrxPage; + FPageHeight: Integer; + FPageWidth: Integer; + FScale: Extended; + FScaleRect: TfrxRect; + FScaleRect1: TfrxRect; + FSelectedObjects: TList; + FSelectionRect: TfrxRect; + FShowBandCaptions: Boolean; + FShowEdges: Boolean; + FShowGrid: Boolean; + FSizedBand: TfrxBand; + FOnModify: TNotifyEvent; + FOnEdit: TNotifyEvent; + FOnInsert: TNotifyEvent; + FOnNotifyPosition: TfrxNotifyPositionEvent; + FOnSelectionChanged: TNotifyEvent; + FOnTopLeftChanged: TNotifyEvent; + procedure DoModify; + procedure AdjustBandHeight(Bnd: TfrxBand); + procedure CheckGuides(var kx, ky: Extended; var Result: Boolean); virtual; + procedure DoNudge(dx, dy: Extended; Smooth: Boolean); + procedure DoSize(dx, dy: Extended); + procedure DoStick(dx, dy: Integer); + procedure DoTab; + procedure DrawBackground; + procedure DrawCross(Down: Boolean); + procedure DrawInsertionRect; + procedure DrawObjects; virtual; + procedure DrawSelectionRect; + procedure FindNearest(dx, dy: Integer); + procedure MouseLeave; + procedure NormalizeCoord(c: TfrxComponent); + procedure NormalizeRect(var R: TfrxRect); + procedure SelectionChanged; + procedure SetScale(Value: Extended); + procedure SetShowBandCaptions(const Value: Boolean); + procedure UpdateBandHeader; + + procedure DblClick; override; + procedure KeyDown(var Key: Word; Shift: TShiftState); override; + procedure KeyUp(var Key: Word; Shift: TShiftState); override; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE; + procedure WMMove(var Message: TWMMove); message WM_MOVE; + procedure WMEraseBackground(var Message: TMessage); message WM_ERASEBKGND; + + // debug + procedure PrepareShiftTree(Band: TfrxBand); + + procedure SetColor(const Value: TColor); + procedure SetGridType(const Value: TfrxGridType); + procedure SetOrigin(const Value: TPoint); + procedure SetParent(AParent: TWinControl); override; + procedure SetShowGrid(const Value: Boolean); + function GetOrigin: TPoint; + function GetRightBottomObject: TfrxComponent; + function GetSelectionBounds: TfrxRect; + function ListsEqual(List1, List2: TList): Boolean; + function SelectedCount: Integer; + public + constructor Create(AOwner: TComponent); override; + procedure Paint; override; + procedure AdjustBands; + procedure DeleteObjects; virtual; + procedure DisableUpdate; + procedure EnableUpdate; + procedure EditObject; virtual; + procedure GroupObjects; + procedure UngroupObjects; + procedure SetInsertion(AClass: TfrxComponentClass; + AWidth, AHeight: Extended; AFlag: Word); virtual; + procedure SetPageDimensions(AWidth, AHeight: Integer; AMargins: TRect); + procedure UpdateView; + + property BandHeader: Extended read FBandHeader write FBandHeader; + property Color: TColor read FColor write SetColor; + property FreeBandsPlacement: Boolean read FFreeBandsPlacement write FFreeBandsPlacement; + property GapBetweenBands: Integer read FGapBetweenBands write FGapBetweenBands; + property GridAlign: Boolean read FGridAlign write FGridAlign; + property GridLCD: Boolean read FGridLCD write FGridLCD; + property GridType: TfrxGridType read FGridType write SetGridType; + property GridX: Extended read FGridX write FGridX; + property GridY: Extended read FGridY write FGridY; + property Insertion: TfrxInsertion read FInsertion; + property IsMouseDown: Boolean read FMouseDown; + property Mode: TfrxDesignMode1 read FMode1; + property Objects: TList read FObjects write FObjects; + property OffsetX: Extended read FOffsetX write FOffsetX; + property OffsetY: Extended read FOffsetY write FOffsetY; + property Origin: TPoint read GetOrigin write SetOrigin; + property Page: TfrxPage read FPage write FPage; + property Scale: Extended read FScale write SetScale; + property SelectedObjects: TList read FSelectedObjects write FSelectedObjects; + property ShowBandCaptions: Boolean read FShowBandCaptions write SetShowBandCaptions; + property ShowEdges: Boolean read FShowEdges write FShowEdges; + property ShowGrid: Boolean read FShowGrid write SetShowGrid; + property OnModify: TNotifyEvent read FOnModify write FOnModify; + property OnEdit: TNotifyEvent read FOnEdit write FOnEdit; + property OnInsert: TNotifyEvent read FOnInsert write FOnInsert; + property OnNotifyPosition: TfrxNotifyPositionEvent read FOnNotifyPosition write + FOnNotifyPosition; + property OnSelectionChanged: TNotifyEvent read FOnSelectionChanged write + FOnSelectionChanged; + property OnTopLeftChanged: TNotifyEvent read FOnTopLeftChanged write + FOnTopLeftChanged; + end; + + TInplaceMemo = class(TUnicodeMemo) + private + FDesigner: TfrxDesignerWorkspace; + FObject: TfrxCustomMemoView; + FOriginalSize: TSize; + procedure LinesChange(Sender: TObject); + public + constructor Create(AOwner: TComponent); override; + procedure Edit(c: TfrxCustomMemoView); + procedure EditDone; + procedure KeyPress(var Key: Char); override; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + end; + + +implementation + +{$R *.res} + +uses frxRes, frxDMPClass, frxUtils, frxCtrls; + +const + DefFontName = 'Tahoma'; + + +type + TMarginsPanel = class(TPanel) + protected + FWorkspace: TfrxDesignerWorkspace; + procedure WMEraseBackground(var Message: TMessage); message WM_ERASEBKGND; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + public + constructor Create(AOwner: TComponent); override; + procedure Paint; override; + end; + + THackComponent = class(TfrxComponent); + + +{ TInplaceMemo } + +constructor TInplaceMemo.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FDesigner := TfrxDesignerWorkspace(AOwner); + Parent := FDesigner; + Visible := False; + WordWrap := False; + OnChange := LinesChange; +end; + +procedure TInplaceMemo.Edit(c: TfrxCustomMemoView); +var + s: WideString; +begin + FObject := c; + + s := c.Text; + if (s <> '') and (s[Length(s)] = #10) then + Delete(s, Length(s) - 1, 2); + Text := s; + + SetBounds(Round(c.AbsLeft * FDesigner.Scale), Round(c.AbsTop * FDesigner.Scale), + Round(c.Width * FDesigner.Scale + 1), Round(c.Height * FDesigner.Scale + 1)); + FOriginalSize.cx := Width; + FOriginalSize.cy := Height; + + Font.Assign(c.Font); + Font.Height := Round(Font.Height * FDesigner.Scale); + if c.Color = clNone then + Color := clWhite else + Color := c.Color; + Ctl3D := False; + BorderStyle := bsNone; + + Show; + SetFocus; + SelectAll; +end; + +procedure TInplaceMemo.EditDone; +begin + if Modified then + begin + FObject.Text := Text; + if FOriginalSize.cx <> Width then + FObject.Width := (Width + 5) / FDesigner.Scale; + if FOriginalSize.cy <> Height then + FObject.Height := (Height + 5) / FDesigner.Scale; + FDesigner.FModifyFlag := True; + FDesigner.DoModify; + end; + Hide; + FDesigner.Repaint; + FDesigner.Cursor := crDefault; +end; + +procedure TInplaceMemo.KeyPress(var Key: Char); +begin + if Key = #27 then + begin + Modified := False; + EditDone; + end; +end; + +procedure TInplaceMemo.LinesChange(Sender: TObject); +var + i, w0, w, h: Integer; +begin + h := (-Font.Height + 3) * Lines.Count + 4; + if h > Height - Font.Height then + Height := h; + + FDesigner.Canvas.Font := Font; + + w := Width; + for i := 0 to Lines.Count - 1 do + begin + w0 := FDesigner.Canvas.TextWidth(Lines[i]) + 6; + if w0 > w then + w := w0; + end; + + if w > Width then + Width := w; +end; + +procedure TInplaceMemo.MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + EditDone; +end; + + +{ TMarginsPanel } + +constructor TMarginsPanel.Create(AOwner: TComponent); +begin + inherited; + Color := clWindow; + BevelInner := bvNone; + BevelOuter := bvNone; +end; + +procedure TMarginsPanel.MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + inherited; + FWorkspace.MouseDown(Button, Shift, X - (FWorkspace.Left - Left), + Y - (FWorkspace.Top - Top)); +end; + +procedure TMarginsPanel.MouseMove(Shift: TShiftState; X, Y: Integer); +begin + inherited; + + if FWorkspace.FMode = dmSelect then + FWorkspace.MouseMove(Shift, X - (FWorkspace.Left - Left), + Y - (FWorkspace.Top - Top)) else + FWorkspace.MouseLeave; + Cursor := FWorkspace.Cursor; +end; + +procedure TMarginsPanel.MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + inherited; + FWorkspace.MouseUp(Button, Shift, X - (FWorkspace.Left - Left), + Y - (FWorkspace.Top - Top)); +end; + +procedure TMarginsPanel.Paint; +var + r: TRect; +begin + with Canvas do + begin + Brush.Color := Color; + Pen.Color := $505050; + Pen.Width := 1; + Pen.Style := psSolid; + + Rectangle(0, 0, Width - 1, Height - 1); + Polyline([Point(1, Height - 1), Point(Width - 1, Height - 1), Point(Width - 1, 0)]); + + Pixels[0, Height - 1] := clGray; + Pixels[Width - 1, 0] := clGray; + + + Pen.Color := clSilver; + Pen.Style := psDot; + with FWorkspace, FWorkspace.FMargins do + r := Rect(Round(Left * FScale), Round(Top * FScale), + Self.Width - Round(Right * FScale) + 1, + Self.Height - Round(Bottom * FScale) + 1); + + Polyline([Point(r.Left - 1, r.Top - 1), + Point(r.Left - 1, r.Bottom), + Point(r.Right, r.Bottom), + Point(r.Right, r.Top - 1), + Point(r.Left - 1, r.Top - 1)]); + end; +end; + +procedure TMarginsPanel.WMEraseBackground(var Message: TMessage); +begin +// +end; + + +{ TfrxDesignerWorkspace } + +constructor TfrxDesignerWorkspace.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FullRepaint := False; + Screen.Cursors[crPencil] := LoadCursor(hInstance, 'frxPENCIL'); + + FMarginsPanel := TMarginsPanel.Create(AOwner); + TMarginsPanel(FMarginsPanel).FWorkspace := Self; + FInplaceMemo := TInplaceMemo.Create(Self); + + FBandHeader := fr01cm * 5; + FColor := clWhite; + FGridAlign := True; + FGridType := gt1cm; + FGridX := fr01cm; + FGridY := fr01cm; + FMode := dmSelect; + FMode1 := dmNone; + FScale := 1; + FShowGrid := True; + FShowEdges := True; +end; + +procedure TfrxDesignerWorkspace.SetParent(AParent: TWinControl); +begin + if not (csDestroying in ComponentState) then + FMarginsPanel.Parent := AParent; + inherited; +end; + +procedure TfrxDesignerWorkspace.DisableUpdate; +begin + FDisableUpdate := True; + FMode := dmSelect; + FMode1 := dmNone; +end; + +procedure TfrxDesignerWorkspace.EnableUpdate; +begin + FDisableUpdate := False; +end; + +procedure TfrxDesignerWorkspace.UpdateView; +var + NotifyRect: TfrxRect; +begin + Invalidate; + if SelectedCount = 0 then + NotifyRect := frxRect(0, 0, 0, 0) else + NotifyRect := GetSelectionBounds; + if Assigned(FOnNotifyPosition) then + FOnNotifyPosition(NotifyRect); +end; + +procedure TfrxDesignerWorkspace.WMMove(var Message: TWMMove); +begin + inherited; + if Assigned(FOnTopLeftChanged) then + FOnTopLeftChanged(Self); +end; + +procedure TfrxDesignerWorkspace.SetInsertion(AClass: TfrxComponentClass; + AWidth, AHeight: Extended; AFlag: Word); +begin + with FInsertion do + begin + ComponentClass := AClass; + Width := AWidth; + Height := AHeight; + OriginalWidth := AWidth; + OriginalHeight := AHeight; + Flags := AFlag; + end; + + FMode := dmInsert; + if AClass = nil then + begin + FMode := dmSelect; + FMode1 := dmNone; + end + else if AClass.InheritsFrom(TfrxCustomLineView) then + begin + Cursor := crPencil; + FMode1 := dmInsertLine; + if FGridType = gtChar then + begin + FInsertion.Left := - FGridX / 2; + FInsertion.Top := - FGridY / 2; + end + else + begin + FInsertion.Left := - FGridX; + FInsertion.Top := - FGridY; + end; + end + else + begin + Cursor := crCross; + FMode1 := dmInsertObject; + FInsertion.Left := -1000 * FGridX; + FInsertion.Top := -1000 * FGridY; + end; +end; + +procedure TfrxDesignerWorkspace.SetScale(Value: Extended); +begin + FScale := Value; + + FMarginsPanel.Width := Round(FPageWidth * FScale); + FMarginsPanel.Height := Round(FPageHeight * FScale); + + SetBounds(FMarginsPanel.Left + Round(FMargins.Left * FScale), + FMarginsPanel.Top + Round(FMargins.Top * FScale), + FMarginsPanel.Width - Round((FMargins.Left + FMargins.Right - 1) * FScale), + FMarginsPanel.Height - Round((FMargins.Top + FMargins.Bottom - 1) * FScale)); + + FMarginsPanel.Invalidate; + Invalidate; +end; + +procedure TfrxDesignerWorkspace.SetPageDimensions(AWidth, AHeight: Integer; + AMargins: TRect); +begin + FPageWidth := AWidth; + FPageHeight := AHeight; + FMargins := AMargins; + SetScale(FScale); + AdjustBands; +end; + +procedure TfrxDesignerWorkspace.SetShowGrid(const Value: Boolean); +begin + FShowGrid := Value; + Invalidate; +end; + +procedure TfrxDesignerWorkspace.UpdateBandHeader; +begin + case FGridType of + gt1pt, gtDialog: + FBandHeader := 16; + gt1cm: + FBandHeader := fr01cm * 5; + gt1in: + FBandHeader := fr01in * 2; + gtChar: + FBandHeader := fr1CharY; + end; + + if not FShowBandCaptions then + FBandHeader := 0; +end; + +procedure TfrxDesignerWorkspace.SetGridType(const Value: TfrxGridType); +begin + FGridType := Value; + UpdateBandHeader; + if FSelectedObjects.Count <> 0 then + MouseMove([], 0, 0); + AdjustBands; + Invalidate; +end; + +procedure TfrxDesignerWorkspace.SetShowBandCaptions(const Value: Boolean); +begin + FShowBandCaptions := Value; + UpdateBandHeader; + AdjustBands; + Invalidate; +end; + +function TfrxDesignerWorkspace.GetOrigin: TPoint; +begin + Result.X := FMarginsPanel.Left; + Result.Y := FMarginsPanel.Top; +end; + +procedure TfrxDesignerWorkspace.SetOrigin(const Value: TPoint); +begin + FMarginsPanel.Left := Value.X; + FMarginsPanel.Top := Value.Y; +end; + +procedure TfrxDesignerWorkspace.SetColor(const Value: TColor); +begin + FColor := Value; + FMarginsPanel.Color := Value; +end; + +procedure TfrxDesignerWorkspace.DoModify; +begin + if FModifyFlag then + if Assigned(FOnModify) then + FOnModify(Self); + FModifyFlag := False; +end; + +procedure TfrxDesignerWorkspace.SelectionChanged; +var + i, j: Integer; + c, c1: TfrxComponent; +begin + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + if (c is TfrxReportComponent) and (c.GroupIndex <> 0) then + for j := 0 to FObjects.Count - 1 do + begin + c1 := FObjects[j]; + if (c1 is TfrxReportComponent) and (c1.GroupIndex = c.GroupIndex) then + begin + if FSelectedObjects.IndexOf(c1) = -1 then + FSelectedObjects.Add(c1); + end; + end; + end; + + if Assigned(FOnSelectionChanged) then + FOnSelectionChanged(Self); + Repaint; +end; + +function TfrxDesignerWorkspace.GetSelectionBounds: TfrxRect; +var + i: Integer; + c: TfrxComponent; +begin + if SelectedCount = 1 then + begin + with TfrxComponent(FSelectedObjects[0]) do + Result := frxRect(Left, Top, Width, Height); + Exit; + end; + + Result := frxRect(1e10, 1e10, -1e10, -1e10); + + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + + if c.AbsLeft < Result.Left then + Result.Left := c.AbsLeft; + if c.AbsTop < Result.Top then + Result.Top := c.AbsTop; + if c.AbsLeft + c.Width > Result.Right then + Result.Right := c.AbsLeft + c.Width; + if c.AbsTop + c.Height > Result.Bottom then + Result.Bottom := c.AbsTop + c.Height; + end; + + with Result do + Result := frxRect(Left, Top, Right - Left, Bottom - Top); +end; + +function TfrxDesignerWorkspace.GetRightBottomObject: TfrxComponent; +var + i: Integer; + c: TfrxComponent; + maxx, maxy: Extended; +begin + maxx := 0; + maxy := 0; + Result := nil; + + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + if (c.AbsLeft + c.Width > maxx) or + ((c.AbsLeft + c.Width = maxx) and (c.AbsTop + c.Height > maxy)) then + begin + maxx := c.AbsLeft + c.Width; + maxy := c.AbsTop + c.Height; + Result := c; + end; + end; +end; + +function TfrxDesignerWorkspace.SelectedCount: Integer; +begin + Result := FSelectedObjects.Count; + if (Result = 1) and + ((FSelectedObjects[0] = FPage) or (TObject(FSelectedObjects[0]) is TfrxReport)) then + Result := 0; +end; + +procedure TfrxDesignerWorkspace.WMEraseBackground(var Message: TMessage); +begin +// do nothing, prevent flickering +end; + +procedure TfrxDesignerWorkspace.Paint; +var + bmp: TBitmap; +begin + bmp := TBitmap.Create; + try + with Canvas.ClipRect do + begin + bmp.Width := Right - Left; + bmp.Height := Bottom - Top; + FCanvas := bmp.Canvas; + SetViewPortOrgEx(FCanvas.Handle, -Left, -Top, nil); + end; + + DrawBackground; + if not FDisableUpdate then + begin + if (FPage <> nil) and (FPage is TfrxReportPage) then + TfrxReportPage(FPage).Draw(FCanvas, FScale, FScale, + -FMargins.Left * FScale, + -FMargins.Top * FScale); + DrawObjects; + end; + + BitBlt(Canvas.Handle, 0, 0, Width, Height, FCanvas.Handle, 0, 0, SRCCOPY); + finally + bmp.Free; + end; + FCanvas := nil; +end; + +procedure TfrxDesignerWorkspace.DrawObjects; +var + i: Integer; + c: TfrxComponent; + + function CreateRotatedFont(Font: TFont; Rotation: Integer): HFont; + var + F: TLogFont; + begin + GetObject(Font.Handle, SizeOf(TLogFont), @F); + F.lfEscapement := Rotation * 10; + F.lfOrientation := Rotation * 10; + Result := CreateFontIndirect(F); + end; + + procedure DrawPoint(x, y: Extended); + var + i, w: Integer; + begin + if FScale > 1.7 then + w := 7 + else if FScale < 0.7 then + w := 3 else + w := 5; + for i := 0 to w - 1 do + begin + FCanvas.MoveTo(Round(x * FScale) - w div 2, Round(y * FScale) - w div 2 + i); + FCanvas.LineTo(Round(x * FScale) + w div 2 +1, Round(y * FScale) - w div 2 + i); + end; + end; + + procedure DrawLine(x, y, dx, dy: Extended); + begin + FCanvas.MoveTo(Round(x * FScale), Round(y * FScale)); + FCanvas.LineTo(Round((x + dx) * FScale), Round((y + dy) * FScale)); + end; + + procedure DrawSqares(c: TfrxComponent); + var + px, py: Extended; + begin + with c, FCanvas do + begin + Pen.Style := psSolid; + Pen.Width := 1; + Pen.Mode := pmXor; + Pen.Color := clWhite; + px := AbsLeft + Width / 2; + py := AbsTop + Height / 2; + + DrawPoint(AbsLeft, AbsTop); + if not (c is TfrxCustomLineView) then + begin + DrawPoint(AbsLeft + Width, AbsTop); + DrawPoint(AbsLeft, AbsTop + Height); + end; + if (SelectedCount > 1) and (c = GetRightBottomObject) then + Pen.Color := clTeal; + DrawPoint(AbsLeft + Width, AbsTop + Height); + + Pen.Color := clWhite; + if (SelectedCount = 1) and not (c is TfrxCustomLineView) then + begin + DrawPoint(px, AbsTop); DrawPoint(px, AbsTop + Height); + DrawPoint(AbsLeft, py); DrawPoint(AbsLeft + Width, py); + end; + + Pen.Mode := pmCopy; + end; + end; + + procedure DrawScriptSign(c: TfrxReportComponent); + var + NeedDraw: Boolean; + Offs: Extended; + begin + NeedDraw := False; + Offs := 0; + if c is TfrxReportComponent then + with c do + if (OnBeforePrint <> '') or (OnAfterPrint <> '') or + (OnAfterData <> '') or (OnPreviewClick <> '') then + NeedDraw := True; + if c is TfrxDialogControl then + with TfrxDialogControl(c) do + if (OnClick <> '') or (OnDblClick <> '') or + (OnEnter <> '') or (OnExit <> '') or + (OnKeyDown <> '') or (OnKeyPress <> '') or + (OnKeyUp <> '') or (OnMouseDown <> '') or + (OnMouseMove <> '') or (OnMouseUp <> '') then + NeedDraw := True; + if c is TfrxBand then + with TfrxBand(c) do + begin + if (OnAfterCalcHeight <> '') then + NeedDraw := True; + if not Vertical then + Offs := -FBandHeader + 2; + end; + + if NeedDraw then + with c, FCanvas do + begin + Pen.Style := psSolid; + Pen.Color := clRed; + Pen.Width := 1; + DrawLine(AbsLeft + 2, AbsTop + Offs + 1, 0, 7); + DrawLine(AbsLeft + 3, AbsTop + Offs + 2, 0, 5); + DrawLine(AbsLeft + 4, AbsTop + Offs + 3, 0, 3); + DrawLine(AbsLeft + 5, AbsTop + Offs + 4, 0, 1); + end; + end; + + procedure DrawObject(c: TfrxReportComponent); + var + s: String; + i, w, x, y: Integer; + d: TfrxDataBand; + fh, oldfh: HFont; + begin + c.IsDesigning := True; + c.Draw(FCanvas, FScale, FScale, FOffsetX, FOffsetY); + + if c is TfrxBand then + with c as TfrxBand, FCanvas do + begin + if Vertical then + begin + Top := 0; + Pen.Style := psSolid; + Pen.Color := clGray; + Pen.Width := 1; + Brush.Style := bsClear; + x := Round((Left - FBandHeader) * FScale); + Rectangle(x, 0, Round((Left + Width) * FScale) + 1, Round((Height) * FScale)); + + if FShowBandCaptions then + begin + Brush.Style := bsSolid; + if c is TfrxDataBand then + Brush.Color := $EEBB00 else + Brush.Color := clBtnFace; + FillRect(Rect(x + 1, 1, Round(Left * FScale), Round(Height * FScale))); + end; + + Font.Name := DefFontName; + Font.Size := Round(8 * FScale); + Font.Color := clBlack; + Font.Style := []; + fh := CreateRotatedFont(Font, 90); + oldfh := SelectObject(Handle, fh); + y := TextWidth(Name) + 4; + TextOut(x + 2, y, Name); + SelectObject(Handle, oldfh); + DeleteObject(fh); + Font.Style := [fsBold]; + fh := CreateRotatedFont(Font, 90); + oldfh := SelectObject(Handle, fh); + TextOut(x + 2, y + TextWidth(BandName + ': ') + 2, BandName + ': '); + SelectObject(Handle, oldfh); + DeleteObject(fh); + end + else + begin + Left := 0; + if (Page is TfrxReportPage) and (TfrxReportPage(Page).Columns > 1) then + if BandNumber in [4..16] then + Width := TfrxReportPage(Page).ColumnWidth * fr01cm; + Pen.Style := psSolid; + Pen.Color := clGray; + Pen.Width := 1; + Brush.Style := bsClear; + y := Round((Top - FBandHeader) * FScale); + Rectangle(0, y, Round(Width * FScale) + 1, Round((Top + Height) * FScale) + 1); + + if FShowBandCaptions then + begin + Brush.Style := bsSolid; + if c is TfrxDataBand then + Brush.Color := $30A7E0 + else + Brush.Color := clBtnFace; + FillRect(Rect(1, y + 1, Round(Width * FScale), Round(Top * FScale))); + end; + + Font.Name := DefFontName; + Font.Size := Round(8 * FScale); + Font.Color := clBlack; + Font.Style := [fsBold]; + TextOut(6, y + 2, BandName); + Font.Style := []; + TextOut(PenPos.X, y + 2, ': ' + Name); + + if c is TfrxDataBand then + begin + d := TfrxDataBand(c); + + if FShowBandCaptions then + begin + if (d.DataSet <> nil) and (c.Report <> nil) then + s := c.Report.GetAlias(d.DataSet) + else if d.RowCount <> 0 then + s := IntToStr(d.RowCount) + else + s := ''; + w := TextWidth(s); + if FScale > 0.7 then + frxResources.MainButtonImages.Draw(FCanvas, + Round(Width * FScale - w - 24), Round(y + 2 * FScale), 53); + if s <> '' then + TextOut(Round(Width * FScale - w - 3), y + 3, s); + end; + + if d.Columns > 1 then + begin + Pen.Style := psDot; + Pen.Color := clBlack; + Brush.Style := bsClear; + for i := 1 to d.Columns do + Rectangle(Round((i - 1) * (d.ColumnWidth + d.ColumnGap) * FScale), + Round(Top * FScale), + Round(((i - 1) * (d.ColumnWidth + d.ColumnGap) + d.ColumnWidth) * FScale), + Round((Top + Height) * FScale)); + end; + end; + if c is TfrxGroupHeader then + begin + s := TfrxGroupHeader(c).Condition; + if s <> '' then + if FShowBandCaptions then + TextOut(Round(Width * FScale - TextWidth(s) - 3), y + 3, s); + end; + end + end + else if not (c is TfrxCustomLineView) and not (c is TfrxDialogComponent) and + not (c is TfrxDialogControl) then + with c, FCanvas do + if FShowEdges and not (FPage is TfrxDataPage) and (c is TfrxView) and + (TfrxView(c).Frame.Typ <> [ftLeft, ftRight, ftTop, ftBottom]) then + begin + Pen.Style := psSolid; + Pen.Color := clBlack; + Pen.Width := 1; + DrawLine(AbsLeft, AbsTop + 3, 0, -3); + DrawLine(AbsLeft, AbsTop, 4, 0); + DrawLine(AbsLeft, AbsTop + Height - 3, 0, 3); + DrawLine(AbsLeft, AbsTop + Height, 4, 0); + DrawLine(AbsLeft + Width - 3, AbsTop, 3, 0); + DrawLine(AbsLeft + Width, AbsTop, 0, 4); + DrawLine(AbsLeft + Width - 3, AbsTop + Height, 3, 0); + DrawLine(AbsLeft + Width, AbsTop + Height, 0, -4); + end; + + DrawScriptSign(c); + + if c.IsAncestor then + frxResources.MainButtonImages.Draw(FCanvas, + Round((c.AbsLeft + 2) * FScale), Round((c.AbsTop + 1) * FScale), 99); + end; + + // debug + procedure DrawShiftTree(c: TfrxReportComponent); + var + i: Integer; + c1: TfrxReportComponent; + begin + for i := 0 to c.FShiftChildren.Count - 1 do + begin + c1 := c.FShiftChildren[i]; + with FCanvas do + begin + Pen.Style := psSolid; + Pen.Color := clRed; + Pen.Mode := pmCopy; + Pen.Width := 1; + if c is TfrxBand then + MoveTo(Round(c.AbsLeft + c.Width / 2), Round(c.AbsTop)) + else + MoveTo(Round(c.AbsLeft + c.Width / 2), Round(c.AbsTop + c.Height)); + LineTo(Round(c1.AbsLeft + c1.Width / 2), Round(c1.AbsTop)); + end; + DrawShiftTree(c1); + end; + end; + + +begin + { update aligned objects } + if Page is TfrxReportPage then + Page.AlignChildren; + + { draw objects } + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if c is TfrxReportComponent then + DrawObject(TfrxReportComponent(c)); + end; + + // debug +{ for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if c is TfrxBand then + begin + PrepareShiftTree(TfrxBand(c)); + DrawShiftTree(TfrxReportComponent(c)); + end; + end;} + + + { draw selection } + for i := 0 to SelectedCount - 1 do + if not FMouseDown then + DrawSqares(FSelectedObjects[i]); +end; + +procedure TfrxDesignerWorkspace.DrawBackground; + + procedure Line(x, y, x1, y1: Integer); + begin + FCanvas.MoveTo(x, y); + FCanvas.LineTo(x1, y1); + end; + + procedure DrawPoints; + var + GridBmp: TBitmap; + i: Extended; + c: TColor; + dx, dy: Extended; + begin + if FGridType = gtDialog then + c := clBlack else + c := clGray; + dx := FGridX * FScale; + dy := FGridY * FScale; + if (dx > 2) and (dy > 2) then + begin + GridBmp := TBitmap.Create; + GridBmp.Width:= Width; + GridBmp.Height := 1; + + GridBmp.Canvas.Pen.Color := FColor; + GridBmp.Canvas.MoveTo(0, 0); + GridBmp.Canvas.LineTo(Width, 0); + + i := 0; + while i < Width do + begin + GridBmp.Canvas.Pixels[Round(i), 0] := c; + i := i + dx; + end; + + i := 0; + while i < Height do + begin + FCanvas.Draw(0, Round(i), GridBmp); + i := i + dy; + end; + + GridBmp.Free; + end; + end; + + procedure DrawMM; + var + i, dx, maxi: Extended; + i1: Integer; + Color5, Color10: TColor; + begin + if FGridLCD then + begin + Color5 := $F2F2F2; + Color10 := $E2E2E2; + end + else + begin + Color5 := $F8F8F8; + Color10 := $E8E8E8; + end; + + with FCanvas do + begin + Pen.Width := 1; + Pen.Mode := pmCopy; + Pen.Style := psSolid; + + if FGridType = gt1cm then + dx := fr01cm * FScale else + dx := fr01in * FScale; + + if Width > Height then + maxi := Width else + maxi := Height; + + i := 0; + i1 := 0; + while i < maxi do + begin + if i1 mod 10 = 0 then + Pen.Color := Color10 + else if i1 mod 5 = 0 then + Pen.Color := Color5 + else if FGridType = gt1in then + Pen.Color := Color5 + else + Pen.Color := clWhite; + if Pen.Color <> clWhite then + begin + Line(Round(i), 0, Round(i), Height); + Line(0, Round(i), Width, Round(i)); + end; + i := i + dx; + Inc(i1); + end; + end; + end; + +begin + FCanvas.Brush.Color := FColor; + FCanvas.Brush.Style := bsSolid; + FCanvas.FillRect(Rect(0, 0, Width, Height)); + + if FShowGrid then + case FGridType of + gt1pt, gtDialog, gtChar: + DrawPoints; + gt1cm, gt1in: + DrawMM; + end; +end; + +procedure TfrxDesignerWorkspace.DrawSelectionRect; +begin + with Canvas do + begin + Pen.Mode := pmXor; + Pen.Color := clSilver; + Pen.Width := 1; + Pen.Style := psDot; + Brush.Style := bsClear; + with FSelectionRect do + Rectangle(Round(Left), Round(Top), Round(Right), Round(Bottom)); + Pen.Mode := pmCopy; + Brush.Style := bsSolid; + end; +end; + +procedure TfrxDesignerWorkspace.DrawInsertionRect; +var + R: TfrxRect; +begin + with Canvas do + begin + Pen.Mode := pmCopy; + Pen.Color := clBlack; + Pen.Width := 1; + Pen.Style := psDot; + Brush.Style := bsClear; + with FInsertion do + R := frxRect(Left, Top, Left + Width, Top + Height); + NormalizeRect(R); + Rectangle(Round(R.Left * FScale), Round(R.Top * FScale), + Round(R.Right * FScale) + 1, Round(R.Bottom * FScale) + 1); + Brush.Style := bsSolid; + end; +end; + +procedure TfrxDesignerWorkspace.DrawCross(Down: Boolean); +var + x, y: Extended; +begin + with FInsertion do + if Down then + begin + if Flags <> 0 then + begin + x := (Left + Width) * FScale; + y := (Top + Height) * FScale; + end + else if Abs(Width) > Abs(Height) then + begin + x := (Left + Width) * FScale; + y := Top * FScale; + end + else + begin + x := Left * FScale; + y := (Top + Height) * FScale; + end; + end + else + begin + x := Left * FScale; + y := Top * FScale; + end; + + with Canvas do + begin + Pen.Mode := pmXor; + Pen.Color := clSilver; + Pen.Width := 1; + Pen.Style := psSolid; + MoveTo(Round(x - 4), Round(y)); + LineTo(Round(x + 5), Round(y)); + MoveTo(Round(x), Round(y - 4)); + LineTo(Round(x), Round(y + 5)); + if Down then + begin + MoveTo(Round(FInsertion.Left * FScale), Round(FInsertion.Top * FScale)); + LineTo(Round(x), Round(y)); + end; + + Pen.Mode := pmCopy; + end; +end; + +procedure TfrxDesignerWorkspace.FindNearest(dx, dy: Integer); +var + i: Integer; + c, sel, found: TfrxComponent; + min, dist, dist_dx, dist_dy: Extended; + r1, r2, r3: TfrxRect; + + function RectsIntersect(r1, r2: TfrxRect): Boolean; + begin + Result := not ((r2.Left > r1.Right) or (r2.Right < r1.Left) or + (r2.Top > r1.Bottom) or (r2.Bottom < r1.Top)); + end; + +begin + if SelectedCount <> 1 then Exit; + + found := nil; + sel := FSelectedObjects[0]; + min := 1e10; + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if not (c is TfrxReportComponent) or (c is TfrxBand) or (c = sel) then continue; + + r1 := frxRect(c.AbsLeft, c.AbsTop, c.AbsLeft + c.Width, c.AbsTop + c.Height); + dist := 0; + dist_dx := 0; + dist_dy := 0; + with sel do + if dx = 1 then + begin + r2 := frxRect(AbsLeft, AbsTop, 1e10, AbsTop + Height); + r3 := frxRect(AbsLeft, 0, 1e10, 1e10); + dist := r1.Left - r2.Left; + dist_dx := r1.Left - (AbsLeft + Width); + if r1.Top > r2.Top then + dist_dy := r1.Top - r2.Bottom else + dist_dy := r2.Top - r1.Bottom; + end + else if dx = -1 then + begin + r2 := frxRect(-1e10, AbsTop, AbsLeft + Width, AbsTop + Height); + r3 := frxRect(0, 0, AbsLeft + Width, 1e10); + dist := r2.Right - r1.Right; + dist_dx := AbsLeft - r1.Right; + if r1.Top > r2.Top then + dist_dy := r1.Top - r2.Bottom else + dist_dy := r2.Top - r1.Bottom; + end + else if dy = 1 then + begin + r2 := frxRect(AbsLeft, AbsTop, AbsLeft + Width, 1e10); + r3 := frxRect(0, AbsTop, 1e10, 1e10); + dist := r1.Top - r2.Top; + dist_dy := r1.Top - (AbsTop + Height); + if r1.Left > r2.Left then + dist_dx := r1.Left - r2.Right else + dist_dx := r2.Left - r1.Right; + end + else if dy = -1 then + begin + r2 := frxRect(AbsLeft, -1e10, AbsLeft + Width, AbsTop + Height); + r3 := frxRect(0, 0, 1e10, AbsTop + Height); + dist := r2.Bottom - r1.Bottom; + dist_dy := AbsTop - r1.Bottom; + if r1.Left > r2.Left then + dist_dx := r1.Left - r2.Right else + dist_dx := r2.Left - r1.Right; + end; + + if not RectsIntersect(r1, r2) then + begin + if (not RectsIntersect(r1, r3)) or + ((dx <> 0) and (dist_dx < dist_dy)) or + ((dy <> 0) and (dist_dy < dist_dx)) or + ((dist_dx = 0) and (dist_dy = 0)) then continue; + dist := sqrt(dist_dx * dist_dx + dist_dy * dist_dy) * (Width + Height); + end; + + if dist < min then + begin + found := c; + min := dist; + end; + end; + + if found <> nil then + begin + FSelectedObjects.Clear; + FSelectedObjects.Add(found); + if Assigned(FOnNotifyPosition) then + FOnNotifyPosition(GetSelectionBounds); + SelectionChanged; + end; +end; + +procedure TfrxDesignerWorkspace.NormalizeCoord(c: TfrxComponent); +begin + if c.Width < 0 then + begin + c.Width := -c.Width; + c.Left := c.Left - c.Width; + end; + if c.Height < 0 then + begin + c.Height := -c.Height; + c.Top := c.Top - c.Height; + end; +end; + +procedure TfrxDesignerWorkspace.NormalizeRect(var R: TfrxRect); +var + i: Extended; +begin + with R do + begin + if Left > Right then + begin + i := Left; + Left := Right; + Right := i + end; + if Top > Bottom then + begin + i := Top; + Top := Bottom; + Bottom := i + end; + end; +end; + +procedure TfrxDesignerWorkspace.AdjustBands; +var + i, j: Integer; + sl: TStringList; + b: TfrxBand; + c, c0: TfrxComponent; + add, add1: Extended; + l: TList; + ch: TfrxChild; + + procedure DoBand(Bnd: TfrxBand); + var + y: Extended; + begin + if Bnd.Vertical then Exit; + + if Bnd is TfrxPageHeader then + y := 0 + else if Bnd is TfrxReportTitle then + y := 0.01 + else if Bnd is TfrxColumnHeader then + y := 0.02 + else if Bnd is TfrxColumnFooter then + y := 99999 + else if Bnd is TfrxReportSummary then + y := 100000 + else if Bnd is TfrxPageFooter then + y := 100001 + else + y := Abs(Bnd.Top); + + if TfrxReportPage(FPage).TitleBeforeHeader then + begin + if Bnd is TfrxReportTitle then + y := 0 + else if Bnd is TfrxPageHeader then + y := 0.01 + end; + + sl.AddObject(Format('%9.2f', [y]), Bnd); + end; + + procedure TossObjects(Bnd: TfrxBand); + var + i: Integer; + c: TfrxComponent; + SaveRestrictions: TfrxRestrictions; + begin + if Bnd.Vertical then Exit; + + while Bnd.Objects.Count > 0 do + begin + c := Bnd.Objects[0]; + SaveRestrictions := c.Restrictions; + c.Restrictions := []; + c.Top := c.AbsTop; + c.Restrictions := SaveRestrictions; + c.Parent := Bnd.Parent; + end; + + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if (c is TfrxView) and (c.AbsTop >= Bnd.Top - 1e-4) and (c.AbsTop < Bnd.Top + Bnd.Height + 1e-4) then + begin + SaveRestrictions := c.Restrictions; + c.Restrictions := []; + c.Top := c.AbsTop - Bnd.Top; + c.Restrictions := SaveRestrictions; + c.Parent := Bnd; + end; + end; + end; + + function Round8(e: Extended): Extended; + begin + Result := Round(e * 100000000) / 100000000; + end; + + procedure AdjustParent(Ctrl: TfrxComponent; Index: Integer); + var + i: Integer; + c: TfrxComponent; + found: Boolean; + begin + found := False; + for i := Index - 1 downto 0 do + begin + c := FObjects[i]; + if (c <> Ctrl) and (c is TfrxDialogControl) and + (csAcceptsControls in TfrxDialogControl(c).Control.ControlStyle) then + if (Ctrl.AbsLeft >= c.AbsLeft) and + (Ctrl.AbsTop >= c.AbsTop) and (Ctrl.AbsLeft < c.AbsLeft + c.Width) and + (Ctrl.AbsTop < c.AbsTop + c.Height) then + begin + Ctrl.Top := Ctrl.AbsTop - c.AbsTop; + Ctrl.Left := Ctrl.AbsLeft - c.AbsLeft; + Ctrl.Parent := c; + found := True; + break; + end; + end; + + if not found and (Ctrl.Parent <> Page) then + begin + Ctrl.Top := Ctrl.AbsTop; + Ctrl.Left := Ctrl.AbsLeft; + Ctrl.Parent := Page; + BringToFront; + end; + end; + +begin + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupAccept; + + { sort bands } + for i := 0 to FObjects.Count - 1 do + if TObject(FObjects[i]) is TfrxBand then + DoBand(FObjects[i]); + + { arrange child bands } + sl.Sorted := False; + i := 0; + while i < sl.Count do + begin + sl[i] := ''; + b := TfrxBand(sl.Objects[i]); + if b.Child <> nil then + begin + j := sl.IndexOfObject(b.Child); + if j <> -1 then + begin + c := TfrxComponent(sl.Objects[j]); + sl.Delete(j); + if j < i then + Dec(i); + sl.InsertObject(i + 1, '', c); + end; + end; + Inc(i); + end; + + { set top/middle/bottom indexes } + i := 0; + while i < sl.Count do + begin + b := TfrxBand(sl.Objects[i]); + if sl[i] = '' then + if (b is TfrxPageHeader) or (b is TfrxReportTitle) or (b is TfrxColumnHeader) then + sl[i] := 'top' + else if (b is TfrxPageFooter) or (b is TfrxReportSummary) or (b is TfrxColumnFooter) then + sl[i] := 'bottom' + else + sl[i] := 'middle'; + ch := b.Child; + while ch <> nil do + begin + j := sl.IndexOfObject(ch); + if j <> -1 then + sl[j] := sl[i]; + ch := ch.Child; + end; + Inc(i); + end; + + add1 := 0; + case FGridType of + gt1pt: add1 := 40; + gt1cm: add1 := fr1cm; + gt1in: add1 := fr1in * 0.4; + gtChar: add1 := fr1CharY; + end; + + { rearrange all bands } + if not FFreeBandsPlacement then + for i := 0 to sl.Count - 1 do + begin + c := TfrxComponent(sl.Objects[i]); + if i = 0 then + c.Top := Round8(FBandHeader) + else + begin + c0 := TfrxComponent(sl.Objects[i - 1]); + if ((sl[i - 1] = 'top') and (sl[i] <> 'top')) or + ((sl[i] = 'bottom') and (sl[i - 1] <> 'bottom')) then + add := add1 else + add := 0; + + c.Top := Round8(Round((c0.Top + c0.Height + FBandHeader + FGapBetweenBands) + / FGridY) * FGridY + add); + end; + end; + + sl.Free; + + { toss objects } + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if c is TfrxBand then + TossObjects(TfrxBand(c)) + else if c is TfrxDialogControl then + AdjustParent(c, i); + end; + + { move all bands to the begin of objects list } + l := TList.Create; + for i := 0 to FObjects.Count - 1 do + if TObject(FObjects[i]) is TfrxBand then + l.Add(FObjects[i]); + for i := 0 to FObjects.Count - 1 do + if not (TObject(FObjects[i]) is TfrxBand) then + l.Add(FObjects[i]); + + FObjects.Clear; + for i := 0 to l.Count - 1 do + FObjects.Add(l[i]); + l.Free; +end; + +procedure TfrxDesignerWorkspace.PrepareShiftTree(Band: TfrxBand); +var + i, j, k: Integer; + c0, c1, c2, top: TfrxReportComponent; + allObjects: TStringList; + Found: Boolean; + area0, area1, area2, area01: TfrxRectArea; +begin + allObjects := TStringList.Create; + allObjects.Duplicates := dupAccept; + + { temporary top object } + top := TfrxMemoView.Create(nil); + top.SetBounds(0, Band.Top-2, Band.Width, 1); + + { sort objects } + for i := 0 to Band.Objects.Count - 1 do + begin + c0 := Band.Objects[i]; + allObjects.AddObject(Format('%9.2f', [c0.Top]), c0); + c0.FShiftChildren.Clear; + end; + allObjects.Sort; + allObjects.InsertObject(0, Format('%10.2f', [top.Top]), top); + + for i := 0 to allObjects.Count - 1 do + begin + c0 := TfrxReportComponent(allObjects.Objects[i]); + area0 := TfrxRectArea.Create(c0); + + { find an object under c0 } + for j := i + 1 to allObjects.Count - 1 do + begin + c1 := TfrxReportComponent(allObjects.Objects[j]); + area1 := TfrxRectArea.Create(c1); + + if not (area0.InterceptsY(area1)) and (area0.Y < area1.Y) and + area0.InterceptsX(area1) then + begin + area01 := area0.InterceptX(area1); + Found := False; + + { check if there is no other objects between c1 and c0 } + for k := j - 1 downto i + 1 do + begin + c2 := TfrxReportComponent(allObjects.Objects[k]); + area2 := TfrxRectArea.Create(c2); + + if not (area0.InterceptsY(area2)) and not (area1.InterceptsY(area2)) and + area01.InterceptsX(area2) then + Found := True; + + area2.Free; + if Found then + break; + end; + + if not Found then + c0.FShiftChildren.Add(c1); + + area01.Free; + end; + + area1.Free; + end; + + area0.Free; + end; + + { copy children from the top object to the band } + Band.FShiftChildren.Clear; + for i := 0 to top.FShiftChildren.Count - 1 do + Band.FShiftChildren.Add(top.FShiftChildren[i]); + + allObjects.Free; + top.Free; +end; + +procedure TfrxDesignerWorkspace.AdjustBandHeight(Bnd: TfrxBand); +var + i: Integer; + max, min: Extended; + c: TfrxComponent; +begin + max := 0; + min := 0; + for i := 0 to Bnd.Objects.Count - 1 do + begin + c := Bnd.Objects[i]; + if (c is TfrxView) and (TfrxView(c).Align in [baClient, baBottom]) then + continue; + if c.Top + c.Height > max then + max := c.Top + c.Height; + if c.Top < min then + min := c.Top; + end; + + max := max - min; + if Bnd.Height < max then + Bnd.Height := max; + if min < 0 then + for i := 0 to Bnd.Objects.Count - 1 do + with TfrxComponent(Bnd.Objects[i]) do + Top := Top - min; +end; + +function TfrxDesignerWorkspace.ListsEqual(List1, List2: TList): Boolean; +var + i: Integer; +begin + Result := List1.Count = List2.Count; + if Result then + for i := 0 to List1.Count - 1 do + if List1.List[i] <> List2.List[i] then + Result := False; +end; + +procedure TfrxDesignerWorkspace.DeleteObjects; +var + c, c1: TfrxComponent; + i: Integer; +begin + if SelectedCount = 0 then exit; + + i := 0; + while FSelectedObjects.Count > i do + begin + c := FSelectedObjects[i]; + + if not (rfDontDelete in c.Restrictions) then + begin + if c.IsAncestor then + raise Exception.Create('Could not delete ' + c.Name + ', it was introduced in the ancestor report'); + FSelectedObjects.Remove(c); + FObjects.Remove(c); + + while c.Objects.Count > 0 do + begin + c1 := c.Objects[0]; + FSelectedObjects.Remove(c1); + FObjects.Remove(c1); + c1.Free; + end; + + c.Free; + end + else + Inc(i); + end; + + if FSelectedObjects.Count = 0 then + FSelectedObjects.Add(FPage); + + AdjustBands; + FModifyFlag := True; + DoModify; + SelectionChanged; +end; + +procedure TfrxDesignerWorkspace.EditObject; +begin + if FSelectedObjects.Count = 1 then + if Assigned(FOnEdit) then + FOnEdit(Self); +end; + +procedure TfrxDesignerWorkspace.DoNudge(dx, dy: Extended; Smooth: Boolean); +var + i: Integer; + c: TfrxComponent; +begin + if SelectedCount = 0 then exit; + if not Smooth or (GridType = gtChar) then + begin + dx := dx * FGridX; + dy := dy * FGridY; + end; + + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + c.Left := c.Left + dx; + c.Top := c.Top + dy; + end; + + FModifyFlag := True; + if Assigned(FOnNotifyPosition) then + FOnNotifyPosition(GetSelectionBounds); + Repaint; +end; + +procedure TfrxDesignerWorkspace.DoSize(dx, dy: Extended); +var + i: Integer; + c: TfrxComponent; +begin + if SelectedCount = 0 then exit; + dx := dx * FGridX; + dy := dy * FGridY; + + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + c.Width := c.Width + dx; + if c.Width < 0 then + c.Width := c.Width - dx; + c.Height := c.Height + dy; + if c.Height < 0 then + c.Height := c.Height - dy; + end; + + FModifyFlag := True; + if Assigned(FOnNotifyPosition) then + FOnNotifyPosition(GetSelectionBounds); + Repaint; +end; + +procedure TfrxDesignerWorkspace.DoStick(dx, dy: Integer); +var + i: Integer; + c, sel, found: TfrxComponent; + min, dist: Extended; + r1, r2: TfrxRect; + gapLeft, gapRight, gapTop, gapBottom: Extended; + + function RectsIntersect(r1, r2: TfrxRect): Boolean; + begin + Result := not ((r2.Left > r1.Right) or (r2.Right < r1.Left) or + (r2.Top > r1.Bottom) or (r2.Bottom < r1.Top)); + end; + +begin + if SelectedCount <> 1 then exit; + + found := nil; + sel := FSelectedObjects[0]; + min := 1e10; + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if not (c is TfrxReportComponent) or (c is TfrxBand) or (c = sel) then continue; + + r1 := frxRect(c.AbsLeft, c.AbsTop, c.AbsLeft + c.Width, c.AbsTop + c.Height); + dist := 0; + with sel do + if dx = 1 then + begin + r2 := frxRect(AbsLeft, AbsTop, 1e10, AbsTop + Height); + dist := r1.Left - r2.Left; + end + else if dx = -1 then + begin + r2 := frxRect(-1e10, AbsTop, AbsLeft + Width, AbsTop + Height); + dist := r2.Right - r1.Right; + end + else if dy = 1 then + begin + r2 := frxRect(AbsLeft, AbsTop, AbsLeft + Width, 1e10); + dist := r1.Top - r2.Top; + end + else if dy = -1 then + begin + r2 := frxRect(AbsLeft, -1e10, AbsLeft + Width, AbsTop + Height); + dist := r2.Bottom - r1.Bottom; + end; + + if RectsIntersect(r1, r2) then + if dist < min then + begin + found := c; + min := dist; + end; + end; + + if found <> nil then + begin + gapLeft := 0; + gapRight := 0; + gapTop := 0; + gapBottom := 0; + if (sel is TfrxDMPMemoView) and (found is TfrxDMPMemoView) then + begin + if (ftLeft in TfrxDMPMemoView(sel).Frame.Typ) or + (ftRight in TfrxDMPMemoView(found).Frame.Typ) then + gapLeft := fr1CharX; + if (ftRight in TfrxDMPMemoView(sel).Frame.Typ) or + (ftLeft in TfrxDMPMemoView(found).Frame.Typ) then + gapRight := fr1CharX; + if (ftTop in TfrxDMPMemoView(sel).Frame.Typ) or + (ftBottom in TfrxDMPMemoView(found).Frame.Typ) then + gapTop := fr1CharY; + if (ftBottom in TfrxDMPMemoView(sel).Frame.Typ) or + (ftTop in TfrxDMPMemoView(found).Frame.Typ) then + gapBottom := fr1CharY; + end; + if dx = 1 then + sel.Left := found.Left - sel.Width - gapRight + else if dx = -1 then + sel.Left := found.Left + found.Width + gapLeft + else if dy = 1 then + sel.Top := found.Top - sel.Height - gapBottom + else if dy = -1 then + sel.Top := found.Top + found.Height + gapTop; + + FModifyFlag := True; + if Assigned(FOnNotifyPosition) then + FOnNotifyPosition(GetSelectionBounds); + Repaint; + end; +end; + +procedure TfrxDesignerWorkspace.DoTab; +var + c: TfrxComponent; + i: Integer; +begin + if SelectedCount <> 1 then Exit; + + c := SelectedObjects[0]; + if (c is TfrxBand) and (c.Objects.Count > 0) then + SelectedObjects[0] := c.Objects[0] + else if c is TfrxView then + begin + i := c.Parent.Objects.IndexOf(c); + if i = c.Parent.Objects.Count - 1 then + i := 0 + else + Inc(i); + SelectedObjects[0] := c.Parent.Objects[i]; + end; + + if Assigned(FOnNotifyPosition) then + FOnNotifyPosition(GetSelectionBounds); + SelectionChanged; +end; + +procedure TfrxDesignerWorkspace.KeyDown(var Key: Word; Shift: TShiftState); +var + p: TPoint; + dx, dy: Integer; +begin + if FDisableUpdate then exit; + + if ssAlt in Shift then + begin + GetCursorPos(p); + p := ScreenToClient(p); + MouseMove(Shift, p.X, p.Y); + end; + + dx := 0; dy := 0; + + case Key of + vk_Delete: + DeleteObjects; + + vk_Return: + EditObject; + + vk_Left: + dx := -1; + + vk_Right: + dx := 1; + + vk_Up: + dy := -1; + + vk_Down: + dy := 1; + + vk_Tab: + DoTab; + end; + + if (dx <> 0) or (dy <> 0) then + if ssCtrl in Shift then + DoNudge(dx, dy, not (ssShift in Shift)) + else if ssShift in Shift then + DoSize(dx, dy) + else if ssAlt in Shift then + DoStick(dx, dy) + else + FindNearest(dx, dy); +end; + +procedure TfrxDesignerWorkspace.KeyUp(var Key: Word; Shift: TShiftState); +begin + if FDisableUpdate then exit; + DoModify; +end; + +procedure TfrxDesignerWorkspace.MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +var + i, j: Integer; + c, c1: TfrxComponent; + EmptySpace: Boolean; + l: TList; + NeedRepaint: Boolean; + p: TPoint; + + function Contain(c: TfrxComponent): Boolean; + var + w0, w1, w2, w3: Extended; + Left, Top, Right, Bottom, e, k, mx, my: Extended; + begin + Result := False; + w0 := 0; + w1 := 0; + w2 := 0; + if c.Width = 0 then + begin + w0 := 4; + w1 := 4 + end + else if c.Height = 0 then + w2 := 4; + w3 := w2; + if c is TfrxBand then + if TfrxBand(c).Vertical then + w0 := FBandHeader + else + w2 := FBandHeader; + + Left := c.AbsLeft; + Right := c.AbsLeft + c.Width; + Top := c.AbsTop; + Bottom := c.AbsTop + c.Height; + mx := X / FScale; + my := Y / FScale; + + if Right < Left then + begin + e := Right; + Right := Left; + Left := e; + end; + if Bottom < Top then + begin + e := Bottom; + Bottom := Top; + Top := e; + end; + + if (c is TfrxLineView) and TfrxLineView(c).Diagonal and + (c.Width <> 0) and (c.Height <> 0) then + begin + k := c.Height / c.Width; + if Abs((k * (mx - c.AbsLeft) - (my - c.AbsTop)) * cos(arctan(k))) < 5 then + Result := True; + if (mx < Left - 5) or (mx > Right + 5) or (my < Top - 5) or (my > Bottom + 5) then + Result := False; + end + else if (mx >= Left - w0) and (mx <= Right + w1) and + (my >= Top - w2) and (my <= Bottom + w3) then + Result := True; + end; + +begin + inherited; + if FDisableUpdate then exit; + if FDblClicked then + begin + FDblClicked := False; + exit; + end; + + if TInplaceMemo(FInplaceMemo).Visible then + TInplaceMemo(FInplaceMemo).EditDone; + + l := TList.Create; + for i := 0 to FSelectedObjects.Count - 1 do + l.Add(FSelectedObjects[i]); + + if FPage is TfrxReportPage then + ValidParentForm(Self).ActiveControl := Parent else + ValidParentForm(Self).ActiveControl := nil; + + FMouseDown := True; + FLastMousePointX := X / FScale; + FLastMousePointY := Y / FScale; + NeedRepaint := False; + +// Ctrl was pressed + if (FMode1 = dmNone) and (ssCtrl in Shift) then + begin + FSelectedObjects.Clear; + FSelectedObjects.Add(FPage); + FMode1 := dmSelectionRect; + FSelectionRect := frxRect(X, Y, X, Y); + NeedRepaint := True; + end; + +// clicked on object or on empty space + if FMode1 = dmNone then + begin + EmptySpace := True; + + for i := FObjects.Count - 1 downto 0 do + begin + c := FObjects[i]; + if (c is TfrxReportComponent) and Contain(c) then + begin + EmptySpace := False; + + if csContainer in c.frComponentStyle then + begin + if c.ContainerMouseDown(Self, X, Y) then + FMode1 := dmContainer + else + for j := c.ContainerObjects.Count - 1 downto 0 do + begin + c1 := c.ContainerObjects[j]; + if c1.Visible and Contain(c1) then + begin + c := c1; + break; + end; + end; + end; + + if ssShift in Shift then + if FSelectedObjects.IndexOf(c) <> -1 then + FSelectedObjects.Remove(c) else + FSelectedObjects.Add(c) + else if FSelectedObjects.IndexOf(c) = -1 then + begin + FSelectedObjects.Clear; + FSelectedObjects.Add(c); + end; + + break; + end; + end; + + if EmptySpace then + begin + FSelectedObjects.Clear; + FSelectedObjects.Add(FPage); + FMode1 := dmSelectionRect; + FSelectionRect := frxRect(X, Y, X, Y); + end + else if FSelectedObjects.Count = 0 then + begin + FSelectedObjects.Add(FPage); + FMode1 := dmNone; + end + else + begin + FSelectedObjects.Remove(FPage); + if FMode1 <> dmContainer then + FMode1 := dmMove; + end; + + NeedRepaint := True; + end; + +// scaling + if FMode1 = dmScale then + begin + FScaleRect := GetSelectionBounds; + FScaleRect.Right := FScaleRect.Right + FScaleRect.Left; + FScaleRect.Bottom := FScaleRect.Bottom + FScaleRect.Top; + FScaleRect1 := FScaleRect; + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + THackComponent(c).FOriginalRect := frxRect(c.AbsLeft, c.AbsTop, c.Width, c.Height); + end; + end; + +// inserting a line + if FMode1 = dmInsertLine then + begin + FInsertion.Width := 0; + FInsertion.Height := 0; + end; + + if NeedRepaint then + if not ListsEqual(l, FSelectedObjects) then + SelectionChanged else + Repaint; + + if (Button = mbRight) and (PopupMenu <> nil) then + begin + FMode1 := dmNone; + FMouseDown := False; + Repaint; + p := ClientToScreen(Point(X, Y)); + PopupMenu.Popup(p.X, p.Y); + end; + + l.Free; +end; + +procedure TfrxDesignerWorkspace.MouseMove(Shift: TShiftState; X, Y: Integer); +var + c: TfrxComponent; + kx, ky, nx, ny: Extended; + i: Integer; + NotifyRect, SaveBounds: TfrxRect; + + function Contain(px, py: Extended): Boolean; + begin + Result := (X / FScale >= px - 2) and (X / FScale <= px + 3) and + (Y / FScale >= py - 2) and (Y / FScale <= py + 3); + end; + + function Contain0(py: Extended): Boolean; + begin + Result := (Y / FScale >= py - 2) and (Y / FScale <= py + 2); + end; + + function Contain1(px, py: Extended): Boolean; + begin + Result := (FLastMousePointX >= px - 2) and (FLastMousePointX <= px + 3) and + (FLastMousePointY >= py - 2) and (FLastMousePointY <= py + 3); + end; + + function Contain2(c: TfrxComponent): Boolean; + var + w1, w2: Integer; + begin + w1 := 0; + w2 := 0; + if c.Width = 0 then + w1 := 4 else + w2 := 4; + if (X / FScale >= c.AbsLeft - w1) and (X / FScale <= c.AbsLeft + c.Width + w1) and + (Y / FScale >= c.AbsTop - w2) and (Y / FScale <= c.AbsTop + c.Height + w2) then + Result := True else + Result := False; + end; + + function Contain3(px: Extended): Boolean; + begin + Result := (X / FScale >= px - 2) and (X / FScale <= px + 2); + end; + + function GridCheck: Boolean; + begin + Result := (kx >= FGridX) or (kx <= -FGridX) or + (ky >= FGridY) or (ky <= -FGridY); + if Result then + begin + kx := Trunc(kx / FGridX) * FGridX; + ky := Trunc(ky / FGridY) * FGridY; + end; + end; + + function CheckMove: Boolean; + var + al: Boolean; + begin + al := FGridAlign; + if ssAlt in Shift then + al := not al; + + Result := False; + + if al and not GridCheck then + Result := True; + + CheckGuides(kx, ky, Result); + end; + + procedure CheckNegative(c: TfrxComponent); + const + ar1: array[ct1..ct8] of TfrxCursorType = (ct3, ct4, ct1, ct2, ct6, ct5, ct0, ct0); + ar2: array[ct1..ct8] of TfrxCursorType = (ct4, ct3, ct2, ct1, ct0, ct0, ct8, ct7); + ar3: array[ct1..ct8] of TfrxCursorType = (ct2, ct1, ct4, ct3, ct0, ct0, ct0, ct0); + begin + if (c is TfrxLineView) and (TfrxLineView(c).Diagonal = True) then exit; + if (c.Width < 0) and (c.Height < 0) then + FCT := ar3[FCT] + else if c.Width < 0 then + FCT := ar1[FCT] + else if c.Height < 0 then + FCT := ar2[FCT]; + NormalizeCoord(c); + end; + + procedure CTtoCursor; + const + ar: array[ct0..ct10] of TCursor = + (crDefault, crSizeNWSE, crSizeNWSE, crSizeNESW, + crSizeNESW, crSizeWE, crSizeWE, crSizeNS, crSizeNS, crCross, crCross); + begin + Cursor := ar[FCT]; + end; + +begin + inherited; + if FDisableUpdate then Exit; + + if SelectedCount = 0 then + NotifyRect := frxRect(X / FScale, Y / FScale, 0, 0) else + NotifyRect := GetSelectionBounds; + +// cursor shapes + if not FMouseDown and (FMode = dmSelect) then + if SelectedCount = 1 then + begin + FMode1 := dmSize; + c := FSelectedObjects[0]; + FCT := ct0; + if Contain(c.AbsLeft, c.AbsTop) then + FCT := ct1 + else if Contain(c.AbsLeft + c.Width, c.AbsTop + c.Height) then + FCT := ct2 + else if Contain(c.AbsLeft + c.Width, c.AbsTop) then + FCT := ct3 + else if Contain(c.AbsLeft, c.AbsTop + c.Height) then + FCT := ct4 + else if Contain(c.AbsLeft + c.Width, c.AbsTop + c.Height / 2) then + FCT := ct5 + else if Contain(c.AbsLeft, c.AbsTop + c.Height / 2) then + FCT := ct6 + else if Contain(c.AbsLeft + c.Width / 2, c.AbsTop) then + FCT := ct7 + else if Contain(c.AbsLeft + c.Width / 2, c.AbsTop + c.Height) then + FCT := ct8; + + if c is TfrxCustomLineView then + if not TfrxCustomLineView(c).Diagonal then + begin + if c.Width = 0 then + if FCT in [ct1, ct3] then + FCT := ct7 + else if FCT in [ct4, ct2] then + FCT := ct8 + else + FCT := ct0; + if c.Height = 0 then + if FCT in [ct1, ct4] then + FCT := ct6 + else if FCT in [ct3, ct2] then + FCT := ct5 + else + FCT := ct0; + end + else + if FCT = ct1 then + FCT := ct9 + else if FCT = ct2 then + FCT := ct10 + else + FCT := ct0; + + + if FCT = ct0 then + FMode1 := dmNone; + CTtoCursor; + end + else if SelectedCount > 1 then + begin + FMode1 := dmScale; + c := GetRightBottomObject; + if (c <> nil) and Contain(c.AbsLeft + c.Width, c.AbsTop + c.Height) then + Cursor := crSizeNWSE + else + begin + Cursor := crDefault; + FMode1 := dmNone; + end; + end + else + Cursor := crDefault; + +// resizing a band - setup + if not FMouseDown and (FMode = dmSelect) and not (FMode1 in [dmSize, dmScale]) then + begin + Cursor := crDefault; + FMode1 := dmNone; + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + + if c is TfrxBand then + if TfrxBand(c).Vertical then + begin + if Contain3(c.Left + c.Width) then + begin + Cursor := crHSplit; + FMode1 := dmSizeBand; + FSizedBand := TfrxBand(c); + break; + end; + end + else + begin + if Contain0(c.Top + c.Height) then + begin + Cursor := crVSplit; + FMode1 := dmSizeBand; + FSizedBand := TfrxBand(c); + break; + end; + end; + end; + end; + +// resizing a band + if FMouseDown and (FMode1 = dmSizeBand) then + begin + kx := X / FScale - FLastMousePointX; + ky := Y / FScale - FLastMousePointY; + if CheckMove then Exit; + + FModifyFlag := True; + if FSizedBand.Vertical then + FSizedBand.Width := FSizedBand.Width + kx + else + FSizedBand.Height := FSizedBand.Height + ky; + AdjustBandHeight(FSizedBand); + AdjustBands; + + FLastMousePointX := FLastMousePointX + kx; + FLastMousePointY := FLastMousePointY + ky; + Repaint; + with FSizedBand do + NotifyRect := frxRect(Left, Top, Width, Height); + end; + +// inplace editing - setup + if not FMouseDown and (ssAlt in Shift) then + begin + Cursor := crDefault; + FMode1 := dmNone; + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if (c is TfrxCustomMemoView) and Contain2(c) then + begin + FInplaceObject := TfrxCustomMemoView(c); + Cursor := crIBeam; + FMode1 := dmInplaceEdit; + break; + end; + end; + end; + +// inserting + if not FMouseDown and (FMode1 = dmInsertObject) then + begin + kx := X / FScale - FInsertion.Left; + ky := Y / FScale - FInsertion.Top; + if CheckMove then Exit; + + FInsertion.Left := FInsertion.Left + kx; + FInsertion.Top := FInsertion.Top + ky; + Repaint; + DrawInsertionRect; + with FInsertion do + NotifyRect := frxRect(Left, Top, Width, Height); + end; + +// inserting + resizing + if FMouseDown and (FMode1 = dmInsertObject) then + begin + kx := X / FScale - FInsertion.Left; + ky := Y / FScale - FInsertion.Top; + if CheckMove then Exit; + + FInsertion.Width := kx; + FInsertion.Height := ky; + Repaint; + DrawInsertionRect; + with FInsertion do + NotifyRect := frxRect(Left, Top, Width, Height); + end; + +// moving + if FMouseDown and (FMode1 = dmMove) then + begin + kx := X / FScale - FLastMousePointX; + ky := Y / FScale - FLastMousePointY; + if CheckMove then Exit; + + { vertical band } + if not FModifyFlag and (SelectedCount = 1) and + (TObject(FSelectedObjects[0]) is TfrxBand) and + (TfrxBand(FSelectedObjects[0]).Vertical) then + begin + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if (c is TfrxView) and + (c.Left >= TfrxBand(FSelectedObjects[0]).Left - 1e-4) and + (c.Left + c.Width <= TfrxBand(FSelectedObjects[0]).Left + + TfrxBand(FSelectedObjects[0]).Width + 1e-4) then + FSelectedObjects.Add(c); + end; + end; + + if (TObject(FSelectedObjects[0]) is TfrxBand) and + (TfrxBand(FSelectedObjects[0]).Vertical) then + ky := 0; + + FModifyFlag := True; + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + c.Left := c.Left + kx; + if FSelectedObjects.IndexOf(c.Parent) = -1 then + begin + if c.IsAncestor and (c is TfrxView) then + if (c.Top + ky < -1e-4) or (c.Top + ky > c.Parent.Height) then + continue; + c.Top := c.Top + ky; + end; + end; + + FLastMousePointX := FLastMousePointX + kx; + FLastMousePointY := FLastMousePointY + ky; + Repaint; + NotifyRect := GetSelectionBounds; + end; + +// resizing one object + if FMouseDown and (FMode1 = dmSize) then + begin + kx := X / FScale - FLastMousePointX; + ky := Y / FScale - FLastMousePointY; + if CheckMove then Exit; + + FModifyFlag := True; + c := FSelectedObjects[0]; + SaveBounds := frxRect(c.Left, c.Top, c.Width, c.Height); + case FCT of + ct1, ct9: + begin + c.Left := c.Left + kx; + c.Width := c.Width - kx; + c.Top := c.Top + ky; + c.Height := c.Height - ky; + end; + + ct2, ct10: + begin + c.Width := c.Width + kx; + c.Height := c.Height + ky; + end; + + ct3: + begin + c.Top := c.Top + ky; + c.Width := c.Width + kx; + c.Height := c.Height - ky; + end; + + ct4: + begin + c.Left := c.Left + kx; + c.Width := c.Width - kx; + c.Height := c.Height + ky; + end; + + ct5: + begin + c.Width := c.Width + kx; + end; + + ct6: + begin + c.Left := c.Left + kx; + c.Width := c.Width - kx; + end; + + ct7: + begin + c.Top := c.Top + ky; + c.Height := c.Height - ky; + end; + + ct8: + begin + c.Height := c.Height + ky; + end; + end; + CheckNegative(c); + CTtoCursor; + + if c.Left < 0 then + c.Left := 0; + + if c.IsAncestor and (c is TfrxView) then + if (c.Top < -1e-4) or (c.Top > c.Parent.Height) then + c.SetBounds(SaveBounds.Left, SaveBounds.Top, SaveBounds.Right, SaveBounds.Bottom); + + if c is TfrxBand then + begin + if FCT in [ct1, ct3, ct7] then + for i := 0 to c.Objects.Count - 1 do + with TfrxComponent(c.Objects[i]) do + Top := Top - ky; + AdjustBandHeight(TfrxBand(c)); + AdjustBands; + end; + + FLastMousePointX := FLastMousePointX + kx; + FLastMousePointY := FLastMousePointY + ky; + Repaint; + NotifyRect := frxRect(c.Left, c.Top, c.Width, c.Height); + end; + +// scaling + if FMouseDown and (FMode1 = dmScale) then + begin + kx := X / FScale - FLastMousePointX; + ky := Y / FScale - FLastMousePointY; + if CheckMove then Exit; + + FModifyFlag := True; + with FScaleRect do + if not ((Right + kx < Left) or (Bottom + ky < Top)) then + FScaleRect := frxRect(Left, Top, Right + kx, Bottom + ky); + nx := (FScaleRect.Right - FScaleRect.Left) / (FScaleRect1.Right - FScaleRect1.Left); + ny := (FScaleRect.Bottom - FScaleRect.Top) / (FScaleRect1.Bottom - FScaleRect1.Top); + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + c.Left := FScaleRect1.Left + (THackComponent(c).FOriginalRect.Left - FScaleRect1.Left) * nx; + c.Top := FScaleRect1.Top + (THackComponent(c).FOriginalRect.Top - FScaleRect1.Top) * ny; + if c.Parent is TfrxBand then + c.Top := c.Top - c.Parent.Top; + c.Width := THackComponent(c).FOriginalRect.Right * nx; + c.Height := THackComponent(c).FOriginalRect.Bottom * ny; + end; + + FLastMousePointX := FLastMousePointX + kx; + FLastMousePointY := FLastMousePointY + ky; + Repaint; + with FScaleRect do + NotifyRect := frxRect(Right - Left, Bottom - Top, nx, ny); + end; + +// drawing selection rectangle + if FMouseDown and (FMode1 = dmSelectionRect) then + begin + DrawSelectionRect; + FSelectionRect := frxRect(FSelectionRect.Left, FSelectionRect.Top, X, Y); + DrawSelectionRect; + end; + +// inserting a line + if not FMouseDown and (FMode1 = dmInsertLine) then + begin + kx := X / FScale - FInsertion.Left; + ky := Y / FScale - FInsertion.Top; + if CheckMove then Exit; + + DrawCross(False); + FInsertion.Left := FInsertion.Left + kx; + FInsertion.Top := FInsertion.Top + ky; + DrawCross(False); + with FInsertion do + NotifyRect := frxRect(Left, Top, 0, 0); + end; + +// inserting a line + resizing + if FMouseDown and (FMode1 = dmInsertLine) then + begin + kx := X / FScale - (FInsertion.Left + FInsertion.Width); + ky := Y / FScale - (FInsertion.Top + FInsertion.Height); + if CheckMove then Exit; + + DrawCross(True); + FInsertion.Width := FInsertion.Width + kx; + FInsertion.Height := FInsertion.Height + ky; + DrawCross(True); + with FInsertion do + NotifyRect := frxRect(Left, Top, Width, Height); + end; + +// check containers + if not FMouseDown and (FMode = dmSelect) and not (FMode1 in [dmSize, dmScale]) then + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if (csContainer in c.frComponentStyle) and Contain2(c) then + c.ContainerMouseMove(Self, X, Y); + end; + +// handle containers + if FMouseDown and (FMode1 = dmContainer) then + begin + kx := X / FScale - FLastMousePointX; + ky := Y / FScale - FLastMousePointY; + if CheckMove then Exit; + + FModifyFlag := True; + c := FSelectedObjects[0]; + c.ContainerMouseMove(Self, X, Y); + FLastMousePointX := FLastMousePointX + kx; + FLastMousePointY := FLastMousePointY + ky; + Repaint; + end; + + if FMouseDown and (Cursor <> crHand) then + if Parent is TScrollingWinControl then + with TScrollingWinControl(Parent) do + begin + x := x + Round(FMargins.Left * FScale); + y := y + Round(FMargins.Top * FScale); + if x > (ClientRect.Right + HorzScrollBar.Position) then + begin + i := x - (ClientRect.Right + HorzScrollBar.Position); + HorzScrollBar.Position := HorzScrollBar.Position + i; + end; + if x < HorzScrollBar.Position then + begin + i := HorzScrollBar.Position - x; + HorzScrollBar.Position := HorzScrollBar.Position - i; + end; + if y > (ClientRect.Bottom + VertScrollBar.Position) then + begin + i := y - (ClientRect.Bottom + VertScrollBar.Position); + VertScrollBar.Position := VertScrollBar.Position + i; + end; + if y < VertScrollBar.Position then + begin + i := VertScrollBar.Position - y; + VertScrollBar.Position := VertScrollBar.Position - i; + end; + end; + + if (SelectedCount = 0) or FMouseDown then + if Assigned(FOnNotifyPosition) then + FOnNotifyPosition(NotifyRect); +end; + +procedure TfrxDesignerWorkspace.MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +var + i, j: Integer; + c, c1: TfrxComponent; + R: TfrxRect; + l: TList; + NotifyRect: TfrxRect; + + function Round8(e: Extended): Extended; + begin + Result := Round(e * 100000000) / 100000000; + end; + + function Contain(c: TfrxComponent): Boolean; + var + cLeft, cTop, cRight, cBottom, e: Extended; + Sign: Boolean; + + function Dist(x, y: Extended): Boolean; + var + k: Extended; + begin + k := c.Height / c.Width; + k := (k * (x / FScale - c.AbsLeft) - (y / FScale - c.AbsTop)) * cos(arctan(k)); + Result := k >= 0; + end; + + function RectInRect: Boolean; + begin + with FSelectionRect do + Result := not ((cLeft > Right / FScale) or + (cRight < Left / FScale) or + (cTop > Bottom / FScale) or + (cBottom < Top / FScale)); + end; + + begin + Result := False; + cLeft := c.AbsLeft; + cRight := c.AbsLeft + c.Width; + cTop := c.AbsTop; + cBottom := c.AbsTop + c.Height; + + if cRight < cLeft then + begin + e := cRight; + cRight := cLeft; + cLeft := e; + end; + if cBottom < cTop then + begin + e := cBottom; + cBottom := cTop; + cTop := e; + end; + + if (c is TfrxLineView) and TfrxLineView(c).Diagonal and + (c.Width <> 0) and (c.Height <> 0) then + with FSelectionRect do + begin + Sign := Dist(Left, Top); + if Dist(Right, Top) <> Sign then + Result := True; + if Dist(Left, Bottom) <> Sign then + Result := True; + if Dist(Right, Bottom) <> Sign then + Result := True; + + if Result then + Result := RectInRect; + end + else + Result := RectInRect; + end; + +begin + inherited; + if FDisableUpdate then Exit; + if Button <> mbLeft then Exit; + + l := TList.Create; + for i := 0 to FSelectedObjects.Count - 1 do + l.Add(FSelectedObjects[i]); + FMouseDown := False; + +// insert an object + if FMode = dmInsert then + begin + with FInsertion do + begin + R := frxRect(Left, Top, Left + Width, Top + Height); + if ((ComponentClass.InheritsFrom(TfrxCustomLineView)) and (Flags = 0)) then + begin + if Width < 0 then + R.Right := Left - Width; + if Height < 0 then + R.Bottom := Top - Height; + + if (Width < 0) and (Abs(Width) > Abs(Height)) then + begin + R.Left := Left + Width; + R.Right := Left; + end; + if (Height < 0) and (Abs(Height) > Abs(Width)) then + begin + R.Top := Top + Height; + R.Bottom := Top; + end; + end + else if not ((ComponentClass.InheritsFrom(TfrxLineView)) and (Flags <> 0)) then + begin + if ((Width >= 0) and (Width < 4)) or ((Height > 0) and (Height < 4)) then + R := frxRect(Left, Top, Left + OriginalWidth, Top + OriginalHeight); + NormalizeRect(R); + end; + Left := Round8(R.Left); + Top := Round8(R.Top); + Width := Round8(R.Right - R.Left); + Height := Round8(R.Bottom - R.Top); + end; + + if Assigned(FOnInsert) then + FOnInsert(Self); + end; + +// select objects that inside of selection rect + if FMode1 = dmSelectionRect then + begin + NormalizeRect(FSelectionRect); + FSelectedObjects.Clear; + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if (c is TfrxReportComponent) and not (c is TfrxBand) and Contain(c) then + if not (csContainer in c.frComponentStyle) then + FSelectedObjects.Add(c) + else + begin + for j := 0 to c.ContainerObjects.Count - 1 do + begin + c1 := c.ContainerObjects[j]; + if c1.Visible and Contain(c1) then + FSelectedObjects.Add(c1); + end; + end; + end; + + if FSelectedObjects.Count = 0 then + FSelectedObjects.Add(FPage); + end; + +// inplace editing + if FMode1 = dmInplaceEdit then + begin + FSelectedObjects.Clear; + FSelectedObjects.Add(FInplaceObject); + SelectionChanged; + TInplaceMemo(FInplaceMemo).Edit(FInplaceObject); + FMode1 := dmNone; + end; + +// round coordinates + if FMode1 in [dmMove, dmSize] then + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + c.Left := Round8(c.Left); + c.Top := Round8(c.Top); + c.Width := Round8(c.Width); + c.Height := Round8(c.Height); + end; + if FMode1 = dmSizeBand then + FSizedBand.Height := Round8(FSizedBand.Height); + + // container + if FMode1 = dmContainer then + begin + c := SelectedObjects[0]; + c.ContainerMouseUp(Self, X, Y); + end; + + AdjustBands; + if not ListsEqual(l, FSelectedObjects) then + SelectionChanged else + Repaint; + DoModify; + l.Free; + FCT := ct0; + if not ((FMode = dmInsert) and (FInsertion.ComponentClass <> nil)) then + FMode1 := dmNone; + + if SelectedCount = 0 then + NotifyRect := frxRect(X / FScale, Y / FScale, 0, 0) else + NotifyRect := GetSelectionBounds; + if Assigned(FOnNotifyPosition) then + FOnNotifyPosition(NotifyRect); +end; + +procedure TfrxDesignerWorkspace.DblClick; +begin + inherited; + EditObject; + FDblClicked := True; +end; + +procedure TfrxDesignerWorkspace.MouseLeave; +begin + if not FMouseDown and (FMode1 = dmInsertObject) then + begin +// DrawInsertionRect; + FInsertion.Left := -FGridX * 1000; + FInsertion.Top := -FGridY * 1000; + Repaint; + end; + if not FMouseDown and (FMode1 = dmInsertLine) then + begin + DrawCross(False); + if FGridType = gtChar then + begin + FInsertion.Left := - FGridX / 2; + FInsertion.Top := - FGridY / 2; + end + else + begin + FInsertion.Left := - FGridX; + FInsertion.Top := - FGridY; + end; + end; + if FMode = dmDrag then + SetInsertion(nil, 0, 0, 0); +end; + +procedure TfrxDesignerWorkspace.CMMouseLeave(var Message: TMessage); +begin + inherited; + MouseLeave; +end; + +procedure TfrxDesignerWorkspace.CheckGuides(var kx, ky: Extended; + var Result: Boolean); +begin +// +end; + +procedure TfrxDesignerWorkspace.GroupObjects; +var + i, j: Integer; + c: TfrxComponent; + sl: TStringList; +begin + sl := TStringList.Create; + sl.Sorted := True; + sl.Duplicates := dupIgnore; + + { reset group index } + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + c.GroupIndex := 0; + end; + + { collect available indexes } + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + sl.Add(IntToStr(c.GroupIndex)); + end; + + { find an unique index } + j := 0; + repeat + Inc(j); + until sl.IndexOf(IntToStr(j)) = -1; + + { set group index } + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + c.GroupIndex := j; + end; + + sl.Free; +end; + +procedure TfrxDesignerWorkspace.UngroupObjects; +var + i: Integer; + c: TfrxComponent; +begin + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + c.GroupIndex := 0; + end; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDesgnWorkspace.res b/official/4.2/LibD11/frxDesgnWorkspace.res new file mode 100644 index 0000000..247c567 Binary files /dev/null and b/official/4.2/LibD11/frxDesgnWorkspace.res differ diff --git a/official/4.2/LibD11/frxDesgnWorkspace1.pas b/official/4.2/LibD11/frxDesgnWorkspace1.pas new file mode 100644 index 0000000..2b22260 --- /dev/null +++ b/official/4.2/LibD11/frxDesgnWorkspace1.pas @@ -0,0 +1,1094 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Designer workspace } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDesgnWorkspace1; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls, Buttons, frxClass, frxDesgn, + frxDesgnWorkspace, frxPopupForm +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxDesignTool = (dtSelect, dtHand, dtZoom, dtText, dtFormat); + + TfrxGuideItem = class(TCollectionItem) + public + Left, Top, Right, Bottom: Extended; + end; + + TfrxVirtualGuides = class(TCollection) + private + function GetGuides(Index: Integer): TfrxGuideItem; + public + constructor Create; + procedure Add(Left, Top, Right, Bottom: Extended); + property Items[Index: Integer]: TfrxGuideItem read GetGuides; default; + end; + + TDesignerWorkspace = class(TfrxDesignerWorkspace) + private + FDesigner: TfrxDesignerForm; + FGuide: Integer; + FListBox: TListBox; + FMemo: TfrxMemoView; + FPopupForm: TfrxPopupForm; + FPopupFormVisible: Boolean; + FShowGuides: Boolean; + FSimulateMove: Boolean; + FTool: TfrxDesignTool; + FVirtualGuides: TfrxVirtualGuides; + FVirtualGuideObjects: TList; + procedure DoLBClick(Sender: TObject); + procedure DoPopupHide(Sender: TObject); + procedure CreateVirtualGuides; + procedure LBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure SetShowGuides(const Value: Boolean); + procedure SetHGuides(const Value: TStrings); + procedure SetVGuides(const Value: TStrings); + function GetHGuides: TStrings; + function GetVGuides: TStrings; + property HGuides: TStrings read GetHGuides write SetHGuides; + property VGuides: TStrings read GetVGuides write SetVGuides; + procedure SetTool(const Value: TfrxDesignTool); + protected + procedure CheckGuides(var kx, ky: Extended; var Result: Boolean); override; + procedure DragOver(Source: TObject; X, Y: Integer; State: TDragState; + var Accept: Boolean); override; + procedure DrawObjects; override; + procedure KeyDown(var Key: Word; Shift: TShiftState); override; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure DblClick; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure DeleteObjects; override; + procedure DragDrop(Source: TObject; X, Y: Integer); override; + procedure SimulateMove; + procedure SetInsertion(AClass: TfrxComponentClass; + AWidth, AHeight: Extended; AFlag: Word); override; + property ShowGuides: Boolean read FShowGuides write SetShowGuides; + property Tool: TfrxDesignTool read FTool write SetTool; + end; + + +implementation + +uses + ComCtrls, frxDesgnCtrls, frxUtils, frxDataTree, frxDMPClass, frxRes; + +type + THackMemo = class(TfrxCustomMemoView); + +function Round8(e: Extended): Extended; +begin + Result := Round(e * 100000000) / 100000000; +end; + +function ToIdent(const s: String): String; +var + I: Integer; +begin + Result := ''; + for i := 1 to Length(s) do + if i = 1 then + begin + if s[i] in ['A'..'Z','a'..'z','_'] then + Result := Result + s[i] + end + else if s[i] in ['A'..'Z','a'..'z','_','0'..'9'] then + Result := Result + s[i]; + if Length(Result) < Length(s) * 2 div 3 then + Result := 'Memo'; +end; + + +{ TfrxVirtualGuides } + +constructor TfrxVirtualGuides.Create; +begin + inherited Create(TfrxGuideItem); +end; + +procedure TfrxVirtualGuides.Add(Left, Top, Right, Bottom: Extended); +var + Item: TfrxGuideItem; +begin + Item := TfrxGuideItem(inherited Add); + Item.Left := Left; + Item.Top := Top; + Item.Right := Right; + Item.Bottom := Bottom; +end; + +function TfrxVirtualGuides.GetGuides(Index: Integer): TfrxGuideItem; +begin + Result := TfrxGuideItem(inherited Items[Index]); +end; + + +{ TDesignerWorkspace } + +constructor TDesignerWorkspace.Create(AOwner: TComponent); +begin + inherited; + FDesigner := TfrxDesignerForm(AOwner); + FVirtualGuides := TfrxVirtualGuides.Create; + FVirtualGuideObjects := TList.Create; +end; + +destructor TDesignerWorkspace.Destroy; +begin + FVirtualGuides.Free; + FVirtualGuideObjects.Free; + inherited; +end; + +procedure TDesignerWorkspace.DeleteObjects; +var + i: Integer; + NeedReload: Boolean; +begin + NeedReload := False; + for i := 0 to FSelectedObjects.Count - 1 do + if TObject(FSelectedObjects[i]) is TfrxSubreport then + NeedReload := True; + + FMemo := nil; + inherited; + + if NeedReload then + FDesigner.ReloadPages(FDesigner.Report.Objects.IndexOf(Page)); +end; + +procedure TDesignerWorkspace.SetInsertion(AClass: TfrxComponentClass; + AWidth, AHeight: Extended; AFlag: Word); +begin + inherited; + CreateVirtualGuides; +end; + +procedure TDesignerWorkspace.DrawObjects; +var + r: TRect; + i, d: Integer; +begin + if FDesigner.Page is TfrxReportPage then + with TfrxReportPage(FDesigner.Page) do + if Columns > 1 then + for i := 0 to Columns - 1 do + begin + d := Round(frxStrToFloat(ColumnPositions[i]) * fr01cm * FScale); + if d = 0 then continue; + FCanvas.Pen.Color := clSilver; + FCanvas.MoveTo(d, 0); + FCanvas.LineTo(d, Self.Height); + end; + + if FShowGuides and (FPage is TfrxReportPage) then + begin + with FCanvas do + begin + Pen.Width := 1; + Pen.Style := psSolid; + Pen.Color := $FFCC00; + Pen.Mode := pmCopy; + end; + + for i := 0 to HGuides.Count - 1 do + begin + d := Round(frxStrToFloat(HGuides[i]) * Scale); + FCanvas.MoveTo(0, d); + FCanvas.LineTo(Width, d); + end; + + for i := 0 to VGuides.Count - 1 do + begin + d := Round(frxStrToFloat(VGuides[i]) * Scale); + FCanvas.MoveTo(d, 0); + FCanvas.LineTo(d, Height); + end; + end; + + inherited; + + if (FMemo <> nil) and FDesigner.DropFields then + with FCanvas do + begin + r.TopLeft := Point(Round((FMemo.Left + FMemo.Width) * FScale) - 16, + Round((FMemo.AbsTop) * FScale) + 2); + r.BottomRight := Point(r.Left + 16, r.Top + 16); + DrawButtonFace(FCanvas, r, 1, bsNew, False, False, False); + + Brush.Color := clBlack; + Brush.Style := bsSolid; + Pen.Color := clBlack; + Pen.Style := psSolid; + FCanvas.Polygon([Point(r.Left + 4, r.Top + 6), Point(r.Left + 7, r.Top + 9), + Point(r.Left + 10, r.Top + 6), Point(r.Left + 4, r.Top + 6)]); + end; + + + if FVirtualGuides.Count > 0 then + begin + if FMouseDown or (FMode1 = dmInsertObject) or (FMode1 = dmInsertLine) then + with FCanvas do + begin + Pen.Width := 1; + Pen.Style := psSolid; + Pen.Color := $FFCC00; + Pen.Mode := pmCopy; + for i := 0 to FVirtualGuides.Count - 1 do + begin + MoveTo(Round(FVirtualGuides[i].Left * Scale), Round(FVirtualGuides[i].Top * Scale)); + LineTo(Round(FVirtualGuides[i].Right * Scale), Round(FVirtualGuides[i].Bottom * Scale)); + end; + end; + FVirtualGuides.Clear; + end; +end; + +procedure TDesignerWorkspace.DragOver(Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); +var + ds: TfrxDataset; + s, fld: String; + w: Integer; +begin + Accept := ((FDesigner.CheckOp(drDontInsertObject) and + (Source is TTreeView) and + (TTreeView(Source).Owner = FDesigner.DataTree) and + (FDesigner.DataTree.GetFieldName <> '')) or + ((Source is TfrxRuler) and FDesigner.ShowGuides)) and (FDesigner.Page is TfrxReportPage); + if not Accept then Exit; + + FMode := dmDrag; + if Source is TfrxRuler then + with Canvas do + begin + Pen.Width := 1; + Pen.Style := psSolid; + Pen.Color := clBlack; + Repaint; + + if GridAlign then + begin + X := Round(Trunc(X / (GridX * Scale)) * GridX * Scale); + Y := Round(Trunc(Y / (GridY * Scale)) * GridY * Scale); + end; + + if TfrxRuler(Source).Align = alLeft then + begin + MoveTo(X, 0); + LineTo(X, Height); + end + else + begin + MoveTo(0, Y); + LineTo(Width, Y); + end; + + MouseMove([], X, Y); + end + else + begin + if (FInsertion.ComponentClass = nil) and + (FDesigner.DataTree.InsFieldCB.Checked or + FDesigner.DataTree.InsCaptionCB.Checked or + not FDesigner.DataTree.IsDataField) then + begin + s := FDesigner.DataTree.GetFieldName; + s := Copy(s, 2, Length(s) - 2); + FDesigner.Report.GetDatasetAndField(s, ds, fld); + try + if (ds <> nil) and (fld <> '') then + w := ds.DisplayWidth[fld] else + w := 10; + except + w := 10; + end; + + if w > 100 then + w := 100; + + SetInsertion(TfrxMemoView, Round(w * 8 / GridX) * GridX, + FDesigner.GetDefaultObjectSize.Y, 0); + end; + + MouseMove([], X - 8, Y - 8); + end; +end; + +procedure TDesignerWorkspace.DragDrop(Source: TObject; X, Y: Integer); +var + eX, eY: Extended; + m: TfrxCustomMemoView; + ds: TfrxDataset; + s, fld: String; +begin + if (Source is TfrxRuler) and (FPage is TfrxReportPage) then + begin + if GridAlign then + begin + eX := Trunc(X / Scale / GridX) * GridX; + eY := Trunc(Y / Scale / GridY) * GridY; + end + else + begin + eX := X / Scale; + eY := Y / Scale; + end; + + eX := Round8(eX); + eY := Round8(eY); + + if TfrxRuler(Source).Align = alLeft then + VGuides.Add(FloatToStr(eX)) else + HGuides.Add(FloatToStr(eY)); + end + else if FDesigner.DataTree.InsFieldCB.Checked or + FDesigner.DataTree.InsCaptionCB.Checked or + not FDesigner.DataTree.IsDataField then + begin + FSelectedObjects.Clear; + + if Page is TfrxDMPPage then + m := TfrxDMPMemoView.Create(Page) + else + m := TfrxMemoView.Create(Page); + s := ToIdent(FDesigner.DataTree.GetFieldName); + if (s <> 'Memo') and (FDesigner.Report.FindObject(s) = nil) then + m.Name := s + else + begin + THackMemo(m).FBaseName := s; + m.CreateUniqueName; + end; + m.IsDesigning := True; + s := FDesigner.DataTree.GetFieldName; + s := Copy(s, 2, Length(s) - 2); + FDesigner.Report.GetDataSetAndField(s, ds, fld); + + if not FDesigner.DataTree.IsDataField or FDesigner.DataTree.InsFieldCB.Checked then + begin + m.DataSet := ds; + m.DataField := fld; + if (ds = nil) and (fld = '') then + begin + if Pos('<', FDesigner.DataTree.GetFieldName) = 1 then + m.Text := '[' + s + ']' else + m.Text := '[' + FDesigner.DataTree.GetFieldName + ']'; + end; + m.SetBounds(Round8(FInsertion.Left), Round8(FInsertion.Top), + Round8(FInsertion.Width), Round8(FInsertion.Height)); + FDesigner.SampleFormat.ApplySample(m); + FObjects.Add(m); + FSelectedObjects.Add(m); + FInsertion.Top := FInsertion.Top - FInsertion.Height; + end + else + m.Free; + if FDesigner.DataTree.IsDataField and FDesigner.DataTree.InsCaptionCB.Checked then + begin + if Page is TfrxDMPPage then + m := TfrxDMPMemoView.Create(Page) else + m := TfrxMemoView.Create(Page); + m.CreateUniqueName; + m.IsDesigning := True; + m.Text := fld; + m.SetBounds(Round8(FInsertion.Left), Round8(FInsertion.Top), + Round8(FInsertion.Width), Round8(FInsertion.Height)); + FDesigner.SampleFormat.ApplySample(m); + FObjects.Add(m); + FSelectedObjects.Add(m); + end; + + SetInsertion(nil, 0, 0, 0); + end; + + FModifyFlag := True; + MouseUp(mbLeft, [], X, Y); + SelectionChanged; +end; + +procedure TDesignerWorkspace.MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +var + ds: TfrxDataset; + r: TRect; + p: TPoint; + + function Contain(c: TfrxComponent): Boolean; + begin + Result := (X / FScale >= c.Left + c.Width - 16) and (X / FScale <= c.Left + c.Width) and + (Y / FScale >= c.AbsTop) and (Y / FScale <= c.AbsTop + 16); + end; + +begin + if FDisableUpdate then Exit; + + if FTool = dtHand then + begin + FMode1 := dmNone; + FMouseDown := True; + FLastMousePointX := X; + FLastMousePointY := Y; + Exit; + end + else if FTool in [dtZoom, dtText] then + begin + FMode1 := dmSelectionRect; + FSelectionRect := frxRect(X, Y, X, Y); + end + else if FTool = dtFormat then + begin + FMode1 := dmNone; + Exit; + end; + + if (FMode = dmSelect) and (FMemo <> nil) and Contain(FMemo) and FDesigner.DropFields then + begin + FPopupForm := TfrxPopupForm.Create(Self); + FPopupForm.OnDestroy := DoPopupHide; + FListBox := TListBox.Create(FPopupForm); + with FListBox do + begin + Parent := FPopupForm; + Ctl3D := False; + Align := alClient; + Style := lbOwnerDrawFixed; + ItemHeight := 16; + OnClick := DoLBClick; + OnDrawItem := LBDrawItem; + r.Top := Round(FMemo.AbsTop * FScale) + 18; + r.Right := Round((FMemo.Left + FMemo.Width) * FScale); + r.Left := r.Right - 140; + r.Bottom := r.Top + 162; + + if r.Left < 0 then + begin + Inc(r.Right, -r.Left); + r.Left := 0; + end; + + p := Self.ClientToScreen(r.TopLeft); + FPopupForm.SetBounds(p.X, p.Y, r.Right - r.Left, r.Bottom - r.Top); + + ds := TfrxDataBand(FMemo.Parent).Dataset; + if ds <> nil then + begin + ds.GetFieldList(Items); + ItemIndex := Items.IndexOf(FMemo.DataField); + FPopupForm.Show; + FPopupFormVisible := True; + end; + end; + + FMode1 := dmNone; + FMouseDown := False; + Exit; + end; + + if not ((FTool = dtZoom) and (Button = mbRight)) then + inherited; + + CreateVirtualGuides; +end; + +procedure TDesignerWorkspace.MouseMove(Shift: TShiftState; X, Y: Integer); +var + i, px, py: Integer; + c, cOver: TfrxComponent; + ds: TfrxDataset; + e, kx, ky: Extended; + + function Contain(c: TfrxComponent): Boolean; + begin + Result := (X / FScale >= c.Left) and (X / FScale <= c.Left + c.Width - 4) and + (Y / FScale >= c.AbsTop) and (Y / FScale <= c.AbsTop + c.Height); + end; + + function GridCheck: Boolean; + begin + Result := (kx >= GridX) or (kx <= -GridX) or + (ky >= GridY) or (ky <= -GridY); + if Result then + begin + kx := Trunc(kx / GridX) * GridX; + ky := Trunc(ky / GridY) * GridY; + end; + end; + +begin + if FDisableUpdate then Exit; + inherited; + + if FTool = dtHand then + begin + Cursor := crHand; + + if FMouseDown then + begin + kx := X - FLastMousePointX; + ky := Y - FLastMousePointY; + + if Parent is TScrollingWinControl then + with TScrollingWinControl(Parent) do + begin + px := HorzScrollBar.Position; + py := VertScrollBar.Position; + HorzScrollBar.Position := px - Round(kx); + VertScrollBar.Position := py - Round(ky); + if HorzScrollBar.Position = px then + FLastMousePointX := X; + if VertScrollBar.Position = py then + FLastMousePointY := Y; + end; + end; + end + else if FTool = dtZoom then + Cursor := crZoom + else if FTool = dtText then + Cursor := crIBeam + else if FTool = dtFormat then + Cursor := crFormat; + + if not FMouseDown and (FMode = dmSelect) and + ((FMode1 = dmNone) or (FMode1 = dmMoveGuide)) and not FPopupFormVisible then + begin + if FPage is TfrxReportPage then + begin + for i := 0 to HGuides.Count - 1 do + begin + e := frxStrToFloat(HGuides[i]); + if (Y / Scale > e - 5) and (Y / Scale < e + 5) then + begin + FMode1 := dmMoveGuide; + Cursor := crVSplit; + FGuide := i; + end; + end; + + for i := 0 to VGuides.Count - 1 do + begin + e := frxStrToFloat(VGuides[i]); + if (X / Scale > e - 5) and (X / Scale < e + 5) then + begin + FMode1 := dmMoveGuide; + Cursor := crHSplit; + FGuide := i; + end; + end; + end; + + if FMode1 = dmNone then + begin + cOver := nil; + for i := FObjects.Count - 1 downto 0 do + begin + c := FObjects[i]; + if (c is TfrxMemoView) and Contain(c) and + (c.Parent is TfrxDataBand) and + (TfrxDataBand(c.Parent).Dataset <> nil) and + (TfrxDataBand(c.Parent).Dataset.FieldsCount > 0) then + begin + ds := TfrxDataBand(c.Parent).Dataset; + if ds <> nil then + cOver := c; + break; + end; + end; + + if FMemo <> cOver then + begin + FMemo := TfrxMemoView(cOver); + Repaint; + end; + end; + end; + +// moving the guideline + if FMouseDown and (FMode1 = dmMoveGuide) then + begin + if Cursor = crHSplit then + begin + e := frxStrToFloat(VGuides[FGuide]); + kx := X / Scale - FLastMousePointX; + ky := 0; + + if not (GridAlign and not GridCheck) then + begin + FModifyFlag := True; + e := Round((e + kx) * 100000000) / 100000000; + FLastMousePointX := FLastMousePointX + kx; + end; + + VGuides[FGuide] := FloatToStr(e); + end + else + begin + e := frxStrToFloat(HGuides[FGuide]); + kx := 0; + ky := Y / Scale - FLastMousePointY; + + if not (GridAlign and not GridCheck) then + begin + FModifyFlag := True; + e := Round((e + ky) * 100000000) / 100000000; + FLastMousePointY := FLastMousePointY + ky; + end; + + HGuides[FGuide] := FloatToStr(e); + end; + + Repaint; + end; +end; + +procedure TDesignerWorkspace.MouseUp(Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +var + i: Integer; + e: Extended; + c: TfrxComponent; + + function Contain(c: TfrxComponent): Boolean; + begin + with FSelectionRect do + Result := not ((c.Left > Right / FScale) or + (c.Left + c.Width < Left / FScale) or + (c.AbsTop > Bottom / FScale) or + (c.AbsTop + c.Height < Top / FScale)); + end; + + procedure CopyFormat(MemoFrom, MemoTo: TfrxMemoView); + begin + MemoTo.Color := MemoFrom.Color; + MemoTo.Font := MemoFrom.Font; + MemoTo.Frame.Assign(MemoFrom.Frame); + MemoTo.BrushStyle := MemoFrom.BrushStyle; + MemoTo.HAlign := MemoFrom.HAlign; + MemoTo.VAlign := MemoFrom.VAlign; + end; + +begin + if FDisableUpdate then Exit; + FSimulateMove := False; + FVirtualGuideObjects.Clear; + + if FTool = dtZoom then + begin + FMode1 := dmNone; + NormalizeRect(FSelectionRect); + + with FSelectionRect do + if (Right - Left > 5) and (Bottom - Top > 5) then + begin + e := Scale; + + if (Right - Left) / (Parent.ClientWidth - 16) < + (Bottom - Top) / (Parent.ClientHeight - 16) then + FDesigner.Scale := (Parent.ClientHeight - 16) / (Bottom - Top) * Scale else + FDesigner.Scale := (Parent.ClientWidth - 16) / (Right - Left) * Scale; + + if Parent is TScrollingWinControl then + with TScrollingWinControl(Parent) do + begin + HorzScrollBar.Position := Round((FSelectionRect.Left / e + + TfrxReportPage(FDesigner.Page).LeftMargin * fr01cm) * Scale); + VertScrollBar.Position := Round((FSelectionRect.Top / e + + TfrxReportPage(FDesigner.Page).TopMargin * fr01cm) * Scale); + end; + end + else + begin + e := Scale; + if Button = mbLeft then + begin + if FDesigner.Scale >= 1 then + FDesigner.Scale := FDesigner.Scale + 1 + else + FDesigner.Scale := FDesigner.Scale + 0.25 + end + else + begin + if FDesigner.Scale >= 2 then + FDesigner.Scale := FDesigner.Scale - 1 + else if FDesigner.Scale > 0.4 then + FDesigner.Scale := FDesigner.Scale - 0.25 + end; + if Parent is TScrollingWinControl then + with TScrollingWinControl(Parent) do + begin + HorzScrollBar.Position := Round((FSelectionRect.Left / e + + TfrxReportPage(FDesigner.Page).LeftMargin * fr01cm) * Scale - + ClientWidth / 2); + VertScrollBar.Position := Round((FSelectionRect.Top / e + + TfrxReportPage(FDesigner.Page).TopMargin * fr01cm) * Scale - + ClientHeight / 2); + end; + end; + end + + else if (FTool = dtText) and FMouseDown then + begin + FMode1 := dmNone; + FMouseDown := False; + NormalizeRect(FSelectionRect); + + if FInplaceObject <> nil then + TInplaceMemo(FInplaceMemo).EditDone; + + FInplaceObject := nil; + + with FSelectionRect do + if (Right - Left < 5) or (Bottom - Top < 5) then + begin + for i := 0 to FObjects.Count - 1 do + begin + c := FObjects[i]; + if (c is TfrxCustomMemoView) and Contain(c) then + FInplaceObject := TfrxMemoView(c); + end; + end + else + begin + if GridAlign then + begin + Left := Trunc(Left / GridX) * GridX; + Right := Trunc(Right / GridX) * GridX; + Top := Trunc(Top / GridY) * GridY; + Bottom := Trunc(Bottom / GridY) * GridY; + end; + + FInsertion.Left := Left / FScale; + FInsertion.Top := Top / FScale; + FInsertion.Width := (Right - Left) / FScale; + FInsertion.Height := (Bottom - Top) / FScale; + if Page is TfrxDMPPage then + FInsertion.ComponentClass := TfrxDMPMemoView else + FInsertion.ComponentClass := TfrxMemoView; + + if Assigned(FOnInsert) then + FOnInsert(Self); + AdjustBands; + + if TObject(FSelectedObjects[0]) is TfrxCustomMemoView then + FInplaceObject := FSelectedObjects[0]; + end; + + if FInplaceObject <> nil then + begin + FSelectedObjects.Clear; + FSelectedObjects.Add(FInplaceObject); + SelectionChanged; + TInplaceMemo(FInplaceMemo).Edit(FInplaceObject); + end; + + Exit; + end + else if FTool = dtFormat then + begin + FSelectionRect := frxRect(X, Y, X + 1, Y + 1); + for i := FObjects.Count - 1 downto 0 do + begin + c := FObjects[i]; + if (c is TfrxMemoView) and Contain(c) and not + (rfDontModify in c.Restrictions) and (c <> FSelectedObjects[0]) then + begin + CopyFormat(TfrxMemoView(FSelectedObjects[0]), TfrxMemoView(c)); + FModifyFlag := True; + break; + end; + end; + end; + + + if FMode1 = dmMoveGuide then + begin + if Cursor = crHSplit then + begin + e := frxStrToFloat(VGuides[FGuide]); + if (e < 3) or (e > (Width / Scale) - 3) then + VGuides.Delete(FGuide); + end + else + begin + e := frxStrToFloat(HGuides[FGuide]); + if (e < 3) or (e > (Height / Scale) - 3) then + HGuides.Delete(FGuide); + end; + + Repaint; + end; + + inherited; +end; + +procedure TDesignerWorkspace.DblClick; +begin + if FTool = dtSelect then + inherited; +end; + +procedure TDesignerWorkspace.KeyDown(var Key: Word; Shift: TShiftState); +begin + if (Key = VK_ESCAPE) and FSimulateMove then + begin + Key := VK_DELETE; + MouseUp(mbLeft, [], 0, 0); + end; + inherited; +end; + +procedure TDesignerWorkspace.SimulateMove; +var + r: TfrxRect; +begin + FMode1 := dmMove; + r := GetSelectionBounds; + MouseDown(mbLeft, [], Round(r.Left / Scale) + 20, Round(r.Top / Scale) + 20); + FSimulateMove := True; +end; + +procedure TDesignerWorkspace.CreateVirtualGuides; +var + i: Integer; +begin + FVirtualGuideObjects.Clear; + for i := 0 to Objects.Count - 1 do + FVirtualGuideObjects.Add(Objects[i]); +end; + +procedure TDesignerWorkspace.DoLBClick(Sender: TObject); +begin + if FMemo <> nil then + begin + FMemo.DataSet := TfrxDataBand(FMemo.Parent).Dataset; + FMemo.DataField := FListBox.Items[FListBox.ItemIndex]; + end; + FPopupForm.Hide; + + FModifyFlag := True; + DoModify; +end; + +procedure TDesignerWorkspace.DoPopupHide(Sender: TObject); +begin + FPopupFormVisible := False; +end; + +procedure TDesignerWorkspace.LBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); +begin + with FListBox do + begin + Canvas.FillRect(ARect); + frxResources.MainButtonImages.Draw(Canvas, ARect.Left, ARect.Top, 54); + Canvas.TextOut(ARect.Left + 20, ARect.Top + 1, Items[Index]); + end; +end; + +procedure TDesignerWorkspace.CheckGuides(var kx, ky: Extended; + var Result: Boolean); +var + i: Integer; + c: TfrxComponent; + + procedure CheckH(coord: Extended); + var + i: Integer; + e: Extended; + begin + if FPage is TfrxReportPage then + for i := 0 to HGuides.Count - 1 do + begin + e := frxStrToFloat(HGuides[i]); + if Abs(coord + ky - e) < 6 then + begin + ky := e - coord; + break; + end; + end; + end; + + procedure CheckV(coord: Extended); + var + i: Integer; + e: Extended; + begin + if FPage is TfrxReportPage then + for i := 0 to VGuides.Count - 1 do + begin + e := frxStrToFloat(VGuides[i]); + if Abs(coord + kx - e) < 6 then + begin + kx := e - coord; + break; + end; + end; + end; + + procedure CheckHH(Left, Top: Extended; Obj: TfrxComponent); + var + i: Integer; + c: TfrxComponent; + e: Extended; + begin + for i := 0 to FVirtualGuideObjects.Count - 1 do + begin + c := FVirtualGuideObjects[i]; + if c = Obj then continue; + e := c.AbsTop; + if Abs(Top + ky - e) < 0.001 then + FVirtualGuides.Add(Left, e, c.AbsLeft, e); + e := c.AbsTop + c.Height; + if Abs(Top + ky - e) < 0.001 then + FVirtualGuides.Add(Left, e, c.AbsLeft, e); + end; + end; + + procedure CheckVV(Left, Top: Extended; Obj: TfrxComponent); + var + i: Integer; + c: TfrxComponent; + e: Extended; + begin + for i := 0 to FVirtualGuideObjects.Count - 1 do + begin + c := FVirtualGuideObjects[i]; + if c = Obj then continue; + e := c.AbsLeft; + if Abs(Left + kx - e) < 0.001 then + FVirtualGuides.Add(e, c.AbsTop, e, Top); + e := c.AbsLeft + c.Width; + if Abs(Left + kx - e) < 0.001 then + FVirtualGuides.Add(e, c.AbsTop, e, Top); + end; + end; + +begin + if not FShowGuides then Exit; + + FVirtualGuides.Clear; + + if FMouseDown and (FMode1 = dmSizeBand) then + CheckH(FSizedBand.Top + FSizedBand.Height); + + if not FMouseDown and ((FMode1 = dmInsertObject) or (FMode1 = dmInsertLine)) then + begin + CheckV(FInsertion.Left); + CheckH(FInsertion.Top); + CheckVV(FInsertion.Left, FInsertion.Top, nil); + CheckHH(FInsertion.Left, FInsertion.Top, nil); + CheckV(FInsertion.Left + FInsertion.Width); + CheckH(FInsertion.Top + FInsertion.Height); + CheckVV(FInsertion.Left + FInsertion.Width, FInsertion.Top, nil); + CheckHH(FInsertion.Left, FInsertion.Top + FInsertion.Height, nil); + end; + + if FMouseDown and ((FMode1 = dmInsertObject) or (FMode1 = dmInsertLine)) then + begin + CheckV(FInsertion.Left); + CheckH(FInsertion.Top); + CheckVV(FInsertion.Left, FInsertion.Top, nil); + CheckHH(FInsertion.Left, FInsertion.Top, nil); + end; + + if FMouseDown and (FMode1 = dmMove) then + for i := 0 to SelectedCount - 1 do + begin + c := FSelectedObjects[i]; + CheckV(c.Left); + CheckVV(c.AbsLeft, c.AbsTop, c); + CheckHH(c.AbsLeft, c.AbsTop, c); + CheckH(c.AbsTop); + CheckH(c.Top); + CheckV(c.Left + c.Width); + CheckVV(c.AbsLeft + c.Width, c.AbsTop, c); + CheckHH(c.AbsLeft, c.AbsTop + c.Height, c); + CheckH(c.AbsTop + c.Height); + end; + + if FMouseDown and (FMode1 = dmSize) then + begin + c := FSelectedObjects[0]; + if FCT in [ct1, ct6, ct4] then + begin + CheckV(c.Left); + CheckVV(c.AbsLeft, c.AbsTop, c); + end; + if FCT in [ct1, ct7, ct3] then + begin + CheckH(c.AbsTop); + CheckHH(c.AbsLeft, c.AbsTop, c); + end; + if FCT in [ct3, ct5, ct2] then + begin + CheckV(c.Left + c.Width); + CheckVV(c.AbsLeft + c.Width, c.AbsTop, c); + end; + if FCT in [ct4, ct8, ct2] then + begin + CheckH(c.AbsTop + c.Height); + CheckHH(c.AbsLeft, c.AbsTop + c.Height, c); + end; + end; +end; + +procedure TDesignerWorkspace.SetShowGuides(const Value: Boolean); +begin + FShowGuides := Value; + Invalidate; +end; + +function TDesignerWorkspace.GetHGuides: TStrings; +begin + Result := TfrxReportPage(FPage).HGuides; +end; + +function TDesignerWorkspace.GetVGuides: TStrings; +begin + Result := TfrxReportPage(FPage).VGuides; +end; + +procedure TDesignerWorkspace.SetHGuides(const Value: TStrings); +begin + TfrxReportPage(FPage).HGuides := Value; +end; + +procedure TDesignerWorkspace.SetVGuides(const Value: TStrings); +begin + TfrxReportPage(FPage).VGuides := Value; +end; + +procedure TDesignerWorkspace.SetTool(const Value: TfrxDesignTool); +begin + FTool := Value; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDialogForm.dfm b/official/4.2/LibD11/frxDialogForm.dfm new file mode 100644 index 0000000..be3c52c Binary files /dev/null and b/official/4.2/LibD11/frxDialogForm.dfm differ diff --git a/official/4.2/LibD11/frxDialogForm.pas b/official/4.2/LibD11/frxDialogForm.pas new file mode 100644 index 0000000..2117cd0 --- /dev/null +++ b/official/4.2/LibD11/frxDialogForm.pas @@ -0,0 +1,80 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Dialog form } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDialogForm; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxDialogForm = class(TForm) + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + protected + procedure ReadState(Reader: TReader); override; + private + FOnModify: TNotifyEvent; + FThreadSafe: Boolean; + procedure WMExitSizeMove(var Msg: TMessage); message WM_EXITSIZEMOVE; + procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE; + public + constructor Create(AOwner: TComponent); override; + property OnModify: TNotifyEvent read FOnModify write FOnModify; + property ThreadSafe: Boolean read FThreadSafe write FThreadSafe; + end; + +implementation + +{$R *.DFM} + +procedure TfrxDialogForm.WMExitSizeMove(var Msg: TMessage); +begin + inherited; + if Assigned(OnModify) then + OnModify(Self); +end; + +procedure TfrxDialogForm.WMGetDlgCode(var Message: TWMGetDlgCode); +begin + Message.Result := DLGC_WANTARROWS or DLGC_WANTTAB; +end; + +procedure TfrxDialogForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + CanClose := False; +end; + +procedure TfrxDialogForm.ReadState(Reader: TReader); +begin + if not ThreadSafe then + inherited ReadState(Reader); +end; + +constructor TfrxDialogForm.Create(AOwner: TComponent); +begin + if AOwner <> nil then + FThreadSafe := AOwner.Tag = 318; + AOwner := nil; + inherited; +end; + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDock.dfm b/official/4.2/LibD11/frxDock.dfm new file mode 100644 index 0000000..08f05f5 Binary files /dev/null and b/official/4.2/LibD11/frxDock.dfm differ diff --git a/official/4.2/LibD11/frxDock.pas b/official/4.2/LibD11/frxDock.pas new file mode 100644 index 0000000..ae64133 --- /dev/null +++ b/official/4.2/LibD11/frxDock.pas @@ -0,0 +1,543 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Tool controls } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDock; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ExtCtrls, StdCtrls, ComCtrls, Buttons, IniFiles +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxTBPanel = class(TPanel) + protected + procedure SetParent(AParent:TWinControl); override; + public + constructor Create(AOwner: TComponent); override; + procedure Paint; override; + end; + + TfrxDockSite = class(TPanel) + private + FPanelSize: Integer; + FSavedSize: Integer; + FSplitter: TControl; + public + constructor Create(AOwner: TComponent); override; + procedure DockDrop(Source: TDragDockObject; X, Y: Integer); override; + procedure DockOver(Source: TDragDockObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); override; + function DoUnDock(NewTarget: TWinControl; Client: TControl): Boolean; override; + procedure SetParent(AParent: TWinControl); override; + procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override; + procedure ReloadDockedControl(const AControlName: string; + var AControl: TControl); override; + property SavedSize: Integer read FSavedSize write FSavedSize; + end; + + +procedure frxSaveToolbarPosition(Ini: TCustomIniFile; t: TToolBar); +procedure frxRestoreToolbarPosition(Ini: TCustomIniFile; t: TToolBar); +procedure frxSaveDock(Ini: TCustomIniFile; d: TfrxDockSite); +procedure frxRestoreDock(Ini: TCustomIniFile; d: TfrxDockSite); +procedure frxSaveFormPosition(Ini: TCustomIniFile; f: TForm); +procedure frxRestoreFormPosition(Ini: TCustomIniFile; f: TForm); + + + +implementation + + +uses frxClass, frxUtils; + +const + rsForm = 'Form4'; + rsToolBar = 'ToolBar4'; + rsDock = 'Dock4'; + rsWidth = 'Width'; + rsHeight = 'Height'; + rsTop = 'Top'; + rsLeft = 'Left'; + rsFloat = 'Float'; + rsVisible = 'Visible'; + rsMaximized = 'Maximized'; + rsData = 'Data'; + rsSize = 'Size'; + + +procedure frxSaveToolbarPosition(Ini: TCustomIniFile; t: TToolBar); +var + X, Y: integer; + Name: String; +begin + Name := rsToolbar + '.' + t.Name; + Ini.WriteBool(Name, rsFloat, t.Floating); + Ini.WriteBool(Name, rsVisible, t.Visible); + if t.Floating then + begin + X := t.Parent.Left; + Y := t.Parent.Top; + end + else + begin + X := t.Left; + Y := t.Top; + end; + Ini.WriteInteger(Name, rsLeft, X); + Ini.WriteInteger(Name, rsTop, Y); + Ini.WriteInteger(Name, rsWidth, t.Width); + Ini.WriteInteger(Name, rsHeight, t.Height); + if t.Parent is TControlBar then + Ini.WriteString(Name, rsDock, t.Parent.Name); +end; + +procedure frxRestoreToolbarPosition(Ini: TCustomIniFile; t: TToolBar); +var + DN: string; + NewDock: TControlBar; + Name: String; + X, Y, DX, DY: Integer; +begin + Name := rsToolbar + '.' + t.Name; + X := Ini.ReadInteger(Name, rsLeft, t.Left); + Y := Ini.ReadInteger(Name, rsTop, t.Top); + DX := Ini.ReadInteger(Name, rsWidth, t.Width); + DY := Ini.ReadInteger(Name, rsHeight, t.Height); + t.Visible := False; + if Ini.ReadBool(Name, rsFloat, False) then + t.ManualFloat(Rect(X, Y, X + DX, Y + DY)) + else + begin + DN := Ini.ReadString(Name, rsDock, t.Parent.Name); + if (t.Owner <> nil) then + begin + NewDock := t.Owner.FindComponent(DN) as TControlBar; + if (NewDock <> nil) and (NewDock <> t.Parent) then + t.ManualDock(NewDock); + end; + t.SetBounds(X, Y, DX, DY); + end; + t.Visible := Ini.ReadBool(Name, rsVisible, True); +end; + +procedure frxSaveDock(Ini: TCustomIniFile; d: TfrxDockSite); +var + s: TMemoryStream; +begin + s := TMemoryStream.Create; + d.DockManager.SaveToStream(s); +{$IFDEF Delphi9} + Ini.WriteString(rsDock + '.' + d.Name, rsData + '2005', frxStreamToString(s)); +{$ELSE} + Ini.WriteString(rsDock + '.' + d.Name, rsData, frxStreamToString(s)); +{$ENDIF} + Ini.WriteInteger(rsDock + '.' + d.Name, rsWidth, d.Width); + Ini.WriteInteger(rsDock + '.' + d.Name, rsHeight, d.Height); + Ini.WriteInteger(rsDock + '.' + d.Name, rsSize, d.SavedSize); + s.Free; +end; + +procedure frxRestoreDock(Ini: TCustomIniFile; d: TfrxDockSite); +var + s: TStream; + sd: String; +begin + s := TMemoryStream.Create; +{$IFDEF Delphi9} + sd := Ini.ReadString(rsDock + '.' + d.Name, rsData + '2005', ''); +{$ELSE} + sd := Ini.ReadString(rsDock + '.' + d.Name, rsData, ''); +{$ENDIF} + frxStringToStream(sd, s); + s.Position := 0; + if s.Size > 0 then + d.DockManager.LoadFromStream(s); + d.AutoSize := False; + d.Width := Ini.ReadInteger(rsDock + '.' + d.Name, rsWidth, d.Width); + d.Height := Ini.ReadInteger(rsDock + '.' + d.Name, rsHeight, d.Height); + d.SavedSize := Ini.ReadInteger(rsDock + '.' + d.Name, rsSize, 100); + d.AutoSize := True; + s.Free; +end; + +procedure frxSaveFormPosition(Ini: TCustomIniFile; f: TForm); +var + Name: String; +begin + Name := rsForm + '.' + f.ClassName; + Ini.WriteInteger(Name, rsLeft, f.Left); + Ini.WriteInteger(Name, rsTop, f.Top); + Ini.WriteInteger(Name, rsWidth, f.Width); + Ini.WriteInteger(Name, rsHeight, f.Height); + Ini.WriteBool(Name, rsMaximized, f.WindowState = wsMaximized); + Ini.WriteBool(Name, rsVisible, f.Visible); + if f.HostDockSite <> nil then + Ini.WriteString(Name, rsDock, f.HostDockSite.Name) else + Ini.WriteString(Name, rsDock, ''); +end; + +procedure frxRestoreFormPosition(Ini: TCustomIniFile; f: TForm); +var + Name: String; + Dock: String; + cDock: TWinControl; +begin + Name := rsForm + '.' + f.ClassName; + if f.FormStyle <> fsMDIChild then + begin + if Ini.ReadBool(Name, rsMaximized, False) then + f.WindowState := wsMaximized + else + f.SetBounds(Ini.ReadInteger(Name, rsLeft, f.Left), + Ini.ReadInteger(Name, rsTop, f.Top), + Ini.ReadInteger(Name, rsWidth, f.Width), + Ini.ReadInteger(Name, rsHeight, f.Height)); + end; + Dock := Ini.ReadString(Name, rsDock, ''); + cDock := frxFindComponent(f.Owner, Dock) as TWinControl; + if cDock <> nil then + f.ManualDock(cDock); + if not (f is TfrxCustomDesigner) then + f.Visible := Ini.ReadBool(Name, rsVisible, True); +end; + + +{ TfrxTBPanel } + +function GetAlign(al: TAlign): TAlign; +begin + if al in [alLeft, alRight] then + Result := alTop else + Result := alLeft; +end; + +constructor TfrxTBPanel.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Align := alLeft; + Width := 8; + Height := 8; + BevelInner := bvNone; + BevelOuter := bvNone; + ControlStyle := ControlStyle{$IFDEF Delphi11} - [csParentBackground]{$ENDIF} + [csOpaque]; +end; + +procedure TfrxTBPanel.SetParent(AParent:TWinControl); +begin + inherited; + if not (csDestroying in ComponentState) and (AParent <> nil) and (Parent is TPanel) then + Align := GetAlign(AParent.Parent.Align); +end; + +procedure TfrxTBPanel.Paint; +begin +{$IFDEF Delphi10} + inherited; +{$ELSE} + with Canvas do + begin + Brush.Color := clBtnFace; + FillRect(Rect(0, 0, Width, Height)); + if csDesigning in ComponentState then + begin + Brush.Style := bsClear; + Pen.Style := psDot; + Pen.Color := clBtnShadow; + Rectangle(0, 0, Width - 1, Height - 1); + end; + end; +{$ENDIF} +end; + + +{ TfrxDockSite } + +type + THackControl = class(TControl); + + TDockSplitter = class(TGraphicControl) + private + FDockSite: TfrxDockSite; + FDown: Boolean; + procedure DrawRubber(X, Y: Integer; Horizontal: Boolean); + public + constructor Create(AOwner: TComponent); override; + procedure MouseDown(Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + procedure MouseUp(Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); override; + procedure Paint; override; + end; + + +{ TDockSplitter } + +constructor TDockSplitter.Create(AOwner: TComponent); +begin + inherited; + FDockSite := TfrxDockSite(AOwner); +end; + +procedure TDockSplitter.DrawRubber(X, Y: Integer; Horizontal: Boolean); +var + i: Integer; +begin + for i := 0 to 6 do + begin + Canvas.Pixels[X, Y] := clWhite; + Canvas.Pixels[X + 1, Y] := clGray; + Canvas.Pixels[X, Y + 1] := clGray; + Canvas.Pixels[X + 1, Y + 1] := clGray; + if Horizontal then + Inc(X, 3) + else + Inc(Y, 3); + end; +end; + +procedure TDockSplitter.MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + inherited; + FDown := True; + + if Cursor = crHandPoint then + with FDockSite do + begin + if Align in [alLeft, alRight] then + begin + if Width = 0 then + begin + AutoSize := False; + Width := SavedSize; + if Align = alLeft then + Self.Left := Left + Width + else + Self.Left := Left - Self.Width; + AutoSize := True; + end + else + begin + AutoSize := False; + SavedSize := Width; + Width := 0; + end; + end + else + begin + if Height = 0 then + begin + AutoSize := False; + Height := SavedSize; + if Align = alTop then + Self.Top := Top + Height + else + Self.Top := Top - Self.Height; + AutoSize := True; + end + else + begin + AutoSize := False; + SavedSize := Height; + Height := 0; + end; + end; + FDown := False; + end; +end; + +procedure TDockSplitter.MouseMove(Shift: TShiftState; X, Y: Integer); +var + mid: Integer; +begin + inherited; + + if Align in [alLeft, alRight] then + begin + mid := Height div 2; + if (Y > mid - 20) and (Y < mid + 20) then + Cursor := crHandPoint + else + Cursor := crHSplit; + end + else + begin + mid := Width div 2; + if (X > mid - 20) and (X < mid + 20) then + Cursor := crHandPoint + else + Cursor := crVSplit; + end; + + if FDown then + with FDockSite do + begin + AutoSize := False; + case Align of + alLeft: + Width := Width + X; + alRight: + Width := Width - X; + alTop: + Height := Height + Y; + alBottom: + Height := Height - Y; + end; + AutoSize := True; + end; +end; + +procedure TDockSplitter.MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + inherited; + FDown := False; +end; + +procedure TDockSplitter.Paint; +var + mid: Integer; +begin + inherited; + with Canvas do + begin +// Brush.Color := clBtnFace; +// FillRect(Rect(0, 0, Width, Height)); + Brush.Color := $C0D0D0; + if Align in [alLeft, alRight] then + begin + mid := Height div 2; + FillRect(Rect(0, mid - 14, 6, mid + 15)); + DrawRubber(2, mid - 9, False); + end + else + begin + mid := Width div 2; + FillRect(Rect(mid - 14, 0, mid + 15, 6)); + DrawRubber(mid - 9, 2, True); + end; + end; +end; + + +{ TfrxDockSite } + +constructor TfrxDockSite.Create(AOwner: TComponent); +begin + inherited; + if csDesigning in ComponentState then + DockSite := True; + Align := alLeft; + Caption := ' '; + AutoSize := True; + BevelInner := bvNone; + BevelOuter := bvNone; + Width := 10; + Height := 10; + + FSplitter := TDockSplitter.Create(Self); + FSplitter.Visible := False; +end; + +procedure TfrxDockSite.SetParent(AParent: TWinControl); +begin + inherited; + if Parent <> nil then + FSplitter.Parent := Parent; +end; + +procedure TfrxDockSite.SetBounds(ALeft, ATop, AWidth, AHeight: Integer); +begin + inherited; + if FSplitter <> nil then + if Align <> FSplitter.Align then + begin + case Align of + alLeft: + begin + FSplitter.Width := 6; + FSplitter.Left := Left + Width + 6; + end; + alRight: + begin + FSplitter.Width := 6; + FSplitter.Left := Left - 6; + end; + alTop: + begin + FSplitter.Height := 6; + FSplitter.Top := Top + Height + 6; + end; + alBottom: + begin + FSplitter.Height := 6; + FSplitter.Top := Top - 6; + end; + end; + FSplitter.Align := Align; + end; +end; + +procedure TfrxDockSite.DockDrop(Source: TDragDockObject; X, Y: Integer); +begin + inherited; + if Align in [alLeft, alRight] then + begin + if Width < FPanelSize then + Source.Control.Width := FPanelSize; + end + else + begin + if Height < FPanelSize then + Source.Control.Height := FPanelSize; + end; + FSplitter.Show; +end; + +procedure TfrxDockSite.DockOver(Source: TDragDockObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); +begin + inherited; + if Align in [alLeft, alRight] then + FPanelSize := Source.Control.Width + else + FPanelSize := Source.Control.Height; +end; + +function TfrxDockSite.DoUnDock(NewTarget: TWinControl; Client: TControl): Boolean; +begin + Result := inherited DoUnDock(NewTarget, Client); + if DockClientCount <= 1 then + FSplitter.Hide; +end; + +procedure TfrxDockSite.ReloadDockedControl(const AControlName: string; + var AControl: TControl); +begin + AControl := FindGlobalComponent(AControlName) as TControl; +end; + + + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxDsgnIntf.pas b/official/4.2/LibD11/frxDsgnIntf.pas new file mode 100644 index 0000000..4065cf8 --- /dev/null +++ b/official/4.2/LibD11/frxDsgnIntf.pas @@ -0,0 +1,1955 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Design interface } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxDsgnIntf; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, StdCtrls, + Menus, TypInfo, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxPropertyAttribute = (paValueList, paSortList, paDialog, + paMultiSelect, paSubProperties, paReadOnly, paOwnerDraw); + TfrxPropertyAttributes = set of TfrxPropertyAttribute; + + TfrxPropertyEditor = class(TObject) + private + FDesigner: TfrxCustomDesigner; + FCompList: TList; + FPropList: TList; + FItemHeight: Integer; + FValues: TStrings; + function GetPropInfo: PPropInfo; + function GetComponent: TPersistent; + function GetfrComponent: TfrxComponent; + protected + procedure GetStrProc(const s: String); + function GetFloatValue: Extended; + function GetOrdValue: Integer; + function GetStrValue: String; + function GetVarValue: Variant; + procedure SetFloatValue(Value: Extended); + procedure SetOrdValue(Value: Integer); + procedure SetStrValue(const Value: String); + procedure SetVarValue(Value: Variant); + public + constructor Create(Designer: TfrxCustomDesigner); virtual; + destructor Destroy; override; + function Edit: Boolean; virtual; + function GetAttributes: TfrxPropertyAttributes; virtual; + function GetName: String; virtual; + function GetExtraLBSize: Integer; virtual; + function GetValue: String; virtual; + procedure GetValues; virtual; + procedure SetValue(const Value: String); virtual; + procedure OnDrawLBItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); virtual; + procedure OnDrawItem(Canvas: TCanvas; ARect: TRect); virtual; + property Component: TPersistent read GetComponent; + property frComponent: TfrxComponent read GetfrComponent; + property Designer: TfrxCustomDesigner read FDesigner; + property ItemHeight: Integer read FItemHeight write FItemHeight; + property PropInfo: PPropInfo read GetPropInfo; + property Value: String read GetValue write SetValue; + property Values: TStrings read FValues; + end; + + TfrxPropertyEditorClass = class of TfrxPropertyEditor; + + TfrxComponentEditor = class(TObject) + private + FComponent: TfrxComponent; + FDesigner: TfrxCustomDesigner; + FMenu: TMenu; + protected + function AddItem(const Caption: String; Tag: Integer; + Checked: Boolean = False): TMenuItem; + public + constructor Create(Component: TfrxComponent; Designer: TfrxCustomDesigner; + Menu: TMenu); + function Edit: Boolean; virtual; + function HasEditor: Boolean; virtual; + procedure GetMenuItems; virtual; + function Execute(Tag: Integer; Checked: Boolean): Boolean; virtual; + property Component: TfrxComponent read FComponent; + property Designer: TfrxCustomDesigner read FDesigner; + end; + + TfrxComponentEditorClass = class of TfrxComponentEditor; + + TfrxIntegerProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + + TfrxFloatProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + + TfrxCharProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + + TfrxStringProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + + TfrxEnumProperty = class(TfrxPropertyEditor) + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetValue: String; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxSetProperty = class(TfrxPropertyEditor) + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetValue: String; override; + end; + + TfrxSetElementProperty = class(TfrxPropertyEditor) + private + FElement: Integer; + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetName: String; override; + function GetValue: String; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxClassProperty = class(TfrxPropertyEditor) + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetValue: String; override; + end; + + TfrxComponentProperty = class(TfrxPropertyEditor) + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetValue: String; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + end; + + TfrxColorProperty = class(TfrxIntegerProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + function GetValue: String; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + procedure OnDrawLBItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); override; + procedure OnDrawItem(Canvas: TCanvas; ARect: TRect); override; + end; + + TfrxFontProperty = class(TfrxClassProperty) + public + function Edit: Boolean; override; + function GetAttributes: TfrxPropertyAttributes; override; + end; + + TfrxFontNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + TfrxFontCharsetProperty = class(TfrxIntegerProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetValue: String; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxModalResultProperty = class(TfrxIntegerProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetValue: String; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxShortCutProperty = class(TfrxPropertyEditor) + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetValue: String; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxCursorProperty = class(TfrxIntegerProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function GetValue: String; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxDateTimeProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + + TfrxDateProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + + TfrxTimeProperty = class(TfrxPropertyEditor) + public + function GetValue: String; override; + procedure SetValue(const Value: String); override; + end; + +{ Internal classes used by Object Inspector } + + TfrxPropertyList = class; + + TfrxPropertyItem = class(TCollectionItem) + private + FEditor: TfrxPropertyEditor; + FExpanded: Boolean; + FSubProperty: TfrxPropertyList; + public + destructor Destroy; override; + property Editor: TfrxPropertyEditor read FEditor; + property Expanded: Boolean read FExpanded write FExpanded; + property SubProperty: TfrxPropertyList read FSubProperty; + end; + + TfrxPropertyList = class(TCollection) + private + FComponent: TPersistent; + FDesigner: TfrxCustomDesigner; + FParent: TfrxPropertyList; + procedure AddProperties(PropertyList: TfrxPropertyList); + procedure FillProperties(AClass: TPersistent); + procedure FillCommonProperties(PropertyList: TfrxPropertyList); + procedure SetComponent(Value: TPersistent); + function GetPropertyItem(Index: Integer): TfrxPropertyItem; + public + constructor Create(Designer: TfrxCustomDesigner); + function Add: TfrxPropertyItem; + property Component: TPersistent read FComponent write SetComponent; + property Items[Index: Integer]: TfrxPropertyItem read GetPropertyItem; default; + property Parent: TfrxPropertyList read FParent; + end; + + +{ registered items } + + TfrxObjectCategory = (ctData, ctReport, ctDialog, ctDMP); + TfrxObjectCategories = set of TfrxObjectCategory; + + TfrxObjectItem = class(TCollectionItem) + public + ClassRef: TfrxComponentClass; + ButtonBmp: TBitmap; + ButtonImageIndex: Integer; + ButtonHint: String; + CategoryName: String; + Flags: Word; + Category: TfrxObjectCategories; + end; + + TfrxComponentEditorItem = class(TCollectionItem) + public + ComponentClass: TfrxComponentClass; + ComponentEditor: TfrxComponentEditorClass; + end; + + TfrxPropertyEditorItem = class(TCollectionItem) + public + PropertyType: PTypeInfo; + ComponentClass: TClass; + PropertyName: String; + EditorClass: TfrxPropertyEditorClass; + end; + + TfrxExportFilterItem = class(TCollectionItem) + public + Filter: TfrxCustomExportFilter; + end; + + TfrxWizardItem = class(TCollectionItem) + public + ClassRef: TfrxWizardClass; + ButtonBmp: TBitmap; + ButtonImageIndex: Integer; + IsToolbarWizard: Boolean; + end; + + TfrxObjectCollection = class(TCollection) + private + function GetObjectItem(Index: Integer): TfrxObjectItem; + public + constructor Create; + procedure RegisterCategory(const CategoryName: String; ButtonBmp: TBitmap; + const ButtonHint: String; ImageIndex: Integer = -1); + procedure RegisterObject(ClassRef: TfrxComponentClass; ButtonBmp: TBitmap; + const CategoryName: String = ''); + procedure RegisterObject1(ClassRef: TfrxComponentClass; ButtonBmp: TBitmap; + const ButtonHint: String = ''; const CategoryName: String = ''; + Flags: Integer = 0; ImageIndex: Integer = -1; + Category: TfrxObjectCategories = []); + procedure Unregister(ClassRef: TfrxComponentClass); + property Items[Index: Integer]: TfrxObjectItem read GetObjectItem; default; + end; + + TfrxComponentEditorCollection = class(TCollection) + private + function GetComponentEditorItem(Index: Integer): TfrxComponentEditorItem; + public + constructor Create; + procedure Register(ComponentClass: TfrxComponentClass; + ComponentEditor: TfrxComponentEditorClass); + procedure UnRegister(ComponentEditor: TfrxComponentEditorClass); + function GetComponentEditor(Component: TfrxComponent; + Designer: TfrxCustomDesigner; Menu: TMenu): TfrxComponentEditor; + property Items[Index: Integer]: TfrxComponentEditorItem + read GetComponentEditorItem; default; + end; + + TfrxPropertyEditorCollection = class(TCollection) + private + FEventEditorItem: Integer; + function GetPropertyEditorItem(Index: Integer): TfrxPropertyEditorItem; + public + constructor Create; + procedure Register(PropertyType: PTypeInfo; ComponentClass: TClass; + const PropertyName: String; EditorClass: TfrxPropertyEditorClass); + procedure RegisterEventEditor(EditorClass: TfrxPropertyEditorClass); + procedure UnRegister(EditorClass: TfrxPropertyEditorClass); + function GetPropertyEditor(PropertyType: PTypeInfo; Component: TPersistent; + PropertyName: String): Integer; + property Items[Index: Integer]: TfrxPropertyEditorItem + read GetPropertyEditorItem; default; + end; + + TfrxExportFilterCollection = class(TCollection) + private + function GetExportFilterItem(Index: Integer): TfrxExportFilterItem; + public + constructor Create; + procedure Register(Filter: TfrxCustomExportFilter); + procedure Unregister(Filter: TfrxCustomExportFilter); + property Items[Index: Integer]: TfrxExportFilterItem + read GetExportFilterItem; default; + end; + + TfrxWizardCollection = class(TCollection) + private + function GetWizardItem(Index: Integer): TfrxWizardItem; + public + constructor Create; + procedure Register(ClassRef: TfrxWizardClass; ButtonBmp: TBitmap; + IsToolbarWizard: Boolean = False); + procedure Register1(ClassRef: TfrxWizardClass; ImageIndex: Integer); + procedure Unregister(ClassRef: TfrxWizardClass); + property Items[Index: Integer]: TfrxWizardItem read GetWizardItem; default; + end; + + +{ internal methods } + +function frxCreatePropertyList(ComponentList: TList; Designer: TfrxCustomDesigner): TfrxPropertyList; +procedure frxHideProperties(ComponentClass: TClass; const Properties: String); + + +function frxObjects: TfrxObjectCollection; +function frxComponentEditors: TfrxComponentEditorCollection; +function frxPropertyEditors: TfrxPropertyEditorCollection; +function frxExportFilters: TfrxExportFilterCollection; +function frxWizards: TfrxWizardCollection; + + +implementation + +uses + Consts, Forms, Dialogs, frxUtils, frxRes; + +type + TIntegerSet = set of 0..31; + +var + FObjects: TfrxObjectCollection = nil; + FComponentEditors: TfrxComponentEditorCollection = nil; + FPropertyEditors: TfrxPropertyEditorCollection = nil; + FExportFilters: TfrxExportFilterCollection = nil; + FWizards: TfrxWizardCollection = nil; + +{ Routines } + +procedure frxHideProperties(ComponentClass: TClass; const Properties: String); +var + i: Integer; + sl: TStringList; +begin + sl := TStringList.Create; + frxSetCommaText(Properties, sl); + + for i := 0 to sl.Count - 1 do + frxPropertyEditors.Register(nil, ComponentClass, sl[i], nil); + + sl.Free; +end; + +function frxCreatePropertyList(ComponentList: TList; + Designer: TfrxCustomDesigner): TfrxPropertyList; +var + i: Integer; + p: TfrxPropertyList; + l: TList; +begin + if ComponentList.Count = 0 then + begin + Result := nil; + Exit; + end; + + l := TList.Create; + for i := 0 to ComponentList.Count - 1 do + begin + p := TfrxPropertyList.Create(Designer); + l.Add(p); + p.Component := ComponentList[i]; + end; + + Result := l[0]; + for i := 1 to ComponentList.Count - 1 do + Result.FillCommonProperties(TfrxPropertyList(l[i])); + + for i := 1 to ComponentList.Count - 1 do + begin + TfrxPropertyList(l[i]).FillCommonProperties(Result); + Result.AddProperties(TfrxPropertyList(l[i])); + TfrxPropertyList(l[i]).Free; + end; + + l.Free; +end; + +function frStrToFloat(s: String): Extended; +var + i: Integer; +begin + for i := 1 to Length(s) do + if s[i] in [',', '.'] then + s[i] := DecimalSeparator; + Result := StrToFloat(Trim(s)); +end; + + +{ TfrxPropertyEditor } + +constructor TfrxPropertyEditor.Create(Designer: TfrxCustomDesigner); +begin + FDesigner := Designer; + FCompList := TList.Create; + FPropList := TList.Create; + FValues := TStringList.Create; +end; + +destructor TfrxPropertyEditor.Destroy; +begin + FCompList.Free; + FPropList.Free; + FValues.Free; + inherited; +end; + +function TfrxPropertyEditor.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect]; +end; + +function TfrxPropertyEditor.GetName: String; +begin + Result := PropInfo.Name; +end; + +function TfrxPropertyEditor.GetComponent: TPersistent; +begin + Result := FCompList[0]; +end; + +function TfrxPropertyEditor.GetfrComponent: TfrxComponent; +begin + if TObject(FCompList[0]) is TfrxComponent then + Result := FCompList[0] else + Result := nil; +end; + +function TfrxPropertyEditor.GetPropInfo: PPropInfo; +begin + Result := FPropList[0]; +end; + +function TfrxPropertyEditor.GetValue: String; +begin + Result := '(Unknown)'; +end; + +procedure TfrxPropertyEditor.SetValue(const Value: String); +begin + { empty method } +end; + +function TfrxPropertyEditor.GetFloatValue: Extended; +begin + Result := GetFloatProp(Component, PropInfo); +end; + +function TfrxPropertyEditor.GetOrdValue: Integer; +begin + Result := GetOrdProp(Component, PropInfo); +end; + +function TfrxPropertyEditor.GetStrValue: String; +begin + Result := GetStrProp(Component, PropInfo); +end; + +function TfrxPropertyEditor.GetVarValue: Variant; +begin + Result := GetVariantProp(Component, PropInfo); +end; + +procedure TfrxPropertyEditor.SetFloatValue(Value: Extended); +var + i: Integer; +begin + for i := 0 to FCompList.Count - 1 do + if (PPropInfo(FPropList[i]).SetProc <> nil) then + SetFloatProp(TObject(FCompList[i]), PPropInfo(FPropList[i]), Value); +end; + +procedure TfrxPropertyEditor.SetOrdValue(Value: Integer); +var + i: Integer; +begin + for i := 0 to FCompList.Count - 1 do + if (PPropInfo(FPropList[i]).SetProc <> nil) then + SetOrdProp(TObject(FCompList[i]), PPropInfo(FPropList[i]), Value); +end; + +procedure TfrxPropertyEditor.SetStrValue(const Value: String); +var + i: Integer; +begin + for i := 0 to FCompList.Count - 1 do + if (PPropInfo(FPropList[i]).SetProc <> nil) then + SetStrProp(TObject(FCompList[i]), PPropInfo(FPropList[i]), Value); +end; + +procedure TfrxPropertyEditor.SetVarValue(Value: Variant); +var + i: Integer; +begin + for i := 0 to FCompList.Count - 1 do + if (PPropInfo(FPropList[i]).SetProc <> nil) then + SetVariantProp(TObject(FCompList[i]), PPropInfo(FPropList[i]), Value); +end; + +procedure TfrxPropertyEditor.GetValues; +begin + FValues.Clear; + TStringList(FValues).Sorted := paSortList in GetAttributes; +end; + +procedure TfrxPropertyEditor.GetStrProc(const s: String); +begin + FValues.Add(s); +end; + +function TfrxPropertyEditor.Edit: Boolean; +var + i: Integer; +begin + Result := False; + GetValues; + if FValues.Count > 0 then + begin + i := FValues.IndexOf(Value) + 1; + if i = FValues.Count then + i := 0; + Value := FValues[i]; + Result := True; + end; +end; + +procedure TfrxPropertyEditor.OnDrawLBItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +begin + with TListBox(Control).Canvas do + begin + FillRect(ARect); + TextOut(ARect.Left + FItemHeight + 4, ARect.Top + 1, TListBox(Control).Items[Index]); + Pen.Color := clGray; + end; +end; + +procedure TfrxPropertyEditor.OnDrawItem(Canvas: TCanvas; ARect: TRect); +begin + Canvas.TextOut(ARect.Left + FItemHeight - 2, ARect.Top, Value); + Canvas.Pen.Color := clGray; +end; + +function TfrxPropertyEditor.GetExtraLBSize: Integer; +begin + Result := FItemHeight + 2; +end; + + +{ TfrxComponentEditor } + +function TfrxComponentEditor.Edit: Boolean; +begin + Result := False; +end; + +procedure TfrxComponentEditor.GetMenuItems; +begin +// empty method +end; + +function TfrxComponentEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +begin + Result := False; +end; + +function TfrxComponentEditor.HasEditor: Boolean; +begin + Result := False; +end; + +function TfrxComponentEditor.AddItem(const Caption: String; Tag: Integer; + Checked: Boolean): TMenuItem; +begin + Result := TMenuItem.Create(FMenu); + Result.Caption := Caption; + Result.Tag := Tag; + Result.Checked := Checked; + FMenu.Items.Add(Result); +end; + + +constructor TfrxComponentEditor.Create(Component: TfrxComponent; + Designer: TfrxCustomDesigner; Menu: TMenu); +begin + FComponent := Component; + FDesigner := Designer; + FMenu := Menu; +end; + + +{ TfrxPropertyList } + +constructor TfrxPropertyList.Create(Designer: TfrxCustomDesigner); +begin + inherited Create(TfrxPropertyItem); + FDesigner := Designer; +end; + +function TfrxPropertyList.GetPropertyItem(Index: Integer): TfrxPropertyItem; +begin + Result := TfrxPropertyItem(inherited Items[Index]); +end; + +function TfrxPropertyList.Add: TfrxPropertyItem; +begin + Result := TfrxPropertyItem(inherited Add); +end; + +procedure TfrxPropertyList.SetComponent(Value: TPersistent); +begin + FComponent := Value; + Clear; + FillProperties(FComponent); +end; + +procedure TfrxPropertyList.FillProperties(AClass: TPersistent); +var + Item, Item1: TfrxPropertyItem; + TypeInfo: PTypeInfo; + PropertyCount: Integer; + PropertyList: PPropList; + i, j: Integer; + FClass: TClass; + + function CreateEditor(EditorClass: TfrxPropertyEditorClass; AClass: TPersistent; + PropInfo: PPropInfo): TfrxPropertyEditor; + var + Item: TfrxPropertyEditorItem; + e: Integer; + begin + Result := nil; + e := frxPropertyEditors.GetPropertyEditor(PropInfo.PropType^, AClass, PropInfo.Name); + if e <> -1 then + begin + Item := frxPropertyEditors[e]; + if Item.EditorClass <> nil then + Result := TfrxPropertyEditor(Item.EditorClass.NewInstance) else + Exit; + end + else + Result := TfrxPropertyEditor(EditorClass.NewInstance); + + Result.Create(FDesigner); + Result.FCompList.Add(AClass); + Result.FPropList.Add(PropInfo); + end; + +begin + if AClass = nil then exit; + + TypeInfo := AClass.ClassInfo; + PropertyCount := GetPropList(TypeInfo, tkProperties, nil); + GetMem(PropertyList, PropertyCount * SizeOf(PPropInfo)); + GetPropList(TypeInfo, tkProperties, PropertyList); + + for i := 0 to PropertyCount - 1 do + begin + Item := Add; + case PropertyList[i].PropType^.Kind of + tkInteger: + Item.FEditor := CreateEditor(TfrxIntegerProperty, AClass, PropertyList[i]); + + tkChar, tkWChar: + Item.FEditor := CreateEditor(TfrxCharProperty, AClass, PropertyList[i]); + + tkFloat: + Item.FEditor := CreateEditor(TfrxFloatProperty, AClass, PropertyList[i]); + + tkString, tkLString, tkWString: + Item.FEditor := CreateEditor(TfrxStringProperty, AClass, PropertyList[i]); + + tkEnumeration: + Item.FEditor := CreateEditor(TfrxEnumProperty, AClass, PropertyList[i]); + + tkSet: + begin + Item.FSubProperty := TfrxPropertyList.Create(FDesigner); + Item.FSubProperty.FParent := Self; + Item.FEditor := CreateEditor(TfrxSetProperty, AClass, PropertyList[i]); + with GetTypeData(GetTypeData(PropertyList[i].PropType^).CompType^)^ do + for j := MinValue to MaxValue do + begin + Item1 := Item.FSubProperty.Add; + Item1.FEditor := CreateEditor(TfrxSetElementProperty, AClass, PropertyList[i]); + if Item1.FEditor <> nil then + TfrxSetElementProperty(Item1.FEditor).FElement := j; + end; + end; + + tkClass: + begin + FClass := GetTypeData(PropertyList[i].PropType^)^.ClassType; + if FClass.InheritsFrom(TComponent) then + Item.FEditor := CreateEditor(TfrxComponentProperty, AClass, PropertyList[i]) + else if FClass.InheritsFrom(TPersistent) then + begin + Item.FEditor := CreateEditor(TfrxClassProperty, AClass, PropertyList[i]); + Item.FSubProperty := TfrxPropertyList.Create(FDesigner); + Item.FSubProperty.FParent := Self; + Item.FSubProperty.Component := TPersistent(GetOrdProp(AClass, PropertyList[i])); + if Item.SubProperty.Count = 0 then + begin + Item.FSubProperty.Free; + Item.FSubProperty := nil; + end; + end; + end; + end; + if Item.FEditor = nil then + Item.Free; + end; + + FreeMem(PropertyList, PropertyCount * SizeOf(PPropInfo)); +end; + +procedure TfrxPropertyList.FillCommonProperties(PropertyList: TfrxPropertyList); +var + i, j: Integer; + p, p1: TfrxPropertyItem; + Found: Boolean; +begin + i := 0; + while i < Count do + begin + p := Items[i]; + Found := False; + if paMultiSelect in p.Editor.GetAttributes then + for j := 0 to PropertyList.Count - 1 do + begin + p1 := PropertyList.Items[j]; + if (p1.Editor.GetPropInfo.PropType^.Kind = p.Editor.GetPropInfo.PropType^.Kind) and + (p1.Editor.GetPropInfo.Name = p.Editor.GetPropInfo.Name) then + begin + Found := True; + break; + end; + end; + + if not Found then + p.Free else + Inc(i); + end; +end; + +procedure TfrxPropertyList.AddProperties(PropertyList: TfrxPropertyList); + + procedure EnumProperties(p1, p2: TfrxPropertyList); + var + i: Integer; + begin + for i := 0 to p1.Count - 1 do + begin + p1[i].Editor.FCompList.Add(p2[i].Editor.FCompList[0]); + p1[i].Editor.FPropList.Add(p2[i].Editor.FPropList[0]); + if p1[i].SubProperty <> nil then + EnumProperties(p1[i].SubProperty, p2[i].SubProperty); + end; + end; + +begin + EnumProperties(Self, PropertyList); +end; + + +{ TfrxPropertyItem } + +destructor TfrxPropertyItem.Destroy; +begin + if Editor <> nil then + Editor.Free; + if SubProperty <> nil then + SubProperty.Free; + inherited; +end; + + +{ TfrxIntegerProperty } + +function TfrxIntegerProperty.GetValue: String; +begin + Result := IntToStr(GetOrdValue); +end; + +procedure TfrxIntegerProperty.SetValue(const Value: String); +begin + SetOrdValue(StrToInt(Value)); +end; + + +{ TfrxFloatProperty } + +function TfrxFloatProperty.GetValue: String; +begin + Result := FloatToStr(GetFloatValue); +end; + +procedure TfrxFloatProperty.SetValue(const Value: String); +begin + SetFloatValue(frStrToFloat(Value)); +end; + + +{ TfrxCharProperty } + +function TfrxCharProperty.GetValue: String; +var + Ch: Char; +begin + Ch := Chr(GetOrdValue); + if Ch in [#33..#255] then + Result := Ch else + FmtStr(Result, '#%d', [Ord(Ch)]); +end; + +procedure TfrxCharProperty.SetValue(const Value: String); +var + i: Integer; +begin + if Length(Value) = 0 then i := 0 else + if Length(Value) = 1 then i := Ord(Value[1]) else + if Value[1] = '#' then i := StrToInt(Copy(Value, 2, 255)) else + raise Exception.Create(frxResources.Get('prInvProp')); + SetOrdValue(i); +end; + + +{ TfrxStringProperty } + +function TfrxStringProperty.GetValue: String; +begin + Result := GetStrValue; +end; + +procedure TfrxStringProperty.SetValue(const Value: String); +begin + SetStrValue(Value); +end; + + +{ TfrxEnumProperty } + +function TfrxEnumProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +function TfrxEnumProperty.GetValue: String; +var + i: Integer; +begin + i := GetOrdValue; + Result := GetEnumName(PropInfo.PropType^, i); +end; + +procedure TfrxEnumProperty.GetValues; +var + i: Integer; +begin + inherited; + with GetTypeData(PropInfo.PropType^)^ do + for i := MinValue to MaxValue do + Values.Add(GetEnumName(PropInfo.PropType^, i)); +end; + +procedure TfrxEnumProperty.SetValue(const Value: String); +var + i: Integer; +begin + i := GetEnumValue(PropInfo.PropType^, Value); + if i < 0 then + raise Exception.Create(frxResources.Get('prInvProp')); + SetOrdValue(i); +end; + + +{ TfrxSetProperty } + +function TfrxSetProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paSubProperties, paReadOnly]; +end; + +function TfrxSetProperty.GetValue: String; +var + S: TIntegerSet; + TypeInfo: PTypeInfo; + I: Integer; +begin + Integer(S) := GetOrdValue; + TypeInfo := GetTypeData(PropInfo.PropType^).CompType^; + Result := '['; + for i := 0 to 31 do + if i in S then + begin + if Length(Result) <> 1 then + Result := Result + ','; + Result := Result + GetEnumName(TypeInfo, i); + end; + Result := Result + ']'; +end; + + +{ TfrxSetElementProperty } + +function TfrxSetElementProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +function TfrxSetElementProperty.GetName: String; +begin + Result := GetEnumName(GetTypeData(PropInfo.PropType^).CompType^, FElement); +end; + +function TfrxSetElementProperty.GetValue: String; +var + S: TIntegerSet; +begin + Integer(S) := GetOrdValue; + if FElement in S then + Result := 'True' else + Result := 'False'; +end; + +procedure TfrxSetElementProperty.GetValues; +begin + inherited; + Values.Add('False'); + Values.Add('True'); +end; + +procedure TfrxSetElementProperty.SetValue(const Value: String); +var + S: TIntegerSet; +begin + Integer(S) := GetOrdValue; + if CompareText(Value, 'True') = 0 then + Include(S, FElement) + else if CompareText(Value, 'False') = 0 then + Exclude(S, FElement) + else + raise Exception.Create(frxResources.Get('prInvProp')); + + SetOrdValue(Integer(S)); +end; + + +{ TfrxClassProperty } + +function TfrxClassProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paSubProperties, paReadOnly]; +end; + +function TfrxClassProperty.GetValue: String; +begin + Result := {'';//}'(' + PropInfo.PropType^.Name + ')'; +end; + + +{ TComponentProperty } + +function TfrxComponentProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +function TfrxComponentProperty.GetValue: String; +var + c: TComponent; +begin + c := TComponent(GetOrdValue); + if c <> nil then + Result := c.Name else + Result := ''; +end; + +procedure TfrxComponentProperty.GetValues; +var + i: Integer; + c, c1: TfrxComponent; +begin + inherited; + + if frComponent <> nil then + begin + if frComponent is TfrxReportComponent then + c := frComponent.Page else + c := frComponent; + for i := 0 to c.AllObjects.Count - 1 do + begin + c1 := c.AllObjects[i]; + if (c1 <> frComponent) and + c1.InheritsFrom(GetTypeData(PropInfo.PropType^)^.ClassType) then + Values.Add(c1.Name); + end; + end; +end; + +procedure TfrxComponentProperty.SetValue(const Value: String); +var + c: TComponent; +begin + c := nil; + if Value <> '' then + begin + c := frComponent.Report.FindObject(Value); + if c = nil then + raise Exception.Create(frxResources.Get('prInvProp')); + end; + + SetOrdValue(Integer(c)); +end; + + +{ TfrxNameProperty } + +function TfrxNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := []; +end; + + +{ TfrxColorProperty } + +function TfrxColorProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paOwnerDraw]; +end; + +function TfrxColorProperty.GetValue: String; +begin + Result := ColorToString(GetOrdValue); +end; + +procedure TfrxColorProperty.SetValue(const Value: String); +var + c: Integer; +begin + if IdentToColor(Value, c) then + SetOrdValue(c) else + inherited SetValue(Value); +end; + +procedure TfrxColorProperty.GetValues; +begin + inherited; + GetColorValues(GetStrProc); +end; + +function TfrxColorProperty.Edit: Boolean; +begin + with TColorDialog.Create(Application) do + begin + Color := GetOrdValue; + Result := Execute; + if Result then + SetOrdValue(Color); + Free; + end; +end; + +procedure TfrxColorProperty.OnDrawLBItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); +var + c: Integer; +begin + inherited; + with TListBox(Control), TListBox(Control).Canvas do + begin + IdentToColor(Items[Index], c); + Brush.Color := c; + Rectangle(ARect.Left + 2, ARect.Top + 2, ARect.Left + (ARect.Bottom - ARect.Top - 2), ARect.Bottom - 2); + end; +end; + +procedure TfrxColorProperty.OnDrawItem(Canvas: TCanvas; ARect: TRect); +begin + inherited; + with Canvas do + begin + Brush.Color := GetOrdValue; + Rectangle(ARect.Left, ARect.Top + 1, ARect.Left + (ARect.Bottom - ARect.Top - 5), ARect.Bottom - 4); + end; +end; + + +{ TfrxFontProperty } + +function TfrxFontProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paDialog, paSubProperties, paReadOnly]; +end; + +function TfrxFontProperty.Edit: Boolean; +var + FontDialog: TFontDialog; +begin + FontDialog := TFontDialog.Create(Application); + try + FontDialog.Font := TFont(GetOrdValue); + FontDialog.Options := FontDialog.Options + [fdForceFontExist]; + FontDialog.Device := fdBoth; + Result := FontDialog.Execute; + if Result then + SetOrdValue(Integer(FontDialog.Font)); + finally + FontDialog.Free; + end; +end; + + +{ TfrxFontNameProperty } + +function TfrxFontNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +procedure TfrxFontNameProperty.GetValues; +begin + Values.Assign(Screen.Fonts); +end; + + +{ TfrxFontCharsetProperty } + +function TfrxFontCharsetProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +function TfrxFontCharsetProperty.GetValue: String; +begin + if not CharsetToIdent(GetOrdValue, Result) then + FmtStr(Result, '%d', [GetOrdValue]); +end; + +procedure TfrxFontCharsetProperty.SetValue(const Value: String); +var + c: Integer; +begin + if IdentToCharset(Value, c) then + SetOrdValue(c) else + inherited SetValue(Value); +end; + +procedure TfrxFontCharsetProperty.GetValues; +begin + inherited; + GetCharsetValues(GetStrProc); +end; + + +{ TfrxModalResultProperty } + +const + ModalResults: array[mrNone..mrYesToAll] of string = ( + 'mrNone', + 'mrOk', + 'mrCancel', + 'mrAbort', + 'mrRetry', + 'mrIgnore', + 'mrYes', + 'mrNo', + 'mrAll', + 'mrNoToAll', + 'mrYesToAll'); + +function TfrxModalResultProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +function TfrxModalResultProperty.GetValue: String; +begin + if GetOrdValue in [mrNone..mrYesToAll] then + Result := ModalResults[GetOrdValue] else + Result := inherited GetValue; +end; + +procedure TfrxModalResultProperty.SetValue(const Value: String); +var + i: Integer; + s: String; +begin + s := Value; + if s = '' then + s := '0'; + for i := Low(ModalResults) to High(ModalResults) do + if CompareText(ModalResults[i], s) = 0 then + begin + SetOrdValue(i); + Exit; + end; + inherited SetValue(s); +end; + +procedure TfrxModalResultProperty.GetValues; +var + i: Integer; +begin + inherited; + for i := mrNone to mrYesToAll do + Values.Add(ModalResults[i]); +end; + + +{ TfrxShortCutProperty } + +const + ShortCuts: array[0..108] of TShortCut = ( + scNone, + Byte('A') or scCtrl, + Byte('B') or scCtrl, + Byte('C') or scCtrl, + Byte('D') or scCtrl, + Byte('E') or scCtrl, + Byte('F') or scCtrl, + Byte('G') or scCtrl, + Byte('H') or scCtrl, + Byte('I') or scCtrl, + Byte('J') or scCtrl, + Byte('K') or scCtrl, + Byte('L') or scCtrl, + Byte('M') or scCtrl, + Byte('N') or scCtrl, + Byte('O') or scCtrl, + Byte('P') or scCtrl, + Byte('Q') or scCtrl, + Byte('R') or scCtrl, + Byte('S') or scCtrl, + Byte('T') or scCtrl, + Byte('U') or scCtrl, + Byte('V') or scCtrl, + Byte('W') or scCtrl, + Byte('X') or scCtrl, + Byte('Y') or scCtrl, + Byte('Z') or scCtrl, + Byte('A') or scCtrl or scAlt, + Byte('B') or scCtrl or scAlt, + Byte('C') or scCtrl or scAlt, + Byte('D') or scCtrl or scAlt, + Byte('E') or scCtrl or scAlt, + Byte('F') or scCtrl or scAlt, + Byte('G') or scCtrl or scAlt, + Byte('H') or scCtrl or scAlt, + Byte('I') or scCtrl or scAlt, + Byte('J') or scCtrl or scAlt, + Byte('K') or scCtrl or scAlt, + Byte('L') or scCtrl or scAlt, + Byte('M') or scCtrl or scAlt, + Byte('N') or scCtrl or scAlt, + Byte('O') or scCtrl or scAlt, + Byte('P') or scCtrl or scAlt, + Byte('Q') or scCtrl or scAlt, + Byte('R') or scCtrl or scAlt, + Byte('S') or scCtrl or scAlt, + Byte('T') or scCtrl or scAlt, + Byte('U') or scCtrl or scAlt, + Byte('V') or scCtrl or scAlt, + Byte('W') or scCtrl or scAlt, + Byte('X') or scCtrl or scAlt, + Byte('Y') or scCtrl or scAlt, + Byte('Z') or scCtrl or scAlt, + VK_F1, + VK_F2, + VK_F3, + VK_F4, + VK_F5, + VK_F6, + VK_F7, + VK_F8, + VK_F9, + VK_F10, + VK_F11, + VK_F12, + VK_F1 or scCtrl, + VK_F2 or scCtrl, + VK_F3 or scCtrl, + VK_F4 or scCtrl, + VK_F5 or scCtrl, + VK_F6 or scCtrl, + VK_F7 or scCtrl, + VK_F8 or scCtrl, + VK_F9 or scCtrl, + VK_F10 or scCtrl, + VK_F11 or scCtrl, + VK_F12 or scCtrl, + VK_F1 or scShift, + VK_F2 or scShift, + VK_F3 or scShift, + VK_F4 or scShift, + VK_F5 or scShift, + VK_F6 or scShift, + VK_F7 or scShift, + VK_F8 or scShift, + VK_F9 or scShift, + VK_F10 or scShift, + VK_F11 or scShift, + VK_F12 or scShift, + VK_F1 or scShift or scCtrl, + VK_F2 or scShift or scCtrl, + VK_F3 or scShift or scCtrl, + VK_F4 or scShift or scCtrl, + VK_F5 or scShift or scCtrl, + VK_F6 or scShift or scCtrl, + VK_F7 or scShift or scCtrl, + VK_F8 or scShift or scCtrl, + VK_F9 or scShift or scCtrl, + VK_F10 or scShift or scCtrl, + VK_F11 or scShift or scCtrl, + VK_F12 or scShift or scCtrl, + VK_INSERT, + VK_INSERT or scShift, + VK_INSERT or scCtrl, + VK_DELETE, + VK_DELETE or scShift, + VK_DELETE or scCtrl, + VK_BACK or scAlt, + VK_BACK or scShift or scAlt); + +function TfrxShortCutProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +function TfrxShortCutProperty.GetValue: String; +var + CurValue: TShortCut; +begin + CurValue := GetOrdValue; + if CurValue = scNone then + Result := srNone else + Result := ShortCutToText(CurValue); +end; + +procedure TfrxShortCutProperty.SetValue(const Value: String); +var + NewValue: TShortCut; +begin + NewValue := 0; + if (Value <> '') and (AnsiCompareText(Value, srNone) <> 0) then + NewValue := TextToShortCut(Value); + SetOrdValue(NewValue); +end; + +procedure TfrxShortCutProperty.GetValues; +var + i: Integer; +begin + inherited; + Values.Add(srNone); + for i := 1 to High(ShortCuts) do + Values.Add(ShortCutToText(ShortCuts[i])); +end; + + +{ TfrxCursorProperty } + +function TfrxCursorProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +function TfrxCursorProperty.GetValue: string; +begin + Result := CursorToString(TCursor(GetOrdValue)); +end; + +procedure TfrxCursorProperty.GetValues; +begin + inherited; + GetCursorValues(GetStrProc); +end; + +procedure TfrxCursorProperty.SetValue(const Value: string); +var + NewValue: Integer; +begin + if IdentToCursor(Value, NewValue) then + SetOrdValue(NewValue) else + inherited; +end; + + +{ TfrxDateTimeProperty } + +function TfrxDateTimeProperty.GetValue: String; +var + DT: TDateTime; +begin + DT := GetFloatValue; + if DT = 0.0 then + Result := '' + else + Result := DateTimeToStr(DT); +end; + +procedure TfrxDateTimeProperty.SetValue(const Value: String); +var + DT: TDateTime; +begin + if Value = '' then + DT := 0.0 + else + DT := StrToDateTime(Value); + SetFloatValue(DT); +end; + + +{ TfrxDateProperty } + +function TfrxDateProperty.GetValue: String; +var + DT: TDateTime; +begin + DT := GetFloatValue; + if DT = 0.0 then + Result := '' + else + Result := DateToStr(DT); +end; + +procedure TfrxDateProperty.SetValue(const Value: String); +var + DT: TDateTime; +begin + if Value = '' then + DT := 0.0 + else + DT := StrToDate(Value); + SetFloatValue(DT); +end; + + +{ TfrxTimeProperty } + +function TfrxTimeProperty.GetValue: String; +var + DT: TDateTime; +begin + DT := GetFloatValue; + if DT = 0.0 then + Result := '' + else + Result := TimeToStr(DT); +end; + +procedure TfrxTimeProperty.SetValue(const Value: String); +var + DT: TDateTime; +begin + if Value = '' then + DT := 0.0 + else + DT := StrToTime(Value); + SetFloatValue(DT); +end; + + +{ TfrxObjectCollection } + +constructor TfrxObjectCollection.Create; +begin + inherited Create(TfrxObjectItem); +end; + +function TfrxObjectCollection.GetObjectItem(Index: Integer): TfrxObjectItem; +begin + Result := TfrxObjectItem(inherited Items[Index]); +end; + +procedure TfrxObjectCollection.RegisterCategory(const CategoryName: String; + ButtonBmp: TBitmap; const ButtonHint: String; ImageIndex: Integer); +begin + RegisterObject1(nil, ButtonBmp, ButtonHint, CategoryName, 0, ImageIndex); +end; + +procedure TfrxObjectCollection.RegisterObject(ClassRef: TfrxComponentClass; + ButtonBmp: TBitmap; const CategoryName: String); +begin + RegisterObject1(ClassRef, ButtonBmp, '', CategoryName); +end; + +procedure TfrxObjectCollection.RegisterObject1( + ClassRef: TfrxComponentClass; ButtonBmp: TBitmap; + const ButtonHint: String = ''; const CategoryName: String = ''; + Flags: Integer = 0; ImageIndex: Integer = -1; + Category: TfrxObjectCategories = []); +var + i: Integer; + Item: TfrxObjectItem; +begin + for i := 0 to Count - 1 do + begin + Item := Items[i]; + if (Item.ClassRef <> nil) and (Item.ClassRef = ClassRef) and + (Item.Flags = Flags) then + Exit; + end; + + if ClassRef <> nil then + RegisterClass(ClassRef); + + Item := TfrxObjectItem(Add); + Item.ClassRef := ClassRef; + Item.ButtonBmp := ButtonBmp; + Item.ButtonImageIndex := ImageIndex; + Item.ButtonHint := ButtonHint; + Item.CategoryName := CategoryName; + Item.Flags := Flags; + Item.Category := Category; + + { if category is not set, determine it automatically } + if (ClassRef <> nil) and (Category = []) then + begin + if ClassRef.InheritsFrom(TfrxDataset) or + ClassRef.InheritsFrom(TfrxCustomDatabase) then + Item.Category := [ctData] + else if ClassRef.InheritsFrom(TfrxDialogControl) or + ClassRef.InheritsFrom(TfrxDialogComponent) then + Item.Category := [ctDialog] + else + Item.Category := [ctReport]; + end; + + if ButtonBmp <> nil then + ButtonBmp.Dormant; +end; + +procedure TfrxObjectCollection.UnRegister(ClassRef: TfrxComponentClass); +var + i: Integer; +begin + i := 0; + while i < Count do + begin + if Items[i].ClassRef = ClassRef then + Items[i].Free else + Inc(i); + end; +end; + + +{ TfrxComponentEditorCollection } + +constructor TfrxComponentEditorCollection.Create; +begin + inherited Create(TfrxComponentEditorItem); +end; + +function TfrxComponentEditorCollection.GetComponentEditorItem( + Index: Integer): TfrxComponentEditorItem; +begin + Result := TfrxComponentEditorItem(inherited Items[Index]); +end; + +function TfrxComponentEditorCollection.GetComponentEditor(Component: TfrxComponent; + Designer: TfrxCustomDesigner; Menu: TMenu): TfrxComponentEditor; +var + i, j: Integer; +begin + Result := nil; + j := -1; + for i := 0 to Count - 1 do + if Items[i].ComponentClass = Component.ClassType then + begin + j := i; + break; + end + else if Component.InheritsFrom(Items[i].ComponentClass) then + j := i; + + if j <> -1 then + begin + Result := TfrxComponentEditor(Items[j].ComponentEditor.NewInstance); + Result.Create(Component, Designer, Menu); + end; +end; + +procedure TfrxComponentEditorCollection.Register(ComponentClass: TfrxComponentClass; + ComponentEditor: TfrxComponentEditorClass); +var + Item: TfrxComponentEditorItem; +begin + Item := TfrxComponentEditorItem(Add); + Item.ComponentClass := ComponentClass; + Item.ComponentEditor := ComponentEditor; +end; + +procedure TfrxComponentEditorCollection.UnRegister(ComponentEditor: TfrxComponentEditorClass); +var + i: Integer; +begin + i := 0; + while i < Count do + begin + if Items[i].ComponentEditor = ComponentEditor then + Items[i].Free else + Inc(i); + end; +end; + + +{ TfrxPropertyEditorCollection } + +constructor TfrxPropertyEditorCollection.Create; +begin + inherited Create(TfrxPropertyEditorItem); + FEventEditorItem := -1; +end; + +function TfrxPropertyEditorCollection.GetPropertyEditorItem( + Index: Integer): TfrxPropertyEditorItem; +begin + Result := TfrxPropertyEditorItem(inherited Items[Index]); +end; + +function TfrxPropertyEditorCollection.GetPropertyEditor(PropertyType: PTypeInfo; + Component: TPersistent; PropertyName: String): Integer; +var + i: Integer; + Item: TfrxPropertyEditorItem; +begin + if (Pos('tfrx', LowerCase(PropertyType.Name)) = 1) and + (Pos('event', LowerCase(PropertyType.Name)) = Length(PropertyType.Name) - 4) then + begin + Result := FEventEditorItem; + Exit; + end; + + Result := -1; + for i := Count - 1 downto 0 do + begin + Item := Items[i]; + if (Item.ComponentClass = nil) and (Item.PropertyName = '') and + (Item.PropertyType = PropertyType) then + Result := i + else if (Item.ComponentClass = nil) and (Item.PropertyType = PropertyType) and + (CompareText(Item.PropertyName, PropertyName) = 0) then + begin + Result := i; + break; + end + else if (Component.InheritsFrom(Item.ComponentClass)) and + (CompareText(Item.PropertyName, PropertyName) = 0) then + begin + Result := i; + break; + end; + end; +end; + +procedure TfrxPropertyEditorCollection.Register(PropertyType: PTypeInfo; + ComponentClass: TClass; const PropertyName: String; + EditorClass: TfrxPropertyEditorClass); +var + Item: TfrxPropertyEditorItem; +begin + Item := TfrxPropertyEditorItem(Add); + Item.PropertyType := PropertyType; + Item.ComponentClass := ComponentClass; + Item.PropertyName := PropertyName; + Item.EditorClass := EditorClass; +end; + +procedure TfrxPropertyEditorCollection.RegisterEventEditor( + EditorClass: TfrxPropertyEditorClass); +begin + Register(nil, nil, '', EditorClass); + FEventEditorItem := Count - 1; +end; + +procedure TfrxPropertyEditorCollection.UnRegister(EditorClass: TfrxPropertyEditorClass); +var + i: Integer; +begin + i := 0; + while i < Count do + begin + if Items[i].EditorClass = EditorClass then + Items[i].Free else + Inc(i); + end; +end; + + +{ TfrxExportFilterCollection } + +constructor TfrxExportFilterCollection.Create; +begin + inherited Create(TfrxExportFilterItem); +end; + +function TfrxExportFilterCollection.GetExportFilterItem( + Index: Integer): TfrxExportFilterItem; +begin + Result := TfrxExportFilterItem(inherited Items[Index]); +end; + +procedure TfrxExportFilterCollection.Register(Filter: TfrxCustomExportFilter); +var + i: Integer; + Item: TfrxExportFilterItem; +begin + if Filter = nil then Exit; + for i := 0 to Count - 1 do + if Items[i].Filter = Filter then + Exit; + + Item := TfrxExportFilterItem(Add); + Item.Filter := Filter; +end; + +procedure TfrxExportFilterCollection.UnRegister(Filter: TfrxCustomExportFilter); +var + i: Integer; +begin + i := 0; + while i < Count do + begin + if Items[i].Filter = Filter then + Items[i].Free else + Inc(i); + end; +end; + + +{ TfrxWizardCollection } + +constructor TfrxWizardCollection.Create; +begin + inherited Create(TfrxWizardItem); +end; + +function TfrxWizardCollection.GetWizardItem(Index: Integer): TfrxWizardItem; +begin + Result := TfrxWizardItem(inherited Items[Index]); +end; + +procedure TfrxWizardCollection.Register(ClassRef: TfrxWizardClass; + ButtonBmp: TBitmap; IsToolbarWizard: Boolean); +var + i: Integer; + Item: TfrxWizardItem; +begin + for i := 0 to Count - 1 do + if Items[i].ClassRef = ClassRef then + Exit; + + Item := TfrxWizardItem(Add); + Item.ClassRef := ClassRef; + Item.ButtonBmp := ButtonBmp; + Item.ButtonImageIndex := -1; + Item.IsToolbarWizard := IsToolbarWizard; + + if ButtonBmp <> nil then + ButtonBmp.Dormant; +end; + +procedure TfrxWizardCollection.Register1(ClassRef: TfrxWizardClass; + ImageIndex: Integer); +var + i: Integer; + Item: TfrxWizardItem; +begin + for i := 0 to Count - 1 do + if Items[i].ClassRef = ClassRef then + Exit; + + Item := TfrxWizardItem(Add); + Item.ClassRef := ClassRef; + Item.ButtonImageIndex := ImageIndex; +end; + +procedure TfrxWizardCollection.UnRegister(ClassRef: TfrxWizardClass); +var + i: Integer; +begin + i := 0; + while i < Count do + begin + if Items[i].ClassRef = ClassRef then + Items[i].Free else + Inc(i); + end; +end; + + +{ globals } + +function frxObjects: TfrxObjectCollection; +begin + if FObjects = nil then + FObjects := TfrxObjectCollection.Create; + Result := FObjects; +end; + +function frxComponentEditors: TfrxComponentEditorCollection; +begin + if FComponentEditors = nil then + FComponentEditors := TfrxComponentEditorCollection.Create; + Result := FComponentEditors; +end; + +function frxPropertyEditors: TfrxPropertyEditorCollection; +begin + if FPropertyEditors = nil then + FPropertyEditors := TfrxPropertyEditorCollection.Create; + Result := FPropertyEditors; +end; + +function frxExportFilters: TfrxExportFilterCollection; +begin + if FExportFilters = nil then + FExportFilters := TfrxExportFilterCollection.Create; + Result := FExportFilters; +end; + +function frxWizards: TfrxWizardCollection; +begin + if FWizards = nil then + FWizards := TfrxWizardCollection.Create; + Result := FWizards; +end; + + +initialization + frxPropertyEditors.Register(TypeInfo(TComponentName), nil, 'Name', TfrxNameProperty); + frxPropertyEditors.Register(TypeInfo(TColor), nil, '', TfrxColorProperty); + frxPropertyEditors.Register(TypeInfo(TFont), nil, '', TfrxFontProperty); + frxPropertyEditors.Register(TypeInfo(String), TFont, 'Name', TfrxFontNameProperty); + frxPropertyEditors.Register(TypeInfo(Integer), TFont, 'Charset', TfrxFontCharsetProperty); + frxPropertyEditors.Register(TypeInfo(TModalResult), nil, '', TfrxModalResultProperty); + frxPropertyEditors.Register(TypeInfo(TShortCut), nil, '', TfrxShortCutProperty); + frxPropertyEditors.Register(TypeInfo(TCursor), nil, '', TfrxCursorProperty); + frxPropertyEditors.Register(TypeInfo(TDateTime), nil, '', TfrxDateTimeProperty); + frxPropertyEditors.Register(TypeInfo(TDate), nil, '', TfrxDateProperty); + frxPropertyEditors.Register(TypeInfo(TTime), nil, '', TfrxTimeProperty); + + +finalization + if FObjects <> nil then + FObjects.Free; + FObjects := nil; + if FComponentEditors <> nil then + FComponentEditors.Free; + FComponentEditors := nil; + if FPropertyEditors <> nil then + FPropertyEditors.Free; + FPropertyEditors := nil; + if FExportFilters <> nil then + FExportFilters.Free; + FExportFilters := nil; + if FWizards <> nil then + FWizards.Free; + FWizards := nil; + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditAliases.dfm b/official/4.2/LibD11/frxEditAliases.dfm new file mode 100644 index 0000000..46fc1f2 Binary files /dev/null and b/official/4.2/LibD11/frxEditAliases.dfm differ diff --git a/official/4.2/LibD11/frxEditAliases.pas b/official/4.2/LibD11/frxEditAliases.pas new file mode 100644 index 0000000..1d8e075 --- /dev/null +++ b/official/4.2/LibD11/frxEditAliases.pas @@ -0,0 +1,206 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Aliases editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditAliases; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ComCtrls, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxAliasesEditorForm = class(TForm) + AliasesLV: TListView; + OkB: TButton; + CancelB: TButton; + ResetB: TButton; + HintL: TLabel; + DSAliasL: TLabel; + DSAliasE: TEdit; + FieldAliasesL: TLabel; + UpdateB: TButton; + procedure FormHide(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure ResetBClick(Sender: TObject); + procedure AliasesLVKeyPress(Sender: TObject; var Key: Char); + procedure FormCreate(Sender: TObject); + procedure UpdateBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure AliasesLVEdited(Sender: TObject; Item: TListItem; + var S: String); + private + FDataSet: TfrxCustomDBDataset; + procedure BuildAliasList(List: TStrings); + public + property DataSet: TfrxCustomDBDataset read FDataSet write FDataSet; + end; + + +implementation + +{$R *.DFM} + +uses frxRes; + + +procedure TfrxAliasesEditorForm.BuildAliasList(List: TStrings); +var + i: Integer; + Item: TListItem; + s: String; +begin + AliasesLV.Items.Clear; + for i := 0 to List.Count - 1 do + begin + s := List.Names[i]; + Item := AliasesLV.Items.Add; + Item.Caption := List.Values[s]; + if s[1] = '-' then { field is disabled } + s := Copy(s, 2, 255) else + Item.Checked := True; + Item.SubItems.Add(s); + end; + if AliasesLV.Items.Count <> 0 then + AliasesLV.Selected := AliasesLV.Items[0]; +end; + +procedure TfrxAliasesEditorForm.FormShow(Sender: TObject); +begin + DSAliasE.Text := FDataSet.UserName; + BuildAliasList(FDataSet.FieldAliases); + if FDataSet.FieldAliases.Count = 0 then + ResetBClick(nil); +end; + +procedure TfrxAliasesEditorForm.FormHide(Sender: TObject); +var + i: Integer; + s: String; +begin + if ModalResult = mrOk then + begin + FDataSet.UserName := DSAliasE.Text; + FDataSet.FieldAliases.Clear; + for i := 0 to AliasesLV.Items.Count - 1 do + begin + s := AliasesLV.Items[i].SubItems[0]; + if not AliasesLV.Items[i].Checked then { disable the field } + s := '-' + s; + FDataSet.FieldAliases.Add(s + '=' + AliasesLV.Items[i].Caption); + end; + end; +end; + +procedure TfrxAliasesEditorForm.ResetBClick(Sender: TObject); +var + i: Integer; + l1, l2: TStrings; +begin + l1 := TStringList.Create; + l2 := TStringList.Create; + l1.Assign(FDataSet.FieldAliases); + { clear aliases to get real field names } + FDataSet.FieldAliases.Clear; + FDataSet.GetFieldList(l2); + { set aliases back } + FDataSet.FieldAliases.Assign(l1); + l1.Free; + + for i := 0 to l2.Count - 1 do + l2[i] := l2[i] + '=' + l2[i]; + + BuildAliasList(l2); + l2.Free; +end; + +procedure TfrxAliasesEditorForm.UpdateBClick(Sender: TObject); +var + i: Integer; + l1, l2: TStrings; +begin + l1 := TStringList.Create; + l2 := TStringList.Create; + l1.Assign(FDataSet.FieldAliases); + try + { clear aliases to get real field names } + FDataSet.FieldAliases.Clear; + FDataSet.GetFieldList(l2); + finally + { set aliases back } + FDataSet.FieldAliases.Assign(l1); + end; + + for i := 0 to l2.Count - 1 do + if l1.IndexOfName(l2[i]) = -1 then + l2[i] := l2[i] + '=' + l2[i] + else + l2[i] := l2[i] + '=' + l1.Values[l2[i]]; + + BuildAliasList(l2); + l1.Free; + l2.Free; +end; + +procedure TfrxAliasesEditorForm.AliasesLVKeyPress(Sender: TObject; + var Key: Char); +begin + if (Key = #13) and (AliasesLV.Selected <> nil) then + AliasesLV.Selected.EditCaption; +end; + +procedure TfrxAliasesEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(3600); + HintL.Caption := frxGet(3601); + DSAliasL.Caption := frxGet(3602); + FieldAliasesL.Caption := frxGet(3603); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + ResetB.Caption := frxGet(3604); + UpdateB.Caption := frxGet(3605); + AliasesLV.Columns[0].Caption := frxResources.Get('alUserName'); + AliasesLV.Columns[1].Caption := frxResources.Get('alOriginal'); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxAliasesEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); + if Key = VK_F2 then + AliasesLV.Selected.EditCaption; + if Key = VK_F5 then + UpdateBClick(nil); +end; + +procedure TfrxAliasesEditorForm.AliasesLVEdited(Sender: TObject; + Item: TListItem; var S: String); +begin + if s = '' then + s := AliasesLV.Selected.SubItems[0]; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditDataBand.dfm b/official/4.2/LibD11/frxEditDataBand.dfm new file mode 100644 index 0000000..b3adb9e Binary files /dev/null and b/official/4.2/LibD11/frxEditDataBand.dfm differ diff --git a/official/4.2/LibD11/frxEditDataBand.pas b/official/4.2/LibD11/frxEditDataBand.pas new file mode 100644 index 0000000..be20ac0 --- /dev/null +++ b/official/4.2/LibD11/frxEditDataBand.pas @@ -0,0 +1,150 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Data Band editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditDataBand; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ExtCtrls, StdCtrls, frxClass, ComCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxDataBandEditorForm = class(TForm) + OkB: TButton; + CancelB: TButton; + GroupBox1: TGroupBox; + DatasetsLB: TListBox; + RecordsL: TLabel; + RecordsE: TEdit; + RecordsUD: TUpDown; + procedure DatasetsLBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure DatasetsLBDblClick(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure DatasetsLBClick(Sender: TObject); + private + { Private declarations } + FDataBand: TfrxDataBand; + FDesigner: TfrxCustomDesigner; + public + { Public declarations } + property DataBand: TfrxDataBand read FDataBand write FDataBand; + end; + + +implementation + +{$R *.DFM} + +uses frxUtils, frxRes; + + +procedure TfrxDataBandEditorForm.FormShow(Sender: TObject); +var + i: Integer; + dsList: TStringList; +begin + FDesigner := TfrxCustomDesigner(Owner); + + dsList := TStringList.Create; + FDesigner.Report.GetDatasetList(dsList); + dsList.Sort; + DatasetsLB.Items := dsList; + DatasetsLB.Items.InsertObject(0, frxResources.Get('dbNotAssigned'), nil); + dsList.Free; + + i := DatasetsLB.Items.IndexOfObject(FDataBand.DataSet); + if i = -1 then + i := 0; + DatasetsLB.ItemIndex := i; + + RecordsUD.Position := FDataBand.RowCount; +end; + +procedure TfrxDataBandEditorForm.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + if DatasetsLB.ItemIndex = 0 then + begin + FDataBand.DataSet := nil; + FDataBand.RowCount := RecordsUD.Position; + end + else + begin + FDataBand.DataSet := TfrxDataSet(DatasetsLB.Items.Objects[DatasetsLB.ItemIndex]); + FDataBand.RowCount := RecordsUD.Position; + end; +end; + +procedure TfrxDataBandEditorForm.DatasetsLBDrawItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +var + r: TRect; +begin + r := ARect; + r.Right := r.Left + 18; + r.Bottom := r.Top + 16; + OffsetRect(r, 2, 0); + with TListBox(Control) do + begin + Canvas.FillRect(ARect); + if Index > 0 then + frxResources.MainButtonImages.Draw(Canvas, ARect.Left + 2, ARect.Top + 1, 53); + Canvas.TextOut(ARect.Left + 22, ARect.Top + 2, Items[Index]); + end; +end; + +procedure TfrxDataBandEditorForm.DatasetsLBDblClick(Sender: TObject); +begin + ModalResult := mrOk; +end; + +procedure TfrxDataBandEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(3100); + RecordsL.Caption := frxGet(3101); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxDataBandEditorForm.FormKeyDown(Sender: TObject; + var Key: Word; Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxDataBandEditorForm.DatasetsLBClick(Sender: TObject); +begin + if DatasetsLB.ItemIndex <> 0 then + RecordsUD.Position := 0; +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditExpr.dfm b/official/4.2/LibD11/frxEditExpr.dfm new file mode 100644 index 0000000..19dd099 Binary files /dev/null and b/official/4.2/LibD11/frxEditExpr.dfm differ diff --git a/official/4.2/LibD11/frxEditExpr.pas b/official/4.2/LibD11/frxEditExpr.pas new file mode 100644 index 0000000..ab9a247 --- /dev/null +++ b/official/4.2/LibD11/frxEditExpr.pas @@ -0,0 +1,149 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Expression Editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditExpr; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ComCtrls, frxClass, ExtCtrls, ImgList, Buttons, frxDataTree +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxExprEditorForm = class(TForm) + ExprMemo: TMemo; + Panel1: TPanel; + OkB: TButton; + CancelB: TButton; + Splitter1: TSplitter; + Panel2: TPanel; + ExprL: TLabel; + Panel: TPanel; + procedure FormCreate(Sender: TObject); + procedure ExprMemoDragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ExprMemoDragDrop(Sender, Source: TObject; X, Y: Integer); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure FormResize(Sender: TObject); + private + FDataTree: TfrxDataTreeForm; + FReport: TfrxReport; + procedure OnDataTreeDblClick(Sender: TObject); + public + end; + + +implementation + +{$R *.DFM} + +uses frxDock, IniFiles, frxRes; + +var + lastPosition: TPoint; + +type + THackWinControl = class(TWinControl); + + +{ TfrxExprEditorForm } + +procedure TfrxExprEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(4400); + ExprL.Caption := frxGet(4401); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); +{$IFDEF UseTabset} + ExprMemo.BevelKind := bkFlat; +{$ELSE} + ExprMemo.BorderStyle := bsSingle; +{$ENDIF} + + FReport := TfrxCustomDesigner(Owner).Report; + FDataTree := TfrxDataTreeForm.Create(Self); + FDataTree.Report := FReport; + FDataTree.OnDblClick := OnDataTreeDblClick; + FDataTree.SetControlsParent(Panel); + FDataTree.HintPanel.Height := 60; + FDataTree.UpdateItems; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxExprEditorForm.FormShow(Sender: TObject); +var + Ini: TCustomIniFile; +begin + Ini := FReport.GetIniFile; + Ini.WriteBool('Form4.TfrxExprEditorForm', 'Visible', True); + frxRestoreFormPosition(Ini, Self); + Ini.Free; + FDataTree.SetLastPosition(lastPosition); +end; + +procedure TfrxExprEditorForm.FormHide(Sender: TObject); +var + Ini: TCustomIniFile; +begin + Ini := FReport.GetIniFile; + frxSaveFormPosition(Ini, Self); + Ini.Free; + lastPosition := FDataTree.GetLastPosition; +end; + +procedure TfrxExprEditorForm.OnDataTreeDblClick(Sender: TObject); +begin + ExprMemo.SelText := FDataTree.GetFieldName; + ExprMemo.SetFocus; +end; + +procedure TfrxExprEditorForm.ExprMemoDragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + Accept := (Source is TTreeView) and (TControl(Source).Owner = FDataTree) and + (FDataTree.GetFieldName <> ''); +end; + +procedure TfrxExprEditorForm.ExprMemoDragDrop(Sender, Source: TObject; X, + Y: Integer); +begin + ExprMemo.SelText := FDataTree.GetFieldName; + ExprMemo.SetFocus; +end; + +procedure TfrxExprEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxExprEditorForm.FormResize(Sender: TObject); +begin + FDataTree.UpdateSize; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditFormat.dfm b/official/4.2/LibD11/frxEditFormat.dfm new file mode 100644 index 0000000..88ee678 Binary files /dev/null and b/official/4.2/LibD11/frxEditFormat.dfm differ diff --git a/official/4.2/LibD11/frxEditFormat.pas b/official/4.2/LibD11/frxEditFormat.pas new file mode 100644 index 0000000..938ce11 --- /dev/null +++ b/official/4.2/LibD11/frxEditFormat.pas @@ -0,0 +1,213 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ DisplayFormat editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditFormat; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxFormatEditorForm = class(TForm) + OkB: TButton; + CancelB: TButton; + CategoryL: TGroupBox; + CategoryLB: TListBox; + FormatL: TGroupBox; + FormatLB: TListBox; + GroupBox1: TGroupBox; + FormatStrL: TLabel; + SeparatorL: TLabel; + FormatE: TEdit; + SeparatorE: TEdit; + procedure FormCreate(Sender: TObject); + procedure CategoryLBClick(Sender: TObject); + procedure FormatLBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure FormatLBClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + FFormat: TfrxFormat; + public + { Public declarations } + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure HostControls(Host: TWinControl); + procedure UnhostControls; + property Format: TfrxFormat read FFormat write FFormat; + end; + + +implementation + +{$R *.DFM} + +uses frxRes; + +const + CategoryNames: array[0..3] of String = + ('fkText', 'fkNumber', 'fkDateTime', 'fkBoolean'); + + +constructor TfrxFormatEditorForm.Create(AOwner: TComponent); +begin + inherited; + FFormat := TfrxFormat.Create; +end; + +destructor TfrxFormatEditorForm.Destroy; +begin + FFormat.Free; + inherited; +end; + +procedure TfrxFormatEditorForm.FormShow(Sender: TObject); + + procedure FillCategory; + var + i: Integer; + begin + for i := 0 to 3 do + CategoryLB.Items.Add(frxResources.Get(CategoryNames[i])); + end; + + procedure FindFormat; + var + i: Integer; + s: String; + begin + for i := 0 to FormatLB.Items.Count - 1 do + begin + s := FormatLB.Items[i]; + if Copy(s, Pos(';', s) + 1, 255) = FFormat.FormatStr then + FormatLB.ItemIndex := i; + end; + end; + +begin + FillCategory; + CategoryLB.ItemIndex := Integer(FFormat.Kind); + CategoryLBClick(Self); + FindFormat; + FormatE.Text := FFormat.FormatStr; + SeparatorE.Text := FFormat.DecimalSeparator; +end; + +procedure TfrxFormatEditorForm.FormHide(Sender: TObject); +var + s: String; +begin + FFormat.Kind := TfrxFormatKind(CategoryLB.ItemIndex); + FFormat.FormatStr := FormatE.Text; + s := SeparatorE.Text; + if s = '' then + s := DecimalSeparator; + FFormat.DecimalSeparator := s[1]; +end; + +procedure TfrxFormatEditorForm.CategoryLBClick(Sender: TObject); +var + i, n: Integer; + s: String; +begin + FormatLB.Items.Clear; + n := CategoryLB.ItemIndex; + SeparatorE.Enabled := n = 1; + SeparatorL.Enabled := n = 1; + + if (n = 0) or (n = 4) or (n = -1) then + Exit; + + for i := 1 to 10 do + begin + s := frxResources.Get(CategoryNames[n] + IntToStr(i)); + if Pos('fk', s) = 0 then + FormatLB.Items.Add(s); + end; +end; + +procedure TfrxFormatEditorForm.FormatLBClick(Sender: TObject); +var + s: String; +begin + s := FormatLB.Items[FormatLB.ItemIndex]; + FormatE.Text := Copy(s, Pos(';', s) + 1, 255); +end; + +procedure TfrxFormatEditorForm.FormatLBDrawItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +var + s: String; +begin + with FormatLB do + begin + Canvas.FillRect(ARect); + s := Items[Index]; + if Pos(';', s) <> 0 then + s := Copy(s, 1, Pos(';', s) - 1); + Canvas.TextOut(ARect.Left + 2, ARect.Top, s); + end; +end; + +procedure TfrxFormatEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(4500); + CategoryL.Caption := frxGet(4501); + FormatL.Caption := frxGet(4502); + FormatStrL.Caption := frxGet(4503); + SeparatorL.Caption := frxGet(4504); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + + if Screen.PixelsPerInch = 120 then + FormatLB.ItemHeight := 17; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxFormatEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxFormatEditorForm.HostControls(Host: TWinControl); +begin + CategoryL.Parent := Host; + FormatL.Parent := Host; + GroupBox1.Parent := Host; + FormShow(Self); +end; + +procedure TfrxFormatEditorForm.UnhostControls; +begin + FormHide(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditFrame.dfm b/official/4.2/LibD11/frxEditFrame.dfm new file mode 100644 index 0000000..a33ca52 Binary files /dev/null and b/official/4.2/LibD11/frxEditFrame.dfm differ diff --git a/official/4.2/LibD11/frxEditFrame.pas b/official/4.2/LibD11/frxEditFrame.pas new file mode 100644 index 0000000..d5d5bb4 --- /dev/null +++ b/official/4.2/LibD11/frxEditFrame.pas @@ -0,0 +1,180 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Frame editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditFrame; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ImgList, ExtCtrls, StdCtrls, frxCtrls, frxDock, ComCtrls, ToolWin, frxClass; + +type + TfrxFrameEditorForm = class(TForm) + FrameL: TLabel; + LineL: TLabel; + ShadowL: TLabel; + OkB: TButton; + CancelB: TButton; + ToolBar1: TToolBar; + FrameTopB: TToolButton; + FrameBottomB: TToolButton; + FrameLeftB: TToolButton; + FrameRightB: TToolButton; + Sep1: TToolButton; + FrameAllB: TToolButton; + FrameNoB: TToolButton; + ToolBar2: TToolBar; + FrameColorB: TToolButton; + FrameStyleB: TToolButton; + Sep2: TfrxTBPanel; + FrameWidthCB: TfrxComboBox; + ToolBar3: TToolBar; + ShadowB: TToolButton; + ShadowColorB: TToolButton; + Sep3: TfrxTBPanel; + ShadowWidthCB: TfrxComboBox; + Bevel1: TBevel; + procedure FormCreate(Sender: TObject); + procedure BClick(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FFrame: TfrxFrame; + FImageList: TImageList; + procedure UpdateControls; + public + property Frame: TfrxFrame read FFrame; + end; + + +implementation + +{$R *.DFM} + +uses frxDesgnCtrls, frxUtils, frxRes; + + +procedure TfrxFrameEditorForm.FormCreate(Sender: TObject); +begin + FFrame := TfrxFrame.Create; + Caption := frxGet(5200); + FrameL.Caption := frxGet(5201); + LineL.Caption := frxGet(5202); + ShadowL.Caption := frxGet(5203); + FrameTopB.Hint := frxGet(5204); + FrameBottomB.Hint := frxGet(5205); + FrameLeftB.Hint := frxGet(5206); + FrameRightB.Hint := frxGet(5207); + FrameAllB.Hint := frxGet(5208); + FrameNoB.Hint := frxGet(5209); + FrameColorB.Hint := frxGet(5210); + FrameStyleB.Hint := frxGet(5211); + FrameWidthCB.Hint := frxGet(5212); + ShadowB.Hint := frxGet(5213); + ShadowColorB.Hint := frxGet(5214); + ShadowWidthCB.Hint := frxGet(5215); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + + FImageList := frxResources.MainButtonImages; + ToolBar1.Images := FImageList; + ToolBar2.Images := FImageList; + ToolBar3.Images := FImageList; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxFrameEditorForm.FormDestroy(Sender: TObject); +begin + FFrame.Free; +end; + +procedure TfrxFrameEditorForm.FormShow(Sender: TObject); +begin + UpdateControls; +end; + +procedure TfrxFrameEditorForm.UpdateControls; +begin + FrameTopB.Down := ftTop in FFrame.Typ; + FrameBottomB.Down := ftBottom in FFrame.Typ; + FrameLeftB.Down := ftLeft in FFrame.Typ; + FrameRightB.Down := ftRight in FFrame.Typ; + ShadowB.Down := FFrame.DropShadow; + FrameWidthCB.Text := FloatToStr(FFrame.Width); + ShadowWidthCB.Text := FloatToStr(FFrame.ShadowWidth); +end; + +procedure TfrxFrameEditorForm.BClick(Sender: TObject); + + procedure SetFrameType(fType: TfrxFrameType; Include: Boolean); + begin + with FFrame do + if Include then + Typ := Typ + [fType] else + Typ := Typ - [fType]; + end; + +begin + case TControl(Sender).Tag of + 1: SetFrameType(ftTop, FrameTopB.Down); + 2: SetFrameType(ftBottom, FrameBottomB.Down); + 3: SetFrameType(ftLeft, FrameLeftB.Down); + 4: SetFrameType(ftRight, FrameRightB.Down); + 5: FFrame.Typ := [ftLeft, ftRight, ftTop, ftBottom]; + 6: FFrame.Typ := []; + 7: + with TfrxColorSelector.Create(TComponent(Sender)) do + begin + OnColorChanged := BClick; + Tag := 70; + end; + 70: FFrame.Color := TfrxColorSelector(Sender).Color; + 8: + with TfrxLineSelector.Create(TComponent(Sender)) do + begin + OnStyleChanged := BClick; + Tag := 80; + end; + 80: FFrame.Style := TfrxFrameStyle(TfrxLineSelector(Sender).Style); + 9: FFrame.Width := frxStrToFloat(FrameWidthCB.Text); + 10: FFrame.DropShadow := ShadowB.Down; + 11: + with TfrxColorSelector.Create(TComponent(Sender)) do + begin + OnColorChanged := BClick; + Tag := 110; + end; + 110: FFrame.ShadowColor := TfrxColorSelector(Sender).Color; + 12: FFrame.ShadowWidth := frxStrToFloat(ShadowWidthCB.Text); + end; + + UpdateControls; +end; + +procedure TfrxFrameEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditGroup.dfm b/official/4.2/LibD11/frxEditGroup.dfm new file mode 100644 index 0000000..f62821d Binary files /dev/null and b/official/4.2/LibD11/frxEditGroup.dfm differ diff --git a/official/4.2/LibD11/frxEditGroup.pas b/official/4.2/LibD11/frxEditGroup.pas new file mode 100644 index 0000000..31bb439 --- /dev/null +++ b/official/4.2/LibD11/frxEditGroup.pas @@ -0,0 +1,188 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Group editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditGroup; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxClass, frxCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxGroupEditorForm = class(TForm) + OKB: TButton; + CancelB: TButton; + BreakOnL: TGroupBox; + DataFieldCB: TComboBox; + DataSetCB: TComboBox; + ExpressionE: TfrxComboEdit; + DataFieldRB: TRadioButton; + ExpressionRB: TRadioButton; + OptionsL: TGroupBox; + KeepGroupTogetherCB: TCheckBox; + StartNewPageCB: TCheckBox; + OutlineCB: TCheckBox; + DrillCB: TCheckBox; + ResetCB: TCheckBox; + procedure ExpressionEButtonClick(Sender: TObject); + procedure DataFieldRBClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure DataSetCBChange(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FGroupHeader: TfrxGroupHeader; + FReport: TfrxReport; + procedure FillDataFieldCB; + procedure FillDataSetCB; + public + property GroupHeader: TfrxGroupHeader read FGroupHeader write FGroupHeader; + end; + + +implementation + +{$R *.DFM} + +uses frxUtils, frxRes; + + +procedure TfrxGroupEditorForm.FormShow(Sender: TObject); +var + ds: TfrxDataSet; + fld: String; +begin + FReport := FGroupHeader.Report; + FillDataSetCB; + + FReport.GetDataSetAndField(FGroupHeader.Condition, ds, fld); + if FGroupHeader.Condition = '' then + begin + DataSetCB.ItemIndex := 0; + FillDataFieldCB; + DataFieldCB.SetFocus; + end + else if (ds <> nil) and (fld <> '') then + begin + DataSetCB.Text := FReport.GetAlias(ds); + FillDataFieldCB; + DataFieldCB.Text := fld; + DataFieldCB.SetFocus; + end + else + begin + ExpressionE.Text := FGroupHeader.Condition; + ExpressionRB.Checked := True; + ExpressionE.SetFocus; + end; + + KeepGroupTogetherCB.Checked := FGroupHeader.KeepTogether; + StartNewPageCB.Checked := FGroupHeader.StartNewPage; + OutlineCB.Checked := Trim(FGroupHeader.OutlineText) <> ''; + DrillCB.Checked := FGroupHeader.DrillDown; + ResetCB.Checked := FGroupHeader.ResetPageNumbers; +end; + +procedure TfrxGroupEditorForm.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + begin + if DataFieldRB.Checked then + FGroupHeader.Condition := DataSetCB.Text + '."' + DataFieldCB.Text + '"' else + FGroupHeader.Condition := ExpressionE.Text; + + FGroupHeader.KeepTogether := KeepGroupTogetherCB.Checked; + FGroupHeader.StartNewPage := StartNewPageCB.Checked; + if OutlineCB.Checked then + FGroupHeader.OutlineText := FGroupHeader.Condition else + FGroupHeader.OutlineText := ''; + FGroupHeader.DrillDown := DrillCB.Checked; + FGroupHeader.ResetPageNumbers := ResetCB.Checked; + end; +end; + +procedure TfrxGroupEditorForm.FillDataSetCB; +begin + FReport.GetDataSetList(DataSetCB.Items); +end; + +procedure TfrxGroupEditorForm.FillDataFieldCB; +var + ds: TfrxDataSet; +begin + ds := FReport.GetDataSet(DataSetCB.Text); + if ds <> nil then + ds.GetFieldList(DataFieldCB.Items) else + DataFieldCB.Items.Clear; +end; + +procedure TfrxGroupEditorForm.ExpressionEButtonClick(Sender: TObject); +var + s: String; +begin + s := TfrxCustomDesigner(Owner).InsertExpression(ExpressionE.Text); + if s <> '' then + ExpressionE.Text := s; +end; + +procedure TfrxGroupEditorForm.DataFieldRBClick(Sender: TObject); +begin + DataSetCB.Enabled := DataFieldRB.Checked; + DataFieldCB.Enabled := DataFieldRB.Checked; + ExpressionE.Enabled := ExpressionRB.Checked; +end; + +procedure TfrxGroupEditorForm.DataSetCBChange(Sender: TObject); +begin + FillDataFieldCB; +end; + +procedure TfrxGroupEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(3200); + BreakOnL.Caption := frxGet(3201); + OptionsL.Caption := frxGet(3202); + OKB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + DataFieldRB.Caption := frxGet(3203); + ExpressionRB.Caption := frxGet(3204); + KeepGroupTogetherCB.Caption := frxGet(3205); + StartNewPageCB.Caption := frxGet(3206); + OutlineCB.Caption := frxGet(3207); + DrillCB.Caption := frxResources.Get('bvDrillDown'); + ResetCB.Caption := frxResources.Get('bvResetPageNo'); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxGroupEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditHighlight.dfm b/official/4.2/LibD11/frxEditHighlight.dfm new file mode 100644 index 0000000..8cf23c0 Binary files /dev/null and b/official/4.2/LibD11/frxEditHighlight.dfm differ diff --git a/official/4.2/LibD11/frxEditHighlight.pas b/official/4.2/LibD11/frxEditHighlight.pas new file mode 100644 index 0000000..0888488 --- /dev/null +++ b/official/4.2/LibD11/frxEditHighlight.pas @@ -0,0 +1,216 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Highlight editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditHighlight; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, frxClass, ExtCtrls, Buttons, frxCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxHighlightEditorForm = class(TForm) + OKB: TButton; + CancelB: TButton; + ConditionL: TGroupBox; + ConditionE: TfrxComboEdit; + FontL: TGroupBox; + FontColorB: TSpeedButton; + BoldCB: TCheckBox; + ItalicCB: TCheckBox; + UnderlineCB: TCheckBox; + ColorDialog1: TColorDialog; + BackgroundL: TGroupBox; + BackColorB: TSpeedButton; + TransparentRB: TRadioButton; + OtherRB: TRadioButton; + procedure FontColorBClick(Sender: TObject); + procedure BackColorBClick(Sender: TObject); + procedure TransparentRBClick(Sender: TObject); + procedure ConditionEButtonClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FBackColor: TColor; + FFontColor: TColor; + FHighlight: TfrxHighlight; + FMemoView: TfrxCustomMemoView; + procedure SetGlyph(Button: TSpeedButton; Color: TColor); + public + property MemoView: TfrxCustomMemoView read FMemoView write FMemoView; + procedure HostControls(Host: TWinControl); + procedure UnhostControls(AModalResult: TModalResult); + end; + + +implementation + +{$R *.DFM} + +uses frxRes; + + +procedure TfrxHighlightEditorForm.FormShow(Sender: TObject); +begin + FHighlight := FMemoView.Highlight; + FBackColor := FHighlight.Color; + FFontColor := FHighlight.Font.Color; + + ConditionE.Text := FHighlight.Condition; + BoldCB.Checked := fsBold in FHighlight.Font.Style; + ItalicCB.Checked := fsItalic in FHighlight.Font.Style; + UnderlineCB.Checked := fsUnderline in FHighlight.Font.Style; + SetGlyph(FontColorB, FFontColor); + + if FBackColor = clTransparent then + TransparentRB.Checked := True else + OtherRB.Checked := True; + SetGlyph(BackColorB, FBackColor); + + TransparentRBClick(nil); +end; + +procedure TfrxHighlightEditorForm.FormHide(Sender: TObject); +var + fs: TFontStyles; +begin + if ModalResult = mrOk then + begin + FHighlight.Condition := ConditionE.Text; + + fs := []; + if BoldCB.Checked then + fs := fs + [fsBold]; + if ItalicCB.Checked then + fs := fs + [fsItalic]; + if UnderlineCB.Checked then + fs := fs + [fsUnderline]; + + FHighlight.Font := MemoView.Font; + FHighlight.Font.Style := fs; + FHighlight.Font.Color := FFontColor; + FHighlight.Color := FBackColor; + end; +end; + +procedure TfrxHighlightEditorForm.SetGlyph(Button: TSpeedButton; Color: TColor); +var + bmp: TBitmap; +begin + bmp := TBitmap.Create; + bmp.Width := 14; + bmp.Height := 15; + with bmp.Canvas do + begin + Brush.Color := clBtnFace; + FillRect(Rect(0, 0, 14, 15)); + Pen.Color := clGray; + Brush.Color := Color; + Rectangle(0, 0, 14, 14); + end; + + Button.Glyph := bmp; + bmp.Free; +end; + +procedure TfrxHighlightEditorForm.FontColorBClick(Sender: TObject); +begin + ColorDialog1.Color := FFontColor; + if ColorDialog1.Execute then + begin + FFontColor := ColorDialog1.Color; + SetGlyph(FontColorB, FFontColor); + end; +end; + +procedure TfrxHighlightEditorForm.BackColorBClick(Sender: TObject); +begin + ColorDialog1.Color := FBackColor; + if ColorDialog1.Execute then + begin + FBackColor := ColorDialog1.Color; + SetGlyph(BackColorB, FBackColor); + end; +end; + +procedure TfrxHighlightEditorForm.TransparentRBClick(Sender: TObject); +begin + BackColorB.Enabled := OtherRB.Checked; + if TransparentRB.Checked then + FBackColor := clTransparent; +end; + +procedure TfrxHighlightEditorForm.ConditionEButtonClick(Sender: TObject); +var + s: String; +begin + s := TfrxCustomDesigner(Owner).InsertExpression(ConditionE.Text); + if s <> '' then + ConditionE.Text := s; +end; + +procedure TfrxHighlightEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(4600); + FontColorB.Caption := frxGet(4601); + BackColorB.Caption := frxGet(4602); + ConditionL.Caption := frxGet(4603); + FontL.Caption := frxGet(4604); + BackgroundL.Caption := frxGet(4605); + OKB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + BoldCB.Caption := frxGet(4606); + ItalicCB.Caption := frxGet(4607); + UnderlineCB.Caption := frxGet(4608); + TransparentRB.Caption := frxGet(4609); + OtherRB.Caption := frxGet(4610); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxHighlightEditorForm.FormKeyDown(Sender: TObject; + var Key: Word; Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxHighlightEditorForm.HostControls(Host: TWinControl); +begin + ConditionL.Parent := Host; + FontL.Parent := Host; + BackgroundL.Parent := Host; + FormShow(Self); +end; + +procedure TfrxHighlightEditorForm.UnhostControls(AModalResult: TModalResult); +begin + ModalResult := AModalResult; + FormHide(Self); +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditMD.dfm b/official/4.2/LibD11/frxEditMD.dfm new file mode 100644 index 0000000..ca47720 Binary files /dev/null and b/official/4.2/LibD11/frxEditMD.dfm differ diff --git a/official/4.2/LibD11/frxEditMD.pas b/official/4.2/LibD11/frxEditMD.pas new file mode 100644 index 0000000..e7613f0 --- /dev/null +++ b/official/4.2/LibD11/frxEditMD.pas @@ -0,0 +1,162 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Master-Detail editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditMD; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + frxClass, StdCtrls, ExtCtrls, frxCustomDB +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxMDEditorForm = class(TForm) + DetailLB: TListBox; + MasterLB: TListBox; + Label1: TLabel; + Label2: TLabel; + AddB: TButton; + LinksLB: TListBox; + Label3: TLabel; + ClearB: TButton; + OkB: TButton; + CancelB: TButton; + Bevel1: TBevel; + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure ClearBClick(Sender: TObject); + procedure DetailLBClick(Sender: TObject); + procedure MasterLBClick(Sender: TObject); + procedure AddBClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FDetailDS: TfrxCustomDataset; + FMasterDS: TfrxCustomDBDataset; + FMasterFields: String; + procedure FillLists; + public + property DataSet: TfrxCustomDataset read FDetailDS write FDetailDS; + end; + + +implementation + +{$R *.DFM} + +uses frxUtils, frxRes; + + +procedure TfrxMDEditorForm.FillLists; +var + i: Integer; + s: String; + sl: TStrings; +begin + FDetailDS.GetFieldList(DetailLB.Items); + FMasterDS.GetFieldList(MasterLB.Items); + LinksLB.Items.Clear; + + sl := TStringList.Create; + frxSetCommaText(FMasterFields, sl); + + for i := 0 to sl.Count - 1 do + begin + s := sl.Names[i]; + if DetailLB.Items.IndexOf(s) <> -1 then + DetailLB.Items.Delete(DetailLB.Items.IndexOf(s)); + s := sl.Values[sl.Names[i]]; + if MasterLB.Items.IndexOf(s) <> -1 then + MasterLB.Items.Delete(MasterLB.Items.IndexOf(s)); + LinksLB.Items.Add(sl[i]); + end; + + AddB.Enabled := False; + sl.Free; +end; + +procedure TfrxMDEditorForm.FormShow(Sender: TObject); +begin + FMasterDS := FDetailDS.Master; + FMasterFields := FDetailDS.MasterFields; + FillLists; +end; + +procedure TfrxMDEditorForm.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + FDetailDS.MasterFields := FMasterFields; +end; + +procedure TfrxMDEditorForm.ClearBClick(Sender: TObject); +begin + FMasterFields := ''; + FillLists; +end; + +procedure TfrxMDEditorForm.DetailLBClick(Sender: TObject); +begin + if MasterLB.ItemIndex <> -1 then + AddB.Enabled := True; +end; + +procedure TfrxMDEditorForm.MasterLBClick(Sender: TObject); +begin + if DetailLB.ItemIndex <> -1 then + AddB.Enabled := True; +end; + +procedure TfrxMDEditorForm.AddBClick(Sender: TObject); +var + s: String; +begin + s := DetailLB.Items[DetailLB.ItemIndex] + '=' + MasterLB.Items[MasterLB.ItemIndex]; + if FMasterFields = '' then + FMasterFields := s else + FMasterFields := FMasterFields + ';' + s; + FillLists; +end; + +procedure TfrxMDEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(3800); + Label1.Caption := frxGet(3801); + Label2.Caption := frxGet(3802); + Label3.Caption := frxGet(3803); + AddB.Caption := frxGet(3804); + ClearB.Caption := frxGet(3805); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxMDEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditMemo.dfm b/official/4.2/LibD11/frxEditMemo.dfm new file mode 100644 index 0000000..67d3340 Binary files /dev/null and b/official/4.2/LibD11/frxEditMemo.dfm differ diff --git a/official/4.2/LibD11/frxEditMemo.pas b/official/4.2/LibD11/frxEditMemo.pas new file mode 100644 index 0000000..368fdf7 --- /dev/null +++ b/official/4.2/LibD11/frxEditMemo.pas @@ -0,0 +1,303 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Memo editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditMemo; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, + Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, ToolWin, frxClass, + frxEditFormat, frxEditHighlight +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxMemoEditorForm = class(TForm) + PageControl1: TPageControl; + TextTS: TTabSheet; + FormatTS: TTabSheet; + HighlightTS: TTabSheet; + ToolBar: TToolBar; + ExprB: TToolButton; + AggregateB: TToolButton; + LocalFormatB: TToolButton; + WordWrapB: TToolButton; + OkB: TButton; + CancelB: TButton; + procedure FormShow(Sender: TObject); + procedure WordWrapBClick(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure MemoKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure ExprBClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure AggregateBClick(Sender: TObject); + procedure LocalFormatBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FFormat: TfrxFormatEditorForm; + FHighlight: TfrxHighlightEditorForm; + FMemoView: TfrxCustomMemoView; + FIsUnicode: Boolean; + FText: WideString; + public + Memo: TMemo; + property MemoView: TfrxCustomMemoView read FMemoView write FMemoView; + property Text: WideString read FText write FText; + end; + + +implementation + +{$R *.DFM} + +uses frxEditSysMemo, IniFiles, frxDock, frxRes, frxUnicodeCtrls; + + +{ TfrxMemoEditorForm } + +procedure TfrxMemoEditorForm.FormShow(Sender: TObject); +var + Ini: TCustomIniFile; +begin + FIsUnicode := FMemoView.Font.Charset = DEFAULT_CHARSET; + + if FIsUnicode then + Memo := TUnicodeMemo.Create(Self) + else + Memo := TMemo.Create(Self); + + with Memo do + begin + Parent := TextTS; + Align := alClient; + ScrollBars := ssBoth; + TabOrder := 1; + OnKeyDown := MemoKeyDown; + end; + + FFormat := TfrxFormatEditorForm.Create(Owner); + FFormat.Format.Assign(MemoView.DisplayFormat); + FFormat.HostControls(FormatTS); + + FHighlight := TfrxHighlightEditorForm.Create(Owner); + FHighlight.MemoView := MemoView; + FHighlight.HostControls(HighlightTS); + + Icon := TForm(Owner).Icon; + Toolbar.Images := frxResources.MainButtonImages; + Ini := TfrxCustomDesigner(Owner).Report.GetIniFile; + Ini.WriteBool('Form4.TfrxMemoEditorForm', 'Visible', True); + WordWrapB.Down := Ini.ReadBool('Form4.TfrxMemoEditorForm', 'WordWrap', False); + WordWrapBClick(nil); + frxRestoreFormPosition(Ini, Self); + Ini.Free; + + with TfrxCustomDesigner(Owner) do + begin + if UseObjectFont then + begin + Memo.Font := FMemoView.Font; + Memo.Font.Color := clBlack; + Memo.Font.Height := FMemoView.Font.Height; + end + else + begin + Memo.Font.Name := MemoFontName; + Memo.Font.Size := MemoFontSize; + end; + end; + + if FIsUnicode then + TUnicodeMemo(Memo).Text := FMemoView.Text + else + Memo.Text := FMemoView.Text; + + Memo.SetFocus; + Memo.Perform(EM_SETSEL, 0, 0); + Memo.Perform(EM_SCROLLCARET, 0, 0); + + PageControl1.SetBounds(0, 0, ClientWidth, ClientHeight - OkB.Height - 8); + OkB.Left := ClientWidth - OkB.Width - CancelB.Width - 8; + CancelB.Left := ClientWidth - CancelB.Width - 4; + OkB.Top := ClientHeight - OkB.Height - 4; + CancelB.Top := OkB.Top; +end; + +procedure TfrxMemoEditorForm.FormHide(Sender: TObject); +var + Ini: TCustomIniFile; +begin + Ini := TfrxCustomDesigner(Owner).Report.GetIniFile; + frxSaveFormPosition(Ini, Self); + Ini.WriteBool('Form4.TfrxMemoEditorForm', 'WordWrap', Memo.WordWrap); + Ini.Free; + + if FIsUnicode then + FText := TUnicodeMemo(Memo).Text + else + FText := Memo.Text; + + FFormat.UnhostControls; + if ModalResult = mrOk then + FMemoView.DisplayFormat.Assign(FFormat.Format); + FFormat.Free; + FHighlight.UnhostControls(ModalResult); + FHighlight.Free; +end; + +procedure TfrxMemoEditorForm.ExprBClick(Sender: TObject); +var + s, s1, s2: String; + + function BracketCount: Integer; + var + i: Integer; + begin + Result := 0; + for i := 1 to Length(s) do + if s[i] = '<' then + Inc(Result); + end; + +begin + s := TfrxCustomDesigner(Owner).InsertExpression(''); + if s <> '' then + begin + s1 := MemoView.ExpressionDelimiters; + s2 := Copy(s1, Pos(',', s1) + 1, 255); + s1 := Copy(s1, 1, Pos(',', s1) - 1); + if (s[1] = '<') and (s[Length(s)] = '>') and (BracketCount = 1) then + s := Copy(s, 2, Length(s) - 2); + Memo.SelText := s1 + s + s2; + end; +end; + +procedure TfrxMemoEditorForm.WordWrapBClick(Sender: TObject); +var + s: WideString; +begin + s := ''; + if FIsUnicode then + s := TUnicodeMemo(Memo).Text; + + Memo.WordWrap := WordWrapB.Down; + if Memo.WordWrap then + Memo.ScrollBars := ssVertical + else + Memo.ScrollBars := ssBoth; + + if FIsUnicode then + TUnicodeMemo(Memo).Text := s; +end; + +procedure TfrxMemoEditorForm.MemoKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if (Key = vk_Return) and (ssCtrl in Shift) then + ModalResult := mrOk + else if Key = vk_Escape then + ModalResult := mrCancel + else if (Key = Ord('A')) and (Shift = [ssCtrl]) then + Memo.SelectAll; +end; + +procedure TfrxMemoEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(3900); + ExprB.Hint := frxGet(3901); + AggregateB.Hint := frxGet(3902); + LocalFormatB.Hint := frxGet(3903); + WordWrapB.Hint := frxGet(3904); + TextTS.Caption := frxGet(3905); + FormatTS.Caption := frxGet(3906); + HighlightTS.Caption := frxGet(3907); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxMemoEditorForm.AggregateBClick(Sender: TObject); +begin + with TfrxSysMemoEditorForm.Create(Owner) do + begin + AggregateOnly := True; + if ShowModal = mrOk then + Memo.SelText := Text; + Free; + end; +end; + +procedure TfrxMemoEditorForm.LocalFormatBClick(Sender: TObject); +var + s: String; + i: Integer; +begin + with TfrxFormatEditorForm.Create(Owner) do + begin + if ShowModal = mrOk then + begin + case Format.Kind of + fkText: + s := ''; + + fkNumeric: + begin + s := Format.FormatStr; + for i := 1 to Length(s) do + if s[i] in ['.', ',', '-'] then + if Format.DecimalSeparator <> '' then + s[i] := Format.DecimalSeparator[1] else + s[i] := DecimalSeparator; + s := ' #n' + s; + end; + + fkDateTime: + s := ' #d' + Format.FormatStr; + + fkBoolean: + s := ' #b' + Format.FormatStr; + end; + + if s <> '' then + begin + i := Memo.SelStart; + if (i > 0) and (Memo.Text[i] = ']') then + Memo.SelStart := Memo.SelStart - 1; + Memo.SelText := s; + + end; + end; + Free; + end; +end; + +procedure TfrxMemoEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditOptions.dfm b/official/4.2/LibD11/frxEditOptions.dfm new file mode 100644 index 0000000..ac3a6e9 Binary files /dev/null and b/official/4.2/LibD11/frxEditOptions.dfm differ diff --git a/official/4.2/LibD11/frxEditOptions.pas b/official/4.2/LibD11/frxEditOptions.pas new file mode 100644 index 0000000..4626a59 --- /dev/null +++ b/official/4.2/LibD11/frxEditOptions.pas @@ -0,0 +1,290 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Designer options } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditOptions; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxOptionsEditor = class(TForm) + OkB: TButton; + CancelB: TButton; + ColorDialog: TColorDialog; + RestoreDefaultsB: TButton; + Label1: TGroupBox; + Label2: TLabel; + Label3: TLabel; + Label4: TLabel; + Label13: TLabel; + Label14: TLabel; + Label15: TLabel; + Label16: TLabel; + CMRB: TRadioButton; + InchesRB: TRadioButton; + PixelsRB: TRadioButton; + CME: TEdit; + InchesE: TEdit; + PixelsE: TEdit; + DialogFormE: TEdit; + ShowGridCB: TCheckBox; + AlignGridCB: TCheckBox; + Label6: TGroupBox; + Label7: TLabel; + Label8: TLabel; + Label9: TLabel; + Label10: TLabel; + CodeWindowFontCB: TComboBox; + CodeWindowSizeCB: TComboBox; + MemoEditorFontCB: TComboBox; + MemoEditorSizeCB: TComboBox; + ObjectFontCB: TCheckBox; + Label11: TGroupBox; + WorkspacePB: TPaintBox; + ToolPB: TPaintBox; + WorkspaceB: TButton; + ToolB: TButton; + LCDCB: TCheckBox; + Label5: TGroupBox; + Label12: TLabel; + Label17: TLabel; + EditAfterInsCB: TCheckBox; + FreeBandsCB: TCheckBox; + GapE: TEdit; + BandsCaptionsCB: TCheckBox; + DropFieldsCB: TCheckBox; + StartupCB: TCheckBox; + procedure FormCreate(Sender: TObject); + procedure WorkspacePBPaint(Sender: TObject); + procedure ToolPBPaint(Sender: TObject); + procedure WorkspaceBClick(Sender: TObject); + procedure ToolBClick(Sender: TObject); + procedure RestoreDefaultsBClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + FWColor: TColor; + FTColor: TColor; + public + { Public declarations } + end; + + +implementation + +{$R *.DFM} + +uses frxDesgn, frxDesgnWorkspace, frxUtils, frxRes; + + +{ TfrxPreferencesEditor } + +procedure TfrxOptionsEditor.FormShow(Sender: TObject); + + procedure SetEnabled(cAr: Array of TControl; Enabled: Boolean); + var + i: Integer; + begin + for i := 0 to High(cAr) do + cAr[i].Enabled := Enabled; + end; + +begin + ColorDialog.CustomColors.Add('ColorA=' + IntToHex(ColorToRGB(clBtnFace), 6)); + + with TfrxDesignerForm(Owner) do + begin + CodeWindowFontCB.Items.Assign(Screen.Fonts); + MemoEditorFontCB.Items.Assign(Screen.Fonts); + + SetEnabled([CMRB, InchesRB, PixelsRB, CME, InchesE, PixelsE], + (Workspace.GridType <> gtDialog) and (Workspace.GridType <> gtChar)); + + CMRB.Checked := Units = duCM; + InchesRB.Checked := Units = duInches; + PixelsRB.Checked := Units = duPixels; + + CME.Text := FloatToStr(GridSize1); + InchesE.Text := FloatToStr(GridSize2); + PixelsE.Text := FloatToStr(GridSize3); + DialogFormE.Text := FloatToStr(GridSize4); + + ShowGridCB.Checked := ShowGrid; + AlignGridCB.Checked := GridAlign; + EditAfterInsCB.Checked := EditAfterInsert; + BandsCaptionsCB.Checked := Workspace.ShowBandCaptions; + DropFieldsCB.Checked := DropFields; + StartupCB.Checked := ShowStartup; + StartupCB.Visible := ConnectionsMI.Visible; + FreeBandsCB.Checked := Workspace.FreeBandsPlacement; + GapE.Text := IntToStr(Workspace.GapBetweenBands); + + CodeWindowFontCB.Text := CodeWindow.Font.Name; + CodeWindowSizeCB.Text := IntToStr(CodeWindow.Font.Size); + MemoEditorFontCB.Text := MemoFontName; + MemoEditorSizeCB.Text := IntToStr(MemoFontSize); + ObjectFontCB.Checked := UseObjectFont; + + FWColor := WorkspaceColor; + FTColor := ToolsColor; + LCDCB.Checked := Workspace.GridLCD; + end; +end; + +procedure TfrxOptionsEditor.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + with TfrxDesignerForm(Owner) do + begin + GridSize4 := frxStrToFloat(DialogFormE.Text); + + if CMRB.Enabled then + begin + GridSize1 := frxStrToFloat(CME.Text); + GridSize2 := frxStrToFloat(InchesE.Text); + GridSize3 := frxStrToFloat(PixelsE.Text); + + if CMRB.Checked then + Units := duCM + else if InchesRB.Checked then + Units := duInches else + Units := duPixels; + end; + + ShowGrid := ShowGridCB.Checked; + GridAlign := AlignGridCB.Checked; + EditAfterInsert := EditAfterInsCB.Checked; + Workspace.ShowBandCaptions := BandsCaptionsCB.Checked; + DropFields := DropFieldsCB.Checked; + ShowStartup := StartupCB.Checked; + Workspace.FreeBandsPlacement := FreeBandsCB.Checked; + Workspace.GapBetweenBands := StrToInt(GapE.Text); + + CodeWindow.Font.Name := CodeWindowFontCB.Text; + CodeWindow.Font.Size := StrToInt(CodeWindowSizeCB.Text); + MemoFontName := MemoEditorFontCB.Text; + MemoFontSize := StrToInt(MemoEditorSizeCB.Text); + UseObjectFont := ObjectFontCB.Checked; + + WorkspaceColor := FWColor; + ToolsColor := FTColor; + Workspace.GridLCD := LCDCB.Checked; + end; +end; + +procedure TfrxOptionsEditor.WorkspacePBPaint(Sender: TObject); +begin + with WorkspacePB.Canvas do + begin + Pen.Color := clGray; + Brush.Color := FWColor; + Rectangle(0, 0, 161, 21); + end; +end; + +procedure TfrxOptionsEditor.ToolPBPaint(Sender: TObject); +begin + with ToolPB.Canvas do + begin + Pen.Color := clGray; + Brush.Color := FTColor; + Rectangle(0, 0, 161, 21); + end; +end; + +procedure TfrxOptionsEditor.WorkspaceBClick(Sender: TObject); +begin + ColorDialog.Color := FWColor; + if ColorDialog.Execute then + FWColor := ColorDialog.Color; + WorkspacePB.Repaint; +end; + +procedure TfrxOptionsEditor.ToolBClick(Sender: TObject); +begin + ColorDialog.Color := FTColor; + if ColorDialog.Execute then + FTColor := ColorDialog.Color; + ToolPB.Repaint; +end; + +procedure TfrxOptionsEditor.RestoreDefaultsBClick(Sender: TObject); +begin + TfrxDesignerForm(Owner).RestoreState(True); + ModalResult := mrOk; +end; + +procedure TfrxOptionsEditor.FormCreate(Sender: TObject); +begin + Caption := frxGet(3000); + Label1.Caption := frxGet(3001); + Label2.Caption := frxGet(3002); + Label3.Caption := frxGet(3003); + Label4.Caption := frxGet(3004); + Label5.Caption := frxGet(3005); + Label6.Caption := frxGet(3006); + Label7.Caption := frxGet(3007); + Label8.Caption := frxGet(3008); + Label9.Caption := frxGet(3009); + Label10.Caption := frxGet(3010); + Label11.Caption := frxGet(3011); + Label12.Caption := frxGet(3012); + Label13.Caption := frxGet(3013); + Label14.Caption := frxGet(3014); + Label15.Caption := frxGet(3015); + Label16.Caption := frxGet(3016); + Label17.Caption := frxGet(3017); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + CMRB.Caption := frxGet(3018); + InchesRB.Caption := frxGet(3019); + PixelsRB.Caption := frxGet(3020); + ShowGridCB.Caption := frxGet(3021); + AlignGridCB.Caption := frxGet(3022); + EditAfterInsCB.Caption := frxGet(3023); + ObjectFontCB.Caption := frxGet(3024); + WorkspaceB.Caption := frxGet(3025); + ToolB.Caption := frxGet(3026); + LCDCB.Caption := frxGet(3027); + FreeBandsCB.Caption := frxGet(3028); + DropFieldsCB.Caption := frxGet(3029); + StartupCB.Caption := frxGet(3030); + RestoreDefaultsB.Caption := frxGet(3031); + BandsCaptionsCB.Caption := frxGet(3032); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxOptionsEditor.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditPage.dfm b/official/4.2/LibD11/frxEditPage.dfm new file mode 100644 index 0000000..8f638dd Binary files /dev/null and b/official/4.2/LibD11/frxEditPage.dfm differ diff --git a/official/4.2/LibD11/frxEditPage.pas b/official/4.2/LibD11/frxEditPage.pas new file mode 100644 index 0000000..8da99ed --- /dev/null +++ b/official/4.2/LibD11/frxEditPage.pas @@ -0,0 +1,358 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Page options } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditPage; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, ComCtrls, frxCtrls, Buttons +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxPageEditorForm = class(TForm) + OKB: TButton; + CancelB: TButton; + PageControl1: TPageControl; + TabSheet1: TTabSheet; + TabSheet3: TTabSheet; + Label11: TGroupBox; + Label1: TLabel; + Label2: TLabel; + UnitL1: TLabel; + UnitL2: TLabel; + WidthE: TEdit; + HeightE: TEdit; + SizeCB: TComboBox; + Label14: TGroupBox; + Label12: TGroupBox; + PortraitImg: TImage; + LandscapeImg: TImage; + PortraitRB: TRadioButton; + LandscapeRB: TRadioButton; + Label13: TGroupBox; + Label3: TLabel; + Label4: TLabel; + Label5: TLabel; + Label6: TLabel; + UnitL3: TLabel; + UnitL4: TLabel; + UnitL5: TLabel; + UnitL6: TLabel; + MarginLeftE: TEdit; + MarginTopE: TEdit; + MarginRightE: TEdit; + MarginBottomE: TEdit; + Label9: TLabel; + Label10: TLabel; + Tray1CB: TComboBox; + Tray2CB: TComboBox; + Label7: TGroupBox; + Label8: TLabel; + Label15: TLabel; + Label16: TLabel; + UnitL7: TLabel; + ColumnsNumberE: TEdit; + ColumnWidthE: TEdit; + ColumnPositionsM: TMemo; + UpDown1: TUpDown; + Label17: TGroupBox; + Label18: TLabel; + PrintOnPrevCB: TCheckBox; + MirrorMarginsCB: TCheckBox; + LargeHeightCB: TCheckBox; + DuplexCB: TComboBox; + EndlessWidthCB: TCheckBox; + EndlessHeightCB: TCheckBox; + procedure PortraitRBClick(Sender: TObject); + procedure SizeCBClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure WidthEChange(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure UpDown1Click(Sender: TObject; Button: TUDBtnType); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + FUpdating: Boolean; + public + { Public declarations } + end; + + +implementation + +{$R *.DFM} + +uses Printers, frxPrinter, frxClass, frxUtils, frxDesgn, frxRes; + + +procedure TfrxPageEditorForm.FormShow(Sender: TObject); +var + i: Integer; + p: TfrxReportPage; +begin + FUpdating := True; + + with frxPrinters.Printer, TfrxDesignerForm(Owner) do + begin + p := TfrxReportPage(Page); + + SizeCB.Items := Papers; + i := PaperIndex(p.PaperSize); + if i = -1 then + i := PaperIndex(256); + SizeCB.ItemIndex := i; + + WidthE.Text := frxFloatToStr(mmToUnits(p.PaperWidth)); + HeightE.Text := frxFloatToStr(mmToUnits(p.PaperHeight, False)); + PortraitRB.Checked := p.Orientation = poPortrait; + LandscapeRB.Checked := p.Orientation = poLandscape; + + MarginLeftE.Text := frxFloatToStr(mmToUnits(p.LeftMargin)); + MarginRightE.Text := frxFloatToStr(mmToUnits(p.RightMargin)); + MarginTopE.Text := frxFloatToStr(mmToUnits(p.TopMargin, False)); + MarginBottomE.Text := frxFloatToStr(mmToUnits(p.BottomMargin, False)); + + Tray1CB.Items := Bins; + Tray2CB.Items := Tray1CB.Items; + i := BinIndex(p.Bin); + if i = -1 then + i := BinIndex(DMBIN_AUTO); + Tray1CB.ItemIndex := i; + i := BinIndex(p.BinOtherPages); + if i = -1 then + i := BinIndex(DMBIN_AUTO); + Tray2CB.ItemIndex := i; + + UpDown1.Position := p.Columns; + ColumnWidthE.Text := frxFloatToStr(mmToUnits(p.ColumnWidth)); + for i := 0 to p.ColumnPositions.Count - 1 do + ColumnPositionsM.Lines.Add(frxFloatToStr(mmToUnits(frxStrToFloat(p.ColumnPositions[i])))); + PrintOnPrevCB.Checked := p.PrintOnPreviousPage; + MirrorMarginsCB.Checked := p.MirrorMargins; + EndlessHeightCB.Checked := p.EndlessHeight; + EndlessWidthCB.Checked := p.EndlessWidth; + LargeHeightCB.Checked := p.LargeDesignHeight; + DuplexCB.ItemIndex := Integer(p.Duplex); + end; + + PortraitRBClick(nil); + FUpdating := False; +end; + +procedure TfrxPageEditorForm.FormHide(Sender: TObject); +var + p: TfrxReportPage; + i: Integer; + c: TfrxReportComponent; + + procedure ChangePage(p: TfrxReportPage); + var + i: Integer; + begin + with frxPrinters.Printer, TfrxDesignerForm(Owner) do + begin + if PortraitRB.Checked then + p.Orientation := poPortrait else + p.Orientation := poLandscape; + + p.SetSizeAndDimensions(PaperNameToNumber(SizeCB.Text), + UnitsTomm(frxStrToFloat(WidthE.Text)), + UnitsTomm(frxStrToFloat(HeightE.Text), False)); + + p.LeftMargin := UnitsTomm(frxStrToFloat(MarginLeftE.Text)); + p.RightMargin := UnitsTomm(frxStrToFloat(MarginRightE.Text)); + p.TopMargin := UnitsTomm(frxStrToFloat(MarginTopE.Text), False); + p.BottomMargin := UnitsTomm(frxStrToFloat(MarginBottomE.Text), False); + + p.Bin := BinNameToNumber(Tray1CB.Text); + p.BinOtherPages := BinNameToNumber(Tray2CB.Text); + + p.Columns := UpDown1.Position; + p.ColumnWidth := UnitsTomm(frxStrToFloat(ColumnWidthE.Text)); + p.ColumnPositions.Clear; + for i := 0 to ColumnPositionsM.Lines.Count - 1 do + p.ColumnPositions.Add(frxFloatToStr(UnitsTomm(frxStrToFloat(ColumnPositionsM.Lines[i])))); + p.PrintOnPreviousPage := PrintOnPrevCB.Checked; + p.MirrorMargins := MirrorMarginsCB.Checked; + p.EndlessWidth := EndlessWidthCB.Checked; + p.EndlessHeight := EndlessHeightCB.Checked; + p.LargeDesignHeight := LargeHeightCB.Checked; + p.Duplex := TfrxDuplexMode(DuplexCB.ItemIndex); + end; + end; + +begin + if ModalResult = mrOk then + begin + p := TfrxReportPage(TfrxDesignerForm(Owner).Page); + ChangePage(p); + + { change all subreport pages } + for i := 0 to p.AllObjects.Count - 1 do + begin + c := p.AllObjects[i]; + if c is TfrxSubReport then + ChangePage(TfrxSubReport(c).Page); + end; + end; +end; + +procedure TfrxPageEditorForm.PortraitRBClick(Sender: TObject); +begin + PortraitImg.Visible := PortraitRB.Checked; + LandscapeImg.Visible := LandscapeRB.Checked; + SizeCBClick(nil); +end; + +procedure TfrxPageEditorForm.SizeCBClick(Sender: TObject); +var + pOr: TPrinterOrientation; + pNumber: Integer; + pWidth, pHeight: Extended; +begin + if FUpdating then Exit; + FUpdating := True; + + with frxPrinters.Printer, TfrxDesignerForm(Owner) do + begin + pNumber := PaperNameToNumber(SizeCB.Text); + pWidth := UnitsTomm(frxStrToFloat(WidthE.Text)); + pHeight := UnitsTomm(frxStrToFloat(HeightE.Text), False); + if PortraitRB.Checked then + pOr := poPortrait else + pOr := poLandscape; + + if pNumber = 256 then + SetViewParams(pNumber, pHeight, pWidth, pOr) else + SetViewParams(pNumber, pWidth, pHeight, pOr); + + WidthE.Text := frxFloatToStr(mmToUnits(PaperWidth)); + HeightE.Text := frxFloatToStr(mmToUnits(PaperHeight, False)); + end; + + FUpdating := False; +end; + +procedure TfrxPageEditorForm.UpDown1Click(Sender: TObject; Button: TUDBtnType); +var + n: Integer; + w: Extended; +begin + if FUpdating then Exit; + + n := UpDown1.Position; + if n = 0 then + n := 1; + + with TfrxDesignerForm(Owner) do + begin + w := (UnitsTomm(frxStrToFloat(WidthE.Text)) - + UnitsTomm(frxStrToFloat(MarginLeftE.Text)) - + UnitsTomm(frxStrToFloat(MarginRightE.Text))) / n; + ColumnWidthE.Text := frxFloatToStr(mmToUnits(w)); + + with ColumnPositionsM.Lines do + begin + Clear; + while Count < n do + Add(frxFloatToStr(mmToUnits(Count * w))); + end; + end; +end; + +procedure TfrxPageEditorForm.WidthEChange(Sender: TObject); +begin + if not FUpdating then + SizeCB.ItemIndex := 0; +end; + +procedure TfrxPageEditorForm.FormCreate(Sender: TObject); +var + uStr: String; +begin + Caption := frxGet(2700); + OKB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + TabSheet1.Caption := frxGet(2701); + Label1.Caption := frxGet(2702); + Label2.Caption := frxGet(2703); + Label11.Caption := frxGet(2704); + Label12.Caption := frxGet(2705); + Label3.Caption := frxGet(2706); + Label4.Caption := frxGet(2707); + Label5.Caption := frxGet(2708); + Label6.Caption := frxGet(2709); + Label13.Caption := frxGet(2710); + Label14.Caption := frxGet(2711); + Label9.Caption := frxGet(2712); + Label10.Caption := frxGet(2713); + PortraitRB.Caption := frxGet(2714); + LandscapeRB.Caption := frxGet(2715); + TabSheet3.Caption := frxGet(2716); + Label7.Caption := frxGet(2717); + Label8.Caption := frxGet(2718); + Label15.Caption := frxGet(2719); + Label16.Caption := frxGet(2720); + Label17.Caption := frxGet(2721); + Label18.Caption := frxGet(2722); + PrintOnPrevCB.Caption := frxGet(2723); + MirrorMarginsCB.Caption := frxGet(2724); + LargeHeightCB.Caption := frxGet(2725); + EndlessWidthCB.Caption := frxGet(2726); + EndlessHeightCB.Caption := frxGet(2727); + DuplexCB.Items.Clear; + DuplexCB.Items.Add(frxResources.Get('dupDefault')); + DuplexCB.Items.Add(frxResources.Get('dupVert')); + DuplexCB.Items.Add(frxResources.Get('dupHorz')); + DuplexCB.Items.Add(frxResources.Get('dupSimpl')); + + uStr := ''; + case TfrxDesignerForm(Owner).Units of + duCM: uStr := frxResources.Get('uCm'); + duInches: uStr := frxResources.Get('uInch'); + duPixels: uStr := frxResources.Get('uPix'); + duChars: uStr := frxResources.Get('uChar'); + end; + + UnitL1.Caption := uStr; + UnitL2.Caption := uStr; + UnitL3.Caption := uStr; + UnitL4.Caption := uStr; + UnitL5.Caption := uStr; + UnitL6.Caption := uStr; + UnitL7.Caption := uStr; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxPageEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditPicture.dfm b/official/4.2/LibD11/frxEditPicture.dfm new file mode 100644 index 0000000..b86da64 Binary files /dev/null and b/official/4.2/LibD11/frxEditPicture.dfm differ diff --git a/official/4.2/LibD11/frxEditPicture.pas b/official/4.2/LibD11/frxEditPicture.pas new file mode 100644 index 0000000..9977fc9 --- /dev/null +++ b/official/4.2/LibD11/frxEditPicture.pas @@ -0,0 +1,185 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Picture editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditPicture; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, + Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, ToolWin, frxCtrls, + frxDock +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxPictureEditorForm = class(TForm) + ToolBar: TToolBar; + LoadB: TToolButton; + ClearB: TToolButton; + OkB: TToolButton; + Box: TScrollBox; + ToolButton1: TToolButton; + CancelB: TToolButton; + Image: TImage; + StatusBar: TStatusBar; + CopyB: TToolButton; + PasteB: TToolButton; + procedure ClearBClick(Sender: TObject); + procedure LoadBClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure OkBClick(Sender: TObject); + procedure CancelBClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure CopyBClick(Sender: TObject); + procedure PasteBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + procedure UpdateImage; + public + { Public declarations } + end; + + +implementation + +{$R *.DFM} + +uses frxClass, frxUtils, frxRes, ClipBrd {$IFDEF OPENPICTUREDLG}, ExtDlgs {$ENDIF}; + +type + THackWinControl = class(TWinControl); + +{ TfrxPictureEditorForm } + +procedure TfrxPictureEditorForm.UpdateImage; +begin + if (Image.Picture.Graphic = nil) or Image.Picture.Graphic.Empty then + StatusBar.Panels[0].Text := frxResources.Get('piEmpty') + else + begin + StatusBar.Panels[0].Text := Format('%d x %d', + [Image.Picture.Width, Image.Picture.Height]); + Image.Stretch := (Image.Picture.Width > Image.Width) or + (Image.Picture.Height > Image.Height); + end; +end; + +procedure TfrxPictureEditorForm.FormShow(Sender: TObject); +begin + Toolbar.Images := frxResources.MainButtonImages; +{$IFDEF UseTabset} + Box.BevelKind := bkFlat; +{$ELSE} + Box.BorderStyle := bsSingle; +{$IFDEF Delphi7} + Box.ControlStyle := Box.ControlStyle + [csNeedsBorderPaint]; +{$ENDIF} +{$ENDIF} + UpdateImage; +end; + +procedure TfrxPictureEditorForm.ClearBClick(Sender: TObject); +begin + Image.Picture.Assign(nil); + UpdateImage; +end; + +procedure TfrxPictureEditorForm.LoadBClick(Sender: TObject); +var +{$IFDEF OPENPICTUREDLG} + OpenDlg: TOpenPictureDialog; +{$ELSE} + OpenDlg: TOpenDialog; +{$ENDIF} +begin +{$IFDEF OPENPICTUREDLG} + OpenDlg := TOpenPictureDialog.Create(nil); +{$ELSE} + OpenDlg := TOpenDialog.Create(nil); +{$ENDIF} + OpenDlg.Options := []; + OpenDlg.Filter := frxResources.Get('ftPictures') + ' (*.bmp ' + +{$IFDEF JPEG} + '*.jpg ' + +{$ENDIF} +{$IFDEF PNG} + '*.png ' + +{$ENDIF} + '*.ico *.wmf *.emf)|*.bmp;' + +{$IFDEF JPEG} + '*.jpg;' + +{$ENDIF} +{$IFDEF PNG} + '*.png;' + +{$ENDIF} + '*.ico;*.wmf;*.emf|' + frxResources.Get('ftAllFiles') + '|*.*'; + if OpenDlg.Execute then + Image.Picture.LoadFromFile(OpenDlg.FileName); + OpenDlg.Free; + UpdateImage; +end; + +procedure TfrxPictureEditorForm.OkBClick(Sender: TObject); +begin + ModalResult := mrOk; +end; + +procedure TfrxPictureEditorForm.CancelBClick(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +procedure TfrxPictureEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(4000); + LoadB.Hint := frxGet(4001); + CopyB.Hint := frxGet(4002); + PasteB.Hint := frxGet(4003); + ClearB.Hint := frxGet(4004); + CancelB.Hint := frxGet(2); + OkB.Hint := frxGet(1); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxPictureEditorForm.CopyBClick(Sender: TObject); +begin + if Image.Picture <> nil then + Clipboard.Assign(Image.Picture); +end; + +procedure TfrxPictureEditorForm.PasteBClick(Sender: TObject); +begin + Image.Picture.Assign(Clipboard); + UpdateImage; +end; + +procedure TfrxPictureEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditQueryParams.dfm b/official/4.2/LibD11/frxEditQueryParams.dfm new file mode 100644 index 0000000..0a0a7e2 Binary files /dev/null and b/official/4.2/LibD11/frxEditQueryParams.dfm differ diff --git a/official/4.2/LibD11/frxEditQueryParams.pas b/official/4.2/LibD11/frxEditQueryParams.pas new file mode 100644 index 0000000..27c75cb --- /dev/null +++ b/official/4.2/LibD11/frxEditQueryParams.pas @@ -0,0 +1,172 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Query params editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditQueryParams; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ComCtrls, StdCtrls, Buttons, DB, frxCustomDB, frxCtrls, ExtCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxParamsEditorForm = class(TForm) + ParamsLV: TListView; + TypeCB: TComboBox; + ValueE: TEdit; + OkB: TButton; + CancelB: TButton; + ButtonPanel: TPanel; + ExpressionB: TSpeedButton; + procedure ParamsLVSelectItem(Sender: TObject; Item: TListItem; + Selected: Boolean); + procedure FormShow(Sender: TObject); + procedure ParamsLVMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure OkBClick(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure ValueEButtonClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FParams: TfrxParams; + public + property Params: TfrxParams read FParams write FParams; + end; + + +implementation + +{$R *.DFM} + +uses frxClass, frxRes; + + +{ TfrxParamEditorForm } + +procedure TfrxParamsEditorForm.FormShow(Sender: TObject); +var + i: Integer; + t: TFieldType; + Item: TListItem; +begin + for i := 0 to Params.Count - 1 do + begin + Item := ParamsLV.Items.Add; + Item.Caption := Params[i].Name; + Item.SubItems.Add(FieldTypeNames[Params[i].DataType]); + Item.SubItems.Add(Params[i].Expression); + end; + + for t := Low(TFieldType) to High(TFieldType) do + TypeCB.Items.Add(FieldTypeNames[t]); + + ParamsLV.Selected := ParamsLV.Items[0]; + ValueE.Height := TypeCB.Height; + ButtonPanel.Height := TypeCB.Height - 2; + ExpressionB.Height := TypeCB.Height - 2; +end; + +procedure TfrxParamsEditorForm.FormHide(Sender: TObject); +var + i: Integer; + t: TFieldType; + Item: TListItem; +begin + if ModalResult <> mrOk then Exit; + + for i := 0 to ParamsLV.Items.Count - 1 do + begin + Item := ParamsLV.Items[i]; + for t := Low(TFieldType) to High(TFieldType) do + if Item.SubItems[0] = FieldTypeNames[t] then + begin + Params[i].DataType := t; + break; + end; + Params[i].Expression := Item.SubItems[1]; + end; +end; + +procedure TfrxParamsEditorForm.ParamsLVSelectItem(Sender: TObject; Item: TListItem; + Selected: Boolean); +begin + if Selected then + begin + TypeCB.Top := ParamsLV.Top + Item.Top; + ValueE.Top := TypeCB.Top; + ButtonPanel.Top := TypeCB.Top; + TypeCB.ItemIndex := TypeCB.Items.IndexOf(Item.SubItems[0]); + ValueE.Text := Item.SubItems[1]; + end + else + begin + Item.SubItems[0] := TypeCB.Text; + Item.SubItems[1] := ValueE.Text; + end; +end; + +procedure TfrxParamsEditorForm.ParamsLVMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +begin + ParamsLV.Selected := ParamsLV.GetItemAt(5, Y); + ParamsLV.ItemFocused := ParamsLV.Selected; +end; + +procedure TfrxParamsEditorForm.OkBClick(Sender: TObject); +begin + ParamsLV.Selected := ParamsLV.Items[0]; +end; + +procedure TfrxParamsEditorForm.ValueEButtonClick(Sender: TObject); +var + s: String; +begin + s := TfrxCustomDesigner(Owner).InsertExpression(ValueE.Text); + if s <> '' then + ValueE.Text := s; +end; + +procedure TfrxParamsEditorForm.FormCreate(Sender: TObject); +begin +{$IFDEF FR_COM} + Icon.Handle := LoadIcon(hInstance, 'SDESGNICON'); +{$ENDIF} + Caption := frxGet(3700); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + ParamsLV.Columns[0].Caption := frxResources.Get('qpName'); + ParamsLV.Columns[1].Caption := frxResources.Get('qpDataType'); + ParamsLV.Columns[2].Caption := frxResources.Get('qpValue'); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxParamsEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditReport.dfm b/official/4.2/LibD11/frxEditReport.dfm new file mode 100644 index 0000000..27e3dd5 Binary files /dev/null and b/official/4.2/LibD11/frxEditReport.dfm differ diff --git a/official/4.2/LibD11/frxEditReport.pas b/official/4.2/LibD11/frxEditReport.pas new file mode 100644 index 0000000..372bfcb --- /dev/null +++ b/official/4.2/LibD11/frxEditReport.pas @@ -0,0 +1,290 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report options } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditReport; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxCtrls, ComCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxReportEditorForm = class(TForm) + OkB: TButton; + CancelB: TButton; + PageControl: TPageControl; + GeneralTS: TTabSheet; + DescriptionTS: TTabSheet; + ReportSettingsL: TGroupBox; + PrintersLB: TListBox; + CopiesL: TLabel; + CopiesE: TEdit; + CollateCB: TCheckBox; + GeneralL: TGroupBox; + PasswordL: TLabel; + DoublePassCB: TCheckBox; + PrintIfEmptyCB: TCheckBox; + PasswordE: TEdit; + DescriptionL: TGroupBox; + Bevel3: TBevel; + NameL: TLabel; + PictureImg: TImage; + Description1L: TLabel; + PictureL: TLabel; + AuthorL: TLabel; + NameE: TEdit; + DescriptionE: TMemo; + PictureB: TButton; + AuthorE: TEdit; + VersionL: TGroupBox; + MajorL: TLabel; + MinorL: TLabel; + ReleaseL: TLabel; + BuildL: TLabel; + CreatedL: TLabel; + Created1L: TLabel; + ModifiedL: TLabel; + Modified1L: TLabel; + MajorE: TEdit; + MinorE: TEdit; + ReleaseE: TEdit; + BuildE: TEdit; + InheritTS: TTabSheet; + InheritGB: TGroupBox; + InheritStateL: TLabel; + DetachRB: TRadioButton; + SelectL: TLabel; + InheritRB: TRadioButton; + DontChangeRB: TRadioButton; + InheritLV: TListView; + procedure FormCreate(Sender: TObject); + procedure PictureBClick(Sender: TObject); + procedure PrintersLBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure FormDestroy(Sender: TObject); + private + { Private declarations } + FTemplates: TStringList; + public + { Public declarations } + end; + + +implementation + +{$R *.DFM} + +uses + frxDesgn, frxEditPicture, frxPrinter, frxUtils, frxRes, frxClass; + + +procedure TfrxReportEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(4700); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + GeneralTS.Caption := frxGet(4701); + ReportSettingsL.Caption := frxGet(4702); + CopiesL.Caption := frxGet(4703); + GeneralL.Caption := frxGet(4704); + PasswordL.Caption := frxGet(4705); + CollateCB.Caption := frxGet(4706); + DoublePassCB.Caption := frxGet(4707); + PrintIfEmptyCB.Caption := frxGet(4708); + DescriptionTS.Caption := frxGet(4709); + NameL.Caption := frxGet(4710); + Description1L.Caption := frxGet(4711); + PictureL.Caption := frxGet(4712); + AuthorL.Caption := frxGet(4713); + MajorL.Caption := frxGet(4714); + MinorL.Caption := frxGet(4715); + ReleaseL.Caption := frxGet(4716); + BuildL.Caption := frxGet(4717); + CreatedL.Caption := frxGet(4718); + ModifiedL.Caption := frxGet(4719); + DescriptionL.Caption := frxGet(4720); + VersionL.Caption := frxGet(4721); + PictureB.Caption := frxGet(4722); + InheritTS.Caption := frxGet(4728); + InheritGB.Caption := frxGet(4723); + SelectL.Caption := frxGet(4724); + DontChangeRB.Caption := frxGet(4725); + DetachRB.Caption := frxGet(4726); + InheritRB.Caption := frxGet(4727); + + if Screen.PixelsPerInch > 96 then + PrintersLB.ItemHeight := 19; + InheritLV.LargeImages := frxResources.WizardImages; + + FTemplates := TStringList.Create; + FTemplates.Sorted := True; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxReportEditorForm.FormDestroy(Sender: TObject); +begin + FTemplates.Free; +end; + +procedure TfrxReportEditorForm.FormShow(Sender: TObject); +var + i: Integer; + lvItem: TListItem; +begin + with TfrxDesignerForm(Owner).Report do + begin + PrintersLB.Items := frxPrinters.Printers; + PrintersLB.Items.Insert(0, frxResources.Get('prDefault')); + PrintersLB.ItemIndex := PrintersLB.Items.IndexOf(PrintOptions.Printer); + CollateCB.Checked := PrintOptions.Collate; + CopiesE.Text := IntToStr(PrintOptions.Copies); + DoublePassCB.Checked := EngineOptions.DoublePass; + PrintIfEmptyCB.Checked := EngineOptions.PrintIfEmpty; + PasswordE.Text := ReportOptions.Password; + + if Trim(ParentReport) = '' then + begin + InheritStateL.Caption := frxResources.Get('riNotInherited'); + DetachRB.Enabled := False; + end + else + InheritStateL.Caption := Format(frxResources.Get('riInherited'), [ParentReport]); + + if frxDesignerComp <> nil then + begin + frxDesignerComp.GetTemplateList(FTemplates); + for i := 0 to FTemplates.Count - 1 do + begin + lvItem := InheritLV.Items.Add; + lvItem.Caption := ExtractFileName(FTemplates[i]); + lvItem.Data := Pointer(i); + lvItem.ImageIndex := 5; + end; + end; + + NameE.Text := ReportOptions.Name; + AuthorE.Text := ReportOptions.Author; + DescriptionE.Lines.Text := ReportOptions.Description.Text; + PictureImg.Picture.Assign(ReportOptions.Picture); + PictureImg.Stretch := (PictureImg.Picture.Width > PictureImg.Width) or + (PictureImg.Picture.Height > PictureImg.Height); + + MajorE.Text := ReportOptions.VersionMajor; + MinorE.Text := ReportOptions.VersionMinor; + ReleaseE.Text := ReportOptions.VersionRelease; + BuildE.Text := ReportOptions.VersionBuild; + Created1L.Caption := DateTimeToStr(ReportOptions.CreateDate); + Modified1L.Caption := DateTimeToStr(ReportOptions.LastChange); + end; +end; + +procedure TfrxReportEditorForm.FormHide(Sender: TObject); +var + templ: String; +begin + if ModalResult = mrOk then + with TfrxDesignerForm(Owner).Report do + begin + if PrintersLB.ItemIndex <> -1 then + begin + PrintOptions.Printer := PrintersLB.Items[PrintersLB.ItemIndex]; + SelectPrinter; + end; + PrintOptions.Collate := CollateCB.Checked; + PrintOptions.Copies := StrToInt(CopiesE.Text); + EngineOptions.DoublePass := DoublePassCB.Checked; + EngineOptions.PrintIfEmpty := PrintIfEmptyCB.Checked; + ReportOptions.Password := PasswordE.Text; + + if not DontChangeRB.Checked then + begin + Designer.Lock; + try + if DetachRB.Checked then + ParentReport := '' + else if InheritRB.Checked and (InheritLV.Selected <> nil) then + begin + ParentReport := ''; + templ := FTemplates[Integer(InheritLV.Selected.Data)]; + InheritFromTemplate(templ); + end; + finally + Designer.ReloadReport; + end; + end; + + ReportOptions.Name := NameE.Text; + ReportOptions.Author := AuthorE.Text; + ReportOptions.Description.Text := DescriptionE.Lines.Text; + ReportOptions.Picture.Assign(PictureImg.Picture); + ReportOptions.VersionMajor := MajorE.Text; + ReportOptions.VersionMinor := MinorE.Text; + ReportOptions.VersionRelease := ReleaseE.Text; + ReportOptions.VersionBuild := BuildE.Text; + end; +end; + +procedure TfrxReportEditorForm.PictureBClick(Sender: TObject); +begin + with TfrxPictureEditorForm.Create(Owner) do + begin + Image.Picture.Assign(PictureImg.Picture); + if ShowModal = mrOk then + begin + PictureImg.Picture.Assign(Image.Picture); + PictureImg.Stretch := (PictureImg.Picture.Width > PictureImg.Width) or + (PictureImg.Picture.Height > PictureImg.Height); + end; + Free; + end; +end; + +procedure TfrxReportEditorForm.PrintersLBDrawItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +var + s: String; +begin + with PrintersLB.Canvas do + begin + FillRect(ARect); + frxResources.PreviewButtonImages.Draw(PrintersLB.Canvas, ARect.Left + 2, ARect.Top, 2); + s := PrintersLB.Items[Index]; + if (Index <> 0) and (frxPrinters[Index - 1].Port <> '') then + s := s + ' ' + frxResources.Get('rePrnOnPort') + ' ' + frxPrinters[Index - 1].Port; + TextOut(ARect.Left + 24, ARect.Top + 1, s); + end; +end; + +procedure TfrxReportEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditReportData.dfm b/official/4.2/LibD11/frxEditReportData.dfm new file mode 100644 index 0000000..bc485df Binary files /dev/null and b/official/4.2/LibD11/frxEditReportData.dfm differ diff --git a/official/4.2/LibD11/frxEditReportData.pas b/official/4.2/LibD11/frxEditReportData.pas new file mode 100644 index 0000000..d67e163 --- /dev/null +++ b/official/4.2/LibD11/frxEditReportData.pas @@ -0,0 +1,214 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report datasets selector } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditReportData; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, frxClass, CheckLst +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxReportDataForm = class(TForm) + OKB: TButton; + CancelB: TButton; + DatasetsLB: TCheckListBox; + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure DatasetsLBClickCheck(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FStandalone: Boolean; + procedure BuildConnectionList; + procedure BuildDatasetList; + public + Report: TfrxReport; + end; + + +implementation + +{$R *.DFM} + +uses frxDesgn, frxUtils, frxRes, IniFiles, Registry; + +var + PrevWidth: Integer = 0; + PrevHeight: Integer = 0; + +procedure TfrxReportDataForm.FormCreate(Sender: TObject); +begin + FStandalone := (frxDesignerComp <> nil) and frxDesignerComp.Standalone; + if FStandalone then + Caption := frxGet(5800) + else + Caption := frxGet(2800); + OKB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxReportDataForm.FormShow(Sender: TObject); +begin + if PrevWidth <> 0 then + begin + Width := PrevWidth; + Height := PrevHeight; + end; + + DatasetsLB.SetBounds(4, 4, ClientWidth - 8, ClientHeight - OkB.Height - 12); + OkB.Left := ClientWidth - OkB.Width - CancelB.Width - 8; + CancelB.Left := ClientWidth - CancelB.Width - 4; + OkB.Top := ClientHeight - OkB.Height - 4; + CancelB.Top := OkB.Top; + + if FStandalone then + BuildConnectionList + else + BuildDatasetList; +end; + +procedure TfrxReportDataForm.FormHide(Sender: TObject); +var + i: Integer; +begin + PrevWidth := Width; + PrevHeight := Height; + if ModalResult <> mrOk then Exit; + + if FStandalone then + Report.ReportOptions.ConnectionName := '' + else + Report.Datasets.Clear; + + for i := 0 to DatasetsLB.Items.Count - 1 do + if DatasetsLB.Checked[i] then + if FStandalone then + Report.ReportOptions.ConnectionName := DatasetsLB.Items[i] + else + Report.DataSets.Add(TfrxDataSet(DatasetsLB.Items.Objects[i])); +end; + +procedure TfrxReportDataForm.BuildConnectionList; +var + i: Integer; + ini: TRegistry; + sl: TStringList; + s2: TStringList; +begin + ini := TRegistry.Create; + try + sl := TStringList.Create; + s2 := TStringList.Create; + try + ini.RootKey := HKEY_LOCAL_MACHINE; + if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS) then + begin + ini.GetValueNames(sl); + ini.CloseKey; + end; + + ini.RootKey := HKEY_CURRENT_USER; + if ini.OpenKeyReadOnly(DEF_REG_CONNECTIONS) then + begin + ini.GetValueNames(s2); + ini.CloseKey; + end; + + sl.AddStrings(s2); + + for i := 0 to sl.Count - 1 do + begin + DataSetsLB.Items.Add(sl[i]); + DataSetsLB.Checked[i] := CompareText(sl[i], Report.ReportOptions.ConnectionName) = 0; + end; + finally + sl.Free; + s2.Free; + end; + finally + ini.Free; + end; +end; + +procedure TfrxReportDataForm.BuildDatasetList; +var + i: Integer; + ds: TfrxDataSet; + dsList: TStringList; +begin + dsList := TStringList.Create; + + if Report.EnabledDataSets.Count > 0 then + begin + for i := 0 to Report.EnabledDataSets.Count - 1 do + begin + ds := Report.EnabledDataSets[i].DataSet; + if ds <> nil then + dsList.AddObject(ds.UserName, ds); + end; + end + else + frxGetDataSetList(dsList); + + dsList.Sort; + + for i := 0 to dsList.Count - 1 do + begin + ds := TfrxDataSet(dsList.Objects[i]); + if (csDesigning in Report.ComponentState) and + ((ds.Owner is TForm) or (ds.Owner is TDataModule)) then + DataSetsLB.Items.AddObject(ds.UserName + ' (' + ds.Owner.Name + '.' + ds.Name + ')', ds) + else + begin + if not (ds.Owner is TfrxReport) or (ds.Owner = Report) then + DataSetsLB.Items.AddObject(ds.UserName, ds); + end; + if Report.Datasets.Find(ds) <> nil then + DataSetsLB.Checked[DataSetsLB.Items.Count - 1] := True; + end; + + dsList.Free; +end; + +procedure TfrxReportDataForm.DatasetsLBClickCheck(Sender: TObject); +var + i: Integer; +begin + if FStandalone then + for i := 0 to DatasetsLB.Items.Count - 1 do + if i <> DatasetsLB.ItemIndex then + DatasetsLB.Checked[i] := False; +end; + +procedure TfrxReportDataForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditSQL.dfm b/official/4.2/LibD11/frxEditSQL.dfm new file mode 100644 index 0000000..a84a650 Binary files /dev/null and b/official/4.2/LibD11/frxEditSQL.dfm differ diff --git a/official/4.2/LibD11/frxEditSQL.inc b/official/4.2/LibD11/frxEditSQL.inc new file mode 100644 index 0000000..456b78e --- /dev/null +++ b/official/4.2/LibD11/frxEditSQL.inc @@ -0,0 +1,18 @@ +{ custom color settings for SQL editor } + +{ + property BlockColor: TColor; + property BlockFontColor: TColor; + property Color; + property CommentAttr: TFont; + property Font; + property KeywordAttr: TFont; + property NumberAttr: TFont; + property StringAttr: TFont; + property TextAttr: TFont; +} + +{ example: + Color := clBlack; + TextAttr.Color := clGreen; +} diff --git a/official/4.2/LibD11/frxEditSQL.pas b/official/4.2/LibD11/frxEditSQL.pas new file mode 100644 index 0000000..74b9f54 --- /dev/null +++ b/official/4.2/LibD11/frxEditSQL.pas @@ -0,0 +1,222 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ SQL editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditSQL; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, + Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, ToolWin, frxSynMemo, + frxCustomDB +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF QBUILDER} +, fqbClass +{$ENDIF}; + + +type + TfrxSQLEditorForm = class(TForm) + ToolBar: TToolBar; + OkB: TToolButton; + CancelB: TToolButton; + QBB: TToolButton; + ParamsB: TToolButton; + ToolButton2: TToolButton; + procedure OkBClick(Sender: TObject); + procedure CancelBClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure MemoKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure FormHide(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure QBBClick(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure ParamsBClick(Sender: TObject); + private + { Private declarations } + FMemo: TfrxSyntaxMemo; + FQuery: TfrxCustomQuery; +{$IFDEF QBUILDER} + FQBEngine: TfqbEngine; +{$ENDIF} + FSaveSQL: TStrings; + FSaveSchema: String; + FSaveParams: TfrxParams; + public + { Public declarations } + property Query: TfrxCustomQuery read FQuery write FQuery; + end; + + +implementation + +{$R *.DFM} + +uses frxClass, frxRes, frxDock, IniFiles, frxEditQueryParams; + + +procedure TfrxSQLEditorForm.FormCreate(Sender: TObject); +begin +{$IFDEF FR_COM} + Icon.Handle := LoadIcon(hInstance, 'SDESGNICON'); +{$ENDIF} + FSaveSQL := TStringList.Create; + FSaveParams := TfrxParams.Create; + + FMemo := TfrxSyntaxMemo.Create(Self); + with FMemo do + begin + Parent := Self; + Align := alClient; + Syntax := 'SQL'; + ShowGutter := True; + GutterWidth := 20; +{$IFDEF UseTabset} + BevelKind := bkFlat; +{$ELSE} + BorderStyle := bsSingle; +{$ENDIF} + Color := clWindow; + OnKeyDown := MemoKeyDown; +{$I frxEditSQL.inc} + end; + Toolbar.Images := frxResources.MainButtonImages; +{$IFDEF QBUILDER} + QBB.Visible := True; +{$ENDIF} + Caption := frxGet(4900); + QBB.Hint := frxGet(4901); + ParamsB.Hint := frxGet(5714); + CancelB.Hint := frxGet(2); + OkB.Hint := frxGet(1); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxSQLEditorForm.FormDestroy(Sender: TObject); +begin + FSaveSQL.Free; + FSaveParams.Free; +end; + +procedure TfrxSQLEditorForm.FormShow(Sender: TObject); +var + Ini: TCustomIniFile; +begin + FSaveSQL.Assign(Query.SQL); + FSaveParams.Assign(Query.Params); + FSaveSchema := Query.SQLSchema; +{$IFDEF QBUILDER} + FQBEngine := Query.QBEngine; +{$ENDIF} + FMemo.Lines.Assign(Query.SQL); + + Ini := TfrxCustomDesigner(Owner).Report.GetIniFile; + Ini.WriteBool('Form4.TfrxSQLEditorForm', 'Visible', True); + frxRestoreFormPosition(Ini, Self); + Ini.Free; +end; + +procedure TfrxSQLEditorForm.FormHide(Sender: TObject); +var + Ini: TCustomIniFile; +begin + if ModalResult = mrOk then + begin + Query.SQL.Assign(FMemo.Lines); + end + else + begin + Query.SQL.Assign(FSaveSQL); + Query.Params.Assign(FSaveParams); + Query.SQLSchema := FSaveSchema; + end; + + Ini := TfrxCustomDesigner(Owner).Report.GetIniFile; + frxSaveFormPosition(Ini, Self); + Ini.Free; +{$IFDEF QBUILDER} + if FQBEngine <> nil then + FQBEngine.Free; +{$ENDIF} +end; + +procedure TfrxSQLEditorForm.OkBClick(Sender: TObject); +begin + ModalResult := mrOk; +end; + +procedure TfrxSQLEditorForm.CancelBClick(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +procedure TfrxSQLEditorForm.MemoKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if (Key = vk_Return) and (ssCtrl in Shift) then + ModalResult := mrOk + else if Key = vk_Escape then + ModalResult := mrCancel + else if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxSQLEditorForm.QBBClick(Sender: TObject); +{$IFDEF QBUILDER} +var + fqbDialog: TfqbDialog; +{$ENDIF} +begin +{$IFDEF QBUILDER} + fqbDialog := TfqbDialog.Create(nil); + try + fqbDialog.Engine := FQBEngine; + fqbDialog.SchemaInsideSQL := False; + fqbDialog.SQL := FMemo.Lines.Text; + fqbDialog.SQLSchema := Query.SQLSchema; + + if fqbDialog.Execute then + begin + FMemo.Lines.Text := fqbDialog.SQL; + Query.SQLSchema := fqbDialog.SQLSchema; + end; + finally + fqbDialog.Free; + end; +{$ENDIF} +end; + +procedure TfrxSQLEditorForm.ParamsBClick(Sender: TObject); +begin + Query.SQL.Assign(FMemo.Lines); + if Query.Params.Count <> 0 then + with TfrxParamsEditorForm.Create(Owner) do + begin + Params := Query.Params; + if ShowModal = mrOk then + Query.UpdateParams; + Free; + end; +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditStrings.dfm b/official/4.2/LibD11/frxEditStrings.dfm new file mode 100644 index 0000000..2750bde Binary files /dev/null and b/official/4.2/LibD11/frxEditStrings.dfm differ diff --git a/official/4.2/LibD11/frxEditStrings.pas b/official/4.2/LibD11/frxEditStrings.pas new file mode 100644 index 0000000..e521e90 --- /dev/null +++ b/official/4.2/LibD11/frxEditStrings.pas @@ -0,0 +1,95 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ TStrings editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditStrings; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, + Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, ToolWin +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxStringsEditorForm = class(TForm) + ToolBar: TToolBar; + OkB: TToolButton; + CancelB: TToolButton; + Memo: TMemo; + procedure OkBClick(Sender: TObject); + procedure CancelBClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure MemoKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + public + { Public declarations } + end; + + +implementation + +{$R *.DFM} + +uses frxClass, frxRes; + + +procedure TfrxStringsEditorForm.OkBClick(Sender: TObject); +begin + ModalResult := mrOk; +end; + +procedure TfrxStringsEditorForm.CancelBClick(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +procedure TfrxStringsEditorForm.FormCreate(Sender: TObject); +begin + Toolbar.Images := frxResources.MainButtonImages; + Caption := frxGet(4800); + CancelB.Hint := frxGet(2); + OkB.Hint := frxGet(1); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxStringsEditorForm.MemoKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if (Key = vk_Return) and (ssCtrl in Shift) then + ModalResult := mrOk + else if Key = vk_Escape then + ModalResult := mrCancel; +end; + +procedure TfrxStringsEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditStyle.dfm b/official/4.2/LibD11/frxEditStyle.dfm new file mode 100644 index 0000000..30998e7 Binary files /dev/null and b/official/4.2/LibD11/frxEditStyle.dfm differ diff --git a/official/4.2/LibD11/frxEditStyle.pas b/official/4.2/LibD11/frxEditStyle.pas new file mode 100644 index 0000000..6500646 --- /dev/null +++ b/official/4.2/LibD11/frxEditStyle.pas @@ -0,0 +1,300 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Style editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditStyle; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ComCtrls, ExtCtrls, ToolWin, StdCtrls, ImgList, frxClass; + +type + TfrxStyleEditorForm = class(TForm) + ToolBar: TToolBar; + AddB: TToolButton; + DeleteB: TToolButton; + Sep1: TToolButton; + LoadB: TToolButton; + SaveB: TToolButton; + Sep2: TToolButton; + CancelB: TToolButton; + OkB: TToolButton; + OpenDialog: TOpenDialog; + SaveDialog: TSaveDialog; + StylesTV: TTreeView; + EditB: TToolButton; + PaintBox: TPaintBox; + ColorB: TButton; + FontB: TButton; + FrameB: TButton; + procedure FormCreate(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure CancelBClick(Sender: TObject); + procedure OkBClick(Sender: TObject); + procedure PaintBoxPaint(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure AddBClick(Sender: TObject); + procedure DeleteBClick(Sender: TObject); + procedure LoadBClick(Sender: TObject); + procedure SaveBClick(Sender: TObject); + procedure BClick(Sender: TObject); + procedure StylesTVClick(Sender: TObject); + procedure StylesTVEdited(Sender: TObject; Node: TTreeNode; + var S: String); + procedure EditBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FImageList: TImageList; + FReport: TfrxReport; + FStyles: TfrxStyles; + procedure UpdateStyles(Focus: Integer = 0); + procedure UpdateControls; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + + +implementation + +{$R *.DFM} + +uses frxDesgn, frxEditFrame, frxDesgnCtrls, frxRes; + + +constructor TfrxStyleEditorForm.Create(AOwner: TComponent); +begin + inherited; + FStyles := TfrxStyles.Create(nil); +end; + +destructor TfrxStyleEditorForm.Destroy; +begin + FStyles.Free; + inherited; +end; + +procedure TfrxStyleEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(5100); + ColorB.Caption := frxGet(5101); + FontB.Caption := frxGet(5102); + FrameB.Caption := frxGet(5103); + AddB.Hint := frxGet(5104); + DeleteB.Hint := frxGet(5105); + EditB.Hint := frxGet(5106); + LoadB.Hint := frxGet(5107); + SaveB.Hint := frxGet(5108); + CancelB.Hint := frxGet(2); + OkB.Hint := frxGet(1); + + FReport := TfrxCustomDesigner(Owner).Report; + FImageList := frxResources.MainButtonImages; + ToolBar.Images := FImageList; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxStyleEditorForm.FormShow(Sender: TObject); +begin + FStyles.Assign(FReport.Styles); + UpdateStyles; +end; + +procedure TfrxStyleEditorForm.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + FReport.Styles.Assign(FStyles); +end; + +procedure TfrxStyleEditorForm.UpdateStyles(Focus: Integer = 0); +var + i: Integer; + Node: TTreeNode; +begin + StylesTV.Items.BeginUpdate; + StylesTV.Items.Clear; + for i := 0 to FStyles.Count - 1 do + begin + Node := StylesTV.Items.AddChild(nil, FStyles[i].Name); + Node.Data := FStyles[i]; + end; + StylesTV.Items.EndUpdate; + + if Focus >= StylesTV.Items.Count then + Focus := StylesTV.Items.Count - 1; + if Focus <> -1 then + StylesTV.Selected := StylesTV.Items[Focus]; + StylesTVClick(nil); +end; + +procedure TfrxStyleEditorForm.UpdateControls; +var + b: Boolean; +begin + b := StylesTV.Selected <> nil; + ColorB.Enabled := b; + FontB.Enabled := b; + FrameB.Enabled := b; +end; + +procedure TfrxStyleEditorForm.PaintBoxPaint(Sender: TObject); +var + m: TfrxMemoView; +begin + with PaintBox.Canvas do + begin + Brush.Color := clWindow; + Pen.Color := clGray; + Pen.Width := 1; + Pen.Style := psSolid; + Rectangle(0, 0, PaintBox.Width, PaintBox.Height); + end; + if StylesTV.Selected = nil then Exit; + + m := TfrxMemoView.Create(nil); + m.ApplyStyle(TfrxStyleItem(StylesTV.Selected.Data)); + m.Text := frxResources.Get('dsStyleSample'); + m.GapX := 20; + m.GapY := 10; + m.Width := m.CalcWidth; + m.Height := m.CalcHeight; + m.Left := (PaintBox.Width - m.Width) / 2; + m.Top := (PaintBox.Height - m.Height) / 2; + m.Draw(PaintBox.Canvas, 1, 1, 0, 0); + m.Free; +end; + +procedure TfrxStyleEditorForm.StylesTVClick(Sender: TObject); +begin + UpdateControls; + PaintBoxPaint(nil); +end; + +procedure TfrxStyleEditorForm.BClick(Sender: TObject); +var + Style: TfrxStyleItem; +begin + if StylesTV.Selected = nil then Exit; + Style := TfrxStyleItem(StylesTV.Selected.Data); + + case TControl(Sender).Tag of + 2: + with TfrxColorSelector.Create(TComponent(Sender)) do + begin + OnColorChanged := BClick; + Tag := 20; + end; + + 20: Style.Color := TfrxColorSelector(Sender).Color; + + 3: + with TFontDialog.Create(Application) do + begin + Font := Style.Font; + Options := Options + [fdForceFontExist]; + if Execute then + Style.Font := Font; + Free; + end; + + 4: + with TfrxFrameEditorForm.Create(Owner) do + begin + Frame.Assign(Style.Frame); + if ShowModal = mrOk then + Style.Frame := Frame; + Free; + end; + end; + + PaintBoxPaint(nil); +end; + +procedure TfrxStyleEditorForm.AddBClick(Sender: TObject); +begin + FStyles.Add.CreateUniqueName; + UpdateStyles(FStyles.Count - 1); + StylesTV.Selected.EditText; +end; + +procedure TfrxStyleEditorForm.DeleteBClick(Sender: TObject); +begin + if StylesTV.Selected = nil then Exit; + TfrxStyleItem(StylesTV.Selected.Data).Free; + UpdateStyles(StylesTV.Selected.Index); +end; + +procedure TfrxStyleEditorForm.LoadBClick(Sender: TObject); +begin + OpenDialog.Filter := frxResources.Get('dsStyleFile') + ' (*.fs3)|*.fs3'; + if frxDesignerComp <> nil then + OpenDialog.InitialDir := frxDesignerComp.OpenDir; + if OpenDialog.Execute then + begin + FStyles.LoadFromFile(OpenDialog.FileName); + UpdateStyles; + end; +end; + +procedure TfrxStyleEditorForm.SaveBClick(Sender: TObject); +begin + SaveDialog.Filter := frxResources.Get('dsStyleFile') + ' (*.fs3)|*.fs3'; + if frxDesignerComp <> nil then + SaveDialog.InitialDir := frxDesignerComp.SaveDir; + if SaveDialog.Execute then + FStyles.SaveToFile(ChangeFileExt(SaveDialog.FileName, '.fs3')); +end; + +procedure TfrxStyleEditorForm.CancelBClick(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +procedure TfrxStyleEditorForm.OkBClick(Sender: TObject); +begin + ModalResult := mrOk; +end; + +procedure TfrxStyleEditorForm.StylesTVEdited(Sender: TObject; Node: TTreeNode; + var S: String); +var + Style: TfrxStyleItem; +begin + Style := TfrxStyleItem(Node.Data); + Style.Name := s; +end; + +procedure TfrxStyleEditorForm.EditBClick(Sender: TObject); +begin + if StylesTV.Selected = nil then Exit; + StylesTV.Selected.EditText; +end; + +procedure TfrxStyleEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); + if Key = VK_F2 then + EditBClick(nil); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditSysMemo.dfm b/official/4.2/LibD11/frxEditSysMemo.dfm new file mode 100644 index 0000000..0f38160 Binary files /dev/null and b/official/4.2/LibD11/frxEditSysMemo.dfm differ diff --git a/official/4.2/LibD11/frxEditSysMemo.pas b/official/4.2/LibD11/frxEditSysMemo.pas new file mode 100644 index 0000000..e096dbf --- /dev/null +++ b/official/4.2/LibD11/frxEditSysMemo.pas @@ -0,0 +1,294 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ SysMemo editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditSysMemo; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxClass, frxCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxSysMemoEditorForm = class(TForm) + OKB: TButton; + CancelB: TButton; + AggregateRB: TRadioButton; + SysVariableRB: TRadioButton; + TextRB: TRadioButton; + AggregatePanel: TGroupBox; + DataBandL: TLabel; + DataSetL: TLabel; + DataFieldL: TLabel; + FunctionL: TLabel; + ExpressionL: TLabel; + DataFieldCB: TComboBox; + DataSetCB: TComboBox; + DataBandCB: TComboBox; + CountInvisibleCB: TCheckBox; + FunctionCB: TComboBox; + ExpressionE: TfrxComboEdit; + RunningTotalCB: TCheckBox; + GroupBox1: TGroupBox; + SysVariableCB: TComboBox; + GroupBox2: TGroupBox; + TextE: TEdit; + SampleL: TLabel; + procedure ExpressionEButtonClick(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure DataSetCBChange(Sender: TObject); + procedure DataBandCBChange(Sender: TObject); + procedure DataFieldCBChange(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FunctionCBChange(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FAggregateOnly: Boolean; + FReport: TfrxReport; + FText: String; + procedure FillDataBandCB; + procedure FillDataFieldCB; + procedure FillDataSetCB; + function CreateAggregate: String; + procedure UpdateSample; + public + property AggregateOnly: Boolean read FAggregateOnly write FAggregateOnly; + property Text: String read FText write FText; + end; + + +implementation + +{$R *.DFM} + +uses frxUtils, frxRes; + + +procedure TfrxSysMemoEditorForm.FormShow(Sender: TObject); +var + s: String; + + procedure HideControls(ar: array of TControl); + var + i: Integer; + begin + for i := 0 to High(ar) do + ar[i].Hide; + end; + +begin + FReport := TfrxCustomDesigner(Owner).Report; + FillDataBandCB; + FillDataSetCB; + + s := FText; + if s <> '' then + SetLength(s, Length(s) - 2); { cut #13#10 } + + if FAggregateOnly then + begin + Caption := frxResources.Get('agAggregate'); + AggregateRB.Checked := True; + HideControls([SysVariableRB, AggregateRB, TextRB, SysVariableCB, TextE, + GroupBox1, GroupBox2]); + AggregatePanel.Top := 4; + OkB.Top := AggregatePanel.Height + 18; + CancelB.Top := OkB.Top; + ClientHeight := CancelB.Top + 33; + end + else if (SysVariableCB.Items.IndexOf(s) <> -1) or (s = '') then + begin + SysVariableRB.Checked := True; + SysVariableCB.Text := s; + end + else + begin + TextRB.Checked := True; + TextE.Text := s; + TextE.SetFocus; + end; + UpdateSample; +end; + +procedure TfrxSysMemoEditorForm.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + begin + if SysVariableRB.Checked then + FText := SysVariableCB.Text + else if AggregateRB.Checked then + FText := '[' + CreateAggregate + ']' + else + FText := TextE.Text + end; +end; + +function TfrxSysMemoEditorForm.CreateAggregate: String; +var + s: String; + i: Integer; +begin + s := FunctionCB.Text; + i := 0; + if CountInvisibleCB.Checked then + i := i or 1; + if RunningTotalCB.Checked then + i := i or 2; + + if s <> 'COUNT' then + begin + s := s + '('; + if ExpressionE.Text <> '' then + s := s + ExpressionE.Text else + s := s + '<' + DataSetCB.Text + '."' + DataFieldCB.Text + '">'; + + if DataBandCB.Text <> '' then + begin + s := s + ',' + DataBandCB.Text; + if i <> 0 then + s := s + ',' + IntToStr(i); + end; + s := s + ')'; + end + else + begin + s := s + '('; + s := s + DataBandCB.Text; + if i <> 0 then + s := s + ',' + IntToStr(i); + s := s + ')'; + end; + + Result := s; +end; + +procedure TfrxSysMemoEditorForm.FillDataBandCB; +var + i: Integer; + c: TfrxComponent; +begin + DataBandCB.Items.Clear; + for i := 0 to FReport.Designer.Objects.Count - 1 do + begin + c := FReport.Designer.Objects[i]; + if c is TfrxDataBand then + DataBandCB.Items.Add(c.Name); + end; +end; + +procedure TfrxSysMemoEditorForm.FillDataSetCB; +begin + FReport.GetDataSetList(DataSetCB.Items); +end; + +procedure TfrxSysMemoEditorForm.FillDataFieldCB; +var + ds: TfrxDataSet; +begin + ds := FReport.GetDataSet(DataSetCB.Text); + if ds <> nil then + ds.GetFieldList(DataFieldCB.Items) else + DataFieldCB.Items.Clear; +end; + +procedure TfrxSysMemoEditorForm.DataBandCBChange(Sender: TObject); +var + b: TfrxDataBand; +begin + b := FReport.Designer.Page.FindObject(DataBandCB.Text) as TfrxDataBand; + if (b <> nil) and (b.DataSet <> nil) and not (b.DataSet is TfrxUserDataSet) then + begin + DataSetCB.Text := FReport.GetAlias(b.DataSet); + DataSetCBChange(nil); + end; +end; + +procedure TfrxSysMemoEditorForm.DataSetCBChange(Sender: TObject); +begin + FillDataFieldCB; + ExpressionE.Text := ''; + UpdateSample; +end; + +procedure TfrxSysMemoEditorForm.DataFieldCBChange(Sender: TObject); +begin + ExpressionE.Text := ''; + UpdateSample; +end; + +procedure TfrxSysMemoEditorForm.ExpressionEButtonClick(Sender: TObject); +var + s: String; +begin + s := TfrxCustomDesigner(Owner).InsertExpression(ExpressionE.Text); + if s <> '' then + ExpressionE.Text := s; + UpdateSample; +end; + +procedure TfrxSysMemoEditorForm.FormCreate(Sender: TObject); +var + i: Integer; +begin + Caption := frxGet(3300); + DataBandL.Caption := frxGet(3301); + DataSetL.Caption := frxGet(3302); + DataFieldL.Caption := frxGet(3303); + FunctionL.Caption := frxGet(3304); + ExpressionL.Caption := frxGet(3305); + OKB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + AggregateRB.Caption := frxGet(3306); + SysVariableRB.Caption := frxGet(3307); + CountInvisibleCB.Caption := frxGet(3308); + TextRB.Caption := frxGet(3309); + RunningTotalCB.Caption := frxGet(3310); + for i := 1 to 6 do + SysVariableCB.Items.Add(frxResources.Get('vt' + IntToStr(i))); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxSysMemoEditorForm.UpdateSample; +begin + if AggregateRB.Checked then + SampleL.Caption := CreateAggregate + else + SampleL.Caption := ''; +end; + +procedure TfrxSysMemoEditorForm.FunctionCBChange(Sender: TObject); +begin + UpdateSample; +end; + +procedure TfrxSysMemoEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditTabOrder.dfm b/official/4.2/LibD11/frxEditTabOrder.dfm new file mode 100644 index 0000000..60ad4e0 Binary files /dev/null and b/official/4.2/LibD11/frxEditTabOrder.dfm differ diff --git a/official/4.2/LibD11/frxEditTabOrder.pas b/official/4.2/LibD11/frxEditTabOrder.pas new file mode 100644 index 0000000..8c1e49e --- /dev/null +++ b/official/4.2/LibD11/frxEditTabOrder.pas @@ -0,0 +1,166 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Tab order editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditTabOrder; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, frxClass; + +type + TfrxTabOrderEditorForm = class(TForm) + OkB: TButton; + CancelB: TButton; + Label1: TLabel; + UpB: TButton; + DownB: TButton; + ControlsLB: TListBox; + procedure FormCreate(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure UpBClick(Sender: TObject); + procedure DownBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FOldOrder: TList; + FParent: TfrxComponent; + procedure UpdateOrder; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + + +implementation + +{$R *.DFM} + +uses frxRes; + + +constructor TfrxTabOrderEditorForm.Create(AOwner: TComponent); +begin + inherited; + FOldOrder := TList.Create; +end; + +destructor TfrxTabOrderEditorForm.Destroy; +begin + FOldOrder.Free; + inherited; +end; + +procedure TfrxTabOrderEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(5400); + Label1.Caption := frxGet(5401); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + UpB.Caption := frxGet(5402); + DownB.Caption := frxGet(5403); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxTabOrderEditorForm.FormShow(Sender: TObject); +var + i: Integer; + l: TList; +begin + if TfrxCustomDesigner(Owner).SelectedObjects.Count = 0 then + FParent := TfrxCustomDesigner(Owner).Page + else + FParent := TfrxCustomDesigner(Owner).SelectedObjects[0]; + l := FParent.Objects; + for i := 0 to l.Count - 1 do + begin + FOldOrder.Add(l[i]); + if (TObject(l[i]) is TfrxDialogControl) and + (TfrxDialogControl(l[i]).Control is TWinControl) then + ControlsLB.Items.AddObject(TfrxDialogControl(l[i]).Name + ': ' + + TfrxDialogControl(l[i]).GetDescription, l[i]); + end; +end; + +procedure TfrxTabOrderEditorForm.FormHide(Sender: TObject); +var + i: Integer; +begin + if ModalResult <> mrOk then + for i := 0 to FOldOrder.Count - 1 do + FParent.Objects[i] := FOldOrder[i]; +end; + +procedure TfrxTabOrderEditorForm.UpdateOrder; +var + i: Integer; + c: TfrxDialogControl; +begin + { TabOrder is self-arranged property, set it to big values to avoid conflicts } + for i := 0 to ControlsLB.Items.Count - 1 do + begin + c := TfrxDialogControl(ControlsLB.Items.Objects[i]); + TWinControl(c.Control).TabOrder := 1000 + i; + end; + { set to normal values } + for i := 0 to ControlsLB.Items.Count - 1 do + begin + c := TfrxDialogControl(ControlsLB.Items.Objects[i]); + TWinControl(c.Control).TabOrder := i; + end; +end; + +procedure TfrxTabOrderEditorForm.UpBClick(Sender: TObject); +var + i: Integer; +begin + i := ControlsLB.ItemIndex; + if (i = -1) or (i = 0) then Exit; + + FParent.Objects.Exchange(FParent.Objects.IndexOf(ControlsLB.Items.Objects[i]), + FParent.Objects.IndexOf(ControlsLB.Items.Objects[i - 1])); + ControlsLB.Items.Exchange(i, i - 1); + ControlsLB.ItemIndex := i - 1; + UpdateOrder; +end; + +procedure TfrxTabOrderEditorForm.DownBClick(Sender: TObject); +var + i: Integer; +begin + i := ControlsLB.ItemIndex; + if (i = -1) or (i = ControlsLB.Items.Count - 1) then Exit; + + FParent.Objects.Exchange(FParent.Objects.IndexOf(ControlsLB.Items.Objects[i]), + FParent.Objects.IndexOf(ControlsLB.Items.Objects[i + 1])); + ControlsLB.Items.Exchange(i, i + 1); + ControlsLB.ItemIndex := i + 1; + UpdateOrder; +end; + +procedure TfrxTabOrderEditorForm.FormKeyDown(Sender: TObject; + var Key: Word; Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEditVar.dfm b/official/4.2/LibD11/frxEditVar.dfm new file mode 100644 index 0000000..ef5da2b Binary files /dev/null and b/official/4.2/LibD11/frxEditVar.dfm differ diff --git a/official/4.2/LibD11/frxEditVar.pas b/official/4.2/LibD11/frxEditVar.pas new file mode 100644 index 0000000..1cae76f --- /dev/null +++ b/official/4.2/LibD11/frxEditVar.pas @@ -0,0 +1,510 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Variables editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEditVar; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ComCtrls, frxClass, ExtCtrls, ImgList, Buttons, frxDock, + ToolWin, frxVariables, frxDataTree +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxVarEditorForm = class(TForm) + VarTree: TTreeView; + ToolBar: TToolBar; + NewCategoryB: TToolButton; + NewVarB: TToolButton; + EditB: TToolButton; + DeleteB: TToolButton; + EditListB: TToolButton; + OkB: TToolButton; + CancelB: TToolButton; + Sep1: TToolButton; + ExprMemo: TMemo; + Splitter1: TSplitter; + Splitter2: TSplitter; + ExprPanel: TPanel; + LoadB: TToolButton; + SaveB: TToolButton; + Sep2: TToolButton; + OpenDialog1: TOpenDialog; + SaveDialog1: TSaveDialog; + Panel: TPanel; + procedure FormShow(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure DeleteBClick(Sender: TObject); + procedure NewCategoryBClick(Sender: TObject); + procedure NewVarBClick(Sender: TObject); + procedure OkBClick(Sender: TObject); + procedure EditBClick(Sender: TObject); + procedure VarTreeEdited(Sender: TObject; Node: TTreeNode; + var S: String); + procedure VarTreeKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure ExprMemoDragOver(Sender, Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); + procedure ExprMemoDragDrop(Sender, Source: TObject; X, Y: Integer); + procedure VarTreeChange(Sender: TObject; Node: TTreeNode); + procedure VarTreeChanging(Sender: TObject; Node: TTreeNode; + var AllowChange: Boolean); + procedure CancelBClick(Sender: TObject); + procedure EditListBClick(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure LoadBClick(Sender: TObject); + procedure SaveBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure Splitter2Moved(Sender: TObject); + private + FReport: TfrxReport; + FUpdating: Boolean; + FVariables: TfrxVariables; + FDataTree: TfrxDataTreeForm; + function Root: TTreeNode; + procedure CreateUniqueName(var s: String); + procedure FillVariables; + procedure UpdateItem0; + procedure OnDataTreeDblClick(Sender: TObject); + public + end; + + +implementation + +{$R *.DFM} + +uses frxEditStrings, frxUtils, frxRes, IniFiles; + +var + lastPosition: TPoint; + +type + THackWinControl = class(TWinControl); + + +procedure SetImageIndex(Node: TTreeNode; Index: Integer); +begin + Node.ImageIndex := Index; + Node.StateIndex := Index; + Node.SelectedIndex := Index; +end; + + +{ TfrxVarEditorForm } + +procedure TfrxVarEditorForm.FormCreate(Sender: TObject); +begin + Icon := TForm(Owner).Icon; + FReport := TfrxCustomDesigner(Owner).Report; + VarTree.Images := frxResources.MainButtonImages; + Toolbar.Images := VarTree.Images; +{$IFDEF UseTabset} + VarTree.BevelKind := bkFlat; + ExprMemo.BevelKind := bkFlat; +{$ELSE} + VarTree.BorderStyle := bsSingle; + ExprMemo.BorderStyle := bsSingle; +{$ENDIF} + + FVariables := TfrxVariables.Create; + FVariables.Assign(FReport.Variables); + + FDataTree := TfrxDataTreeForm.Create(Owner); + FDataTree.Report := FReport; + FDataTree.OnDblClick := OnDataTreeDblClick; + FDataTree.SetControlsParent(Panel); + FDataTree.HintPanel.Height := 64; + FDataTree.UpdateItems; + + Caption := frxGet(2900); + NewCategoryB.Hint := frxGet(2901); + NewVarB.Hint := frxGet(2902); + EditB.Hint := frxGet(2903); + DeleteB.Hint := frxGet(2904); + EditListB.Hint := frxGet(2905); + LoadB.Hint := frxGet(2906); + SaveB.Hint := frxGet(2907); + CancelB.Hint := frxGet(2); + OkB.Hint := frxGet(1); + ExprPanel.Caption := ' ' + frxGet(2908); + OpenDialog1.Filter := frxGet(2909); + SaveDialog1.Filter := frxGet(2910); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxVarEditorForm.FormDestroy(Sender: TObject); +begin + FDataTree.Free; + FVariables.Free; +end; + +procedure TfrxVarEditorForm.FormShow(Sender: TObject); +var + Ini: TCustomIniFile; +begin + Ini := FReport.GetIniFile; + Ini.WriteBool('Form4.TfrxVarEditorForm', 'Visible', True); + frxRestoreFormPosition(Ini, Self); + ExprMemo.Height := Ini.ReadInteger('Form4.TfrxVarEditorForm', 'Split1Pos', 76); + Panel.Width := Ini.ReadInteger('Form4.TfrxVarEditorForm', 'Split2Pos', 400); + FDataTree.UpdateSize; + Ini.Free; + + FillVariables; + VarTree.SetFocus; + FDataTree.SetLastPosition(lastPosition); +end; + +procedure TfrxVarEditorForm.FormHide(Sender: TObject); +var + Ini: TCustomIniFile; +begin + Ini := FReport.GetIniFile; + frxSaveFormPosition(Ini, Self); + Ini.WriteInteger('Form4.TfrxVarEditorForm', 'Split1Pos', ExprMemo.Height); + Ini.WriteInteger('Form4.TfrxVarEditorForm', 'Split2Pos', Panel.Width); + Ini.Free; + lastPosition := FDataTree.GetLastPosition; +end; + +procedure TfrxVarEditorForm.OkBClick(Sender: TObject); +begin + ModalResult := mrOk; + VarTree.Selected := VarTree.Items[0]; + FReport.Variables.Assign(FVariables); +end; + +procedure TfrxVarEditorForm.CancelBClick(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +function TfrxVarEditorForm.Root: TTreeNode; +begin + Result := VarTree.Items[0]; +end; + +procedure TfrxVarEditorForm.UpdateItem0; +begin + if Root.Count = 0 then + Root.Text := frxResources.Get('vaNoVar') else + Root.Text := frxResources.Get('vaVar'); +end; + +procedure TfrxVarEditorForm.CreateUniqueName(var s: String); +var + i: Integer; +begin + i := 0; + repeat + Inc(i); + until FVariables.IndexOf(s + IntToStr(i)) = -1; + s := s + IntToStr(i); +end; + +procedure TfrxVarEditorForm.FillVariables; +var + i: Integer; + CategoriesList, VariablesList: TStrings; + Node: TTreeNode; + + procedure AddVariables(Node: TTreeNode); + var + i: Integer; + Node1: TTreeNode; + begin + for i := 0 to VariablesList.Count - 1 do + begin + Node1 := VarTree.Items.AddChild(Node, VariablesList[i]); + SetImageIndex(Node1, 80); + end; + end; + +begin + FUpdating := True; + CategoriesList := TStringList.Create; + VariablesList := TStringList.Create; + FVariables.GetCategoriesList(CategoriesList); + + VarTree.Items.BeginUpdate; + VarTree.Items.Clear; + VarTree.Items.AddChild(nil, ''); + SetImageIndex(Root, 66); + + for i := 0 to CategoriesList.Count - 1 do + begin + FVariables.GetVariablesList(CategoriesList[i], VariablesList); + Node := VarTree.Items.AddChild(Root, CategoriesList[i]); + SetImageIndex(Node, 66); + AddVariables(Node); + end; + + if CategoriesList.Count = 0 then + begin + FVariables.GetVariablesList('', VariablesList); + AddVariables(Root); + end; + + UpdateItem0; + VarTree.FullExpand; + VarTree.TopItem := Root; + VarTree.Items.EndUpdate; + CategoriesList.Free; + VariablesList.Free; + FUpdating := False; +end; + +procedure TfrxVarEditorForm.DeleteBClick(Sender: TObject); +var + Node: TTreeNode; +begin + Node := VarTree.Selected; + if (Node = nil) or (Node = Root) then Exit; + + if Node.Parent <> Root then + FVariables.DeleteVariable(Node.Text) else + FVariables.DeleteCategory(Node.Text); + Node.Free; + UpdateItem0; +end; + +procedure TfrxVarEditorForm.NewCategoryBClick(Sender: TObject); +var + Node: TTreeNode; + s: String; +begin + s := ' New Category'; + CreateUniqueName(s); + Node := VarTree.Items.AddChild(Root, Trim(s)); + SetImageIndex(Node, 66); + FVariables.Add.Name := s; + VarTree.FullExpand; + UpdateItem0; +end; + +procedure TfrxVarEditorForm.NewVarBClick(Sender: TObject); +var + Node: TTreeNode; + s: String; +begin + if Root.Count = 0 then Exit; + Node := VarTree.Selected; + if (Node = nil) or (Node = Root) then + Node := VarTree.Items[0][Root.Count - 1] + else if Node.Parent <> Root then + Node := Node.Parent; + + s := 'New Variable'; + CreateUniqueName(s); + FVariables.AddVariable(Node.Text, s, ''); + + Node := VarTree.Items.AddChild(Node, s); + SetImageIndex(Node, 80); + + VarTree.FullExpand; + UpdateItem0; +end; + +procedure TfrxVarEditorForm.EditBClick(Sender: TObject); +var + Node: TTreeNode; +begin + Node := VarTree.Selected; + if (Node = nil) or (Node = Root) then Exit; + + Node.EditText; +end; + +procedure TfrxVarEditorForm.VarTreeEdited(Sender: TObject; Node: TTreeNode; + var S: String); +var + s1, s2: String; +begin + if (Node.Text = s) or (Root.Count = 0) then Exit; + + s1 := s; + s2 := Node.Text; + + if Node.Parent = Root then + begin + s1 := ' ' + s1; + s2 := ' ' + s2; + end; + + if FVariables.IndexOf(s1) <> -1 then + begin + s := Node.Text; + frxErrorMsg(frxResources.Get('vaDupName')); + end + else + FVariables.Items[FVariables.IndexOf(s2)].Name := s1; +end; + +procedure TfrxVarEditorForm.VarTreeKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + case Key of + vk_Insert: + if not VarTree.IsEditing then + if Root.Count = 0 then + NewCategoryBClick(nil) else + NewVarBClick(nil); + vk_Delete: + if not VarTree.IsEditing then + DeleteBClick(nil); + vk_Return, vk_F2: + if not VarTree.IsEditing then + EditBClick(nil); + end; +end; + +procedure TfrxVarEditorForm.ExprMemoDragOver(Sender, Source: TObject; X, + Y: Integer; State: TDragState; var Accept: Boolean); +begin + Accept := (Source is TTreeView) and (TControl(Source).Owner = FDataTree) and + (FDataTree.GetFieldName <> ''); +end; + +procedure TfrxVarEditorForm.ExprMemoDragDrop(Sender, Source: TObject; X, + Y: Integer); +begin + ExprMemo.SelText := FDataTree.GetFieldName; +end; + +procedure TfrxVarEditorForm.OnDataTreeDblClick(Sender: TObject); +begin + ExprMemo.SelText := FDataTree.GetFieldName; +end; + +procedure TfrxVarEditorForm.VarTreeChange(Sender: TObject; Node: TTreeNode); +begin + if FUpdating then Exit; + + if (Node = nil) or (Node = Root) or (Node.Parent = Root) then + ExprMemo.Text := '' else + ExprMemo.Text := VarToStr(FVariables[Node.Text]); + ExprMemo.Modified := False; +end; + +procedure TfrxVarEditorForm.VarTreeChanging(Sender: TObject; + Node: TTreeNode; var AllowChange: Boolean); +begin + if FUpdating then Exit; + Node := VarTree.Selected; + + if ExprMemo.Modified then + if not ((Node = nil) or (Node = Root) or (Node.Parent = Root)) then + FVariables[Node.Text] := ExprMemo.Text; +end; + +procedure TfrxVarEditorForm.EditListBClick(Sender: TObject); + + procedure VarToStrings(Lines: TStrings); + var + i: Integer; + s: String; + begin + for i := 0 to FVariables.Count - 1 do + begin + s := FVariables.Items[i].Name; + if s <> '' then + if s[1] = ' ' then + s := Copy(s, 2, 255) else + s := ' ' + s; + Lines.Add(s); + end; + end; + + procedure StringsToVar(Lines: TStrings); + var + i: Integer; + v: TfrxVariables; + s: String; + begin + v := TfrxVariables.Create; + for i := 0 to Lines.Count - 1 do + begin + s := Lines[i]; + if Trim(s) <> '' then + begin + if s[1] = ' ' then + s := Copy(s, 2, 255) else + s := ' ' + s; + if FVariables.IndexOf(s) <> -1 then + v[s] := FVariables[s] else + v[s] := ''; + end; + end; + + FVariables.Assign(v); + FillVariables; + v.Free; + end; + +begin + with TfrxStringsEditorForm.Create(Owner) do + begin + VarToStrings(Memo.Lines); + if ShowModal = mrOk then + StringsToVar(Memo.Lines); + VarTree.Items[0].Selected := True; + Free; + end; +end; + +procedure TfrxVarEditorForm.LoadBClick(Sender: TObject); +begin + if OpenDialog1.Execute then + begin + FVariables.LoadFromFile(OpenDialog1.FileName); + FillVariables; + end; +end; + +procedure TfrxVarEditorForm.SaveBClick(Sender: TObject); +begin + VarTree.Selected := VarTree.Items[0]; + if SaveDialog1.Execute then + FVariables.SaveToFile(SaveDialog1.FileName); +end; + +procedure TfrxVarEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if (Shift = [ssCtrl]) and (Key = vk_Return) then + OkBClick(nil); + if Key = VK_ESCAPE then + CancelBClick(nil); + if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxVarEditorForm.Splitter2Moved(Sender: TObject); +begin + FDataTree.UpdateSize; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEngine.pas b/official/4.2/LibD11/frxEngine.pas new file mode 100644 index 0000000..3752d04 --- /dev/null +++ b/official/4.2/LibD11/frxEngine.pas @@ -0,0 +1,2561 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report engine } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEngine; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs, + frxClass, frxAggregate, frxXML, frxDMPClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + { TfrxHeaderList holds a set of bands that should appear on each new page. + This includes page header, column header and header bands with + "Reprint on new page" setting } + + TfrxHeaderListItem = class(TObject) + public + Band: TfrxBand; + Left: Extended; + IsInKeepList: Boolean; + end; + + TfrxHeaderList = class(TObject) + private + FList: TList; + function GetCount: Integer; + function GetItems(Index: Integer): TfrxHeaderListItem; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + procedure AddItem(ABand: TfrxBand; ALeft: Extended; AInKeepList: Boolean); + procedure RemoveItem(ABand: TfrxBand); + property Count: Integer read GetCount; + property Items[Index: Integer]: TfrxHeaderListItem read GetItems; default; + end; + + TfrxEngine = class(TfrxCustomEngine) + private + FAggregates: TfrxAggregateList; + FCallFromAddPage: Boolean; + FCallFromEndPage: Boolean; + FCurBand: TfrxBand; + FDontShowHeaders: Boolean; + FHeaderList: TfrxHeaderList; { list of header bands } + FFirstReportPage: Boolean; { needed for correct setting of PreviewPages.FirstPage } + FFirstColumnY: Extended; { position of the first column } + FIsFirstBand: Boolean; { needed for KeepTogether } + FIsFirstPage: Boolean; { first and last page flags } + FIsLastPage: Boolean; { } + FKeepBand: TfrxBand; + FKeepFooter: Boolean; + FKeeping: Boolean; + FKeepOutline: TfrxXMLItem; + FKeepPosition: Integer; + FKeepAnchor: Integer; + FOutputTo: TfrxNullBand; { used in the subreports } + FPage: TfrxReportPage; { currently proceeded page } + FPageCurX: Extended; + FStartNewPageBand: TfrxBand; { needed in addpage } + FVHeaderList: TList; { list of vheader bands } + FVMasterBand: TfrxBand; { master hband for vbands } + FVPageList: TList; { list of page breaks for vbands } + procedure AddBandOutline(Band: TfrxBand); + procedure AddColumn; + procedure AddPage; + procedure AddPageOutline; + procedure AddToHeaderList(Band: TfrxBand); + procedure AddToVHeaderList(Band: TfrxBand); + procedure CheckBandColumns(Band: TfrxDataBand; ColumnKeepPos: Integer; + SaveCurY: Extended); + procedure CheckDrill(Master: TfrxDataBand; Band: TfrxGroupHeader); + procedure CheckGroups(Master: TfrxDataBand; Band: TfrxGroupHeader; + ColumnKeepPos: Integer; SaveCurY: Extended); + procedure CheckSubReports(Band: TfrxBand); + procedure CheckSuppress(Band: TfrxBand); + procedure DoShow(Band: TfrxBand); + procedure DrawSplit(Band: TfrxBand); + procedure EndColumn; + procedure EndKeep(Band: TfrxBand); + procedure Finalize; + procedure InitGroups(Master: TfrxDataBand; Band: TfrxGroupHeader; + Index: Integer; ResetLineN: Boolean = False); + procedure InitPage; + procedure NotifyObjects(Band: TfrxBand); + procedure OutlineRoot; + procedure OutlineUp(Band: TfrxBand); + procedure PreparePage(ErrorList: TStrings; PrepareVBands: Boolean); + procedure PrepareShiftTree(Band: TfrxBand); + procedure RemoveFromHeaderList(Band: TfrxBand); + procedure RemoveFromVHeaderList(Band: TfrxBand); + procedure ResetSuppressValues(Band: TfrxBand); + procedure RunPage(Page: TfrxReportPage); + procedure RunReportPages; + procedure ShowGroupFooters(Band: TfrxGroupHeader; Index: Integer; Master: TfrxDataBand); + procedure ShowVBands(HBand: TfrxBand); + procedure StartKeep(Band: TfrxBand; Position: Integer = 0); + procedure Stretch(Band: TfrxBand); + procedure UnStretch(Band: TfrxBand); + function CanShow(Obj: TObject; PrintIfDetailEmpty: Boolean): Boolean; + function FindBand(Band: TfrxBandClass): TfrxBand; + function Initialize: Boolean; + function RunDialogs: Boolean; + protected + public + constructor Create(AReport: TfrxReport); override; + destructor Destroy; override; + procedure EndPage; override; + procedure NewColumn; override; + procedure NewPage; override; + function Run: Boolean; override; + procedure ShowBand(Band: TfrxBand); overload; override; + procedure ShowBand(Band: TfrxBandClass); overload; override; + function HeaderHeight: Extended; override; + function FooterHeight: Extended; override; + function FreeSpace: Extended; override; + function GetAggregateValue(const Name, Expression: String; + Band: TfrxBand; Flags: Integer): Variant; override; + end; + + +implementation + +uses frxUtils, frxPreviewPages, frxRes; + +type + THackComponent = class(TfrxComponent); + THackMemoView = class(TfrxCustomMemoView); + + +{ TfrxHeaderList } + +constructor TfrxHeaderList.Create; +begin + FList := TList.Create; +end; + +destructor TfrxHeaderList.Destroy; +begin + Clear; + FList.Free; + inherited; +end; + +procedure TfrxHeaderList.Clear; +begin + while FList.Count > 0 do + begin + TObject(FList[0]).Free; + FList.Delete(0); + end; +end; + +function TfrxHeaderList.GetCount: Integer; +begin + Result := FList.Count; +end; + +function TfrxHeaderList.GetItems(Index: Integer): TfrxHeaderListItem; +begin + Result := FList[Index]; +end; + +procedure TfrxHeaderList.AddItem(ABand: TfrxBand; ALeft: Extended; AInKeepList: Boolean); +var + Item: TfrxHeaderListItem; +begin + Item := TfrxHeaderListItem.Create; + Item.Band := ABand; + Item.Left := ALeft; + Item.IsInKeepList := AInKeepList; + FList.Add(Item); +end; + +procedure TfrxHeaderList.RemoveItem(ABand: TfrxBand); +var + i: Integer; +begin + for i := 0 to Count - 1 do + if Items[i].Band = ABand then + begin + Items[i].Free; + FList.Delete(i); + break; + end; +end; + + +{ TfrxEngine } + +constructor TfrxEngine.Create(AReport: TfrxReport); +begin + inherited; + FHeaderList := TfrxHeaderList.Create; + FVHeaderList := TList.Create; + FVPageList := TList.Create; + FAggregates := TfrxAggregateList.Create(AReport); +end; + +destructor TfrxEngine.Destroy; +begin + FHeaderList.Free; + FVHeaderList.Free; + FVPageList.Free; + FAggregates.Free; + inherited; +end; + +function TfrxEngine.Initialize: Boolean; +var + i, j: Integer; + b: TfrxDataBand; +begin + PreviewPages.Initialize; + StartDate := Date; + StartTime := Time; + Running := True; + FKeeping := False; + CurVColumn := 0; + FOutputTo := nil; + + { clear all aggregate items } + FAggregates.Clear; + + { add all report pages to the PreviewPages } + for i := 0 to Report.PagesCount - 1 do + if Report.Pages[i] is TfrxReportPage then + begin + { set the current page } + FPage := TfrxReportPage(Report.Pages[i]); + { create band tree for the current page } + PreparePage(Report.Errors, False); + PreparePage(Report.Errors, True); + end; + + { check datasets used } + for i := 0 to Report.PagesCount - 1 do + if Report.Pages[i] is TfrxReportPage then + begin + FPage := TfrxReportPage(Report.Pages[i]); + if (Report.DataSet <> nil) and (Report.DataSet = FPage.DataSet) then + begin + Report.Errors.Add('Cannot use the same dataset for Report.DataSet and Page.DataSet'); + break; + end; + for j := 0 to FPage.FSubBands.Count - 1 do + begin + b := FPage.FSubBands[j]; + if (b <> nil) and (b.DataSet <> nil) then + if Report.DataSet = b.DataSet then + begin + Report.Errors.Add('Cannot use the same dataset for Report.DataSet and Band.DataSet'); + break; + end + else if FPage.DataSet = b.DataSet then + begin + Report.Errors.Add('Cannot use the same dataset for Page.DataSet and Band.DataSet'); + break; + end + end; + end; + + Result := Report.Errors.Count = 0; +end; + +procedure TfrxEngine.Finalize; +begin + try + Report.DataSets.Finalize; + finally + PreviewPages.Finish; + Running := False; + end; +end; + +function TfrxEngine.Run: Boolean; +var + i: Integer; +begin + Result := False; + try + if Initialize then + try + Report.DataSets.Initialize; + Report.DoNotifyEvent(Report, Report.OnStartReport); + if RunDialogs then + begin + Result := True; + + { add all report pages to the PreviewPages } + for i := 0 to Report.PagesCount - 1 do + if Report.Pages[i] is TfrxReportPage then + begin + FPage := TfrxReportPage(Report.Pages[i]); + PreviewPages.AddSourcePage(FPage); + { find aggregates } + FAggregates.AddItems(FPage); + end; + + { start the report } + FinalPass := not DoublePass; + TotalPages := 0; + PreviewPages.BeginPass; + RunReportPages; + if DoublePass then + begin + TotalPages := PreviewPages.Count; + PreviewPages.ClearFirstPassPages; + FAggregates.ClearValues; + FinalPass := True; + RunReportPages; + end; + end + finally + Report.DoNotifyEvent(Report, Report.OnStopReport); + end; + finally + Finalize; + end; +end; + +{$HINTS OFF} +function TfrxEngine.RunDialogs: Boolean; +var + i: Integer; + p: TfrxDialogPage; + v: Variant; +begin + Result := True; +{$IFNDEF FR_VER_BASIC} + if Trim(Report.OnRunDialogs) <> '' then + begin + v := VarArrayOf([True]); + Report.DoParamEvent(Report.OnRunDialogs, v); + Result := v[0]; + end + else + for i := 0 to Report.PagesCount - 1 do + if (Report.Pages[i] is TfrxDialogPage) and Report.Pages[i].Visible then + begin + p := TfrxDialogPage(Report.Pages[i]); + { refresh the border style - it was bsSizeable in the designer } + p.DialogForm.BorderStyle := p.BorderStyle; + { don't show empty form } + if p.DialogForm.ControlCount <> 0 then + begin + if Assigned(OnRunDialog) then + OnRunDialog(p) else + p.ShowModal; + if p.ModalResult = mrCancel then + begin + Result := False; + break; + end; + end; + end; +{$ENDIF} +end; +{$HINTS ON} + +procedure TfrxEngine.RunReportPages; + + procedure DoPages; + var + i: Integer; + begin + for i := 0 to Report.PagesCount - 1 do + if Report.Pages[i] is TfrxReportPage then + begin + FPage := TfrxReportPage(Report.Pages[i]); + { ignore subreport pages and invisible pages } + if not FPage.IsSubReport and FPage.Visible then + RunPage(FPage); + if Report.Terminated then break; + FFirstReportPage := False; + end; + end; + +begin + FFirstReportPage := True; + if Report.DataSet = nil then + DoPages + else + begin + Report.DataSet.First; + while not Report.DataSet.Eof do + begin + if Report.Terminated then break; + DoPages; + Report.DataSet.Next; + end; + end; +end; + +procedure TfrxEngine.PreparePage(ErrorList: TStrings; PrepareVBands: Boolean); +var + i, j, k: Integer; + t, c: TfrxComponent; + b: TfrxBand; + Bands: TList; + SortBands: TStringList; + + procedure ClearNils; + var + i: Integer; + begin + i := 0; + while i < Bands.Count do + if Bands[i] = nil then + Bands.Delete(i) else + Inc(i); + end; + + procedure MakeTree(Obj: TObject; From: Integer); + var + i: Integer; + b: TfrxBand; + begin + if Obj is TfrxReportPage then + begin + { fill the first level - TfrxReportPage.FMasterBands } + for i := 0 to Bands.Count - 1 do + begin + b := Bands[i]; + if b = nil then continue; + if b is TfrxMasterData then + begin + if TfrxDataBand(b).DataSet <> nil then { ignore empty datasets } + if PrepareVBands then + TfrxReportPage(Obj).FVSubBands.Add(b) + else + TfrxReportPage(Obj).FSubBands.Add(b); + Bands[i] := nil; + MakeTree(b, i + 1); + end; + end; + end + else + begin + { fill next levels - TfrxBand.FSubBands } + for i := From to Bands.Count - 1 do + begin + b := Bands[i]; + if b = nil then continue; + { looking for sub-level bands } + if b.BandNumber = TfrxBand(Obj).BandNumber + 1 then + begin + if TfrxDataBand(b).DataSet <> nil then { ignore empty datasets } + TfrxBand(Obj).FSubBands.Add(b); + Bands[i] := nil; + if not (b is TfrxDataBand6) then + MakeTree(b, i + 1); + end + else if b.BandNumber <= TfrxBand(Obj).BandNumber then + break; { found higher-level data band } + end; + end; + end; + + procedure ConnectHeaders; + var + i: Integer; + b1, b2: TfrxBand; + begin + for i := 0 to Bands.Count - 1 do + begin + b1 := Bands[i]; + { looking for data band } + if b1 is TfrxDataBand then + begin + if i > 0 then + begin + b2 := Bands[i - 1]; + if b2 is TfrxHeader then { if top band is header, connect it } + begin + b1.FHeader := b2; + Bands[i - 1] := nil; + end; + end; + + if i < Bands.Count - 1 then { if bottom band is footer, connect it } + begin + b2 := Bands[i + 1]; + if b2 is TfrxFooter then + begin + b1.FFooter := b2; + Bands[i + 1] := nil; + end; + end; + end; + end; + + ClearNils; + { now all headers/footers must be connected. If not, add an error } + for i := 0 to Bands.Count - 1 do + begin + b1 := Bands[i]; + if (b1 is TfrxHeader) or (b1 is TfrxFooter) then + begin + ErrorList.Add(frxResources.Get('enUnconnHeader') + ' ' + b1.Name); + Bands[i] := nil; + end; + end; + + ClearNils; + end; + + procedure ConnectGroups; + var + i, j: Integer; + b1, b2: TfrxBand; + begin + { connect group headers } + i := 0; + while i < Bands.Count do + begin + b1 := Bands[i]; + if b1 is TfrxGroupHeader then + begin + b1.FSubBands.Add(b1); + Inc(i); + { add all subsequent headers to the first header's FSubBands } + while (i < Bands.Count) and (TfrxBand(Bands[i]) is TfrxGroupHeader) do + begin + b1.FSubBands.Add(Bands[i]); + Inc(i); + end; + + { search for databand } + while (i < Bands.Count) and not (TfrxBand(Bands[i]) is TfrxDataBand) do + Inc(i); + + { now we expect to see the databand } + if (i = Bands.Count) or not (TObject(Bands[i]) is TfrxDataBand) then + ErrorList.Add(frxResources.Get('enUnconnGroup') + ' ' + b1.Name) + else + TfrxBand(Bands[i]).FGroup := b1; + end + else + Inc(i); + end; + + { connect group footers } + for i := 0 to Bands.Count - 1 do + begin + b1 := Bands[i]; + if b1 is TfrxGroupFooter then + for j := i - 1 downto 0 do + begin + b2 := Bands[j]; + if b2 is TfrxGroupHeader then { connect to top-nearest header } + begin + b2.FFooter := b1; + Bands[i] := nil; + Bands[j] := nil; + break; + end; + end; + end; + + { remove header bands from the list } + for i := 0 to Bands.Count - 1 do + begin + b1 := Bands[i]; + if b1 is TfrxGroupHeader then + Bands[i] := nil; + end; + + { looking for footers w/o corresponding header } + for i := 0 to Bands.Count - 1 do + begin + b1 := Bands[i]; + if b1 is TfrxGroupFooter then + begin + ErrorList.Add(frxResources.Get('enUnconnGFooter') + ' ' + b1.Name); + Bands[i] := nil; + end; + end; + + ClearNils; + end; + +begin + SortBands := TStringList.Create; + SortBands.Sorted := True; + + { align all objects with Align property <> baNone } + FPage.AlignChildren; + + { clear all page SubBands } + if PrepareVBands then + FPage.FVSubBands.Clear + else + FPage.FSubBands.Clear; + + for i := 0 to FPage.Objects.Count - 1 do + begin + t := FPage.Objects[i]; + if t is TfrxBand then + begin + b := TfrxBand(t); + if b.Vertical <> PrepareVBands then + continue; + PrepareShiftTree(b); + b.FSubBands.Clear; + b.FHeader := nil; + b.FFooter := nil; + b.FGroup := nil; + b.FHasVBands := False; + if b is TfrxDataBand then + if (TfrxDataBand(b).DataSet = nil) and (TfrxDataBand(b).RowCount > 0) then + begin + TfrxDataBand(b).DataSet := TfrxDataBand(b).VirtualDataSet; + TfrxDataBand(b).DataSet.Initialize; + end; + + { connect objects to vertical bands } + if (not PrepareVBands) and not (b is TfrxOverlay) then + for j := 0 to FPage.Objects.Count - 1 do + begin + t := FPage.Objects[j]; + if (t is TfrxBand) and TfrxBand(t).Vertical then + begin + k := 0; + while k < b.Objects.Count do + begin + c := b.Objects[k]; + if (c.Left >= t.Left - 1e-4) and + (c.Left + c.Width <= t.Left + t.Width + 1e-4) then + begin + b.FHasVBands := True; + c.Parent := t; + THackComponent(c).FOriginalBand := b; + c.Left := c.Left - t.Left; + end + else + Inc(k); + end; + end; + end; + end; + end; + + { sort bands by position } + for i := 0 to FPage.Objects.Count - 1 do + begin + t := FPage.Objects[i]; + if t is TfrxBand then + begin + b := TfrxBand(t); + if b.Vertical <> PrepareVBands then + continue; + if b.BandNumber in [4..13] then + if b.Vertical then + SortBands.AddObject(Format('%9.2f', [b.Left]), b) + else + SortBands.AddObject(Format('%9.2f', [b.Top]), b); + end; + end; + + { copy sorted items to TList - it's easier to work with it } + Bands := TList.Create; + for i := 0 to SortBands.Count - 1 do + begin + t := TfrxComponent(SortBands.Objects[i]); + Bands.Add(t); + end; + + SortBands.Free; + + ConnectGroups; + ConnectHeaders; + MakeTree(FPage, 0); + + ClearNils; + for i := 0 to Bands.Count - 1 do + begin + t := Bands[i]; + ErrorList.Add(frxResources.Get('enBandPos') + ' ' + t.Name); + end; + + Bands.Free; +end; + +procedure TfrxEngine.PrepareShiftTree(Band: TfrxBand); +var + i, j, k: Integer; + c0, c1, c2, top: TfrxReportComponent; + allObjects: TStringList; + Found: Boolean; + area0, area1, area2, area01: TfrxRectArea; +begin + if Band.FShiftChildren.Count <> 0 then + Exit; + + allObjects := TStringList.Create; + allObjects.Duplicates := dupAccept; + + { temporary top object } + top := TfrxMemoView.Create(nil); + top.SetBounds(0, Band.Top-2, Band.Width, 1); + + { sort objects } + for i := 0 to Band.Objects.Count - 1 do + begin + c0 := Band.Objects[i]; + allObjects.AddObject(Format('%9.2f', [c0.Top]), c0); + c0.FShiftChildren.Clear; + end; + allObjects.Sort; + allObjects.InsertObject(0, Format('%10.2f', [top.Top]), top); + + for i := 0 to allObjects.Count - 1 do + begin + c0 := TfrxReportComponent(allObjects.Objects[i]); + area0 := TfrxRectArea.Create(c0); + + { find an object under c0 } + for j := i + 1 to allObjects.Count - 1 do + begin + c1 := TfrxReportComponent(allObjects.Objects[j]); + area1 := TfrxRectArea.Create(c1); + + if not (area0.InterceptsY(area1)) and (area0.Y < area1.Y) and + area0.InterceptsX(area1) then + begin + area01 := area0.InterceptX(area1); + Found := False; + + { check if there is no other objects between c1 and c0 } + for k := j - 1 downto i + 1 do + begin + c2 := TfrxReportComponent(allObjects.Objects[k]); + area2 := TfrxRectArea.Create(c2); + + if not (area0.InterceptsY(area2)) and not (area1.InterceptsY(area2)) and + area01.InterceptsX(area2) then + Found := True; + + area2.Free; + if Found then + break; + end; + + if not Found then + c0.FShiftChildren.Add(c1); + + area01.Free; + end; + + area1.Free; + end; + + area0.Free; + end; + + { copy children from the top object to the band } + Band.FShiftChildren.Clear; + for i := 0 to top.FShiftChildren.Count - 1 do + Band.FShiftChildren.Add(top.FShiftChildren[i]); + + allObjects.Free; + top.Free; +end; + +function TfrxEngine.CanShow(Obj: TObject; PrintIfDetailEmpty: Boolean): Boolean; +var + i: Integer; + Bands: TList; + b: TfrxDataBand; + res: Boolean; +begin + if Obj is TfrxReportPage then + Bands := TfrxReportPage(Obj).FSubBands else + Bands := TfrxBand(Obj).FSubBands; + + Result := True; + { Check all subdetail bands to ensure they all have records } + if not PrintIfDetailEmpty then + begin + Result := False; + if (Bands.Count = 0) and not (Obj is TfrxPage) then + Result := True; + + for i := 0 to Bands.Count - 1 do + begin + b := Bands[i]; + if b.DataSet <> nil then + begin + Report.DoNotifyEvent(b, b.OnMasterDetail); + b.DataSet.First; + + while not b.DataSet.Eof do + begin + res := CanShow(b, b.PrintIfDetailEmpty); + if res then + begin + Result := True; + break; + end + else + b.DataSet.Next; + end; + end; + end; + end; +end; + +procedure TfrxEngine.ResetSuppressValues(Band: TfrxBand); +var + i: Integer; +begin + for i := 0 to Band.Objects.Count - 1 do + if TObject(Band.Objects[i]) is TfrxCustomMemoView then + THackMemoView(Band.Objects[i]).FLastValue := Null; +end; + +procedure TfrxEngine.InitGroups(Master: TfrxDataBand; Band: TfrxGroupHeader; + Index: Integer; ResetLineN: Boolean = False); +var + i: Integer; + b: TfrxGroupHeader; +begin + for i := Index to Band.FSubBands.Count - 1 do + begin + b := Band.FSubBands[i]; + if ResetLineN then + begin + b.FLineN := 1; + b.FLineThrough := 1; + ResetSuppressValues(b); + end + else + begin + Inc(b.FLineN); + if i < Band.FSubBands.Count - 1 then + TfrxBand(Band.FSubBands[i + 1]).FLineN := 0; + Inc(b.FLineThrough); + end; + end; + + CheckDrill(Master, Band); + + for i := Index to Band.FSubBands.Count - 1 do + begin + b := Band.FSubBands[i]; + CurLine := b.FLineN; + CurLineThrough := b.FLineThrough; + Report.CurObject := b.Name; + b.FLastValue := Report.Calc(b.Condition); + if b.KeepTogether then + StartKeep(b); + ShowBand(b); + AddBandOutline(b); + if b.Vertical then + AddToVHeaderList(b) + else + AddToHeaderList(b); + end; +end; + +procedure TfrxEngine.ShowGroupFooters(Band: TfrxGroupHeader; Index: Integer; + Master: TfrxDataBand); +var + i: Integer; + b: TfrxGroupHeader; +begin + for i := Band.FSubBands.Count - 1 downto Index do + begin + b := Band.FSubBands[i]; + if b.FFooter <> nil then + if not TfrxGroupFooter(b.FFooter).HideIfSingleDataRecord or (Master.FLineN > 2) then + ShowBand(b.FFooter) + else + FAggregates.Reset(b.FFooter); + + OutlineUp(b); + if b.Vertical then + RemoveFromVHeaderList(b) + else + RemoveFromHeaderList(b); + if b.KeepTogether then + EndKeep(b); + end; +end; + +procedure TfrxEngine.CheckDrill(Master: TfrxDataBand; Band: TfrxGroupHeader); +var + i, j: Integer; + b, b1: TfrxGroupHeader; + drillName: String; + drillVisible: Boolean; +begin + for i := 0 to Band.FSubBands.Count - 1 do + begin + b := Band.FSubBands[i]; + if b.DrillDown then + begin + drillName := b.Name + '.' + IntToStr(b.FLineThrough); + drillVisible := Report.DrillState.IndexOf(drillName) <> -1; + if b.ExpandDrillDown then + drillVisible := not DrillVisible; + for j := i + 1 to Band.FSubBands.Count - 1 do + begin + b1 := Band.FSubBands[j]; + b1.Visible := drillVisible; + if b1.FFooter <> nil then + b1.FFooter.Visible := drillVisible; + end; + Master.Visible := drillVisible; + if not b.ShowFooterIfDrillDown and (b.FFooter <> nil) then + b.FFooter.Visible := drillVisible; + if not drillVisible then + break; + end; + end; +end; + +procedure TfrxEngine.CheckGroups(Master: TfrxDataBand; Band: TfrxGroupHeader; + ColumnKeepPos: Integer; SaveCurY: Extended); +var + i: Integer; + b: TfrxGroupHeader; + NextNeeded: Boolean; +begin + CheckDrill(Master, Band); + + for i := 0 to Band.FSubBands.Count - 1 do + begin + b := Band.FSubBands[i]; + + Report.CurObject := b.Name; + if Report.Calc(b.Condition) <> b.FLastValue then + begin + Master.CurColumn := Master.Columns; + CheckBandColumns(Master, ColumnKeepPos, SaveCurY); + + { avoid exception in uni-directional datasets } + NextNeeded := True; + try + Master.DataSet.Prior; + except + NextNeeded := False; + end; + ShowGroupFooters(Band, i, Master); + if NextNeeded then + Master.DataSet.Next; + + InitGroups(Master, Band, i); + Master.FLineN := 1; + ResetSuppressValues(Master); + break; + end; + end; +end; + +procedure TfrxEngine.CheckBandColumns(Band: TfrxDataBand; ColumnKeepPos: Integer; + SaveCurY: Extended); +begin + if Band.Columns > 1 then + begin + { collect max position in b.FMaxY } + if CurY > Band.FMaxY then + Band.FMaxY := CurY; + { all columns have been printed } + if Band.CurColumn >= Band.Columns then + begin + { need page break } + if Band.FMaxY > PageHeight - FooterHeight then + begin + if FKeeping then { standard keep procedure } + NewColumn + else + begin + PreviewPages.CutObjects(ColumnKeepPos); + NewColumn; + PreviewPages.PasteObjects(CurX, CurY); + CurY := CurY + Band.FMaxY - SaveCurY; + end; + end + else + CurY := Band.FMaxY; { start the new band from saved b.FMaxY } + end + else + CurY := SaveCurY; { start the new band from saved SaveCurY } + if Band.Visible then + Band.CurColumn := Band.CurColumn + 1; + end; +end; + +procedure TfrxEngine.NotifyObjects(Band: TfrxBand); +var + i: Integer; + c: TfrxComponent; +begin + for i := 0 to NotifyList.Count - 1 do + begin + c := NotifyList[i]; + if c <> nil then + c.OnNotify(Band); + end; +end; + +procedure TfrxEngine.RunPage(Page: TfrxReportPage); + + { "Null" band contains all free-placed objects that don't have a parent band } + procedure ShowNullBand; + var + i: Integer; + b: TfrxNullBand; + SaveCurY: Extended; + begin + b := TfrxNullBand.Create(nil); + b.Width := PageWidth; + b.Height := PageHeight; + SaveCurY := CurY; + for i := 0 to FPage.Objects.Count - 1 do + if not (TObject(FPage.Objects[i]) is TfrxBand) then + b.Objects.Add(FPage.Objects[i]); + try + b.AlignChildren; + ShowBand(b); + finally + CurY := SaveCurY; + b.Objects.Clear; + b.Free; + end; + end; + + { Band tree is the structure that we created in the PreparePage method } + procedure ShowBandTree(Obj: TObject); + var + i: Integer; + Bands: TList; + b: TfrxDataBand; + FirstTime: Boolean; + FooterKeepPos, ColumnKeepPos: Integer; + SaveCurY: Extended; + begin + Application.ProcessMessages; + if Report.Terminated then Exit; + + FooterKeepPos := 0; + ColumnKeepPos := 0; + SaveCurY := CurY; + if Obj is TfrxReportPage then + Bands := TfrxReportPage(Obj).FSubBands else + Bands := TfrxBand(Obj).FSubBands; + + for i := 0 to Bands.Count - 1 do + begin + b := Bands[i]; + if b.DataSet = nil then + continue; + b.DataSet.First; + b.FLineN := 1; + b.FLineThrough := 1; + b.CurColumn := 1; + FirstTime := True; + ResetSuppressValues(b); + + while not b.DataSet.Eof do + begin + if CanShow(b, b.PrintIfDetailEmpty) then + begin + if FirstTime then + begin + if b.KeepTogether then + StartKeep(b); + if b.KeepHeader and (b.FHeader <> nil) then + StartKeep(b); + AddToHeaderList(b.FHeader); + ShowBand(b.FHeader); + end + { keeping a master-detail differs from keeping a group } + else if (b.FGroup = nil) and b.KeepTogether then + StartKeep(b); + + if b.FGroup <> nil then + if FirstTime then + InitGroups(b, TfrxGroupHeader(b.FGroup), 0, True) else + CheckGroups(b, TfrxGroupHeader(b.FGroup), ColumnKeepPos, SaveCurY); + + if b.KeepFooter then + FooterKeepPos := PreviewPages.GetCurPosition; + if (b.Columns > 1) and (b.CurColumn = 1) then + ColumnKeepPos := PreviewPages.GetCurPosition; + + SaveCurY := CurY; + CurLine := b.FLineN; + CurLineThrough := b.FLineThrough; + ShowBand(b); + NotifyObjects(b); + + if FirstTime then + if b.KeepHeader and (b.FHeader <> nil) then + EndKeep(b); + FirstTime := False; + + Inc(b.FLineN); + Inc(b.FLineThrough); + CheckBandColumns(b, ColumnKeepPos, SaveCurY); + AddBandOutline(b); + ShowBandTree(b); + OutlineUp(b); + end; + + FIsFirstBand := False; + + if b.FooterAfterEach then + ShowBand(b.FFooter); + + { keeping a master-detail differs from keeping a group } + if (b.FGroup = nil) and b.KeepTogether then + EndKeep(b); + b.DataSet.Next; + if b.RowCount <> 0 then + if b.FLineN > b.RowCount then break; + + if Report.Terminated then break; + end; + + { update the CurY if band is multicolumn } + b.CurColumn := b.Columns; + CheckBandColumns(b, ColumnKeepPos, SaveCurY); + + if not FirstTime then { some bands have been printed } + begin + if b.FGroup <> nil then + ShowGroupFooters(TfrxGroupHeader(b.FGroup), 0, b); + + if not b.FooterAfterEach then + begin + if b.KeepFooter then + StartKeep(b, FooterKeepPos); + FKeepFooter := True; + ShowBand(b.FFooter); + if b.KeepFooter then + EndKeep(b); + FKeepFooter := False; + end; + RemoveFromHeaderList(b.FHeader); + if (b.FGroup <> nil) and b.KeepTogether then + EndKeep(b); + end; + + if Report.Terminated then break; + FIsFirstBand := False; + end; + end; + + procedure ShowPage; + var + pgWidth, pgHeight: Extended; + begin + if CanShow(FPage, Report.EngineOptions.PrintIfEmpty) then + begin + InitPage; + ShowNullBand; + + if Assigned(Report.OnManualBuild) then + Report.OnManualBuild(FPage) + else if Trim(FPage.OnManualBuild) <> '' then + Report.DoNotifyEvent(FPage, FPage.OnManualBuild) + else + ShowBandTree(FPage); + + FIsLastPage := True; + if FPage.EndlessHeight or FPage.EndlessWidth then + begin + if FPage.EndlessWidth then + pgWidth := PageWidth + FPage.LeftMargin * fr01cm + FPage.RightMargin * fr01cm + else + pgWidth := FPage.PaperWidth * fr01cm; + if FPage.EndlessHeight then + begin + PageHeight := CurY + FooterHeight; + pgHeight := PageHeight + FPage.TopMargin * fr01cm + FPage.BottomMargin * fr01cm + end + else + pgHeight := FPage.PaperHeight * fr01cm; + TfrxPreviewPages(PreviewPages).UpdatePageDimensions(FPage, pgWidth, pgHeight); + end; + + EndPage; + FIsLastPage := False; + end; + end; + +begin + { The Page parameter needed only for subreport pages. General is FPage } + if Page.IsSubReport then + begin + ShowBandTree(Page); + Exit; + end; + + FIsFirstBand := True; + Report.DoNotifyEvent(FPage, FPage.OnBeforePrint); + + if FPage.DataSet <> nil then + begin + FPage.DataSet.First; + + while not FPage.DataSet.Eof do + begin + if Report.Terminated then break; + ShowPage; + FPage.DataSet.Next; + end; + end + else + ShowPage; + + Report.DoNotifyEvent(FPage, FPage.OnAfterPrint); +end; + +procedure TfrxEngine.ShowVBands(HBand: TfrxBand); + + procedure ShowBandTree(Bands: TList); + var + i: Integer; + b: TfrxDataBand; + FirstTime: Boolean; + begin + if Report.Terminated then Exit; + + for i := 0 to Bands.Count - 1 do + begin + b := Bands[i]; + if b.DataSet = nil then + continue; + b.DataSet.First; + b.FLineN := 1; + b.FLineThrough := 1; + b.CurColumn := 1; + FirstTime := True; + ResetSuppressValues(b); + + while not b.DataSet.Eof do + begin + if FirstTime then + begin + ShowBand(b.FHeader); + AddToVHeaderList(b.FHeader); + end; + + if b.FGroup <> nil then + if FirstTime then + InitGroups(b, TfrxGroupHeader(b.FGroup), 0, True) else + CheckGroups(b, TfrxGroupHeader(b.FGroup), 0, 0); + + FirstTime := False; + + CurLine := b.FLineN; + CurLineThrough := b.FLineThrough; + ShowBand(b); + NotifyObjects(b); + + Inc(b.FLineN); + Inc(b.FLineThrough); + ShowBandTree(b.FSubBands); + + if b.FooterAfterEach then + ShowBand(b.FFooter); + + b.DataSet.Next; + if b.RowCount <> 0 then + if b.FLineN > b.RowCount then break; + if Report.Terminated then break; + end; + + if b.FGroup <> nil then + ShowGroupFooters(TfrxGroupHeader(b.FGroup), 0, b); + + if not FirstTime then { some bands have been printed } + begin + RemoveFromVHeaderList(b.FHeader); + if not b.FooterAfterEach then + ShowBand(b.FFooter); + end; + + if Report.Terminated then break; + end; + end; + +begin + FVMasterBand := HBand; + FVMasterBand.FOriginalObjectsCount := FVMasterBand.Objects.Count; + FVMasterBand.AllowSplit := False; + + FVHeaderList.Clear; + FVPageList.Clear; + FVPageList.Add(Pointer(0)); + + CurVColumn := 0; + ShowBandTree(TfrxReportPage(HBand.Page).FVSubBands); + FVPageList.Add(Pointer(FVMasterBand.Objects.Count)); +end; + +procedure TfrxEngine.InitPage; +begin + { fill in the header/footer lists } + FHeaderList.Clear; + if FPage.TitleBeforeHeader then + begin + FHeaderList.AddItem(FindBand(TfrxReportTitle), 0, False); + FHeaderList.AddItem(FindBand(TfrxPageHeader), 0, False); + end + else + begin + FHeaderList.AddItem(FindBand(TfrxPageHeader), 0, False); + FHeaderList.AddItem(FindBand(TfrxReportTitle), 0, False); + end; + + { calculating the page/footer sizes } + PageHeight := FPage.PaperHeight * fr01cm - FPage.TopMargin * fr01cm - + FPage.BottomMargin * fr01cm; + PageWidth := FPage.PaperWidth * fr01cm - FPage.LeftMargin * fr01cm - + FPage.RightMargin * fr01cm; + + { reset the current position } + CurX := 0; + CurY := 0; + CurColumn := 1; + FPageCurX := 0; + FVMasterBand := nil; + + FIsFirstPage := True; + FIsLastPage := False; + + if FPage.ResetPageNumbers then + PreviewPages.ResetLogicalPageNumber; + + if (PreviewPages.Count = 0) or not FPage.PrintOnPreviousPage then + AddPage + else + begin + PreviewPages.CurPage := PreviewPages.Count - 1; + CurY := PreviewPages.GetLastY; + RemoveFromHeaderList(FindBand(TfrxReportTitle)); + ShowBand(TfrxReportTitle); + end; + + if FFirstReportPage then + PreviewPages.FirstPage := PreviewPages.CurPage; + FFirstColumnY := CurY; + ShowBand(TfrxColumnHeader); + FHeaderList.AddItem(FindBand(TfrxColumnHeader), 0, False); + RemoveFromHeaderList(FindBand(TfrxReportTitle)); + OutlineRoot; + AddPageOutline; +end; + +function TfrxEngine.HeaderHeight: Extended; +var + Band: TfrxBand; +begin + Result := 0; + + Band := FindBand(TfrxColumnHeader); + while Band <> nil do + begin + Result := Result + Band.Height; + Band := Band.Child; + end; + Band := FindBand(TfrxPageHeader); + while Band <> nil do + begin + Result := Result + Band.Height; + Band := Band.Child; + end; +end; + +function TfrxEngine.FooterHeight: Extended; +var + Band: TfrxBand; +begin + Result := 0; + + Band := FindBand(TfrxColumnFooter); + if Band <> nil then + Result := Result + Band.Height; + Band := FindBand(TfrxPageFooter); + if Band <> nil then + Result := Result + Band.Height; +end; + +function TfrxEngine.FindBand(Band: TfrxBandClass): TfrxBand; +begin + Result := FPage.FindBand(Band); +end; + +procedure TfrxEngine.ShowBand(Band: TfrxBand); +var + chBand: TfrxBand; +begin + if Band <> nil then + begin + if Band.KeepChild then + StartKeep(Band); + DoShow(Band); + chBand := Band.Child; + if (chBand <> nil) and (Band.Visible or Band.PrintChildIfInvisible) then + ShowBand(chBand); + if Band.KeepChild then + EndKeep(Band); + if Band is TfrxDataBand then + FAggregates.AddValue(Band); + end; +end; + +procedure TfrxEngine.ShowBand(Band: TfrxBandClass); +begin + ShowBand(FindBand(Band)); +end; + +procedure TfrxEngine.AddToHeaderList(Band: TfrxBand); +begin + { only header bands with "Reprint on new page" flag can be added } + if ((Band is TfrxHeader) and TfrxHeader(Band).ReprintOnNewPage) or + ((Band is TfrxGroupHeader) and TfrxGroupHeader(Band).ReprintOnNewPage) then + FHeaderList.AddItem(Band, FPageCurX, FKeeping); +end; + +procedure TfrxEngine.AddToVHeaderList(Band: TfrxBand); +begin + { only header bands with "Reprint on new page" flag can be added } + if ((Band is TfrxHeader) and TfrxHeader(Band).ReprintOnNewPage) or + ((Band is TfrxGroupHeader) and TfrxGroupHeader(Band).ReprintOnNewPage) then + FVHeaderList.Add(Band); +end; + +procedure TfrxEngine.RemoveFromHeaderList(Band: TfrxBand); +begin + if Band <> nil then + FHeaderList.RemoveItem(Band); +end; + +procedure TfrxEngine.RemoveFromVHeaderList(Band: TfrxBand); +begin + if Band <> nil then + FVHeaderList.Remove(Band); +end; + +function TfrxEngine.FreeSpace: Extended; +begin + if FPage.EndlessHeight then + Result := 1e+6 + else + Result := PageHeight - FooterHeight - CurY; +end; + +procedure TfrxEngine.Stretch(Band: TfrxBand); +var + i: Integer; + h, maxh: Extended; + c, maxc: TfrxView; + HaveSub, NeedShift: Boolean; + + procedure DoSubReports; + var + i: Integer; + SaveCurX, SaveCurY, SavePageCurX: Extended; + Sub: TfrxSubReport; + MainBand: Boolean; + AllObjects: TList; + c: TfrxComponent; + begin + { create a band which will accepts all subsequent output } + MainBand := False; + if FOutputTo = nil then + begin + Band.FOriginalObjectsCount := Band.Objects.Count; + FOutputTo := TfrxNullBand.Create(nil); + MainBand := True; + end; + + { save the current position } + SaveCurX := CurX; + SaveCurY := CurY; + SavePageCurX := FPageCurX; + + { looking for subreport objects } + for i := 0 to Band.Objects.Count - 1 do + if TObject(Band.Objects[i]) is TfrxSubReport then + begin + Sub := TfrxSubReport(Band.Objects[i]); + if not Sub.Visible or not Sub.PrintOnParent or not MainBand then continue; + + { set up all properties... } + FPageCurX := SavePageCurX + Sub.Left; + CurX := SaveCurX + Sub.Left; + CurY := Sub.Top; + { ...and run the subreport } + RunPage(Sub.Page); + end; + + { restore saved position } + CurX := SaveCurX; + CurY := SaveCurY; + FPageCurX := SavePageCurX; + + if MainBand then + begin + { copy all output to the band } + AllObjects := FOutputTo.AllObjects; + + for i := 0 to AllObjects.Count - 1 do + begin + c := AllObjects[i]; + if (c is TfrxView) and not (c is TfrxSubReport) then + begin + c.Left := c.AbsLeft; + c.Top := c.AbsTop; + c.ParentFont := False; + c.Parent := Band; + end; + if c is TfrxStretcheable then + TfrxStretcheable(c).StretchMode := smDontStretch; + end; + + { Clear the FOutputTo property. Extra objects will be freed + in the Unstretch method. } + FOutputTo.Free; + FOutputTo := nil; + end; + end; + + procedure ShiftObjects(Parent: TfrxReportComponent; Amount: Extended); + var + i: Integer; + v: TfrxView; + diff: Extended; + begin + for i := 0 to Parent.FShiftChildren.Count - 1 do + begin + v := Parent.FShiftChildren[i]; + if v.ShiftMode = smAlways then + begin + v.Top := v.Top + Amount; + ShiftObjects(v, Amount + v.FShiftAmount); + end + else if v.ShiftMode = smWhenOverlapped then + begin + if not (Parent is TfrxBand) and (v.Top < Parent.Top + Parent.Height) then + begin + diff := Parent.Top + Parent.Height - v.Top; + v.Top := Parent.Top + Parent.Height; + ShiftObjects(v, diff + v.FShiftAmount); + end + else + ShiftObjects(v, v.FShiftAmount); + end + else {if v.FShiftAmount <> 0 then} + ShiftObjects(v, Amount + v.FShiftAmount); + + v.FShiftAmount := 0; + end; + end; + +begin + FCurBand := Band; + HaveSub := False; + NeedShift := False; + PrepareShiftTree(Band); + + { it is not necessary for vertical bands } + if Band <> FVMasterBand then + begin + { firing band OnBeforePrint event } + Report.CurObject := Band.Name; + Band.BeforePrint; + Report.DoBeforePrint(Band); + end; + + { firing OnBeforePrint events, stretching objects } + for i := 0 to Band.Objects.Count - 1 do + begin + c := Band.Objects[i]; + if (c is TfrxSubReport) and TfrxSubReport(c).PrintOnParent then + HaveSub := True; + + { skip getdata for vertical bands' objects } + if Band <> FVMasterBand then + begin + Report.CurObject := c.Name; + c.BeforePrint; + if Band.Visible then + begin + Report.DoBeforePrint(c); + if c.Visible then + begin + c.GetData; + Report.DoNotifyEvent(c, c.OnAfterData); + end; + end; + end; + if not Band.Visible or not c.Visible then continue; + + if (c is TfrxStretcheable) and (TfrxStretcheable(c).StretchMode <> smDontStretch) then + begin + h := TfrxStretcheable(c).CalcHeight; + if h > c.Height then + begin + c.FShiftAmount := h - c.Height; { needed to shift underlying objects } + c.Height := h; { stretch the object } + NeedShift := True; + end + else + c.FShiftAmount := 0; + end; + end; + + if not Band.Visible then Exit; + + { shift objects } + if NeedShift then + ShiftObjects(Band, 0); + + { check subreports that have PrintOnParent option } + if HaveSub then + DoSubReports; + + { calculate the max height of the band } + maxh := 0; + maxc := nil; + for i := 0 to Band.Objects.Count - 1 do + begin + c := Band.Objects[i]; + if c.Top + c.Height > maxh then + begin + maxh := c.Top + c.Height; + maxc := c; + end; + end; + if (maxc <> nil) and (maxc is TfrxDMPMemoView) and + (ftBottom in TfrxDMPMemoView(maxc).Frame.Typ) then + maxh := maxh + fr1CharY; + if Band.Stretched then + Band.Height := maxh; + + { fire Band.OnAfterCalcHeight event } + Report.CurObject := Band.Name; + Report.DoNotifyEvent(Band, Band.OnAfterCalcHeight); + + { set the height of objects that should stretch to max height } + for i := 0 to Band.Objects.Count - 1 do + begin + c := Band.Objects[i]; + if (c is TfrxStretcheable) and (TfrxStretcheable(c).StretchMode = smMaxHeight) then + begin + c.Height := maxh - c.Top; + if (c is TfrxDMPMemoView) and (ftBottom in TfrxDMPMemoView(c).Frame.Typ) then + c.Height := c.Height - fr1CharY; + end; + end; +end; + +procedure TfrxEngine.UnStretch(Band: TfrxBand); +var + i: Integer; + c: TfrxView; +begin + { fire OnAfterPrint event } + if Band.Visible then + for i := 0 to Band.Objects.Count - 1 do + begin + c := Band.Objects[i]; + Report.CurObject := c.Name; + Report.DoAfterPrint(c); + end; + + { restore state } + for i := 0 to Band.Objects.Count - 1 do + begin + c := Band.Objects[i]; + c.AfterPrint; + end; + + Report.CurObject := Band.Name; + Report.DoAfterPrint(Band); + Band.AfterPrint; + + { remove extra band objects if any } + if Band.FOriginalObjectsCount <> -1 then + begin + while Band.Objects.Count > Band.FOriginalObjectsCount do + TObject(Band.Objects[Band.Objects.Count - 1]).Free; + Band.FOriginalObjectsCount := -1; + end; +end; + +procedure TfrxEngine.AddPage; +var + i: Integer; + SaveCurX: Extended; + SaveCurLine, SaveCurLineThrough: Integer; + Band: TfrxBand; +begin + PreviewPages.AddPage(FPage); + CurY := 0; + + Band := FindBand(TfrxOverlay); + if (Band <> nil) and not TfrxOverlay(Band).PrintOnTop then + ShowBand(Band); + + CurY := 0; + SaveCurX := CurX; + FFirstColumnY := 0; + + for i := 0 to FHeaderList.Count - 1 do + begin + { use own CurX - we may be inside subreports now } + CurX := FHeaderList[i].Left; + Band := FHeaderList[i].Band; + if Band = FStartNewPageBand then + continue; + + if FIsFirstPage and (Band is TfrxPageHeader) and + not TfrxPageHeader(Band).PrintOnFirstPage then + begin + if Band.PrintChildIfInvisible then + Band := Band.Child + else + continue; + end; + + if Band <> nil then + if not FKeeping or not FHeaderList[i].IsInKeepList then + begin + if (Band is TfrxHeader) and FDontShowHeaders then continue; + Band.Overflow := True; + SaveCurLine := CurLine; + SaveCurLineThrough := CurLineThrough; + CurLine := Band.FLineN; + CurLineThrough := Band.FLineThrough; + FCallFromAddPage := True; + + { fix the stack overflow error if call NewPage from ReportTitle } + if Band is TfrxReportTitle then + FHeaderList[i].Band := nil; + if Band is TfrxPageHeader then + FFirstColumnY := Band.Height; + + ShowBand(Band); + + FCallFromAddPage := False; + Band.Overflow := False; + CurLine := SaveCurLine; + CurLineThrough := SaveCurLineThrough; + end; + end; + + CurX := SaveCurX; +end; + +procedure TfrxEngine.EndPage; +var + Band: TfrxBand; + + procedure ShowBand(Band: TfrxBand); + begin + if Band = nil then Exit; + + Stretch(Band); + try + if Band.Visible then + begin + Band.Left := 0; + Band.Top := CurY; + + if Band is TfrxPageFooter then + if (FIsFirstPage and not TfrxPageFooter(Band).PrintOnFirstPage) or + (FIsLastPage and not TfrxPageFooter(Band).PrintOnLastPage) then + Exit; + + if not PreviewPages.BandExists(Band) then + PreviewPages.AddObject(Band); + CurY := CurY + Band.Height; + end; + finally + UnStretch(Band); + end; + + FAggregates.Reset(Band); + end; + +begin + EndColumn; + if not FIsLastPage then + begin + CurX := FPageCurX; + CurColumn := 1; + end; + + if FIsLastPage and not FCallFromEndPage then + begin + { avoid stack overflow if reportsummary does not fit on the page } + FCallFromEndPage := True; + try + Self.ShowBand(TfrxReportSummary); + finally + FCallFromEndPage := False; + end; + end; + + Band := FindBand(TfrxPageFooter); + if Band <> nil then + CurY := PageHeight - Band.Height; + ShowBand(Band); + + Band := FindBand(TfrxOverlay); + if (Band <> nil) and TfrxOverlay(Band).PrintOnTop then + begin + CurY := 0; + ShowBand(Band); + end; + + FIsFirstPage := False; +end; + +procedure TfrxEngine.AddColumn; +var + i: Integer; + AddX: Extended; + + procedure DoShow(Band: TfrxBand); + begin + Band.Overflow := True; + Stretch(Band); + + try + if Band.Visible then + begin + Band.Left := CurX; + Band.Top := CurY; + PreviewPages.AddObject(Band); + CurY := CurY + Band.Height; + end; + finally + UnStretch(Band); + Band.Overflow := False; + end; + end; + + procedure ShowBand(Band: TfrxBand); + begin + while Band <> nil do + begin + DoShow(Band); + if Band.Visible or Band.PrintChildIfInvisible then + Band := Band.Child else + break; + end; + end; + +begin + CurColumn := CurColumn + 1; + AddX := frxStrToFloat(FPage.ColumnPositions[CurColumn - 1]) * fr01cm; + CurY := FFirstColumnY; + + for i := 0 to FHeaderList.Count - 1 do + begin + CurX := FHeaderList[i].Left + AddX; + if not (FHeaderList[i].Band is TfrxPageHeader) then + ShowBand(FHeaderList[i].Band); + end; + + CurX := FPageCurX + AddX; +end; + +procedure TfrxEngine.EndColumn; +var + Band: TfrxBand; +begin + Band := FindBand(TfrxColumnFooter); + if Band = nil then Exit; + + Stretch(Band); + try + if Band.Visible then + begin + Band.Left := CurX - FPageCurX; + Band.Top := CurY; + PreviewPages.AddObject(Band); + { move the current position } + CurY := CurY + Band.Height; + end; + finally + UnStretch(Band); + end; + + FAggregates.Reset(Band); +end; + +procedure TfrxEngine.NewPage; +begin + if FKeeping then + begin + if FKeepFooter then + FAggregates.DeleteValue(FKeepBand); + PreviewPages.CutObjects(FKeepPosition); + CurY := PreviewPages.GetLastY; + end; + EndPage; + AddPage; + if FKeeping then + begin + FAggregates.EndKeep; + PreviewPages.PasteObjects(0, CurY); + PreviewPages.Outline.ShiftItems(FKeepOutline, Round(CurY)); + PreviewPages.ShiftAnchors(FKeepAnchor, Round(CurY)); + CurY := PreviewPages.GetLastY; + if FKeepFooter then + FAggregates.AddValue(FKeepBand); + end; + FKeeping := False; + AddPageOutline; +end; + +procedure TfrxEngine.NewColumn; +begin + if CurColumn >= FPage.Columns then + NewPage + else + begin + EndColumn; + AddColumn; + end; +end; + +procedure TfrxEngine.DrawSplit(Band: TfrxBand); +var + i: Integer; + List, SaveObjects, ShiftedList: TList; + View: TfrxView; + StrView: TfrxStretcheable; + CurHeight, Corr: Extended; + + procedure ShiftObjects(TopView: TfrxView; Delta: Extended); + var + i: Integer; + View: TfrxView; + begin + for i := 0 to List.Count - 1 do + begin + View := List[i]; + if (View <> TopView) and (ShiftedList.IndexOf(View) = -1) and + (View.Top >= TopView.Top + TopView.Height) and + (View.Left < TopView.Left + TopView.Width) and + (TopView.Left < View.Left + View.Width) then + begin + View.Top := View.Top + Delta; + ShiftedList.Add(View); + end; + end; + end; + + procedure DrawPart; + var + i: Integer; + View: TfrxView; + begin + { draw current objects } + Band.Left := CurX; + Band.Top := CurY; + PreviewPages.AddObject(Band); + { add new column/page } + if List.Count > 0 then + NewColumn else + CurY := CurY + Band.Height; + + { correct the top coordinate of remained objects } + Band.Objects.Clear; + for i := 0 to List.Count - 1 do + begin + View := List[i]; + View.Top := View.Top - CurHeight; + { restore the height of stretched objects } + if View is TfrxStretcheable then + begin + if View.Top < 0 then + View.Top := 0; + View.Height := TfrxStretcheable(View).FSaveHeight; + end; + end; + end; + + procedure CalcBandHeight; + var + i: Integer; + View: TfrxView; + begin + Band.Height := 0; + { calculate the band's height } + for i := 0 to Band.Objects.Count - 1 do + begin + View := Band.Objects[i]; + if View.Top + View.Height > Band.Height then + Band.Height := View.Top + View.Height; + end; + + { correct objects with StretchToMaxHeight or BandAlign = baBottom } + if List.Count = 0 then + for i := 0 to Band.Objects.Count - 1 do + begin + View := Band.Objects[i]; + if View.Align = baBottom then + View.Top := Band.Height - View.Height + else if (View is TfrxStretcheable) and + (TfrxStretcheable(View).StretchMode = smMaxHeight) then + View.Height := Band.Height - View.Top; + end; + end; + +begin + List := TList.Create; + SaveObjects := TList.Create; + ShiftedList := TList.Create; + + { initializing lists } + for i := 0 to Band.Objects.Count - 1 do + begin + View := Band.Objects[i]; + if not (View is TfrxSubReport) then + List.Add(View); + SaveObjects.Add(View); + if View is TfrxStretcheable then + begin + TfrxStretcheable(View).InitPart; + TfrxStretcheable(View).FSaveHeight := View.Height; + end; + end; + + Band.Objects.Clear; + + CurHeight := FreeSpace; + + while List.Count > 0 do + begin + ShiftedList.Clear; + i := 0; + + while i < List.Count do + begin + View := List[i]; + + { whole object fits in the page } + if View.Top + View.Height <= CurHeight then + begin + { add to band and remove from list } + Band.Objects.Add(View); + List.Remove(View); + { prepare last part of text } + if View is TfrxStretcheable then + TfrxStretcheable(View).DrawPart; + continue; + end; + + if View is TfrxStretcheable then + begin + StrView := List[i]; + { view is inside draw area } + if StrView.Top < CurHeight then + begin + { trying to place it } + StrView.Height := CurHeight - StrView.Top; + { DrawPart method returns the amount of unused space. If view + can't fit in the height, this method returns the Height } + Corr := StrView.DrawPart; + { shift the underlying objects down } + ShiftObjects(StrView, Corr); + + if Abs(Corr - StrView.Height) < 1e-4 then + begin + { view can't fit, return back the height and correct the top } + StrView.Top := CurHeight; + StrView.Height := StrView.FSaveHeight; + end + else + begin + { view can draw something } + Band.Objects.Add(StrView); + { decrease the remained height } + StrView.FSaveHeight := StrView.FSaveHeight - StrView.Height + Corr; + end; + end; + end + else + begin + { non-stretcheable view can't be splitted, draw it in the next page } + if View.Top < CurHeight then + begin + { shift the underlying objects down } + ShiftObjects(View, CurHeight - View.Top); + View.Top := CurHeight; + end; + end; + + Inc(i); + end; + + { draw the visible part } + CalcBandHeight; + DrawPart; + CurHeight := FreeSpace; + end; + + { get objects back to the band } + Band.Objects.Clear; + for i := 0 to SaveObjects.Count - 1 do + Band.Objects.Add(SaveObjects[i]); + + List.Free; + SaveObjects.Free; + ShiftedList.Free; +end; + +procedure TfrxEngine.CheckSuppress(Band: TfrxBand); +var + i: Integer; + c: TfrxComponent; + hasSuppress: Boolean; +begin + hasSuppress := False; + for i := 0 to Band.Objects.Count - 1 do + begin + c := Band.Objects[i]; + if (c is TfrxCustomMemoView) and TfrxCustomMemoView(c).SuppressRepeated then + begin + hasSuppress := True; + TfrxCustomMemoView(c).ResetSuppress; + end; + end; + + if hasSuppress then + begin + UnStretch(Band); + Stretch(Band); + end; +end; + +procedure TfrxEngine.DoShow(Band: TfrxBand); +var + IsMultiColumnBand, IsSplit: Boolean; + TempBand: TfrxBand; + SaveCurX: Extended; + SavePageList: TList; + SaveVMasterBand: TfrxBand; + i: Integer; + + procedure RenderVBand; + var + i, j, SavePageN: Integer; + SaveCurY: Extended; + c: TfrxComponent; + SaveObjects: TList; + begin + SaveObjects := TList.Create; + SavePageN := PreviewPages.CurPage; + SaveCurY := CurY; + { the next NewPage call shouldn't form a new page } + PreviewPages.AddPageAction := apWriteOver; + + { save hband objects } + for i := 0 to FVMasterBand.Objects.Count - 1 do + SaveObjects.Add(FVMasterBand.Objects[i]); + + for i := 0 to FVPageList.Count - 2 do + begin + FVMasterBand.Objects.Clear; + for j := Integer(FVPageList[i]) to Integer(FVPageList[i + 1]) - 1 do + begin + c := SaveObjects[j]; + FVMasterBand.Objects.Add(c); + end; + PreviewPages.AddObject(FVMasterBand); + + if i <> FVPageList.Count - 2 then + begin + FDontShowHeaders := True; + NewPage; + FDontShowHeaders := False; + end + else + EndPage; + end; + + { restore hband objects } + FVMasterBand.Objects.Clear; + for i := 0 to SaveObjects.Count - 1 do + FVMasterBand.Objects.Add(SaveObjects[i]); + SaveObjects.Free; + + PreviewPages.CurPage := SavePageN; + CurY := SaveCurY; + CurX := SaveCurX; + { the next NewPage call should form a new page } + PreviewPages.AddPageAction := apAdd; + end; + + procedure AddVBand; + var + i: Integer; + c, c1: TfrxReportComponent; + begin + if Band is TfrxDataBand then + CurVColumn := CurVColumn + 1; + if (Band is TfrxFooter) or (Band is TfrxGroupFooter) then + FCurBand := Band + else + FCurBand := FVMasterBand; + + { fire beforeprint } + Report.CurObject := Band.Name; + Band.BeforePrint; + Report.DoBeforePrint(Band); + + if Band.Visible then + begin + if CurX + Band.Width > PageWidth then + if FPage.EndlessWidth then + PageWidth := PageWidth + Band.Width + else + begin + CurX := 0; + FVPageList.Add(Pointer(FVMasterBand.Objects.Count)); + { reprint headers } + for i := 0 to FVHeaderList.Count - 1 do + ShowBand(TfrxBand(FVHeaderList[i])); + end; + + { find objects that intersect with vertical Band } + for i := 0 to Band.Objects.Count - 1 do + begin + c := Band.Objects[i]; + if THackComponent(c).FOriginalBand = FVMasterBand then + begin + { fire beforeprint and getdata } + Report.CurObject := c.Name; + c.BeforePrint; + Report.DoBeforePrint(c); + c.GetData; + Report.DoNotifyEvent(c, c.OnAfterData); + + { copy the object } + c1 := TfrxReportComponent(c.NewInstance); + c1.Create(FVMasterBand); + c1.Assign(c); + with THackComponent(c1) do + begin + FAliasName := THackComponent(c).FAliasName; + FOriginalComponent := THackComponent(c).FOriginalComponent; + end; + c1.Left := c1.Left + CurX; + + { restore the object's state } + c.AfterPrint; + end; + end; + + CurX := CurX + Band.Width; + end; + + { fire afterprint } + Report.CurObject := Band.Name; + Report.DoAfterPrint(Band); + Band.AfterPrint; + + if Band is TfrxDataBand then + FAggregates.AddValue(FVMasterBand, CurVColumn); + + { reset aggregates } + if (Band is TfrxFooter) or (Band is TfrxGroupFooter) then + FAggregates.Reset(Band); + end; + +begin + SavePageList := nil; + SaveVMasterBand := nil; + + { make cross-bands } + if Band.FHasVBands then + begin + SaveCurX := CurX; + { fire onbeforeprint } + Report.CurObject := Band.Name; + Band.BeforePrint; + Report.DoBeforePrint(Band); + { show vertical bands } + ShowVBands(Band); + CurX := 0; + { the next NewPage call should form a new page } + PreviewPages.AddPageAction := apAdd; + + { save global variables - FVPageList and FVMasterBand } + { they may be changed in the NewPage call, if cross has a h-header } + { with ReprintOnNewPage option } + SavePageList := TList.Create; + for i := 0 to FVPageList.Count - 1 do + SavePageList.Add(FVPageList[i]); + SaveVMasterBand := FVMasterBand; + end; + + { show one vertical band } + if Band.Vertical then + begin + AddVBand; + Exit; + end; + + IsMultiColumnBand := (Band is TfrxDataBand) and (TfrxDataBand(Band).Columns > 1); + IsSplit := False; + + { check for StartNewPage flag } + if not FCallFromAddPage then + if Band.Visible then { don't process invisible bands } + if Band.StartNewPage then + if FOutputTo = nil then + if not (((Band is TfrxDataBand) or (Band is TfrxGroupHeader)) and (Band.FLineN = 1)) then + begin + FStartNewPageBand := Band; + if (Band is TfrxGroupHeader) and (TfrxGroupHeader(Band).ResetPageNumbers) then + PreviewPages.ResetLogicalPageNumber; + NewPage; + FStartNewPageBand := nil; + end; + + Stretch(Band); + Band.FStretchedHeight := Band.Height; + try + if Band.Visible then + begin + { if band has columns, print all columns in one page. Page feed will be + performed after the last column } + if not IsMultiColumnBand and not (Band is TfrxOverlay) and not (Band is TfrxNullBand) and + (Band.Height > FreeSpace) then + if FOutputTo = nil then + if Band.AllowSplit then + begin + DrawSplit(Band); + IsSplit := True; + end + else + begin + CheckSuppress(Band); + NewColumn; + end; + + if not IsSplit then + begin + if not (Band is TfrxNullBand) then + begin + { multicolumn band manages its Left property itself } + if IsMultiColumnBand then + Band.Left := Band.Left + CurX else + Band.Left := CurX; + Band.Top := CurY; + end; + + { output the band } + if FOutputTo = nil then + begin + if Band.FHasVBands then + begin + { restore global variables - FVPageList and FVMasterBand } + { they may be changed in the NewPage call, if cross has a h-header } + { with ReprintOnNewPage option } + FVPageList.Clear; + for i := 0 to SavePageList.Count - 1 do + FVPageList.Add(SavePageList[i]); + SavePageList.Free; + FVMasterBand := SaveVMasterBand; + RenderVBand; + end + else if (not FCallFromAddPage) or (not PreviewPages.BandExists(Band)) then + PreviewPages.AddObject(Band) + end + else + begin + TempBand := TfrxBand.Create(FOutputTo); + TempBand.AssignAll(Band); + end; + + { move the current position } + CurY := CurY + Band.Height; + end; + end; + finally + UnStretch(Band); + end; + + { reset aggregate values } +// if (Band is TfrxFooter) or (Band is TfrxGroupFooter) or +// (Band is TfrxPageFooter) or (Band is TfrxReportSummary) then + FAggregates.Reset(Band); + + { print subreports contained in this band } + if Band.Visible then + CheckSubReports(Band); +end; + +procedure TfrxEngine.CheckSubReports(Band: TfrxBand); +var + i, SavePageN, SaveColumnN: Integer; + SaveCurX, SaveCurY, SavePageCurX: Extended; + HaveSub: Boolean; + Sub: TfrxSubReport; + MaxPageN, MaxColumnN: Integer; + MaxCurY: Extended; +begin + { save the current position } + HaveSub := False; + SavePageN := PreviewPages.CurPage; + SaveColumnN := CurColumn; + SaveCurX := CurX; + SaveCurY := CurY; + SavePageCurX := FPageCurX; + + { init max position } + MaxPageN := SavePageN; //0 + MaxColumnN := SaveColumnN; //0 + MaxCurY := SaveCurY; //0 + + { looking for subreport objects } + for i := 0 to Band.Objects.Count - 1 do + if TObject(Band.Objects[i]) is TfrxSubReport then + begin + Sub := TfrxSubReport(Band.Objects[i]); + if not Sub.Visible or Sub.PrintOnParent then continue; + HaveSub := True; + + { set up all properties... } + PreviewPages.CurPage := SavePageN; + FPageCurX := SavePageCurX + Sub.Left; + CurColumn := SaveColumnN; + CurX := SaveCurX + Sub.Left; + CurY := SaveCurY - Band.Height + Sub.Top; //SaveCurY - Sub.Height; + { ...and run the subreport } + RunPage(Sub.Page); + + { calc max position } + if PreviewPages.CurPage > MaxPageN then + begin + MaxPageN := PreviewPages.CurPage; + MaxColumnN := CurColumn; + MaxCurY := CurY; + end + else if PreviewPages.CurPage = MaxPageN then + if CurColumn > MaxColumnN then + begin + MaxColumnN := CurColumn; + MaxCurY := CurY; + end + else if CurColumn = MaxColumnN then + if CurY > MaxCurY then + MaxCurY := CurY; + end; + + { move the current position to the last generated page } + if HaveSub then + begin + PreviewPages.CurPage := MaxPageN; + CurColumn := MaxColumnN; + CurX := SavePageCurX; + if CurColumn > 1 then + CurX := CurX + frxStrToFloat(FPage.ColumnPositions[CurColumn - 1]) * fr01cm; + CurY := MaxCurY; + FPageCurX := SavePageCurX; + end; +end; + +procedure TfrxEngine.StartKeep(Band: TfrxBand; Position: Integer = 0); +begin + if FKeeping or FIsFirstBand then Exit; + + FKeeping := True; + FKeepBand := Band; + if Position = 0 then + Position := PreviewPages.GetCurPosition; + FKeepPosition := Position; + FKeepOutline := PreviewPages.Outline.GetCurPosition; + FKeepAnchor := PreviewPages.GetAnchorCurPosition; + FAggregates.StartKeep; +end; + +procedure TfrxEngine.EndKeep(Band: TfrxBand); +begin + if FKeepBand = Band then + begin + FKeeping := False; + FKeepBand := nil; + FAggregates.EndKeep; + end; +end; + +function TfrxEngine.GetAggregateValue(const Name, Expression: String; + Band: TfrxBand; Flags: Integer): Variant; +begin + Result := FAggregates.GetValue(FCurBand, CurVColumn, Name, Expression, Band, Flags); +end; + +procedure TfrxEngine.AddBandOutline(Band: TfrxBand); +var + pos: Integer; +begin + if Band.OutlineText <> '' then + begin + Report.CurObject := Band.Name; + if Band.Stretched then + pos := Round(CurY - Band.FStretchedHeight) + else + pos := Round(CurY - Band.Height); + if Band.Visible then + PreviewPages.Outline.AddItem(VarToStr(Report.Calc(Band.OutlineText)), pos); + end; +end; + +procedure TfrxEngine.AddPageOutline; +begin + if FPage.OutlineText <> '' then + begin + OutlineRoot; + Report.CurObject := FPage.Name; + PreviewPages.Outline.AddItem(VarToStr(Report.Calc(FPage.OutlineText)), 0); + end; +end; + +procedure TfrxEngine.OutlineRoot; +begin + PreviewPages.Outline.LevelRoot; +end; + +procedure TfrxEngine.OutlineUp(Band: TfrxBand); +begin + if Band.OutlineText <> '' then + PreviewPages.Outline.LevelUp; +end; + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxEvaluateForm.dfm b/official/4.2/LibD11/frxEvaluateForm.dfm new file mode 100644 index 0000000..a02ae16 Binary files /dev/null and b/official/4.2/LibD11/frxEvaluateForm.dfm differ diff --git a/official/4.2/LibD11/frxEvaluateForm.pas b/official/4.2/LibD11/frxEvaluateForm.pas new file mode 100644 index 0000000..f18ef06 --- /dev/null +++ b/official/4.2/LibD11/frxEvaluateForm.pas @@ -0,0 +1,118 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Evaluate dialog } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxEvaluateForm; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, fs_iinterpreter +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxEvaluateForm = class(TForm) + Label1: TLabel; + ExpressionE: TEdit; + Label2: TLabel; + ResultM: TMemo; + OkB: TButton; + CancelB: TButton; + procedure ExpressionEKeyPress(Sender: TObject; var Key: Char); + procedure FormShow(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FScript: TfsScript; + FIsWatch: Boolean; + public + property IsWatch: Boolean read FIsWatch write FIsWatch; + property Script: TfsScript read FScript write FScript; + end; + + +implementation + +{$R *.DFM} + +uses frxRes; + + +procedure TfrxEvaluateForm.ExpressionEKeyPress(Sender: TObject; var Key: Char); +var + v: Variant; + s: String; +begin + if IsWatch then Exit; + if Key = #13 then + begin + v := FScript.Evaluate(ExpressionE.Text); + s := VarToStr(v); + if TVarData(v).VType = varBoolean then + if Boolean(v) = True then + s := 'True' else + s := 'False' + else if (TVarData(v).VType = varString) or (TVarData(v).VType = varOleStr) then + s := '''' + v + '''' + else if v = Null then + s := 'Null'; + ResultM.Text := s; + ExpressionE.SelectAll; + end + else if Key = #27 then + Close; +end; + +procedure TfrxEvaluateForm.FormShow(Sender: TObject); +begin + ExpressionE.SelectAll; + ResultM.Text := ''; + if IsWatch then + begin + OkB.Visible := True; + CancelB.Visible := True; + ResultM.Visible := False; + Label2.Visible := False; + ClientHeight := OkB.Top + OkB.Height + 4; + end; +end; + +procedure TfrxEvaluateForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(5500); + Label1.Caption := frxGet(5501); + Label2.Caption := frxGet(5502); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxEvaluateForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_ESCAPE then + ModalResult := mrCancel; + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxExportCSV.dfm b/official/4.2/LibD11/frxExportCSV.dfm new file mode 100644 index 0000000..9d8f82d Binary files /dev/null and b/official/4.2/LibD11/frxExportCSV.dfm differ diff --git a/official/4.2/LibD11/frxExportCSV.pas b/official/4.2/LibD11/frxExportCSV.pas new file mode 100644 index 0000000..7445c66 --- /dev/null +++ b/official/4.2/LibD11/frxExportCSV.pas @@ -0,0 +1,308 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ CSV export } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportCSV; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, extctrls, frxClass, frxExportMatrix, ShellAPI +{$IFDEF Delphi6}, Variants {$ENDIF}; + +type + TfrxCSVExportDialog = class(TForm) + OkB: TButton; + CancelB: TButton; + SaveDialog1: TSaveDialog; + GroupPageRange: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + GroupQuality: TGroupBox; + OpenCB: TCheckBox; + OEMCB: TCheckBox; + SeparatorLB: TLabel; + SeparatorE: TEdit; + procedure FormCreate(Sender: TObject); + procedure PageNumbersEChange(Sender: TObject); + procedure PageNumbersEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + end; + + TfrxCSVExport = class(TfrxCustomExportFilter) + private + FMatrix: TfrxIEMatrix; + FOpenAfterExport: Boolean; + Exp: TStream; + FPage: TfrxReportPage; + FOEM: Boolean; + FSeparator: String; + procedure ExportPage(Stream: TStream); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + procedure ExportObject(Obj: TfrxComponent); override; + published + property Separator: String read FSeparator write FSeparator; + property OEMCodepage: Boolean read FOEM write FOEM; + property OpenAfterExport: Boolean read FOpenAfterExport write FOpenAfterExport default False; + end; + + +implementation + +uses frxUtils, frxFileUtils, frxUnicodeUtils, frxRes, frxrcExports; + +{$R *.dfm} + +{ TfrxCSVExport } + +constructor TfrxCSVExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FOEM := False; + FSeparator := ';'; + FilterDesc := frxGet(8851); + DefaultExt := frxGet(8852); +end; + +class function TfrxCSVExport.GetDescription: String; +begin + Result := frxResources.Get('CSVExport'); +end; + +procedure TfrxCSVExport.ExportPage(Stream: TStream); +var + x, y, i: Integer; + Obj: TfrxIEMObject; + s: String; + + function StrToOem(const AnsiStr: String): String; + begin + SetLength(Result, Length(AnsiStr)); + if Length(Result) > 0 then + CharToOemBuff(PChar(AnsiStr), PChar(Result), Length(Result)); + end; + + function PrepareString(const Str: String): String; + begin + if FOEM then + Result := StrToOem(Str) + else + Result := Str; + Result := '"' + StringReplace(Result, #13#10, '', [rfReplaceAll]) + '"'; + end; + +begin + FMatrix.Prepare; + + for y := 0 to FMatrix.Height - 2 do + begin + for x := 0 to FMatrix.Width - 1 do + begin + i := FMatrix.GetCell(x, y); + if (i <> -1) then + begin + Obj := FMatrix.GetObjectById(i); + if Obj.Counter = 0 then + begin + s := PrepareString(Obj.Memo.Text) + FSeparator; + Stream.Write(s[1], Length(s)); + Obj.Counter := 1; + end + else begin + s := FSeparator; + Stream.Write(s[1], Length(s)); + end; + end; + end; + Stream.Write(#13#10, 2); + end; + +end; + +function TfrxCSVExport.ShowModal: TModalResult; +begin + if not Assigned(Stream) then + begin + with TfrxCSVExportDialog.Create(nil) do + begin + OpenCB.Visible := not SlaveExport; + if SlaveExport then + FOpenAfterExport := False; + + if (FileName = '') and (not SlaveExport) then + SaveDialog1.FileName := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), SaveDialog1.DefaultExt) + else + SaveDialog1.FileName := FileName; + + OpenCB.Checked := FOpenAfterExport; + OEMCB.Checked := FOEM; + SeparatorE.Text := FSeparator; + + if PageNumbers <> '' then + begin + PageNumbersE.Text := PageNumbers; + PageNumbersRB.Checked := True; + end; + + Result := ShowModal; + + if Result = mrOk then + begin + PageNumbers := ''; + CurPage := False; + if CurPageRB.Checked then + CurPage := True + else if PageNumbersRB.Checked then + PageNumbers := PageNumbersE.Text; + + FOpenAfterExport := OpenCB.Checked; + FOEM := OEMCB.Checked; + FSeparator := SeparatorE.Text; + + if not SlaveExport then + begin + if DefaultPath <> '' then + SaveDialog1.InitialDir := DefaultPath; + if SaveDialog1.Execute then + FileName := SaveDialog1.FileName + else + Result := mrCancel; + end + else + FileName := ChangeFileExt(GetTempFile, SaveDialog1.DefaultExt); + end; + Free; + end; + end else + Result := mrOk; +end; + +function TfrxCSVExport.Start: Boolean; +begin + if (FileName <> '') or Assigned(Stream) then + begin + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + FileName := DefaultPath + '\' + FileName; + FMatrix := TfrxIEMatrix.Create(UseFileCache, Report.EngineOptions.TempDir); + FMatrix.Background := False; + FMatrix.BackgroundImage := False; + FMatrix.Printable := ExportNotPrintable; + FMatrix.RichText := True; + FMatrix.PlainRich := True; + FMatrix.AreaFill := False; + FMatrix.CropAreaFill := True; + FMatrix.Inaccuracy := 5; + FMatrix.DeleteHTMLTags := True; + FMatrix.Images := False; + FMatrix.WrapText := True; + FMatrix.ShowProgress := False; + FMatrix.FramesOptimization := True; + try + if Assigned(Stream) then + Exp := Stream + else + Exp := TFileStream.Create(FileName, fmCreate); + Result := True; + except + Result := False; + end; + end + else + Result := False; +end; + +procedure TfrxCSVExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + FMatrix.Clear; +end; + +procedure TfrxCSVExport.ExportObject(Obj: TfrxComponent); +begin + if Obj is TfrxView then + FMatrix.AddObject(TfrxView(Obj)); +end; + +procedure TfrxCSVExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + FPage := Page; + ExportPage(Exp); +end; + +procedure TfrxCSVExport.Finish; +begin + FMatrix.Free; + if not Assigned(Stream) then + Exp.Free; + if FOpenAfterExport and (not Assigned(Stream)) then + ShellExecute(GetDesktopWindow, 'open', PChar(FileName), nil, nil, SW_SHOW); +end; + +{ TfrxCSVExportDialog } + +procedure TfrxCSVExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8850); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + GroupPageRange.Caption := frxGet(7); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + DescrL.Caption := frxGet(9); + GroupQuality.Caption := frxGet(8302); + OEMCB.Caption := frxGet(8304); + OpenCB.Caption := frxGet(8706); + SaveDialog1.Filter := frxGet(8851); + SaveDialog1.DefaultExt := frxGet(8852); + SeparatorLB.Caption := frxGet(8853); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxCSVExportDialog.PageNumbersEChange(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxCSVExportDialog.PageNumbersEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8, '-', ',':; + else + key := #0; + end; +end; + +procedure TfrxCSVExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxExportHTML.dfm b/official/4.2/LibD11/frxExportHTML.dfm new file mode 100644 index 0000000..bfdacec Binary files /dev/null and b/official/4.2/LibD11/frxExportHTML.dfm differ diff --git a/official/4.2/LibD11/frxExportHTML.pas b/official/4.2/LibD11/frxExportHTML.pas new file mode 100644 index 0000000..b84b97d --- /dev/null +++ b/official/4.2/LibD11/frxExportHTML.pas @@ -0,0 +1,1042 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ HTML table export filter } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportHTML; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxClass, JPEG, ShellAPI, frxExportMatrix, frxProgress +{$IFDEF Delphi6}, Variants {$ENDIF}, frxExportImage; + +type + TfrxHTMLExportDialog = class(TForm) + SaveDialog1: TSaveDialog; + GroupQuality: TGroupBox; + StylesCB: TCheckBox; + PicsSameCB: TCheckBox; + FixWidthCB: TCheckBox; + NavigatorCB: TCheckBox; + MultipageCB: TCheckBox; + GroupPageRange: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + OpenAfterCB: TCheckBox; + OkB: TButton; + CancelB: TButton; + BackgrCB: TCheckBox; + PicturesL: TLabel; + PFormatCB: TComboBox; + procedure FormCreate(Sender: TObject); + procedure PageNumbersEChange(Sender: TObject); + procedure PageNumbersEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + end; + + TfrxHTMLExport = class(TfrxCustomExportFilter) + private + Exp: TStream; + FAbsLinks: Boolean; + FCurrentPage: Integer; + FExportPictures: Boolean; + FExportStyles: Boolean; + FFixedWidth: Boolean; + FMatrix: TfrxIEMatrix; + FMozillaBrowser: Boolean; + FMultipage: Boolean; + FNavigator: Boolean; + FOpenAfterExport: Boolean; + FPicsInSameFolder: Boolean; + FPicturesCount: Integer; + FProgress: TfrxProgress; + FUseJpeg: Boolean; + FServer: Boolean; + FPrintLink: String; + FRefreshLink: String; + FBackground: Boolean; + FBackImage: TBitmap; + FBackImageExist: Boolean; + FReportPath: String; + FUseGif: Boolean; + FCentered: Boolean; + FEmptyLines: Boolean; + procedure WriteExpLn(const str: String); + procedure ExportPage; + function ChangeReturns(const Str: String): String; + function TruncReturns(const Str: WideString): WideString; + function GetPicsFolder: String; + function GetPicsFolderRel: String; + function GetFrameFolder: String; + function ReverseSlash(const S: String): String; + function HTMLCodeStr(const Str: String): String; + procedure SetUseGif(const Value: Boolean); + procedure SetUseJpeg(const Value: Boolean); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + procedure ExportObject(Obj: TfrxComponent); override; + class function GetDescription: String; override; + property Server: Boolean read FServer write FServer; + property PrintLink: String read FPrintLink write FPrintLink; + property RefreshLink: String read FRefreshLink write FRefreshLink; + property ReportPath: String read FReportPath write FReportPath; + published + property OpenAfterExport: Boolean read FOpenAfterExport write FOpenAfterExport default False; + property FixedWidth: Boolean read FFixedWidth write FFixedWidth default False; + property ExportPictures: Boolean read FExportPictures write FExportPictures default True; + property PicsInSameFolder: Boolean read FPicsInSameFolder write FPicsInSameFolder default False; + property ExportStyles: Boolean read FExportStyles write FExportStyles default True; + property Navigator: Boolean read FNavigator write FNavigator default False; + property Multipage: Boolean read FMultipage write FMultipage default False; + property MozillaFrames: Boolean read FMozillaBrowser write FMozillaBrowser default False; + property UseJpeg: Boolean read FUseJpeg write SetUseJpeg default True; + property UseGif: Boolean read FUseGif write SetUseGif default False; + property AbsLinks: Boolean read FAbsLinks write FAbsLinks default False; + property Background: Boolean read FBackground write FBackground; + property Centered: Boolean read FCentered write FCentered; + property EmptyLines: Boolean read FEmptyLines write FEmptyLines; + end; + + +implementation + +uses frxUtils, frxFileUtils, frxUnicodeUtils, frxRes, frxrcExports, Math; + +{$R *.dfm} + +const + Xdivider = 1; + Ydivider = 1.03; + Navigator_src = + ''#13#10 + + '' + + '' + + '' + + ''#13#10 + + ''#13#10 + + '
'#13#10 + + ''#13#10 + + ''#13#10 + + ''#13#10 + + ''#13#10 + + ''#13#10 + + ''#13#10 + + ''#13#10 + + ''#13#10'%s' + + ''#13#10 + + ''#13#10 + + '
 %s:  
'; + Server_sect = + ''#13#10 + + ''#13#10; + DefPrint = 'parent.mainFrame.focus(); parent.mainFrame.print();'; + LinkPrint = 'parent.location = "%s";'; + DefRefresh = 'parent.location = "result?report=" + frRepName + "&multipage=" + frMultipage;'; + LinkRefresh = 'parent.location = "%s";'; + +{ TfrxHTMLExport } + +constructor TfrxHTMLExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FExportPictures := True; + FExportStyles := True; + FFixedWidth := True; + FUseJpeg := True; + FUseGif := False; + FServer := False; + FPrintLink := ''; + FBackground := False; + FCentered := False; + FBackImage := TBitmap.Create; + FilterDesc := frxGet(8210); + DefaultExt := frxGet(8211); + FEmptyLines := True; +end; + +class function TfrxHTMLExport.GetDescription: String; +begin + Result := frxResources.Get('HTMLexport'); +end; + +function TfrxHTMLExport.TruncReturns(const Str: WideString): WideString; +begin + if Copy(Str, Length(Str) - 1, 2) = #13#10 then + Result := Copy(Str, 1, Length(Str) - 2) + else + Result := Str; +end; + +function TfrxHTMLExport.ChangeReturns(const Str: String): String; +var + i: Integer; +begin + Result := ''; + for i := 1 to Length(Str) do + begin + if Str[i] = '&' then + Result := Result + '&' + else if (i < Length(Str)) and (Str[i] = #13) and (Str[i + 1] = #10) then + Result := Result + '
' + else if Str[i] = '"' then + Result := Result + '"' + else if (Str[i] <> #10) then + Result := Result + Str[i] + end; +end; + +procedure TfrxHTMLExport.WriteExpLn(const str: String); +begin + if Length(str) > 0 then + begin + Exp.Write(str[1], Length(str)); + Exp.Write(#13#10, 2); + end; +end; + +procedure TfrxHTMLExport.ExportPage; +var + i, x, y, dx, dy, fx, fy, pbk: Integer; + dcol, drow: Integer; + text, s, s1, sb, si, su: String; + Vert, Horiz: String; + obj: TfrxIEMObject; + EStyle: TfrxIEMStyle; + St, buff: String; + hlink, newpage: Boolean; + jpg : TJPEGImage; + tableheader, columnWidths: String; + + procedure AlignFR2AlignExcel(HAlign: TfrxHAlign; VAlign: TfrxVAlign; + var AlignH, AlignV: String); + begin + if HAlign = haLeft then + AlignH := 'Left' + else if HAlign = haRight then + AlignH := 'Right' + else if HAlign = haCenter then + AlignH := 'Center' + else if HAlign = haBlock then + AlignH := 'Justify' + else + AlignH := ''; + if VAlign = vaTop then + AlignV := 'Top' + else if VAlign = vaBottom then + AlignV := 'Bottom' + else if VAlign = vaCenter then + AlignV := 'Middle' + else + AlignV := ''; + end; + +begin + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + if Length(Report.ReportOptions.Name) > 0 then + s := Report.ReportOptions.Name + else + s := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), ''); + WriteExpLn('' + UTF8Encode(s) + ''); + + if FExportStyles then + begin + WriteExpLn(''); + end; + WriteExpLn(''); + WriteExpLn(''); + + WriteExpLn(''); + if FFixedWidth then + st := ' width="' + IntToStr(Round((FMatrix.MaxWidth - FMatrix.Left) / Xdivider)) + '"' + else + st := ''; + if FCentered then + st := st + ' align="center"'; + tableheader := ''); + + columnWidths := ''; + for x := 0 to FMatrix.Width - 2 do + begin + dcol := Round((FMatrix.GetXPosById(x + 1) - FMatrix.GetXPosById(x)) / Xdivider); + columnWidths := columnWidths + ''; + end; + if FMatrix.Width < 2 then + columnWidths := columnWidths + ''; + columnWidths := columnWidths + ''; + WriteExpLn(columnWidths); + + pbk := 0; + st := ''; + newpage := False; + + for y := 0 to FMatrix.Height - 2 do + begin + if ShowProgress and (not FMultipage) then + if FProgress.Terminated then + break; + drow := Round((FMatrix.GetYPosById(y + 1) - FMatrix.GetYPosById(y)) / Ydivider); + s := ''; + if FMatrix.PagesCount > pbk then + if Round(FMatrix.GetPageBreak(pbk)) <= Round(FMatrix.GetYPosById(y + 1)) then + begin + Inc(pbk); + if ShowProgress and (not FMultipage) then + FProgress.Tick; + newpage := True; + end; + if drow = 0 then + drow := 1; + WriteExpLn(''); + buff := ''; + for x := 0 to FMatrix.Width - 2 do + begin + if ShowProgress and (not FMultipage) then + if FProgress.Terminated then + break; + i := FMatrix.GetCell(x, y); + if (i <> -1) then + begin + Obj := FMatrix.GetObjectById(i); + if Obj.Counter = 0 then + begin + FMatrix.GetObjectPos(i, fx, fy, dx, dy); + Obj.Counter := 1; + if dx > 1 then + s := ' colspan="' + IntToStr(dx) + '"' + else + s := ''; + if dy > 1 then + sb := ' rowspan="' + IntToStr(dy) + '"' + else + sb := ''; + if FExportStyles then + st := ' class="' + 's' + IntToStr(Obj.StyleIndex) + '"' + else + st := ''; + if Length(Trim(Obj.Memo.Text)) = 0 then + st := st + ' style="font-size:1px"'; + + buff := buff + ''; + if Length(Obj.URL) > 0 then + begin + if Obj.URL[1] = '@' then + if FMultipage then + begin + Obj.URL := StringReplace(Obj.URL, '@', '', []); + Obj.URL := ReverseSlash(GetPicsFolderRel + Trim(Obj.URL) + '.html') + end + else + Obj.URL := StringReplace(Obj.URL, '@', '#PageN', []); + buff := buff + ''; + hlink := True; + end + else + hlink := False; + if Obj.IsText then + begin + text := Trim(ChangeReturns(UTF8Encode(TruncReturns(Obj.Memo.Text)))); + if Length(text) > 0 then + buff := buff + text + else + buff := buff + ' '; + end else + if Obj.Image <> nil then + begin + if FUseJpeg then + begin + s := GetPicsFolder + 'img' + IntToStr(FPicturesCount) + '.jpg'; + s1 := ExtractFilePath(s); + if (s1 = ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.files\')) or (s1 = '') then + s := ExtractFilePath(filename) + s; + jpg := TJPEGImage.Create; + jpg.Assign(Obj.Image); + jpg.SaveToFile(s); + jpg.Free; + s := ReverseSlash(GetPicsFolderRel + 'img' + IntToStr(FPicturesCount) + '.jpg'); + end else + if FUseGif then + begin + s := GetPicsFolder + 'img' + IntToStr(FPicturesCount) + '.gif'; + s1 := ExtractFilePath(s); + if (s1 = ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.files\')) or (s1 = '') then + s := ExtractFilePath(filename) + s; + GIFSaveToFile(s, Obj.Image); + s := ReverseSlash(GetPicsFolderRel + 'img' + IntToStr(FPicturesCount) + '.gif'); + end else + begin + s := GetPicsFolder + 'img' + IntToStr(FPicturesCount) + '.bmp'; + s1 := ExtractFilePath(s); + if (s1 = ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.files\')) or + (s1 = '') then + s := ExtractFilePath(filename) + s; + Obj.Image.SaveToFile(s); + s := ReverseSlash(GetPicsFolderRel + 'img' + IntToStr(FPicturesCount) + '.bmp'); + end; + buff := buff + ''; + Inc(FPicturesCount); + end; + if hlink then + buff := buff + ''; + buff := buff + ''; + end; + end + else + buff := buff + ''; + end; + WriteExpLn(buff); + WriteExpLn(''); + if newpage then + begin + WriteExpLn(''); + newpage := False; + if y < FMatrix.Height - 2 then + begin + WriteExpLn(''); + WriteExpLn(tableheader + ' class="page_break">'); + WriteExpLn(columnWidths); + end; + end; + end; + if FMultipage or (FMatrix.Height < 2) then + WriteExpLn(''); + WriteExpLn(''); +end; + +function TfrxHTMLExport.ShowModal: TModalResult; +begin + if not Assigned(Stream) then + begin + with TfrxHTMLExportDialog.Create(nil) do + begin + SendMessage(GetWindow(PFormatCB.Handle,GW_CHILD), EM_SETREADONLY, 1, 0); + OpenAfterCB.Visible := not SlaveExport; + PFormatCB.Enabled := not SlaveExport; + MultipageCB.Enabled := not SlaveExport; + BackgrCB.Enabled := not SlaveExport; + NavigatorCB.Enabled := not SlaveExport; + PicsSameCB.Enabled := not SlaveExport; + if SlaveExport then + begin + FOpenAfterExport := False; + FExportPictures := False; + FPicsInSameFolder := True; + FNavigator := False; + FMultipage := False; + FBackground := False; + end; + + if (FileName = '') and (not SlaveExport) then + SaveDialog1.FileName := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), SaveDialog1.DefaultExt) + else + SaveDialog1.FileName := FileName; + + StylesCB.Checked := FExportStyles; + PicsSameCB.Checked := FPicsInSameFolder; + if not FExportPictures then + PFormatCB.ItemIndex := 0 + else + begin + if FUseJpeg then + PFormatCB.ItemIndex := 1 + else if FUseGif then + PFormatCB.ItemIndex := 3 + else + PFormatCB.ItemIndex := 2 + end; + OpenAfterCB.Checked := FOpenAfterExport; + FixWidthCB.Checked := FFixedWidth; + NavigatorCB.Checked := FNavigator; + MultipageCB.Checked := FMultipage; + BackgrCB.Checked := FBackground; + + if PageNumbers <> '' then + begin + PageNumbersE.Text := PageNumbers; + PageNumbersRB.Checked := True; + end; + + Result := ShowModal; + if Result = mrOk then + begin + PageNumbers := ''; + CurPage := False; + if CurPageRB.Checked then + CurPage := True + else if PageNumbersRB.Checked then + PageNumbers := PageNumbersE.Text; + + FExportStyles := StylesCB.Checked; + FPicsInSameFolder := PicsSameCB.Checked; + FExportPictures := not (PFormatCB.ItemIndex = 0); + FUseJpeg := PFormatCB.ItemIndex = 1; + FUseGif := PFormatCB.ItemIndex = 3; + FOpenAfterExport := OpenAfterCB.Checked; + FFixedWidth := FixWidthCB.Checked; + FMultipage := MultipageCB.Checked; + FNavigator := NavigatorCB.Checked; + FBackground := BackgrCB.Checked; + + if not SlaveExport then + begin + if DefaultPath <> '' then + SaveDialog1.InitialDir := DefaultPath; + if SaveDialog1.Execute then + FileName := SaveDialog1.FileName + else + Result := mrCancel; + end + else + FileName := ChangeFileExt(GetTempFile, SaveDialog1.DefaultExt); + end; + Free; + end + end else + Result := mrOk; +end; + +function TfrxHTMLExport.Start: Boolean; +begin + if SlaveExport then + begin + FOpenAfterExport := False; + FExportPictures := False; + FPicsInSameFolder := True; + FNavigator := False; + FMultipage := False; + FBackground := False; + end; + if (FileName <> '') or Assigned(Stream) then + begin + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + FileName := DefaultPath + '\' + FileName; + FCurrentPage := 0; + FPicturesCount := 0; + FMatrix := TfrxIEMatrix.Create(UseFileCache, Report.EngineOptions.TempDir); + FMatrix.Report := Report; + if not FMultipage then + FMatrix.ShowProgress := ShowProgress + else + FMatrix.ShowProgress := False; + FMatrix.Inaccuracy := 0.5; + FMatrix.RotatedAsImage := True; + FMatrix.FramesOptimization := True; + FMatrix.Background := FBackground; + FMatrix.BackgroundImage := False; + FMatrix.Printable := ExportNotPrintable; + FMatrix.RichText := True; + FMatrix.PlainRich := True; + FMatrix.EmptyLines := EmptyLines; + if Assigned(Stream) then + begin + FMultipage := False; + FExportPictures := False; + FNavigator := False; + end; + Result := True + end + else + Result := False; +end; + +procedure TfrxHTMLExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + Inc(FCurrentPage); + FBackImageExist := False; + FBackImage.Width := 0; + FBackImage.Height := 0; +end; + +procedure TfrxHTMLExport.ExportObject(Obj: TfrxComponent); +begin + if (Obj is TfrxView) and (ExportNotPrintable or TfrxView(Obj).Printable) then + begin + if (Obj is TfrxCustomMemoView) or + (FExportPictures and (not (Obj is TfrxCustomMemoView))) then + FMatrix.AddObject(TfrxView(Obj)); + if (TfrxView(Obj).Name = '_pagebackground') and FExportPictures and FBackground then + begin + FBackImageExist := True; + FBackImage.Width := Round(TfrxView(Obj).Width); + FBackImage.Height := Round(TfrxView(Obj).Height); + TfrxView(Obj).Draw(FBackImage.Canvas ,1, 1, -TfrxView(Obj).AbsLeft, -TfrxView(Obj).AbsTop); + end; + end; +end; + +procedure TfrxHTMLExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + if FMultipage then + begin + FMatrix.Prepare; + try + Exp := TFileStream.Create(GetPicsFolder + IntToStr(FCurrentPage) + '.html', fmCreate); + try + ExportPage; + finally + FMatrix.Clear; + Exp.Free; + end; + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; + end + else FMatrix.AddPage(Page.Orientation, Page.Width, Page.Height, Page.LeftMargin, + Page.TopMargin, Page.RightMargin, Page.BottomMargin); +end; + +procedure TfrxHTMLExport.Finish; +var + s, st, serv, print: String; + Refresh: String; + +begin + if not FMultipage then + begin + if ShowProgress then + begin + FProgress := TfrxProgress.Create(Self); + FProgress.Execute(FCurrentPage - 1, frxResources.Get('ProgressWait'), true, true); + end; + FMatrix.Prepare; + try + if ShowProgress then + if FProgress.Terminated then + Exit; + if not Assigned(Stream) then + begin + if FNavigator then + Exp := TFileStream.Create(GetPicsFolder + 'main.html', fmCreate) + else + Exp := TFileStream.Create(FileName, fmCreate); + end + else + Exp := Stream; + try + ExportPage; + finally + FMatrix.Clear; + if not Assigned(Stream) then + Exp.Free; + end; + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; + if ShowProgress then + FProgress.Free; + end; + if FNavigator then + begin + try + Exp := TFileStream.Create(GetPicsFolder + 'nav.html', fmCreate); + try + if FMultipage then + s := '1' + else + s := '0'; + st := ''; + if FPicsInSameFolder then + st := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.'); + if FServer then + serv := Format(Server_sect, [UTF8Encode(frxResources.Get('HTMLNavRefresh')), UTF8Encode(frxResources.Get('HTMLNavPrint'))]) + else + serv := ''; + if Length(FPrintLink) > 0 then + print := Format(LinkPrint, [FPrintLink]) + else + print := DefPrint; + + if Length(FRefreshLink) > 0 then + refresh := Format(LinkRefresh, [FRefreshLink]) + else + refresh := DefRefresh; + + WriteExpLn(Format(Navigator_src, [ + IntToStr(FCurrentPage), + HTMLCodeStr(StringReplace(Report.FileName, FReportPath, '', [])), + s, st, Refresh, print, + UTF8Encode(frxResources.Get('HTMLNavFirst')), + UTF8Encode(frxResources.Get('HTMLNavPrev')), + UTF8Encode(frxResources.Get('HTMLNavNext')), + UTF8Encode(frxResources.Get('HTMLNavLast')), + serv, UTF8Encode(frxResources.Get('HTMLNavTotal'))])); + + finally + Exp.Free; + end; + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; + + try + Exp := TFileStream.Create(FileName, fmCreate); + try + WriteExpLn(''); + WriteExpLn(''); + if Length(Report.ReportOptions.Name) > 0 then + s := Report.ReportOptions.Name + else + s := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), ''); + WriteExpLn('' + UTF8Encode(s) + ''); + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + if FMultipage then + WriteExpLn('') + else + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + finally + Exp.Free; + end; + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; + end; + + FMatrix.Free; + + if FOpenAfterExport and (not Assigned(Stream)) then + if FMultipage and (not FNavigator) then + ShellExecute(GetDesktopWindow, 'open', PChar(GetPicsFolder + '1.html'), nil, nil, SW_SHOW) + else + ShellExecute(GetDesktopWindow, 'open', PChar(FileName), nil, nil, SW_SHOW); +end; + +function TfrxHTMLExport.GetPicsFolderRel: String; +begin + if FPicsInSameFolder then + Result := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.') + else if FMultipage then + Result := '' + else if FAbsLinks then + Result := ExtractFilePath(FileName) + ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)),'.files') + '\' + else if FNavigator then + Result := '' + else + Result := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)),'.files') + '\' +end; + +function TfrxHTMLExport.GetFrameFolder: String; +begin + if not FPicsInSameFolder then + Result := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)),'.files') + '\' + else + Result := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.'); +end; + +function TfrxHTMLExport.GetPicsFolder: String; +var + SecAtrtrs: TSecurityAttributes; +begin + if FPicsInSameFolder then + begin + if FAbsLinks then + Result := ExtractFilePath(FileName) + ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.') + else + Result := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.') + end + else + begin + if FAbsLinks then + Result := ExtractFilePath(FileName) + ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.files') + else + Result := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(FileName)), '.files'); + SecAtrtrs.nLength := SizeOf(TSecurityAttributes); + SecAtrtrs.lpSecurityDescriptor := nil; + SecAtrtrs.bInheritHandle := True; + CreateDirectory(PChar(Result), @SecAtrtrs); + Result := Result + '\'; + end; +end; + +function TfrxHTMLExport.ReverseSlash(const S: String): String; +begin + Result := StringReplace(S, '\', '/', [rfReplaceAll]); +end; + +destructor TfrxHTMLExport.Destroy; +begin + FBackImage.Free; + inherited; +end; + +function TfrxHTMLExport.HTMLCodeStr(const Str: String): String; +var + i: Integer; + c: Char; + s: String; + + function StrToHex(const s: String): String; + var + Len, i: Integer; + C, H, L: Byte; + + function HexChar(N : Byte) : Char; + begin + if (N < 10) then Result := Chr(Ord('0') + N) + else Result := Chr(Ord('A') + (N - 10)); + end; + + begin + Len := Length(s); + SetLength(Result, Len shl 1); + for i := 1 to Len do begin + C := Ord(s[i]); + H := (C shr 4) and $f; + L := C and $f; + Result[i shl 1 - 1] := HexChar(H); + Result[i shl 1]:= HexChar(L); + end; + end; + +begin + Result := ''; + for i := 1 to Length(Str) do + begin + c := Str[i]; + case c of + '0'..'9', 'A'..'Z', 'a'..'z': Result := Result + c; + else begin + s := c; + Result := Result + '%' + StrToHex(s); + end + end; + end; +end; + +procedure TfrxHTMLExport.SetUseGif(const Value: Boolean); +begin + FUseGif := Value; + if FUseJpeg and FUseGif then + FUseJpeg := False; +end; + +procedure TfrxHTMLExport.SetUseJpeg(const Value: Boolean); +begin + FUseJpeg := Value; + if FUseJpeg and FUseGif then + FUseGif := False; +end; + +{ TfrxHTMLExportDialog } + +procedure TfrxHTMLExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8200); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + GroupPageRange.Caption := frxGet(7); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + DescrL.Caption := frxGet(9); + GroupQuality.Caption := frxGet(8); + OpenAfterCB.Caption := frxGet(8201); + StylesCB.Caption := frxGet(8202); + PicturesL.Caption := frxGet(8203); + PicsSameCB.Caption := frxGet(8204); + FixWidthCB.Caption := frxGet(8205); + NavigatorCB.Caption := frxGet(8206); + MultipageCB.Caption := frxGet(8207); + BackgrCB.Caption := frxGet(8209); + SaveDialog1.Filter := frxGet(8210); + SaveDialog1.DefaultExt := frxGet(8211); + PFormatCB.Items[0] := frxGet(8313); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + + +procedure TfrxHTMLExportDialog.PageNumbersEChange(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxHTMLExportDialog.PageNumbersEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8, '-', ',':; + else + key := #0; + end; +end; + +procedure TfrxHTMLExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxExportImage.dfm b/official/4.2/LibD11/frxExportImage.dfm new file mode 100644 index 0000000..7403621 Binary files /dev/null and b/official/4.2/LibD11/frxExportImage.dfm differ diff --git a/official/4.2/LibD11/frxExportImage.pas b/official/4.2/LibD11/frxExportImage.pas new file mode 100644 index 0000000..5e970b9 --- /dev/null +++ b/official/4.2/LibD11/frxExportImage.pas @@ -0,0 +1,1172 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ BMP, JPEG, TIFF, GIF export filters } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportImage; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxClass, Jpeg +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +procedure GIFSaveToStream(const Stream: TStream; const Bitmap: TBitmap); +procedure GIFSaveToFile(const FileName: String; const Bitmap: TBitmap); + +type + TfrxCustomImageExport = class(TfrxCustomExportFilter) + private + FBitmap: TBitmap; + FCrop: Boolean; + FCurrentPage: Integer; + FJPEGQuality: Integer; + FMaxX: Integer; + FMaxY: Integer; + FMinX: Integer; + FMinY: Integer; + FMonochrome: Boolean; + FResolution: Integer; + FCurrentRes: Integer; + FSeparate: Boolean; + FYOffset: Integer; + FFileSuffix: String; + FFirstPage: Boolean; + FExportNotPrintable: Boolean; + function SizeOverflow(const Val: Extended): Boolean; + protected + FDiv: Extended; + procedure Save; virtual; + procedure FinishExport; + public + constructor Create(AOwner: TComponent); override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + procedure ExportObject(Obj: TfrxComponent); override; + + property JPEGQuality: Integer read FJPEGQuality write FJPEGQuality default 90; + property CropImages: Boolean read FCrop write FCrop default False; + property Monochrome: Boolean read FMonochrome write FMonochrome default False; + property Resolution: Integer read FResolution write FResolution; + property SeparateFiles: Boolean read FSeparate write FSeparate; + property ExportNotPrintable: Boolean read FExportNotPrintable write FExportNotPrintable; + end; + + TfrxBMPExport = class(TfrxCustomImageExport) + protected + procedure Save; override; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + published + property CropImages; + property Monochrome; + end; + + TfrxTIFFExport = class(TfrxCustomImageExport) + private + procedure SaveTiffToStream(const Stream: TStream; const Bitmap: TBitmap); + protected + procedure Save; override; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + published + property CropImages; + property Monochrome; + end; + + TfrxJPEGExport = class(TfrxCustomImageExport) + protected + procedure Save; override; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + published + property JPEGQuality; + property CropImages; + property Monochrome; + end; + + TfrxGIFExport = class(TfrxCustomImageExport) + protected + procedure Save; override; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + published + property CropImages; + property Monochrome; + end; + + TfrxIMGExportDialog = class(TForm) + OK: TButton; + Cancel: TButton; + GroupPageRange: TGroupBox; + GroupBox1: TGroupBox; + CropPage: TCheckBox; + Label2: TLabel; + Quality: TEdit; + Mono: TCheckBox; + SaveDialog1: TSaveDialog; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + Label1: TLabel; + Resolution: TEdit; + SeparateCB: TCheckBox; + procedure FormCreate(Sender: TObject); + procedure PageNumbersEChange(Sender: TObject); + procedure PageNumbersEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FFilter: TfrxCustomImageExport; + procedure SetFilter(const Value: TfrxCustomImageExport); + public + property Filter: TfrxCustomImageExport read FFilter write SetFilter; + end; + +implementation + +uses frxUtils, frxFileUtils, frxRes, frxrcExports; + +{$R *.dfm} + +type + PDirEntry = ^TDirEntry; + TDirEntry = record + _Tag: Word; + _Type: Word; + _Count: LongInt; + _Value: LongInt; + end; + +const + TifHeader: array[0..7] of Byte = ( + $49, $49, $2A, $00, $08, $00, $00, $00); + MAX_TBITMAP_HEIGHT = 30000; + MAXBITSCODES = 12; + HSIZE = 5003; + NullString: array[0..3] of Byte = ($00, $00, $00, $00); + Software: array[0..9] of Char = ('F', 'a', 's', 't', 'R', 'e', 'p', 'o', 'r', 't'); + code_mask: array [0..16] of cardinal = ($0000, $0001, $0003, $0007, $000F, + $001F, $003F, $007F, $00FF, $01FF, $03FF, $07FF, $0FFF, + $1FFF, $3FFF, $7FFF, $FFFF); + BitsPerSample: array[0..2] of Word = ($0008, $0008, $0008); + D_BW_C: array[0..13] of TDirEntry = ( + (_Tag: $00FE; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $0100; _Type: $0003; _Count: $00000001; _Value: $00000000), + (_Tag: $0101; _Type: $0003; _Count: $00000001; _Value: $00000000), + (_Tag: $0102; _Type: $0003; _Count: $00000001; _Value: $00000001), + (_Tag: $0103; _Type: $0003; _Count: $00000001; _Value: $00000001), + (_Tag: $0106; _Type: $0003; _Count: $00000001; _Value: $00000001), + (_Tag: $0111; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $0115; _Type: $0003; _Count: $00000001; _Value: $00000001), + (_Tag: $0116; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $0117; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $011A; _Type: $0005; _Count: $00000001; _Value: $00000000), + (_Tag: $011B; _Type: $0005; _Count: $00000001; _Value: $00000000), + (_Tag: $0128; _Type: $0003; _Count: $00000001; _Value: $00000002), + (_Tag: $0131; _Type: $0002; _Count: $0000000A; _Value: $00000000)); + D_COL_C: array[0..14] of TDirEntry = ( + (_Tag: $00FE; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $0100; _Type: $0003; _Count: $00000001; _Value: $00000000), + (_Tag: $0101; _Type: $0003; _Count: $00000001; _Value: $00000000), + (_Tag: $0102; _Type: $0003; _Count: $00000001; _Value: $00000008), + (_Tag: $0103; _Type: $0003; _Count: $00000001; _Value: $00000001), + (_Tag: $0106; _Type: $0003; _Count: $00000001; _Value: $00000003), + (_Tag: $0111; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $0115; _Type: $0003; _Count: $00000001; _Value: $00000001), + (_Tag: $0116; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $0117; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $011A; _Type: $0005; _Count: $00000001; _Value: $00000000), + (_Tag: $011B; _Type: $0005; _Count: $00000001; _Value: $00000000), + (_Tag: $0128; _Type: $0003; _Count: $00000001; _Value: $00000002), + (_Tag: $0131; _Type: $0002; _Count: $0000000A; _Value: $00000000), + (_Tag: $0140; _Type: $0003; _Count: $00000300; _Value: $00000008)); + D_RGB_C: array[0..14] of TDirEntry = ( + (_Tag: $00FE; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $0100; _Type: $0003; _Count: $00000001; _Value: $00000000), + (_Tag: $0101; _Type: $0003; _Count: $00000001; _Value: $00000000), + (_Tag: $0102; _Type: $0003; _Count: $00000003; _Value: $00000008), + (_Tag: $0103; _Type: $0003; _Count: $00000001; _Value: $00000001), + (_Tag: $0106; _Type: $0003; _Count: $00000001; _Value: $00000002), + (_Tag: $0111; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $0115; _Type: $0003; _Count: $00000001; _Value: $00000003), + (_Tag: $0116; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $0117; _Type: $0004; _Count: $00000001; _Value: $00000000), + (_Tag: $011A; _Type: $0005; _Count: $00000001; _Value: $00000000), + (_Tag: $011B; _Type: $0005; _Count: $00000001; _Value: $00000000), + (_Tag: $011C; _Type: $0003; _Count: $00000001; _Value: $00000001), + (_Tag: $0128; _Type: $0003; _Count: $00000001; _Value: $00000002), + (_Tag: $0131; _Type: $0002; _Count: $0000000A; _Value: $00000000)); + +{ TfrxCustomImageExport } + +constructor TfrxCustomImageExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FCrop := True; + FJPEGQuality := 90; + FResolution := 96; + FSeparate := True; + FExportNotPrintable := False; + CropImages := False; +end; + +function TfrxCustomImageExport.ShowModal: TModalResult; +begin + with TfrxIMGExportDialog.Create(nil) do + begin + Filter := Self; + Quality.Text := IntToStr(FJPEGQuality); + CropPage.Checked := FCrop; + Mono.Checked := FMonochrome; + Quality.Enabled := Self is TfrxJPEGExport; + Mono.Enabled := not (Self is TfrxGIFExport); + Resolution.Text := IntToStr(FResolution); + if SlaveExport then + begin + SeparateCB.Checked := False; + SeparateCB.Visible := False; + end + else + SeparateCB.Checked := FSeparate; + + if (FileName = '') and (not SlaveExport) then + SaveDialog1.FileName := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), SaveDialog1.DefaultExt) + else + SaveDialog1.FileName := FileName; + + if PageNumbers <> '' then + begin + PageNumbersE.Text := PageNumbers; + PageNumbersRB.Checked := True; + end; + + Result := ShowModal; + + if Result = mrOk then + begin + FJPEGQuality := StrToInt(Quality.Text); + FCrop := CropPage.Checked; + FMonochrome := Mono.Checked; + FResolution := StrToInt(Resolution.Text); + FSeparate := SeparateCB.Checked; + PageNumbers := ''; + CurPage := False; + if CurPageRB.Checked then + CurPage := True + else if PageNumbersRB.Checked then + PageNumbers := PageNumbersE.Text; + + if not SlaveExport then + begin + if DefaultPath <> '' then + SaveDialog1.InitialDir := DefaultPath; + if SaveDialog1.Execute then + FileName := SaveDialog1.FileName else + Result := mrCancel + end else + FileName := ChangeFileExt(GetTempFile, SaveDialog1.DefaultExt); + end; + Free; + end; +end; + +function TfrxCustomImageExport.Start: Boolean; +begin + if SlaveExport then + FSeparate := False; + CurPage := False; + FCurrentPage := 0; + FYOffset := 0; + if not FSeparate then + begin + FBitmap := TBitmap.Create; + FCurrentRes := FBitmap.Canvas.Font.PixelsPerInch; + FDiv := FResolution / FCurrentRes; + FBitmap.Canvas.Brush.Color := clWhite; + FBitmap.Monochrome := Monochrome; + FMaxX := 0; + FMaxY := 0; + FFirstPage := True; + end; + Result := (FileName <> '') or (Stream <> nil); + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + FileName := DefaultPath + '\' + FileName; +end; + +procedure TfrxCustomImageExport.StartPage(Page: TfrxReportPage; Index: Integer); +var + i: Extended; +begin + Inc(FCurrentPage); + if FSeparate then + begin + FBitmap := TBitmap.Create; + FCurrentRes := FBitmap.Canvas.Font.PixelsPerInch; + FDiv := FResolution / FCurrentRes; + FBitmap.Canvas.Brush.Color := clWhite; + FBitmap.Monochrome := Monochrome; + FBitmap.Width := Round(Page.Width * FDiv); + FBitmap.Height := Round(Page.Height * FDiv); + FMaxX := 0; + FMaxY := 0; + FMinX := FBitmap.Width; + FMinY := FBitmap.Height; + end else + begin + if FFirstpage then + begin + if FBitmap.Width < Round(Page.Width * FDiv) then + FBitmap.Width := Round(Page.Width * FDiv); + i := Page.Height * Report.PreviewPages.Count * FDiv; + if SizeOverflow(i) then + i := MAX_TBITMAP_HEIGHT; + FBitmap.Height := Round(i); + FFirstPage := False; + FMinX := FBitmap.Width; + FMinY := FBitmap.Height; + end; + end; +end; + +procedure TfrxCustomImageExport.ExportObject(Obj: TfrxComponent); +var + z: Integer; +begin + if (Obj is TfrxView) and (FExportNotPrintable or TfrxView(Obj).Printable) then + begin + if Obj.Name <> '_pagebackground' then + begin + z := Round(Obj.AbsLeft * FDiv); + if z < FMinX then + FMinX := z; + z := FYOffset + Round(Obj.AbsTop * FDiv); + if z < FMinY then + FMinY := z; + z := Round((Obj.AbsLeft + Obj.Width) * FDiv) + 1; + if z > FMaxX then + FMaxX := z; + z := FYOffset + Round((Obj.AbsTop + Obj.Height) * FDiv) + 1; + if z > FMaxY then + FMaxY := z; + end; + TfrxView(Obj).Draw(FBitmap.Canvas, FDiv, FDiv, 0, FYOffset); + end; +end; + +procedure TfrxCustomImageExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + if FSeparate then + FinishExport + else + FYOffset := FYOffset + Round(Page.Height * FDiv); +end; + +procedure TfrxCustomImageExport.Finish; +begin + if not FSeparate then + FinishExport; +end; + +procedure TfrxCustomImageExport.Save; +begin + if FSeparate then + FFileSuffix := '.' + IntToStr(FCurrentPage) + else + FFileSuffix := ''; +end; + +procedure TfrxCustomImageExport.FinishExport; +var + RFrom, RTo: TRect; +begin + try + if FCrop then + begin + RFrom := Rect(FMinX, FMinY, FMaxX, FMaxY); + RTo := Rect(0, 0, FMaxX - FMinX, FMaxY - FMinY); + FBitmap.Canvas.CopyRect(RTo, FBitmap.Canvas, RFrom); + FBitmap.Width := FMaxX - FMinX; + FBitmap.Height := FMaxY - FMinY; + end; + Save; + finally + FBitmap.Free; + end; +end; + +function TfrxCustomImageExport.SizeOverflow(const Val: Extended): Boolean; +begin + Result := Val > MAX_TBITMAP_HEIGHT; +end; + +{ TfrxIMGExportDialog } + +procedure TfrxIMGExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8600); + OK.Caption := frxGet(1); + Cancel.Caption := frxGet(2); + GroupPageRange.Caption := frxGet(7); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + DescrL.Caption := frxGet(9); + GroupBox1.Caption := frxGet(8601); + Label2.Caption := frxGet(8602); + Label1.Caption := frxGet(8603); + SeparateCB.Caption := frxGet(8604); + CropPage.Caption := frxGet(8605); + Mono.Caption := frxGet(8606); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxIMGExportDialog.SetFilter(const Value: TfrxCustomImageExport); +begin + FFilter := Value; + SaveDialog1.Filter := FFilter.FilterDesc; + SaveDialog1.DefaultExt := FFilter.DefaultExt; +end; + + +{ TfrxBMPExport } + +constructor TfrxBMPExport.Create(AOwner: TComponent); +begin + inherited; + FilterDesc := frxResources.Get('BMPexportFilter'); + DefaultExt := '.bmp'; +end; + +class function TfrxBMPExport.GetDescription: String; +begin + Result := frxResources.Get('BMPexport'); +end; + +procedure TfrxBMPExport.Save; +begin + inherited; + if Stream <> nil then + FBitmap.SaveToStream(Stream) + else + FBitmap.SaveToFile(ChangeFileExt(FileName, FFileSuffix + '.bmp')); +end; + + +{ TfrxTIFFExport } + +constructor TfrxTIFFExport.Create(AOwner: TComponent); +begin + inherited; + FilterDesc := frxResources.Get('TIFFexportFilter'); + DefaultExt := '.tif'; +end; + +class function TfrxTIFFExport.GetDescription: String; +begin + Result := frxResources.Get('TIFFexport'); +end; + +procedure TfrxTIFFExport.Save; +var + TFStream: TFileStream; +begin + inherited; + try + if Stream <> nil then + SaveTiffToStream(Stream, FBitmap) + else + begin + TFStream := TFileStream.Create(ChangeFileExt(FileName, FFileSuffix + '.tif'), fmCreate); + try + SaveTiffToStream(TFStream, FBitmap); + finally + TFStream.Free; + end; + end; + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; +end; + +procedure TfrxTIFFExport.SaveTIFFToStream(const Stream: TStream; const Bitmap: TBitmap); +var + i, k: Integer; + dib_f: Boolean; + Header, Bits, BitsPtr, TmpBitsPtr, NewBits: PChar; + HeaderSize, BitsSize: DWORD; + Width, Height, DataWidth, BitCount: Integer; + MapRed, MapGreen, MapBlue: array[0..255, 0..1] of Byte; + ColTabSize, BmpWidth: Integer; + Red, Blue, Green: Char; + O_XRes, O_YRes, O_Soft, O_Strip, O_Dir, O_BPS: LongInt; + RGB: Word; + Res: Word; + NoOfDirs: array[0..1] of Byte; + D_BW: array[0..13] of TDirEntry; + D_COL: array[0..14] of TDirEntry; + D_RGB: array[0..14] of TDirEntry; + Res_Value: array[0..7] of Byte; +begin + if Bitmap.Handle = 0 then Exit; + NoOfDirs[1] := 0; + Res := FResolution * 10; + Res_Value[0] := Res and $00ff; + Res_Value[1] := (Res and $ff00) shr 8; + Res_Value[2] := 0; + Res_Value[3] := 0; + Res_Value[4] := $0A; + Res_Value[5] := 0; + Res_Value[6] := 0; + Res_Value[7] := 0; + GetDIBSizes(Bitmap.Handle, HeaderSize, BitsSize); + Header := GlobalAllocPtr(GMEM_MOVEABLE or GMEM_SHARE, HeaderSize + BitsSize); + try + Bits := Header + HeaderSize; + dib_f := GetDIB(Bitmap.Handle, Bitmap.Palette, Header^, Bits^); + if dib_f then + begin + Width := PBITMAPINFO(Header)^.bmiHeader.biWidth; + Height := PBITMAPINFO(Header)^.bmiHeader.biHeight; + BitCount := PBITMAPINFO(Header)^.bmiHeader.biBitCount; + NoOfDirs[0] := $0F; + ColTabSize := (1 shl BitCount); + BmpWidth := Trunc(BitsSize / Height); + Stream.Write(TifHeader, sizeof(TifHeader)); + if BitCount = 1 then + begin + CopyMemory(@D_BW, @D_BW_C, SizeOf(D_BW)); + NoOfDirs[0] := $0E; + O_XRes := Stream.Position; + Stream.Write(Res_Value, sizeof(Res_Value)); + O_YRes := Stream.Position; + Stream.Write(Res_Value, sizeof(Res_Value)); + O_Soft := Stream.Position; + Stream.Write(Software, sizeof(Software)); + DataWidth := ((Width + 7) div 8); + O_Strip := Stream.Position; + if Height < 0 then + for i := 0 to Height - 1 do + begin + BitsPtr := Bits + i * BmpWidth; + Stream.Write(BitsPtr^, DataWidth); + end + else + for i := 1 to Height do + begin + BitsPtr := Bits + (Height - i) * BmpWidth; + Stream.Write(BitsPtr^, DataWidth); + end; + Stream.Write(NullString, sizeof(NullString)); + D_BW[1]._Value := LongInt(Width); + D_BW[2]._Value := LongInt(abs(Height)); + D_BW[8]._Value := LongInt(abs(Height)); + D_BW[9]._Value := LongInt(DataWidth * abs(Height)); + D_BW[6]._Value := O_Strip; + D_BW[10]._Value := O_XRes; + D_BW[11]._Value := O_YRes; + D_BW[13]._Value := O_Soft; + O_Dir := Stream.Position; + Stream.Write(NoOfDirs, sizeof(NoOfDirs)); + Stream.Write(D_BW, sizeof(D_BW)); + Stream.Write(NullString, sizeof(NullString)); + Stream.Seek(4, soFromBeginning); + Stream.Write(O_Dir, sizeof(O_Dir)); + end; + if BitCount in [4, 8] then + begin + CopyMemory(@D_COL, @D_COL_C, SizeOf(D_COL)); + DataWidth := Width; + if BitCount = 4 then + begin + Width := (Width div BitCount) * BitCount; + if BitCount = 4 then + DataWidth := Width div 2; + end; + D_COL[1]._Value := LongInt(Width); + D_COL[2]._Value := LongInt(abs(Height)); + D_COL[3]._Value := LongInt(BitCount); + D_COL[8]._Value := LongInt(Height); + D_COL[9]._Value := LongInt(DataWidth * abs(Height)); + for i := 0 to ColTabSize - 1 do + begin + MapRed[i][1] := PBITMAPINFO(Header)^.bmiColors[i].rgbRed; + MapRed[i][0] := 0; + MapGreen[i][1] := PBITMAPINFO(Header)^.bmiColors[i].rgbGreen; + MapGreen[i][0] := 0; + MapBlue[i][1] := PBITMAPINFO(Header)^.bmiColors[i].rgbBlue; + MapBlue[i][0] := 0; + end; + D_COL[14]._Count := LongInt(ColTabSize * 3); + Stream.Write(MapRed, ColTabSize * 2); + Stream.Write(MapGreen, ColTabSize * 2); + Stream.Write(MapBlue, ColTabSize * 2); + O_XRes := Stream.Position; + Stream.Write(Res_Value, sizeof(Res_Value)); + O_YRes := Stream.Position; + Stream.Write(Res_Value, sizeof(Res_Value)); + O_Soft := Stream.Position; + Stream.Write(Software, sizeof(Software)); + O_Strip := Stream.Position; + if Height < 0 then + for i := 0 to Height - 1 do + begin + BitsPtr := Bits + i * BmpWidth; + Stream.Write(BitsPtr^, DataWidth); + end + else + for i := 1 to Height do + begin + BitsPtr := Bits + (Height - i) * BmpWidth; + Stream.Write(BitsPtr^, DataWidth); + end; + D_COL[6]._Value := O_Strip; + D_COL[10]._Value := O_XRes; + D_COL[11]._Value := O_YRes; + D_COL[13]._Value := O_Soft; + O_Dir := Stream.Position; + Stream.Write(NoOfDirs, sizeof(NoOfDirs)); + Stream.Write(D_COL, sizeof(D_COL)); + Stream.Write(NullString, sizeof(NullString)); + Stream.Seek(4, soFromBeginning); + Stream.Write(O_Dir, sizeof(O_Dir)); + end; + if BitCount = 16 then + begin + CopyMemory(@D_RGB, @D_RGB_C, SizeOf(D_RGB)); + D_RGB[1]._Value := LongInt(Width); + D_RGB[2]._Value := LongInt(Height); + D_RGB[8]._Value := LongInt(Height); + D_RGB[9]._Value := LongInt(3 * Width * Height); + O_XRes := Stream.Position; + Stream.Write(Res_Value, sizeof(Res_Value)); + O_YRes := Stream.Position; + Stream.Write(Res_Value, sizeof(Res_Value)); + O_BPS := Stream.Position; + Stream.Write(BitsPerSample, sizeof(BitsPerSample)); + O_Soft := Stream.Position; + Stream.Write(Software, sizeof(Software)); + O_Strip := Stream.Position; + GetMem(NewBits, Width * Height * 3); + for i := 0 to Height - 1 do + begin + BitsPtr := Bits + i * BmpWidth; + TmpBitsPtr := NewBits + i * Width * 3; + for k := 0 to Width - 1 do + begin + RGB := PWord(BitsPtr)^; + Blue := Char((RGB and $1F) shl 3 or $7); + Green := Char((RGB shr 5 and $1F) shl 3 or $7); + Red := Char((RGB shr 10 and $1F) shl 3 or $7); + PByte(TmpBitsPtr)^ := Byte(Red); + PByte(TmpBitsPtr + 1)^ := Byte(Green); + PByte(TmpBitsPtr + 2)^ := Byte(Blue); + BitsPtr := BitsPtr + 2; + TmpBitsPtr := TmpBitsPtr + 3; + end; + end; + for i := 1 to Height do + begin + TmpBitsPtr := NewBits + (Height - i) * Width * 3; + Stream.Write(TmpBitsPtr^, Width * 3); + end; + FreeMem(NewBits); + D_RGB[3]._Value := O_BPS; + D_RGB[6]._Value := O_Strip; + D_RGB[10]._Value := O_XRes; + D_RGB[11]._Value := O_YRes; + D_RGB[14]._Value := O_Soft; + O_Dir := Stream.Position; + Stream.Write(NoOfDirs, sizeof(NoOfDirs)); + Stream.Write(D_RGB, sizeof(D_RGB)); + Stream.Write(NullString, sizeof(NullString)); + Stream.Seek(4, soFromBeginning); + Stream.Write(O_Dir, sizeof(O_Dir)); + end; + if BitCount in [24, 32] then + begin + CopyMemory(@D_RGB, @D_RGB_C, SizeOf(D_RGB)); + D_RGB[1]._Value := LongInt(Width); + D_RGB[2]._Value := LongInt(Height); + D_RGB[8]._Value := LongInt(Height); + D_RGB[9]._Value := LongInt(3 * Width * Height); + O_XRes := Stream.Position; + Stream.Write(Res_Value, sizeof(Res_Value)); + O_YRes := Stream.Position; + Stream.Write(Res_Value, sizeof(Res_Value)); + O_BPS := Stream.Position; + Stream.Write(BitsPerSample, sizeof(BitsPerSample)); + O_Soft := Stream.Position; + Stream.Write(Software, sizeof(Software)); + O_Strip := Stream.Position; + for i := 0 to Height - 1 do + begin + BitsPtr := Bits + i * BmpWidth; + for k := 0 to Width - 1 do + begin + Blue := (BitsPtr)^; + Red := (BitsPtr + 2)^; + (BitsPtr)^ := Red; + (BitsPtr + 2)^ := Blue; + BitsPtr := BitsPtr + BitCount div 8; + end; + end; + if BitCount = 32 then + for i := 0 to Height - 1 do + begin + BitsPtr := Bits + i * BmpWidth; + TmpBitsPtr := BitsPtr; + for k := 0 to Width - 1 do + begin + (TmpBitsPtr)^ := (BitsPtr)^; + (TmpBitsPtr + 1)^ := (BitsPtr + 1)^; + (TmpBitsPtr + 2)^ := (BitsPtr + 2)^; + TmpBitsPtr := TmpBitsPtr + 3; + BitsPtr := BitsPtr + 4; + end; + end; + BmpWidth := Trunc(BitsSize / Height); + if Height < 0 then + for i := 0 to Height - 1 do + begin + BitsPtr := Bits + i * BmpWidth; + Stream.Write(BitsPtr^, Width * 3); + end + else + for i := 1 to Height do + begin + BitsPtr := Bits + (Height - i) * BmpWidth; + Stream.Write(BitsPtr^, Width * 3); + end; + D_RGB[3]._Value := O_BPS; + D_RGB[6]._Value := O_Strip; + D_RGB[10]._Value := O_XRes; + D_RGB[11]._Value := O_YRes; + D_RGB[14]._Value := O_Soft; + O_Dir := Stream.Position; + Stream.Write(NoOfDirs, sizeof(NoOfDirs)); + Stream.Write(D_RGB, sizeof(D_RGB)); + Stream.Write(NullString, sizeof(NullString)); + Stream.Seek(4, soFromBeginning); + Stream.Write(O_Dir, sizeof(O_Dir)); + end; + end; + finally + GlobalFreePtr(Header); + end; +end; + + +{ TfrxJPEGExport } + +constructor TfrxJPEGExport.Create(AOwner: TComponent); +begin + inherited; + FilterDesc := frxResources.Get('JPEGexportFilter'); + DefaultExt := '.jpg'; +end; + +class function TfrxJPEGExport.GetDescription: String; +begin + Result := frxResources.Get('JPEGexport'); +end; + +procedure TfrxJPEGExport.Save; +var + Image: TJPEGImage; + TFStream: TFileStream; +begin + inherited; + try + if Stream <> nil then + begin + Image := TJPEGImage.Create; + try + Image.CompressionQuality := FJPEGQuality; + Image.Assign(FBitmap); + Image.SaveToStream(Stream); + finally + Image.Free; + end; + end + else + begin + TFStream := TFileStream.Create(ChangeFileExt(FileName, FFileSuffix + '.jpg'), fmCreate); + try + Image := TJPEGImage.Create; + try + Image.CompressionQuality := FJPEGQuality; + Image.Assign(FBitmap); + Image.SaveToStream(TFStream); + finally + Image.Free; + end; + finally + TFStream.Free; + end; + end; + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; +end; + +{ TfrxGIFExport } + +procedure GIFSaveToFile(const FileName: String; const Bitmap: TBitmap); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmCreate); + try + GIFSaveToStream(f, Bitmap); + finally + f.Free; + end; +end; + +procedure GIFSaveToStream(const Stream: TStream; const Bitmap: TBitmap); +var + w, h: word; + flags, b: byte; + i: Integer; + Palette: array [0..255] of PALETTEENTRY; + s: String; + CountDown: Integer; + curx, cury: Integer; + htab: array [0..HSIZE] of longint; + codetab: array [0..HSIZE] of integer; + accum: array [0..255] of byte; + a_count: integer; + InitCodeSize: Integer; + g_init_bits: Integer; + maxcode, free_ent: integer; + cur_accum: cardinal; + cur_bits, clear_flg, clearcode, EOFCode, n_bits: Integer; + + function GifNextPixel: Integer; + var + P : PByteArray; + begin + if CountDown = 0 then + Result := -1 + else begin + Dec(CountDown); + P := Bitmap.ScanLine[cury]; + Result := P[curx]; + Inc(curx); + if curx = Bitmap.Width then + begin + curx := 0; + Inc(cury); + end; + end; + end; + + procedure Putword(const w: Integer); + begin + Stream.Write(w, 2); + end; + + procedure cl_hash(const hsize: longint); + var + i: longint; + begin + for i := 0 to hsize - 1 do + htab[i] := -1; + end; + + procedure flush_char; + var + b: byte; + begin + if a_count > 0 then + begin + b := byte(a_count); + Stream.Write(b, 1); + Stream.Write(accum, a_count); + a_count := 0; + end; + end; + + procedure char_out(c: byte); + begin + accum[a_count] := c; + Inc(a_count); + if a_count >= 254 then + flush_char; + end; + + procedure output(const code: Integer); + begin + cur_accum := cur_accum and code_mask[cur_bits]; + if cur_bits > 0 then + cur_accum := cur_accum or (cardinal(code) shl cur_bits) + else + cur_accum := code; + cur_bits := cur_bits + n_bits; + while cur_bits >= 8 do + begin + char_out(cur_accum and $ff); + cur_accum := cur_accum shr 8; + cur_bits := cur_bits - 8; + end; + if (free_ent > maxcode) or (clear_flg <> 0) then + begin + if clear_flg <> 0 then + begin + n_bits := g_init_bits; + maxcode := (1 shl n_bits) - 1; + clear_flg := 0; + end + else begin + Inc(n_bits); + if n_bits = MAXBITSCODES then + maxcode := 1 shl MAXBITSCODES + else + maxcode := (1 shl n_bits) - 1; + end; + end; + if code = EOFCode then + begin + while cur_bits > 0 do + begin + char_out(cur_accum and $ff); + cur_accum := cur_accum shr 8; + cur_bits := cur_bits - 8; + end; + flush_char; + end; + end; + + procedure compressLZW(const init_bits: Integer); + var + fcode, c, ent, hshift, disp, i: longint; + maxmaxcode: integer; + label probe; + label nomatch; + begin + g_init_bits := init_bits; + cur_accum := 0; + cur_bits := 0; + clear_flg := 0; + n_bits := g_init_bits; + maxcode := (1 shl g_init_bits) - 1; + maxmaxcode := 1 shl MAXBITSCODES; + ClearCode := 1 shl (init_bits - 1); + EOFCode := ClearCode + 1; + free_ent := ClearCode + 2; + a_count := 0; + ent := GifNextPixel; + hshift := 0; + fcode := HSIZE; + while fcode < 65536 do + begin + fcode := fcode * 2; + hshift := hshift + 1; + end; + hshift := 8 - hshift; + cl_hash(HSIZE); + output(ClearCode); + c := GifNextPixel; + while c <> -1 do + begin + fcode := longint((longint(c) shl MAXBITSCODES) + ent); + i := ((c shl hshift) xor ent); + if HTab[i] = fcode then + begin + ent := CodeTab[i]; + c := GifNextPixel; + continue; + end + else if HTab[i] < 0 then + goto nomatch; + disp := HSIZE - i; + if i = 0 then + disp := 1; + probe: + i := i - disp; + if i < 0 then i := i + HSIZE; + if HTab[i] = fcode then + begin + ent := CodeTab[i]; + c := GifNextPixel; + continue; + end; + if HTab[i] > 0 then + goto probe; + nomatch: + output(ent); + ent := c; + if free_ent < maxmaxcode then + begin + CodeTab[i] := free_ent; + free_ent := free_ent + 1; + HTab[i] := fcode; + end + else begin + cl_hash(HSIZE); + free_ent := ClearCode + 2; + clear_flg := 1; + output(ClearCode); + end; + c := GifNextPixel; + end; + output(ent); + output(EOFCode); + end; + +begin + Bitmap.PixelFormat := pf8bit; + Stream.Write('GIF89a', 6); + w := Bitmap.Width; + h := Bitmap.Height; + Stream.Write(w, 2); + Stream.Write(h, 2); + flags := $e7; + Stream.Write(flags, 1); + flags := 0; + Stream.Write(flags, 1); + Stream.Write(flags, 1); + GetPaletteEntries(Bitmap.Palette, 0, 256, Palette); + for i := 0 to 255 do + begin + Stream.Write(Palette[i].peRed, 1); + Stream.Write(Palette[i].peGreen, 1); + Stream.Write(Palette[i].peBlue, 1); + end; + Stream.Write(String('!'), 1); + flags := $F9; + Stream.Write(flags, 1); + flags := 4; + Stream.Write(flags, 1); + flags := 0; + Stream.Write(flags, 1); + Stream.Write(flags, 1); + Stream.Write(flags, 1); + Stream.Write(flags, 1); + Stream.Write(flags, 1); + Stream.Write(String('!'), 1); + flags := 254; + Stream.Write(flags, 1); + s := 'FastReport'; + flags := Length(s); + Stream.Write(flags, 1); + Stream.Write(s[1], flags); + flags := 0; + Stream.Write(flags, 1); + curx := 0; + cury := 0; + CountDown := Bitmap.Width * Bitmap.Height; + Stream.Write(String(','), 1); + Putword(0); + Putword(0); + Putword(Bitmap.Width); + Putword(Bitmap.Height); + flags := 0; + Stream.Write(flags, 1); + InitCodeSize := 8; + b := byte(InitCodeSize); + Stream.Write(b, 1); + compressLZW(InitCodeSize + 1); + flags := 0; + Stream.Write(flags, 1); + Stream.Write(String(';'), 1); +end; + +constructor TfrxGIFExport.Create(AOwner: TComponent); +begin + inherited; + FilterDesc := frxResources.Get('GifexportFilter'); + DefaultExt := '.gif'; +end; + +class function TfrxGIFExport.GetDescription: String; +begin + Result := frxResources.Get('GIFexport'); +end; + +procedure TfrxGIFExport.Save; +var + TFStream: TFileStream; +begin + inherited; + try + if Stream <> nil then + GIFSaveToStream(Stream, FBitmap) + else + begin + TFStream := TFileStream.Create(ChangeFileExt(FileName, FFileSuffix + '.gif'), fmCreate); + try + GIFSaveToStream(TFStream, FBitmap); + finally + TFStream.Free; + end; + end; + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; +end; + +procedure TfrxIMGExportDialog.PageNumbersEChange(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxIMGExportDialog.PageNumbersEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8, '-', ',':; + else + key := #0; + end; +end; + +procedure TfrxIMGExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + diff --git a/official/4.2/LibD11/frxExportMail.dfm b/official/4.2/LibD11/frxExportMail.dfm new file mode 100644 index 0000000..0472ec5 Binary files /dev/null and b/official/4.2/LibD11/frxExportMail.dfm differ diff --git a/official/4.2/LibD11/frxExportMail.pas b/official/4.2/LibD11/frxExportMail.pas new file mode 100644 index 0000000..712f8ee --- /dev/null +++ b/official/4.2/LibD11/frxExportMail.pas @@ -0,0 +1,477 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ E-mail export } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportMail; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, extctrls, frxClass, IniFiles, ComCtrls, frxSMTP +{$IFDEF Delphi6}, Variants {$ENDIF}; + +type + TfrxMailExportDialog = class(TForm) + OkB: TButton; + CancelB: TButton; + PageControl1: TPageControl; + ExportSheet: TTabSheet; + MessageGroup: TGroupBox; + AddressLB: TLabel; + SubjectLB: TLabel; + MessageLB: TLabel; + MessageM: TMemo; + AttachGroup: TGroupBox; + ExportsCombo: TComboBox; + FormatLB: TLabel; + SettingCB: TCheckBox; + AccountSheet: TTabSheet; + MailGroup: TGroupBox; + RememberCB: TCheckBox; + AccountGroup: TGroupBox; + FromNameE: TEdit; + FromNameLB: TLabel; + FromAddrE: TEdit; + FromAddrLB: TLabel; + OrgLB: TLabel; + OrgE: TEdit; + SignatureLB: TLabel; + SignatureM: TMemo; + HostLB: TLabel; + HostE: TEdit; + PortE: TEdit; + PortLB: TLabel; + LoginLB: TLabel; + LoginE: TEdit; + PasswordE: TEdit; + PasswordLB: TLabel; + SignBuildBtn: TButton; + AddressE: TComboBox; + SubjectE: TComboBox; + ReqLB: TLabel; + procedure FormCreate(Sender: TObject); + procedure SignBuildBtnClick(Sender: TObject); + procedure OkBClick(Sender: TObject); + procedure PortEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + end; + + TfrxMailExport = class(TfrxCustomExportFilter) + private + FExportFilter: TfrxCustomExportFilter; + FAddress: String; + FSubject: String; + FMessage: TStrings; + FShowExportDialog: Boolean; + FOldSlaveStatus: Boolean; + FFromName: String; + FFromMail: String; + FFromCompany: String; + FSignature: TStrings; + FSmtpHost: String; + FSmtpPort: Integer; + FLogin: String; + FPassword: String; + FUseIniFile: Boolean; + FLogFile: String; + procedure SetMessage(const Value: TStrings); + procedure SetSignature(const Value: TStrings); + protected + property DefaultPath; + property Stream; + property CurPage; + property PageNumbers; + property FileName; + property UseFileCache; + property ExportNotPrintable; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + function Mail(const Server: String; const Port: Integer;const + UserField, PasswordField, FromField, ToField, SubjectField, + TextField, FileName, AttachName: String): String; + procedure ExportObject(Obj: TfrxComponent); override; + property ExportFilter: TfrxCustomExportFilter read FExportFilter write FExportFilter; + published + property Address: String read FAddress write FAddress; + property Subject: String read FSubject write FSubject; + property Lines: TStrings read FMessage write SetMessage; + property ShowExportDialog: Boolean read FShowExportDialog write FShowExportDialog; + property FromMail: String read FFromMail write FFromMail; + property FromName: String read FFromName write FFromName; + property FromCompany: String read FFromCompany write FFromCompany; + property Signature: TStrings read FSignature write SetSignature; + property SmtpHost: String read FSmtpHost write FSmtpHost; + property SmtpPort: Integer read FSmtpPort write FSmtpPort; + property Login: String read FLogin write Flogin; + property Password: String read FPassword write FPassword; + property UseIniFile: Boolean read FUseIniFile write FUseIniFile; + property LogFile: String read FLogFile write FLogFile; + end; + + +implementation + +uses frxDsgnIntf, frxFileUtils, frxNetUtils, frxUtils, + frxUnicodeUtils, frxRes, frxrcExports, Registry; + +{$R *.dfm} + +const + EMAIL_EXPORT_SECTION = 'EmailExport'; + +{ TfrxMailExport } + +constructor TfrxMailExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FAddress := ''; + FSubject := ''; + FMessage := TStringList.Create; + FShowExportDialog := True; + FFromName := ''; + FFromMail := ''; + FFromCompany := ''; + FSignature := TStringList.Create; + FSmtpHost := ''; + FSmtpPort := 25; + FLogin := ''; + FPassword := ''; + FUseIniFile := True; +end; + +destructor TfrxMailExport.Destroy; +begin + FMessage.Free; + FSignature.Free; + inherited; +end; + +class function TfrxMailExport.GetDescription: String; +begin + Result := frxResources.Get('EmailExport'); +end; + +function TfrxMailExport.ShowModal: TModalResult; +var + i: Integer; + ini: TCustomIniFile; + Section: String; +begin + with TfrxMailExportDialog.Create(nil) do + begin + try + AttachGroup.Visible := not SlaveExport; + SendMessage(GetWindow(ExportsCombo.Handle,GW_CHILD), EM_SETREADONLY, 1, 0); + for i := 0 to frxExportFilters.Count - 1 do + begin + if (TfrxCustomExportFilter(frxExportFilters[i].Filter).ClassName <> 'TfrxDotMatrixExport') + and (TfrxCustomExportFilter(frxExportFilters[i].Filter).ClassName <> 'TfrxMailExport') then + ExportsCombo.Items.AddObject(TfrxCustomExportFilter(frxExportFilters[i].Filter).GetDescription, TfrxCustomExportFilter(frxExportFilters[i].Filter)); + end; + ExportsCombo.Items.AddObject(frxResources.Get('FastReportFile'), nil); + SettingCB.Checked := ShowExportDialog; + if Assigned(Report) then + ini := Report.GetIniFile + else + ini := TRegistryIniFile.Create('\Software\Fast Reports'); + try + if not FUseIniFile then + RememberCB.Visible := False; + + Section := EMAIL_EXPORT_SECTION + '.Properties'; + + if ini.SectionExists(Section) and FUseIniFile then + begin + FromNameE.Text := ini.ReadString(Section, 'FromName', ''); + FromAddrE.Text := ini.ReadString(Section, 'FromAddress', ''); + OrgE.Text := ini.ReadString(Section, 'Organization', ''); + SignatureM.Lines.Text := ini.ReadString(Section, 'Signature', ''); + HostE.Text := ini.ReadString(Section, 'SmtpHost', ''); + PortE.Text := ini.ReadString(Section, 'SmtpPort', '25'); + LoginE.Text := Base64Decode(ini.ReadString(Section, 'Login', '')); + PasswordE.Text := Base64Decode(ini.ReadString(Section, 'Password', '')); + ExportsCombo.ItemIndex := ini.ReadInteger(Section, 'LastUsedExport', 0); + ini.ReadSection(EMAIL_EXPORT_SECTION + '.RecentAddresses' , AddressE.Items); + ini.ReadSection(EMAIL_EXPORT_SECTION + '.RecentSubjects' , SubjectE.Items); + end + else begin + FromNameE.Text := FFromName; + FromAddrE.Text := FFromMail; + OrgE.Text := FFromCompany; + SignatureM.Lines.Text := FSignature.Text; + HostE.Text := FSmtpHost; + PortE.Text := IntToStr(FSmtpPort); + LoginE.Text := FLogin; + PasswordE.Text := FPassword; + if not Assigned(FExportFilter) then + ExportsCombo.ItemIndex := 0 + else + ExportsCombo.ItemIndex := ExportsCombo.Items.IndexOfObject(FExportFilter); + end; + + AddressE.Text := FAddress; + SubjectE.Text := FSubject; + MessageM.Text := FMessage.Text; + + Result := ShowModal; + + if Result = mrOk then + begin + FAddress := AddressE.Text; + FFromName := FromNameE.Text; + FFromMail := FromAddrE.Text; + FFromCompany := OrgE.Text; + FSignature.Text := SignatureM.Lines.Text; + FSmtpHost := HostE.Text; + FSmtpPort := StrToInt(PortE.Text); + FLogin := LoginE.Text; + FPassword := PasswordE.Text; + FSubject := SubjectE.Text; + FMessage.Text := MessageM.Lines.Text; + + if RememberCB.Checked and FUseIniFile then + begin + ini.WriteString(Section, 'FromName', FromNameE.Text); + ini.WriteString(Section, 'FromAddress', FromAddrE.Text); + ini.WriteString(Section, 'Organization', OrgE.Text); + ini.WriteString(Section, 'Signature', SignatureM.Lines.Text); + ini.WriteString(Section, 'SmtpHost', HostE.Text); + ini.WriteString(Section, 'SmtpPort', PortE.Text); + ini.WriteString(Section, 'Login', Base64Encode(LoginE.Text)); + ini.WriteString(Section, 'Password', Base64Encode(PasswordE.Text)); + end; + if FUseIniFile then + begin + ini.WriteInteger(Section, 'LastUsedExport', ExportsCombo.ItemIndex); + ini.WriteString(EMAIL_EXPORT_SECTION + '.RecentAddresses' , AddressE.Text, ''); + ini.WriteString(EMAIL_EXPORT_SECTION + '.RecentSubjects' , SubjectE.Text, ''); + end; + ShowExportDialog := SettingCB.Checked; + FExportFilter := TfrxCustomExportFilter(ExportsCombo.Items.Objects[ExportsCombo.ItemIndex]); + end; + finally + ini.Free; + end; + finally + Free; + end; + end; +end; + +function TfrxMailExport.Start: Boolean; +var + s, f: String; + fname: String; +begin + s := ''; + if Assigned(FExportFilter) and (FExportFilter.FileName <> '') then + f := ExtractFileName(frxUnixPath2WinPath(FExportFilter.FileName)) + else if Report.ReportOptions.Name = '' then + f := StringReplace(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), ExtractFileExt(frxUnixPath2WinPath(Report.FileName)), '', []) + else + f := Report.ReportOptions.Name; + if Assigned(FExportFilter) and (FExportFilter.FileName = '') then + f := f + FExportFilter.DefaultExt; // ExtractFileExt(FExportFilter.FileName); + if Assigned(FExportFilter) then + begin + FOldSlaveStatus := FExportFilter.SlaveExport; + FExportFilter.SlaveExport := True; + try + FExportFilter.ShowDialog := ShowDialog and ShowExportDialog; + FExportFilter.ShowProgress := ShowProgress; + if Report.Export(FExportFilter) then + begin + s := Mail(FSmtpHost, FSmtpPort, FLogin, FPassword, FFromMail, FAddress, + FSubject, FMessage.Text + FSignature.Text, FExportFilter.FileName, f); + end; + finally + DeleteFile(FExportFilter.FileName); + FExportFilter.FileName := ''; + FExportFilter.SlaveExport := FOldSlaveStatus; + end; + end + else begin + f := f + '.fp3'; + fname := GetTempFile; + Report.PreviewPages.SaveToFile(fname); + try + s := Mail(FSmtpHost, FSmtpPort, FLogin, FPassword, FFromMail, FAddress, + FSubject, FMessage.Text + FSignature.Text, fname, f); + finally + DeleteFile(fname); + end; + end; + if s <> '' then + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(s); + simMessageBoxes: frxErrorMsg(s); + simReThrow: Exception.Create(s); + end; + Result := False; +end; + +procedure TfrxMailExport.ExportObject(Obj: TfrxComponent); +begin + // Fake +end; + +function TfrxMailExport.Mail(const Server: String; const Port: Integer;const + UserField, PasswordField, FromField, ToField, SubjectField, + TextField, FileName, AttachName: String): String; +var + frxMail: TfrxSMTPClient; +begin + frxMail := TfrxSMTPClient.Create(nil); + try + frxMail.Host := Server; + frxMail.Port := Port; + frxMail.User := UserField; + frxMail.Password := PasswordField; + frxMail.MailFrom := FromField; + frxMail.MailTo := ToField; + frxMail.MailSubject := SubjectField; + frxMail.MailText := StringReplace(TextField, '\n', #13#10, [rfReplaceAll]); + frxMail.MailFile := FileName; + frxMail.AttachName := AttachName; + frxMail.ShowProgress := ShowProgress; + frxMail.LogFile := LogFile; + frxMail.Open; + finally + Result := frxMail.Errors.Text; + frxMail.Free; + end; +end; + +procedure TfrxMailExport.SetMessage(const Value: TStrings); +begin + FMessage.Assign(Value); +end; + +procedure TfrxMailExport.SetSignature(const Value: TStrings); +begin + FSignature.Assign(Value); +end; + +{ TfrxMailExportDialog } + +procedure TfrxMailExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8900); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + ExportSheet.Caption := frxGet(8901); + AccountSheet.Caption := frxGet(8902); + AccountGroup.Caption := frxGet(8903); + AddressLB.Caption := frxGet(8904); + AttachGroup.Caption := frxGet(8905); + FormatLB.Caption := frxGet(8906); + FromAddrLB.Caption := frxGet(8907); + FromNameLB.Caption := frxGet(8908); + HostLB.Caption := frxGet(8909); + LoginLB.Caption := frxGet(8910); + MailGroup.Caption := frxGet(8911); + MessageGroup.Caption := frxGet(8912); + MessageLB.Caption := frxGet(8913); + OrgLB.Caption := frxGet(8914); + PasswordLB.Caption := frxGet(8915); + PortLB.Caption := frxGet(8916); + RememberCB.Caption := frxGet(8917); + ReqLB.Caption := frxGet(8918); + SettingCB.Caption := frxGet(8919); + SignatureLB.Caption := frxGet(8920); + SignBuildBtn.Caption := frxGet(8921); + SubjectLB.Caption := frxGet(8922); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + + +procedure TfrxMailExportDialog.SignBuildBtnClick(Sender: TObject); +begin + SignatureM.Clear; + SignatureM.Lines.Add('--'); + SignatureM.Lines.Add(frxGet(8923) + ','); + if Length(FromNameE.Text) > 0 then + SignatureM.Lines.Add(' ' + FromNameE.Text); + if Length(FromAddrE.Text) > 0 then + SignatureM.Lines.Add(' mailto: ' + FromAddrE.Text); + if Length(OrgE.Text) > 0 then + SignatureM.Lines.Add(' ' + OrgE.Text); +end; + +procedure TfrxMailExportDialog.OkBClick(Sender: TObject); +var + i: Integer; +begin + for i := 0 to ComponentCount - 1 do + if Components[i] is TLabel then + (Components[i] as TLabel).Font.Style := []; + if AddressE.Text = '' then + begin + ExportSheet.Show; + AddressLB.Font.Style := [fsBold]; + ModalResult := mrNone; + end; + if SubjectE.Text = '' then + begin + ExportSheet.Show; + SubjectLB.Font.Style := [fsBold]; + ModalResult := mrNone; + end; + if FromAddrE.Text = '' then + begin + AccountSheet.Show; + FromAddrLB.Font.Style := [fsBold]; + ModalResult := mrNone; + end; + if HostE.Text = '' then + begin + AccountSheet.Show; + HostLB.Font.Style := [fsBold]; + ModalResult := mrNone; + end; + if PortE.Text = '' then + begin + AccountSheet.Show; + PortLB.Font.Style := [fsBold]; + ModalResult := mrNone; + end; + ReqLB.Visible := ModalResult = mrNone +end; + +procedure TfrxMailExportDialog.PortEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8:; + else + key := #0; + end; +end; + +procedure TfrxMailExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxExportMatrix.pas b/official/4.2/LibD11/frxExportMatrix.pas new file mode 100644 index 0000000..268ddd9 --- /dev/null +++ b/official/4.2/LibD11/frxExportMatrix.pas @@ -0,0 +1,1631 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Intermediate Export Matrix } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportMatrix; + +{$I frx.inc} + +//{$DEFINE FR_DEBUG} + +interface + +uses + Windows, Messages, SysUtils, Classes, graphics, frxClass, frxPreviewPages, + frxProgress, Printers, frxUtils, frxUnicodeUtils; + +type + TfrxIEMObject = class; + TfrxIEMObjectList = class; + TfrxIEMStyle = class; + TfrxIEMatrix = class; + + TfrxIEMatrix = class(TObject) + private + FIEMObjectList: TList; + FIEMStyleList: TList; + FXPos: TList; + FYPos: TList; + FPages: TList; + FWidth: Integer; + FHeight: Integer; + FMaxWidth: Extended; + FMaxHeight: Extended; + FMinLeft: Extended; + FMinTop: Extended; + FMatrix: array of integer; + FDeltaY: Extended; + FShowProgress: Boolean; + FMaxCellHeight: Extended; + FMaxCellWidth: Extended; + FInaccuracy: Extended; + FProgress: TfrxProgress; + FRotatedImage: Boolean; + FPlainRich: Boolean; + FRichText: Boolean; + FCropFillArea: Boolean; + FFillArea: Boolean; + FOptFrames: Boolean; + FLeft: Extended; + FTop: Extended; + FDeleteHTMLTags: Boolean; + FBackImage: Boolean; + FBackground: Boolean; + FReport: TfrxReport; + FPrintable: Boolean; + FImages: Boolean; + FWrap: Boolean; + FEmptyLines: Boolean; + FHeader: TfrxBand; + FFooter: TfrxBand; + FBrushAsBitmap: Boolean; + function AddStyleInternal(Style: TfrxIEMStyle): integer; + function AddStyle(Obj: TfrxView): integer; + function AddInternalObject(Obj: TfrxIEMObject; x, y, dx, dy: integer): integer; + function IsMemo(Obj: TfrxView): boolean; + function IsLine(Obj: TfrxView): boolean; + function IsRect(Obj: TfrxView): boolean; + function QuickFind(aList: TList; aPosition: Extended; var Index: Integer): Boolean; + procedure SetCell(x, y: integer; Value: integer); + procedure FillArea(x, y, dx, dy: integer; Value: integer); + procedure ReplaceArea(ObjIndex:integer; x, y, dx, dy: integer; Value: integer); + procedure FindRectArea(x, y: integer; var dx, dy: integer); + procedure CutObject(ObjIndex: Integer; x, y, dx, dy: integer); + procedure CloneFrames(Obj1, Obj2: Integer); + procedure AddPos(List: TList; Value: Extended); + procedure OrderPosArray(List: TList; Vert: boolean); + procedure OrderByCells; + procedure Render; + procedure Analyse; + procedure OptimizeFrames; + public + constructor Create(const UseFileCache: Boolean; const TempDir: String); + destructor Destroy; override; + function GetFontCharset(Font: TFont): Integer; + function GetCell(x, y: integer): integer; + function GetObjectById(ObjIndex: integer): TfrxIEMObject; + function GetStyleById(StyleIndex: integer): TfrxIEMStyle; + function GetXPosById(PosIndex: integer): Extended; + function GetYPosById(PosIndex: integer): Extended; + function GetObject(x, y: integer): TfrxIEMObject; + function GetStyle(x, y: integer): TfrxIEMStyle; + function GetCellXPos(x: integer): Extended; + function GetCellYPos(y: integer): Extended; + procedure DeleteMatrixLine(y: Integer); + function GetStylesCount: Integer; + function GetPagesCount: Integer; + function GetObjectsCount: Integer; + procedure Clear; + procedure AddObject(Obj: TfrxView); + procedure AddDialogObject(Obj: TfrxReportComponent); + procedure AddPage(Orientation: TPrinterOrientation; Width: Extended; + Height: Extended; LeftMargin: Extended; TopMargin: Extended; + RightMargin: Extended; BottomMargin: Extended); + procedure Prepare; + procedure GetObjectPos(ObjIndex: integer; var x, y, dx, dy: integer); + function GetPageBreak(Page: integer): Extended; + function GetPageWidth(Page: integer): Extended; + function GetPageHeight(Page: integer): Extended; + function GetPageLMargin(Page: integer): Extended; + function GetPageTMargin(Page: integer): Extended; + function GetPageRMargin(Page: integer): Extended; + function GetPageBMargin(Page: integer): Extended; + function GetPageOrientation(Page: integer): TPrinterOrientation; + procedure SetPageHeader(Band: TfrxBand); + procedure SetPageFooter(Band: TfrxBand); + + property Width: Integer read FWidth; + property Height: Integer read FHeight; + property MaxWidth: Extended read FMaxWidth; + property MaxHeight: Extended read FMaxHeight; + property MinLeft: Extended read FMinLeft; + property MinTop: Extended read FMinTop; + property ShowProgress: Boolean read FShowProgress write FShowProgress; + property MaxCellHeight: Extended read FMaxCellHeight write FMaxCellHeight; + property MaxCellWidth: Extended read FMaxCellWidth write FMaxCellWidth; + property PagesCount: Integer read GetPagesCount; + property StylesCount: Integer read GetStylesCount; + property ObjectsCount: Integer read GetObjectsCount; + property Inaccuracy: Extended read FInaccuracy write FInaccuracy; + property RotatedAsImage: boolean read FRotatedImage write FRotatedImage; + property RichText: boolean read FRichText write FRichText; + property PlainRich: boolean read FPlainRich write FPlainRich; + property AreaFill: boolean read FFillArea write FFillArea; + property CropAreaFill: boolean read FCropFillArea write FCropFillArea; + property FramesOptimization: boolean read FOptFrames write FOptFrames; + property DeleteHTMLTags: Boolean read FDeleteHTMLTags write FDeleteHTMLTags; + property Left: Extended read FLeft; + property Top: Extended read FTop; + property BackgroundImage: Boolean read FBackImage write FBackImage; + property Background: Boolean read FBackground write FBackground; + property Report: TfrxReport read FReport write FReport; + property Printable: Boolean read FPrintable write FPrintable; + property Images: Boolean read FImages write FImages; + property WrapText: Boolean read FWrap write FWrap; + property EmptyLines: Boolean read FEmptyLines write FEmptyLines; + property BrushAsBitmap: Boolean read FBrushAsBitmap write FBrushAsBitmap; + end; + + TfrxIEMObject = class(TObject) + private + FMemo: TWideStrings; + FURL: String; + FStyleIndex: Integer; + FStyle: TfrxIEMStyle; + FIsText: Boolean; + FIsRichText: Boolean; + FIsDialogObject: Boolean; + FLeft: Extended; + FTop: Extended; + FWidth: Extended; + FHeight: Extended; + FImage: TBitmap; + FParent: TfrxIEMObject; + FCounter: Integer; + FLink: TObject; + FRTL: Boolean; + FAnchor: String; + FCached: Boolean; + FFooter: Boolean; + FHeader: Boolean; + FName: String; + FHTMLTags: Boolean; + procedure SetMemo(const Value: TWideStrings); + function GetImage: TBitmap; + procedure SetImage(const Value: TBitmap); + public + constructor Create; + destructor Destroy; override; + + property Memo: TWideStrings read FMemo write SetMemo; + property URL: String read FURL write FURL; + property StyleIndex: Integer read FStyleIndex write FStyleIndex; + property IsText: Boolean read FIsText write FIsText; + property IsRichText: Boolean read FIsRichText write FIsRichText; + property IsDialogObject: Boolean read FIsDialogObject write FIsDialogObject; + property Left: Extended read FLeft write FLeft; + property Top: Extended read FTop write FTop; + property Width: Extended read FWidth write FWidth; + property Height: Extended read FHeight write FHeight; + property Image: TBitmap read GetImage write SetImage; + property Parent: TfrxIEMObject read FParent write FParent; + property Style: TfrxIEMStyle read FStyle write FStyle; + property Counter: Integer read FCounter write FCounter; + property Link: TObject read FLink write FLink; + property RTL: Boolean read FRTL write FRTL; + property Anchor: String read FAnchor write FAnchor; + property Cached: Boolean read FCached write FCached; + property Footer: Boolean read FFooter write FFooter; + property Header: Boolean read FHeader write FHeader; + property Name: String read FName write FName; + property HTMLTags: Boolean read FHTMLTags write FHTMLTags; + end; + + TfrxIEMObjectList = class(TObject) + public + Obj: TfrxIEMObject; + x, y, dx, dy : Integer; + Exist: Boolean; + constructor Create; + destructor Destroy; override; + end; + + TfrxIEMPos = class(TObject) + public + Value: Extended; + end; + + TfrxIEMPage = class(TObject) + public + Value: Extended; + Orientation: TPrinterOrientation; + Width: Extended; + Height: Extended; + LeftMargin: Extended; + TopMargin:Extended; + BottomMargin: Extended; + RightMargin:Extended; + end; + + TfrxIEMStyle = class(TObject) + public + Font: TFont; + LineSpacing: Extended; + VAlign: TfrxVAlign; + HAlign: TfrxHAlign; + FrameTyp: TfrxFrameTypes; + FrameWidth: Single; + FrameColor: TColor; + FrameStyle: TfrxFrameStyle; + Color: TColor; + Rotation: Integer; + BrushStyle: TBrushStyle; + ParagraphGap: Extended; + GapX: Extended; + GapY: Extended; + CharSpacing: Extended; + WordBreak: Boolean; + Charset: Integer; + FDisplayFormat: TfrxFormat; + constructor Create; + destructor Destroy; override; + procedure Assign(Style: TfrxIEMStyle); + procedure SetDisplayFormat(const Value: TfrxFormat); + + property DisplayFormat: TfrxFormat read FDisplayFormat write SetDisplayFormat; + end; + +implementation + +uses frxres, frxrcExports; + +{ TfrxIEMatrix } + +const + MAX_POS_SEARCH_DEPTH = 100; + +constructor TfrxIEMatrix.Create(const UseFileCache: Boolean; const TempDir: String); +begin + FIEMObjectList := TList.Create; + FIEMStyleList := TList.Create; + FXPos := TList.Create; + FYPos := TList.Create; + FPages := TList.Create; + FMaxWidth := 0; + FMaxHeight := 0; + FMinLeft := 99999; + FMinTop := 99999; + FDeltaY := 0; + FMaxCellHeight := 0; + FShowProgress := true; + FInaccuracy := 0; + FRotatedImage := false; + FPlainRich := true; + FRichText := false; + FFillArea := false; + FCropFillArea := false; + FOptFrames := false; + FTop := 0; + FLeft := 0; + FBackImage := False; + FBackground := False; + FReport := nil; + FPrintable := True; + FImages := True; + FWrap := False; + FEmptyLines := True; + FHeader := nil; + FFooter := nil; + FBrushAsBitmap := True; +end; + +destructor TfrxIEMatrix.Destroy; +begin + Clear; + FXPos.Free; + FYPos.Free; + FIEMObjectList.Free; + FIEMStyleList.Free; + FPages.Free; + inherited; +end; + +function TfrxIEMatrix.AddInternalObject(Obj: TfrxIEMObject; x, y, dx, dy: integer): integer; +var + FObjItem: TfrxIEMObjectList; +begin + FObjItem := TfrxIEMObjectList.Create; + FObjItem.x := x; + FObjItem.y := y; + FObjItem.dx := dx; + FObjItem.dy := dy; + FObjItem.Obj := Obj; + FIEMObjectList.Add(FObjItem); + Result := FIEMObjectList.Count - 1; +end; + +procedure TfrxIEMatrix.AddObject(Obj: TfrxView); +var + dx, dy, fdx, fdy: Extended; + FObj: TfrxIEMObject; + DrawPosX, DrawPosY: Extended; + Memo: TfrxCustomMemoView; + Line: TfrxCustomLineView; + OldFrameWidth: Extended; + FRealBounds: TfrxRect; +begin + if (Obj.Name = '_pagebackground') and + (not FBackground) and (FPrintable or Obj.Printable) + then + Exit; + OldFrameWidth := 0; + + if Obj.Frame.DropShadow and (Obj is TfrxCustomMemoView) then + begin + Obj.Width := Obj.Width - Obj.Frame.ShadowWidth; + Obj.Height := Obj.Height - Obj.Frame.ShadowWidth; + Obj.Frame.DropShadow := False; + AddObject(Obj); + Obj.Width := Obj.Width + Obj.Frame.ShadowWidth; + Obj.Height := Obj.Height + Obj.Frame.ShadowWidth; + Obj.Frame.DropShadow := True; + Memo := TfrxCustomMemoView.Create(nil); + try + Memo.Name := 'Shadow'; + Memo.Font.Size := 1; + Memo.Color := Obj.Frame.ShadowColor; + Memo.Left := Obj.AbsLeft + Obj.Width - Obj.Frame.ShadowWidth; + Memo.Top := Obj.AbsTop + Obj.Frame.ShadowWidth; + Memo.Width := Obj.Frame.ShadowWidth; + Memo.Height := Obj.Height - Obj.Frame.ShadowWidth; + AddObject(Memo); + Memo.Left := Obj.AbsLeft + Obj.Frame.ShadowWidth; + Memo.Top := Obj.AbsTop + Obj.Height - Obj.Frame.ShadowWidth; + Memo.Width := Obj.Width - Obj.Frame.ShadowWidth; + Memo.Height := Obj.Frame.ShadowWidth; + AddObject(Memo); + finally + Memo.Free; + end; + exit; + end; + + if (Obj.ClassName = 'TfrxRichView') and FRichText and FPlainRich then + begin + Memo := TfrxCustomMemoView.Create(nil); + try + Obj.PlainText := True; + Memo.Lines.Text := Obj.GetComponentText; + Memo.Name := Obj.Name; + Memo.Left := Obj.AbsLeft; + Memo.Top := Obj.AbsTop; + Memo.Width := Obj.Width; + Memo.Height := Obj.Height; + AddObject(Memo); + finally + Obj.PlainText := False; + Memo.Free; + end; + exit; + end; + + FObj := TfrxIEMObject.Create; + FObj.Name := Obj.Name; + FObj.StyleIndex := AddStyle(Obj); + if FObj.StyleIndex <> -1 then + FObj.Style := TfrxIEMStyle(FIEMStyleList[FObj.StyleIndex]); + FObj.URL :=Obj.URL; + if Assigned(FReport) and (FObj.URL <> '') and (FObj.URL[1] = '#') then + FObj.URL := '@' + IntToStr(TfrxPreviewPages(FReport.PreviewPages).GetAnchorPage(StringReplace(FObj.URL, '#', '', []))); + + if Obj.AbsLeft >= 0 then + FObj.Left := Obj.AbsLeft + else FObj.Left := 0; + if Obj.AbsTop >= 0 then + FObj.Top := FDeltaY + Obj.AbsTop + else FObj.Top := FDeltaY; + FObj.Width := Obj.Width; + FObj.Height := Obj.Height; + if IsMemo(Obj) then + begin + // Memo + if (FDeleteHTMLTags and TfrxCustomMemoView(Obj).AllowHTMLTags) or FWrap then + FObj.Memo.Text := TfrxCustomMemoView(Obj).WrapText(True) + else + FObj.Memo := TfrxCustomMemoView(Obj).Memo; + if not FDeleteHTMLTags then + FObj.HTMLTags := TfrxCustomMemoView(Obj).AllowHTMLTags; + if TfrxCustomMemoView(Obj).Font.Charset <> DEFAULT_CHARSET then + FObj.Memo.Text := AnsiToUnicode(FObj.Memo.Text, TfrxCustomMemoView(Obj).Font.Charset); + FObj.IsText := True; + FObj.IsRichText := False; + FObj.RTL := TfrxCustomMemoView(Obj).RTLReading; + end + else if (Obj.ClassName = 'TfrxRichView') and (FRichText) then + begin + // Rich + FObj.IsText := True; + FObj.IsRichText := True; + FObj.Memo.Text := Obj.GetComponentText; + end + else if IsLine(Obj) then + begin + // Line + FObj.IsText := True; + FObj.IsRichText := False; + if FObj.Left > (FObj.Left + FObj.Width) then + begin + FObj.Left := FObj.Left + FObj.Width; + FObj.Width := -FObj.Width; + end; + if FObj.Top > (FObj.Top + Obj.Height) then + begin + FObj.Top := FObj.Top + FObj.Height; + FObj.Height := -FObj.Height; + end; + if FObj.Width = 0 then + if FInaccuracy < 1 then FObj.Width := 1 + else FObj.Width := FInaccuracy; + if FObj.Height = 0 then + if FInaccuracy < 1 then FObj.Height := 1 + else FObj.Height := FInaccuracy; + end + else if IsRect(Obj) then + begin + if Obj.Color = clNone then + begin + // Rect as lines + Line := TfrxCustomLineView.Create(nil); + Line.Name := 'Line'; + Line.Frame.Assign(Obj.Frame); + Line.Left := Obj.AbsLeft; + Line.Top := Obj.AbsTop; + Line.Width := Obj.Width; + Line.Height := 0; + AddObject(Line); + Line.Left := Obj.AbsLeft; + Line.Top := Obj.AbsTop; + Line.Width := 0; + Line.Height := Obj.Height; + AddObject(Line); + Line.Left := Obj.AbsLeft; + Line.Top := Obj.AbsTop + Obj.Height; + Line.Width := Obj.Width; + Line.Height := 0; + AddObject(Line); + Line.Left := Obj.AbsLeft + Obj.Width; + Line.Top := Obj.AbsTop; + Line.Width := 0; + Line.Height := Obj.Height; + AddObject(Line); + Line.Free; + end else + begin + // Rect as memo + Memo := TfrxCustomMemoView.Create(nil); + Memo.Frame.Assign(Obj.Frame); + Memo.Name := 'Rect'; + Memo.Color := Obj.Color; + Memo.Left := Obj.AbsLeft; + Memo.Top := Obj.AbsTop; + Memo.Width := Obj.Width; + Memo.Height := Obj.Height; + Memo.Frame.Typ := [ftLeft, ftTop, ftRight, ftBottom]; + Memo.Font.Size := 1; + AddObject(Memo); + Memo.Free; + end; + FObj.Free; + Exit; + end + else begin + // Bitmap + if (not ((Obj.Name = '_pagebackground') and (not FBackImage))) and FImages and (Obj.ClassName <> 'TfrxGradientView') then + begin + if (Obj.Frame.Typ <> []) and (Obj.Frame.Width > 0) then + begin + OldFrameWidth := Obj.Frame.Width; + Obj.Frame.Width := 0; + end; + FObj.IsText := False; + FObj.IsRichText := False; + + FRealBounds := Obj.GetRealBounds; + dx := FRealBounds.Right - FRealBounds.Left; + dy := FRealBounds.Bottom - FRealBounds.Top; + + if (dx = Obj.Width) or (Obj.AbsLeft = FRealBounds.Left) then + fdx := 0 + else if (Obj.AbsLeft + Obj.Width) = FRealBounds.Right then + fdx := (dx - Obj.Width) + else + fdx := (dx - Obj.Width) / 2; + + if (dy = Obj.Height) or (Obj.AbsTop = FRealBounds.Top) then + fdy := 0 + else if (Obj.AbsTop + Obj.Height) = FRealBounds.Bottom then + fdy := (dy - Obj.Height) + else + fdy := (dy - Obj.Height) / 2; + + DrawPosX := Obj.AbsLeft - fdx; + DrawPosY := Obj.AbsTop - fdy; + FObj.Left := FObj.Left - fdx; + FObj.Top := FObj.Top - fdy; + + if Round(dx) = 0 then + dx := 1; + if dx < 0 then + begin + dx := -dx; + FObj.Left := FObj.Left - dx; + DrawPosX := DrawPosX - dx; + end; + if Round(dy) = 0 then + dy := 1; + if dy < 0 then + begin + dy := -dy; + FObj.Top := FObj.Top - dy; + DrawPosY := DrawPosY - dy; + end; + + FObj.Width := dx; + FObj.Height := dy; + FObj.Image := TBitmap.Create; + FObj.Image.PixelFormat := pf24bit; + FObj.Image.Height := Round(dy) + 1; + FObj.Image.Width := Round(dx) + 1; + TfrxView(Obj).Draw(FObj.Image.Canvas, 1, 1, -DrawPosX, -DrawPosY); + if OldFrameWidth > 0 then + Obj.Frame.Width := OldFrameWidth; + end + end; + + if (Obj.Parent <> nil) and ((FHeader <> nil) or (FFooter <> nil)) then + begin + FObj.Header := Obj.Parent = FHeader; + FObj.Footer := Obj.Parent = FFooter; + end; + + if FObj.Top + FObj.Height > FMaxHeight then + FMaxHeight := FObj.Top + FObj.Height; + if FObj.Left + FObj.Width > FMaxWidth then + FMaxWidth := FObj.Left + FObj.Width; + if FObj.Left < FMinLeft then + FMinLeft := FObj.Left; + if FObj.Top < FMinTop then + FMinTop := FObj.Top; + if (FObj.Left < FLeft) or (FLeft = 0) then + FLeft := FObj.Left; + if (FObj.Top < FTop) or (FTop = 0) then + FTop := FObj.Top; + AddPos(FXPos, FObj.Left); + AddPos(FXPos, FObj.Left + FObj.Width); + AddPos(FYPos, FObj.Top); + AddPos(FYPos, FObj.Top + FObj.Height); + AddInternalObject(FObj, 0, 0, 1, 1); +end; + +procedure TfrxIEMatrix.AddDialogObject(Obj: TfrxReportComponent); +var + FObj: TfrxIEMObject; +begin + if Obj is TfrxDialogControl then + begin + FObj := TfrxIEMObject.Create; + FObj.StyleIndex := 0; + FObj.Style := nil; + FObj.URL := ''; + FObj.Left := Obj.AbsLeft; + FObj.Top := Obj.AbsTop; + FObj.Width := Obj.Width; + FObj.Height := Obj.Height; + FObj.IsText := False; + FObj.IsRichText := False; + FObj.Link := Obj; + if FObj.Top + FObj.Height > FMaxHeight then + FMaxHeight := FObj.Top + FObj.Height; + if FObj.Left + FObj.Width > FMaxWidth then + FMaxWidth := FObj.Left + FObj.Width; + if FObj.Left < FMinLeft then + FMinLeft := FObj.Left; + if FObj.Top < FMinTop then + FMinTop := FObj.Top; + AddPos(FXPos, FObj.Left); + AddPos(FXPos, FObj.Left + FObj.Width); + AddPos(FYPos, FObj.Top); + AddPos(FYPos, FObj.Top + FObj.Height); + AddInternalObject(FObj, 0, 0, 1, 1); + end; +end; + +procedure TfrxIEMatrix.AddPage(Orientation: TPrinterOrientation; +Width: Extended; Height: Extended; LeftMargin: Extended; TopMargin: Extended; +RightMargin: Extended; BottomMargin: Extended); +var + Page: TfrxIEMPage; +begin + FDeltaY := FMaxHeight; + Page := TfrxIEMPage.Create; + Page.Value := FMaxHeight; + Page.Orientation := Orientation; + Page.Width := Width; + Page.Height := Height; + Page.LeftMargin := LeftMargin; + page.TopMargin := TopMargin; + Page.RightMargin := LeftMargin; + page.BottomMargin := TopMargin; + FPages.Add(Page); +end; + +procedure TfrxIEMatrix.AddPos(List: TList; Value: Extended); +var + Pos: TfrxIEMPos; + i, cnt: integer; + Exist: Boolean; +begin + Exist := False; + if List.Count > MAX_POS_SEARCH_DEPTH then + cnt := List.Count - MAX_POS_SEARCH_DEPTH + else + cnt := 0; + for i := List.Count - 1 downto cnt do + if TfrxIEMPos(List[i]).Value = Value then + begin + Exist := True; + break; + end; + if not Exist then + begin + Pos := TfrxIEMPos.Create; + Pos.Value := Value; + List.Add(Pos); + end; +end; + +function TfrxIEMatrix.AddStyle(Obj: TfrxView): integer; +var + Style: TfrxIEMStyle; + MObj: TfrxCustomMemoView; +begin + Style := TfrxIEMStyle.Create; + if IsMemo(Obj) then + begin + MObj := TfrxCustomMemoView(Obj); + if MObj.Highlight.Active and + Assigned(MObj.Highlight.Font) then + begin + Style.Font.Assign(MObj.Highlight.Font); + Style.Color := MObj.Highlight.Color; + end else + begin + Style.Font.Assign(MObj.Font); + Style.Color := MObj.Color; + end; + Style.DisplayFormat := MObj.DisplayFormat; + Style.HAlign := MObj.HAlign; + Style.VAlign := MObj.VAlign; + Style.LineSpacing := MObj.LineSpacing; + Style.GapX := MObj.GapX; + Style.GapY := MObj.GapY; + if MObj.Font.Charset = 1 then + Style.Charset := GetFontCharset(MObj.Font) + else + Style.Charset := MObj.Font.Charset; + Style.CharSpacing := MObj.CharSpacing; + Style.ParagraphGap := MObj.ParagraphGap; + Style.WordBreak := MObj.WordBreak; + Style.FrameTyp := MObj.Frame.Typ; + Style.FrameWidth := MObj.Frame.Width; + Style.FrameColor := MObj.Frame.Color; + Style.FrameStyle := MObj.Frame.Style; + Style.Rotation := MObj.Rotation; + end + else if IsLine(Obj) then + begin + Style.Color := Obj.Color; + if Obj.Width = 0 then + Style.FrameTyp := [ftLeft] + else if Obj.Height = 0 then + Style.FrameTyp := [ftTop] + else Style.FrameTyp := []; + Style.FrameWidth := Obj.Frame.Width; + Style.FrameColor := Obj.Frame.Color; + Style.FrameStyle := Obj.Frame.Style; + Style.Font.Name := 'Arial'; + Style.Font.Size := 1; + end + else if IsRect(Obj) then + begin + Style.Free; + Result := -1; + Exit; + end + else begin + Style.Font.Assign(Obj.Font); + Style.FrameTyp := []; + Style.Color := Obj.Color; + Style.FrameWidth := Obj.Frame.Width; + Style.FrameColor := Obj.Frame.Color; + Style.FrameStyle := Obj.Frame.Style; + Style.FrameTyp := Obj.Frame.Typ; + end; + Result := AddStyleInternal(Style); +end; + +function TfrxIEMatrix.AddStyleInternal(Style: TfrxIEMStyle): integer; +var + i: integer; + Style2: TfrxIEMStyle; +begin + Result := -1; + for i := 0 to FIEMStyleList.Count - 1 do + begin + Style2 := TfrxIEMStyle(FIEMStyleList[i]); + if (Style.Font.Color = Style2.Font.Color) and + (Style.Font.Name = Style2.Font.Name) and + (Style.Font.Size = Style2.Font.Size) and + (Style.Font.Style = Style2.Font.Style) and + (Style.DisplayFormat.Kind = Style2.DisplayFormat.Kind) and + (Style.DisplayFormat.DecimalSeparator = Style2.DisplayFormat.DecimalSeparator) and + (Style.DisplayFormat.FormatStr = Style2.DisplayFormat.FormatStr) and + (Style.LineSpacing = Style2.LineSpacing) and + (Style.GapX = Style2.GapX) and + (Style.GapY = Style2.GapY) and + (Style.ParagraphGap = Style2.ParagraphGap) and + (Style.CharSpacing = Style2.CharSpacing) and + (Style.Charset = Style2.Charset) and + (Style.WordBreak = Style2.WordBreak) and + (Style.HAlign = Style2.HAlign) and + (Style.VAlign = Style2.VAlign) and + (Style.FrameTyp = Style2.FrameTyp) and + (Style.FrameWidth = Style2.FrameWidth) and + (Style.FrameColor = Style2.FrameColor) and + (Style.FrameStyle = Style2.FrameStyle) and + (Style.Rotation = Style2.Rotation) and + (Style.BrushStyle = Style2.BrushStyle) and + (Style.Color = Style2.Color) then + begin + Result := i; + break; + end; + end; + if Result = -1 then + begin + FIEMStyleList.Add(Style); + Result := FIEMStyleList.Count - 1; + end else + Style.Free; +end; + +procedure TfrxIEMatrix.Analyse; +var + i, j, k: integer; + dx, dy: integer; + obj: TfrxIEMObjectList; +begin + for i := 0 to FHeight - 1 do + for j := 0 to FWidth - 1 do + begin + k := GetCell(j, i); + if k <> -1 then + begin + obj := TfrxIEMObjectList(FIEMObjectList[k]); + if not obj.Exist then + begin + FindRectArea(j, i, dx, dy); + if (obj.x <> j) or (obj.y <> i) or + (obj.dx <> dx) or (obj.dy <> dy) then + begin + if not Obj.Exist then + CutObject(k, j, i, dx, dy) + end else + Obj.Exist := true; + end; + end; + end; + if FShowProgress then + FProgress.Tick; +end; + +procedure TfrxIEMatrix.Clear; +var + i : Integer; +begin + for i := 0 to FIEMObjectList.Count - 1 do + TfrxIEMObjectList(FIEMObjectList[i]).Free; + FIEMObjectList.Clear; + for i := 0 to FIEMStyleList.Count - 1 do + TfrxIEMStyle(FIEMStyleList[i]).Free; + FIEMStyleList.Clear; + for i := 0 to FXPos.Count - 1 do + TfrxIEMPos(FXPos[i]).Free; + FXPos.Clear; + for i := 0 to FYPos.Count - 1 do + TfrxIEMPos(FYPos[i]).Free; + FYPos.Clear; + for i := 0 to FPages.Count - 1 do + TfrxIEMPage(FPages[i]).Free; + FPages.Clear; + SetLength(FMatrix, 0); + FDeltaY := 0; +end; + +procedure TfrxIEMatrix.CloneFrames(Obj1, Obj2: Integer); +var + FOld, FNew: TfrxIEMObject; + FrameTyp: TfrxFrameTypes; + NewStyle: TfrxIEMStyle; +begin + FOld := TfrxIEMObjectList(FIEMObjectList[Obj1]).Obj; + FNew := TfrxIEMObjectList(FIEMObjectList[Obj2]).Obj; + if (FOld.Style <> nil) and (FNew.Style <> nil) then + begin + FrameTyp := []; + if (ftTop in FOld.Style.FrameTyp) and (FOld.Top = FNew.Top) then + FrameTyp := FrameTyp + [ftTop]; + if (ftLeft in FOld.Style.FrameTyp) and (FOld.Left = FNew.Left) then + FrameTyp := FrameTyp + [ftLeft]; + if (ftBottom in FOld.Style.FrameTyp) and + ((FOld.Top + FOld.Height) = (FNew.Top + FNew.Height)) then + FrameTyp := FrameTyp + [ftBottom]; + if (ftRight in FOld.Style.FrameTyp) and + ((FOld.Left + FOld.Width) = (FNew.Left + FNew.Width)) then + FrameTyp := FrameTyp + [ftRight]; + if FrameTyp <> FNew.Style.FrameTyp then + begin + NewStyle := TfrxIEMStyle.Create; + NewStyle.FrameTyp := FrameTyp; + NewStyle.FrameWidth := FOld.Style.FrameWidth; + NewStyle.FrameColor := FOld.Style.FrameColor; + NewStyle.FrameStyle := FOld.Style.FrameStyle; + NewStyle.Font.Assign(FOld.Style.Font); + NewStyle.DisplayFormat.Assign(FOld.Style.DisplayFormat); + NewStyle.LineSpacing := FOld.Style.LineSpacing; + NewStyle.GapX := FOld.Style.GapX; + NewStyle.GapY := FOld.Style.GapY; + NewStyle.ParagraphGap := FOld.Style.ParagraphGap; + NewStyle.CharSpacing := FOld.Style.CharSpacing; + NewStyle.Charset := FOld.Style.Charset; + NewStyle.WordBreak := FOld.Style.WordBreak; + NewStyle.VAlign := FOld.Style.VAlign; + NewStyle.HAlign := FOld.Style.HAlign; + NewStyle.Color := FOld.Style.Color; + NewStyle.Rotation := FOld.Style.Rotation; + NewStyle.BrushStyle := FOld.Style.BrushStyle; + FNew.StyleIndex := AddStyleInternal(NewStyle); + FNew.Style := TfrxIEMStyle(FIEMStyleList[FNew.StyleIndex]); + end; +end; +end; + +procedure TfrxIEMatrix.CutObject(ObjIndex, x, y, dx, dy: integer); +var + Obj: TfrxIEMObject; + NewObject: TfrxIEMObject; + NewIndex: Integer; + fdx, fdy: Extended; +begin + Obj := TfrxIEMObjectList(FIEMObjectList[ObjIndex]).Obj; + NewObject := TfrxIEMObject.Create; + NewObject.StyleIndex := Obj.StyleIndex; + NewObject.Style := Obj.Style; + NewObject.Left := TfrxIEMPos(FXPos[x]).Value; + NewObject.Top := TfrxIEMPos(FYPos[y]).Value; + NewObject.Width := TfrxIEMPos(FXPos[x + dx]).Value - TfrxIEMPos(FXPos[x]).Value; + NewObject.Height := TfrxIEMPos(FYPos[y + dy]).Value - TfrxIEMPos(FYPos[y]).Value; + NewObject.Parent := Obj; + NewObject.IsText := Obj.IsText; + NewObject.IsRichText := Obj.IsRichText; + NewObject.HTMLTags := Obj.HTMLTags; + fdy := Obj.Top + Obj.Height - NewObject.Top; + fdx := Obj.Left + Obj.Width - NewObject.Left; + if (fdy > Obj.Height / 3) and (fdx > Obj.Width / 3) then + begin + NewObject.Image := Obj.Image; + NewObject.Link := Obj.Link; + NewObject.IsText := Obj.IsText; + NewObject.Memo := Obj.Memo; + Obj.Memo.Clear; + Obj.IsText := True; + Obj.Link := nil; + Obj.Image := nil; + end; + NewIndex := AddInternalObject(NewObject, x, y, dx, dy); + ReplaceArea(ObjIndex, x, y, dx, dy, NewIndex); + CloneFrames(ObjIndex, NewIndex); + TfrxIEMObjectList(FIEMObjectList[NewIndex]).Exist := True; +end; + +procedure TfrxIEMatrix.FillArea(x, y, dx, dy, Value: integer); +var + i, j: integer; +begin + for i := y to y + dy - 1 do + for j := x to x + dx - 1 do + SetCell(j, i, Value); +end; + +procedure TfrxIEMatrix.FindRectArea(x, y: integer; var dx, dy: integer); +var + px, py: integer; + Obj: integer; +begin + Obj := GetCell(x, y); + px := x; + py := y; + dx := 0; + while GetCell(px, py) = Obj do + begin + while GetCell(px, py) = Obj do + Inc(px); + if dx = 0 then + dx := px - x + else if px - x < dx then + break; + Inc(py); + px := x; + end; + dy := py - y; +end; + +function TfrxIEMatrix.GetCell(x, y: integer): integer; +begin + if (x < FWidth) and (y < FHeight) and (x >= 0) and (y >= 0) then + Result := FMatrix[FWidth * y + x] + else Result := -1; +end; + +function TfrxIEMatrix.GetCellXPos(x: integer): Extended; +begin + Result := TfrxIEMPos(FXPos[x]).Value; +end; + +function TfrxIEMatrix.GetCellYPos(y: integer): Extended; +begin + Result := TfrxIEMPos(FYPos[y]).Value; +end; + +function TfrxIEMatrix.GetObject(x, y: integer): TfrxIEMObject; +var + i: integer; +begin + i := GetCell(x, y); + if i = -1 then + Result := nil + else + Result := TfrxIEMObjectList(FIEMObjectList[i]).Obj; +end; + +function TfrxIEMatrix.GetObjectById(ObjIndex: integer): TfrxIEMObject; +begin + if ObjIndex < FIEMObjectList.Count then + Result := TfrxIEMObjectList(FIEMObjectList[ObjIndex]).Obj + else Result := nil; +end; + +procedure TfrxIEMatrix.GetObjectPos(ObjIndex: integer; var x, y, dx, + dy: integer); +begin + x := TfrxIEMObjectList(FIEMObjectList[ObjIndex]).x; + y := TfrxIEMObjectList(FIEMObjectList[ObjIndex]).y; + dx := TfrxIEMObjectList(FIEMObjectList[ObjIndex]).dx; + dy := TfrxIEMObjectList(FIEMObjectList[ObjIndex]).dy; +end; + +function TfrxIEMatrix.GetObjectsCount: Integer; +begin + Result := FIEMObjectList.Count; +end; + +function TfrxIEMatrix.GetPageBreak(Page: integer): Extended; +begin + if Page < FPages.Count then + Result := TfrxIEMPage(FPages[Page]).Value + else + Result := 0; +end; + +function TfrxIEMatrix.GetPageHeight(Page: integer): Extended; +begin + if Page < FPages.Count then + Result := TfrxIEMPage(FPages[Page]).Height + else + Result := 0; +end; + +function TfrxIEMatrix.GetPageLMargin(Page: integer): Extended; +begin + if Page < FPages.Count then + Result := TfrxIEMPage(FPages[Page]).LeftMargin + else + Result := 0; +end; + +function TfrxIEMatrix.GetPageTMargin(Page: integer): Extended; +begin + if Page < FPages.Count then + Result := TfrxIEMPage(FPages[Page]).TopMargin + else + Result := 0; +end; + +function TfrxIEMatrix.GetPageWidth(Page: integer): Extended; +begin + if Page < FPages.Count then + Result := TfrxIEMPage(FPages[Page]).Width + else + Result := 0; +end; + +function TfrxIEMatrix.GetPageBMargin(Page: integer): Extended; +begin + if Page < FPages.Count then + Result := TfrxIEMPage(FPages[Page]).BottomMargin + else + Result := 0; +end; + +function TfrxIEMatrix.GetPageRMargin(Page: integer): Extended; +begin + if Page < FPages.Count then + Result := TfrxIEMPage(FPages[Page]).RightMargin + else + Result := 0; +end; + +function TfrxIEMatrix.GetPageOrientation(Page: integer): TPrinterOrientation; +begin + if Page < FPages.Count then + Result := TfrxIEMPage(FPages[Page]).Orientation + else + Result := poPortrait; +end; + +function TfrxIEMatrix.GetPagesCount: Integer; +begin + Result := FPages.Count; +end; + +function TfrxIEMatrix.GetStyle(x, y: integer): TfrxIEMStyle; +var + Obj: TfrxIEMObject; +begin + Obj := GetObject(x, y); + if Obj <> nil then + Result := TfrxIEMStyle(FIEMStyleList[Obj.StyleIndex]) + else + Result := nil; +end; + +function TfrxIEMatrix.GetStyleById(StyleIndex: integer): TfrxIEMStyle; +begin + Result := TfrxIEMStyle(FIEMStyleList[StyleIndex]); +end; + +function TfrxIEMatrix.GetStylesCount: Integer; +begin + Result := FIEMStyleList.Count; +end; + +function TfrxIEMatrix.GetXPosById(PosIndex: integer): Extended; +begin + Result := TfrxIEMPos(FXPos[PosIndex]).Value; +end; + +function TfrxIEMatrix.GetYPosById(PosIndex: integer): Extended; +begin + Result := TfrxIEMPos(FYPos[PosIndex]).Value; +end; + +function TfrxIEMatrix.IsMemo(Obj: TfrxView): boolean; +begin + Result := (Obj is TfrxCustomMemoView) and + ((Obj.BrushStyle in [bsSolid, bsClear]) or (not FBrushAsBitmap)) and + ((TfrxCustomMemoView(Obj).Rotation = 0) or (not FRotatedImage)); +end; + +function TfrxIEMatrix.IsLine(Obj: TfrxView): boolean; +begin + Result := (Obj is TfrxCustomLineView) and ((Obj.Width = 0) or (Obj.Height = 0)); +end; + +function TfrxIEMatrix.IsRect(Obj: TfrxView): boolean; +begin + Result := (Obj is TfrxShapeView) and (TfrxShapeView(Obj).Shape = skRectangle); +end; + +procedure TfrxIEMatrix.OptimizeFrames; +var + x, y: Integer; + Obj, PrevObj: TfrxIEMObject; + FrameTyp: TfrxFrameTypes; + Style: TfrxIEMStyle; +begin + for y := 0 to Height - 1 do + for x := 0 to Width - 1 do + begin + Obj := GetObject(x, y); + if Obj = nil then continue; + FrameTyp := Obj.Style.FrameTyp; + + if (ftTop in FrameTyp) and (y > 0) then + begin + PrevObj := GetObject(x, y - 1); + if (PrevObj <> nil) and (PrevObj <> Obj) then + if (ftBottom in PrevObj.Style.FrameTyp) and + (PrevObj.Style.FrameWidth = Obj.Style.FrameWidth) and + (PrevObj.Style.FrameColor = Obj.Style.FrameColor) then + FrameTyp := FrameTyp - [ftTop]; + end; + if (ftLeft in FrameTyp) and (x > 0) then + begin + PrevObj := GetObject(x - 1, y); + if (PrevObj <> nil) and (PrevObj <> Obj) then + if (ftRight in PrevObj.Style.FrameTyp) and + (PrevObj.Style.FrameWidth = Obj.Style.FrameWidth) and + (PrevObj.Style.FrameColor = Obj.Style.FrameColor) then + FrameTyp := FrameTyp - [ftLeft]; + end; + + if FrameTyp <> Obj.Style.FrameTyp then + begin + Style := TfrxIEMStyle.Create; + Style.Assign(Obj.Style); + Style.FrameTyp := FrameTyp; + Obj.StyleIndex := AddStyleInternal(Style); + Obj.Style := TfrxIEMStyle(FIEMStyleList[Obj.StyleIndex]); + end; + end; +end; + +function TfrxIEMatrix.QuickFind(aList: TList; aPosition: Extended; var Index: Integer): Boolean; +var + L, H, I: Integer; + C: Extended; +begin + Result := False; + L := 0; + H := aList.Count - 1; + while L <= H do begin + I := (L + H) shr 1; + C := TfrxIEMPos(aList[I]).Value - aPosition; + if C < 0 then + L := I + 1 + else begin + H := I - 1; + if C = 0 then begin + Result := True; + L := I + end + end + end; + Index := L +end; + +procedure TfrxIEMatrix.OrderByCells; +var + i, j, k, dx, dy: integer; + curx, cury: Extended; + obj: TfrxIEMObject; +begin + OrderPosArray(FXPos, false); + OrderPosArray(FYPos, true); + for i := 0 to FIEMObjectList.Count - 1 do + begin + dx := 0; dy := 0; + obj := TfrxIEMObjectList(FIEMObjectList[i]).Obj; + QuickFind(FXPos, Obj.Left, j); + if j < FXPos.Count then + begin + TfrxIEMObjectList(FIEMObjectList[i]).x := j; + curx := Obj.Left; + k := j; + while (Obj.Left + Obj.Width > curx) and (k < FXPos.Count - 1) do + begin + Inc(k); + curx := TfrxIEMPos(FXPos[k]).Value; + Inc(dx); + end; + TfrxIEMObjectList(FIEMObjectList[i]).dx := dx; + end; + QuickFind(FYPos, Obj.Top, j); + if j < FYPos.Count then + begin + TfrxIEMObjectList(FIEMObjectList[i]).y := j; + cury := Obj.Top; + k := j; + while (Obj.Top + Obj.Height > cury) and (k < FYPos.Count - 1) do + begin + Inc(k); + cury := TfrxIEMPos(FYPos[k]).Value; + Inc(dy); + end; + TfrxIEMObjectList(FIEMObjectList[i]).dy := dy; + end; + end; + if FShowProgress then + FProgress.Tick; +end; + +function SortPosCompare(Item1, Item2: Pointer): Integer; +begin + if TfrxIEMPos(Item1).Value < TfrxIEMPos(Item2).Value then + Result := -1 + else if TfrxIEMPos(Item1).Value > TfrxIEMPos(Item2).Value then + Result := 1 + else + Result := 0; +end; + +procedure TfrxIEMatrix.OrderPosArray(List: TList; Vert: boolean); +var + i, j, Cnt: integer; + pos1, pos2: Extended; + Reorder: Boolean; +begin + List.Sort(SortPosCompare); + if FShowProgress then + FProgress.Tick; + i := 0; + while i <= List.Count - 2 do + begin + pos1 := TfrxIEMPos(List[i]).Value; + pos2 := TfrxIEMPos(List[i + 1]).Value; + if pos2 - pos1 < FInaccuracy then + begin + TfrxIEMPos(List[i]).Free; + List.Delete(i); + end else Inc(i); + end; + if FShowProgress then + FProgress.Tick; + Reorder := False; + if Vert and (FMaxCellHeight > 0) then + for i := 0 to List.Count - 2 do + begin + pos1 := TfrxIEMPos(List[i]).Value; + pos2 := TfrxIEMPos(List[i + 1]).Value; + if pos2 - pos1 > FMaxCellHeight then + begin + Cnt := Round(Int((pos2 - pos1) / FMaxCellHeight)); + for j := 1 to Cnt do + AddPos(List, pos1 + FMaxCellHeight * j); + Reorder := True; + end; + end; + if FShowProgress then + FProgress.Tick; + if (not Vert) and (FMaxCellWidth > 0) then + for i := 0 to List.Count - 2 do + begin + pos1 := TfrxIEMPos(List[i]).Value; + pos2 := TfrxIEMPos(List[i + 1]).Value; + if pos2 - pos1 > FMaxCellWidth then + begin + Cnt := Round(Int((pos2 - pos1) / FMaxCellWidth)); + for j := 1 to Cnt do + AddPos(List, pos1 + FMaxCellWidth * j); + Reorder := True; + end; + end; + if Reorder then + List.Sort(SortPosCompare); + if FShowProgress then + FProgress.Tick; +end; + +procedure TfrxIEMatrix.Prepare; +var + Style: TfrxIEMStyle; + FObj: TfrxIEMObject; + FObjItem: TfrxIEMObjectList; + i, j: Integer; + f: Boolean; +{$IFDEF FR_DEBUG} + FLines: TStrings; + s: String; +{$ENDIF} +begin + if FShowProgress then + begin + FProgress := TfrxProgress.Create(nil); + FProgress.Execute(11, frxResources.Get('ProgressWait'), false, true); + end; + if FFillArea then + begin + Style := TfrxIEMStyle.Create; + Style.FrameTyp := []; + Style.Color := clWhite; + FObj := TfrxIEMObject.Create; + FObj.StyleIndex := AddStyleInternal(Style); + FObj.Style := Style; + if FCropFillArea then + begin + FObj.Left := FMinLeft; + FObj.Top := FMinTop; + end + else + begin + FObj.Left := 0; + FObj.Top := 0; + end; + FObj.Width := MaxWidth; + FObj.Height := MaxHeight; + FObj.IsText := True; + AddPos(FXPos, 0); + AddPos(FYPos, 0); + FObjItem := TfrxIEMObjectList.Create; + FObjItem.x := 0; + FObjItem.y := 0; + FObjItem.dx := 1; + FObjItem.dy := 1; + FObjItem.Obj := FObj; + FIEMObjectList.Insert(0, FObjItem); + end; + OrderByCells; + FWidth := FXPos.Count; + FHeight := FYPos.Count; + Render; + Analyse; + if FOptFrames then + OptimizeFrames; + if FShowProgress then + FProgress.Free; + +{$IFDEF FR_DEBUG} + FLines := TStringList.Create; + try + for i := 0 to Height - 1 do + begin + s := Format('%10f', [TfrxIEMPos(FYPos[i]).Value]) + ' |'; + for j := 0 to Width - 1 do + s := s + ' ' + Format('%6d', [GetCell(j, i)]); + FLines.Add(s); + end; + FLines.SaveToFile('c:\matrix_before.log'); + finally + FLines.Free; + end; +{$ENDIF} + + if not FEmptyLines then + begin + i := 0; + while i < Height - 1 do + begin + f := True; + for j := 0 to Width - 1 do + f := f and (GetCell(j, i) = - 1); + if f then + DeleteMatrixLine(i) + else + Inc(i); + end; + end; + +{$IFDEF FR_DEBUG} + FLines := TStringList.Create; + try + for i := 0 to Height - 1 do + begin + s := Format('%10f', [TfrxIEMPos(FYPos[i]).Value]) + ' |'; + for j := 0 to Width - 1 do + s := s + ' ' + Format('%6d', [GetCell(j, i)]); + FLines.Add(s); + end; + FLines.SaveToFile('c:\matrix_after.log'); + finally + FLines.Free; + end; +{$ENDIF} +end; + +procedure TfrxIEMatrix.Render; +var + i, old: integer; + obj: TfrxIEMObjectList; + Style: TfrxIEMStyle; + OldColor: TColor; +begin + SetLength(FMatrix, FWidth * FHeight); + FillArea(0, 0, FWidth, FHeight, -1); + for i := 0 to FIEMObjectList.Count - 1 do + begin + obj := TfrxIEMObjectList(FIEMObjectList[i]); + if (Obj.Obj.Style <> nil) and (Obj.Obj.Style.Color = clNone) then + begin + old := GetCell(obj.x, obj.y); + if old <> -1 then + begin + OldColor := TfrxIEMObjectList(FIEMObjectList[Old]).Obj.Style.Color; + if (OldColor <> Obj.Obj.Style.Color) and (OldColor <> Obj.Obj.Style.Font.Color) then + begin + Style := TfrxIEMStyle.Create; + Style.Assign(Obj.Obj.Style); + Style.Color := OldColor; + Obj.Obj.StyleIndex := AddStyleInternal(Style); + Obj.Obj.Style := TfrxIEMStyle(FIEMStyleList[Obj.Obj.StyleIndex]); + end; + end; + end; + FillArea(obj.x, obj.y, obj.dx, obj.dy, i); + end; + if FShowProgress then + FProgress.Tick; +end; + +procedure TfrxIEMatrix.ReplaceArea(ObjIndex, x, y, dx, dy, Value: integer); +var + i, j: integer; +begin + for i := y to y + dy - 1 do + for j := x to x + dx - 1 do + if GetCell(j, i) = ObjIndex then + FMatrix[FWidth * i + j] := Value; +end; + +procedure TfrxIEMatrix.SetCell(x, y, Value: integer); +begin + if (x < FWidth) and (y < FHeight) and (x >= 0) and (y >= 0) then + FMatrix[FWidth * y + x] := Value; +end; + +procedure TfrxIEMatrix.DeleteMatrixLine(y: Integer); +var + i, j: Integer; + delta: Extended; +begin + if (y >= 0) and (y < FHeight) then + begin + if (y < FHeight - 1) then + delta := TfrxIEMPos(FYPos[y + 1]).Value - TfrxIEMPos(FYPos[y]).Value + else + delta := 0; + for i := 1 to FHeight - y - 1 do + TfrxIEMPos(FYPos[y + i]).Value := TfrxIEMPos(FYPos[y + i]).Value - delta; + if Assigned(TfrxIEMPos(FYPos[y])) then + TfrxIEMPos(FYPos[y]).Free; + FYPos.Delete(y); + j := FWidth * (FHeight - y - 1); + for i := 0 to j - 1 do + FMatrix[FWidth * y + i] := FMatrix[FWidth * (y + 1) + i]; + Dec(FHeight); + end; +end; + +function TfrxIEMatrix.GetFontCharset(Font: TFont): Integer; +var + b: TBitmap; + pm: ^OUTLINETEXTMETRIC; + i: Cardinal; +begin + Result := 0; + b := TBitmap.Create; + try + b.Canvas.Lock; + b.Canvas.Font.Assign(Font); + i := GetOutlineTextMetrics(b.Canvas.Handle, 0, nil); + if i = 0 then + begin + b.Canvas.Font.Name := 'Arial'; + i := GetOutlineTextMetrics(b.Canvas.Handle, 0, nil); + end; + if i <> 0 then + begin + pm := GlobalAllocPtr(GMEM_MOVEABLE or GMEM_SHARE, i); + try + if pm <> nil then + i := GetOutlineTextMetrics(b.Canvas.Handle, i, pm) + else + i := 0; + if i <> 0 then + Result := pm.otmTextMetrics.tmCharSet; + finally + GlobalFreePtr(pm); + end; + end; + finally + b.Canvas.Unlock; + b.Free; + end; +end; + +procedure TfrxIEMatrix.SetPageFooter(Band: TfrxBand); +begin + FFooter := Band; +end; + +procedure TfrxIEMatrix.SetPageHeader(Band: TfrxBand); +begin + FHeader := Band; +end; + +{ TfrxIEMObjectList } + +constructor TfrxIEMObjectList.Create; +begin + Exist := False; +end; + +destructor TfrxIEMObjectList.Destroy; +begin + Obj.Free; + inherited; +end; + +{ TfrxIEMStyle } + +procedure TfrxIEMStyle.Assign(Style: TfrxIEMStyle); +begin + Font.Assign(Style.Font); + FDisplayFormat.Assign(Style.DisplayFormat); + LineSpacing := Style.LineSpacing; + GapX := Style.GapX; + GapY := Style.GapY; + ParagraphGap := Style.ParagraphGap; + CharSpacing := Style.CharSpacing; + Charset := Style.Charset; + WordBreak := Style.WordBreak; + VAlign := Style.VAlign; + HAlign := Style.HAlign; + FrameTyp := Style.FrameTyp; + FrameWidth := Style.FrameWidth; + FrameColor := Style.FrameColor; + FrameStyle := Style.FrameStyle; + Color := Style.Color; + Rotation := Style.Rotation; + BrushStyle := Style.BrushStyle; +end; + +constructor TfrxIEMStyle.Create; +begin + Font := TFont.Create; + FDisplayFormat := TfrxFormat.Create; + FDisplayFormat.DecimalSeparator := ''; + FDisplayFormat.FormatStr := ''; + FDisplayFormat.Kind := fkText; +end; + +procedure TfrxIEMStyle.SetDisplayFormat(const Value: TfrxFormat); +begin + FDisplayFormat.Assign(Value); +end; + +destructor TfrxIEMStyle.Destroy; +begin + FDisplayFormat.Free; + Font.Free; + inherited; +end; + +{ TfrxIEMObject } + +constructor TfrxIEMObject.Create; +begin + FMemo := TWideStrings.Create; + Left := 0; + Top := 0; + Image := nil; + FParent := nil; + FCounter := 0; + FIsText := true; + FIsRichText := false; + FIsDialogObject := False; + FLink := nil; + FHTMLTags := False; +end; + +destructor TfrxIEMObject.Destroy; +begin + FMemo.Free; + if Assigned(FImage) then + FImage.Free; + inherited; +end; + +function TfrxIEMObject.GetImage: TBitmap; +begin + Result := FImage; +end; + +procedure TfrxIEMObject.SetImage(const Value: TBitmap); +begin + FImage := Value; +end; + +procedure TfrxIEMObject.SetMemo(const Value: TWideStrings); +begin + FMemo.Assign(Value); +end; + +end. diff --git a/official/4.2/LibD11/frxExportODF.dfm b/official/4.2/LibD11/frxExportODF.dfm new file mode 100644 index 0000000..3f0962c Binary files /dev/null and b/official/4.2/LibD11/frxExportODF.dfm differ diff --git a/official/4.2/LibD11/frxExportODF.pas b/official/4.2/LibD11/frxExportODF.pas new file mode 100644 index 0000000..3a1ee27 --- /dev/null +++ b/official/4.2/LibD11/frxExportODF.pas @@ -0,0 +1,1128 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Open Document Format export } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportODF; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, extctrls, Printers, frxClass, frxExportMatrix, frxProgress, + frxXML, ShellAPI, frxZip {$IFDEF Delphi6}, Variants {$ENDIF}; + +type + TfrxODFExportDialog = class(TForm) + OkB: TButton; + CancelB: TButton; + SaveDialog1: TSaveDialog; + GroupPageRange: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + GroupQuality: TGroupBox; + WCB: TCheckBox; + ContinuousCB: TCheckBox; + PageBreaksCB: TCheckBox; + OpenCB: TCheckBox; + BackgrCB: TCheckBox; + procedure FormCreate(Sender: TObject); + procedure PageNumbersEChange(Sender: TObject); + procedure PageNumbersEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + end; + + TfrxODFExport = class(TfrxCustomExportFilter) + private + FExportPageBreaks: Boolean; + FExportStyles: Boolean; + FFirstPage: Boolean; + FMatrix: TfrxIEMatrix; + FOpenAfterExport: Boolean; + FPageBottom: Extended; + FPageLeft: Extended; + FPageRight: Extended; + FPageTop: Extended; + FPageWidth: Extended; + FPageHeight: Extended; + FPageOrientation: TPrinterOrientation; + FShowProgress: Boolean; + FWysiwyg: Boolean; + FBackground: Boolean; + FCreator: String; + FEmptyLines: Boolean; + FTempFolder: String; + FZipFile: TfrxZipArchive; + FThumbImage: TImage; + FProgress: TfrxProgress; + FExportType: String; + procedure DoOnProgress(Sender: TObject); + function OdfPrepareString(const Str: WideString): WideString; + function OdfGetFrameName(const FrameStyle: TfrxFrameStyle): String; + procedure OdfMakeHeader(const Item: TfrxXMLItem); + procedure OdfCreateMeta(const FileName: String; const Creator: String); + procedure OdfCreateManifest(const FileName: String; const PicCount: Integer; const MValue: String); + procedure OdfCreateMime(const FileName: String; const MValue: String); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + procedure ExportObject(Obj: TfrxComponent); override; + property ExportType: String read FExportType write FExportType; + property ExportTitle; + protected + procedure ExportPage(Stream: TStream); + published + property ExportStyles: Boolean read FExportStyles write FExportStyles default True; + property ExportPageBreaks: Boolean read FExportPageBreaks write FExportPageBreaks default True; + property OpenAfterExport: Boolean read FOpenAfterExport + write FOpenAfterExport default False; + property ShowProgress: Boolean read FShowProgress write FShowProgress; + property Wysiwyg: Boolean read FWysiwyg write FWysiwyg default True; + property Background: Boolean read FBackground write FBackground default False; + property Creator: String read FCreator write FCreator; + property EmptyLines: Boolean read FEmptyLines write FEmptyLines; + property SuppressPageHeadersFooters; + end; + + TfrxODSExport = class(TfrxODFExport) + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + property ExportTitle; + published + property ExportStyles; + property ExportPageBreaks; + property OpenAfterExport; + property ShowProgress; + property Wysiwyg; + property Background; + property Creator; + property EmptyLines; + property SuppressPageHeadersFooters; + end; + + TfrxODTExport = class(TfrxODFExport) + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + published + property ExportStyles; + property ExportPageBreaks; + property OpenAfterExport; + property ShowProgress; + property Wysiwyg; + property Background; + property Creator; + property EmptyLines; + property SuppressPageHeadersFooters; + end; + +implementation + +uses frxUtils, frxFileUtils, frxUnicodeUtils, frxRes, frxrcExports; + +{$R *.dfm} + +const + odfDivider = 37.82; + odfPageDiv = 37.8; + odfMargDiv = 10; + odfHeaderSize = 20; + odfRep = 'urn:oasis:names:tc:opendocument:xmlns:'; + +var + odfXMLHeader: array[0..odfHeaderSize - 1] of array [0..1] of String = ( + ('xmlns:office', odfRep + 'office:1.0'), + ('xmlns:style', odfRep + 'style:1.0'), + ('xmlns:text', odfRep + 'text:1.0'), + ('xmlns:table', odfRep + 'table:1.0'), + ('xmlns:draw', odfRep + 'drawing:1.0'), + ('xmlns:fo', odfRep + 'xsl-fo-compatible:1.0'), + ('xmlns:xlink', 'http://www.w3.org/1999/xlink'), + ('xmlns:dc', 'http://purl.org/dc/elements/1.1/'), + ('xmlns:meta', odfRep + 'meta:1.0'), + ('xmlns:number', odfRep + 'datastyle:1.0'), + ('xmlns:svg', odfRep + 'svg-compatible:1.0'), + ('xmlns:chart', odfRep + 'chart:1.0'), + ('xmlns:dr3d', odfRep + 'dr3d:1.0'), + ('xmlns:math', 'http://www.w3.org/1998/Math/MathML'), + ('xmlns:form', odfRep + 'form:1.0'), + ('xmlns:script', odfRep + 'script:1.0'), + ('xmlns:dom', 'http://www.w3.org/2001/xml-events'), + ('xmlns:xforms', 'http://www.w3.org/2002/xforms'), + ('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'), + ('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance')); + +{ TfrxODFExport } + +constructor TfrxODFExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FExportPageBreaks := True; + FExportStyles := True; + FShowProgress := True; + FWysiwyg := True; + FBackground := True; + FCreator := 'FastReport'; + FEmptyLines := True; + FThumbImage := TImage.Create(nil); +end; + +class function TfrxODFExport.GetDescription: String; +begin + Result := ''; +end; + +procedure TfrxODFExport.OdfCreateMeta(const FileName: String; const Creator: String); +var + XML: TfrxXMLDocument; +begin + XML := TfrxXMLDocument.Create; + try + XML.AutoIndent := True; + XML.Root.Name := 'office:document-meta'; + XML.Root.Prop['xmlns:office'] := 'urn:oasis:names:tc:opendocument:xmlns:office:1.0'; + XML.Root.Prop['xmlns:xlink'] := 'http://www.w3.org/1999/xlink'; + XML.Root.Prop['xmlns:dc'] := 'http://purl.org/dc/elements/1.1/'; + XML.Root.Prop['xmlns:meta'] := 'urn:oasis:names:tc:opendocument:xmlns:meta:1.0'; + with XML.Root.Add do + begin + Name := 'office:meta'; + with Add do + begin + Name := 'meta:generator'; + Value := 'fast-report.com/Fast Report/build:' + FR_VERSION; + end; + with Add do + begin + Name := 'meta:initial-creator'; + Value := Creator; + end; + with Add do + begin + Name := 'meta:creation-date'; + Value := FormatDateTime('YYYY-MM-DD', Now) + 'T' + FormatDateTime('HH:MM:SS', Now); + end; + end; + XML.SaveToFile(FileName); + finally + XML.Free; + end; +end; + +procedure TfrxODFExport.OdfCreateMime(const FileName: String; const MValue: String); +var + f: TFileStream; + s: String; +begin + f := TFileStream.Create(FileName, fmCreate); + try + s := 'application/vnd.oasis.opendocument.' + MValue; + f.Write(s[1], Length(s)); + finally + f.Free; + end; +end; + +procedure TfrxODFExport.OdfCreateManifest(const FileName: String; const PicCount: Integer; const MValue: String); +var + XML: TfrxXMLDocument; + i: Integer; +begin + XML := TfrxXMLDocument.Create; + try + XML.AutoIndent := True; + XML.Root.Name := 'manifest:manifest'; + XML.Root.Prop['xmlns:manifest'] := 'urn:oasis:names:tc:opendocument:xmlns:manifest:1.0'; + with XML.Root.Add do + begin + Name := 'manifest:file-entry'; + Prop['manifest:media-type'] := 'application/vnd.oasis.opendocument.' + MValue; + Prop['manifest:full-path'] := '/'; + end; + with XML.Root.Add do + begin + Name := 'manifest:file-entry'; + Prop['manifest:media-type'] := 'text/xml'; + Prop['manifest:full-path'] := 'content.xml'; + end; + with XML.Root.Add do + begin + Name := 'manifest:file-entry'; + Prop['manifest:media-type'] := 'text/xml'; + Prop['manifest:full-path'] := 'styles.xml'; + end; + with XML.Root.Add do + begin + Name := 'manifest:file-entry'; + Prop['manifest:media-type'] := 'text/xml'; + Prop['manifest:full-path'] := 'meta.xml'; + end; + for i := 1 to PicCount do + with XML.Root.Add do + begin + Name := 'manifest:file-entry'; + Prop['manifest:media-type'] := 'image/bmp'; + Prop['manifest:full-path'] := 'Pictures/Pic' + IntToStr(i) + '.bmp'; + end; + XML.SaveToFile(FileName); + finally + XML.Free; + end; +end; + +function TfrxODFExport.OdfPrepareString(const Str: WideString): WideString; +var + i: Integer; + s: WideString; +begin + Result := ''; + s := Str; + if Copy(s, Length(s) - 1, 4) = #13#10 then + Delete(s, Length(s) - 1, 4); + for i := 1 to Length(s) do + begin + if s[i] = '&' then + Result := Result + '&' + else + if s[i] = '"' then + Result := Result + '"' + else if s[i] = '<' then + Result := Result + '<' + else if s[i] = '>' then + Result := Result + '>' + else if (s[i] <> #10) then + Result := Result + s[i] + end; +end; + +function TfrxODFExport.OdfGetFrameName(const FrameStyle: TfrxFrameStyle): String; +begin + if FrameStyle = fsDouble then + Result := 'double' + else + Result := 'solid'; +end; + +procedure TfrxODFExport.OdfMakeHeader(const Item: TfrxXMLItem); +var + i: Integer; +begin + for i := 0 to odfHeaderSize - 1 do + Item.Prop[odfXMLHeader[i][0]] := odfXMLHeader[i][1]; +end; + +procedure TfrxODFExport.ExportPage(Stream: TStream); +var + XML: TfrxXMLDocument; + f: TFileStream; + s, s1, s2: WideString; + FList: TStringList; + i, j, x, y, Page, PicCount: Integer; + dx, dy, fx, fy: Integer; + Style: TfrxIEMStyle; + d: Extended; + Obj: TfrxIEMObject; + l : integer; +begin + if ShowProgress then + FProgress.Execute(FMatrix.Height - 1, frxResources.Get('ProgressWait'), True, True); + FTempFolder := GetTempFile; + DeleteFile(FTempFolder); + FTempFolder := FTempFolder + '\'; + MkDir(FTempFolder); + MkDir(FTempFolder + 'Pictures'); + MkDir(FTempFolder + 'Thumbnails'); + PicCount := 0; + FThumbImage.Picture.SaveToFile(FTempFolder + 'Thumbnails\thumbnail.bmp'); + XML := TfrxXMLDocument.Create; + try + XML.AutoIndent := True; + XML.Root.Name := 'office:document-styles'; + OdfMakeHeader(XML.Root); + with XML.Root.Add do + begin + Name := 'office:automatic-styles'; + with Add do + begin + Name := 'style:page-layout'; + Prop['style:name'] := 'pm1'; + with Add do + begin + Name := 'style:page-layout-properties'; + Prop['fo:page-width'] := frFloat2Str( FPageWidth / odfPageDiv, 1) + 'cm'; + Prop['fo:page-height'] := frFloat2Str( FPageHeight / odfPageDiv, 1) + 'cm'; + Prop['fo:margin-top'] := frFloat2Str(FPageTop / odfMargDiv, 3) + 'cm'; + Prop['fo:margin-bottom'] := frFloat2Str(FPageBottom / odfMargDiv, 3) + 'cm'; + Prop['fo:margin-left'] := frFloat2Str(FPageLeft / odfMargDiv, 3) + 'cm'; + Prop['fo:margin-right'] := frFloat2Str(FPageRight / odfMargDiv, 3) + 'cm'; + end; + end; + end; + with XML.Root.Add do + begin + Name := 'office:master-styles'; + with Add do + begin + Name := 'style:master-page'; + Prop['style:name'] := 'PageDef'; + Prop['style:page-layout-name'] := 'pm1'; + with Add do + begin + Name := 'style:header'; + Prop['style:display'] := 'false'; + end; + with Add do + begin + Name := 'style:footer'; + Prop['style:display'] := 'false'; + end; + end; + end; + XML.SaveToFile(FTempFolder + 'styles.xml'); + finally + XML.Free; + end; + + XML := TfrxXMLDocument.Create; + try + XML.AutoIndent := True; + XML.Root.Name := 'office:document-content'; + OdfMakeHeader(XML.Root); + with XML.Root.Add do + Name := 'office:scripts'; + // font styles + FList := TStringList.Create; + try + FList.Sorted := True; + for i := 0 to FMatrix.StylesCount - 1 do + begin + Style := FMatrix.GetStyleById(i); + if (Style.Font <> nil) and (FList.IndexOf(Style.Font.Name) = -1) then + FList.Add(Style.Font.Name); + end; + with XML.Root.Add do + begin + Name := 'office:font-face-decls'; + for i := 0 to FList.Count - 1 do + begin + with Add do + begin + Name := 'style:font-face'; + Prop['style:name'] := FList[i]; + Prop['svg:font-family'] := ''' + FList[i] + '''; + Prop['style:font-pitch'] := 'variable'; + end; + end; + end; + finally + FList.Free; + end; + with XML.Root.Add do + begin + Name := 'office:automatic-styles'; + // columns styles + FList := TStringList.Create; + try + FList.Sorted := True; + for i := 1 to FMatrix.Width - 1 do + begin + d := (FMatrix.GetXPosById(i) - FMatrix.GetXPosById(i - 1)) / odfDivider; + s := frFloat2Str(d, 3); + if FList.IndexOf(s) = -1 then + FList.Add(s); + end; + for i := 0 to FList.Count - 1 do + begin + with Add do + begin + Name := 'style:style'; + Prop['style:name'] := 'co' + FList[i]; + Prop['style:family'] := 'table-column'; + with Add do + begin + Name := 'style:table-column-properties'; + Prop['fo:break-before'] := 'auto'; + Prop['style:column-width'] := FList[i] + 'cm'; + end; + end; + end; + finally + FList.Free; + end; + // rows styles + FList := TStringList.Create; + try + FList.Sorted := True; + for i := 0 to FMatrix.Height - 2 do + begin + d := (FMatrix.GetYPosById(i + 1) - FMatrix.GetYPosById(i)) / odfDivider; + s := frFloat2Str(d, 3); + if FList.IndexOf(s) = -1 then + FList.Add(s); + end; + for i := 0 to FList.Count - 1 do + begin + with Add do + begin + Name := 'style:style'; + Prop['style:name'] := 'ro' + FList[i]; + Prop['style:family'] := 'table-row'; + with Add do + begin + Name := 'style:table-row-properties'; + Prop['fo:break-before'] := 'auto'; + Prop['style:row-height'] := FList[i] + 'cm'; + end; + end; + end; + with Add do + begin + Name := 'style:style'; + Prop['style:name'] := 'ro_breaked'; + Prop['style:family'] := 'table-row'; + with Add do + begin + Name := 'style:table-row-properties'; + Prop['fo:break-before'] := 'page'; + Prop['style:row-height'] := '0.001cm'; + end; + end; + finally + FList.Free; + end; + // table style + with Add do + begin + Name := 'style:style'; + Prop['style:name'] := 'ta1'; + Prop['style:family'] := 'table'; + Prop['style:master-page-name'] := 'PageDef'; + with Add do + begin + Name := 'style:table-properties'; + Prop['table:display'] := 'true'; + Prop['style:writing-mode'] := 'lr-tb'; /// RTL - LTR? + end; + end; + // cells styles + with Add do + begin + Name := 'style:style'; + Prop['style:name'] := 'ceb'; + Prop['style:family'] := 'table-cell'; + Prop['style:display'] := 'false'; + end; + for i := 0 to FMatrix.StylesCount - 1 do + begin + Style := FMatrix.GetStyleById(i); + with Add do + begin + Name := 'style:style'; + Prop['style:name'] := 'ce' + IntToStr(i); + Prop['style:family'] := 'table-cell'; + Prop['style:parent-style-name'] := 'Default'; + if FExportType <> 'text' then + begin + with Add do + begin + Name := 'style:text-properties'; + Prop['style:font-name'] := Style.Font.Name; + Prop['fo:font-size'] := IntToStr(Style.Font.Size) + 'pt'; + if fsUnderline in Style.Font.Style then + begin + Prop['style:text-underline-style'] := 'solid'; + Prop['style:text-underline-width'] := 'auto'; + Prop['style:text-underline-color'] := 'font-color'; + end; + if fsItalic in Style.Font.Style then + Prop['fo:font-style'] := 'italic'; + if fsBold in Style.Font.Style then + Prop['fo:font-weight'] := 'bold'; + Prop['fo:color'] := HTMLRGBColor(Style.Font.Color); + end; + with Add do + begin + Name := 'style:paragraph-properties'; + if Style.HAlign = haLeft then + Prop['fo:text-align'] := 'start'; + if Style.HAlign = haCenter then + Prop['fo:text-align'] := 'center'; + if Style.HAlign = haRight then + Prop['fo:text-align'] := 'end'; + if Style.GapX <> 0 then + begin + Prop['fo:margin-left'] := frFloat2Str(Style.GapX / odfDivider, 3) + 'cm'; + Prop['fo:margin-right'] := Prop['fo:margin-left']; + end; + end; + end; + with Add do + begin + Name := 'style:table-cell-properties'; + Prop['fo:background-color'] := HTMLRGBColor(Style.Color); + Prop['style:repeat-content'] := 'false'; + if Style.Rotation > 0 then + begin + Prop['style:rotation-angle'] := IntToStr(Style.Rotation); + Prop['style:rotation-align'] := 'none'; + end; + if Style.VAlign = vaCenter then + Prop['style:vertical-align'] := 'middle'; + if Style.VAlign = vaTop then + Prop['style:vertical-align'] := 'top'; + if Style.VAlign = vaBottom then + Prop['style:vertical-align'] := 'bottom'; + if (ftLeft in Style.FrameTyp) then + Prop['fo:border-left'] := frFloat2Str(Style.FrameWidth / odfDivider, 3) + 'cm ' + OdfGetFrameName(Style.FrameStyle) + ' ' + HTMLRGBColor(Style.FrameColor); + if (ftRight in Style.FrameTyp) then + Prop['fo:border-right'] := frFloat2Str(Style.FrameWidth / odfDivider, 3) + 'cm ' + OdfGetFrameName(Style.FrameStyle) + ' ' + HTMLRGBColor(Style.FrameColor); + if (ftTop in Style.FrameTyp) then + Prop['fo:border-top'] := frFloat2Str(Style.FrameWidth / odfDivider, 3) + 'cm ' + OdfGetFrameName(Style.FrameStyle) + ' ' + HTMLRGBColor(Style.FrameColor); + if (ftBottom in Style.FrameTyp) then + Prop['fo:border-bottom'] := frFloat2Str(Style.FrameWidth / odfDivider, 3) + 'cm ' + OdfGetFrameName(Style.FrameStyle) + ' ' + HTMLRGBColor(Style.FrameColor); + end; + end; + end; + if FExportType = 'text' then + begin + // text styles + with Add do + begin + Name := 'style:style'; + Prop['style:name'] := 'pb'; + Prop['style:family'] := 'paragraph'; + Prop['style:display'] := 'false'; + end; + for i := 0 to FMatrix.StylesCount - 1 do + begin + Style := FMatrix.GetStyleById(i); + with Add do + begin + Name := 'style:style'; + Prop['style:name'] := 'p' + IntToStr(i); + Prop['style:family'] := 'paragraph'; + Prop['style:parent-style-name'] := 'Default'; + with Add do + begin + Name := 'style:text-properties'; + Prop['style:font-name'] := Style.Font.Name; + Prop['fo:font-size'] := IntToStr(Style.Font.Size) + 'pt'; + if fsUnderline in Style.Font.Style then + begin + Prop['style:text-underline-style'] := 'solid'; + Prop['style:text-underline-width'] := 'auto'; + Prop['style:text-underline-color'] := 'font-color'; + end; + if fsItalic in Style.Font.Style then + Prop['fo:font-style'] := 'italic'; + if fsBold in Style.Font.Style then + Prop['fo:font-weight'] := 'bold'; + Prop['fo:color'] := HTMLRGBColor(Style.Font.Color); + end; + with Add do + begin + Name := 'style:paragraph-properties'; + if Style.HAlign = haLeft then + Prop['fo:text-align'] := 'start'; + if Style.HAlign = haCenter then + Prop['fo:text-align'] := 'center'; + if Style.HAlign = haRight then + Prop['fo:text-align'] := 'end'; + if Style.GapX <> 0 then + begin + Prop['fo:margin-left'] := frFloat2Str(Style.GapX / odfDivider, 3) + 'cm'; + Prop['fo:margin-right'] := Prop['fo:margin-left']; + end; + end; + end; + end; + end; + // pic style + with Add do + begin + Name := 'style:style'; + Prop['style:name'] := 'gr1'; + Prop['style:family'] := 'graphic'; + with Add do + begin + Name := 'style:graphic-properties'; + Prop['draw:stroke'] := 'none'; + Prop['draw:fill'] := 'none'; + Prop['draw:textarea-horizontal-align'] := 'center'; + Prop['draw:textarea-vertical-align'] := 'middle'; + Prop['draw:color-mode'] := 'standard'; + Prop['draw:luminance'] := '0%'; + Prop['draw:contrast'] := '0%'; + Prop['draw:gamma'] := '100%'; + Prop['draw:red'] := '0%'; + Prop['draw:green'] := '0%'; + Prop['draw:blue'] := '0%'; + Prop['fo:clip'] := 'rect(0cm 0cm 0cm 0cm)'; + Prop['draw:image-opacity'] := '100%'; + Prop['style:mirror'] := 'none'; + end; + end; + end; + // BODY + with XML.Root.Add do + begin + Name := 'office:body'; + with Add do + begin + Name := 'office:spreadsheet'; + with Add do + begin + Name := 'table:table'; + Prop['table:name'] := 'Table'; + Prop['table:style-name'] := 'ta1'; + Prop['table:print'] := 'false'; + for x := 1 to FMatrix.Width - 1 do + with Add do + begin + Name := 'table:table-column'; + d := (FMatrix.GetXPosById(x) - FMatrix.GetXPosById(x - 1)) / odfDivider; + s := frFloat2Str(d, 3); + Prop['table:style-name'] := 'co' + s; + end; + Page := 0; + for y := 0 to FMatrix.Height - 2 do + begin + if ShowProgress then + begin + FProgress.Tick; + if FProgress.Terminated then + break; + end; + if FMatrix.PagesCount > Page then + if FMatrix.GetYPosById(y) >= FMatrix.GetPageBreak(Page) then + begin + Inc(Page); + if FExportPageBreaks then + with Add do + begin + Name := 'table:table-row'; + Prop['table:style-name'] := 'ro_breaked'; + end; + continue; + end; + with Add do + begin + Name := 'table:table-row'; + d := (FMatrix.GetYPosById(y + 1) - FMatrix.GetYPosById(y)) / odfDivider; + s := frFloat2Str(d, 3); + Prop['table:style-name'] := 'ro' + s; + for x := 0 to FMatrix.Width - 1 do + begin + i := FMatrix.GetCell(x, y); + with Add do + begin + if i <> -1 then + begin + Obj := FMatrix.GetObjectById(i); + if Obj.Counter = 0 then + begin + Name := 'table:table-cell'; + Obj.Counter := 1; + FMatrix.GetObjectPos(i, fx, fy, dx, dy); + Prop['table:style-name'] := 'ce' + IntToStr(Obj.StyleIndex); + if dx > 1 then + Prop['table:number-columns-spanned'] := IntToStr(dx); + if dy > 1 then + Prop['table:number-rows-spanned'] := IntToStr(dy); + // text + if Obj.IsText then + begin + +// s := UTF8Encode(OdfPrepareString(Obj.Memo.Text)); +// added from + s := OdfPrepareString(Obj.Memo.Text); + if Obj.Style.FDisplayFormat.Kind = fkNumeric then + begin + s2 := ''; + for l := 1 to length(s) do + if ((s[l] >= '0') and (s[l] <= '9')) or (s[l] = '-') then + s2 := s2 + s[l] + else + if Copy(s, l, 1) = DecimalSeparator then + s2 := s2 + '.'; + Prop['office:value-type'] := 'float'; + end + else + s2 := s; + s := UTF8Encode(s2); +// added to + Prop['office:value'] := s; + with Add do + begin + Name := 'text:p'; + if FExportType = 'text' then + Prop['text:style-name'] := 'p' + IntToStr(Obj.StyleIndex); + Value := s; + end; + end + else + // picture + if Obj.Image <> nil then + begin + Inc(PicCount); + with Add do + begin + s := 'pic' + IntToStr(PicCount) + '.bmp'; + Obj.Image.SaveToFile(FTempFolder + 'Pictures\' + s); + Name := 'draw:frame'; + Prop['draw:z-index'] := '0'; + Prop['draw:name'] := 'Picture' + IntToStr(PicCount); + Prop['draw:style-name'] := 'gr1'; + Prop['draw:text-style-name'] := 'P1'; + Prop['svg:width'] := frFloat2Str(Obj.Width / odfDivider, 3) + 'cm'; + Prop['svg:height'] := frFloat2Str(Obj.Height / odfDivider, 3) + 'cm'; + Prop['svg:x'] := '0cm'; + Prop['svg:y'] := '0cm'; + with Add do + begin + Name := 'draw:image'; + Prop['xlink:href'] := 'Pictures/' + s; + Prop['xlink:type'] := 'simple'; + Prop['xlink:show'] := 'embed'; + Prop['xlink:actuate'] := 'onLoad'; + end; + end; + end; + end + else + begin + Name := 'table:covered-table-cell'; + Prop['table:style-name'] := 'ceb'; + if FExportType = 'text' then + begin + with Add do + begin + Name := 'text:p'; + if FExportType = 'text' then + Prop['text:style-name'] := 'pb'; + end; + end; + end; + end + else + begin + Name := 'table:table-cell'; + if FExportType = 'text' then + begin + with Add do + begin + Name := 'text:p'; + if FExportType = 'text' then + Prop['text:style-name'] := 'pb'; + end; + end; + end; + end; + end; + end; + end; + end; + end; + end; + XML.SaveToFile(FTempFolder + 'content.xml'); + finally + XML.Free; + end; + MkDir(FTempFolder + 'META-INF'); + s := FExportType; + OdfCreateManifest(FTempFolder + 'META-INF\manifest.xml', PicCount, s); + OdfCreateMime(FTempFolder + 'mimetype', s); + OdfCreateMeta(FTempFolder + 'meta.xml', Creator); + FZipFile := TfrxZipArchive.Create; + try + FZipFile.RootFolder := FTempFolder; + FZipFile.AddDir(FTempFolder); + if ShowProgress then + begin + FProgress.Execute(FZipFile.FileCount, frxResources.Get('ProgressWait'), True, True); + FZipFile.OnProgress := DoOnProgress; + end; + FZipFile.SaveToStream(Stream); + finally + FZipFile.Free; + end; + DeleteFolder(FTempFolder); +end; + +function TfrxODFExport.ShowModal: TModalResult; +begin + if not Assigned(Stream) then + begin + with TfrxODFExportDialog.Create(nil) do + begin + SaveDialog1.DefaultExt := DefaultExt; + SaveDialog1.Filter := FilterDesc; + Caption := ExportTitle; + OpenCB.Visible := not SlaveExport; + if SlaveExport then + FOpenAfterExport := False; + + if (FileName = '') and (not SlaveExport) then + SaveDialog1.FileName := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), SaveDialog1.DefaultExt) + else + SaveDialog1.FileName := FileName; + + ContinuousCB.Checked := (not EmptyLines) or SuppressPageHeadersFooters; + PageBreaksCB.Checked := FExportPageBreaks and (not ContinuousCB.Checked); + WCB.Checked := FWysiwyg; + OpenCB.Checked := FOpenAfterExport; + BackgrCB.Checked := FBackground; + + if PageNumbers <> '' then + begin + PageNumbersE.Text := PageNumbers; + PageNumbersRB.Checked := True; + end; + + Result := ShowModal; + + if Result = mrOk then + begin + PageNumbers := ''; + CurPage := False; + if CurPageRB.Checked then + CurPage := True + else if PageNumbersRB.Checked then + PageNumbers := PageNumbersE.Text; + + FExportPageBreaks := PageBreaksCB.Checked and (not ContinuousCB.Checked); + EmptyLines := not ContinuousCB.Checked; + SuppressPageHeadersFooters := ContinuousCB.Checked; + FWysiwyg := WCB.Checked; + FOpenAfterExport := OpenCB.Checked; + FBackground := BackgrCB.Checked; + + if not SlaveExport then + begin + if DefaultPath <> '' then + SaveDialog1.InitialDir := DefaultPath; + if SaveDialog1.Execute then + FileName := SaveDialog1.FileName + else + Result := mrCancel; + end + else + FileName := ChangeFileExt(GetTempFile, SaveDialog1.DefaultExt); + end; + Free; + end; + end else + Result := mrOk; +end; + +function TfrxODFExport.Start: Boolean; +begin + FThumbImage.Width := 0; + FThumbImage.Height := 0; + if (FileName <> '') or Assigned(Stream) then + begin + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + FileName := DefaultPath + '\' + FileName; + FFirstPage := True; + FMatrix := TfrxIEMatrix.Create(UseFileCache, Report.EngineOptions.TempDir); + FMatrix.RotatedAsImage := False; + FMatrix.ShowProgress := ShowProgress; + FMatrix.Background := FBackground and FEmptyLines; + FMatrix.BackgroundImage := False; + FMatrix.Printable := ExportNotPrintable; + FMatrix.RichText := True; + FMatrix.PlainRich := True; + FMatrix.EmptyLines := FEmptyLines; + FMatrix.WrapText := True; + FExportPageBreaks := FExportPageBreaks and FEmptyLines; + if FWysiwyg then + FMatrix.Inaccuracy := 0.5 + else + FMatrix.Inaccuracy := 10; + FMatrix.DeleteHTMLTags := True; + Result := True + end + else + Result := False; +end; + +procedure TfrxODFExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + if FFirstPage then + begin + FPageLeft := Page.LeftMargin; + FPageTop := Page.TopMargin; + FPageBottom := Page.BottomMargin; + FPageRight := Page.RightMargin; + FPageOrientation := Page.Orientation; + FPageWidth := Page.Width; + FPageHeight := Page.Height; + FThumbImage.Width := Round(Page.Width / 5); + FThumbImage.Height := Round(Page.Height / 5); + end; +end; + +procedure TfrxODFExport.ExportObject(Obj: TfrxComponent); +begin + if (Obj is TfrxView) and (ExportNotPrintable or TfrxView(Obj).Printable) then + begin + FMatrix.AddObject(TfrxView(Obj)); + if FFirstPage then + TfrxView(Obj).Draw(FThumbImage.Canvas, 0.2, 0.2, Obj.Left / 5, Obj.Top / 5); + end; +end; + +procedure TfrxODFExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + FFirstPage := False; + FMatrix.AddPage(Page.Orientation, Page.Width, Page.Height, Page.LeftMargin, + Page.TopMargin, Page.RightMargin, Page.BottomMargin); +end; + +procedure TfrxODFExport.Finish; +var + Exp: TStream; +begin + FMatrix.Prepare; + if ShowProgress then + FProgress := TfrxProgress.Create(nil); + try + try + if Assigned(Stream) then + Exp := Stream + else + Exp := TFileStream.Create(FileName, fmCreate); + try + ExportPage(Exp); + finally + if not Assigned(Stream) then + Exp.Free; + end; + if FOpenAfterExport and (not Assigned(Stream)) then + ShellExecute(GetDesktopWindow, 'open', PChar(FileName), nil, nil, SW_SHOW); + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; + finally + FMatrix.Free; + if ShowProgress then + FProgress.Free; + end; +end; + +destructor TfrxODFExport.Destroy; +begin + FThumbImage.Free; + inherited; +end; + +procedure TfrxODFExport.DoOnProgress(Sender: TObject); +begin + if ShowProgress then + FProgress.Tick; +end; + +{ TfrxODSExport } + +constructor TfrxODSExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + ExportType := 'spreadsheet'; + FilterDesc := frxResources.Get('ODSExportFilter'); + DefaultExt := frxGet(8960); + ExportTitle := frxResources.Get('ODSExport'); +end; + +class function TfrxODSExport.GetDescription: String; +begin + Result := frxResources.Get('ODSExport'); +end; + +{ TfrxODTExport } + +constructor TfrxODTExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + ExportType := 'text'; + FilterDesc := frxResources.Get('ODTExportFilter'); + DefaultExt := frxGet(8961); + ExportTitle := frxResources.Get('ODTExport'); +end; + +class function TfrxODTExport.GetDescription: String; +begin + Result := frxResources.Get('ODTExport'); +end; + +{ TfrxODFExportDialog } + +procedure TfrxODFExportDialog.FormCreate(Sender: TObject); +begin + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + GroupPageRange.Caption := frxGet(7); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + DescrL.Caption := frxGet(9); + GroupQuality.Caption := frxGet(8); + ContinuousCB.Caption := frxGet(8950); + PageBreaksCB.Caption := frxGet(6); + WCB.Caption := frxGet(8102); + BackgrCB.Caption := frxGet(8103); + OpenCB.Caption := frxGet(8706); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + + +procedure TfrxODFExportDialog.PageNumbersEChange(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxODFExportDialog.PageNumbersEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8, '-', ',':; + else + key := #0; + end; +end; + +procedure TfrxODFExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxExportPDF.dfm b/official/4.2/LibD11/frxExportPDF.dfm new file mode 100644 index 0000000..29fcfcf Binary files /dev/null and b/official/4.2/LibD11/frxExportPDF.dfm differ diff --git a/official/4.2/LibD11/frxExportPDF.pas b/official/4.2/LibD11/frxExportPDF.pas new file mode 100644 index 0000000..d703bc2 --- /dev/null +++ b/official/4.2/LibD11/frxExportPDF.pas @@ -0,0 +1,307 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ PDF export filter } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportPDF; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, ComObj, Printers, frxClass, JPEG, ShellAPI, + ComCtrls, frxPDFFile +{$IFDEF Delphi6}, Variants {$ENDIF}; + +type + TfrxPDFExportDialog = class(TForm) + OkB: TButton; + CancelB: TButton; + GroupPageRange: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + GroupQuality: TGroupBox; + CompressedCB: TCheckBox; + OpenCB: TCheckBox; + SaveDialog1: TSaveDialog; + EmbeddedCB: TCheckBox; + PrintOptCB: TCheckBox; + OutlineCB: TCheckBox; + BackgrCB: TCheckBox; + procedure FormCreate(Sender: TObject); + procedure PageNumbersEChange(Sender: TObject); + procedure PageNumbersEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + end; + + TfrxPDFExport = class(TfrxCustomExportFilter) + private + FCompressed: Boolean; + FEmbedded: Boolean; + FOpenAfterExport: Boolean; + FPDF: TfrxPDFFile; + FPDFpage: TfrxPDFPage; + FPrintOpt: Boolean; + FOutline: Boolean; + FSubject: WideString; + FAuthor: WideString; + FBackground: Boolean; + FCreator: WideString; + FTags: Boolean; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure ExportObject(Obj: TfrxComponent); override; + procedure Finish; override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + published + property Compressed: Boolean read FCompressed write FCompressed default True; + property EmbeddedFonts: Boolean read FEmbedded write FEmbedded default False; + property OpenAfterExport: Boolean read FOpenAfterExport + write FOpenAfterExport default False; + property PrintOptimized: Boolean read FPrintOpt write FPrintOpt; + property Outline: Boolean read FOutline write FOutline; + property Author: WideString read FAuthor write FAuthor; + property Subject: WideString read FSubject write FSubject; + property Background: Boolean read FBackground write FBackground; + property Creator: WideString read FCreator write FCreator; + property HTMLTags: Boolean read FTags write FTags; + end; + +implementation + +uses frxUtils, frxFileUtils, frxRes, frxrcExports; + +{$R *.dfm} + +{ TfrxPDFExport } + +constructor TfrxPDFExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FCompressed := True; + FPrintOpt := False; + FAuthor := 'FastReport'; + FSubject := 'FastReport PDF export'; + FBackground := False; + FCreator := 'FastReport (http://www.fast-report.com)'; + FTags := True; + FilterDesc := frxGet(8707); + DefaultExt := frxGet(8708); +end; + +class function TfrxPDFExport.GetDescription: String; +begin + Result := frxResources.Get('PDFexport'); +end; + +function TfrxPDFExport.ShowModal: TModalResult; +var + s: String; +begin + if not Assigned(Stream) then + begin + if Assigned(Report) then + FOutline := Report.PreviewOptions.OutlineVisible + else + FOutline := True; + with TfrxPDFExportDialog.Create(nil) do + begin + OpenCB.Visible := not SlaveExport; + if SlaveExport then + FOpenAfterExport := False; + + if (FileName = '') and (not SlaveExport) then + begin + s := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), SaveDialog1.DefaultExt); + SaveDialog1.FileName := s; + end + else + SaveDialog1.FileName := FileName; + + OpenCB.Checked := FOpenAfterExport; + CompressedCB.Checked := FCompressed; + EmbeddedCB.Checked := FEmbedded; + PrintOptCB.Checked := FPrintOpt; + OutlineCB.Checked := FOutline; + OutlineCB.Enabled := FOutline; + BackgrCB.Checked := FBackground; + + if PageNumbers <> '' then + begin + PageNumbersE.Text := PageNumbers; + PageNumbersRB.Checked := True; + end; + + Result := ShowModal; + if Result = mrOk then + begin + PageNumbers := ''; + CurPage := False; + if CurPageRB.Checked then + CurPage := True + else if PageNumbersRB.Checked then + PageNumbers := PageNumbersE.Text; + + FOpenAfterExport := OpenCB.Checked; + FCompressed := CompressedCB.Checked; + FEmbedded := EmbeddedCB.Checked; + FPrintOpt := PrintOptCB.Checked; + FOutline := OutlineCB.Checked; + FBackground := BackgrCB.Checked; + if not SlaveExport then + begin + if DefaultPath <> '' then + SaveDialog1.InitialDir := DefaultPath; + if SaveDialog1.Execute then + FileName := SaveDialog1.FileName + else + Result := mrCancel; + end + else + FileName := ChangeFileExt(GetTempFile, SaveDialog1.DefaultExt); + end; + Free; + end; + end else + Result := mrOk; +end; + +function TfrxPDFExport.Start: Boolean; +var + f: Boolean; +begin + if (FileName <> '') or Assigned(Stream) then + begin + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + FileName := DefaultPath + '\' + FileName; + f := Report.PreviewPages.Count > 200; + FPDF := TfrxPDFFile.Create(UseFileCache and f, Report.EngineOptions.TempDir); + FPDF.Compressed := FCompressed; + FPDF.EmbeddedFonts := FEmbedded; + FPDF.PrintOptimized := FPrintOpt; + FPDF.Outline := FOutline; + FPDF.Background := FBackground; + FPDF.Author := FAuthor; + FPDF.Subject := FSubject; + FPDF.Creator := FCreator; + FPDF.HTMLTags := FTags; + FPDF.PageNumbers := PageNumbers; + FPDF.TotalPages := Report.PreviewPages.Count; + if FOutline then + FPDF.PreviewOutline := Report.PreviewPages.Outline; + Result := True + end else + Result := False; +end; + +procedure TfrxPDFExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + FPDFPage := FPDF.AddPage(Page); +end; + +procedure TfrxPDFExport.ExportObject(Obj: TfrxComponent); +begin + if (Obj is TfrxView) and (ExportNotPrintable or TfrxView(Obj).Printable) then + FPDFPage.AddObject(TfrxView(Obj)); +end; + +procedure TfrxPDFExport.Finish; +var + Exp: TStream; + +begin + + try + try + if Assigned(Stream) then + Exp := Stream + else + Exp := TFileStream.Create(FileName, fmCreate); + try + FPDF.Title := Report.ReportOptions.Name; + FPDF.SaveToStream(Exp); + finally + if not Assigned(Stream) then + Exp.Free; + if FOpenAfterExport and (not Assigned(Stream)) then + ShellExecute(GetDesktopWindow, 'open', PChar(FileName), nil, nil, SW_SHOW); + end; + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; + finally + FPDF.Free; + end; +end; + +{ TfrxPDFExportDialog } + +procedure TfrxPDFExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8700); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + GroupPageRange.Caption := frxGet(7); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + DescrL.Caption := frxGet(9); + GroupQuality.Caption := frxGet(8); + CompressedCB.Caption := frxGet(8701); + EmbeddedCB.Caption := frxGet(8702); + PrintOptCB.Caption := frxGet(8703); + OutlineCB.Caption := frxGet(8704); + BackgrCB.Caption := frxGet(8705); + OpenCB.Caption := frxGet(8706); + SaveDialog1.Filter := frxGet(8707); + SaveDialog1.DefaultExt := frxGet(8708); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxPDFExportDialog.PageNumbersEChange(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxPDFExportDialog.PageNumbersEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8, '-', ',':; + else + key := #0; + end; +end; + +procedure TfrxPDFExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxExportRTF.dfm b/official/4.2/LibD11/frxExportRTF.dfm new file mode 100644 index 0000000..b887b6c Binary files /dev/null and b/official/4.2/LibD11/frxExportRTF.dfm differ diff --git a/official/4.2/LibD11/frxExportRTF.pas b/official/4.2/LibD11/frxExportRTF.pas new file mode 100644 index 0000000..f1c152c --- /dev/null +++ b/official/4.2/LibD11/frxExportRTF.pas @@ -0,0 +1,1105 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ RTF export filter } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportRTF; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, extctrls, ComObj, Printers, frxClass, JPEG, ShellAPI, frxExportMatrix +{$IFDEF Delphi6}, Variants {$ENDIF}, frxProgress, ComCtrls, frxGraphicUtils; + +type + TfrxHeaderFooterMode = (hfText, hfPrint, hfNone); + + TfrxRTFExportDialog = class(TForm) + OkB: TButton; + CancelB: TButton; + GroupPageRange: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + GroupQuality: TGroupBox; + WCB: TCheckBox; + PageBreaksCB: TCheckBox; + PicturesCB: TCheckBox; + OpenCB: TCheckBox; + SaveDialog1: TSaveDialog; + ContinuousCB: TCheckBox; + HeadFootL: TLabel; + PColontitulCB: TComboBox; + procedure FormCreate(Sender: TObject); + procedure PageNumbersEChange(Sender: TObject); + procedure PageNumbersEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + end; + + TfrxRTFExport = class(TfrxCustomExportFilter) + private + FColorTable: TStringList; + FCurrentPage: Integer; + FDataList: TList; + FExportPageBreaks: Boolean; + FExportPictures: Boolean; + FFirstPage: Boolean; + FFontTable: TStringList; + FCharsetTable: TStringList; + FMatrix: TfrxIEMatrix; + FOpenAfterExport: Boolean; + FProgress: TfrxProgress; + FWysiwyg: Boolean; + FCreator: String; + FHeaderFooterMode: TfrxHeaderFooterMode; + + function TruncReturns(const Str: WideString): WideString; + function GetRTFBorders(const Style: TfrxIEMStyle): string; + function GetRTFColor(const c: DWORD): string; + function GetRTFFontStyle(const f: TFontStyles): String; + function GetRTFFontColor(const f: String): String; + function GetRTFFontName(const f: String; const charset: Integer): String; + function GetRTFHAlignment(const HAlign: TfrxHAlign) : String; + function GetRTFVAlignment(const VAlign: TfrxVAlign) : String; + function StrToRTFSlash(const Value: WideString): WideString; + function StrToRTFUnicodeEx(const Value: WideString): String; + function StrToRTFUnicode(const Value: WideString): String; + procedure ExportPage(const Stream: TStream); + procedure PrepareExport; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + function ShowModal: TModalResult; override; + function Start: boolean; override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + procedure ExportObject(Obj: TfrxComponent); override; + published + property ExportPageBreaks: Boolean read FExportPageBreaks write FExportPageBreaks default True; + property ExportPictures: Boolean read FExportPictures write FExportPictures default True; + property OpenAfterExport: Boolean read FOpenAfterExport + write FOpenAfterExport default False; + property Wysiwyg: Boolean read FWysiwyg write FWysiwyg; + property Creator: String read FCreator write FCreator; + property SuppressPageHeadersFooters; + property HeaderFooterMode: TfrxHeaderFooterMode read FHeaderFooterMode write FHeaderFooterMode; + end; + + +implementation + +uses frxUtils, frxFileUtils, frxRes, frxrcExports; + +{$R *.dfm} + +const + Xdivider = 15.05; + Ydivider = 13; + PageDivider = 15.02; + MargDivider = 56.48; + FONT_DIVIDER = 15; + IMAGE_DIVIDER = 25.3; + + +{ TfrxRTFExport } + +constructor TfrxRTFExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + ShowDialog := True; + FExportPageBreaks := True; + FExportPictures := True; + FWysiwyg := True; + FHeaderFooterMode := hfText; + FCreator := 'FastReport http://www.fast-report.com'; + FilterDesc := frxGet(8504); + DefaultExt := frxGet(8505); +end; + +class function TfrxRTFExport.GetDescription: String; +begin + Result := frxResources.Get('RTFexport'); +end; + +function TfrxRTFExport.TruncReturns(const Str: WideString): WideString; +begin + Result := Str; + if Copy(Result, Length(Result) - 1, 2) = #13#10 then + Delete(Result, Length(Result) - 1, 2); +end; + +function TfrxRTFExport.StrToRTFSlash(const Value: WideString): WideString; +var + i: integer; +begin + result := ''; + for i := 1 to Length(Value) do + begin + if Value[i] = '\' then + result := result + '\\' + else if Value[i] = '{' then + result := result + '\{' + else if Value[i] = '}' then + result := result + '\}' + else if (Value[i] = #13) and (i < (Length(Value) - 1)) and (Value[i + 1] = #10) then + result := result + '\line'#13 + else + result := result + Value[i]; + end; +end; + +function TfrxRTFExport.StrToRTFUnicodeEx(const Value: WideString): String; +var + s: WideString; +begin + s := StrToRTFSlash(Value); + Result := StrToRTFUnicode(s); +end; + +function TfrxRTFExport.StrToRTFUnicode(const Value: WideString): String; +var + i: integer; + pwc: ^Word; +begin + result := ''; + for i := 1 to Length(Value) do + begin + pwc := @Value[i]; + if pwc^ > 127 then + result := result + '\u' + IntToStr(pwc^) + '\''3f' + else + result := result + Chr(pwc^); + end; +end; + +function TfrxRTFExport.GetRTFBorders(const Style: TfrxIEMStyle): string; +var + brdrw: String; + brdrc: String; + brdrs: String; +begin + Result := ''; + brdrw := '\brdrs\brdrw' + IntToStr(Round(Style.FrameWidth * 20)); + brdrc := '\brdrcf' + GetRTFFontColor(GetRTFColor(Style.FrameColor)); + if Style.FrameStyle = fsDouble then + brdrs := '\brdrdb' + else if Style.FrameStyle <> fsSolid then + brdrs := '\brdrdashsm' + else brdrs := ''; + if ftTop in Style.FrameTyp then + Result := Result + '\clbrdrt' + brdrw + brdrc + brdrs; + if ftLeft in Style.FrameTyp then + Result := Result + '\clbrdrl' + brdrw + brdrc + brdrs; + if ftBottom in Style.FrameTyp then + Result := Result + '\clbrdrb' + brdrw + brdrc + brdrs; + if ftRight in Style.FrameTyp then + Result := Result + '\clbrdrr' + brdrw + brdrc + brdrs; +end; + +function TfrxRTFExport.GetRTFColor(const c: DWORD): string; +var + cn: DWORD; +begin + cn := ColorToRGB(c); + Result := '\red' + IntToStr(GetRValue(cn)) + + '\green' + IntToStr(GetGValue(cn)) + + '\blue' + IntToStr(GetBValue(cn)) + ';' +end; + +function TfrxRTFExport.GetRTFFontStyle(const f: TFontStyles): String; +begin + Result := ''; + if fsItalic in f then Result := '\i'; + if fsBold in f then Result := Result + '\b'; + if fsUnderline in f then Result := Result + '\ul'; +end; + +function TfrxRTFExport.GetRTFFontColor(const f: String): String; +var + i: Integer; +begin + i := FColorTable.IndexOf(f); + if i <> -1 then + Result := IntToStr(i + 1) + else + begin + FColorTable.Add(f); + Result := IntToStr(FColorTable.Count); + end; +end; + +function TfrxRTFExport.GetRTFFontName(const f: String; const Charset: Integer): String; +var + i: Integer; +begin + i := FFontTable.IndexOf(f); + if i <> -1 then + Result := IntToStr(i) + else + begin + FFontTable.Add(f); + FCharsetTable.Add(IntToStr(charset)); + Result := IntToStr(FFontTable.Count - 1); + end; +end; + +function TfrxRTFExport.GetRTFHAlignment(const HAlign: TfrxHAlign) : String; +begin + if (HAlign = haLeft) then Result := '\ql' + else if (HAlign = haRight) then Result := '\qr' + else if (HAlign = haCenter) then Result := '\qc' +// else if (HAlign = haBlock) then Result := '\qj' + else Result := '\ql'; +end; + +function TfrxRTFExport.GetRTFVAlignment(const VAlign: TfrxVAlign) : String; +begin + if (VAlign = vaTop) then Result := '\clvertalt' + else if (VAlign = vaCenter) then Result := '\clvertalc' + else if (VAlign = vaBottom) then Result := '\clvertalb' + else Result := '\clvertalt'; +end; + +procedure TfrxRTFExport.PrepareExport; +var + i, j, x, y, n, n1, fx: Integer; + s, s0, s1, s2: String; + Obj: TfrxIEMObject; + RepPos: TStringList; + + function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer; + var + I,X: Integer; + Len, LenSubStr: Integer; + begin + if Offset = 1 then + Result := Pos(SubStr, S) + else + begin + I := Offset; + LenSubStr := Length(SubStr); + Len := Length(S) - LenSubStr + 1; + while I <= Len do + begin + if S[I] = SubStr[1] then + begin + X := 1; + while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do + Inc(X); + if (X = LenSubStr) then + begin + Result := I; + exit; + end; + end; + Inc(I); + end; + Result := 0; + end; + end; + +begin + for y := 0 to FMatrix.Height - 1 do + for x := 0 to FMatrix.Width - 1 do + begin + i := FMatrix.GetCell(x, y); + if (i <> -1) then + begin + Obj := FMatrix.GetObjectById(i); + if Obj.Counter <> -1 then + begin + Obj.Counter := -1; + GetRTFFontColor(GetRTFColor(Obj.Style.Color)); + GetRTFFontColor(GetRTFColor(Obj.Style.FrameColor)); + if Obj.IsRichText then + begin + RepPos := TStringList.Create; + s := Obj.Memo.Text; + fx := Pos('{\fonttbl', s); + Delete(s, 1, fx + 8); + i := 1; + RepPos.Clear; + while (i < Length(s)) and (s[i] <> '}') do + begin + while (i < Length(s)) and (s[i] <> '{') and (s[i] <> '}') do + Inc(i); + j := i; + while (j < Length(s)) and (s[j] <> '}') do + Inc(j); + Inc(j); + s1 := Copy(s, i , j - i - 2); + i := j; + j := Pos(' ', s1); + s2 := Copy(s1, j + 1, Length(s1) - j + 1); + s0 := '\f' + GetRTFFontName(s2, 1); + j := Pos('\f', s1); + n := j + 1; + while (n < Length(s1)) and (s1[n] <> '\') and (s1[n] <> ' ') do + Inc(n); + s2 := Copy(s1, j, n - j); + j := Pos('}}', s); + s1 := Copy(s, j + 2, Length(s) - j - 1); + j := j + 2; + n := 1; + while n > 0 do + begin + n := Pos(s2, s1); + if n > 0 then + begin + if RepPos.IndexOf(IntToStr(n + j - 1)) = -1 then + begin + RepPos.Add(IntToStr(n + j - 1)); + Delete(s, n + j - 1, Length(s2)); + Insert(s0, s, n + j - 1); + end; + j := j + n + Length(s2) - 1; + s1 := Copy(s, j, Length(s) - j + 1); + end; + end; + end; + fx := Pos('}}', s); + if fx > 0 then + Delete(s, 1, fx + 1); + fx := Pos('{\colortbl', s); + if fx > 0 then + begin + Delete(s, 1, fx + 11); + i := 1; + n1 := 1; + RepPos.Clear; + while (i < Length(s)) and (s[i] <> '}') do + begin + while (i < Length(s)) and (s[i] <> '\') do + Inc(i); + j := i; + while (j < Length(s)) and (s[j] <> ';') do + Inc(j); + Inc(j); + s1 := Copy(s, i , j - i); + i := j; + s0 := '\cf' + GetRTFFontColor(s1); + s2 := '\cf' + IntToStr(n1); + j := Pos(';}', s); + s1 := Copy(s, j + 2, Length(s) - j - 1); + j := j + 2; + n := 1; + while n > 0 do + begin + n := Pos(s2, s1); + if n > 0 then + begin + if RepPos.IndexOf(IntToStr(n + j - 1)) = -1 then + begin + RepPos.Add(IntToStr(n + j - 1)); + Delete(s, n + j - 1, Length(s2)); + Insert(s0, s, n + j - 1); + end; + j := j + n + Length(s2) - 1; + s1 := Copy(s, j, Length(s) - j + 1); + end; + end; + Inc(n1); + end; + fx := Pos(';}', s); + if fx > 0 then + Delete(s, 1, fx + 1); + end; + fx := Pos('{\stylesheet', s); + if fx > 0 then + begin + Delete(s, 1, fx + 12); + fx := Pos('}}', s); + if fx > 0 then + Delete(s, 1, fx + 1); + end; + s := StringReplace(s, '\pard', '', [rfReplaceAll]); + Delete(s, Length(s) - 3, 3); + + fx := 1; + while fx > 0 do + begin + fx := Pos('\lang', s); + if fx > 0 then + begin + Delete(s, fx , 5); + n := PosEx('\', s, fx); + Delete(s, fx, n - fx); + end; + end; + + fx := 1; + while fx > 0 do + begin + fx := Pos('\sa', s); + if fx > 0 then + begin + Delete(s, fx , 3); + n := PosEx('\', s, fx); + Delete(s, fx, n - fx); + end; + end; + + fx := 1; + while fx > 0 do + begin + fx := Pos('\sb', s); + if fx > 0 then + begin + Delete(s, fx , 3); + n := PosEx('\', s, fx); + Delete(s, fx, n - fx); + end; + end; + + fx := 1; + while fx > 0 do + begin + fx := Pos('\cbpat', s); + if fx > 0 then + begin + Delete(s, fx , 5); + n := PosEx('\', s, fx); + Delete(s, fx, n - fx); + end; + end; + + fx := 1; + while fx > 0 do + begin + fx := Pos('\cfpat', s); + if fx > 0 then + begin + Delete(s, fx , 5); + n := PosEx('\', s, fx); + Delete(s, fx, n - fx); + end; + end; + + Obj.Memo.Text := s; + RepPos.Free; + end else if Obj.IsText then + begin + GetRTFFontColor(GetRTFColor(Obj.Style.Font.Color)); + GetRTFFontName(Obj.Style.Font.Name, Obj.Style.Charset); + end; + end; + end; + end; +end; + +procedure TfrxRTFExport.ExportPage(const Stream: TStream); +var + i, j, x, y, fx, fy, dx, dy, n, n1, pbk: Integer; + dcol, drow, xoffs: Integer; + buff, s, s0, s1, s2: String; + st, st1: WideString; + CellsLine: String; + Obj: TfrxIEMObject; + Graphic: TGraphic; + Str, CellsStream: TStream; + bArr: array[0..1023] of Byte; + FMode: Integer; // 3 - header, 2 - footer, 1 - body, 0 - stop + FHTMLTags: TfrxHTMLTagsList; + Tag: TfrxHTMLTag; + + TagFColor: TColor; + TagFStyleB, TagFStyleU, TagFStyleI: Integer; + + procedure WriteExpLn(const str: string); + begin + if Length(str) > 0 then + begin + Stream.Write(str[1], Length(str)); + Stream.Write(#13#10, 2); + end; + end; + + procedure SetPageProp(Page: Integer); + begin + WriteExpLn('\pgwsxn' + IntToStr(Round(FMatrix.GetPageWidth(Page) * PageDivider)) + + '\pghsxn' + IntToStr(Round(FMatrix.GetPageHeight(Page) * PageDivider)) + + '\marglsxn' + IntToStr(Round(FMatrix.GetPageLMargin(Page) * MargDivider)) + + '\margrsxn' + IntToStr(Round(FMatrix.GetPageRMargin(Page) * MargDivider)) + + '\margtsxn' + IntToStr(Round(FMatrix.GetPageTMargin(Page) * MargDivider)) + + '\margbsxn' + IntToStr(Round(FMatrix.GetPageBMargin(Page) * MargDivider))); + if FMatrix.GetPageOrientation(Page) = poLandscape then + WriteExpLn('\lndscpsxn'); + end; + +begin + PrepareExport; + WriteExpLn('{\rtf1\ansi'); + s := '{\fonttbl'; + for i := 0 to FFontTable.Count - 1 do + begin + s1 := '{\f' + IntToStr(i) + '\fcharset' + FCharsetTable[i] + ' ' + FFontTable[i] + '}'; + if Length(s + s1) < 255 then + s := s + s1 + else + begin + WriteExpLn(s); + s := s1; + end; + end; + s := s + '}'; + WriteExpLn(s); + s := '{\colortbl;'; + for i := 0 to FColorTable.Count - 1 do + begin + s1 := FColorTable[i]; + if Length(s + s1) < 255 then + s := s + s1 + else + begin + WriteExpLn(s); + s := s1; + end; + end; + s := s + '}'; + WriteExpLn(s); + WriteExpLn('{\info{\title ' + StrToRTFUnicodeEx(Report.ReportOptions.Name) + + '}{\author ' + StrToRTFUnicodeEx(FCreator) + + '}{\creatim\yr' + FormatDateTime('yyyy', Now) + + '\mo' + FormatDateTime('mm', Now) + '\dy' + FormatDateTime('dd', Now) + + '\hr' + FormatDateTime('hh', Now) + '\min' + FormatDateTime('nn', Now) + '}}'); + if ShowProgress then + FProgress.Execute(FMatrix.Height - 1, frxResources.Get('ProgressWait'), True, True); + pbk := 0; + SetPageProp(pbk); + + if FHeaderFooterMode = hfPrint then + FMode := 3 + else + FMode := 1; +/// + while FMode > 0 do + begin + if FMode = 3 then + WriteExpLn('{\header ') + else if FMode = 2 then + WriteExpLn('{\footer '); + + for y := 0 to FMatrix.Height - 2 do + begin + if ShowProgress then + begin + FProgress.Tick; + if FProgress.Terminated then + break; + end; + if FExportPageBreaks and (FMode = 1) then + if FMatrix.PagesCount > pbk then + if FMatrix.GetPageBreak(pbk) <= FMatrix.GetYPosById(y) then + begin + WriteExpLn('\pard\sect'); + Inc(pbk); + if pbk < FMatrix.PagesCount then + SetPageProp(pbk); + continue; + end; + drow := Round((FMatrix.GetYPosById(y + 1) - FMatrix.GetYPosById(y)) * Ydivider); + buff := '\trrh' + IntToStr(drow)+ '\trgaph15'; + CellsStream := TMemoryStream.Create; + try + xoffs := Round(FMatrix.GetXPosById(1)); + for x := 1 to FMatrix.Width - 2 do + begin + i := FMatrix.GetCell(x, y); + if (i <> -1) then + begin + Obj := FMatrix.GetObjectById(i); + + if (FMode = 3) and (not Obj.Header) then + Continue; + if (FMode = 2) and (not Obj.Footer) then + Continue; + if (FMode = 1) and (Obj.Header or Obj.Footer) and + ((FHeaderFooterMode = hfPrint) or + (FHeaderFooterMode = hfNone)) then + Continue; + + FMatrix.GetObjectPos(i, fx, fy, dx, dy); + if Obj.Counter = -1 then + begin + if dy > 1 then + buff := buff + '\clvmgf'; + if (obj.Style.Color mod 16777216) <> clWhite then + buff := buff + '\clcbpat' + GetRTFFontColor(GetRTFColor(Obj.Style.Color)); + buff := buff + GetRTFVAlignment(Obj.Style.VAlign) + GetRTFBorders(Obj.Style) + '\cltxlrtb'; + dcol := Round((Obj.Left + Obj.Width - xoffs) * Xdivider); + buff := buff + '\cellx' + IntToStr(dcol); + if Obj.IsText then + begin + s := '\f' + GetRTFFontName(Obj.Style.Font.Name, Obj.Style.Charset); + if Length(Obj.Memo.Text) > 0 then + s := s + '\fs' + IntToStr(Obj.Style.Font.Size * 2) + else + begin + j := drow div FONT_DIVIDER; + if j > 20 then j := 20; + s := s + '\fs' + IntToStr(j); + end; + s := s + GetRTFFontStyle(Obj.Style.Font.Style); + s := s + '\cf' + GetRTFFontColor(GetRTFColor(Obj.Style.Font.Color)); + if (Obj.IsRichText) then + s1 := Obj.Memo.Text + else + begin + if Obj.HTMLTags then + begin + FHTMLTags := TfrxHTMLTagsList.Create; + try + FHTMLTags.SetDefaults(Obj.Style.Font.Color, Obj.Style.Font.Size, Obj.Style.Font.Style); + FHTMLTags.AllowTags := True; + st := StrToRTFSlash(TruncReturns(Obj.Memo.Text)); + st1 := st; + s1 := ''; + + TagFColor := Obj.Style.Color; + TagFStyleB := 0; + TagFStyleU := 0; + TagFStyleI := 0; + + FHTMLTags.ExpandHTMLTags(st); + for i := 0 to FHTMLTags.Count - 1 do + for j := 0 to FHTMLTags[i].Count - 1 do + begin + Tag := FHTMLTags[i].Items[j]; + + // bold tags + if (fsBold in Tag.Style) and (TagFStyleB = 0) then + begin + Inc(TagFStyleB); + s1 := s1 + '\b '; + end; + if (TagFStyleB > 0) and (not (fsBold in Tag.Style)) then + begin + Dec(TagFStyleB); + s1 := s1 + '\b0 '; + end; + + // italic tags + if (fsItalic in Tag.Style) and (TagFStyleI = 0) then + begin + Inc(TagFStyleI); + s1 := s1 + '\i '; + end; + if (TagFStyleI > 0) and (not (fsItalic in Tag.Style)) then + begin + Dec(TagFStyleI); + s1 := s1 + '\i0 '; + end; + + // underline tags + if (fsUnderline in Tag.Style) and (TagFStyleU = 0) then + begin + Inc(TagFStyleU); + s1 := s1 + '\ul '; + end; + if (TagFStyleU > 0) and (not (fsUnderline in Tag.Style)) then + begin + Dec(TagFStyleU); + s1 := s1 + '\ul0 '; + end; + + // color tags + if (Tag.Color <> Obj.Style.Font.Color) and (Tag.Color <> TagFColor) then + begin + TagFColor := Tag.Color; + s1 := s1 + '\cf' + GetRTFFontColor(GetRTFColor(TagFColor)) + ' '; + end; + if (Tag.Color <> TagFColor) then + begin + TagFColor := Tag.Color; + s1 := s1 + '\cf' + GetRTFFontColor(GetRTFColor(TagFColor)) + ' '; + end; + + s1 := s1 + StrToRTFUnicode(st1[Tag.Position]); + + end; + s1 := s1 + '\plain'; + finally + FHTMLTags.Free; + end; + end + else + s1 := StrToRTFUnicodeEx(TruncReturns(Obj.Memo.Text)); + end; + if Trim(s1) <> '' then + begin + j := Round(Obj.Style.CharSpacing * FONT_DIVIDER); + s2 := '\sb' + IntToStr(Round(Obj.Style.GapY * Ydivider)) + + '\li' + IntToStr(Round((Obj.Style.GapX / 2) * Xdivider)) + + '\fi' + IntToStr(Round((Obj.Style.ParagraphGap) * Xdivider)) + + '\expnd' + IntToStr(j div 5) + '\expndtw' + IntToStr(j) + + '\sl' + IntToStr(Round((Obj.Style.Font.Size + Obj.Style.LineSpacing - 2) * Ydivider)) + + '\slmult0'; + if Obj.Style.WordBreak then + s2 := s2 + '\hyphauto1\hyphcaps1'; + end else + s2 := ''; + CellsLine := GetRTFHAlignment(Obj.Style.HAlign) + + '{' + s + s2 + ' ' + s1 + '\cell}'; + s := '\par'#13#10'\cell'; + while Pos(s, CellsLine) > 0 do + CellsLine := StringReplace(CellsLine, s, '\cell', []); + CellsStream.Write(CellsLine[1], Length(CellsLine)); + end + else if FExportPictures then + begin + Graphic := Obj.Image; + if not ((Graphic = nil) or Graphic.Empty) then + begin + Str := TMemoryStream.Create; + try + dx := Round(Obj.Width); + dy := Round(Obj.Height); + fx := Graphic.Width; + fy := Graphic.Height; + Graphic.SaveToStream(Str); + Str.Position := 0; + CellsLine := '{\sb0\li0\sl0\slmult0 {\pict\wmetafile8\picw' + FloatToStr(Round(dx * IMAGE_DIVIDER)) + + '\pich' + FloatToStr(Round(dy * IMAGE_DIVIDER)) + '\picbmp\picbpp4' + #13#10; + CellsStream.Write(CellsLine[1], Length(CellsLine)); + Str.Read(n, 2); + Str.Read(n, 4); + n := n div 2 + 7; + s0 := IntToHex(n + $24, 8); + s := '010009000003' + Copy(s0, 7, 2) + Copy(s0, 5, 2) + + Copy(s0, 3, 2) + Copy(s0, 1, 2) + '0000'; + s0 := IntToHex(n, 8); + s1 := Copy(s0, 7, 2) + Copy(s0, 5, 2) + Copy(s0, 3, 2) + Copy(s0, 1, 2); + s := s + s1 + '0000050000000b0200000000050000000c02'; + s0 := IntToHex(fy, 4); + s := s + Copy(s0, 3, 2) + Copy(s0, 1, 2); + s0 := IntToHex(fx, 4); + s := s + Copy(s0, 3, 2) + Copy(s0, 1, 2) + + '05000000090200000000050000000102ffffff000400000007010300' + s1 + + '430f2000cc000000'; + s0 := IntToHex(fy, 4); + s := s + Copy(s0, 3, 2) + Copy(s0, 1, 2); + s0 := IntToHex(fx, 4); + s := s + Copy(s0, 3, 2) + Copy(s0, 1, 2) + '00000000'; + s0 := IntToHex(fy, 4); + s := s + Copy(s0, 3, 2) + Copy(s0, 1, 2); + s0 := IntToHex(fx, 4); + s := s + Copy(s0, 3, 2) + Copy(s0, 1, 2) + '00000000'; + CellsLine := s + #13#10; + CellsStream.Write(CellsLine[1], Length(CellsLine)); + Str.Read(bArr[0], 8); + n1 := 0; s := ''; + repeat + n := Str.Read(bArr[0], 1024); + for j := 0 to n - 1 do + begin + s := s + IntToHex(bArr[j], 2); + Inc(n1); + if n1 > 63 then + begin + n1 := 0; + CellsLine := s + #13#10; + CellsStream.Write(CellsLine[1], Length(CellsLine)); + s := ''; + end; + end; + until n < 1024; + finally + Str.Free; + end; + if n1 <> 0 then + begin + CellsLine := s + #13#10; + CellsStream.Write(CellsLine[1], Length(CellsLine)); + end; + s := '030000000000}'; + CellsLine := s + '\cell}' + #13#10; + CellsStream.Write(CellsLine[1], Length(CellsLine)); + end; + end; + Obj.Counter := y + 1; + end + else + begin + if (dy > 1) and (Obj.Counter <> (y + 1))then + begin + buff := buff + '\clvmrg'; + buff := buff + GetRTFBorders(Obj.Style) + '\cltxlrtb'; + dcol := Round((Obj.Left + Obj.Width - xoffs) * Xdivider); + buff := buff + '\cellx' + IntToStr(dcol); + j := drow div FONT_DIVIDER; + if j > 20 then + j := 20; + CellsLine := '{\fs' + IntToStr(j) + '\cell}'; + CellsStream.Write(CellsLine[1], Length(CellsLine)); + Obj.Counter := y + 1; + end; + end + end + end; + if CellsStream.Size > 0 then + begin + s := '\trowd' + buff + '\pard\intbl'; + WriteExpLn(s); + Stream.CopyFrom(CellsStream, 0); + WriteExpLn('\pard\intbl{\trowd' + buff + '\row}'); + end; + finally + CellsStream.Free; + end; + end; + if FMode in [2, 3] then + WriteExpLn('}'); + Dec(FMode); + end; + WriteExpLn('}'); +end; + +function TfrxRTFExport.ShowModal: TModalResult; +begin + if not Assigned(Stream) then + begin + with TfrxRTFExportDialog.Create(nil) do + begin + SendMessage(GetWindow(PColontitulCB.Handle,GW_CHILD), EM_SETREADONLY, 1, 0); + OpenCB.Visible := not SlaveExport; + if SlaveExport then + FOpenAfterExport := False; + + if (FileName = '') and (not SlaveExport) then + SaveDialog1.FileName := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), SaveDialog1.DefaultExt) + else + SaveDialog1.FileName := FileName; + + ContinuousCB.Checked := SuppressPageHeadersFooters; + PicturesCB.Checked := FExportPictures; + PageBreaksCB.Checked := FExportPageBreaks; + WCB.Checked := FWysiwyg; + OpenCB.Checked := FOpenAfterExport; + + if PageNumbers <> '' then + begin + PageNumbersE.Text := PageNumbers; + PageNumbersRB.Checked := True; + end; + + if FHeaderFooterMode = hfText then + PColontitulCB.ItemIndex := 0 + else if FHeaderFooterMode = hfPrint then + PColontitulCB.ItemIndex := 1 + else + PColontitulCB.ItemIndex := 2; + + Result := ShowModal; + + if Result = mrOk then + begin + if PColontitulCB.ItemIndex = 0 then + FHeaderFooterMode := hfText + else if PColontitulCB.ItemIndex = 1 then + FHeaderFooterMode := hfPrint + else + FHeaderFooterMode := hfNone; + + PageNumbers := ''; + CurPage := False; + if CurPageRB.Checked then + CurPage := True + else if PageNumbersRB.Checked then + PageNumbers := PageNumbersE.Text; + + SuppressPageHeadersFooters := ContinuousCB.Checked; + + if FHeaderFooterMode = hfPrint then + SuppressPageHeadersFooters := True; + + FExportPictures := PicturesCB.Checked; + FExportPageBreaks := PageBreaksCB.Checked; + FWysiwyg := WCB.Checked; + FOpenAfterExport := OpenCB.Checked; + + if not SlaveExport then + begin + if DefaultPath <> '' then + SaveDialog1.InitialDir := DefaultPath; + if SaveDialog1.Execute then + FileName := SaveDialog1.FileName + else + Result := mrCancel; + end + else + FileName := ChangeFileExt(GetTempFile, SaveDialog1.DefaultExt); + end; + Free; + end; + end else + Result := mrOk; +end; + +function TfrxRTFExport.Start: Boolean; +begin + if (FileName <> '') or Assigned(Stream) then + begin + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + FileName := DefaultPath + '\' + FileName; + FFirstPage := True; + FCurrentPage := 0; + FMatrix := TfrxIEMatrix.Create(UseFileCache, Report.EngineOptions.TempDir); + FMatrix.ShowProgress := ShowProgress; + if FWysiwyg then + FMatrix.Inaccuracy := 0.5 + else + FMatrix.Inaccuracy := 10; + FMatrix.RotatedAsImage := True; + FMatrix.RichText := True; + FMatrix.PlainRich := False; + FMatrix.AreaFill := True; + FMatrix.CropAreaFill := True; +// FMatrix.DeleteHTMLTags := True; + FMatrix.DeleteHTMLTags := False; + FMatrix.BackgroundImage := False; + FMatrix.Background := False; + FMatrix.Printable := ExportNotPrintable; + FFontTable := TStringList.Create; + FCharsetTable := TStringList.Create; + FColorTable := TStringList.Create; + FDataList := TList.Create; + Result := True + end + else + Result := False; +end; + +procedure TfrxRTFExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + Inc(FCurrentPage); + if FFirstPage then + FFirstPage := False; +end; + +procedure TfrxRTFExport.ExportObject(Obj: TfrxComponent); +begin + if (Obj is TfrxPageHeader) and (ExportNotPrintable or TfrxView(Obj).Printable) then + FMatrix.SetPageHeader(TfrxBand(Obj)) + else if (Obj is TfrxPageFooter) and (ExportNotPrintable or TfrxView(Obj).Printable) then + FMatrix.SetPageFooter(TfrxBand(Obj)) + else if (Obj is TfrxView) and (ExportNotPrintable or TfrxView(Obj).Printable) then + begin + if (Obj is TfrxCustomMemoView) or + (FExportPictures and (not (Obj is TfrxCustomMemoView))) then + FMatrix.AddObject(TfrxView(Obj)) + end; +end; + +procedure TfrxRTFExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + FMatrix.AddPage(Page.Orientation, Page.Width, Page.Height, Page.LeftMargin, + Page.TopMargin, Page.RightMargin, Page.BottomMargin); +end; + +procedure TfrxRTFExport.Finish; +var + Exp: TStream; + +begin + FMatrix.Prepare; + if ShowProgress then + FProgress := TfrxProgress.Create(nil); + try + if Assigned(Stream) then + Exp := Stream + else + Exp := TFileStream.Create(FileName, fmCreate); + try + ExportPage(Exp); + finally + if not Assigned(Stream) then + Exp.Free; + end; + + if FOpenAfterExport and (not Assigned(Stream)) then + ShellExecute(GetDesktopWindow, 'open', PChar(FileName), nil, nil, SW_SHOW); + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; + FMatrix.Clear; + FMatrix.Free; + FFontTable.Free; + FCharsetTable.Free; + FColorTable.Free; + FDataList.Free; + if ShowProgress then + FProgress.Free; +end; + +{ TfrxRTFExportDialog } + +procedure TfrxRTFExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8500); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + GroupPageRange.Caption := frxGet(7); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + DescrL.Caption := frxGet(9); + GroupQuality.Caption := frxGet(8); + ContinuousCB.Caption := frxGet(8950); + PicturesCB.Caption := frxGet(8501); + PageBreaksCB.Caption := frxGet(6); + WCB.Caption := frxGet(8502); + OpenCB.Caption := frxGet(8503); + SaveDialog1.Filter := frxGet(8504); + SaveDialog1.DefaultExt := frxGet(8505); + HeadFootL.Caption := frxGet(8951); + PColontitulCB.Items[0] := frxGet(8952); + PColontitulCB.Items[1] := frxGet(8953); + PColontitulCB.Items[2] := frxGet(8954); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxRTFExportDialog.PageNumbersEChange(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxRTFExportDialog.PageNumbersEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8, '-', ',':; + else + key := #0; + end; +end; + +procedure TfrxRTFExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxExportTXT.dfm b/official/4.2/LibD11/frxExportTXT.dfm new file mode 100644 index 0000000..b0917dc Binary files /dev/null and b/official/4.2/LibD11/frxExportTXT.dfm differ diff --git a/official/4.2/LibD11/frxExportTXT.pas b/official/4.2/LibD11/frxExportTXT.pas new file mode 100644 index 0000000..c24789e --- /dev/null +++ b/official/4.2/LibD11/frxExportTXT.pas @@ -0,0 +1,1514 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Text advanced export filter } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportTXT; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls, frxClass, frxProgress, Buttons, ComCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxTXTExport = class; + + TfrxTXTExportDialog = class(TForm) + OK: TButton; + Cancel: TButton; + Panel1: TPanel; + GroupCellProp: TGroupBox; + GroupPageRange: TGroupBox; + Pages: TLabel; + Descr: TLabel; + E_Range: TEdit; + GroupScaleSettings: TGroupBox; + ScX: TLabel; + Label2: TLabel; + ScY: TLabel; + Label9: TLabel; + E_ScaleX: TEdit; + CB_PageBreaks: TCheckBox; + GroupFramesSettings: TGroupBox; + RB_NoneFrames: TRadioButton; + RB_Simple: TRadioButton; + RB_Graph: TRadioButton; + CB_OEM: TCheckBox; + CB_EmptyLines: TCheckBox; + CB_LeadSpaces: TCheckBox; + CB_PrintAfter: TCheckBox; + Panel2: TPanel; + GroupBox1: TGroupBox; + Label1: TLabel; + Label3: TLabel; + PgHeight: TLabel; + PgWidth: TLabel; + Preview: TMemo; + EPage: TEdit; + PageUpDown: TUpDown; + LBPage: TLabel; + ToolButton1: TSpeedButton; + ToolButton2: TSpeedButton; + BtnPreview: TSpeedButton; + SaveDialog1: TSaveDialog; + UpDown1: TUpDown; + UpDown2: TUpDown; + E_ScaleY: TEdit; + procedure FormCreate(Sender: TObject); + procedure CB_OEMClick(Sender: TObject); + procedure RefreshClick(Sender: TObject); + procedure FormClose(Sender: TObject; var Action: TCloseAction); + procedure FormActivate(Sender: TObject); + procedure E_ScaleXChange(Sender: TObject); + procedure BtnPreviewClick(Sender: TObject); + procedure ToolButton1Click(Sender: TObject); + procedure ToolButton2Click(Sender: TObject); + procedure UpDown1Changing(Sender: TObject; var AllowChange: Boolean); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + TxtExp: TfrxTXTExport; + Flag, created, MakeInit, running: Boolean; + printer: Integer; + public + PagesCount: Integer; + Exporter: TfrxTXTExport; + PreviewActive: Boolean; + end; + + PfrxTXTStyle = ^TfrxTXTStyle; + TfrxTXTStyle = packed record + Font: TFont; + VAlignment: TfrxVAlign; + HAlignment: TfrxHAlign; + FrameTyp: TfrxFrameTypes; + FrameWidth: Single; + FrameColor: TColor; + FrameStyle: TfrxFrameStyle; + FillColor: TColor; + IsText: Boolean; + end; + + TfrxTXTPrinterCommand = packed record + Name: String; + SwitchOn: String; + SwitchOff: String; + Trigger: Boolean; + end; + + TfrxTXTPrinterType = packed record + name: String; + CommCount: Integer; + Commands: array[0..31] of TfrxTXTPrinterCommand; + end; + + TfrxTXTExport = class(TfrxCustomExportFilter) + private + CurrentPage: Integer; + FirstPage: Boolean; + CurY: Integer; + RX: TList; // TObjCell + RY: TList; // TObjCell + ObjectPos: TList; // TObjPos + PageObj: TList; // TfrxView + StyleList: TList; + CY, LastY: Extended; + frExportSet: TfrxTXTExportDialog; + pgBreakList: TStringList; + expBorders, expBordersGraph, expPrintAfter, expUseSavedProps, + expPrinterDialog, expPageBreaks, expOEM, expEmptyLines, + expLeadSpaces: Boolean; + expCustomFrameSet: String; + expScaleX, expScaleY: Extended; + MaxWidth: Extended; + Scr: array of Char; + ScrWidth: Integer; + ScrHeight: Integer; + PrinterInitString: String; + Stream: TFileStream; + procedure WriteExpLn(const str: String); + procedure WriteExp(const str: String); + procedure ObjCellAdd(Vector: TList; Value: Extended); + procedure ObjPosAdd(Vector: TList; x, y, dx, dy, obj: Integer); + function CompareStyles(Style1, Style2: PfrxTXTStyle): Boolean; + function FindStyle(Style: PfrxTXTStyle): Integer; + procedure MakeStyleList; + procedure ClearLastPage; + procedure OrderObjectByCells; + procedure ExportPage; + function ChangeReturns(const Str: String): String; + function TruncReturns(const Str: String): String; + procedure AfterExport(const FileName: String); + procedure PrepareExportPage; + procedure DrawMemo(x, y: Integer; dx, dy: Integer; text: String; st: Integer); + procedure FlushScr; + procedure CreateScr(dx, dy: Integer); + procedure FreeScr; + procedure ScrType(x, y: Integer; c: Char); + function ScrGet(x, y: Integer): Char; + procedure ScrString(x, y: Integer; const s: String); + procedure FormFeed; + function MakeInitString: String; + public + PrintersCount: Integer; + PrinterTypes: array [0..15] of TfrxTXTPrinterType; + SelectedPrinterType: Integer; + PageWidth, PageHeight: Integer; + IsPreview: Boolean; + Copys: Integer; + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + procedure ExportObject(Obj: TfrxComponent); override; + class function GetDescription: String; override; + function RegisterPrinterType(const Name: String):Integer; + procedure RegisterPrinterCommand(PrinterIndex: Integer; + const Name, switch_on, switch_off: String); + procedure LoadPrinterInit(const FName: String); + procedure SavePrinterInit(const FName: String); + procedure SpoolFile(const FileName: String); + published + property ScaleWidth: Extended read expScaleX write expScaleX; + property ScaleHeight: Extended read expScaleY write expScaleY; + property Borders: Boolean read expBorders write expBorders; + property Pseudogrpahic: Boolean read expBordersGraph write expBordersGraph; + property PageBreaks: Boolean read expPageBreaks write expPageBreaks; + property OEMCodepage: Boolean read expOEM write expOEM; + property EmptyLines: Boolean read expEmptyLines write expEmptyLines; + property LeadSpaces: Boolean read expLeadSpaces write expLeadSpaces; + property PrintAfter: Boolean read expPrintAfter write expPrintAfter; + property PrinterDialog: Boolean read expPrinterDialog write expPrinterDialog; + property UseSavedProps: Boolean read expUseSavedProps write expUseSavedProps; + property InitString: String read PrinterInitString write PrinterInitString; + property CustomFrameSet: String read expCustomFrameSet write expCustomFrameSet; + end; + +implementation + +uses frxUtils, frxprinter, Printers, Winspool, frxExportTxtPrn, + frxFileUtils, frxres, frxrcExports; + +{$R *.dfm} + +type + PObjCell = ^TObjCell; + TObjCell = packed record + Value: Extended; + Count: Integer; + end; + + PObjPos = ^TObjPos; + TObjPos = packed record + obj: Integer; + x,y: Integer; + dx, dy: Integer; + style: Integer; + end; + +const + Xdivider = 7; + Ydivider = 8; + FrameSet: array [1..2] of String = ( +// frameset: vertical, horizontal, up-left corner, up-right corner +// down-left corner, down-right corner, down tap, left tap, +// up tap, right tap, cross + '|-+++++++++', + #179#196#218#191#192#217#193#195#194#180#197 ); + EpsonCommCnt = 12; + Epson: array [0..EpsonCommCnt - 1, 0..2] of String = ( + ('Reset', #27#64, ''), + ('Normal', #27#120#00, ''), + ('Pica', #27#120#01#27#107#00, ''), + ('Elite', #27#120#01#27#107#01, ''), + ('Condensed', #15, #18), + ('Bold', #27#71, #27#72), + ('Italic', #27#52, #27#53), + ('Wide', #27#87#01, #27#87#00), + ('12cpi', #27#77, #27#80), + ('Linefeed 1/8"', #27#48, ''), + ('Linefeed 7/72"', #27#49, ''), + ('Linefeed 1/6"', #27#50, '')); + HPCommCnt = 6; + HPComm: array [0..HPCommCnt - 1, 0..2] of String = ( + ('Reset', #27#69, ''), + ('Landscape orientation', #27#38#108#49#79, #27#38#108#48#79), + ('Italic', #27#40#115#49#83, #27#40#115#48#83), + ('Bold', #27#40#115#51#66, #27#40#115#48#66), + ('Draft EconoMode', #27#40#115#49#81, #27#40#115#50#81), + ('Condenced', #27#40#115#49#50#72#27#38#108#56#68, #27#40#115#49#48#72)); + IBMCommCnt = 8; + IBMComm: array [0..IBMCommCnt - 1, 0..2] of String = ( + ('Reset', #27#64, ''), + ('Normal', #27#120#00, ''), + ('Pica', #27#48#73, ''), + ('Elite', #27#56#73, ''), + ('Condensed', #15, #18), + ('Bold', #27#71, #27#72), + ('Italic', #27#52, #27#53), + ('12cpi', #27#77, #27#80)); + +function ComparePoints(Item1, Item2: Pointer): Integer; +begin + if PObjCell(Item1).Value > PObjCell(Item2).Value then + Result := 1 + else if PObjCell(Item1).Value < PObjCell(Item2).Value then + Result := -1 + else + Result := 0; +end; + +function CompareObjects(Item1, Item2: Pointer): Integer; +var + m1, m2: TfrxView; + Res: Extended; +begin + m1 := TfrxView(Item1); + m2 := TfrxView(Item2); + Res := m1.Top - m2.Top; + if Res = 0 then + Res := m1.Left - m2.Left; + if Res = 0 then + if (m1 is TfrxCustomMemoView) and (m2 is TfrxCustomMemoView) then + Res := Length(TfrxMemoView(m1).Memo.Text) - Length(TfrxMemoView(m2).Memo.Text); + if Res > 0 then + Result := 1 + else if Res < 0 then + Result := -1 + else + Result := 0; +end; + +class function TfrxTXTExport.GetDescription: String; +begin + Result := frxResources.Get('TextExport'); +end; + +constructor TfrxTXTExport.Create(AOwner: TComponent); +var + i: Integer; +begin + inherited Create(AOwner); + RX := TList.Create; + RY := TList.Create; + PageObj := TList.Create; + ObjectPos := TList.Create; + StyleList := TList.Create; + pgBreakList := TStringList.Create; + ShowDialog := True; + expBorders := False; + expPageBreaks := True; + expScaleX := 1.0; + expScaleY := 1.0; + expBordersGraph := False; + expOEM := False; + expEmptyLines := False; + expLeadSpaces := False; + PrinterInitString := ''; + PageWidth := 0; + PageHeight := 0; + IsPreview := False; + expPrintAfter := False; + expUseSavedProps := True; + expPrinterDialog := True; + PrintersCount := 0; + SelectedPrinterType := 0; + expCustomFrameSet := ''; + Copys := 1; + /// printer registration + RegisterPrinterType('NONE'); + RegisterPrinterType('EPSON ESC/P2 Matrix/Stylus)'); + for i := 0 to EpsonCommCnt - 1 do + RegisterPrinterCommand(1, Epson[i, 0], Epson[i, 1], Epson[i, 2]); + RegisterPrinterType('HP PCL (LaserJet/DeskJet)'); + for i := 0 to HPCommCnt - 1 do + RegisterPrinterCommand(2, HPComm[i, 0], HPComm[i, 1], HPComm[i, 2]); + RegisterPrinterType('CANON/IBM (Matrix)'); + for i := 0 to IBMCommCnt - 1 do + RegisterPrinterCommand(3, IBMComm[i, 0], IBMComm[i, 1], IBMComm[i, 2]); +end; + +destructor TfrxTXTExport.Destroy; +begin + ClearLastPage; + RX.Free; + RY.Free; + PageObj.Free; + ObjectPos.Free; + StyleList.Free; + pgBreakList.Free; + inherited; +end; + +function TfrxTXTExport.TruncReturns(const Str: String): String; +begin + Result := StringReplace(Str, #1, '', [rfReplaceAll]); + if Copy(Result, Length(Result) - 1, 2) = #13#10 then + Delete(Result, Length(Result) - 1, 2); +end; + +function TfrxTXTExport.ChangeReturns(const Str: String): String; +begin + Result := StringReplace(Str, #1, '', [rfReplaceAll]); +end; + +procedure TfrxTXTExport.ClearLastPage; +var + i: Integer; +begin + PageObj.Clear; + for i := 0 to StyleList.Count - 1 do + begin + PfrxTXTStyle(StyleList[i]).Font.Free; + FreeMemory(PfrxTXTStyle(StyleList[i])); + end; + StyleList.Clear; + for i := 0 to RX.Count - 1 do FreeMem(PObjCell(RX[i])); + RX.Clear; + for i := 0 to RY.Count - 1 do FreeMem(PObjCell(RY[i])); + RY.Clear; + for i := 0 to ObjectPos.Count - 1 do FreeMem(PObjPos(ObjectPos[i])); + ObjectPos.Clear; +end; + +procedure TfrxTXTExport.ObjCellAdd(Vector: TList; Value: Extended); +var + ObjCell: PObjCell; + i, cnt: Integer; + exist: Boolean; +begin + exist := False; + if Vector.Count > 0 then + begin + if Vector.Count > 100 then + cnt := Vector.Count - 100 else + cnt := 0; + for i := Vector.Count - 1 downto cnt do + if Round(PObjCell(Vector[i]).Value) = Round(Value) then + begin + exist := True; + break; + end; + end; + if not exist then + begin + GetMem(ObjCell, SizeOf(TObjCell)); + ObjCell.Value := Value; + ObjCell.Count := 0; + Vector.Add(ObjCell); + end; +end; + +procedure TfrxTXTExport.ObjPosAdd(Vector: TList; x, y, dx, dy, obj: Integer); +var + ObjPos: PObjPos; +begin + GetMem(ObjPos, SizeOf(TObjPos)); + ObjPos.x := x; + ObjPos.y := y; + ObjPos.dx := dx; + ObjPos.dy := dy; + ObjPos.obj := Obj; + Vector.Add(ObjPos); +end; + +procedure TfrxTXTExport.OrderObjectByCells; +var + obj, c, fx, fy, dx, dy, mi: integer; + m, curx, cury: Extended; +begin + for obj := 0 to PageObj.Count - 1 do + begin + fx := 0; fy := 0; + dx := 1; dy := 1; + for c := 0 to RX.Count - 1 do + if Round(PObjCell(RX[c]).Value) = Round(TfrxView(PageObj[obj]).Left) then + begin + fx := c; + m := TfrxView(PageObj[obj]).Left; + mi := c + 1; + curx := TfrxView(PageObj[obj]).Left + TfrxView(PageObj[obj]).Width; + while Round(m) < Round(curx) do + begin + m := m + PObjCell(RX[mi]).Value - PObjCell(RX[mi - 1]).Value; + inc(mi); + end; + dx := mi - c - 1; + break; + end; + for c := 0 to RY.Count - 1 do + if Round(PObjCell(RY[c]).Value) = Round(TfrxView(PageObj[obj]).Top) then + begin + fy := c; + m := TfrxView(PageObj[obj]).Top; + mi := c + 1; + cury := TfrxView(PageObj[obj]).Top + TfrxView(PageObj[obj]).Height; + while Round(m) < Round(cury) do + begin + m := m + PObjCell(RY[mi]).Value - PObjCell(RY[mi - 1]).Value; + inc(mi); + end; + dy := mi - c - 1; + break; + end; + ObjPosAdd(ObjectPos, fx, fy, dx, dy, obj); + end; +end; + +function TfrxTXTExport.CompareStyles(Style1, Style2: PfrxTXTStyle): Boolean; +begin + if Style1.IsText and Style2.IsText then + begin + Result := (Style1.Font.Color = Style2.Font.Color) and + (Style1.Font.Name = Style2.Font.Name) and + (Style1.Font.Size = Style2.Font.Size) and + (Style1.Font.Style = Style2.Font.Style) and + (Style1.Font.Charset = Style2.Font.Charset) and + (Style1.VAlignment = Style2.VAlignment) and + (Style1.HAlignment = Style2.HAlignment) and + (Style1.FrameTyp = Style2.FrameTyp) and + (Style1.FrameWidth = Style2.FrameWidth) and + (Style1.FrameColor = Style2.FrameColor) and + (Style1.FrameStyle = Style2.FrameStyle) and + (Style1.FillColor = Style2.FillColor); + end + else if (not Style1.IsText) and (not Style2.IsText) then + begin + Result := (Style1.VAlignment = Style2.VAlignment) and + (Style1.HAlignment = Style2.HAlignment) and + (Style1.FrameTyp = Style2.FrameTyp) and + (Style1.FrameWidth = Style2.FrameWidth) and + (Style1.FrameColor = Style2.FrameColor) and + (Style1.FrameStyle = Style2.FrameStyle) and + (Style1.FillColor = Style2.FillColor); + end + else + Result := False; +end; + +function TfrxTXTExport.FindStyle(Style: PfrxTXTStyle): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to StyleList.Count - 1 do + if CompareStyles(Style, PfrxTXTStyle(StyleList[i])) then + Result := i; +end; + +procedure TfrxTXTExport.MakeStyleList; +var + i, j, k: Integer; + obj: TfrxView; + style: PfrxTXTStyle; +begin + j := 0; + for i := 0 to ObjectPos.Count - 1 do + begin + obj := PageObj[PObjPos(ObjectPos[i]).obj]; + style := AllocMem(SizeOf(TfrxTXTStyle)); + if obj is TfrxCustomMemoView then + begin + style.Font := TFont.Create; + style.Font.Assign(TfrxMemoView(obj).Font); + style.VAlignment := TfrxMemoView(obj).VAlign; + style.HAlignment := TfrxMemoView(obj).HAlign; + style.IsText := True; + end + else + begin + style.Font := nil; + style.IsText := False; + end; + style.FrameTyp := obj.Frame.Typ; + style.FrameWidth := obj.Frame.Width; + style.FrameColor := obj.Frame.Color; + style.FrameStyle := obj.Frame.Style; + style.FillColor := obj.Color; + k := FindStyle(Style); + if k = -1 then + begin + StyleList.Add(style); + PObjPos(ObjectPos[i]).style := j; + j := j + 1; + end + else + begin + PObjPos(ObjectPos[i]).style := k; + Style.Font.Free; + FreeMemory(Style); + end; + end; +end; + +function StrToOem(const AnsiStr: String): String; +begin + SetLength(Result, Length(AnsiStr)); + if Length(Result) > 0 then + CharToOemBuff(PChar(AnsiStr), PChar(Result), Length(Result)); +end; + +function MakeStr(C: Char; N: Integer): String; +begin + if N < 1 then + Result := '' + else + begin + SetLength(Result, N); + FillChar(Result[1], Length(Result), C); + end; +end; + +function AddChar(C: Char; const S: String; N: Integer): String; +begin + if Length(S) < N then + Result := MakeStr(C, N - Length(S)) + S else + Result := S; +end; + +function AddCharR(C: Char; const S: String; N: Integer): String; +begin + if Length(S) < N then + Result := S + MakeStr(C, N - Length(S)) else + Result := S; +end; + +function LeftStr(const S: String; N: Integer): String; +begin + Result := AddCharR(' ', S, N); +end; + +function RightStr(const S: String; N: Integer): String; +begin + Result := AddChar(' ', S, N); +end; + +function CenterStr(const S: String; Len: Integer): String; +begin + if Length(S) < Len then + begin + Result := MakeStr(' ', (Len div 2) - (Length(S) div 2)) + S; + Result := Result + MakeStr(' ', Len - Length(Result)); + end + else + Result := S; +end; + +const + Delims = [' ', #9, '-']; + +function WrapTxt(s: String; dx, dy: Integer): String; +var + i, j, k: Integer; + buf1, buf2: String; +begin + i := 0; + buf2 := s; + Result := ''; + while (i < dy) and (Length(Buf2) > 0) do + begin + if Length(buf2) > dx then + begin + if buf2[dx + 1] = #10 then + buf1 := copy(buf2, 1, dx + 1) + else if buf2[dx + 1] = #13 then + buf1 := copy(buf2, 1, dx + 2) + else + buf1 := copy(buf2, 1, dx) + end + else + begin + Result := Result + buf2; + break; + end; + k := Pos(#13#10, buf1); + if k > 0 then + j := k + 1 + else if Length(Buf1) < dx then + begin + j := Length(Buf1); + k := 1; + end + else + j := dx; + if (not (buf2[dx + 1] in Delims)) or (k > 0) then + begin + if k = 0 then + while (j > 0) and (not (buf1[j] in Delims)) do + Dec(j); + if j > 0 then + begin + buf1 := copy(buf1, 1, j); + buf2 := copy(buf2, j + 1, Length(buf2) - j) + end + else + buf2 := copy(buf2, dx + 1, Length(buf2) - dx); + end + else + buf2 := copy(buf2, dx + 2, Length(buf2) - dx - 1); + i := i + 1; + Result := Result + buf1; + if k = 0 then + Result := Result + #13#10; + end; +end; + +procedure TfrxTXTExport.WriteExpLn(const str: String); +var + ln: String; +begin + if Length(str) > 0 then + begin + if Length(str) > PageWidth then + PageWidth := Length(str); + Inc(PageHeight); + Stream.Write(str[1], Length(str)); + ln := #13#10; + Stream.Write(ln[1], Length(ln)); + end + else if expEmptyLines then + begin + ln := #13#10; + Inc(PageHeight); + Stream.Write(ln[1], Length(ln)); + end; +end; + +procedure TfrxTXTExport.WriteExp(const str: String); +begin + if Length(str) > 0 then + Stream.Write(str[1], Length(str)) +end; + +procedure TfrxTXTExport.CreateScr(dx, dy: Integer); +var + i, j: Integer; +begin + ScrWidth := dx; + ScrHeight := dy; + Initialize(Scr); + SetLength(Scr, ScrWidth * ScrHeight); + for i := 0 to ScrHeight - 1 do + for j := 0 to ScrWidth - 1 do + Scr[i * ScrWidth + j] := ' '; +end; + +procedure TfrxTXTExport.ScrString(x, y: Integer; const s: String); +var + i: Integer; +begin + for i := 0 to Length(s) - 1 do + ScrType(x + i, y, s[i + 1]); +end; + +function TfrxTXTExport.ScrGet(x, y: Integer): Char; +begin + if (x < ScrWidth) and (y < ScrHeight) and + (x >= 0) and (y >= 0) then + Result := Scr[ScrWidth * y + x] else + Result := ' '; +end; + +procedure TfrxTXTExport.DrawMemo(x, y, dx, dy: Integer; text: String; + st: Integer); +var + i, sx, sy, lines: Integer; + buf: String; + style: PfrxTXTStyle; + f: String; + + function AlignBuf: String; + begin + if (style.HAlignment = haLeft) then + buf := LeftStr(buf, dx - 1) + else if (style.HAlignment = haRight) then + buf := RightStr(buf, dx - 1) + else if (style.HAlignment = haCenter) then + buf := CenterStr(buf, dx - 1) + else + buf := LeftStr(buf, dx - 1); + if expOEM then + buf := StrToOem(buf); + Result := buf; + end; + +begin + style := PfrxTXTStyle(StyleList[st]); + if (Style.FrameTyp <> []) and expBorders then + begin + if Length(expCustomFrameSet) > 0 then + f := CustomFrameSet + else if expBordersGraph then + f := FrameSet[2] + else + f := FrameSet[1]; + if (ScrGet(x + 1, y) in [f[1], f[3], f[4]]) then + begin + Inc(x); + Dec(dx); + end + else if (ScrGet(x - 1, y) in [f[1], f[3], f[4]]) then + begin + Dec(x); + Inc(dx); + end; + if (ftLeft in Style.FrameTyp) then + for i := 0 to dy do + if i = 0 then + ScrType(x, y + i, f[3]) + else if i = dy then + ScrType(x, y + i, f[5]) + else + ScrType(x, y + i, f[1]); + if (ftRight in Style.FrameTyp) then + for i := 0 to dy do + if i = 0 then + ScrType(x + dx, y + i, f[4]) + else if i = dy then + ScrType(x + dx, y + i, f[6]) + else + ScrType(x + dx, y + i, f[1]); + if (ftTop in Style.FrameTyp) then + for i := 0 to dx do + if i = 0 then + ScrType(x + i, y, f[3]) + else if i = dx then + ScrType(x + i, y, f[4]) + else + ScrType(x + i, y, f[2]); + if (ftBottom in Style.FrameTyp) then + for i := 0 to dx do + if i = 0 then + ScrType(x + i, y + dy, f[5]) + else if i = dx then + ScrType(x + i, y + dy, f[6]) + else + ScrType(x + i, y + dy, f[2]); + end; + text := WrapTxt(text, dx - 1, dy - 1); + text := StringReplace(text, #13#10, #13, [rfReplaceAll]); + lines := 1; + for i := 0 to Length(text) - 1 do + if text[i + 1] = #13 then + Inc(lines); + sx := x; + if (style.VAlignment = vaBottom) then + sy := y + dy - lines - 1 + else if (style.VAlignment = vaCenter) then + sy := y + (dy - lines - 1) div 2 + else + sy := y; + buf := ''; + for i := 0 to Length(text) - 1 do + if text[i + 1] = #13 then + begin + Inc(sy); + if sy > (y + dy) then + break; + ScrString(sx + 1, sy, AlignBuf); + buf := ''; + end + else + begin + buf := buf + text[i + 1]; + end; + if buf <> '' then + ScrString(sx + 1, sy + 1, AlignBuf); +end; + +procedure TfrxTXTExport.FlushScr; +var + i, j, cnt, maxcnt: Integer; + buf: String; + f: String; + c: Char; + + function IsLine(c: Char): Boolean; + begin + Result := (c in [f[1], f[2]]); + end; + + function IsConner(c: Char): Boolean; + begin + Result := (c in [f[3], f[4], f[5], f[6], f[7], f[8], f[9], f[10], f[11]]); + end; + + function IsFrame(c: Char): Boolean; + begin + Result := IsLine(c) or IsConner(c); + end; + + function FrameOpt(c: Char; x, y: Integer; f: String): Char; + begin + if (not IsLine(ScrGet(x - 1, y))) and + (not IsLine(ScrGet(x + 1, y))) and + (not IsLine(ScrGet(x, y - 1))) and + (IsLine(ScrGet(x, y + 1))) then + Result := f[1] + else if (not IsLine(ScrGet(x - 1, y))) and + (not IsLine(ScrGet(x + 1, y))) and + (IsLine(ScrGet(x, y - 1))) and + (not IsLine(ScrGet(x, y + 1))) then + Result := f[1] + else if (not IsLine(ScrGet(x - 1, y))) and + (IsLine(ScrGet(x + 1, y))) and + (not IsLine(ScrGet(x, y - 1))) and + (not IsLine(ScrGet(x, y + 1))) then + Result := f[2] + else if (not IsLine(ScrGet(x + 1, y))) and + (IsLine(ScrGet(x - 1, y))) and + (not IsLine(ScrGet(x, y - 1))) and + (not IsLine(ScrGet(x, y + 1))) then + Result := f[2] + else if (not IsFrame(ScrGet(x + 1, y))) and + (not IsFrame(ScrGet(x - 1, y))) and + (ScrGet(x, y + 1) = f[1]) and + (ScrGet(x, y - 1) = f[1]) then + Result := f[1] + else if (ScrGet(x + 1, y) = f[2]) and + (ScrGet(x - 1, y) = f[2]) and + (not IsFrame(ScrGet(x, y + 1))) and + (not IsFrame(ScrGet(x, y - 1))) then + Result := f[2] + else if (ScrGet(x + 1, y) = f[2]) and + (ScrGet(x - 1, y) = f[2]) and + (ScrGet(x, y + 1) = f[1]) and + (ScrGet(x, y - 1) = f[1]) then + Result := f[11] + else if (ScrGet(x + 1, y) = f[2]) and + (ScrGet(x - 1, y) = f[2]) and + (ScrGet(x, y + 1) = f[1]) and + (ScrGet(x, y - 1) <> f[1]) then + Result := f[9] + else if (ScrGet(x + 1, y) = f[2]) and + (ScrGet(x - 1, y) = f[2]) and + (ScrGet(x, y - 1) = f[1]) and + (ScrGet(x, y + 1) <> f[1]) then + Result := f[7] + else if (ScrGet(x, y - 1) = f[1]) and + (ScrGet(x, y + 1) = f[1]) and + (ScrGet(x + 1, y) = f[2]) and + (ScrGet(x - 1, y) <> f[2])then + Result := f[8] + else if (ScrGet(x, y - 1) = f[1]) and + (ScrGet(x, y + 1) = f[1]) and + (ScrGet(x - 1, y) = f[2]) and + (ScrGet(x + 1, y) <> f[2])then + Result := f[10] + else if (ScrGet(x + 1, y) = f[2]) and + (ScrGet(x - 1, y) <> f[2]) and + (ScrGet(x, y + 1) = f[1]) and + (ScrGet(x, y - 1) <> f[1]) then + Result := f[3] + else if (ScrGet(x + 1, y) = f[2]) and + (ScrGet(x - 1, y) <> f[2]) and + (ScrGet(x, y + 1) <> f[1]) and + (ScrGet(x, y - 1) = f[1]) then + Result := f[5] + else if (ScrGet(x + 1, y) <> f[2]) and + (ScrGet(x - 1, y) = f[2]) and + (ScrGet(x, y + 1) <> f[1]) and + (ScrGet(x, y - 1) = f[1]) then + Result := f[6] + else if (ScrGet(x + 1, y) <> f[2]) and + (ScrGet(x - 1, y) = f[2]) and + (ScrGet(x, y + 1) = f[1]) and + (ScrGet(x, y - 1) <> f[1]) then + Result := f[4] + else + Result := c; + end; + +begin + if expBorders then + begin + if Length(expCustomFrameSet) > 0 then + f := CustomFrameSet + else if expBordersGraph then + f := FrameSet[2] + else + f := FrameSet[1]; + for i := 0 to ScrHeight - 1 do + for j := 0 to ScrWidth - 1 do + begin + c := Scr[i * ScrWidth + j]; + if IsConner(c) then + Scr[i * ScrWidth + j] := FrameOpt(c, j, i, f); + end; + end; + if not expLeadSpaces then + begin + maxcnt := 99999; + for i := 0 to ScrHeight - 1 do + begin + cnt := 0; + for j := 0 to ScrWidth - 1 do + if (Scr[i * ScrWidth + j] = ' ') then + Inc(cnt) else + break; + if cnt < maxcnt then + maxcnt := cnt; + end; + end + else + maxcnt := 0; + for i := 0 to ScrHeight - 1 do + begin + buf := ''; + for j := 0 to ScrWidth - 1 do + buf := buf + Scr[i * ScrWidth + j]; + buf := TrimRight(buf); + if (maxcnt > 0) then + buf := Copy(buf, maxcnt + 1, Length(buf) - maxcnt); + WriteExpLn(buf); + end; +end; + +procedure TfrxTXTExport.FreeScr; +begin + Finalize(Scr); + ScrHeight := 0; + ScrWidth := 0; +end; + +procedure TfrxTXTExport.ScrType(x,y: Integer; c: Char); +var + i: Integer; +begin + i := ScrWidth * y + x; + if (not expOEM) and (c = #160) then + c := ' '; + Scr[i] := c; +end; + +procedure TfrxTXTExport.ExportPage; +var + i, x, y: Integer; + s: String; + obj: TfrxMemoView; +begin + i := 0; + CreateScr(Round(expScaleX * MaxWidth / Xdivider) + 10, Round(expScaleY * LastY / Ydivider) + 2); + for y := 1 to RY.Count - 1 do + begin + for x := 1 to RX.Count - 1 do + if i < ObjectPos.Count then + if ((PObjPos(ObjectPos[i]).y + CurY + 1) = y) and + ((PObjPos(ObjectPos[i]).x + 1) = x) then + begin + Obj := TfrxMemoView(PageObj[PObjPos(ObjectPos[i]).obj]); + s := ChangeReturns(TruncReturns(Obj.Memo.Text)); + DrawMemo(Round(expScaleX * obj.Left / Xdivider), + Round(expScaleY * obj.Top / Ydivider), + Round(expScaleX * obj.Width / Xdivider), + Round(expScaleY * obj.Height / Ydivider), + s, PObjPos(ObjectPos[i]).style); + Obj.Free; + Inc(i); + end; + end; + FlushScr; + FreeScr; +end; + + +function TfrxTXTExport.ShowModal: TModalResult; +var + preview: Boolean; +begin + if ShowDialog then + begin + preview := False; + frExportSet := TfrxTXTExportDialog.Create(nil); + frExportSet.Exporter := Self; + frExportSet.CB_PrintAfter.Visible := not SlaveExport; + if SlaveExport then + expPrintAfter := False; + + if FileName = '' then + frExportSet.SaveDialog1.FileName := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), frExportSet.SaveDialog1.DefaultExt) + else + frExportSet.SaveDialog1.FileName := FileName; + + frExportSet.PreviewActive := false; + frExportSet.RB_Graph.Checked := expBordersGraph; + frExportSet.RB_NoneFrames.Checked := not expBorders; + frExportSet.RB_Simple.Checked := expBorders and (not expBordersGraph); + frExportSet.CB_PageBreaks.Checked := expPageBreaks; + frExportSet.CB_OEM.Checked := expOEM; + frExportSet.CB_EmptyLines.Checked := expEmptyLines; + frExportSet.CB_LeadSpaces.Checked := expLeadSpaces; + frExportSet.UpDown1.Position := StrToInt(IntToStr(Round(expScaleX * 100))); + frExportSet.UpDown2.Position := StrToInt(IntToStr(Round(expScaleY * 100))); + frExportSet.CB_PrintAfter.Checked := expPrintAfter; + frExportSet.PreviewActive := preview; + frExportSet.PagesCount := Report.PreviewPages.Count; + Result := frExportSet.ShowModal; + if Result = mrOk then + begin + PageNumbers := frExportSet.E_Range.Text; + expBorders := not frExportSet.RB_NoneFrames.Checked; + expBordersGraph := frExportSet.RB_Graph.Checked; + expPageBreaks := frExportSet.CB_PageBreaks.Checked; + expOEM := frExportSet.CB_OEM.Checked; + expEmptyLines := frExportSet.CB_EmptyLines.Checked; + expLeadSpaces := frExportSet.CB_LeadSpaces.Checked; + expScaleX := StrToInt(frExportSet.E_ScaleX.Text) / 100; + expScaleY := StrToInt(frExportSet.E_ScaleY.Text) / 100; + expPrintAfter := frExportSet.CB_PrintAfter.Checked; + if frExportSet.MakeInit then + begin + SelectedPrinterType := frExportSet.printer; + MakeInitString; + end; + if DefaultPath <> '' then + frExportSet.SaveDialog1.InitialDir := DefaultPath; + if not SlaveExport then + begin + if frExportSet.SaveDialog1.Execute then + begin + FileName := frExportSet.SaveDialog1.Filename; + end + else + Result := mrCancel; + end + else + FileName := ChangeFileExt(GetTempFile, frExportSet.SaveDialog1.DefaultExt); + end; + frExportSet.Free; + end + else + Result := mrOk; +end; + +function TfrxTXTExport.Start: Boolean; +begin + CurrentPage := 0; + FirstPage := True; + ClearLastPage; + if not IsPreview then + WriteExp(PrinterInitString); + pgBreakList.Clear; + if FileName <> '' then + begin + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + FileName := DefaultPath + '\' + FileName; + Stream := TFileStream.Create(FileName, fmCreate); + Result := True + end + else + Result := False; +end; + +procedure TfrxTXTExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + Inc(CurrentPage); + MaxWidth := 0; + LastY := 0; + CY := 0; + CurY := 0; + PageWidth := 0; + PageHeight := 0; +end; + +procedure TfrxTXTExport.ExportObject(Obj: TfrxComponent); +var + MemoView: TfrxMemoView; + maxy: Extended; +begin + if Obj is TfrxCustomMemoView then + begin + if ((TfrxMemoView(Obj).Memo.Count > 0) or (TfrxMemoView(Obj).Frame.Typ <> [])) then + begin + MemoView := TfrxMemoView.Create(nil); + MemoView.Assign(Obj); + MemoView.Left := Obj.AbsLeft; + MemoView.Top := Obj.AbsTop + CY; + MemoView.Width := Obj.Width; + MemoView.Height := Obj.Height; + MemoView.Font.Assign(Obj.Font); // added by Samuel Herzog + PageObj.Add(MemoView); + ObjCellAdd(RX, Obj.AbsLeft); + ObjCellAdd(RX, Obj.AbsLeft + Obj.Width); + ObjCellAdd(RY, Obj.AbsTop + CY); + ObjCellAdd(RY, Obj.AbsTop + Obj.Height + CY); + end; + end; + if Obj.AbsLeft + Obj.Width > MaxWidth then + MaxWidth := Obj.AbsLeft + Obj.Width; + maxy := Obj.AbsTop + Obj.Height + CY; + if maxy > LastY then + LastY := maxy; +end; + +procedure TfrxTXTExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + PrepareExportPage; + ExportPage; + if expPageBreaks then + FormFeed; + ClearLastPage; +end; + +procedure TfrxTXTExport.Finish; +begin + if (not expPageBreaks) and (not IsPreview) then + FormFeed; + Stream.Free; + AfterExport(FileName); +end; + +procedure TfrxTXTExport.SpoolFile(const FileName: String); +const + BUF_SIZE = 1024; +var + f: TFileStream; + buf: String; + l: longint; +begin + frxPrinters.Printer.Title := FileName; + frxPrinters.Printer.BeginRAWDoc; + f := TFileStream.Create(FileName, fmOpenRead); + SetLength(buf, BUF_SIZE); + l := BUF_SIZE; + while l = BUF_SIZE do + begin + l := f.Read(buf[1], BUF_SIZE); + SetLength(buf, l); + frxPrinters.Printer.WriteRAWDoc(buf); + end; + f.Free; + frxPrinters.Printer.EndRAWDoc; + DeleteFile(FileName); +end; + +function GetTempFName: String; +var + Path: String[64]; + FileName: String[255]; +begin + Path[0] := Chr(GetTempPath(64, @Path[1])); + GetTempFileName(@Path[1], PChar('fr'), 0, @FileName[1]); + Result := StrPas(@FileName[1]); +end; + +procedure TfrxTXTExport.AfterExport(const FileName: String); +var + i: Integer; + fname: String; + f, ffrom: TFileStream; +begin + if expPrintAfter then + begin + if Printer.Printers.Count = 0 then Exit; + if expPrinterDialog then + with TfrxPrnInit.Create(Self) do + begin + i := ShowModal; + if i = mrOk then + Copys := UpDown1.Position; + Free; + end + else + i := mrOk; + if i = mrOk then + begin + MakeInitString; + fname := GetTempFName; + f := TFileStream.Create(fname, fmCreate); + ffrom := TFileStream.Create(FileName, fmOpenRead); + f.Write(PrinterInitString[1], Length(PrinterInitString)); + f.CopyFrom(ffrom, 0); + f.Free; + ffrom.Free; + f := TFileStream.Create(FileName, fmCreate); + ffrom := TFileStream.Create(fname, fmOpenRead); + f.CopyFrom(ffrom, 0); + f.Free; + ffrom.Free; + DeleteFile(fname); + for i := 1 to Copys do + SpoolFile(FileName); + end; + end; +end; + +procedure TfrxTXTExport.PrepareExportPage; +begin + RX.Sort(@ComparePoints); + RY.Sort(@ComparePoints); + PageObj.Sort(@CompareObjects); + OrderObjectByCells; + MakeStyleList; +end; + +function TfrxTXTExport.MakeInitString: String; +var + i: Integer; +begin + if PrintersCount > 0 then + begin + PrinterInitString := ''; + for i := 0 to PrinterTypes[SelectedPrinterType].CommCount - 1 do + if PrinterTypes[SelectedPrinterType].Commands[i].Trigger then + PrinterInitString := PrinterInitString + + PrinterTypes[SelectedPrinterType].Commands[i].SwitchOn + else + PrinterInitString := PrinterInitString + + PrinterTypes[SelectedPrinterType].Commands[i].SwitchOff; + end; +end; + +procedure TfrxTXTExport.RegisterPrinterCommand(PrinterIndex: Integer; + const Name, switch_on, switch_off: String); +var + i: Integer; +begin + i := PrinterTypes[PrinterIndex].CommCount; + PrinterTypes[PrinterIndex].Commands[i].Name := Name; + PrinterTypes[PrinterIndex].Commands[i].SwitchOn := Switch_On; + PrinterTypes[PrinterIndex].Commands[i].SwitchOff := Switch_Off; + PrinterTypes[PrinterIndex].Commands[i].Trigger := False; + Inc(PrinterTypes[PrinterIndex].CommCount); +end; + +function TfrxTXTExport.RegisterPrinterType(const Name: String): Integer; +begin + PrinterTypes[PrintersCount].Name := Name; + PrinterTypes[PrintersCount].CommCount := 0; + Inc(PrintersCount); + Result := PrintersCount - 1; +end; + +procedure TfrxTXTExport.LoadPrinterInit(const FName: String); +var + f: TextFile; + i: Integer; + buf: String; + b: Boolean; +begin +{$I-} + AssignFile(f, FName); + Reset(f); + ReadLn(f, buf); + SelectedPrinterType := StrToInt(buf); + i := 0; + while (not eof(f)) and (i < PrinterTypes[SelectedPrinterType].CommCount) do + begin + ReadLn(f, buf); + if Pos('True', buf) > 0 then + b := True + else + b := False; + PrinterTypes[SelectedPrinterType].Commands[i].Trigger := b; + Inc(i); + end; + MakeInitString; +{$I+} +end; + +procedure TfrxTXTExport.SavePrinterInit(const FName: String); +var + f: TextFile; + i: Integer; + s: String; +begin +{$I-} + AssignFile(f, FName); + Rewrite(f); + WriteLn(f, IntToStr(SelectedPrinterType)); + for i := 0 to PrinterTypes[SelectedPrinterType].CommCount - 1 do + begin + if PrinterTypes[SelectedPrinterType].Commands[i].Trigger then + s := 'True' else + s := 'False'; + WriteLn(f, s); + end; + CloseFile(f); +{$I+} +end; + +procedure TfrxTXTExport.FormFeed; +begin + WriteExp(#12); +end; + +////////////////////////////////////////////// + +procedure TfrxTXTExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8300); + OK.Caption := frxGet(1); + Cancel.Caption := frxGet(2); + BtnPreview.Hint := frxGet(8301); + GroupCellProp.Caption := frxGet(8302); + CB_PageBreaks.Caption := frxGet(8303); + CB_OEM.Caption := frxGet(8304); + CB_EmptyLines.Caption := frxGet(8305); + CB_LeadSpaces.Caption := frxGet(8306); + GroupPageRange.Caption := frxGet(7); + Pages.Caption := frxGet(8307); + Descr.Caption := frxGet(8308); + GroupScaleSettings.Caption := frxGet(8309); + ScX.Caption := frxGet(8310); + ScY.Caption := frxGet(8311); + GroupFramesSettings.Caption := frxGet(8312); + RB_NoneFrames.Caption := frxGet(8313); + RB_Simple.Caption := frxGet(8314); + RB_Graph.Caption := frxGet(8315); + RB_Graph.Hint := frxGet(8316); + CB_PrintAfter.Caption := frxGet(8317); + GroupBox1.Caption := frxGet(8319); + Label1.Caption := frxGet(8320); + Label3.Caption := frxGet(8321); + LBPage.Caption := frxGet(8322); + ToolButton1.Hint := frxGet(8323); + ToolButton2.Hint := frxGet(8324); + SaveDialog1.Filter := frxGet(8325); + SaveDialog1.DefaultExt := frxGet(8326); + + created := False; + TxtExp := TfrxTXTExport.CreateNoRegister; + BtnPreviewClick(Sender); + Created := True; + MakeInit := False; + printer := 0; + PageUpDown.Max := PagesCount; + running := False; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxTXTExportDialog.CB_OEMClick(Sender: TObject); +begin + RB_Graph.Enabled := CB_OEM.Checked; + if not RB_Simple.Checked then + RB_Simple.Checked := RB_Graph.Checked; + E_ScaleXChange(Sender); +end; + +procedure TfrxTXTExportDialog.RefreshClick(Sender: TObject); +var + fname: String; + Progr: Boolean; +begin + if Flag then + begin + running := true; + fname := GetTempFName; + TxtExp.IsPreview := True; + TxtExp.ShowDialog := False; + TxtExp.Borders := not RB_NoneFrames.Checked; + TxtExp.Pseudogrpahic := RB_Graph.Checked; + TxtExp.PageBreaks := CB_PageBreaks.Checked; + TxtExp.OEMCodepage := CB_OEM.Checked; + TxtExp.EmptyLines := CB_EmptyLines.Checked; + TxtExp.LeadSpaces := CB_LeadSpaces.Checked; + TxtExp.ScaleWidth := StrToInt(E_ScaleX.Text) / 100; + TxtExp.ScaleHeight := StrToInt(E_ScaleY.Text) / 100; + progr := Exporter.ShowProgress; + Exporter.ShowProgress := False; + TxtExp.FileName := fname; + TxtExp.PageNumbers := EPage.Text; + Exporter.Report.Export(TxtExp); + Exporter.ShowProgress := progr; + if CB_OEM.Checked then + Preview.Font.Name := 'Terminal' else + Preview.Font.Name := 'Courier New'; + Preview.Lines.LoadFromFile(fname); + DeleteFile(fname); + PgWidth.Caption := IntToStr(TxtExp.PageWidth); + PgHeight.Caption := IntToStr(TxtExp.PageHeight); + running := false; + end; +end; + +procedure TfrxTXTExportDialog.FormClose(Sender: TObject; + var Action: TCloseAction); +begin + TxtExp.Free; +end; + +procedure TfrxTXTExportDialog.FormActivate(Sender: TObject); +begin +{ CB_OEMClick(Sender); + if PreviewActive then + BtnPreview.Down := True; + BtnPreviewClick(Sender);} +end; + +procedure TfrxTXTExportDialog.E_ScaleXChange(Sender: TObject); +begin + if PreviewActive then + RefreshClick(Sender); +end; + +procedure TfrxTXTExportDialog.BtnPreviewClick(Sender: TObject); +begin + if BtnPreview.Down then + begin + PreviewActive := True; + Left := Left - 177; + Width := 631; + Panel2.Visible := True; + Flag := True; + E_ScaleXChange(Sender); + end + else + begin + if created and PreviewActive then + Left := Left + 177; + Flag := False; + PreviewActive := False; + Width := 277; + Panel2.Visible := False; + end; +end; + +procedure TfrxTXTExportDialog.ToolButton1Click(Sender: TObject); +begin + if Preview.Font.Size < 30 then + Preview.Font.Size := Preview.Font.Size + 1; +end; + +procedure TfrxTXTExportDialog.ToolButton2Click(Sender: TObject); +begin + if Preview.Font.Size > 2 then + Preview.Font.Size := Preview.Font.Size - 1; +end; + +procedure TfrxTXTExportDialog.UpDown1Changing(Sender: TObject; + var AllowChange: Boolean); +begin + if PreviewActive then + if not running then + RefreshClick(Sender) + else + AllowChange := False; +end; + +procedure TfrxTXTExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxExportText.dfm b/official/4.2/LibD11/frxExportText.dfm new file mode 100644 index 0000000..4ab8c03 Binary files /dev/null and b/official/4.2/LibD11/frxExportText.dfm differ diff --git a/official/4.2/LibD11/frxExportText.pas b/official/4.2/LibD11/frxExportText.pas new file mode 100644 index 0000000..708549f --- /dev/null +++ b/official/4.2/LibD11/frxExportText.pas @@ -0,0 +1,528 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Simple text export } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportText; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, extctrls, frxClass, frxExportMatrix, ShellAPI +{$IFDEF Delphi6}, Variants {$ENDIF}; + +type + TfrxSimpleTextExportDialog = class(TForm) + OkB: TButton; + CancelB: TButton; + SaveDialog1: TSaveDialog; + GroupPageRange: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + GroupQuality: TGroupBox; + PageBreaksCB: TCheckBox; + OpenCB: TCheckBox; + FramesCB: TCheckBox; + EmptyLinesCB: TCheckBox; + OEMCB: TCheckBox; + procedure FormCreate(Sender: TObject); + procedure PageNumbersEChange(Sender: TObject); + procedure PageNumbersEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + end; + + TfrxSimpleTextExport = class(TfrxCustomExportFilter) + private + FPageBreaks: Boolean; + FMatrix: TfrxIEMatrix; + FOpenAfterExport: Boolean; + Exp: TStream; + FPage: TfrxReportPage; + FFrames: Boolean; + pX: Extended; + pY: Extended; + pT: Extended; + FEmptyLines: Boolean; + FOEM: Boolean; + procedure ExportPage(Stream: TStream); + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + procedure ExportObject(Obj: TfrxComponent); override; + published + property PageBreaks: Boolean read FPageBreaks write FPageBreaks default True; + property Frames: Boolean read FFrames write FFrames; + property EmptyLines: Boolean read FEmptyLines write FEmptyLines; + property OEMCodepage: Boolean read FOEM write FOEM; + property OpenAfterExport: Boolean read FOpenAfterExport write FOpenAfterExport default False; + end; + + +implementation + +uses frxUtils, frxFileUtils, frxUnicodeUtils, frxRes, frxrcExports; + +{$R *.dfm} + +{ TfrxSimpleTextExport } + +constructor TfrxSimpleTextExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FPageBreaks := True; + FFrames := False; + FEmptyLines := False; + FOEM := False; + FilterDesc := frxGet(8801); + DefaultExt := frxGet(8802); +end; + +class function TfrxSimpleTextExport.GetDescription: String; +begin + Result := frxResources.Get('SimpleTextExport'); +end; + +procedure TfrxSimpleTextExport.ExportPage(Stream: TStream); +var + x, y, i: Integer; + FScreen: array of Char; + FScreenWidth: Integer; + FScreenHeight: Integer; + Obj: TfrxIEMObject; + c: Char; + s: String; + + function MakeStr(C: Char; N: Integer): String; + begin + if N < 1 then + Result := '' + else + begin + SetLength(Result, N); + FillChar(Result[1], Length(Result), C); + end; + end; + + function AddChar(C: Char; const S: String; N: Integer): String; + begin + if Length(S) < N then + Result := MakeStr(C, N - Length(S)) + S else + Result := S; + end; + + function AddCharR(C: Char; const S: String; N: Integer): String; + begin + if Length(S) < N then + Result := S + MakeStr(C, N - Length(S)) else + Result := S; + end; + + function LeftStr(const S: String; N: Integer): String; + begin + Result := AddCharR(' ', S, N); + end; + + function RightStr(const S: String; N: Integer): String; + begin + Result := AddChar(' ', S, N); + end; + + function CenterStr(const S: String; Len: Integer): String; + begin + if Length(S) < Len then + begin + Result := MakeStr(' ', (Len div 2) - (Length(S) div 2)) + S; + Result := Result + MakeStr(' ', Len - Length(Result)); + end + else + Result := S; + end; + + function AlignStr(const Buf: String; const style: TfrxIEMStyle; const Width: Integer): String; + begin + if (style.HAlign = haRight) then + Result := RightStr(buf, Width - 1) + else if (style.HAlign = haCenter) then + Result := CenterStr(buf, Width - 1) + else + Result := LeftStr(buf, Width - 1); + end; + + procedure ScreenCreate; + begin + Initialize(FScreen); + SetLength(FScreen, FScreenWidth * FScreenHeight); + FillChar(FScreen[0], Length(FScreen), #32); + end; + + procedure ScreenType(const x,y: Integer; const c: Char); + begin + FScreen[FScreenWidth * y + x] := c; + end; + + procedure ScreenString(const x, y: Integer; const s: String); + var + i: Integer; + begin + for i := 0 to Length(s) - 1 do + ScreenType(x + i, y, s[i + 1]); + end; + + procedure ScreenMemo(const Obj: TfrxIEMObject); + var + i: Integer; + curx, cury: Integer; + s: String; + + function StrToOem(const AnsiStr: String): String; + begin + SetLength(Result, Length(AnsiStr)); + if Length(Result) > 0 then + CharToOemBuff(PChar(AnsiStr), PChar(Result), Length(Result)); + end; + + begin + curx := Round(Obj.Left / pX); + cury := Round(Obj.Top / pY); + for i := 0 to Obj.Memo.Count - 1 do + begin + if FOEM then + s := StrToOem(Obj.Memo[i]) + else + s := Obj.Memo[i]; + ScreenString(curx, cury + i, AlignStr(s, Obj.Style, Round(Obj.Width / pX) - 1)); + end; + if FFrames then + begin + if (ftLeft in Obj.Style.FrameTyp) then + for i := 0 to Round(Obj.Height / pY) - 1 do + ScreenType(curx - 1, cury + i, '|'); + if (ftRight in Obj.Style.FrameTyp) then + for i := 0 to Round(Obj.Height / pY) - 1 do + ScreenType(curx + Round(Obj.Width / pX) - 2, cury + i, '|'); + if (ftTop in Obj.Style.FrameTyp) then + for i := 0 to Round(Obj.Width / pX) - 1 do + ScreenType(curx - 1 + i, cury - 1, '-'); + if (ftBottom in Obj.Style.FrameTyp) then + for i := 0 to Round(Obj.Width / pX) - 1 do + ScreenType(curx - 1 + i, cury + Round(Obj.Height / pY) - 1, '-'); + end; + end; + + function ScreenGet(const x, y: Integer): Char; + begin + if (x < FScreenWidth) and (y < FScreenHeight) and + (x >= 0) and (y >= 0) then + Result := FScreen[FScreenWidth * y + x] else + Result := ' '; + end; + + function GetMaxPX(const Obj: TfrxIEMObject): Extended; + var + i : Integer; + begin + Result := 0; + for i := 0 to Obj.Memo.Count - 1 do + if Length(Obj.Memo[i]) > Result then + Result := Length(Obj.Memo[i]); + if (Result > 0) then //and (Obj.Width ) + Result := 6 * Obj.Width / (Result * Obj.Style.Font.Size); + if Result < 1 then + Result := 1; + end; + + function GetMaxPY(const Obj: TfrxIEMObject): Extended; + begin + if Obj.Memo.Count > 0 then + Result := 5 * Obj.Height / (Obj.Memo.Count * Obj.Style.Font.Size) + else + Result := 0; + end; + + function ColumnEmpty(const x: Integer): Boolean; + var + y: Integer; + begin + Result := True; + for y := 0 to FScreenHeight - 1 do + if FScreen[FScreenWidth * y + x] <> #32 then + begin + Result := False; + break; + end; + end; + + procedure DeleteColumn(const x: Integer); + var + i, j: Integer; + begin + for i := 0 to FScreenHeight - 1 do + begin + for j := x to FScreenWidth - 2 do + FScreen[FScreenWidth * i + j] := FScreen[FScreenWidth * i + j + 1]; + FScreen[FScreenWidth * i + FScreenWidth - 1] := #32; + end; + end; + +begin + FMatrix.Prepare; + + for i := 0 to FMatrix.ObjectsCount - 1 do + begin + pT := GetMaxPX(FMatrix.GetObjectById(i)); + if (pT < pX) and (pT <> 0) then + pX := pT; + pT := GetMaxPY(FMatrix.GetObjectById(i)); + if (pT < pY) and (pT <> 0) then + pY := pT; + end; + + FScreenWidth := Round(FPage.Width / pX); + FScreenHeight := Round(FPage.Height / pY); + ScreenCreate; + + for y := 0 to FMatrix.Height - 2 do + begin + for x := 0 to FMatrix.Width - 1 do + begin + i := FMatrix.GetCell(x, y); + if (i <> -1) then + begin + Obj := FMatrix.GetObjectById(i); + ScreenMemo(Obj); + end; + end; + end; + + x := 0; + i := 2; + y := FScreenWidth; + while x < y - 1 do + if ColumnEmpty(x) then + begin + if i = 0 then + begin + DeleteColumn(x); + Dec(y); + end + else begin + Dec(i); + Inc(x); + end; + end + else begin + Inc(x); + i := 2; + end; + + for y := 0 to FScreenHeight - 1 do + begin + s := ''; + for x := 0 to FScreenWidth - 1 do + begin + c := ScreenGet(x, y); + s := s + c; + end; + s := TrimRight(s); + if (Length(Trim(s)) > 0) or FEmptyLines then + begin + s := s + #13#10; + Stream.Write(s[1], Length(s)); + end; + end; + if FPageBreaks then + Stream.Write(String(#12), 1); +end; + +function TfrxSimpleTextExport.ShowModal: TModalResult; +begin + if not Assigned(Stream) then + begin + with TfrxSimpleTextExportDialog.Create(nil) do + begin + OpenCB.Visible := not SlaveExport; + if SlaveExport then + FOpenAfterExport := False; + + if (FileName = '') and (not SlaveExport) then + SaveDialog1.FileName := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), SaveDialog1.DefaultExt) + else + SaveDialog1.FileName := FileName; + + PageBreaksCB.Checked := FPageBreaks; + OpenCB.Checked := FOpenAfterExport; + FramesCB.Checked := FFrames; + EmptyLinesCB.Checked := FEmptyLines; + OEMCB.Checked := FOEM; + + if PageNumbers <> '' then + begin + PageNumbersE.Text := PageNumbers; + PageNumbersRB.Checked := True; + end; + + Result := ShowModal; + + if Result = mrOk then + begin + PageNumbers := ''; + CurPage := False; + if CurPageRB.Checked then + CurPage := True + else if PageNumbersRB.Checked then + PageNumbers := PageNumbersE.Text; + + FPageBreaks := PageBreaksCB.Checked; + FOpenAfterExport := OpenCB.Checked; + FFrames := FramesCB.Checked; + FEmptyLines := EmptyLinesCB.Checked; + FOEM := OEMCB.Checked; + + if not SlaveExport then + begin + if DefaultPath <> '' then + SaveDialog1.InitialDir := DefaultPath; + if SaveDialog1.Execute then + FileName := SaveDialog1.FileName + else + Result := mrCancel; + end + else + FileName := ChangeFileExt(GetTempFile, SaveDialog1.DefaultExt); + end; + Free; + end; + end else + Result := mrOk; +end; + +function TfrxSimpleTextExport.Start: Boolean; +begin + if (FileName <> '') or Assigned(Stream) then + begin + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + FileName := DefaultPath + '\' + FileName; + FMatrix := TfrxIEMatrix.Create(UseFileCache, Report.EngineOptions.TempDir); + FMatrix.Background := False; + FMatrix.BackgroundImage := False; + FMatrix.Printable := ExportNotPrintable; + FMatrix.RichText := True; + FMatrix.PlainRich := True; + FMatrix.AreaFill := False; + FMatrix.CropAreaFill := True; + FMatrix.Inaccuracy := 0.5; + FMatrix.DeleteHTMLTags := True; + FMatrix.Images := False; + FMatrix.WrapText := True; + FMatrix.ShowProgress := False; + FMatrix.FramesOptimization := True; + try + if Assigned(Stream) then + Exp := Stream + else + Exp := TFileStream.Create(FileName, fmCreate); + Result := True; + except + Result := False; + end; + end + else + Result := False; +end; + +procedure TfrxSimpleTextExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + FMatrix.Clear; + pX := MAXWORD; + pY := MAXWORD; +end; + +procedure TfrxSimpleTextExport.ExportObject(Obj: TfrxComponent); +begin + if Obj is TfrxView then + FMatrix.AddObject(TfrxView(Obj)); +end; + +procedure TfrxSimpleTextExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + FPage := Page; + ExportPage(Exp); +end; + +procedure TfrxSimpleTextExport.Finish; +begin + FMatrix.Free; + if not Assigned(Stream) then + Exp.Free; + if FOpenAfterExport and (not Assigned(Stream)) then + ShellExecute(GetDesktopWindow, 'open', PChar(FileName), nil, nil, SW_SHOW); +end; + +{ TfrxSimpleTextExportDialog } + +procedure TfrxSimpleTextExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8800); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + GroupPageRange.Caption := frxGet(7); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + DescrL.Caption := frxGet(9); + GroupQuality.Caption := frxGet(8302); + PageBreaksCB.Caption := frxGet(6); + FramesCB.Caption := frxGet(8312); + EmptyLinesCB.Caption := frxGet(8305); + OEMCB.Caption := frxGet(8304); + OpenCB.Caption := frxGet(8706); + SaveDialog1.Filter := frxGet(8801); + SaveDialog1.DefaultExt := frxGet(8802); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxSimpleTextExportDialog.PageNumbersEChange(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxSimpleTextExportDialog.PageNumbersEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8, '-', ',':; + else + key := #0; + end; +end; + +procedure TfrxSimpleTextExportDialog.FormKeyDown(Sender: TObject; + var Key: Word; Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxExportTxtPrn.dfm b/official/4.2/LibD11/frxExportTxtPrn.dfm new file mode 100644 index 0000000..39aa7d9 Binary files /dev/null and b/official/4.2/LibD11/frxExportTxtPrn.dfm differ diff --git a/official/4.2/LibD11/frxExportTxtPrn.pas b/official/4.2/LibD11/frxExportTxtPrn.pas new file mode 100644 index 0000000..4a63d59 --- /dev/null +++ b/official/4.2/LibD11/frxExportTxtPrn.pas @@ -0,0 +1,189 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Text advanced export filter } +{ Printing form } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxExportTxtPrn; + +interface + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls, CheckLst, frxExportTXT, Buttons +{$IFDEF Delphi6}, Variants {$ENDIF}, ComCtrls, Mask, frxRes, frxrcExports; + +type + TfrxPrnInit = class(TForm) + OK: TButton; + Cancel: TButton; + OpenDialog1: TOpenDialog; + SaveDialog1: TSaveDialog; + GroupBox1: TGroupBox; + Label4: TLabel; + Image1: TImage; + CB1: TComboBox; + PropButton: TButton; + GroupBox3: TGroupBox; + Label2: TLabel; + Panel2: TPanel; + GroupBox2: TGroupBox; + CheckListBox1: TCheckListBox; + Label1: TLabel; + ComboBox1: TComboBox; + Button1: TSpeedButton; + Button2: TSpeedButton; + E1: TMaskEdit; + UpDown1: TUpDown; + procedure FormCreate(Sender: TObject); + procedure ComboBox1Change(Sender: TObject); + procedure CheckListBox1ClickCheck(Sender: TObject); + procedure Button1Click(Sender: TObject); + procedure Button2Click(Sender: TObject); + procedure FormDeactivate(Sender: TObject); + procedure PropButtonClick(Sender: TObject); + procedure CB1Click(Sender: TObject); + procedure CB1DrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + exp: TfrxTXTExport; + OldIndex: Integer; + procedure Localize; + public + { Public declarations } + end; + +var + frxPrnInit: TfrxPrnInit; + +implementation + +{$R *.dfm} + +uses frxutils, Printers, frxprinter, frxclass; + +procedure TfrxPrnInit.FormCreate(Sender: TObject); +var + i: integer; +begin + CB1.Items.Assign(Printer.Printers); + CB1.ItemIndex := Printer.PrinterIndex; + OldIndex := Printer.PrinterIndex; + Localize; + SendMessage(GetWindow(ComboBox1.Handle,GW_CHILD), EM_SETREADONLY, 1, 0); + exp := TfrxTXTExport(Owner); + ComboBox1.Items.Clear; + CheckListBox1.Items.Clear; + for i := 0 to exp.PrintersCount - 1 do + ComboBox1.Items.Add(exp.PrinterTypes[i].name); + ComboBox1.ItemIndex := exp.SelectedPrinterType; + ComboBox1Change(Sender); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxPrnInit.ComboBox1Change(Sender: TObject); +var + j: integer; +begin + CheckListBox1.Items.Clear; + for j := 0 to exp.PrinterTypes[ComboBox1.ItemIndex].CommCount - 1 do + begin + CheckListBox1.Items.Add(exp.PrinterTypes[ComboBox1.ItemIndex].Commands[j].Name); + CheckListBox1.Checked[j] := exp.PrinterTypes[ComboBox1.ItemIndex].Commands[j].Trigger; + end; + exp.SelectedPrinterType := ComboBox1.ItemIndex; +end; + +procedure TfrxPrnInit.CheckListBox1ClickCheck(Sender: TObject); +begin + exp.PrinterTypes[ComboBox1.ItemIndex].Commands[CheckListBox1.ItemIndex].Trigger := + CheckListBox1.Checked[CheckListBox1.ItemIndex]; +end; + +procedure TfrxPrnInit.Localize; +begin + Caption := frxGet(8400); + OK.Caption := frxGet(1); + Cancel.Caption := frxGet(2); + GroupBox1.Caption := frxGet(8401); + Label4.Caption := frxGet(8402); + PropButton.Caption := frxGet(8403); + GroupBox3.Caption := frxGet(8404); + Label2.Caption := frxGet(8405); + GroupBox2.Caption := frxGet(8406); + Label1.Caption := frxGet(8407); + OpenDialog1.DefaultExt := frxGet(8408); + OpenDialog1.Filter := frxGet(8409); + SaveDialog1.DefaultExt := frxGet(8410); + SaveDialog1.Filter := frxGet(8411); +end; + +procedure TfrxPrnInit.Button1Click(Sender: TObject); +begin + if OpenDialog1.Execute then + begin + exp.LoadPrinterInit(OpenDialog1.FileName); + ComboBox1.ItemIndex := exp.SelectedPrinterType; + ComboBox1Change(Sender); + end; +end; + +procedure TfrxPrnInit.Button2Click(Sender: TObject); +begin + if SaveDialog1.Execute then + exp.SavePrinterInit(SaveDialog1.FileName); +end; + +procedure TfrxPrnInit.FormDeactivate(Sender: TObject); +begin + if ModalResult <> mrOk then + frxPrinters.PrinterIndex := OldIndex; +end; + +procedure TfrxPrnInit.PropButtonClick(Sender: TObject); +begin + frxPrinters.Printer.PropertiesDlg; +end; + +procedure TfrxPrnInit.CB1Click(Sender: TObject); +begin + frxPrinters.PrinterIndex := CB1.ItemIndex; +end; + +procedure TfrxPrnInit.CB1DrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); +var + r: TRect; +begin + r := ARect; + r.Right := r.Left + 18; + r.Bottom := r.Top + 16; + OffsetRect(r, 2, 0); + with CB1.Canvas do + begin + FillRect(ARect); + BrushCopy(r, Image1.Picture.Bitmap, Rect(0, 0, 18, 16), clOlive); + TextOut(ARect.Left + 24, ARect.Top + 1, CB1.Items[Index]); + end; +end; + +procedure TfrxPrnInit.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxExportXLS.dfm b/official/4.2/LibD11/frxExportXLS.dfm new file mode 100644 index 0000000..32649e9 Binary files /dev/null and b/official/4.2/LibD11/frxExportXLS.dfm differ diff --git a/official/4.2/LibD11/frxExportXLS.pas b/official/4.2/LibD11/frxExportXLS.pas new file mode 100644 index 0000000..56f6498 --- /dev/null +++ b/official/4.2/LibD11/frxExportXLS.pas @@ -0,0 +1,1365 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Excel OLE export filter } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} +{ Improved by: } +{ Serge Buzadzhy } +{ buzz@devrace.com } +{ Bysoev Alexander } +{ Kanal-B@Yandex.ru } +{******************************************} + +unit frxExportXLS; + +interface + +{$I frx.inc} +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Printers, ComObj, frxClass, frxProgress, + frxExportMatrix, Clipbrd, ActiveX +{$IFDEF Delphi6}, Variants {$ENDIF}; + +type + TfrxXLSExportDialog = class(TForm) + OkB: TButton; + CancelB: TButton; + SaveDialog1: TSaveDialog; + GroupPageRange: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + GroupQuality: TGroupBox; + MergeCB: TCheckBox; + WCB: TCheckBox; + ContinuousCB: TCheckBox; + PicturesCB: TCheckBox; + OpenExcelCB: TCheckBox; + AsTextCB: TCheckBox; + BackgrCB: TCheckBox; + FastExpCB: TCheckBox; + PageBreaksCB: TCheckBox; + procedure FormCreate(Sender: TObject); + procedure PageNumbersEChange(Sender: TObject); + procedure PageNumbersEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + end; + + TfrxExcel = class; + + TfrxXLSExport = class(TfrxCustomExportFilter) + private + FExcel: TfrxExcel; + FExportPictures: Boolean; + FExportStyles: Boolean; + FFirstPage: Boolean; + FMatrix: TfrxIEMatrix; + FMergeCells: Boolean; + FOpenExcelAfterExport: Boolean; + FPageBottom: Extended; + FPageLeft: Extended; + FPageRight: Extended; + FPageTop: Extended; + FPageOrientation: TPrinterOrientation; + FProgress: TfrxProgress; + FWysiwyg: Boolean; + FAsText: Boolean; + FBackground: Boolean; + FFastExport: Boolean; + FpageBreaks: Boolean; + FEmptyLines: Boolean; + procedure ExportPage_Fast; + procedure ExportPage; + function CleanReturns(const Str: WIdeString): WideString; + function FrameTypesToByte(Value: TfrxFrameTypes): Byte; + function GetNewIndex(Strings: TStrings; ObjValue: Integer): Integer; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + procedure ExportObject(Obj: TfrxComponent); override; + published + property ExportStyles: Boolean read FExportStyles write FExportStyles default True; + property ExportPictures: Boolean read FExportPictures write FExportPictures default True; + property MergeCells: Boolean read FMergeCells write FMergeCells default True; + property OpenExcelAfterExport: Boolean read FOpenExcelAfterExport + write FOpenExcelAfterExport default False; + property Wysiwyg: Boolean read FWysiwyg write FWysiwyg default True; + property AsText: Boolean read FAsText write FAsText; + property Background: Boolean read FBackground write FBackground; + property FastExport: Boolean read FFastExport write FFastExport; + property PageBreaks: Boolean read FpageBreaks write FPageBreaks; + property EmptyLines: Boolean read FEmptyLines write FEmptyLines; + property SuppressPageHeadersFooters; + end; + + TfrxExcel = class(TObject) + private + FIsOpened: Boolean; + FIsVisible: Boolean; + Excel: Variant; + WorkBook: Variant; + WorkSheet: Variant; + Range: Variant; + function ByteToFrameTypes(Value: Byte): TfrxFrameTypes; + protected + function IntToCoord(X, Y: Integer): String; + function Pos2Str(Pos: Integer): String; + procedure SetVisible(DoShow: Boolean); + procedure ApplyStyles(aRanges:TStrings; Kind:byte;aProgress: TfrxProgress); + procedure ApplyFrame(const RangeCoord:string; aFrame:byte); + procedure SetRowsSize(aRanges: TStrings; Sizes: array of Currency;MainSizeIndex:integer;RowsCount:integer;aProgress: TfrxProgress); + procedure ApplyStyle(const RangeCoord: string; aStyle: integer); + procedure ApplyFormats(aRanges: TStringlist; aProgress: TfrxProgress); + procedure ApplyFormat(const RangeCoord, aFormat: String); + public + constructor Create; + destructor Destroy; override; + procedure MergeCells; + procedure SetCellFrame(Frame: TfrxFrameTypes); + procedure SetRowSize(y: Integer; Size: Extended); + procedure OpenExcel; + procedure SetColSize(x: Integer; Size: Extended); + procedure SetPageMargin(Left, Right, Top, Bottom: Extended; + Orientation: TPrinterOrientation); + procedure SetRange(x, y, dx, dy: Integer); + property Visible: Boolean read FIsVisible write SetVisible; + end; + + +implementation + +uses frxUtils, frxFileUtils, frxRes, frxUnicodeUtils, frxrcExports; + +{$R *.dfm} + +const + Xdivider = 8; + Ydivider = 1.315; + XLMaxHeight = 409; + XLMaxChars = 900; + xlLeft = -4131; + xlRight = -4152; + xlTop = -4160; + xlCenter = -4108 ; + xlBottom = -4107; + xlJustify = -4130 ; + xlThin = 2; + xlHairline = 1; + xlNone = -4142; + xlAutomatic = -4105; + xlInsideHorizontal = 12 ; + xlInsideVertical = 11 ; + xlEdgeBottom = 9 ; + xlEdgeLeft = 7 ; + xlEdgeRight = 10 ; + xlEdgeTop = 8 ; + xlSolid = 1 ; + xlLineStyleNone = -4142; + xlTextWindows = 20 ; + xlNormal = -4143 ; + xlNoChange = 1 ; + xlPageBreakManual = -4135 ; + xlSizeYRound = 0.25; + +{ TfrxXLSExport } + +type + TArrData = array [1..1] of variant; + PArrData = ^TArrData; + PFrameTypes = ^TfrxFrameTypes; + +constructor TfrxXLSExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FMergeCells := True; + FExportPictures := True; + FExportStyles := True; + FWysiwyg := True; + FAsText := False; + FBackground := True; + FFastExport := True; + FPageBreaks := True; + FilterDesc := frxGet(8009); + DefaultExt := frxGet(8010); + FEmptyLines := True; +end; + +class function TfrxXLSExport.GetDescription: String; +begin + Result := frxResources.Get('XlsOLEexport'); +end; + +function TfrxXLSExport.FrameTypesToByte(Value: TfrxFrameTypes): Byte; +begin + Result := PByte(@Value)^ +end; + +function TfrxXLSExport.GetNewIndex(Strings: TStrings; ObjValue: Integer): Integer; +var + L, H, I, C: Integer; +begin + Result:=0; + if Strings.Count > 0 then + begin + L := 0; + H := Strings.Count - 1; + while L <= H do + begin + I := (L + H) shr 1; + C:= Integer(Strings.Objects[I]) - ObjValue; + if C < 0 then + L := I + 1 + else begin + H := I - 1; + if C = 0 then + begin + L := I; + break; + end; + end; + end; + Result := L; + end; +end; + +function TfrxXLSExport.CleanReturns(const Str: WideString): WideString; +var + i: Integer; + s: WideString; +begin + s := Str; + i := Pos(#13, s); + while i > 0 do + begin + if i > 0 then + Delete(s, i, 1); + i := Pos(#13, s); + end; + while Copy(s, Length(s), 1) = #10 do + Delete(s, Length(s), 1); + Result := s; +end; + +{$WARNINGS OFF} +procedure TfrxXLSExport.ExportPage; +var + i, fx, fy, x, y, dx, dy: Integer; + dcol, drow: Extended; + s: WideString; + Vert, Horiz: Integer; + ExlArray: Variant; + obj: TfrxIEMObject; + EStyle: TfrxIEMStyle; + XStyle: Variant; + Pic: TPicture; + PicFormat: Word; + PicData: Cardinal; + PicPalette: HPALETTE; + PicCount: Integer; + PBreakCounter: Integer; + + procedure AlignFR2AlignExcel(HAlign: TfrxHAlign; VAlign: TfrxVAlign; var AlignH, AlignV: integer); + begin + if HAlign = haLeft then + AlignH := xlLeft + else if HAlign = haRight then + AlignH := xlRight + else if HAlign = haCenter then + AlignH := xlCenter + else if HAlign = haBlock then + AlignH := xlJustify + else + AlignH := xlLeft; + + if VAlign = vaTop then + AlignV := xlTop + else if VAlign = vaBottom then + AlignV := xlBottom + else if VAlign = vaCenter then + AlignV := xlCenter + else + AlignV := xlTop; + end; + +begin + PicCount := 0; + FExcel.SetPageMargin(FPageLeft, FPageRight, FPageTop, FPageBottom, FPageOrientation); + + if ShowProgress then + begin + FProgress := TfrxProgress.Create(self); + FProgress.Execute(FMatrix.Height - 1, frxResources.Get('ProgressRows'), True, True); + end; + + PBreakCounter := 0; + for y := 1 to FMatrix.Height - 1 do + begin + if ShowProgress then + begin + if FProgress.Terminated then break; + FProgress.Tick; + end; + drow := (FMatrix.GetYPosById(y) - FMatrix.GetYPosById(y - 1)) / Ydivider; + FExcel.SetRowSize(y, drow); + if (FMatrix.GetCellYPos(y) >= FMatrix.GetPageBreak(PBreakCounter)) and FpageBreaks then + begin + FExcel.WorkSheet.Rows[y + 2].PageBreak := xlPageBreakManual; + Inc(PBreakCounter); + end; + end; + + if ShowProgress then + begin + if not FProgress.Terminated then + FProgress.Execute(FMatrix.Width - 1, frxResources.Get('ProgressColumns'), True, True); + end else; + + for x := 1 to FMatrix.Width - 1 do + begin + if ShowProgress then + begin + if FProgress.Terminated then break; + FProgress.Tick; + end; + dcol := (FMatrix.GetXPosById(x) - FMatrix.GetXPosById(x - 1)) / Xdivider; + FExcel.SetColSize(x, dcol); + end; + + if ShowProgress then + if not FProgress.Terminated then + FProgress.Execute(FMatrix.StylesCount - 1, frxResources.Get('ProgressStyles'), True, True); + + for x := 0 to FMatrix.StylesCount - 1 do + begin + if ShowProgress then + begin + if FProgress.Terminated then break; + FProgress.Tick; + end; + EStyle := FMatrix.GetStyleById(x); + s := 'S' + IntToStr(x); + XStyle := FExcel.Excel.ActiveWorkbook.Styles.Add(s); + XStyle.Font.Bold := fsBold in EStyle.Font.Style; + XStyle.Font.Italic := fsItalic in EStyle.Font.Style; + XStyle.Font.Underline := fsUnderline in EStyle.Font.Style;; + XStyle.Font.Name := EStyle.Font.Name; + XStyle.Font.Size := EStyle.Font.Size; + XStyle.Font.Color:= ColorToRGB(EStyle.Font.Color); + XStyle.Interior.Color := ColorToRGB(EStyle.Color); + AlignFR2AlignExcel(EStyle.HAlign, EStyle.VAlign, Horiz, Vert); + XStyle.VerticalAlignment := Vert; + XStyle.HorizontalAlignment := Horiz; + Application.ProcessMessages; + end; + + ExlArray := VarArrayCreate([0, FMatrix.Height - 1, 0, FMatrix.Width - 1], varOleStr); + + if ShowProgress then + if not FProgress.Terminated then + FProgress.Execute(FMatrix.Height, frxResources.Get('ProgressObjects'), True, True); + + for y := 1 to FMatrix.Height do + begin + if ShowProgress then + begin + if FProgress.Terminated then break; + FProgress.Tick; + end; + for x := 1 to FMatrix.Width do + begin + i := FMatrix.GetCell(x - 1, y - 1); + if i <> -1 then + begin + Obj := FMatrix.GetObjectById(i); + if Obj.Counter = 0 then + begin + Obj.Counter := 1; + FMatrix.GetObjectPos(i, fx, fy, dx, dy); + FExcel.SetRange(x, y, dx, dy); + if Obj.IsText then + begin + if FExportStyles then + FExcel.Range.Style := 'S' + IntToStr(Obj.StyleIndex); + if FMergeCells then + if (dx > 1) or (dy > 1) then + if (dx > 1) or (dy > 1) then + begin + FExcel.SetRange(x, y, dx, dy); + FExcel.MergeCells; + end; + if FExportStyles then + FExcel.SetCellFrame(obj.Style.FrameTyp); + s := CleanReturns(Obj.Memo.Text); + if Length(s) > XLMaxChars then + s := Copy(s, 1, XLMaxChars); + ExlArray[y - 1, x - 1] := s; + end + else + begin + Inc(PicCount); + Pic := TPicture.Create; + Pic.Bitmap.Assign(Obj.Image); + Pic.SaveToClipboardFormat(PicFormat, PicData, PicPalette); + Clipboard.SetAsHandle(PicFormat,THandle(PicData)); + FExcel.Range.PasteSpecial(EmptyParam, EmptyParam, EmptyParam, EmptyParam); + FExcel.WorkSheet.Pictures[PicCount].Width := Pic.Width / 1.38; + FExcel.WorkSheet.Pictures[PicCount].Height := Pic.Height/ 1.38; + Pic.Free; + end; + end; + end; + end; + end; + + FExcel.SetRange(1, 1, FMatrix.Width - 1, FMatrix.Height - 1); + FExcel.Range.Value := ExlArray; + FExcel.WorkSheet.Cells.WrapText := True; + if ShowProgress then + FProgress.Free; +end; +{$WARNINGS ON} + +procedure TfrxXLSExport.ExportPage_Fast; +var + i, fx, fy, x, y, dx, dy: Integer; + dcol, drow: Extended; + s: OLEVariant; + Vert, Horiz: Integer; + ExlArray: Variant; + + obj: TfrxIEMObject; + EStyle: TfrxIEMStyle; + XStyle: Variant; + Pic: TPicture; + PicFormat: Word; + PicData: Cardinal; + PicPalette: HPALETTE; + PicCount: Integer; + PBreakCounter: Integer; + RowSizes: array of Currency; + RowSizesCount: array of Integer; + imc: Integer; + ArrData: PArrData; + j: Integer; + FixRow: String; + CurRowSize: Integer; + CurRangeCoord: String; + vRowsToSizes: TStrings; + vCellStyles: TStrings; + vCellFrames: TStrings; + vCellMerges: TStrings; + vCellFormats: TStringList; + + function ConvertFormat(const fstr: string): string; + var + i, err, p : integer; + s: string; + begin + result := ''; + if length(fstr)>0 then + begin + p := pos('.', fstr); + if p > 0 then + begin + s := Copy(fstr, p + 1, length(fstr) - p - 1); + val(s, p ,err); + end; + case fstr[length(fstr)] of + 'n': begin + result := '# ##0' + DecimalSeparator; + for i := 1 to p do result := result + '0'; + end; + 'f': begin + result := '0' + DecimalSeparator; + for i := 1 to p do result := result + '0'; + end; + 'd': begin + result := '#' + DecimalSeparator; + for i := 1 to p do result := result + '#'; + end; + end; + end; + end; + + procedure AlignFR2AlignExcel(HAlign: TfrxHAlign; VAlign: TfrxVAlign; var AlignH, AlignV: integer); + begin + if HAlign = haLeft then + AlignH := xlLeft + else if HAlign = haRight then + AlignH := xlRight + else if HAlign = haCenter then + AlignH := xlCenter + else if HAlign = haBlock then + AlignH := xlJustify + else + AlignH := xlLeft; + + if VAlign = vaTop then + AlignV := xlTop + else if VAlign = vaBottom then + AlignV := xlBottom + else if VAlign = vaCenter then + AlignV := xlCenter + else + AlignV := xlTop; + end; + + function RoundSizeY(const Value: Extended; xlSizeYRound: Currency): Currency; + begin + Result := Round(Value / xlSizeYRound) * xlSizeYRound + end; + + function GetSizeIndex(const aSize: Currency): integer; + var + i: integer; + c: integer; + begin + c := Length(RowSizes); + for i := 0 to c - 1 do + begin + if RowSizes[i] = aSize then + begin + Result := i; + RowSizesCount[i] := RowSizesCount[i] + 1; + Exit + end; + end; + SetLength(RowSizes, c + 1); + SetLength(RowSizesCount,c + 1); + RowSizes[c] := aSize; + RowSizesCount[c] := 1; + Result := c + end; + +begin + PicCount := 0; + FExcel.SetPageMargin(FPageLeft, FPageRight, FPageTop, FPageBottom, FPageOrientation); + + if ShowProgress then + begin + FProgress := TfrxProgress.Create(self); + FProgress.Execute(FMatrix.Height - 1, frxResources.Get('ProgressRows') + ' - 1', True, True); + end; + + PBreakCounter := 0; + + FixRow := 'A1'; + CurRowSize := 0; + vRowsToSizes := TStringList.Create; + try + vRowsToSizes.Capacity := FMatrix.Height; + imc := 0; + for y := 1 to FMatrix.Height - 1 do + begin + if ShowProgress then + begin + if FProgress.Terminated then + break; + FProgress.Tick; + end; + + if (FMatrix.GetCellYPos(y) >= FMatrix.GetPageBreak(PBreakCounter)) and FpageBreaks then + begin + FExcel.WorkSheet.Rows[y + 2].PageBreak := xlPageBreakManual; + Inc(PBreakCounter); + end; + + drow := (FMatrix.GetYPosById(y) - FMatrix.GetYPosById(y - 1)) / Ydivider; + j := GetSizeIndex(RoundSizeY(drow, xlSizeYRound)); + if RowSizesCount[j] > RowSizesCount[imc] then + imc := j; + if y > 1 then + begin + if j <> CurRowSize then + begin + if FixRow <> 'A' + IntToStr(y - 1) then + CurRangeCoord := FixRow + ':A' + IntToStr(y - 1) + else + CurRangeCoord := FixRow; + i := GetNewIndex(vRowsToSizes, CurRowSize); + vRowsToSizes.InsertObject(i, CurRangeCoord, TObject(CurRowSize)); + FixRow := 'A' + IntToStr(y); + CurRowSize := j; + end; + end; + if y = FMatrix.Height - 1 then + begin + CurRangeCoord := FixRow + ':A' + IntToStr(y); + i := GetNewIndex(vRowsToSizes, j); + vRowsToSizes.InsertObject(i, CurRangeCoord, TObject(j)); + end; + end; + FExcel.SetRowsSize(vRowsToSizes, RowSizes, imc, FMatrix.Height, FProgress) + finally + vRowsToSizes.Free; + end; + + if ShowProgress then + if not FProgress.Terminated then + FProgress.Execute(FMatrix.Width - 1, frxResources.Get('ProgressColumns'), True, True); + + for x := 1 to FMatrix.Width - 1 do + begin + if ShowProgress then + begin + if FProgress.Terminated then + break; + FProgress.Tick; + end; + dcol := (FMatrix.GetXPosById(x) - FMatrix.GetXPosById(x - 1)) / Xdivider; + FExcel.SetColSize(x, dcol); + end; + + if ShowProgress then + if not FProgress.Terminated then + FProgress.Execute(FMatrix.StylesCount - 1, frxResources.Get('ProgressStyles'), True, True); + + for x := 0 to FMatrix.StylesCount - 1 do + begin + if ShowProgress then + begin + if FProgress.Terminated then break; + FProgress.Tick; + end; + EStyle := FMatrix.GetStyleById(x); + s := 'S' + IntToStr(x); + XStyle := FExcel.Excel.ActiveWorkbook.Styles.Add(s); + XStyle.Font.Bold := fsBold in EStyle.Font.Style; + XStyle.Font.Italic := fsItalic in EStyle.Font.Style; + XStyle.Font.Underline := fsUnderline in EStyle.Font.Style;; + XStyle.Font.Name := EStyle.Font.Name; + XStyle.Font.Size := EStyle.Font.Size; + XStyle.Font.Color:= ColorToRGB(EStyle.Font.Color); + XStyle.Interior.Color := ColorToRGB(EStyle.Color); + if (EStyle.Rotation > 0) and (EStyle.Rotation <= 90) then + XStyle.Orientation := EStyle.Rotation + else + if (EStyle.Rotation < 360) and (EStyle.Rotation >= 270) then + XStyle.Orientation := EStyle.Rotation - 360; + + AlignFR2AlignExcel(EStyle.HAlign, EStyle.VAlign, Horiz, Vert); + XStyle.VerticalAlignment := Vert; + XStyle.HorizontalAlignment := Horiz; + Application.ProcessMessages; + end; + ExlArray := VarArrayCreate([1, FMatrix.Height , 1, FMatrix.Width ], varVariant); + if ShowProgress then + if not FProgress.Terminated then + FProgress.Execute(FMatrix.Height, frxResources.Get('ProgressObjects'), True, True); + ArrData := VarArrayLock(ExlArray) ; + vCellStyles := TStringList.Create; + vCellFrames := TStringList.Create; + vCellMerges := TStringList.Create; + vCellFormats := TStringList.Create; + try + for y := 1 to FMatrix.Height do + begin + if ShowProgress then + begin + if FProgress.Terminated then + Break; + FProgress.Tick; + end; + for x := 1 to FMatrix.Width do + begin + i := FMatrix.GetCell(x - 1, y - 1); + if i <> -1 then + begin + Obj := FMatrix.GetObjectById(i); + if Obj.Counter = 0 then + begin + Obj.Counter := 1; + FMatrix.GetObjectPos(i, fx, fy, dx, dy); + with FExcel do + if (dx > 1) or (dy > 1) then + CurRangeCoord := IntToCoord(x, y)+ ':' + + IntToCoord(x + dx - 1, y + dy - 1) + else + CurRangeCoord := IntToCoord(x, y); + if FExportStyles then + begin + j := GetNewIndex(vCellStyles, Obj.StyleIndex); + vCellStyles.InsertObject(j, CurRangeCoord, TObject(Obj.StyleIndex)); + end; + + if FMergeCells then + if (dx > 1) or (dy > 1) then + vCellMerges.Add(CurRangeCoord); + if FExportStyles then + begin + i := FrameTypesToByte(obj.Style.FrameTyp); + if i <> 0 then + begin + j := GetNewIndex(vCellFrames, i); + vCellFrames.InsertObject(j, CurRangeCoord, TObject(i)); + end; + end; + + s := CleanReturns(Obj.Memo.Text); + if Length(s) > XLMaxChars then + s := Copy(s, 1, XLMaxChars); + + if not FAsText then + if (Obj.Style.DisplayFormat.Kind = fkNumeric) then + begin + if length(s) > 0 then + begin + s := StringReplace(s, ThousandSeparator, '', [rfReplaceAll]); + if Obj.Style.DisplayFormat.DecimalSeparator <> '' then + s := StringReplace(s, Obj.Style.DisplayFormat.DecimalSeparator, '.', [rfReplaceAll]) + else + s := StringReplace(s, DecimalSeparator, '.', [rfReplaceAll]); + if (Obj.Style.DisplayFormat.FormatStr <> '') then + vCellFormats.Add(ConVertFormat(Obj.Style.DisplayFormat.FormatStr) + + '=' + FExcel.IntToCoord(x, y)) + end + end + else + if (Obj.Style.DisplayFormat.Kind = fkText) then + s := '''' + s; + + if FAsText then + s := '''' + s; + ArrData^[y + FMatrix.Height * (x - 1)] := s; + if (not Obj.IsText) and (Obj.Image <> nil) then + begin + FExcel.SetRange(x, y, dx, dy); + Inc(PicCount); + Pic := TPicture.Create; + Pic.Bitmap.Assign(Obj.Image); + Pic.SaveToClipboardFormat(PicFormat, PicData, PicPalette); + Clipboard.SetAsHandle(PicFormat,THandle(PicData)); + FExcel.Range.PasteSpecial(EmptyParam, EmptyParam, EmptyParam, EmptyParam); + FExcel.WorkSheet.Pictures[PicCount].Left := FExcel.WorkSheet.Pictures[PicCount].Left + 1; + FExcel.WorkSheet.Pictures[PicCount].Top := FExcel.WorkSheet.Pictures[PicCount].Top + 1; + FExcel.WorkSheet.Pictures[PicCount].Width := Pic.Width / 1.38; + FExcel.WorkSheet.Pictures[PicCount].Height := Pic.Height/ 1.38; + Pic.Free; + end; + end; + end; + end; + end; + + if FExportStyles then + begin + FExcel.ApplyStyles(vCellStyles, 0, FProgress); + FExcel.ApplyStyles(vCellFrames, 1, FProgress); + FExcel.ApplyFormats(vCellFormats, FProgress); + end; + if FMergeCells then + FExcel.ApplyStyles(vCellMerges, 2, FProgress); + finally + VarArrayUnlock(ExlArray); + vCellStyles.Free; + vCellFrames.Free; + vCellMerges.Free; + vCellFormats.Free; + end; + FExcel.SetRange(1, 1, FMatrix.Width , FMatrix.Height); + FExcel.Range.Value := ExlArray; + FExcel.WorkSheet.Cells.WrapText := True; + if ShowProgress then + FProgress.Free; +end; + +function TfrxXLSExport.ShowModal: TModalResult; +begin + with TfrxXLSExportDialog.Create(nil) do + begin + OpenExcelCB.Visible := not SlaveExport; + if SlaveExport then + FOpenExcelAfterExport := False; + + if (FileName = '') and (not SlaveExport) then + SaveDialog1.FileName := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), SaveDialog1.DefaultExt) + else + SaveDialog1.FileName := FileName; + + ContinuousCB.Checked := (not EmptyLines) or SuppressPageHeadersFooters; + PicturesCB.Checked := FExportPictures; + MergeCB.Checked := FMergeCells; + WCB.Checked := FWysiwyg; + OpenExcelCB.Checked := FOpenExcelAfterExport; + AsTextCB.Checked := FAsText; + BackgrCB.Checked := FBackground; + FastExpCB.Checked := FFastExport; + PageBreaksCB.Checked := FpageBreaks; + + if PageNumbers <> '' then + begin + PageNumbersE.Text := PageNumbers; + PageNumbersRB.Checked := True; + end; + + Result := ShowModal; + if Result = mrOk then + begin + PageNumbers := ''; + CurPage := False; + if CurPageRB.Checked then + CurPage := True + else if PageNumbersRB.Checked then + PageNumbers := PageNumbersE.Text; + + FMergeCells := MergeCB.Checked; + FPageBreaks := PageBreaksCB.Checked; + FExportPictures := PicturesCB.Checked; + EmptyLines := not ContinuousCB.Checked; + SuppressPageHeadersFooters := ContinuousCB.Checked; + FWysiwyg := WCB.Checked; + FOpenExcelAfterExport := OpenExcelCB.Checked; + FAsText := AsTextCB.Checked; + FBackground := BackgrCB.Checked; + FFastExport := FastExpCB.Checked; + + if not SlaveExport then + begin + if DefaultPath <> '' then + SaveDialog1.InitialDir := DefaultPath; + if SaveDialog1.Execute then + FileName := SaveDialog1.FileName + else + Result := mrCancel; + end + else + FileName := ChangeFileExt(GetTempFile, SaveDialog1.DefaultExt); + end; + Free; + end; +end; + +function TfrxXLSExport.Start: Boolean; +begin + if FileName <> '' then + begin + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + if DefaultPath[Length(DefaultPath)] = '\' then + FileName := DefaultPath + FileName + else + FileName := DefaultPath + '\' + FileName; + FFirstPage := True; + FMatrix := TfrxIEMatrix.Create(UseFileCache, Report.EngineOptions.TempDir); + FMatrix.ShowProgress := ShowProgress; + FMatrix.MaxCellHeight := XLMaxHeight * Ydivider; + FMatrix.BackgroundImage := False; + FMatrix.Background := FBackground and FEmptyLines; + FMatrix.RichText := True; + FMatrix.PlainRich := True; + if FWysiwyg then + FMatrix.Inaccuracy := 0.5 + else + FMatrix.Inaccuracy := 10; + FMatrix.RotatedAsImage := False; + FMatrix.DeleteHTMLTags := True; + FMatrix.Printable := ExportNotPrintable; + FMatrix.EmptyLines := FEmptyLines; + FExcel := TfrxExcel.Create; + FExcel.OpenExcel; + Result := True; + end + else + Result := False; +end; + +procedure TfrxXLSExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + if FFirstPage then + begin + FFirstPage := False; + FPageLeft := Page.LeftMargin * 2.6; + FPageTop := Page.TopMargin * 2.6; + FPageBottom := Page.BottomMargin * 2.6; + FPageRight := Page.RightMargin * 2.6; + FPageOrientation := Page.Orientation; + end; +end; + +procedure TfrxXLSExport.ExportObject(Obj: TfrxComponent); +begin + if (Obj is TfrxView) and (ExportNotPrintable or TfrxView(Obj).Printable) then + if (Obj is TfrxCustomMemoView) or + (FExportPictures and (not (Obj is TfrxCustomMemoView))) then + FMatrix.AddObject(TfrxView(Obj)); +end; + +procedure TfrxXLSExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + FMatrix.AddPage(Page.Orientation, Page.Width, Page.Height, Page.LeftMargin, + Page.TopMargin, Page.RightMargin, Page.BottomMargin); +end; + +procedure TfrxXLSExport.Finish; + +begin + FMatrix.Prepare; + try + if FFastExport then + ExportPage_Fast + else + ExportPage; + + FExcel.SetRange(1, 1, 1, 1); + FExcel.Range.Select; + if FOpenExcelAfterExport then + FExcel.Visible := True; + finally + try + try + if ExtractFilePath(FileName) = '' then + FileName := GetCurrentDir + '\' + FileName; + FExcel.WorkBook.SaveAs(FileName, xlNormal, EmptyParam, + EmptyParam, EmptyParam, EmptyParam, xlNoChange, EmptyParam, EmptyParam, EmptyParam); + finally + FExcel.Excel.Application.DisplayAlerts := True; + FExcel.Excel.Application.ScreenUpdating := True; + end; + if not FOpenExcelAfterExport then + begin + FExcel.Excel.Quit; + FExcel.Excel := Null; + FExcel.Excel := Unassigned; + end; + except + end; + end; + FMatrix.Free; + FExcel.Free; +end; + + +{ TfrxExcel } + +constructor TfrxExcel.Create; +begin + inherited Create; + FIsOpened := False; + FIsVisible := False; + OleInitialize(nil); +end; + +function TfrxExcel.Pos2Str(Pos: Integer): String; +var + i, j: Integer; +begin + if Pos > 26 then + begin + i := Pos mod 26; + j := Pos div 26; + if i = 0 then + Result := Chr(64 + j - 1) + else + Result := Chr(64 + j); + if i = 0 then + Result := Result + chr(90) + else + Result := Result + Chr(64 + i); + end + else + Result := Chr(64 + Pos); +end; + +procedure TfrxExcel.SetVisible(DoShow: Boolean); +begin + if not FIsOpened then Exit; + if DoShow then + Excel.Visible := True + else + Excel.Visible := False; +end; + +function TfrxExcel.IntToCoord(X, Y: Integer): String; +begin + Result := Pos2Str(X) + IntToStr(Y); +end; + +procedure TfrxExcel.SetColSize(x: Integer; Size: Extended); +var + r: Variant; +begin + if (Size > 0) and (Size < 256) and (x < 256) then + begin + try + r := WorkSheet.Columns; + r.Columns[x].ColumnWidth := Size; + except + end; + end; +end; + +procedure TfrxExcel.SetRowSize(y: Integer; Size: Extended); +var + r: Variant; +begin + if Size > 0 then + begin + r := WorkSheet.Rows; + if size > 409 then + size := 409; + r.Rows[y].RowHeight := Size; + end; +end; + +procedure TfrxExcel.MergeCells; +begin + Range.MergeCells := True; +end; + +procedure TfrxExcel.OpenExcel; +begin + try + Excel := CreateOLEObject('Excel.Application'); + Excel.Application.ScreenUpdating := False; + Excel.Application.DisplayAlerts := False; + WorkBook := Excel.WorkBooks.Add; + WorkSheet := WorkBook.WorkSheets[1]; + FIsOpened := True; + except + FIsOpened := False; + end; +end; + +procedure TfrxExcel.SetPageMargin(Left, Right, Top, Bottom: Extended; + Orientation: TPrinterOrientation); +var + Orient: Integer; +begin + if Orientation = poLandscape then + Orient := 2 + else + Orient := 1; + try + Excel.ActiveSheet.PageSetup.LeftMargin := Left; + Excel.ActiveSheet.PageSetup.RightMargin := Right; + Excel.ActiveSheet.PageSetup.TopMargin := Top; + Excel.ActiveSheet.PageSetup.BottomMargin := Bottom; + Worksheet.PageSetup.Orientation := Orient; + except + end; +end; + +procedure TfrxExcel.SetRange(x, y, dx, dy: Integer); +begin + try + if x > 255 then + x := 255; + if (x + dx) > 255 then + dx := 255 - x; + if (dx > 0) and (dy > 0) then + Range := WorkSheet.Range[IntToCoord(x, y), IntToCoord(x + dx - 1, y + dy - 1)]; + except + end; +end; + +procedure TfrxExcel.SetRowsSize(aRanges: TStrings; + Sizes: array of Currency; MainSizeIndex: integer; + RowsCount:integer; aProgress: TfrxProgress); +var + i: integer; + s: string; + curSizes: integer; + v: Variant; +begin + if aRanges.Count > 0 then + begin + + if Assigned(aProgress) then + if not aProgress.Terminated then + begin + s := frxResources.Get('ProgressRows') + ' - 2'; + aProgress.Execute(aRanges.Count, s, True, True); + end; + + WorkSheet.Range['A1:A' + IntToStr(RowsCount)].RowHeight := Sizes[MainSizeIndex]; + s := aRanges[0]; + curSizes := Integer(aRanges.Objects[0]); + + for i := 1 to Pred(aRanges.Count) do + begin + + if Assigned(aProgress) then + begin + if aProgress.Terminated then + Break; + aProgress.Tick; + end; + + if Integer(aRanges.Objects[i]) = MainSizeIndex then + Continue; + if Integer(aRanges.Objects[i]) <> curSizes then + begin + if curSizes <> MainSizeIndex then + begin + try + v := WorkSheet.Range[s]; + v.RowHeight := Sizes[curSizes]; + except + end; + end; + curSizes := Integer(aRanges.Objects[i]); + s := aRanges[i]; + end + else if Length(s) + Length(aRanges[i]) + 1 > 255 then + begin + try + v := WorkSheet.Range[s]; + v.RowHeight := Sizes[curSizes]; + except + end; + s := aRanges[i]; + end + else s := s + ';' + aRanges[i] + end; + + if Length(s) > 0 then + begin + try + v := WorkSheet.Range[s].Rows; + v.RowHeight := Sizes[curSizes]; + except + end; + end; + + end; +end; + +procedure TfrxExcel.ApplyStyles(aRanges: TStrings; Kind: byte; aProgress: TfrxProgress); +// Kind=0 - Styles +// Kind=1 - Frames +// Kind=2 - Merge +var + i: integer; + s: string; + curStyle: integer; +begin + if aRanges.Count > 0 then + begin + if Assigned(aProgress) then + if not aProgress.Terminated then + aProgress.Execute(aRanges.Count, frxResources.Get('ProgressStyles') + ' - ' + IntToStr(Kind + 1), True, True); + + s := aRanges[0]; + curStyle := Integer(aRanges.Objects[0]); + for i := 1 to Pred(aRanges.Count) do + begin + if Assigned(aProgress) then + begin + if aProgress.Terminated then + Break; + aProgress.Tick; + end; + if Integer(aRanges.Objects[i]) <> CurStyle then + begin + case Kind of + 0: ApplyStyle(s, CurStyle); + 1: ApplyFrame(s, CurStyle); + end; + CurStyle := Integer(aRanges.Objects[i]); + s := aRanges[i]; + end + else if Length(s) + Length(aRanges[i]) + 1 > 255 then + begin + case Kind of + 0: ApplyStyle(s, CurStyle); + 1: ApplyFrame(s, CurStyle); + 2: try + WorkSheet.Range[s].MergeCells := True; + except + end; + end; + s := aRanges[i]; + end + else s := s + ListSeparator + aRanges[i] + end; + case Kind of + 0: ApplyStyle(s, CurStyle); + 1: ApplyFrame(s, CurStyle); + 2: try + WorkSheet.Range[s].MergeCells := True; + except + end; + end; + end; +end; + +procedure TfrxExcel.ApplyStyle(const RangeCoord: String; aStyle: Integer); +begin + try + if Length(RangeCoord) > 0 then + WorkSheet.Range[RangeCoord].Style := 'S' + IntToStr(aStyle) + except + end; +end; + +function TfrxExcel.ByteToFrameTypes(Value: Byte): TfrxFrameTypes; +begin + Result := PFrameTypes(@Value)^ +end; + +procedure TfrxExcel.ApplyFrame(const RangeCoord: String; aFrame: Byte); +var + vFrame: TfrxFrameTypes; + vBorders: Variant; +begin + try + if aFrame <> 0 then + if Length(RangeCoord) > 0 then + begin + vFrame := ByteToFrameTypes(aFrame); + vBorders := WorkSheet.Range[RangeCoord].Cells.Borders; + if ftLeft in vFrame then + vBorders.Item[xlEdgeLeft].Linestyle := xlSolid; + if ftRight in vFrame then + vBorders.Item[xlEdgeRight].Linestyle := xlSolid; + if ftTop in vFrame then + vBorders.Item[xlEdgeTop].Linestyle := xlSolid; + if ftBottom in vFrame then + vBorders.Item[xlEdgeBottom].Linestyle := xlSolid; + end; + except + end; +end; + +procedure TfrxExcel.SetCellFrame(Frame: TfrxFrameTypes); +begin + if ftLeft in Frame then + Range.Cells.Borders.Item[xlEdgeLeft].Linestyle := xlSolid; + if ftRight in Frame then + Range.Cells.Borders.Item[xlEdgeRight].Linestyle := xlSolid; + if ftTop in Frame then + Range.Borders.Item[xlEdgeTop].Linestyle := xlSolid; + if ftBottom in Frame then + Range.Borders.Item[xlEdgeBottom].Linestyle := xlSolid; +end; + +procedure TfrxExcel.ApplyFormats(aRanges: TStringlist; aProgress: TfrxProgress); +var + i: integer; + s: string; + curFormat: string; + + function ValueFrom(List: TStringList; Index: Integer): String; + begin + if Index >= 0 then + Result := Copy(List[Index], Length(List.Names[Index]) + 2, MaxInt) else + Result := ''; + end; + +begin + if aRanges.Count > 0 then + begin + if Assigned(aProgress) then + aProgress.Execute(aRanges.Count, 'Data formats', True, True); + s := ValueFrom(aRanges, 0); + curFormat := aRanges.Names[0]; + for i := 1 to Pred(aRanges.Count) do + begin + if Assigned(aProgress) then + begin + if aProgress.Terminated then + Break; + aProgress.Tick; + end; + if aRanges.Names[i] <> CurFormat then + begin + ApplyFormat(s, CurFormat); + CurFormat := aRanges.Names[i]; + s := ValueFrom(aRanges, i); + end + else + if Length(s) + Length(ValueFrom(aRanges, i)) + 1 > 255 then + begin + ApplyFormat(s, CurFormat); + s := ValueFrom(aRanges, i); + end + else + s := s + ListSeparator + ValueFrom(aRanges, i) + end; + ApplyFormat(s, CurFormat); + end; +end; + +procedure TfrxExcel.ApplyFormat(const RangeCoord, aFormat: String); +begin + if Length(RangeCoord) > 0 then + try + WorkSheet.Range[RangeCoord].NumberFormat := aFormat; + except + end; +end; + +destructor TfrxExcel.Destroy; +begin + OleUnInitialize; + inherited; +end; + +{ TfrxXLSExportDialog } + +procedure TfrxXLSExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8000); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + GroupPageRange.Caption := frxGet(7); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + DescrL.Caption := frxGet(9); + GroupQuality.Caption := frxGet(8); + ContinuousCB.Caption := frxGet(8950); + PicturesCB.Caption := frxGet(8002); + MergeCB.Caption := frxGet(8003); + PageBreaksCB.Caption := frxGet(6); + FastExpCB.Caption := frxGet(8004); + WCB.Caption := frxGet(8005); + AsTextCB.Caption := frxGet(8006); + BackgrCB.Caption := frxGet(8007); + OpenExcelCB.Caption := frxGet(8008); + SaveDialog1.Filter := frxGet(8009); + SaveDialog1.DefaultExt := frxGet(8010); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxXLSExportDialog.PageNumbersEChange(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxXLSExportDialog.PageNumbersEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8, '-', ',':; + else + key := #0; + end; +end; + +procedure TfrxXLSExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + diff --git a/official/4.2/LibD11/frxExportXML.dfm b/official/4.2/LibD11/frxExportXML.dfm new file mode 100644 index 0000000..1d5eedd Binary files /dev/null and b/official/4.2/LibD11/frxExportXML.dfm differ diff --git a/official/4.2/LibD11/frxExportXML.pas b/official/4.2/LibD11/frxExportXML.pas new file mode 100644 index 0000000..cbe4e13 --- /dev/null +++ b/official/4.2/LibD11/frxExportXML.pas @@ -0,0 +1,669 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ XML Excel export } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} +{ Improved by Bysoev Alexander } +{ Kanal-B@Yandex.ru } +{******************************************} + +unit frxExportXML; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, extctrls, Printers, ComObj, frxClass, frxExportMatrix, frxProgress +{$IFDEF Delphi6}, Variants {$ENDIF}; + +type + TfrxXMLExportDialog = class(TForm) + OkB: TButton; + CancelB: TButton; + SaveDialog1: TSaveDialog; + GroupPageRange: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + GroupQuality: TGroupBox; + WCB: TCheckBox; + ContinuousCB: TCheckBox; + PageBreaksCB: TCheckBox; + OpenExcelCB: TCheckBox; + BackgrCB: TCheckBox; + procedure FormCreate(Sender: TObject); + procedure PageNumbersEChange(Sender: TObject); + procedure PageNumbersEKeyPress(Sender: TObject; var Key: Char); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + end; + + TfrxXMLExport = class(TfrxCustomExportFilter) + private + FExportPageBreaks: Boolean; + FExportStyles: Boolean; + FFirstPage: Boolean; + FMatrix: TfrxIEMatrix; + FOpenExcelAfterExport: Boolean; + FPageBottom: Extended; + FPageLeft: Extended; + FPageRight: Extended; + FPageTop: Extended; + FPageOrientation: TPrinterOrientation; + FProgress: TfrxProgress; + FShowProgress: Boolean; + FWysiwyg: Boolean; + FBackground: Boolean; + FCreator: String; + FEmptyLines: Boolean; + procedure ExportPage(Stream: TStream); + function ChangeReturns(const Str: String): String; + function TruncReturns(const Str: WideString): WideString; + public + constructor Create(AOwner: TComponent); override; + class function GetDescription: String; override; + function ShowModal: TModalResult; override; + function Start: Boolean; override; + procedure Finish; override; + procedure FinishPage(Page: TfrxReportPage; Index: Integer); override; + procedure StartPage(Page: TfrxReportPage; Index: Integer); override; + procedure ExportObject(Obj: TfrxComponent); override; + published + property ExportStyles: Boolean read FExportStyles write FExportStyles default True; + property ExportPageBreaks: Boolean read FExportPageBreaks write FExportPageBreaks default True; + property OpenExcelAfterExport: Boolean read FOpenExcelAfterExport + write FOpenExcelAfterExport default False; + property ShowProgress: Boolean read FShowProgress write FShowProgress; + property Wysiwyg: Boolean read FWysiwyg write FWysiwyg default True; + property Background: Boolean read FBackground write FBackground default False; + property Creator: String read FCreator write FCreator; + property EmptyLines: Boolean read FEmptyLines write FEmptyLines; + property SuppressPageHeadersFooters; + end; + + +implementation + +uses frxUtils, frxFileUtils, frxUnicodeUtils, frxRes, frxrcExports; + +{$R *.dfm} + +const + Xdivider = 1.376; + Ydivider = 1.376; + MargDiv = 26.6; + XLMaxHeight = 409; + + +{ TfrxXMLExport } + +constructor TfrxXMLExport.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + FExportPageBreaks := True; + FExportStyles := True; + FShowProgress := True; + FWysiwyg := True; + FBackground := True; + FCreator := 'FastReport'; + FilterDesc := frxGet(8105); + DefaultExt := frxGet(8106); + FEmptyLines := True; +end; + +class function TfrxXMLExport.GetDescription: String; +begin + Result := frxResources.Get('XlsXMLexport'); +end; + +function TfrxXMLExport.TruncReturns(const Str: WideString): WideString; +begin + Result := Str; + if Copy(Result, Length(Result) - 1, 2) = #13#10 then + Delete(Result, Length(Result) - 1, 2); +end; + +function TfrxXMLExport.ChangeReturns(const Str: String): String; +var + i: Integer; +begin + Result := ''; + for i := 1 to Length(Str) do + begin + if Str[i] = '&' then + Result := Result + '&' + else if (i < Length(Str)) and (Str[i] = #13) and (Str[i + 1] = #10) then + Result := Result + ' ' + else if Str[i] = '"' then + Result := Result + '"' + else if Str[i] = '<' then + Result := Result + '<' + else if Str[i] = '>' then + Result := Result + '>' + else if (Str[i] <> #10) then + Result := Result + Str[i] + end; +end; + +procedure TfrxXMLExport.ExportPage(Stream: TStream); +var + i, x, y, dx, dy, fx, fy, Page: Integer; + s: WideString; + sb, si, su: String; + dcol, drow: Extended; + Vert, Horiz: String; + obj: TfrxIEMObject; + EStyle: TfrxIEMStyle; + St: String; + PageBreak: TStringList; + + function IsDigits(const Str: String): Boolean; + var + i: Integer; + begin + Result := True; + for i := 1 to Length(Str) do + if not((AnsiChar(Str[i]) in ['0'..'9', ',' ,'.' ,'-', ' ', '']) or (Ord(Str[i]) = 160)) then + begin + Result := False; + break; + end; + end; + + procedure WriteExpLn(const str: String); + begin + if Length(str) > 0 then + Stream.Write(str[1], Length(str)); + Stream.Write(#13#10, 2); + end; + + procedure AlignFR2AlignExcel(HAlign: TfrxHAlign; VAlign: TfrxVAlign; + var AlignH, AlignV: String); + begin + if HAlign = haLeft then + AlignH := 'Left' + else if HAlign = haRight then + AlignH := 'Right' + else if HAlign = haCenter then + AlignH := 'Center' + else if HAlign = haBlock then + AlignH := 'Justify' + else + AlignH := ''; + if VAlign = vaTop then + AlignV := 'Top' + else if VAlign = vaBottom then + AlignV := 'Bottom' + else if VAlign = vaCenter then + AlignV := 'Center' + else + AlignV := ''; + end; + + function ConvertFormat(const fstr: string): string; + var + err, p : integer; + s: string; + begin + result := ''; + s := ''; + if length(fstr)>0 then + begin + p := pos('.', fstr); + if p > 0 then + begin + s := Copy(fstr, p+1, length(fstr)-p-1); + val(s, p ,err); + SetLength(s, p); + if p>0 then + begin + FillChar(s[1], p, '0'); + s:='.' + s; + end; + end; + case fstr[length(fstr)] of + 'n': result := '#,##0' + s; + 'f': result := '0' + s; + 'g': result := '0.##'; + 'm': result := '#,##0.00'; +// 'm': result := '#,##0.00".;"'; + else + result := '#,##0.00'; + end; + end; + end; + +begin + PageBreak := TStringList.Create; + + try + if FShowProgress then + begin + FProgress := TfrxProgress.Create(nil); + FProgress.Execute(FMatrix.PagesCount, 'Exporting pages', True, True); + end; + + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn('' + UTF8Encode(Report.ReportOptions.Name) + ''); + WriteExpLn('' + UTF8Encode(Report.ReportOptions.Author) + ''); + WriteExpLn('' + DateToStr(Date) + 'T' + TimeToStr(Time) + 'Z'); + WriteExpLn('' + UTF8Encode(Report.ReportOptions.VersionMajor) + '.' + + UTF8Encode(Report.ReportOptions.VersionMinor) + '.' + + UTF8Encode(Report.ReportOptions.VersionRelease) + '.' + + UTF8Encode(Report.ReportOptions.VersionBuild) + ''); + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn('False'); + WriteExpLn('False'); + WriteExpLn(''); + if FExportStyles then + begin + WriteExpLn(''); + for x := 0 to FMatrix.StylesCount - 1 do + begin + EStyle := FMatrix.GetStyleById(x); + s := 's' + IntToStr(x); + WriteExpLn(''); + end; + WriteExpLn(''); + end; + + s := 'Page 1'; + WriteExpLn(''); + WriteExpLn(''); + for x := 1 to FMatrix.Width - 1 do + begin + dcol := (FMatrix.GetXPosById(x) - FMatrix.GetXPosById(x - 1)) / Xdivider; + WriteExpLn(''); + end; + st := ''; + Page := 0; + + for y := 0 to FMatrix.Height - 2 do + begin + drow := (FMatrix.GetYPosById(y + 1) - FMatrix.GetYPosById(y)) / Ydivider; + WriteExpLn(''); + if FMatrix.PagesCount > Page then + if FMatrix.GetYPosById(y) >= FMatrix.GetPageBreak(Page) then + begin + Inc(Page); + PageBreak.Add(IntToStr(y + 1)); + if FShowProgress then + begin + FProgress.Tick; + if FProgress.Terminated then + break; + end; + end; + for x := 0 to FMatrix.Width - 1 do + begin + if FShowProgress then + if FProgress.Terminated then + break; + si := ' ss:Index="' + IntToStr(x + 1) + '" '; + i := FMatrix.GetCell(x, y); + if (i <> -1) then + begin + Obj := FMatrix.GetObjectById(i); + if Obj.Counter = 0 then + begin + FMatrix.GetObjectPos(i, fx, fy, dx, dy); + Obj.Counter := 1; + if Obj.IsText then + begin + if dx > 1 then + begin + s := 'ss:MergeAcross="' + IntToStr(dx - 1) + '" '; + Inc(dx); + end + else + s := ''; + if dy > 1 then + sb := 'ss:MergeDown="' + IntToStr(dy - 1) + '" ' + else + sb := ''; + if FExportStyles then + st := 'ss:StyleID="' + 's' + IntToStr(Obj.StyleIndex) + '" ' + else + st := ''; + WriteExpLn(''); + + s := TruncReturns(Obj.Memo.Text); + if (Obj.Style.DisplayFormat.Kind = fkNumeric) and IsDigits(s) then + begin + s := StringReplace(s, ThousandSeparator, '', [rfReplaceAll]); + s := StringReplace(s, CurrencyString, '', [rfReplaceAll]); + if Obj.Style.DisplayFormat.DecimalSeparator <> '' then + s := StringReplace(s, Obj.Style.DisplayFormat.DecimalSeparator, '.', [rfReplaceAll]) + else + s := StringReplace(s, DecimalSeparator, '.', [rfReplaceAll]); + s := Trim(s); + si := ' ss:Type="Number"'; + WriteExpLn('' + UTF8Encode(s) + ''); + end + else + begin + si := ' ss:Type="String"'; + s := ChangeReturns(UTF8Encode(s)); + WriteExpLn('' + s + ''); + end; + WriteExpLn(''); + end; + end + end + else + WriteExpLn(''); + end; + WriteExpLn(''); + end; + + WriteExpLn('
'); + WriteExpLn(''); + WriteExpLn(''); + if FPageOrientation = poLandscape then + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + WriteExpLn(''); + + if FExportPageBreaks then + begin + WriteExpLn(''); + WriteExpLn(''); + for i := 0 to FMatrix.PagesCount - 2 do + begin + WriteExpLn(''); + WriteExpLn('' + PageBreak[i] + ''); + WriteExpLn(''); + end; + WriteExpLn(''); + WriteExpLn(''); + end; + WriteExpLn('
'); + WriteExpLn('
'); + finally + PageBreak.Free; + end; + if FShowProgress then + FProgress.Free; +end; + +function TfrxXMLExport.ShowModal: TModalResult; +begin + if not Assigned(Stream) then + begin + with TfrxXMLExportDialog.Create(nil) do + begin + OpenExcelCB.Visible := not SlaveExport; + if SlaveExport then + FOpenExcelAfterExport := False; + + if (FileName = '') and (not SlaveExport) then + SaveDialog1.FileName := ChangeFileExt(ExtractFileName(frxUnixPath2WinPath(Report.FileName)), SaveDialog1.DefaultExt) + else + SaveDialog1.FileName := FileName; + + ContinuousCB.Checked := (not EmptyLines) or SuppressPageHeadersFooters; + PageBreaksCB.Checked := FExportPageBreaks and (not ContinuousCB.Checked); + WCB.Checked := FWysiwyg; + OpenExcelCB.Checked := FOpenExcelAfterExport; + BackgrCB.Checked := FBackground; + + if PageNumbers <> '' then + begin + PageNumbersE.Text := PageNumbers; + PageNumbersRB.Checked := True; + end; + + Result := ShowModal; + + if Result = mrOk then + begin + PageNumbers := ''; + CurPage := False; + if CurPageRB.Checked then + CurPage := True + else if PageNumbersRB.Checked then + PageNumbers := PageNumbersE.Text; + + FExportPageBreaks := PageBreaksCB.Checked and (not ContinuousCB.Checked); + EmptyLines := not ContinuousCB.Checked; + SuppressPageHeadersFooters := ContinuousCB.Checked; + FWysiwyg := WCB.Checked; + FOpenExcelAfterExport := OpenExcelCB.Checked; + FBackground := BackgrCB.Checked; + + if not SlaveExport then + begin + if DefaultPath <> '' then + SaveDialog1.InitialDir := DefaultPath; + if SaveDialog1.Execute then + FileName := SaveDialog1.FileName + else + Result := mrCancel; + end + else + FileName := ChangeFileExt(GetTempFile, SaveDialog1.DefaultExt); + end; + Free; + end; + end else + Result := mrOk; +end; + +function TfrxXMLExport.Start: Boolean; +begin + if (FileName <> '') or Assigned(Stream) then + begin + if (ExtractFilePath(FileName) = '') and (DefaultPath <> '') then + FileName := DefaultPath + '\' + FileName; + FFirstPage := True; + FMatrix := TfrxIEMatrix.Create(UseFileCache, Report.EngineOptions.TempDir); + FMatrix.ShowProgress := ShowProgress; + FMatrix.MaxCellHeight := XLMaxHeight * Ydivider; + FMatrix.Background := FBackground and FEmptyLines; + FMatrix.BackgroundImage := False; + FMatrix.Printable := ExportNotPrintable; + FMatrix.RichText := True; + FMatrix.PlainRich := True; + FMatrix.EmptyLines := FEmptyLines; + FExportPageBreaks := FExportPageBreaks and FEmptyLines; + if FWysiwyg then + FMatrix.Inaccuracy := 0.5 + else + FMatrix.Inaccuracy := 10; + FMatrix.DeleteHTMLTags := True; + Result := True + end + else + Result := False; +end; + +procedure TfrxXMLExport.StartPage(Page: TfrxReportPage; Index: Integer); +begin + if FFirstPage then + begin + FFirstPage := False; + FPageLeft := Page.LeftMargin; + FPageTop := Page.TopMargin; + FPageBottom := Page.BottomMargin; + FPageRight := Page.RightMargin; + FPageOrientation := Page.Orientation; + end; +end; + +procedure TfrxXMLExport.ExportObject(Obj: TfrxComponent); +begin + if Obj is TfrxView then + FMatrix.AddObject(TfrxView(Obj)); +end; + +procedure TfrxXMLExport.FinishPage(Page: TfrxReportPage; Index: Integer); +begin + FMatrix.AddPage(Page.Orientation, Page.Width, Page.Height, Page.LeftMargin, + Page.TopMargin, Page.RightMargin, Page.BottomMargin); +end; + +procedure TfrxXMLExport.Finish; +var + Exp: TStream; + Excel: Variant; + +begin + FMatrix.Prepare; + + try + if Assigned(Stream) then + Exp := Stream + else + Exp := TFileStream.Create(FileName, fmCreate); + try + ExportPage(Exp); + finally + if not Assigned(Stream) then + Exp.Free; + end; + try + if FOpenExcelAfterExport and (not Assigned(Stream)) then + begin + Excel := CreateOLEObject('Excel.Application'); + Excel.Visible := True; + Excel.WorkBooks.Open(FileName); + end; + finally + Excel := Unassigned; + end; + except + on e: Exception do + case Report.EngineOptions.NewSilentMode of + simSilent: Report.Errors.Add(e.Message); + simMessageBoxes: frxErrorMsg(e.Message); + simReThrow: raise; + end; + end; + FMatrix.Free; +end; + +{ TfrxXMLExportDialog } + +procedure TfrxXMLExportDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(8100); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + GroupPageRange.Caption := frxGet(7); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + DescrL.Caption := frxGet(9); + GroupQuality.Caption := frxGet(8); + ContinuousCB.Caption := frxGet(8950); + PageBreaksCB.Caption := frxGet(6); + WCB.Caption := frxGet(8102); + BackgrCB.Caption := frxGet(8103); + OpenExcelCB.Caption := frxGet(8104); + SaveDialog1.Filter := frxGet(8105); + SaveDialog1.DefaultExt := frxGet(8106); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + + +procedure TfrxXMLExportDialog.PageNumbersEChange(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxXMLExportDialog.PageNumbersEKeyPress(Sender: TObject; + var Key: Char); +begin + case key of + '0'..'9':; + #8, '-', ',':; + else + key := #0; + end; +end; + +procedure TfrxXMLExportDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. diff --git a/official/4.2/LibD11/frxFileUtils.pas b/official/4.2/LibD11/frxFileUtils.pas new file mode 100644 index 0000000..60bf2bc --- /dev/null +++ b/official/4.2/LibD11/frxFileUtils.pas @@ -0,0 +1,156 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ File utilities unit } +{ } +{ Copyright (c) 2006-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxFileUtils; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, ShlObj, FileCtrl; + +function GetFileSize(const FileName: String): Longint; +function StreamSearch(Strm: TStream; const StartPos: Longint; const Value: String): Longint; +function BrowseDialog(const Path:String; const Title: string = ''): string; +procedure DeleteFolder(const DirName: String); +{$IFNDEF Delphi6} +function DirectoryExists(const Name: string): Boolean; +{$ENDIF} + +implementation + +{$IFNDEF Delphi6} +function DirectoryExists(const Name: string): Boolean; +var + Code: Integer; +begin + Code := GetFileAttributes(PChar(Name)); + Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0); +end; +{$ENDIF} + +function GetFileSize(const FileName: String): Longint; +var + SRec: TSearchRec; +begin + FindFirst(FileName, faAnyFile, SRec); + Result := SRec.Size; + FindClose(SRec); +end; + +function StreamSearch(Strm: TStream; const StartPos: Longint; const Value: String): Longint; +var + i, oldpos: Longint; + s1: String; + Stream: TMemoryStream; +begin + Result := -1; + try + Stream := TMemoryStream.Create; + oldpos := Strm.Position; + try + Strm.Position := 0; + Stream.CopyFrom(Strm, 0); + SetLength(s1, 1); + i := 1; + Stream.Position := StartPos; + while (Stream.Position < Stream.Size) do + begin + Stream.Read(s1[1], 1); + while (s1[1] = Value[i]) and (Stream.Position <= Stream.Size) and (Length(Value) > (i - 1)) do + begin + Stream.Read(s1[1], 1); + Inc(i); + end; + if Length(Value) = (i - 1) then + begin + Result := Stream.Position - i; + break; + end else + i := 1; + end; + finally + Stream.Free; + end; + Strm.Position := oldpos; + except + end; +end; + +function BrowseCallbackProc(hwnd: HWND; uMsg: UINT; lParam: LPARAM; lpData: LPARAM):integer; stdcall; +begin + if uMsg = BFFM_INITIALIZED then + if lpData <> 0 then + SendMessage(hwnd, BFFM_SETSELECTION, 1, lpData); + Result := 0; +end; + +function BrowseDialog(const Path: String; const Title: String = ''): string; +var + lpItemID : PItemIDList; + bi : TBrowseInfo; + DisplayName : array[0..MAX_PATH] of char; + TempPath : array[0..MAX_PATH] of char; +begin + Result := Path; + FillChar(bi, sizeof(TBrowseInfo), #0); + bi.hwndOwner := GetActiveWindow; + bi.pszDisplayName := @DisplayName; + bi.lpszTitle := PChar(Title); + bi.ulFlags := BIF_RETURNONLYFSDIRS + $0040; + bi.lpfn := BrowseCallbackProc; + bi.lParam := LPARAM(PChar(Path)); + lpItemID := SHBrowseForFolder(bi); + if lpItemId <> nil then + begin + SHGetPathFromIDList(lpItemID, TempPath); + Result := TempPath; + GlobalFreePtr(lpItemID); + end; + if Result[Length(Result)] <> '\' then + Result := Result + '\'; +end; + +{$WARNINGS OFF} +procedure DeleteFolder(const DirName: String); +var + SearchRec: TSearchRec; + i: Integer; +begin + if DirectoryExists(DirName) then + begin + i := FindFirst(DirName + '\*.*', faAnyFile, SearchRec); + while i = 0 do + begin + if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then + begin + if (SearchRec.Attr and faDirectory) > 0 then + DeleteFolder(DirName + '\' + SearchRec.Name) + else if (SearchRec.Attr and faVolumeID) = 0 then + try + DeleteFile(PChar(DirName + '\' + SearchRec.Name)); + except + end; + end; + i := FindNext(SearchRec); + end; + FindClose(SearchRec); + try + RemoveDirectory(PChar(DirName)); + except + end; + end; +end; +{$WARNINGS ON} + +end. diff --git a/official/4.2/LibD11/frxGZip.pas b/official/4.2/LibD11/frxGZip.pas new file mode 100644 index 0000000..2cd135f --- /dev/null +++ b/official/4.2/LibD11/frxGZip.pas @@ -0,0 +1,218 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ GZIP compress/decompress } +{ } +{ Copyright (c) 2004-2007 } +{ by Alexander Fediachov, } +{ Fast Reports, Inc. } +{ } +{******************************************} + +unit frxGZip; + +interface + +{$I frx.inc} + +uses Windows, Classes, SysUtils, frxZLib, frxClass; + +type + TfrxCompressionLevel = (gzNone, gzFastest, gzDefault, gzMax); + + TfrxGZipCompressor = class(TfrxCustomCompressor) + public + procedure Compress(Dest: TStream); override; + function Decompress(Source: TStream): Boolean; override; + end; + + +procedure frxCompressStream(Source, Dest: TStream; + Compression: TfrxCompressionLevel = gzDefault; FileName: String = ''); +function frxDecompressStream(Source, Dest: TStream): String; +procedure frxDeflateStream(Source, Dest: TStream; + Compression: TfrxCompressionLevel = gzDefault); +procedure frxInflateStream(Source, Dest: TStream); + + +implementation + +uses frxUtils; + +procedure frxCompressStream(Source, Dest: TStream; + Compression: TfrxCompressionLevel = gzDefault; FileName: String = ''); +var + header: array [0..3] of Byte; + Compressor: TZCompressionStream; + Size: Cardinal; + CRC: Cardinal; +begin + CRC := frxStreamCRC32(Source); + Size := Source.Size; + if FileName = '' then + FileName := '1'; + FileName := FileName + #0; + + // put gzip header + header[0] := $1f; // ID1 (IDentification 1) + header[1] := $8b; // ID2 (IDentification 2) + header[2] := $8; // CM (Compression Method) CM = 8 denotes the "deflate" + header[3] := $8; // FLG (FLaGs) bit 3 FNAME + Dest.Write(header, 4); + + // reserve 4 bytes in MTIME field + Dest.Write(header, 4); + + header[0] := 0; // XFL (eXtra FLags) XFL = 2 - compressor used maximum compression + header[1] := 0; // OS (Operating System) 0 - FAT filesystem (MS-DOS, OS/2, NT/Win32) + Dest.Write(header, 2); + + // original file name, zero-terminated + Dest.Write(FileName[1], Length(FileName)); + + // seek back to skip 2 bytes zlib header + Dest.Seek(-2, soFromCurrent); + + // put compressed data + Compressor := TZCompressionStream.Create(Dest, TZCompressionLevel(Compression)); + try + Compressor.CopyFrom(Source, 0); + finally + Compressor.Free; + end; + + // get adler32 checksum + Dest.Seek(-4, soFromEnd); + Dest.Read(header, 4); + // write it to the header (to MTIME field) + Dest.Position := 4; + Dest.Write(header, 4); + + // restore original file name (it was corrupted by zlib header) + Dest.Seek(2, soFromCurrent); + Dest.Write(FileName[1], Length(FileName)); + + // put crc32 and length + Dest.Seek(-4, soFromEnd); + Dest.Write(CRC, 4); + Dest.Write(Size, 4); +end; + +function frxDecompressStream(Source, Dest: TStream): String; +var + s: String; + header: array [0..3] of byte; + adler32: Integer; + FTempStream: TMemoryStream; + UnknownPtr: Pointer; + NewSize: Integer; +begin + s := ''; + + // read gzip header + Source.Read(header, 4); + if (header[0] = $1f) and (header[1] = $8b) and (header[2] = $8) then + begin + Source.Read(adler32, 4); + Source.Read(header, 2); + if (header[3] and $8) <> 0 then + begin + Source.Read(header, 1); + while header[0] <> 0 do + begin + s := s + Char(header[0]); + Source.Read(header, 1); + end; + end; + end; + + FTempStream := TMemoryStream.Create; + try + // put zlib header + s := #$78#$DA; + FTempStream.Write(s[1], 2); + // put compressed data, skip gzip's crc32 and filelength + FTempStream.CopyFrom(Source, Source.Size - Source.Position - 8); + // put adler32 + FTempStream.Write(adler32, 4); + + // uncompress data and save it to the Dest + ZDeCompress(FTempStream.Memory, FTempStream.Size, UnknownPtr, NewSize); + Dest.Write(UnknownPtr^, NewSize); + FreeMem(UnknownPtr, NewSize); + finally + FTempStream.Free; + end; + Result := s; +end; + +procedure frxDeflateStream(Source, Dest: TStream; + Compression: TfrxCompressionLevel = gzDefault); +var + Compressor: TZCompressionStream; +begin + Compressor := TZCompressionStream.Create(Dest, TZCompressionLevel(Compression)); + try + Compressor.CopyFrom(Source, 0); + finally + Compressor.Free; + end; +end; + +procedure frxInflateStream(Source, Dest: TStream); +var + FTempStream: TMemoryStream; + UnknownPtr: Pointer; + NewSize: Integer; +begin + FTempStream := TMemoryStream.Create; + try + FTempStream.CopyFrom(Source, 0); + // uncompress data and save it to the Dest + ZDeCompress(FTempStream.Memory, FTempStream.Size, UnknownPtr, NewSize); + Dest.Write(UnknownPtr^, NewSize); + FreeMem(UnknownPtr, NewSize); + finally + FTempStream.Free; + end; +end; + + +{ TfrxGZipCompressor } + +procedure TfrxGZipCompressor.Compress(Dest: TStream); +var + Compression: TfrxCompressionLevel; + FileName: String; +begin + if IsFR3File then + begin + Compression := gzMax; + FileName := '1.fr3'; + end + else + begin + Compression := gzDefault; + FileName := '1.fp3'; + end; + frxCompressStream(Stream, Dest, Compression, FileName); +end; + +function TfrxGZipCompressor.Decompress(Source: TStream): Boolean; +var + Signature: array[0..1] of Byte; +begin + Source.Read(Signature, 2); + Source.Seek(-2, soFromCurrent); + Result := (Signature[0] = $1F) and (Signature[1] = $8B); + if Result then + frxDecompressStream(Source, Stream); + Stream.Position := 0; +end; + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxGradient.pas b/official/4.2/LibD11/frxGradient.pas new file mode 100644 index 0000000..bec1c59 --- /dev/null +++ b/official/4.2/LibD11/frxGradient.pas @@ -0,0 +1,276 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Gradient object } +{ } +{ (former RoundRect plus Add-in object) } +{ (C) Guilbaud Olivier for FR 2.4 } +{ mailto: golivier@free.fr } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxGradient; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxGradientObject = class(TComponent); // fake component + + TfrxGradientStyle = (gsHorizontal, gsVertical, gsElliptic, gsRectangle, + gsVertCenter, gsHorizCenter); + + TfrxGradientView = class(TfrxView) + private + FBeginColor: TColor; + FEndColor: TColor; + FStyle: TfrxGradientStyle; + procedure DrawGradient(X, Y, X1, Y1: Integer); + public + constructor Create(AOwner: TComponent); override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + class function GetDescription: String; override; + published + property BeginColor: TColor read FBeginColor write FBeginColor default clWhite; + property EndColor: TColor read FEndColor write FEndColor default clGray; + property Style: TfrxGradientStyle read FStyle write FStyle; + property Frame; + end; + + +implementation + +uses frxGradientRTTI, frxDsgnIntf, frxRes; + + +constructor TfrxGradientView.Create(AOwner: TComponent); +begin + inherited; + FBeginColor := clWhite; + FEndColor := clGray; +end; + +class function TfrxGradientView.GetDescription: String; +begin + Result := frxResources.Get('obGrad'); +end; + +procedure TfrxGradientView.DrawGradient(X, Y, X1, Y1: Integer); +var + FromR, FromG, FromB: Integer; + DiffR, DiffG, DiffB: Integer; + ox, oy, dx, dy: Integer; + + procedure DoHorizontal(fr, fg, fb, dr, dg, db: Integer); + var + ColorRect: TRect; + I: Integer; + R, G, B: Byte; + begin + ColorRect.Top := oy; + ColorRect.Bottom := oy + dy; + for I := 0 to 255 do + begin + ColorRect.Left := MulDiv (I, dx, 256) + ox; + ColorRect.Right := MulDiv (I + 1, dx, 256) + ox; + R := fr + MulDiv(I, dr, 255); + G := fg + MulDiv(I, dg, 255); + B := fb + MulDiv(I, db, 255); + FCanvas.Brush.Color := RGB(R, G, B); + FCanvas.FillRect(ColorRect); + end; + end; + + procedure DoVertical(fr, fg, fb, dr, dg, db: Integer); + var + ColorRect: TRect; + I: Integer; + R, G, B: Byte; + begin + ColorRect.Left := ox; + ColorRect.Right := ox + dx; + for I := 0 to 255 do + begin + ColorRect.Top := MulDiv (I, dy, 256) + oy; + ColorRect.Bottom := MulDiv (I + 1, dy, 256) + oy; + R := fr + MulDiv(I, dr, 255); + G := fg + MulDiv(I, dg, 255); + B := fb + MulDiv(I, db, 255); + FCanvas.Brush.Color := RGB(R, G, B); + FCanvas.FillRect(ColorRect); + end; + end; + + procedure DoElliptic(fr, fg, fb, dr, dg, db: Integer); + var + I: Integer; + R, G, B: Byte; + Pw, Ph: Double; + x1, y1, x2, y2: Double; + bmp: TBitmap; + begin + bmp := TBitmap.Create; + bmp.Width := dx; + bmp.Height := dy; + bmp.Canvas.Pen.Style := psClear; + + x1 := 0 - (dx / 4); + x2 := dx + (dx / 4); + y1 := 0 - (dy / 4); + y2 := dy + (dy / 4); + Pw := ((dx / 4) + (dx / 2)) / 155; + Ph := ((dy / 4) + (dy / 2)) / 155; + for I := 0 to 155 do + begin + x1 := x1 + Pw; + x2 := X2 - Pw; + y1 := y1 + Ph; + y2 := y2 - Ph; + R := fr + MulDiv(I, dr, 155); + G := fg + MulDiv(I, dg, 155); + B := fb + MulDiv(I, db, 155); + bmp.Canvas.Brush.Color := R or (G shl 8) or (b shl 16); + bmp.Canvas.Ellipse(Trunc(x1), Trunc(y1), Trunc(x2), Trunc(y2)); + end; + + FCanvas.Draw(ox, oy, bmp); + bmp.Free; + end; + + procedure DoRectangle(fr, fg, fb, dr, dg, db: Integer); + var + I: Integer; + R, G, B: Byte; + Pw, Ph: Real; + x1, y1, x2, y2: Double; + begin + FCanvas.Pen.Style := psClear; + FCanvas.Pen.Mode := pmCopy; + x1 := 0 + ox; + x2 := ox + dx; + y1 := 0 + oy; + y2 := oy + dy; + Pw := (dx / 2) / 255; + Ph := (dy / 2) / 255; + for I := 0 to 255 do + begin + x1 := x1 + Pw; + x2 := X2 - Pw; + y1 := y1 + Ph; + y2 := y2 - Ph; + R := fr + MulDiv(I, dr, 255); + G := fg + MulDiv(I, dg, 255); + B := fb + MulDiv(I, db, 255); + FCanvas.Brush.Color := RGB(R, G, B); + FCanvas.FillRect(Rect(Trunc(x1), Trunc(y1), Trunc(x2), Trunc(y2))); + end; + FCanvas.Pen.Style := psSolid; + end; + + procedure DoVertCenter(fr, fg, fb, dr, dg, db: Integer); + var + ColorRect: TRect; + I: Integer; + R, G, B: Byte; + Haf: Integer; + begin + Haf := dy Div 2; + ColorRect.Left := 0 + ox; + ColorRect.Right := ox + dx; + for I := 0 to Haf do + begin + ColorRect.Top := MulDiv(I, Haf, Haf) + oy; + ColorRect.Bottom := MulDiv(I + 1, Haf, Haf) + oy; + R := fr + MulDiv(I, dr, Haf); + G := fg + MulDiv(I, dg, Haf); + B := fb + MulDiv(I, db, Haf); + FCanvas.Brush.Color := RGB(R, G, B); + FCanvas.FillRect(ColorRect); + ColorRect.Top := dy - (MulDiv (I, Haf, Haf)) + oy; + ColorRect.Bottom := dy - (MulDiv (I + 1, Haf, Haf)) + oy; + FCanvas.FillRect(ColorRect); + end; + end; + + procedure DoHorizCenter(fr, fg, fb, dr, dg, db: Integer); + var + ColorRect: TRect; + I: Integer; + R, G, B: Byte; + Haf: Integer; + begin + Haf := dx Div 2; + ColorRect.Top := 0 + oy; + ColorRect.Bottom := oy + dy; + for I := 0 to Haf do + begin + ColorRect.Left := MulDiv(I, Haf, Haf) + ox; + ColorRect.Right := MulDiv(I + 1, Haf, Haf) + ox; + R := fr + MulDiv(I, dr, Haf); + G := fg + MulDiv(I, dg, Haf); + B := fb + MulDiv(I, db, Haf); + FCanvas.Brush.Color := RGB(R, G, B); + FCanvas.FillRect(ColorRect); + ColorRect.Left := dx - (MulDiv (I, Haf, Haf)) + ox; + ColorRect.Right := dx - (MulDiv (I + 1, Haf, Haf)) + ox; + FCanvas.FillRect(ColorRect); + end; + end; + +begin + ox := X; + oy := Y; + dx := X1 - X; + dy := Y1 - Y; + FromR := FBeginColor and $000000ff; + FromG := (FBeginColor shr 8) and $000000ff; + FromB := (FBeginColor shr 16) and $000000ff; + DiffR := (FEndColor and $000000ff) - FromR; + DiffG := ((FEndColor shr 8) and $000000ff) - FromG; + DiffB := ((FEndColor shr 16) and $000000ff) - FromB; + + case FStyle of + gsHorizontal: + DoHorizontal(FromR, FromG, FromB, DiffR, DiffG, DiffB); + gsVertical: + DoVertical(FromR, FromG, FromB, DiffR, DiffG, DiffB); + gsElliptic: + DoElliptic(FromR, FromG, FromB, DiffR, DiffG, DiffB); + gsRectangle: + DoRectangle(FromR, FromG, FromB, DiffR, DiffG, DiffB); + gsVertCenter: + DoVertCenter(FromR, FromG, FromB, DiffR, DiffG, DiffB); + gsHorizCenter: + DoHorizCenter(FromR, FromG, FromB, DiffR, DiffG, DiffB); + end; +end; + +procedure TfrxGradientView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +begin + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + DrawGradient(FX, FY, FX1, FY1); + DrawFrame; +end; + + +initialization + frxObjects.RegisterObject1(TfrxGradientView, nil, '', '', 0, 50); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxGradientRTTI.pas b/official/4.2/LibD11/frxGradientRTTI.pas new file mode 100644 index 0000000..d56e580 --- /dev/null +++ b/official/4.2/LibD11/frxGradientRTTI.pas @@ -0,0 +1,55 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Gradient RTTI } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxGradientRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, frxGradient, frxClassRTTI +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnum('TfrxGradientStyle', 'gsHorizontal, gsVertical, gsElliptic, ' + + 'gsRectangle, gsVertCenter, gsHorizCenter'); + AddClass(TfrxGradientView, 'TfrxView'); + end; +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxGraphicUtils.pas b/official/4.2/LibD11/frxGraphicUtils.pas new file mode 100644 index 0000000..d037b04 --- /dev/null +++ b/official/4.2/LibD11/frxGraphicUtils.pas @@ -0,0 +1,1663 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Graphic routines } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxGraphicUtils; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs, + frxClass, frxUnicodeUtils +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TIntArray = array[0..MaxInt div 4 - 1] of Integer; + PIntArray = ^TIntArray; + + TfrxHTMLTag = class(TObject) + public + Position: Integer; + Size: Integer; + AddY: Integer; + Style: TFontStyles; + Color: Integer; + Default: Boolean; + Small: Boolean; + procedure Assign(Tag: TfrxHTMLTag); + end; + + TfrxHTMLTags = class(TObject) + private + FItems: TList; + procedure Add(Tag: TfrxHTMLTag); + function GetItems(Index: Integer): TfrxHTMLTag; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + function Count: Integer; + property Items[Index: Integer]: TfrxHTMLTag read GetItems; default; + end; + + TfrxHTMLTagsList = class(TObject) + private + FAllowTags: Boolean; + FAddY: Integer; + FColor: LongInt; + FDefColor: LongInt; + FDefSize: Integer; + FDefStyle: TFontStyles; + FItems: TList; + FPosition: Integer; + FSize: Integer; + FStyle: TFontStyles; + FTempArray: PIntArray; + procedure NewLine; + procedure Wrap(TagsCount: Integer; AddBreak: Boolean); + function Add: TfrxHTMLTag; + function FillCharSpacingArray(var ar: PIntArray; const s: WideString; + Canvas: TCanvas; LineIndex, Add: Integer; Convert: Boolean): Integer; + function GetItems(Index: Integer): TfrxHTMLTags; + function GetPrevTag: TfrxHTMLTag; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + procedure SetDefaults(DefColor: TColor; DefSize: Integer; + DefStyle: TFontStyles); + procedure ExpandHTMLTags(var s: WideString); + function Count: Integer; + property AllowTags: Boolean read FAllowTags write FAllowTags; + property Items[Index: Integer]: TfrxHTMLTags read GetItems; default; + property Position: Integer read FPosition write FPosition; + end; + + TfrxDrawText = class(TObject) + private +// internals + FBMP: TBitmap; + FLocked: Boolean; + FCanvas: TCanvas; + FDefPPI: Integer; + FScrPPI: Integer; + FTempArray: PIntArray; + +// data passed by SetXXX calls + FFontSize: Integer; + FHTMLTags: TfrxHTMLTagsList; + FCharSpacing: Extended; + FLineSpacing: Extended; + FOptions: Integer; + FOriginalRect: TRect; + FParagraphGap: Extended; + FPlainText: WideString; + FPrintScale: Extended; + FRotation: Integer; + FRTLReading: Boolean; + FScaledRect: TRect; + FScaleX: Extended; + FScaleY: Extended; + FText: TWideStrings; + FWordBreak: Boolean; + FWordWrap: Boolean; + FWysiwyg: Boolean; + + function GetWrappedText: WideString; + function IsPrinter(C: TCanvas): Boolean; + procedure DrawTextLine(C: TCanvas; const s: WideString; + X, Y, DX, LineIndex: Integer; Align: TfrxHAlign; var fh, oldfh: HFont); + procedure WrapTextLine(s: WideString; Width, FirstLineWidth, + CharSpacing: Integer); + public + constructor Create; + destructor Destroy; override; + +// Call these methods in the same order + procedure SetFont(Font: TFont); + procedure SetOptions(WordWrap, HTMLTags, RTLReading, WordBreak, + Clipped, Wysiwyg: Boolean; Rotation: Integer); + procedure SetGaps(ParagraphGap, CharSpacing, LineSpacing: Extended); + procedure SetDimensions(ScaleX, ScaleY, PrintScale: Extended; + OriginalRect, ScaledRect: TRect); + procedure SetText(Text: TWideStrings); + procedure SetParaBreaks(FirstParaBreak, LastParaBreak: Boolean); + function DeleteTags(const Txt: WideString): WideString; + +// call these methods only after methods listed above + procedure DrawText(C: TCanvas; HAlign: TfrxHAlign; VAlign: TfrxVAlign); + function CalcHeight: Extended; + function CalcWidth: Extended; + function LineHeight: Extended; + function TextHeight: Extended; +// returns the text that don't fit in the bounds + function GetInBoundsText: WideString; + function GetOutBoundsText(var ParaBreak: Boolean): WideString; + function UnusedSpace: Extended; + +// call these methods before and after doing something + procedure Lock; + procedure Unlock; + + property Canvas: TCanvas read FCanvas; + property DefPPI: Integer read FDefPPI; + property ScrPPI: Integer read FScrPPI; + property WrappedText: WideString read GetWrappedText; + end; + + +var + frxDrawText: TfrxDrawText; + +implementation + +uses frxPrinter; + +const + glasn: String = 'Ũ'; + soglasn: String = ''; + znaks: String = ''; + znaks1: String = ''; + +{ , , + . + + 1. , + , ; , + -, -. + + 2. . + + - - + + 3. . + + - - + + 4. . + + - - + + 5. . + + -, - - + + 6. + , . + + - - } + +{ , } +function BreakRussianWord(const s: WideString): String; +var + i, j: Integer; + CanBreak: Boolean; + + function Check1and5(const s: WideString): Boolean; + var + i: Integer; + begin + Result := False; + if Length(s) >= 2 then + for i := 1 to Length(s) do + if Pos(s[i], glasn) <> 0 then + begin + Result := True; + break; + end; + end; + +begin + Result := ''; + if Length(s) < 4 then Exit; + + for i := 1 to Length(s) do + begin + CanBreak := False; + if Pos(s[i], soglasn) <> 0 then + begin + CanBreak := True; + { 2 } + if (i < Length(s)) and (Pos(s[i + 1], glasn) <> 0) then + CanBreak := False; + { 3 } + if (i < Length(s)) and (Pos(s[i + 1], znaks) <> 0) then + CanBreak := False; + end; + if Pos(s[i], glasn) <> 0 then + begin + CanBreak := True; + { 4 } + if (i < Length(s)) and (Pos(s[i + 1], znaks1) <> 0) then + CanBreak := False; + { 6 } + if (i < Length(s) - 2) and (Pos(s[i + 1], soglasn) <> 0) and + (s[i + 1] = s[i + 2]) and (Pos(s[i + 3], glasn) <> 0) then + CanBreak := False; + end; + if CanBreak then + Result := Result + Chr(i); + end; + + { 1, 5 } + for i := 1 to Length(Result) do + begin + j := Ord(Result[i]); + if not (Check1and5(Copy(s, 1, j)) and Check1and5(Copy(s, j + 1, 255))) then + Result[i] := #255; + end; + while Pos(#255, Result) <> 0 do + Delete(Result, Pos(#255, Result), 1); +end; + +procedure IncArray(Ar: PIntArray; x1, x2, n, one: Integer); +var + xm: Integer; +begin + if n <= 0 then Exit; + xm := (x2 - x1 + 1) div 2; + if xm = 0 then + xm := 1; + if n = 1 then + Inc(Ar[x1 + xm - 1], one) + else + begin + IncArray(Ar, x1, x1 + xm - 1, n div 2, one); + IncArray(Ar, x1 + xm, x2, n - n div 2, one); + end; +end; + +function CreateRotatedFont(Font: TFont; Rotation: Integer): HFont; +var + F: TLogFont; +begin + GetObject(Font.Handle, SizeOf(TLogFont), @F); + F.lfEscapement := Rotation * 10; + F.lfOrientation := Rotation * 10; + Result := CreateFontIndirect(F); +end; + + +{ TfrxHTMLTag } + +procedure TfrxHTMLTag.Assign(Tag: TfrxHTMLTag); +begin + Position := Tag.Position; + Size := Tag.Size; + AddY := Tag.AddY; + Style := Tag.Style; + Color := Tag.Color; + Default := Tag.Default; + Small := Tag.Small; +end; + + +{ TfrxHTMLTags } + +constructor TfrxHTMLTags.Create; +begin + FItems := TList.Create; +end; + +destructor TfrxHTMLTags.Destroy; +begin + Clear; + FItems.Free; + inherited; +end; + +procedure TfrxHTMLTags.Clear; +var + i: Integer; +begin + for i := 0 to FItems.Count - 1 do + TfrxHTMLTag(FItems[i]).Free; + FItems.Clear; +end; + +function TfrxHTMLTags.GetItems(Index: Integer): TfrxHTMLTag; +begin + Result := TfrxHTMLTag(FItems[Index]); +end; + +function TfrxHTMLTags.Count: Integer; +begin + Result := FItems.Count; +end; + +procedure TfrxHTMLTags.Add(Tag: TfrxHTMLTag); +begin + FItems.Add(Tag); +end; + + +{ TfrxHTMLTagsList } + +constructor TfrxHTMLTagsList.Create; +begin + FItems := TList.Create; + FAllowTags := True; + GetMem(FTempArray, SizeOf(Integer) * 32768); +end; + +destructor TfrxHTMLTagsList.Destroy; +begin + Clear; + FItems.Free; + FreeMem(FTempArray, SizeOf(Integer) * 32768); + inherited; +end; + +procedure TfrxHTMLTagsList.Clear; +var + i: Integer; +begin + for i := 0 to FItems.Count - 1 do + TfrxHTMLTags(FItems[i]).Free; + FItems.Clear; +end; + +procedure TfrxHTMLTagsList.NewLine; +begin + if Count <> 0 then + FItems.Add(TfrxHTMLTags.Create); +end; + +procedure TfrxHTMLTagsList.Wrap(TagsCount: Integer; AddBreak: Boolean); +var + i: Integer; + Line, OldLine: TfrxHTMLTags; + NewTag: TfrxHTMLTag; +begin + OldLine := Items[Count - 1]; + if OldLine.Count <= TagsCount then + Exit; + + NewLine; + Line := Items[Count - 1]; + for i := TagsCount to OldLine.Count - 1 do + Line.Add(OldLine[i]); + OldLine.FItems.Count := TagsCount; + if AddBreak then + begin + NewTag := TfrxHTMLTag.Create; + OldLine.FItems.Add(NewTag); + NewTag.Assign(TfrxHTMLTag(OldLine.FItems[TagsCount - 1])) + end + else if Line[0].Default then + Line[0].Assign(OldLine[TagsCount - 1]); +end; + +function TfrxHTMLTagsList.Count: Integer; +begin + Result := FItems.Count; +end; + +function TfrxHTMLTagsList.GetItems(Index: Integer): TfrxHTMLTags; +begin + Result := TfrxHTMLTags(FItems[Index]); +end; + +function TfrxHTMLTagsList.Add: TfrxHTMLTag; +var + i: Integer; +begin + Result := TfrxHTMLTag.Create; + i := Count - 1; + if i = -1 then + begin + FItems.Add(TfrxHTMLTags.Create); + i := 0; + end; + Items[i].Add(Result); +end; + +function TfrxHTMLTagsList.GetPrevTag: TfrxHTMLTag; +var + Tags: TfrxHTMLTags; +begin + Result := nil; + Tags := Items[Count - 1]; + if Tags.Count > 1 then + Result := Tags[Tags.Count - 2] + else if Count > 1 then + begin + Tags := Items[Count - 2]; + Result := Tags[Tags.Count - 1]; + end; +end; + +procedure TfrxHTMLTagsList.SetDefaults(DefColor: TColor; DefSize: Integer; + DefStyle: TFontStyles); +begin + FDefColor := DefColor; + FDefSize := DefSize; + FDefStyle := DefStyle; + FAddY := 0; + FColor := FDefColor; + FSize := FDefSize; + FStyle := FDefStyle; + FPosition := 1; + Clear; +end; + +procedure TfrxHTMLTagsList.ExpandHTMLTags(var s: WideString); +var + i, j, j1: Integer; + b: Boolean; + cl: WideString; + + procedure AddTag; + var + Tag, PrevTag: TfrxHTMLTag; + begin + Tag := Add; + Tag.Position := FPosition; // this will help us to get position in the original text + Tag.Size := FSize; + Tag.Style := FStyle; + Tag.Color := FColor; + Tag.AddY := FAddY; +// when "Default" changes, we need to set Font.Style, Size and Color + if FAllowTags then + begin + PrevTag := GetPrevTag; + if PrevTag <> nil then + Tag.Default := (FStyle = PrevTag.Style) and + (FColor = PrevTag.Color) and + (FSize = PrevTag.Size) + else + Tag.Default := (FStyle = FDefStyle) and (FColor = FDefColor) and (FSize = FDefSize); + end + else + Tag.Default := True; + Tag.Small := FSize <> FDefSize; + end; + +begin + i := 1; + if Length(s) = 0 then Exit; + + while i <= Length(s) do + begin + b := True; + + if FAllowTags then + if s[i] = '<' then + begin + + // , , tags + if (i + 2 <= Length(s)) and (s[i + 2] = '>') then + begin + case s[i + 1] of + 'b','B': FStyle := FStyle + [fsBold]; + 'i','I': FStyle := FStyle + [fsItalic]; + 'u','U': FStyle := FStyle + [fsUnderline]; + else + b := False; + end; + if b then + begin + System.Delete(s, i, 3); + Inc(FPosition, 3); + continue; + end; + end + + // , tags + else if (i + 4 <= Length(s)) and (s[i + 4] = '>') then + begin + if Pos('SUB>', AnsiUpperCase(s)) = i + 1 then + begin + FSize := Round(FDefSize / 1.5); + FAddY := 1; + b := True; + end + else if Pos('SUP>', AnsiUpperCase(s)) = i + 1 then + begin + FSize := Round(FDefSize / 1.5); + FAddY := 0; + b := True; + end; + if b then + begin + System.Delete(s, i, 5); + Inc(FPosition, 5); + continue; + end; + end + + // tag + else if (i + 1 <= Length(s)) and ((s[i + 1] = 's') or (s[i + 1] = 'S')) then + begin + if Pos('STRIKE>', AnsiUpperCase(s)) = i + 1 then + begin + FStyle := FStyle + [fsStrikeOut]; + System.Delete(s, i, 8); + Inc(FPosition, 8); + continue; + end; + end + + // , , , , , , tags + else if (i + 1 <= Length(s)) and (s[i + 1] = '/') then + begin + if (i + 3 <= Length(s)) and (s[i + 3] = '>') then + begin + case s[i + 2] of + 'b','B': FStyle := FStyle - [fsBold]; + 'i','I': FStyle := FStyle - [fsItalic]; + 'u','U': FStyle := FStyle - [fsUnderline]; + else + b := False; + end; + if b then + begin + System.Delete(s, i, 4); + Inc(FPosition, 4); + continue; + end; + end + else if (Pos('STRIKE>', AnsiUpperCase(s)) = i + 2) then + begin + FStyle := FStyle - [fsStrikeOut]; + System.Delete(s, i, 9); + Inc(FPosition, 9); + continue; + end + else if Pos('FONT>', AnsiUpperCase(s)) = i + 2 then + begin + FColor := FDefColor; + System.Delete(s, i, 7); + Inc(FPosition, 7); + continue; + end + else if (Pos('SUB>', AnsiUpperCase(s)) = i + 2) or + (Pos('SUP>', AnsiUpperCase(s)) = i + 2) then + begin + FSize := FDefSize; + FAddY := 0; + System.Delete(s, i, 6); + Inc(FPosition, 6); + continue; + end + end + + // tag + else if Pos('FONT COLOR', AnsiUpperCase(s)) = i + 1 then + begin + j := i + 11; + while (j <= Length(s)) and (s[j] <> '=') do + Inc(j); + Inc(j); + while (j <= Length(s)) and (s[j] = ' ') do + Inc(j); + j1 := j; + while (j <= Length(s)) and (s[j] <> '>') do + Inc(j); + + cl := Copy(s, j1, j - j1); + if cl <> '' then + begin + if (Length(cl) > 3) and (cl[1] = '"') and (cl[2] = '#') and + (cl[Length(cl)] = '"') then + begin + cl := '$' + Copy(cl, 3, Length(cl) - 3); + FColor := StrToInt(cl); + FColor := (FColor and $00FF0000) div 65536 + + (FColor and $000000FF) * 65536 + + (FColor and $0000FF00); + System.Delete(s, i, j - i + 1); + Inc(FPosition, j - i + 1); + continue; + end + else if IdentToColor('cl' + cl, FColor) then + begin + System.Delete(s, i, j - i + 1); + Inc(FPosition, j - i + 1); + continue; + end; + end; + end + end; + + AddTag; + Inc(i); + Inc(FPosition); + end; + + if Length(s) = 0 then + begin + AddTag; + s := ' '; + end; +end; + +function TfrxHTMLTagsList.FillCharSpacingArray(var ar: PIntArray; const s: WideString; + Canvas: TCanvas; LineIndex, Add: Integer; Convert: Boolean): Integer; +var + i, n: Integer; + Tags: TfrxHTMLTags; + Tag: TfrxHTMLTag; + + procedure BreakArray; + var + i, j, offs: Integer; + Size: TSize; + ansis: String; + begin + if (Win32Platform <> VER_PLATFORM_WIN32_NT) or (Canvas.Font.Charset <> DEFAULT_CHARSET) then + begin + ansis := s; + GetTextExtentExPoint(Canvas.Handle, PChar(ansis), n, 0, nil, + @FTempArray[0], Size); + end + else + GetTextExtentExPointW(Canvas.Handle, PWideChar(s), n, 0, nil, + @FTempArray[0], Size); + i := 0; + repeat + if FTempArray[i] = 32767 then + begin + offs := FTempArray[i - 1]; + if (Win32Platform <> VER_PLATFORM_WIN32_NT) or (Canvas.Font.Charset <> DEFAULT_CHARSET) then + begin + ansis := s; + GetTextExtentExPoint(Canvas.Handle, PChar(ansis) + i, n - i, 0, nil, + @FTempArray[i], Size); + end + else + GetTextExtentExPointW(Canvas.Handle, PWideChar(s) + i, n - i, 0, nil, + @FTempArray[i], Size); + for j := i to n - 1 do + if FTempArray[j] = 32767 then + begin + i := j - 1; + break; + end + else + FTempArray[j] := FTempArray[j] + offs; + end; + Inc(i); + until i >= n; + end; + +begin + Result := 0; + n := Length(s); + + Tags := Items[LineIndex]; + Tag := Tags.Items[0]; + if not Tag.Default then + Canvas.Font.Style := Tag.Style; + + BreakArray; + + for i := 0 to n - 1 do + begin + Tag := Tags.Items[i]; + if (i <> 0) and not Tag.Default then + begin + Canvas.Font.Style := Tag.Style; + BreakArray; + end; + + if i > 0 then + Ar[i] := FTempArray[i] - FTempArray[i - 1] + Add else + Ar[i] := FTempArray[i] + Add; + if Tag.Small then + Ar[i] := Round(Ar[i] / 1.5); + Inc(Result, Ar[i]); + if Convert and (i > 0) then + Inc(Ar[i], Ar[i - 1]); + end; +end; + + +{ TfrxDrawText } + +constructor TfrxDrawText.Create; +begin + FBMP := TBitmap.Create; + FCanvas := FBMP.Canvas; + FDefPPI := 600; + FScrPpi := 96; + FHTMLTags := TfrxHTMLTagsList.Create; + FText := TWideStrings.Create; + FWysiwyg := True; + GetMem(FTempArray, SizeOf(Integer) * 32768); +end; + +destructor TfrxDrawText.Destroy; +begin + FBMP.Free; + FHTMLTags.Free; + FText.Free; + FreeMem(FTempArray, SizeOf(Integer) * 32768); + inherited; +end; + +procedure TfrxDrawText.SetFont(Font: TFont); +var + h: Integer; +begin + FFontSize := Font.Size; + h := -Round(FFontSize * FDefPPI / 72); // height is as in the 600 dpi printer + FCanvas.Lock; + try + with FCanvas.Font do + begin + if Name <> Font.Name then + Name := Font.Name; + if Height <> h then + Height := h; + if Style <> Font.Style then + Style := Font.Style; + if Charset <> Font.Charset then + Charset := Font.Charset; + if Color <> Font.Color then + Color := Font.Color; + end; + finally + FCanvas.Unlock; + end; +end; + +procedure TfrxDrawText.SetOptions(WordWrap, HTMLTags, RTLReading, + WordBreak, Clipped, Wysiwyg: Boolean; Rotation: Integer); +begin + FWordWrap := WordWrap; + FHTMLTags.AllowTags := HTMLTags; + FRTLReading := RTLReading; + FOptions := 0; + if RTLReading then + FOptions := ETO_RTLREADING; + if Clipped then + FOptions := FOptions or ETO_CLIPPED; + FWordBreak := WordBreak; + FRotation := Rotation mod 360; + FWysiwyg := Wysiwyg; +end; + +procedure TfrxDrawText.SetDimensions(ScaleX, ScaleY, PrintScale: Extended; + OriginalRect, ScaledRect: TRect); +begin + FScaleX := ScaleX; + FScaleY := ScaleY; + FPrintScale := PrintScale; + FOriginalRect := OriginalRect; + FScaledRect := ScaledRect; +end; + +procedure TfrxDrawText.SetGaps(ParagraphGap, CharSpacing, LineSpacing: Extended); +begin + FParagraphGap := ParagraphGap; + FCharSpacing := CharSpacing; + FLineSpacing := LineSpacing; +end; + +procedure TfrxDrawText.SetText(Text: TWideStrings); +var + i, j, n, Width: Integer; + s: WideString; + Style: TFontStyles; + FPPI: Extended; +begin + FCanvas.Lock; + try + FPlainText := ''; + FText.Clear; + finally + FCanvas.Unlock; + end; + + n := Text.Count; + if n = 0 then Exit; + + FCanvas.Lock; + try + // set up html engine + FHTMLTags.SetDefaults(FCanvas.Font.Color, FFontSize, FCanvas.Font.Style); + Style := FCanvas.Font.Style; + + // width of the wrap area + Width := FOriginalRect.Right - FOriginalRect.Left; + if ((FRotation >= 90) and (FRotation < 180)) or + ((FRotation >= 270) and (FRotation < 360)) then + Width := FOriginalRect.Bottom - FOriginalRect.Top; + + for i := 0 to n - 1 do + begin + j := FText.Count; + s := Text[i]; + if s = '' then + s := ' '; + FPlainText := FPlainText + s + #13#10; + FPPI := FDefPPI / FScrPPI; + WrapTextLine(s, + Round(Width * FPPI), + Round((Width - FParagraphGap) * FPPI), + Round(FCharSpacing * FPPI)); + if FText.Count <> j then + begin + FText.Objects[j] := Pointer(1); // mark the begin of paragraph: + if FText.Count - 1 = j then // it will be needed in DrawText + FText.Objects[j] := Pointer(3) else // both begin and end at one line + FText.Objects[FText.Count - 1] := Pointer(2); // mark the end of paragraph + end; + end; + + FCanvas.Font.Style := Style; + finally + FCanvas.Unlock; + end; +end; + +procedure TfrxDrawText.SetParaBreaks(FirstParaBreak, LastParaBreak: Boolean); +begin + if FText.Count = 0 then Exit; + + if FirstParaBreak then + FText.Objects[0] := Pointer(Integer(FText.Objects[0]) and not 1); + if LastParaBreak then + FText.Objects[FText.Count - 1] := Pointer(Integer(FText.Objects[FText.Count - 1]) and not 2); +end; + +function TfrxDrawText.DeleteTags(const Txt: WideString): WideString; +begin + Result := Txt; + FHTMLTags.ExpandHTMLTags(Result); +end; + +procedure TfrxDrawText.WrapTextLine(s: WideString; + Width, FirstLineWidth, CharSpacing: Integer); +var + n, i, Offset, LineBegin, LastSpace, BreakPos: Integer; + sz: TSize; + TheWord: WideString; + WasBreak: Boolean; + + function BreakWord(const s: WideString; LineBegin, CurPos, LineEnd: Integer): WideString; + var + i, BreakPos: Integer; + TheWord, Breaks: WideString; + begin + // get the whole word + i := CurPos; + while (i <= LineEnd) and (Pos(s[i], ' .,-;') = 0) do + Inc(i); + TheWord := Copy(s, LineBegin, i - LineBegin); + // get available break positions + Breaks := BreakRussianWord(AnsiUpperCase(TheWord)); + // find the closest position + BreakPos := CurPos - LineBegin; + for i := Length(Breaks) downto 1 do + if Ord(Breaks[i]) < BreakPos then + begin + BreakPos := Ord(Breaks[i]); + break; + end; + if BreakPos <> CurPos - LineBegin then + Result := Copy(TheWord, 1, BreakPos) else + Result := ''; + end; + +begin +// remove all HTML tags and build the tag list + FHTMLTags.NewLine; + FHTMLTags.ExpandHTMLTags(s); + FHTMLTags.FPosition := FHTMLTags.FPosition + 2; + + n := Length(s); + if (n < 2) or not FWordWrap then // no need to wrap a string with 0 or 1 symbol + begin + FText.Add(s); + Exit; + end; + +// get the intercharacter spacing table and calculate the width + FCanvas.Lock; + try + sz.cx := FHTMLTags.FillCharSpacingArray(FTempArray, s, FCanvas, + FHTMLTags.Count - 1, CharSpacing, True); + finally + FCanvas.Unlock; + end; + +// text fits, no need to wrap it + if sz.cx < FirstLineWidth then + begin + FText.Add(s); + Exit; + end; + + Offset := 0; + i := 1; + LineBegin := 1; // index of the first symbol in the current line + LastSpace := 1; // index of the last space symbol in the current line + + while i <= n do + begin + if s[i] = ' ' then + LastSpace := i; + + if FTempArray[i - 1] - Offset > FirstLineWidth then // need wrap + begin + if LastSpace = LineBegin then // there is only one word without spaces... + begin + if i <> LineBegin then // ... and it has more than 1 symbol + begin + if FWordBreak then + begin + TheWord := BreakWord(s, LineBegin, i, n); + WasBreak := TheWord <> ''; + if not WasBreak then + TheWord := Copy(s, LineBegin, i - LineBegin); + if WasBreak then + FText.Add(TheWord + '-') else + FText.Add(TheWord); + BreakPos := Length(TheWord); + FHTMLTags.Wrap(BreakPos, WasBreak); + LastSpace := LineBegin + BreakPos - 1; + end + else + begin + FText.Add(Copy(s, LineBegin, i - LineBegin)); + FHTMLTags.Wrap(i - LineBegin, False); + LastSpace := i - 1; + end; + end + else + begin + FText.Add(s[LineBegin]); // can't wrap 1 symbol, just add it to the new line + FHTMLTags.Wrap(1, False); + end; + end + else // we have a space symbol inside + begin + if FWordBreak then + begin + TheWord := BreakWord(s, LastSpace + 1, i, n); + WasBreak := TheWord <> ''; + if WasBreak then + FText.Add(Copy(s, LineBegin, LastSpace - LineBegin + 1) + TheWord + '-') else + FText.Add(Copy(s, LineBegin, LastSpace - LineBegin)); + BreakPos := LastSpace - LineBegin + Length(TheWord) + 1; + FHTMLTags.Wrap(BreakPos, WasBreak); + if WasBreak then + LastSpace := LineBegin + BreakPos - 1; + end + else + begin + FText.Add(Copy(s, LineBegin, LastSpace - LineBegin)); + FHTMLTags.Wrap(LastSpace - LineBegin + 1, False); + end; + end; + + Offset := FTempArray[LastSpace - 1]; // starting a new line + i := LastSpace; + Inc(LastSpace); + LineBegin := LastSpace; + FirstLineWidth := Width; // this line is not first, so use Width + end; + + Inc(i); + end; + + if n - LineBegin + 1 > 0 then // put the rest of line to FText + FText.Add(Copy(s, LineBegin, n - LineBegin + 1)); +end; + +procedure TfrxDrawText.DrawTextLine(C: TCanvas; const s: WideString; + X, Y, DX, LineIndex: Integer; Align: TfrxHAlign; var fh, oldfh: HFont); +var + spaceAr: PIntArray; + n, i, j, cw, neededSize, extraSize, spaceCount: Integer; + add1, add2, add3, addCount: Integer; + ratio: Extended; + Sz, prnSz, PPI: Integer; + Tag: TfrxHTMLTag; + CosA, SinA: Extended; + Style: TFontStyles; + FPPI: Extended; + + function CountSpaces: Integer; + var + i: Integer; + begin + Result := 0; + for i := 0 to n - 1 do + begin + spaceAr[i] := 0; + if (s[i + 1] = ' ') or (s[i + 1] = #$A0) then + begin + Inc(Result); + spaceAr[i] := 1; + end; + end; + end; + + function CalcWidth(Index, Count: Integer): Integer; + var + i: Integer; + begin + Result := 0; + for i := Index to Index + Count - 1 do + Result := Result + FTempArray[i]; + end; + +begin + n := Length(s); + if n = 0 then Exit; + + spaceAr := nil; + FCanvas.Lock; + + try + Style := C.Font.Style; + FHTMLTags.FDefStyle := Style; + FCanvas.Font.Style := Style; + FPPI := FDefPPI / FScrPPI; + + PrnSz := FHTMLTags.FillCharSpacingArray(FTempArray, s, FCanvas, LineIndex, + Round(FCharSpacing * FPPI), False) - Round(FCharSpacing * FPPI); + Sz := FHTMLTags.FillCharSpacingArray(FTempArray, s, C, LineIndex, + Round(FCharSpacing * FScaleX), False) - Round(FCharSpacing * FScaleX); //!Den + + C.Font.Style := Style; + if FHTMLTags.AllowTags and (FRotation <> 0) then + begin + SelectObject(C.Handle, oldfh); + DeleteObject(fh); + fh := CreateRotatedFont(C.Font, FRotation); + oldfh := SelectObject(C.Handle, fh); + end; + + PPI := GetDeviceCaps(C.Handle, LOGPIXELSX); + ratio := FDefPPI / PPI; + if IsPrinter(C) then + neededSize := Round(prnSz * FPrintScale / ratio) else + neededSize := Round(prnSz / (FDefPPI / 96) * FScaleX); + if not FWysiwyg then + neededSize := Sz; + extraSize := neededSize - Sz; + + CosA := Cos(pi / 180 * FRotation); + SinA := Sin(pi / 180 * FRotation); + if Align = haRight then + begin + X := x + Round((dx - neededSize + 1) * CosA); + Y := y - Round((dx - neededSize + 1) * SinA); + + Dec(X, 1); + if (fsBold in Style) or (fsItalic in Style) then + if FRotation = 0 then + Dec(X, 1); + end + else if Align = haCenter then + begin + X := x + Round((dx - neededSize) / 2 * CosA); + Y := y - Round((dx - neededSize) / 2 * SinA); + end; + + + if Align = haBlock then + begin + GetMem(spaceAr, SizeOf(Integer) * n); + spaceCount := CountSpaces; + if spaceCount = 0 then + Align := haLeft else + extraSize := Abs(dx) - Sz; + end + else + spaceCount := 0; + + if extraSize < 0 then + begin + extraSize := -extraSize; + add3 := -1; + end + else + add3 := 1; + + if Align <> haBlock then + begin + if extraSize < n then + IncArray(FTempArray, 0, n - 1, extraSize, add3) + else + begin + add1 := extraSize div n * add3; + for i := 0 to n - 1 do + Inc(FTempArray[i], add1); + IncArray(FTempArray, 0, n - 1, extraSize - add1 * n * add3, add3) + end; + end + else + begin + add1 := extraSize div spaceCount; + add2 := extraSize mod spaceCount; + addCount := 0; + for i := 0 to n - 1 do + if spaceAr[i] = 1 then + begin + Inc(FTempArray[i], add1 * add3); + if addCount <= add2 then + begin + Inc(FTempArray[i], add3); + Inc(addCount); + end; + end; + end; + + + i := 0; + Tag := FHTMLTags[LineIndex].Items[0]; + add1 := Round(Tag.AddY * Tag.Size * FScaleY); + + repeat + j := i; + while i < n do + begin + Tag := FHTMLTags[LineIndex].Items[i]; + if not Tag.Default then + begin + Tag.Default := True; + break; + end; + Inc(i); + end; + + if (C.Font.Charset = DEFAULT_CHARSET) and (Win32Platform = VER_PLATFORM_WIN32_NT) then + if FWysiwyg then + ExtTextOutW(C.Handle, X + Round(add1 * SinA), Y + Round(add1 * CosA), + FOptions, @FScaledRect, PWideChar(s) + j, i - j, @FTempArray[j]) + else + ExtTextOutW(C.Handle, X + Round(add1 * SinA), Y + Round(add1 * CosA), + FOptions, @FScaledRect, PWideChar(s) + j, i - j, nil) + else + if FWysiwyg then + ExtTextOut(C.Handle, X + Round(add1 * SinA), Y + Round(add1 * CosA), + FOptions, @FScaledRect, PChar(String(s)) + j, i - j, @FTempArray[j]) + else + ExtTextOut(C.Handle, X + Round(add1 * SinA), Y + Round(add1 * CosA), + FOptions, @FScaledRect, PChar(String(s)) + j, i - j, nil); + + if i < n then + begin + if IsPrinter(C) then + C.Font.Height := -Round(Tag.Size * PPI * FPrintScale / 72) else + C.Font.Height := -Round(Tag.Size * FScaleY * 96 / 72); + C.Font.Style := Tag.Style; + C.Font.Color := Tag.Color; + add1 := Round(Tag.AddY * Tag.Size * FScaleY); + + cw := CalcWidth(j, i - j); + if FRotation = 0 then + X := X + cw + else + begin + X := X + Round(cw * CosA); + Y := Y - Round(cw * SinA); + + SelectObject(C.Handle, oldfh); + DeleteObject(fh); + fh := CreateRotatedFont(C.Font, FRotation); + oldfh := SelectObject(C.Handle, fh); + end; + end; + until i >= n; + + if spaceAr <> nil then + FreeMem(spaceAr, SizeOf(Integer) * n); + + finally + FCanvas.Unlock; + end; +end; + +procedure TfrxDrawText.DrawText(C: TCanvas; HAlign: TfrxHAlign; VAlign: TfrxVAlign); +var + Ar: PIntArray; + i, n, neededSize, extraSize, add1, add3: Integer; + ratio: Extended; + al: TfrxHAlign; + x, y, par: Integer; + Sz, prnSz: Integer; + Tag: TfrxHTMLTag; + fh, oldfh: HFont; + h, PPI, dx, gx: Integer; + CosA, SinA: Extended; + + procedure CalcRotatedCoords; + var + AbsCosA, AbsSinA: Extended; + dy: Integer; + begin + CosA := Cos(pi / 180 * FRotation); + SinA := Sin(pi / 180 * FRotation); + AbsCosA := Abs(CosA); + AbsSinA := Abs(SinA); + + dy := 0; + with FScaledRect do + case FRotation of + 0: + begin + x := Left; + y := Top; + dx := Right - Left; + dy := Bottom - Top; + end; + + 1..89: + begin + x := Left; + dx := Round((Right - Left - neededsize * AbsSinA) / AbsCosA); + y := Top + Round(dx * AbsSinA); + dy := Bottom - y - Round(neededsize * AbsCosA) + neededsize; + CosA := 1; SinA := 0; + end; + + 90: + begin + x := Left; + y := Bottom; + dx := Bottom - Top; + dy := Right - Left; + end; + + 91..179: + begin + y := Bottom; + dx := Round((Right - Left - neededsize * AbsSinA) / AbsCosA); + x := Left + Round(dx * AbsCosA); + dy := Bottom - Top - Round(neededsize * AbsCosA + dx * AbsSinA) + neededsize; + CosA := -1; SinA := 0; + end; + + 180: + begin + x := Right; + y := Bottom; + dx := Right - Left; + dy := Bottom - Top; + end; + + 181..269: + begin + x := Right; + dx := Round((Right - Left - neededsize * AbsSinA) / AbsCosA); + y := Bottom - Round(dx * AbsSinA); + dy := y - Top - Round(neededsize * AbsCosA) + neededsize; + CosA := -1; SinA := 0; + end; + + 270: + begin + x := Right; + y := Top; + dx := Bottom - Top; + dy := Right - Left; + end; + + 271..359: + begin + y := Top; + dx := Round((Right - Left - neededsize * AbsSinA) / AbsCosA); + x := Left + Round(neededsize * AbsSinA); + dy := Bottom - Top - Round(dx * AbsSinA + neededsize * AbsCosA) + neededsize; + CosA := 1; SinA := 0; + end; + end; + + if VAlign = vaBottom then + begin + y := y + Round(CosA * (dy - neededSize)); + x := x + Round(SinA * (dy - neededSize)); + end + else if VAlign = vaCenter then + begin + y := y + Round(CosA * (dy - neededSize) / 2); + x := x + Round(SinA * (dy - neededSize) / 2); + end; + + CosA := cos(pi / 180 * FRotation); + SinA := sin(pi / 180 * FRotation); + end; + +begin + n := FText.Count; + if (n = 0) or (FHTMLTags.Count = 0) then exit; // no text to draw + + FCanvas.Lock; + try + PPI := GetDeviceCaps(C.Handle, LOGPIXELSY); + if IsPrinter(C) then + h := -Round(FFontSize * PPI * FPrintScale / 72) else + h := -Round(FFontSize * FScaleY * 96 / 72); + C.Font := FCanvas.Font; + C.Font.Height := h; + + if FHTMLTags[0].Count > 0 then + begin + Tag := FHTMLTags[0].Items[0]; + if not Tag.Default then + begin + C.Font.Style := Tag.Style; + C.Font.Color := Tag.Color; + if IsPrinter(C) then + C.Font.Height := -Round(Tag.Size * PPI * FPrintScale / 72) else + C.Font.Height := -Round(Tag.Size * FScaleY * 96 / 72); + end; + Tag.Default := True; + end; + + fh := 0; oldfh := 0; + if FRotation <> 0 then + begin + fh := CreateRotatedFont(C.Font, FRotation); + oldfh := SelectObject(C.Handle, fh); + end; + + Sz := -C.Font.Height; + PrnSz := -FCanvas.Font.Height; + if IsPrinter(C) then + begin + ratio := FDefPPI / PPI / FPrintScale; + neededSize := Round((prnSz * n + FLineSpacing * FScaleY * ratio * n) / ratio) + end + else + begin + ratio := FDefPPI / 96; + neededSize := Round((prnSz * n + FLineSpacing * ratio * n) / ratio * FScaleY); + end; + extraSize := neededSize - (Sz * n + Round(FLineSpacing * FScaleY) * n); + + if not FWysiwyg then + extraSize := 0; + + CalcRotatedCoords; + + GetMem(Ar, SizeOf(Integer) * n); + for i := 0 to n - 2 do + Ar[i] := Round(FLineSpacing * FScaleY) + Sz; + + if extraSize < 0 then + begin + extraSize := -extraSize; + add3 := -1; + end + else + add3 := 1; + + if n > 1 then + if extraSize < n then + IncArray(Ar, 0, n - 2, extraSize, add3) + else if n > 1 then + begin + add1 := extraSize div (n - 1) * add3; + for i := 0 to n - 2 do + Inc(Ar[i], add1); + IncArray(Ar, 0, n - 2, extraSize - add1 * (n - 1) * add3, add3) + end; + + SetBkMode(C.Handle, Transparent); + + for i := 0 to n - 1 do + begin + gx := 0; + al := HAlign; + par := Integer(FText.Objects[i]); + if (par and 1) <> 0 then + if HAlign in [haLeft, haBlock] then + gx := Round(FParagraphGap * FScaleX); + if (par and 2) <> 0 then + if HAlign = haBlock then + if FRTLReading then + al := haRight else + al := haLeft; + + DrawTextLine(C, FText[i], x + gx, y, dx - gx, i, al, fh, oldfh); + Inc(y, Round(Ar[i] * CosA)); + Inc(x, Round(Ar[i] * SinA)); + end; + + FreeMem(Ar, SizeOf(Integer) * n); + + if FRotation <> 0 then + begin + SelectObject(C.Handle, oldfh); + DeleteObject(fh); + end; + + finally + FCanvas.Unlock; + end; +end; + +function TfrxDrawText.UnusedSpace: Extended; +var + PrnSz: Integer; + n: Integer; + ratio: Extended; +begin + FCanvas.Lock; + try + PrnSz := -FCanvas.Font.Height; + ratio := FDefPPI / FScrPPI; + + // number of lines that will fit in the bounds + n := Trunc((FOriginalRect.Bottom - FOriginalRect.Top + 1) / + (PrnSz / ratio + FLineSpacing)); + if n = 0 then + Result := 0 + else + begin + Result := (FOriginalRect.Bottom - FOriginalRect.Top + 1) - + (PrnSz / ratio + FLineSpacing) * n; + if Result = 0 then + Result := 1e-4; + end; + finally + FCanvas.Unlock; + end; +end; + +function TfrxDrawText.CalcHeight: Extended; +var + PrnSz: Integer; + n: Integer; + ratio: Extended; +begin + n := FText.Count; + if n = 0 then + begin + Result := 0; + Exit; + end; + FCanvas.Lock; + try + PrnSz := -FCanvas.Font.Height; + finally + FCanvas.Unlock; + end; + ratio := FDefPPI / FScrPPI; + Result := (PrnSz / ratio + FLineSpacing) * n; +end; + +function TfrxDrawText.CalcWidth: Extended; +var + Sz: TSize; + s: WideString; + i, maxWidth, par: Integer; + ratio: Extended; +begin + if FText.Count = 0 then + begin + Result := 0; + Exit; + end; + + ratio := FDefPPI / FScrPPI; + maxWidth := 0; + FCanvas.Lock; + try + for i := 0 to FText.Count - 1 do + begin + s := FText[i]; + GetTextExtentPointW(FCanvas.Handle, PWideChar(s), Length(s), Sz); + Inc(Sz.cx, Round(Length(s) * FCharSpacing * ratio)); + + par := Integer(FText.Objects[i]); + if (par and 1) <> 0 then + Inc(Sz.cx, Round(FParagraphGap * ratio)); + + if maxWidth < Sz.cx then + maxWidth := Sz.cx; + end; + finally + FCanvas.Unlock; + end; + + Result := maxWidth / ratio; +end; + +function TfrxDrawText.LineHeight: Extended; +var + PrnSz: Integer; + ratio: Extended; +begin + FCanvas.Lock; + try + PrnSz := -FCanvas.Font.Height; + finally + FCanvas.Unlock; + end; + ratio := FDefPPI / FScrPPI; + Result := PrnSz / ratio + FLineSpacing; +end; + +function TfrxDrawText.GetOutBoundsText(var ParaBreak: Boolean): WideString; +var + PrnSz: Integer; + n, vl: Integer; + ratio: Extended; + Tag: TfrxHTMLTags; + cl: LongInt; +begin + ParaBreak := False; + Result := ''; + n := FText.Count; + if n = 0 then Exit; + + FCanvas.Lock; + try + PrnSz := -FCanvas.Font.Height; + ratio := FDefPPI / FScrPPI; + + // number of lines that will fit in the bounds + vl := Trunc((FOriginalRect.Bottom - FOriginalRect.Top + 1) / (PrnSz / ratio + FLineSpacing)); + if vl > n then + vl := n; + + if vl < FHTMLTags.Count then + begin + // deleting all outbounds text + while FText.Count > vl do + FText.Delete(FText.Count - 1); + + if Integer(FText.Objects[vl - 1]) in [0, 1] then + ParaBreak := True; + + Tag := FHTMLTags[vl]; + Result := Copy(FPlainText, Tag[0].Position, Length(FPlainText) - Tag[0].Position + 1); + if ParaBreak then + if (Length(Result) > 0) and (Result[1] = ' ') then + Delete(Result, 1, 1); + Delete(FPlainText, Tag[0].Position, Length(FPlainText) - Tag[0].Position + 1); + + if FHTMLTags.AllowTags then + begin + if fsBold in Tag[0].Style then + Result := '' + Result; + if fsItalic in Tag[0].Style then + Result := '' + Result; + if fsUnderline in Tag[0].Style then + Result := '' + Result; + cl := ColorToRGB(Tag[0].Color); + cl := (cl and $00FF0000) div 65536 + (cl and $000000FF) * 65536 + (cl and $0000FF00); + Result := '' + Result; + end; + end; + finally + FCanvas.Unlock; + end; +end; + +function TfrxDrawText.GetInBoundsText: WideString; +begin + Result := FPlainText; +end; + +function TfrxDrawText.IsPrinter(C: TCanvas): Boolean; +begin + Result := C is TfrxPrinterCanvas; +end; + +procedure TfrxDrawText.Lock; +begin + while FLocked do + Application.ProcessMessages; + FLocked := True; +end; + +procedure TfrxDrawText.Unlock; +begin + FLocked := False; +end; + +function TfrxDrawText.GetWrappedText: WideString; +begin + Result := FText.Text; +end; + +function TfrxDrawText.TextHeight: Extended; +var + PrnSz: Integer; + ratio: Extended; +begin + FCanvas.Lock; + try + PrnSz := -FCanvas.Font.Height; + finally + FCanvas.Unlock; + end; + ratio := FDefPPI / FScrPPI; + Result := PrnSz / ratio; +end; + +initialization + frxDrawText := TfrxDrawText.Create; + + +finalization + frxDrawText.Free; + + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxHTTPClient.pas b/official/4.2/LibD11/frxHTTPClient.pas new file mode 100644 index 0000000..c09a739 --- /dev/null +++ b/official/4.2/LibD11/frxHTTPClient.pas @@ -0,0 +1,614 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ HTTP connection client unit } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxHTTPClient; + +{$I frx.inc} + +interface + +uses + Windows, SysUtils, Classes, ScktComp, frxServerUtils, frxNetUtils, + frxGzip, frxMD5 +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxHTTPServerFields = class; + TfrxHTTPClientFields = class; + TfrxClientThread = class; + + TfrxHTTPClient = class(TComponent) + private + FActive: Boolean; + FAnswer: TStrings; + FBreaked: Boolean; + FClientFields: TfrxHTTPClientFields; + FErrors: TStrings; + FHeader: TStrings; + FHost: String; + FMIC: Boolean; + FPort: Integer; + FProxyHost: String; + FProxyPort: Integer; + FRetryCount: Integer; + FRetryTimeOut: Integer; + FServerFields: TfrxHTTPServerFields; + FStream: TMemoryStream; + FTempStream: TMemoryStream; + FThread: TfrxClientThread; + FTimeOut: Integer; + FProxyLogin: String; + FProxyPassword: String; + procedure DoConnect(Sender: TObject; Socket: TCustomWinSocket); + procedure DoDisconnect(Sender: TObject; Socket: TCustomWinSocket); + procedure DoError(Sender: TObject; Socket: TCustomWinSocket; + ErrorEvent: TErrorEvent; var ErrorCode: Integer); + procedure DoRead(Sender: TObject; Socket: TCustomWinSocket); + procedure SetActive(const Value: Boolean); + procedure SetClientFields(const Value: TfrxHTTPClientFields); + procedure SetServerFields(const Value: TfrxHTTPServerFields); + public + ParentThread: TThread; + StreamSize: Cardinal; + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Connect; + procedure Disconnect; + procedure Open; + procedure Close; + property Answer: TStrings read FAnswer write FAnswer; + property Breaked: Boolean read FBreaked; + property Errors: TStrings read FErrors write Ferrors; + property Header: TStrings read FHeader write FHeader; + property Stream: TMemoryStream read FStream write FStream; + published + property Active: Boolean read FActive write SetActive; + property ClientFields: TfrxHTTPClientFields read FClientFields write SetClientFields; + property Host: String read FHost write FHost; + property MIC: Boolean read FMIC write FMIC; + property Port: Integer read FPort write FPort; + property ProxyHost: String read FProxyHost write FProxyHost; + property ProxyPort: Integer read FProxyPort write FProxyPort; + property ProxyLogin: String read FProxyLogin write FProxyLogin; + property ProxyPassword: String read FProxyPassword write FProxyPassword; + property RetryCount: Integer read FRetryCount write FRetryCount; + property RetryTimeOut: Integer read FRetryTimeOut write FRetryTimeOut; + property ServerFields: TfrxHTTPServerFields read FServerFields write SetServerFields; + property TimeOut: Integer read FTimeOut write FTimeOut; + end; + + TfrxHTTPServerFields = class (TPersistent) + private + FAnswerCode: Integer; + FContentEncoding: String; + FContentMD5: String; + FContentLength: Integer; + FLocation: String; + FSessionId: String; + FCookie: String; + public + constructor Create; + procedure Assign(Source: TPersistent); override; + published + property AnswerCode: Integer read FAnswerCode write FAnswerCode; + property ContentEncoding: String read FContentEncoding write FContentEncoding; + property ContentMD5: String read FContentMD5 write FContentMD5; + property ContentLength: Integer read FContentLength write FContentLength; + property Location: String read FLocation write FLocation; + property SessionId: String read FSessionId write FSessionId; + property Cookie: String read FCookie write FCookie; + end; + + TfrxHTTPClientFields = class (TPersistent) + private + FAcceptEncoding: String; + FHost: String; + FHTTPVer: String; + FLogin: String; + FName: String; + FPassword: String; + FQueryType: TfrxHTTPQueryType; + FReferer: String; + FUserAgent: String; + FVariables: String; + FAccept: String; + FAcceptCharset: String; + FContentType: String; + FRange: String; + public + constructor Create; + procedure Assign(Source: TPersistent); override; + published + property AcceptEncoding: String read FAcceptEncoding write FAcceptEncoding; + property Accept: String read FAccept write FAccept; + property AcceptCharset: String read FAcceptCharset write FAcceptCharset; + property FileName: String read FName write FName; + property Host: String read FHost write FHost; + property HTTPVer: String read FHTTPVer write FHTTPVer; + property Login: String read FLogin write FLogin; + property Password: String read FPassword write FPassword; + property QueryType: TfrxHTTPQueryType read FQueryType write FQueryType; + property Referer: String read FReferer write FReferer; + property UserAgent: String read FUserAgent write FUserAgent; + property Variables: String read FVariables write FVariables; + property ContentType: String read FContentType write FContentType; + property Range: String read FRange write FRange; + end; + + TfrxClientThread = class (TThread) + protected + FClient: TfrxHTTPClient; + procedure DoOpen; + procedure Execute; override; + public + FSocket: TClientSocket; + constructor Create(Client: TfrxHTTPClient); + destructor Destroy; override; + end; + +implementation + +uses frxFileUtils; + +type + THackThread = class(TThread); + +{ TfrxHTTPServerFields } + +constructor TfrxHTTPServerFields.Create; +begin + FAnswerCode := 0; + FLocation := ''; + FContentEncoding := ''; + FContentMD5 := ''; + FContentLength := 0; +end; + +procedure TfrxHTTPServerFields.Assign(Source: TPersistent); +begin + if Source is TfrxHTTPServerFields then + begin + FAnswerCode := TfrxHTTPServerFields(Source).AnswerCode; + FLocation := TfrxHTTPServerFields(Source).Location; + FContentEncoding := TfrxHTTPServerFields(Source).ContentEncoding; + FContentMD5 := TfrxHTTPServerFields(Source).ContentMD5; + FContentLength := TfrxHTTPServerFields(Source).ContentLength; + end; +end; + +{ TfrxHTTPClientFields } + +constructor TfrxHTTPClientFields.Create; +begin + FQueryType := qtGet; + FHTTPVer := 'HTTP/1.0'; + FName := ''; + FUserAgent := 'FastReport/4.0'; + FHost := ''; + FAcceptEncoding := 'gzip'; + FLogin := ''; + FPassword := ''; + FReferer := ''; +end; + +procedure TfrxHTTPClientFields.Assign(Source: TPersistent); +begin + if Source is TfrxHTTPClientFields then + begin + FQueryType := TfrxHTTPClientFields(Source).QueryType; + FName := TfrxHTTPClientFields(Source).FileName; + FHTTPVer := TfrxHTTPClientFields(Source).HTTPVer; + FUserAgent := TfrxHTTPClientFields(Source).UserAgent; + FHost := TfrxHTTPClientFields(Source).Host; + FAcceptEncoding := TfrxHTTPClientFields(Source).AcceptEncoding; + FLogin := TfrxHTTPClientFields(Source).Login; + FPassword := TfrxHTTPClientFields(Source).Password; + FReferer := TfrxHTTPClientFields(Source).Referer; + end; +end; + +{ TfrxHTTPClient } + +constructor TfrxHTTPClient.Create(AOwner: TComponent); +begin + inherited; + FHeader := TStringList.Create; + FAnswer := TStringList.Create; + FStream := TMemoryStream.Create; + FTempStream := TMemoryStream.Create; + FErrors := TStringList.Create; + FHost := '127.0.0.1'; + FPort := 80; + FProxyHost := ''; + FProxyPort := 8080; + FActive := False; + FServerFields := TfrxHTTPServerFields.Create; + FClientFields := TfrxHTTPClientFields.Create; + FRetryTimeOut := 5; + FRetryCount := 3; + FTimeOut := 30; + FBreaked := False; + FMIC := True; + ParentThread := nil; + FThread := TfrxClientThread.Create(Self); + FThread.FSocket.OnConnect := DoConnect; + FThread.FSocket.OnRead := DoRead; + FThread.FSocket.OnDisconnect := DoDisconnect; + FThread.FSocket.OnError := DoError; +end; + +destructor TfrxHTTPClient.Destroy; +begin + Close; + PMessages; + while FActive do + PMessages; + FThread.Free; + FClientFields.Free; + FServerFields.Free; + FHeader.Free; + FAnswer.Free; + FStream.Free; + FTempStream.Free; + FErrors.Free; + inherited; +end; + +procedure TfrxHTTPClient.Connect; +var + ticks: Cardinal; + i: Integer; +begin + i := FRetryCount; + FBreaked := False; + repeat + FErrors.Clear; + FTempStream.Clear; + FActive := True; + if Length(FProxyHost) > 0 then + begin + FThread.FSocket.Host := FProxyHost; + FThread.FSocket.Address := FProxyHost; + FThread.FSocket.Port := FProxyPort; + end else + begin + FThread.FSocket.Host := FHost; + FThread.FSocket.Address := FHost; + FThread.FSocket.Port := FPort; + end; + FThread.FSocket.ClientType := ctNonBlocking; + FThread.Execute; + try + ticks := GetTickCount; + while FActive and (not FBreaked) do + begin + PMessages; + if (GetTickCount - ticks) > Cardinal(FTimeOut * 1000) then + begin + Errors.Add('Timeout expired (' + IntToStr(FTimeOut) + ')'); + break; + end; + end; + finally + Disconnect; + end; + if not FBreaked then + begin + if (Errors.Count = 0) and ((FServerFields.AnswerCode = 301) or + (FServerFields.AnswerCode = 302) or (FServerFields.AnswerCode = 303)) then + begin + i := FRetryCount; + FClientFields.FileName := FServerFields.Location; + end + else if (Errors.Count > 0) + and (FServerFields.AnswerCode <> 500) + and (FServerFields.AnswerCode <> 401) + and (FServerFields.AnswerCode <> 403) + and (FServerFields.AnswerCode <> 404) then + begin + Dec(i); + if i > 0 then + Sleep(FRetryTimeOut * 1000) + else + if FRetryCount > 1 then + Errors.Add('Retry count (' + IntToStr(FRetryCount) + ') exceed') + end else + i := 0; + end; + until (i = 0) or FBreaked; +end; + +procedure TfrxHTTPClient.Disconnect; +begin +// Close; + FThread.FSocket.Close; +// FThread.Terminate; +// if not FThread.Terminated then +// FThread.WaitFor; + FActive := False; +end; + +procedure TfrxHTTPClient.DoConnect(Sender: TObject; + Socket: TCustomWinSocket); +var + s, s1, s2: String; + m: TMemoryStream; +begin + FHeader.Clear; + if FClientFields.QueryType = qtGet then + s := 'GET' + else if FClientFields.QueryType = qtPost then + s := 'POST' + else if FClientFields.QueryType = qtHead then + s := 'HEAD' + else + s := ''; + if Length(FProxyHost) > 0 then + s1 := 'http://' + Host + ':' + IntToStr(FPort) + '/' + FClientFields.FileName + else + begin + if ((Length(FClientFields.FileName) > 0) and (FClientFields.FileName[1] = '/')) or (Pos('http://', FClientFields.FileName) = 1) then + s1 := FClientFields.FileName + else + s1 := '/' + FClientFields.FileName; + end; + s2 := FClientFields.Variables; + if (FClientFields.QueryType = qtGet) and (s2 <> '') then + s1 := s1 + '?' + s2; + FHeader.Add(s + ' ' + s1 + ' ' + FClientFields.HTTPVer); + if Length(FClientFields.Host) = 0 then + s := Socket.LocalAddress + else + s := FClientFields.Host; + FHeader.Add('Host: ' + Host); + if Length(FClientFields.UserAgent) > 0 then + FHeader.Add('User-Agent: ' + FClientFields.UserAgent); + if FClientFields.Accept <> '' then + FHeader.Add('Accept: ' + FClientFields.Accept); + if Length(FClientFields.AcceptEncoding) > 0 then + FHeader.Add('Accept-Encoding: ' + FClientFields.AcceptEncoding); + if FClientFields.AcceptCharset <> '' then + FHeader.Add('Accept-Charset: ' + FClientFields.AcceptCharset); + if (FProxyHost <> '') and (FProxyLogin <> '') then + FHeader.Add('Proxy-Authorization: Basic ' + Base64Encode(FProxyLogin + ':' + + FproxyPassword)); + if Length(FClientFields.Login) > 0 then + FHeader.Add('Authorization: Basic ' + Base64Encode(FClientFields.Login + ':' + + FClientFields.Password)); + FHeader.Add('Connection: close'); + if FClientFields.Referer <> '' then + FHeader.Add('Referer: ' + FClientFields.Referer); + if FClientFields.ContentType <> '' then + FHeader.Add('Content-Type: ' + FClientFields.ContentType); + if FServerFields.Cookie <> '' then + FHeader.Add('Cookie: ' + FServerFields.Cookie); + if FClientFields.Range <> '' then + FHeader.Add('Range: ' + FClientFields.Range); + if (FClientFields.QueryType = qtPost) and (s2 <> '') then + begin + FStream.Write(s2[1], Length(s2)); + FStream.Position := 0; + end; + if FStream.Size > 0 then + FHeader.Add('Content-Length: ' + IntToStr(FStream.Size)); + FHeader.Add(''); + try + m := TMemoryStream.Create; + try + m.Write(FHeader.Text[1], Length(FHeader.Text)); + if FStream.Size > 1 then + m.Write(FStream.Memory^, FStream.Size); + Socket.SendBuf(m.Memory^, m.Size); + finally + m.Free; + end + except + Errors.Add('Data send error'); + end; +end; + +procedure TfrxHTTPClient.DoDisconnect(Sender: TObject; + Socket: TCustomWinSocket); +var + i, j, Len: Integer; + s, s1, s2: String; + MICStream: TMemoryStream; + + function IsDigit(const c: Char): Boolean; + begin + Result := c in ['0'..'9']; + end; + +begin + FAnswer.Clear; + FStream.Clear; + if FTempStream.Size > 0 then + begin + FTempStream.Position := 0; + i := StreamSearch(FTempStream, 0, #13#10#13#10); + if i <> 0 then + begin + Len := i + 4; + StreamSize := FTempStream.Size - Len; + SetLength(s, Len); + FTempStream.Position := 0; + FTempStream.ReadBuffer(s[1], Len); + FAnswer.Text := s; + + i := Pos(#13#10, s); + s1 := Copy(s, 1, i - 1); + j := 0; + s2 := ''; + for i := 1 to Length(s1) do + begin + if IsDigit(s1[i]) then + begin + s2 := s2 + s1[i]; + Inc(j); + end else + if j = 3 then + break + else + begin + j := 0; + s2 := ''; + end; + end; + s1 := s2; + + if Length(s1) = 3 then + FServerFields.FAnswerCode := StrToInt(s1); + s1 := ParseHeaderField('Location: ', s); + if (Length(s1) > 0) and (s1[1] = '/') then + Delete(s1, 1, 1); + FServerFields.Location := s1; + FServerFields.ContentEncoding := LowerCase(ParseHeaderField('Content-Encoding: ', s)); + FServerFields.ContentMD5 := ParseHeaderField('Content-MD5: ', s); + s1 := ParseHeaderField('Set-Cookie: ', s); + if s1 <> '' then + FServerFields.Cookie := s1; + s1 := ParseHeaderField('SessionId: ', s); + if Length(s1) > 0 then + FServerFields.SessionId := s1; + s1 := ParseHeaderField('Content-length: ', s); + if Length(s1) > 0 then + FServerFields.ContentLength := StrToInt(s1); + s1 := GetHTTPErrorText(FServerFields.AnswerCode); + if Length(s1) > 0 then + Errors.Add(s1); + if Errors.Count = 0 then + begin + if FServerFields.ContentLength > 0 then + if ((FTempStream.Size - Len) <> FServerFields.ContentLength) and ((FServerFields.FAnswerCode = 200) or (FServerFields.FAnswerCode = 206)) then + Errors.Add('Received data size mismatch'); + if (Length(FServerFields.ContentMD5) > 0) and FMIC and (Errors.Count = 0) then + begin + MICStream := TMemoryStream.Create; + try + MICStream.CopyFrom(FTempStream, FTempStream.Size - Len); + if MD5Stream(MICStream) <> FServerFields.ContentMD5 then + Errors.Add('Message integrity checksum (MIC) error'); + finally + FTempStream.Position := Len; + MICStream.Free; + end; + end; + if Errors.Count = 0 then + if Pos('gzip', FServerFields.ContentEncoding) > 0 then + try + frxDecompressStream(FTempStream, FStream) + except + Errors.Add('Unpack data error') + end + else + FStream.CopyFrom(FTempStream, FTempStream.Size - Len); + end; + end else + Errors.Add('Bad header'); + FTempStream.Clear; + end + else if Errors.Count = 0 then + Errors.Add('Zero bytes received'); + if FStream.Size > 0 then + FStream.Position := 0; + FActive := False; +end; + +procedure TfrxHTTPClient.DoError(Sender: TObject; Socket: TCustomWinSocket; + ErrorEvent: TErrorEvent; var ErrorCode: Integer); +begin + Errors.Add(GetSocketErrorText(ErrorCode)); + FActive := False; + ErrorCode := 0; +end; + +procedure TfrxHTTPClient.DoRead(Sender: TObject; Socket: TCustomWinSocket); +var + buf: PChar; + i, j: Integer; +begin + i := Socket.ReceiveLength; + GetMem(buf, i); + j := i; + try + try + while j > 0 do + begin + j := Socket.ReceiveBuf(buf^, i); + FTempStream.Write(buf^, j); + end; + except + Errors.Add('Data receive error.') + end; + finally + FreeMem(buf); + end; +end; + +procedure TfrxHTTPClient.SetActive(const Value: Boolean); +begin + if Value then Connect + else Disconnect; +end; + +procedure TfrxHTTPClient.Close; +begin + FBreaked := True; + Active := False; +end; + +procedure TfrxHTTPClient.Open; +begin + Active := True; +end; + +procedure TfrxHTTPClient.SetServerFields(const Value: TfrxHTTPServerFields); +begin + FServerFields.Assign(Value); +end; + +procedure TfrxHTTPClient.SetClientFields(const Value: TfrxHTTPClientFields); +begin + FClientFields.Assign(Value); +end; + +{ TfrxClientThread } + +constructor TfrxClientThread.Create(Client: TfrxHTTPClient); +begin + inherited Create(True); + FClient := Client; + FreeOnTerminate := False; + FSocket := TClientSocket.Create(nil); +end; + +destructor TfrxClientThread.Destroy; +begin + FSocket.Close; + FSocket.Free; + inherited; +end; + +procedure TfrxClientThread.DoOpen; +begin +// +end; + +procedure TfrxClientThread.Execute; +begin + FSocket.Open; +// DoOpen; +end; + +end. diff --git a/official/4.2/LibD11/frxIBO4.bpk b/official/4.2/LibD11/frxIBO4.bpk new file mode 100644 index 0000000..22710e8 --- /dev/null +++ b/official/4.2/LibD11/frxIBO4.bpk @@ -0,0 +1,190 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = frxIBO4.bpl +OBJFILES = frxRegIBO.obj frxIBO4.obj +RESFILES = frx4.res frxReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +LIBRARIES = +SPARELIBS = VCL40.lib +PACKAGES = vcl40.bpi vclsmp40.bpi fs4.bpi frx4.bpi IBO40CRT_C4.bpi IBO40FRT_C4.bpi IBO40TRT_C4.bpi IBO40VRT_C4.bpi IBO40XRT_C4.bpi + +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release;..\FastScript +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -D"FastReport 4.0 IBO Components" -aa \ + -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxIBO4.cpp b/official/4.2/LibD11/frxIBO4.cpp new file mode 100644 index 0000000..3fcbcba --- /dev/null +++ b/official/4.2/LibD11/frxIBO4.cpp @@ -0,0 +1,24 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frx4.res"); +USEPACKAGE("vcl40.bpi"); +USEUNIT("frxRegIBO.pas"); +USERES("frxReg.dcr"); +USEPACKAGE("IBO40CRT_C4.bpi"); +USEPACKAGE("IBO40FRT_C4.bpi"); +USEPACKAGE("IBO40TRT_C4.bpi"); +USEPACKAGE("IBO40VRT_C4.bpi"); +USEPACKAGE("IBO40XRT_C4.bpi"); +USEPACKAGE("fs4.bpi"); +USEPACKAGE("frx4.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxIBO4.dpk b/official/4.2/LibD11/frxIBO4.dpk new file mode 100644 index 0000000..22ef3d8 --- /dev/null +++ b/official/4.2/LibD11/frxIBO4.dpk @@ -0,0 +1,44 @@ +// Package file for Delphi 4 + +package frxIBO4; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + IBO40CRT_D4, + IBO40FRT_D4, + IBO40TRT_D4, + IBO40VRT_D4, + IBO40XRT_D4, + frx4, + fs4; + +contains + frxIBOSet in 'frxIBOSet.pas'; + +end. diff --git a/official/4.2/LibD11/frxIBO5.bpk b/official/4.2/LibD11/frxIBO5.bpk new file mode 100644 index 0000000..2257ae9 --- /dev/null +++ b/official/4.2/LibD11/frxIBO5.bpk @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxIBO5.cpp b/official/4.2/LibD11/frxIBO5.cpp new file mode 100644 index 0000000..0439cc5 --- /dev/null +++ b/official/4.2/LibD11/frxIBO5.cpp @@ -0,0 +1,24 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frx5.res"); +USEUNIT("frxRegIBO.pas"); +USERES("frxReg.dcr"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("IBO40CRT_C5.bpi"); +USEPACKAGE("IBO40FRT_C5.bpi"); +USEPACKAGE("IBO40TRT_C5.bpi"); +USEPACKAGE("IBO40VRT_C5.bpi"); +USEPACKAGE("IBO40XRT_C5.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("frx5.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxIBO5.dpk b/official/4.2/LibD11/frxIBO5.dpk new file mode 100644 index 0000000..ddc33e4 --- /dev/null +++ b/official/4.2/LibD11/frxIBO5.dpk @@ -0,0 +1,44 @@ +// Package file for Delphi 5 + +package frxIBO5; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + IBO40CRT_D5, + IBO40FRT_D5, + IBO40TRT_D5, + IBO40VRT_D5, + IBO40XRT_D5, + frx5, + fs5; + +contains + frxIBOSet in 'frxIBOSet.pas'; + +end. diff --git a/official/4.2/LibD11/frxIBO6.bpk b/official/4.2/LibD11/frxIBO6.bpk new file mode 100644 index 0000000..e615af5 --- /dev/null +++ b/official/4.2/LibD11/frxIBO6.bpk @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxIBO6.cpp b/official/4.2/LibD11/frxIBO6.cpp new file mode 100644 index 0000000..48ce892 --- /dev/null +++ b/official/4.2/LibD11/frxIBO6.cpp @@ -0,0 +1,18 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frxIBO6.dpk b/official/4.2/LibD11/frxIBO6.dpk new file mode 100644 index 0000000..fe3a07f --- /dev/null +++ b/official/4.2/LibD11/frxIBO6.dpk @@ -0,0 +1,44 @@ +// Package file for Delphi 6 + +package frxIBO6; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + IBO40CRT_D6, + IBO40FRT_D6, + IBO40TRT_D6, + IBO40VRT_D6, + IBO40XRT_D6, + frx6, + fs6; + +contains + frxIBOSet in 'frxIBOSet.pas'; + +end. diff --git a/official/4.2/LibD11/frxIBO7.dpk b/official/4.2/LibD11/frxIBO7.dpk new file mode 100644 index 0000000..aa9d09e --- /dev/null +++ b/official/4.2/LibD11/frxIBO7.dpk @@ -0,0 +1,44 @@ +// Package file for Delphi 7 + +package frxIBO7; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + IBO40CRT_D7, + IBO40FRT_D7, + IBO40TRT_D7, + IBO40VRT_D7, + IBO40XRT_D7, + frx7, + fs7; + +contains + frxIBOSet in 'frxIBOSet.pas'; + +end. diff --git a/official/4.2/LibD11/frxIBOSet.pas b/official/4.2/LibD11/frxIBOSet.pas new file mode 100644 index 0000000..1370bd6 --- /dev/null +++ b/official/4.2/LibD11/frxIBOSet.pas @@ -0,0 +1,398 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ IBO DB dataset } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxIBOSet; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, frxClass, IB_Components, IB_Header +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxIBODataset = class(TfrxCustomDBDataset) + private + FBookmark: String; + FDataSet: TIB_DataSet; + FDataSource: TIB_DataSource; + FEof: Boolean; + procedure SetDataSet(Value: TIB_DataSet); + procedure SetDataSource(Value: TIB_DataSource); + function DataSetActive: Boolean; + function IsDataSetStored: Boolean; + protected + FDS: TIB_DataSet; + function GetDisplayText(Index: String): WideString; override; + function GetDisplayWidth(Index: String): Integer; override; + function GetFieldType(Index: String): TfrxFieldType; override; + function GetValue(Index: String): Variant; override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + procedure Initialize; override; + procedure Finalize; override; + procedure First; override; + procedure Next; override; + procedure Prior; override; + procedure Open; override; + procedure Close; override; + function Eof: Boolean; override; + + function GetDataSet: TIB_DataSet; + function IsBlobField(const fName: String): Boolean; override; + procedure AssignBlobTo(const fName: String; Obj: TObject); override; + procedure GetFieldList(List: TStrings); override; + published + property DataSet: TIB_DataSet read FDataSet write SetDataSet stored IsDataSetStored; + property DataSource: TIB_DataSource read FDataSource write SetDataSource stored IsDataSetStored; + end; + + +implementation + +uses frxUtils, frxRes, frxUnicodeUtils; + +type + EDSError = class(Exception); + + +{ TfrxIBODataset } + +procedure TfrxIBODataset.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if Operation = opRemove then + if AComponent = FDataSource then + DataSource := nil + else if AComponent = FDataSet then + DataSet := nil +end; + +procedure TfrxIBODataset.SetDataSet(Value: TIB_DataSet); +begin + FDataSet := Value; + if Value <> nil then + FDataSource := nil; + FDS := GetDataSet; +end; + +procedure TfrxIBODataset.SetDataSource(Value: TIB_DataSource); +begin + FDataSource := Value; + if Value <> nil then + FDataSet := nil; + FDS := GetDataSet; +end; + +function TfrxIBODataset.DataSetActive: Boolean; +begin + Result := (FDS <> nil) and FDS.Active; +end; + +function TfrxIBODataset.GetDataset: TIB_DataSet; +begin + if FDataSet <> nil then + Result := FDataSet + else if (FDataSource <> nil) and (FDataSource.DataSet <> nil) then + Result := FDataSource.DataSet + else + Result := nil; +end; + +function TfrxIBODataset.IsDataSetStored: Boolean; +begin + Result := Report = nil; +end; + +procedure TfrxIBODataset.Initialize; +begin + if FDS = nil then + raise Exception.Create(Format(frxResources.Get('dbNotConn'), [Name])); + + FEof := False; + FInitialized := False; +end; + +procedure TfrxIBODataset.Finalize; +begin + if FDS = nil then Exit; + if FBookMark <> '' then + FDS.Bookmark := FBookmark; + FBookMark := ''; + + if CloseDataSource then + Close; + FInitialized := False; +end; + +procedure TfrxIBODataset.Open; +var + i: Integer; +begin + if FInitialized then + Exit; + + FInitialized := True; + FDS.Open; + if (RangeBegin = rbCurrent) or (RangeEnd = reCurrent) then + FBookmark := FDS.Bookmark else + FBookmark := ''; + + GetFieldList(Fields); + for i := 0 to Fields.Count - 1 do + Fields.Objects[i] := FDS.FindField(ConvertAlias(Fields[i])); + + inherited; +end; + +procedure TfrxIBODataset.Close; +begin + inherited; + + if FBookMark <> '' then + FDS.Bookmark := FBookmark; + FBookMark := ''; + + FInitialized := False; + FDS.Close; +end; + +procedure TfrxIBODataset.First; +begin + if not FInitialized then + Open; + + if RangeBegin = rbFirst then + FDS.First else + FDS.Bookmark := FBookmark; + FEof := False; + inherited First; +end; + +procedure TfrxIBODataset.Next; +begin + if not FInitialized then + Open; + + FEof := False; + if RangeEnd = reCurrent then + begin + if FDS.Bookmark = FBookmark then + FEof := True; + Exit; + end; + if not Eof then FDS.Next; + inherited Next; +end; + +procedure TfrxIBODataset.Prior; +begin + if not FInitialized then + Open; + + FDS.Prior; + inherited Prior; +end; + +function TfrxIBODataset.Eof: Boolean; +begin + if not FInitialized then + Open; + + Result := inherited Eof or FDS.Eof or FEof; + if FDS.Eof then + begin + if not FDS.Bof then + try + FDS.Prior; + except + end; + FEof := True; + end; +end; + +function TfrxIBODataset.GetDisplayText(Index: String): WideString; +var + i: Integer; +begin + if not FInitialized then + Open; + + if DataSetActive then + if Fields.Count = 0 then + Result := FDS.FieldByName(Index).DisplayText + else + begin + i := Fields.IndexOf(Index); + if i <> -1 then + Result := TIB_Column(Fields.Objects[i]).DisplayText + else + begin + Result := frxResources.Get('dbFldNotFound') + ' ' + UserName + '."' + + Index + '"'; + ReportRef.Errors.Add(ReportRef.CurObject + ': ' + Result); + end; + end + else + Result := UserName + '."' + Index + '"'; +end; + +function TfrxIBODataset.GetValue(Index: String): Variant; +var + i: Integer; + f: TIB_Column; +begin + if not FInitialized then + Open; + + i := Fields.IndexOf(Index); + if i <> -1 then + begin + f := TIB_Column(Fields.Objects[i]); + if f.IsCurrencyDataType then + Result := f.AsCurrency + else + Result := f.Value + end + else + begin + Result := Null; + ReportRef.Errors.Add(ReportRef.CurObject + ': ' + + frxResources.Get('dbFldNotFound') + ' ' + UserName + '."' + Index + '"'); + end; +end; + +function TfrxIBODataset.GetDisplayWidth(Index: String): Integer; +var + f: TIB_Column; +// fDef: TFieldDef; +begin + Result := 10; + Index := ConvertAlias(Index); + f := FDS.FindField(Index); + if f <> nil then + Result := f.DisplayWidth div 7 +{ else + begin + try + if not FDS.FieldDefs.Updated then + FDS.FieldDefs.Update; + except + end; + fDef := FDS.FieldDefs.Find(Index); + if fDef <> nil then + case fDef.DataType of + ftString: Result := fDef.Size; + ftLargeInt: Result := 15; + ftDateTime: Result := 20; + end; + end;} +end; + +function TfrxIBODataset.GetFieldType(Index: String): TfrxFieldType; +var + f: TIB_Column; +begin + Result := fftNumeric; + f := FDS.FindField(ConvertAlias(Index)); + if f <> nil then + if (f.SqlType = SQL_TEXT) or (f.SqlType = SQL_TEXT_) or + (f.SqlType = SQL_VARYING) or (f.SqlType = SQL_VARYING_) then + Result := fftString + else if f.IsBoolean then + Result := fftBoolean; +end; + +procedure TfrxIBODataset.AssignBlobTo(const fName: String; Obj: TObject); +var + Field: TIB_Column; + BlobStream: TStream; + sl: TStringList; +begin + if not FInitialized then + Open; + Field := TIB_Column(Fields.Objects[Fields.IndexOf(fName)]); + + if Obj is TWideStrings then + begin + BlobStream := TMemoryStream.Create; + sl := TStringList.Create; + try + Field.AssignTo(BlobStream); + BlobStream.Position := 0; + sl.LoadFromStream(BlobStream); + TWideStrings(Obj).Assign(sl); + finally + BlobStream.Free; + sl.Free; + end; + end + else if Obj is TStream then + begin + Field.AssignTo(Obj); + TStream(Obj).Position := 0; + end; +end; + +procedure TfrxIBODataset.GetFieldList(List: TStrings); +var + i: Integer; + tempList: TStringList; +begin + List.Clear; + tempList := TStringList.Create; + + if FieldAliases.Count = 0 then + begin + if FDS <> nil then + try + FDS.Prepare; + FDS.GetFieldNamesList(tempList); + for i := 0 to tempList.Count - 1 do + List.Add(Copy(tempList[i], Pos('.', tempList[i]) + 1, 255)); + except + end; + end + else + begin + for i := 0 to FieldAliases.Count - 1 do + List.Add(FieldAliases.Values[FieldAliases.Names[i]]); + end; + + tempList.Free; +end; + +function TfrxIBODataset.IsBlobField(const fName: String): Boolean; +var + Field: TIB_Column; + i: Integer; +begin + if not FInitialized then + Open; + + Result := False; + i := Fields.IndexOf(fName); + if i <> -1 then + begin + Field := TIB_Column(Fields.Objects[i]); + Result := (Field <> nil) and (Field.SQLType >= 520) and (Field.SQLType <= 541); + end; +end; + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxIBX10.bdsproj b/official/4.2/LibD11/frxIBX10.bdsproj new file mode 100644 index 0000000..1537b93 --- /dev/null +++ b/official/4.2/LibD11/frxIBX10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxIBX10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxIBX10.dpk b/official/4.2/LibD11/frxIBX10.dpk new file mode 100644 index 0000000..acb9bb2 --- /dev/null +++ b/official/4.2/LibD11/frxIBX10.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2006 + +package frxIBX10; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + frx10, + frxDB10, +{$IFDEF QBUILDER} + fqb100, +{$ENDIF} + fs10, + fsIBX10; + +contains + frxIBXComponents in 'frxIBXComponents.pas', + frxIBXEditor in 'frxIBXEditor.pas', + frxIBXRTTI in 'frxIBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxIBX11.bdsproj b/official/4.2/LibD11/frxIBX11.bdsproj new file mode 100644 index 0000000..2fa6701 --- /dev/null +++ b/official/4.2/LibD11/frxIBX11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxIBX11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxIBX11.dpk b/official/4.2/LibD11/frxIBX11.dpk new file mode 100644 index 0000000..71455e6 --- /dev/null +++ b/official/4.2/LibD11/frxIBX11.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2007 + +package frxIBX11; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + frx11, + frxDB11, +{$IFDEF QBUILDER} + fqb110, +{$ENDIF} + fs11, + fsIBX11; + +contains + frxIBXComponents in 'frxIBXComponents.pas', + frxIBXEditor in 'frxIBXEditor.pas', + frxIBXRTTI in 'frxIBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxIBX5.bpk b/official/4.2/LibD11/frxIBX5.bpk new file mode 100644 index 0000000..079a801 --- /dev/null +++ b/official/4.2/LibD11/frxIBX5.bpk @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxIBX5.cpp b/official/4.2/LibD11/frxIBX5.cpp new file mode 100644 index 0000000..be155d1 --- /dev/null +++ b/official/4.2/LibD11/frxIBX5.cpp @@ -0,0 +1,31 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("frxIBX5.res"); +USEPACKAGE("vcl50.bpi"); +USEUNIT("frxIBXReg.pas"); +USEUNIT("frxIBXComponents.pas"); +USEUNIT("frxIBXEditor.pas"); +USEUNIT("frxIBXRTTI.pas"); +USERES("frxIBXReg.dcr"); +USEPACKAGE("vcldb50.bpi"); +USEPACKAGE("vclib50.bpi"); +USEPACKAGE("frx5.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("frxDB5.bpi"); +USEPACKAGE("fsIBX5.bpi"); +USEPACKAGE("fqb50.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxIBX5.dpk b/official/4.2/LibD11/frxIBX5.dpk new file mode 100644 index 0000000..48f636f --- /dev/null +++ b/official/4.2/LibD11/frxIBX5.dpk @@ -0,0 +1,48 @@ +// Package file for Delphi 5 + +package frxIBX5; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + VCLDB50, + VCLIB50, + frx5, + frxDB5, +{$IFDEF QBUILDER} + fqb50, +{$ENDIF} + fs5, + fsIBX5; + +contains + frxIBXComponents in 'frxIBXComponents.pas', + frxIBXEditor in 'frxIBXEditor.pas', + frxIBXRTTI in 'frxIBXRTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxIBX5.res b/official/4.2/LibD11/frxIBX5.res new file mode 100644 index 0000000..da3d366 Binary files /dev/null and b/official/4.2/LibD11/frxIBX5.res differ diff --git a/official/4.2/LibD11/frxIBX6.bpk b/official/4.2/LibD11/frxIBX6.bpk new file mode 100644 index 0000000..903afcf --- /dev/null +++ b/official/4.2/LibD11/frxIBX6.bpk @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=1 +Item0=_DEBUG + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxIBX6.cpp b/official/4.2/LibD11/frxIBX6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/frxIBX6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frxIBX6.dpk b/official/4.2/LibD11/frxIBX6.dpk new file mode 100644 index 0000000..e952627 --- /dev/null +++ b/official/4.2/LibD11/frxIBX6.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 6 + +package frxIBX6; + +{$I frx.inc} + +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + frx6, + frxDB6, +{$IFDEF QBUILDER} + fqb60, +{$ENDIF} + fs6, + fsIBX6; + +contains + frxIBXComponents in 'frxIBXComponents.pas', + frxIBXEditor in 'frxIBXEditor.pas', + frxIBXRTTI in 'frxIBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxIBX6.res b/official/4.2/LibD11/frxIBX6.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frxIBX6.res differ diff --git a/official/4.2/LibD11/frxIBX7.dpk b/official/4.2/LibD11/frxIBX7.dpk new file mode 100644 index 0000000..0d29a5a --- /dev/null +++ b/official/4.2/LibD11/frxIBX7.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 7 + +package frxIBX7; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + frx7, + frxDB7, +{$IFDEF QBUILDER} + fqb70, +{$ENDIF} + fs7, + fsIBX7; + +contains + frxIBXComponents in 'frxIBXComponents.pas', + frxIBXEditor in 'frxIBXEditor.pas', + frxIBXRTTI in 'frxIBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxIBX9.bdsproj b/official/4.2/LibD11/frxIBX9.bdsproj new file mode 100644 index 0000000..eb0741b --- /dev/null +++ b/official/4.2/LibD11/frxIBX9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxIBX9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxIBX9.dpk b/official/4.2/LibD11/frxIBX9.dpk new file mode 100644 index 0000000..2ad5953 --- /dev/null +++ b/official/4.2/LibD11/frxIBX9.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2005 + +package frxIBX9; + +{$I frx.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + frx9, + frxDB9, +{$IFDEF QBUILDER} + fqb90, +{$ENDIF} + fs9, + fsIBX9; + +contains + frxIBXComponents in 'frxIBXComponents.pas', + frxIBXEditor in 'frxIBXEditor.pas', + frxIBXRTTI in 'frxIBXRTTI.pas'; + + +end. diff --git a/official/4.2/LibD11/frxIBXComponents.pas b/official/4.2/LibD11/frxIBXComponents.pas new file mode 100644 index 0000000..bd0d46e --- /dev/null +++ b/official/4.2/LibD11/frxIBXComponents.pas @@ -0,0 +1,511 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ IBX enduser components } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxIBXComponents; + +interface + +{$I frx.inc} + +uses + Windows, Classes, frxClass, frxCustomDB, DB, IBDatabase, IBTable, IBQuery +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF QBUILDER} +, fqbClass +{$ENDIF}; + + +type + TfrxIBXComponents = class(TfrxDBComponents) + private + FDefaultDatabase: TIBDatabase; + FOldComponents: TfrxIBXComponents; + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + function GetDescription: String; override; + published + property DefaultDatabase: TIBDatabase read FDefaultDatabase write FDefaultDatabase; + end; + + TfrxIBXDatabase = class(TfrxCustomDatabase) + private + FDatabase: TIBDatabase; + FTransaction: TIBTransaction; + function GetSQLDialect: Integer; + procedure SetSQLDialect(const Value: Integer); + protected + procedure SetConnected(Value: Boolean); override; + procedure SetDatabaseName(const Value: String); override; + procedure SetLoginPrompt(Value: Boolean); override; + procedure SetParams(Value: TStrings); override; + function GetConnected: Boolean; override; + function GetDatabaseName: String; override; + function GetLoginPrompt: Boolean; override; + function GetParams: TStrings; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + class function GetDescription: String; override; + procedure SetLogin(const Login, Password: String); override; + property Database: TIBDatabase read FDatabase; + published + property DatabaseName; + property LoginPrompt; + property Params; + property SQLDialect: Integer read GetSQLDialect write SetSQLDialect; + property Connected; + end; + + TfrxIBXTable = class(TfrxCustomTable) + private + FDatabase: TfrxIBXDatabase; + FTable: TIBTable; + procedure SetDatabase(const Value: TfrxIBXDatabase); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure SetMaster(const Value: TDataSource); override; + procedure SetMasterFields(const Value: String); override; + procedure SetIndexFieldNames(const Value: String); override; + procedure SetIndexName(const Value: String); override; + procedure SetTableName(const Value: String); override; + function GetIndexFieldNames: String; override; + function GetIndexName: String; override; + function GetTableName: String; override; + public + constructor Create(AOwner: TComponent); override; + constructor DesignCreate(AOwner: TComponent; Flags: Word); override; + class function GetDescription: String; override; + procedure BeforeStartReport; override; + property Table: TIBTable read FTable; + published + property Database: TfrxIBXDatabase read FDatabase write SetDatabase; + end; + + TfrxIBXQuery = class(TfrxCustomQuery) + private + FDatabase: TfrxIBXDatabase; + FQuery: TIBQuery; + procedure SetDatabase(const Value: TfrxIBXDatabase); + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure SetMaster(const Value: TDataSource); override; + procedure SetSQL(Value: TStrings); override; + function GetSQL: TStrings; override; + public + constructor Create(AOwner: TComponent); override; + constructor DesignCreate(AOwner: TComponent; Flags: Word); override; + class function GetDescription: String; override; + procedure BeforeStartReport; override; + procedure UpdateParams; override; +{$IFDEF QBUILDER} + function QBEngine: TfqbEngine; override; +{$ENDIF} + property Query: TIBQuery read FQuery; + published + property Database: TfrxIBXDatabase read FDatabase write SetDatabase; + end; + +{$IFDEF QBUILDER} + TfrxEngineIBX = class(TfqbEngine) + private + FQuery: TIBQuery; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure ReadTableList(ATableList: TStrings); override; + procedure ReadFieldList(const ATableName: string; var AFieldList: TfqbFieldList); override; + function ResultDataSet: TDataSet; override; + procedure SetSQL(const Value: string); override; + end; +{$ENDIF} + +var + IBXComponents: TfrxIBXComponents; + + +implementation + +uses + frxIBXRTTI, +{$IFNDEF NO_EDITORS} + frxIBXEditor, +{$ENDIF} + frxDsgnIntf, frxRes; + + +{ TfrxDBComponents } + +constructor TfrxIBXComponents.Create(AOwner: TComponent); +begin + inherited; + FOldComponents := IBXComponents; + IBXComponents := Self; +end; + +destructor TfrxIBXComponents.Destroy; +begin + if IBXComponents = Self then + IBXComponents := FOldComponents; + inherited; +end; + +function TfrxIBXComponents.GetDescription: String; +begin + Result := 'IBX'; +end; + +procedure TfrxIBXComponents.Notification(AComponent: TComponent; + Operation: TOperation); +begin + inherited; + if (AComponent = FDefaultDatabase) and (Operation = opRemove) then + FDefaultDatabase := nil; +end; + + +{ TfrxIBXDatabase } + +constructor TfrxIBXDatabase.Create(AOwner: TComponent); +begin + inherited; + FDatabase := TIBDatabase.Create(nil); + FTransaction := TIBTransaction.Create(nil); + FDatabase.DefaultTransaction := FTransaction; + Component := FDatabase; +end; + +destructor TfrxIBXDatabase.Destroy; +begin + FTransaction.Free; + inherited; +end; + +class function TfrxIBXDatabase.GetDescription: String; +begin + Result := frxResources.Get('obIBXDB'); +end; + +function TfrxIBXDatabase.GetConnected: Boolean; +begin + Result := FDatabase.Connected; +end; + +function TfrxIBXDatabase.GetDatabaseName: String; +begin + Result := FDatabase.DatabaseName; +end; + +function TfrxIBXDatabase.GetLoginPrompt: Boolean; +begin + Result := FDatabase.LoginPrompt; +end; + +function TfrxIBXDatabase.GetParams: TStrings; +begin + Result := FDatabase.Params; +end; + +function TfrxIBXDatabase.GetSQLDialect: Integer; +begin + Result := FDatabase.SQLDialect; +end; + +procedure TfrxIBXDatabase.SetConnected(Value: Boolean); +begin + BeforeConnect(Value); + FDatabase.Connected := Value; + FTransaction.Active := Value; +end; + +procedure TfrxIBXDatabase.SetDatabaseName(const Value: String); +begin + FDatabase.DatabaseName := Value; +end; + +procedure TfrxIBXDatabase.SetLoginPrompt(Value: Boolean); +begin + FDatabase.LoginPrompt := Value; +end; + +procedure TfrxIBXDatabase.SetParams(Value: TStrings); +begin + FDatabase.Params := Value; +end; + +procedure TfrxIBXDatabase.SetSQLDialect(const Value: Integer); +begin + FDatabase.SQLDialect := Value; +end; + +procedure TfrxIBXDatabase.SetLogin(const Login, Password: String); +begin + Params.Text := 'user_name=' + Login + #13#10 + 'password=' + Password; +end; + + +{ TfrxIBXTable } + +constructor TfrxIBXTable.Create(AOwner: TComponent); +begin + FTable := TIBTable.Create(nil); + DataSet := FTable; + SetDatabase(nil); + inherited; +end; + +constructor TfrxIBXTable.DesignCreate(AOwner: TComponent; Flags: Word); +var + i: Integer; + l: TList; +begin + inherited; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + if TObject(l[i]) is TfrxIBXDatabase then + begin + SetDatabase(TfrxIBXDatabase(l[i])); + break; + end; +end; + +class function TfrxIBXTable.GetDescription: String; +begin + Result := frxResources.Get('obIBXTb'); +end; + +procedure TfrxIBXTable.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FDatabase) then + SetDatabase(nil); +end; + +procedure TfrxIBXTable.SetDatabase(const Value: TfrxIBXDatabase); +begin + FDatabase := Value; + if Value <> nil then + FTable.Database := Value.Database + else if IBXComponents <> nil then + FTable.Database := IBXComponents.DefaultDatabase + else + FTable.Database := nil; + DBConnected := FTable.Database <> nil; +end; + +function TfrxIBXTable.GetIndexFieldNames: String; +begin + Result := FTable.IndexFieldNames; +end; + +function TfrxIBXTable.GetIndexName: String; +begin + Result := FTable.IndexName; +end; + +function TfrxIBXTable.GetTableName: String; +begin + Result := FTable.TableName; +end; + +procedure TfrxIBXTable.SetIndexFieldNames(const Value: String); +begin + FTable.IndexFieldNames := Value; +end; + +procedure TfrxIBXTable.SetIndexName(const Value: String); +begin + FTable.IndexName := Value; +end; + +procedure TfrxIBXTable.SetTableName(const Value: String); +begin + FTable.TableName := Value; +end; + +procedure TfrxIBXTable.SetMaster(const Value: TDataSource); +begin + FTable.MasterSource := Value; +end; + +procedure TfrxIBXTable.SetMasterFields(const Value: String); +begin + FTable.MasterFields := Value; +end; + +procedure TfrxIBXTable.BeforeStartReport; +begin + SetDatabase(FDatabase); +end; + + +{ TfrxIBXQuery } + +constructor TfrxIBXQuery.Create(AOwner: TComponent); +begin + FQuery := TIBQuery.Create(nil); + Dataset := FQuery; + SetDatabase(nil); + inherited; +end; + +constructor TfrxIBXQuery.DesignCreate(AOwner: TComponent; Flags: Word); +var + i: Integer; + l: TList; +begin + inherited; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + if TObject(l[i]) is TfrxIBXDatabase then + begin + SetDatabase(TfrxIBXDatabase(l[i])); + break; + end; +end; + +class function TfrxIBXQuery.GetDescription: String; +begin + Result := frxResources.Get('obIBXQ'); +end; + +procedure TfrxIBXQuery.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (Operation = opRemove) and (AComponent = FDatabase) then + SetDatabase(nil); +end; + +procedure TfrxIBXQuery.SetDatabase(const Value: TfrxIBXDatabase); +begin + FDatabase := Value; + if Value <> nil then + FQuery.Database := Value.Database + else if IBXComponents <> nil then + FQuery.Database := IBXComponents.DefaultDatabase + else + FQuery.Database := nil; + DBConnected := FQuery.Database <> nil; +end; + +procedure TfrxIBXQuery.SetMaster(const Value: TDataSource); +begin + FQuery.DataSource := Value; +end; + +procedure TfrxIBXQuery.SetSQL(Value: TStrings); +begin + FQuery.SQL := Value; +end; + +function TfrxIBXQuery.GetSQL: TStrings; +begin + Result := FQuery.SQL; +end; + +procedure TfrxIBXQuery.UpdateParams; +begin + frxParamsToTParams(Self, FQuery.Params); +end; + +procedure TfrxIBXQuery.BeforeStartReport; +begin + SetDatabase(FDatabase); +end; + +{$IFDEF QBUILDER} +function TfrxIBXQuery.QBEngine: TfqbEngine; +begin + Result := TfrxEngineIBX.Create(nil); + TfrxEngineIBX(Result).FQuery.Database := FQuery.Database; +end; +{$ENDIF} + + +{$IFDEF QBUILDER} +constructor TfrxEngineIBX.Create(AOwner: TComponent); +begin + inherited; + FQuery := TIBQuery.Create(Self); +end; + +destructor TfrxEngineIBX.Destroy; +begin + FQuery.Free; + inherited; +end; + +procedure TfrxEngineIBX.ReadFieldList(const ATableName: string; + var AFieldList: TfqbFieldList); +var + TempTable: TIBTable; + Fields: TFieldDefs; + i: Integer; + tmpField: TfqbField; +begin + AFieldList.Clear; + TempTable := TIBTable.Create(Self); + TempTable.Database := FQuery.Database; + TempTable.TableName := ATableName; + Fields := TempTable.FieldDefs; + try + try + TempTable.Active := True; + tmpField:= TfqbField(AFieldList.Add); + tmpField.FieldName := '*'; + for i := 0 to Fields.Count - 1 do + begin + tmpField := TfqbField(AFieldList.Add); + tmpField.FieldName := Fields.Items[i].Name; + tmpField.FieldType := Ord(Fields.Items[i].DataType) + end; + except + end; + finally + TempTable.Free; + end; +end; + +procedure TfrxEngineIBX.ReadTableList(ATableList: TStrings); +begin + ATableList.Clear; + FQuery.Database.GetTableNames(ATableList, ShowSystemTables); +end; + +function TfrxEngineIBX.ResultDataSet: TDataSet; +begin + Result := FQuery; +end; + +procedure TfrxEngineIBX.SetSQL(const Value: string); +begin + FQuery.SQL.Text := Value; +end; +{$ENDIF} + + +initialization + frxObjects.RegisterObject1(TfrxIBXDataBase, nil, '', '', 0, 60); + frxObjects.RegisterObject1(TfrxIBXTable, nil, '', '', 0, 61); + frxObjects.RegisterObject1(TfrxIBXQuery, nil, '', '', 0, 62); + +finalization + frxObjects.UnRegister(TfrxIBXDataBase); + frxObjects.UnRegister(TfrxIBXTable); + frxObjects.UnRegister(TfrxIBXQuery); + + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxIBXEditor.pas b/official/4.2/LibD11/frxIBXEditor.pas new file mode 100644 index 0000000..c23a349 --- /dev/null +++ b/official/4.2/LibD11/frxIBXEditor.pas @@ -0,0 +1,164 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ IBX components design editors } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxIBXEditor; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, Dialogs, frxIBXComponents, frxCustomDB, + frxDsgnIntf, frxRes, IBDatabase, IBTable +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxDatabaseNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + function Edit: Boolean; override; + end; + + TfrxDatabaseProperty = class(TfrxComponentProperty) + public + function GetValue: String; override; + end; + + TfrxTableNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + procedure SetValue(const Value: String); override; + end; + + TfrxIndexNameProperty = class(TfrxStringProperty) + public + function GetAttributes: TfrxPropertyAttributes; override; + procedure GetValues; override; + end; + + +{ TfrxDatabaseNameProperty } + +function TfrxDatabaseNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paDialog]; +end; + +function TfrxDatabaseNameProperty.Edit: Boolean; +var + SaveConnected: Boolean; +begin + with TOpenDialog.Create(nil) do + begin + InitialDir := GetCurrentDir; + Filter := frxResources.Get('ftDB') + ' (*.gdb)|*.gdb|' + + frxResources.Get('ftAllFiles') + ' (*.*)|*.*'; + Result := Execute; + if Result then + with TfrxIBXDatabase(Component).Database do + begin + SaveConnected := Connected; + Connected := False; + DatabaseName := FileName; + Connected := SaveConnected; + end; + Free; + end; +end; + + +{ TfrxDatabaseProperty } + +function TfrxDatabaseProperty.GetValue: String; +var + db: TfrxIBXDatabase; +begin + db := TfrxIBXDatabase(GetOrdValue); + if db = nil then + begin + if (IBXComponents <> nil) and (IBXComponents.DefaultDatabase <> nil) then + Result := IBXComponents.DefaultDatabase.Name + else + Result := frxResources.Get('prNotAssigned'); + end + else + Result := inherited GetValue; +end; + + +{ TfrxTableNameProperty } + +function TfrxTableNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList, paSortList]; +end; + +procedure TfrxTableNameProperty.GetValues; +begin + inherited; + with TfrxIBXTable(Component).Table do + if Database <> nil then + DataBase.GetTableNames(Values, False); +end; + +procedure TfrxTableNameProperty.SetValue(const Value: String); +begin + inherited; + Designer.UpdateDataTree; +end; + + +{ TfrxIndexProperty } + +function TfrxIndexNameProperty.GetAttributes: TfrxPropertyAttributes; +begin + Result := [paMultiSelect, paValueList]; +end; + +procedure TfrxIndexNameProperty.GetValues; +var + i: Integer; +begin + inherited; + try + with TfrxIBXTable(Component).Table do + if (TableName <> '') and (IndexDefs <> nil) then + begin + IndexDefs.Update; + for i := 0 to IndexDefs.Count - 1 do + if IndexDefs[i].Name <> '' then + Values.Add(IndexDefs[i].Name); + end; + except + end; +end; + + +initialization + frxPropertyEditors.Register(TypeInfo(String), TfrxIBXDataBase, 'DatabaseName', + TfrxDataBaseNameProperty); + frxPropertyEditors.Register(TypeInfo(TfrxIBXDatabase), TfrxIBXTable, 'Database', + TfrxDatabaseProperty); + frxPropertyEditors.Register(TypeInfo(TfrxIBXDatabase), TfrxIBXQuery, 'Database', + TfrxDatabaseProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxIBXTable, 'TableName', + TfrxTableNameProperty); + frxPropertyEditors.Register(TypeInfo(String), TfrxIBXTable, 'IndexName', + TfrxIndexNameProperty); + +end. diff --git a/official/4.2/LibD11/frxIBXRTTI.pas b/official/4.2/LibD11/frxIBXRTTI.pas new file mode 100644 index 0000000..3a408bd --- /dev/null +++ b/official/4.2/LibD11/frxIBXRTTI.pas @@ -0,0 +1,101 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ IBX components RTTI } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxIBXRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, fs_iinterpreter, frxIBXComponents, fs_iibxrtti +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + with AddClass(TfrxIBXDatabase, 'TfrxCustomDatabase') do + AddProperty('Database', 'TIBDatabase', GetProp, nil); + with AddClass(TfrxIBXTable, 'TfrxCustomTable') do + AddProperty('Table', 'TIBTable', GetProp, nil); + with AddClass(TfrxIBXQuery, 'TfrxCustomQuery') do + begin + AddMethod('procedure ExecSQL', CallMethod); + AddProperty('Query', 'TIBQuery', GetProp, nil); + end; + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TfrxIBXQuery then + begin + if MethodName = 'EXECSQL' then + TfrxIBXQuery(Instance).Query.ExecSQL + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TfrxIBXDatabase then + begin + if PropName = 'DATABASE' then + Result := Integer(TfrxIBXDatabase(Instance).Database) + end + else if ClassType = TfrxIBXTable then + begin + if PropName = 'TABLE' then + Result := Integer(TfrxIBXTable(Instance).Table) + end + else if ClassType = TfrxIBXQuery then + begin + if PropName = 'QUERY' then + Result := Integer(TfrxIBXQuery(Instance).Query) + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/frxIBXReg.dcr b/official/4.2/LibD11/frxIBXReg.dcr new file mode 100644 index 0000000..2c1fbe2 Binary files /dev/null and b/official/4.2/LibD11/frxIBXReg.dcr differ diff --git a/official/4.2/LibD11/frxIBXReg.pas b/official/4.2/LibD11/frxIBXReg.pas new file mode 100644 index 0000000..124e8e5 --- /dev/null +++ b/official/4.2/LibD11/frxIBXReg.pas @@ -0,0 +1,37 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ IBX components registration } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxIBXReg; + +interface + +{$I frx.inc} + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes +{$IFNDEF Delphi6} +, DsgnIntf +{$ELSE} +, DesignIntf, DesignEditors +{$ENDIF} +, frxIBXComponents; + +procedure Register; +begin + RegisterComponents('FastReport 4.0', [TfrxIBXComponents]); +end; + +end. diff --git a/official/4.2/LibD11/frxInheritError.dfm b/official/4.2/LibD11/frxInheritError.dfm new file mode 100644 index 0000000..4748d12 Binary files /dev/null and b/official/4.2/LibD11/frxInheritError.dfm differ diff --git a/official/4.2/LibD11/frxInheritError.pas b/official/4.2/LibD11/frxInheritError.pas new file mode 100644 index 0000000..7f8f35b --- /dev/null +++ b/official/4.2/LibD11/frxInheritError.pas @@ -0,0 +1,76 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Inherit error dialog } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxInheritError; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, ImgList, ExtCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxInheritErrorForm = class(TForm) + OkB: TButton; + CancelB: TButton; + MessageL: TLabel; + DeleteRB: TRadioButton; + RenameRB: TRadioButton; + PaintBox1: TPaintBox; + ImageList1: TImageList; + procedure FormCreate(Sender: TObject); + procedure PaintBox1Paint(Sender: TObject); + private + { Private declarations } + public + { Public declarations } + end; + + +implementation + +{$R *.dfm} + +uses frxRes; + +procedure TfrxInheritErrorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(6000); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + MessageL.Caption := frxGet(6001); + DeleteRB.Caption := frxGet(6002); + RenameRB.Caption := frxGet(6003); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxInheritErrorForm.PaintBox1Paint(Sender: TObject); +begin + with PaintBox1 do + begin + Canvas.Brush.Color := Color; + Canvas.FillRect(Rect(0, 0, 32, 32)); + ImageList1.Draw(Canvas, 0, 0, 0); + end; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxInsp.dfm b/official/4.2/LibD11/frxInsp.dfm new file mode 100644 index 0000000..f0264f4 Binary files /dev/null and b/official/4.2/LibD11/frxInsp.dfm differ diff --git a/official/4.2/LibD11/frxInsp.pas b/official/4.2/LibD11/frxInsp.pas new file mode 100644 index 0000000..248281f --- /dev/null +++ b/official/4.2/LibD11/frxInsp.pas @@ -0,0 +1,1141 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Object Inspector } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxInsp; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, + Dialogs, ExtCtrls, StdCtrls, Buttons, frxDsgnIntf, frxPopupForm, + frxClass, Menus, ComCtrls +{$IFDEF UseTabset} +, Tabs +{$ENDIF} +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxObjectInspector = class(TForm) + ObjectsCB: TComboBox; + PopupMenu1: TPopupMenu; + N11: TMenuItem; + N21: TMenuItem; + N31: TMenuItem; + BackPanel: TPanel; + Box: TScrollBox; + PB: TPaintBox; + Edit1: TEdit; + EditPanel: TPanel; + EditBtn: TSpeedButton; + ComboPanel: TPanel; + ComboBtn: TSpeedButton; + HintPanel: TScrollBox; + Splitter1: TSplitter; + PropL: TLabel; + DescrL: TLabel; + N41: TMenuItem; + N51: TMenuItem; + N61: TMenuItem; + procedure PBPaint(Sender: TObject); + procedure FormResize(Sender: TObject); + procedure PBMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure PBMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure PBMouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); + procedure Edit1KeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure Edit1KeyPress(Sender: TObject; var Key: Char); + procedure EditBtnClick(Sender: TObject); + procedure ComboBtnClick(Sender: TObject); + procedure Edit1MouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure ObjectsCBClick(Sender: TObject); + procedure ObjectsCBDrawItem(Control: TWinControl; Index: Integer; + Rect: TRect; State: TOwnerDrawState); + procedure PBDblClick(Sender: TObject); + procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState; + MousePos: TPoint; var Handled: Boolean); + procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState; + MousePos: TPoint; var Handled: Boolean); + procedure FormEndDock(Sender, Target: TObject; X, Y: Integer); + procedure ComboBtnMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure FormShow(Sender: TObject); + procedure TabChange(Sender: TObject); + procedure N11Click(Sender: TObject); + procedure N21Click(Sender: TObject); + procedure N31Click(Sender: TObject); + procedure FormDeactivate(Sender: TObject); + private + { Private declarations } + FDesigner: TfrxCustomDesigner; + FDisableDblClick: Boolean; + FDisableUpdate: Boolean; + FDown: Boolean; + FEventList: TfrxPropertyList; + FHintWindow: THintWindow; + FItemIndex: Integer; + FLastPosition: String; + FList: TfrxPropertyList; + FPopupForm: TfrxPopupForm; + FPopupLB: TListBox; + FPopupLBVisible: Boolean; + FPropertyList: TfrxPropertyList; + FPanel: TPanel; + FRowHeight: Integer; + FSelectedObjects: TList; + FSplitterPos: Integer; +{$IFDEF UseTabset} + FTabs: TTabSet; +{$ELSE} + FTabs: TTabControl; +{$ENDIF} + FTempBMP: TBitmap; + FTempList: TList; + FTickCount: UInt; + FUpdatingObjectsCB: Boolean; + FUpdatingPB: Boolean; + FOnSelectionChanged: TNotifyEvent; + FOnModify: TNotifyEvent; + + function Count: Integer; + function GetItem(Index: Integer): TfrxPropertyItem; + function GetName(Index: Integer): String; + function GetOffset(Index: Integer): Integer; + function GetType(Index: Integer): TfrxPropertyAttributes; + function GetValue(Index: Integer): String; + procedure AdjustControls; + procedure CMMouseLeave(var Msg: TMessage); message CM_MouseLeave; + procedure DrawOneLine(i: Integer; Selected: Boolean); + procedure DoModify; + procedure SetObjects(Value: TList); + procedure SetItemIndex(Value: Integer); + procedure SetSelectedObjects(Value: TList); + procedure SetValue(Index: Integer; Value: String); + procedure LBClick(Sender: TObject); + function GetSplitter1Pos: Integer; + procedure SetSplitter1Pos(const Value: Integer); + public + { Public declarations } + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure DisableUpdate; + procedure EnableUpdate; + procedure Inspect(AObjects: array of TPersistent); + procedure SetColor(Color: TColor); + procedure UpdateProperties; + property Objects: TList write SetObjects; + property ItemIndex: Integer read FItemIndex write SetItemIndex; + property SelectedObjects: TList read FSelectedObjects write SetSelectedObjects; + property SplitterPos: Integer read FSplitterPos write FSplitterPos; + property Splitter1Pos: Integer read GetSplitter1Pos write SetSplitter1Pos; + property OnModify: TNotifyEvent read FOnModify write FOnModify; + property OnSelectionChanged: TNotifyEvent read FOnSelectionChanged write FOnSelectionChanged; + end; + + +implementation + +{$R *.DFM} + +uses frxUtils, frxRes, frxrcInsp; + + +type + TInspPanel = class(TPanel) + protected + procedure WMEraseBackground(var Message: TMessage); message WM_ERASEBKGND; + procedure Paint; override; + end; + + THackWinControl = class(TWinControl); + + +{ TInspPanel } + +procedure TInspPanel.WMEraseBackground(var Message: TMessage); +begin +// empty method +end; + +procedure TInspPanel.Paint; +begin +// empty method +end; + + +{ TfrxObjectInspector } + +constructor TfrxObjectInspector.Create(AOwner: TComponent); +begin + if not (AOwner is TfrxCustomDesigner) then + raise Exception.Create('The Owner of the object inspector should be TfrxCustomDesigner'); + inherited Create(AOwner); + FItemIndex := -1; + FTempBMP := TBitmap.Create; + FTempList := TList.Create; + FDesigner := TfrxCustomDesigner(AOwner); + FHintWindow := THintWindow.Create(Self); + FHintWindow.Color := clInfoBk; + + FPanel := TInspPanel.Create(Self); + with FPanel do + begin + Parent := Box; + BevelInner := bvNone; + BevelOuter := bvNone; + end; + PB.Parent := FPanel; + ComboPanel.Parent := FPanel; + EditPanel.Parent := FPanel; + Edit1.Parent := FPanel; +{$IFDEF UseTabset} + Box.BevelKind := bkFlat; + HintPanel.BevelKind := bkFlat; +{$ELSE} + Box.BorderStyle := bsSingle; + HintPanel.BorderStyle := bsSingle; +{$IFDEF Delphi7} + Box.ControlStyle := Box.ControlStyle + [csNeedsBorderPaint]; + HintPanel.ControlStyle := HintPanel.ControlStyle + [csNeedsBorderPaint]; +{$ENDIF} +{$ENDIF} + + FRowHeight := Canvas.TextHeight('Wg') + 3; + with Box.VertScrollBar do + begin + Increment := FRowHeight; + Tracking := True; + end; + +{$IFDEF UseTabset} + FTabs := TTabSet.Create(Self); + FTabs.OnClick := TabChange; + FTabs.ShrinkToFit := True; + FTabs.Style := tsSoftTabs; + FTabs.TabPosition := tpTop; +{$ELSE} + FTabs := TTabControl.Create(Self); + FTabs.OnChange := TabChange; +{$ENDIF} + FTabs.Parent := Self; + FTabs.SendToBack; + FTabs.Tabs.Add(frxResources.Get('oiProp')); + FTabs.Tabs.Add(frxResources.Get('oiEvent')); + FTabs.TabIndex := 0; + + if Screen.PixelsPerInch > 96 then + ObjectsCB.ItemHeight := 19; + FSplitterPos := PB.Width div 2; + AutoScroll := False; + + FormResize(nil); + + Caption := frxGet(2000); +end; + +destructor TfrxObjectInspector.Destroy; +begin + FTempBMP.Free; + FTempList.Free; + if FPropertyList <> nil then + FPropertyList.Free; + if FEventList <> nil then + FEventList.Free; + inherited; +end; + +procedure TfrxObjectInspector.UpdateProperties; +begin + SetSelectedObjects(FSelectedObjects); +end; + +procedure TfrxObjectInspector.Inspect(AObjects: array of TPersistent); +var + i: Integer; +begin + FTempList.Clear; + for i := Low(AObjects) to High(AObjects) do + FTempList.Add(AObjects[i]); + Objects := FTempList; + SelectedObjects := FTempList; +end; + +function TfrxObjectInspector.GetSplitter1Pos: Integer; +begin + Result := HintPanel.Height; +end; + +procedure TfrxObjectInspector.SetSplitter1Pos(const Value: Integer); +begin + HintPanel.Height := Value; +end; + +procedure TfrxObjectInspector.DisableUpdate; +begin + FDisableUpdate := True; +end; + +procedure TfrxObjectInspector.EnableUpdate; +begin + FDisableUpdate := False; +end; + +procedure TfrxObjectInspector.SetColor(Color: TColor); +begin + ObjectsCB.Color := Color; + Box.Color := Color; + PB.Repaint; +end; + +procedure TfrxObjectInspector.SetObjects(Value: TList); +var + i: Integer; + s: String; +begin + ObjectsCB.Items.Clear; + for i := 0 to Value.Count - 1 do + begin + if TObject(Value[i]) is TComponent then + s := TComponent(Value[i]).Name + ': ' + TComponent(Value[i]).ClassName else + s := ''; + ObjectsCB.Items.AddObject(s, Value[i]); + end; +end; + +procedure TfrxObjectInspector.SetSelectedObjects(Value: TList); +var + i: Integer; + s: String; + + procedure CreateLists; + var + i: Integer; + p: TfrxPropertyItem; + s: String; + begin + if FPropertyList <> nil then + FPropertyList.Free; + if FEventList <> nil then + FEventList.Free; + FEventList := nil; + + FPropertyList := frxCreatePropertyList(Value, FDesigner); + if FPropertyList <> nil then + begin + FEventList := TfrxPropertyList.Create(FDesigner); + + i := 0; + while i < FPropertyList.Count do + begin + p := FPropertyList[i]; + s := p.Editor.PropInfo.PropType^.Name; + if (Pos('Tfrx', s) = 1) and (Pos('Event', s) = Length(s) - 4) then + p.Collection := FEventList else + Inc(i); + end; + end; + + if FTabs.TabIndex = 0 then + FList := FPropertyList else + FList := FEventList; + end; + +begin + FSelectedObjects := Value; + CreateLists; + + FUpdatingObjectsCB := True; + if FSelectedObjects.Count = 1 then + begin + ObjectsCB.ItemIndex := ObjectsCB.Items.IndexOfObject(FSelectedObjects[0]); + if ObjectsCB.ItemIndex = -1 then + begin + s := TComponent(FSelectedObjects[0]).Name + ': ' + + TComponent(FSelectedObjects[0]).ClassName; + ObjectsCB.Items.AddObject(s, FSelectedObjects[0]); + ObjectsCB.ItemIndex := ObjectsCB.Items.IndexOfObject(FSelectedObjects[0]); + end; + end + else + ObjectsCB.ItemIndex := -1; + FUpdatingObjectsCB := False; + + FItemIndex := -1; + FormResize(nil); + if Count > 0 then + begin + for i := 0 to Count - 1 do + if GetName(i) = FLastPosition then + begin + ItemIndex := i; + Exit; + end; + s := FLastPosition; + ItemIndex := 0; + FLastPosition := s; + end; +end; + +function TfrxObjectInspector.Count: Integer; + + function EnumProperties(p: TfrxPropertyList): Integer; + var + i: Integer; + begin + Result := 0; + for i := 0 to p.Count - 1 do + begin + Inc(Result); + if (p[i].SubProperty <> nil) and p[i].Expanded then + Inc(Result, EnumProperties(p[i].SubProperty)); + end; + end; + +begin + if FList <> nil then + Result := EnumProperties(FList) else + Result := 0; +end; + +function TfrxObjectInspector.GetItem(Index: Integer): TfrxPropertyItem; + + function EnumProperties(p: TfrxPropertyList; var Index: Integer): TfrxPropertyItem; + var + i: Integer; + begin + Result := nil; + for i := 0 to p.Count - 1 do + begin + Dec(Index); + if Index < 0 then + begin + Result := p[i]; + break; + end; + if (p[i].SubProperty <> nil) and p[i].Expanded then + Result := EnumProperties(p[i].SubProperty, Index); + if Index < 0 then + break; + end; + end; + +begin + if (Index >= 0) and (Index < Count) then + Result := EnumProperties(FList, Index) else + Result := nil; +end; + +function TfrxObjectInspector.GetOffset(Index: Integer): Integer; +var + p: TfrxPropertyList; +begin + Result := 0; + p := TfrxPropertyList(GetItem(Index).Collection); + while p.Parent <> nil do + begin + Inc(Result); + p := p.Parent; + end; +end; + +function TfrxObjectInspector.GetName(Index: Integer): String; +begin + Result := GetItem(Index).Editor.GetName; +end; + +function TfrxObjectInspector.GetType(Index: Integer): TfrxPropertyAttributes; +begin + Result := GetItem(Index).Editor.GetAttributes; +end; + +function TfrxObjectInspector.GetValue(Index: Integer): String; +begin + Result := GetItem(Index).Editor.Value; +end; + +procedure TfrxObjectInspector.DoModify; +var + i: Integer; +begin + if FSelectedObjects.Count = 1 then + begin + i := ObjectsCB.Items.IndexOfObject(FSelectedObjects[0]); + if TObject(FSelectedObjects[0]) is TComponent then + ObjectsCB.Items.Strings[i] := TComponent(FSelectedObjects[0]).Name + ': ' + + TComponent(FSelectedObjects[0]).ClassName; + ObjectsCB.ItemIndex := ObjectsCB.Items.IndexOfObject(FSelectedObjects[0]); + end; + + if Assigned(FOnModify) then + FOnModify(Self); +end; + +procedure TfrxObjectInspector.SetItemIndex(Value: Integer); +var + p: TfrxPropertyItem; + s: String; +begin + PropL.Caption := ''; + DescrL.Caption := ''; + if Value > Count - 1 then + Value := Count - 1; + if Value < 0 then + Value := -1; + + Edit1.Visible := Count > 0; + if Count = 0 then Exit; + + if FItemIndex <> -1 then + if Edit1.Modified then + SetValue(FItemIndex, Edit1.Text); + FItemIndex := Value; + + if FItemIndex <> -1 then + begin + FLastPosition := GetName(FItemIndex); + p := GetItem(FItemIndex); + s := GetName(FItemIndex); + PropL.Caption := s; + if TfrxPropertyList(p.Collection).Component <> nil then + begin + s := 'prop' + s + '.' + TfrxPropertyList(p.Collection).Component.ClassName; + if frxResources.Get(s) = s then + s := frxResources.Get('prop' + GetName(FItemIndex)) else + s := frxResources.Get(s); + DescrL.Caption := s; + end; + end; + + AdjustControls; +end; + +procedure TfrxObjectInspector.SetValue(Index: Integer; Value: String); +begin + try + GetItem(Index).Editor.Value := Value; + DoModify; + PBPaint(nil); + except + on E: Exception do + begin + frxErrorMsg(E.Message); + Edit1.Text := GetItem(Index).Editor.Value; + end; + end; +end; + +procedure TfrxObjectInspector.AdjustControls; +var + PropType: TfrxPropertyAttributes; + y, ww: Integer; +begin + if (csDocking in ControlState) or FDisableUpdate then Exit; + if FItemIndex = -1 then + begin + EditPanel.Visible := False; + ComboPanel.Visible := False; + Edit1.Visible := False; + FUpdatingPB := False; + PBPaint(nil); + Exit; + end; + + FUpdatingPB := True; + PropType := GetType(FItemIndex); + + EditPanel.Visible := paDialog in PropType; + ComboPanel.Visible := paValueList in PropType; + Edit1.ReadOnly := paReadOnly in PropType; + + ww := PB.Width - FSplitterPos - 2; + y := FItemIndex * FRowHeight + 1; + if EditPanel.Visible then + begin + EditPanel.SetBounds(PB.Width - 15, y - 1, 15, FRowHeight - 1); + EditBtn.SetBounds(0, 0, EditPanel.Width, EditPanel.Height); + Dec(ww, 15); + end; + if ComboPanel.Visible then + begin + ComboPanel.SetBounds(PB.Width - 15, y - 1, 15, FRowHeight - 1); + ComboBtn.SetBounds(0, 0, ComboPanel.Width, ComboPanel.Height); + Dec(ww, 15); + end; + + Edit1.Text := GetValue(FItemIndex); + Edit1.Modified := False; + Edit1.SetBounds(FSplitterPos + 2, y, ww, FRowHeight - 2); + Edit1.SelectAll; + + if y + FRowHeight > Box.VertScrollBar.Position + Box.ClientHeight then + Box.VertScrollBar.Position := y - Box.ClientHeight + FRowHeight; + if y < Box.VertScrollBar.Position then + Box.VertScrollBar.Position := y - 1; + + FUpdatingPB := False; + PBPaint(nil); +end; + +procedure TfrxObjectInspector.DrawOneLine(i: Integer; Selected: Boolean); +var + R: TRect; + s: String; + p: TfrxPropertyItem; + offs, add: Integer; + + procedure Line(x, y, dx, dy: Integer); + begin + FTempBMP.Canvas.MoveTo(x, y); + FTempBMP.Canvas.LineTo(x + dx, y + dy); + end; + + procedure DrawProperty; + var + x, y: Integer; + begin + x := offs + GetOffset(i) * (12 + add); + y := 1 + i * FRowHeight; + + with FTempBMP.Canvas do + begin + Pen.Color := clGray; + Brush.Color := clWhite; + + if offs < 12 then + begin + Rectangle(x + 1, y + 2 + add, x + 10, y + 11 + add); + Line(x + 3, y + 6 + add, 5, 0); + if s[1] = '+' then + Line(x + 5, y + 4 + add, 0, 5); + + s := Copy(s, 2, 255); + Inc(x, 12 + add); + end; + + Brush.Style := bsClear; + if ((s = 'Name') or (s = 'Width') or (s = 'Height') or (s = 'Left') or (s = 'Top')) + and (GetOffset(i) = 0) then + Font.Style := [fsBold]; + TextRect(R, x, y, s); + end; + end; + +begin + if Count > 0 then + with FTempBMP.Canvas do + begin + Pen.Color := clBtnShadow; + Font.Assign(Self.Font); + R := Rect(0, i * FRowHeight, FSplitterPos, i * FRowHeight + FRowHeight - 1); + + if Screen.PixelsPerInch > 96 then + add := 2 + else + add := 0; + p := GetItem(i); + s := GetName(i); + if p.SubProperty <> nil then + begin + offs := 1 + add; + if p.Expanded then + s := '-' + s else + s := '+' + s; + end + else + offs := 13 + add; + + p.Editor.ItemHeight := FRowHeight; + + if Selected then + begin + Pen.Color := clBtnFace; + Line(0, FRowHeight + -1 + i * FRowHeight, PB.Width, 0); + Brush.Color := clBtnFace; + FillRect(R); + DrawProperty; + end + else + begin + Pen.Color := clBtnFace; + Line(0, FRowHeight + -1 + i * FRowHeight, PB.Width, 0); + Pen.Color := clBtnFace; + Line(FSplitterPos - 1, 0 + i * FRowHeight, 0, FRowHeight); + DrawProperty; + Font.Color := clNavy; + if paOwnerDraw in p.Editor.GetAttributes then + p.Editor.OnDrawItem(FTempBMP.Canvas, + Rect(FSplitterPos + 2, 1 + i * FRowHeight, Width, 1 + (i + 1) * FRowHeight)) + else + TextOut(FSplitterPos + 2, 1 + i * FRowHeight, GetValue(i)); + end; + end; +end; + + +{ Form events } + +procedure TfrxObjectInspector.FormShow(Sender: TObject); +begin + AdjustControls; +end; + +procedure TfrxObjectInspector.FormResize(Sender: TObject); +var + h: Integer; +begin + if Screen.PixelsPerInch > 96 then + h := 26 + else + h := 22; + FTabs.SetBounds(0, ObjectsCB.Top + ObjectsCB.Height + 4, ClientWidth, h); +{$IFDEF UseTabset} + BackPanel.Top := FTabs.Top + FTabs.Height - 1; +{$ELSE} + BackPanel.Top := FTabs.Top + FTabs.Height - 2; +{$ENDIF} + BackPanel.Width := ClientWidth; + BackPanel.Height := ClientHeight - BackPanel.Top; + ObjectsCB.Width := ClientWidth; + + FPanel.Height := Count * FRowHeight; + FPanel.Width := Box.ClientWidth; + AdjustControls; +end; + +procedure TfrxObjectInspector.FormEndDock(Sender, Target: TObject; X, Y: Integer); +begin + FormResize(nil); +end; + +procedure TfrxObjectInspector.TabChange(Sender: TObject); +begin + if FDesigner.IsPreviewDesigner then + begin + FTabs.TabIndex := 0; + Exit; + end; + if FTabs.TabIndex = 0 then + FList := FPropertyList else +{$IFNDEF FR_VER_BASIC} + FList := FEventList; +{$ELSE} + FTabs.TabIndex := 0; +{$ENDIF} + FItemIndex := -1; + FormResize(nil); +end; + +procedure TfrxObjectInspector.N11Click(Sender: TObject); +begin + if Edit1.Visible then + Edit1.CutToClipboard; +end; + +procedure TfrxObjectInspector.N21Click(Sender: TObject); +begin + if Edit1.Visible then + Edit1.PasteFromClipboard; +end; + +procedure TfrxObjectInspector.N31Click(Sender: TObject); +begin + if Edit1.Visible then + Edit1.CopyToClipboard; +end; + +procedure TfrxObjectInspector.FormDeactivate(Sender: TObject); +begin + if FDisableUpdate then Exit; + SetItemIndex(FItemIndex); +end; + + +{ PB events } + +procedure TfrxObjectInspector.PBPaint(Sender: TObject); +var + i: Integer; + r: TRect; +begin + if FUpdatingPB then Exit; + + r := PB.BoundsRect; + FTempBMP.Width := PB.Width; + FTempBMP.Height := PB.Height; + with FTempBMP.Canvas do + begin + Brush.Color := Box.Color; + FillRect(r); + end; + + if not FDisableUpdate then + begin + for i := 0 to Count - 1 do + if i <> ItemIndex then + DrawOneLine(i, False); + if FItemIndex <> -1 then + DrawOneLine(ItemIndex, True); + end; + + PB.Canvas.Draw(0, 0, FTempBMP); +end; + +procedure TfrxObjectInspector.PBMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var + p: TfrxPropertyItem; + n, x1: Integer; +begin + FDisableDblClick := False; + if Count = 0 then Exit; + if PB.Cursor = crHSplit then + FDown := True + else + begin + n := Y div FRowHeight; + + if (X > FSplitterPos) and (X < FSplitterPos + 15) and + (n >= 0) and (n < Count) then + begin + p := GetItem(n); + if p.Editor.ClassName = 'TfrxBooleanProperty' then + begin + p.Editor.Edit; + DoModify; + PBPaint(nil); + Exit; + end; + end; + + ItemIndex := n; + Edit1.SetFocus; + FTickCount := GetTickCount; + + p := GetItem(ItemIndex); + x1 := GetOffset(ItemIndex) * 12; + if (X > x1) and (X < x1 + 13) and (p.SubProperty <> nil) then + begin + p.Expanded := not p.Expanded; + FormResize(nil); + FDisableDblClick := True; + end; + end; +end; + +procedure TfrxObjectInspector.PBMouseUp(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + FDown := False; +end; + +procedure TfrxObjectInspector.PBMouseMove(Sender: TObject; + Shift: TShiftState; X, Y: Integer); +var + n, OffsetX, MaxWidth: Integer; + s: String; + HideHint: Boolean; + + procedure ShowHint(const s: String; x, y: Integer); + var + HintRect: TRect; + p: TPoint; + begin + p := PB.ClientToScreen(Point(x - 2, y - 2)); + HintRect := FHintWindow.CalcHintRect(1000, s, nil); + OffsetRect(HintRect, p.X, p.Y); + FHintWindow.ActivateHint(HintRect, s); + HideHint := False; + end; + +begin + HideHint := True; + + if not FDown then + begin + if (X > FSplitterPos - 4) and (X < FSplitterPos + 2) then + PB.Cursor := crHSplit + else + begin + PB.Cursor := crDefault; + + { hint window } + n := Y div FRowHeight; + if (X > 12) and (n >= 0) and (n < Count) then + begin + if X <= FSplitterPos - 4 then + begin + OffsetX := (GetOffset(n) + 1) * 12; + s := GetName(n); + MaxWidth := FSplitterPos - OffsetX; + end + else + begin + OffsetX := FSplitterPos + 1; + s := GetValue(n); + MaxWidth := PB.ClientWidth - FSplitterPos; + if n = ItemIndex then + MaxWidth := 1000; + end; + + if PB.Canvas.TextWidth(s) > MaxWidth then + ShowHint(s, OffsetX, n * FRowHeight); + end; + end; + end + else + begin + if (x > 30) and (x < PB.ClientWidth - 30) then + FSplitterPos := X; + AdjustControls; + end; + + if HideHint then + FHintWindow.ReleaseHandle; +end; + +procedure TfrxObjectInspector.PBDblClick(Sender: TObject); +var + p: TfrxPropertyItem; +begin + if (Count = 0) or FDisableDblClick then Exit; + + p := GetItem(ItemIndex); + if p.SubProperty <> nil then + begin + p.Expanded := not p.Expanded; + FormResize(nil); + end; +end; + + +{ Edit1 events } + +procedure TfrxObjectInspector.Edit1MouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + if GetTickCount - FTickCount < GetDoubleClickTime then + EditBtnClick(nil); +end; + +procedure TfrxObjectInspector.Edit1KeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +var + i: Integer; +begin + if Count = 0 then Exit; + if Key = vk_Escape then + begin + Edit1.Perform(EM_UNDO, 0, 0); + Edit1.Modified := False; + end; + if Key = vk_Up then + begin + if ItemIndex > 0 then + ItemIndex := ItemIndex - 1; + Key := 0; + end + else if Key = vk_Down then + begin + if ItemIndex < Count - 1 then + ItemIndex := ItemIndex + 1; + Key := 0; + end + else if Key = vk_Prior then + begin + i := Box.Height div FRowHeight; + i := ItemIndex - i; + if i < 0 then + i := 0; + ItemIndex := i; + Key := 0; + end + else if Key = vk_Next then + begin + i := Box.Height div FRowHeight; + i := ItemIndex + i; + ItemIndex := i; + Key := 0; + end; +end; + +procedure TfrxObjectInspector.Edit1KeyPress(Sender: TObject; var Key: Char); +begin + if Key = #13 then + begin + if paDialog in GetType(ItemIndex) then + EditBtnClick(nil) + else + begin + if Edit1.Modified then + SetValue(ItemIndex, Edit1.Text); + Edit1.Modified := False; + end; + Edit1.SelectAll; + Key := #0; + end; +end; + + +{ EditBtn and ComboBtn events } + +procedure TfrxObjectInspector.EditBtnClick(Sender: TObject); +begin + if GetItem(ItemIndex).Editor.Edit then + begin + ItemIndex := FItemIndex; + DoModify; + end; +end; + +procedure TfrxObjectInspector.ComboBtnMouseDown(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +begin + FPopupLBVisible := GetTickCount - frxPopupFormCloseTime < 100; +end; + +procedure TfrxObjectInspector.ComboBtnClick(Sender: TObject); +var + i, wItems, nItems: Integer; + p: TPoint; +begin + if FPopupLBVisible then + Edit1.SetFocus + else + begin + FPopupForm := TfrxPopupForm.Create(Self); + FPopupLB := TListBox.Create(FPopupForm); + with FPopupLB do + begin + Parent := FPopupForm; + Ctl3D := False; + Align := alClient; + if paOwnerDraw in GetItem(FItemIndex).Editor.GetAttributes then + Style := lbOwnerDrawFixed; + ItemHeight := FRowHeight; + OnClick := LBClick; + OnDrawItem := GetItem(FItemIndex).Editor.OnDrawLBItem; + GetItem(FItemIndex).Editor.GetValues; + Items.Assign(GetItem(FItemIndex).Editor.Values); + + if Items.Count > 0 then + begin + ItemIndex := Items.IndexOf(GetValue(FItemIndex)); + wItems := 0; + for i := 0 to Items.Count - 1 do + begin + if Canvas.TextWidth(Items[i]) > wItems then + wItems := Canvas.TextWidth(Items[i]); + end; + + Inc(wItems, 8); + if paOwnerDraw in GetItem(FItemIndex).Editor.GetAttributes then + Inc(wItems, GetItem(FItemIndex).Editor.GetExtraLBSize); + nItems := Items.Count; + if nItems > 8 then + begin + nItems := 8; + Inc(wItems, GetSystemMetrics(SM_CXVSCROLL)); + end; + + p := Edit1.ClientToScreen(Point(0, Edit1.Height)); + + if wItems < PB.Width - FSplitterPos then + FPopupForm.SetBounds(p.X - 3, p.Y, + PB.Width - FSplitterPos + 1, nItems * ItemHeight + 2) + else + FPopupForm.SetBounds(p.X + (PB.Width - FSplitterPos - wItems) - 2, p.Y, + wItems, nItems * ItemHeight + 2); + if FPopupForm.Left < 0 then + FPopupForm.Left := 0; + if FPopupForm.Top + FPopupForm.Height > Screen.Height then + FPopupForm.Top := Screen.Height - FPopupForm.Height; + FDisableUpdate := True; + FPopupForm.Show; + FDisableUpdate := False; + end; + end; + end; +end; + +procedure TfrxObjectInspector.LBClick(Sender: TObject); +begin + Edit1.Text := FPopupLB.Items[FPopupLB.ItemIndex]; + FPopupForm.Hide; + Edit1.SetFocus; + Edit1.SelectAll; + SetValue(ItemIndex, Edit1.Text); +end; + + +{ ObjectsCB events } + +procedure TfrxObjectInspector.ObjectsCBClick(Sender: TObject); +begin + if FUpdatingObjectsCB then Exit; + + FSelectedObjects.Clear; + if ObjectsCB.ItemIndex <> -1 then + FSelectedObjects.Add(ObjectsCB.Items.Objects[ObjectsCB.ItemIndex]); + SetSelectedObjects(FSelectedObjects); + Edit1.SetFocus; + if Assigned(FOnSelectionChanged) then + FOnSelectionChanged(Self); +end; + +procedure TfrxObjectInspector.ObjectsCBDrawItem(Control: TWinControl; + Index: Integer; Rect: TRect; State: TOwnerDrawState); +begin + if FDisableUpdate then exit; + with ObjectsCB.Canvas do + begin + FillRect(Rect); + if Index <> -1 then + TextOut(Rect.Left + 2, Rect.Top + 1, ObjectsCB.Items[Index]); + end; +end; + + +{ Mouse wheel } + +procedure TfrxObjectInspector.FormMouseWheelDown(Sender: TObject; + Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); +begin + with Box.VertScrollBar do + Position := Position + FRowHeight; +end; + +procedure TfrxObjectInspector.FormMouseWheelUp(Sender: TObject; + Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); +begin + with Box.VertScrollBar do + Position := Position - FRowHeight; +end; + +procedure TfrxObjectInspector.CMMouseLeave(var Msg: TMessage); +begin + FHintWindow.ReleaseHandle; + inherited; +end; + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxMD5.pas b/official/4.2/LibD11/frxMD5.pas new file mode 100644 index 0000000..793f701 --- /dev/null +++ b/official/4.2/LibD11/frxMD5.pas @@ -0,0 +1,520 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ MD5 checksum generation } +{ } +{******************************************} +// Original RSA Data Security, Inc. Copyright notice +///////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All +// rights reserved. +// +// License to copy and use this software is granted provided that it +// is identified as the "RSA Data Security, Inc. MD5 Message-Digest +// Algorithm" in all material mentioning or referencing this software +// or this function. +// License is also granted to make and use derivative works provided +// that such works are identified as "derived from the RSA Data +// Security, Inc. MD5 Message-Digest Algorithm" in all material +// mentioning or referencing the derived work. +// RSA Data Security, Inc. makes no representations concerning either +// the merchantability of this software or the suitability of this +// software for any particular purpose. It is provided "as is" +// without express or implied warranty of any kind. +// These notices must be retained in any copies of any part of this +// documentation and/or software. + +unit frxmd5; + +{$I frx.inc} + +interface + +uses Classes; + +function MD5String(szString: String): String; +function MD5File(szFilename: String): String; +function MD5Stream(Stream: TStream): String; + +implementation + +uses SysUtils; + +type + uint4 = longword; + uchar = byte; + Puint4 = ^uint4; + Puchar = ^uchar; + + TfrxMD5 = class (TObject) + private + m_State: array [0..3] of uint4; + m_Count: array [0..1] of uint4; + m_Buffer: array [0..63] of uchar; + m_Digest: array [0..15] of uchar; + procedure Transform(block: Puchar); + procedure Encode(dest: Puchar; src: Puint4; nLength: uint4); + procedure Decode(dest: Puint4; src: Puchar; nLength: uint4); + function RotateLeft(x: uint4; n: uint4): uint4; + procedure FF(var a: uint4; b: uint4; c: uint4; d: uint4; x: uint4; s: uint4; ac: uint4); + procedure GG(var a: uint4; b: uint4; c: uint4; d: uint4; x: uint4; s: uint4; ac: uint4); + procedure HH(var a: uint4; b: uint4; c: uint4; d: uint4; x: uint4; s: uint4; ac: uint4); + procedure II(var a: uint4; b: uint4; c: uint4; d: uint4; x: uint4; s: uint4; ac: uint4); + public + constructor Create; + procedure Init; + procedure Update(chInput: Puchar; nInputLen: uint4); + procedure Finalize; + function Digest: Puchar; + end; + +const +//Magic initialization constants + MD5_INIT_STATE_0 = $67452301; + MD5_INIT_STATE_1 = $efcdab89; + MD5_INIT_STATE_2 = $98badcfe; + MD5_INIT_STATE_3 = $10325476; +//Constants for Transform routine. + MD5_S11 = 7; + MD5_S12 = 12; + MD5_S13 = 17; + MD5_S14 = 22; + MD5_S21 = 5; + MD5_S22 = 9; + MD5_S23 = 14; + MD5_S24 = 20; + MD5_S31 = 4; + MD5_S32 = 11; + MD5_S33 = 16; + MD5_S34 = 23; + MD5_S41 = 6; + MD5_S42 = 10; + MD5_S43 = 15; + MD5_S44 = 21; +//Transformation Constants - Round 1 + MD5_T01 = $d76aa478; + MD5_T02 = $e8c7b756; + MD5_T03 = $242070db; + MD5_T04 = $c1bdceee; + MD5_T05 = $f57c0faf; + MD5_T06 = $4787c62a; + MD5_T07 = $a8304613; + MD5_T08 = $fd469501; + MD5_T09 = $698098d8; + MD5_T10 = $8b44f7af; + MD5_T11 = $ffff5bb1; + MD5_T12 = $895cd7be; + MD5_T13 = $6b901122; + MD5_T14 = $fd987193; + MD5_T15 = $a679438e; + MD5_T16 = $49b40821; +//Transformation Constants - Round 2 + MD5_T17 = $f61e2562; + MD5_T18 = $c040b340; + MD5_T19 = $265e5a51; + MD5_T20 = $e9b6c7aa; + MD5_T21 = $d62f105d; + MD5_T22 = $02441453; + MD5_T23 = $d8a1e681; + MD5_T24 = $e7d3fbc8; + MD5_T25 = $21e1cde6; + MD5_T26 = $c33707d6; + MD5_T27 = $f4d50d87; + MD5_T28 = $455a14ed; + MD5_T29 = $a9e3e905; + MD5_T30 = $fcefa3f8; + MD5_T31 = $676f02d9; + MD5_T32 = $8d2a4c8a; +//Transformation Constants - Round 3 + MD5_T33 = $fffa3942; + MD5_T34 = $8771f681; + MD5_T35 = $6d9d6122; + MD5_T36 = $fde5380c; + MD5_T37 = $a4beea44; + MD5_T38 = $4bdecfa9; + MD5_T39 = $f6bb4b60; + MD5_T40 = $bebfbc70; + MD5_T41 = $289b7ec6; + MD5_T42 = $eaa127fa; + MD5_T43 = $d4ef3085; + MD5_T44 = $04881d05; + MD5_T45 = $d9d4d039; + MD5_T46 = $e6db99e5; + MD5_T47 = $1fa27cf8; + MD5_T48 = $c4ac5665; +//Transformation Constants - Round 4 + MD5_T49 = $f4292244; + MD5_T50 = $432aff97; + MD5_T51 = $ab9423a7; + MD5_T52 = $fc93a039; + MD5_T53 = $655b59c3; + MD5_T54 = $8f0ccc92; + MD5_T55 = $ffeff47d; + MD5_T56 = $85845dd1; + MD5_T57 = $6fa87e4f; + MD5_T58 = $fe2ce6e0; + MD5_T59 = $a3014314; + MD5_T60 = $4e0811a1; + MD5_T61 = $f7537e82; + MD5_T62 = $bd3af235; + MD5_T63 = $2ad7d2bb; + MD5_T64 = $eb86d391; +//Null data (except for first BYTE) used to finalise the checksum calculation + PADDING: array [0..63] of byte = +( $80, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0); + +function Byte2Hex(const b: byte): String; +var + H, L: Byte; + function HexChar(N : Byte) : Char; + begin + if (N < 10) then Result := Chr(Ord('0') + N) + else Result := Chr(Ord('A') + (N - 10)); + end; +begin + SetLength(Result, 2); + H := (b shr 4) and $f; + L := b and $f; + Result[1] := HexChar(H); + Result[2]:= HexChar(L); +end; + +// PrintMD5: Converts a completed md5 digest into a char* string. +function PrintMD5(md5Digest: Puchar): String; +var + nCount: Integer; + tmp: Puchar; +begin + Result := ''; + tmp := md5Digest; + for nCount := 0 to 15 do + begin + Result := Result + LowerCase(Byte2Hex(Byte(tmp^))); + Inc(tmp); + end; +end; + +// MD5String: Performs the MD5 algorithm on a char* string, returning +// the results as a char*. +function MD5String(szString: String): String; +var + nLen: Integer; + alg: TfrxMD5; +begin + Result := ''; + alg := TfrxMD5.Create; + try + nLen := Length(szString); + alg.Update(Puchar(szString), nLen); + alg.Finalize; + Result := PrintMD5(alg.Digest); + finally + alg.Free; + end; +end; + +function MD5Stream(Stream: TStream): String; +var + nLen: Integer; + buf: array [0..255] of char; + alg: TfrxMD5; + oldpos: Longint; +begin + Result := ''; + alg := TfrxMD5.Create; + oldpos := Stream.Position; + try + Stream.Position := 0; + nLen := 256; + while nLen = 256 do + begin + nLen := Stream.Read(buf, nLen); + alg.Update(@buf, nLen); + end; + alg.Finalize; + Result := PrintMD5(alg.Digest); + finally + Stream.Position := oldpos; + alg.Free; + end; +end; + +function MD5File(szFilename: String): String; +var + f: TFileStream; +begin + Result := ''; + f := TFileStream.Create(szFilename, fmOpenRead + fmShareDenyWrite); + try + Result := MD5Stream(f); + finally + f.Free + end; +end; + +{ TfrxMD5 } +constructor TfrxMD5.Create; +begin + Init; +end; + +// md5::Init +// Initializes a new context. +procedure TfrxMD5.Init; +begin + FillChar(m_Count, 2 * SizeOf(uint4), 0); + m_State[0] := MD5_INIT_STATE_0; + m_State[1] := MD5_INIT_STATE_1; + m_State[2] := MD5_INIT_STATE_2; + m_State[3] := MD5_INIT_STATE_3; +end; + +// MD5 block update operation. Continues an MD5 message-digest +// operation, processing another message block, and updating the +// context. +procedure TfrxMD5.Update(chInput: Puchar; nInputLen: uint4); +var + i, index, partLen: uint4; + tmp: Puchar; +begin + // Compute number of bytes mod 64 + index := (m_Count[0] shr 3) and $3F; + // Update number of bits + m_Count[0] := m_Count[0] + (nInputLen shl 3); + if m_Count[0] < (nInputLen shl 3) then + m_Count[1] := m_Count[1] + 1; + m_Count[1] := m_Count[1] + (nInputLen shr 29); + partLen := 64 - index; + // Transform as many times as possible. + if nInputLen >= partLen then + begin + Move(chInput^, m_Buffer[index], partLen); + Transform(Puchar(@m_Buffer)); + i := partLen; + while (i + 63) < nInputLen do + begin + tmp := chInput; + Inc(tmp, i); + Transform(tmp); + i := i + 64; + end; + index := 0; + end else + i := 0; + // Buffer remaining input + tmp := chInput; + Inc(tmp, i); + Move(tmp^, m_Buffer[index], nInputLen - i); +end; + +// MD5 finalization. Ends an MD5 message-digest operation, writing +// the message digest and zeroizing the context. +procedure TfrxMD5.Finalize; +var + bits: array [0..7] of uchar; + index, padLen: uint4; +begin + // Save number of bits + Encode(Puchar(@bits), Puint4(@m_Count), 8); + // Pad out to 56 mod 64 + index := (m_Count[0] shr 3) and $3f; + if index < 56 then + padLen := 56 - index + else + padLen := 120 - index; + Update(Puchar(@PADDING), padLen); + // Append length (before padding) + Update(Puchar(@bits), 8); + // Store state in digest + Encode(Puchar(@m_Digest), Puint4(@m_State), 16); + FillChar(m_Count, 2 * sizeof(uint4), 0); + FillChar(m_State, 4 * sizeof(uint4), 0); + FillChar(m_Buffer, 64 * sizeof(uchar), 0); +end; + +function TfrxMD5.Digest: Puchar; +begin + Result := Puchar(@m_Digest); +end; + +// MD5 basic transformation. Transforms state based on block. +procedure TfrxMD5.Transform(block: Puchar); +var + a, b, c, d: uint4; + X: array [0..15] of uint4; +begin + a := m_State[0]; + b := m_State[1]; + c := m_State[2]; + d := m_State[3]; + Decode(Puint4(@X), block, 64); + //Perform Round 1 of the transformation + FF (a, b, c, d, X[ 0], MD5_S11, MD5_T01); + FF (d, a, b, c, X[ 1], MD5_S12, MD5_T02); + FF (c, d, a, b, X[ 2], MD5_S13, MD5_T03); + FF (b, c, d, a, X[ 3], MD5_S14, MD5_T04); + FF (a, b, c, d, X[ 4], MD5_S11, MD5_T05); + FF (d, a, b, c, X[ 5], MD5_S12, MD5_T06); + FF (c, d, a, b, X[ 6], MD5_S13, MD5_T07); + FF (b, c, d, a, X[ 7], MD5_S14, MD5_T08); + FF (a, b, c, d, X[ 8], MD5_S11, MD5_T09); + FF (d, a, b, c, X[ 9], MD5_S12, MD5_T10); + FF (c, d, a, b, X[10], MD5_S13, MD5_T11); + FF (b, c, d, a, X[11], MD5_S14, MD5_T12); + FF (a, b, c, d, X[12], MD5_S11, MD5_T13); + FF (d, a, b, c, X[13], MD5_S12, MD5_T14); + FF (c, d, a, b, X[14], MD5_S13, MD5_T15); + FF (b, c, d, a, X[15], MD5_S14, MD5_T16); + //Perform Round 2 of the transformation + GG (a, b, c, d, X[ 1], MD5_S21, MD5_T17); + GG (d, a, b, c, X[ 6], MD5_S22, MD5_T18); + GG (c, d, a, b, X[11], MD5_S23, MD5_T19); + GG (b, c, d, a, X[ 0], MD5_S24, MD5_T20); + GG (a, b, c, d, X[ 5], MD5_S21, MD5_T21); + GG (d, a, b, c, X[10], MD5_S22, MD5_T22); + GG (c, d, a, b, X[15], MD5_S23, MD5_T23); + GG (b, c, d, a, X[ 4], MD5_S24, MD5_T24); + GG (a, b, c, d, X[ 9], MD5_S21, MD5_T25); + GG (d, a, b, c, X[14], MD5_S22, MD5_T26); + GG (c, d, a, b, X[ 3], MD5_S23, MD5_T27); + GG (b, c, d, a, X[ 8], MD5_S24, MD5_T28); + GG (a, b, c, d, X[13], MD5_S21, MD5_T29); + GG (d, a, b, c, X[ 2], MD5_S22, MD5_T30); + GG (c, d, a, b, X[ 7], MD5_S23, MD5_T31); + GG (b, c, d, a, X[12], MD5_S24, MD5_T32); + //Perform Round 3 of the transformation + HH (a, b, c, d, X[ 5], MD5_S31, MD5_T33); + HH (d, a, b, c, X[ 8], MD5_S32, MD5_T34); + HH (c, d, a, b, X[11], MD5_S33, MD5_T35); + HH (b, c, d, a, X[14], MD5_S34, MD5_T36); + HH (a, b, c, d, X[ 1], MD5_S31, MD5_T37); + HH (d, a, b, c, X[ 4], MD5_S32, MD5_T38); + HH (c, d, a, b, X[ 7], MD5_S33, MD5_T39); + HH (b, c, d, a, X[10], MD5_S34, MD5_T40); + HH (a, b, c, d, X[13], MD5_S31, MD5_T41); + HH (d, a, b, c, X[ 0], MD5_S32, MD5_T42); + HH (c, d, a, b, X[ 3], MD5_S33, MD5_T43); + HH (b, c, d, a, X[ 6], MD5_S34, MD5_T44); + HH (a, b, c, d, X[ 9], MD5_S31, MD5_T45); + HH (d, a, b, c, X[12], MD5_S32, MD5_T46); + HH (c, d, a, b, X[15], MD5_S33, MD5_T47); + HH (b, c, d, a, X[ 2], MD5_S34, MD5_T48); + //Perform Round 4 of the transformation + II (a, b, c, d, X[ 0], MD5_S41, MD5_T49); + II (d, a, b, c, X[ 7], MD5_S42, MD5_T50); + II (c, d, a, b, X[14], MD5_S43, MD5_T51); + II (b, c, d, a, X[ 5], MD5_S44, MD5_T52); + II (a, b, c, d, X[12], MD5_S41, MD5_T53); + II (d, a, b, c, X[ 3], MD5_S42, MD5_T54); + II (c, d, a, b, X[10], MD5_S43, MD5_T55); + II (b, c, d, a, X[ 1], MD5_S44, MD5_T56); + II (a, b, c, d, X[ 8], MD5_S41, MD5_T57); + II (d, a, b, c, X[15], MD5_S42, MD5_T58); + II (c, d, a, b, X[ 6], MD5_S43, MD5_T59); + II (b, c, d, a, X[13], MD5_S44, MD5_T60); + II (a, b, c, d, X[ 4], MD5_S41, MD5_T61); + II (d, a, b, c, X[11], MD5_S42, MD5_T62); + II (c, d, a, b, X[ 2], MD5_S43, MD5_T63); + II (b, c, d, a, X[ 9], MD5_S44, MD5_T64); + m_State[0] := m_State[0] + a; + m_State[1] := m_State[1] + b; + m_State[2] := m_State[2] + c; + m_State[3] := m_State[3] + d; + FillChar(X, sizeof(X), 0); +end; + +// Encodes input (uint4) into output (uchar). Assumes nLength is +// a multiple of 4. +procedure TfrxMD5.Encode(dest: Puchar; src: Puint4; nLength: uint4); +var + j: uint4; + tmp: Puchar; + tmp2: Puint4; +begin + j := 0; + tmp := dest; + tmp2 := src; + while j < nLength do + begin + tmp^ := uchar(tmp2^ and $ff); + Inc(tmp); + tmp^ := uchar((tmp2^ shr 8) and $ff); + Inc(tmp); + tmp^ := uchar((tmp2^ shr 16) and $ff); + Inc(tmp); + tmp^ := uchar((tmp2^ shr 24) and $ff); + Inc(tmp); + Inc(tmp2); + j := j + 4; + end; +end; + +// Decodes input (uchar) into output (uint4). Assumes nLength is +// a multiple of 4. +procedure TfrxMD5.Decode(dest: Puint4; src: Puchar; nLength: uint4); +var + j: uint4; + tmp2: Puchar; + tmp: Puint4; +begin + j := 0; + tmp := dest; + tmp2 := src; + while j < nLength do + begin + tmp^ := uint4(tmp2^); + Inc(tmp2); + tmp^ := tmp^ or uint4(tmp2^ shl 8); + Inc(tmp2); + tmp^ := tmp^ or uint4(tmp2^ shl 16); + Inc(tmp2); + tmp^ := tmp^ or uint4(tmp2^ shl 24); + Inc(tmp2); + Inc(tmp); + j := j + 4; + end; +end; + +function TfrxMD5.RotateLeft(x: uint4; n: uint4): uint4; +begin + Result := (x shl n) or (x shr (32 - n)); +end; + +procedure TfrxMD5.FF(var a: uint4; b: uint4; c: uint4; d: uint4; x: uint4; s: uint4; ac: uint4); +begin + a := a + ((b and c) or (not b and d)) + x + ac; + a := RotateLeft(a, s); + a := a + b; +end; + +procedure TfrxMD5.GG(var a: uint4; b: uint4; c: uint4; d: uint4; x: uint4; s: uint4; ac: uint4); +begin + a := a + ((b and d) or (c and (not d))) + x + ac; + a := RotateLeft(a, s); + a := a + b; +end; + +procedure TfrxMD5.HH(var a: uint4; b: uint4; c: uint4; d: uint4; x: uint4; s: uint4; ac: uint4); +begin + a := a + (b xor c xor d) + x + ac; + a := RotateLeft(a, s); + a := a + b; +end; + +procedure TfrxMD5.II(var a: uint4; b: uint4; c: uint4; d: uint4; x: uint4; s: uint4; ac: uint4); +begin + a := a + (c xor (b or (not d))) + x + ac; + a := RotateLeft(a, s); + a := a + b; +end; + +end. diff --git a/official/4.2/LibD11/frxNetUtils.pas b/official/4.2/LibD11/frxNetUtils.pas new file mode 100644 index 0000000..513b402 --- /dev/null +++ b/official/4.2/LibD11/frxNetUtils.pas @@ -0,0 +1,361 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Network utilities unit } +{ } +{ Copyright (c) 2006-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxNetUtils; + +{$I frx.inc} + +interface + +uses + Windows, Messages, SysUtils, Classes, Registry; + +function DateTimeToRFCDateTime(const D: TDateTime): String; +function GMTDateTimeToRFCDateTime(const D: TDateTime): String; +function PadRight(const S: String; const PadChar: Char; const Len: Integer): String; +function PadLeft(const S: String; const PadChar: Char; const Len: Integer): String; +function Base64Encode(const S: String): String; +function Base64Decode(const S: String): String; +function GetFileMIMEType(const FileName: String): String; +function GetSocketErrorText(const ErrorCode: integer):string; +function ParseHeaderField(const Field: String; const Header: String): String; +procedure PMessages; + +implementation + +const + Base64Charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; + RFCDayNames : Array[1..7] of String = ( + 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); + RFCMonthNames : Array[1..12] of String = ( + 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); + +function GMTDateTimeToRFCDateTime(const D: TDateTime): String; +var + Ho, Mi, Se, Ms : Word; + Ye, Mo, Da : Word; +begin + DecodeTime(D, Ho, Mi, Se, Ms); + DecodeDate(D, Ye, Mo, Da); + Result := RFCDayNames[DayOfWeek(D)] + ', '; + Result := Result + PadLeft(IntToStr(Da), '0', 2) + ' ' + + RFCMonthNames[Mo] + ' ' + IntToStr(Ye) + ' '; + Result := Result + PadLeft(IntToStr(Ho), '0', 2) + ':' + PadLeft(IntToStr(Mi), '0', 2); + Result := Result + ':' + PadLeft(IntToStr(Se), '0', 2); + Result := Result + ' GMT'; +end; + +function GMTBias : Integer; +var + TZI : TTimeZoneInformation; +begin + if GetTimeZoneInformation(TZI) = TIME_ZONE_ID_DAYLIGHT then + Result := TZI.DaylightBias + else + Result := 0; + Result := Result + TZI.Bias; +end; + +function DateTimeToRFCDateTime(const D: TDateTime): String; +begin + Result := GMTDateTimeToRFCDateTime(D + GMTBias / (24.0 * 60.0)); +end; + +function PadLeft(const S: String; const PadChar: Char; const Len: Integer): String; +var + F, L, P, M : Integer; + I, J: PChar; +begin + if Len > 0 then + begin + M := Length(S); + if Len <> M then + begin + L := Len; + P := L - M; + if P < 0 then + P := 0; + SetLength(Result, L); + if P > 0 then + FillChar(Pointer(Result)^, P, Ord(PadChar)); + if L > P then + begin + I := Pointer(Result); + J := Pointer(S); + Inc(I, P); + for F := 1 to L - P do + begin + I^ := J^; + Inc(I); + Inc(J); + end; + end; + end else + Result := S; + end else + Result := ''; +end; + +function PadRight(const S: String; const PadChar: Char; const Len: Integer): String; +var + F, L, P, M : Integer; + I, J: PChar; +begin + if Len > 0 then + begin + M := Length(S); + if Len <> M then + begin + L := Len; + P := L - M; + if P < 0 then + P := 0; + SetLength(Result, L); + if L > P then + begin + I := Pointer(Result); + J := Pointer(S); + for F := 1 to L - P do + begin + I^ := J^; + Inc(I); + Inc(J); + end; + end; + if P > 0 then + FillChar(Result[L - P + 1], P, Ord(PadChar)); + end else + Result := S; + end else + Result := ''; +end; + +function Base64Encode(const S: String): String; +var + R, C : Byte; + F, L, M, N, U : Integer; + P : PChar; +begin + L := Length(S); + if L > 0 then + begin + M := L mod 3; + N := (L div 3) * 4 + M; + if M > 0 then Inc(N); + U := N mod 4; + if U > 0 then + begin + U := 4 - U; + Inc(N, U); + end; + SetLength(Result, N); + P := Pointer(Result); + R := 0; + for F := 0 to L - 1 do + begin + C := Byte(S [F + 1]); + case F mod 3 of + 0 : begin + P^ := Base64Charset[C shr 2 + 1]; + Inc(P); + R := (C and 3) shl 4; + end; + 1 : begin + P^ := Base64Charset[C shr 4 + R + 1]; + Inc(P); + R := (C and $0F) shl 2; + end; + 2 : begin + P^ := Base64Charset[C shr 6 + R + 1]; + Inc(P); + P^ := Base64Charset[C and $3F + 1]; + Inc(P); + end; + end; + end; + if M > 0 then + begin + P^ := Base64Charset[R + 1]; + Inc(P); + end; + for F := 1 to U do + begin + P^ := '='; + Inc(P); + end; + end else + Result := ''; +end; + +function Base64Decode(const S: String): String; +var + F, L, M, P: Integer; + B, OutPos: Byte; + OutB: Array[1..3] of Byte; + Lookup: Array[Char] of Byte; + R: PChar; +begin + L := Length(S); + P := 0; + while (L - P > 0) and (S[L - P] = '=') do Inc(P); + M := L - P; + if M <> 0 then + begin + SetLength(Result, (M * 3) div 4); + FillChar(Lookup, Sizeof(Lookup), #0); + for F := 0 to 63 do + Lookup[Base64Charset[F + 1]] := F; + R := Pointer(Result); + OutPos := 0; + for F := 1 to L - P do + begin + B := Lookup[S[F]]; + case OutPos of + 0 : OutB[1] := B shl 2; + 1 : begin + OutB[1] := OutB[1] or (B shr 4); + R^ := Char(OutB[1]); + Inc(R); + OutB[2] := (B shl 4) and $FF; + end; + 2 : begin + OutB[2] := OutB[2] or (B shr 2); + R^ := Char(OutB[2]); + Inc(R); + OutB[3] := (B shl 6) and $FF; + end; + 3 : begin + OutB[3] := OutB[3] or B; + R^ := Char(OutB[3]); + Inc(R); + end; + end; + OutPos := (OutPos + 1) mod 4; + end; + if (OutPos > 0) and (P = 0) then + if OutB[OutPos] <> 0 then + Result := Result + Char(OutB[OutPos]); + end else + Result := ''; +end; + +function GetFileMIMEType(const FileName: String): String; +var + Registry: TRegistry; + ext: String; +begin + Result := 'application/octet-stream'; + ext := ExtractFileExt(FileName); + Registry := TRegistry.Create; + try + Registry.RootKey := HKEY_CLASSES_ROOT; + if Registry.KeyExists(ext) then + begin + Registry.OpenKey(ext, false); + Result := Registry.ReadString('Content Type'); + Registry.CloseKey; + end; + finally + Registry.Free; + end; +end; + +function GetSocketErrorText(const ErrorCode: integer):string; +begin + case errorcode of + 10004: result:= 'Interrupted system call.'; + 10009: result:= 'Bad file number.'; + 10013: result:= 'Access denied.'; + 10014: result:= 'Bad address.'; + 10022: result:= 'Invalid argument.'; + 10024: result:= 'Too many open files.'; + 10035: result:= 'Operation would block. Check also the DataToSend property of the component (if any).'; + 10036: result:= 'Operation now in progress.'; + 10037: result:= 'Operation already in progress.'; + 10038: result:= 'Socket operation on non-socket.'; + 10039: result:= 'Destination address required.'; + 10040: result:= 'Message too long.'; + 10041: result:= 'Protocol wrong type for socket.'; + 10042: result:= 'Bad protocol option.'; + 10043: result:= 'Protocol not supported.'; + 10044: result:= 'Socket type not supported.'; + 10045: result:= 'Operation not supported on socket.'; + 10046: result:= 'Protocol family not supported.'; + 10047: result:= 'Address family not supported by protocol family.'; + 10048: result:= 'Address already in use.'; + 10049: result:= 'Can''t assign requested address.'; + 10050: result:= 'Network is down.'; + 10051: result:= 'Network is unreachable.'; + 10052: result:= 'Net dropped connection or reset.'; + 10053: result:= 'Software caused connection abort.'; + 10054: result:= 'Connection reset by peer.'; + 10055: result:= 'No buffer space available.'; + 10056: result:= 'Socket is already connected.'; + 10057: result:= 'Socket is not connected.'; + 10058: result:= 'Can''t send after socket shutdown.'; + 10059: result:= 'Too many references, can''t splice.'; + 10060: result:= 'Connection timed out.'; + 10061: result:= 'Connection refused.'; + 10062: result:= 'Too many levels of symbolic links.'; + 10063: result:= 'File name too long.'; + 10064: result:= 'Host is down.'; + 10065: result:= 'No route to host.'; + 10066: result:= 'Directory not empty.'; + 10067: result:= 'Too many processes.'; + 10068: result:= 'Too many users.'; + 10069: result:= 'Disc Quota Exceeded.'; + 10070: result:= 'Stale NFS file handle.'; + 10071: result:= 'Too many levels of remote in path.'; + 10091: result:= 'Network subsystem is unavailable.'; + 10092: result:= 'WINSOCK DLL Version out of range.'; + 10093: result:= 'Winsock not loaded yet.'; + 11001: result:= 'Host not found.'; + 11002: result:= 'Non-authoritative ''Host not found'' (try again or check DNS setup).'; + 11003: result:= 'Non-recoverable errors: FORMERR, REFUSED, NOTIMP.'; + 11004: result:= 'Valid name, no data record (check DNSsetup).'; + 500: result:= 'Exception occured with astadataset'; + 501: result:= 'Unauthorized remote control attempted' + else + Result := 'Unknown error' + end; + Result := Result + '(' + IntToStr(errorcode) + ')'; +end; + +procedure PMessages; +var + Msg: TMsg; +begin + while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do begin + if Msg.Message = WM_QUIT then exit; + TranslateMessage(Msg); + DispatchMessage(Msg); + end; + Sleep(1); +end; + +function ParseHeaderField(const Field: String; const Header: String): String; +var + i: integer; + s: string; +begin + i := Pos(Field, Header); + Result := ''; + if i > 0 then + begin + s := Copy(Header, i + Length(Field), Length(Header) - i + Length(Field)); + i := Pos(#13#10, s); + if i > 0 then + Result := Copy(s, 1, i - 1); + end; +end; + +end. diff --git a/official/4.2/LibD11/frxNewItem.dfm b/official/4.2/LibD11/frxNewItem.dfm new file mode 100644 index 0000000..8fdb63e Binary files /dev/null and b/official/4.2/LibD11/frxNewItem.dfm differ diff --git a/official/4.2/LibD11/frxNewItem.pas b/official/4.2/LibD11/frxNewItem.pas new file mode 100644 index 0000000..f0d1261 --- /dev/null +++ b/official/4.2/LibD11/frxNewItem.pas @@ -0,0 +1,176 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ New item dialog } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxNewItem; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ComCtrls, StdCtrls, ImgList; + +type + TfrxNewItemForm = class(TForm) + Pages: TPageControl; + ItemsTab: TTabSheet; + OkB: TButton; + CancelB: TButton; + TemplateTab: TTabSheet; + InheritCB: TCheckBox; + TemplateLV: TListView; + ItemsLV: TListView; + procedure FormCreate(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure ItemsLVDblClick(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + FTemplates: TStringList; + public + { Public declarations } + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + + +implementation + +{$R *.DFM} + +uses frxClass, frxDesgn, frxDsgnIntf, frxUtils, frxRes; + + +constructor TfrxNewItemForm.Create(AOwner: TComponent); +begin + inherited; + FTemplates := TStringList.Create; + FTemplates.Sorted := True; +end; + +destructor TfrxNewItemForm.Destroy; +begin + FTemplates.Free; + inherited; +end; + +procedure TfrxNewItemForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(5300); + ItemsTab.Caption := frxGet(5301); + TemplateTab.Caption := frxGet(5302); + InheritCB.Caption := frxGet(5303); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + ItemsLV.LargeImages := frxResources.WizardImages; + TemplateLV.LargeImages := frxResources.WizardImages; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxNewItemForm.FormShow(Sender: TObject); +var + i: Integer; + Item: TfrxWizardItem; + lvItem: TListItem; +begin + for i := 0 to frxWizards.Count - 1 do + begin + Item := frxWizards[i]; + if (Item.ButtonBmp <> nil) and (Item.ButtonImageIndex = -1) then + begin + frxResources.SetWizardImages(Item.ButtonBmp); + Item.ButtonImageIndex := frxResources.WizardImages.Count - 1; + end; + + lvItem := ItemsLV.Items.Add; + lvItem.Caption := Item.ClassRef.GetDescription; + lvItem.Data := Item; + lvItem.ImageIndex := Item.ButtonImageIndex; + end; + + if frxDesignerComp <> nil then + begin + frxDesignerComp.GetTemplateList(FTemplates); + for i := 0 to FTemplates.Count - 1 do + begin + lvItem := TemplateLV.Items.Add; + lvItem.Caption := ExtractFileName(FTemplates[i]); + lvItem.Data := Pointer(i); + lvItem.ImageIndex := 5; + end; + end; +end; + +procedure TfrxNewItemForm.ItemsLVDblClick(Sender: TObject); +begin + ModalResult := mrOk; +end; + +procedure TfrxNewItemForm.FormDestroy(Sender: TObject); +var + w: TfrxCustomWizard; + Designer: TfrxDesignerForm; + Report: TfrxReport; + templ: String; +begin + if ModalResult = mrOk then + begin + if (Pages.ActivePage = ItemsTab) and (ItemsLV.Selected <> nil) then + begin + w := TfrxCustomWizard(TfrxWizardItem(ItemsLV.Selected.Data).ClassRef.NewInstance); + w.Create(Owner); + if w.Execute then + w.Designer.Modified := True; + w.Free; + end + else if (Pages.ActivePage = TemplateTab) and (TemplateLV.Selected <> nil) then + begin + Designer := TfrxDesignerForm(Owner); + Report := Designer.Report; + templ := FTemplates[Integer(TemplateLV.Selected.Data)]; + Designer.Lock; + try + Report.Clear; + if InheritCB.Checked then + Report.ParentReport := ExtractRelativePath( + Report.GetApplicationFolder, templ) + else + begin + if Assigned(Report.OnLoadTemplate) then + Report.OnLoadTemplate(Report, templ) + else + Report.LoadFromFile(templ); + end; + finally + Report.FileName := ''; + Designer.ReloadReport; + end; + end; + end; +end; + +procedure TfrxNewItemForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxOLE.pas b/official/4.2/LibD11/frxOLE.pas new file mode 100644 index 0000000..faee066 --- /dev/null +++ b/official/4.2/LibD11/frxOLE.pas @@ -0,0 +1,287 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ OLE object } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxOLE; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + OleCtnrs, StdCtrls, ExtCtrls, frxClass, ActiveX +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF FR_COM} +, FastReport_TLB +{$ENDIF}; + + +type + TfrxSizeMode = (fsmClip, fsmScale); + + TfrxOLEObject = class(TComponent) // fake component + end; + +{$IFDEF FR_COM} + TfrxOLEView = class(TfrxView, IfrxOLEView) +{$ELSE} + TfrxOLEView = class(TfrxView) +{$ENDIF} + private + FOleContainer: TOleContainer; + FSizeMode: TfrxSizeMode; + FStretched: Boolean; + procedure ReadData(Stream: TStream); + procedure SetStretched(const Value: Boolean); + procedure WriteData(Stream: TStream); + protected + procedure DefineProperties(Filer: TFiler); override; +{$IFDEF FR_COM} + function Get_OleContainer(out Value: IUnknown): HResult; stdcall; + function Get_SizeMode(out Value: Integer): HResult; stdcall; + function Set_SizeMode(Value: Integer): HResult; stdcall; + function Get_Stretched(out Value: WordBool): HResult; stdcall; + function Set_Stretched(Value: WordBool): HResult; stdcall; +{$ENDIF} + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure GetData; override; + class function GetDescription: String; override; + property OleContainer: TOleContainer read FOleContainer; + published + property BrushStyle; + property Color; + property Cursor; + property DataField; + property DataSet; + property DataSetName; + property Frame; + property SizeMode: TfrxSizeMode read FSizeMode write FSizeMode default fsmClip; + property Stretched: Boolean read FStretched write SetStretched default False; + property TagStr; + property URL; + end; + +procedure frxAssignOle(ContFrom, ContTo: TOleContainer); + + +implementation + +uses + frxOLERTTI, +{$IFNDEF NO_EDITORS} + frxOLEEditor, +{$ENDIF} + frxDsgnIntf, frxRes; + + +procedure frxAssignOle(ContFrom, ContTo: TOleContainer); +var + st: TMemoryStream; +begin + if (ContFrom = nil) or (ContFrom.OleObjectInterface = nil) then + begin + ContTo.DestroyObject; + Exit; + end; + st := TMemoryStream.Create; + ContFrom.SaveToStream(st); + st.Position := 0; + ContTo.LoadFromStream(st); + st.Free; +end; + +function HimetricToPixels(const P: TPoint): TPoint; +begin + Result.X := MulDiv(P.X, Screen.PixelsPerInch, 2540); + Result.Y := MulDiv(P.Y, Screen.PixelsPerInch, 2540); +end; + + +{ TfrxOLEView } + +constructor TfrxOLEView.Create(AOwner: TComponent); +begin + inherited; + Font.Name := 'Tahoma'; + Font.Size := 8; + + FOleContainer := TOleContainer.Create(nil); + with FOleContainer do + begin + Parent := frxParentForm; + SendMessage(frxParentForm.Handle, WM_CREATEHANDLE, Integer(FOleContainer), 0); + AllowInPlace := False; + AutoVerbMenu := False; + BorderStyle := bsNone; + SizeMode := smClip; + end; +end; + +destructor TfrxOLEView.Destroy; +begin + SendMessage(frxParentForm.Handle, WM_DESTROYHANDLE, Integer(FOleContainer), 0); + FOleContainer.Free; + inherited; +end; + +class function TfrxOLEView.GetDescription: String; +begin + Result := frxResources.Get('obOLE'); +end; + +procedure TfrxOLEView.DefineProperties(Filer: TFiler); +begin + inherited; + Filer.DefineBinaryProperty('OLE', ReadData, WriteData, + OleContainer.OleObjectInterface <> nil); +end; + +procedure TfrxOLEView.ReadData(Stream: TStream); +begin + FOleContainer.LoadFromStream(Stream); +end; + +procedure TfrxOLEView.WriteData(Stream: TStream); +begin + FOleContainer.SaveToStream(Stream); +end; + +procedure TfrxOLEView.SetStretched(const Value: Boolean); +var + VS: TPoint; +begin + FStretched := Value; + if not Stretched then + with FOleContainer do + if OleObjectInterface <> nil then + begin + Run; + VS.X := MulDiv(Width, 2540, Screen.PixelsPerInch); + VS.Y := MulDiv(Height, 2540, Screen.PixelsPerInch); + OleObjectInterface.SetExtent(DVASPECT_CONTENT, VS); + end; +end; + +procedure TfrxOLEView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); +var + DRect, R: TRect; + W, H: Integer; + ViewObject2: IViewObject2; + S, ViewSize: TPoint; +begin + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + DRect := Rect(FX, FY, FX1, FY1); + OleContainer.Width := FDX; + OleContainer.Height := FDY; + DrawBackground; + + if (FDX > 0) and (FDY > 0) then + with OleContainer do + if OleObjectInterface <> nil then + if Self.SizeMode = fsmClip then + OleDraw(OleObjectInterface, DVASPECT_CONTENT, Canvas.Handle, DRect) + else + begin + if Succeeded(OleObjectInterface.QueryInterface(IViewObject2, + ViewObject2)) then + begin + ViewObject2.GetExtent(DVASPECT_CONTENT, -1, nil, ViewSize); + W := DRect.Right - DRect.Left; + H := DRect.Bottom - DRect.Top; + S := HimetricToPixels(ViewSize); + if W * S.Y > H * S.X then + begin + S.X := S.X * H div S.Y; + S.Y := H; + end + else + begin + S.Y := S.Y * W div S.X; + S.X := W; + end; + + R.Left := DRect.Left + (W - S.X) div 2; + R.Top := DRect.Top + (H - S.Y) div 2; + R.Right := R.Left + S.X; + R.Bottom := R.Top + S.Y; + OleDraw(OleObjectInterface, DVASPECT_CONTENT, Canvas.Handle, R); + end + end + else + frxResources.ObjectImages.Draw(Canvas, FX + 1, FY + 2, 22); + + DrawFrame; +end; + +procedure TfrxOLEView.GetData; +var + s: TMemoryStream; +begin + inherited; + if IsDataField then + begin + s := TMemoryStream.Create; + try + DataSet.AssignBlobTo(DataField, s); + FOleContainer.LoadFromStream(s); + finally + s.Free; + end; + end; +end; + +{$IFDEF FR_COM} +function TfrxOLEView.Get_OleContainer(out Value: IUnknown): HResult; stdcall; +begin + Value := OleContainer; + Result := S_OK; +end; + +function TfrxOLEView.Get_SizeMode(out Value: Integer): HResult; stdcall; +begin + Value := Integer(SizeMode); + Result := S_OK; +end; + +function TfrxOLEView.Set_SizeMode(Value: Integer): HResult; stdcall; +begin + SizeMode := TfrxSizeMode(Value); + Result := S_OK; +end; + +function TfrxOLEView.Get_Stretched(out Value: WordBool): HResult; stdcall; +begin + Value := Stretched; + Result := S_OK; +end; + +function TfrxOLEView.Set_Stretched(Value: WordBool): HResult; stdcall; +begin + Stretched := Value; + Result := S_OK; +end; +{$ENDIF} + + +initialization + frxObjects.RegisterObject1(TfrxOLEView, nil, '', '', 0, 22); + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxOLEEditor.dfm b/official/4.2/LibD11/frxOLEEditor.dfm new file mode 100644 index 0000000..1ee2da4 Binary files /dev/null and b/official/4.2/LibD11/frxOLEEditor.dfm differ diff --git a/official/4.2/LibD11/frxOLEEditor.pas b/official/4.2/LibD11/frxOLEEditor.pas new file mode 100644 index 0000000..ec59ae9 --- /dev/null +++ b/official/4.2/LibD11/frxOLEEditor.pas @@ -0,0 +1,148 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ OLE design editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxOLEEditor; + +interface + +{$I frx.inc} + +uses + Windows, Classes, SysUtils, Graphics, Controls, StdCtrls, Forms, Menus, + Dialogs, frxClass, frxCustomEditors, frxDsgnIntf, frxOLE, OleCtnrs +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxOLEEditor = class(TfrxViewEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxOleEditorForm = class(TForm) + InsertB: TButton; + EditB: TButton; + CloseB: TButton; + OleContainer: TOleContainer; + procedure InsertBClick(Sender: TObject); + procedure EditBClick(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + public + { Public declarations } + end; + + +implementation + +{$R *.DFM} + +uses frxRes; + + +{ TfrxOLEEditor } + +function TfrxOLEEditor.HasEditor: Boolean; +begin + Result := True; +end; + +function TfrxOLEEditor.Edit: Boolean; +begin + with TfrxOleEditorForm.Create(Designer) do + begin + frxAssignOLE(TfrxOLEView(Component).OleContainer, OleContainer); + Result := ShowModal = mrOk; + if Result then + frxAssignOLE(OleContainer, TfrxOLEView(Component).OleContainer); + Free; + end; +end; + +function TfrxOLEEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + i: Integer; + c: TfrxComponent; + v: TfrxOLEView; +begin + Result := inherited Execute(Tag, Checked); + for i := 0 to Designer.SelectedObjects.Count - 1 do + begin + c := Designer.SelectedObjects[i]; + if (c is TfrxOLEView) and not (rfDontModify in c.Restrictions) then + begin + v := TfrxOLEView(c); + if Tag = 1 then + v.Stretched := Checked; + Result := True; + end; + end; +end; + +procedure TfrxOLEEditor.GetMenuItems; +var + v: TfrxOLEView; +begin + v := TfrxOLEView(Component); + AddItem(frxResources.Get('olStretched'), 1, v.Stretched); + inherited; +end; + + +{ TfrxOLEEditorForm } + +procedure TfrxOleEditorForm.InsertBClick(Sender: TObject); +begin + OleContainer.InsertObjectDialog; +end; + +procedure TfrxOleEditorForm.EditBClick(Sender: TObject); +begin + if OleContainer.OleObjectInterface <> nil then + OleContainer.DoVerb(ovPrimary); +end; + +procedure TfrxOleEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(3400); + InsertB.Caption := frxGet(3401); + EditB.Caption := frxGet(3402); + CloseB.Caption := frxGet(3403); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + + +procedure TfrxOleEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +initialization + frxComponentEditors.Register(TfrxOLEView, TfrxOLEEditor); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxOLERTTI.pas b/official/4.2/LibD11/frxOLERTTI.pas new file mode 100644 index 0000000..50866d2 --- /dev/null +++ b/official/4.2/LibD11/frxOLERTTI.pas @@ -0,0 +1,70 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ OLE RTTI } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxOLERTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, frxOLE, frxClassRTTI +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnum('TfrxSizeMode', 'fsmClip, fsmScale'); + with AddClass(TfrxOLEView, 'TfrxView') do + AddProperty('OleContainer', 'TOleContainer', GetProp, nil); + end; +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TfrxOLEView then + begin + if PropName = 'OLECONTAINER' then + Result := Integer(TfrxOLEView(Instance).OleContainer) + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPBarcode.pas b/official/4.2/LibD11/frxPBarcode.pas new file mode 100644 index 0000000..f8808ce --- /dev/null +++ b/official/4.2/LibD11/frxPBarcode.pas @@ -0,0 +1,206 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ PSOFT Barcode Add-in object } +{ http://www.psoft.sk } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPBarcode; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Menus, EanKod, EanSpecs, frxClass, ExtCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxPBarCodeObject = class(TComponent); // fake component + + TfrxPBarCodeView = class(TfrxView) + private + FBarCode: TEan; + FExpression: String; + FText: String; + FLinesColor: TColor; + FBarType: TTypBarCode; + FRotation: Integer; + FFontAutoSize: Boolean; + FCalcCheckSum: Boolean; + FShowText: Boolean; + function GetPDF417: TpsPDF417; + function GetSecurity: Boolean; + function GetHorzLines: TBarcodeHorzLines; + function GetStartStopLine: Boolean; + function GetTrasparent: Boolean; + procedure SetPDF417(const Value: TpsPDF417); + procedure SetSecurity(const Value: Boolean); + procedure SetHorzLines(const Value: TBarcodeHorzLines); + procedure SetStartStopLines(const Value: Boolean); + procedure SetTrasparent(const Value: Boolean); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure GetData; override; + class function GetDescription: String; override; + property BarCode: TEan read FBarCode; + published + property HorzLines: TBarcodeHorzLines read GetHorzLines write SetHorzLines; + property Security: Boolean read GetSecurity write SetSecurity; + property PDF417: TpsPDF417 read GetPDF417 write SetPDF417; + property StartStopLines: Boolean read GetStartStopLine write SetStartStopLines; + property Trasparent: Boolean read GetTrasparent write SetTrasparent; + property LinesColor: TColor read FLinesColor write FLinesColor default clBlack; + property BarType: TTypBarCode read FBarType write FBarType; + property Rotation: Integer read FRotation write FRotation; + property Font; + property FontAutoSize: Boolean read FFontAutoSize write FFontAutoSize default True; + property CalcCheckSum: Boolean read FCalcCheckSum write FCalcCheckSum default False; + property ShowText: Boolean read FShowText write FShowText default True; + property Color; + property DataField; + property DataSet; + property DataSetName; + property Expression: String read FExpression write FExpression; + property Frame; + property Text: String read FText write FText; + end; + + +implementation + +uses +{$IFNDEF NO_EDITORS} + frxPBarcodeEditor, +{$ENDIF} + frxPBarcodeRTTI, frxDsgnIntf, frxRes; + + + +{ TfrxPBarCodeView } + +constructor TfrxPBarCodeView.Create(AOwner: TComponent); +begin + inherited; + FBarCode := TEan.Create(nil); + FLinesColor := clBlack; + FFontAutoSize := True; + FShowText := True; +end; + +destructor TfrxPBarCodeView.Destroy; +begin + FBarCode.Free; + inherited Destroy; +end; + +class function TfrxPBarCodeView.GetDescription: String; +begin + Result := 'PSOFT Barcode object'; +end; + +procedure TfrxPBarCodeView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +begin + FBarCode.LinesColor := FLinesColor; + FBarCode.BackgroundColor := Color; + FBarCode.Transparent := Color = clNone; + + FBarCode.Angle := FRotation; + FBarCode.Font.Assign(Font); + FBarCode.FontAutoSize := FFontAutoSize; + + FBarCode.AutoCheckDigit := FCalcCheckSum; + FBarCode.TypBarCode := FBarType; + if FText <> '' then + FBarCode.BarCode := FText; + FBarcode.ShowLabels := FShowText; + + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + PaintBarCode(Canvas, Rect(FX, FY, FX1, FY1), FBarCode); + DrawFrame; +end; + +procedure TfrxPBarCodeView.GetData; +begin + inherited; + if IsDataField then + FText := DataSet.Value[DataField] + else if FExpression <> '' then + FText := Report.Calc(FExpression); +end; + + +function TfrxPBarCodeView.GetPDF417: TpsPDF417; +begin + Result := FBarCode.PDF417; +end; + +procedure TfrxPBarCodeView.SetPDF417(const Value: TpsPDF417); +begin + FBarCode.PDF417 := Value; +end; + +function TfrxPBarCodeView.GetSecurity: Boolean; +begin + Result := FBarCode.Security; +end; + +procedure TfrxPBarCodeView.SetSecurity(const Value: Boolean); +begin + FBarCode.Security := Value; +end; + +function TfrxPBarCodeView.GetHorzLines: TBarcodeHorzLines; +begin + Result := FBarCode.HorzLines; +end; + +procedure TfrxPBarCodeView.SetHorzLines(const Value: TBarcodeHorzLines); +begin + FBarCode.HorzLines := Value; +end; + +function TfrxPBarCodeView.GetStartStopLine: Boolean; +begin + Result := FBarCode.StartStopLines; +end; + +procedure TfrxPBarCodeView.SetStartStopLines(const Value: Boolean); +begin + FBarCode.StartStopLines := Value; +end; + +function TfrxPBarCodeView.GetTrasparent: Boolean; +begin + Result := FBarCode.Transparent; +end; + +procedure TfrxPBarCodeView.SetTrasparent(const Value: Boolean); +begin + FBarCode.Transparent := Value; +end; + +initialization + frxObjects.RegisterObject1(TfrxPBarCodeView, nil, '', 'Other', 0, 23); + + + +end. + + +//a925ad72a1da9d8873ffb721772811b5 + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPBarcodeEditor.dfm b/official/4.2/LibD11/frxPBarcodeEditor.dfm new file mode 100644 index 0000000..d0ccdc8 Binary files /dev/null and b/official/4.2/LibD11/frxPBarcodeEditor.dfm differ diff --git a/official/4.2/LibD11/frxPBarcodeEditor.pas b/official/4.2/LibD11/frxPBarcodeEditor.pas new file mode 100644 index 0000000..386d4a3 --- /dev/null +++ b/official/4.2/LibD11/frxPBarcodeEditor.pas @@ -0,0 +1,241 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ PSOFT Barcode design editor } +{ http://www.psoft.sk } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPBarcodeEditor; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Menus, ExtCtrls, Buttons, frxClass, frxPBarcode, frxCustomEditors, + EanKod, EanSpecs, frxCtrls, ComCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxPBarcodeEditor = class(TfrxViewEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxPBarcodeEditorForm = class(TForm) + CancelB: TButton; + OkB: TButton; + CodeE: TfrxComboEdit; + CodeLbl: TLabel; + TypeCB: TComboBox; + TypeLbl: TLabel; + ExampleBvl: TBevel; + ExamplePB: TPaintBox; + OptionsLbl: TGroupBox; + CalcCheckSumCB: TCheckBox; + ViewTextCB: TCheckBox; + RotationLbl: TGroupBox; + Rotation0RB: TRadioButton; + Rotation90RB: TRadioButton; + Rotation180RB: TRadioButton; + Rotation270RB: TRadioButton; + procedure ExprBtnClick(Sender: TObject); + procedure ExamplePBPaint(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + FBarcode: TfrxPBarcodeView; + public + { Public declarations } + property Barcode: TfrxPBarcodeView read FBarcode write FBarcode; + end; + + +implementation + +uses frxDsgnIntf, frxRes, frxUtils; + +{$R *.DFM} + + +{ TfrxPBarcodeEditor } + +function TfrxPBarcodeEditor.HasEditor: Boolean; +begin + Result := True; +end; + +function TfrxPBarcodeEditor.Edit: Boolean; +begin + with TfrxPBarcodeEditorForm.Create(Designer) do + begin + Barcode := TfrxPBarcodeView(Component); + Result := ShowModal = mrOk; + Free; + end; +end; + +function TfrxPBarcodeEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + i: Integer; + c: TfrxComponent; + v: TfrxPBarcodeView; +begin + Result := inherited Execute(Tag, Checked); + for i := 0 to Designer.SelectedObjects.Count - 1 do + begin + c := Designer.SelectedObjects[i]; + if (c is TfrxPBarcodeView) and not (rfDontModify in c.Restrictions) then + begin + v := TfrxPBarcodeView(c); + if Tag = 1 then + v.CalcCheckSum := Checked + else if Tag = 2 then + v.ShowText := Checked; + Result := True; + end; + end; +end; + +procedure TfrxPBarcodeEditor.GetMenuItems; +var + v: TfrxPBarcodeView; +begin + v := TfrxPBarcodeView(Component); + AddItem(frxResources.Get('bcCalcChecksum'), 1, v.CalcCheckSum); + AddItem(frxResources.Get('bcShowText'), 2, v.ShowText); + inherited; +end; + + +{ TfrxPBarcodeEditorForm } + +procedure TfrxPBarcodeEditorForm.FormShow(Sender: TObject); +begin + FBarcode.BarCode.AddTypesToList(TypeCB.Items, btText); + + CodeE.Text := FBarcode.Text; + TypeCB.ItemIndex := Integer(FBarcode.BarType); + CalcCheckSumCB.Checked := FBarcode.CalcCheckSum; + ViewTextCB.Checked := FBarcode.ShowText; + + case FBarcode.Rotation of + 90: Rotation90RB.Checked := True; + 180: Rotation180RB.Checked := True; + 270: Rotation270RB.Checked := True; + else Rotation0RB.Checked := True; + end; + + ExamplePBPaint(nil); +end; + +procedure TfrxPBarcodeEditorForm.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + begin + FBarcode.Text := CodeE.Text; + FBarcode.BarType := TTypBarcode(TypeCB.ItemIndex); + FBarcode.CalcCheckSum := CalcCheckSumCB.Checked; + FBarcode.ShowText := ViewTextCB.Checked; + + if Rotation90RB.Checked then + FBarcode.Rotation := 90 + else if Rotation180RB.Checked then + FBarcode.Rotation := 180 + else if Rotation270RB.Checked then + FBarcode.Rotation := 270 + else + FBarcode.Rotation := 0; + end; +end; + +procedure TfrxPBarcodeEditorForm.ExprBtnClick(Sender: TObject); +var + s: String; +begin + s := TfrxCustomDesigner(Owner).InsertExpression(CodeE.Text); + if s <> '' then + CodeE.Text := s; +end; + +procedure TfrxPBarcodeEditorForm.ExamplePBPaint(Sender: TObject); +var + Barcode: TfrxPBarcodeView; +begin + Barcode := TfrxPBarcodeView.Create(nil); + Barcode.BarType := TTypBarcode(TypeCB.ItemIndex); + if Rotation0RB.Checked then + Barcode.Rotation := 0 + else if Rotation90RB.Checked then + Barcode.Rotation := 90 + else if Rotation180RB.Checked then + Barcode.Rotation := 180 + else + Barcode.Rotation := 270; + Barcode.CalcCheckSum := CalcCheckSumCB.Checked; + Barcode.ShowText := ViewTextCB.Checked; + Barcode.SetBounds(20, 20, ExamplePB.Width - 40, 200); + + with ExamplePB.Canvas do + begin + Brush.Color := clWhite; + FillRect(Rect(0, 0, ExamplePB.Width, ExamplePB.Height)); + end; + + Barcode.Draw(ExamplePB.Canvas, 1, 1, 0, 0); + Barcode.Free; +end; + +procedure TfrxPBarcodeEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(3500); + CodeLbl.Caption := frxGet(3501); + TypeLbl.Caption := frxGet(3502); + OptionsLbl.Caption := frxGet(3504); + RotationLbl.Caption := frxGet(3505); + CancelB.Caption := frxGet(2); + OkB.Caption := frxGet(1); + CalcCheckSumCB.Caption := frxGet(3506); + ViewTextCB.Caption := frxGet(3507); + Rotation0RB.Caption := frxGet(3508); + Rotation90RB.Caption := frxGet(3509); + Rotation180RB.Caption := frxGet(3510); + Rotation270RB.Caption := frxGet(3511); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + + +procedure TfrxPBarcodeEditorForm.FormKeyDown(Sender: TObject; + var Key: Word; Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +initialization + frxComponentEditors.Register(TfrxPBarcodeView, TfrxPBarcodeEditor); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPBarcodeRTTI.pas b/official/4.2/LibD11/frxPBarcodeRTTI.pas new file mode 100644 index 0000000..bdd3a5e --- /dev/null +++ b/official/4.2/LibD11/frxPBarcodeRTTI.pas @@ -0,0 +1,61 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ PSOFT Barcode RTTI } +{ http://www.psoft.sk } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPBarcodeRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, frxPBarcode, frxClassRTTI +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + + +type + TFunctions = class(TfsRTTIModule) + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnum('TTypBarCode', + 'bcEan8, bcEan13, bcCodabar, bcCode39Standard, bcCode39Full, bcCode93Standard, ' + + 'bcCode93Full, bcCode128, bcABCCodabar, bc25Datalogic, bc25Interleaved, ' + + 'bc25Matrix, bc25Industrial, bc25IATA, bc25Invert, bc25Coop, bcITF, bcISBN, ' + + 'bcISSN, bcISMN, bcUPCA, bcUPCE0, bcUPCE1, bcUPCShipping, bcJAN8, bcJAN13, ' + + 'bcMSIPlessey, bcPostNet, bcOPC, bcEan128, bcCode11, bcPZN, bcPDF417'); + AddClass(TfrxPBarcodeView, 'TfrxView'); + end; +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPDFFile.pas b/official/4.2/LibD11/frxPDFFile.pas new file mode 100644 index 0000000..cc84552 --- /dev/null +++ b/official/4.2/LibD11/frxPDFFile.pas @@ -0,0 +1,1780 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ PDF file library } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{******************************************} +{ Add CJK Font support by } +{ crispin2k@hotmail.com } +{ http://www.jane.com.tw } +{******************************************} + +unit frxPDFFile; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Forms, + ComObj, ComCtrls, frxClass, frxUtils, JPEG, frxUnicodeUtils +{$IFDEF Delphi6}, Variants {$ENDIF}; + +type + TfrxPDFPage = class; + TfrxPDFFont = class; + + TfrxPDFElement = class(TObject) + private + FXrefPosition: Cardinal; + FIndex: Integer; + FLines: String; + FCR: Boolean; + procedure Write(const S: String); + procedure WriteLn(const S: String); + procedure Flush(const Stream: TStream); + public + constructor Create; + procedure SaveToStream(const Stream: TStream); virtual; + property XrefPosition: Cardinal read FXrefPosition; + property Index: Integer read FIndex write FIndex; + end; + + TfrxPDFToolkit = class(TObject) + public + Divider: Extended; + LineHeight: Extended; + LastColor: TColor; + LastColorResult: String; + constructor Create; + function GetHTextPos(const Left: Extended; const Width: Extended; const CharSpacing: Extended; + const Text: String; const Align: TfrxHAlign): Extended; + function GetVTextPos(const Top: Extended; const Height: Extended; const Text: String; + const Align: TfrxVAlign; const Line: Integer = 0; const Count: Integer = 1): Extended; + function GetLineWidth(const Text: String; const CharSpacing: Extended): Extended; + procedure SetMemo(const Memo: TfrxCustomMemoView); + end; + + TfrxPDFFile = class(TfrxPDFElement) + private + FPages: TList; + FFonts: TList; + FXRef: TStringList; + FObjNo: Integer; + FCounter: Integer; + FTitle: String; + FStartXRef: Cardinal; + FStartFonts: Integer; + FStartPages: Integer; + FPagesRoot: Integer; + FCompressed: Boolean; + FPrintOpt: Boolean; + FOutline: Boolean; + FPreviewOutline: TfrxCustomOutline; + FSubject: String; + FAuthor: String; + FBackground: Boolean; + FCreator: String; + FHTMLTags: Boolean; + FPageNumbers: String; + FTotalPages: Integer; + public + FStreamObjects: TStream; + FTempStreamFile: String; + FEmbedded: Boolean; + FFontDCnt: Integer; + PTool: TfrxPDFToolkit; + constructor Create(const UseFileCache: Boolean; const TempDir: String); + destructor Destroy; override; + procedure Clear; + procedure XRefAdd(Stream: TStream; ObjNo: Integer); + procedure SaveToStream(const Stream: TStream); override; + function AddPage(const Page: TfrxReportPage): TfrxPDFPage; + function AddFont(const Font: TFont): Integer; + + property Pages: TList read FPages; + property Fonts: TList read FFonts; + property Counter: Integer read FCounter write FCounter; + property Title: String read FTitle write FTitle; + property Compressed: Boolean read FCompressed write FCompressed; + property EmbeddedFonts: Boolean read FEmbedded write FEmbedded default True; + property PrintOptimized: Boolean read FPrintOpt write FPrintOpt; + property Outline: Boolean read FOutline write FOutline; + property PreviewOutline: TfrxCustomOutline read FPreviewOutline write FPreviewOutline; + property Author: String read FAuthor write FAuthor; + property Subject: String read FSubject write FSubject; + property Background: Boolean read FBackground write FBackground; + property Creator: String read FCreator write FCreator; + property HTMLTags: Boolean read FHTMLTags write FHTMLTags; + property PageNumbers: String read FPageNumbers write FPageNumbers; + property TotalPages: Integer read FTotalPages write FTotalPages; + end; + + TfrxPDFPage = class(TfrxPDFElement) + private + FStreamOffset: Longint; + FParent: TfrxPDFFile; + FWidth: Extended; + FHeight: Extended; + FMarginLeft: Extended; + FMarginTop: Extended; + FStream: TStream; + FStreamSize: Longint; + public + constructor Create; + procedure SaveToStream(const Stream: TStream); override; + procedure AddObject(const Obj: TfrxView); + property StreamOffset: Longint read FStreamOffset write FStreamOffset; + property StreamSize: Longint read FStreamSize write FStreamSize; + + property OutStream: TStream read FStream write FStream; + property Parent: TfrxPDFFile read FParent write FParent; + property Width: Extended read FWidth write FWidth; + property Height: Extended read FHeight write FHeight; + property MarginLeft: Extended read FMarginLeft write FMarginLeft; + property MarginTop: Extended read FMarginTop write FMarginTop; + end; + + TfrxPDFFont = class(TfrxPDFElement) + private + FFont: TFont; + FParent: TfrxPDFFile; + FFontDCnt: Integer; + public + constructor Create; + destructor Destroy; override; + procedure SaveToStream(const Stream: TStream); override; + + property Parent: TfrxPDFFile read FParent write FParent; + property Font: TFont read FFont; + end; + + TfrxPDFOutlineNode = class(TObject) + private + FNumber: Integer; + FDest: Integer; + FTop: Integer; + FCountTree: Integer; + FCount: Integer; + FTitle: String; + FLast: TfrxPDFOutlineNode; + FNext: TfrxPDFOutlineNode; + FParent: TfrxPDFOutlineNode; + FPrev: TfrxPDFOutlineNode; + FFirst: TfrxPDFOutlineNode; + public + constructor Create; + destructor Destroy; override; + property Title: String read FTitle write FTitle; + property Dest: Integer read FDest write FDest; + property Top: Integer read FTop write FTop; + property Number: Integer read FNumber write FNumber; + property CountTree: Integer read FCountTree write FCountTree; + property Count: Integer read FCount write FCount; + property First: TfrxPDFOutlineNode read FFirst write FFirst; + property Last: TfrxPDFOutlineNode read FLast write FLast; + property Parent: TfrxPDFOutlineNode read FParent write FParent; + property Prev: TfrxPDFOutlineNode read FPrev write FPrev; + property Next: TfrxPDFOutlineNode read FNext write FNext; + end; + +implementation + +uses frxGraphicUtils, frxGzip; + +const + PDF_VER = '1.3'; + PDF_DIVIDER = 0.75; + PDF_MARG_DIVIDER = 0.05; + PDF_PRINTOPT = 3; // 4 change to 3 + +type + PABC = ^ABCarray; + ABCarray = array [0..255] of ABC; + +function CheckOEM(const Value: String): boolean; +var + i: integer; +begin + result := false; + for i := 1 to Length(Value) do + if (ByteType(Value, i) <> mbSingleByte) or + (Ord(Value[i]) > 122) or + (Ord(Value[i]) < 32) then + begin + result := true; + Break; + end; +end; + +function StrToUTF16(const Value: String): String; +var + PW: Pointer; + Len: integer; + i: integer; + pwc: ^Word; +begin + result := 'FEFF'; + Len := MultiByteToWideChar(0, CP_ACP, PChar(Value), Length(Value), nil, 0); + GetMem(PW, Len * 2); + try + Len := MultiByteToWideChar(0, CP_ACP, PChar(Value), Length(Value), PW, Len * 2); + pwc := PW; + for i := 0 to Len - 1 do + begin + result := result + IntToHex(pwc^, 4); + Inc(pwc); + end; + finally + FreeMem(PW); + end; +end; + +function PrepareString(const Text: String): String; +begin + if CheckOEM(Text) then + Result := '<' + StrToUTF16(Text) + '>' + else + Result := '(' + Text + ')'; +end; + +{ TfrxPDFFile } + +constructor TfrxPDFFile.Create(const UseFileCache: Boolean; const TempDir: String); +begin + inherited Create; + PTool := TfrxPDFToolkit.Create; + FPages := TList.Create; + FFonts := TList.Create; + FXRef := TStringList.Create; + FCounter := 4; + FStartPages := 0; + FStartXRef := 0; + FStartFonts := 0; + FCompressed := True; + FPrintOpt := False; + FOutline := False; + FPreviewOutline := nil; + FHTMLTags := False; + FFontDCnt := 0; + FObjNo := 0; + if UseFileCache then + begin + FTempStreamFile := frxCreateTempFile(TempDir); + FStreamObjects := TFileStream.Create(FTempStreamFile, fmCreate); + end else + FStreamObjects := TMemoryStream.Create; +end; + +destructor TfrxPDFFile.Destroy; +begin + Clear; + FXRef.Free; + FPages.Free; + FFonts.Free; + PTool.Free; + FStreamObjects.Free; + try + DeleteFile(FTempStreamFile); + except + end; + inherited; +end; + +procedure TfrxPDFFile.Clear; +var + i: Integer; +begin + for i := 0 to FPages.Count - 1 do + TfrxPDFPage(FPages[i]).Free; + FPages.Clear; + for i := 0 to FFonts.Count - 1 do + TfrxPDFFont(FFonts[i]).Free; + FFonts.Clear; + FXRef.Clear; +end; + +procedure TfrxPDFFile.SaveToStream(const Stream: TStream); +var + i, j: Integer; + s, s1: String; + Page, Top: Integer; + Text: String; + Parent: Integer; + OutlineCount: Integer; + NodeNumber: Integer; + OutlineTree: TfrxPDFOutlineNode; + pgN: TStringList; + + function CheckPageInRange(const PageN: Integer): Boolean; + begin + Result := True; + if (pgN.Count <> 0) and (pgN.IndexOf(IntToStr(PageN + 1)) = -1) then + Result := False; + end; + + procedure DoPrepareOutline(Node: TfrxPDFOutlineNode); + var + i: Integer; + p: TfrxPDFOutlineNode; + prev: TfrxPDFOutlineNode; + begin + Inc(NodeNumber); + prev := nil; + p := nil; + for i := 0 to FPreviewOutline.Count - 1 do + begin + FPreviewOutline.GetItem(i, Text, Page, Top); + if CheckPageInRange(Page) then + begin + p := TfrxPDFOutlineNode.Create; + p.Title := Text; + p.Dest := Page; + p.Top := Top; + p.Prev := prev; + if prev <> nil then + prev.Next := p + else + Node.First := p; + prev := p; + p.Parent := Node; + FPreviewOutline.LevelDown(i); + DoPrepareOutline(p); + Node.Count := Node.Count + 1; + Node.CountTree := Node.CountTree + p.CountTree + 1; + FPreviewOutline.LevelUp; + end; + end; + Node.Last := p; + end; + + procedure DoWriteOutline(Node: TfrxPDFOutlineNode; Parent: Integer); + var + p: TfrxPDFOutlineNode; + begin + p := Node; + if p.Dest = -1 then + p.Number := Parent + else + begin + p.Number := FCounter; + Inc(FObjNo); + XRefAdd(Stream, FObjNo); + WriteLn(IntToStr(FCounter) + ' 0 obj'); + Inc(FCounter); + WriteLn('<<'); + WriteLn('/Title ' + PrepareString(p.Title)); + WriteLn('/Parent ' + IntToStr(Parent) + ' 0 R'); + if p.Prev <> nil then + WriteLn('/Prev ' + IntToStr(p.Prev.Number) + ' 0 R'); + if p.First <> nil then + begin + WriteLn('/First ' + IntToStr(p.Number + 1) + ' 0 R'); + WriteLn('/Last ' + IntToStr(p.Number + p.CountTree - p.Last.CountTree ) + ' 0 R'); + WriteLn('/Count ' + IntToStr(p.Count)); + end; + if p.Next <> nil then + WriteLn('/Next ' + IntToStr(p.Number + p.CountTree + 1) + ' 0 R'); + if CheckPageInRange(p.Dest) then + begin + if pgN.Count > 0 then + s := '/Dest [' + IntToStr(FpagesRoot + FFonts.Count * FFontDCnt + pgN.IndexOf(IntToStr(p.Dest + 1)) * 2 + 1) + ' 0 R /XYZ 0 ' + IntToStr(Round(TfrxPDFPage(FPages[pgN.IndexOf(IntToStr(p.Dest + 1))]).Height - p.Top * PDF_DIVIDER)) + ' 0]' + else + s := '/Dest [' + IntToStr(FpagesRoot + FFonts.Count * FFontDCnt + p.Dest * 2 + 1) + ' 0 R /XYZ 0 ' + IntToStr(Round(TfrxPDFPage(FPages[p.Dest]).Height - p.Top * PDF_DIVIDER)) + ' 0]'; + WriteLn(s); + end; + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + end; + if p.First <> nil then + DoWriteOutline(p.First, p.Number); + if p.Next <> nil then + DoWriteOutline(p.Next, Parent); + end; + +begin + inherited SaveToStream(Stream); + OutlineCount := 0; + OutlineTree := nil; + if FOutline then + if not Assigned(FPreviewOutline) then + FOutline := False + else + FPreviewOutline.LevelRoot; + FCounter := 1; + s := FormatDateTime('yyyy', Now) + FormatDateTime('mm', Now) + + FormatDateTime('dd', Now) + FormatDateTime('hh', Now) + + FormatDateTime('nn', Now) + FormatDateTime('ss', Now); + WriteLn('%PDF-' + PDF_VER); + WriteLn('%'#226#227#207#211); + Flush(Stream); + Inc(FObjNo); + XRefAdd(Stream, FObjNo); + WriteLn(IntToStr(FCounter) + ' 0 obj'); + Inc(FCounter); + WriteLn('<<'); + WriteLn('/Type /Catalog'); + i := 0; + + if FOutline then + begin + OutlineTree := TfrxPDFOutlineNode.Create; + pgN := TStringList.Create; + NodeNumber := 0; + frxParsePageNumbers(PageNumbers, pgN, FTotalPages); + DoPrepareOutline(OutlineTree); + if OutlineTree.CountTree > 0 then + begin + OutlineCount := OutlineTree.CountTree - OutlineTree.Last.CountTree; + i := OutlineTree.CountTree + 1; + end else + FOutline := False; + end; + + FPagesRoot := FObjNo + 2 + i; + WriteLn('/Pages ' + IntToStr(FPagesRoot) + ' 0 R'); + if FOutline then s1 := '/UseOutlines' + else s1 := '/UseNone'; + WriteLn('/PageMode ' + s1); + if FOutline then + WriteLn('/Outlines ' + IntToStr(FCounter + 1) + ' 0 R'); + if Length(Title) > 0 then + WriteLn('/ViewerPreferences << /DisplayDocTitle true >>'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(FObjNo); + XRefAdd(Stream, FObjNo); + WriteLn(IntToStr(FCounter) + ' 0 obj'); + Inc(FCounter); + WriteLn('<<'); + WriteLn('/Producer ' + PrepareString(FCreator)); + WriteLn('/Author ' + PrepareString(FAuthor)); + WriteLn('/Subject ' + PrepareString(FSubject)); + WriteLn('/Creator ' + PrepareString(Application.Name)); + WriteLn('/Title ' + PrepareString(FTitle)); + WriteLn('/CreationDate (D:' + s + ')'); + WriteLn('/ModDate (D:' + s + ')'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + if FOutline then + begin + Inc(FObjNo); + XRefAdd(Stream, FObjNo); + WriteLn(IntToStr(FCounter) + ' 0 obj'); + Parent := FCounter; + Inc(FCounter); + FPreviewOutline.LevelRoot; + WriteLn('<<'); + WriteLn('/Count ' + IntToStr(FPreviewOutline.Count)); + WriteLn('/First ' + IntToStr(FCounter) + ' 0 R'); + WriteLn('/Last ' + IntToStr(FCounter + OutlineCount - 1) + ' 0 R'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + DoWriteOutline(OutlineTree, Parent); + OutlineTree.Free; + pgN.Free; + FCounter := FCounter + FPreviewOutline.Count; + end; + FStartFonts := FObjNo; + Inc(FObjNo); + for i := 0 to FFonts.Count - 1 do + TfrxPDFFont(FFonts[i]).SaveToStream(Stream); + + FStartPages := FObjNo + 1; + + for i := 0 to FPages.Count - 1 do + begin + TfrxPDFPage(FPages[FPages.Count - 1]).StreamSize := FStreamObjects.Size - TfrxPDFPage(FPages[FPages.Count - 1]).StreamOffset; + TfrxPDFPage(FPages[i]).SaveToStream(Stream); + end; + + Flush(Stream); + XRefAdd(Stream, FPagesRoot); + WriteLn(IntToStr(FPagesRoot) + ' 0 obj'); + WriteLn('<<'); + WriteLn('/Type /Pages'); + Write('/Kids ['); + for i := 0 to FPages.Count - 1 do + Write(IntToStr(FStartPages + i * 2) + ' 0 R '); + WriteLn(']'); + WriteLn('/Count ' + IntToStr(FPages.Count)); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + FStartXRef := Stream.Position; + WriteLn('xref'); + WriteLn('0 ' + IntToStr(FXRef.Count + 1)); + WriteLn('0000000000 65535 f'); + + for i := 1 to FXRef.Count do + begin + j := FXRef.IndexOfObject(TObject(i)); + if j <> -1 then + WriteLn(FXRef.Strings[j] + ' 00000 n'); + end; + + WriteLn('trailer'); + WriteLn('<<'); + WriteLn('/Size ' + IntToStr(FXref.Count + 1)); + WriteLn('/Root 1 0 R'); + WriteLn('/Info 2 0 R'); + WriteLn('>>'); + WriteLn('startxref'); + WriteLn(IntToStr(FStartXRef)); + WriteLn('%%EOF'); + Flush(Stream); +end; + +procedure TfrxPDFFile.XRefAdd(Stream: TStream; ObjNo: Integer); +begin + FXRef.AddObject(StringOfChar('0', 10 - Length(IntToStr(Stream.Position))) + IntToStr(Stream.Position), TObject(ObjNo)); +end; + +function TfrxPDFFile.AddFont(const Font: TFont): Integer; +var + Font2: TfrxPDFFont; + i, j: Integer; +begin + j := -1; + for i := 0 to FFonts.Count - 1 do + begin + Font2 := TfrxPDFFont(FFonts[i]); + if (Font2.Font.Name = Font.Name) and + (Font2.Font.Style = Font.Style) and + (Font2.Font.Charset = Font.Charset) then + begin + j := i; + break; + end; + end; + if j = -1 then + begin + Font2 := TfrxPDFFont.Create; + Font2.Parent := Self; + Font2.Font.Assign(Font); + FFonts.Add(Font2); + j := FFonts.Count - 1; + Font2.Index := j + 1 + end; + Result := j; +end; + +function TfrxPDFFile.AddPage(const Page: TfrxReportPage): TfrxPDFPage; +var + PDFPage: TfrxPDFPage; +begin + PDFPage := TfrxPDFPage.Create; + PDFPage.Width := Page.Width * PDF_DIVIDER; + PDFPage.Height := Page.Height * PDF_DIVIDER; + PDFPage.MarginLeft := Page.LeftMargin * PDF_MARG_DIVIDER; + PDFPAge.MarginTop := Page.TopMargin * PDF_MARG_DIVIDER; + PDFPage.Parent := Self; + PDFPage.OutStream := FStreamObjects; + PDFPage.StreamOffset := FStreamObjects.Position; + if FPages.Count > 0 then + TfrxPDFPage(FPages[FPages.Count - 1]).StreamSize := FStreamObjects.Position - + TfrxPDFPage(FPages[FPages.Count - 1]).StreamOffset; + FPages.Add(PDFPage); + PDFPage.Index := FPages.Count; + Result := PDFPage; + FFontDCnt := 2; +end; + +{ TfrxPDFPage } + +constructor TfrxPDFPage.Create; +begin + inherited; + FMarginLeft := 0; + FMarginTop := 0; +end; + +procedure TfrxPDFPage.SaveToStream(const Stream: TStream); +var + i: Integer; + s: String; + TmpPageStream: TMemoryStream; + TmpPageStream2: TMemoryStream; +begin + inherited SaveToStream(Stream); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts + (Index - 1) * 2) + ' 0 obj'); + WriteLn('<<'); + WriteLn('/Type /Page'); + WriteLn('/Parent ' + IntToStr(Parent.FPagesRoot) + ' 0 R'); + WriteLn('/MediaBox [0 0 ' + frFloat2Str(FWidth) + ' ' + frFloat2Str(FHeight) + ' ]'); + WriteLn('/Resources <<'); + WriteLn('/Font <<'); + for i := 0 to Parent.FFonts.Count - 1 do + WriteLn('/F' + IntToStr(TfrxPDFFont(Parent.FFonts[i]).Index - 1) + ' ' + + IntToStr(TfrxPDFFont(Parent.FFonts[i]).FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('>>'); + WriteLn('/XObject <<'); + WriteLn('>>'); + WriteLn('/ProcSet [/PDF /Text /ImageC ]'); + WriteLn('>>'); + WriteLn('/Contents ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts + (Index-1) * 2 + 1) + ' 0 R'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts + (Index-1) * 2 + 1) + ' 0 obj'); + Write('<< '); + TmpPageStream := TMemoryStream.Create; + TmpPageStream2 := TMemoryStream.Create; + try + OutStream.Position := FStreamOffset; + TmpPageStream2.CopyFrom(OutStream, FStreamSize); + if Parent.FCompressed then + begin + frxDeflateStream(TmpPageStream2, TmpPageStream, gzFastest); + s := '/Filter /FlateDecode /Length ' + IntToStr(TmpPageStream.Size) + + ' /Length1 ' + IntToStr(TmpPageStream2.Size); + end + else + s := '/Length ' + IntToStr(TmpPageStream2.Size); + WriteLn(s + ' >>'); + WriteLn('stream'); + Flush(Stream); + if Parent.FCompressed then + begin + Stream.CopyFrom(TmpPageStream, 0); + WriteLn(''); + end else + Stream.CopyFrom(TmpPageStream2, 0); + finally + TmpPageStream2.Free; + TmpPageStream.Free; + end; + WriteLn('endstream'); + WriteLn('endobj'); + Flush(Stream); +end; + +procedure TfrxPDFPage.AddObject(const Obj: TfrxView); +var + FontIndex: Integer; + x, y, dx, dy, fdx, fdy, PGap, FCharSpacing: Extended; + i, iz: Integer; + Jpg: TJPEGImage; + s: String; + Lines: TStrings; + TempBitmap: TBitmap; + OldFrameWidth: Extended; + TempColor: TColor; + Left, Right, Top, Bottom, Width, Height, BWidth, BHeight: String; + FUnderlineSize: Double; + FRealBounds: TfrxRect; + + function GetLeft(const Left: Extended): Extended; + begin + Result := FMarginLeft + Left * PDF_DIVIDER + end; + + function GetTop(const Top: Extended): Extended; + begin + Result := FHeight - (FMarginTop + Top * PDF_DIVIDER) + end; + + function GetPDFColor(const Color: TColor): String; + var + TheRgbValue : TColorRef; + begin + if Color = clBlack then + Result := '0 0 0' + else if Color = clWhite then + Result := '1 1 1' + else if Color = Parent.PTool.LastColor then + Result := Parent.PTool.LastColorResult + else begin + TheRgbValue := ColorToRGB(Color); + Result := frFloat2Str(GetRValue(TheRGBValue) / 255) + ' ' + + frFloat2Str(GetGValue(TheRGBValue) / 255) + ' ' + + frFloat2Str(GetBValue(TheRGBValue) / 255); + Parent.PTool.LastColor := Color; + Parent.PTool.LastColorResult := Result; + end; + end; + + procedure MakeUpFrames; + begin + if (Obj.Frame.Typ <> []) and (Obj.Frame.Color <> clNone) then + begin + WriteLn(GetPDFColor(Obj.Frame.Color) + ' RG'); + WriteLn(frFloat2Str(Obj.Frame.Width * PDF_DIVIDER) + ' w'); + if Obj.Frame.Typ = [ftTop, ftRight, ftBottom, ftLeft] then + begin + WriteLn(Left + ' ' + Top + ' m'); + WriteLn(Right + ' ' + Top + ' l'); + WriteLn(Right + ' ' + Bottom + ' l'); + WriteLn(Left + ' ' + Bottom + ' l'); + WriteLn(Left + ' ' + Top + ' l'); + WriteLn('s') + end else + begin + if ftTop in Obj.Frame.Typ then + begin + WriteLn(Left + ' ' + Top + ' m'); + WriteLn(Right + ' ' + Top + ' l'); + WriteLn('S') + end; + if ftRight in Obj.Frame.Typ then + begin + WriteLn(Right + ' ' + Top + ' m'); + WriteLn(Right + ' ' + Bottom + ' l'); + WriteLn('S') + end; + if ftBottom in Obj.Frame.Typ then + begin + WriteLn(Left + ' ' + Bottom + ' m'); + WriteLn(Right + ' ' + Bottom + ' l'); + WriteLn('S') + end; + if ftLeft in Obj.Frame.Typ then + begin + WriteLn(Left + ' ' + Top + ' m'); + WriteLn(Left + ' ' + Bottom + ' l'); + WriteLn('S') + end; + end; + end; + end; + + function HTMLTags(const View: TfrxCustomMemoView): Boolean; + var + f: Boolean; + begin + f := View.AllowHTMLTags; + if f then + begin + Result := FParent.HTMLTags and + (Pos('<' ,View.Memo.Text) > 0) and + (Pos('>' ,View.Memo.Text) > 0); + end else + Result := False; + end; + + function TruncReturns(const Str: string): string; + var + l: Integer; + begin + Result := Str; + l := Length(Result); + if (Result[l - 1] = #13) and (Result[l] = #10) then + Delete(Result, l - 2, 2); + Result := StringReplace(Result, #1, '', [rfReplaceAll]); + end; + + function CheckOutPDFChars(const Str: string): string; + begin + Result := StringReplace(Str, '\', '\\', [rfReplaceAll]); + Result := StringReplace(Result, '(', '\(', [rfReplaceAll]); + Result := StringReplace(Result, ')', '\)', [rfReplaceAll]); + end; + + function Str2RTL(const Str: String): String; + var + b, i, l: Integer; + s: String; + t, f: Boolean; + begin + Result := frxReverseString(Str); + l := Length(Result); + i := 1; + b := 1; + f := False; + while i <= l do + begin + if Result[i] = '(' then + Result[i] := ')' + else if Result[i] = ')' then + Result[i] := '(' + else if Result[i] = '[' then + Result[i] := ']' + else if Result[i] = ']' then + Result[i] := '['; + t := not ((Ord(Result[i]) > 32) and (Ord(Result[i]) < 122)); + if (t and f) then + begin + s := Copy(Result, b, i - b); + Delete(Result, b, i - b); + s := frxReverseString(s); + Insert(s, Result, b); + f := False; + end; + if not (t or f) then + begin + b := i; + f := True; + end; + i := i + 1; + end; + end; + +begin + Left := frFloat2Str(GetLeft(Obj.AbsLeft)); + Top := frFloat2Str(GetTop(Obj.AbsTop)); + Right := frFloat2Str(GetLeft(Obj.AbsLeft + Obj.Width)); + Bottom := frFloat2Str(GetTop(Obj.AbsTop + Obj.Height)); + Width := frFloat2Str(Obj.Width * PDF_DIVIDER); + Height := frFloat2Str(Obj.Height * PDF_DIVIDER); + + OldFrameWidth := 0; + // Text + if (Obj is TfrxCustomMemoView) and (TfrxCustomMemoView(Obj).Rotation = 0) and + (TfrxCustomMemoView(Obj).BrushStyle in [bsSolid, bsClear]) and + (not HTMLTags(TfrxCustomMemoView(Obj))) then + begin + // save clip to stack + WriteLn('q'); + // set clipping path for the memo + Write(frFloat2Str(GetLeft(Obj.AbsLeft - Obj.Frame.Width)) + ' ' + frFloat2Str(GetTop(Obj.AbsTop + Obj.Height + Obj.Frame.Width)) + ' '); + WriteLn(frFloat2Str((Obj.Width + Obj.Frame.Width * 2)* PDF_DIVIDER) + ' ' + + frFloat2Str((Obj.Height + Obj.Frame.Width * 2) * PDF_DIVIDER) + ' re'); + WriteLn('W'); + WriteLn('n'); + // Shadow + if Obj.Frame.DropShadow then + begin + Obj.Width := Obj.Width - Obj.Frame.ShadowWidth; + Obj.Height := Obj.Height - Obj.Frame.ShadowWidth; + Width := frFloat2Str(Obj.Width * PDF_DIVIDER); + Height := frFloat2Str(Obj.Height * PDF_DIVIDER); + Right := frFloat2Str(GetLeft(Obj.AbsLeft + Obj.Width)); + Bottom := frFloat2Str(GetTop(Obj.AbsTop + Obj.Height)); + s := GetPDFColor(Obj.Frame.ShadowColor); + WriteLn(s + ' rg'); + WriteLn(s + ' RG'); + Write(frFloat2Str(GetLeft(Obj.AbsLeft + Obj.Width)) + ' ' + + frFloat2Str(GetTop(Obj.AbsTop + Obj.Height + Obj.Frame.ShadowWidth)) + ' '); + WriteLn(frFloat2Str(Obj.Frame.ShadowWidth * PDF_DIVIDER) + ' ' + + frFloat2Str(Obj.Height * PDF_DIVIDER) + ' re'); + WriteLn('B'); + Write(frFloat2Str(GetLeft(Obj.AbsLeft + Obj.Frame.ShadowWidth)) + ' ' + + frFloat2Str(GetTop(Obj.AbsTop + Obj.Height + Obj.Frame.ShadowWidth)) + ' '); + WriteLn(frFloat2Str(Obj.Width * PDF_DIVIDER) + ' ' + + frFloat2Str(Obj.Frame.ShadowWidth * PDF_DIVIDER) + ' re'); + WriteLn('B'); + end; + if TfrxCustomMemoView(Obj).Highlight.Active and + Assigned(TfrxCustomMemoView(Obj).Highlight.Font) then + begin + Obj.Font.Assign(TfrxCustomMemoView(Obj).Highlight.Font); + Obj.Color := TfrxCustomMemoView(Obj).Highlight.Color; + end; + if Obj.Color <> clNone then + begin + WriteLn(GetPDFColor(Obj.Color) + ' rg'); + Write(Left + ' ' + Bottom + ' '); + WriteLn(Width + ' ' + Height + ' re'); + WriteLn('f'); + end; + // Frames + MakeUpFrames; + Lines := TStringList.Create; + Lines.Text := TfrxCustomMemoView(Obj).WrapText(True); + if Lines.Count > 0 then + begin + FontIndex := Parent.AddFont(Obj.Font); + WriteLn('/F' + IntToStr(TfrxPDFFont(Parent.FFonts[FontIndex]).Index - 1) + + ' ' + IntToStr(Obj.Font.Size) + ' Tf'); + if Obj.Font.Color <> clNone then + TempColor := Obj.Font.Color + else + TempColor := clBlack; + WriteLn(GetPDFColor(TempColor) + ' rg'); + FCharSpacing := TfrxCustomMemoView(Obj).CharSpacing * PDF_DIVIDER; + if TfrxCustomMemoView(Obj).CharSpacing <> 0 then + WriteLn(frFloat2Str(FCharSpacing) + ' Tc'); + + Parent.PTool.SetMemo(TfrxCustomMemoView(Obj)); + // Underlines by FuxMedia + if TfrxCustomMemoView(Obj).Underlines then + begin + iz := Trunc(Obj.Height / Parent.PTool.LineHeight); + for i:= 0 to iz do + begin + y := GetTop(Parent.PTool.GetVTextPos(Obj.AbsTop + TfrxCustomMemoView(Obj).GapY + 1, + Obj.Height - TfrxCustomMemoView(Obj).GapY * 2, + 'XYZ', TfrxCustomMemoView(Obj).VAlign, i, iz)); + WriteLn(GetPDFColor(Obj.Frame.Color) + ' RG'); + WriteLn(frFloat2Str(Obj.Frame.Width * PDF_DIVIDER) + ' w'); + WriteLn(Left + ' ' + frFloat2Str(y) + ' m'); + WriteLn(Right + ' ' + frFloat2Str(y) + ' l'); + WriteLn('S'); + end; + end; + + // output lines of memo + FUnderlineSize := Obj.Font.Size * 0.12; + for i := 0 to Lines.Count - 1 do + begin + if i = 0 then + PGap := TfrxCustomMemoView(Obj).ParagraphGap + else + PGap := 0; + if TfrxCustomMemoView(Obj).RTLReading then + s := CheckOutPDFChars(Str2RTL(TruncReturns(Lines[i]))) + else + s := CheckOutPDFChars(TruncReturns(Lines[i])); + if Length(Trim(s)) > 0 then + begin + // Text output + WriteLn('BT'); + if TfrxCustomMemoView(Obj).HAlign <> haRight then + FCharSpacing := 0; + x := FCharSpacing + GetLeft(Parent.PTool.GetHTextPos(Obj.AbsLeft + + TfrxCustomMemoView(Obj).GapX + PGap, + Obj.Width - TfrxCustomMemoView(Obj).GapX * 2 - + PGap, TfrxCustomMemoView(Obj).CharSpacing, Lines[i], TfrxCustomMemoView(Obj).HAlign)); + y := GetTop(Parent.PTool.GetVTextPos(Obj.AbsTop + + TfrxCustomMemoView(Obj).GapY - 1, + Obj.Height - TfrxCustomMemoView(Obj).GapY * 2, + Lines[i], TfrxCustomMemoView(Obj).VAlign, i, Lines.Count)); + WriteLn(frFloat2Str(x) + ' ' + frFloat2Str(y) + ' Td'); + WriteLn('(' + s + ') Tj'); + WriteLn('ET'); + // set Underline + if fsUnderline in (TfrxCustomMemoView(Obj).Font.Style) then + begin + WriteLn(GetPDFColor(Obj.Font.Color) + ' RG'); + WriteLn(frFloat2Str(Obj.Font.Size * 0.08) + ' w'); + WriteLn(frFloat2Str(x) + ' ' + frFloat2Str(y - FUnderlineSize) + ' m'); + WriteLn(frFloat2Str(x + Parent.PTool.GetLineWidth(Lines[i], TfrxCustomMemoView(Obj).CharSpacing) * PDF_DIVIDER) + + ' ' + frFloat2Str(y - FUnderlineSize) + ' l'); + WriteLn('S') + end; + end; + end; + end; + // restore clip + WriteLn('Q'); + Lines.Free; + end + // Lines + else if Obj is TfrxCustomLineView then + begin + WriteLn(GetPDFColor(Obj.Frame.Color) + ' RG'); + WriteLn(frFloat2Str(Obj.Frame.Width * PDF_DIVIDER) + ' w'); + WriteLn(Left + ' ' + Top + ' m'); + WriteLn(Right + ' ' + Bottom + ' l'); + WriteLn('S') + end + // Rects + else if (Obj is TfrxShapeView) and (TfrxShapeView(Obj).Shape = skRectangle) then + begin + WriteLn(GetPDFColor(Obj.Frame.Color) + ' RG'); + WriteLn(frFloat2Str(Obj.Frame.Width * PDF_DIVIDER) + ' w'); + WriteLn(GetPDFColor(Obj.Color) + ' rg'); + Write(Left + ' ' + Bottom + ' '); + WriteLn(Width + ' ' + Height + ' re'); + WriteLn('B'); + end + // Shape line 1 + else if (Obj is TfrxShapeView) and (TfrxShapeView(Obj).Shape = skDiagonal1) then + begin + WriteLn(GetPDFColor(Obj.Frame.Color) + ' RG'); + WriteLn(frFloat2Str(Obj.Frame.Width * PDF_DIVIDER) + ' w'); + WriteLn(Left + ' ' + Bottom + ' m'); + WriteLn(Right + ' ' + Top + ' l'); + WriteLn('S') + end + // Shape line 2 + else if (Obj is TfrxShapeView) and (TfrxShapeView(Obj).Shape = skDiagonal2) then + begin + WriteLn(GetPDFColor(Obj.Frame.Color) + ' RG'); + WriteLn(frFloat2Str(Obj.Frame.Width * PDF_DIVIDER) + ' w'); + WriteLn(Left + ' ' + Top + ' m'); + WriteLn(Right + ' ' + Bottom + ' l'); + WriteLn('S') + end + else + // Bitmaps + if not ((Obj.Name = '_pagebackground') and (not Parent.Background)) and + (Obj.Height > 0) and (Obj.Width > 0) then + begin + if Obj.Frame.Width > 0 then + begin + OldFrameWidth := Obj.Frame.Width; + Obj.Frame.Width := 0; + end; + + FRealBounds := Obj.GetRealBounds; + dx := FRealBounds.Right - FRealBounds.Left; + dy := FRealBounds.Bottom - FRealBounds.Top; + + if (dx = Obj.Width) or (Obj.AbsLeft = FRealBounds.Left) then + fdx := 0 + else if (Obj.AbsLeft + Obj.Width) = FRealBounds.Right then + fdx := (dx - Obj.Width) + else + fdx := (dx - Obj.Width) / 2; + + if (dy = Obj.Height) or (Obj.AbsTop = FRealBounds.Top) then + fdy := 0 + else if (Obj.AbsTop + Obj.Height) = FRealBounds.Bottom then + fdy := (dy - Obj.Height) + else + fdy := (dy - Obj.Height) / 2; + + TempBitmap := TBitmap.Create; + TempBitmap.PixelFormat := pf24bit; + + if (Parent.PrintOptimized or (Obj is TfrxCustomMemoView)) and (Obj.BrushStyle in [bsSolid, bsClear]) then + i := PDF_PRINTOPT + else i := 1; + + iz := 0; + + if (Obj.ClassName = 'TfrxBarCodeView') and not Parent.PrintOptimized then + begin + i := 2; + iz := i; + end; + + TempBitmap.Width := Round(dx * i) + i; + TempBitmap.Height := Round(dy * i) + i; + + Obj.Draw(TempBitmap.Canvas, i, i, -Round((Obj.AbsLeft - fdx) * i) + iz, -Round((Obj.AbsTop - fdy)* i)); + WriteLn('q'); + + if dx <> 0 then + BWidth := frFloat2Str(dx * PDF_DIVIDER) + else + BWidth := '1'; + if dy <> 0 then + BHeight := frFloat2Str(dy * PDF_DIVIDER) + else + BHeight := '1'; + + WriteLn(BWidth + ' 0 0 ' + BHeight + ' ' + + frFloat2Str(GetLeft(Obj.AbsLeft - fdx)) + ' ' + + frFloat2Str(GetTop(Obj.AbsTop - fdy + dy)) + ' cm'); + WriteLn('BI'); + WriteLn('/W ' + IntToStr(TempBitmap.Width)); + WriteLn('/H ' + IntToStr(TempBitmap.Height)); + WriteLn('/CS /RGB'); + WriteLn('/BPC 8'); + WriteLn('/I true'); + WriteLn('/F [/DCT]'); + WriteLn('ID'); + Flush(OutStream); + + Jpg := TJPEGImage.Create; + + if (Obj.ClassName = 'TfrxBarCodeView') or + (Obj is TfrxCustomLineView) or + (Obj is TfrxShapeView) then + begin + Jpg.PixelFormat := jf8Bit; + Jpg.CompressionQuality := 85; + end + else begin + Jpg.PixelFormat := jf24Bit; + Jpg.CompressionQuality := 80; + end; + + Jpg.Assign(TempBitmap); + Jpg.SaveToStream(OutStream); + Jpg.Free; + + WriteLn(''); + WriteLn('EI'); + WriteLn('Q'); + TempBitmap.Free; + if OldFrameWidth > 0 then + Obj.Frame.Width := OldFrameWidth; + MakeUpFrames; + end; + Flush(OutStream); +end; + +{ TfrxPDFFont } + +constructor TfrxPDFFont.Create; +begin + inherited; + FFont := TFont.Create; +end; + +destructor TfrxPDFFont.Destroy; +begin + FFont.Free; + inherited; +end; + +procedure TfrxPDFFont.SaveToStream(const Stream: TStream); +var + s: String; + b: TBitmap; + pm: ^OUTLINETEXTMETRIC; + FontName: String; + i: Cardinal; + pfont: PChar; + FirstChar, LastChar : Integer; + MemStream: TMemoryStream; + MemStream1: TMemoryStream; + pwidths: PABC; + Charset: TFontCharSet; + + // support DBCS font name encoding + function EncodeFontName(AFontName: String): string; + var + s: string; + Index, Len: Integer; + begin + s := ''; + Len := Length(AFontName); + Index := 0; + while Index < Len do + begin + Index := Index + 1; + if Byte(AFontName[Index]) > $7F then + s := s + '#' + IntToHex(Byte(AFontName[Index]), 2) + else + s := s + AFontname[Index]; + end; + Result := s; + end; + + function PrepareFontName(const Font: TFont): String; + begin + Result := StringReplace(Font.Name, ' ', '#20', [rfReplaceAll]); + s := ''; + if fsBold in Font.Style then + s := s + 'Bold'; + if fsItalic in Font.Style then + s := s + 'Italic'; + if s <> '' then + Result := Result + ',' + s; + Result := EncodeFontName(Result); + end; + +begin + inherited SaveToStream(Stream); + b := TBitmap.Create; + try + b.Canvas.Lock; + b.Canvas.Font.Assign(Font); + b.Canvas.Font.PixelsPerInch := 96; + b.Canvas.Font.Size := 750; + i := GetOutlineTextMetrics(b.Canvas.Handle, 0, nil); + if i = 0 then + begin + b.Canvas.Font.Name := 'Arial'; + i := GetOutlineTextMetrics(b.Canvas.Handle, 0, nil); + end; + if i <> 0 then + begin + pm := GlobalAllocPtr(GMEM_MOVEABLE or GMEM_SHARE, i); + try + if pm <> nil then + i := GetOutlineTextMetrics(b.Canvas.Handle, i, pm) + else + i := 0; + if i <> 0 then + begin + FirstChar := Ord(pm.otmTextMetrics.tmFirstChar); + LastChar := Ord(pm.otmTextMetrics.tmLastChar); + + FontName := PrepareFontName(b.Canvas.Font); + + Charset := pm.otmTextMetrics.tmCharSet; + FFontDCnt := Parent.FFontDCnt; + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /Font'); + WriteLn('/Name /F' + IntToStr(Index - 1)); + WriteLn('/BaseFont /' + FontName); + + if not (Charset in [CHINESEBIG5_CHARSET, GB2312_CHARSET,SHIFTJIS_CHARSET,HANGEUL_CHARSET]) then + WriteLn('/Subtype /TrueType') + else + WriteLn('/Subtype /Type0'); + + case Charset of + SYMBOL_CHARSET: + WriteLn('/Encoding /MacRomanEncoding'); + + ANSI_CHARSET: + WriteLn('/Encoding /WinAnsiEncoding'); + + RUSSIAN_CHARSET: {1251} + begin + WriteLn('/Encoding <>'); + end; + + EASTEUROPE_CHARSET: {1250} + begin + WriteLn('/Encoding <>'); + end; + + GREEK_CHARSET: {1253} + begin + WriteLn('/Encoding <>'); + end; + + TURKISH_CHARSET: {1254} + begin + WriteLn('/Encoding <>'); + end; + + HEBREW_CHARSET: {1255} + begin + WriteLn('/Encoding <>'); + end; + + ARABIC_CHARSET: + begin + WriteLn('/Encoding <>'); + end; + + BALTIC_CHARSET: + begin + WriteLn('/Encoding <>'); + end; + + VIETNAMESE_CHARSET: + begin + WriteLn('/Encoding <>'); + end; + + CHINESEBIG5_CHARSET: {136} + begin + WriteLn('/DescendantFonts [' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R]'); + WriteLn('/Encoding /ETenms-B5-H'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /Font'); + WriteLn('/Subtype'); + WriteLn('/CIDFontType2'); + WriteLn('/BaseFont /'+ EncodeFontName(FontName)); + WriteLn('/WinCharSet 136'); + WriteLn('/FontDescriptor ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('/CIDSystemInfo'); + WriteLn('<<'); + WriteLn('/Registry(Adobe)'); + WriteLn('/Ordering(CNS1)'); + WriteLn('/Supplement 0'); + WriteLn('>>'); + WriteLn('/DW 1000'); + WriteLn('/W [1 95 500]'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /FontDescriptor'); + if Parent.FEmbedded then + WriteLn('/FontFile2 ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('/FontName /' + EncodeFontName(FontName)); + WriteLn('/Flags 7'); + WriteLn('/FontBBox [' + IntToStr(pm^.otmrcFontBox.Left) + ' '+ IntToStr(pm^.otmrcFontBox.Bottom) + ' '+ IntToStr(pm^.otmrcFontBox.Right) + ' '+ IntToStr(pm^.otmrcFontBox.Top) + ' ]'); + WriteLn('/Style << /Panose <010502020300000000000000> >>'); + WriteLn('/Ascent ' + IntToStr(pm^.otmAscent)); + WriteLn('/Descent ' + IntToStr(pm^.otmDescent)); + WriteLn('/CapHeight ' + IntToStr(pm^.otmTextMetrics.tmHeight)); + WriteLn('/StemV ' + IntToStr(50 + Round(sqr(pm^.otmTextMetrics.tmWeight / 65)))); + WriteLn('/ItalicAngle ' + IntToStr(pm^.otmItalicAngle)); + WriteLn('>>'); + WriteLn('endobj'); + end; + GB2312_CHARSET: {134} + begin + WriteLn('/DescendantFonts [' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R]'); + WriteLn('/Encoding /GB-EUC-H'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /Font'); + WriteLn('/Subtype'); + WriteLn('/CIDFontType2'); + WriteLn('/BaseFont /'+ EncodeFontName(FontName)); + WriteLn('/WinCharSet 134'); + WriteLn('/FontDescriptor ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('/CIDSystemInfo'); + WriteLn('<<'); + WriteLn('/Registry(Adobe)'); + WriteLn('/Ordering(GB1)'); + WriteLn('/Supplement 2'); + WriteLn('>>'); + WriteLn('/DW 1000'); + WriteLn('/W [ 1 95 500 814 939 500 7712 [ 500 ] 7716 [ 500 ] ]'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /FontDescriptor'); + if Parent.FEmbedded then + WriteLn('/FontFile2 ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('/FontName /' + EncodeFontName(FontName)); + WriteLn('/Flags 6'); + WriteLn('/FontBBox [' + IntToStr(pm^.otmrcFontBox.Left) + ' '+ IntToStr(pm^.otmrcFontBox.Bottom) + ' '+ IntToStr(pm^.otmrcFontBox.Right) + ' '+ IntToStr(pm^.otmrcFontBox.Top) + ' ]'); + WriteLn('/Style << /Panose <010502020400000000000000> >>'); + WriteLn('/Ascent ' + IntToStr(pm^.otmAscent)); + WriteLn('/Descent ' + IntToStr(pm^.otmDescent)); + WriteLn('/CapHeight ' + IntToStr(pm^.otmTextMetrics.tmHeight)); + WriteLn('/StemV ' + IntToStr(50 + Round(sqr(pm^.otmTextMetrics.tmWeight / 65)))); + WriteLn('/ItalicAngle ' + IntToStr(pm^.otmItalicAngle)); + WriteLn('>>'); + WriteLn('endobj'); + end; + SHIFTJIS_CHARSET: {80} + begin + WriteLn('/DescendantFonts [' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R]'); + WriteLn('/Encoding /90msp-RKSJ-H'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /Font'); + WriteLn('/Subtype'); + WriteLn('/CIDFontType2'); + WriteLn('/BaseFont /'+ EncodeFontName(FontName)); + WriteLn('/WinCharSet 80'); + Write('/FontDescriptor ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('/CIDSystemInfo'); + WriteLn('<<'); + WriteLn('/Registry(Adobe)'); + WriteLn('/Ordering(Japan1)'); + WriteLn('/Supplement 2'); + WriteLn('>>'); + WriteLn('/DW 1000'); + WriteLn('/W [ 1 95 500 231 632 500 ]'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /FontDescriptor'); + if Parent.FEmbedded then + WriteLn('/FontFile2 ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('/FontName /' + EncodeFontName(FontName)); + WriteLn('/Flags 6'); + WriteLn('/FontBBox [' + IntToStr(pm^.otmrcFontBox.Left) + ' '+ IntToStr(pm^.otmrcFontBox.Bottom) + ' '+ IntToStr(pm^.otmrcFontBox.Right) + ' '+ IntToStr(pm^.otmrcFontBox.Top) + ' ]'); + WriteLn('/Style << /Panose <010502020400000000000000> >>'); + WriteLn('/Ascent ' + IntToStr(pm^.otmAscent)); + WriteLn('/Descent ' + IntToStr(pm^.otmDescent)); + WriteLn('/CapHeight ' + IntToStr(pm^.otmTextMetrics.tmHeight)); + WriteLn('/StemV ' + IntToStr(50 + Round(sqr(pm^.otmTextMetrics.tmWeight / 65)))); + WriteLn('/ItalicAngle ' + IntToStr(pm^.otmItalicAngle)); + WriteLn('>>'); + WriteLn('endobj'); + end; + HANGEUL_CHARSET: {129} + begin + WriteLn('/DescendantFonts [' + IntToStr(Index + 1 + Parent.FStartFonts) + ' 0 R]'); + WriteLn('/Encoding /KSCms-UHC-H'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /Font'); + WriteLn('/Subtype'); + WriteLn('/CIDFontType2'); + WriteLn('/BaseFont /'+ EncodeFontName(FontName)); + WriteLn('/WinCharSet 129'); + Write('/FontDescriptor '+ IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('/CIDSystemInfo'); + WriteLn('<<'); + WriteLn('/Registry(Adobe)'); + WriteLn('/Ordering(Korea1)'); + WriteLn('/Supplement 1'); + WriteLn('>>'); + WriteLn('/DW 1000'); + WriteLn('/W [ 1 95 500 8094 8190 500 ]'); + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /FontDescriptor '); + if Parent.FEmbedded then + WriteLn('/FontFile2 ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('/FontName /' + EncodeFontName(FontName)); + WriteLn('/Flags 6'); + WriteLn('/FontBBox [' + IntToStr(pm^.otmrcFontBox.Left) + ' '+ IntToStr(pm^.otmrcFontBox.Bottom) + ' '+ IntToStr(pm^.otmrcFontBox.Right) + ' '+ IntToStr(pm^.otmrcFontBox.Top) + ' ]'); + WriteLn('/Style << /Panose <010502020400000000000000> >>'); + WriteLn('/Ascent ' + IntToStr(pm^.otmAscent)); + WriteLn('/Descent ' + IntToStr(pm^.otmDescent)); + WriteLn('/CapHeight ' + IntToStr(pm^.otmTextMetrics.tmHeight)); + WriteLn('/StemV ' + IntToStr(50 + Round(sqr(pm^.otmTextMetrics.tmWeight / 65)))); + WriteLn('/ItalicAngle ' + IntToStr(pm^.otmItalicAngle)); + WriteLn('>>'); + WriteLn('endobj'); + end; + end; + + if not (Charset in [CHINESEBIG5_CHARSET, GB2312_CHARSET,SHIFTJIS_CHARSET,HANGEUL_CHARSET]) then + begin + WriteLn('/FontDescriptor ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('/FirstChar ' + IntToStr(FirstChar)); + WriteLn('/LastChar ' + IntToStr(LastChar)); + pwidths := GlobalAllocPtr(GMEM_MOVEABLE or GMEM_SHARE, SizeOf(ABCArray)); + try + Write('/Widths ['); + GetCharABCWidths(b.Canvas.Handle, FirstChar, LastChar, pwidths^); + for i := 0 to (LastChar - FirstChar) do + Write(IntToStr(pwidths^[i].abcA + Integer(pwidths^[i].abcB) + pwidths^[i].abcC) + ' '); + WriteLn(']'); + finally + GlobalFreePtr(pwidths); + end; + WriteLn('>>'); + WriteLn('endobj'); + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + WriteLn('<<'); + WriteLn('/Type /FontDescriptor'); + WriteLn('/FontName /' + FontName); + WriteLn('/Flags 32'); + WriteLn('/FontBBox [' + IntToStr(pm^.otmrcFontBox.Left) + ' '+ IntToStr(pm^.otmrcFontBox.Bottom) + ' '+ IntToStr(pm^.otmrcFontBox.Right) + ' '+ IntToStr(pm^.otmrcFontBox.Top) + ' ]'); + WriteLn('/ItalicAngle ' + IntToStr(pm^.otmItalicAngle)); + WriteLn('/Ascent ' + IntToStr(pm^.otmAscent)); + WriteLn('/Descent ' + IntToStr(pm^.otmDescent)); + WriteLn('/Leading ' + IntToStr(pm^.otmTextMetrics.tmInternalLeading)); + WriteLn('/CapHeight ' + IntToStr(pm^.otmTextMetrics.tmHeight)); +// WriteLn('/XHeight ' + IntToStr(pm^.otmsXHeight)); + WriteLn('/StemV ' + IntToStr(50 + Round(sqr(pm^.otmTextMetrics.tmWeight / 65)))); + WriteLn('/AvgWidth ' + IntToStr(pm^.otmTextMetrics.tmAveCharWidth)); + WriteLn('/MaxWidth ' + IntToStr(pm^.otmTextMetrics.tmMaxCharWidth)); + WriteLn('/MissingWidth ' + IntToStr(pm^.otmTextMetrics.tmAveCharWidth)); + if Parent.FEmbedded then + WriteLn('/FontFile2 ' + IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 R'); + WriteLn('>>'); + WriteLn('endobj'); + end; + + if Parent.FEmbedded then + begin + Flush(Stream); + Inc(Parent.FObjNo); + Parent.XRefAdd(Stream, Parent.FObjNo); + WriteLn(IntToStr(Parent.FFontDCnt + Parent.FStartFonts) + ' 0 obj'); + Parent.FFontDCnt := Parent.FFontDCnt + 1; + i := GetFontData(b.Canvas.Handle, 0, 0, nil, 1); + pfont := GlobalAllocPtr(GMEM_MOVEABLE or GMEM_SHARE, i); + try + i := GetFontData(b.Canvas.Handle, 0, 0, pfont, i); + MemStream := TMemoryStream.Create; + try + MemStream.Write(pfont^, i); + MemStream1 := TMemoryStream.Create; + try + frxDeflateStream(MemStream, MemStream1, gzMax); + WriteLn('<< /Length ' + IntToStr(MemStream1.Size) + ' /Filter /FlateDecode /Length1 ' + IntToStr(MemStream.Size) + ' >>'); + WriteLn('stream'); + Flush(Stream); + Stream.CopyFrom(MemStream1, 0); + finally + MemStream1.Free; + end; + finally + MemStream.Free; + end; + finally + GlobalFreePtr(pfont); + end; + WriteLn(''); + WriteLn('endstream'); + WriteLn('endobj'); + end; + end; + Flush(Stream); + finally + GlobalFreePtr(pm); + end; + end + else + Exception.Create('Error on get font info'); + finally + b.Canvas.Unlock; + b.Free; + end; +end; + +{ TfrxPDFElement } + +constructor TfrxPDFElement.Create; +begin + FIndex := 0; + FXrefPosition := 0; + FCR := False; + FLines := ''; +end; + +procedure TfrxPDFElement.Write(const S: String); +begin + FLines := FLines + S; +end; + +procedure TfrxPDFElement.WriteLn(const S: String); +begin + FLines := FLines + S + #13#10; +end; + +procedure TfrxPDFElement.Flush(const Stream: TStream); +begin + Stream.Write(FLines[1], Length(FLines)); + FLines := ''; +end; + + +procedure TfrxPDFElement.SaveToStream(const Stream: TStream); +begin + FXrefPosition := Stream.Position; +end; + +{ TfrxPDFToolkit } + +constructor TfrxPDFToolkit.Create; +begin + Divider := frxDrawText.DefPPI / frxDrawText.ScrPPI; + LastColor := clBlack; + LastColorResult := '0 0 0'; +end; + +function TfrxPDFToolkit.GetHTextPos(const Left: Extended; const Width: Extended; + const CharSpacing: Extended; const Text: String; const Align: TfrxHAlign): Extended; +var + FWidth: Extended; +begin + frxDrawText.Lock; + try + if (Align = haLeft) or (Align = haBlock) then + Result := Left + else begin + FWidth := frxDrawText.Canvas.TextWidth(Text) / Divider + Length(Text) * CharSpacing; + if Align = haCenter then + Result := Left + (Width - FWidth) / 2 + else + Result := Left + Width - FWidth; + end; + finally + frxDrawText.UnLock; + end; +end; + +function TfrxPDFToolkit.GetLineWidth(const Text: String; const CharSpacing: Extended): Extended; +var + FWidth: Extended; +begin + frxDrawText.Lock; + try + FWidth := frxDrawText.Canvas.TextWidth(Text) / Divider + Length(Text) * CharSpacing; + finally + frxDrawText.UnLock; + end; + Result := FWidth; +end; + +function TfrxPDFToolkit.GetVTextPos(const Top: Extended; const Height: Extended; + const Text: String; const Align: TfrxVAlign; const Line: Integer = 0; + const Count: Integer = 1): Extended; +var + i: Integer; +begin + frxDrawText.Lock; + try + if Line <= Count then + i := Line + else + i := 0; + if Align = vaBottom then + Result := Top + Height - LineHeight * (Count - i - 1) + else if Align = vaCenter then + Result := Top + (Height - (LineHeight * Count)) / 2 + LineHeight * (i + 1) + else + Result := Top + (LineHeight * i) + frxDrawText.TextHeight; + finally + frxDrawText.UnLock; + end; +end; + +procedure TfrxPDFToolkit.SetMemo(const Memo: TfrxCustomMemoView); +begin + frxDrawText.SetFont(Memo.Font); + frxDrawText.SetGaps(0, 0, Memo.LineSpacing); + LineHeight := frxDrawText.LineHeight; +end; + +{ TfrxPDFOutlineNode } + +constructor TfrxPDFOutlineNode.Create; +begin + Title := ''; + Dest := -1; + Number := 0; + Count := 0; + CountTree :=0; + Parent := nil; + First := nil; + Prev := nil; + Next := nil; + Last := nil; +end; + +destructor TfrxPDFOutlineNode.Destroy; +begin + if Next <> nil then + Next.Free; + if First <> nil then + First.Free; + inherited; +end; + +end. + diff --git a/official/4.2/LibD11/frxPassw.dfm b/official/4.2/LibD11/frxPassw.dfm new file mode 100644 index 0000000..c91be69 Binary files /dev/null and b/official/4.2/LibD11/frxPassw.dfm differ diff --git a/official/4.2/LibD11/frxPassw.pas b/official/4.2/LibD11/frxPassw.pas new file mode 100644 index 0000000..099a46f --- /dev/null +++ b/official/4.2/LibD11/frxPassw.pas @@ -0,0 +1,61 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Password form } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPassw; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, + Dialogs, StdCtrls, ExtCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxPasswordForm = class(TForm) + OkB: TButton; + CancelB: TButton; + PasswordE: TEdit; + PasswordL: TLabel; + Image1: TImage; + procedure FormCreate(Sender: TObject); + private + public + end; + + +implementation + +{$R *.dfm} + +uses frxRes; + + +procedure TfrxPasswordForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(5000); + PasswordL.Caption := frxGet(5001); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPictureCache.pas b/official/4.2/LibD11/frxPictureCache.pas new file mode 100644 index 0000000..4e35012 --- /dev/null +++ b/official/4.2/LibD11/frxPictureCache.pas @@ -0,0 +1,136 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Picture Cache } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPictureCache; + +interface + +{$I frx.inc} + +uses + Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs, + frxClass, frxXML +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxPictureCache = class(TObject) + private + FIndex: TStringList; + function Add: TStream; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + procedure AddPicture(Picture: TfrxPictureView); + procedure GetPicture(Picture: TfrxPictureView); + procedure SaveToXML(Item: TfrxXMLItem); + procedure LoadFromXML(Item: TfrxXMLItem); + end; + + +implementation + +uses + frxUtils; + + +{ TfrxPictureCache } + +constructor TfrxPictureCache.Create; +begin + FIndex := TStringList.Create; +end; + +destructor TfrxPictureCache.Destroy; +begin + Clear; + FIndex.Free; + inherited; +end; + +procedure TfrxPictureCache.Clear; +begin + while FIndex.Count > 0 do + begin + TStream(FIndex.Objects[0]).Free; + FIndex.Delete(0); + end; +end; + +function TfrxPictureCache.Add: TStream; +begin + Result := TMemoryStream.Create; + FIndex.AddObject('', Result); +end; + +procedure TfrxPictureCache.AddPicture(Picture: TfrxPictureView); +begin + if Picture.Picture.Graphic = nil then + Picture.ImageIndex := 0 + else + begin + Picture.ImageIndex := FIndex.Count + 1; + Picture.Picture.Graphic.SaveToStream(Add); + end; +end; + +procedure TfrxPictureCache.GetPicture(Picture: TfrxPictureView); +var + s: TStream; +begin + if (Picture.ImageIndex <= 0) or (Picture.ImageIndex > FIndex.Count) then + Picture.Picture.Assign(nil) + else + begin + s := TStream(FIndex.Objects[Picture.ImageIndex - 1]); + s.Position := 0; + Picture.LoadPictureFromStream(s); + end; +end; + +procedure TfrxPictureCache.LoadFromXML(Item: TfrxXMLItem); +var + i: Integer; + xi: TfrxXMLItem; +begin + Clear; + for i := 0 to Item.Count - 1 do + begin + xi := Item[i]; + frxStringToStream(xi.Prop['stream'], Add); + end; +end; + +procedure TfrxPictureCache.SaveToXML(Item: TfrxXMLItem); +var + i: Integer; + s: TStream; + xi: TfrxXMLItem; +begin + Item.Clear; + for i := 0 to FIndex.Count - 1 do + begin + xi := Item.Add; + s := TStream(FIndex.Objects[i]); + s.Position := 0; + xi.Name := 'item'; + xi.Text := 'stream="' + frxStreamToString(s) + '"'; + end; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPopupForm.dfm b/official/4.2/LibD11/frxPopupForm.dfm new file mode 100644 index 0000000..9e8f0ac Binary files /dev/null and b/official/4.2/LibD11/frxPopupForm.dfm differ diff --git a/official/4.2/LibD11/frxPopupForm.pas b/official/4.2/LibD11/frxPopupForm.pas new file mode 100644 index 0000000..6e07f59 --- /dev/null +++ b/official/4.2/LibD11/frxPopupForm.pas @@ -0,0 +1,61 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Parent form for pop-up controls } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPopupForm; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxPopupForm = class(TForm) + procedure FormDeactivate(Sender: TObject); + procedure FormClose(Sender: TObject; var Action: TCloseAction); + private + { Private declarations } + public + { Public declarations } + end; + +var + frxPopupFormCloseTime: UInt = 0; + + +implementation + +{$R *.DFM} + + +procedure TfrxPopupForm.FormDeactivate(Sender: TObject); +begin + frxPopupFormCloseTime := GetTickCount; + Close; +end; + +procedure TfrxPopupForm.FormClose(Sender: TObject; + var Action: TCloseAction); +begin + Action := caFree; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPreview.dfm b/official/4.2/LibD11/frxPreview.dfm new file mode 100644 index 0000000..2ee9dbf Binary files /dev/null and b/official/4.2/LibD11/frxPreview.dfm differ diff --git a/official/4.2/LibD11/frxPreview.pas b/official/4.2/LibD11/frxPreview.pas new file mode 100644 index 0000000..996ba0f --- /dev/null +++ b/official/4.2/LibD11/frxPreview.pas @@ -0,0 +1,2885 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report preview } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPreview; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ExtCtrls, Buttons, StdCtrls, Menus, ComCtrls, ImgList, frxCtrls, frxDock, +{$IFDEF FR_COM} + FastReport_TLB, +{$ENDIF} + ToolWin, frxPreviewPages, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +const + WM_UPDATEZOOM = WM_USER + 1; + +type + TfrxPreview = class; + TfrxPreviewWorkspace = class; + TfrxPageList = class; + + TfrxPreviewTool = (ptHand, ptZoom); // not implemented, backw compatibility only + TfrxPageChangedEvent = procedure(Sender: TfrxPreview; PageNo: Integer) of object; + +{$IFDEF FR_COM} + TfrxPreview = class(TfrxCustomPreview, IfrxPreview) +{$ELSE} + TfrxPreview = class(TfrxCustomPreview) +{$ENDIF} + private + FAllowF3: Boolean; + FBorderStyle: TBorderStyle; + FCancelButton: TButton; + FLocked: Boolean; + FMessageLabel: TLabel; + FMessagePanel: TPanel; + FOnPageChanged: TfrxPageChangedEvent; + FOutline: TTreeView; + FOutlineColor: TColor; + FOutlinePopup: TPopupMenu; + FPageNo: Integer; + FRefreshing: Boolean; + FRunning: Boolean; + FScrollBars: TScrollStyle; + FSplitter: TSplitter; + FThumbnail: TfrxPreviewWorkspace; + FTick: Cardinal; + FTool: TfrxPreviewTool; + FWorkspace: TfrxPreviewWorkspace; + FZoom: Extended; + FZoomMode: TfrxZoomMode; + function GetActiveFrameColor: TColor; + function GetBackColor: TColor; + function GetFrameColor: TColor; + function GetOutlineVisible: Boolean; + function GetOutlineWidth: Integer; + function GetPageCount: Integer; + function GetThumbnailVisible: Boolean; + procedure EditTemplate; + procedure OnCancel(Sender: TObject); + procedure OnCollapseClick(Sender: TObject); + procedure OnExpandClick(Sender: TObject); + procedure OnMoveSplitter(Sender: TObject); + procedure OnOutlineClick(Sender: TObject); + procedure SetActiveFrameColor(const Value: TColor); + procedure SetBackColor(const Value: TColor); + procedure SetBorderStyle(Value: TBorderStyle); + procedure SetFrameColor(const Value: TColor); + procedure SetOutlineColor(const Value: TColor); + procedure SetOutlineWidth(const Value: Integer); + procedure SetOutlineVisible(const Value: Boolean); + procedure SetPageNo(Value: Integer); + procedure SetThumbnailVisible(const Value: Boolean); + procedure SetZoom(const Value: Extended); + procedure SetZoomMode(const Value: TfrxZoomMode); + procedure UpdateOutline; + procedure UpdatePages; + procedure UpdatePageNumbers; + procedure WMEraseBackground(var Message: TMessage); message WM_ERASEBKGND; + procedure WMGetDlgCode(var Message: TWMGetDlgCode); message WM_GETDLGCODE; + protected + procedure CreateParams(var Params: TCreateParams); override; + procedure Resize; override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + procedure KeyDown(var Key: Word; Shift: TShiftState); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Init; override; + procedure Lock; override; + procedure Unlock; override; + procedure RefreshReport; override; + procedure InternalOnProgressStart(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer); override; + procedure InternalOnProgress(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer); override; + procedure InternalOnProgressStop(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer); override; + +{$IFDEF FR_COM} + function AddPage: HResult; stdcall; + function DeletePage: HResult; stdcall; + function Print: HResult; stdcall; + function Edit: HResult; stdcall; + function First: HResult; stdcall; + function Next: HResult; stdcall; + function Prior: HResult; stdcall; + function Last: HResult; stdcall; + function PageSetupDlg: HResult; stdcall; + function Find: HResult; stdcall; + function FindNext: HResult; stdcall; + function Cancel: HResult; stdcall; + function Clear: HResult; stdcall; + function SetPosition(PageN, Top: Integer): HResult; stdcall; + function ShowMessage(const s: WideString): HResult; stdcall; + function HideMessage: HResult; stdcall; + function MouseWheelScroll(Delta: Integer; Horz: WordBool; Zoom: WordBool): HResult; stdcall; + function Get_PageCount(out Value: Integer): HResult; stdcall; + function Get_PageNo(out Value: Integer): HResult; stdcall; + function Set_PageNo(Value: Integer): HResult; stdcall; + function Get_Tool(out Value: frxPreviewTool): HResult; stdcall; + function Set_Tool(Value: frxPreviewTool): HResult; stdcall; + function Get_Zoom(out Value: Double): HResult; stdcall; + function Set_Zoom(Value: Double): HResult; stdcall; + function Get_ZoomMode(out Value: frxZoomMode): HResult; stdcall; + function Set_ZoomMode(Value: frxZoomMode): HResult; stdcall; + function Get_OutlineVisible(out Value: WordBool): HResult; stdcall; + function Set_OutlineVisible(Value: WordBool): HResult; stdcall; + function Get_OutlineWidth(out Value: Integer): HResult; stdcall; + function Set_OutlineWidth(Value: Integer): HResult; stdcall; + function Get_Enabled(out Value: WordBool): HResult; stdcall; + function Set_Enabled(Value: WordBool): HResult; stdcall; + function LoadPreparedReportFromFile(const FileName: WideString): HResult; stdcall; + function SavePreparedReportToFile(const FileName: WideString): HResult; stdcall; + function Get_FullScreen(out Value: WordBool): HResult; stdcall; + function Set_FullScreen(Value: WordBool): HResult; stdcall; + function Get_ToolBarVisible(out Value: WordBool): HResult; stdcall; + function Set_ToolBarVisible(Value: WordBool): HResult; stdcall; + function Get_StatusBarVisible(out Value: WordBool): HResult; stdcall; + function Set_StatusBarVisible(Value: WordBool): HResult; stdcall; +{$ELSE} + procedure AddPage; + procedure DeletePage; + procedure Print; + procedure Edit; + procedure First; + procedure Next; + procedure Prior; + procedure Last; + procedure PageSetupDlg; + procedure Find; + procedure FindNext; + procedure Cancel; + procedure Clear; + procedure SetPosition(PageN, Top: Integer); + procedure ShowMessage(const s: String); + procedure HideMessage; + procedure MouseWheelScroll(Delta: Integer; Horz: Boolean = False; + Zoom: Boolean = False); +{$ENDIF} + procedure LoadFromFile; overload; + procedure LoadFromFile(FileName: String); overload; + procedure SaveToFile; overload; + procedure SaveToFile(FileName: String); overload; + procedure Export(Filter: TfrxCustomExportFilter); + function FindText(SearchString: String; FromTop, IsCaseSensitive: Boolean): Boolean; + function FindTextFound: Boolean; + procedure FindTextClear; + + property PageCount: Integer read GetPageCount; + property PageNo: Integer read FPageNo write SetPageNo; + // not implemented, backw compatibility only + property Tool: TfrxPreviewTool read FTool write FTool; + property Zoom: Extended read FZoom write SetZoom; + property ZoomMode: TfrxZoomMode read FZoomMode write SetZoomMode; + published + property Align; + property ActiveFrameColor: TColor read GetActiveFrameColor write SetActiveFrameColor default $804020; + property BackColor: TColor read GetBackColor write SetBackColor default clGray; + property BevelEdges; + property BevelInner; + property BevelKind; + property BevelOuter; + property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle; + property BorderWidth; + property FrameColor: TColor read GetFrameColor write SetFrameColor default clBlack; + property OutlineColor: TColor read FOutlineColor write SetOutlineColor default clWindow; + property OutlineVisible: Boolean read GetOutlineVisible write SetOutlineVisible; + property OutlineWidth: Integer read GetOutlineWidth write SetOutlineWidth; + property PopupMenu; + property ThumbnailVisible: Boolean read GetThumbnailVisible write SetThumbnailVisible; + property OnClick; + property OnPageChanged: TfrxPageChangedEvent read FOnPageChanged write FOnPageChanged; + end; + + TfrxPreviewForm = class(TForm) + ToolBar: TToolBar; + OpenB: TToolButton; + SaveB: TToolButton; + PrintB: TToolButton; + ExportB: TToolButton; + FindB: TToolButton; + PageSettingsB: TToolButton; + Sep3: TfrxTBPanel; + ZoomCB: TfrxComboBox; + Sep1: TToolButton; + Sep2: TToolButton; + FirstB: TToolButton; + PriorB: TToolButton; + Sep4: TfrxTBPanel; + PageE: TEdit; + NextB: TToolButton; + LastB: TToolButton; + StatusBar: TStatusBar; + ZoomMinusB: TToolButton; + Sep5: TToolButton; + ZoomPlusB: TToolButton; + DesignerB: TToolButton; + frTBPanel1: TfrxTBPanel; + CancelB: TSpeedButton; + ExportPopup: TPopupMenu; + HiddenMenu: TPopupMenu; + Showtemplate1: TMenuItem; + RightMenu: TPopupMenu; + FullScreenBtn: TToolButton; + EmailB: TToolButton; + PdfB: TToolButton; + OutlineB: TToolButton; + ThumbB: TToolButton; + N1: TMenuItem; + ExpandMI: TMenuItem; + CollapseMI: TMenuItem; + procedure FormCreate(Sender: TObject); + procedure ZoomMinusBClick(Sender: TObject); + procedure ZoomCBClick(Sender: TObject); + procedure FormKeyPress(Sender: TObject; var Key: Char); + procedure FirstBClick(Sender: TObject); + procedure PriorBClick(Sender: TObject); + procedure NextBClick(Sender: TObject); + procedure LastBClick(Sender: TObject); + procedure PageEClick(Sender: TObject); + procedure PrintBClick(Sender: TObject); + procedure OpenBClick(Sender: TObject); + procedure SaveBClick(Sender: TObject); + procedure FindBClick(Sender: TObject); + procedure FormClose(Sender: TObject; var Action: TCloseAction); + procedure DesignerBClick(Sender: TObject); + procedure NewPageBClick(Sender: TObject); + procedure DelPageBClick(Sender: TObject); + procedure CancelBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure PageSettingsBClick(Sender: TObject); + procedure FormMouseWheel(Sender: TObject; Shift: TShiftState; + WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); + procedure DesignerBMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure Showtemplate1Click(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + procedure FullScreenBtnClick(Sender: TObject); + procedure PdfBClick(Sender: TObject); + procedure EmailBClick(Sender: TObject); + procedure ZoomPlusBClick(Sender: TObject); + procedure OutlineBClick(Sender: TObject); + procedure ThumbBClick(Sender: TObject); + procedure CollapseAllClick(Sender: TObject); + procedure ExpandAllClick(Sender: TObject); + private + FFreeOnClose: Boolean; + FPreview: TfrxPreview; + FOldBS: TFormBorderStyle; + FOldState: TWindowState; + FFullScreen: Boolean; + FPDFExport: TfrxCustomExportFilter; + FEmailExport: TfrxCustomExportFilter; + procedure ExportMIClick(Sender: TObject); + procedure OnPageChanged(Sender: TfrxPreview; PageNo: Integer); + procedure OnPreviewDblClick(Sender: TObject); + procedure UpdateControls; + procedure UpdateZoom; + procedure WMUpdateZoom(var Message: TMessage); message WM_UPDATEZOOM; + procedure WMActivateApp(var Msg: TWMActivateApp); message WM_ACTIVATEAPP; + procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND; + function GetReport: TfrxReport; + public + procedure Init; + procedure SetMessageText(const Value: String); + procedure SwitchToFullScreen; + property FreeOnClose: Boolean read FFreeOnClose write FFreeOnClose; + property Preview: TfrxPreview read FPreview; + property Report: TfrxReport read GetReport; + end; + + TfrxPreviewWorkspace = class(TfrxScrollWin) + private + FActiveFrameColor: TColor; + FBackColor: TColor; + FDefaultCursor: TCursor; + FDisableUpdate: Boolean; + FDown: Boolean; + FEMFImage: TMetafile; + FEMFImagePage: Integer; + FFrameColor: TColor; + FIsThumbnail: Boolean; + FLastFoundPage: Integer; + FLastPoint: TPoint; + FLocked: Boolean; + FOffset: TPoint; + FPageList: TfrxPageList; + FPageNo: Integer; + FPreview: TfrxPreview; + FPreviewPages: TfrxCustomPreviewPages; + FZoom: Extended; + procedure DrawPages(BorderOnly: Boolean); + procedure FindText; + procedure SetToPageNo(PageNo: Integer); + procedure UpdateScrollBars; + protected + procedure MouseDown(Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure OnHScrollChange(Sender: TObject); override; + procedure Resize; override; + procedure OnVScrollChange(Sender: TObject); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Paint; override; + procedure SetPosition(PageN, Top: Integer); + { page list } + procedure AddPage(AWidth, AHeight: Integer); + procedure ClearPageList; + procedure CalcPageBounds(ClientWidth: Integer); + + property ActiveFrameColor: TColor read FActiveFrameColor write FActiveFrameColor default $804020; + property BackColor: TColor read FBackColor write FBackColor default clGray; + property FrameColor: TColor read FFrameColor write FFrameColor default clBlack; + property IsThumbnail: Boolean read FIsThumbnail write FIsThumbnail; + property Locked: Boolean read FLocked write FLocked; + property PageNo: Integer read FPageNo write FPageNo; + property Preview: TfrxPreview read FPreview write FPreview; + property PreviewPages: TfrxCustomPreviewPages read FPreviewPages + write FPreviewPages; + property Zoom: Extended read FZoom write FZoom; + end; + + TfrxPageItem = class(TCollectionItem) + public + Height: Word; + Width: Word; + OffsetX: Integer; + OffsetY: Integer; + end; + + TfrxPageList = class(TCollection) + private + FMaxWidth: Integer; + function GetItems(Index: Integer): TfrxPageItem; + public + constructor Create; + property Items[Index: Integer]: TfrxPageItem read GetItems; default; + procedure AddPage(AWidth, AHeight: Integer; Zoom: Extended); + procedure CalcBounds(ClientWidth: Integer); + function FindPage(OffsetY: Integer; OffsetX: Integer = 0): Integer; + function GetPageBounds(Index, ClientWidth: Integer; Scale: Extended): TRect; + function GetMaxBounds: TPoint; + end; + + +implementation + +{$R *.DFM} +{$R *.RES} + +uses + Printers, frxPrinter, frxSearchDialog, frxUtils, frxRes, frxDsgnIntf, + frxPreviewPageSettings, frxDMPClass; + + +type + THackControl = class(TWinControl); + +{ search given string in a metafile } + +var + TextToFind: String; + TextFound: Boolean; + TextBounds: TRect; + RecordNo: Integer; + LastFoundRecord: Integer; + CaseSensitive: Boolean; + +function EnumEMFRecordsProc(DC: HDC; HandleTable: PHandleTable; + EMFRecord: PEnhMetaRecord; nObj: Integer; OptData: Pointer): Bool; stdcall; +var + Typ: Byte; + s: String; + t: TEMRExtTextOut; + Found: Boolean; +begin + Result := True; + Typ := EMFRecord^.iType; + if Typ in [83, 84] then + begin + t := PEMRExtTextOut(EMFRecord)^; + s := WideCharLenToString(PWideChar(PChar(EMFRecord) + t.EMRText.offString), + t.EMRText.nChars); + if CaseSensitive then + Found := Pos(TextToFind, s) <> 0 else + Found := Pos(AnsiUpperCase(TextToFind), AnsiUpperCase(s)) <> 0; + if Found and (RecordNo > LastFoundRecord) then + begin + TextFound := True; + TextBounds := t.rclBounds; + LastFoundRecord := RecordNo; + Result := False; + end; + end; + Inc(RecordNo); +end; + + +{ TfrxPageList } + +constructor TfrxPageList.Create; +begin + inherited Create(TfrxPageItem); +end; + +function TfrxPageList.GetItems(Index: Integer): TfrxPageItem; +begin + Result := TfrxPageItem(inherited Items[Index]); +end; + +procedure TfrxPageList.AddPage(AWidth, AHeight: Integer; Zoom: Extended); +begin + with TfrxPageItem(Add) do + begin + Width := Round(AWidth * Zoom); + Height := Round(AHeight * Zoom); + end; +end; + +procedure TfrxPageList.CalcBounds(ClientWidth: Integer); +var + i, j, CurX, CurY, MaxY, offs: Integer; + Item: TfrxPageItem; +begin + FMaxWidth := 0; + CurY := 10; + i := 0; + while i < Count do + begin + j := i; + CurX := 0; + MaxY := 0; + { find series of pages that will fit in the clientwidth } + { also calculate max height of series } + while j < Count do + begin + Item := Items[j]; + { check the width, allow at least one iteration } + if (CurX > 0) and (CurX + Item.Width > ClientWidth) then break; + Item.OffsetX := CurX; + Item.OffsetY := CurY; + Inc(CurX, Item.Width + 10); + if Item.Height > MaxY then + MaxY := Item.Height; + Inc(j); + end; + + if CurX > FMaxWidth then + FMaxWidth := CurX; + + { center series horizontally } + offs := (ClientWidth - CurX + 10) div 2; + if offs < 0 then + offs := 0; + Inc(offs, 10); + while (i < j) do + begin + Inc(Items[i].OffsetX, offs); + Inc(i); + end; + + Inc(CurY, MaxY + 10); + end; +end; + +function TfrxPageList.FindPage(OffsetY: Integer; OffsetX: Integer = 0): Integer; +var + i, i0, i1, c, add: Integer; + Item: TfrxPageItem; +begin + i0 := 0; + i1 := Count - 1; + + while i0 <= i1 do + begin + i := (i0 + i1) div 2; + if OffsetX <> 0 then + add := 0 else + add := Round(Items[i].Height / 5); + if Items[i].OffsetY <= OffsetY + add then + c := -1 else + c := 1; + + if c < 0 then + i0 := i + 1 else + i1 := i - 1; + end; + + { find exact page } + if OffsetX <> 0 then + begin + for i := i1 - 20 to i1 + 20 do + begin + if (i < 0) or (i >= Count) then continue; + Item := Items[i]; + if PtInRect(Rect(Item.OffsetX, Item.OffsetY, + Item.OffsetX + Item.Width, Item.OffsetY + Item.Height), + Point(OffsetX, OffsetY)) then + begin + i1 := i; + break; + end; + end; + end; + + Result := i1; +end; + +function TfrxPageList.GetPageBounds(Index, ClientWidth: Integer; + Scale: Extended): TRect; +var + ColumnOffs: Integer; + Item: TfrxPageItem; +begin + if (Index >= Count) or (Index < 0) then + begin + if 794 * Scale > ClientWidth then + ColumnOffs := 10 else + ColumnOffs := Round((ClientWidth - 794 * Scale) / 2); + Result.Left := ColumnOffs; + Result.Top := Round(10 * Scale); + Result.Right := Result.Left + Round(794 * Scale); + Result.Bottom := Result.Top + Round(1123 * Scale); + end + else + begin + Item := Items[Index]; + Result.Left := Item.OffsetX; + Result.Top := Item.OffsetY; + Result.Right := Result.Left + Item.Width; + Result.Bottom := Result.Top + Item.Height; + end; +end; + +function TfrxPageList.GetMaxBounds: TPoint; +begin + if Count = 0 then + Result := Point(0, 0) + else + begin + Result.X := FMaxWidth; + Result.Y := Items[Count - 1].OffsetY + Items[Count - 1].Height; + end; +end; + + +{ TfrxPreviewWorkspace } + +constructor TfrxPreviewWorkspace.Create(AOwner: TComponent); +begin + inherited; + FPageList := TfrxPageList.Create; + + FBackColor := clGray; + FFrameColor := clBlack; + FActiveFrameColor := $804020; + FZoom := 1; + FDefaultCursor := crHand; + + LargeChange := 300; + SmallChange := 8; +end; + +destructor TfrxPreviewWorkspace.Destroy; +begin + if FEMFImage <> nil then + FEMFImage.Free; + FPageList.Free; + inherited; +end; + +procedure TfrxPreviewWorkspace.OnHScrollChange(Sender: TObject); +var + pp: Integer; + r: TRect; +begin + pp := FOffset.X - HorzPosition; + FOffset.X := HorzPosition; + r := Rect(0, 0, ClientWidth, ClientHeight); + ScrollWindowEx(Handle, pp, 0, @r, @r, 0, nil, SW_ERASE + SW_INVALIDATE); +end; + +procedure TfrxPreviewWorkspace.OnVScrollChange(Sender: TObject); +var + i, pp: Integer; + r: TRect; +begin + pp := FOffset.Y - VertPosition; + FOffset.Y := VertPosition; + r := Rect(0, 0, ClientWidth, ClientHeight); + ScrollWindowEx(Handle, 0, pp, @r, @r, 0, nil, SW_ERASE + SW_INVALIDATE); + + if not FIsThumbnail then + begin + i := FPageList.FindPage(FOffset.Y); + FDisableUpdate := True; + Preview.PageNo := i + 1; + FDisableUpdate := False; + end; +end; + +procedure TfrxPreviewWorkspace.DrawPages(BorderOnly: Boolean); +var + i, n: Integer; + PageBounds: TRect; + h: HRGN; + + function PageVisible: Boolean; + begin + if (PageBounds.Top > ClientHeight) or (PageBounds.Bottom < 0) then + Result := False + else + Result := RectVisible(Canvas.Handle, PageBounds); + end; + + procedure DrawPage(Index: Integer); + var + i: Integer; + TxtBounds: TRect; + begin + with Canvas, PageBounds do + begin + Pen.Color := FrameColor; + Pen.Width := 1; + Pen.Mode := pmCopy; + Pen.Style := psSolid; + Brush.Color := clWhite; + Brush.Style := bsSolid; + Dec(Bottom); + Rectangle(Left, Top, Right, Bottom); + end; + + PreviewPages.DrawPage(Index, Canvas, Zoom, Zoom, PageBounds.Left, PageBounds.Top); + + if FIsThumbnail then + with Canvas do + begin + Font.Name := 'Arial'; + Font.Size := 8; + Font.Style := []; + Font.Color := clWhite; + Brush.Style := bsSolid; + Brush.Color := BackColor; + TextOut(PageBounds.Left + 1, PageBounds.Top + 1, ' ' + IntToStr(Index + 1) + ' '); + end; + + { highlight text found } + TxtBounds := Rect(Round(TextBounds.Left * Zoom), + Round(TextBounds.Top * Zoom), + Round(TextBounds.Right * Zoom), + Round(TextBounds.Bottom * Zoom)); + if TextFound and (Index = FLastFoundPage) then + with Canvas, TxtBounds do + begin + Pen.Width := 1; + Pen.Style := psSolid; + Pen.Mode := pmXor; + Pen.Color := clWhite; + for i := 0 to Bottom - Top do + begin + MoveTo(PageBounds.Left + Left - 1, PageBounds.Top + Top + i); + LineTo(PageBounds.Left + Right + 1, PageBounds.Top + Top + i); + end; + Pen.Mode := pmCopy; + end; + end; + +begin + if not Visible then Exit; + + if Locked or (FPageList.Count = 0) then + begin + Canvas.Brush.Color := BackColor; + Canvas.FillRect(Rect(0, 0, ClientWidth, ClientHeight)); + Exit; + end; + + if PreviewPages = nil then Exit; + + h := CreateRectRgn(0, 0, ClientWidth, ClientHeight); + GetClipRgn(Canvas.Handle, h); + + { index of first visible page } + n := FPageList.FindPage(FOffset.Y); + + { exclude page areas to prevent flickering } + for i := n - 40 to n + 40 do + begin + if i < 0 then continue; + if i >= FPageList.Count then break; + + PageBounds := FPageList.GetPageBounds(i, ClientWidth, Zoom); + OffsetRect(PageBounds, -FOffset.X, -FOffset.Y); + if PageVisible then + with PageBounds do + ExcludeClipRect(Canvas.Handle, Left, Top, Right, Bottom); + end; + + { now draw background on the non-clipped area} + with Canvas do + begin + Brush.Color := BackColor; + Brush.Style := bsSolid; + FillRect(Rect(0, 0, ClientWidth, ClientHeight)); + end; + + { restore clipregion } + SelectClipRgn(Canvas.Handle, h); + + { draw border around the active page } + PageBounds := FPageList.GetPageBounds(PageNo - 1, ClientWidth, Zoom); + OffsetRect(PageBounds, -FOffset.X, -FOffset.Y); + with Canvas, PageBounds do + begin + Pen.Color := ActiveFrameColor; + Pen.Width := 2; + Pen.Mode := pmCopy; + Pen.Style := psSolid; + Polyline([Point(Left - 1, Top - 1), + Point(Right + 1, Top - 1), + Point(Right + 1, Bottom + 1), + Point(Left - 1, Bottom + 1), + Point(Left - 1, Top - 2)]); + end; + if not BorderOnly then + begin + { draw visible pages } + for i := n - 40 to n + 40 do + begin + if i < 0 then continue; + if i >= FPageList.Count then break; + + PageBounds := FPageList.GetPageBounds(i, ClientWidth, Zoom); + OffsetRect(PageBounds, -FOffset.X, -FOffset.Y); + Inc(PageBounds.Bottom); + if PageVisible then + DrawPage(i); + end; + end; + + DeleteObject(h); +end; + +procedure TfrxPreviewWorkspace.Paint; +begin + DrawPages(False); +end; + +procedure TfrxPreviewWorkspace.MouseDown(Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +begin + if (FPageList.Count = 0) or Locked then Exit; + + if Button = mbLeft then + begin + FDown := True; + FLastPoint.X := X; + FLastPoint.Y := Y; + end; +end; + +procedure TfrxPreviewWorkspace.MouseMove(Shift: TShiftState; X, Y: Integer); +var + PageNo: Integer; + PageBounds: TRect; + Cur: TCursor; +begin + if (FPageList.Count = 0) or Locked or FIsThumbnail then Exit; + + if FDown then + begin + HorzPosition := HorzPosition - (X - FLastPoint.X); + VertPosition := VertPosition - (Y - FLastPoint.Y); + FLastPoint.X := X; + FLastPoint.Y := Y; + end + else + begin + PageNo := FPageList.FindPage(FOffset.Y + Y, FOffset.X + X); + PageBounds := FPageList.GetPageBounds(PageNo, ClientWidth, Zoom); + Cur := FDefaultCursor; + PreviewPages.ObjectOver(PageNo, X, Y, mbLeft, [], Zoom, + PageBounds.Left - FOffset.X, PageBounds.Top - FOffset.Y, False, Cur); + Cursor := Cur; + end; +end; + +procedure TfrxPreviewWorkspace.MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +var + PageNo: Integer; + PageBounds: TRect; + Cur: TCursor; +begin + if not FIsThumbnail and Assigned(Preview.OnClick) then + Preview.OnClick(Preview); + if (FPageList.Count = 0) or Locked then Exit; + + FDown := False; + PageNo := FPageList.FindPage(FOffset.Y + Y, FOffset.X + X); + FDisableUpdate := True; + Preview.PageNo := PageNo + 1; + FDisableUpdate := False; + if not FIsThumbnail and (Button <> mbRight) then + begin + PageBounds := FPageList.GetPageBounds(PageNo, ClientWidth, Zoom); + PreviewPages.ObjectOver(PageNo, X, Y, Button, Shift, Zoom, + PageBounds.Left - FOffset.X, PageBounds.Top - FOffset.Y, True, Cur); + end; +end; + +procedure TfrxPreviewWorkspace.FindText; +var + EMFCanvas: TMetafileCanvas; + PageBounds, TxtBounds: TRect; +begin + TextFound := False; + + while FLastFoundPage < FPageList.Count do + begin + if (FEMFImage = nil) or (FEMFImagePage <> FLastFoundPage) then + begin + if FEMFImage <> nil then + FEMFImage.Free; + FEMFImage := TMetafile.Create; + EMFCanvas := TMetafileCanvas.Create(FEMFImage, 0); + PreviewPages.DrawPage(FLastFoundPage, EMFCanvas, 1, 1, 0, 0); + EMFCanvas.Free; + end; + + FEMFImagePage := FLastFoundPage; + RecordNo := 0; + EnumEnhMetafile(0, FEMFImage.Handle, @EnumEMFRecordsProc, nil, Rect(0, 0, 0, 0)); + + if TextFound then + begin + PageBounds := FPageList.GetPageBounds(FLastFoundPage, ClientWidth, Zoom); + TxtBounds := Rect(Round(TextBounds.Left * Zoom), + Round(TextBounds.Top * Zoom), + Round(TextBounds.Right * Zoom), + Round(TextBounds.Bottom * Zoom)); + + if (PageBounds.Top + TxtBounds.Top < FOffset.Y) or + (PageBounds.Top + TxtBounds.Bottom > FOffset.Y + ClientHeight) then + VertPosition := PageBounds.Top + TxtBounds.Bottom - ClientHeight + 20; + if (PageBounds.Left + TxtBounds.Left < FOffset.X) or + (PageBounds.Left + TxtBounds.Right > FOffset.X + ClientWidth) then + HorzPosition := PageBounds.Left + TxtBounds.Right - ClientWidth + 20; + Repaint; + break; + end; + + LastFoundRecord := -1; + Inc(FLastFoundPage); + end; +end; + +procedure TfrxPreviewWorkspace.Resize; +begin + inherited; + HorzPage := ClientWidth; + VertPage := ClientHeight; +end; + +procedure TfrxPreviewWorkspace.SetToPageNo(PageNo: Integer); +begin + if FDisableUpdate then Exit; + VertPosition := + FPageList.GetPageBounds(PageNo - 1, ClientWidth, Zoom).Top - 10; +end; + +procedure TfrxPreviewWorkspace.UpdateScrollBars; +var + MaxSize: TPoint; +begin + MaxSize := FPageList.GetMaxBounds; + HorzRange := MaxSize.X + 10; + VertRange := MaxSize.Y + 10; +end; + +procedure TfrxPreviewWorkspace.SetPosition(PageN, Top: Integer); +var + Pos: Integer; + Page: TfrxReportPage; +begin + Page := PreviewPages.Page[PageN - 1]; + if Top = 0 then + Pos := 0 + else + Pos := Round((Top + Page.TopMargin * fr01cm) * Zoom); + + VertPosition := FPageList.GetPageBounds(PageN - 1, ClientWidth, Zoom).Top - 10 + Pos; +end; + +procedure TfrxPreviewWorkspace.AddPage(AWidth, AHeight: Integer); +begin + FPageList.AddPage(AWidth, AHeight, Zoom); +end; + +procedure TfrxPreviewWorkspace.CalcPageBounds(ClientWidth: Integer); +begin + FPageList.CalcBounds(ClientWidth); +end; + +procedure TfrxPreviewWorkspace.ClearPageList; +begin + FPageList.Clear; +end; + + +{ TfrxPreview } + +constructor TfrxPreview.Create(AOwner: TComponent); +var + m: TMenuItem; +begin + inherited; + + FOutlinePopup := TPopupMenu.Create(Self); + FOutlinePopup.Images := frxResources.PreviewButtonImages; + m := TMenuItem.Create(FOutlinePopup); + FOutlinePopup.Items.Add(m); + m.Caption := frxGet(601); + m.ImageIndex := 13; + m.OnClick := OnCollapseClick; + m := TMenuItem.Create(FOutlinePopup); + FOutlinePopup.Items.Add(m); + m.Caption := frxGet(600); + m.ImageIndex := 14; + m.OnClick := OnExpandClick; + + FOutline := TTreeView.Create(Self); + with FOutline do + begin + Parent := Self; + Align := alLeft; + HideSelection := False; +{$IFDEF UseTabset} + BorderStyle := bsNone; + BevelKind := bkFlat; +{$ELSE} + BorderStyle := bsSingle; +{$ENDIF} + OnClick := OnOutlineClick; + PopupMenu := FOutlinePopup; + end; + + FThumbnail := TfrxPreviewWorkspace.Create(Self); + FThumbnail.Parent := Self; + FThumbnail.Align := alLeft; + FThumbnail.Visible := False; + FThumbnail.Zoom := 0.1; + FThumbnail.IsThumbnail := True; + FThumbnail.Preview := Self; + + FSplitter := TSplitter.Create(Self); + FSplitter.Parent := Self; + FSplitter.Align := alLeft; + FSplitter.Width := 4; + FSplitter.Left := FOutline.Width + 1; + FSplitter.OnMoved := OnMoveSplitter; + + FWorkspace := TfrxPreviewWorkspace.Create(Self); + FWorkspace.Parent := Self; + FWorkspace.Align := alClient; + FWorkspace.Preview := Self; + + FMessagePanel := TPanel.Create(Self); + FMessagePanel.Parent := Self; + FMessagePanel.Visible := False; + FMessagePanel.SetBounds(0, 0, 0, 0); + + FMessageLabel := TLabel.Create(FMessagePanel); + FMessageLabel.Parent := FMessagePanel; + FMessageLabel.AutoSize := False; + FMessageLabel.Alignment := taCenter; + FMessageLabel.SetBounds(4, 20, 255, 20); + + FCancelButton := TButton.Create(FMessagePanel); + FCancelButton.Parent := FMessagePanel; + FCancelButton.SetBounds(92, 44, 75, 25); + FCancelButton.Caption := frxResources.Get('clCancel'); + FCancelButton.Visible := False; + FCancelButton.OnClick := OnCancel; + + FBorderStyle := bsSingle; + FPageNo := 1; + FScrollBars := ssBoth; + FZoom := 1; + FZoomMode := zmDefault; + FOutlineColor := clWindow; + + Width := 100; + Height := 100; +end; + +destructor TfrxPreview.Destroy; +begin + if Report <> nil then + Report.Preview := nil; + inherited; +end; + +procedure TfrxPreview.CreateParams(var Params: TCreateParams); +const + BorderStyles: array[TBorderStyle] of DWORD = (0, WS_BORDER); +begin + inherited CreateParams(Params); + with Params do + begin + Style := Style or BorderStyles[FBorderStyle]; + if Ctl3D and NewStyleControls and (FBorderStyle = bsSingle) then + begin + Style := Style and not WS_BORDER; + ExStyle := Params.ExStyle or WS_EX_CLIENTEDGE; + end; + end; +end; + +procedure TfrxPreview.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited Notification(AComponent, Operation); + + if Operation = opRemove then + if AComponent = Report then + begin + Clear; + Report := nil; + PreviewPages := nil; + end; +end; + +procedure TfrxPreview.Init; +begin + FWorkspace.PreviewPages := PreviewPages; + FThumbnail.PreviewPages := PreviewPages; + + TextFound := False; + FWorkspace.FLastFoundPage := 0; + LastFoundRecord := -1; + FAllowF3 := False; + + FWorkspace.DoubleBuffered := True; + OutlineWidth := Report.PreviewOptions.OutlineWidth; + OutlineVisible := Report.PreviewOptions.OutlineVisible; + ThumbnailVisible := Report.PreviewOptions.ThumbnailVisible; + UpdatePages; + UpdateOutline; + First; +end; + +procedure TfrxPreview.WMEraseBackground(var Message: TMessage); +begin +end; + +procedure TfrxPreview.WMGetDlgCode(var Message: TWMGetDlgCode); +begin + Message.Result := DLGC_WANTARROWS; +end; + +procedure TfrxPreview.KeyDown(var Key: Word; Shift: TShiftState); +begin + inherited; + if Key = vk_Up then + FWorkspace.VertPosition := FWorkspace.VertPosition - 8 + else if Key = vk_Down then + FWorkspace.VertPosition := FWorkspace.VertPosition + 8 + else if Key = vk_Left then + FWorkspace.HorzPosition := FWorkspace.HorzPosition - 8 + else if Key = vk_Right then + FWorkspace.HorzPosition := FWorkspace.HorzPosition + 8 + else if Key = vk_Prior then + if ssCtrl in Shift then + PageNo := PageNo - 1 + else + FWorkspace.VertPosition := FWorkspace.VertPosition - 300 + else if Key = vk_Next then + if ssCtrl in Shift then + PageNo := PageNo + 1 + else + FWorkspace.VertPosition := FWorkspace.VertPosition + 300 + else if Key = vk_Home then + PageNo := 1 + else if Key = vk_End then + PageNo := PageCount + else if (Key = vk_F3) and (pbFind in Report.PreviewOptions.Buttons) then + FindNext + else if ssCtrl in Shift then + begin + if (Key = Ord('P')) and (pbPrint in Report.PreviewOptions.Buttons) then + Print + else if (Key = Ord('S')) and (pbSave in Report.PreviewOptions.Buttons) then + SaveToFile + else if (Key = Ord('F')) and (pbFind in Report.PreviewOptions.Buttons) then + Find + else if (Key = Ord('O')) and (pbLoad in Report.PreviewOptions.Buttons) then + LoadFromFile + end; +end; + +procedure TfrxPreview.Resize; +begin + inherited; + if PreviewPages <> nil then + UpdatePages; +end; + +procedure TfrxPreview.OnMoveSplitter(Sender: TObject); +begin + UpdatePages; +end; + +procedure TfrxPreview.OnCollapseClick(Sender: TObject); +begin + FOutline.FullCollapse; +end; + +procedure TfrxPreview.OnExpandClick(Sender: TObject); +begin + FOutline.FullExpand; + if FOutline.Items.Count > 0 then + FOutline.TopItem := FOutline.Items[0]; +end; + +procedure TfrxPreview.SetZoom(const Value: Extended); +begin + FZoom := Value; + if FZoom < 0.25 then + FZoom := 0.25; + + FZoomMode := zmDefault; + UpdatePages; +end; + +procedure TfrxPreview.SetZoomMode(const Value: TfrxZoomMode); +begin + FZoomMode := Value; + UpdatePages; +end; + +function TfrxPreview.GetOutlineVisible: Boolean; +begin + Result := FOutline.Visible; +end; + +procedure TfrxPreview.SetOutlineVisible(const Value: Boolean); +var + NeedChange: Boolean; +begin + NeedChange := Value <> FOutline.Visible; + + FSplitter.Visible := Value or ThumbnailVisible; + FOutline.Visible := Value; + if Value then + FThumbnail.Visible := False; + + if Owner is TfrxPreviewForm then + TfrxPreviewForm(Owner).OutlineB.Down := Value; + if NeedChange then + UpdatePages; +end; + +function TfrxPreview.GetThumbnailVisible: Boolean; +begin + Result := FThumbnail.Visible; +end; + +procedure TfrxPreview.SetThumbnailVisible(const Value: Boolean); +var + NeedChange: Boolean; +begin + NeedChange := Value <> FThumbnail.Visible; + + FSplitter.Visible := Value or OutlineVisible; + FThumbnail.Visible := Value; + if Value then + FOutline.Visible := False; + + if Value then + begin + FThumbnail.HorzPosition := FThumbnail.HorzPosition; + FThumbnail.VertPosition := FThumbnail.VertPosition; + end; + if Owner is TfrxPreviewForm then + TfrxPreviewForm(Owner).ThumbB.Down := Value; + if NeedChange then + UpdatePages; +end; + +function TfrxPreview.GetOutlineWidth: Integer; +begin + Result := FOutline.Width; +end; + +procedure TfrxPreview.SetOutlineWidth(const Value: Integer); +begin + FOutline.Width := Value; + if not (csDesigning in ComponentState) then + FThumbnail.Width := Value; +end; + +procedure TfrxPreview.SetOutlineColor(const Value: TColor); +begin + FOutlineColor := Value; + FOutline.Color := Value; +end; + +procedure TfrxPreview.SetPageNo(Value: Integer); +var + ActivePageChanged: Boolean; +begin + if Value < 1 then + Value := 1; + if Value > PageCount then + Value := PageCount; + ActivePageChanged := FPageNo <> Value; + FPageNo := Value; + FWorkspace.PageNo := Value; + FThumbnail.PageNo := Value; + + if ActivePageChanged then + begin + FWorkspace.DrawPages(True); + FThumbnail.DrawPages(True); + end; + FWorkspace.SetToPageNo(FPageNo); + FThumbnail.SetToPageNo(FPageNo); + UpdatePageNumbers; +end; + +function TfrxPreview.GetActiveFrameColor: TColor; +begin + Result := FWorkspace.ActiveFrameColor; +end; + +function TfrxPreview.GetBackColor: TColor; +begin + Result := FWorkspace.BackColor; +end; + +function TfrxPreview.GetFrameColor: TColor; +begin + Result := FWorkspace.FrameColor; +end; + +procedure TfrxPreview.SetActiveFrameColor(const Value: TColor); +begin + FWorkspace.ActiveFrameColor := Value; +end; + +procedure TfrxPreview.SetBackColor(const Value: TColor); +begin + FWorkspace.BackColor := Value; +end; + +procedure TfrxPreview.SetFrameColor(const Value: TColor); +begin + FWorkspace.FrameColor := Value; +end; + +procedure TfrxPreview.SetBorderStyle(Value: TBorderStyle); +begin + if BorderStyle <> Value then + begin + FBorderStyle := Value; + RecreateWnd; + end; +end; + +procedure TfrxPreview.UpdatePageNumbers; +begin + if Assigned(FOnPageChanged) then + FOnPageChanged(Self, FPageNo); +end; + +function TfrxPreview.GetPageCount: Integer; +begin + if PreviewPages <> nil then + Result := PreviewPages.Count + else + Result := 0; +end; + +{$IFDEF FR_COM} +function TfrxPreview.ShowMessage(const s: WideString): HResult; +{$ELSE} +procedure TfrxPreview.ShowMessage(const s: String); +{$ENDIF} +begin + FMessagePanel.SetBounds((Width - 260) div 2, (Height - 75) div 3, 260, 75); + FMessageLabel.Caption := s; + FMessagePanel.Show; + FMessagePanel.Update; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.HideMessage: HResult; +{$ELSE} +procedure TfrxPreview.HideMessage; +{$ENDIF} +begin + FMessagePanel.Hide; + FCancelButton.Hide; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.First: HResult; +{$ELSE} +procedure TfrxPreview.First; +{$ENDIF} +begin + PageNo := 1; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.Next: HResult; +{$ELSE} +procedure TfrxPreview.Next; +{$ENDIF} +begin + PageNo := PageNo + 1; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.Prior: HResult; +{$ELSE} +procedure TfrxPreview.Prior; +{$ENDIF} +begin + PageNo := PageNo - 1; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.Last: HResult; +{$ELSE} +procedure TfrxPreview.Last; +{$ENDIF} +begin + PageNo := PageCount; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.Print: HResult; +begin + if not FRunning then + begin + try + PreviewPages.CurPreviewPage := PageNo; + PreviewPages.Print; + Result := S_OK; + except + Result := E_FAIL; + end; + Unlock; + end else + Result := RPC_E_SERVERCALL_RETRYLATER; +end; +{$ELSE} +procedure TfrxPreview.Print; +begin + if FRunning then Exit; + try + PreviewPages.CurPreviewPage := PageNo; + PreviewPages.Print; + finally + Unlock; + end; +end; +{$ENDIF} + +procedure TfrxPreview.SaveToFile; +var + SaveDlg: TSaveDialog; +begin + if FRunning then Exit; + SaveDlg := TSaveDialog.Create(Application); + try + SaveDlg.Filter := frxResources.Get('clFP3files') + ' (*.fp3)|*.fp3'; + if SaveDlg.Execute then + begin + FWorkspace.Repaint; + SaveToFile(ChangeFileExt(SaveDlg.FileName, '.fp3')); + end; + finally + SaveDlg.Free; + end; +end; + +procedure TfrxPreview.SaveToFile(FileName: String); +begin + if FRunning then Exit; + try + Lock; + ShowMessage(frxResources.Get('clSaving')); + PreviewPages.SaveToFile(FileName); + finally + Unlock; + end; +end; + +procedure TfrxPreview.LoadFromFile; +var + OpenDlg: TOpenDialog; +begin + if FRunning then Exit; + OpenDlg := TOpenDialog.Create(nil); + try + OpenDlg.Options := [ofHideReadOnly]; + OpenDlg.Filter := frxResources.Get('clFP3files') + ' (*.fp3)|*.fp3'; + if OpenDlg.Execute then + begin + FWorkspace.Repaint; + LoadFromFile(OpenDlg.FileName); + end; + finally + OpenDlg.Free; + end; +end; + +procedure TfrxPreview.LoadFromFile(FileName: String); +begin + if FRunning then Exit; + try + Lock; + ShowMessage(frxResources.Get('clLoading')); + PreviewPages.LoadFromFile(FileName); + finally + UpdateOutline; + Unlock; + PageNo := 1; + end; +end; + +procedure TfrxPreview.Export(Filter: TfrxCustomExportFilter); +begin + if FRunning then Exit; + try + PreviewPages.CurPreviewPage := PageNo; + if Report.DotMatrixReport and (frxDotMatrixExport <> nil) and + (Filter.ClassName = 'TfrxTextExport') then + Filter := frxDotMatrixExport; + PreviewPages.Export(Filter); + finally + Unlock; + end; +end; + +function TfrxPreview.FindText(SearchString: String; FromTop, IsCaseSensitive: Boolean): Boolean; +begin + TextToFind := SearchString; + CaseSensitive := IsCaseSensitive; + if FromTop then + FWorkspace.FLastFoundPage := 0 + else + FWorkspace.FLastFoundPage := PageNo - 1; + LastFoundRecord := -1; + + FWorkspace.FindText; + + FAllowF3 := True; + Result := TextFound; +end; + +function TfrxPreview.FindTextFound: Boolean; +begin + Result := TextFound; +end; + +procedure TfrxPreview.FindTextClear; +begin + LastFoundRecord := -1; + FWorkspace.FLastFoundPage := 0; + TextFound := False; + Invalidate; +end; + +{$IFDEF FR_COM} +function TfrxPreview.PageSetupDlg: HResult; +{$ELSE} +procedure TfrxPreview.PageSetupDlg; +{$ENDIF} +var + APage: TfrxReportPage; + + procedure UpdateReport; + var + i: Integer; + begin + for i := 0 to Report.PagesCount - 1 do + if Report.Pages[i] is TfrxReportPage then + with TfrxReportPage(Report.Pages[i]) do + begin + Orientation := APage.Orientation; + PaperWidth := APage.PaperWidth; + PaperHeight := APage.PaperHeight; + PaperSize := APage.PaperSize; + + LeftMargin := APage.LeftMargin; + RightMargin := APage.RightMargin; + TopMargin := APage.TopMargin; + BottomMargin := APage.BottomMargin; + end; + end; + +begin +{$IFDEF FR_COM} + if FRunning then Result := RPC_E_SERVERCALL_RETRYLATER else + begin +{$ELSE} + if FRunning then Exit; +{$ENDIF} + APage := PreviewPages.Page[PageNo - 1]; + + if Assigned(APage) then with TfrxPageSettingsForm.Create(Application) do + begin + Page := APage; + Report := Self.Report; + if ShowModal = mrOk then + begin + if NeedRebuild then + begin + UpdateReport; + Self.Report.PrepareReport; + end + else + begin + try + Lock; + PreviewPages.ModifyPage(PageNo - 1, Page); + finally + Unlock; + end; + end; + end; + Free; + end; +{$IFDEF FR_COM} + Result := S_OK; + end; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.Find: HResult; +{$ELSE} +procedure TfrxPreview.Find; +{$ENDIF} +begin + with TfrxSearchDialog.Create(Application) do + begin + if ShowModal = mrOk then + begin + TextToFind := TextE.Text; + CaseSensitive := CaseCB.Checked; + if TopCB.Checked then + FWorkspace.FLastFoundPage := 0 + else + FWorkspace.FLastFoundPage := PageNo - 1; + LastFoundRecord := -1; + FWorkspace.FindText; + end; + Free; + end; + + FAllowF3 := True; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.FindNext: HResult; +{$ELSE} +procedure TfrxPreview.FindNext; +{$ENDIF} +begin + if FAllowF3 then + FWorkspace.FindText; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.Edit: HResult; +{$ELSE} +procedure TfrxPreview.Edit; +{$ENDIF} +var + r: TfrxReport; + p: TfrxReportPage; + SourcePage: TfrxPage; + + procedure RemoveBands; + var + i: Integer; + l: TList; + c: TfrxComponent; + begin + l := p.AllObjects; + + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxView then + begin + TfrxView(c).DataField := ''; + TfrxView(c).DataSet := nil; + TfrxView(c).Restrictions := []; + end; + + if c.Parent <> p then + begin + c.Left := c.AbsLeft; + c.Top := c.AbsTop; + c.ParentFont := False; + c.Parent := p; + if (c is TfrxView) and (TfrxView(c).Align in [baBottom, baClient]) then + TfrxView(c).Align := baNone; + end; + end; + + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if c is TfrxBand then + c.Free; + end; + end; + +begin + SourcePage := PreviewPages.Page[PageNo - 1]; + r := nil; + if Assigned(SourcePage) then + try + if SourcePage is TfrxDMPPage then + p := TfrxDMPPage.Create(nil) else + p := TfrxReportPage.Create(nil); + p.AssignAll(SourcePage); + RemoveBands; + r := TfrxReport.Create(nil); + p.Parent := r; + if r.DesignPreviewPage then + try + Lock; + PreviewPages.ModifyPage(PageNo - 1, TfrxReportPage(r.Pages[0])); + finally + Unlock; + end; + except + if Assigned(r) then r.Free; + end; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +procedure TfrxPreview.EditTemplate; +var + r: TfrxReport; + i: Integer; +begin + r := TfrxReport.Create(nil); + try + for i := 0 to TfrxPreviewPages(PreviewPages).SourcePages.Count - 1 do + r.Objects.Add(TfrxPreviewPages(PreviewPages).SourcePages[i]); + r.DesignReport; + finally + r.Objects.Clear; + r.Free; + end; +end; + +{$IFDEF FR_COM} +function TfrxPreview.Clear: HResult; +begin + if FRunning then Result := RPC_E_SERVERCALL_RETRYLATER else + begin +{$ELSE} +procedure TfrxPreview.Clear; +begin + if FRunning then Exit; +{$ENDIF} + Lock; + try + PreviewPages.Clear; + finally + Unlock; + end; + + UpdateOutline; + PageNo := 0; + with FWorkspace do + begin + HorzRange := 0; + VertRange := 0; + end; +{$IFDEF FR_COM} + Result := S_OK; + end; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.AddPage: HResult; +begin + if FRunning then Result := RPC_E_SERVERCALL_RETRYLATER else + begin +{$ELSE} +procedure TfrxPreview.AddPage; +begin + if FRunning then Exit; +{$ENDIF} + PreviewPages.AddEmptyPage(PageNo - 1); + UpdatePages; + PageNo := PageNo; +{$IFDEF FR_COM} + Result := S_OK; + end; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.DeletePage: HResult; +begin + if FRunning then Result := RPC_E_SERVERCALL_RETRYLATER else + begin +{$ELSE} +procedure TfrxPreview.DeletePage; +begin + if FRunning then Exit; +{$ENDIF} + PreviewPages.DeletePage(PageNo - 1); + if PageNo >= PageCount then + PageNo := PageNo - 1; + UpdatePages; + UpdatePageNumbers; +{$IFDEF FR_COM} + Result := S_OK; + end; +{$ENDIF} +end; + +procedure TfrxPreview.Lock; +begin + FLocked := True; + FWorkspace.Locked := True; + FThumbnail.Locked := True; +end; + +procedure TfrxPreview.Unlock; +begin + HideMessage; + FLocked := False; + FWorkspace.Locked := False; + FThumbnail.Locked := False; + //FPageNo := 1; + UpdatePages; + FWorkspace.Repaint; + FThumbnail.Repaint; +end; + +{$IFDEF FR_COM} +function TfrxPreview.SetPosition(PageN, Top: Integer): HResult; +{$ELSE} +procedure TfrxPreview.SetPosition(PageN, Top: Integer); +{$ENDIF} +begin + if PageN > PageCount then + PageN := PageCount; + if PageN <= 0 then + PageN := 1; + FWorkspace.SetPosition(PageN, Top); +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +procedure TfrxPreview.RefreshReport; +var + hpos, vpos, pno: Integer; +begin + hpos := FWorkspace.FOffset.X; + vpos := FWorkspace.FOffset.Y; + pno := FPageNo; + + Lock; + FRefreshing := True; + try + Report.PrepareReport; + FLocked := False; + FThumbnail.Locked := False; + if pno <= PageCount then + FPageNo := pno + else + FPageNo := 1; + UpdatePages; + UpdateOutline; + finally + FRefreshing := False; + end; + + FWorkspace.DoubleBuffered := True; + FWorkspace.FOffset.X := hpos; + FWorkspace.FOffset.Y := vpos; + FWorkspace.Locked := False; + FWorkspace.Repaint; + FThumbnail.Repaint; + FWorkspace.DoubleBuffered := False; + if pno > PageCount then + PageNo := 1; +end; + +procedure TfrxPreview.UpdatePages; +var + PageSize: TPoint; + i: Integer; +begin + if FLocked or (PageCount = 0) then Exit; + + { clear find settings } + FAllowF3 := False; + FWorkspace.FEMFImagePage := -1; + + { calc zoom if not zmDefault} + PageSize := PreviewPages.PageSize[PageNo - 1]; + if PageSize.Y = 0 then Exit; + case FZoomMode of + zmWholePage: + begin + FZoom := (FWorkspace.Height - 26) / PageSize.Y; + SetPosition(PageNo, 0); + end; + zmPageWidth: + FZoom := (FWorkspace.Width - GetSystemMetrics(SM_CXVSCROLL) - 26) / PageSize.X; + end; + + FWorkspace.DoubleBuffered := True; + FThumbnail.DoubleBuffered := True; + { fill page list and calc bounds } + FWorkspace.Zoom := FZoom; + FThumbnail.Zoom := 0.1; + FWorkspace.ClearPageList; + FThumbnail.ClearPageList; + for i := 0 to PageCount - 1 do + begin + PageSize := PreviewPages.PageSize[i]; + FWorkspace.AddPage(PageSize.X, PageSize.Y); + if not FRunning then + FThumbnail.AddPage(PageSize.X, PageSize.Y); + end; + + FWorkspace.CalcPageBounds(FWorkspace.Width - GetSystemMetrics(SM_CXVSCROLL) - 26); + if not FRunning then + FThumbnail.CalcPageBounds(FThumbnail.Width - GetSystemMetrics(SM_CXVSCROLL) - 26); + + FWorkspace.UpdateScrollBars; + FThumbnail.UpdateScrollBars; + { avoid positioning errors when resizing } + FWorkspace.HorzPosition := FWorkspace.HorzPosition; + FWorkspace.VertPosition := FWorkspace.VertPosition; + + if not FRefreshing then + begin + FWorkspace.Repaint; + FThumbnail.Repaint; + end; + + if Owner is TfrxPreviewForm then + TfrxPreviewForm(Owner).UpdateZoom; + FWorkspace.DoubleBuffered := False; + FThumbnail.DoubleBuffered := False; +end; + +procedure TfrxPreview.UpdateOutline; +var + Outline: TfrxCustomOutline; + + procedure DoUpdate(RootNode: TTreeNode); + var + i, n: Integer; + Node: TTreeNode; + Page, Top: Integer; + Text: String; + begin + n := Outline.Count; + for i := 0 to n - 1 do + begin + Outline.GetItem(i, Text, Page, Top); + Node := FOutline.Items.AddChild(RootNode, Text); + Node.ImageIndex := Page + 1; + Node.StateIndex := Top; + + Outline.LevelDown(i); + DoUpdate(Node); + Outline.LevelUp; + end; + end; + +begin + FOutline.Items.BeginUpdate; + FOutline.Items.Clear; + Outline := Report.PreviewPages.Outline; + Outline.LevelRoot; + DoUpdate(nil); + if Report.PreviewOptions.OutlineExpand then + FOutline.FullExpand; + if FOutline.Items.Count > 0 then + FOutline.TopItem := FOutline.Items[0]; + FOutline.Items.EndUpdate; +end; + +procedure TfrxPreview.OnOutlineClick(Sender: TObject); +var + Node: TTreeNode; + PageN, Top: Integer; +begin + Node := FOutline.Selected; + if Node = nil then Exit; + + PageN := Node.ImageIndex; + Top := Node.StateIndex; + + SetPosition(PageN, Top); + SetFocus; +end; + +procedure TfrxPreview.InternalOnProgressStart(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer); +begin + if FRefreshing then Exit; + + Clear; + Report.DrillState.Clear; + FRunning := True; + if Owner is TfrxPreviewForm then + TfrxPreviewForm(Owner).UpdateControls; +end; + +procedure TfrxPreview.InternalOnProgress(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer); +var + PageSize: TPoint; +begin + if FRefreshing then + begin + UpdatePageNumbers; + Exit; + end; + + if Report.Engine.FinalPass then + begin + PageSize := Report.PreviewPages.PageSize[Progress]; + if Progress < 50 then + begin + FWorkspace.AddPage(PageSize.X, PageSize.Y); + FWorkspace.CalcPageBounds(FWorkspace.Width - GetSystemMetrics(SM_CXVSCROLL) - 26); + end; + end; + + if Progress = 0 then + begin + PageNo := 1; + if Report.Engine.FinalPass then + UpdatePages; + if Owner is TfrxPreviewForm then + TfrxPreviewForm(Owner).CancelB.Caption := frxResources.Get('clCancel'); + FTick := GetTickCount; + end + else if Progress = 1 then + begin + FTick := GetTickCount - FTick; + if FTick < 5 then + FTick := 50 + else if FTick < 10 then + FTick := 20 + else + FTick := 5; + PageNo := 1; + if Report.Engine.FinalPass then + UpdatePages; + end + else if Progress mod Integer(FTick) = 0 then + begin + UpdatePageNumbers; + if Report.Engine.FinalPass then + FWorkspace.UpdateScrollBars; + end; + + Application.ProcessMessages; +end; + +procedure TfrxPreview.InternalOnProgressStop(Sender: TfrxReport; + ProgressType: TfrxProgressType; Progress: Integer); +begin + if FRefreshing then Exit; + + FRunning := False; + UpdatePageNumbers; + FWorkspace.UpdateScrollBars; + FThumbnail.UpdateScrollBars; + UpdatePages; + UpdateOutline; + if Owner is TfrxPreviewForm then + begin + TfrxPreviewForm(Owner).CancelB.Caption := frxResources.Get('clClose'); + TfrxPreviewForm(Owner).StatusBar.Panels[1].Text := ''; + TfrxPreviewForm(Owner).UpdateControls; + end; +end; + +procedure TfrxPreview.OnCancel(Sender: TObject); +begin + Report.Terminated := True; +end; + +{$IFDEF FR_COM} +function TfrxPreview.Cancel: HResult; +{$ELSE} +procedure TfrxPreview.Cancel; +{$ENDIF} +begin + if FRunning then + OnCancel(Self); +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.MouseWheelScroll(Delta: Integer; Horz: WordBool; Zoom: WordBool): HResult; stdcall; +{$ELSE} +procedure TfrxPreview.MouseWheelScroll(Delta: Integer; Horz: Boolean = False; + Zoom: Boolean = False); +{$ENDIF} +begin + if Delta <> 0 then + if Zoom then + begin + FZoom := FZoom + Round(Delta / Abs(Delta)) / 10; + if FZoom < 0.3 then + FZoom := 0.3; + SetZoom(FZoom); + end + else + begin + with FWorkspace do + begin + if Horz then + HorzPosition := HorzPosition + Round(-Delta / Abs(Delta)) * 20 + else + VertPosition := VertPosition + Round(-Delta / Abs(Delta)) * 20; + end; + end; +{$IFDEF FR_COM} + Result := S_OK; +{$ENDIF} +end; + +{$IFDEF FR_COM} +function TfrxPreview.LoadPreparedReportFromFile(const FileName: WideString): HResult; stdcall; +begin + Result := S_OK; + try + LoadFromFile(FileName); + except + Result := E_INVALIDARG; + end; +end; + +function TfrxPreview.SavePreparedReportToFile(const FileName: WideString): HResult; stdcall; +begin + Result := S_OK; + try + SaveToFile(FileName); + except + Result := E_INVALIDARG; + end; +end; + +function TfrxPreview.Get_FullScreen(out Value: WordBool): HResult; stdcall; +begin + if Owner is TfrxPreviewForm then + begin + Value := TfrxPreviewForm(Owner).FFullScreen; + Result := S_OK; + end else Result := E_FAIL; +end; + +function TfrxPreview.Set_FullScreen(Value: WordBool): HResult; stdcall; +begin + if Owner is TfrxPreviewForm then + begin + if TfrxPreviewForm(Owner).FFullScreen <> Value then + TfrxPreviewForm(Owner).SwitchToFullScreen; + Result := S_OK; + end + else + Result := E_FAIL; +end; + +function TfrxPreview.Get_ToolBarVisible(out Value: WordBool): HResult; stdcall; +begin + if Owner is TfrxPreviewForm then + begin + Value := TfrxPreviewForm(Owner).ToolBar.Visible; + Result := S_OK; + end + else + Result := E_FAIL; +end; + +function TfrxPreview.Set_ToolBarVisible(Value: WordBool): HResult; stdcall; +begin + if Owner is TfrxPreviewForm then + begin + TfrxPreviewForm(Owner).ToolBar.Visible := Value; + Result := S_OK; + end + else + Result := E_FAIL; +end; + +function TfrxPreview.Get_StatusBarVisible(out Value: WordBool): HResult; stdcall; +begin + if Owner is TfrxPreviewForm then + begin + Value := TfrxPreviewForm(Owner).StatusBar.Visible; + Result := S_OK; + end + else + Result := E_FAIL; +end; + +function TfrxPreview.Set_StatusBarVisible(Value: WordBool): HResult; stdcall; +begin + if Owner is TfrxPreviewForm then + begin + TfrxPreviewForm(Owner).StatusBar.Visible := Value; + Result := S_OK; + end + else + Result := E_FAIL; +end; + + +function TfrxPreview.Get_PageCount(out Value: Integer): HResult; stdcall; +begin + Value := PageCount; + Result := S_OK; +end; + +function TfrxPreview.Get_PageNo(out Value: Integer): HResult; stdcall; +begin + Value := PageNo; + Result := S_OK; +end; + +function TfrxPreview.Set_PageNo(Value: Integer): HResult; stdcall; +begin + PageNo := Value; + Result := S_OK; +end; + +function TfrxPreview.Get_Tool(out Value: frxPreviewTool): HResult; stdcall; +begin + Value := frxPreviewTool(Tool); + Result := S_OK; +end; + +function TfrxPreview.Set_Tool(Value: frxPreviewTool): HResult; stdcall; +begin + Tool := TfrxPreviewTool(Value); + Result := S_OK; +end; + +function TfrxPreview.Get_Zoom(out Value: Double): HResult; stdcall; +begin + Value := Zoom; + Result := S_OK; +end; + +function TfrxPreview.Set_Zoom(Value: Double): HResult; stdcall; +begin + Zoom := Value; + Result := S_OK; +end; + +function TfrxPreview.Get_ZoomMode(out Value: frxZoomMode): HResult; stdcall; +begin + Value := frxZoomMode(ZoomMode); + Result := S_OK; +end; + +function TfrxPreview.Set_ZoomMode(Value: frxZoomMode): HResult; stdcall; +begin + ZoomMode := TfrxZoomMode(Value); + Result := S_OK; +end; + +function TfrxPreview.Get_OutlineVisible(out Value: WordBool): HResult; stdcall; +begin + Value := OutlineVisible; + Result := S_OK; +end; + +function TfrxPreview.Set_OutlineVisible(Value: WordBool): HResult; stdcall; +begin + OutlineVisible := Value; + Result := S_OK; +end; + +function TfrxPreview.Get_OutlineWidth(out Value: Integer): HResult; stdcall; +begin + Value := OutlineWidth; + Result := S_OK; +end; + +function TfrxPreview.Set_OutlineWidth(Value: Integer): HResult; stdcall; +begin + OutlineWidth := Value; + Result := S_OK; +end; + +function TfrxPreview.Get_Enabled(out Value: WordBool): HResult; stdcall; +begin + Value := Enabled; + Result := S_OK; +end; + +function TfrxPreview.Set_Enabled(Value: WordBool): HResult; stdcall; +begin + Enabled := Value; + Result := S_OK; +end; +{$ENDIF} + + +{ TfrxPreviewForm } + +procedure TfrxPreviewForm.FormCreate(Sender: TObject); +begin +{$IFDEF FR_COM} + Icon.Handle := LoadIcon(hInstance, 'SDESGNICON'); +{$ENDIF} + Caption := frxGet(100); + PrintB.Caption := frxGet(101); + PrintB.Hint := frxGet(102); + OpenB.Caption := frxGet(103); + OpenB.Hint := frxGet(104); + SaveB.Caption := frxGet(105); + SaveB.Hint := frxGet(106); + ExportB.Caption := frxGet(107); + ExportB.Hint := frxGet(108); + FindB.Caption := frxGet(109); + FindB.Hint := frxGet(110); + ZoomCB.Hint := frxGet(119); + PageSettingsB.Caption := frxGet(120); + PageSettingsB.Hint := frxGet(121); + DesignerB.Caption := frxGet(132); + DesignerB.Hint := frxGet(133); + {$IFDEF FR_LITE} + DesignerB.Hint := DesignerB.Hint + #13#10 + 'This feature is not available in FreeReport'; + {$ENDIF} + FirstB.Caption := frxGet(134); + FirstB.Hint := frxGet(135); + PriorB.Caption := frxGet(136); + PriorB.Hint := frxGet(137); + NextB.Caption := frxGet(138); + NextB.Hint := frxGet(139); + LastB.Caption := frxGet(140); + LastB.Hint := frxGet(141); + CancelB.Caption := frxResources.Get('clClose'); + PageE.Hint := frxGet(142); + FullScreenBtn.Hint := frxGet(150); + PdfB.Hint := frxGet(151); + EmailB.Hint := frxGet(152); + ZoomPlusB.Caption := frxGet(124); + ZoomPlusB.Hint := frxGet(125); + ZoomMinusB.Caption := frxGet(126); + ZoomMinusB.Hint := frxGet(127); + OutlineB.Caption := frxGet(128); + OutlineB.Hint := frxGet(129); + ThumbB.Caption := frxGet(130); + ThumbB.Hint := frxGet(131); + ZoomCB.Items.Clear; + ZoomCB.Items.Add('25%'); + ZoomCB.Items.Add('50%'); + ZoomCB.Items.Add('75%'); + ZoomCB.Items.Add('100%'); + ZoomCB.Items.Add('150%'); + ZoomCB.Items.Add('200%'); + ZoomCB.Items.Add(frxResources.Get('zmPageWidth')); + ZoomCB.Items.Add(frxResources.Get('zmWholePage')); + Toolbar.Images := frxResources.PreviewButtonImages; + ExpandMI.Caption := frxGet(600); + CollapseMI.Caption := frxGet(601); + + FPreview := TfrxPreview.Create(Self); + FPreview.Parent := Self; + FPreview.Align := alClient; + FPreview.BorderStyle := bsNone; + FPreview.BevelKind := bkNone; + FPreview.OnPageChanged := OnPageChanged; + FPreview.FWorkspace.OnDblClick := OnPreviewDblClick; + ActiveControl := FPreview; + SetWindowLong(PageE.Handle, GWL_STYLE, GetWindowLong(PageE.Handle, GWL_STYLE) or ES_NUMBER); + + if Screen.PixelsPerInch > 96 then + StatusBar.Height := 24; + + FFullScreen := False; + FPDFExport := nil; + FEmailExport := nil; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxPreviewForm.Init; +var + i, j, k: Integer; + m, e: TMenuItem; +begin + FPreview.Init; + with Report.PreviewOptions do + begin + if Maximized then + WindowState := wsMaximized; + if MDIChild then + FormStyle := fsMDIChild; + FPreview.Zoom := Zoom; + FPreview.ZoomMode := ZoomMode; + + {$IFDEF FR_LITE} + DesignerB.Enabled := False; + {$ELSE} + DesignerB.Enabled := AllowEdit; + {$ENDIF} + + PrintB.Visible := pbPrint in Buttons; + OpenB.Visible := pbLoad in Buttons; + SaveB.Visible := pbSave in Buttons; + ExportB.Visible := pbExport in Buttons; + FindB.Visible := pbFind in Buttons; + PdfB.Visible := False; + EmailB.Visible := False; + + ZoomPlusB.Visible := pbZoom in Buttons; + ZoomMinusB.Visible := pbZoom in Buttons; + Sep3.Visible := pbZoom in Buttons; + FullScreenBtn.Visible := (pbZoom in Buttons) and not (pbNoFullScreen in Buttons); + if not (pbZoom in Buttons) then + Sep1.Free; + + OutlineB.Visible := pbOutline in Buttons; + ThumbB.Visible := pbOutline in Buttons; + PageSettingsB.Visible := pbPageSetup in Buttons; + DesignerB.Visible := pbEdit in Buttons; + if not (PageSettingsB.Visible or DesignerB.Visible) then + Sep2.Free; + + FirstB.Visible := pbNavigator in Buttons; + PriorB.Visible := pbNavigator in Buttons; + NextB.Visible := pbNavigator in Buttons; + LastB.Visible := pbNavigator in Buttons; + Sep4.Visible := pbNavigator in Buttons; + if not (pbNavigator in Buttons) then + Sep5.Free; + + CancelB.Visible := not (pbNoClose in Buttons); + + Toolbar.ShowCaptions := ShowCaptions; + end; + + if (frxExportFilters.Count = 0) or + ((frxExportFilters.Count = 1) and (frxExportFilters[0].Filter = frxDotMatrixExport)) then + ExportB.Visible := False; + + for i := 0 to frxExportFilters.Count - 1 do + begin + if frxExportFilters[i].Filter = frxDotMatrixExport then + continue; + m := TMenuItem.Create(ExportPopup); + ExportPopup.Items.Add(m); + m.Caption := TfrxCustomExportFilter(frxExportFilters[i].Filter).GetDescription + '...'; + m.Tag := i; + m.OnClick := ExportMIClick; + if TfrxCustomExportFilter(frxExportFilters[i].Filter).ClassName = 'TfrxPDFExport' then + begin + FPDFExport := TfrxCustomExportFilter(frxExportFilters[i].Filter); + PdfB.Visible := pbExportQuick in Report.PreviewOptions.Buttons; + end; + if not (pbNoEmail in Report.PreviewOptions.Buttons) then + if TfrxCustomExportFilter(frxExportFilters[i].Filter).ClassName = 'TfrxMailExport' then + begin + FEmailExport := TfrxCustomExportFilter(frxExportFilters[i].Filter); + EmailB.Visible := pbExportQuick in Report.PreviewOptions.Buttons; + end; + end; + + if Report.ReportOptions.Name <> '' then + Caption := Report.ReportOptions.Name; + + k := 0; + + RightMenu.Images := ToolBar.Images; + for i := 0 to ToolBar.ButtonCount - 1 do + begin + if (ToolBar.Buttons[i].Style <> tbsCheck) and + (ToolBar.Buttons[i].Visible) and + (ToolBar.Buttons[i].Hint <> '') then + begin + m := TMenuItem.Create(RightMenu); + RightMenu.Items.Add(m); + ToolBar.Buttons[i].Tag := Integer(m); + m.Caption := ToolBar.Buttons[i].Hint; + m.OnClick := ToolBar.Buttons[i].OnClick; + m.ImageIndex := ToolBar.Buttons[i].ImageIndex; + if Assigned(ToolBar.Buttons[i].DropdownMenu) then + for j := 0 to ToolBar.Buttons[i].DropdownMenu.Items.Count - 1 do + begin + e := TMenuItem.Create(m); + e.Caption := ToolBar.Buttons[i].DropdownMenu.Items[j].Caption; + e.Tag := ToolBar.Buttons[i].DropdownMenu.Items[j].Tag; + e.OnClick := ToolBar.Buttons[i].DropdownMenu.Items[j].OnClick; + m.Add(e); + end; + end; + if ToolBar.Buttons[i].Style = tbsSeparator then + begin + if k = 1 then + break; + m := TMenuItem.Create(RightMenu); + RightMenu.Items.Add(m); + m.Caption := '-'; + Inc(k); + end; + end; + + PopupMenu := RightMenu; +end; + +procedure TfrxPreviewForm.UpdateControls; + + function HasDrillDown: Boolean; + var + l: TList; + i: Integer; + c: TfrxComponent; + begin + Result := False; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if (c is TfrxGroupHeader) and TfrxGroupHeader(c).DrillDown then + begin + Result := True; + break; + end; + end; + end; + + procedure EnableControls(cAr: array of TObject; Enabled: Boolean); + var + i: Integer; + begin + for i := 0 to High(cAr) do + begin + if cAr[i] is TMenuItem then + TMenuItem(cAr[i]).Visible := Enabled + else if cAr[i] is TToolButton then + begin + TToolButton(cAr[i]).Enabled := Enabled; + TToolButton(cAr[i]).Down := False; + if TToolButton(cAr[i]).Tag <> 0 then + TMenuItem(TToolButton(cAr[i]).Tag).Enabled := Enabled; + end; + end; + end; + +begin + EnableControls([PrintB, OpenB, SaveB, ExportB, PdfB, EmailB, FindB, PageSettingsB], + (not FPreview.FRunning) and (FPreview.PageCount > 0)); + EnableControls([DesignerB], + not FPreview.FRunning and Report.PreviewOptions.AllowEdit); + EnableControls([ExpandMI, CollapseMI, N1], + not FPreview.FRunning and HasDrillDown); +end; + +procedure TfrxPreviewForm.PrintBClick(Sender: TObject); +begin + FPreview.Print; + Enabled := True; +end; + +procedure TfrxPreviewForm.OpenBClick(Sender: TObject); +begin + FPreview.LoadFromFile; + if Report.ReportOptions.Name <> '' then + Caption := Report.ReportOptions.Name + else + Caption := frxGet(100); +end; + +procedure TfrxPreviewForm.SaveBClick(Sender: TObject); +begin + FPreview.SaveToFile; +end; + +procedure TfrxPreviewForm.FindBClick(Sender: TObject); +begin + FPreview.Find; +end; + +procedure TfrxPreviewForm.ZoomPlusBClick(Sender: TObject); +begin + FPreview.Zoom := FPreview.Zoom + 0.25; +end; + +procedure TfrxPreviewForm.ZoomMinusBClick(Sender: TObject); +begin + FPreview.Zoom := FPreview.Zoom - 0.25; +end; + +function TfrxPreviewForm.GetReport: TfrxReport; +begin + Result := Preview.Report; +end; + +procedure TfrxPreviewForm.UpdateZoom; +begin + ZoomCB.Text := IntToStr(Round(FPreview.Zoom * 100)) + '%'; +end; + +procedure TfrxPreviewForm.ZoomCBClick(Sender: TObject); +var + s: String; +begin + FPreview.SetFocus; + + if ZoomCB.ItemIndex = 6 then + FPreview.ZoomMode := zmPageWidth + else if ZoomCB.ItemIndex = 7 then + FPreview.ZoomMode := zmWholePage + else + begin + s := ZoomCB.Text; + + if Pos('%', s) <> 0 then + s[Pos('%', s)] := ' '; + while Pos(' ', s) <> 0 do + Delete(s, Pos(' ', s), 1); + + if s <> '' then + FPreview.Zoom := frxStrToFloat(s) / 100; + end; + + PostMessage(Handle, WM_UPDATEZOOM, 0, 0); +end; + +procedure TfrxPreviewForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_ESCAPE then + CancelBClick(Self); + if Key = VK_F11 then + SwitchToFullScreen; + if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxPreviewForm.FormKeyPress(Sender: TObject; var Key: Char); +begin + if Key = #13 then + begin + if ActiveControl = ZoomCB then + ZoomCBClick(nil); + if ActiveControl = PageE then + PageEClick(nil); + end; +end; + +procedure TfrxPreviewForm.WMUpdateZoom(var Message: TMessage); +begin + UpdateZoom; +end; + +procedure TfrxPreviewForm.PageSettingsBClick(Sender: TObject); +begin + FPreview.PageSetupDlg; +end; + +procedure TfrxPreviewForm.OnPageChanged(Sender: TfrxPreview; PageNo: Integer); +var + FirstPass: Boolean; +begin + FirstPass := False; + if FPreview.PreviewPages <> nil then + FirstPass := not FPreview.PreviewPages.Engine.FinalPass; + + if FirstPass and FPreview.FRunning then + StatusBar.Panels[0].Text := frxResources.Get('clFirstPass') + ' ' + + IntToStr(FPreview.PageCount) + else + StatusBar.Panels[0].Text := Format(frxResources.Get('clPageOf'), + [PageNo, FPreview.PageCount]); + PageE.Text := IntToStr(PageNo); +end; + +procedure TfrxPreviewForm.PageEClick(Sender: TObject); +begin + FPreview.PageNo := StrToInt(PageE.Text); + FPreview.SetFocus; +end; + +procedure TfrxPreviewForm.FirstBClick(Sender: TObject); +begin + FPreview.First; +end; + +procedure TfrxPreviewForm.PriorBClick(Sender: TObject); +begin + FPreview.Prior; +end; + +procedure TfrxPreviewForm.NextBClick(Sender: TObject); +begin + FPreview.Next; +end; + +procedure TfrxPreviewForm.LastBClick(Sender: TObject); +begin + FPreview.Last; +end; + +procedure TfrxPreviewForm.FormMouseWheel(Sender: TObject; + Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; + var Handled: Boolean); +begin + FPreview.MouseWheelScroll(WheelDelta, False, ssCtrl in Shift); +end; + +procedure TfrxPreviewForm.DesignerBClick(Sender: TObject); +begin + FPreview.Edit; +end; + +procedure TfrxPreviewForm.FormCloseQuery(Sender: TObject; + var CanClose: Boolean); +begin + CanClose := not FPreview.FRunning; +end; + +procedure TfrxPreviewForm.FormClose(Sender: TObject; var Action: TCloseAction); +begin + if FFreeOnClose then + Action := caFree; + if Assigned(Report.OnClosePreview) then + Report.OnClosePreview(Self); +end; + +procedure TfrxPreviewForm.NewPageBClick(Sender: TObject); +begin + FPreview.AddPage; +end; + +procedure TfrxPreviewForm.DelPageBClick(Sender: TObject); +begin + FPreview.DeletePage; +end; + +procedure TfrxPreviewForm.CancelBClick(Sender: TObject); +begin + if FPreview.FRunning then + FPreview.Cancel else + Close; +end; + +procedure TfrxPreviewForm.ExportMIClick(Sender: TObject); +begin + FPreview.Export(TfrxCustomExportFilter(frxExportFilters[TMenuItem(Sender).Tag].Filter)); + Enabled := True; +end; + +procedure TfrxPreviewForm.DesignerBMouseUp(Sender: TObject; + Button: TMouseButton; Shift: TShiftState; X, Y: Integer); +var + pt: TPoint; +begin + pt := DesignerB.ClientToScreen(Point(0, 0)); + if Button = mbRight then + HiddenMenu.Popup(pt.X, pt.Y); +end; + +procedure TfrxPreviewForm.Showtemplate1Click(Sender: TObject); +begin + FPreview.EditTemplate; +end; + +procedure TfrxPreviewForm.SetMessageText(const Value: String); +begin + StatusBar.Panels[1].Text := Value; + Application.ProcessMessages; +end; + +procedure TfrxPreviewForm.SwitchToFullScreen; +begin + if not FFullScreen then + begin + StatusBar.Visible := False; + ToolBar.Visible := False; + FOldBS := BorderStyle; + FOldState := WindowState; + BorderStyle := bsNone; + WindowState := wsMaximized; + FFullScreen := True; + end + else + begin + WindowState := FOldState; + BorderStyle := FOldBS; + FFullScreen := False; + StatusBar.Visible := True; + ToolBar.Visible := True; + end; +end; + +procedure TfrxPreviewForm.FullScreenBtnClick(Sender: TObject); +begin + SwitchToFullScreen; +end; + +procedure TfrxPreviewForm.PdfBClick(Sender: TObject); +begin + if Assigned(FPDFExport) then + FPreview.Export(FPDFExport); +end; + +procedure TfrxPreviewForm.EmailBClick(Sender: TObject); +begin + if Assigned(FEmailExport) then + FPreview.Export(FEmailExport); +end; + +procedure TfrxPreviewForm.WMActivateApp(var Msg: TWMActivateApp); +begin + if IsIconic(Application.Handle) then + begin + ShowWindow(Application.Handle, SW_RESTORE); + SetActiveWindow(Handle); + end; + inherited; +end; + +procedure TfrxPreviewForm.WMSysCommand(var Msg: TWMSysCommand); +begin + if Msg.CmdType = SC_MINIMIZE then + if not Report.PreviewOptions.MDIChild then + ShowWindow(Application.Handle, SW_MINIMIZE) + else + inherited + else + inherited; +end; + +procedure TfrxPreviewForm.OutlineBClick(Sender: TObject); +begin + FPreview.OutlineVisible := OutlineB.Down; +end; + +procedure TfrxPreviewForm.ThumbBClick(Sender: TObject); +begin + FPreview.ThumbnailVisible := ThumbB.Down; +end; + +procedure TfrxPreviewForm.OnPreviewDblClick(Sender: TObject); +begin + if FFullScreen then + SwitchToFullScreen; +end; + +procedure TfrxPreviewForm.CollapseAllClick(Sender: TObject); +var + l: TList; + i: Integer; + c: TfrxComponent; +begin + FPreview.Lock; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if (c is TfrxGroupHeader) and TfrxGroupHeader(c).DrillDown then + TfrxGroupHeader(c).ExpandDrillDown := False; + end; + Report.DrillState.Clear; + Preview.RefreshReport; +end; + +procedure TfrxPreviewForm.ExpandAllClick(Sender: TObject); +var + l: TList; + i: Integer; + c: TfrxComponent; +begin + FPreview.Lock; + l := Report.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if (c is TfrxGroupHeader) and TfrxGroupHeader(c).DrillDown then + TfrxGroupHeader(c).ExpandDrillDown := True; + end; + Report.DrillState.Clear; + Preview.RefreshReport; +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPreview.res b/official/4.2/LibD11/frxPreview.res new file mode 100644 index 0000000..358bacf Binary files /dev/null and b/official/4.2/LibD11/frxPreview.res differ diff --git a/official/4.2/LibD11/frxPreviewPageSettings.dfm b/official/4.2/LibD11/frxPreviewPageSettings.dfm new file mode 100644 index 0000000..a88bcab Binary files /dev/null and b/official/4.2/LibD11/frxPreviewPageSettings.dfm differ diff --git a/official/4.2/LibD11/frxPreviewPageSettings.pas b/official/4.2/LibD11/frxPreviewPageSettings.pas new file mode 100644 index 0000000..d21a881 --- /dev/null +++ b/official/4.2/LibD11/frxPreviewPageSettings.pas @@ -0,0 +1,257 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Preview Page settings } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPreviewPageSettings; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ExtCtrls, StdCtrls, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxDesignerUnits = (duCM, duInches, duPixels, duChars); + + TfrxPageSettingsForm = class(TForm) + OKB: TButton; + CancelB: TButton; + SizeL: TGroupBox; + WidthL: TLabel; + HeightL: TLabel; + UnitL1: TLabel; + UnitL2: TLabel; + WidthE: TEdit; + HeightE: TEdit; + SizeCB: TComboBox; + OrientationL: TGroupBox; + PortraitImg: TImage; + LandscapeImg: TImage; + PortraitRB: TRadioButton; + LandscapeRB: TRadioButton; + MarginsL: TGroupBox; + LeftL: TLabel; + TopL: TLabel; + RightL: TLabel; + BottomL: TLabel; + UnitL3: TLabel; + UnitL4: TLabel; + UnitL5: TLabel; + UnitL6: TLabel; + MarginLeftE: TEdit; + MarginTopE: TEdit; + MarginRightE: TEdit; + MarginBottomE: TEdit; + OtherL: TGroupBox; + ApplyToCurRB: TRadioButton; + ApplyToAllRB: TRadioButton; + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure PortraitRBClick(Sender: TObject); + procedure SizeCBClick(Sender: TObject); + procedure WidthEChange(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + FPage: TfrxReportPage; + FReport: TfrxReport; + FUnits: TfrxDesignerUnits; + FUpdating: Boolean; + function GetNeedRebuild: Boolean; + function mmToUnits(mm: Extended): Extended; + function UnitsTomm(mm: Extended): Extended; + public + { Public declarations } + property NeedRebuild: Boolean read GetNeedRebuild; + property Page: TfrxReportPage read FPage write FPage; + property Report: TfrxReport read FReport write FReport; + end; + + +implementation + +{$R *.DFM} + +uses Printers, frxPrinter, frxUtils, frxRes, IniFiles; + + +function TfrxPageSettingsForm.mmToUnits(mm: Extended): Extended; +begin + Result := 0; + case FUnits of + duCM, duPixels, duChars: + Result := mm / 10; + duInches: + Result := mm / 25.4; + end; +end; + +function TfrxPageSettingsForm.UnitsTomm(mm: Extended): Extended; +begin + Result := 0; + case FUnits of + duCM, duPixels, duChars: + Result := mm * 10; + duInches: + Result := mm * 25.4; + end; +end; + +function TfrxPageSettingsForm.GetNeedRebuild: Boolean; +begin + Result := ApplyToAllRB.Checked; +end; + +procedure TfrxPageSettingsForm.FormShow(Sender: TObject); +var + i: Integer; + Ini: TCustomIniFile; + uStr: String; +begin + FUpdating := True; + + Caption := frxGet(400); + WidthL.Caption := frxGet(401); + HeightL.Caption := frxGet(402); + SizeL.Caption := frxGet(403); + OrientationL.Caption := frxGet(404); + LeftL.Caption := frxGet(405); + TopL.Caption := frxGet(406); + RightL.Caption := frxGet(407); + BottomL.Caption := frxGet(408); + MarginsL.Caption := frxGet(409); + PortraitRB.Caption := frxGet(410); + LandscapeRB.Caption := frxGet(411); + OKB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + OtherL.Caption := frxGet(412); + ApplyToCurRB.Caption := frxGet(413); + ApplyToAllRB.Caption := frxGet(414); + + Ini := Report.GetIniFile; + FUnits := TfrxDesignerUnits(Ini.ReadInteger('Form.TfrxDesignerForm', 'Units', 0)); + Ini.Free; + + uStr := ''; + case FUnits of + duCM, duPixels, duChars: + uStr := frxResources.Get('uCm'); + duInches: + uStr := frxResources.Get('uInch'); + end; + + UnitL1.Caption := uStr; + UnitL2.Caption := uStr; + UnitL3.Caption := uStr; + UnitL4.Caption := uStr; + UnitL5.Caption := uStr; + UnitL6.Caption := uStr; + + SizeCB.Items := frxPrinters.Printer.Papers; + i := frxPrinters.Printer.PaperIndex(Page.PaperSize); + if i = -1 then + i := frxPrinters.Printer.PaperIndex(256); + SizeCB.ItemIndex := i; + + WidthE.Text := frxFloatToStr(mmToUnits(Page.PaperWidth)); + HeightE.Text := frxFloatToStr(mmToUnits(Page.PaperHeight)); + PortraitRB.Checked := Page.Orientation = poPortrait; + LandscapeRB.Checked := Page.Orientation = poLandscape; + + MarginLeftE.Text := frxFloatToStr(mmToUnits(Page.LeftMargin)); + MarginRightE.Text := frxFloatToStr(mmToUnits(Page.RightMargin)); + MarginTopE.Text := frxFloatToStr(mmToUnits(Page.TopMargin)); + MarginBottomE.Text := frxFloatToStr(mmToUnits(Page.BottomMargin)); + + PortraitRBClick(nil); + FUpdating := False; +end; + +procedure TfrxPageSettingsForm.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + begin + if PortraitRB.Checked then + Page.Orientation := poPortrait else + Page.Orientation := poLandscape; + + Page.PaperWidth := UnitsTomm(frxStrToFloat(WidthE.Text)); + Page.PaperHeight := UnitsTomm(frxStrToFloat(HeightE.Text)); + Page.PaperSize := frxPrinters.Printer.PaperNameToNumber(SizeCB.Text); + + Page.LeftMargin := UnitsTomm(frxStrToFloat(MarginLeftE.Text)); + Page.RightMargin := UnitsTomm(frxStrToFloat(MarginRightE.Text)); + Page.TopMargin := UnitsTomm(frxStrToFloat(MarginTopE.Text)); + Page.BottomMargin := UnitsTomm(frxStrToFloat(MarginBottomE.Text)); + + Page.AlignChildren; + end; +end; + +procedure TfrxPageSettingsForm.PortraitRBClick(Sender: TObject); +begin + PortraitImg.Visible := PortraitRB.Checked; + LandscapeImg.Visible := LandscapeRB.Checked; + SizeCBClick(nil); +end; + +procedure TfrxPageSettingsForm.SizeCBClick(Sender: TObject); +var + pOr: TPrinterOrientation; + pNumber: Integer; + pWidth, pHeight: Extended; +begin + if FUpdating then Exit; + FUpdating := True; + + with frxPrinters.Printer do + begin + pNumber := PaperNameToNumber(SizeCB.Text); + pWidth := UnitsTomm(frxStrToFloat(WidthE.Text)); + pHeight := UnitsTomm(frxStrToFloat(HeightE.Text)); + if PortraitRB.Checked then + pOr := poPortrait else + pOr := poLandscape; + + if pNumber = 256 then + SetViewParams(pNumber, pHeight, pWidth, pOr) else + SetViewParams(pNumber, pWidth, pHeight, pOr); + + WidthE.Text := frxFloatToStr(mmToUnits(PaperWidth)); + HeightE.Text := frxFloatToStr(mmToUnits(PaperHeight)); + end; + + FUpdating := False; +end; + +procedure TfrxPageSettingsForm.WidthEChange(Sender: TObject); +begin + if not FUpdating then + SizeCB.ItemIndex := 0; +end; + +procedure TfrxPageSettingsForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPreviewPages.pas b/official/4.2/LibD11/frxPreviewPages.pas new file mode 100644 index 0000000..5149a31 --- /dev/null +++ b/official/4.2/LibD11/frxPreviewPages.pas @@ -0,0 +1,2326 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Preview Pages } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPreviewPages; + +interface + +{$I frx.inc} + +uses + Windows, SysUtils, Messages, Classes, Graphics, Controls, Forms, Dialogs, + frxClass, frxXML, frxPictureCache +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxOutline = class(TfrxCustomOutline) + private + protected + function GetCount: Integer; override; + public + function Root: TfrxXMLItem; + procedure AddItem(const Text: String; Top: Integer); override; + procedure LevelDown(Index: Integer); override; + procedure LevelRoot; override; + procedure LevelUp; override; + procedure GetItem(Index: Integer; var Text: String; + var Page, Top: Integer); override; + procedure ShiftItems(From: TfrxXMLItem; NewTop: Integer); override; + function GetCurPosition: TfrxXMLItem; override; + end; + + TfrxDictionary = class(TObject) + private + FNames: TStringList; + FSourceNames: TStringList; + public + constructor Create; + destructor Destroy; override; + procedure Add(const Name, SourceName: String; Obj: TObject); + procedure Clear; + function AddUnique(const Base, SourceName: String; Obj: TObject): String; + function CreateUniqueName(const Base: String): String; + function GetSourceName(const Name: String): String; + function GetObject(const Name: String): TObject; + property Names: TStringList read FNames; + property SourceNames: TStringList read FSourceNames; + end; + + TfrxPreviewPages = class(TfrxCustomPreviewPages) + private + FAllowPartialLoading: Boolean; + FCopyNo: Integer; + FDictionary: TfrxDictionary; { list of all objects } + FFirstObjectIndex: Integer; { used in the ClearFirstPassPages } + FFirstPageIndex: Integer; { used in the ClearFirstPassPages } + FLogicalPageN: Integer; + FPageCache: TStringList; { last 20 TfrxPreviewPage } + FPagesItem: TfrxXMLItem; { shortcut to XMLDoc.Root.FindName('previewpages') } + FPictureCache: TfrxPictureCache; + FPrintScale: Extended; + FSourcePages: TList; { list of source pages } + FTempStream: TStream; + FXMLDoc: TfrxXMLDocument; { parsed FP3 document } + FXMLSize: Integer; + procedure AfterLoad; + procedure BeforeSave; + procedure ClearPageCache; + procedure ClearSourcePages; + function CurXMLPage: TfrxXMLItem; + function GetObject(const Name: String): TfrxComponent; + procedure DoLoadFromStream; + procedure DoSaveToStream; + protected + function GetCount: Integer; override; + function GetPage(Index: Integer): TfrxReportPage; override; + function GetPageSize(Index: Integer): TPoint; override; + public + constructor Create(AReport: TfrxReport); override; + destructor Destroy; override; + procedure Clear; override; + procedure Initialize; override; + + { engine commands } + procedure AddAnchor(const Text: String); + procedure AddObject(Obj: TfrxComponent); override; + procedure AddPage(Page: TfrxReportPage); override; + procedure AddPicture(Picture: TfrxPictureView); override; + procedure AddSourcePage(Page: TfrxReportPage); override; + procedure AddToSourcePage(Obj: TfrxComponent); override; + procedure BeginPass; override; + procedure ClearFirstPassPages; override; + procedure CutObjects(APosition: Integer); override; + procedure Finish; override; + procedure IncLogicalPageNumber; override; + procedure ResetLogicalPageNumber; override; + procedure PasteObjects(X, Y: Extended); override; + procedure ShiftAnchors(From, NewTop: Integer); override; + procedure UpdatePageDimensions(Page: TfrxReportPage; Width, Height: Extended); + function BandExists(Band: TfrxBand): Boolean; override; + function FindAnchor(const Text: String): TfrxXMLItem; + function GetAnchorPage(const Text: String): Integer; + function GetAnchorCurPosition: Integer; override; + function GetCurPosition: Integer; override; + function GetLastY: Extended; override; + function GetLogicalPageNo: Integer; override; + function GetLogicalTotalPages: Integer; override; + + { preview commands } + procedure DrawPage(Index: Integer; Canvas: TCanvas; ScaleX, ScaleY, + OffsetX, OffsetY: Extended); override; + procedure AddEmptyPage(Index: Integer); override; + procedure DeletePage(Index: Integer); override; + procedure ModifyPage(Index: Integer; Page: TfrxReportPage); override; + procedure AddFrom(Report: TfrxReport); override; + procedure LoadFromStream(Stream: TStream; + AllowPartialLoading: Boolean = False); override; + procedure SaveToStream(Stream: TStream); override; + function LoadFromFile(const FileName: String; + ExceptionIfNotFound: Boolean = False): Boolean; override; + procedure SaveToFile(const FileName: String); override; + function Print: Boolean; override; + function Export(Filter: TfrxCustomExportFilter): Boolean; override; + procedure ObjectOver(Index: Integer; X, Y: Integer; Button: TMouseButton; + Shift: TShiftState; Scale, OffsetX, OffsetY: Extended; + Click: Boolean; var Cursor: TCursor); override; + property SourcePages: TList read FSourcePages; + end; + + +implementation + +uses + frxPreview, Printers, frxPrinter, frxPrintDialog, frxXMLSerializer, frxUtils, + ShellApi, frxDMPClass, frxRes; + +type + THackComponent = class(TfrxComponent); + THackMemoView = class(TfrxCustomMemoView); + THackThread = class(TThread); + +{$IFDEF TRIAL} +const + FR_UNREG = ')segap 5 ylno( noisrev deretsigernU - tropeRtsaF'; +{$ENDIF} + +{ TfrxOutline } + +procedure TfrxOutline.AddItem(const Text: String; Top: Integer); +begin + CurItem := CurItem.Add; + CurItem.Name := 'item'; + CurItem.Text := 'text="' + frxStrToXML(Text) + + '" page="' + IntToStr(PreviewPages.CurPage) + + '" top="' + IntToStr(Top) + '"'; +end; + +procedure TfrxOutline.GetItem(Index: Integer; var Text: String; var Page, + Top: Integer); +var + Item: TfrxXMLItem; + s: String; +begin + Item := CurItem[Index]; + Text := Item.Prop['text']; + + s := Item.Prop['page']; + if s <> '' then + Page := StrToInt(s); + + s := Item.Prop['top']; + if s <> '' then + Top := StrToInt(s); +end; + +procedure TfrxOutline.LevelDown(Index: Integer); +begin + CurItem := CurItem[Index]; +end; + +procedure TfrxOutline.LevelRoot; +begin + CurItem := Root; +end; + +procedure TfrxOutline.LevelUp; +begin + if CurItem <> Root then + CurItem := CurItem.Parent; +end; + +function TfrxOutline.Root: TfrxXMLItem; +begin + Result := TfrxPreviewPages(PreviewPages).FXMLDoc.Root.FindItem('outline'); +end; + +function TfrxOutline.GetCount: Integer; +begin + if CurItem = nil then + Result := 0 + else + Result := CurItem.Count; +end; + +procedure TfrxOutline.ShiftItems(From: TfrxXMLItem; NewTop: Integer); +var + i, TopY, CorrY: Integer; + + procedure EnumItems(Item: TfrxXMLItem); + var + i: Integer; + begin + Item.Prop['page'] := IntToStr(StrToInt(Item.Prop['page']) + 1); + Item.Prop['top'] := IntToStr(StrToInt(Item.Prop['top']) + CorrY); + for i := 0 to Item.Count - 1 do + EnumItems(Item[i]); + end; + +begin + if From = nil then Exit; + i := From.Parent.IndexOf(From); + if i + 1 >= From.Parent.Count then Exit; + From := From.Parent[i + 1]; + + TopY := StrToInt(From.Prop['top']); + CorrY := NewTop - TopY; + EnumItems(From); +end; + +function TfrxOutline.GetCurPosition: TfrxXMLItem; +begin + if Count = 0 then + Result := nil else + Result := CurItem[Count - 1]; +end; + + +{ TfrxDictionary } + +constructor TfrxDictionary.Create; +begin + FNames := TStringList.Create; + FNames.Sorted := True; + FSourceNames := TStringList.Create; +end; + +destructor TfrxDictionary.Destroy; +begin + FNames.Free; + FSourceNames.Free; + inherited; +end; + +procedure TfrxDictionary.Clear; +begin + FNames.Clear; + FSourceNames.Clear; +end; + +procedure TfrxDictionary.Add(const Name, SourceName: String; Obj: TObject); +var + i: Integer; +begin + i := FSourceNames.AddObject(SourceName, Obj); + FNames.AddObject(Name, TObject(i)); +end; + +function TfrxDictionary.AddUnique(const Base, SourceName: String; Obj: TObject): String; +begin + Result := CreateUniqueName(Base); + Add(Result, SourceName, Obj); +end; + +function TfrxDictionary.CreateUniqueName(const Base: String): String; +var + i: Integer; +begin + i := 10000; + while (i > 1) and (FNames.IndexOf(Base + IntToStr(i)) = -1) do + i := i div 2; + while FNames.IndexOf(Base + IntToStr(i)) <> -1 do + Inc(i); + Result := Base + IntToStr(i); +end; + +function TfrxDictionary.GetObject(const Name: String): TObject; +var + i: Integer; +begin + Result := nil; + i := FNames.IndexOf(Name); + if i <> -1 then + Result := FSourceNames.Objects[Integer(FNames.Objects[i])]; +end; + +function TfrxDictionary.GetSourceName(const Name: String): String; +var + i: Integer; +begin + Result := ''; + i := FNames.IndexOf(Name); + if i <> -1 then + Result := FSourceNames[Integer(FNames.Objects[i])]; +end; + + +{ TfrxPreviewPages } + +constructor TfrxPreviewPages.Create(AReport: TfrxReport); +begin + inherited; + FDictionary := TfrxDictionary.Create; + FSourcePages := TList.Create; + FXMLDoc := TfrxXMLDocument.Create; + FXMLDoc.Root.Name := 'preparedreport'; +// FXMLDoc.AutoIndent := True; + FPageCache := TStringList.Create; + FPictureCache := TfrxPictureCache.Create; +end; + +destructor TfrxPreviewPages.Destroy; +begin + ClearPageCache; + FPageCache.Free; + FDictionary.Free; + ClearSourcePages; + FPictureCache.Free; + FSourcePages.Free; + FXMLDoc.Free; + inherited; +end; + +procedure TfrxPreviewPages.Clear; +begin + ClearPageCache; + ClearSourcePages; + FXMLDoc.Clear; + FDictionary.Clear; + FPictureCache.Clear; + CurPage := -1; + FXMLSize := 0; +end; + +procedure TfrxPreviewPages.Initialize; +begin + FXMLDoc.TempDir := Report.EngineOptions.TempDir; + Report.InternalOnProgressStart(ptRunning); +end; + +procedure TfrxPreviewPages.ClearPageCache; +begin + while FPageCache.Count > 0 do + begin + TfrxReportPage(FPageCache.Objects[0]).Free; + FPageCache.Delete(0); + end; +end; + +procedure TfrxPreviewPages.ClearSourcePages; +begin + while FSourcePages.Count > 0 do + begin + TfrxReportPage(FSourcePages[0]).Free; + FSourcePages.Delete(0); + end; +end; + +procedure TfrxPreviewPages.BeginPass; +begin + FFirstPageIndex := Count - 1; + if FFirstPageIndex <> -1 then + FFirstObjectIndex := FXMLDoc.Root.FindItem('previewpages')[FFirstPageIndex].Count; + ResetLogicalPageNumber; +end; + +procedure TfrxPreviewPages.ClearFirstPassPages; +var + PagesRoot: TfrxXMLItem; + p: TfrxXMLItem; + i: Integer; +begin + if FFirstPageIndex = -1 then + begin + for i := 0 to FXMLDoc.Root.Count - 1 do + if (CompareText(FXMLDoc.Root[i].Name, 'anchors') <> 0) and + (CompareText(FXMLDoc.Root[i].Name, 'logicalpagenumbers') <> 0) then + FXMLDoc.Root[i].Clear; + end + else + begin + PagesRoot := FXMLDoc.Root.FindItem('previewpages'); + p := PagesRoot[FFirstPageIndex]; + { clear some objects on first page } + while p.Count > FFirstObjectIndex do + p[FFirstObjectIndex].Free; + { clear remained pages } + while Count > FFirstPageIndex + 1 do + PagesRoot[FFirstPageIndex + 1].Free; + end; + + ResetLogicalPageNumber; + CurPage := FFirstPageIndex; + FXMLSize := 0; +end; + +function TfrxPreviewPages.CurXMLPage: TfrxXMLItem; +begin + Result := FXMLDoc.Root.FindItem('previewpages'); + Result := Result[CurPage]; +end; + +function TfrxPreviewPages.GetCount: Integer; +begin + Result := FXMLDoc.Root.FindItem('previewpages').Count; +end; + +function TfrxPreviewPages.GetCurPosition: Integer; +begin + Result := CurXMLPage.Count; +end; + +procedure TfrxPreviewPages.AddAnchor(const Text: String); +var + AnchorRoot, Item: TfrxXMLItem; +begin + AnchorRoot := FXMLDoc.Root.FindItem('anchors'); + Item := AnchorRoot.Add; + Item.Name := 'item'; + Item.Text := 'text="' + frxStrToXML(Text) + + '" page="' + IntToStr(CurPage) + + '" top="' + IntToStr(Round(Engine.CurY)) + '"'; +end; + +function TfrxPreviewPages.FindAnchor(const Text: String): TfrxXMLItem; +var + AnchorRoot, Item: TfrxXMLItem; + i: Integer; +begin + Result := nil; + AnchorRoot := FXMLDoc.Root.FindItem('anchors'); + for i := AnchorRoot.Count - 1 downto 0 do + begin + Item := AnchorRoot[i]; + if AnsiCompareText(Item.Prop['text'], Text) = 0 then + begin + Result := Item; + Exit; + end; + end; +end; + +function TfrxPreviewPages.GetAnchorPage(const Text: String): Integer; +var + Item: TfrxXMLItem; +begin + Item := FindAnchor(Text); + if Item <> nil then + Result := StrToInt(Item.Prop['page']) + 1 else + Result := 1; +end; + +function TfrxPreviewPages.GetAnchorCurPosition: Integer; +begin + Result := FXMLDoc.Root.FindItem('anchors').Count - 1; +end; + +procedure TfrxPreviewPages.ShiftAnchors(From, NewTop: Integer); +var + i, CorrY: Integer; + AnchorRoot, Item: TfrxXMLItem; +begin + AnchorRoot := FXMLDoc.Root.FindItem('anchors'); + if (From + 1 < 0) or (From + 1 >= AnchorRoot.Count) then Exit; + + Item := AnchorRoot[From + 1]; + CorrY := NewTop - StrToInt(Item.Prop['top']); + + for i := From + 1 to AnchorRoot.Count - 1 do + begin + Item := AnchorRoot[i]; + Item.Prop['page'] := IntToStr(StrToInt(Item.Prop['page']) + 1); + Item.Prop['top'] := IntToStr(StrToInt(Item.Prop['top']) + CorrY); + end; +end; + +procedure TfrxPreviewPages.IncLogicalPageNumber; +var + xi: TfrxXMLItem; +begin + if Engine.FinalPass and Engine.DoublePass then Exit; + + Inc(FLogicalPageN); + xi := FXMLDoc.Root.FindItem('logicalpagenumbers').Add; + xi.Name := 'page'; + xi.Prop['n'] := IntToStr(FLogicalPageN); +end; + +procedure TfrxPreviewPages.ResetLogicalPageNumber; +var + i: Integer; + xi, pageItem: TfrxXMLItem; +begin + if Engine.FinalPass and Engine.DoublePass then Exit; + + pageItem := FXMLDoc.Root.FindItem('logicalpagenumbers'); + for i := CurPage downto FFirstPageIndex + 1 do + begin + if (i < 0) or (i >= pageItem.Count) then continue; + xi := pageItem[i]; + xi.Prop['t'] := IntToStr(FLogicalPageN); + if xi.Prop['n'] = '1' then + break; + end; + FLogicalPageN := 0; +end; + +function TfrxPreviewPages.GetLogicalPageNo: Integer; +var + xi: TfrxXMLItem; +begin + xi := FXMLDoc.Root.FindItem('logicalpagenumbers'); + if (CurPage < 0) or (CurPage >= xi.Count) then + Result := CurPage - FirstPage + 1 + else + begin + xi := xi[CurPage]; + Result := StrToInt(xi.Prop['n']); + end; +end; + +function TfrxPreviewPages.GetLogicalTotalPages: Integer; +var + xi: TfrxXMLItem; +begin + xi := FXMLDoc.Root.FindItem('logicalpagenumbers'); + if (CurPage < 0) or (CurPage >= xi.Count) then + Result := Engine.TotalPages - FirstPage + else + begin + xi := xi[CurPage]; + if xi.Prop['t'] <> '' then + Result := StrToInt(xi.Prop['t']) + else + Result := 0; + end; +end; + +procedure TfrxPreviewPages.AddObject(Obj: TfrxComponent); + + procedure DoAdd(c: TfrxComponent; Item: TfrxXMLItem); + var + i: Integer; + begin + if (not c.Visible) or not (csPreviewVisible in c.frComponentStyle) then Exit; + + with THackComponent(c) do + begin + Item := Item.Add; + { the component that was created after report has been started } + if FOriginalComponent = nil then + begin + Item.Name := ClassName; + Item.Text := AllDiff(nil); + end + else + begin + { the component that exists in the report template } + Item.Name := FAliasName; + if Engine.FinalPass then + begin + if csDefaultDiff in frComponentStyle then + Item.Text := AllDiff(FOriginalComponent) else + Item.Text := Diff(FOriginalComponent); + end + else + { we don't need to output all info on the first pass, only coordinates } + Item.Text := InternalDiff(FOriginalComponent); + end; + Inc(FXMLSize, Length(Item.Name) + Length(Item.Text) + Item.InstanceSize + 16); + end; + + for i := 0 to c.Objects.Count - 1 do + DoAdd(c.Objects[i], Item); + end; + +begin + DoAdd(Obj, CurXMLPage); +end; + +procedure TfrxPreviewPages.AddPage(Page: TfrxReportPage); +var + xi: TfrxXMLItem; + + procedure UnloadPages; + var + i: Integer; + begin + if Report.EngineOptions.UseFileCache then + if FXMLSize > Report.EngineOptions.MaxMemSize * 1024 * 1024 then + begin + for i := xi.Count - 2 downto 0 do + if xi[i].Loaded then + FXMLDoc.UnloadItem(xi[i]) else + break; + FXMLSize := 0; + end; + end; + + function GetSourceNo(Page: TfrxReportPage): Integer; + var + i: Integer; + begin + Result := -1; + for i := 0 to FSourcePages.Count - 1 do + if THackComponent(FSourcePages[i]).FOriginalComponent = Page then + begin + Result := i; + break; + end; + end; + +begin + FPagesItem := FXMLDoc.Root.FindItem('previewpages'); + xi := FPagesItem; + UnloadPages; + + CurPage := CurPage + 1; + if (CurPage >= Count) or (AddPageAction = apAdd) then + begin + xi := xi.Add; + xi.Name := 'page' + IntToStr(GetSourceNo(Page)); + if Count > 2 then + xi.Unloadable := True; + Report.InternalOnProgress(ptRunning, CurPage + 1); + AddPageAction := apWriteOver; + CurPage := Count - 1; + IncLogicalPageNumber; + end; +end; + +procedure TfrxPreviewPages.AddSourcePage(Page: TfrxReportPage); +var + p: TfrxReportPage; + xs: TfrxXMLSerializer; + xi: TfrxXMLItem; + i: Integer; + originals, copies: TList; + c1, c2: TfrxComponent; + s, s1: String; + + function EnumObjects(Parent, Parent1: TfrxComponent): TfrxComponent; + var + i: Integer; + c: TfrxComponent; + begin + Result := nil; + if not (csPreviewVisible in Parent.frComponentStyle) then Exit; + + c := TfrxComponent(Parent.NewInstance); + c.Create(Parent1); + if Parent is TfrxPictureView then + TfrxPictureView(Parent).IsPictureStored := False; + c.Assign(Parent); + if Parent is TfrxPictureView then + TfrxPictureView(Parent).IsPictureStored := True; + c.Name := Parent.Name; + originals.Add(Parent); + copies.Add(c); + + for i := 0 to Parent.Objects.Count - 1 do + EnumObjects(Parent.Objects[i], c); + Result := c; + end; + +begin + xs := TfrxXMLSerializer.Create(nil); + xi := TfrxXMLItem.Create; + originals := TList.Create; + copies := TList.Create; + + try + p := TfrxReportPage(EnumObjects(Page, nil)); + THackComponent(p).FOriginalComponent := Page; + FSourcePages.Add(p); + + for i := 1 to copies.Count - 1 do + begin + c1 := copies[i]; + c2 := originals[i]; + + THackComponent(c2).FOriginalComponent := c1; + THackComponent(c1).FOriginalComponent := c2; + + if c1 is TfrxBand then + s := 'b' else + s := LowerCase(c1.BaseName[1]); + s := FDictionary.AddUnique(s, 'Page' + IntToStr(FSourcePages.Count - 1) + + '.' + c1.Name, c1); + // speed optimization + if c1 is TfrxCustomMemoView then + begin + TfrxCustomMemoView(c1).DataSet := nil; + TfrxCustomMemoView(c1).DataField := ''; + end; + if csDefaultDiff in c1.frComponentStyle then + s1 := c1.ClassName + else + s1 := xs.WriteComponentStr(c1); + THackComponent(c1).FBaseName := s1; + THackComponent(c1).FAliasName := s; + THackComponent(c2).FAliasName := s; + end; + + finally + originals.Free; + copies.Free; + xs.Free; + xi.Free; + end; +end; + +procedure TfrxPreviewPages.AddPicture(Picture: TfrxPictureView); +begin + FPictureCache.AddPicture(Picture); +end; + +procedure TfrxPreviewPages.AddToSourcePage(Obj: TfrxComponent); +var + NewObj: TfrxComponent; + Page: TfrxReportPage; + s: String; + xs: TfrxXMLSerializer; +begin + xs := TfrxXMLSerializer.Create(nil); + Page := FSourcePages[FSourcePages.Count - 1]; + NewObj := TfrxComponent(Obj.NewInstance); + NewObj.Create(Page); + NewObj.Assign(Obj); + NewObj.CreateUniqueName; + + s := FDictionary.AddUnique(LowerCase(NewObj.BaseName[1]), + 'Page' + IntToStr(FSourcePages.Count - 1) + '.' + NewObj.Name, NewObj); + if csDefaultDiff in NewObj.frComponentStyle then + THackComponent(NewObj).FBaseName := NewObj.ClassName else + THackComponent(NewObj).FBaseName := xs.WriteComponentStr(NewObj); + + THackComponent(Obj).FOriginalComponent := NewObj; + THackComponent(Obj).FAliasName := s; + THackComponent(NewObj).FAliasName := s; + xs.Free; +end; + +procedure TfrxPreviewPages.UpdatePageDimensions(Page: TfrxReportPage; Width, Height: Extended); +var + SourcePage: TfrxReportPage; + xi: TfrxXMLItem; + i: Integer; +begin + SourcePage := nil; + for i := 0 to FSourcePages.Count - 1 do + begin + SourcePage := FSourcePages[i]; + if THackComponent(SourcePage).FOriginalComponent = Page then + break; + end; + + SourcePage.PaperSize := 256; + SourcePage.PaperWidth := Width / fr01cm; + SourcePage.PaperHeight := Height / fr01cm; + xi := TfrxXMLItem.Create; + xi.Text := THackComponent(SourcePage).FBaseName; + xi.Prop['PaperSize'] := '256'; + xi.Prop['PaperWidth'] := frxFloatToStr(SourcePage.PaperWidth); + xi.Prop['PaperHeight'] := frxFloatToStr(SourcePage.PaperHeight); + THackComponent(SourcePage).FBaseName := xi.Text; + xi.Free; +end; + +procedure TfrxPreviewPages.Finish; +var + i: Integer; +begin + ClearPageCache; + { avoid bug with multiple PrepareReport(False) } + for i := 0 to FSourcePages.Count - 1 do + THackComponent(FSourcePages[i]).FOriginalComponent := nil; + Report.InternalOnProgressStop(ptRunning); +end; + +function TfrxPreviewPages.BandExists(Band: TfrxBand): Boolean; +var + i: Integer; + c: TfrxComponent; +begin + Result := False; + for i := 0 to CurXMLPage.Count - 1 do + begin + c := GetObject(CurXMLPage[i].Name); + if c <> nil then + if (THackComponent(c).FOriginalComponent = Band) or + ((Band is TfrxPageFooter) and (c is TfrxPageFooter)) or + ((Band is TfrxColumnFooter) and (c is TfrxColumnFooter)) then + begin + Result := True; + break; + end; + end; +end; + +function TfrxPreviewPages.GetLastY: Extended; +var + i: Integer; + c: TfrxComponent; + s: String; + y: Extended; +begin + Result := 0; + for i := 0 to CurXMLPage.Count - 1 do + begin + c := GetObject(CurXMLPage[i].Name); + if c is TfrxBand then + if not (c is TfrxPageFooter) and not (c is TfrxOverlay) then + begin + s := CurXMLPage[i].Prop['t']; + if s <> '' then + y := frxStrToFloat(s) else + y := c.Top; + s := CurXMLPage[i].Prop['h']; + if s <> '' then + y := y + frxStrToFloat(s) else + y := y + c.Height; + if y > Result then + Result := y; + end; + end; +end; + +procedure TfrxPreviewPages.CutObjects(APosition: Integer); +var + xi: TfrxXMLItem; +begin + xi := FXMLDoc.Root.FindItem('cutted'); + while APosition < CurXMLPage.Count do + xi.AddItem(CurXMLPage[APosition]); +end; + +procedure TfrxPreviewPages.PasteObjects(X, Y: Extended); +var + xi: TfrxXMLItem; + LeftX, TopY, CorrX, CorrY: Extended; + + procedure CorrectX(xi: TfrxXMLItem); + var + X: Extended; + begin + if xi.Prop['l'] <> '' then + X := frxStrToFloat(xi.Prop['l']) else + X := 0; + X := X + CorrX; + xi.Prop['l'] := FloatToStr(X); + end; + + procedure CorrectY(xi: TfrxXMLItem); + var + Y: Extended; + begin + if xi.Prop['t'] <> '' then + Y := frxStrToFloat(xi.Prop['t']) else + Y := 0; + Y := Y + CorrY; + xi.Prop['t'] := FloatToStr(Y); + end; + +begin + xi := FXMLDoc.Root.FindItem('cutted'); + + if xi.Count > 0 then + begin + if xi[0].Prop['l'] <> '' then + LeftX := frxStrToFloat(xi[0].Prop['l']) else + LeftX := 0; + CorrX := X - LeftX; + + if xi[0].Prop['t'] <> '' then + TopY := frxStrToFloat(xi[0].Prop['t']) else + TopY := 0; + CorrY := Y - TopY; + + while xi.Count > 0 do + begin + CorrectX(xi[0]); + CorrectY(xi[0]); + CurXMLPage.AddItem(xi[0]); + end; + end; + + xi.Free; +end; + +procedure TfrxPreviewPages.DoLoadFromStream; +var + Compressor: TfrxCustomCompressor; +begin + Compressor := nil; + if frxCompressorClass <> nil then + begin + FAllowPartialLoading := False; + Compressor := TfrxCustomCompressor(frxCompressorClass.NewInstance); + Compressor.Create(nil); + Compressor.Report := Report; + Compressor.IsFR3File := False; + try + Compressor.CreateStream; + if Compressor.Decompress(FTempStream) then + FTempStream := Compressor.Stream; + except + Compressor.Free; + Report.Errors.Add(frxResources.Get('clDecompressError')); + frxCommonErrorHandler(Report, frxResources.Get('clErrors') + #13#10 + Report.Errors.Text); + Exit; + end; + end; + FXMLDoc.LoadFromStream(FTempStream, FAllowPartialLoading); + AfterLoad; + if Compressor <> nil then + Compressor.Free; +end; + +procedure TfrxPreviewPages.DoSaveToStream; +var + Compressor: TfrxCustomCompressor; + StreamTo: TStream; +begin + StreamTo := FTempStream; + Compressor := nil; + if Report.ReportOptions.Compressed and (frxCompressorClass <> nil) then + begin + Compressor := TfrxCustomCompressor(frxCompressorClass.NewInstance); + Compressor.Create(nil); + Compressor.Report := Report; + Compressor.IsFR3File := False; + Compressor.CreateStream; + StreamTo := Compressor.Stream; + end; + try + BeforeSave; + FXMLDoc.SaveToStream(StreamTo); + finally + if Compressor <> nil then + begin + try + Compressor.Compress(FTempStream); + finally + Compressor.Free; + end; + end; + end; +end; + +procedure TfrxPreviewPages.LoadFromStream(Stream: TStream; + AllowPartialLoading: Boolean = False); +begin + Clear; + FTempStream := Stream; + FAllowPartialLoading := AllowPartialLoading; +{$IFNDEF FR_COM} +// if Report.EngineOptions.ReportThread <> nil then +// THackThread(Report.EngineOptions.ReportThread).Synchronize(DoLoadFromStream) +// else +{$ENDIF} + DoLoadFromStream; +end; + +procedure TfrxPreviewPages.SaveToStream(Stream: TStream); +begin + FTempStream := Stream; +{$IFNDEF FR_COM} +// if Report.EngineOptions.ReportThread <> nil then +// THackThread(Report.EngineOptions.ReportThread).Synchronize(DoSaveToStream) +// else +{$ENDIF} + DoSaveToStream; +end; + +function TfrxPreviewPages.LoadFromFile(const FileName: String; + ExceptionIfNotFound: Boolean): Boolean; +var + Stream: TFileStream; +begin + Result := FileExists(FileName); + if Result or ExceptionIfNotFound then + begin + Stream := TFileStream.Create(FileName, fmOpenRead + fmShareDenyWrite); + try + LoadFromStream(Stream); + finally + Stream.Free; + end; +{ Clear; + FXMLDoc.LoadFromFile(FileName); + AfterLoad;} + end; +end; + +procedure TfrxPreviewPages.SaveToFile(const FileName: String); +var + Stream: TFileStream; +begin + Stream := TFileStream.Create(FileName, fmCreate); + try + SaveToStream(Stream); + finally + Stream.Free; + end; +{ BeforeSave; + FXMLDoc.SaveToFile(FileName); + ClearPageCache; + AfterLoad;} +end; + +procedure TfrxPreviewPages.AfterLoad; +var + i: Integer; + xs: TfrxXMLSerializer; + xi: TfrxXMLItem; + p: TfrxReportPage; + +{ store source objects' properties in the FBaseName to get it later in the GetPage } + procedure DoProps(p: TfrxReportPage); + var + i: Integer; + l: TList; + c: THackComponent; + begin + l := p.AllObjects; + for i := 0 to l.Count - 1 do + begin + c := l[i]; + c.FBaseName := xs.WriteComponentStr(c); + end; + end; + +{ fill FDictionary.Objects } + procedure FillDictionary; + var + i: Integer; + Name, PageName, ObjName: String; + PageN: Integer; + begin + xi := FXMLDoc.Root.FindItem('dictionary'); + FDictionary.Clear; + for i := 0 to xi.Count - 1 do + begin + Name := Copy(xi[i].Text, 7, Length(xi[i].Text) - 7); + PageName := Copy(Name, 1, Pos('.', Name) - 1); + ObjName := Copy(Name, Pos('.', Name) + 1, 255); + + PageN := StrToInt(Copy(PageName, 5, 255)); + FDictionary.Add(xi[i].Name, Name, + TfrxReportPage(FSourcePages[PageN]).FindObject(ObjName)); + end; + end; + +begin + FPagesItem := FXMLDoc.Root.FindItem('previewpages'); + xs := TfrxXMLSerializer.Create(nil); + +{ load the report settings } + xi := FXMLDoc.Root.FindItem('report'); + if xi.Count > 0 then + xs.ReadRootComponent(Report, xi[0]); + +{ build sourcepages } + try + xi := FXMLDoc.Root.FindItem('sourcepages'); + ClearSourcePages; + + for i := 0 to xi.Count - 1 do + begin + if CompareText(xi[i].Name, 'TfrxDMPPage') = 0 then + p := TfrxDMPPage.Create(nil) else + p := TfrxReportPage.Create(nil); + xs.Owner := p; + xs.ReadRootComponent(p, xi[i]); + DoProps(p); + FSourcePages.Add(p); + end; + xi.Clear; + + finally + xs.Free; + end; + +{ build the dictionary } + FillDictionary; + +{ load the picturecache } + FPictureCache.LoadFromXML(FXMLDoc.Root.FindItem('picturecache')); +end; + +procedure TfrxPreviewPages.BeforeSave; +var + i: Integer; + xs: TfrxXMLSerializer; + xi: TfrxXMLItem; +begin + FPagesItem := FXMLDoc.Root.FindItem('previewpages'); + xs := TfrxXMLSerializer.Create(nil); + +{ upload the report settings } + xi := FXMLDoc.Root.FindItem('report'); + xi.Clear; + xi := xi.Add; + xi.Name := Report.ClassName; + xi.Text := 'DotMatrixReport="' + frxValueToXML(Report.DotMatrixReport) + + '" PreviewOptions.OutlineVisible="' + frxValueToXML(Report.PreviewOptions.OutlineVisible) + + '" PreviewOptions.OutlineWidth="' + frxValueToXML(Report.PreviewOptions.OutlineWidth) + + '" ReportOptions.Name="' + frxStrToXML(Report.ReportOptions.Name) + '"'; + +{ upload the sourcepages } + try + xi := FXMLDoc.Root.FindItem('sourcepages'); + xi.Clear; + for i := 0 to FSourcePages.Count - 1 do + xs.WriteRootComponent(FSourcePages[i], True, xi.Add); + + finally + xs.Free; + end; + +{ upload the dictionary } + xi := FXMLDoc.Root.FindItem('dictionary'); + xi.Clear; + for i := 0 to FDictionary.Names.Count - 1 do + with xi.Add do + begin + Name := FDictionary.Names[i]; + Text := 'name="' + FDictionary.GetSourceName(Name) + '"'; + end; + +{ upload the picturecache } + xi := FXMLDoc.Root.FindItem('picturecache'); + FPictureCache.SaveToXML(xi); +end; + +function TfrxPreviewPages.GetObject(const Name: String): TfrxComponent; +begin + Result := TfrxComponent(FDictionary.GetObject(Name)); +end; + +function TfrxPreviewPages.GetPage(Index: Integer): TfrxReportPage; +var + xi: TfrxXMLItem; + xs: TfrxXMLSerializer; + i: Integer; + Source: TfrxReportPage; + + procedure DoObjects(Item: TfrxXMLItem; Owner: TfrxComponent); + var + i: Integer; + c, c0: TfrxComponent; + begin + for i := 0 to Item.Count - 1 do + begin + c0 := GetObject(Item[i].Name); + { object not found in the dictionary } + if c0 = nil then + c := xs.ReadComponentStr(Owner, Item[i].Name + ' ' + Item[i].Text, True) + else + begin + c := xs.ReadComponentStr(Owner, + THackComponent(c0).FBaseName + ' ' + Item[i].Text, True); + c.Name := c0.Name; + if (c is TfrxPictureView) and (TfrxPictureView(c).Picture.Graphic = nil) then + FPictureCache.GetPicture(TfrxPictureView(c)); + end; + c.Parent := Owner; + + DoObjects(Item[i], c); + end; + end; + +begin + Result := nil; + if Count = 0 then Exit; + + { check pagecache first } + if not Engine.Running then + begin + i := FPageCache.IndexOf(IntToStr(Index)); + if i <> -1 then + begin + Result := TfrxReportPage(FPageCache.Objects[i]); + FPageCache.Exchange(i, 0); + Exit; + end; + end; + + xs := TfrxXMLSerializer.Create(nil); + try + { load the page item } + xi := FPagesItem[Index]; + FXMLDoc.LoadItem(xi); + + if CompareText(xi.Name, 'TfrxReportPage') = 0 then + begin + { page item do not refer to the originalpages } + Result := TfrxReportPage.Create(nil); + xs.ReadRootComponent(Result, xi); + end + else if CompareText(xi.Name, 'TfrxDMPPage') = 0 then + begin + { page item do not refer to the originalpages } + Result := TfrxDMPPage.Create(nil); + xs.ReadRootComponent(Result, xi); + end + else + begin + Source := FSourcePages[StrToInt(Copy(xi.Name, 5, 5))]; + { create reportpage and assign properties from original page } + if Source is TfrxDMPPage then + Result := TfrxDMPPage.Create(nil) else + Result := TfrxReportPage.Create(nil); + Result.Assign(Source); + + { create objects } + DoObjects(xi, Result); + end; + finally + xs.Free; + end; + + { update aligned objects } + Result.AlignChildren; + + { add this page to the pagecache } + FPageCache.InsertObject(0, IntToStr(Index), Result); + i := FPageCache.Count; + + { remove the least used item from the pagecache } + if (i > 1) and (i > Report.PreviewOptions.PagesInCache) then + begin + xi := FPagesItem[StrToInt(FPageCache[i - 1])]; + if Report.EngineOptions.UseFileCache and xi.Unloadable then + begin + FXMLDoc.UnloadItem(xi); + xi.Clear; + end; + + TfrxReportPage(FPageCache.Objects[i - 1]).Free; + FPageCache.Delete(i - 1); + end; +end; + +function TfrxPreviewPages.GetPageSize(Index: Integer): TPoint; +var + xi: TfrxXMLItem; + p: TfrxReportPage; +begin + if (Count = 0) or (Index < 0) or (Index >= Count) then + begin + Result := Point(0, 0); + Exit; + end; + + xi := FPagesItem[Index]; + if (CompareText(xi.Name, 'TfrxReportPage') = 0) or + (CompareText(xi.Name, 'TfrxDMPPage') = 0) then + p := GetPage(Index) else + p := FSourcePages[StrToInt(Copy(xi.Name, 5, 256))]; + Result.X := Round(p.Width); + Result.Y := Round(p.Height); +end; + +procedure TfrxPreviewPages.AddEmptyPage(Index: Integer); +var + xi: TfrxXMLItem; +begin + if Count = 0 then Exit; + + xi := TfrxXMLItem.Create; + xi.Name := FPagesItem[Index].Name; + FPagesItem.InsertItem(Index, xi); + ClearPageCache; +end; + +procedure TfrxPreviewPages.DeletePage(Index: Integer); +begin + if Count < 2 then Exit; + + FPagesItem[Index].Free; + ClearPageCache; +end; + +procedure TfrxPreviewPages.ModifyPage(Index: Integer; Page: TfrxReportPage); +var + xs: TfrxXMLSerializer; +begin + xs := TfrxXMLSerializer.Create(nil); + try + FPagesItem[Index].Clear; + xs.WriteRootComponent(Page, True, FPagesItem[Index]); + FPagesItem[Index].Unloadable := False; + ClearPageCache; + finally + xs.Free; + end; +end; + +procedure TfrxPreviewPages.AddFrom(Report: TfrxReport); +var + i: Integer; + Page: TfrxReportPage; + xi: TfrxXMLItem; + xs: TfrxXMLSerializer; +begin + xs := TfrxXMLSerializer.Create(nil); + + for i := 0 to Report.PreviewPages.Count - 1 do + begin + Page := Report.PreviewPages.Page[i]; + xi := TfrxXMLItem.Create; + xi.Name := FPagesItem[Count - 1].Name; + xs.WriteRootComponent(Page, True, xi); + xi.Unloadable := False; + FPagesItem.AddItem(xi); + end; + + xs.Free; + ClearPageCache; +end; + +procedure TfrxPreviewPages.DrawPage(Index: Integer; Canvas: TCanvas; + ScaleX, ScaleY, OffsetX, OffsetY: Extended); +var + i: Integer; + Page: TfrxReportPage; + l: TList; + c: TfrxComponent; + IsPrinting: Boolean; + SaveLeftMargin, SaveRightMargin: Extended; + rgn: HRGN; + + function ViewVisible(c: TfrxComponent): Boolean; + var + r: TRect; + begin + with c do + r := Rect(Round(AbsLeft * ScaleX) - 20, Round(AbsTop * ScaleY) - 20, + Round((AbsLeft + Width) * ScaleX + 20), + Round((AbsTop + Height) * ScaleY + 20)); + OffsetRect(r, Round(OffsetX), Round(OffsetY)); + Result := RectVisible(Canvas.Handle, r) or (Canvas is TMetafileCanvas); + end; + +begin + Page := GetPage(Index); + if Page = nil then Exit; + + SaveLeftMargin := Page.LeftMargin; + SaveRightMargin := Page.RightMargin; + if Page.MirrorMargins and (Index mod 2 = 1) then + begin + Page.LeftMargin := SaveRightMargin; + Page.RightMargin := SaveLeftMargin; + end; + + IsPrinting := Canvas is TfrxPrinterCanvas; + rgn := 0; + if not IsPrinting then + begin + rgn := CreateRectRgn(0, 0, 10000, 10000); + GetClipRgn(Canvas.Handle, rgn); + IntersectClipRect(Canvas.Handle, + Round(OffsetX), + Round(OffsetY), + Round(OffsetX + Page.PaperWidth * fr01cm * ScaleX) - 1, + Round(OffsetY + Page.PaperHeight * fr01cm * ScaleY) - 1); + end; + + Page.Draw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + OffsetX := OffsetX + Page.LeftMargin * fr01cm * ScaleX; + OffsetY := OffsetY + Page.TopMargin * fr01cm * ScaleY; + + l := Page.AllObjects; + + for i := 0 to l.Count - 1 do + begin + c := l[i]; + if (c is TfrxView) and ViewVisible(c) then + if not IsPrinting or TfrxView(c).Printable then + begin + c.IsPrinting := IsPrinting; + { needed for TOTALPAGES macro } + if c is TfrxCustomMemoView then + begin + THackMemoView(c).FTotalPages := Count; + THackMemoView(c).FCopyNo := FCopyNo; + THackMemoView(c).FPrintScale := FPrintScale; + end; + { draw the object } + TfrxView(c).Draw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + c.IsPrinting := False; + end; + end; + + Page.LeftMargin := SaveLeftMargin; + Page.RightMargin := SaveRightMargin; + if not IsPrinting then + begin + SelectClipRgn(Canvas.Handle, rgn); + DeleteObject(rgn); + end; +end; + +function TfrxPreviewPages.Print: Boolean; +var + MaxCount: Integer; + PagesPrinted, ACopyNo: Integer; + pgList: TStringList; + LastDuplexMode: TfrxDuplexMode; + LastPaperSize, LastPaperWidth, LastPaperHeight, LastBin: Integer; + LastOrientation: TPrinterOrientation; + SplitAddX, SplitAddY: Extended; + DuplexMode: TfrxDuplexMode; + SavePrintOptions: TfrxPrintOptions; + SheetWidth, SheetHeight: Extended; + + + function GetNextPage(var Index: Integer): TfrxReportPage; + begin + Result := nil; + while Index < Count - 1 do + begin + Inc(Index); + if (pgList.Count <> 0) and (pgList.IndexOf(IntToStr(Index + 1)) = -1) then + continue + else + begin + Result := GetPage(Index); + break; + end; + end; + end; + + procedure SplitPage(a, b, c, d: Extended; var x, y: Integer; var NeedRotate: Boolean); + var + tempX, tempY: Integer; + tempC: Extended; + + procedure TrySplit; + begin + if Abs(Trunc(a / c) * c - a) < 11 then + x := Round(a / c) + else + x := Trunc(a / c) + 1; + + if Abs(Trunc(b / d) * d - b) < 11 then + y := Round(b / d) + else + y := Trunc(b / d) + 1; + end; + + begin + NeedRotate := False; + + TrySplit; + + tempX := x; + tempY := y; + + tempC := c; + c := d; + d := tempC; + + TrySplit; + + if x * y >= tempX * tempY then + begin + x := tempX; + y := tempY; + end + else + NeedRotate := True; + end; + + procedure DoPrint; + var + i: Integer; + Printer: TfrxCustomPrinter; + PagePrinted: Boolean; + Page: TfrxReportPage; + + function PrintSplittedPage(Index: Integer): Boolean; + var + Bin, ACopies, x, y, countX, countY: Integer; + pieceX, pieceY, offsX, offsY, marginX, marginY, printedX, printedY: Extended; + orient: TPrinterOrientation; + NeedChangeOrientation: Boolean; + dup: TfrxDuplexMode; + begin + Result := True; + if Index >= Count then Exit; + + if (pgList.Count <> 0) and (pgList.IndexOf(IntToStr(Index + 1)) = -1) then Exit; + if ((Report.PrintOptions.PrintPages = ppOdd) and ((Index + 1) mod 2 = 0)) or + ((Report.PrintOptions.PrintPages = ppEven) and ((Index + 1) mod 2 = 1)) then Exit; + if Report.Terminated then + begin + Printer.Abort; + Result := False; + Exit; + end; + + Page := GetPage(Index); + + if Report.PrintOptions.Collate then + begin + ACopies := 1; + FCopyNo := ACopyNo; + end + else + begin + ACopies := Report.PrintOptions.Copies; + FCopyNo := 1; + end; + + if Assigned(Report.OnPrintPage) then + Report.OnPrintPage(Page, FCopyNo); + + if Index = 0 then + Bin := Page.Bin else + Bin := Page.BinOtherPages; + + SplitPage(Page.PaperWidth, Page.PaperHeight, SheetWidth, SheetHeight, + countX, countY, NeedChangeOrientation); + + orient := poPortrait; + if NeedChangeOrientation then + orient := poLandscape; + + dup := Page.Duplex; + if DuplexMode <> dmNone then + dup := DuplexMode; + + if not PagePrinted or (orient <> LastOrientation) then + Printer.SetPrintParams(Report.PrintOptions.PrintOnSheet, + SheetWidth, SheetHeight, orient, Bin, Integer(dup) + 1, ACopies); + if not PagePrinted then + Printer.BeginDoc; + + if orient = poPortrait then + begin + pieceX := SheetWidth * (Printer.DPI.X / 25.4); + pieceY := SheetHeight * (Printer.DPI.Y / 25.4); + end + else + begin + pieceX := SheetHeight * (Printer.DPI.X / 25.4); + pieceY := SheetWidth * (Printer.DPI.Y / 25.4); + end; + + marginY := 0; + printedY := 0; + offsY := -Printer.TopMargin * Printer.DPI.Y / 25.4; + + for y := 1 to countY do + begin + marginX := 0; + printedX := 0; + offsX := -Printer.LeftMargin * Printer.DPI.X / 25.4; + + for x := 1 to countX do + begin + Printer.BeginPage; + DrawPage(Index, Printer.Canvas, Printer.DPI.X / 96, Printer.DPI.Y / 96, + offsX, offsY); + +{$IFDEF TRIAL} + with Printer.Canvas do + begin + Font.Size := 12; + Font.Color := clBlack; + TextOut(0, 0, frxReverseString(FR_UNREG)); + end; +{$ENDIF} + Printer.EndPage; + + printedX := printedX + (pieceX - marginX - Printer.RightMargin * Printer.DPI.X / 25.4) - + SplitAddX * Printer.DPI.X / 25.4; + offsX := -printedX; + marginX := Printer.LeftMargin * Printer.DPI.X / 25.4; + end; + + printedY := printedY + (pieceY - marginY - Printer.BottomMargin * Printer.DPI.Y / 25.4) - + SplitAddY * Printer.DPI.Y / 25.4; + offsY := -printedY; + marginY := Printer.TopMargin * Printer.DPI.Y / 25.4; + end; + + Report.InternalOnProgress(ptPrinting, Index + 1); + Application.ProcessMessages; + + PagePrinted := True; + Inc(PagesPrinted); + + LastOrientation := Page.Orientation; + ClearPageCache; + end; + + + function PrintPage(Index: Integer): Boolean; + var + Bin, ACopies: Integer; + dup: TfrxDuplexMode; + ZoomX, ZoomY: Extended; + begin + Result := True; + if Index >= Count then Exit; + + if (pgList.Count <> 0) and (pgList.IndexOf(IntToStr(Index + 1)) = -1) then Exit; + if ((Report.PrintOptions.PrintPages = ppOdd) and ((Index + 1) mod 2 = 0)) or + ((Report.PrintOptions.PrintPages = ppEven) and ((Index + 1) mod 2 = 1)) then Exit; + if Report.Terminated then + begin + Printer.Abort; + Result := False; + Exit; + end; + + Page := GetPage(Index); + + if Report.PrintOptions.Collate then + begin + ACopies := 1; + FCopyNo := ACopyNo; + end + else + begin + ACopies := Report.PrintOptions.Copies; + FCopyNo := 1; + end; + + if Assigned(Report.OnPrintPage) then + Report.OnPrintPage(Page, FCopyNo); + + if Index = 0 then + Bin := Page.Bin else + Bin := Page.BinOtherPages; + + dup := Page.Duplex; + if DuplexMode <> dmNone then + dup := DuplexMode; + + if Report.PrintOptions.PrintMode = pmDefault then + begin + if (not PagePrinted) or + (LastPaperSize <> Page.PaperSize) or + (LastPaperWidth <> Round(Page.PaperWidth)) or + (LastPaperHeight <> Round(Page.PaperHeight)) or + (LastBin <> Bin) or + (LastOrientation <> Page.Orientation) or + (LastDuplexMode <> dup) then + Printer.SetPrintParams(Page.PaperSize, Page.PaperWidth, Page.PaperHeight, + Page.Orientation, Bin, Integer(dup) + 1, ACopies); + end + else + if (not PagePrinted) or + (LastBin <> Bin) or + (LastOrientation <> Page.Orientation) or + (LastDuplexMode <> dup) then + begin + Printer.SetPrintParams(Report.PrintOptions.PrintOnSheet, + SheetWidth, SheetHeight, Page.Orientation, Bin, Integer(dup) + 1, ACopies); + SheetWidth := frxPrinters.Printer.PaperWidth; + SheetHeight := frxPrinters.Printer.PaperHeight; + end; + if not PagePrinted then + Printer.BeginDoc; + + Printer.BeginPage; + + if Report.PrintOptions.PrintMode = pmDefault then + begin + ZoomX := 1; + ZoomY := 1; + end + else + begin + ZoomX := SheetWidth / Page.PaperWidth; + ZoomY := SheetHeight / Page.PaperHeight; + if ZoomY < ZoomX then + FPrintScale := ZoomY + else + FPrintScale := ZoomX; + end; + + DrawPage(Index, Printer.Canvas, Printer.DPI.X / 96 * ZoomX, Printer.DPI.Y / 96 * ZoomY, + -Printer.LeftMargin * Printer.DPI.X / 25.4, + -Printer.TopMargin * Printer.DPI.Y / 25.4); + + Report.InternalOnProgress(ptPrinting, Index + 1); + +{$IFDEF TRIAL} + with Printer.Canvas do + begin + Font.Size := 12; + Font.Color := clBlack; + TextOut(0, 0, frxReverseString(FR_UNREG)); + end; +{$ENDIF} + Printer.EndPage; + Application.ProcessMessages; + + PagePrinted := True; + Inc(PagesPrinted); + + LastPaperSize := Page.PaperSize; + LastPaperWidth := Round(Page.PaperWidth); + LastPaperHeight := Round(Page.PaperHeight); + LastBin := Bin; + LastOrientation := Page.Orientation; + LastDuplexMode := dup; + ClearPageCache; + end; + + procedure PrintPages; + var + i: Integer; + begin + PagesPrinted := 0; + + if Report.PrintOptions.Reverse then + begin + for i := MaxCount - 1 downto 0 do + if not PrintPage(i) then + break; + end + else + for i := 0 to MaxCount - 1 do + if not PrintPage(i) then + break; + end; + + procedure PrintSplittedPages; + var + i: Integer; + begin + PagesPrinted := 0; + + if Report.PrintOptions.Reverse then + begin + for i := MaxCount - 1 downto 0 do + if not PrintSplittedPage(i) then + break; + end + else + for i := 0 to MaxCount - 1 do + if not PrintSplittedPage(i) then + break; + end; + + procedure PrintJoinedPages; + var + Index, cp, x, y, countX, countY: Integer; + pieceX, pieceY, offsX, offsY: Extended; + orient: TPrinterOrientation; + NeedChangeOrientation: Boolean; + dup: TfrxDuplexMode; + begin + PagesPrinted := 0; + if Count = 0 then Exit; + + { get the first page and calculate the join options } + Index := -1; + Page := GetNextPage(Index); + + SplitPage(SheetWidth, SheetHeight, Page.PaperWidth, Page.PaperHeight, + countX, countY, NeedChangeOrientation); + orient := poPortrait; + if NeedChangeOrientation then + begin + orient := poLandscape; + x := countX; + countX := countY; + countY := x; + end; + + { setup the printer } + dup := Page.Duplex; + if DuplexMode <> dmNone then + dup := DuplexMode; + Printer.SetPrintParams(Report.PrintOptions.PrintOnSheet, + SheetWidth, SheetHeight, orient, Page.Bin, Integer(dup) + 1, 1); + PagePrinted := True; + Printer.BeginDoc; + + { start the cycle } + pieceX := Page.PaperWidth * (Printer.DPI.X / 25.4); + pieceY := Page.PaperHeight * (Printer.DPI.Y / 25.4); + + Index := -1; + while Index < MaxCount - 1 do + begin + cp := 1; + offsY := -Printer.TopMargin * Printer.DPI.Y / 25.4; + Printer.BeginPage; + + for y := 1 to countY do + begin + offsX := -Printer.LeftMargin * Printer.DPI.X / 25.4; + + for x := 1 to countX do + begin + { get the next page } + FCopyNo := cp; + if cp = 1 then + Page := GetNextPage(Index); + Inc(cp); + if cp > Report.PrintOptions.Copies then + cp := 1; + + if Page = nil then break; + + DrawPage(Index, Printer.Canvas, Printer.DPI.X / 96, Printer.DPI.Y / 96, + offsX, offsY); + + offsX := offsX + pieceX; + end; + + if Page = nil then break; + offsY := offsY + pieceY; + end; + +{$IFDEF TRIAL} + with Printer.Canvas do + begin + Font.Size := 12; + Font.Color := clBlack; + TextOut(0, 0, frxReverseString(FR_UNREG)); + end; +{$ENDIF} + Printer.EndPage; + + Report.InternalOnProgress(ptPrinting, Index); + Application.ProcessMessages; + if Report.Terminated then + begin + Printer.Abort; + Exit; + end; + + Inc(PagesPrinted); + ClearPageCache; + end; + end; + + begin + Printer := frxPrinters.Printer; + Report.Terminated := False; + Report.InternalOnProgressStart(ptPrinting); + + if Report.ReportOptions.Name <> '' then + Printer.Title := Report.ReportOptions.Name else + Printer.Title := Report.FileName; + if Report.PrintOptions.Copies <= 0 then + Report.PrintOptions.Copies := 1; +{$IFNDEF TRIAL} + MaxCount := Count; +{$ELSE} + MaxCount := 5; +{$ENDIF} + + PagePrinted := False; + LastDuplexMode := dmNone; + + if Report.PrintOptions.Collate then + for i := 0 to Report.PrintOptions.Copies - 1 do + begin + ACopyNo := i + 1; + case Report.PrintOptions.PrintMode of + pmDefault, pmScale: + PrintPages; + pmSplit: + PrintSplittedPages; + pmJoin: + PrintJoinedPages; + end; + if (LastDuplexMode in [dmVertical, dmHorizontal]) and (PagesPrinted mod 2 <> 0) then + begin + Printer.BeginPage; + Printer.EndPage; + end; + + if Report.Terminated then break; + end + else + begin + case Report.PrintOptions.PrintMode of + pmDefault, pmScale: + PrintPages; + pmSplit: + PrintSplittedPages; + pmJoin: + PrintJoinedPages; + end; + end; + + if PagePrinted then + Printer.EndDoc; + Report.InternalOnProgressStop(ptPrinting); + end; + +begin + Result := True; + if not frxPrinters.HasPhysicalPrinters then + begin + frxErrorMsg(frxResources.Get('clNoPrinters')); + Result := False; + Exit; + end; + + FPrintScale := 1; + + if Report.DotMatrixReport and (frxDotMatrixExport <> nil) then + begin + Report.SelectPrinter; + frxDotMatrixExport.ShowDialog := Report.PrintOptions.ShowDialog; + Result := Export(frxDotMatrixExport); + Exit; + end; + + SavePrintOptions := TfrxPrintOptions.Create; + SavePrintOptions.Assign(Report.PrintOptions); + DuplexMode := dmNone; + Report.SelectPrinter; + + if Report.PrintOptions.ShowDialog then + with TfrxPrintDialog.Create(Application) do + begin + AReport := Report; + ADuplexMode := DuplexMode; + ShowModal; + if ModalResult = mrOk then + begin + DuplexMode := ADuplexMode; + Free; + end + else + begin + Free; + FCopyNo := 0; + Result := False; + SavePrintOptions.Free; + Exit; + end; + end; + + if Report.PrintOptions.PrintMode <> pmDefault then + begin + frxPrinters.Printer.SetViewParams(Report.PrintOptions.PrintOnSheet, 0, 0, poPortrait); + SheetWidth := frxPrinters.Printer.PaperWidth; + SheetHeight := frxPrinters.Printer.PaperHeight; + SplitAddX := 3; + SplitAddY := 3; + end; + + if Assigned(Report.OnPrintReport) then + Report.OnPrintReport(Report); + + if Report.Preview <> nil then + Report.Preview.Lock; + pgList := TStringList.Create; + try + frxParsePageNumbers(Report.PrintOptions.PageNumbers, pgList, Count); + ClearPageCache; + DoPrint; + finally + if Assigned(Report.OnAfterPrintReport) then + Report.OnAfterPrintReport(Report); + FCopyNo := 0; + Report.PrintOptions.Assign(SavePrintOptions); + SavePrintOptions.Free; + pgList.Free; + end; +end; + +function TfrxPreviewPages.Export(Filter: TfrxCustomExportFilter): Boolean; +var + pgList: TStringList; + tempBMP: TBitmap; + + procedure ExportPage(Index: Integer); + var + i, j: Integer; + Page: TfrxReportPage; + c: TfrxComponent; + p: TfrxPictureView; +{$IFDEF TRIAL} + m: TfrxCustomMemoView; +{$ENDIF} + + procedure ExportObject(c: TfrxComponent); + begin + if c is TfrxCustomMemoView then + begin + { set up font if Highlight is active } + if TfrxCustomMemoView(c).Highlight.Active then + TfrxCustomMemoView(c).Font.Assign(TfrxCustomMemoView(c).Highlight.Font); + { needed for TOTALPAGES, COPYNAME macros } + THackMemoView(c).FTotalPages := Count; + THackMemoView(c).FCopyNo := 1; + THackMemoView(c).ExtractMacros; + { needed if memo has AutoWidth and Align properties } + if THackMemoView(c).AutoWidth then + THackMemoView(c).Draw(tempBMP.Canvas, 1, 1, 0, 0); + end; + Filter.ExportObject(c); + end; + + begin + if Index >= Count then Exit; + if (pgList.Count <> 0) and (pgList.IndexOf(IntToStr(Index + 1)) = -1) then Exit; + Page := GetPage(Index); + if Page = nil then Exit; + + if Filter.ShowProgress then + Report.InternalOnProgress(ptExporting, Index + 1); + + Filter.StartPage(Page, Index); + try + { set the offset of the page objects } + if Page.MirrorMargins and (Index mod 2 = 1) then + Page.Left := Page.RightMargin * fr01cm else + Page.Left := Page.LeftMargin * fr01cm; + Page.Top := Page.TopMargin * fr01cm; + + { export the page background picture and frame } + p := TfrxPictureView.Create(nil); + p.Name := '_pagebackground'; + p.Color := Page.Color; + p.Frame.Assign(Page.Frame); + p.Picture.Assign(Page.BackPicture); + p.Stretched := True; + p.KeepAspectRatio := False; + try + p.SetBounds(Page.Left, Page.Top, + Page.Width - (Page.LeftMargin + Page.RightMargin) * fr01cm, + Page.Height - (Page.TopMargin + Page.BottomMargin) * fr01cm); + Filter.ExportObject(p); + finally + p.Free; + end; +{$IFDEF TRIAL} + m := TfrxCustomMemoView.Create(nil); + try + m.SetBounds(Page.Left, Page.Top - 10, + Page.Width - (Page.LeftMargin + Page.RightMargin) * fr01cm, 10); + m.Text := frxReverseString(FR_UNREG); + m.HAlign := haRight; + m.Font.Size := 7; + m.Font.Color := clGray; + Filter.ExportObject(m); + finally + m.Free; + end; +{$ENDIF} + + for i := 0 to Page.Objects.Count - 1 do + begin + c := Page.Objects[i]; + if c is TfrxBand then + begin + if c is TfrxPageHeader then + begin + { suppress a header } + if Filter.SuppressPageHeadersFooters and (Index <> 0) then continue; + end; + if c is TfrxPageFooter then + begin + { suppress a footer } + if Filter.SuppressPageHeadersFooters and (Index <> Count - 1) then continue; + end; + end; + + ExportObject(c); + if c.Objects.Count <> 0 then + for j := 0 to c.Objects.Count - 1 do + ExportObject(c.Objects[j]); + end; + + finally + Filter.FinishPage(Page, Index); + end; + + if Report.Preview = nil then + ClearPageCache + else + begin + Page.Left := 0; + Page.Top := 0; + end; + end; + + procedure DoExport; + var + i: Integer; + begin + if Filter.Start then + try + if Report.Preview <> nil then + begin + Report.Preview.Refresh; + Report.Preview.Lock; + end; + + if Filter.ShowProgress then + Report.InternalOnProgressStart(ptExporting); + +{$IFNDEF TRIAL} + for i := 0 to Count - 1 do +{$ELSE} + for i := 0 to 4 do +{$ENDIF} + begin + ExportPage(i); + if Report.Terminated then break; + Application.ProcessMessages; + end; + + finally + if Report.Preview <> nil then + begin + TfrxPreview(Report.Preview).HideMessage; + Report.Preview.Refresh; + end; + + if Filter.ShowProgress then + Report.InternalOnProgressStop(ptExporting); + + Filter.Finish; + end; + end; + +begin + Result := False; + FCopyNo := 0; + if Filter = nil then Exit; + + Filter.Report := Report; + if (Filter.ShowDialog and (Filter.ShowModal <> mrOk)) then + Exit; + if Filter.CurPage then + if Report.Preview <> nil then + Filter.PageNumbers := IntToStr(CurPreviewPage) else + Filter.PageNumbers := '1'; + + Result := True; + Report.Terminated := False; + + pgList := TStringList.Create; + tempBMP := TBitmap.Create; + try + frxParsePageNumbers(Filter.PageNumbers, pgList, Count); + + if Filter = frxDotMatrixExport then + if Assigned(Report.OnPrintReport) then + Report.OnPrintReport(Report); + + try + DoExport; + except + on e: Exception do + begin + Result := False; + Report.Errors.Text := e.Message; + frxCommonErrorHandler(Report, frxResources.Get('clErrors') + #13#10 + Report.Errors.Text); + end; + end; + + if Filter = frxDotMatrixExport then + if Assigned(Report.OnAfterPrintReport) then + Report.OnAfterPrintReport(Report); + finally + pgList.Free; + tempBMP.Free; + end; +end; + +procedure TfrxPreviewPages.ObjectOver(Index: Integer; X, Y: Integer; + Button: TMouseButton; Shift: TShiftState; Scale, OffsetX, OffsetY: Extended; + Click: Boolean; var Cursor: TCursor); +var + Page: TfrxReportPage; + c: TfrxComponent; + l: TList; + i: Integer; + Flag: Boolean; + v: TfrxView; + drill: TfrxGroupHeader; + drillName: String; + + function MouseInView(c: TfrxComponent): Boolean; + var + r: TRect; + begin + with c do + r := Rect(Round(AbsLeft * Scale), Round(AbsTop * Scale), + Round((AbsLeft + Width) * Scale), + Round((AbsTop + Height) * Scale)); + OffsetRect(r, Round(OffsetX), Round(OffsetY)); + Result := PtInRect(r, Point(X, Y)); + end; + + procedure SetToAnchor(const Text: String); + var + Item: TfrxXMLItem; + PageN, Top: Integer; + begin + Item := FindAnchor(Text); + if Item <> nil then + begin + PageN := StrToInt(Item.Prop['page']); + Top := StrToInt(Item.Prop['top']); + TfrxPreview(Report.Preview).SetPosition(PageN + 1, Top); + end; + end; + +begin + if (Index < 0) or (Index >= Count) or Engine.Running then Exit; + Page := GetPage(Index); + if Page = nil then Exit; + + if Page.MirrorMargins and (Index mod 2 = 1) then + OffsetX := OffsetX + Page.RightMargin * fr01cm * Scale else + OffsetX := OffsetX + Page.LeftMargin * fr01cm * Scale; + OffsetY := OffsetY + Page.TopMargin * fr01cm * Scale; + + Report.SetProgressMessage(''); + Page := GetPage(Index); // get page again to ensure it was not cleared during export + if Page = nil then Exit; + + drill := nil; + l := Page.AllObjects; + + for i := l.Count - 1 downto 0 do + begin + c := l[i]; + if (c is TfrxGroupHeader) and MouseInView(c) then + if TfrxGroupHeader(c).DrillDown then + begin + drill := TfrxGroupHeader(c); + break; + end; + + if (c is TfrxView) and MouseInView(c) then + begin + v := TfrxView(c); + if (v.Parent is TfrxGroupHeader) and TfrxGroupHeader(v.Parent).DrillDown then + begin + drill := TfrxGroupHeader(v.Parent); + break; + end; + if v.Cursor <> crDefault then + Cursor := v.Cursor; + if v.URL <> '' then + begin + Report.SetProgressMessage(v.URL); + if v.Cursor = crDefault then + Cursor := crHandPoint; + end; + + if Click then + begin + if v.URL <> '' then + if Pos('@', v.URL) = 1 then + TfrxPreview(Report.Preview).PageNo := StrToInt(Copy(v.URL, 2, 255)) + else if Pos('#', v.URL) = 1 then + SetToAnchor(Copy(v.URL, 2, 255)) + else + ShellExecute(GetDesktopWindow, nil, PChar(v.URL), nil, nil, sw_ShowNormal); + + Flag := False; + Report.DoPreviewClick(v, Button, Shift, Flag); + if Flag then + begin + ModifyPage(Index, Page); + Report.Preview.Invalidate; + end; + end + else if Assigned(Report.OnMouseOverObject) then + Report.OnMouseOverObject(v); + break; + end; + end; + + if drill <> nil then + begin + Cursor := crHandPoint; + if Click and (Button = mbLeft) then + begin + drillName := drill.Name + '.' + IntToStr(drill.Tag); + if Report.DrillState.IndexOf(drillName) = -1 then + Report.DrillState.Add(drillName) + else + Report.DrillState.Delete(Report.DrillState.IndexOf(drillName)); + Report.Preview.RefreshReport; + end; + end; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPrintDialog.dfm b/official/4.2/LibD11/frxPrintDialog.dfm new file mode 100644 index 0000000..6d4310f Binary files /dev/null and b/official/4.2/LibD11/frxPrintDialog.dfm differ diff --git a/official/4.2/LibD11/frxPrintDialog.pas b/official/4.2/LibD11/frxPrintDialog.pas new file mode 100644 index 0000000..b75d553 --- /dev/null +++ b/official/4.2/LibD11/frxPrintDialog.pas @@ -0,0 +1,324 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Print dialog } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPrintDialog; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, frxCtrls, ExtCtrls, Buttons, ComCtrls, frxClass +{$IFDEF Delphi6} +, Variants, ImgList +{$ENDIF}; + + +type + TfrxPrintDialog = class(TForm) + OkB: TButton; + CancelB: TButton; + FileDlg: TSaveDialog; + Label12: TGroupBox; + WhereL: TLabel; + WhereL1: TLabel; + PrintersCB: TComboBox; + PropButton: TButton; + FileCB: TCheckBox; + Label1: TGroupBox; + DescrL: TLabel; + AllRB: TRadioButton; + CurPageRB: TRadioButton; + PageNumbersRB: TRadioButton; + PageNumbersE: TEdit; + Label2: TGroupBox; + CopiesL: TLabel; + CollateImg: TImage; + NonCollateImg: TImage; + CopiesPB: TPaintBox; + CopiesE: TEdit; + CollateCB: TCheckBox; + UpDown1: TUpDown; + ScaleGB: TGroupBox; + PagPageSizeCB: TComboBox; + NameL: TLabel; + PagSizeL: TLabel; + PrintModeCB: TComboBox; + PrintModeIL: TImageList; + OtherGB: TGroupBox; + PrintL: TLabel; + DuplexL: TLabel; + PrintPagesCB: TComboBox; + DuplexCB: TComboBox; + OrderL: TLabel; + OrderCB: TComboBox; + procedure PrintersCBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure FormCreate(Sender: TObject); + procedure PropButtonClick(Sender: TObject); + procedure PrintersCBClick(Sender: TObject); + procedure PageNumbersRBClick(Sender: TObject); + procedure CollateLClick(Sender: TObject); + procedure CollateCBClick(Sender: TObject); + procedure CopiesPBPaint(Sender: TObject); + procedure PageNumbersEEnter(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure PrintModeCBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure FormShow(Sender: TObject); + procedure PrintModeCBClick(Sender: TObject); + private + { Private declarations } + OldIndex: Integer; + public + { Public declarations } + AReport: TfrxReport; + ADuplexMode: TfrxDuplexMode; + end; + + +implementation + +{$R *.DFM} + +uses frxPrinter, Printers, frxUtils, frxRes; + + +procedure TfrxPrintDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(200); + Label12.Caption := frxGet(201); + DescrL.Caption := frxGet(9); + Label1.Caption := frxGet(202); + CopiesL.Caption := frxGet(203); + CollateCB.Caption := frxGet(204); + Label2.Caption := frxGet(205); + PrintL.Caption := frxGet(206); + WhereL.Caption := frxGet(208); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + PropButton.Caption := frxGet(209); + AllRB.Caption := frxGet(3); + CurPageRB.Caption := frxGet(4); + PageNumbersRB.Caption := frxGet(5); + FileCB.Caption := frxGet(210); + NameL.Caption := frxGet(212); + ScaleGB.Caption := frxGet(213); + PagSizeL.Caption := frxGet(214); + DuplexL.Caption := frxGet(216); + OtherGB.Caption := frxGet(207); + OrderL.Caption := frxGet(211); + + OrderCB.Items.Clear; + OrderCB.Items.Add(frxResources.Get('poDirect')); + OrderCB.Items.Add(frxResources.Get('poReverse')); + + PrintPagesCB.Items.Clear; + PrintPagesCB.Items.Add(frxResources.Get('ppAll')); + PrintPagesCB.Items.Add(frxResources.Get('ppOdd')); + PrintPagesCB.Items.Add(frxResources.Get('ppEven')); + PrintPagesCB.ItemIndex := 0; + + DuplexCB.Items.Clear; + DuplexCB.Items.Add(frxResources.Get('dupDefault')); + DuplexCB.Items.Add(frxResources.Get('dupVert')); + DuplexCB.Items.Add(frxResources.Get('dupHorz')); + DuplexCB.Items.Add(frxResources.Get('dupSimpl')); + DuplexCB.ItemIndex := 0; + + PrintModeCB.Items.Clear; + PrintModeCB.Items.Add(frxResources.Get('pmDefault')); + PrintModeCB.Items.Add(frxResources.Get('pmSplit')); + PrintModeCB.Items.Add(frxResources.Get('pmJoin')); + PrintModeCB.Items.Add(frxResources.Get('pmScale')); + + SetWindowLong(CopiesE.Handle, GWL_STYLE, GetWindowLong(CopiesE.Handle, GWL_STYLE) or ES_NUMBER); + + if Screen.PixelsPerInch > 96 then + PrintersCB.ItemHeight := 19; + PrintersCB.Items.Assign(frxPrinters.Printers); + PrintersCB.ItemIndex := frxPrinters.PrinterIndex; + PrintersCBClick(nil); + + OldIndex := frxPrinters.PrinterIndex; + CollateCBClick(nil); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxPrintDialog.FormShow(Sender: TObject); +begin + UpDown1.Position := AReport.PrintOptions.Copies; + CollateCB.Checked := AReport.PrintOptions.Collate; + PageNumbersE.Text := AReport.PrintOptions.PageNumbers; + if AReport.PrintOptions.PageNumbers <> '' then + PageNumbersRB.Checked := True; + PrintPagesCB.ItemIndex := Integer(AReport.PrintOptions.PrintPages); + if AReport.PrintOptions.Reverse then + OrderCB.ItemIndex := 1 + else + OrderCB.ItemIndex := 0; + + PrintModeCB.ItemIndex := Integer(AReport.PrintOptions.PrintMode); + PrintModeCBClick(nil); + if AReport.PrintOptions.PrintMode <> pmDefault then + begin + PagPageSizeCB.ItemIndex := frxPrinters.Printer.PaperIndex(AReport.PrintOptions.PrintOnSheet) + 1; + if frxPrinters.Printer.PaperIndex(256) < frxPrinters.Printer.PaperIndex(AReport.PrintOptions.PrintOnSheet) then + PagPageSizeCB.ItemIndex := PagPageSizeCB.ItemIndex - 1; + end; +end; + +procedure TfrxPrintDialog.FormHide(Sender: TObject); +begin + if ModalResult <> mrOk then + frxPrinters.PrinterIndex := OldIndex + else + begin + frxPrinters.Printer.FileName := ''; + if FileCB.Checked then + if FileDlg.Execute then + frxPrinters.Printer.FileName := ChangeFileExt(FileDlg.FileName, '.prn') else + ModalResult := mrCancel; + end; + + if ModalResult = mrOk then + begin + AReport.PrintOptions.Copies := StrToInt(CopiesE.Text); + AReport.PrintOptions.Collate := CollateCB.Checked; + if AllRB.Checked then + AReport.PrintOptions.PageNumbers := '' + else if CurPageRB.Checked then + AReport.PrintOptions.PageNumbers := IntToStr(AReport.PreviewPages.CurPreviewPage) + else + AReport.PrintOptions.PageNumbers := PageNumbersE.Text; + AReport.PrintOptions.PrintPages := TfrxPrintPages(PrintPagesCB.ItemIndex); + ADuplexMode := TfrxDuplexMode(DuplexCB.ItemIndex); + AReport.PrintOptions.Reverse := OrderCB.ItemIndex = 1; + + AReport.PrintOptions.PrintMode := TfrxPrintMode(PrintModeCB.ItemIndex); + AReport.PrintOptions.PrintOnSheet := frxPrinters.Printer.PaperNameToNumber(PagPageSizeCB.Text); + end; +end; + +procedure TfrxPrintDialog.PrintersCBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); +begin + with PrintersCB.Canvas do + begin + FillRect(ARect); + frxResources.PreviewButtonImages.Draw(PrintersCB.Canvas, ARect.Left + 2, ARect.Top, 2); + TextOut(ARect.Left + 24, ARect.Top + 1, PrintersCB.Items[Index]); + end; +end; + +procedure TfrxPrintDialog.PropButtonClick(Sender: TObject); +begin + frxPrinters.Printer.PropertiesDlg; +end; + +procedure TfrxPrintDialog.PrintersCBClick(Sender: TObject); +var + SaveSheet: Integer; +begin + if PagPageSizeCB.ItemIndex <= 0 then + SaveSheet := -1 + else + SaveSheet := frxPrinters.Printer.PaperNameToNumber(PagPageSizeCB.Text); + + frxPrinters.PrinterIndex := PrintersCB.ItemIndex; + WhereL1.Caption := frxPrinters.Printer.Port; + PagPageSizeCB.Items := frxPrinters.Printer.Papers; + PagPageSizeCB.Items.Delete(frxPrinters.Printer.PaperIndex(256)); + PagPageSizeCB.Items.Insert(0, frxResources.Get('pgDefault')); + + if (SaveSheet <> -1) and (frxPrinters.Printer.PaperIndex(SaveSheet) <> -1) then + begin + PagPageSizeCB.ItemIndex := frxPrinters.Printer.PaperIndex(SaveSheet) + 1; + if frxPrinters.Printer.PaperIndex(256) < frxPrinters.Printer.PaperIndex(SaveSheet) then + PagPageSizeCB.ItemIndex := PagPageSizeCB.ItemIndex - 1 + end + else + PagPageSizeCB.ItemIndex := 0 +end; + +procedure TfrxPrintDialog.PageNumbersEEnter(Sender: TObject); +begin + PageNumbersRB.Checked := True; +end; + +procedure TfrxPrintDialog.PageNumbersRBClick(Sender: TObject); +begin + if Visible then + PageNumbersE.SetFocus; +end; + +procedure TfrxPrintDialog.CollateLClick(Sender: TObject); +begin + CollateCB.Checked := not CollateCB.Checked; +end; + +procedure TfrxPrintDialog.CollateCBClick(Sender: TObject); +begin + CopiesPBPaint(nil); +end; + +procedure TfrxPrintDialog.CopiesPBPaint(Sender: TObject); +begin + with CopiesPB.Canvas do + begin + Brush.Color := Color; + FillRect(Rect(0, 0, CopiesPB.Width, CopiesPB.Height)); + if CollateCB.Checked then + frxDrawTransparent(CopiesPB.Canvas, 0, 0, CollateImg.Picture.Bitmap) else + frxDrawTransparent(CopiesPB.Canvas, 0, 0, NonCollateImg.Picture.Bitmap); + end; +end; + +procedure TfrxPrintDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxPrintDialog.PrintModeCBDrawItem(Control: TWinControl; + Index: Integer; ARect: TRect; State: TOwnerDrawState); +begin + with PrintModeCB do + begin + Canvas.FillRect(ARect); + PrintModeIL.Draw(Canvas, ARect.Left + 2, ARect.Top + 1, Index); + Canvas.TextOut(ARect.Left + 74, ARect.Top + 10, Items[Index]); + end; +end; + +procedure TfrxPrintDialog.PrintModeCBClick(Sender: TObject); +var + DefaultMode: Boolean; +begin + DefaultMode := PrintModeCB.ItemIndex = 0; + if DefaultMode then + PagPageSizeCB.ItemIndex := 0; + PagPageSizeCB.Enabled := not DefaultMode; + if not DefaultMode and (PagPageSizeCB.ItemIndex = 0) then + PagPageSizeCB.ItemIndex := frxPrinters.Printer.PaperIndex(DMPAPER_A4); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxPrinter.pas b/official/4.2/LibD11/frxPrinter.pas new file mode 100644 index 0000000..72dda45 --- /dev/null +++ b/official/4.2/LibD11/frxPrinter.pas @@ -0,0 +1,964 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Printer } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxPrinter; + +interface + +{$I frx.inc} + +uses + Windows, SysUtils, Classes, Graphics, Forms, Printers +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxPrinterCanvas = class; + + TfrxCustomPrinter = class(TObject) + private + FBin: Integer; + FBins: TStrings; + FCanvas: TfrxPrinterCanvas; + FDefOrientation: TPrinterOrientation; + FDefPaper: Integer; + FDefPaperHeight: Extended; + FDefPaperWidth: Extended; + FDPI: TPoint; + FFileName: String; + FHandle: THandle; + FInitialized: Boolean; + FName: String; + FPaper: Integer; + FPapers: TStrings; + FPaperHeight: Extended; + FPaperWidth: Extended; + FLeftMargin: Extended; + FTopMargin: Extended; + FRightMargin: Extended; + FBottomMargin: Extended; + FOrientation: TPrinterOrientation; + FPort: String; + FPrinting: Boolean; + FTitle: String; + public + constructor Create(const AName, APort: String); virtual; + destructor Destroy; override; + procedure Init; virtual; abstract; + procedure Abort; virtual; abstract; + procedure BeginDoc; virtual; abstract; + procedure BeginPage; virtual; abstract; + procedure BeginRAWDoc; virtual; abstract; + procedure EndDoc; virtual; abstract; + procedure EndPage; virtual; abstract; + procedure EndRAWDoc; virtual; abstract; + procedure WriteRAWDoc(const buf: String); virtual; abstract; + + function BinIndex(ABin: Integer): Integer; + function PaperIndex(APaper: Integer): Integer; + function BinNameToNumber(const ABin: String): Integer; + function PaperNameToNumber(const APaper: String): Integer; + procedure SetViewParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; + AOrientation: TPrinterOrientation); virtual; abstract; + procedure SetPrintParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation; + ABin, ADuplex, ACopies: Integer); virtual; abstract; + procedure PropertiesDlg; virtual; abstract; + + property Bin: Integer read FBin; + property Bins: TStrings read FBins; + property Canvas: TfrxPrinterCanvas read FCanvas; + property DefOrientation: TPrinterOrientation read FDefOrientation; + property DefPaper: Integer read FDefPaper; + property DefPaperHeight: Extended read FDefPaperHeight; + property DefPaperWidth: Extended read FDefPaperWidth; + property DPI: TPoint read FDPI; + property FileName: String read FFileName write FFileName; + property Handle: THandle read FHandle; + property Name: String read FName; + property Paper: Integer read FPaper; + property Papers: TStrings read FPapers; + property PaperHeight: Extended read FPaperHeight; + property PaperWidth: Extended read FPaperWidth; + property LeftMargin: Extended read FLeftMargin; + property TopMargin: Extended read FTopMargin; + property RightMargin: Extended read FRightMargin; + property BottomMargin: Extended read FBottomMargin; + property Orientation: TPrinterOrientation read FOrientation; + property Port: String read FPort; + property Title: String read FTitle write FTitle; + end; + + TfrxVirtualPrinter = class(TfrxCustomPrinter) + public + procedure Init; override; + procedure Abort; override; + procedure BeginDoc; override; + procedure BeginPage; override; + procedure BeginRAWDoc; override; + procedure EndDoc; override; + procedure EndPage; override; + procedure EndRAWDoc; override; + procedure WriteRAWDoc(const buf: String); override; + procedure SetViewParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; + AOrientation: TPrinterOrientation); override; + procedure SetPrintParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation; + ABin, ADuplex, ACopies: Integer); override; + procedure PropertiesDlg; override; + end; + + TfrxPrinter = class(TfrxCustomPrinter) + private + FDeviceMode: THandle; + FDC: HDC; + FDriver: String; + FMode: PDeviceMode; + procedure CreateDevMode; + procedure FreeDevMode; + procedure GetDC; + procedure RecreateDC; + public + destructor Destroy; override; + procedure Init; override; + procedure Abort; override; + procedure BeginDoc; override; + procedure BeginPage; override; + procedure BeginRAWDoc; override; + procedure EndDoc; override; + procedure EndPage; override; + procedure EndRAWDoc; override; + procedure WriteRAWDoc(const buf: String); override; + procedure SetViewParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; + AOrientation: TPrinterOrientation); override; + procedure SetPrintParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation; + ABin, ADuplex, ACopies: Integer); override; + procedure PropertiesDlg; override; + procedure UpdateDeviceCaps; + property DeviceMode: PDeviceMode read FMode; + end; + + + TfrxPrinters = class(TObject) + private + FHasPhysicalPrinters: Boolean; + FPrinters: TStrings; + FPrinterIndex: Integer; + FPrinterList: TList; + function GetDefaultPrinter: String; + function GetItem(Index: Integer): TfrxCustomPrinter; + function GetCurrentPrinter: TfrxCustomPrinter; + procedure SetPrinterIndex(Value: Integer); + public + constructor Create; + destructor Destroy; override; + function IndexOf(AName: String): Integer; + procedure Clear; + procedure FillPrinters; + property Items[Index: Integer]: TfrxCustomPrinter read GetItem; default; + property HasPhysicalPrinters: Boolean read FHasPhysicalPrinters; + property Printer: TfrxCustomPrinter read GetCurrentPrinter; + property PrinterIndex: Integer read FPrinterIndex write SetPrinterIndex; + property Printers: TStrings read FPrinters; + end; + + TfrxPrinterCanvas = class(TCanvas) + private + FPrinter: TfrxCustomPrinter; + procedure UpdateFont; + public + procedure Changing; override; + end; + + +function frxPrinters: TfrxPrinters; +function frxGetPaperDimensions(PaperSize: Integer; var Width, Height: Extended): Boolean; + + +implementation + +uses frxUtils, WinSpool, Dialogs, frxRes; + + +type + TPaperInfo = packed record + Typ: Integer; + Name: String; + X, Y: Integer; + end; + + +const + PAPERCOUNT = 66; + PaperInfo: array[0..PAPERCOUNT - 1] of TPaperInfo = ( + (Typ:1; Name: ''; X:2159; Y:2794), + (Typ:2; Name: ''; X:2159; Y:2794), + (Typ:3; Name: ''; X:2794; Y:4318), + (Typ:4; Name: ''; X:4318; Y:2794), + (Typ:5; Name: ''; X:2159; Y:3556), + (Typ:6; Name: ''; X:1397; Y:2159), + (Typ:7; Name: ''; X:1842; Y:2667), + (Typ:8; Name: ''; X:2970; Y:4200), + (Typ:9; Name: ''; X:2100; Y:2970), + (Typ:10; Name: ''; X:2100; Y:2970), + (Typ:11; Name: ''; X:1480; Y:2100), + (Typ:12; Name: ''; X:2500; Y:3540), + (Typ:13; Name: ''; X:1820; Y:2570), + (Typ:14; Name: ''; X:2159; Y:3302), + (Typ:15; Name: ''; X:2150; Y:2750), + (Typ:16; Name: ''; X:2540; Y:3556), + (Typ:17; Name: ''; X:2794; Y:4318), + (Typ:18; Name: ''; X:2159; Y:2794), + (Typ:19; Name: ''; X:984; Y:2254), + (Typ:20; Name: ''; X:1048; Y:2413), + (Typ:21; Name: ''; X:1143; Y:2635), + (Typ:22; Name: ''; X:1207; Y:2794), + (Typ:23; Name: ''; X:1270; Y:2921), + (Typ:24; Name: ''; X:4318; Y:5588), + (Typ:25; Name: ''; X:5588; Y:8636), + (Typ:26; Name: ''; X:8636; Y:11176), + (Typ:27; Name: ''; X:1100; Y:2200), + (Typ:28; Name: ''; X:1620; Y:2290), + (Typ:29; Name: ''; X:3240; Y:4580), + (Typ:30; Name: ''; X:2290; Y:3240), + (Typ:31; Name: ''; X:1140; Y:1620), + (Typ:32; Name: ''; X:1140; Y:2290), + (Typ:33; Name: ''; X:2500; Y:3530), + (Typ:34; Name: ''; X:1760; Y:2500), + (Typ:35; Name: ''; X:1760; Y:1250), + (Typ:36; Name: ''; X:1100; Y:2300), + (Typ:37; Name: ''; X:984; Y:1905), + (Typ:38; Name: ''; X:920; Y:1651), + (Typ:39; Name: ''; X:3778; Y:2794), + (Typ:40; Name: ''; X:2159; Y:3048), + (Typ:41; Name: ''; X:2159; Y:3302), + (Typ:42; Name: ''; X:2500; Y:3530), + (Typ:43; Name: ''; X:1000; Y:1480), + (Typ:44; Name: ''; X:2286; Y:2794), + (Typ:45; Name: ''; X:2540; Y:2794), + (Typ:46; Name: ''; X:3810; Y:2794), + (Typ:47; Name: ''; X:2200; Y:2200), + (Typ:50; Name: ''; X:2355; Y:3048), + (Typ:51; Name: ''; X:2355; Y:3810), + (Typ:52; Name: ''; X:2969; Y:4572), + (Typ:53; Name: ''; X:2354; Y:3223), + (Typ:54; Name: ''; X:2101; Y:2794), + (Typ:55; Name: ''; X:2100; Y:2970), + (Typ:56; Name: ''; X:2355; Y:3048), + (Typ:57; Name: ''; X:2270; Y:3560), + (Typ:58; Name: ''; X:3050; Y:4870), + (Typ:59; Name: ''; X:2159; Y:3223), + (Typ:60; Name: ''; X:2100; Y:3300), + (Typ:61; Name: ''; X:1480; Y:2100), + (Typ:62; Name: ''; X:1820; Y:2570), + (Typ:63; Name: ''; X:3220; Y:4450), + (Typ:64; Name: ''; X:1740; Y:2350), + (Typ:65; Name: ''; X:2010; Y:2760), + (Typ:66; Name: ''; X:4200; Y:5940), + (Typ:67; Name: ''; X:2970; Y:4200), + (Typ:68; Name: ''; X:3220; Y:4450)); + + +var + FPrinters: TfrxPrinters = nil; + + +function frxGetPaperDimensions(PaperSize: Integer; var Width, Height: Extended): Boolean; +var + i: Integer; +begin + Result := False; + for i := 0 to PAPERCOUNT - 1 do + if PaperInfo[i].Typ = PaperSize then + begin + Width := PaperInfo[i].X / 10; + Height := PaperInfo[i].Y / 10; + Result := True; + break; + end; +end; + + +{ TfrxPrinterCanvas } + +procedure TfrxPrinterCanvas.Changing; +begin + inherited; + UpdateFont; +end; + +procedure TfrxPrinterCanvas.UpdateFont; +var + FontSize: Integer; +begin + if FPrinter.DPI.Y <> Font.PixelsPerInch then + begin + FontSize := Font.Size; + Font.PixelsPerInch := FPrinter.DPI.Y; + Font.Size := FontSize; + end; +end; + + +{ TfrxCustomPrinter } + +constructor TfrxCustomPrinter.Create(const AName, APort: String); +begin + FName := AName; + FPort := APort; + + FBins := TStringList.Create; + FBins.AddObject(frxResources.Get('prDefault'), Pointer(DMBIN_AUTO)); + + FPapers := TStringList.Create; + FPapers.AddObject(frxResources.Get('prCustom'), Pointer(256)); + + FCanvas := TfrxPrinterCanvas.Create; + FCanvas.FPrinter := Self; +end; + +destructor TfrxCustomPrinter.Destroy; +begin + FBins.Free; + FPapers.Free; + FCanvas.Free; + inherited; +end; + +function TfrxCustomPrinter.BinIndex(ABin: Integer): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to FBins.Count - 1 do + if Integer(FBins.Objects[i]) = ABin then + begin + Result := i; + break; + end; +end; + +function TfrxCustomPrinter.PaperIndex(APaper: Integer): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to FPapers.Count - 1 do + if Integer(FPapers.Objects[i]) = APaper then + begin + Result := i; + break; + end; +end; + +function TfrxCustomPrinter.BinNameToNumber(const ABin: String): Integer; +var + i: Integer; +begin + i := FBins.IndexOf(ABin); + if i = -1 then + i := 0; + Result := Integer(FBins.Objects[i]); +end; + +function TfrxCustomPrinter.PaperNameToNumber(const APaper: String): Integer; +var + i: Integer; +begin + i := FPapers.IndexOf(APaper); + if i = -1 then + i := 0; + Result := Integer(FPapers.Objects[i]); +end; + + +{ TfrxVirtualPrinter } + +procedure TfrxVirtualPrinter.Init; +var + i: Integer; +begin + if FInitialized then Exit; + + FDPI := Point(600, 600); + FDefPaper := DMPAPER_A4; + FDefOrientation := poPortrait; + FDefPaperWidth := 210; + FDefPaperHeight := 297; + + for i := 0 to PAPERCOUNT - 1 do + FPapers.AddObject(PaperInfo[i].Name, Pointer(PaperInfo[i].Typ)); + + FBin := -1; + FInitialized := True; +end; + +procedure TfrxVirtualPrinter.Abort; +begin +end; + +procedure TfrxVirtualPrinter.BeginDoc; +begin +end; + +procedure TfrxVirtualPrinter.BeginPage; +begin +end; + +procedure TfrxVirtualPrinter.EndDoc; +begin +end; + +procedure TfrxVirtualPrinter.EndPage; +begin +end; + +procedure TfrxVirtualPrinter.BeginRAWDoc; +begin +end; + +procedure TfrxVirtualPrinter.EndRAWDoc; +begin +end; + +procedure TfrxVirtualPrinter.WriteRAWDoc(const buf: String); +begin +end; + +procedure TfrxVirtualPrinter.SetViewParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation); +var + i: Integer; + Found: Boolean; +begin + Found := False; + if APaperSize <> 256 then + for i := 0 to PAPERCOUNT - 1 do + if PaperInfo[i].Typ = APaperSize then + begin + if AOrientation = poPortrait then + begin + APaperWidth := PaperInfo[i].X / 10; + APaperHeight := PaperInfo[i].Y / 10; + end + else + begin + APaperWidth := PaperInfo[i].Y / 10; + APaperHeight := PaperInfo[i].X / 10; + end; + Found := True; + break; + end; + + if not Found then + APaperSize := 256; + + FOrientation := AOrientation; + FPaper := APaperSize; + FPaperWidth := APaperWidth; + FPaperHeight := APaperHeight; + FLeftMargin := 5; + FTopMargin := 5; + FRightMargin := 5; + FBottomMargin := 5; +end; + +procedure TfrxVirtualPrinter.SetPrintParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation; + ABin, ADuplex, ACopies: Integer); +begin + SetViewParams(APaperSize, APaperWidth, APaperHeight, AOrientation); + FBin := ABin; +end; + +procedure TfrxVirtualPrinter.PropertiesDlg; +begin +end; + + +{ TfrxPrinter } + +destructor TfrxPrinter.Destroy; +begin + FreeDevMode; + inherited; +end; + +procedure TfrxPrinter.Init; + + procedure FillPapers; + var + i, PaperSizesCount: Integer; + PaperSizes: array[0..255] of Word; + PaperNames: PChar; + begin + FillChar(PaperSizes, SizeOf(PaperSizes), 0); + PaperSizesCount := DeviceCapabilities(PChar(FName), PChar(FPort), DC_PAPERS, @PaperSizes, FMode); + GetMem(PaperNames, PaperSizesCount * 64); + DeviceCapabilities(PChar(FName), PChar(FPort), DC_PAPERNAMES, PaperNames, FMode); + + for i := 0 to PaperSizesCount - 1 do + if PaperSizes[i] <> 256 then + FPapers.AddObject(StrPas(PaperNames + i * 64), Pointer(PaperSizes[i])); + + FreeMem(PaperNames, PaperSizesCount * 64); + end; + + procedure FillBins; + var + i, BinsCount: Integer; + BinNumbers: array[0..255] of Word; + BinNames: PChar; + begin + FillChar(BinNumbers, SizeOf(BinNumbers), 0); + BinsCount := DeviceCapabilities(PChar(FName), PChar(FPort), DC_BINS, @BinNumbers[0], FMode); + GetMem(BinNames, BinsCount * 64); + DeviceCapabilities(PChar(FName), PChar(FPort), DC_BINNAMES, BinNames, FMode); + + for i := 0 to BinsCount - 1 do + if BinNumbers[i] <> DMBIN_AUTO then + FBins.AddObject(StrPas(BinNames + i * 24), Pointer(BinNumbers[i])); + + FreeMem(BinNames, BinsCount * 64); + end; + +begin + if FInitialized then Exit; + + CreateDevMode; + if FDeviceMode = 0 then Exit; + RecreateDC; + + UpdateDeviceCaps; + FDefPaper := FMode.dmPaperSize; + FPaper := FDefPaper; + FDefPaperWidth := FPaperWidth; + FDefPaperHeight := FPaperHeight; + if FMode.dmOrientation = DMORIENT_PORTRAIT then + FDefOrientation := poPortrait else + FDefOrientation := poLandscape; + FOrientation := FDefOrientation; + + FillPapers; + FillBins; + FBin := -1; + + FInitialized := True; +end; + +procedure TfrxPrinter.Abort; +begin + AbortDoc(FDC); + EndDoc; +end; + +procedure TfrxPrinter.BeginDoc; +var + DocInfo: TDocInfo; +begin + FPrinting := True; + + FillChar(DocInfo, SizeOf(DocInfo), 0); + DocInfo.cbSize := SizeOf(DocInfo); + DocInfo.lpszDocName := PChar(FTitle); + if FFileName <> '' then + DocInfo.lpszOutput := PChar(FFileName); + + RecreateDC; + StartDoc(FDC, DocInfo); +end; + +procedure TfrxPrinter.BeginPage; +begin + StartPage(FDC); +end; + +procedure TfrxPrinter.EndDoc; +var + Saved8087CW: Word; +begin + Saved8087CW := Default8087CW; + Set8087CW($133F); + try + Windows.EndDoc(FDC); + except + end; + Set8087CW(Saved8087CW); + + FPrinting := False; + RecreateDC; + FBin := -1; +end; + +procedure TfrxPrinter.EndPage; +begin + Windows.EndPage(FDC); +end; + +procedure TfrxPrinter.BeginRAWDoc; +var + DocInfo1: TDocInfo1; +begin + RecreateDC; + DocInfo1.pDocName := PChar(FTitle); + DocInfo1.pOutputFile := nil; + DocInfo1.pDataType := 'RAW'; + StartDocPrinter(FHandle, 1, @DocInfo1); + StartPagePrinter(FHandle); +end; + +procedure TfrxPrinter.EndRAWDoc; +begin + EndPagePrinter(FHandle); + EndDocPrinter(FHandle); +end; + +procedure TfrxPrinter.WriteRAWDoc(const buf: String); +var + N: DWORD; +begin + WritePrinter(FHandle, PChar(buf), Length(buf), N); +end; + +procedure TfrxPrinter.CreateDevMode; +var + bufSize: Integer; + dm: TDeviceMode; +begin + if OpenPrinter(PChar(FName), FHandle, nil) then + begin + bufSize := DocumentProperties(0, FHandle, PChar(FName), dm, dm, 0); + if bufSize > 0 then + begin + FDeviceMode := GlobalAlloc(GHND, bufSize); + if FDeviceMode <> 0 then + begin + FMode := GlobalLock(FDeviceMode); + if DocumentProperties(0, FHandle, PChar(FName), FMode^, FMode^, + DM_OUT_BUFFER) < 0 then + begin + GlobalUnlock(FDeviceMode); + GlobalFree(FDeviceMode); + FDeviceMode := 0; + FMode := nil; + end + end; + end; + end; +end; + +procedure TfrxPrinter.FreeDevMode; +begin + FCanvas.Handle := 0; + if FDC <> 0 then + DeleteDC(FDC); + if FHandle <> 0 then + ClosePrinter(FHandle); + if FDeviceMode <> 0 then + begin + GlobalUnlock(FDeviceMode); + GlobalFree(FDeviceMode); + end; +end; + +procedure TfrxPrinter.RecreateDC; +begin + if FDC <> 0 then + try + DeleteDC(FDC); + except + end; + FDC := 0; + GetDC; +end; + +procedure TfrxPrinter.GetDC; +begin + if FDC = 0 then + begin + if FPrinting then + FDC := CreateDC(PChar(FDriver), PChar(FName), nil, FMode) else + FDC := CreateIC(PChar(FDriver), PChar(FName), nil, FMode); + FCanvas.Handle := FDC; + FCanvas.Refresh; + FCanvas.UpdateFont; + end; +end; + +procedure TfrxPrinter.SetViewParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation); +begin + if APaperSize <> 256 then + begin + FMode.dmFields := DM_PAPERSIZE or DM_ORIENTATION; + FMode.dmPaperSize := APaperSize; + if AOrientation = poPortrait then + FMode.dmOrientation := DMORIENT_PORTRAIT else + FMode.dmOrientation := DMORIENT_LANDSCAPE; + RecreateDC; + UpdateDeviceCaps; + end + else + begin + // copy the margins from A4 paper + SetViewParams(DMPAPER_A4, 0, 0, AOrientation); + FPaperHeight := APaperHeight; + FPaperWidth := APaperWidth; + end; + + FPaper := APaperSize; + FOrientation := AOrientation; +end; + +procedure TfrxPrinter.SetPrintParams(APaperSize: Integer; + APaperWidth, APaperHeight: Extended; AOrientation: TPrinterOrientation; + ABin, ADuplex, ACopies: Integer); +begin + FMode.dmFields := FMode.dmFields or DM_PAPERSIZE or DM_ORIENTATION or DM_COPIES or + DM_DEFAULTSOURCE; + if ADuplex <> 1 then + FMode.dmFields := FMode.dmFields or DM_DUPLEX; + + if APaperSize = 256 then + begin + FMode.dmFields := FMode.dmFields or DM_PAPERLENGTH or DM_PAPERWIDTH; + FMode.dmPaperLength := Round(APaperHeight * 10); + FMode.dmPaperWidth := Round(APaperWidth * 10); + end + else + begin + FMode.dmPaperLength := 0; + FMode.dmPaperWidth := 0; + end; + + FMode.dmPaperSize := APaperSize; + + if AOrientation = poPortrait then + FMode.dmOrientation := DMORIENT_PORTRAIT else + FMode.dmOrientation := DMORIENT_LANDSCAPE; + + FMode.dmCopies := ACopies; + if FBin <> -1 then + ABin := FBin; + if ABin <> DMBIN_AUTO then + FMode.dmDefaultSource := ABin; + if ADuplex = 4 then + FMode.dmDuplex := DMDUP_SIMPLEX + else if ADuplex <> 1 then + FMode.dmDuplex := ADuplex; + + FDC := ResetDC(FDC, FMode^); + FDC := ResetDC(FDC, FMode^); // needed for some printers + FCanvas.Refresh; + UpdateDeviceCaps; + FPaper := APaperSize; + FOrientation := AOrientation; +end; + +procedure TfrxPrinter.UpdateDeviceCaps; +begin + FDPI := Point(GetDeviceCaps(FDC, LOGPIXELSX), GetDeviceCaps(FDC, LOGPIXELSY)); + if (FDPI.X = 0) or (FDPI.Y = 0) then + raise Exception.Create('Printer selected is not valid'); + FPaperHeight := Round(GetDeviceCaps(FDC, PHYSICALHEIGHT) / FDPI.Y * 25.4); + FPaperWidth := Round(GetDeviceCaps(FDC, PHYSICALWIDTH) / FDPI.X * 25.4); + FLeftMargin := Round(GetDeviceCaps(FDC, PHYSICALOFFSETX) / FDPI.X * 25.4); + FTopMargin := Round(GetDeviceCaps(FDC, PHYSICALOFFSETY) / FDPI.Y * 25.4); + FRightMargin := FPaperWidth - Round(GetDeviceCaps(FDC, HORZRES) / FDPI.X * 25.4) - FLeftMargin; + FBottomMargin := FPaperHeight - Round(GetDeviceCaps(FDC, VERTRES) / FDPI.Y * 25.4) - FTopMargin; +end; + +procedure TfrxPrinter.PropertiesDlg; +var + h: THandle; +begin + if Screen.ActiveForm <> nil then + h := Screen.ActiveForm.Handle else + h := 0; + if DocumentProperties(h, FHandle, PChar(FName), FMode^, + FMode^, DM_IN_BUFFER or DM_OUT_BUFFER or DM_IN_PROMPT) > 0 then + begin + FBin := FMode.dmDefaultSource; + RecreateDC; + end; +end; + + +{ TfrxPrinters } + +constructor TfrxPrinters.Create; +begin + FPrinterList := TList.Create; + FPrinters := TStringList.Create; + + FillPrinters; + if FPrinterList.Count = 0 then + begin + FPrinterList.Add(TfrxVirtualPrinter.Create(frxResources.Get('prVirtual'), '')); + FHasPhysicalPrinters := False; + PrinterIndex := 0; + end + else + begin + FHasPhysicalPrinters := True; + PrinterIndex := IndexOf(GetDefaultPrinter); + end; +end; + +destructor TfrxPrinters.Destroy; +begin + Clear; + FPrinterList.Free; + FPrinters.Free; + inherited; +end; + +procedure TfrxPrinters.Clear; +begin + while FPrinterList.Count > 0 do + begin + TObject(FPrinterList[0]).Free; + FPrinterList.Delete(0); + end; + FPrinters.Clear; +end; + +function TfrxPrinters.GetItem(Index: Integer): TfrxCustomPrinter; +begin + Result := FPrinterList[Index]; +end; + +function TfrxPrinters.IndexOf(AName: String): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to FPrinterList.Count - 1 do + if AnsiCompareText(Items[i].Name, AName) = 0 then + begin + Result := i; + break; + end; +end; + +procedure TfrxPrinters.SetPrinterIndex(Value: Integer); +begin + if Value <> -1 then + FPrinterIndex := Value + else + FPrinterIndex := IndexOf(GetDefaultPrinter); + Items[FPrinterIndex].Init; +end; + +function TfrxPrinters.GetCurrentPrinter: TfrxCustomPrinter; +begin + Result := Items[PrinterIndex]; +end; + +function TfrxPrinters.GetDefaultPrinter: String; +var + prnName: array[0..255] of Char; +begin + GetProfileString('windows', 'device', '', prnName, 255); + Result := Copy(prnName, 1, Pos(',', prnName) - 1); +end; + +procedure TfrxPrinters.FillPrinters; +var + i, j: Integer; + Buf, prnInfo: PChar; + Flags, bufSize, prnCount: DWORD; + Level: Byte; + sl: TStringList; + + procedure AddPrinter(ADevice, APort: String); + begin + FPrinterList.Add(TfrxPrinter.Create(ADevice, APort)); + FPrinters.Add(ADevice); + end; + +begin + Clear; + if Win32Platform = VER_PLATFORM_WIN32_NT then + begin + Flags := PRINTER_ENUM_CONNECTIONS or PRINTER_ENUM_LOCAL; + Level := 4; + end + else + begin + Flags := PRINTER_ENUM_LOCAL; + Level := 5; + end; + + bufSize := 0; + EnumPrinters(Flags, nil, Level, nil, 0, bufSize, prnCount); + if bufSize = 0 then Exit; + + GetMem(Buf, bufSize); + try + if not EnumPrinters(Flags, nil, Level, PByte(Buf), bufSize, bufSize, prnCount) then + Exit; + prnInfo := Buf; + + for i := 0 to prnCount - 1 do + if Level = 4 then + with PPrinterInfo4(prnInfo)^ do + begin + AddPrinter(pPrinterName, ''); + Inc(prnInfo, SizeOf(TPrinterInfo4)); + end + else + with PPrinterInfo5(prnInfo)^ do + begin + sl := TStringList.Create; + frxSetCommaText(pPortName, sl, ','); + + for j := 0 to sl.Count - 1 do + AddPrinter(pPrinterName, sl[j]); + + sl.Free; + Inc(prnInfo, SizeOf(TPrinterInfo5)); + end; + + finally + FreeMem(Buf, bufSize); + end; +end; + + + +function frxPrinters: TfrxPrinters; +begin + if FPrinters = nil then + FPrinters := TfrxPrinters.Create; + Result := FPrinters; +end; + + +initialization + FPrinters := nil; + +finalization + if FPrinters <> nil then + FPrinters.Free; + FPrinters := nil; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxProgress.dfm b/official/4.2/LibD11/frxProgress.dfm new file mode 100644 index 0000000..eeb58fa Binary files /dev/null and b/official/4.2/LibD11/frxProgress.dfm differ diff --git a/official/4.2/LibD11/frxProgress.pas b/official/4.2/LibD11/frxProgress.pas new file mode 100644 index 0000000..7827399 --- /dev/null +++ b/official/4.2/LibD11/frxProgress.pas @@ -0,0 +1,161 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Progress } +{ } +{ Copyright (c) 2004-2007 } +{ by Alexander Fediachov, } +{ Fast Reports, Inc. } +{ } +{******************************************} + +unit frxProgress; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ComCtrls, StdCtrls, ExtCtrls; + +type + TfrxProgress = class(TForm) + Panel1: TPanel; + LMessage: TLabel; + Bar: TProgressBar; + CancelB: TButton; + procedure WMNCHitTest(var Message :TWMNCHitTest); message WM_NCHITTEST; + procedure FormCreate(Sender: TObject); + procedure CancelBClick(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormDestroy(Sender: TObject); + private + FActiveForm: TForm; + FTerminated: Boolean; + FPosition: Integer; + FMessage: String; + FProgress: Boolean; + procedure SetPosition(Value: Integer); + procedure SetMessage(const Value: String); + procedure SetTerminated(Value: Boolean); + procedure SetProgress(Value: Boolean); + public + procedure Reset; + procedure Execute(MaxValue: Integer; const Msg: String; + Canceled: Boolean; Progress: Boolean); + procedure Tick; + property Terminated: Boolean read FTerminated write SetTerminated; + property Position: Integer read FPosition write SetPosition; + property ShowProgress: Boolean read FProgress write SetProgress; + property Message: String read FMessage write SetMessage; + end; + + +implementation + +{$R *.DFM} + +uses frxRes; + +{ TfrxProgress } + +procedure TfrxProgress.WMNCHitTest(var Message: TWMNCHitTest); +begin + inherited; + if Message.Result = htClient then + Message.Result := htCaption; +end; + +procedure TfrxProgress.FormCreate(Sender: TObject); +begin + CancelB.Caption := frxGet(2); + FActiveForm := Screen.ActiveForm; + if FActiveForm <> nil then + FActiveForm.Enabled := False; + Bar.Min := 0; + Bar.Max := 100; + Position := 0; + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxProgress.FormDestroy(Sender: TObject); +begin + if FActiveForm <> nil then + FActiveForm.Enabled := True; +end; + +procedure TfrxProgress.FormHide(Sender: TObject); +begin + if FActiveForm <> nil then + FActiveForm.Enabled := True; +end; + +procedure TfrxProgress.Reset; +begin + Position := 0; +end; + +procedure TfrxProgress.SetPosition(Value: Integer); +begin + FPosition := Value; + Bar.Position := Value; + BringToFront; + Application.ProcessMessages; +end; + +procedure TfrxProgress.Execute(MaxValue: Integer; const Msg: String; + Canceled: Boolean; Progress: Boolean); +begin + Terminated := False; + CancelB.Visible := Canceled; + ShowProgress := Progress; + Bar.Min := 0; + Reset; + Bar.Max := MaxValue; + Message := Msg; + Show; + Application.ProcessMessages; +end; + +procedure TfrxProgress.Tick; +begin + if (Position < Bar.Max) and (Position >= Bar.Min) then + Position := Position + 1; +end; + +procedure TfrxProgress.SetMessage(const Value: String); +begin + FMessage := Value; + LMessage.Caption := Value; + LMessage.Refresh; +end; + +procedure TfrxProgress.CancelBClick(Sender: TObject); +begin + Terminated := True; +end; + +procedure TfrxProgress.SetTerminated(Value: boolean); +begin + FTerminated := Value; + if Value then Close; +end; + +procedure TfrxProgress.SetProgress(Value: boolean); +begin + Bar.Visible := Value; + FProgress := Value; + if Value then + LMessage.Top := 15 + else + LMessage.Top := 35; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxReg.dcr b/official/4.2/LibD11/frxReg.dcr new file mode 100644 index 0000000..c2daa6e Binary files /dev/null and b/official/4.2/LibD11/frxReg.dcr differ diff --git a/official/4.2/LibD11/frxReg.pas b/official/4.2/LibD11/frxReg.pas new file mode 100644 index 0000000..63015a4 --- /dev/null +++ b/official/4.2/LibD11/frxReg.pas @@ -0,0 +1,138 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Registration unit } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxReg; + +{$I frx.inc} +//{$I frxReg.inc} + +interface + + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, +{$IFNDEF Delphi6} + DsgnIntf, +{$ELSE} + DesignIntf, DesignEditors, +{$ENDIF} + Dialogs, frxClass, + frxDock, frxCtrls, frxDesgnCtrls, + frxDesgn, frxPreview, frxRich, frxOLE, frxBarCode, + frxChBox, frxDMPExport, +{$IFNDEF FR_VER_BASIC} + frxDCtrl, +{$ENDIF} + frxCross, frxRichEdit, frxGradient, + frxGZip, frxEditAliases, frxCrypt; + +{-----------------------------------------------------------------------} +type + TfrxReportEditor = class(TComponentEditor) + procedure ExecuteVerb(Index: Integer); override; + function GetVerb(Index: Integer): String; override; + function GetVerbCount: Integer; override; + end; + + TfrxDataSetEditor = class(TComponentEditor) + procedure ExecuteVerb(Index: Integer); override; + function GetVerb(Index: Integer): String; override; + function GetVerbCount: Integer; override; + end; + + +{ TfrxReportEditor } + +procedure TfrxReportEditor.ExecuteVerb(Index: Integer); +var + Report: TfrxReport; +begin + Report := TfrxReport(Component); + if Report.Designer <> nil then + Report.Designer.BringToFront + else + begin + Report.DesignReport(Designer, Self); + if Report.StoreInDFM then + Designer.Modified; + end; +end; + +function TfrxReportEditor.GetVerb(Index: Integer): String; +begin + Result := 'Edit Report...'; +end; + +function TfrxReportEditor.GetVerbCount: Integer; +begin + Result := 1; +end; + + +{ TfrxDataSetEditor } + +procedure TfrxDataSetEditor.ExecuteVerb(Index: Integer); +begin + with TfrxAliasesEditorForm.Create(Application) do + begin + DataSet := TfrxCustomDBDataSet(Component); + if ShowModal = mrOk then + Self.Designer.Modified; + Free; + end; +end; + +function TfrxDataSetEditor.GetVerb(Index: Integer): String; +begin + Result := 'Edit Fields Aliases...'; +end; + +function TfrxDataSetEditor.GetVerbCount: Integer; +begin + Result := 1; +end; + + +{-----------------------------------------------------------------------} +procedure Register; +begin + RegisterComponents('FastReport 4.0', + [TfrxReport, TfrxUserDataset, +{$IFNDEF FR_VER_BASIC} + TfrxDesigner, +{$ENDIF} + TfrxPreview, + TfrxBarcodeObject, TfrxOLEObject, TfrxRichObject, + TfrxCrossObject, TfrxCheckBoxObject, TfrxGradientObject, + TfrxDotMatrixExport +{$IFNDEF FR_VER_BASIC} + , TfrxDialogControls +{$ENDIF} + , TfrxGZipCompressor, TfrxCrypt + ]); + + RegisterComponents('FR4 tools', + [TfrxDockSite, TfrxTBPanel, TfrxComboEdit, + TfrxComboBox, TfrxFontComboBox, TfrxRuler, TfrxScrollBox]); + + RegisterComponentEditor(TfrxReport, TfrxReportEditor); + RegisterComponentEditor(TfrxCustomDBDataSet, TfrxDataSetEditor); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxRegCS.dcr b/official/4.2/LibD11/frxRegCS.dcr new file mode 100644 index 0000000..4cacfb6 Binary files /dev/null and b/official/4.2/LibD11/frxRegCS.dcr differ diff --git a/official/4.2/LibD11/frxRegCS.pas b/official/4.2/LibD11/frxRegCS.pas new file mode 100644 index 0000000..37cd39e --- /dev/null +++ b/official/4.2/LibD11/frxRegCS.pas @@ -0,0 +1,40 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Registration unit } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxRegCS; + +{$I frx.inc} + +interface + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, +{$IFNDEF Delphi6} + DsgnIntf, +{$ELSE} + DesignIntf, DesignEditors, +{$ENDIF} + frxServer, frxServerClient, frxHTTPClient; + +{-----------------------------------------------------------------------} +procedure Register; +begin + RegisterComponents('FastReport 4.0 Client/Server', + [TfrxReportServer, TfrxServerConnection, TfrxReportClient, + TfrxHTTPClient]); +end; + +end. diff --git a/official/4.2/LibD11/frxRegDB.pas b/official/4.2/LibD11/frxRegDB.pas new file mode 100644 index 0000000..3b8c871 --- /dev/null +++ b/official/4.2/LibD11/frxRegDB.pas @@ -0,0 +1,48 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Registration unit } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxRegDB; + +{$I frx.inc} + +interface + + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes, Forms, Controls, +{$IFNDEF Delphi6} + DsgnIntf, +{$ELSE} + DesignIntf, DesignEditors, +{$ENDIF} + frxDBSet, + frxCustomDB, + frxCustomDBEditor, + frxCustomDBRTTI, + frxEditMD, + frxEditQueryParams; + + +{-----------------------------------------------------------------------} +procedure Register; +begin + RegisterComponents('FastReport 4.0', [TfrxDBDataset]); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxRegIBO.pas b/official/4.2/LibD11/frxRegIBO.pas new file mode 100644 index 0000000..3c47217 --- /dev/null +++ b/official/4.2/LibD11/frxRegIBO.pas @@ -0,0 +1,42 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Registration unit } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxRegIBO; + +{$I frx.inc} + +interface + + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes, Forms, Controls, +{$IFNDEF Delphi6} + DsgnIntf, +{$ELSE} + DesignIntf, DesignEditors, +{$ENDIF} + frxIBOSet; + +{-----------------------------------------------------------------------} +procedure Register; +begin + RegisterComponents('FastReport 4.0', [TfrxIBODataset]); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxRegTee.pas b/official/4.2/LibD11/frxRegTee.pas new file mode 100644 index 0000000..49109c5 --- /dev/null +++ b/official/4.2/LibD11/frxRegTee.pas @@ -0,0 +1,43 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Registration unit } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxRegTee; + +{$I frx.inc} + +interface + + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, +{$IFNDEF Delphi6} + DsgnIntf, +{$ELSE} + DesignIntf, DesignEditors, +{$ENDIF} + frxChart; + + +procedure Register; +begin + RegisterComponents('FastReport 4.0', + [TfrxChartObject]); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxReportTree.dfm b/official/4.2/LibD11/frxReportTree.dfm new file mode 100644 index 0000000..d27ad2a Binary files /dev/null and b/official/4.2/LibD11/frxReportTree.dfm differ diff --git a/official/4.2/LibD11/frxReportTree.pas b/official/4.2/LibD11/frxReportTree.pas new file mode 100644 index 0000000..a5cc894 --- /dev/null +++ b/official/4.2/LibD11/frxReportTree.pas @@ -0,0 +1,214 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report Tree } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxReportTree; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + ComCtrls, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxReportTreeForm = class(TForm) + Tree: TTreeView; + procedure FormShow(Sender: TObject); + procedure TreeChange(Sender: TObject; Node: TTreeNode); + procedure FormCreate(Sender: TObject); + procedure TreeKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + FComponents: TList; + FDesigner: TfrxCustomDesigner; + FNodes: TList; + FReport: TfrxReport; + FUpdating: Boolean; + FOnSelectionChanged: TNotifyEvent; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure SetColor(Value: TColor); + procedure UpdateItems; + procedure UpdateSelection; + property OnSelectionChanged: TNotifyEvent read FOnSelectionChanged + write FOnSelectionChanged; + end; + + +implementation + +{$R *.DFM} + +uses frxRes, frxDesgn, frxDsgnIntf; + +type + THackWinControl = class(TWinControl); + + +{ TfrxReportTreeForm } + +constructor TfrxReportTreeForm.Create(AOwner: TComponent); +begin + inherited; + FComponents := TList.Create; + FNodes := TList.Create; +{$IFDEF UseTabset} + Tree.BevelKind := bkFlat; +{$ELSE} + Tree.BorderStyle := bsSingle; +{$ENDIF} +end; + +destructor TfrxReportTreeForm.Destroy; +begin + FComponents.Free; + FNodes.Free; + inherited; +end; + +procedure TfrxReportTreeForm.FormShow(Sender: TObject); +begin + UpdateItems; +end; + +procedure TfrxReportTreeForm.UpdateItems; + + procedure SetImageIndex(Node: TTreeNode; Index: Integer); + begin + Node.ImageIndex := Index; + Node.StateIndex := Index; + Node.SelectedIndex := Index; + end; + + procedure EnumItems(c: TfrxComponent; RootNode: TTreeNode); + var + i: Integer; + Node: TTreeNode; + Item: TfrxObjectItem; + begin + Node := Tree.Items.AddChild(RootNode, c.Name); + FComponents.Add(c); + FNodes.Add(Node); + Node.Data := c; + if c is TfrxReport then + begin + Node.Text := 'Report'; + SetImageIndex(Node, 34); + end + else if c is TfrxReportPage then + SetImageIndex(Node, 35) + else if c is TfrxDialogPage then + SetImageIndex(Node, 36) + else if c is TfrxDataPage then + SetImageIndex(Node, 37) + else if c is TfrxBand then + SetImageIndex(Node, 40) + else + begin + for i := 0 to frxObjects.Count - 1 do + begin + Item := frxObjects[i]; + if Item.ClassRef = c.ClassType then + begin + SetImageIndex(Node, Item.ButtonImageIndex); + break; + end; + end; + end; + + if c is TfrxDataPage then + begin + for i := 0 to c.Objects.Count - 1 do + if TObject(c.Objects[i]) is TfrxDialogComponent then + EnumItems(c.Objects[i], Node) + end + else + for i := 0 to c.Objects.Count - 1 do + EnumItems(c.Objects[i], Node); + end; + +begin + Tree.Items.BeginUpdate; + Tree.Items.Clear; + FComponents.Clear; + FNodes.Clear; + EnumItems(FReport, nil); + + Tree.FullExpand; + UpdateSelection; + Tree.Items.EndUpdate; +end; + +procedure TfrxReportTreeForm.TreeChange(Sender: TObject; Node: TTreeNode); +begin + if FUpdating then Exit; + FDesigner.SelectedObjects.Clear; + FDesigner.SelectedObjects.Add(Tree.Selected.Data); + if Assigned(FOnSelectionChanged) then + FOnSelectionChanged(Self); +end; + +procedure TfrxReportTreeForm.SetColor(Value: TColor); +begin + Tree.Color := Value; + UpdateItems; +end; + +procedure TfrxReportTreeForm.FormCreate(Sender: TObject); +begin + FDesigner := TfrxCustomDesigner(Owner); + FReport := FDesigner.Report; + Tree.Images := frxResources.ObjectImages; + Caption := frxGet(2200); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxReportTreeForm.UpdateSelection; +var + c: TComponent; + i: Integer; +begin + if FDesigner.SelectedObjects.Count = 0 then Exit; + c := FDesigner.SelectedObjects[0]; + FUpdating := True; + + i := FComponents.IndexOf(c); + if i <> -1 then + begin + TTreeNode(FNodes[i]).Selected := True; + Tree.TopItem := TTreeNode(FNodes[i]); + end; + + FUpdating := False; +end; + +procedure TfrxReportTreeForm.TreeKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = vk_Delete then + begin + THackWinControl(TfrxDesignerForm(FDesigner).Workspace).KeyDown(Key, Shift); + end; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxRes.pas b/official/4.2/LibD11/frxRes.pas new file mode 100644 index 0000000..8249c38 --- /dev/null +++ b/official/4.2/LibD11/frxRes.pas @@ -0,0 +1,515 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Language resources management } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxRes; + +interface + +{$I frx.inc} + +uses + Windows, SysUtils, Classes, Controls, Graphics, Forms, ImgList, TypInfo +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF FR_COM} +, ComObj +, FastReport_TLB +, DispatchablePersistent +{$ENDIF}; + + +type +{$IFDEF FR_COM} + TfrxResources = class(TDispatchablePersistent, IfrxResources) +{$ELSE} + TfrxResources = class(TObject) +{$ENDIF} + private + FDisabledButtonImages: TImageList; + FMainButtonImages: TImageList; + FNames: TStringList; + FObjectImages: TImageList; + FPreviewButtonImages: TImageList; + FValues: TStringList; + FWizardImages: TImageList; + FLanguages: TStringList; + FHelpFile: String; + procedure BuildLanguagesList; + function GetMainButtonImages: TImageList; + function GetObjectImages: TImageList; + function GetPreviewButtonImages: TImageList; + function GetWizardImages: TImageList; + public + constructor Create; + destructor Destroy; override; + function Get(const StrName: String): String; + procedure Add(const Ref, Str: String); + procedure AddStrings(const Str: String); + procedure Clear; + procedure LoadFromFile(const FileName: String); + procedure LoadFromStream(Stream: TStream); + procedure SetButtonImages(Images: TBitmap; Clear: Boolean = False); + procedure SetObjectImages(Images: TBitmap; Clear: Boolean = False); + procedure SetPreviewButtonImages(Images: TBitmap; Clear: Boolean = False); + procedure SetWizardImages(Images: TBitmap; Clear: Boolean = False); + procedure UpdateFSResources; + procedure Help(Sender: TObject); overload; + property DisabledButtonImages: TImageList read FDisabledButtonImages; + property MainButtonImages: TImageList read GetMainButtonImages; + property PreviewButtonImages: TImageList read GetPreviewButtonImages; + property ObjectImages: TImageList read GetObjectImages; + property WizardImages: TImageList read GetWizardImages; + property Languages: TStringList read FLanguages; + property HelpFile: String read FHelpFile write FHelpFile; +{$IFDEF FR_COM} + function Get_HelpFile(out Value: WideString): HResult; stdcall; + function Set_HelpFile(const Value: WideString): HResult; stdcall; + function Help: HResult; overload; stdcall; + function GetResourceString(const ID: WideString; out Value: WideString): HResult; stdcall; + function LoadLanguageResourcesFromFile(const FileName: WideString): HResult; stdcall; +{$ENDIF} + end; + +function frxResources: TfrxResources; +function frxGet(ID: Integer): String; + + +implementation + +uses frxUtils, frxChm, fs_iconst, frxGZip; + +var + FResources: TfrxResources = nil; + + +{ TfrxResources } + +constructor TfrxResources.Create; +begin +{$IFDEF FR_COM} + inherited Create(IfrxResources); +{$ELSE} + inherited; +{$ENDIF} + FDisabledButtonImages := TImageList.Create(nil); + FDisabledButtonImages.Width := 16; + FDisabledButtonImages.Height := 16; + FMainButtonImages := TImageList.Create(nil); + FMainButtonImages.Width := 16; + FMainButtonImages.Height := 16; + FObjectImages := TImageList.Create(nil); + FObjectImages.Width := 16; + FObjectImages.Height := 16; + FPreviewButtonImages := TImageList.Create(nil); + FPreviewButtonImages.Width := 16; + FPreviewButtonImages.Height := 16; + FWizardImages := TImageList.Create(nil); + FWizardImages.Width := 32; + FWizardImages.Height := 32; + FNames := TStringList.Create; + FValues := TStringList.Create; + FNames.Sorted := True; + FLanguages := TStringList.Create; + HelpFile := 'FRUser.chm'; + BuildLanguagesList; +end; + +destructor TfrxResources.Destroy; +begin + FLanguages.Free; + FDisabledButtonImages.Free; + FMainButtonImages.Free; + FObjectImages.Free; + FPreviewButtonImages.Free; + FWizardImages.Free; + FNames.Free; + FValues.Free; + inherited; +end; + +procedure TfrxResources.Add(const Ref, Str: String); +var + i: Integer; +begin + i := FNames.IndexOf(Ref); + if i = -1 then + begin + FNames.AddObject(Ref, Pointer(FValues.Count)); + FValues.Add(Str); + end + else + FValues[Integer(FNames.Objects[i])] := Str; +end; + +procedure TfrxResources.AddStrings(const Str: String); +var + i: Integer; + sl: TStringList; + nm, vl: String; +begin + sl := TStringList.Create; + sl.Text := Str; + for i := 0 to sl.Count - 1 do + begin + nm := sl[i]; + vl := Copy(nm, Pos('=', nm) + 1, MaxInt); + nm := Copy(nm, 1, Pos('=', nm) - 1); + if (nm <> '') and (vl <> '') then + Add(nm, vl); + end; + sl.Free; +end; + +procedure TfrxResources.Clear; +begin + FNames.Clear; + FValues.Clear; +end; + +function TfrxResources.Get(const StrName: String): String; +var + i: Integer; +begin + i := FNames.IndexOf(StrName); + if i <> -1 then + Result := FValues[Integer(FNames.Objects[i])] else + Result := StrName; + if (Result <> '') and (Result[1] = '!') then + Delete(Result, 1, 1); +end; + +function TfrxResources.GetMainButtonImages: TImageList; +var + Images: TBitmap; + stm: TMemoryStream; + res: TResourceStream; +begin + if FMainButtonImages.Count = 0 then + begin + Images := TBitmap.Create; + stm := TMemoryStream.Create; + res := TResourceStream.Create(hInstance, 'DesgnButtons', RT_RCDATA); + try + frxDecompressStream(res, stm); + stm.Position := 0; + Images.LoadFromStream(stm); + SetButtonImages(Images); + finally + stm.Free; + res.Free; + Images.Free; + end; + end; + + Result := FMainButtonImages; +end; + +function TfrxResources.GetPreviewButtonImages: TImageList; +var + Images: TBitmap; + stm: TMemoryStream; + res: TResourceStream; +begin + if FPreviewButtonImages.Count = 0 then + begin + Images := TBitmap.Create; + stm := TMemoryStream.Create; + res := TResourceStream.Create(hInstance, 'PreviewButtons', RT_RCDATA); + try + frxDecompressStream(res, stm); + stm.Position := 0; + Images.LoadFromStream(stm); + SetPreviewButtonImages(Images); + finally + stm.Free; + res.Free; + Images.Free; + end; + end; + + Result := FPreviewButtonImages; +end; + +function TfrxResources.GetObjectImages: TImageList; +var + Images: TBitmap; + stm: TMemoryStream; + res: TResourceStream; +begin + if FObjectImages.Count = 0 then + begin + Images := TBitmap.Create; + stm := TMemoryStream.Create; + res := TResourceStream.Create(hInstance, 'ObjectButtons', RT_RCDATA); + try + frxDecompressStream(res, stm); + stm.Position := 0; + Images.LoadFromStream(stm); + SetObjectImages(Images); + finally + stm.Free; + res.Free; + Images.Free; + end; + end; + + Result := FObjectImages; +end; + +function TfrxResources.GetWizardImages: TImageList; +var + Images: TBitmap; + stm: TMemoryStream; + res: TResourceStream; +begin + if FWizardImages.Count = 0 then + begin + Images := TBitmap.Create; + stm := TMemoryStream.Create; + res := TResourceStream.Create(hInstance, 'WizardButtons', RT_RCDATA); + try + frxDecompressStream(res, stm); + stm.Position := 0; + Images.LoadFromStream(stm); + SetWizardImages(Images); + finally + stm.Free; + res.Free; + Images.Free; + end; + end; + + Result := FWizardImages; +end; + +procedure TfrxResources.SetButtonImages(Images: TBitmap; Clear: Boolean = False); +begin + if Clear then + begin + FMainButtonImages.Clear; + FDisabledButtonImages.Clear; + end; + frxAssignImages(Images, 16, 16, FMainButtonImages, FDisabledButtonImages); +end; + +procedure TfrxResources.SetObjectImages(Images: TBitmap; Clear: Boolean = False); +begin + if Clear then + FObjectImages.Clear; + frxAssignImages(Images, 16, 16, FObjectImages); +end; + +procedure TfrxResources.SetPreviewButtonImages(Images: TBitmap; Clear: Boolean = False); +begin + if Clear then + FPreviewButtonImages.Clear; + frxAssignImages(Images, 16, 16, FPreviewButtonImages); +end; + +procedure TfrxResources.SetWizardImages(Images: TBitmap; Clear: Boolean = False); +begin + if Clear then + FWizardImages.Clear; + frxAssignImages(Images, 32, 32, FWizardImages); +end; + +procedure TfrxResources.LoadFromFile(const FileName: String); +var + f: TFileStream; +begin + if FileExists(FileName) then + begin + f := TFileStream.Create(FileName, fmOpenRead); + try + LoadFromStream(f); + finally + f.Free; + end; + end; +end; + +procedure TfrxResources.LoadFromStream(Stream: TStream); +var + sl: TStringList; + i: Integer; + nm, vl: String; +begin + sl := TStringList.Create; + try + sl.LoadFromStream(Stream); + Clear; + for i := 0 to sl.Count - 1 do + begin + nm := sl[i]; + vl := Copy(nm, Pos('=', nm) + 1, MaxInt); + nm := Copy(nm, 1, Pos('=', nm) - 1); + if (nm <> '') and (vl <> '') then + Add(nm, vl); + end; + finally + sl.Free; + end; + UpdateFSResources; +end; + +procedure TfrxResources.UpdateFSResources; +begin + SLangNotFound := Get('SLangNotFound'); + SInvalidLanguage := Get('SInvalidLanguage'); + SIdRedeclared := Get('SIdRedeclared'); + SUnknownType := Get('SUnknownType'); + SIncompatibleTypes := Get('SIncompatibleTypes'); + SIdUndeclared := Get('SIdUndeclared'); + SClassRequired := Get('SClassRequired'); + SIndexRequired := Get('SIndexRequired'); + SStringError := Get('SStringError'); + SClassError := Get('SClassError'); + SArrayRequired := Get('SArrayRequired'); + SVarRequired := Get('SVarRequired'); + SNotEnoughParams := Get('SNotEnoughParams'); + STooManyParams := Get('STooManyParams'); + SLeftCantAssigned := Get('SLeftCantAssigned'); + SForError := Get('SForError'); + SEventError := Get('SEventError'); +end; + +type + THelpTopic = record + Sender: String; + Topic: String; + end; + +const + helpTopicsCount = 17; + helpTopics: array[0..helpTopicsCount - 1] of THelpTopic = + ((Sender: 'TfrxDesignerForm'; Topic: 'Designer.htm'), + (Sender: 'TfrxOptionsEditor'; Topic: 'Designer_options.htm'), + (Sender: 'TfrxReportEditorForm'; Topic: 'Report_options.htm'), + (Sender: 'TfrxPageEditorForm'; Topic: 'Page_options.htm'), + (Sender: 'TfrxCrossEditorForm'; Topic: 'Cross_tab_reports.htm'), + (Sender: 'TfrxChartEditorForm'; Topic: 'Diagrams.htm'), + (Sender: 'TfrxSyntaxMemo'; Topic: 'Script.htm'), + (Sender: 'TfrxDialogPage'; Topic: 'Dialogue_forms.htm'), + (Sender: 'TfrxDialogComponent'; Topic: 'Data_access_components.htm'), + (Sender: 'TfrxVarEditorForm'; Topic: 'Variables.htm'), + (Sender: 'TfrxHighlightEditorForm'; Topic: 'Conditional_highlighting.htm'), + (Sender: 'TfrxSysMemoEditorForm'; Topic: 'Inserting_aggregate_function.htm'), + (Sender: 'TfrxFormatEditorForm'; Topic: 'Values_formatting.htm'), + (Sender: 'TfrxGroupEditorForm'; Topic: 'Report_with_groups.htm'), + (Sender: 'TfrxPictureEditorForm'; Topic: 'Picture_object.htm'), + (Sender: 'TfrxMemoEditorForm'; Topic: 'Text_object.htm'), + (Sender: 'TfrxSQLEditorForm'; Topic: 'TfrxADOQuery.htm') + ); + + + + +procedure TfrxResources.Help(Sender: TObject); +var + i: Integer; + topic: String; +begin + topic := ''; + if Sender <> nil then + for i := 0 to helpTopicsCount - 1 do + if CompareText(helpTopics[i].Sender, Sender.ClassName) = 0 then + topic := '::/' + helpTopics[i].Topic; + frxDisplayHHTopic(Application.Handle, ExtractFilePath(Application.ExeName) + FHelpFile + topic); +end; + +procedure TfrxResources.BuildLanguagesList; +var + i: Integer; + SRec: TSearchRec; + Dir: String; + s: String; +begin + Dir := GetAppPath; + FLanguages.Clear; + i := FindFirst(Dir + '*.frc', faAnyFile, SRec); + try + while i = 0 do + begin + s := LowerCase(SRec.Name); + s := UpperCase(Copy(s, 1, 1)) + Copy(s, 2, Length(s) - 1); + s := StringReplace(s, '.frc', '', []); + FLanguages.Add(s); + i := FindNext(SRec); + end; + FLanguages.Sort; + finally + FindClose(Srec); + end; +end; + + +function frxResources: TfrxResources; +begin + if FResources = nil then + FResources := TfrxResources.Create; + Result := FResources; +end; + +function frxGet(ID: Integer): String; +begin + Result := frxResources.Get(IntToStr(ID)); +end; + +{$IFDEF FR_COM} +function TfrxResources.Get_HelpFile(out Value: WideString): HResult; stdcall; +begin + Value := HelpFile; + Result := S_OK; +end; + +function TfrxResources.Set_HelpFile(const Value: WideString): HResult; stdcall; +begin + HelpFile := Value; + Result := S_OK; +end; + +function TfrxResources.Help: HResult; stdcall; +begin + Help(nil); + Result := S_OK; +end; + +function TfrxResources.GetResourceString(const ID: WideString; out Value: WideString): HResult; stdcall; +begin + Value := Get(ID); + Result := S_OK; +end; + +function TfrxResources.LoadLanguageResourcesFromFile(const FileName: WideString): HResult; stdcall; +begin + try + LoadFromFile(FileName); + Result := S_OK; + except + Result := E_FAIL; + end; +end; +{$ENDIF} + + +initialization + +finalization + if FResources <> nil then + FResources.Free; + FResources := nil; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxRich.pas b/official/4.2/LibD11/frxRich.pas new file mode 100644 index 0000000..d64adb7 --- /dev/null +++ b/official/4.2/LibD11/frxRich.pas @@ -0,0 +1,625 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ RichEdit Add-In Object } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxRich; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Forms, Menus, frxClass, + RichEdit, frxRichEdit, frxPrinter +{$IFDEF Delphi6} +, Variants +{$ENDIF} +{$IFDEF FR_COM} +, ActiveX, AxCtrls +, ClrStream +, FastReport_TLB +{$ENDIF}; + + +type + TfrxRichObject = class(TComponent) // fake component + end; + +{$IFDEF FR_COM} + TfrxRichView = class(TfrxStretcheable, IfrxRichView) +{$ELSE} + TfrxRichView = class(TfrxStretcheable) +{$ENDIF} + private + FAllowExpressions: Boolean; + FExpressionDelimiters: String; + FFlowTo: TfrxRichView; + FGapX: Extended; + FGapY: Extended; + FParaBreak: Boolean; + FRichEdit: TrxRichEdit; + FTempStream: TMemoryStream; + FTempStream1: TMemoryStream; + FWysiwyg: Boolean; + function CreateMetafile: TMetafile; + function IsExprDelimitersStored: Boolean; + function UsePrinterCanvas: Boolean; + procedure ReadData(Stream: TStream); + procedure WriteData(Stream: TStream); +{$IFDEF FR_COM} + function LoadViewFromStream(const Stream: IUnknown): HResult; stdcall; + function SaveViewToStream(const Stream: IUnknown): HResult; stdcall; + function Get_RichAlign(out Value: frxHAlign): HResult; stdcall; + function Set_RichAlign(Value: frxHAlign): HResult; stdcall; + function Get_WYSIWIG(out Value: WordBool): HResult; stdcall; + function Set_WYSIWIG(Value: WordBool): HResult; stdcall; + function Get_AllowExpressions(out Value: WordBool): HResult; stdcall; + function Set_AllowExpressions(Value: WordBool): HResult; stdcall; +{$ENDIF} + protected + procedure DefineProperties(Filer: TFiler); override; + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, OffsetY: Extended); override; + procedure AfterPrint; override; + procedure BeforePrint; override; + procedure GetData; override; + procedure InitPart; override; + function CalcHeight: Extended; override; + function DrawPart: Extended; override; + class function GetDescription: String; override; + function GetComponentText: String; override; + property RichEdit: TrxRichEdit read FRichEdit; + published + property AllowExpressions: Boolean read FAllowExpressions + write FAllowExpressions default True; + property BrushStyle; + property Color; + property Cursor; + property DataField; + property DataSet; + property DataSetName; + property ExpressionDelimiters: String read FExpressionDelimiters + write FExpressionDelimiters stored IsExprDelimitersStored; + property FlowTo: TfrxRichView read FFlowTo write FFlowTo; + property Frame; + property GapX: Extended read FGapX write FGapX; + property GapY: Extended read FGapY write FGapY; + property TagStr; + property URL; + property Wysiwyg: Boolean read FWysiwyg write FWysiwyg default True; + end; + + +procedure frxAssignRich(RichFrom, RichTo: TrxRichEdit); + + +implementation + +uses + frxRichRTTI, +{$IFNDEF NO_EDITORS} + frxRichEditor, +{$ENDIF} + frxUtils, frxDsgnIntf, frxRes; + + +procedure frxAssignRich(RichFrom, RichTo: TrxRichEdit); +var + st: TMemoryStream; +begin + st := TMemoryStream.Create; + try + RichFrom.Lines.SaveToStream(st); + st.Position := 0; + RichTo.Lines.LoadFromStream(st); + finally + st.Free; + end; +end; + + +{ TfrxRichView } + +constructor TfrxRichView.Create(AOwner: TComponent); +begin + inherited; + FRichEdit := TrxRichEdit.Create(nil); + FRichEdit.Parent := frxParentForm; + SendMessage(frxParentForm.Handle, WM_CREATEHANDLE, Integer(FRichEdit), 0); + FRichEdit.AutoURLDetect := False; + { make rich transparent } + SetWindowLong(FRichEdit.Handle, GWL_EXSTYLE, + GetWindowLong(FRichEdit.Handle, GWL_EXSTYLE) or WS_EX_TRANSPARENT); + + FTempStream := TMemoryStream.Create; + FTempStream1 := TMemoryStream.Create; + + FAllowExpressions := True; + FExpressionDelimiters := '[,]'; + FGapX := 2; + FGapY := 1; + FWysiwyg := True; +end; + +destructor TfrxRichView.Destroy; +begin + SendMessage(frxParentForm.Handle, WM_DESTROYHANDLE, Integer(FRichEdit), 0); + FRichEdit.Free; + FTempStream.Free; + FTempStream1.Free; + inherited; +end; + +class function TfrxRichView.GetDescription: String; +begin + Result := frxResources.Get('obRich'); +end; + +function TfrxRichView.IsExprDelimitersStored: Boolean; +begin + Result := FExpressionDelimiters <> '[,]'; +end; + +procedure TfrxRichView.DefineProperties(Filer: TFiler); +begin + inherited; + Filer.DefineBinaryProperty('RichEdit', ReadData, WriteData, True); +end; + +procedure TfrxRichView.ReadData(Stream: TStream); +begin + FRichEdit.Lines.LoadFromStream(Stream); +end; + +procedure TfrxRichView.WriteData(Stream: TStream); +begin + FRichEdit.Lines.SaveToStream(Stream); +end; + +procedure TfrxRichView.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited Notification(AComponent, Operation); + if (Operation = opRemove) and (AComponent = FFlowTo) then + FFlowTo := nil; +end; + +function TfrxRichView.UsePrinterCanvas: Boolean; +begin + Result := frxPrinters.HasPhysicalPrinters and FWysiwyg; +end; + +function TfrxRichView.CreateMetafile: TMetafile; +var + Range: TFormatRange; + EMFCanvas: TMetafileCanvas; + PrinterHandle: THandle; +begin + if UsePrinterCanvas then + PrinterHandle := frxPrinters.Printer.Canvas.Handle + else + PrinterHandle := GetDC(0); + FillChar(Range, SizeOf(TFormatRange), 0); + + with Range do + begin + rc := Rect(Round(GapX * 1440 / 96), Round(GapY * 1440 / 96), + Round((Width - GapX) * 1440 / 96), + Round((Height - GapY) * 1440 / 96)); + rcPage := rc; + + Result := TMetafile.Create; + Result.Width := Round(Width * GetDeviceCaps(PrinterHandle, LOGPIXELSX) / 96); + Result.Height := Round(Height * GetDeviceCaps(PrinterHandle, LOGPIXELSY) / 96); + + EMFCanvas := TMetafileCanvas.Create(Result, PrinterHandle); + hdc := EMFCanvas.Handle; + hdcTarget := hdc; + + chrg.cpMin := 0; + chrg.cpMax := -1; + FRichEdit.Perform(EM_FORMATRANGE, 1, Integer(@Range)); + end; + + if not UsePrinterCanvas then + ReleaseDC(0, PrinterHandle); + + FRichEdit.Perform(EM_FORMATRANGE, 0, 0); + EMFCanvas.Free; +end; + +procedure TfrxRichView.Draw(Canvas: TCanvas; ScaleX, ScaleY, OffsetX, + OffsetY: Extended); +var + EMF: TMetafile; +begin + BeginDraw(Canvas, ScaleX, ScaleY, OffsetX, OffsetY); + DrawBackground; + + EMF := CreateMetafile; + try + Canvas.StretchDraw(Rect(FX, FY, FX1, FY1), EMF); + finally + EMF.Free; + end; + + DrawFrame; +end; + +procedure TfrxRichView.BeforePrint; +begin + inherited; + FTempStream.Position := 0; + FRichEdit.Lines.SaveToStream(FTempStream); +end; + +procedure TfrxRichView.AfterPrint; +begin + FTempStream.Position := 0; + FRichEdit.Lines.LoadFromStream(FTempStream); + inherited; +end; + +procedure TfrxRichView.GetData; +var + ss: TStringStream; + i, j, TextLen: Integer; + s1, s2, dc1, dc2: String; + + function GetSpecial(const s: String; Pos: Integer): Integer; + var + i: Integer; + begin + Result := 0; + for i := 1 to Pos do + if s[i] in [#10, #13] then + Inc(Result); + end; + + function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer; + var + I,X: Integer; + Len, LenSubStr: Integer; + begin + if Offset = 1 then + Result := Pos(SubStr, S) + else + begin + I := Offset; + LenSubStr := Length(SubStr); + Len := Length(S) - LenSubStr + 1; + while I <= Len do + begin + if S[I] = SubStr[1] then + begin + X := 1; + while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do + Inc(X); + if (X = LenSubStr) then + begin + Result := I; + exit; + end; + end; + Inc(I); + end; + Result := 0; + end; + end; + +begin + inherited; + if IsDataField then + begin + ss := TStringStream.Create(VarToStr(DataSet.Value[DataField])); + try + FRichEdit.Lines.LoadFromStream(ss); + finally + ss.Free; + end; + end; + + if FAllowExpressions then + begin + dc1 := FExpressionDelimiters; + dc2 := Copy(dc1, Pos(',', dc1) + 1, 255); + dc1 := Copy(dc1, 1, Pos(',', dc1) - 1); + + with FRichEdit do + try + Lines.BeginUpdate; + + i := Pos(dc1, Text); + while i > 0 do + begin + SelStart := i - 1 - GetSpecial(Text, i) div 2; + s1 := frxGetBrackedVariable(Text, dc1, dc2, i, j); + s2 := VarToStr(Report.Calc(s1)); + + SelLength := j - i + 1; + TextLen := Length(Text) - SelLength; + SelText := s2; + + i := PosEx(dc1, Text, i + Length(Text) - TextLen); + end; + finally + Lines.EndUpdate; + end; + end; + + if FFlowTo <> nil then + begin + InitPart; + DrawPart; + FTempStream1.Position := 0; + FlowTo.RichEdit.Lines.LoadFromStream(FTempStream1); + FFlowTo.AllowExpressions := False; + end; +end; + +function TfrxRichView.CalcHeight: Extended; +var + Range: TFormatRange; +begin + FillChar(Range, SizeOf(TFormatRange), 0); + with Range do + begin + rc := Rect(0, 0, Round((Width - GapX * 2) * 1440 / 96), Round(1000000 * 1440.0 / 96)); + rcPage := rc; + if UsePrinterCanvas then + hdc := frxPrinters.Printer.Canvas.Handle + else + hdc := GetDC(0); + hdcTarget := hdc; + + chrg.cpMin := 0; + chrg.cpMax := -1; + FRichEdit.Perform(EM_FORMATRANGE, 0, Integer(@Range)); + + if not UsePrinterCanvas then + ReleaseDC(0, hdc); + if RichEdit.GetTextLen = 0 then + Result := 0 + else + Result := Round(rc.Bottom / (1440.0 / 96)) + 2 * GapY + 2; + end; + + FRichEdit.Perform(EM_FORMATRANGE, 0, 0); +end; + +function TfrxRichView.DrawPart: Extended; +var + Range: TFormatRange; + LastChar: Integer; +begin + { get remained part of text } + FTempStream1.Position := 0; + FRichEdit.Lines.LoadFromStream(FTempStream1); + if FParaBreak then + begin +// FRichEdit.SelStart := 1; +// FRichEdit.SelLength := 1; + FRichEdit.Paragraph.FirstIndent := 0; + FRichEdit.Paragraph.LeftIndent := 0; + end; + + { calculate the last visible char } + FillChar(Range, SizeOf(TFormatRange), 0); + with Range do + begin + rc := Rect(0, 0, Round((Width - GapX * 2) * 1440 / 96), + Round((Height - GapY * 2) * 1440 / 96)); + rcPage := rc; + if UsePrinterCanvas then + hdc := frxPrinters.Printer.Canvas.Handle + else + hdc := GetDC(0); + hdcTarget := hdc; + + chrg.cpMin := 0; + chrg.cpMax := -1; + LastChar := FRichEdit.Perform(EM_FORMATRANGE, 0, Integer(@Range)); + Result := Round((rcPage.Bottom - rc.Bottom) / (1440.0 / 96)) + 2 * GapY + 0.1; + + if not UsePrinterCanvas then + ReleaseDC(0, hdc); + end; + FRichEdit.Perform(EM_FORMATRANGE, 0, 0); + + { text can't fit } + if Result < 0 then + begin + Result := Height; + Exit; + end; + + { copy the outbounds text to the temp stream } + try + if LastChar > 1 then + begin + FRichEdit.SelStart := LastChar - 1; + FRichEdit.SelLength := 1; + FParaBreak := FRichEdit.SelText <> #13; + end; + + FRichEdit.SelStart := LastChar; + FRichEdit.SelLength := FRichEdit.GetTextLen - LastChar + 1; + if FRichEdit.SelLength = 1 then + Result := 0; + FTempStream1.Clear; + FRichEdit.StreamMode := [smSelection]; + FRichEdit.Lines.SaveToStream(FTempStream1); + FRichEdit.SelText := ''; + finally + FRichEdit.StreamMode := []; + end; +end; + +procedure TfrxRichView.InitPart; +begin + FTempStream1.Clear; + FRichEdit.Lines.SaveToStream(FTempStream1); + FParaBreak := False; +end; + +function TfrxRichView.GetComponentText: String; +var + FTStream: TMemoryStream; +begin + if PlainText then + begin + FTStream := TMemoryStream.Create; + try + FTempStream.Clear; + FRichEdit.Lines.SaveToStream(FTStream); + FRichEdit.PlainText := True; + FRichEdit.Lines.SaveToStream(FTempStream); + SetLength(Result, FTempStream.Size); + FTempStream.Position := 0; + FTempStream.Read(Result[1], FTempStream.Size); + FRichEdit.PlainText := False; + FTStream.Position := 0; + FRichEdit.Lines.LoadFromStream(FTStream); + finally + FTStream.Free; + end; + end + else + begin + FTempStream.Clear; + FRichEdit.Lines.SaveToStream(FTempStream); + SetLength(Result, FTempStream.Size); + FTempStream.Position := 0; + FTempStream.Read(Result[1], FTempStream.Size); + end; +end; + +{$IFDEF FR_COM} +function TfrxRichView.LoadViewFromStream(const Stream: IUnknown): HResult; stdcall; +var + ComStream: IStream; + OleStream: TOleStream; + + NetStream: _Stream; + ClrStream: TClrStream; +begin + try + Result := Stream.QueryInterface(IStream, ComStream); + if Result = S_OK then + begin + OleStream := TOleStream.Create(ComStream); + ReadData(OleStream); + OleStream.Free; + ComStream := nil; + end + else + begin + Result := Stream.QueryInterface(_Stream, NetStream); + if Result = S_OK then + begin + ClrStream := TClrStream.Create(NetStream); + ReadData(ClrStream); + ClrStream.Free; + NetStream._Release(); + end; + end; + except + Result := E_FAIL; + end; +end; + +function TfrxRichView.SaveViewToStream(const Stream: IUnknown): HResult; stdcall; +var + ComStream: IStream; + OleStream: TOleStream; + + NetStream: _Stream; + ClrStream: TClrStream; +begin + try + Result := Stream.QueryInterface(IStream, ComStream); + if Result = S_OK then + begin + OleStream := TOleStream.Create(ComStream); + WriteData(OleStream); + OleStream.Free; + ComStream := nil; + end + else + begin + Result := Stream.QueryInterface(_Stream, NetStream); + if Result = S_OK then + begin + ClrStream := TClrStream.Create(NetStream); + WriteData(ClrStream); + ClrStream.Free; + NetStream._Release(); + end; + end; + except + Result := E_FAIL; + end; +end; + +function TfrxRichView.Get_RichAlign(out Value: frxHAlign): HResult; stdcall; +begin + Result := S_OK; + Value := frxHAlign(FRichEdit.Paragraph.Alignment); +end; + +function TfrxRichView.Set_RichAlign(Value: frxHAlign): HResult; stdcall; +begin + Result := S_OK; + FRichEdit.SelectAll; + case Value of + hAlignLeft: FRichEdit.Paragraph.Alignment := paLeftJustify; + hAlignRight: FRichEdit.Paragraph.Alignment := paRightJustify; + hAlignCenter: FRichEdit.Paragraph.Alignment := paCenter; + hAlignBlock: FRichEdit.Paragraph.Alignment := paJustify; + else Result := E_FAIL; + end; +end; + +function TfrxRichView.Get_WYSIWIG(out Value: WordBool): HResult; stdcall; +begin + Value := FWysiwyg; + Result := S_OK; +end; + +function TfrxRichView.Set_WYSIWIG(Value: WordBool): HResult; stdcall; +begin + FWysiwyg := Value; + Result := S_OK; +end; + +function TfrxRichView.Get_AllowExpressions(out Value: WordBool): HResult; stdcall; +begin + Value := FAllowExpressions; + Result := S_OK; +end; + +function TfrxRichView.Set_AllowExpressions(Value: WordBool): HResult; stdcall; +begin + FAllowExpressions := Value; + Result := S_OK; +end; +{$ENDIF} + +initialization + frxObjects.RegisterObject1(TfrxRichView, nil, '', '', 0, 26); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxRichEdit.pas b/official/4.2/LibD11/frxRichEdit.pas new file mode 100644 index 0000000..6d74e28 --- /dev/null +++ b/official/4.2/LibD11/frxRichEdit.pas @@ -0,0 +1,4362 @@ +{*******************************************************} +{ } +{ Delphi VCL Extensions (RX) } +{ } +{ Copyright (c) 1998 Master-Bank } +{ } +{ Changes made by Alexander Tzyganenko: } +{ - removed ifdefs to match Delphi4 and above } +{ - removed maxmin unit from uses list } +{ } +{*******************************************************} + +unit frxRichEdit; + +{$I frx.inc} + +interface + +uses + Windows, ActiveX, ComObj, CommCtrl, Messages, SysUtils, Classes, Controls, + Forms, Graphics, StdCtrls, Dialogs, RichEdit, Menus, ComCtrls; + +type + TRichEditVersion = 1..3; + +{$IFDEF RICHBCB} + TCharFormat2A = record + cbSize: UINT; + dwMask: DWORD; + dwEffects: DWORD; + yHeight: Longint; + yOffset: Longint; + crTextColor: TColorRef; + bCharSet: Byte; + bPitchAndFamily: Byte; + szFaceName: array[0..LF_FACESIZE - 1] of AnsiChar; + { new fields in version 2.0 } + wWeight: Word; { Font weight (LOGFONT value) } + sSpacing: Smallint; { Amount to space between letters } + crBackColor: TColorRef; { Background color } + lid: LCID; { Locale ID } + dwReserved: DWORD; { Reserved. Must be 0 } + sStyle: Smallint; { Style handle } + wKerning: Word; { Twip size above which to kern char pair } + bUnderlineType: Byte; { Underline type } + bAnimation: Byte; { Animated text like marching ants } + bRevAuthor: Byte; { Revision author index } + bReserved1: Byte; + end; + TCharFormat2 = TCharFormat2A; + + TParaFormat2 = record + cbSize: UINT; + dwMask: DWORD; + wNumbering: Word; + wReserved: Word; + dxStartIndent: Longint; + dxRightIndent: Longint; + dxOffset: Longint; + wAlignment: Word; + cTabCount: Smallint; + rgxTabs: array [0..MAX_TAB_STOPS - 1] of Longint; + { new fields in version 2.0 } + dySpaceBefore: Longint; { Vertical spacing before paragraph } + dySpaceAfter: Longint; { Vertical spacing after paragraph } + dyLineSpacing: Longint; { Line spacing depending on Rule } + sStyle: Smallint; { Style handle } + bLineSpacingRule: Byte; { Rule for line spacing (see tom.doc) } + bCRC: Byte; { Reserved for CRC for rapid searching } + wShadingWeight: Word; { Shading in hundredths of a per cent } + wShadingStyle: Word; { Nibble 0: style, 1: cfpat, 2: cbpat } + wNumberingStart: Word; { Starting value for numbering } + wNumberingStyle: Word; { Alignment, roman/arabic, (), ), ., etc.} + wNumberingTab: Word; { Space bet 1st indent and 1st-line text } + wBorderSpace: Word; { Space between border and text (twips) } + wBorderWidth: Word; { Border pen width (twips) } + wBorders: Word; { Byte 0: bits specify which borders } + { Nibble 2: border style, 3: color index } + end; +{$ENDIF} + +type + TRxCustomRichEdit = class; + +{ TRxTextAttributes } + + TRxAttributeType = (atDefaultText, atSelected, atWord); + TRxConsistentAttribute = (caBold, caColor, caFace, caItalic, caSize, + caStrikeOut, caUnderline, caProtected, caOffset, caHidden, caLink, + caBackColor, caDisabled, caWeight, caSubscript, caRevAuthor); + TRxConsistentAttributes = set of TRxConsistentAttribute; + TSubscriptStyle = (ssNone, ssSubscript, ssSuperscript); + TUnderlineType = (utNone, utSolid, utWord, utDouble, utDotted, utWave); + + TRxTextAttributes = class(TPersistent) + private + RichEdit: TRxCustomRichEdit; + FType: TRxAttributeType; + procedure AssignFont(Font: TFont); + procedure GetAttributes(var Format: TCharFormat2); + function GetCharset: TFontCharset; + procedure SetCharset(Value: TFontCharset); + function GetSubscriptStyle: TSubscriptStyle; + procedure SetSubscriptStyle(Value: TSubscriptStyle); + function GetBackColor: TColor; + function GetColor: TColor; + function GetConsistentAttributes: TRxConsistentAttributes; + function GetHeight: Integer; + function GetHidden: Boolean; + function GetDisabled: Boolean; + function GetLink: Boolean; + function GetName: TFontName; + function GetOffset: Integer; + function GetPitch: TFontPitch; + function GetProtected: Boolean; + function GetRevAuthorIndex: Byte; + function GetSize: Integer; + function GetStyle: TFontStyles; + function GetUnderlineType: TUnderlineType; + procedure SetAttributes(var Format: TCharFormat2); + procedure SetBackColor(Value: TColor); + procedure SetColor(Value: TColor); + procedure SetDisabled(Value: Boolean); + procedure SetHeight(Value: Integer); + procedure SetHidden(Value: Boolean); + procedure SetLink(Value: Boolean); + procedure SetName(Value: TFontName); + procedure SetOffset(Value: Integer); + procedure SetPitch(Value: TFontPitch); + procedure SetProtected(Value: Boolean); + procedure SetRevAuthorIndex(Value: Byte); + procedure SetSize(Value: Integer); + procedure SetStyle(Value: TFontStyles); + procedure SetUnderlineType(Value: TUnderlineType); + protected + procedure InitFormat(var Format: TCharFormat2); + procedure AssignTo(Dest: TPersistent); override; + public + constructor Create(AOwner: TRxCustomRichEdit; AttributeType: TRxAttributeType); + procedure Assign(Source: TPersistent); override; + property Charset: TFontCharset read GetCharset write SetCharset; + property BackColor: TColor read GetBackColor write SetBackColor; + property Color: TColor read GetColor write SetColor; + property ConsistentAttributes: TRxConsistentAttributes read GetConsistentAttributes; + property Disabled: Boolean read GetDisabled write SetDisabled; + property Hidden: Boolean read GetHidden write SetHidden; + property Link: Boolean read GetLink write SetLink; + property Name: TFontName read GetName write SetName; + property Offset: Integer read GetOffset write SetOffset; + property Pitch: TFontPitch read GetPitch write SetPitch; + property Protected: Boolean read GetProtected write SetProtected; + property RevAuthorIndex: Byte read GetRevAuthorIndex write SetRevAuthorIndex; + property SubscriptStyle: TSubscriptStyle read GetSubscriptStyle write SetSubscriptStyle; + property Size: Integer read GetSize write SetSize; + property Style: TFontStyles read GetStyle write SetStyle; + property Height: Integer read GetHeight write SetHeight; + property UnderlineType: TUnderlineType read GetUnderlineType write SetUnderlineType; + end; + +{ TRxParaAttributes } + + TRxNumbering = (nsNone, nsBullet, nsArabicNumbers, nsLoCaseLetter, + nsUpCaseLetter, nsLoCaseRoman, nsUpCaseRoman); + TRxNumberingStyle = (nsParenthesis, nsPeriod, nsEnclosed, nsSimple); + TParaAlignment = (paLeftJustify, paRightJustify, paCenter, paJustify); + TLineSpacingRule = (lsSingle, lsOneAndHalf, lsDouble, lsSpecifiedOrMore, + lsSpecified, lsMultiple); + THeadingStyle = 0..9; + TParaTableStyle = (tsNone, tsTableRow, tsTableCellEnd, tsTableCell); + + TRxParaAttributes = class(TPersistent) + private + RichEdit: TRxCustomRichEdit; + procedure GetAttributes(var Paragraph: TParaFormat2); + function GetAlignment: TParaAlignment; + function GetFirstIndent: Longint; + function GetHeadingStyle: THeadingStyle; + function GetLeftIndent: Longint; + function GetRightIndent: Longint; + function GetSpaceAfter: Longint; + function GetSpaceBefore: Longint; + function GetLineSpacing: Longint; + function GetLineSpacingRule: TLineSpacingRule; + function GetNumbering: TRxNumbering; + function GetNumberingStyle: TRxNumberingStyle; + function GetNumberingTab: Word; + function GetTab(Index: Byte): Longint; + function GetTabCount: Integer; + function GetTableStyle: TParaTableStyle; + procedure SetAlignment(Value: TParaAlignment); + procedure SetAttributes(var Paragraph: TParaFormat2); + procedure SetFirstIndent(Value: Longint); + procedure SetHeadingStyle(Value: THeadingStyle); + procedure SetLeftIndent(Value: Longint); + procedure SetRightIndent(Value: Longint); + procedure SetSpaceAfter(Value: Longint); + procedure SetSpaceBefore(Value: Longint); + procedure SetLineSpacing(Value: Longint); + procedure SetLineSpacingRule(Value: TLineSpacingRule); + procedure SetNumbering(Value: TRxNumbering); + procedure SetNumberingStyle(Value: TRxNumberingStyle); + procedure SetNumberingTab(Value: Word); + procedure SetTab(Index: Byte; Value: Longint); + procedure SetTabCount(Value: Integer); + procedure SetTableStyle(Value: TParaTableStyle); + protected + procedure InitPara(var Paragraph: TParaFormat2); + procedure AssignTo(Dest: TPersistent); override; + public + constructor Create(AOwner: TRxCustomRichEdit); + procedure Assign(Source: TPersistent); override; + property Alignment: TParaAlignment read GetAlignment write SetAlignment; + property FirstIndent: Longint read GetFirstIndent write SetFirstIndent; + property HeadingStyle: THeadingStyle read GetHeadingStyle write SetHeadingStyle; + property LeftIndent: Longint read GetLeftIndent write SetLeftIndent; + property LineSpacing: Longint read GetLineSpacing write SetLineSpacing; + property LineSpacingRule: TLineSpacingRule read GetLineSpacingRule write SetLineSpacingRule; + property Numbering: TRxNumbering read GetNumbering write SetNumbering; + property NumberingStyle: TRxNumberingStyle read GetNumberingStyle write SetNumberingStyle; + property NumberingTab: Word read GetNumberingTab write SetNumberingTab; + property RightIndent: Longint read GetRightIndent write SetRightIndent; + property SpaceAfter: Longint read GetSpaceAfter write SetSpaceAfter; + property SpaceBefore: Longint read GetSpaceBefore write SetSpaceBefore; + property Tab[Index: Byte]: Longint read GetTab write SetTab; + property TabCount: Integer read GetTabCount write SetTabCount; + property TableStyle: TParaTableStyle read GetTableStyle write SetTableStyle; + end; + +{ TOEMConversion } + + TOEMConversion = class(TConversion) + public + function ConvertReadStream(Stream: TStream; Buffer: PChar; BufSize: Integer): Integer; override; + function ConvertWriteStream(Stream: TStream; Buffer: PChar; BufSize: Integer): Integer; override; + end; + +{ TRxCustomRichEdit } + + TUndoName = (unUnknown, unTyping, unDelete, unDragDrop, unCut, unPaste); + TRichSearchType = (stWholeWord, stMatchCase, stBackward, stSetSelection); + TRichSearchTypes = set of TRichSearchType; + TRichSelection = (stText, stObject, stMultiChar, stMultiObject); + TRichSelectionType = set of TRichSelection; + TRichLangOption = (rlAutoKeyboard, rlAutoFont, rlImeCancelComplete, + rlImeAlwaysSendNotify); + TRichLangOptions = set of TRichLangOption; + TRichStreamFormat = (sfDefault, sfRichText, sfPlainText); + TRichStreamMode = (smSelection, smPlainRtf, smNoObjects, smUnicode); + TRichStreamModes = set of TRichStreamMode; + TRichEditURLClickEvent = procedure(Sender: TObject; const URLText: string; + Button: TMouseButton) of object; + TRichEditProtectChangeEx = procedure(Sender: TObject; const Message: TMessage; + StartPos, EndPos: Integer; var AllowChange: Boolean) of object; + TRichEditFindErrorEvent = procedure(Sender: TObject; const FindText: string) of object; + TRichEditFindCloseEvent = procedure(Sender: TObject; Dialog: TFindDialog) of object; + + PRichConversionFormat = ^TRichConversionFormat; + TRichConversionFormat = record + ConversionClass: TConversionClass; + Extension: string; + PlainText: Boolean; + Next: PRichConversionFormat; + end; + + TRxCustomRichEdit = class(TCustomMemo) + private + FHideScrollBars: Boolean; + FSelectionBar: Boolean; + FAutoURLDetect: Boolean; + FWordSelection: Boolean; + FPlainText: Boolean; + FSelAttributes: TRxTextAttributes; + FDefAttributes: TRxTextAttributes; + FWordAttributes: TRxTextAttributes; + FParagraph: TRxParaAttributes; + FOldParaAlignment: TParaAlignment; + FScreenLogPixels: Integer; + FUndoLimit: Integer; + FRichEditStrings: TStrings; + FMemStream: TMemoryStream; + FHideSelection: Boolean; + FLangOptions: TRichLangOptions; + FModified: Boolean; + FLinesUpdating: Boolean; + FPageRect: TRect; + FClickRange: TCharRange; + FClickBtn: TMouseButton; + FFindDialog: TFindDialog; + FReplaceDialog: TReplaceDialog; + FLastFind: TFindDialog; + FAllowObjects: Boolean; + FCallback: TObject; + FRichEditOle: IUnknown; + FPopupVerbMenu: TPopupMenu; + FTitle: string; + FAutoVerbMenu: Boolean; + FAllowInPlace: Boolean; + FDefaultConverter: TConversionClass; + FOnSelChange: TNotifyEvent; + FOnResizeRequest: TRichEditResizeEvent; + FOnProtectChange: TRichEditProtectChange; + FOnProtectChangeEx: TRichEditProtectChangeEx; + FOnSaveClipboard: TRichEditSaveClipboard; + FOnURLClick: TRichEditURLClickEvent; + FOnTextNotFound: TRichEditFindErrorEvent; + FOnCloseFindDialog: TRichEditFindCloseEvent; + function GetAutoURLDetect: Boolean; + function GetWordSelection: Boolean; + function GetLangOptions: TRichLangOptions; + function GetCanRedo: Boolean; + function GetCanPaste: Boolean; + function GetRedoName: TUndoName; + function GetUndoName: TUndoName; + function GetStreamFormat: TRichStreamFormat; + function GetStreamMode: TRichStreamModes; + function GetSelectionType: TRichSelectionType; + procedure PopupVerbClick(Sender: TObject); + procedure ObjectPropsClick(Sender: TObject); + procedure CloseObjects; + procedure UpdateHostNames; + procedure SetAllowObjects(Value: Boolean); + procedure SetStreamFormat(Value: TRichStreamFormat); + procedure SetStreamMode(Value: TRichStreamModes); + procedure SetAutoURLDetect(Value: Boolean); + procedure SetWordSelection(Value: Boolean); + procedure SetHideScrollBars(Value: Boolean); + procedure SetHideSelection(Value: Boolean); + procedure SetTitle(const Value: string); + procedure SetLangOptions(Value: TRichLangOptions); + procedure SetRichEditStrings(Value: TStrings); + procedure SetDefAttributes(Value: TRxTextAttributes); + procedure SetSelAttributes(Value: TRxTextAttributes); + procedure SetWordAttributes(Value: TRxTextAttributes); + procedure SetSelectionBar(Value: Boolean); + procedure SetUndoLimit(Value: Integer); + procedure UpdateTextModes(Plain: Boolean); + procedure AdjustFindDialogPosition(Dialog: TFindDialog); + procedure SetupFindDialog(Dialog: TFindDialog; const SearchStr, + ReplaceStr: string); + function FindEditText(Dialog: TFindDialog; AdjustPos, Events: Boolean): Boolean; + function GetCanFindNext: Boolean; + procedure FindDialogFind(Sender: TObject); + procedure ReplaceDialogReplace(Sender: TObject); + procedure FindDialogClose(Sender: TObject); + procedure SetUIActive(Active: Boolean); + procedure CMDocWindowActivate(var Message: TMessage); message CM_DOCWINDOWACTIVATE; + procedure CMUIDeactivate(var Message: TMessage); message CM_UIDEACTIVATE; + procedure CMBiDiModeChanged(var Message: TMessage); message CM_BIDIMODECHANGED; + procedure CMColorChanged(var Message: TMessage); message CM_COLORCHANGED; + procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED; + procedure CNNotify(var Message: TWMNotify); message CN_NOTIFY; + procedure EMReplaceSel(var Message: TMessage); message EM_REPLACESEL; + procedure WMDestroy(var Msg: TWMDestroy); message WM_DESTROY; + procedure WMMouseMove(var Message: TMessage); message WM_MOUSEMOVE; + procedure WMPaint(var Message: TWMPaint); message WM_PAINT; + procedure WMSetCursor(var Message: TWMSetCursor); message WM_SETCURSOR; + procedure WMSetFont(var Message: TWMSetFont); message WM_SETFONT; +{$IFDEF Delphi5} + procedure WMRButtonUp(var Message: TMessage); message WM_RBUTTONUP; +{$ENDIF} + protected + procedure CreateParams(var Params: TCreateParams); override; + procedure CreateWindowHandle(const Params: TCreateParams); override; + procedure CreateWnd; override; + procedure DestroyWnd; override; + function GetPopupMenu: TPopupMenu; override; + procedure TextNotFound(Dialog: TFindDialog); virtual; + procedure RequestSize(const Rect: TRect); virtual; + procedure SelectionChange; dynamic; + function ProtectChange(const Message: TMessage; StartPos, + EndPos: Integer): Boolean; dynamic; + function SaveClipboard(NumObj, NumChars: Integer): Boolean; dynamic; + procedure URLClick(const URLText: string; Button: TMouseButton); dynamic; + procedure SetPlainText(Value: Boolean); virtual; + procedure CloseFindDialog(Dialog: TFindDialog); virtual; + procedure DoSetMaxLength(Value: Integer); override; + function GetSelLength: Integer; override; + function GetSelStart: Integer; override; + function GetSelText: string; override; + procedure SetSelLength(Value: Integer); override; + procedure SetSelStart(Value: Integer); override; + property AllowInPlace: Boolean read FAllowInPlace write FAllowInPlace default True; + property AllowObjects: Boolean read FAllowObjects write SetAllowObjects default True; + property AutoURLDetect: Boolean read GetAutoURLDetect write SetAutoURLDetect default True; + property AutoVerbMenu: Boolean read FAutoVerbMenu write FAutoVerbMenu default True; + property HideSelection: Boolean read FHideSelection write SetHideSelection default True; + property HideScrollBars: Boolean read FHideScrollBars + write SetHideScrollBars default True; + property Title: string read FTitle write SetTitle; + property LangOptions: TRichLangOptions read GetLangOptions write SetLangOptions default [rlAutoFont]; + property Lines: TStrings read FRichEditStrings write SetRichEditStrings; + property PlainText: Boolean read FPlainText write SetPlainText default False; + property SelectionBar: Boolean read FSelectionBar write SetSelectionBar default True; + property StreamFormat: TRichStreamFormat read GetStreamFormat write SetStreamFormat default sfDefault; + property StreamMode: TRichStreamModes read GetStreamMode write SetStreamMode default []; + property UndoLimit: Integer read FUndoLimit write SetUndoLimit default 100; + property WordSelection: Boolean read GetWordSelection write SetWordSelection default True; + property ScrollBars default ssBoth; + property TabStop default True; + property OnSaveClipboard: TRichEditSaveClipboard read FOnSaveClipboard + write FOnSaveClipboard; + property OnSelectionChange: TNotifyEvent read FOnSelChange write FOnSelChange; + property OnProtectChange: TRichEditProtectChange read FOnProtectChange + write FOnProtectChange; { obsolete } + property OnProtectChangeEx: TRichEditProtectChangeEx read FOnProtectChangeEx + write FOnProtectChangeEx; + property OnResizeRequest: TRichEditResizeEvent read FOnResizeRequest + write FOnResizeRequest; + property OnURLClick: TRichEditURLClickEvent read FOnURLClick write FOnURLClick; + property OnTextNotFound: TRichEditFindErrorEvent read FOnTextNotFound write FOnTextNotFound; + property OnCloseFindDialog: TRichEditFindCloseEvent read FOnCloseFindDialog + write FOnCloseFindDialog; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Clear; override; + procedure SetSelection(StartPos, EndPos: Longint; ScrollCaret: Boolean); + function GetSelection: TCharRange; + function GetTextRange(StartPos, EndPos: Longint): string; + function LineFromChar(CharIndex: Integer): Integer; + function GetLineIndex(LineNo: Integer): Integer; + function GetLineLength(CharIndex: Integer): Integer; + function WordAtCursor: string; + function FindText(const SearchStr: string; + StartPos, Length: Integer; Options: TRichSearchTypes): Integer; + function GetSelTextBuf(Buffer: PChar; BufSize: Integer): Integer; override; + function GetCaretPos: TPoint; override; + function GetCharPos(CharIndex: Integer): TPoint; + function InsertObjectDialog: Boolean; + function ObjectPropertiesDialog: Boolean; + function PasteSpecialDialog: Boolean; + function FindDialog(const SearchStr: string): TFindDialog; + function ReplaceDialog(const SearchStr, ReplaceStr: string): TReplaceDialog; + function FindNext: Boolean; + procedure Print(const Caption: string); virtual; + class procedure RegisterConversionFormat(const AExtension: string; + APlainText: Boolean; AConversionClass: TConversionClass); + procedure ClearUndo; + procedure Redo; + procedure StopGroupTyping; + property CanFindNext: Boolean read GetCanFindNext; + property CanRedo: Boolean read GetCanRedo; + property CanPaste: Boolean read GetCanPaste; + property RedoName: TUndoName read GetRedoName; + property UndoName: TUndoName read GetUndoName; + property DefaultConverter: TConversionClass read FDefaultConverter + write FDefaultConverter; + property DefAttributes: TRxTextAttributes read FDefAttributes write SetDefAttributes; + property SelAttributes: TRxTextAttributes read FSelAttributes write SetSelAttributes; + property WordAttributes: TRxTextAttributes read FWordAttributes write SetWordAttributes; + property PageRect: TRect read FPageRect write FPageRect; + property Paragraph: TRxParaAttributes read FParagraph; + property SelectionType: TRichSelectionType read GetSelectionType; + end; + + TRxRichEdit = class(TRxCustomRichEdit) + published + property Align; + property Alignment; + property AutoURLDetect; + property AutoVerbMenu; + property AllowObjects; + property AllowInPlace; + property Anchors; + property BiDiMode; + property BorderWidth; + property DragKind; + property BorderStyle; + property Color; + property Ctl3D; + property DragCursor; + property DragMode; + property Enabled; + property Font; + property HideSelection; + property HideScrollBars; + property Title; + property ImeMode; + property ImeName; + property Constraints; + property ParentBiDiMode; + property LangOptions; + property Lines; + property MaxLength; + property ParentColor; + property ParentCtl3D; + property ParentFont; + property ParentShowHint; + property PlainText; + property PopupMenu; + property ReadOnly; + property ScrollBars; + property SelectionBar; + property ShowHint; + property StreamFormat; + property StreamMode; + property TabOrder; + property TabStop; + property UndoLimit; + property Visible; + property WantTabs; + property WantReturns; + property WordSelection; + property WordWrap; + property OnChange; + property OnDblClick; + property OnDragDrop; + property OnDragOver; +{$IFDEF Delphi5} + property OnContextPopup; +{$ENDIF} + property OnEndDock; + property OnStartDock; + property OnEndDrag; + property OnEnter; + property OnExit; + property OnKeyDown; + property OnKeyPress; + property OnKeyUp; + property OnMouseDown; + property OnMouseMove; + property OnMouseUp; + property OnMouseWheel; + property OnMouseWheelDown; + property OnMouseWheelUp; + property OnProtectChange; { obsolete } + property OnProtectChangeEx; + property OnResizeRequest; + property OnSaveClipboard; + property OnSelectionChange; + property OnStartDrag; + property OnTextNotFound; + property OnCloseFindDialog; + property OnURLClick; + end; + +var + RichEditVersion: TRichEditVersion; + +implementation + +uses Printers, ComStrs, OleConst, OleDlg, OleCtnrs; + +const + RTFConversionFormat: TRichConversionFormat = ( + ConversionClass: TConversion; + Extension: 'rtf'; + PlainText: False; + Next: nil); + TextConversionFormat: TRichConversionFormat = ( + ConversionClass: TConversion; + Extension: 'txt'; + PlainText: True; + Next: @RTFConversionFormat); + +var + ConversionFormatList: PRichConversionFormat = @TextConversionFormat; + +const + RichEdit10ModuleName = 'RICHED32.DLL'; + RichEdit20ModuleName = 'RICHED20.DLL'; +// for support RichEdit 3.0 + EM_SETTYPOGRAPHYOPTIONS = WM_USER + 202; + EM_GETTYPOGRAPHYOPTIONS = WM_USER + 203; + TO_ADVANCEDTYPOGRAPHY = 1; + TO_SIMPLELINEBREAK = 2; + FT_DOWN = 1; + +type + PENLink = ^TENLink; + PENOleOpFailed = ^TENOleOpFailed; + TFindTextEx = TFindTextExA; + + TTextRangeA = record + chrg: TCharRange; + lpstrText: PAnsiChar; + end; + TTextRangeW = record + chrg: TCharRange; + lpstrText: PWideChar; + end; + TTextRange = TTextRangeA; + +function ResStr(const Ident: string): string; +begin + Result := Ident; +end; + +{ TRxTextAttributes } + +const + AttrFlags: array[TRxAttributeType] of Word = (0, SCF_SELECTION, + SCF_WORD or SCF_SELECTION); + +constructor TRxTextAttributes.Create(AOwner: TRxCustomRichEdit; + AttributeType: TRxAttributeType); +begin + inherited Create; + RichEdit := AOwner; + FType := AttributeType; +end; + +procedure TRxTextAttributes.InitFormat(var Format: TCharFormat2); +begin + FillChar(Format, SizeOf(Format), 0); + if RichEditVersion >= 2 then Format.cbSize := SizeOf(Format) + else Format.cbSize := SizeOf(TCharFormat); +end; + +function TRxTextAttributes.GetConsistentAttributes: TRxConsistentAttributes; +var + Format: TCharFormat2; +begin + Result := []; + if RichEdit.HandleAllocated and (FType <> atDefaultText) then begin + InitFormat(Format); + SendMessage(RichEdit.Handle, EM_GETCHARFORMAT, + AttrFlags[FType], LPARAM(@Format)); + with Format do begin + if (dwMask and CFM_BOLD) <> 0 then Include(Result, caBold); + if (dwMask and CFM_COLOR) <> 0 then Include(Result, caColor); + if (dwMask and CFM_FACE) <> 0 then Include(Result, caFace); + if (dwMask and CFM_ITALIC) <> 0 then Include(Result, caItalic); + if (dwMask and CFM_SIZE) <> 0 then Include(Result, caSize); + if (dwMask and CFM_STRIKEOUT) <> 0 then Include(Result, caStrikeOut); + if (dwMask and CFM_UNDERLINE) <> 0 then Include(Result, caUnderline); + if (dwMask and CFM_PROTECTED) <> 0 then Include(Result, caProtected); + if (dwMask and CFM_OFFSET) <> 0 then Include(Result, caOffset); + if (dwMask and CFM_HIDDEN) <> 0 then Include(result, caHidden); + if RichEditVersion >= 2 then begin + if (dwMask and CFM_LINK) <> 0 then Include(Result, caLink); + if (dwMask and CFM_BACKCOLOR) <> 0 then Include(Result, caBackColor); + if (dwMask and CFM_DISABLED) <> 0 then Include(Result, caDisabled); + if (dwMask and CFM_WEIGHT) <> 0 then Include(Result, caWeight); + if (dwMask and CFM_SUBSCRIPT) <> 0 then Include(Result, caSubscript); + if (dwMask and CFM_REVAUTHOR) <> 0 then Include(Result, caRevAuthor); + end; + end; + end; +end; + +procedure TRxTextAttributes.GetAttributes(var Format: TCharFormat2); +begin + InitFormat(Format); + if RichEdit.HandleAllocated then + SendMessage(RichEdit.Handle, EM_GETCHARFORMAT, AttrFlags[FType], + LPARAM(@Format)); +end; + +procedure TRxTextAttributes.SetAttributes(var Format: TCharFormat2); +begin + if RichEdit.HandleAllocated then + SendMessage(RichEdit.Handle, EM_SETCHARFORMAT, AttrFlags[FType], + LPARAM(@Format)); +end; + +function TRxTextAttributes.GetCharset: TFontCharset; +var + Format: TCharFormat2; +begin + GetAttributes(Format); + Result := Format.bCharset; +end; + +procedure TRxTextAttributes.SetCharset(Value: TFontCharset); +var + Format: TCharFormat2; +begin + InitFormat(Format); + with Format do + begin + dwMask := CFM_CHARSET; + bCharSet := Value; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetProtected: Boolean; +var + Format: TCharFormat2; +begin + GetAttributes(Format); + with Format do + Result := (dwEffects and CFE_PROTECTED) <> 0; +end; + +procedure TRxTextAttributes.SetProtected(Value: Boolean); +var + Format: TCharFormat2; +begin + InitFormat(Format); + with Format do begin + dwMask := CFM_PROTECTED; + if Value then dwEffects := CFE_PROTECTED; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetLink: Boolean; +var + Format: TCharFormat2; +begin + Result := False; + if RichEditVersion < 2 then Exit; + GetAttributes(Format); + with Format do Result := (dwEffects and CFE_LINK) <> 0; +end; + +procedure TRxTextAttributes.SetLink(Value: Boolean); +var + Format: TCharFormat2; +begin + if RichEditVersion < 2 then Exit; + InitFormat(Format); + with Format do begin + dwMask := CFM_LINK; + if Value then dwEffects := CFE_LINK; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetRevAuthorIndex: Byte; +var + Format: TCharFormat2; +begin + GetAttributes(Format); + Result := Format.bRevAuthor; +end; + +procedure TRxTextAttributes.SetRevAuthorIndex(Value: Byte); +var + Format: TCharFormat2; +begin + if RichEditVersion < 2 then Exit; + InitFormat(Format); + with Format do begin + dwMask := CFM_REVAUTHOR; + bRevAuthor := Value; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetHidden: Boolean; +var + Format: TCharFormat2; +begin + Result := False; + if RichEditVersion < 2 then Exit; + GetAttributes(Format); + Result := Format.dwEffects and CFE_HIDDEN <> 0; +end; + +procedure TRxTextAttributes.SetHidden(Value: Boolean); +var + Format: TCharFormat2; +begin + if RichEditVersion < 2 then Exit; + InitFormat(Format); + with Format do begin + dwMask := CFM_HIDDEN; + if Value then dwEffects := CFE_HIDDEN; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetDisabled: Boolean; +var + Format: TCharFormat2; +begin + Result := False; + if RichEditVersion < 2 then Exit; + GetAttributes(Format); + Result := Format.dwEffects and CFE_DISABLED <> 0; +end; + +procedure TRxTextAttributes.SetDisabled(Value: Boolean); +var + Format: TCharFormat2; +begin + if RichEditVersion < 2 then Exit; + InitFormat(Format); + with Format do begin + dwMask := CFM_DISABLED; + if Value then dwEffects := CFE_DISABLED; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetColor: TColor; +var + Format: TCharFormat2; +begin + GetAttributes(Format); + with Format do + if (dwEffects and CFE_AUTOCOLOR) <> 0 then Result := clWindowText + else Result := crTextColor; +end; + +procedure TRxTextAttributes.SetColor(Value: TColor); +var + Format: TCharFormat2; +begin + InitFormat(Format); + with Format do begin + dwMask := CFM_COLOR; + if (Value = clWindowText) or (Value = clDefault) then + dwEffects := CFE_AUTOCOLOR + else crTextColor := ColorToRGB(Value); + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetBackColor: TColor; +var + Format: TCharFormat2; +begin + if RichEditVersion < 2 then begin + Result := clWindow; + Exit; + end; + GetAttributes(Format); + with Format do + if (dwEffects and CFE_AUTOBACKCOLOR) <> 0 then Result := clWindow + else Result := crBackColor; +end; + +procedure TRxTextAttributes.SetBackColor(Value: TColor); +var + Format: TCharFormat2; +begin + if RichEditVersion < 2 then Exit; + InitFormat(Format); + with Format do begin + dwMask := CFM_BACKCOLOR; + if (Value = clWindow) or (Value = clDefault) then + dwEffects := CFE_AUTOBACKCOLOR + else crBackColor := ColorToRGB(Value); + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetName: TFontName; +var + Format: TCharFormat2; +begin + GetAttributes(Format); + Result := Format.szFaceName; +end; + +procedure TRxTextAttributes.SetName(Value: TFontName); +var + Format: TCharFormat2; +begin + InitFormat(Format); + with Format do begin + dwMask := CFM_FACE; + StrPLCopy(szFaceName, Value, SizeOf(szFaceName)); + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetStyle: TFontStyles; +var + Format: TCharFormat2; +begin + Result := []; + GetAttributes(Format); + with Format do begin + if (dwEffects and CFE_BOLD) <> 0 then Include(Result, fsBold); + if (dwEffects and CFE_ITALIC) <> 0 then Include(Result, fsItalic); + if (dwEffects and CFE_UNDERLINE) <> 0 then Include(Result, fsUnderline); + if (dwEffects and CFE_STRIKEOUT) <> 0 then Include(Result, fsStrikeOut); + end; +end; + +procedure TRxTextAttributes.SetStyle(Value: TFontStyles); +var + Format: TCharFormat2; +begin + InitFormat(Format); + with Format do begin + dwMask := CFM_BOLD or CFM_ITALIC or CFM_UNDERLINE or CFM_STRIKEOUT; + if fsBold in Value then dwEffects := dwEffects or CFE_BOLD; + if fsItalic in Value then dwEffects := dwEffects or CFE_ITALIC; + if fsUnderline in Value then dwEffects := dwEffects or CFE_UNDERLINE; + if fsStrikeOut in Value then dwEffects := dwEffects or CFE_STRIKEOUT; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetUnderlineType: TUnderlineType; +var + Format: TCharFormat2; +begin + Result := utNone; + if RichEditVersion < 2 then Exit; + GetAttributes(Format); + with Format do begin + if (dwEffects and CFE_UNDERLINE <> 0) and + (dwMask and CFM_UNDERLINETYPE = CFM_UNDERLINETYPE) then + Result := TUnderlineType(bUnderlineType); + end; +end; + +procedure TRxTextAttributes.SetUnderlineType(Value: TUnderlineType); +var + Format: TCharFormat2; +begin + if RichEditVersion < 2 then Exit; + InitFormat(Format); + with Format do begin + dwMask := CFM_UNDERLINETYPE or CFM_UNDERLINE; + bUnderlineType := Ord(Value); + if Value <> utNone then dwEffects := dwEffects or CFE_UNDERLINE; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetOffset: Integer; +var + Format: TCharFormat2; +begin + GetAttributes(Format); + Result := Format.yOffset div 20; +end; + +procedure TRxTextAttributes.SetOffset(Value: Integer); +var + Format: TCharFormat2; +begin + InitFormat(Format); + with Format do begin + dwMask := DWORD(CFM_OFFSET); + yOffset := Value * 20; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetSize: Integer; +var + Format: TCharFormat2; +begin + GetAttributes(Format); + Result := Format.yHeight div 20; +end; + +procedure TRxTextAttributes.SetSize(Value: Integer); +var + Format: TCharFormat2; +begin + InitFormat(Format); + with Format do begin + dwMask := DWORD(CFM_SIZE); + yHeight := Value * 20; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetHeight: Integer; +begin + Result := MulDiv(Size, RichEdit.FScreenLogPixels, 72); +end; + +procedure TRxTextAttributes.SetHeight(Value: Integer); +begin + Size := MulDiv(Value, 72, RichEdit.FScreenLogPixels); +end; + +function TRxTextAttributes.GetPitch: TFontPitch; +var + Format: TCharFormat2; +begin + GetAttributes(Format); + case (Format.bPitchAndFamily and $03) of + DEFAULT_PITCH: Result := fpDefault; + VARIABLE_PITCH: Result := fpVariable; + FIXED_PITCH: Result := fpFixed; + else Result := fpDefault; + end; +end; + +procedure TRxTextAttributes.SetPitch(Value: TFontPitch); +var + Format: TCharFormat2; +begin + InitFormat(Format); + with Format do begin + case Value of + fpVariable: bPitchAndFamily := VARIABLE_PITCH; + fpFixed: bPitchAndFamily := FIXED_PITCH; + else bPitchAndFamily := DEFAULT_PITCH; + end; + end; + SetAttributes(Format); +end; + +function TRxTextAttributes.GetSubscriptStyle: TSubscriptStyle; +var + Format: TCharFormat2; +begin + Result := ssNone; + if RichEditVersion < 2 then Exit; + GetAttributes(Format); + with Format do begin + if (dwEffects and CFE_SUBSCRIPT) <> 0 then + Result := ssSubscript + else if (dwEffects and CFE_SUPERSCRIPT) <> 0 then + Result := ssSuperscript; + end; +end; + +procedure TRxTextAttributes.SetSubscriptStyle(Value: TSubscriptStyle); +var + Format: TCharFormat2; +begin + if RichEditVersion < 2 then Exit; + InitFormat(Format); + with Format do begin + dwMask := DWORD(CFM_SUBSCRIPT); + case Value of + ssSubscript: dwEffects := CFE_SUBSCRIPT; + ssSuperscript: dwEffects := CFE_SUPERSCRIPT; + end; + end; + SetAttributes(Format); +end; + +procedure TRxTextAttributes.AssignFont(Font: TFont); +var + LogFont: TLogFont; + Format: TCharFormat2; +begin + InitFormat(Format); + with Format do begin + case Font.Pitch of + fpVariable: bPitchAndFamily := VARIABLE_PITCH; + fpFixed: bPitchAndFamily := FIXED_PITCH; + else bPitchAndFamily := DEFAULT_PITCH; + end; + dwMask := dwMask or CFM_SIZE or CFM_BOLD or CFM_ITALIC or + CFM_UNDERLINE or CFM_STRIKEOUT or CFM_FACE or CFM_COLOR; + yHeight := Font.Size * 20; + if fsBold in Font.Style then dwEffects := dwEffects or CFE_BOLD; + if fsItalic in Font.Style then dwEffects := dwEffects or CFE_ITALIC; + if fsUnderline in Font.Style then dwEffects := dwEffects or CFE_UNDERLINE; + if fsStrikeOut in Font.Style then dwEffects := dwEffects or CFE_STRIKEOUT; + StrPLCopy(szFaceName, Font.Name, SizeOf(szFaceName)); + if (Font.Color = clWindowText) or (Font.Color = clDefault) then + dwEffects := CFE_AUTOCOLOR + else crTextColor := ColorToRGB(Font.Color); + dwMask := dwMask or CFM_CHARSET; + bCharSet := Font.Charset; + if GetObject(Font.Handle, SizeOf(LogFont), @LogFont) <> 0 then begin + dwMask := dwMask or DWORD(CFM_WEIGHT); + wWeight := Word(LogFont.lfWeight); + end; + end; + SetAttributes(Format); +end; + +procedure TRxTextAttributes.Assign(Source: TPersistent); +var + Format: TCharFormat2; +begin + if Source is TFont then AssignFont(TFont(Source)) + else if Source is TTextAttributes then begin + Name := TTextAttributes(Source).Name; + Charset := TTextAttributes(Source).Charset; + Style := TTextAttributes(Source).Style; + Pitch := TTextAttributes(Source).Pitch; + Color := TTextAttributes(Source).Color; + end + else if Source is TRxTextAttributes then begin + TRxTextAttributes(Source).GetAttributes(Format); + SetAttributes(Format); + end + else inherited Assign(Source); +end; + +procedure TRxTextAttributes.AssignTo(Dest: TPersistent); +begin + if Dest is TFont then begin + TFont(Dest).Color := Color; + TFont(Dest).Name := Name; + TFont(Dest).Charset := Charset; + TFont(Dest).Style := Style; + TFont(Dest).Size := Size; + TFont(Dest).Pitch := Pitch; + end + else if Dest is TTextAttributes then begin + TTextAttributes(Dest).Color := Color; + TTextAttributes(Dest).Name := Name; + TTextAttributes(Dest).Charset := Charset; + TTextAttributes(Dest).Style := Style; + TTextAttributes(Dest).Pitch := Pitch; + end + else inherited AssignTo(Dest); +end; + +{ TRxParaAttributes } + +constructor TRxParaAttributes.Create(AOwner: TRxCustomRichEdit); +begin + inherited Create; + RichEdit := AOwner; +end; + +procedure TRxParaAttributes.InitPara(var Paragraph: TParaFormat2); +begin + FillChar(Paragraph, SizeOf(Paragraph), 0); + if RichEditVersion >= 2 then + Paragraph.cbSize := SizeOf(Paragraph) + else + Paragraph.cbSize := SizeOf(TParaFormat); +end; + +procedure TRxParaAttributes.GetAttributes(var Paragraph: TParaFormat2); +begin + InitPara(Paragraph); + if RichEdit.HandleAllocated then + SendMessage(RichEdit.Handle, EM_GETPARAFORMAT, 0, LPARAM(@Paragraph)); +end; + +procedure TRxParaAttributes.SetAttributes(var Paragraph: TParaFormat2); +begin + RichEdit.HandleNeeded; { we REALLY need the handle for BiDi } + if RichEdit.HandleAllocated then begin + if RichEdit.UseRightToLeftAlignment then + if Paragraph.wAlignment = PFA_LEFT then + Paragraph.wAlignment := PFA_RIGHT + else if Paragraph.wAlignment = PFA_RIGHT then + Paragraph.wAlignment := PFA_LEFT; + SendMessage(RichEdit.Handle, EM_SETPARAFORMAT, 0, LPARAM(@Paragraph)); + end; +end; + +function TRxParaAttributes.GetAlignment: TParaAlignment; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := TParaAlignment(Paragraph.wAlignment - 1); +end; + +procedure TRxParaAttributes.SetAlignment(Value: TParaAlignment); +var + Paragraph: TParaFormat2; +begin + InitPara(Paragraph); + with Paragraph do + begin + dwMask := PFM_ALIGNMENT; + wAlignment := Ord(Value) + 1; + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetNumbering: TRxNumbering; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := TRxNumbering(Paragraph.wNumbering); + if RichEditVersion = 1 then + if Result <> nsNone then Result := nsBullet; +end; + +procedure TRxParaAttributes.SetNumbering(Value: TRxNumbering); +var + Paragraph: TParaFormat2; +begin + if RichEditVersion = 1 then + if Value <> nsNone then Value := TRxNumbering(PFN_BULLET); + case Value of + nsNone: LeftIndent := 0; + else if LeftIndent < 10 then LeftIndent := 10; + end; + InitPara(Paragraph); + with Paragraph do begin + dwMask := PFM_NUMBERING; + wNumbering := Ord(Value); + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetNumberingStyle: TRxNumberingStyle; +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 2 then + Result := nsSimple + else begin + GetAttributes(Paragraph); + Result := TRxNumberingStyle(Paragraph.wNumberingStyle); + end; +end; + +procedure TRxParaAttributes.SetNumberingStyle(Value: TRxNumberingStyle); +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 2 then Exit; + InitPara(Paragraph); + with Paragraph do begin + dwMask := PFM_NUMBERINGSTYLE; + wNumberingStyle := Ord(Value); + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetNumberingTab: Word; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := Paragraph.wNumberingTab div 20; +end; + +procedure TRxParaAttributes.SetNumberingTab(Value: Word); +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 2 then Exit; + InitPara(Paragraph); + with Paragraph do begin + dwMask := PFM_NUMBERINGTAB; + wNumberingTab := Value * 20; + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetFirstIndent: Longint; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := Paragraph.dxStartIndent div 20; +end; + +procedure TRxParaAttributes.SetFirstIndent(Value: Longint); +var + Paragraph: TParaFormat2; +begin + InitPara(Paragraph); + with Paragraph do + begin + dwMask := PFM_STARTINDENT; + dxStartIndent := Value * 20; + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetHeadingStyle: THeadingStyle; +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 3 then Result := 0 + else begin + GetAttributes(Paragraph); + Result := Paragraph.sStyle; + end; +end; + +procedure TRxParaAttributes.SetHeadingStyle(Value: THeadingStyle); +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 3 then Exit; + InitPara(Paragraph); + with Paragraph do begin + dwMask := PFM_STYLE; + sStyle := Value; + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetLeftIndent: Longint; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := Paragraph.dxOffset div 20; +end; + +procedure TRxParaAttributes.SetLeftIndent(Value: Longint); +var + Paragraph: TParaFormat2; +begin + InitPara(Paragraph); + with Paragraph do + begin + dwMask := PFM_OFFSET; + dxOffset := Value * 20; + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetRightIndent: Longint; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := Paragraph.dxRightIndent div 20; +end; + +procedure TRxParaAttributes.SetRightIndent(Value: Longint); +var + Paragraph: TParaFormat2; +begin + InitPara(Paragraph); + with Paragraph do + begin + dwMask := PFM_RIGHTINDENT; + dxRightIndent := Value * 20; + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetSpaceAfter: Longint; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := Paragraph.dySpaceAfter div 20; +end; + +procedure TRxParaAttributes.SetSpaceAfter(Value: Longint); +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 2 then Exit; + InitPara(Paragraph); + with Paragraph do begin + dwMask := PFM_SPACEAFTER; + dySpaceAfter := Value * 20; + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetSpaceBefore: Longint; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := Paragraph.dySpaceBefore div 20; +end; + +procedure TRxParaAttributes.SetSpaceBefore(Value: Longint); +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 2 then Exit; + InitPara(Paragraph); + with Paragraph do begin + dwMask := PFM_SPACEBEFORE; + dySpaceBefore := Value * 20; + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetLineSpacing: Longint; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := Paragraph.dyLineSpacing div 20; +end; + +procedure TRxParaAttributes.SetLineSpacing(Value: Longint); +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 2 then Exit; + GetAttributes(Paragraph); + with Paragraph do begin + dwMask := PFM_LINESPACING; + dyLineSpacing := Value * 20; + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetLineSpacingRule: TLineSpacingRule; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := TLineSpacingRule(Paragraph.bLineSpacingRule); +end; + +procedure TRxParaAttributes.SetLineSpacingRule(Value: TLineSpacingRule); +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 2 then Exit; + GetAttributes(Paragraph); + with Paragraph do begin + dwMask := PFM_LINESPACING; + bLineSpacingRule := Ord(Value); + end; + SetAttributes(Paragraph); +end; + +function TRxParaAttributes.GetTab(Index: Byte): Longint; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := Paragraph.rgxTabs[Index] div 20; +end; + +procedure TRxParaAttributes.SetTab(Index: Byte; Value: Longint); +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + with Paragraph do + begin + rgxTabs[Index] := Value * 20; + dwMask := PFM_TABSTOPS; + if cTabCount < Index then cTabCount := Index; + SetAttributes(Paragraph); + end; +end; + +function TRxParaAttributes.GetTabCount: Integer; +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + Result := Paragraph.cTabCount; +end; + +procedure TRxParaAttributes.SetTabCount(Value: Integer); +var + Paragraph: TParaFormat2; +begin + GetAttributes(Paragraph); + with Paragraph do + begin + dwMask := PFM_TABSTOPS; + cTabCount := Value; + SetAttributes(Paragraph); + end; +end; + +function TRxParaAttributes.GetTableStyle: TParaTableStyle; +var + Paragraph: TParaFormat2; +begin + Result := tsNone; + if RichEditVersion < 2 then Exit; + GetAttributes(Paragraph); + with Paragraph do begin + if (wReserved and PFE_TABLEROW) <> 0 then + Result := tsTableRow + else if (wReserved and PFE_TABLECELLEND) <> 0 then + Result := tsTableCellEnd + else if (wReserved and PFE_TABLECELL) <> 0 then + Result := tsTableCell; + end; +end; + +procedure TRxParaAttributes.SetTableStyle(Value: TParaTableStyle); +var + Paragraph: TParaFormat2; +begin + if RichEditVersion < 2 then Exit; + InitPara(Paragraph); + with Paragraph do begin + dwMask := PFM_TABLE; + case Value of + tsTableRow: wReserved := PFE_TABLEROW; + tsTableCellEnd: wReserved := PFE_TABLECELLEND; + tsTableCell: wReserved := PFE_TABLECELL; + end; + end; + SetAttributes(Paragraph); +end; + +procedure TRxParaAttributes.AssignTo(Dest: TPersistent); +var + I: Integer; +begin + if Dest is TParaAttributes then begin + with TParaAttributes(Dest) do begin +// if Self.Alignment = paJustify then Alignment := taLeftJustify +// else + Alignment := TAlignment(Self.Alignment); + FirstIndent := Self.FirstIndent; + LeftIndent := Self.LeftIndent; + RightIndent := Self.RightIndent; + if Self.Numbering <> nsNone then + Numbering := TNumberingStyle(nsBullet) + else Numbering := TNumberingStyle(nsNone); + for I := 0 to MAX_TAB_STOPS - 1 do + Tab[I] := Self.Tab[I]; + end; + end + else inherited AssignTo(Dest); +end; + +procedure TRxParaAttributes.Assign(Source: TPersistent); +var + I: Integer; + Paragraph: TParaFormat2; +begin + if Source is TParaAttributes then begin + Alignment := TParaAlignment(TParaAttributes(Source).Alignment); + FirstIndent := TParaAttributes(Source).FirstIndent; + LeftIndent := TParaAttributes(Source).LeftIndent; + RightIndent := TParaAttributes(Source).RightIndent; + Numbering := TRxNumbering(TParaAttributes(Source).Numbering); + for I := 0 to MAX_TAB_STOPS - 1 do + Tab[I] := TParaAttributes(Source).Tab[I]; + end + else if Source is TRxParaAttributes then begin + TRxParaAttributes(Source).GetAttributes(Paragraph); + SetAttributes(Paragraph); + end + else inherited Assign(Source); +end; + +{ OLE utility routines } + +function WStrLen(Str: PWideChar): Integer; +begin + Result := 0; + while Str[Result] <> #0 do Inc(Result); +end; + +procedure ReleaseObject(var Obj); +begin + if IUnknown(Obj) <> nil then begin + IUnknown(Obj) := nil; + end; +end; + +procedure CreateStorage(var Storage: IStorage); +var + LockBytes: ILockBytes; +begin + OleCheck(CreateILockBytesOnHGlobal(0, True, LockBytes)); + try + OleCheck(StgCreateDocfileOnILockBytes(LockBytes, STGM_READWRITE + or STGM_SHARE_EXCLUSIVE or STGM_CREATE, 0, Storage)); + finally + ReleaseObject(LockBytes); + end; +end; + +procedure DestroyMetaPict(MetaPict: HGlobal); +begin + if MetaPict <> 0 then begin + DeleteMetaFile(PMetaFilePict(GlobalLock(MetaPict))^.hMF); + GlobalUnlock(MetaPict); + GlobalFree(MetaPict); + end; +end; + +function OleSetDrawAspect(OleObject: IOleObject; Iconic: Boolean; + IconMetaPict: HGlobal; var DrawAspect: Longint): HResult; +var + OleCache: IOleCache; + EnumStatData: IEnumStatData; + OldAspect, AdviseFlags, Connection: Longint; + TempMetaPict: HGlobal; + FormatEtc: TFormatEtc; + Medium: TStgMedium; + ClassID: TCLSID; + StatData: TStatData; +begin + Result := S_OK; + OldAspect := DrawAspect; + if Iconic then begin + DrawAspect := DVASPECT_ICON; + AdviseFlags := ADVF_NODATA; + end + else begin + DrawAspect := DVASPECT_CONTENT; + AdviseFlags := ADVF_PRIMEFIRST; + end; + if (DrawAspect <> OldAspect) or (DrawAspect = DVASPECT_ICON) then begin + Result := OleObject.QueryInterface(IOleCache, OleCache); + if Succeeded(Result) then + try + if DrawAspect <> OldAspect then begin + { Setup new cache with the new aspect } + FillChar(FormatEtc, SizeOf(FormatEtc), 0); + FormatEtc.dwAspect := DrawAspect; + FormatEtc.lIndex := -1; + Result := OleCache.Cache(FormatEtc, AdviseFlags, Connection); + end; + if Succeeded(Result) and (DrawAspect = DVASPECT_ICON) then begin + TempMetaPict := 0; + if IconMetaPict = 0 then begin + if Succeeded(OleObject.GetUserClassID(ClassID)) then begin + TempMetaPict := OleGetIconOfClass(ClassID, nil, True); + IconMetaPict := TempMetaPict; + end; + end; + try + FormatEtc.cfFormat := CF_METAFILEPICT; + FormatEtc.ptd := nil; + FormatEtc.dwAspect := DVASPECT_ICON; + FormatEtc.lIndex := -1; + FormatEtc.tymed := TYMED_MFPICT; + Medium.tymed := TYMED_MFPICT; + Medium.hMetaFilePict := IconMetaPict; + Medium.unkForRelease := nil; + Result := OleCache.SetData(FormatEtc, Medium, False); + finally + DestroyMetaPict(TempMetaPict); + end; + end; + if Succeeded(Result) and (DrawAspect <> OldAspect) then begin + { remove any existing caches that are set up for the old display aspect } + OleCache.EnumCache(EnumStatData); + if EnumStatData <> nil then + try + while EnumStatData.Next(1, StatData, nil) = 0 do + if StatData.formatetc.dwAspect = OldAspect then + OleCache.Uncache(StatData.dwConnection); + finally + ReleaseObject(EnumStatData); + end; + end; + finally + ReleaseObject(OleCache); + end; + if Succeeded(Result) and (DrawAspect <> DVASPECT_ICON) then + OleObject.Update; + end; +end; + +function GetIconMetaPict(OleObject: IOleObject; DrawAspect: Longint): HGlobal; +var + DataObject: IDataObject; + FormatEtc: TFormatEtc; + Medium: TStgMedium; + ClassID: TCLSID; +begin + Result := 0; + if DrawAspect = DVASPECT_ICON then begin + OleObject.QueryInterface(IDataObject, DataObject); + if DataObject <> nil then begin + FormatEtc.cfFormat := CF_METAFILEPICT; + FormatEtc.ptd := nil; + FormatEtc.dwAspect := DVASPECT_ICON; + FormatEtc.lIndex := -1; + FormatEtc.tymed := TYMED_MFPICT; + if Succeeded(DataObject.GetData(FormatEtc, Medium)) then + Result := Medium.hMetaFilePict; + ReleaseObject(DataObject); + end; + end; + if Result = 0 then begin + OleCheck(OleObject.GetUserClassID(ClassID)); + Result := OleGetIconOfClass(ClassID, nil, True); + end; +end; + +{ Return the first piece of a moniker } + +function OleStdGetFirstMoniker(Moniker: IMoniker): IMoniker; +var + Mksys: Longint; + EnumMoniker: IEnumMoniker; +begin + Result := nil; + if Moniker <> nil then begin + if (Moniker.IsSystemMoniker(Mksys) = 0) and + (Mksys = MKSYS_GENERICCOMPOSITE) then + begin + if Moniker.Enum(True, EnumMoniker) <> 0 then Exit; + EnumMoniker.Next(1, Result, nil); + ReleaseObject(EnumMoniker); + end + else begin + Result := Moniker; + end; + end; +end; + +{ Return length of file moniker piece of the given moniker } + +function OleStdGetLenFilePrefixOfMoniker(Moniker: IMoniker): Integer; +var + MkFirst: IMoniker; + BindCtx: IBindCtx; + Mksys: Longint; + P: PWideChar; +begin + Result := 0; + if Moniker <> nil then begin + MkFirst := OleStdGetFirstMoniker(Moniker); + if MkFirst <> nil then begin + if (MkFirst.IsSystemMoniker(Mksys) = 0) and + (Mksys = MKSYS_FILEMONIKER) then + begin + if CreateBindCtx(0, BindCtx) = 0 then begin + if (MkFirst.GetDisplayName(BindCtx, nil, P) = 0) and (P <> nil) then + begin + Result := WStrLen(P); + CoTaskMemFree(P); + end; + ReleaseObject(BindCtx); + end; + end; + ReleaseObject(MkFirst); + end; + end; +end; + +function CoAllocCStr(const S: string): PChar; +begin + Result := StrCopy(CoTaskMemAlloc(Length(S) + 1), PChar(S)); +end; + +function WStrToString(P: PWideChar): string; +begin + Result := ''; + if P <> nil then begin + Result := WideCharToString(P); + CoTaskMemFree(P); + end; +end; + +function GetFullNameStr(OleObject: IOleObject): string; +var + P: PWideChar; +begin + OleObject.GetUserType(USERCLASSTYPE_FULL, P); + Result := WStrToString(P); +end; + +function GetShortNameStr(OleObject: IOleObject): string; +var + P: PWideChar; +begin + OleObject.GetUserType(USERCLASSTYPE_SHORT, P); + Result := WStrToString(P); +end; + +function GetDisplayNameStr(OleLink: IOleLink): string; +var + P: PWideChar; +begin + OleLink.GetSourceDisplayName(P); + Result := WStrToString(P); +end; + +function GetVCLFrameForm(Form: TCustomForm): IVCLFrameForm; +begin + if Form.OleFormObject = nil then TOleForm.Create(Form); + Result := Form.OleFormObject as IVCLFrameForm; +end; + +function IsFormMDIChild(Form: TCustomForm): Boolean; +begin + Result := (Form is TForm) and (TForm(Form).FormStyle = fsMDIChild); +end; + +{ Clipboard formats } + +var + CFEmbeddedObject: Integer; + CFLinkSource: Integer; + CFRtf: Integer; + CFRtfNoObjs: Integer; + +const + CF_EMBEDDEDOBJECT = 'Embedded Object'; + CF_LINKSOURCE = 'Link Source'; + +{************************************************************************} + +{ OLE Extensions to the Rich Text Editor } +{ Converted from RICHOLE.H } + +{ Structure passed to GetObject and InsertObject } + +type + _ReObject = record + cbStruct: DWORD; { Size of structure } + cp: ULONG; { Character position of object } + clsid: TCLSID; { Class ID of object } + poleobj: IOleObject; { OLE object interface } + pstg: IStorage; { Associated storage interface } + polesite: IOleClientSite; { Associated client site interface } + sizel: TSize; { Size of object (may be 0,0) } + dvAspect: Longint; { Display aspect to use } + dwFlags: DWORD; { Object status flags } + dwUser: DWORD; { Dword for user's use } + end; + TReObject = _ReObject; + +const + +{ Flags to specify which interfaces should be returned in the structure above } + + REO_GETOBJ_NO_INTERFACES = $00000000; + REO_GETOBJ_POLEOBJ = $00000001; + REO_GETOBJ_PSTG = $00000002; + REO_GETOBJ_POLESITE = $00000004; + REO_GETOBJ_ALL_INTERFACES = $00000007; + +{ Place object at selection } + + REO_CP_SELECTION = ULONG(-1); + +{ Use character position to specify object instead of index } + + REO_IOB_SELECTION = ULONG(-1); + REO_IOB_USE_CP = ULONG(-2); + +{ Object flags } + + REO_NULL = $00000000; { No flags } + REO_READWRITEMASK = $0000003F; { Mask out RO bits } + REO_DONTNEEDPALETTE = $00000020; { Object doesn't need palette } + REO_BLANK = $00000010; { Object is blank } + REO_DYNAMICSIZE = $00000008; { Object defines size always } + REO_INVERTEDSELECT = $00000004; { Object drawn all inverted if sel } + REO_BELOWBASELINE = $00000002; { Object sits below the baseline } + REO_RESIZABLE = $00000001; { Object may be resized } + REO_LINK = $80000000; { Object is a link (RO) } + REO_STATIC = $40000000; { Object is static (RO) } + REO_SELECTED = $08000000; { Object selected (RO) } + REO_OPEN = $04000000; { Object open in its server (RO) } + REO_INPLACEACTIVE = $02000000; { Object in place active (RO) } + REO_HILITED = $01000000; { Object is to be hilited (RO) } + REO_LINKAVAILABLE = $00800000; { Link believed available (RO) } + REO_GETMETAFILE = $00400000; { Object requires metafile (RO) } + +{ Flags for IRichEditOle.GetClipboardData, } +{ IRichEditOleCallback.GetClipboardData and } +{ IRichEditOleCallback.QueryAcceptData } + + RECO_PASTE = $00000000; { paste from clipboard } + RECO_DROP = $00000001; { drop } + RECO_COPY = $00000002; { copy to the clipboard } + RECO_CUT = $00000003; { cut to the clipboard } + RECO_DRAG = $00000004; { drag } + +{ RichEdit GUIDs } + +{ IID_IRichEditOle: TGUID = ( + D1:$00020D00;D2:$0000;D3:$0000;D4:($C0,$00,$00,$00,$00,$00,$00,$46)); + IID_IRichEditOleCallback: TGUID = ( + D1:$00020D03;D2:$0000;D3:$0000;D4:($C0,$00,$00,$00,$00,$00,$00,$46));} + +type + +{ + * IRichEditOle + * + * Purpose: + * Interface used by the client of RichEdit to perform OLE-related + * operations. + * + * The methods herein may just want to be regular Windows messages. +} + + IRichEditOle = interface(IUnknown) + ['{00020d00-0000-0000-c000-000000000046}'] + function GetClientSite(out clientSite: IOleClientSite): HResult; stdcall; + function GetObjectCount: HResult; stdcall; + function GetLinkCount: HResult; stdcall; + function GetObject(iob: Longint; out reobject: TReObject; + dwFlags: DWORD): HResult; stdcall; + function InsertObject(var reobject: TReObject): HResult; stdcall; + function ConvertObject(iob: Longint; rclsidNew: TIID; + lpstrUserTypeNew: LPCSTR): HResult; stdcall; + function ActivateAs(rclsid: TIID; rclsidAs: TIID): HResult; stdcall; + function SetHostNames(lpstrContainerApp: LPCSTR; + lpstrContainerObj: LPCSTR): HResult; stdcall; + function SetLinkAvailable(iob: Longint; fAvailable: BOOL): HResult; stdcall; + function SetDvaspect(iob: Longint; dvaspect: DWORD): HResult; stdcall; + function HandsOffStorage(iob: Longint): HResult; stdcall; + function SaveCompleted(iob: Longint; const stg: IStorage): HResult; stdcall; + function InPlaceDeactivate: HResult; stdcall; + function ContextSensitiveHelp(fEnterMode: BOOL): HResult; stdcall; + function GetClipboardData(var chrg: TCharRange; reco: DWORD; + out dataobj: IDataObject): HResult; stdcall; + function ImportDataObject(dataobj: IDataObject; cf: TClipFormat; + hMetaPict: HGLOBAL): HResult; stdcall; + end; + +{ + * IRichEditOleCallback + * + * Purpose: + * Interface used by the RichEdit to get OLE-related stuff from the + * application using RichEdit. +} + + IRichEditOleCallback = interface(IUnknown) + ['{00020d03-0000-0000-c000-000000000046}'] + function GetNewStorage(out stg: IStorage): HResult; stdcall; + function GetInPlaceContext(out Frame: IOleInPlaceFrame; + out Doc: IOleInPlaceUIWindow; + lpFrameInfo: POleInPlaceFrameInfo): HResult; stdcall; + function ShowContainerUI(fShow: BOOL): HResult; stdcall; + function QueryInsertObject(const clsid: TCLSID; const stg: IStorage; + cp: Longint): HResult; stdcall; + function DeleteObject(const oleobj: IOleObject): HResult; stdcall; + function QueryAcceptData(const dataobj: IDataObject; + var cfFormat: TClipFormat; reco: DWORD; fReally: BOOL; + hMetaPict: HGLOBAL): HResult; stdcall; + function ContextSensitiveHelp(fEnterMode: BOOL): HResult; stdcall; + function GetClipboardData(const chrg: TCharRange; reco: DWORD; + out dataobj: IDataObject): HResult; stdcall; + function GetDragDropEffect(fDrag: BOOL; grfKeyState: DWORD; + var dwEffect: DWORD): HResult; stdcall; + function GetContextMenu(seltype: Word; const oleobj: IOleObject; + const chrg: TCharRange; out menu: HMENU): HResult; stdcall; + end; + +{************************************************************************} + +{ TRichEditOleCallback } + +type + TRichEditOleCallback = class(TObject, IUnknown, IRichEditOleCallback) + private + FDocForm: IVCLFrameForm; + FFrameForm: IVCLFrameForm; + FAccelTable: HAccel; + FAccelCount: Integer; + FAutoScroll: Boolean; + procedure CreateAccelTable; + procedure DestroyAccelTable; + procedure AssignFrame; + private + FRefCount: Longint; + FRichEdit: TRxCustomRichEdit; + public + constructor Create(RichEdit: TRxCustomRichEdit); + destructor Destroy; override; + function QueryInterface(const iid: TGUID; out Obj): HResult; stdcall; + function _AddRef: Longint; stdcall; + function _Release: Longint; stdcall; + function GetNewStorage(out stg: IStorage): HResult; stdcall; + function GetInPlaceContext(out Frame: IOleInPlaceFrame; + out Doc: IOleInPlaceUIWindow; + lpFrameInfo: POleInPlaceFrameInfo): HResult; stdcall; + function GetClipboardData(const chrg: TCharRange; reco: DWORD; + out dataobj: IDataObject): HResult; stdcall; + function GetContextMenu(seltype: Word; const oleobj: IOleObject; + const chrg: TCharRange; out menu: HMENU): HResult; stdcall; + function ShowContainerUI(fShow: BOOL): HResult; stdcall; + function QueryInsertObject(const clsid: TCLSID; const stg: IStorage; + cp: Longint): HResult; stdcall; + function DeleteObject(const oleobj: IOleObject): HResult; stdcall; + function QueryAcceptData(const dataobj: IDataObject; var cfFormat: TClipFormat; + reco: DWORD; fReally: BOOL; hMetaPict: HGLOBAL): HResult; stdcall; + function ContextSensitiveHelp(fEnterMode: BOOL): HResult; stdcall; + function GetDragDropEffect(fDrag: BOOL; grfKeyState: DWORD; + var dwEffect: DWORD): HResult; stdcall; + end; + +constructor TRichEditOleCallback.Create(RichEdit: TRxCustomRichEdit); +begin + inherited Create; + FRichEdit := RichEdit; +end; + +destructor TRichEditOleCallback.Destroy; +begin + DestroyAccelTable; + FFrameForm := nil; + FDocForm := nil; + inherited Destroy; +end; + +function TRichEditOleCallback.QueryInterface(const iid: TGUID; out Obj): HResult; +begin + if GetInterface(iid, Obj) then Result := S_OK + else Result := E_NOINTERFACE; +end; + +function TRichEditOleCallback._AddRef: Longint; +begin + Inc(FRefCount); + Result := FRefCount; +end; + +function TRichEditOleCallback._Release: Longint; +begin + Dec(FRefCount); + Result := FRefCount; +end; + +procedure TRichEditOleCallback.CreateAccelTable; +var + Menu: TMainMenu; +begin + if (FAccelTable = 0) and Assigned(FFrameForm) then begin + Menu := FFrameForm.Form.Menu; + if Menu <> nil then + Menu.GetOle2AcceleratorTable(FAccelTable, FAccelCount, [0, 2, 4]); + end; +end; + +procedure TRichEditOleCallback.DestroyAccelTable; +begin + if FAccelTable <> 0 then begin + DestroyAcceleratorTable(FAccelTable); + FAccelTable := 0; + FAccelCount := 0; + end; +end; + +procedure TRichEditOleCallback.AssignFrame; +begin + if (GetParentForm(FRichEdit) <> nil) and not Assigned(FFrameForm) and + FRichEdit.AllowInPlace then + begin + FDocForm := GetVCLFrameForm(ValidParentForm(FRichEdit)); + FFrameForm := FDocForm; + if IsFormMDIChild(FDocForm.Form) then + FFrameForm := GetVCLFrameForm(Application.MainForm); + end; +end; + +function TRichEditOleCallback.GetNewStorage( + out stg: IStorage): HResult; +begin + try + CreateStorage(stg); + Result := S_OK; + except + Result:= E_OUTOFMEMORY; + end; +end; + +function TRichEditOleCallback.GetInPlaceContext( + out Frame: IOleInPlaceFrame; + out Doc: IOleInPlaceUIWindow; + lpFrameInfo: POleInPlaceFrameInfo): HResult; +begin + AssignFrame; + if Assigned(FFrameForm) and FRichEdit.AllowInPlace then begin + Frame := FFrameForm; + Doc := FDocForm; + CreateAccelTable; + with lpFrameInfo^ do begin + fMDIApp := False; + FFrameForm.GetWindow(hWndFrame); + hAccel := FAccelTable; + cAccelEntries := FAccelCount; + end; + Result := S_OK; + end + else Result := E_NOTIMPL; +end; + +function TRichEditOleCallback.QueryInsertObject(const clsid: TCLSID; const stg: IStorage; + cp: Longint): HResult; +begin + Result := NOERROR; +end; + +function TRichEditOleCallback.DeleteObject(const oleobj: IOleObject): HResult; +begin + if Assigned(oleobj) then oleobj.Close(OLECLOSE_NOSAVE); + Result := NOERROR; +end; + +function TRichEditOleCallback.QueryAcceptData(const dataobj: IDataObject; + var cfFormat: TClipFormat; reco: DWORD; fReally: BOOL; + hMetaPict: HGLOBAL): HResult; +begin + Result := S_OK; +end; + +function TRichEditOleCallback.ContextSensitiveHelp(fEnterMode: BOOL): HResult; +begin + Result := NOERROR; +end; + +function TRichEditOleCallback.GetClipboardData(const chrg: TCharRange; reco: DWORD; + out dataobj: IDataObject): HResult; +begin + Result := E_NOTIMPL; +end; + +function TRichEditOleCallback.GetDragDropEffect(fDrag: BOOL; grfKeyState: DWORD; + var dwEffect: DWORD): HResult; +begin + Result := E_NOTIMPL; +end; + +function TRichEditOleCallback.GetContextMenu(seltype: Word; + const oleobj: IOleObject; const chrg: TCharRange; + out menu: HMENU): HResult; +begin + Result := E_NOTIMPL; +end; + +function TRichEditOleCallback.ShowContainerUI(fShow: BOOL): HResult; +begin + if not fShow then AssignFrame; + if Assigned(FFrameForm) then begin + if fShow then begin + FFrameForm.SetMenu(0, 0, 0); + FFrameForm.ClearBorderSpace; + FRichEdit.SetUIActive(False); + DestroyAccelTable; + TForm(FFrameForm.Form).AutoScroll := FAutoScroll; + FFrameForm := nil; + FDocForm := nil; + end + else begin + FAutoScroll := TForm(FFrameForm.Form).AutoScroll; + TForm(FFrameForm.Form).AutoScroll := False; + FRichEdit.SetUIActive(True); + end; + Result := S_OK; + end + else Result := E_NOTIMPL; +end; + +{ TOleUIObjInfo - helper interface for Object Properties dialog } + +type + TOleUIObjInfo = class(TInterfacedObject, IOleUIObjInfo) + private + FRichEdit: TRxCustomRichEdit; + FReObject: TReObject; + public + constructor Create(RichEdit: TRxCustomRichEdit; ReObject: TReObject); + function GetObjectInfo(dwObject: Longint; + var dwObjSize: Longint; var lpszLabel: PChar; + var lpszType: PChar; var lpszShortType: PChar; + var lpszLocation: PChar): HResult; stdcall; + function GetConvertInfo(dwObject: Longint; var ClassID: TCLSID; + var wFormat: Word; var ConvertDefaultClassID: TCLSID; + var lpClsidExclude: PCLSID; var cClsidExclude: Longint): HResult; stdcall; + function ConvertObject(dwObject: Longint; + const clsidNew: TCLSID): HResult; stdcall; + function GetViewInfo(dwObject: Longint; var hMetaPict: HGlobal; + var dvAspect: Longint; var nCurrentScale: Integer): HResult; stdcall; + function SetViewInfo(dwObject: Longint; hMetaPict: HGlobal; + dvAspect: Longint; nCurrentScale: Integer; + bRelativeToOrig: BOOL): HResult; stdcall; + end; + +constructor TOleUIObjInfo.Create(RichEdit: TRxCustomRichEdit; + ReObject: TReObject); +begin + inherited Create; + FRichEdit := RichEdit; + FReObject := ReObject; +end; + +function TOleUIObjInfo.GetObjectInfo(dwObject: Longint; + var dwObjSize: Longint; var lpszLabel: PChar; + var lpszType: PChar; var lpszShortType: PChar; + var lpszLocation: PChar): HResult; +begin + if @dwObjSize <> nil then + dwObjSize := -1 { Unknown size }; + if @lpszLabel <> nil then + lpszLabel := CoAllocCStr(GetFullNameStr(FReObject.poleobj)); + if @lpszType <> nil then + lpszType := CoAllocCStr(GetFullNameStr(FReObject.poleobj)); + if @lpszShortType <> nil then + lpszShortType := CoAllocCStr(GetShortNameStr(FReObject.poleobj)); + if (@lpszLocation <> nil) then begin + if Trim(FRichEdit.Title) <> '' then + lpszLocation := CoAllocCStr(Format('%s - %s', + [FRichEdit.Title, Application.Title])) + else + lpszLocation := CoAllocCStr(Application.Title); + end; + Result := S_OK; +end; + +function TOleUIObjInfo.GetConvertInfo(dwObject: Longint; var ClassID: TCLSID; + var wFormat: Word; var ConvertDefaultClassID: TCLSID; + var lpClsidExclude: PCLSID; var cClsidExclude: Longint): HResult; +begin + FReObject.poleobj.GetUserClassID(ClassID); + Result := S_OK; +end; + +function TOleUIObjInfo.ConvertObject(dwObject: Longint; + const clsidNew: TCLSID): HResult; +begin + Result := E_NOTIMPL; +end; + +function TOleUIObjInfo.GetViewInfo(dwObject: Longint; var hMetaPict: HGlobal; + var dvAspect: Longint; var nCurrentScale: Integer): HResult; +begin + if @hMetaPict <> nil then + hMetaPict := GetIconMetaPict(FReObject.poleobj, FReObject.dvAspect); + if @dvAspect <> nil then dvAspect := FReObject.dvAspect; + if @nCurrentScale <> nil then nCurrentScale := 0; + Result := S_OK; +end; + +function TOleUIObjInfo.SetViewInfo(dwObject: Longint; hMetaPict: HGlobal; + dvAspect: Longint; nCurrentScale: Integer; + bRelativeToOrig: BOOL): HResult; +var + Iconic: Boolean; +begin + if Assigned(FRichEdit.FRichEditOle) then begin + case dvAspect of + DVASPECT_CONTENT: + Iconic := False; + DVASPECT_ICON: + Iconic := True; + else + Iconic := FReObject.dvAspect = DVASPECT_ICON; + end; + IRichEditOle(FRichEdit.FRichEditOle).InPlaceDeactivate; + Result := OleSetDrawAspect(FReObject.poleobj, Iconic, hMetaPict, + FReObject.dvAspect); + if Succeeded(Result) then + IRichEditOle(FRichEdit.FRichEditOle).SetDvaspect( + Longint(REO_IOB_SELECTION), FReObject.dvAspect); + end + else Result := E_NOTIMPL; +end; + +{ TOleUILinkInfo - helper interface for Object Properties dialog } + +type + TOleUILinkInfo = class(TInterfacedObject, IOleUILinkInfo) + private + FReObject: TReObject; + FRichEdit: TRxCustomRichEdit; + FOleLink: IOleLink; + public + constructor Create(RichEdit: TRxCustomRichEdit; ReObject: TReObject); + function GetNextLink(dwLink: Longint): Longint; stdcall; + function SetLinkUpdateOptions(dwLink: Longint; + dwUpdateOpt: Longint): HResult; stdcall; + function GetLinkUpdateOptions(dwLink: Longint; + var dwUpdateOpt: Longint): HResult; stdcall; + function SetLinkSource(dwLink: Longint; pszDisplayName: PChar; + lenFileName: Longint; var chEaten: Longint; + fValidateSource: BOOL): HResult; stdcall; + function GetLinkSource(dwLink: Longint; var pszDisplayName: PChar; + var lenFileName: Longint; var pszFullLinkType: PChar; + var pszShortLinkType: PChar; var fSourceAvailable: BOOL; + var fIsSelected: BOOL): HResult; stdcall; + function OpenLinkSource(dwLink: Longint): HResult; stdcall; + function UpdateLink(dwLink: Longint; fErrorMessage: BOOL; + fErrorAction: BOOL): HResult; stdcall; + function CancelLink(dwLink: Longint): HResult; stdcall; + function GetLastUpdate(dwLink: Longint; + var LastUpdate: TFileTime): HResult; stdcall; + end; + +procedure LinkError(const Ident: string); +begin + Application.MessageBox(PChar(Ident), PChar(SLinkProperties), + MB_OK or MB_ICONSTOP); +end; + +constructor TOleUILinkInfo.Create(RichEdit: TRxCustomRichEdit; + ReObject: TReObject); +begin + inherited Create; + FReObject := ReObject; + FRichEdit := RichEdit; + OleCheck(FReObject.poleobj.QueryInterface(IOleLink, FOleLink)); +end; + +function TOleUILinkInfo.GetNextLink(dwLink: Longint): Longint; +begin + if dwLink = 0 then Result := Longint(FRichEdit) + else Result := 0; +end; + +function TOleUILinkInfo.SetLinkUpdateOptions(dwLink: Longint; + dwUpdateOpt: Longint): HResult; +begin + Result := FOleLink.SetUpdateOptions(dwUpdateOpt); + if Succeeded(Result) then FRichEdit.Modified := True; +end; + +function TOleUILinkInfo.GetLinkUpdateOptions(dwLink: Longint; + var dwUpdateOpt: Longint): HResult; +begin + Result := FOleLink.GetUpdateOptions(dwUpdateOpt); +end; + +function TOleUILinkInfo.SetLinkSource(dwLink: Longint; pszDisplayName: PChar; + lenFileName: Longint; var chEaten: Longint; + fValidateSource: BOOL): HResult; +var + DisplayName: string; + Buffer: array[0..255] of WideChar; +begin + Result := E_FAIL; + if fValidateSource then begin + DisplayName := pszDisplayName; + if Succeeded(FOleLink.SetSourceDisplayName(StringToWideChar(DisplayName, + Buffer, SizeOf(Buffer) div 2))) then + begin + chEaten := Length(DisplayName); + try + OleCheck(FReObject.poleobj.Update); + except + Application.HandleException(FRichEdit); + end; + Result := S_OK; + end; + end + else LinkError(SInvalidLinkSource); +end; + +function TOleUILinkInfo.GetLinkSource(dwLink: Longint; var pszDisplayName: PChar; + var lenFileName: Longint; var pszFullLinkType: PChar; + var pszShortLinkType: PChar; var fSourceAvailable: BOOL; + var fIsSelected: BOOL): HResult; +var + Moniker: IMoniker; +begin + if @pszDisplayName <> nil then + pszDisplayName := CoAllocCStr(GetDisplayNameStr(FOleLink)); + if @lenFileName <> nil then begin + lenFileName := 0; + FOleLink.GetSourceMoniker(Moniker); + if Moniker <> nil then begin + lenFileName := OleStdGetLenFilePrefixOfMoniker(Moniker); + ReleaseObject(Moniker); + end; + end; + if @pszFullLinkType <> nil then + pszFullLinkType := CoAllocCStr(GetFullNameStr(FReObject.poleobj)); + if @pszShortLinkType <> nil then + pszShortLinkType := CoAllocCStr(GetShortNameStr(FReObject.poleobj)); + Result := S_OK; +end; + +function TOleUILinkInfo.OpenLinkSource(dwLink: Longint): HResult; +begin + try + OleCheck(FReObject.poleobj.DoVerb(OLEIVERB_SHOW, nil, FReObject.polesite, + 0, FRichEdit.Handle, FRichEdit.ClientRect)); + except + Application.HandleException(FRichEdit); + end; + Result := S_OK; +end; + +function TOleUILinkInfo.UpdateLink(dwLink: Longint; fErrorMessage: BOOL; + fErrorAction: BOOL): HResult; +begin + try + OleCheck(FReObject.poleobj.Update); + except + Application.HandleException(FRichEdit); + end; + Result := S_OK; +end; + +function TOleUILinkInfo.CancelLink(dwLink: Longint): HResult; +begin + LinkError(SCannotBreakLink); + Result := E_NOTIMPL; +end; + +function TOleUILinkInfo.GetLastUpdate(dwLink: Longint; + var LastUpdate: TFileTime): HResult; +begin + Result := S_OK; +end; + +{ Get RichEdit OLE interface } + +function GetRichEditOle(Wnd: HWnd; var RichEditOle): Boolean; +begin + Result := SendMessage(Wnd, EM_GETOLEINTERFACE, 0, Longint(@RichEditOle)) <> 0; +end; + +{ TRichEditStrings } + +const + ReadError = $0001; + WriteError = $0002; + NoError = $0000; + +type + TRichEditStrings = class(TStrings) + private + RichEdit: TRxCustomRichEdit; + FFormat: TRichStreamFormat; + FMode: TRichStreamModes; + FConverter: TConversion; + procedure EnableChange(const Value: Boolean); + protected + function Get(Index: Integer): string; override; + function GetCount: Integer; override; + procedure Put(Index: Integer; const S: string); override; + procedure SetUpdateState(Updating: Boolean); override; + procedure SetTextStr(const Value: string); override; + public + destructor Destroy; override; + procedure Clear; override; + procedure AddStrings(Strings: TStrings); override; + procedure Delete(Index: Integer); override; + procedure Insert(Index: Integer; const S: string); override; + procedure LoadFromFile(const FileName: string); override; + procedure LoadFromStream(Stream: TStream); override; + procedure SaveToFile(const FileName: string); override; + procedure SaveToStream(Stream: TStream); override; + property Format: TRichStreamFormat read FFormat write FFormat; + property Mode: TRichStreamModes read FMode write FMode; + end; + +destructor TRichEditStrings.Destroy; +begin + FConverter.Free; + inherited Destroy; +end; + +procedure TRichEditStrings.AddStrings(Strings: TStrings); +var + SelChange: TNotifyEvent; +begin + SelChange := RichEdit.OnSelectionChange; + RichEdit.OnSelectionChange := nil; + try + inherited AddStrings(Strings); + finally + RichEdit.OnSelectionChange := SelChange; + end; +end; + +function TRichEditStrings.GetCount: Integer; +begin + with RichEdit do begin + Result := SendMessage(Handle, EM_GETLINECOUNT, 0, 0); + if GetLineLength(GetLineIndex(Result - 1)) = 0 then Dec(Result); + end; +end; + +function TRichEditStrings.Get(Index: Integer): string; +var + Text: array[0..4095] of Char; + L: Integer; +begin + Word((@Text)^) := SizeOf(Text); + L := SendMessage(RichEdit.Handle, EM_GETLINE, Index, Longint(@Text)); + if (Text[L - 2] = #13) and (Text[L - 1] = #10) then Dec(L, 2) + else if (RichEditVersion >= 2) and (Text[L - 1] = #13) then Dec(L); + SetString(Result, Text, L); +end; + +procedure TRichEditStrings.Put(Index: Integer; const S: string); +var + Selection: TCharRange; +begin + if Index >= 0 then + begin + Selection.cpMin := RichEdit.GetLineIndex(Index); + if Selection.cpMin <> -1 then begin + Selection.cpMax := Selection.cpMin + + RichEdit.GetLineLength(Selection.cpMin); + SendMessage(RichEdit.Handle, EM_EXSETSEL, 0, Longint(@Selection)); + RichEdit.FLinesUpdating := True; + try + SendMessage(RichEdit.Handle, EM_REPLACESEL, 0, Longint(PChar(S))); + finally + RichEdit.FLinesUpdating := False; + end; + end; + end; +end; + +procedure TRichEditStrings.Insert(Index: Integer; const S: string); +var + L: Integer; + Selection: TCharRange; + Fmt: PChar; + Str: string; +begin + if Index >= 0 then begin + Selection.cpMin := RichEdit.GetLineIndex(Index); + if Selection.cpMin >= 0 then begin + if RichEditVersion = 1 then Fmt := '%s'#13#10 + else Fmt := '%s'#13; + end + else begin + Selection.cpMin := RichEdit.GetLineIndex(Index - 1); + if Selection.cpMin < 0 then Exit; + L := RichEdit.GetLineLength(Selection.cpMin); + if L = 0 then Exit; + Inc(Selection.cpMin, L); + if RichEditVersion = 1 then Fmt := #13#10'%s' + else Fmt := #13'%s'; + end; + Selection.cpMax := Selection.cpMin; + SendMessage(RichEdit.Handle, EM_EXSETSEL, 0, Longint(@Selection)); + Str := SysUtils.Format(Fmt, [S]); + RichEdit.FLinesUpdating := True; + try + SendMessage(RichEdit.Handle, EM_REPLACESEL, 0, Longint(PChar(Str))); + finally + RichEdit.FLinesUpdating := False; + end; + if RichEditVersion = 1 then + if RichEdit.SelStart <> (Selection.cpMax + Length(Str)) then + raise EOutOfResources.Create(ResStr(sRichEditInsertError)); + end; +end; + +procedure TRichEditStrings.Delete(Index: Integer); +const + Empty: PChar = ''; +var + Selection: TCharRange; +begin + if Index < 0 then Exit; + Selection.cpMin := RichEdit.GetLineIndex(Index); + if Selection.cpMin <> -1 then begin + Selection.cpMax := RichEdit.GetLineIndex(Index + 1); + if Selection.cpMax = -1 then + Selection.cpMax := Selection.cpMin + + RichEdit.GetLineLength(Selection.cpMin); + SendMessage(RichEdit.Handle, EM_EXSETSEL, 0, Longint(@Selection)); + RichEdit.FLinesUpdating := True; + try + SendMessage(RichEdit.Handle, EM_REPLACESEL, 0, Longint(Empty)); + finally + RichEdit.FLinesUpdating := False; + end; + end; +end; + +procedure TRichEditStrings.Clear; +begin + RichEdit.Clear; +end; + +procedure TRichEditStrings.SetUpdateState(Updating: Boolean); +begin + if RichEdit.Showing then + SendMessage(RichEdit.Handle, WM_SETREDRAW, Ord(not Updating), 0); + if not Updating then begin + RichEdit.Refresh; + RichEdit.Perform(CM_TEXTCHANGED, 0, 0); + end; +end; + +procedure TRichEditStrings.EnableChange(const Value: Boolean); +var + EventMask: Longint; +begin + with RichEdit do begin + EventMask := SendMessage(Handle, EM_GETEVENTMASK, 0, 0); + if Value then + EventMask := EventMask or ENM_CHANGE + else + EventMask := EventMask and not ENM_CHANGE; + SendMessage(Handle, EM_SETEVENTMASK, 0, EventMask); + end; +end; + +procedure TRichEditStrings.SetTextStr(const Value: string); +begin + EnableChange(False); + try + inherited SetTextStr(Value); + finally + EnableChange(True); + end; +end; + +function AdjustLineBreaks(Dest, Source: PChar): Integer; assembler; +asm + PUSH ESI + PUSH EDI + MOV EDI,EAX + MOV ESI,EDX + MOV EDX,EAX + CLD +@@1: LODSB +@@2: OR AL,AL + JE @@4 + CMP AL,0AH + JE @@3 + STOSB + CMP AL,0DH + JNE @@1 + MOV AL,0AH + STOSB + LODSB + CMP AL,0AH + JE @@1 + JMP @@2 +@@3: MOV EAX,0A0DH + STOSW + JMP @@1 +@@4: STOSB + LEA EAX,[EDI-1] + SUB EAX,EDX + POP EDI + POP ESI +end; + +function StreamSave(dwCookie: Longint; pbBuff: PByte; + cb: Longint; var pcb: Longint): Longint; stdcall; +var + StreamInfo: PRichEditStreamInfo; +begin + Result := NoError; + StreamInfo := PRichEditStreamInfo(Pointer(dwCookie)); + try + pcb := 0; + if StreamInfo^.Converter <> nil then + pcb := StreamInfo^.Converter.ConvertWriteStream(StreamInfo^.Stream, PChar(pbBuff), cb); + except + Result := WriteError; + end; +end; + +function StreamLoad(dwCookie: Longint; pbBuff: PByte; + cb: Longint; var pcb: Longint): Longint; stdcall; +var + Buffer, pBuff: PChar; + StreamInfo: PRichEditStreamInfo; +begin + Result := NoError; + StreamInfo := PRichEditStreamInfo(Pointer(dwCookie)); + Buffer := StrAlloc(cb + 1); + try + cb := cb div 2; + pcb := 0; + pBuff := Buffer + cb; + try + if StreamInfo^.Converter <> nil then + pcb := StreamInfo^.Converter.ConvertReadStream(StreamInfo^.Stream, pBuff, cb); + if pcb > 0 then + begin + pBuff[pcb] := #0; + if pBuff[pcb - 1] = #13 then pBuff[pcb - 1] := #0; + pcb := AdjustLineBreaks(Buffer, pBuff); + Move(Buffer^, pbBuff^, pcb); + end; + except + Result := ReadError; + end; + finally + StrDispose(Buffer); + end; +end; + +procedure TRichEditStrings.LoadFromStream(Stream: TStream); +var + EditStream: TEditStream; + Position: Longint; + TextType: Longint; + StreamInfo: TRichEditStreamInfo; + Converter: TConversion; +begin + StreamInfo.Stream := Stream; + if FConverter <> nil then Converter := FConverter + else Converter := RichEdit.DefaultConverter.Create; + StreamInfo.Converter := Converter; + try + with EditStream do + begin + dwCookie := Longint(Pointer(@StreamInfo)); + pfnCallBack := @StreamLoad; + dwError := 0; + end; + Position := Stream.Position; + case FFormat of + sfDefault: + if RichEdit.PlainText then TextType := SF_TEXT + else TextType := SF_RTF; + sfRichText: TextType := SF_RTF; + else {sfPlainText} TextType := SF_TEXT; + end; + if TextType = SF_RTF then begin + if smPlainRtf in Mode then TextType := TextType or SFF_PLAINRTF; + end; + if TextType = SF_TEXT then begin + if (smUnicode in Mode) and (RichEditVersion > 1) then + TextType := TextType or SF_UNICODE; + end; + if smSelection in Mode then TextType := TextType or SFF_SELECTION; + SendMessage(RichEdit.Handle, EM_STREAMIN, TextType, Longint(@EditStream)); + if (EditStream.dwError <> 0) then begin + Stream.Position := Position; + if (TextType and SF_RTF = SF_RTF) then TextType := SF_TEXT + else TextType := SF_RTF; + SendMessage(RichEdit.Handle, EM_STREAMIN, TextType, Longint(@EditStream)); + if EditStream.dwError <> 0 then + raise EOutOfResources.Create(ResStr(sRichEditLoadFail)); + end; + RichEdit.SetSelection(0, 0, True); + finally + if FConverter = nil then Converter.Free; + end; +end; + +procedure TRichEditStrings.SaveToStream(Stream: TStream); +var + EditStream: TEditStream; + TextType: Longint; + StreamInfo: TRichEditStreamInfo; + Converter: TConversion; +begin + if FConverter <> nil then Converter := FConverter + else Converter := RichEdit.DefaultConverter.Create; + StreamInfo.Stream := Stream; + StreamInfo.Converter := Converter; + try + with EditStream do + begin + dwCookie := Longint(Pointer(@StreamInfo)); + pfnCallBack := @StreamSave; + dwError := 0; + end; + case FFormat of + sfDefault: + if RichEdit.PlainText then TextType := SF_TEXT + else TextType := SF_RTF; + sfRichText: TextType := SF_RTF; + else {sfPlainText} TextType := SF_TEXT; + end; + if TextType = SF_RTF then begin + if smNoObjects in Mode then TextType := SF_RTFNOOBJS; + if smPlainRtf in Mode then TextType := TextType or SFF_PLAINRTF; + end + else if TextType = SF_TEXT then begin + if (smUnicode in Mode) and (RichEditVersion > 1) then + TextType := TextType or SF_UNICODE; + end; + if smSelection in Mode then TextType := TextType or SFF_SELECTION; + SendMessage(RichEdit.Handle, EM_STREAMOUT, TextType, Longint(@EditStream)); + if EditStream.dwError <> 0 then + raise EOutOfResources.Create(ResStr(sRichEditSaveFail)); + finally + if FConverter = nil then Converter.Free; + end; +end; + +procedure TRichEditStrings.LoadFromFile(const FileName: string); +var + Ext: string; + Convert: PRichConversionFormat; + SaveFormat: TRichStreamFormat; +begin + Ext := AnsiLowerCaseFileName(ExtractFileExt(Filename)); + System.Delete(Ext, 1, 1); + Convert := ConversionFormatList; + while Convert <> nil do + with Convert^ do + if Extension <> Ext then Convert := Next + else Break; + if (FConverter = nil) and (Convert <> nil) then + FConverter := Convert^.ConversionClass.Create; + try + SaveFormat := Format; + try + if Convert <> nil then begin + if Convert^.PlainText then FFormat := sfPlainText + else FFormat := sfRichText; + end; + inherited LoadFromFile(FileName); + finally + FFormat := SaveFormat; + end; + except + FConverter.Free; + FConverter := nil; + raise; + end; +end; + +procedure TRichEditStrings.SaveToFile(const FileName: string); +var + Ext: string; + Convert: PRichConversionFormat; + SaveFormat: TRichStreamFormat; +begin + Ext := AnsiLowerCaseFileName(ExtractFileExt(Filename)); + System.Delete(Ext, 1, 1); + Convert := ConversionFormatList; + while Convert <> nil do + with Convert^ do + if Extension <> Ext then Convert := Next + else Break; + if (FConverter = nil) and (Convert <> nil) then + FConverter := Convert^.ConversionClass.Create; + try + SaveFormat := Format; + try + if Convert <> nil then begin + if Convert^.PlainText then FFormat := sfPlainText + else FFormat := sfRichText; + end; + inherited SaveToFile(FileName); + finally + FFormat := SaveFormat; + end; + except + FConverter.Free; + FConverter := nil; + raise; + end; +end; + +{ TOEMConversion } + +function TOEMConversion.ConvertReadStream(Stream: TStream; Buffer: PChar; + BufSize: Integer): Integer; +var + Mem: TMemoryStream; +begin + Mem := TMemoryStream.Create; + try + Mem.SetSize(BufSize); + Result := inherited ConvertReadStream(Stream, PChar(Mem.Memory), BufSize); + OemToCharBuff(PChar(Mem.Memory), Buffer, Result); + finally + Mem.Free; + end; +end; + +function TOEMConversion.ConvertWriteStream(Stream: TStream; Buffer: PChar; + BufSize: Integer): Integer; +var + Mem: TMemoryStream; +begin + Mem := TMemoryStream.Create; + try + Mem.SetSize(BufSize); + CharToOemBuff(Buffer, PChar(Mem.Memory), BufSize); + Result := inherited ConvertWriteStream(Stream, PChar(Mem.Memory), BufSize); + finally + Mem.Free; + end; +end; + +{ TRxCustomRichEdit } + +constructor TRxCustomRichEdit.Create(AOwner: TComponent); +var + DC: HDC; +begin + inherited Create(AOwner); + ControlStyle := ControlStyle - [csSetCaption]; + FSelAttributes := TRxTextAttributes.Create(Self, atSelected); + FDefAttributes := TRxTextAttributes.Create(Self, atDefaultText); + FWordAttributes := TRxTextAttributes.Create(Self, atWord); + FParagraph := TRxParaAttributes.Create(Self); + FRichEditStrings := TRichEditStrings.Create; + TRichEditStrings(FRichEditStrings).RichEdit := Self; + TabStop := True; + Width := 185; + Height := 89; + AutoSize := False; + DoubleBuffered := False; + FAllowObjects := True; + FAllowInPlace := True; + FAutoVerbMenu := True; + FHideSelection := True; + FHideScrollBars := True; + ScrollBars := ssBoth; + FSelectionBar := True; + FLangOptions := [rlAutoFont]; + DC := GetDC(0); + FScreenLogPixels := GetDeviceCaps(DC, LOGPIXELSY); + ReleaseDC(0, DC); + DefaultConverter := TConversion; + FOldParaAlignment := TParaAlignment(Alignment); + FUndoLimit := 100; + FAutoURLDetect := True; + FWordSelection := True; + with FClickRange do begin + cpMin := -1; + cpMax := -1; + end; + FCallback := TRichEditOleCallback.Create(Self); + Perform(CM_PARENTBIDIMODECHANGED, 0, 0); +end; + +destructor TRxCustomRichEdit.Destroy; +begin + FLastFind := nil; + FSelAttributes.Free; + FDefAttributes.Free; + FWordAttributes.Free; + FParagraph.Free; + FRichEditStrings.Free; + FMemStream.Free; + FPopupVerbMenu.Free; + FFindDialog.Free; + FReplaceDialog.Free; + inherited Destroy; + { be sure that callback object is destroyed after inherited Destroy } + TRichEditOleCallback(FCallback).Free; +end; + +procedure TRxCustomRichEdit.Clear; +begin + CloseObjects; + inherited Clear; + Modified := False; +end; + +procedure TRxCustomRichEdit.CreateParams(var Params: TCreateParams); +const + HideScrollBars: array[Boolean] of DWORD = (ES_DISABLENOSCROLL, 0); + HideSelections: array[Boolean] of DWORD = (ES_NOHIDESEL, 0); + WordWraps: array[Boolean] of DWORD = (0, ES_AUTOHSCROLL); + SelectionBars: array[Boolean] of DWORD = (0, ES_SELECTIONBAR); +begin + inherited CreateParams(Params); + case RichEditVersion of + 1: CreateSubClass(Params, RICHEDIT_CLASS10A); + else CreateSubClass(Params, RICHEDIT_CLASS); + end; + with Params do begin + Style := (Style and not (WS_HSCROLL or WS_VSCROLL)) or ES_SAVESEL or + (WS_CLIPSIBLINGS or WS_CLIPCHILDREN); + { NOTE: WS_CLIPCHILDREN and WS_CLIPSIBLINGS are essential otherwise } + { once the object is inserted you see some painting problems. } + Style := Style and not (WS_HSCROLL or WS_VSCROLL); + if ScrollBars in [ssVertical, ssBoth] then + Style := Style or WS_VSCROLL; + if (ScrollBars in [ssHorizontal, ssBoth]) and not WordWrap then + Style := Style or WS_HSCROLL; + Style := Style or HideScrollBars[FHideScrollBars] or + SelectionBars[FSelectionBar] or HideSelections[FHideSelection] and + not WordWraps[WordWrap]; + WindowClass.style := WindowClass.style and not (CS_HREDRAW or CS_VREDRAW); + end; +end; + +procedure TRxCustomRichEdit.CreateWnd; +var + StreamFmt: TRichStreamFormat; + Mode: TRichStreamModes; + DesignMode: Boolean; + Mask: Longint; +begin + StreamFmt := TRichEditStrings(Lines).Format; + Mode := TRichEditStrings(Lines).Mode; + inherited CreateWnd; + if (SysLocale.FarEast) and not (SysLocale.PriLangID = LANG_JAPANESE) then + Font.Charset := GetDefFontCharSet; + Mask := ENM_CHANGE or ENM_SELCHANGE or ENM_REQUESTRESIZE or ENM_PROTECTED; + if RichEditVersion >= 2 then Mask := Mask or ENM_LINK; + SendMessage(Handle, EM_SETEVENTMASK, 0, Mask); + SendMessage(Handle, EM_SETBKGNDCOLOR, 0, ColorToRGB(Color)); + DoSetMaxLength(MaxLength); + SetWordSelection(FWordSelection); + if RichEditVersion >= 2 then begin + SendMessage(Handle, EM_AUTOURLDETECT, Longint(FAutoURLDetect), 0); + SendMessage(Handle, EM_SETTYPOGRAPHYOPTIONS, TO_ADVANCEDTYPOGRAPHY, TO_ADVANCEDTYPOGRAPHY); + FUndoLimit := SendMessage(Handle, EM_SETUNDOLIMIT, FUndoLimit, 0); + UpdateTextModes(PlainText); + SetLangOptions(FLangOptions); + end; + if FAllowObjects then begin + SendMessage(Handle, EM_SETOLECALLBACK, 0, + LPARAM(TRichEditOleCallback(FCallback) as IRichEditOleCallback)); + GetRichEditOle(Handle, FRichEditOle); + UpdateHostNames; + end; + if FMemStream <> nil then begin + FMemStream.ReadBuffer(DesignMode, SizeOf(DesignMode)); + if DesignMode then begin + TRichEditStrings(Lines).Format := sfPlainText; + TRichEditStrings(Lines).Mode := []; + end; + try + Lines.LoadFromStream(FMemStream); + FMemStream.Free; + FMemStream := nil; + finally + TRichEditStrings(Lines).Format := StreamFmt; + TRichEditStrings(Lines).Mode := Mode; + end; + end; + if RichEditVersion < 2 then + SendMessage(Handle, WM_SETFONT, 0, 0); + Modified := FModified; +end; + +procedure TRxCustomRichEdit.DestroyWnd; +var + StreamFmt: TRichStreamFormat; + Mode: TRichStreamModes; + DesignMode: Boolean; +begin + FModified := Modified; + FMemStream := TMemoryStream.Create; + StreamFmt := TRichEditStrings(Lines).Format; + Mode := TRichEditStrings(Lines).Mode; + DesignMode := (csDesigning in ComponentState); + FMemStream.WriteBuffer(DesignMode, SizeOf(DesignMode)); + if DesignMode then begin + TRichEditStrings(Lines).Format := sfPlainText; + TRichEditStrings(Lines).Mode := []; + end; + try + Lines.SaveToStream(FMemStream); + FMemStream.Position := 0; + finally + TRichEditStrings(Lines).Format := StreamFmt; + TRichEditStrings(Lines).Mode := Mode; + end; + inherited DestroyWnd; +end; + +procedure TRxCustomRichEdit.SetAllowObjects(Value: Boolean); +begin + if FAllowObjects <> Value then begin + FAllowObjects := Value; + RecreateWnd; + end; +end; + +procedure TRxCustomRichEdit.UpdateHostNames; +var + AppName: string; +begin + if HandleAllocated and Assigned(FRichEditOle) then begin + AppName := Application.Title; + if Trim(AppName) = '' then + AppName := ExtractFileName(Application.ExeName); + if Trim(Title) = '' then + IRichEditOle(FRichEditOle).SetHostNames(PChar(AppName), PChar(AppName)) + else + IRichEditOle(FRichEditOle).SetHostNames(PChar(AppName), PChar(Title)); + end; +end; + +procedure TRxCustomRichEdit.SetTitle(const Value: string); +begin + if FTitle <> Value then begin + FTitle := Value; + UpdateHostNames; + end; +end; + +function TRxCustomRichEdit.GetPopupMenu: TPopupMenu; +var + EnumOleVerb: IEnumOleVerb; + OleVerb: TOleVerb; + Item: TMenuItem; + ReObject: TReObject; +begin + FPopupVerbMenu.Free; + FPopupVerbMenu := nil; + Result := inherited GetPopupMenu; + if FAutoVerbMenu and (SelectionType = [stObject]) and + Assigned(FRichEditOle) then + begin + FillChar(ReObject, SizeOf(ReObject), 0); + ReObject.cbStruct := SizeOf(ReObject); + if Succeeded(IRichEditOle(FRichEditOle).GetObject( + Longint(REO_IOB_SELECTION), ReObject, REO_GETOBJ_POLEOBJ)) then + try + if Assigned(ReObject.poleobj) and + (ReObject.dwFlags and REO_INPLACEACTIVE = 0) then + begin + FPopupVerbMenu := TPopupMenu.Create(Self); + if ReObject.poleobj.EnumVerbs(EnumOleVerb) = 0 then + try + while (EnumOleVerb.Next(1, OleVerb, nil) = 0) and + (OleVerb.lVerb >= 0) and + (OleVerb.grfAttribs and OLEVERBATTRIB_ONCONTAINERMENU <> 0) do + begin + Item := TMenuItem.Create(FPopupVerbMenu); + Item.Caption := WideCharToString(OleVerb.lpszVerbName); + Item.Tag := OleVerb.lVerb; + Item.Default := (OleVerb.lVerb = OLEIVERB_PRIMARY); + Item.OnClick := PopupVerbClick; + FPopupVerbMenu.Items.Add(Item); + end; + finally + ReleaseObject(EnumOleVerb); + end; + if (Result <> nil) and (Result.Items.Count > 0) then begin + Item := TMenuItem.Create(FPopupVerbMenu); + Item.Caption := '-'; + Result.Items.Add(Item); + Item := TMenuItem.Create(FPopupVerbMenu); + Item.Caption := Format(ResStr(SPropDlgCaption), + [GetFullNameStr(ReObject.poleobj)]); + Item.OnClick := ObjectPropsClick; + Result.Items.Add(Item); + if FPopupVerbMenu.Items.Count > 0 then begin + FPopupVerbMenu.Items.Caption := GetFullNameStr(ReObject.poleobj); + Result.Items.Add(FPopupVerbMenu.Items); + end; + end + else if FPopupVerbMenu.Items.Count > 0 then begin + Item := TMenuItem.Create(FPopupVerbMenu); + Item.Caption := Format(ResStr(SPropDlgCaption), + [GetFullNameStr(ReObject.poleobj)]); + Item.OnClick := ObjectPropsClick; + FPopupVerbMenu.Items.Insert(0, Item); + Result := FPopupVerbMenu; + end; + end; + finally + ReleaseObject(ReObject.poleobj); + end; + end; +end; + +procedure TRxCustomRichEdit.PopupVerbClick(Sender: TObject); +var + ReObject: TReObject; +begin + if Assigned(FRichEditOle) then begin + FillChar(ReObject, SizeOf(ReObject), 0); + ReObject.cbStruct := SizeOf(ReObject); + if Succeeded(IRichEditOle(FRichEditOle).GetObject( + Longint(REO_IOB_SELECTION), ReObject, REO_GETOBJ_POLEOBJ or + REO_GETOBJ_POLESITE)) then + try + if ReObject.dwFlags and REO_INPLACEACTIVE = 0 then + OleCheck(ReObject.poleobj.DoVerb((Sender as TMenuItem).Tag, nil, + ReObject.polesite, 0, Handle, ClientRect)); + finally + ReleaseObject(ReObject.polesite); + ReleaseObject(ReObject.poleobj); + end; + end; +end; + +procedure TRxCustomRichEdit.ObjectPropsClick(Sender: TObject); +begin + ObjectPropertiesDialog; +end; + +procedure TRxCustomRichEdit.WMSetFont(var Message: TWMSetFont); +begin + FDefAttributes.Assign(Font); +end; + +procedure TRxCustomRichEdit.CMFontChanged(var Message: TMessage); +begin + inherited; + FDefAttributes.Assign(Font); +end; + +procedure TRxCustomRichEdit.CreateWindowHandle(const Params: TCreateParams); +var + Bounds: TRect; +begin + Bounds := BoundsRect; + inherited CreateWindowHandle(Params); + if HandleAllocated then BoundsRect := Bounds; +end; + +procedure TRxCustomRichEdit.DoSetMaxLength(Value: Integer); +begin + { The rich edit control's default maximum amount of text is 32K } + { Let's set it at 16M by default } + if Value = 0 then Value := $FFFFFF; + SendMessage(Handle, EM_EXLIMITTEXT, 0, Value); +end; + +function TRxCustomRichEdit.GetCaretPos: TPoint; +var + CharRange: TCharRange; +begin + SendMessage(Handle, EM_EXGETSEL, 0, Longint(@CharRange)); + Result.X := CharRange.cpMax; + Result.Y := LineFromChar(Result.X); + Dec(Result.X, GetLineIndex(-1)); +end; + +function TRxCustomRichEdit.GetSelLength: Integer; +begin + with GetSelection do + Result := cpMax - cpMin; +end; + +function TRxCustomRichEdit.GetSelStart: Integer; +begin + Result := GetSelection.cpMin; +end; + +function TRxCustomRichEdit.GetSelText: string; +begin + with GetSelection do + Result := GetTextRange(cpMin, cpMax); +end; + +function TRxCustomRichEdit.GetSelTextBuf(Buffer: PChar; BufSize: Integer): Integer; +var + S: string; +begin + S := SelText; + Result := Length(S); + if BufSize < Length(S) then Result := BufSize; + StrPLCopy(Buffer, S, Result); +end; + +procedure TRxCustomRichEdit.CMBiDiModeChanged(var Message: TMessage); +var + AParagraph: TParaFormat2; +begin + HandleNeeded; { we REALLY need the handle for BiDi } + inherited; + Paragraph.GetAttributes(AParagraph); + AParagraph.dwMask := PFM_ALIGNMENT; + AParagraph.wAlignment := Ord(Alignment) + 1; + Paragraph.SetAttributes(AParagraph); +end; + +procedure TRxCustomRichEdit.SetHideScrollBars(Value: Boolean); +begin + if HideScrollBars <> Value then begin + FHideScrollBars := Value; + RecreateWnd; + end; +end; + +procedure TRxCustomRichEdit.SetSelectionBar(Value: Boolean); +begin + if FSelectionBar <> Value then begin + FSelectionBar := Value; + RecreateWnd; + end; +end; + +procedure TRxCustomRichEdit.SetHideSelection(Value: Boolean); +begin + if HideSelection <> Value then begin + FHideSelection := Value; + SendMessage(Handle, EM_HIDESELECTION, Ord(HideSelection), LPARAM(True)); + end; +end; + +function TRxCustomRichEdit.GetAutoURLDetect: Boolean; +begin + Result := FAutoURLDetect; + if HandleAllocated and not (csDesigning in ComponentState) then begin + if RichEditVersion >= 2 then + Result := Boolean(SendMessage(Handle, EM_GETAUTOURLDETECT, 0, 0)); + end; +end; + +procedure TRxCustomRichEdit.SetAutoURLDetect(Value: Boolean); +begin + if Value <> FAutoURLDetect then begin + FAutoURLDetect := Value; + if HandleAllocated and (RichEditVersion >= 2) then + SendMessage(Handle, EM_AUTOURLDETECT, Longint(FAutoURLDetect), 0); + end; +end; + +function TRxCustomRichEdit.GetWordSelection: Boolean; +begin + Result := FWordSelection; + if HandleAllocated then + Result := (SendMessage(Handle, EM_GETOPTIONS, 0, 0) and + ECO_AUTOWORDSELECTION) <> 0; +end; + +procedure TRxCustomRichEdit.SetWordSelection(Value: Boolean); +var + Options: LPARAM; +begin + FWordSelection := Value; + if HandleAllocated then begin + Options := SendMessage(Handle, EM_GETOPTIONS, 0, 0); + if Value then Options := Options or ECO_AUTOWORDSELECTION + else Options := Options and not ECO_AUTOWORDSELECTION; + SendMessage(Handle, EM_SETOPTIONS, ECOOP_SET, Options); + end; +end; + +const + RichLangOptions: array[TRichLangOption] of DWORD = (IMF_AUTOKEYBOARD, + IMF_AUTOFONT, IMF_IMECANCELCOMPLETE, IMF_IMEALWAYSSENDNOTIFY); + +function TRxCustomRichEdit.GetLangOptions: TRichLangOptions; +var + Flags: Longint; + I: TRichLangOption; +begin + Result := FLangOptions; + if HandleAllocated and not (csDesigning in ComponentState) and + (RichEditVersion >= 2) then + begin + Result := []; + Flags := SendMessage(Handle, EM_GETLANGOPTIONS, 0, 0); + for I := Low(TRichLangOption) to High(TRichLangOption) do + if Flags and RichLangOptions[I] <> 0 then Include(Result, I); + end; +end; + +procedure TRxCustomRichEdit.SetLangOptions(Value: TRichLangOptions); +var + Flags: DWORD; + I: TRichLangOption; +begin + FLangOptions := Value; + if HandleAllocated and (RichEditVersion >= 2) then begin + Flags := 0; + for I := Low(TRichLangOption) to High(TRichLangOption) do + if I in Value then Flags := Flags or RichLangOptions[I]; + SendMessage(Handle, EM_SETLANGOPTIONS, 0, LPARAM(Flags)); + end; +end; + +procedure TRxCustomRichEdit.SetSelAttributes(Value: TRxTextAttributes); +begin + FSelAttributes.Assign(Value); +end; + +function TRxCustomRichEdit.GetCanRedo: Boolean; +begin + Result := False; + if HandleAllocated and (RichEditVersion >= 2) then + Result := SendMessage(Handle, EM_CANREDO, 0, 0) <> 0; +end; + +function TRxCustomRichEdit.GetCanPaste: Boolean; +begin + Result := False; + if HandleAllocated then + Result := SendMessage(Handle, EM_CANPASTE, 0, 0) <> 0; +end; + +function TRxCustomRichEdit.GetRedoName: TUndoName; +begin + Result := unUnknown; + if (RichEditVersion >= 2) and HandleAllocated then + Result := TUndoName(SendMessage(Handle, EM_GETREDONAME, 0, 0)); +end; + +function TRxCustomRichEdit.GetUndoName: TUndoName; +begin + Result := unUnknown; + if (RichEditVersion >= 2) and HandleAllocated then + Result := TUndoName(SendMessage(Handle, EM_GETUNDONAME, 0, 0)); +end; + +function TRxCustomRichEdit.GetSelectionType: TRichSelectionType; +const + SelTypes: array[TRichSelection] of Integer = ( + SEL_TEXT, SEL_OBJECT, SEL_MULTICHAR, SEL_MULTIOBJECT); +var + Selection: Integer; + I: TRichSelection; +begin + Result := []; + if HandleAllocated then begin + Selection := SendMessage(Handle, EM_SELECTIONTYPE, 0, 0); + for I := Low(TRichSelection) to High(TRichSelection) do + if SelTypes[I] and Selection <> 0 then Include(Result, I); + end; +end; + +function TRxCustomRichEdit.GetSelection: TCharRange; +begin + SendMessage(Handle, EM_EXGETSEL, 0, Longint(@Result)); +end; + +procedure TRxCustomRichEdit.SetSelection(StartPos, EndPos: Longint; + ScrollCaret: Boolean); +var + CharRange: TCharRange; +begin + with CharRange do begin + cpMin := StartPos; + cpMax := EndPos; + end; + SendMessage(Handle, EM_EXSETSEL, 0, Longint(@CharRange)); + if ScrollCaret then SendMessage(Handle, EM_SCROLLCARET, 0, 0); +end; + +procedure TRxCustomRichEdit.SetSelLength(Value: Integer); +begin + with GetSelection do SetSelection(cpMin, cpMin + Value, True); +end; + +procedure TRxCustomRichEdit.SetSelStart(Value: Integer); +begin + SetSelection(Value, Value, False); +end; + +function TRxCustomRichEdit.GetCharPos(CharIndex: Integer): TPoint; +var + Res: Longint; +begin + FillChar(Result, SizeOf(Result), 0); + if HandleAllocated then begin + if RichEditVersion = 2 then begin + Res := SendMessage(Handle, Messages.EM_POSFROMCHAR, CharIndex, 0); + Result.X := LoWord(Res); + Result.Y := HiWord(Res); + end + else { RichEdit 1.0 and 3.0 } + SendMessage(Handle, Messages.EM_POSFROMCHAR, WPARAM(@Result), CharIndex); + end; +end; + +function TRxCustomRichEdit.GetTextRange(StartPos, EndPos: Longint): string; +var + TextRange: TTextRange; +begin + SetLength(Result, EndPos - StartPos + 1); + TextRange.chrg.cpMin := StartPos; + TextRange.chrg.cpMax := EndPos; + TextRange.lpstrText := PAnsiChar(Result); + SetLength(Result, SendMessage(Handle, EM_GETTEXTRANGE, 0, Longint(@TextRange))); +end; + +function TRxCustomRichEdit.WordAtCursor: string; +var + Range: TCharRange; +begin + Result := ''; + if HandleAllocated then begin + Range.cpMax := SelStart; + if Range.cpMax = 0 then Range.cpMin := 0 + else if SendMessage(Handle, EM_FINDWORDBREAK, WB_ISDELIMITER, Range.cpMax) <> 0 then + Range.cpMin := SendMessage(Handle, EM_FINDWORDBREAK, WB_MOVEWORDLEFT, Range.cpMax) + else + Range.cpMin := SendMessage(Handle, EM_FINDWORDBREAK, WB_LEFT, Range.cpMax); + while SendMessage(Handle, EM_FINDWORDBREAK, WB_ISDELIMITER, Range.cpMin) <> 0 do + Inc(Range.cpMin); + Range.cpMax := SendMessage(Handle, EM_FINDWORDBREAK, WB_RIGHTBREAK, Range.cpMax); + Result := Trim(GetTextRange(Range.cpMin, Range.cpMax)); + end; +end; + +function TRxCustomRichEdit.LineFromChar(CharIndex: Integer): Integer; +begin + Result := SendMessage(Handle, EM_EXLINEFROMCHAR, 0, CharIndex); +end; + +function TRxCustomRichEdit.GetLineIndex(LineNo: Integer): Integer; +begin + Result := SendMessage(Handle, EM_LINEINDEX, LineNo, 0); +end; + +function TRxCustomRichEdit.GetLineLength(CharIndex: Integer): Integer; +begin + Result := SendMessage(Handle, EM_LINELENGTH, CharIndex, 0); +end; + +procedure TRxCustomRichEdit.SetUndoLimit(Value: Integer); +begin + if (Value <> FUndoLimit) then begin + FUndoLimit := Value; + if (RichEditVersion >= 2) and HandleAllocated then + FUndoLimit := SendMessage(Handle, EM_SETUNDOLIMIT, Value, 0); + end; +end; + +procedure TRxCustomRichEdit.SetDefAttributes(Value: TRxTextAttributes); +begin + FDefAttributes.Assign(Value); +end; + +procedure TRxCustomRichEdit.SetWordAttributes(Value: TRxTextAttributes); +begin + FWordAttributes.Assign(Value); +end; + +function TRxCustomRichEdit.GetStreamFormat: TRichStreamFormat; +begin + Result := TRichEditStrings(Lines).Format; +end; + +function TRxCustomRichEdit.GetStreamMode: TRichStreamModes; +begin + Result := TRichEditStrings(Lines).Mode; +end; + +procedure TRxCustomRichEdit.SetStreamFormat(Value: TRichStreamFormat); +begin + TRichEditStrings(Lines).Format := Value; +end; + +procedure TRxCustomRichEdit.SetStreamMode(Value: TRichStreamModes); +begin + TRichEditStrings(Lines).Mode := Value; +end; + +procedure TRxCustomRichEdit.SetPlainText(Value: Boolean); +var + MemStream: TStream; + StreamFmt: TRichStreamFormat; + Mode: TRichStreamModes; +begin + if PlainText <> Value then begin + if HandleAllocated and (RichEditVersion >= 2) then begin + MemStream := TMemoryStream.Create; + try + StreamFmt := TRichEditStrings(Lines).Format; + Mode := TRichEditStrings(Lines).Mode; + try + if (csDesigning in ComponentState) or Value then + TRichEditStrings(Lines).Format := sfPlainText + else TRichEditStrings(Lines).Format := sfRichText; + TRichEditStrings(Lines).Mode := []; + Lines.SaveToStream(MemStream); + MemStream.Position := 0; + TRichEditStrings(Lines).EnableChange(False); + try + SendMessage(Handle, WM_SETTEXT, 0, 0); + UpdateTextModes(Value); + FPlainText := Value; + finally + TRichEditStrings(Lines).EnableChange(True); + end; + Lines.LoadFromStream(MemStream); + finally + TRichEditStrings(Lines).Format := StreamFmt; + TRichEditStrings(Lines).Mode := Mode; + end; + finally + MemStream.Free; + end; + end; + FPlainText := Value; + end; +end; + +procedure TRxCustomRichEdit.UpdateTextModes(Plain: Boolean); +const + TextModes: array[Boolean] of DWORD = (TM_RICHTEXT, TM_PLAINTEXT); + UndoModes: array[Boolean] of DWORD = (TM_SINGLELEVELUNDO, TM_MULTILEVELUNDO); +begin + if (RichEditVersion >= 2) and HandleAllocated then begin + SendMessage(Handle, EM_SETTEXTMODE, TextModes[Plain] or + UndoModes[FUndoLimit > 1], 0); + end; +end; + +procedure TRxCustomRichEdit.CMColorChanged(var Message: TMessage); +begin + inherited; + SendMessage(Handle, EM_SETBKGNDCOLOR, 0, ColorToRGB(Color)) +end; + +procedure TRxCustomRichEdit.EMReplaceSel(var Message: TMessage); +var + CharRange: TCharRange; +begin + Perform(EM_EXGETSEL, 0, Longint(@CharRange)); + with CharRange do + cpMax := cpMin + Integer(StrLen(PChar(Message.lParam))); + if (FUndoLimit > 1) and (RichEditVersion >= 2) and not FLinesUpdating then + Message.wParam := 1; { allow Undo } + inherited; + if not FLinesUpdating then begin + Perform(EM_EXSETSEL, 0, Longint(@CharRange)); + Perform(EM_SCROLLCARET, 0, 0); + end; +end; + +procedure TRxCustomRichEdit.SetRichEditStrings(Value: TStrings); +begin + FRichEditStrings.Assign(Value); +end; + +procedure TRxCustomRichEdit.CloseObjects; +var + I: Integer; + ReObject: TReObject; +begin + if Assigned(FRichEditOle) then begin + FillChar(ReObject, SizeOf(ReObject), 0); + ReObject.cbStruct := SizeOf(ReObject); + with IRichEditOle(FRichEditOle) do begin + for I := GetObjectCount - 1 downto 0 do + if Succeeded(GetObject(I, ReObject, REO_GETOBJ_POLEOBJ)) then begin + if ReObject.dwFlags and REO_INPLACEACTIVE <> 0 then + IRichEditOle(FRichEditOle).InPlaceDeactivate; + ReObject.poleobj.Close(OLECLOSE_NOSAVE); + ReleaseObject(ReObject.poleobj); + end; + end; + end; +end; + +function TRxCustomRichEdit.PasteSpecialDialog: Boolean; + + procedure SetPasteEntry(var Entry: TOleUIPasteEntry; Format: TClipFormat; + tymed: DWORD; const FormatName, ResultText: string; Flags: DWORD); + begin + with Entry do begin + fmtetc.cfFormat := Format; + fmtetc.dwAspect := DVASPECT_CONTENT; + fmtetc.lIndex := -1; + fmtetc.tymed := tymed; + if FormatName <> '' then lpstrFormatName := PChar(FormatName) + else lpstrFormatName := '%s'; + if ResultText <> '' then lpstrResultText := PChar(ResultText) + else lpstrResultText := '%s'; + dwFlags := Flags; + end; + end; + +const + PasteFormatCount = 6; +var + Data: TOleUIPasteSpecial; + PasteFormats: array[0..PasteFormatCount - 1] of TOleUIPasteEntry; + Format: Integer; + OleClientSite: IOleClientSite; + Storage: IStorage; + OleObject: IOleObject; + ReObject: TReObject; + Selection: TCharRange; +begin + Result := False; + if not CanPaste or not Assigned(FRichEditOle) then Exit; + FillChar(Data, SizeOf(Data), 0); + FillChar(PasteFormats, SizeOf(PasteFormats), 0); + with Data do begin + cbStruct := SizeOf(Data); + hWndOwner := Handle; + arrPasteEntries := @PasteFormats; + cPasteEntries := PasteFormatCount; + arrLinkTypes := @CFLinkSource; + cLinkTypes := 1; + dwFlags := PSF_SELECTPASTE; + end; + SetPasteEntry(PasteFormats[0], CFEmbeddedObject, TYMED_ISTORAGE, '', '', + OLEUIPASTE_PASTE or OLEUIPASTE_ENABLEICON); + SetPasteEntry(PasteFormats[1], CFLinkSource, TYMED_ISTREAM, '', '', + OLEUIPASTE_LINKTYPE1 or OLEUIPASTE_ENABLEICON); + SetPasteEntry(PasteFormats[2], CFRtf, TYMED_ISTORAGE, + CF_RTF, CF_RTF, OLEUIPASTE_PASTE); + SetPasteEntry(PasteFormats[3], CFRtfNoObjs, TYMED_ISTORAGE, + CF_RTFNOOBJS, CF_RTFNOOBJS, OLEUIPASTE_PASTE); + SetPasteEntry(PasteFormats[4], CF_TEXT, TYMED_HGLOBAL, + 'Unformatted text', 'text without any formatting', OLEUIPASTE_PASTE); + SetPasteEntry(PasteFormats[5], CF_BITMAP, TYMED_GDI, + 'Windows Bitmap', 'bitmap image', OLEUIPASTE_PASTE); + try + if OleUIPasteSpecial(Data) = OLEUI_OK then begin + Result := True; + if Data.nSelectedIndex in [0, 1] then begin + { CFEmbeddedObject, CFLinkSource } + FillChar(ReObject, SizeOf(TReObject), 0); + IRichEditOle(FRichEditOle).GetClientSite(OleClientSite); + Storage := nil; + try + CreateStorage(Storage); + case Data.nSelectedIndex of + 0: OleCheck(OleCreateFromData(Data.lpSrcDataObj, IOleObject, + OLERENDER_DRAW, nil, OleClientSite, Storage, OleObject)); + 1: OleCheck(OleCreateLinkFromData(Data.lpSrcDataObj, IOleObject, + OLERENDER_DRAW, nil, OleClientSite, Storage, OleObject)); + end; + try + with ReObject do begin + cbStruct := SizeOf(TReObject); + cp := REO_CP_SELECTION; + poleobj := OleObject; + OleObject.GetUserClassID(clsid); + pstg := Storage; + polesite := OleClientSite; + dvAspect := DVASPECT_CONTENT; + dwFlags := REO_RESIZABLE; + OleCheck(OleSetDrawAspect(OleObject, + Data.dwFlags and PSF_CHECKDISPLAYASICON <> 0, + Data.hMetaPict, dvAspect)); + end; + SendMessage(Handle, EM_EXGETSEL, 0, Longint(@Selection)); + Selection.cpMax := Selection.cpMin + 1; + OleCheck(IRichEditOle(FRichEditOle).InsertObject(ReObject)); + SendMessage(Handle, EM_EXSETSEL, 0, Longint(@Selection)); + IRichEditOle(FRichEditOle).SetDvaspect( + Longint(REO_IOB_SELECTION), ReObject.dvAspect); + finally + ReleaseObject(OleObject); + end; + finally + ReleaseObject(OleClientSite); + ReleaseObject(Storage); + end; + end + else begin + Format := PasteFormats[Data.nSelectedIndex].fmtetc.cfFormat; + OleCheck(IRichEditOle(FRichEditOle).ImportDataObject( + Data.lpSrcDataObj, Format, Data.hMetaPict)); + end; + SendMessage(Handle, EM_SCROLLCARET, 0, 0); + end; + finally + DestroyMetaPict(Data.hMetaPict); + ReleaseObject(Data.lpSrcDataObj); + end; +end; + +function TRxCustomRichEdit.InsertObjectDialog: Boolean; +var + Data: TOleUIInsertObject; + NameBuffer: array[0..255] of Char; + OleClientSite: IOleClientSite; + Storage: IStorage; + OleObject: IOleObject; + ReObject: TReObject; + IsNewObject: Boolean; + Selection: TCharRange; +begin + FillChar(Data, SizeOf(Data), 0); + FillChar(NameBuffer, SizeOf(NameBuffer), 0); + FillChar(ReObject, SizeOf(TReObject), 0); + if Assigned(FRichEditOle) then begin + IRichEditOle(FRichEditOle).GetClientSite(OleClientSite); + Storage := nil; + try + CreateStorage(Storage); + with Data do begin + cbStruct := SizeOf(Data); + dwFlags := IOF_SELECTCREATENEW or IOF_VERIFYSERVERSEXIST or + IOF_CREATENEWOBJECT or IOF_CREATEFILEOBJECT or IOF_CREATELINKOBJECT; + hWndOwner := Handle; + lpszFile := NameBuffer; + cchFile := SizeOf(NameBuffer); + iid := IOleObject; + oleRender := OLERENDER_DRAW; + lpIOleClientSite := OleClientSite; + lpIStorage := Storage; + ppvObj := @OleObject; + end; + try + Result := OleUIInsertObject(Data) = OLEUI_OK; + if Result then + try + IsNewObject := Data.dwFlags and IOF_SELECTCREATENEW = IOF_SELECTCREATENEW; + with ReObject do begin + cbStruct := SizeOf(TReObject); + cp := REO_CP_SELECTION; + clsid := Data.clsid; + poleobj := OleObject; + pstg := Storage; + polesite := OleClientSite; + dvAspect := DVASPECT_CONTENT; + dwFlags := REO_RESIZABLE; + if IsNewObject then dwFlags := dwFlags or REO_BLANK; + OleCheck(OleSetDrawAspect(OleObject, + Data.dwFlags and IOF_CHECKDISPLAYASICON <> 0, + Data.hMetaPict, dvAspect)); + end; + SendMessage(Handle, EM_EXGETSEL, 0, Longint(@Selection)); + Selection.cpMax := Selection.cpMin + 1; + OleCheck(IRichEditOle(FRichEditOle).InsertObject(ReObject)); + SendMessage(Handle, EM_EXSETSEL, 0, Longint(@Selection)); + SendMessage(Handle, EM_SCROLLCARET, 0, 0); + IRichEditOle(FRichEditOle).SetDvaspect( + Longint(REO_IOB_SELECTION), ReObject.dvAspect); + if IsNewObject then OleObject.DoVerb(OLEIVERB_SHOW, nil, + OleClientSite, 0, Handle, ClientRect); + finally + ReleaseObject(OleObject); + end; + finally + DestroyMetaPict(Data.hMetaPict); + end; + finally + ReleaseObject(OleClientSite); + ReleaseObject(Storage); + end; + end + else Result := False; +end; + +function TRxCustomRichEdit.ObjectPropertiesDialog: Boolean; +var + ObjectProps: TOleUIObjectProps; + PropSheet: TPropSheetHeader; + GeneralProps: TOleUIGnrlProps; + ViewProps: TOleUIViewProps; + LinkProps: TOleUILinkProps; + DialogCaption: string; + ReObject: TReObject; +begin + Result := False; + if not Assigned(FRichEditOle) or (SelectionType <> [stObject]) then Exit; + FillChar(ObjectProps, SizeOf(ObjectProps), 0); + FillChar(PropSheet, SizeOf(PropSheet), 0); + FillChar(GeneralProps, SizeOf(GeneralProps), 0); + FillChar(ViewProps, SizeOf(ViewProps), 0); + FillChar(LinkProps, SizeOf(LinkProps), 0); + FillChar(ReObject, SizeOf(ReObject), 0); + ReObject.cbStruct := SizeOf(ReObject); + if Succeeded(IRichEditOle(FRichEditOle).GetObject(Longint(REO_IOB_SELECTION), + ReObject, REO_GETOBJ_POLEOBJ or REO_GETOBJ_POLESITE)) then + if ReObject.dwFlags and REO_INPLACEACTIVE = 0 then begin + ObjectProps.cbStruct := SizeOf(ObjectProps); + ObjectProps.dwFlags := OPF_DISABLECONVERT; + ObjectProps.lpPS := @PropSheet; + ObjectProps.lpObjInfo := TOleUIObjInfo.Create(Self, ReObject); + if (ReObject.dwFlags and REO_LINK) <> 0 then begin + ObjectProps.dwFlags := ObjectProps.dwFlags or OPF_OBJECTISLINK; + ObjectProps.lpLinkInfo := TOleUILinkInfo.Create(Self, ReObject); + end; + ObjectProps.lpGP := @GeneralProps; + ObjectProps.lpVP := @ViewProps; + ObjectProps.lpLP := @LinkProps; + PropSheet.dwSize := SizeOf(PropSheet); + PropSheet.hWndParent := Handle; + PropSheet.hInstance := MainInstance; + DialogCaption := Format(ResStr(SPropDlgCaption), + [GetFullNameStr(ReObject.poleobj)]); + PropSheet.pszCaption := PChar(DialogCaption); + GeneralProps.cbStruct := SizeOf(GeneralProps); + ViewProps.cbStruct := SizeOf(ViewProps); + ViewProps.dwFlags := VPF_DISABLESCALE; + LinkProps.cbStruct := SizeOf(LinkProps); + LinkProps.dwFlags := ELF_DISABLECANCELLINK; + Result := OleUIObjectProperties(ObjectProps) = OLEUI_OK; + end; +end; + +procedure TRxCustomRichEdit.Print(const Caption: string); +var + Range: TFormatRange; + LastChar, MaxLen, LogX, LogY, OldMap: Integer; + SaveRect: TRect; + TextLenEx: TGetTextLengthEx; +begin + FillChar(Range, SizeOf(TFormatRange), 0); + with Printer, Range do begin + Title := Caption; + BeginDoc; + hdc := Handle; + hdcTarget := hdc; + LogX := GetDeviceCaps(Handle, LOGPIXELSX); + LogY := GetDeviceCaps(Handle, LOGPIXELSY); + if IsRectEmpty(PageRect) then begin + rc.right := PageWidth * 1440 div LogX; + rc.bottom := PageHeight * 1440 div LogY; + end + else begin + rc.left := PageRect.Left * 1440 div LogX; + rc.top := PageRect.Top * 1440 div LogY; + rc.right := PageRect.Right * 1440 div LogX; + rc.bottom := PageRect.Bottom * 1440 div LogY; + end; + rcPage := rc; + SaveRect := rc; + LastChar := 0; + if RichEditVersion >= 2 then begin + with TextLenEx do begin + flags := GTL_DEFAULT; + codepage := CP_ACP; + end; + MaxLen := Perform(EM_GETTEXTLENGTHEX, WParam(@TextLenEx), 0); + end + else MaxLen := GetTextLen; + chrg.cpMax := -1; + { ensure printer DC is in text map mode } + OldMap := SetMapMode(hdc, MM_TEXT); + SendMessage(Self.Handle, EM_FORMATRANGE, 0, 0); { flush buffer } + try + repeat + rc := SaveRect; + chrg.cpMin := LastChar; + LastChar := SendMessage(Self.Handle, EM_FORMATRANGE, 1, Longint(@Range)); + if (LastChar < MaxLen) and (LastChar <> -1) then NewPage; + until (LastChar >= MaxLen) or (LastChar = -1); + EndDoc; + finally + SendMessage(Self.Handle, EM_FORMATRANGE, 0, 0); { flush buffer } + SetMapMode(hdc, OldMap); { restore previous map mode } + end; + end; +end; + +var + Painting: Boolean = False; + +procedure TRxCustomRichEdit.WMPaint(var Message: TWMPaint); +var + R, R1: TRect; +begin + if RichEditVersion >= 2 then + inherited + else begin + if GetUpdateRect(Handle, R, True) then + begin + with ClientRect do R1 := Rect(Right - 3, Top, Right, Bottom); + if IntersectRect(R, R, R1) then InvalidateRect(Handle, @R1, True); + end; + if Painting then + Invalidate + else begin + Painting := True; + try + inherited; + finally + Painting := False; + end; + end; + end; +end; + +procedure TRxCustomRichEdit.WMDestroy(var Msg: TWMDestroy); +begin + CloseObjects; + ReleaseObject(FRichEditOle); + inherited; +end; + +procedure TRxCustomRichEdit.WMMouseMove(var Message: TMessage); +begin + inherited; +end; + +procedure TRxCustomRichEdit.WMSetCursor(var Message: TWMSetCursor); +begin + inherited; +end; + +{$IFDEF Delphi5} +procedure TRxCustomRichEdit.WMRButtonUp(var Message: TMessage); +begin + { RichEd20 does not pass the WM_RBUTTONUP message to defwndproc, } + { so we get no WM_CONTEXTMENU message. Simulate message here. } +// if Win32MajorVersion < 5 then + Perform(WM_CONTEXTMENU, Handle, LParam(PointToSmallPoint( + ClientToScreen(SmallPointToPoint(TWMMouse(Message).Pos))))); + inherited; +end; +{$ENDIF} + +procedure TRxCustomRichEdit.CNNotify(var Message: TWMNotify); +var + AMsg: TMessage; +begin + with Message do + case NMHdr^.code of + EN_SELCHANGE: SelectionChange; + EN_REQUESTRESIZE: RequestSize(PReqSize(NMHdr)^.rc); + EN_SAVECLIPBOARD: + with PENSaveClipboard(NMHdr)^ do + if not SaveClipboard(cObjectCount, cch) then Result := 1; + EN_PROTECTED: + with PENProtected(NMHdr)^ do begin + AMsg.Msg := Msg; + AMsg.WParam := WParam; + AMsg.LParam := LParam; + AMsg.Result := 0; + if not ProtectChange(AMsg, chrg.cpMin, chrg.cpMax) then + Result := 1; + end; + EN_LINK: + with PENLink(NMHdr)^ do begin + case Msg of + WM_RBUTTONDOWN: + begin + FClickRange := chrg; + FClickBtn := mbRight; + end; + WM_RBUTTONUP: + begin + if (FClickBtn = mbRight) and (FClickRange.cpMin = chrg.cpMin) and + (FClickRange.cpMax = chrg.cpMax) then + URLClick(GetTextRange(chrg.cpMin, chrg.cpMax), mbRight); + with FClickRange do begin + cpMin := -1; + cpMax := -1; + end; + end; + WM_LBUTTONDOWN: + begin + FClickRange := chrg; + FClickBtn := mbLeft; + end; + WM_LBUTTONUP: + begin + if (FClickBtn = mbLeft) and (FClickRange.cpMin = chrg.cpMin) and + (FClickRange.cpMax = chrg.cpMax) then + URLClick(GetTextRange(chrg.cpMin, chrg.cpMax), mbLeft); + with FClickRange do begin + cpMin := -1; + cpMax := -1; + end; + end; + end; + end; + EN_STOPNOUNDO: + begin + { cannot allocate enough memory to maintain the undo state } + end; + end; +end; + +function TRxCustomRichEdit.SaveClipboard(NumObj, NumChars: Integer): Boolean; +begin + Result := True; + if Assigned(OnSaveClipboard) then + OnSaveClipboard(Self, NumObj, NumChars, Result); +end; + +function TRxCustomRichEdit.ProtectChange(const Message: TMessage; StartPos, + EndPos: Integer): Boolean; +begin + Result := False; + if Assigned(OnProtectChangeEx) then + OnProtectChangeEx(Self, Message, StartPos, EndPos, Result) + else if Assigned(OnProtectChange) then + OnProtectChange(Self, StartPos, EndPos, Result); +end; + +procedure TRxCustomRichEdit.SelectionChange; +begin + if Assigned(OnSelectionChange) then OnSelectionChange(Self); +end; + +procedure TRxCustomRichEdit.RequestSize(const Rect: TRect); +begin + if Assigned(OnResizeRequest) then OnResizeRequest(Self, Rect); +end; + +procedure TRxCustomRichEdit.URLClick(const URLText: string; Button: TMouseButton); +begin + if Assigned(OnURLClick) then OnURLClick(Self, URLText, Button); +end; + +function TRxCustomRichEdit.FindText(const SearchStr: string; + StartPos, Length: Integer; Options: TRichSearchTypes): Integer; +var + Find: TFindTextEx; + Flags: Integer; +begin + with Find.chrg do begin + cpMin := StartPos; + cpMax := cpMin + Abs(Length); + end; + if RichEditVersion >= 2 then begin + if not (stBackward in Options) then Flags := FT_DOWN + else Flags := 0; + end + else begin + Options := Options - [stBackward]; + Flags := 0; + end; + if stWholeWord in Options then Flags := Flags or FT_WHOLEWORD; + if stMatchCase in Options then Flags := Flags or FT_MATCHCASE; + Find.lpstrText := PChar(SearchStr); + Result := SendMessage(Handle, EM_FINDTEXTEX, Flags, Longint(@Find)); + if (Result >= 0) and (stSetSelection in Options) then begin + SendMessage(Handle, EM_EXSETSEL, 0, Longint(@Find.chrgText)); + SendMessage(Handle, EM_SCROLLCARET, 0, 0); + end; +end; + +procedure TRxCustomRichEdit.ClearUndo; +begin + SendMessage(Handle, EM_EMPTYUNDOBUFFER, 0, 0); +end; + +procedure TRxCustomRichEdit.Redo; +begin + SendMessage(Handle, EM_REDO, 0, 0); +end; + +procedure TRxCustomRichEdit.StopGroupTyping; +begin + if (RichEditVersion >= 2) and HandleAllocated then + SendMessage(Handle, EM_STOPGROUPTYPING, 0, 0); +end; + +procedure TRxCustomRichEdit.SetUIActive(Active: Boolean); +var + Form: TCustomForm; +begin + try + Form := GetParentForm(Self); + if Form <> nil then + if Active then begin + if (Form.ActiveOleControl <> nil) and + (Form.ActiveOleControl <> Self) then + Form.ActiveOleControl.Perform(CM_UIDEACTIVATE, 0, 0); + Form.ActiveOleControl := Self; + if AllowInPlace and CanFocus then SetFocus; + end + else begin + if Form.ActiveOleControl = Self then Form.ActiveOleControl := nil; + if (Form.ActiveControl = Self) and AllowInPlace then begin + Windows.SetFocus(Handle); + SelectionChange; + end; + end; + except + Application.HandleException(Self); + end; +end; + +procedure TRxCustomRichEdit.CMDocWindowActivate(var Message: TMessage); +begin + if Assigned(FCallback) then + with TRichEditOleCallback(FCallback) do + if Assigned(FDocForm) and IsFormMDIChild(FDocForm.Form) then begin + if Message.WParam = 0 then begin + FFrameForm.SetMenu(0, 0, 0); + FFrameForm.ClearBorderSpace; + end; + end; +end; + +procedure TRxCustomRichEdit.CMUIDeactivate(var Message: TMessage); +begin + if (GetParentForm(Self) <> nil) and Assigned(FRichEditOle) and + (GetParentForm(Self).ActiveOleControl = Self) then + {IRichEditOle(FRichEditOle).InPlaceDeactivate}; +end; + +{ Find & Replace Dialogs } + +procedure TRxCustomRichEdit.SetupFindDialog(Dialog: TFindDialog; + const SearchStr, ReplaceStr: string); +begin + with Dialog do begin + if SearchStr <> '' then FindText := SearchStr; + if RichEditVersion = 1 then + Options := Options + [frHideUpDown, frDown]; + OnFind := FindDialogFind; + OnClose := FindDialogClose; + end; + if Dialog is TReplaceDialog then + with TReplaceDialog(Dialog) do begin + if ReplaceStr <> '' then ReplaceText := ReplaceStr; + OnReplace := ReplaceDialogReplace; + end; +end; + +function TRxCustomRichEdit.FindDialog(const SearchStr: string): TFindDialog; +begin + if FFindDialog = nil then begin + FFindDialog := TFindDialog.Create(Self); + if FReplaceDialog <> nil then + FFindDialog.FindText := FReplaceDialog.FindText; + end; + Result := FFindDialog; + SetupFindDialog(FFindDialog, SearchStr, ''); + FFindDialog.Execute; +end; + +function TRxCustomRichEdit.ReplaceDialog(const SearchStr, + ReplaceStr: string): TReplaceDialog; +begin + if FReplaceDialog = nil then begin + FReplaceDialog := TReplaceDialog.Create(Self); + if FFindDialog <> nil then + FReplaceDialog.FindText := FFindDialog.FindText; + end; + Result := FReplaceDialog; + SetupFindDialog(FReplaceDialog, SearchStr, ReplaceStr); + FReplaceDialog.Execute; +end; + +function TRxCustomRichEdit.GetCanFindNext: Boolean; +begin + Result := HandleAllocated and (FLastFind <> nil) and + (FLastFind.FindText <> ''); +end; + +function TRxCustomRichEdit.FindNext: Boolean; +begin + if CanFindNext then Result := FindEditText(FLastFind, False, True) + else Result := False; +end; + +procedure TRxCustomRichEdit.AdjustFindDialogPosition(Dialog: TFindDialog); +var + TextRect, R: TRect; +begin + if Dialog.Handle = 0 then Exit; + with TextRect do begin + TopLeft := ClientToScreen(GetCharPos(SelStart)); + BottomRight := ClientToScreen(GetCharPos(SelStart + SelLength)); + Inc(Bottom, 20); + end; + with Dialog do begin + GetWindowRect(Handle, R); + if PtInRect(R, TextRect.TopLeft) or PtInRect(R, TextRect.BottomRight) then + begin + if TextRect.Top > R.Bottom - R.Top + 20 then + OffsetRect(R, 0, TextRect.Top - R.Bottom - 20) + else begin + if TextRect.Top + R.Bottom - R.Top < GetSystemMetrics(SM_CYSCREEN) then + OffsetRect(R, 0, 40 + TextRect.Top - R.Top); + end; + Position := R.TopLeft; + end; + end; +end; + +function TRxCustomRichEdit.FindEditText(Dialog: TFindDialog; AdjustPos, Events: Boolean): Boolean; +var + Length, StartPos: Integer; + SrchOptions: TRichSearchTypes; + + function Max(A, B: Longint): Longint; + begin + if A > B then Result := A + else Result := B; + end; + + function Min(A, B: Longint): Longint; + begin + if A < B then Result := A + else Result := B; + end; + +begin + with TFindDialog(Dialog) do begin + SrchOptions := [stSetSelection]; + if frDown in Options then begin + StartPos := Max(SelStart, SelStart + SelLength); + Length := System.Length(Text) - StartPos + 1; + end + else begin + SrchOptions := SrchOptions + [stBackward]; + StartPos := Min(SelStart, SelStart + SelLength); + Length := StartPos + 1; + end; + if frMatchCase in Options then + SrchOptions := SrchOptions + [stMatchCase]; + if frWholeWord in Options then + SrchOptions := SrchOptions + [stWholeWord]; + Result := Self.FindText(FindText, StartPos, Length, SrchOptions) >= 0; + if FindText <> '' then FLastFind := Dialog; + if Result then begin + if AdjustPos then AdjustFindDialogPosition(Dialog); + end + else if Events then TextNotFound(Dialog); + end; +end; + +procedure TRxCustomRichEdit.TextNotFound(Dialog: TFindDialog); +begin + with Dialog do + if Assigned(FOnTextNotFound) then FOnTextNotFound(Self, FindText); +end; + +procedure TRxCustomRichEdit.FindDialogFind(Sender: TObject); +begin + FindEditText(TFindDialog(Sender), True, True); +end; + +procedure TRxCustomRichEdit.ReplaceDialogReplace(Sender: TObject); +var + Cnt: Integer; + SaveSelChange: TNotifyEvent; +begin + with TReplaceDialog(Sender) do begin + if (frReplaceAll in Options) then begin + Cnt := 0; + SaveSelChange := FOnSelChange; + TRichEditStrings(Lines).EnableChange(False); + try + FOnSelChange := nil; + while FindEditText(TFindDialog(Sender), False, False) do begin + SelText := ReplaceText; + Inc(Cnt); + end; + if Cnt = 0 then TextNotFound(TFindDialog(Sender)) + else AdjustFindDialogPosition(TFindDialog(Sender)); + finally + TRichEditStrings(Lines).EnableChange(True); + FOnSelChange := SaveSelChange; + if Cnt > 0 then begin + Change; + SelectionChange; + end; + end; + end + else if (frReplace in Options) then begin + if FindEditText(TFindDialog(Sender), True, True) then + SelText := ReplaceText; + end; + end; +end; + +procedure TRxCustomRichEdit.FindDialogClose(Sender: TObject); +begin + CloseFindDialog(Sender as TFindDialog); +end; + +procedure TRxCustomRichEdit.CloseFindDialog(Dialog: TFindDialog); +begin + if Assigned(FOnCloseFindDialog) then FOnCloseFindDialog(Self, Dialog); +end; + +{ Conversion formats } + +procedure AppendConversionFormat(const Ext: string; Plain: Boolean; + AClass: TConversionClass); +var + NewRec: PRichConversionFormat; +begin + New(NewRec); + with NewRec^ do begin + Extension := AnsiLowerCaseFileName(Ext); + PlainText := Plain; + ConversionClass := AClass; + Next := ConversionFormatList; + end; + ConversionFormatList := NewRec; +end; + +class procedure TRxCustomRichEdit.RegisterConversionFormat(const AExtension: string; + APlainText: Boolean; AConversionClass: TConversionClass); +begin + AppendConversionFormat(AExtension, APlainText, AConversionClass); +end; + +{ Initialization part } + +var + OldError: Longint; + FLibHandle: THandle; + Ver: TOsVersionInfo; + +initialization + RichEditVersion := 1; + OldError := SetErrorMode(SEM_NOOPENFILEERRORBOX); + try + FLibHandle := LoadLibrary(RichEdit20ModuleName); + if (FLibHandle > 0) and (FLibHandle < HINSTANCE_ERROR) then FLibHandle := 0; + if FLibHandle = 0 then begin + FLibHandle := LoadLibrary(RichEdit10ModuleName); + if (FLibHandle > 0) and (FLibHandle < HINSTANCE_ERROR) then FLibHandle := 0; + end + else begin + RichEditVersion := 2; + Ver.dwOSVersionInfoSize := SizeOf(Ver); + GetVersionEx(Ver); + with Ver do begin + if (dwPlatformId = VER_PLATFORM_WIN32_NT) and + (dwMajorVersion >= 5) then + RichEditVersion := 3; + end; + end; + finally + SetErrorMode(OldError); + end; + CFEmbeddedObject := RegisterClipboardFormat(CF_EMBEDDEDOBJECT); + CFLinkSource := RegisterClipboardFormat(CF_LINKSOURCE); + CFRtf := RegisterClipboardFormat(CF_RTF); + CFRtfNoObjs := RegisterClipboardFormat(CF_RTFNOOBJS); +finalization + if FLibHandle <> 0 then FreeLibrary(FLibHandle); +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxRichEditor.dfm b/official/4.2/LibD11/frxRichEditor.dfm new file mode 100644 index 0000000..85dc971 Binary files /dev/null and b/official/4.2/LibD11/frxRichEditor.dfm differ diff --git a/official/4.2/LibD11/frxRichEditor.pas b/official/4.2/LibD11/frxRichEditor.pas new file mode 100644 index 0000000..6fe0a50 --- /dev/null +++ b/official/4.2/LibD11/frxRichEditor.pas @@ -0,0 +1,487 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ RichEdit design editor } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxRichEditor; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Menus, ExtCtrls, Buttons, frxClass, frxRich, frxCustomEditors, + frxCtrls, frxRichEdit, ImgList, frxDock, ToolWin, ComCtrls +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxRichEditor = class(TfrxViewEditor) + public + function Edit: Boolean; override; + function HasEditor: Boolean; override; + procedure GetMenuItems; override; + function Execute(Tag: Integer; Checked: Boolean): Boolean; override; + end; + + TfrxRichEditorForm = class(TForm) + OpenDialog: TOpenDialog; + SaveDialog: TSaveDialog; + SpeedBar: TToolBar; + Ruler: TPanel; + FontDialog1: TFontDialog; + FirstInd: TLabel; + LeftInd: TLabel; + RulerLine: TBevel; + RightInd: TLabel; + BoldB: TToolButton; + ItalicB: TToolButton; + LeftAlignB: TToolButton; + CenterAlignB: TToolButton; + RightAlignB: TToolButton; + UnderlineB: TToolButton; + BulletsB: TToolButton; + TTB: TToolButton; + CancelB: TToolButton; + OkB: TToolButton; + ExprB: TToolButton; + FontNameCB: TfrxFontComboBox; + FontSizeCB: TfrxComboBox; + OpenB: TToolButton; + SaveB: TToolButton; + UndoB: TToolButton; + Sep1: TToolButton; + Sep2: TToolButton; + Sep3: TfrxTBPanel; + Sep4: TToolButton; + Sep5: TToolButton; + BlockAlignB: TToolButton; + + procedure SelectionChange(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FileOpen(Sender: TObject); + procedure FileSaveAs(Sender: TObject); + procedure EditUndo(Sender: TObject); + procedure SelectFont(Sender: TObject); + procedure RulerResize(Sender: TObject); + procedure FormResize(Sender: TObject); + procedure FormPaint(Sender: TObject); + procedure BoldBClick(Sender: TObject); + procedure AlignButtonClick(Sender: TObject); + procedure FontNameCBChange(Sender: TObject); + procedure BulletsBClick(Sender: TObject); + procedure RulerItemMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure RulerItemMouseMove(Sender: TObject; Shift: TShiftState; X, + Y: Integer); + procedure FirstIndMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure LeftIndMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure RightIndMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + procedure CancelBClick(Sender: TObject); + procedure OkBClick(Sender: TObject); + procedure ExprBClick(Sender: TObject); + procedure FontSizeCBChange(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + { Private declarations } + FDragging: Boolean; + FDragOfs: Integer; + FRichView: TfrxRichView; + FUpdating: Boolean; + RichEdit1: TrxRichEdit; + function CurrText: TrxTextAttributes; + procedure SetupRuler; + procedure SetEditRect; + public + { Public declarations } + property RichView: TfrxRichView read FRichView write FRichView; + end; + + +implementation + +{$R *.DFM} + +uses frxDsgnIntf, frxRes; + + +const + RulerAdj = 4/3; + GutterWid = 6; + + +{ TfrxRichEditor } + +function TfrxRichEditor.HasEditor: Boolean; +begin + Result := True; +end; + +function TfrxRichEditor.Edit: Boolean; +begin + with TfrxRichEditorForm.Create(Designer) do + begin + RichView := TfrxRichView(Component); + Result := ShowModal = mrOk; + Free; + end; +end; + +function TfrxRichEditor.Execute(Tag: Integer; Checked: Boolean): Boolean; +var + i: Integer; + c: TfrxComponent; + v: TfrxRichView; +begin + Result := inherited Execute(Tag, Checked); + + for i := 0 to Designer.SelectedObjects.Count - 1 do + begin + c := Designer.SelectedObjects[i]; + if (c is TfrxRichView) and not (rfDontModify in c.Restrictions) then + begin + v := TfrxRichView(c); + case Tag of + 1: v.AllowExpressions := Checked; + 2: if Checked then + v.StretchMode := smActualHeight else + v.StretchMode := smDontStretch; + 3: if Checked then + v.StretchMode := smMaxHeight else + v.StretchMode := smDontStretch; + end; + + Result := True; + end; + end; +end; + +procedure TfrxRichEditor.GetMenuItems; +var + v: TfrxRichView; +begin + v := TfrxRichView(Component); + + AddItem(frxResources.Get('mvExpr'), 1, v.AllowExpressions); + AddItem('-', -1); + AddItem(frxResources.Get('mvStretch'), 2, v.StretchMode = smActualHeight); + AddItem(frxResources.Get('mvStretchToMax'), 3, v.StretchMode = smMaxHeight); + + inherited; +end; + + +{ TfrxRichEditorForm } + +procedure TfrxRichEditorForm.SelectionChange(Sender: TObject); +begin + with RichEdit1.Paragraph do + try + FUpdating := True; + FirstInd.Left := Trunc(FirstIndent * RulerAdj) - 4 + GutterWid; + LeftInd.Left := Trunc((LeftIndent + FirstIndent) * RulerAdj) - 4 + GutterWid; + RightInd.Left := Ruler.ClientWidth - 6 - Trunc((RightIndent + GutterWid) * RulerAdj); + BoldB.Down := fsBold in RichEdit1.SelAttributes.Style; + ItalicB.Down := fsItalic in RichEdit1.SelAttributes.Style; + UnderlineB.Down := fsUnderline in RichEdit1.SelAttributes.Style; + BulletsB.Down := Boolean(Numbering); + FontSizeCB.Text := IntToStr(RichEdit1.SelAttributes.Size); + FontNameCB.Text := RichEdit1.SelAttributes.Name; + case Alignment of + paLeftJustify: LeftAlignB.Down := True; + paCenter: CenterAlignB.Down := True; + paRightJustify: RightAlignB.Down := True; + paJustify: BlockAlignB.Down := True; + end; + finally + FUpdating := False; + end; +end; + +function TfrxRichEditorForm.CurrText: TrxTextAttributes; +begin + if RichEdit1.SelLength > 0 then + Result := RichEdit1.SelAttributes else + Result := RichEdit1.DefAttributes; +end; + +procedure TfrxRichEditorForm.SetupRuler; +var + I: Integer; + S: String; +begin + SetLength(S, 201); + I := 1; + while I < 200 do + begin + S[I] := #9; + S[I+1] := '|'; + Inc(I, 2); + end; + Ruler.Caption := S; +end; + +procedure TfrxRichEditorForm.SetEditRect; +var + R: TRect; +begin + with RichEdit1 do + begin + R := Rect(GutterWid, 0, ClientWidth - GutterWid, ClientHeight); + SendMessage(Handle, EM_SETRECT, 0, Longint(@R)); + end; +end; + +{ Event Handlers } + +procedure TfrxRichEditorForm.FormResize(Sender: TObject); +begin + SetEditRect; + SelectionChange(Sender); +end; + +procedure TfrxRichEditorForm.FormPaint(Sender: TObject); +begin + SetEditRect; +end; + +procedure TfrxRichEditorForm.FileOpen(Sender: TObject); +begin + OpenDialog.Filter := frxResources.Get('ftRichFile') + ' (*.rtf)|*.rtf'; + if OpenDialog.Execute then + begin + RichEdit1.Lines.LoadFromFile(OpenDialog.FileName); + RichEdit1.SetFocus; + SelectionChange(Self); + end; +end; + +procedure TfrxRichEditorForm.FileSaveAs(Sender: TObject); +begin + SaveDialog.Filter := frxResources.Get('ftRichFile') + ' (*.rtf)|*.rtf|' + + frxResources.Get('ftTextFile') + ' (*.txt)|*.txt'; + if SaveDialog.Execute then + RichEdit1.Lines.SaveToFile(ChangeFileExt(SaveDialog.FileName, '.rtf')); +end; + +procedure TfrxRichEditorForm.EditUndo(Sender: TObject); +begin + with RichEdit1 do + if HandleAllocated then SendMessage(Handle, EM_UNDO, 0, 0); +end; + +procedure TfrxRichEditorForm.SelectFont(Sender: TObject); +begin + FontDialog1.Font.Assign(RichEdit1.SelAttributes); + if FontDialog1.Execute then + CurrText.Assign(FontDialog1.Font); + RichEdit1.SetFocus; +end; + +procedure TfrxRichEditorForm.RulerResize(Sender: TObject); +begin + RulerLine.Width := Ruler.ClientWidth - RulerLine.Left * 2; +end; + +procedure TfrxRichEditorForm.BoldBClick(Sender: TObject); +var + s: TFontStyles; +begin + if FUpdating then Exit; + s := []; + if BoldB.Down then s := s + [fsBold]; + if ItalicB.Down then s := s + [fsItalic]; + if UnderlineB.Down then s := s + [fsUnderline]; + CurrText.Style := s; +end; + +procedure TfrxRichEditorForm.AlignButtonClick(Sender: TObject); +begin + if FUpdating then Exit; + case TControl(Sender).Tag of + 0: RichEdit1.Paragraph.Alignment := paLeftJustify; + 1: RichEdit1.Paragraph.Alignment := paCenter; + 2: RichEdit1.Paragraph.Alignment := paRightJustify; + 3: RichEdit1.Paragraph.Alignment := paJustify; + end; +end; + +procedure TfrxRichEditorForm.FontNameCBChange(Sender: TObject); +begin + if FUpdating then Exit; + CurrText.Name := FontNameCB.Text; + RichEdit1.SetFocus; +end; + +procedure TfrxRichEditorForm.BulletsBClick(Sender: TObject); +begin + if FUpdating then Exit; + RichEdit1.Paragraph.Numbering := TrxNumbering(BulletsB.Down); +end; + +{ Ruler Indent Dragging } + +procedure TfrxRichEditorForm.RulerItemMouseDown(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +begin + FDragOfs := (TLabel(Sender).Width div 2); + TLabel(Sender).Left := TLabel(Sender).Left + X - FDragOfs; + FDragging := True; +end; + +procedure TfrxRichEditorForm.RulerItemMouseMove(Sender: TObject; Shift: TShiftState; + X, Y: Integer); +begin + if FDragging then + TLabel(Sender).Left := TLabel(Sender).Left + X - FDragOfs +end; + +procedure TfrxRichEditorForm.FirstIndMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +begin + FDragging := False; + RichEdit1.Paragraph.FirstIndent := + Trunc((FirstInd.Left + FDragOfs - GutterWid) / RulerAdj); + LeftIndMouseUp(Sender, Button, Shift, X, Y); +end; + +procedure TfrxRichEditorForm.LeftIndMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +begin + FDragging := False; + RichEdit1.Paragraph.LeftIndent := + Trunc((LeftInd.Left + FDragOfs - GutterWid) / RulerAdj) - RichEdit1.Paragraph.FirstIndent; + SelectionChange(Sender); +end; + +procedure TfrxRichEditorForm.RightIndMouseUp(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +begin + FDragging := False; + RichEdit1.Paragraph.RightIndent := + Trunc((Ruler.ClientWidth - RightInd.Left + FDragOfs - 2) / RulerAdj) - 2 * GutterWid; + SelectionChange(Sender); +end; + +procedure TfrxRichEditorForm.CancelBClick(Sender: TObject); +begin + ModalResult := mrCancel; +end; + +procedure TfrxRichEditorForm.OkBClick(Sender: TObject); +begin + ModalResult := mrOk; +end; + +procedure TfrxRichEditorForm.ExprBClick(Sender: TObject); +var + s, s1, s2: String; + + function BracketCount: Integer; + var + i: Integer; + begin + Result := 0; + for i := 1 to Length(s) do + if s[i] = '<' then + Inc(Result); + end; + +begin + s := TfrxCustomDesigner(Owner).InsertExpression(''); + if s <> '' then + begin + s1 := RichView.ExpressionDelimiters; + s2 := Copy(s1, Pos(',', s1) + 1, 255); + s1 := Copy(s1, 1, Pos(',', s1) - 1); + if (s[1] = '<') and (s[Length(s)] = '>') and (BracketCount = 1) then + s := Copy(s, 2, Length(s) - 2); + RichEdit1.SelText := s1 + s + s2; + end; +end; + +procedure TfrxRichEditorForm.FontSizeCBChange(Sender: TObject); +begin + CurrText.Size := StrToInt(FontSizeCB.Text); + RichEdit1.SetFocus; +end; + +procedure TfrxRichEditorForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(4200); + OpenB.Hint := frxGet(4201); + SaveB.Hint := frxGet(4202); + UndoB.Hint := frxGet(4203); + TTB.Hint := frxGet(4204); + ExprB.Hint := frxGet(4205); + CancelB.Hint := frxGet(2); + OkB.Hint := frxGet(1); + BoldB.Hint := frxGet(4206); + ItalicB.Hint := frxGet(4207); + UnderlineB.Hint := frxGet(4208); + LeftAlignB.Hint := frxGet(4209); + CenterAlignB.Hint := frxGet(4210); + RightAlignB.Hint := frxGet(4211); + BlockAlignB.Hint := frxGet(4212); + BulletsB.Hint := frxGet(4213); + + RichEdit1 := TrxRichEdit.Create(Self); + RichEdit1.Parent := Self; + RichEdit1.Align := alClient; + RichEdit1.OnSelectionChange := SelectionChange; + + SpeedBar.Images := frxResources.MainButtonImages; + Icon := TForm(Owner).Icon; + OpenDialog.InitialDir := ExtractFilePath(ParamStr(0)); + SaveDialog.InitialDir := OpenDialog.InitialDir; + SetupRuler; + SelectionChange(Self); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxRichEditorForm.FormShow(Sender: TObject); +begin + frxAssignRich(RichView.RichEdit, RichEdit1); + RichEdit1.SetFocus; +end; + +procedure TfrxRichEditorForm.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + frxAssignRich(RichEdit1, RichView.RichEdit); +end; + + +procedure TfrxRichEditorForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +initialization + frxComponentEditors.Register(TfrxRichView, TfrxRichEditor); + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxRichRTTI.pas b/official/4.2/LibD11/frxRichRTTI.pas new file mode 100644 index 0000000..e6d82a2 --- /dev/null +++ b/official/4.2/LibD11/frxRichRTTI.pas @@ -0,0 +1,71 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Rich RTTI } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxRichRTTI; + +interface + +{$I frx.inc} + +implementation + +uses + Windows, Classes, SysUtils, Forms, fs_iinterpreter, fs_iformsrtti, frxRich, + frxRichEdit, frxClassRTTI +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TFunctions = class(TfsRTTIModule) + private + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddClass(TrxRichEdit, 'TWinControl'); + with AddClass(TfrxRichView, 'TfrxView') do + AddProperty('RichEdit', 'TrxRichEdit', GetProp, nil); + end; +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TfrxRichView then + begin + if PropName = 'RICHEDIT' then + Result := Integer(TfrxRichView(Instance).RichEdit) + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxSMTP.pas b/official/4.2/LibD11/frxSMTP.pas new file mode 100644 index 0000000..eb6573c --- /dev/null +++ b/official/4.2/LibD11/frxSMTP.pas @@ -0,0 +1,450 @@ + +{******************************************} +{ } +{ FastReport 4.0 } +{ SMTP connection client unit } +{ } +{ Copyright (c) 2006-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxSMTP; + +interface + +{$I frx.inc} + +uses + Windows, SysUtils, Classes, ScktComp, frxNetUtils, frxProgress +{$IFDEF Delphi6}, Variants {$ENDIF}; + + +type + TfrxSMTPClientThread = class; + + TfrxSMTPClient = class(TComponent) + private + FActive: Boolean; + FBreaked: Boolean; + FErrors: TStrings; + FHost: String; + FPort: Integer; + FThread: TfrxSMTPClientThread; + FTimeOut: Integer; + FPassword: String; + FMailTo: String; + FUser: String; + FMailFile: String; + FMailFrom: String; + FMailSubject: String; + FMailText: String; + FAnswer: String; + FAccepted: Boolean; + FAuth: String; + FCode: Integer; + FSending: Boolean; + FAttachName: String; + FProgress: TfrxProgress; + FShowProgress: Boolean; + FLogFile: String; + FLog: TStringList; + FAnswerList: TStringList; + F200Flag: Boolean; + F210Flag: Boolean; + F215Flag: Boolean; + FUserName: String; + procedure DoConnect(Sender: TObject; Socket: TCustomWinSocket); + procedure DoDisconnect(Sender: TObject; Socket: TCustomWinSocket); + procedure DoError(Sender: TObject; Socket: TCustomWinSocket; + ErrorEvent: TErrorEvent; var ErrorCode: Integer); + procedure DoRead(Sender: TObject; Socket: TCustomWinSocket); + procedure SetActive(const Value: Boolean); + procedure AddLogIn(const s: String); + procedure AddLogOut(const s: String); + function DomainByEmail(const addr: String): String; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Connect; + procedure Disconnect; + procedure Open; + procedure Close; + property Breaked: Boolean read FBreaked; + property Errors: TStrings read FErrors write Ferrors; + property LogFile: String read FLogFile write FLogFile; + published + property Active: Boolean read FActive write SetActive; + property Host: String read FHost write FHost; + property Port: Integer read FPort write FPort; + property TimeOut: Integer read FTimeOut write FTimeOut; + property UserName: String read FUserName write FUserName; + property User: String read FUser write FUser; + property Password: String read FPassword write FPassword; + property MailFrom: String read FMailFrom write FMailFrom; + property MailTo: String read FMailTo write FMailTo; + property MailSubject: String read FMailSubject write FMailSubject; + property MailText: String read FMailText write FMailText; + property MailFile: String read FMailFile write FMailFile; + property AttachName: String read FAttachName write FAttachName; + property ShowProgress: Boolean read FShowProgress write FShowProgress; + end; + + TfrxSMTPClientThread = class (TThread) + protected + FClient: TfrxSMTPClient; + procedure DoOpen; + procedure Execute; override; + public + FSocket: TClientSocket; + constructor Create(Client: TfrxSMTPClient); + destructor Destroy; override; + end; + +implementation + +uses frxRes, frxrcExports; + +const + MIME_STRING_SIZE = 57; + boundary = '----------FastReport'; + +type + THackThread = class(TThread); + + +{ TfrxSMTPClient } + +constructor TfrxSMTPClient.Create(AOwner: TComponent); +begin + inherited; + FErrors := TStringList.Create; + FHost := '127.0.0.1'; + FPort := 25; + FActive := False; + FTimeOut := 60; + FBreaked := False; + FThread := TfrxSMTPClientThread.Create(Self); + FThread.FSocket.OnConnect := DoConnect; + FThread.FSocket.OnRead := DoRead; + FThread.FSocket.OnDisconnect := DoDisconnect; + FThread.FSocket.OnError := DoError; + FAttachName := ''; + FShowProgress := False; + FLogFile := ''; + FLog := TStringList.Create; + FAnswerList := TStringList.Create; +end; + +destructor TfrxSMTPClient.Destroy; +begin + Close; + while FActive do + PMessages; + FThread.Free; + FErrors.Free; + FLog.Free; + FAnswerList.Free; + inherited; +end; + +procedure TfrxSMTPClient.Connect; +var + ticks: Cardinal; +begin + FLog.Clear; + if (FLogFile <> '') and FileExists(LogFile) then + FLog.LoadFromFile(LogFile); + FLog.Add(DateTimeToStr(Now)); + FErrors.Clear; + FActive := True; + FThread.FSocket.Host := FHost; + FThread.FSocket.Address := FHost; + FThread.FSocket.Port := FPort; + FThread.FSocket.ClientType := ctNonBlocking; + F200Flag := False; + F210Flag := False; + F215Flag := False; + if FShowProgress then + begin + FProgress := TfrxProgress.Create(Self); + FProgress.Execute(100, frxGet(8924) + ' ' + FMailTo, False, True); + end; + FThread.Execute; + try + ticks := GetTickCount; + while FActive and (not FBreaked) do + begin + PMessages; + if FShowProgress then + FProgress.Tick; + if ((GetTickCount - ticks) > Cardinal(FTimeOut * 1000)) then + begin + Errors.Add('Timeout expired (' + IntToStr(FTimeOut) + ')'); + break; + end; + if FSending then + ticks := GetTickCount; + Sleep(100); + end; + finally + if FShowProgress then + FProgress.Free; + Disconnect; + end; + FLog.Add('---' + DateTimeToStr(Now)); + FLog.AddStrings(FErrors); + if FLogFile <> '' then + FLog.SaveToFile(FLogFile); +end; + +procedure TfrxSMTPClient.Disconnect; +begin + FThread.FSocket.Close; + FThread.Terminate; + FActive := False; +end; + +procedure TfrxSMTPClient.DoConnect(Sender: TObject; + Socket: TCustomWinSocket); +var + s: String; +begin + s := 'HELO ' + DomainByEmail(FMailFrom) + #13#10; + Socket.SendText(s); + AddLogOut(s); + FCode := 0; + FAuth := FUser; + FAccepted := False; + FSending := False; +end; + +procedure TfrxSMTPClient.DoDisconnect(Sender: TObject; + Socket: TCustomWinSocket); +begin + if Pos('221', FAnswer) = 0 then + Errors.Add(FAnswer); + FActive := False; + FSending := False; +end; + +procedure TfrxSMTPClient.DoError(Sender: TObject; Socket: TCustomWinSocket; + ErrorEvent: TErrorEvent; var ErrorCode: Integer); +begin + if FAnswer <> '' then + Errors.Add(FAnswer); + Errors.Add(GetSocketErrorText(ErrorCode)); + FActive := False; + ErrorCode := 0; + FSending := False; +end; + +procedure TfrxSMTPClient.DoRead(Sender: TObject; Socket: TCustomWinSocket); +var + buf: PChar; + i, k: Integer; + Stream: TMemoryStream; + fbuf: PChar; + FStream: TFileStream; + s: String; + s1: String; + + procedure OutStream(const S: String); + begin + Stream.Write(S[1], Length(S)); + Stream.Write(#13#10, 2); + end; + +begin + i := Socket.ReceiveLength; + GetMem(buf, i); + try + try + i := Socket.ReceiveBuf(buf^, i); + SetLength(FAnswer, i); + CopyMemory(PChar(FAnswer), buf, i); + FAnswerList.Text := FAnswer; + + for k := 0 to FAnswerList.Count - 1 do + begin + FAnswer := FAnswerList[k]; + FCode := StrToInt(Copy(FAnswer, 1, 3)); + AddLogIn(FAnswer); + if (FCode = 235) then + begin + FCode := 220; + FAccepted := True; + end; + if (FUser <> '') and (not FAccepted) and (FCode = 220) then + begin + s := 'AUTH LOGIN'#13#10; + Socket.SendText(s); + AddLogOut(s); + end + else if FCode = 334 then + begin + Socket.SendText(Base64Encode(FAuth) + #13#10); + FAuth := FPassword; + AddLogOut('****'); + end + else if (FCode = 220) then + begin + s := 'MAIL FROM: ' + '<' + FMailFrom + '>' + #13#10; + Socket.SendText(s); + AddLogOut(s); + F210Flag := True; + end + else if (FCode = 250) and F210Flag then + begin + s := 'RCPT TO: ' + '<' + FMailTo + '>' + #13#10; + Socket.SendText(s); + AddLogOut(s); + F210Flag := False; + F215Flag := True; + end + else if (FCode = 250) and F215Flag then + begin + s := 'DATA'#13#10; + Socket.SendText(s); + AddLogOut(s); + F215Flag := False; + end + else if (FCode = 250) and F200Flag then + begin + s := 'QUIT'#13#10; + Socket.SendText(s); + AddLogOut(s); + F200Flag := False; + end + else if (FCode = 354) then + begin + FSending := True; + Stream := TMemoryStream.Create; + try + OutStream('Date: ' + DateTimeToRFCDateTime(Now)); + OutStream('Subject: ' + FMailSubject); + OutStream('To: ' + FMailTo); + OutStream('From: ' + FMailFrom); + OutStream('X-Mailer: FastReport'); + if (FMailFile <> '') and FileExists(FMailFile) then + begin + OutStream('MIME-Version: 1.0'); + OutStream('Content-Type: multipart/mixed; boundary="' + boundary +'"'); + OutStream(#13#10'--' + boundary); + OutStream('Content-Type: text/plain'); + OutStream('Content-Transfer-Encoding: 7bit'); + OutStream(#13#10 + FMailText); + OutStream('--' + boundary); + s := GetFileMIMEType(FMailFile); + if FAttachName = '' then + s1 := ExtractFileName(FMailFile) + else + s1 := FAttachName; + OutStream('Content-Type: ' + s + '; name="' + s1 + '"'); + OutStream('Content-Transfer-Encoding: base64'); + OutStream('Content-Disposition: attachment; filename="' + s1 + '"'#13#10); + FStream := TFileStream.Create(FMailFile, fmOpenRead + fmShareDenyWrite); + GetMem(fbuf, MIME_STRING_SIZE); + try + i := MIME_STRING_SIZE; + while i = MIME_STRING_SIZE do + begin + i := FStream.Read(fbuf^, i); + SetLength(s, i); + CopyMemory(PChar(s), fbuf, i); + s := Base64Encode(s); + OutStream(s); + end; + finally + FreeMem(fbuf); + FStream.Free; + end; + OutStream(#13#10 + '--' + boundary + '--'); + end + else + OutStream(#13#10 + FMailText); + OutStream('.'); + AddLogOut('message(skipped)'); + Socket.SendBuf(Stream.Memory^, Stream.Size); + F200Flag := True; + finally + FSending := False; + Stream.Free; + end; + end; + end; + except + on e: Exception do + Errors.Add('Data receive error: ' + e.Message) + end; + finally + FreeMem(buf); + end; +end; + +procedure TfrxSMTPClient.SetActive(const Value: Boolean); +begin + if Value then Connect + else Disconnect; +end; + +procedure TfrxSMTPClient.Close; +begin + FBreaked := True; + Active := False; +end; + +procedure TfrxSMTPClient.Open; +begin + Active := True; +end; + +function TfrxSMTPClient.DomainByEmail(const addr: String): String; +var + i: Integer; +begin + i := Pos('@', addr); + if i > 0 then + Result := Copy(addr, i + 1, Length(addr) - i) + else + Result := addr; +end; + +procedure TfrxSMTPClient.AddLogIn(const s: String); +begin + FLog.Add('<' + s); +end; + +procedure TfrxSMTPClient.AddLogOut(const s: String); +begin + FLog.Add('>' + s); +end; + +{ TfrxSMTPClientThread } + +constructor TfrxSMTPClientThread.Create(Client: TfrxSMTPClient); +begin + inherited Create(True); + FClient := Client; + FreeOnTerminate := False; + FSocket := TClientSocket.Create(nil); +end; + +destructor TfrxSMTPClientThread.Destroy; +begin + FSocket.Free; + inherited; +end; + +procedure TfrxSMTPClientThread.DoOpen; +begin + FSocket.Open; +end; + +procedure TfrxSMTPClientThread.Execute; +begin + Synchronize(DoOpen); +end; + +end. diff --git a/official/4.2/LibD11/frxSearchDialog.dfm b/official/4.2/LibD11/frxSearchDialog.dfm new file mode 100644 index 0000000..67c8984 Binary files /dev/null and b/official/4.2/LibD11/frxSearchDialog.dfm differ diff --git a/official/4.2/LibD11/frxSearchDialog.pas b/official/4.2/LibD11/frxSearchDialog.pas new file mode 100644 index 0000000..b0d9bf0 --- /dev/null +++ b/official/4.2/LibD11/frxSearchDialog.pas @@ -0,0 +1,95 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Search dialog } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxSearchDialog; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ExtCtrls; + +type + TfrxSearchDialog = class(TForm) + ReplacePanel: TPanel; + ReplaceL: TLabel; + ReplaceE: TEdit; + Panel2: TPanel; + TextL: TLabel; + TextE: TEdit; + Panel3: TPanel; + OkB: TButton; + CancelB: TButton; + SearchL: TGroupBox; + CaseCB: TCheckBox; + TopCB: TCheckBox; + procedure FormCreate(Sender: TObject); + procedure FormHide(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + private + public + end; + + +implementation + +uses frxRes; + +{$R *.DFM} + +var + LastText: String; + +procedure TfrxSearchDialog.FormCreate(Sender: TObject); +begin + Caption := frxGet(300); + TextL.Caption := frxGet(301); + SearchL.Caption := frxGet(302); + ReplaceL.Caption := frxGet(303); + TopCB.Caption := frxGet(304); + CaseCB.Caption := frxGet(305); + OkB.Caption := frxGet(1); + CancelB.Caption := frxGet(2); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxSearchDialog.FormShow(Sender: TObject); +begin + TextE.Text := LastText; + TextE.SetFocus; + TextE.SelectAll; +end; + +procedure TfrxSearchDialog.FormHide(Sender: TObject); +begin + if ModalResult = mrOk then + LastText := TextE.Text; +end; + +procedure TfrxSearchDialog.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxServer.pas b/official/4.2/LibD11/frxServer.pas new file mode 100644 index 0000000..06f21fe --- /dev/null +++ b/official/4.2/LibD11/frxServer.pas @@ -0,0 +1,1364 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ HTTP Report Server } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServer; + +{$I frx.inc} + +interface + +uses + Forms, Windows, Classes, frxClass, ScktComp, Registry, + WinSock, frxVariables, frxGZip, frxServerLog, + frxServerSessionManager, frxServerStat, frxServerReports, + frxServerVariables, frxServerSSI, frxServerUtils, frxNetUtils, frxMD5, + frxServerCache, frxServerReportsList, frxUnicodeUtils, frxUsers + + , SysUtils, frxServerConfig, frxServerTemplates; + +type + TfrxHTTPServer = class; + TfrxServerSession = class; + TfrxServerData = class; + TfrxServerGuard = class; + TfrxServerGetReportEvent = procedure(const ReportName: String; + Report: TfrxReport; User: String = '') of object; + TfrxServerGetVariablesEvent = procedure(const ReportName: String; + Variables: TfrxVariables; User: String = '') of object; + TfrxServerAfterBuildReport = procedure(const ReportName: String; + Variables: TfrxVariables; User: String = '') of object; + + TfrxReportServer = class(TComponent) + private + FActive: Boolean; + FAllow: TStrings; + FConfig: TfrxServerConfig; // obsolete + FDeny: TStrings; + FGetReport: TfrxServerGetReportEvent; + FPDFPrint: Boolean; + FTotals: TStrings; + FVariables: TfrxServerVariables; + FWebServer: TfrxHTTPServer; + FGetVariables: TfrxServerGetVariablesEvent; + FBuildReport: TfrxServerAfterBuildReport; + FReportList: TfrxServerReportsList; + + FConfigFileName: String; + FGuard: TfrxServerGuard; + function GetTotals: TStrings; + procedure SetActive(const Value: Boolean); + procedure SetConfig(const Value: TfrxServerConfig); + procedure StatToVar; +// procedure IdleEventHandler(Sender: TObject; var Done: Boolean); + procedure Initialize; + public + constructor Create(AOwner: TComponent); override; + + destructor Destroy; override; + procedure Open; + procedure Close; + + procedure LoadConfigs; + property Totals: TStrings read GetTotals; + property Variables: TfrxServerVariables read FVariables; + property ReportsList: TfrxServerReportsList read FReportList; + published + property Configuration: TfrxServerConfig read FConfig write SetConfig; // obsolete + property Active: Boolean read FActive write SetActive; + property AllowIP: TStrings read FAllow write FAllow; + property DenyIP: TStrings read FDeny write FDeny; + property PrintPDF: Boolean read FPDFPrint write FPDFPrint; + property OnGetReport: TfrxServerGetReportEvent read FGetReport + write FGetReport; + property OnGetVariables: TfrxServerGetVariablesEvent read FGetVariables + write FGetVariables; + property OnAfterBuildReport: TfrxServerAfterBuildReport read FBuildReport + write FBuildReport; + + property WebServer: TfrxHTTPServer read FWebServer; + end; + + TfrxHTTPServer = class(TServerSocket) + private + FBasePath: String; + FGzip: Boolean; + FMainDocument: String; + FNoCacheHeader: Boolean; + FParentReportServer: TfrxReportServer; + FReportPath: String; + FSocketTimeOut: Integer; + procedure ClientAccept(Sender: TObject; Socket: TCustomWinSocket); + procedure ClientDisconnect(Sender: TObject; Socket: TCustomWinSocket); + procedure ClientError(Sender: TObject; Socket: TCustomWinSocket; + ErrorEvent: TErrorEvent; var ErrorCode: Integer); + procedure GetThread(Sender: TObject; ClientSocket: TServerClientWinSocket; + var SocketThread: TServerClientThread); + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + published + property BasePath: String read FBasePath write FBasePath; + property Gzip: Boolean read FGzip write FGzip; + property MainDocument: String read FMainDocument write FMainDocument; + property NoCacheHeader: Boolean read FNoCacheHeader write FNoCacheHeader; + property ParentReportServer: TfrxReportServer read FParentReportServer + write FParentReportServer; + property ReportPath: String read FReportPath write FReportPath; + property SocketTimeOut: Integer read FSocketTimeOut write FSocketTimeOut; + end; + + TfrxServerSession = class(TServerClientThread) + private + FAuthNeeded: Boolean; + FDialog: Boolean; + FDialogSessionId: String; + FErrorCode: Integer; + FErrorText: String; + FFormat: TfrxServerFormat; + FGzip: Boolean; + FHeader: String; + FHost: String; + FHTTPVersion: String; + FIsReport: Boolean; + FKeepAlive: boolean; + FMethod: AnsiString; + FMIMEType: String; + FMultipage: Boolean; + FName: String; + FNoCacheHeader: Boolean; + FPageNavigator: Boolean; + FPageRange: String; + FParentHTTPServer: TfrxHTTPServer; + FParentReportServer: TfrxReportServer; + FRedirect: Boolean; + FReferer: String; + FRemoteIP: String; + FReplyBody: TStringList; + FReplyHeader: TStringList; + FRepSession: TfrxReportSession; + FResultPage: String; + FServerReplyData: TStringList; + FSessionId: String; + FSessionItem: TfrxSessionItem; + FSize: integer; + FUserAgent: String; + FVariables: TfrxVariables; + FStream: TMemoryStream; + FFileDate: TDateTime; + FCacheId: String; + FLogin: String; + FPassword: String; + FReportMessage: String; + FReturnData: String; + FInParams: TStringList; + FOutParams: TStringList; + FData: TfrxServerData; + FActive: Boolean; + + function CheckBadPath: Boolean; + function CheckDeflate(FileName: String): Boolean; + function CheckSSI(FileName: String): Boolean; + function ParseHeaderField(Field: String): String; + function ParseParam(S: String): String; + procedure CheckAuth; + procedure CloseSession; + procedure CreateReplyHTTPData; + procedure ErrorLog; + procedure GetFileMIMEType; + procedure MakeServerReply; + procedure ParseHTTPHeader; + procedure UpdateSessionFName; + procedure WriteLogs; + procedure DoGetVariables; + procedure AddOutData(const Name: String; const Value: String); + public + constructor Create(CreateSuspended: Boolean; + ASocket: TServerClientWinSocket); + destructor Destroy; override; + procedure ClientExecute; override; + procedure PrepareReportQuery; + + property NoCacheHeader: Boolean read FNoCacheHeader write FNoCacheHeader; + property ParentHTTPServer: TfrxHTTPServer read FParentHTTPServer + write FParentHTTPServer; + property ParentReportServer: TfrxReportServer read FParentReportServer + write FParentReportServer; + property SessionId: String read FSessionId write FSessionId; + property SessionItem: TfrxSessionItem read FSessionItem write FSessionItem; + property Login: String read FLogin; + property Password: String read FPassword; + property Data: TfrxServerData read FData write FData; + property Active: Boolean read FActive write FActive; + end; + + TfrxServerData = class(TObject) + private + FErrorCode: Integer; + FInParams: TStringList; + FOutParams: TStringList; + FStream: TMemoryStream; + FFileName: String; + FHeader: String; + FRepHeader: String; + FHTTPVer: String; + FLastMod: TDateTime; + FExpires: TDateTime; + public + constructor Create; + destructor Destroy; override; + procedure Assign(Source: TfrxServerData); + + property InParams: TStringList read FInParams; + property OutParams: TStringList read FOutParams; + property ErrorCode: Integer read FErrorCode write FErrorCode; + property Stream: TMemoryStream read FStream; + property FileName: String read FFileName write FFileName; + property Header: String read FHeader write FHeader; + property RepHeader: String read FRepHeader write FRepHeader; + property HTTPVer: String read FHTTPVer write FHTTPVer; + property Expires: TDateTime read FExpires write FExpires; + property LastMod: TDateTime read FLastMod write FLastMod; + end; + + TfrxServerGuard = class(TThread) + private + FTimeOut: Integer; + FServer: TfrxReportServer; + FListTimeOut: Integer; + procedure DoLoadConf; + protected + procedure Execute; override; + public + constructor Create(Server: TfrxReportServer); + destructor Destroy; override; + + property TimeOut: Integer read FTimeOut write FTimeOut; + property ListTimeOut: Integer read FListTimeOut write FListTimeOut; + end; + +const + MAX_IE_GZIP = 4096; + SERVER_NAME = 'FastReport Server'; + SERVER_VERSION = {$I frxServerVersion.inc}; + SERVER_DATA = ''; + SID_SIGN = 'sid_f'; + + + +implementation + +uses frxUtils, frxFileUtils, SyncObjs; + +const + SERVER_COPY = '© Copyright 1998-2007 by Fast Reports Inc.'; + METHOD_GET = 'GET'; + HTML = 'text/html'; + ERR_UNKNOWN_METHOD = '1'; + ERR_OK = '0'; + + + +{ TfrxReportServer } + +procedure TfrxReportServer.LoadConfigs; +begin + ServerConfig.LoadFromFile(FConfigFileName); + ServerUsers.LoadFromFile(frxGetAbsPathDir(ServerConfig.GetValue('server.security.usersfile'), ServerConfig.ConfigFolder)); +end; + +procedure TfrxReportServer.Initialize; +var + s: String; +begin + LogWriter := TfrxServerLog.Create; + FConfig := TfrxServerConfig.Create; // obsolete + FConfigFileName := ServerConfig.ConfigFolder + 'config.xml'; + + LoadConfigs; + + LogWriter.MaxLogSize := StrToInt(ServerConfig.GetValue('server.logs.rotatesize')); + LogWriter.MaxLogFiles := StrToInt(ServerConfig.GetValue('server.logs.rotatefiles')); + LogWriter.LogDir := frxGetAbsPathDir(ServerConfig.GetValue('server.logs.path'), ServerConfig.ConfigFolder); + LogWriter.AddLevel(ServerConfig.GetValue('server.logs.errorlog')); + LogWriter.AddLevel(ServerConfig.GetValue('server.logs.accesslog')); + LogWriter.AddLevel(ServerConfig.GetValue('server.logs.refererlog')); + LogWriter.AddLevel(ServerConfig.GetValue('server.logs.agentlog')); + LogWriter.AddLevel(ServerConfig.GetValue('server.logs.serverlog')); + + + + FAllow := TStringList.Create; + FDeny := TStringList.Create; + + s := frxGetAbsPathDir(ServerConfig.GetValue('server.security.allowfile'), ServerConfig.ConfigFolder); + if FileExists(s) then + FAllow.LoadFromFile(s); + s := frxGetAbsPathDir(ServerConfig.GetValue('server.security.denyfile'), ServerConfig.ConfigFolder); + if FileExists(s) then + FDeny.LoadFromFile(s); + + FTotals := TStringList.Create; + LogWriter.Write(SERVER_LEVEL, DateTimeToStr(Now) + #9'Started'); + LogWriter.Write(SERVER_LEVEL, 'Logs path:' + #9 + frxGetAbsPathDir(ServerConfig.GetValue('server.logs.path'), ServerConfig.ConfigFolder)); + LogWriter.Write(SERVER_LEVEL, 'Reports path:' + #9 + frxGetAbsPathDir(ServerConfig.GetValue('server.reports.path'), ServerConfig.ConfigFolder)); + LogWriter.Write(SERVER_LEVEL, 'Reports cache path:' + #9 + frxGetAbsPathDir(ServerConfig.GetValue('server.cache.path'), ServerConfig.ConfigFolder)); + LogWriter.Write(SERVER_LEVEL, 'Root path:' + #9 + frxGetAbsPathDir(ServerConfig.GetValue('server.http.rootpath'), ServerConfig.ConfigFolder)); + if FileExists(FConfigFileName) then + LogWriter.Write(SERVER_LEVEL, 'Config file:' + #9 + FConfigFileName) + else + LogWriter.Write(SERVER_LEVEL, 'ERROR! Config file ' + FConfigFileName + ' not found!'); + + SessionManager := TfrxSessionManager.Create; + FWebServer := TfrxHTTPServer.Create(nil); + FWebServer.ParentReportServer := Self; + ReportCache := TfrxServerCache.Create; + ServerStatistic := TfrxServerStatistic.Create; + FVariables := TfrxServerVariables.Create; + + ServerUsers.LoadFromFile(ServerConfig.GetValue('server.security.usersfile')); + + + FVariables.AddVariable('SERVER_NAME', ServerConfig.GetValue('server.name')); + + + FVariables.AddVariable('SERVER_COPYRIGHT', SERVER_COPY); + FVariables.AddVariable('SERVER_SOFTWARE', SERVER_VERSION); + FVariables.AddVariable('SERVER_LAST_UPDATE', SERVER_DATA); + + FPDFPrint := True; + Active := False; + + ReportCache.Clear; + FReportList := TfrxServerReportsList.Create; + + + LogWriter.Active := ServerConfig.GetBool('server.logs.active'); + + FGuard := TfrxServerGuard.Create(Self); +end; + + + +constructor TfrxReportServer.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + ServerConfig.ConfigFolder := GetAppPath; + + Initialize; +end; + +destructor TfrxReportServer.Destroy; +begin + FGuard.Free; + + FReportList.Free; + ReportCache.Free; + FAllow.Free; + FDeny.Free; + FWebServer.Free; + LogWriter.Write(SERVER_LEVEL, DateTimeToStr(Now) + #9'Stopped'#9 + #13#10 + Totals.Text); + LogWriter.Flush; + Active := False; + ServerStatistic.Free; + SessionManager.Free; + FConfig.Free; + FTotals.Free; + FVariables.Free; + LogWriter.Free; + PMessages; + inherited; +end; + +procedure TfrxReportServer.SetActive(const Value: Boolean); +begin + + try + FWebServer.Active := Value; + except + if Value then + LogWriter.Write(SERVER_LEVEL, DateTimeToStr(Now) + #9'Port open failed. ' + #13#10) + else + LogWriter.Write(SERVER_LEVEL, DateTimeToStr(Now) + #9'Port close failed. ' + #13#10) + end; + + if FWebServer.Active = Value then + FActive := Value; +// if Value and LogWriter.Suspended then +// LogWriter.Resume; +end; + +procedure TfrxReportServer.Open; +begin + if ServerConfig.GetBool('server.security.reportslist') then + begin + FReportList.ReportsPath := frxGetAbsPathDir(ServerConfig.GetValue('server.reports.path'), ServerConfig.ConfigFolder); + FReportList.BuildListOfReports; + FVariables.AddVariable('SERVER_REPORTS_LIST', FReportList.Lines.Text); + FVariables.AddVariable('SERVER_REPORTS_HTML', FReportList.Html); + end; + Active := True; +end; + +procedure TfrxReportServer.Close; +begin + Active := False; + ReportCache.Clear; +end; + +procedure TfrxReportServer.SetConfig(const Value: TfrxServerConfig); +begin + FConfig.Assign(Value); +end; + +function TfrxReportServer.GetTotals: TStrings; +begin + FTotals.Clear; + FTotals.Add('Uptime: ' + ServerStatistic.FormatUpTime); + FTotals.Add('Total sessions: ' + IntToStr(ServerStatistic.TotalSessionsCount)); + FTotals.Add('Total reports: ' + IntToStr(ServerStatistic.TotalReportsCount)); + FTotals.Add('Total cache hits: ' + IntToStr(ServerStatistic.TotalCacheHits)); + FTotals.Add('Total errors: ' + IntToStr(ServerStatistic.TotalErrors)); + FTotals.Add('Max sessions: ' + IntToStr(ServerStatistic.MaxSessionsCount)); + FTotals.Add('Max reports: ' + IntToStr(ServerStatistic.MaxReportsCount)); + Result := FTotals; +end; + +procedure TfrxReportServer.StatToVar; +begin + FVariables.AddVariable('SERVER_UPTIME', ServerStatistic.FormatUpTime); + FVariables.AddVariable('SERVER_TOTAL_SESSIONS', IntToStr(ServerStatistic.TotalSessionsCount)); + FVariables.AddVariable('SERVER_TOTAL_REPORTS', IntToStr(ServerStatistic.TotalReportsCount)); + FVariables.AddVariable('SERVER_TOTAL_ERRORS', IntToStr(ServerStatistic.TotalErrors)); + FVariables.AddVariable('SERVER_TOTAL_CACHE', IntToStr(ServerStatistic.TotalCacheHits)); + FVariables.AddVariable('SERVER_MAX_SESSIONS', IntToStr(ServerStatistic.MaxSessionsCount)); + FVariables.AddVariable('SERVER_MAX_REPORTS', IntToStr(ServerStatistic.MaxReportsCount)); +end; + + + +{ TfrxHTTPServer } + +constructor TfrxHTTPServer.Create(AOwner: TComponent); +begin + inherited Create(AOwner); + Active := False; + ServerType := stThreadBlocking; + Port := StrToInt(ServerConfig.GetValue('server.http.port')); + FGzip := ServerConfig.GetBool('server.http.compression'); + FMainDocument := ServerConfig.GetValue('server.http.indexfile'); + FBasePath := frxGetAbsPathDir(ServerConfig.GetValue('server.http.rootpath'), ServerConfig.ConfigFolder); + FSocketTimeOut := StrToInt(ServerConfig.GetValue('server.http.sockettimeout')); + FNoCacheHeader := ServerConfig.GetBool('server.http.nocacheheader'); + OnClientError := ClientError; + OnClientDisconnect := ClientDisconnect; + OnAccept := ClientAccept; + OnGetThread := GetThread; + LogWriter.Write(SERVER_LEVEL, DateTimeToStr(Now) + #9'HTTP server created'); +end; + +destructor TfrxHTTPServer.Destroy; +begin + LogWriter.Write(SERVER_LEVEL, DateTimeToStr(Now) + #9'HTTP server closed'); + PMessages; + inherited; +end; + +procedure TfrxHTTPServer.ClientError(Sender: TObject; + Socket: TCustomWinSocket; ErrorEvent: TErrorEvent; + var ErrorCode: Integer); +begin + LogWriter.Write(ERROR_LEVEL, DateTimeToStr(Now) + #9 + Socket.RemoteAddress + #9 + GetSocketErrorText(ErrorCode)); + LogWriter.ErrorReached; + ErrorCode := 0; + SessionManager.CompleteSessionId(String(TCustomWinSocket(Socket).Data)); + Socket.Close; +end; + +procedure TfrxHTTPServer.ClientDisconnect(Sender: TObject; Socket: TCustomWinSocket); +begin + SessionManager.CompleteSessionId(String(TCustomWinSocket(Socket).Data)); +end; + +procedure TfrxHTTPServer.GetThread(Sender: TObject; + ClientSocket: TServerClientWinSocket; var SocketThread: TServerClientThread); +begin + try + SocketThread := TfrxServerSession.Create(True, ClientSocket); + SocketThread.FreeOnTerminate := True; + SocketThread.KeepInCache := False; + TfrxServerSession(SocketThread).ParentReportServer := ParentReportServer; + TfrxServerSession(SocketThread).ParentHTTPServer := Self; + if ClientSocket <> nil then + ClientSocket.Data := PChar(TfrxServerSession(SocketThread).SessionId); + TfrxServerSession(SocketThread).SessionItem := SessionManager.AddSession(TfrxServerSession(SocketThread).SessionId, TCustomWinSocket(ClientSocket)); + + SocketThread.Resume; + FParentReportServer.StatToVar; + except + LogWriter.Write(ERROR_LEVEL, DateTimeToStr(Now) + #9 + ClientSocket.RemoteAddress + ' client session creation error'); + end; +end; + +procedure TfrxHTTPServer.ClientAccept(Sender: TObject; + Socket: TCustomWinSocket); +begin + if ParentReportServer.DenyIP.IndexOf(Socket.RemoteAddress) <> -1 then + begin + LogWriter.Write(ERROR_LEVEL, DateTimeToStr(Now) + #9 + Socket.RemoteAddress + ' denial of client connection'); + Socket.Close; + end + else if (ParentReportServer.AllowIP.Count > 0) and + (ParentReportServer.AllowIP.IndexOf(Socket.RemoteAddress) = -1) then + begin + LogWriter.Write(ERROR_LEVEL, DateTimeToStr(Now) + #9 + Socket.RemoteAddress + ' client connection not allowed'); + Socket.Close; + end; +end; + +{ TfrxServerSession } + +constructor TfrxServerSession.Create(CreateSuspended: Boolean; ASocket: TServerClientWinSocket); +begin + inherited Create(CreateSuspended, ASocket); + FSessionId := SID_SIGN + MakeSessionId; + FIsReport := False; + FSize := 0; + FKeepAlive := False; + FRemoteIP := ClientSocket.RemoteAddress; + FServerReplyData := TStringList.Create; + FReplyHeader := TStringList.Create; + FReplyBody := TStringList.Create; + FFormat := sfHTM; + FPageRange := ''; + FGzip := False; + FResultPage := ''; + FRedirect := False; + FStream := TMemoryStream.Create; + FInParams := TStringList.Create; + FOutParams := TStringList.Create; + FData := nil; +end; + +destructor TfrxServerSession.Destroy; +begin + PMessages; + FInParams.Free; + FOutParams.Free; + FStream.Free; + FServerReplyData.Free; + FReplyHeader.Free; + FReplyBody.Free; + inherited; +end; + +function TfrxServerSession.ParseHeaderField(Field: String): String; +var + i: integer; + s: string; +begin + i := Pos(Field, FHeader); + Result := ''; + if i > 0 then + begin + s := Copy(FHeader, i + Length(Field), Length(FHeader) - i + Length(Field)); + i := Pos(#13#10, s); + if i > 0 then + Result := Copy(s, 1, i - 1); + end; +end; + +procedure TfrxServerSession.ParseHTTPHeader; +var + i, j: Integer; + s: string; + P, V: String; + RepName: String; +begin + FMethod := ERR_UNKNOWN_METHOD; + FErrorCode := 0; + FReturnData := ''; + if Pos(METHOD_GET, FHeader) > 0 then + begin + i := Pos('/', FHeader); + if i > 0 then + begin + FName := Trim(Copy(FHeader, i + 1, Pos('HTTP', FHeader) - i - 2)); + FHTTPVersion := Copy(FHeader, Pos('HTTP/', FHeader), 8); + FHost := ParseHeaderField('Host: '); + FKeepAlive := ParseHeaderField('Connection: ') = 'keep-alive'; + FReferer := ParseHeaderField('Referer: '); + FUserAgent := ParseHeaderField('User-Agent: '); + s := ParseHeaderField('Accept-Encoding: '); + if Length(s) > 0 then + if (Pos('gzip', LowerCase(s)) > 0) and (FParentHTTPServer.Gzip) then + FGzip := True; + CheckAuth; + FMethod := METHOD_GET; + WriteLogs; + if not FAuthNeeded then + begin + i := Pos('?', FName); + if i > 0 then + FName := Copy(FName, i + 1, Length(FName) - i); + s := ParseParam('getvariable'); + if Length(s) = 0 then + begin + RepName := ParseParam('report'); + if (Length(RepName) > 0) then + begin + FIsReport := True; + FDialogSessionId := ParseParam('sessionid'); + FCacheId := ParseParam('cacheid'); + if Length(FDialogSessionId) > 0 then + FDialog := True; + s := ParseParam('format'); + if Length(s) > 0 then + begin + s := UpperCase(s); + if s = 'PDF' then FFormat := sfPDF else + if s = 'ODS' then FFormat := sfODS else + if s = 'ODT' then FFormat := sfODT else + if s = 'XML' then FFormat := sfXML else + if s = 'XLS' then FFormat := sfXLS else + if s = 'RTF' then FFormat := sfRTF else + if s = 'TXT' then FFormat := sfTXT else + if s = 'CSV' then FFormat := sfCSV else + if s = 'JPG' then FFormat := sfJPG else + if s = 'BMP' then FFormat := sfBMP else + if s = 'GIF' then FFormat := sfGIF else + if (s = 'TIFF') or (s = 'TIF') then FFormat := sfTIFF else + if (s = 'FRP') or (s = 'FP3') then FFormat := sfFRP else + FFormat := sfHTM; + end; + s := ParseParam('multipage'); + if s = '0' then FMultipage := False + else if s = '1' then FMultipage := True + else FMultipage := not ServerConfig.GetBool('server.exports.html.singlepage'); + s := ParseParam('pagenav'); + if s = '0' then FPageNavigator := False + else if s = '1' then FPageNavigator := True + else FPageNavigator := ServerConfig.GetBool('server.exports.html.navigator'); + s := ParseParam('pagerange'); + FPageRange := s; + if Pos('=', FName) > 0 then + begin + FVariables := TfrxVariables.Create; + i := 1; + while i > 0 do + begin + j := 1; + while (j <= i) and (j <> 0) do + begin + i := Pos('=', FName); + j := Pos('&', FName); + if (j < i) and (j <> 0) then + FName := Copy(FName, j + 1, Length(FName) - j); + end; + if i > 0 then + begin + P := Copy(FName, 1, i - 1); + V := '''' + UTF8Decode(ParseParam(P)) + ''''; + FVariables[P] := V; + end; + end; + end else + FVariables := nil; + FName := frxGetAbsPathDir(ServerConfig.GetValue('server.reports.path'), ServerConfig.ConfigFolder) + RepName; + PrepareReportQuery; + if Assigned(FVariables) then + FVariables.Free; + end else + if i > 0 then + FErrorCode := 403; + end else + begin + FReturnData := TfrxReportServer(ParentReportServer).Variables.GetValue(s); + if Length(FReturnData) = 0 then + FErrorCode := 404; + end; + end; + end + end; +end; + +function TfrxServerSession.ParseParam(S: String): String; +var + i, j: integer; +begin + i := Pos(UpperCase(S) + '=', UpperCase(FName)); + if i > 0 then + begin + Result := Copy(FName, i + Length(S) + 1, Length(FName) - i + Length(S) + 1); + j := Pos('&', Result); + if j > 0 then + Result := Copy(Result, 1, j - 1); + Delete(FName, i, Length(S) + Length(Result) + 1); + end else + Result := ''; + if Length(FName) > 0 then + begin + i := 1; + while (FName[i] = '&') and (i < Length(FName)) do + Inc(i); + Delete(FName, 1, i - 1); + end; + Result := HTML2Str(Result); +end; + +function TfrxServerSession.CheckBadPath: Boolean; +begin + Result := (Pos('..\', FName) > 0) or (Pos('../', FName) > 0); +end; + +procedure TfrxServerSession.CreateReplyHTTPData; +var + SearchRec: TSearchRec; + s, sn: String; +begin + FServerReplyData.Clear; + FReplyHeader.Clear; + + if Length(FReturnData) > 0 then + FErrorCode := 200; + + if (FErrorCode = 0) then + if CheckBadPath then + FErrorCode := 403 + else if FAuthNeeded then + FErrorCode := 401 + else if (Length(FResultPage) > 0) and FileExists(FParentHTTPServer.BasePath + FResultPage) then + begin + FErrorCode := 301; + FRedirect := True; + end else + begin + if FName = '' then + FName := FParentHTTPServer.MainDocument; + if (FindFirst(FParentHTTPServer.BasePath + FName, faReadOnly + faArchive, SearchRec) = 0) or + (FindFirst(FParentHTTPServer.BasePath + FName + FParentHTTPServer.MainDocument, faReadOnly + faArchive, SearchRec) = 0) + then + begin + FErrorCode := 200; + FSize := SearchRec.Size; + FFileDate := FileDateToDateTime(SearchRec.Time); + end else + FErrorCode := 404; + FindClose(SearchRec); + end; + UpdateSessionFName; + GetFileMIMEType; + s := ''; + if FErrorCode = 401 then + s := ' Unauthorized' + else if FErrorCode = 403 then + s := ' Forbidden'; + if FData <> nil then + FData.HTTPVer := FHTTPVersion; + if FData <> nil then + FData.ErrorCode := FErrorCode; + FReplyHeader.Add(FHTTPVersion + ' ' + IntToStr(FErrorCode) + s); + if Length(s) = 0 then + begin + sn := 'Server'; + + FReplyHeader.Add(sn + ': ' + SERVER_NAME); + AddOutData(sn, SERVER_NAME); + + if FErrorCode = 200 then + begin + sn := 'Content-type'; + AddOutData(sn, FMIMEType); + FReplyHeader.Add(sn + ': ' + FMIMEType); + end; + if (FParentHTTPServer.FNoCacheHeader) and (not FRedirect) then + begin + sn := 'Cache-Control'; + s := 'must-revalidate, max-age=0'; + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + sn := 'Pragma'; + s := 'no-cache'; + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + end; + sn := 'Accept-ranges'; + s := 'none'; + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + sn := 'Last-Modified'; + s := DateTimeToRFCDateTime(FFileDate); + AddOutData(sn, s); + FReplyHeader.Add(sn + ':' + s); + sn := 'Expires'; + s := DateTimeToRFCDateTime(FFileDate); + if FData <> nil then + begin + FData.Expires := FFileDate; + FData.LastMod := FFileDate; + end; + AddOutData(sn, s); + FReplyHeader.Add(sn + ':' + s); + if FGzip and CheckDeflate(FName) and (FErrorCode = 200) + + then + begin + sn := 'Content-Encoding'; + s := 'gzip'; + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s) + end else + FGzip := False; + if FRedirect then + begin + sn := 'Location'; + s := FResultPage; + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + end; + if FIsReport then + begin + sn := 'SessionId'; + if FDialogSessionId <> '' then + s := FDialogSessionId + else + s := FSessionId; + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + end; + end; +end; + +procedure TfrxServerSession.PrepareReportQuery; +var + Path: String; + SecAtrtrs: TSecurityAttributes; +begin + if FIsReport then + begin + Path := FParentHTTPServer.BasePath + FSessionId; + SecAtrtrs.nLength := SizeOf(TSecurityAttributes) ; + SecAtrtrs.lpSecurityDescriptor := nil; + SecAtrtrs.bInheritHandle := true; + CreateDirectory(PChar(Path), @SecAtrtrs); + if not FDialog then + begin + FRepSession := TfrxReportSession.Create; + FRepSession.ParentThread := Self; + FRepSession.NativeClient := Pos('FastReport', FUserAgent) > 0; + FRepSession.Stream := FStream; + FRepSession.ParentReportServer := ParentReportServer; + FRepSession.SessionId := FSessionId; + FRepSession.CacheId := FCacheId; + FRepSession.FileName := FName; + FRepSession.ReportPath := FParentHTTPServer.ReportPath; + FRepSession.IndexFileName := FParentHTTPServer.MainDocument; + FRepSession.RootPath := FParentHTTPServer.BasePath; + FRepSession.PageRange := FPageRange; + FRepSession.Format := FFormat; + if Assigned(ParentReportServer.OnGetVariables) then + Synchronize(DoGetVariables); + FRepSession.Variables := FVariables; + FRepSession.FreeOnTerminate := True; + + FRepSession.Password := FPassword; + + FSessionItem.ReportThread := FRepSession; + + FRepSession.PageNav := FPageNavigator; + FRepSession.Multipage := FMultipage; + FRepSession.UserLogin := FLogin; + + FRepSession.Resume; + end else + begin + FSessionItem := SessionManager.FindSessionById(FDialogSessionId); + if FSessionItem <> nil then + begin + FRepSession := FSessionItem.ReportThread; + if FRepSession <> nil then + begin + FRepSession.Stream := FStream; + FRepSession.Variables := FVariables; + FRepSession.Continue := True; + while FRepSession.DialogActive and (not Terminated) do + PMessages; + end + end + end; + if (FRepSession <> nil) and (not Terminated) then + begin + while (not Terminated) and (FRepSession.Active) and (not FRepSession.DialogActive) do + begin + Sleep(10); + PMessages; + end; + if FDialog then + FName := '\' + FDialogSessionId + FRepSession.ResultPage + else + begin + FName := '\' + FSessionId + FRepSession.ResultPage; + end; + + FReportMessage := FRepSession.ReportMessage; + + if FRepSession.Auth then + FAuthNeeded := True; + + if (not FRepSession.DialogActive) then + if FDialog then + begin + FRepSession.Terminate; + SessionManager.FindSessionById(FDialogSessionId).ReportThread := nil; + end else + SessionManager.FindSessionById(FSessionId).ReportThread := nil; + FRepSession.Readed := True; + end else + FName := ''; + FResultPage := StringReplace(FName, '\', '/', [rfReplaceAll]); + FFileDate := Now; + end; +end; + +procedure TfrxServerSession.MakeServerReply; +var + FStream: TFileStream; + Buffer, sn, s: String; + i: Integer; + MemStream, MemStreamOut: TMemoryStream; + FSSIStream: TfrxSSIStream; + FTemplate: TfrxServerTemplate; +begin + if FData <> nil then + FData.FileName := FName; + if FErrorCode = 200 then + begin + if ClientSocket.Connected + + then + begin + MemStream := TMemoryStream.Create; + FSSIStream := TfrxSSIStream.Create; + FSSIStream.BasePath := FParentHTTPServer.BasePath; + FSSIStream.Variables := FParentReportServer.Variables; + try + try + if Length(FReturnData) = 0 then + begin + FStream := TFileStream.Create(FParentHTTPServer.BasePath + FName, fmOpenRead + fmShareDenyWrite); + try + FSSIStream.CopyFrom(FStream, 0); + finally + FStream.Free; + end; + if CheckSSI(FName) then + FSSIStream.Prepare + end + else + FSSIStream.Write(FReturnData[1], Length(FReturnData)); + + FSSIStream.Position := 0; + if FGzip + + then + begin + try + frxCompressStream(FSSIStream, MemStream, gzMax, FName); + except + FErrorText := 'GZIP pack error'; + ErrorLog; + end; + end else + MemStream.CopyFrom(FSSIStream, 0); + MemStream.Position := 0; + sn := 'Content-length'; + s := IntToStr(MemStream.Size); + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + if ServerConfig.GetBool('server.http.mic') then + begin + sn := 'Content-MD5'; + s := MD5Stream(MemStream); + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + end; + FReplyHeader.Add(''); + Buffer := FReplyHeader.Text; + except + FErrorText := 'error prepare output result'; + ErrorLog; + end; + + MemStreamOut := TMemoryStream.Create; + try + MemStream.SaveToStream(MemStreamOut); + MemStreamOut.Position := 0; + ClientSocket.SendBuf(Buffer[1], Length(Buffer)); + ClientSocket.SendStreamThenDrop(MemStreamOut); + except + MemStreamOut.Free; + FErrorText := 'error socket stream output result'; + ErrorLog; + end; + + finally + MemStream.Free; + FSSIStream.Free; + end + end; + end else + begin + sn := 'Content-type'; + s := 'text/html'; + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + + if FErrorCode = 404 then + begin + FTemplate := TfrxServerTemplate.Create; + try + FTemplate.SetTemplate('error404'); + FTemplate.Variables.AddVariable('ERROR', FReportMessage + '
' + ServerConfig.ServerMessage); + FTemplate.Prepare; + Buffer := FTemplate.TemplateStrings.Text; + finally + FTemplate.Free; + end; + + i := Length(Buffer); + FErrorText := FName + ' document not found ' + FReportMessage; + ErrorLog; + end else + if FRedirect or (FErrorCode = 403) then + begin + i := 0; + Buffer := ''; + end else + if FErrorCode = 401 then + begin + i := 0; + Buffer := ''; + sn := 'WWW-Authenticate'; + s := 'Basic realm="' + SERVER_NAME + '"'; + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + end else + begin + FTemplate := TfrxServerTemplate.Create; + try + FTemplate.SetTemplate('error500'); + FTemplate.Variables.AddVariable('ERROR', ''); + FTemplate.Prepare; + Buffer := FTemplate.TemplateStrings.Text; + finally + FTemplate.Free; + end; + i := Length(Buffer); + FErrorText := 'unknown error'; + ErrorLog; + end; + sn := 'Content-length'; + s := IntToStr(i); + AddOutData(sn, s); + FReplyHeader.Add(sn + ': ' + s); + FReplyHeader.Add(''); +// Buffer := FReplyHeader.Text + Buffer; + + try + ClientSocket.SendText(FReplyHeader.Text); + ClientSocket.SendText(Buffer); + ClientSocket.Close; + except + FErrorText := 'error socket stream output answer'; + ErrorLog; + end; + + end; +end; + +procedure TfrxServerSession.ClientExecute; +var + FDSet: TFDSet; + TimeVal: TTimeVal; + TempStream: TMemoryStream; + i: Integer; + Len: Integer; +begin + LogWriter.StatAddCurrentSession; + + FD_ZERO(FDSet); + FD_SET(ClientSocket.SocketHandle, FDSet); + TimeVal.tv_sec := FParentHTTPServer.SocketTimeOut; + TimeVal.tv_usec := 0; + if (select(0, @FDSet, nil, nil, @TimeVal) > 0) and not Terminated then + begin + TempStream := TMemoryStream.Create; + try + i := ClientSocket.ReceiveLength; + TempStream.SetSize(i); + try + ClientSocket.ReceiveBuf(TempStream.Memory^, i); + except + FErrorText := 'error socket stream read'; + ErrorLog; + end; + TempStream.Position := 0; + i := StreamSearch(TempStream, 0, #13#10#13#10); + if i <> 0 then + begin + Len := i + 4; + SetLength(FHeader, Len); + try + TempStream.Position := 0; + TempStream.ReadBuffer(FHeader[1], Len); + try + FStream.CopyFrom(TempStream, TempStream.Size - Len); + except + FErrorText := 'error client query'; + ErrorLog; + end; + except + FErrorText := 'error client stream parsing'; + ErrorLog; + end; + end; + finally + TempStream.Free; + end; + end; + if (select(0, nil, @FDSet, nil, @TimeVal) > 0) and not Terminated then + if (Length(FHeader) > 0) and ClientSocket.Connected then + begin + ParseHTTPHeader; + CreateReplyHTTPData; + MakeServerReply; + end; + CloseSession; + + LogWriter.StatRemoveCurrentSession; +end; + +procedure TfrxServerSession.GetFileMIMEType; +var + Registry: TRegistry; + ext: String; +begin + ext := ExtractFileExt(FName); + Registry := TRegistry.Create; + try +{$IFNDEF Delphi4} + Registry.Access := KEY_READ; +{$ENDIF} + Registry.RootKey := HKEY_CLASSES_ROOT; + FMIMEType := ''; + if Registry.KeyExists(ext) then + begin + Registry.OpenKey(ext, false); + FMIMEType := Registry.ReadString('Content Type'); + Registry.CloseKey; + end; + finally + Registry.Free; + end; +end; + +procedure TfrxServerSession.WriteLogs; +begin + LogWriter.Write(ACCESS_LEVEL, DateTimeToStr(Now) + #9 + FSessionId + #9 + FRemoteIP + #9 + FName); + if Length(FReferer) > 0 then + LogWriter.Write(REFERER_LEVEL, DateTimeToStr(Now) + #9 + FRemoteIP + #9 + FReferer); + if Length(FUserAgent) > 0 then + LogWriter.Write(AGENT_LEVEL, DateTimeToStr(Now) + #9 + FRemoteIP + #9 + FUserAgent); +end; + +procedure TfrxServerSession.ErrorLog; +begin + LogWriter.Write(ERROR_LEVEL, DateTimeToStr(Now) + #9 + FRemoteIP + #9 + FErrorText); + LogWriter.ErrorReached; +end; + +procedure TfrxServerSession.UpdateSessionFName; +begin + SessionManager.FindSessionById(FSessionId).FileName := FName; +end; + +procedure TfrxServerSession.CloseSession; +begin + SessionManager.CompleteSessionId(SessionId); +end; + +function TfrxServerSession.CheckSSI(FileName: String): Boolean; +var + ext: String; +begin + ext := LowerCase(ExtractFileExt(FileName)); + Result := (ext = '.htm') or (ext = '.html') or + (ext = '.shtm') or (ext = '.shtml'); +end; + +function TfrxServerSession.CheckDeflate(FileName: String): Boolean; +var + ext: String; +begin + ext := LowerCase(ExtractFileExt(FileName)); + if Pos('MSIE', FUserAgent) > 0 then + Result := ((ext = '.htm') or (ext = '.html') or + (ext = '.shtm') or (ext = '.shtml') or + (ext = '.css') or (ext = '.txt') or + (ext = '.bmp')) and (FSize > MAX_IE_GZIP) + else + Result := (ext <> '.jpg') and (ext <> '.jpeg') and + (ext <> '.gif') and (ext <> '.png') and + (ext <> '.ods') and (ext <> '.odt') and + (ext <> '.zip') and (ext <> '.rar'); +end; + +procedure TfrxServerSession.CheckAuth; +var + i: Integer; + s: String; + L, P: String; +begin + FAuthNeeded := ((Length(ServerConfig.GetValue('server.security.login')) > 0) and + (Length(ServerConfig.GetValue('server.security.password')) > 0)) + or (ServerConfig.GetBool('server.security.userauth')); + s := ParseHeaderField('Authorization: '); + if Length(s) > 0 then + begin + i := Pos('Basic ', s); + if i > 0 then + begin + s := Copy(s, i + 6, Length(s) - i - 5); + s := Base64Decode(s); + i := Pos(':', s); + if i > 0 then + begin + L := Copy(s, 1, i - 1); + P := Copy(s, i + 1, Length(s) - i); + FLogin := L; + FPassword := P; + + if ServerConfig.GetBool('server.security.userauth') then + begin + FAuthNeeded := not ServerUsers.AllowLogin(L, P); + if FName = '' then + FName := ServerUsers.GetUserIndex(L); + end + else + if (L = ServerConfig.GetValue('server.security.login')) and + (P = ServerConfig.GetValue('server.security.password')) then + FAuthNeeded := False + end; + end; + end; +end; + +procedure TfrxServerSession.DoGetVariables; +begin + ParentReportServer.OnGetVariables(FName, FVariables, FLogin); +end; + + +procedure TfrxServerSession.AddOutData(const Name: String; const Value: String); +begin + if FData <> nil then + FData.OutParams.Add(Name + '=' + Value); +end; + +{ TfrxServerData } + +procedure TfrxServerData.Assign(Source: TfrxServerData); +begin + FInParams.Assign(Source.InParams); + FOutParams.Assign(Source.FOutParams); + FErrorCode := Source.ErrorCode; + FStream.Clear; + if Source.Stream.Size > 0 then + begin + Source.Stream.Position := 0; + FStream.CopyFrom(Source.Stream, 0); + end; + FErrorCode := Source.ErrorCode; + FFileName := Source.FileName; +end; + +constructor TfrxServerData.Create; +begin + FInParams := TStringList.Create; + FOutParams := TStringList.Create; + FStream := TMemoryStream.Create; + FErrorCode := 0; +end; + +destructor TfrxServerData.Destroy; +begin + FStream.Free; + FInParams.Free; + FOutParams.Free; + inherited; +end; + +{ TfrxServerGuard } + +constructor TfrxServerGuard.Create(Server: TfrxReportServer); +begin + inherited Create(True); + FServer := Server; + FTimeOut := 10; + FListTimeOut := 30; + Priority := tpLowest; + Resume; +end; + +destructor TfrxServerGuard.Destroy; +begin + Terminate; + PMessages; + WaitFor; + inherited; +end; + +procedure TfrxServerGuard.DoLoadConf; +begin + FServer.LoadConfigs; +end; + +procedure TfrxServerGuard.Execute; +var + time1, time2, out1, out2: Cardinal; +begin + time1 := GetTickCount; + time2 := time1; + out1 := FTimeOut * 1000; + out2 := FListTimeOut * 1000; + while not Terminated do + begin + if (GetTickCount - time1) > out1 then + begin + Synchronize(DoLoadConf); + time1 := GetTickCount; + end; + if (GetTickCount - time2) > out2 then + begin +// FServer.ReportsList.BuildListOfReports; + time2 := GetTickCount; + end; + Sleep(1); + end; +end; + +initialization + + +finalization + + +end. diff --git a/official/4.2/LibD11/frxServerCache.pas b/official/4.2/LibD11/frxServerCache.pas new file mode 100644 index 0000000..533782f --- /dev/null +++ b/official/4.2/LibD11/frxServerCache.pas @@ -0,0 +1,457 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Server cahce module } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerCache; + +{$I frx.inc} + +interface + +uses Windows, Classes, SysUtils, frxUtils, frxServerUtils, frxNetUtils, + frxVariables, frxClass, frxServerLog, SyncObjs; + +type + TfrxServerCacheItem = class(TCollectionItem) + private + FReportName: String; + FVariables: TfrxVariables; + FFileName: String; + FExpTime: TDateTime; + FSessionId: String; + FStream: TStream; + public + constructor Create(Collection: TCollection); override; + destructor Destroy; override; + published + property ReportName: String read FReportName write FReportName; + property Variables: TfrxVariables read FVariables write FVariables; + property FileName: String read FFileName write FFileName; + property ExpTime: TDateTime read FExpTime write FExpTime; + property SessionId: String read FSessionId write FSessionId; + property Stream: TStream read FStream write FStream; + end; + + TfrxServerCacheSpool = class(TCollection) + private + function GetItems(Index: Integer): TfrxServerCacheItem; + function EqualVariables(const Var1: TfrxVariables; const Var2: TfrxVariables): Boolean; + public + constructor Create; + destructor Destroy; override; + property Items[Index: Integer]: TfrxServerCacheItem read GetItems; + procedure Clear; + published + function Add: TfrxServerCacheItem; + function Insert(Index: Integer): TfrxServerCacheItem; + function IndexOf(const ReportName: String; const Variables: TfrxVariables; const SessionId: String): Integer; + end; + + TfrxServerCache = class (TThread) + private + FCachePath: String; + FActive: Boolean; + FLatency: Integer; + FHeap: TfrxServerCacheSpool; + FLatencyReports: TStrings; + FLatencyValues: TStrings; + FMemoryCache: Boolean; + FThreadActive: Boolean; + function GetReportLatency(const ReportName: String): Integer; + procedure SetActive(const Value: Boolean); + procedure CleanUpFiles; + procedure RemoveExpired; + protected + procedure Execute; override; + public + constructor Create; + destructor Destroy; override; + function GetCachedStream(const Report: TfrxReport; const ReportName: String; const Variables: TfrxVariables; const Id: String): Boolean; + procedure Open; + procedure Close; + procedure Clear; + procedure AddReport(const Report: TfrxReport; + const ReportName: String; const Variables: TfrxVariables; const Id: String); + + property Active: Boolean read FActive write SetActive; + property CachePath: String read FCachePath write FCachePath; + property DefaultLatency: Integer read FLatency write FLatency; + property Heap: TfrxServerCacheSpool read FHeap; + property LatencyReports: TStrings read FLatencyReports; + property LatencyValues: TStrings read FLatencyValues; + property MemoryCache: Boolean read FMemoryCache write FMemoryCache; + end; + +const + CACHE_PREFIX = '$fr'; + +var + CacheCS1: TCriticalSection; + ReportCache: TfrxServerCache; + +implementation + +uses frxFileUtils, frxServerConfig; + +{ TfrxServerCacheSpool } + +function TfrxServerCacheSpool.Add: TfrxServerCacheItem; +begin + Result := TfrxServerCacheItem.Create(Self); +end; + +procedure TfrxServerCacheSpool.Clear; +var + i: Integer; +begin + CacheCS1.Enter; + try + for i := 0 to Count - 1 do + if Assigned(Items[i].Stream) then + begin + Items[i].Stream.Free; + Items[i].Stream := nil; + end; + finally + CacheCS1.Leave; + end; + inherited Clear; +end; + +constructor TfrxServerCacheSpool.Create; +begin + inherited Create(TfrxServerCacheItem); +end; + +destructor TfrxServerCacheSpool.Destroy; +begin + inherited; +end; + +function TfrxServerCacheSpool.EqualVariables(const Var1, + Var2: TfrxVariables): Boolean; +var + i, j, k: Integer; +begin + Result := False; + if Assigned(Var1) and Assigned(Var2) then + begin + j := Var1.Count; + if j = Var2.Count then + begin + Result := True; + for i := 0 to j - 1 do + begin + k := Var2.IndexOf(Var1.Items[i].Name); + if (k = -1) or (Var2.Items[k].Value <> Var1.Items[i].Value) then + begin + Result := False; + Break; + end; + end; + end; + end + else if Var1 = Var2 then + Result := True; +end; + +function TfrxServerCacheSpool.GetItems(Index: Integer): TfrxServerCacheItem; +begin + Result := TfrxServerCacheItem(inherited Items[Index]); +end; + +function TfrxServerCacheSpool.IndexOf(const ReportName: String; + const Variables: TfrxVariables; const SessionId: String): Integer; +var + i: Integer; + s: String; +begin + Result := -1; + for i := 0 to Count - 1 do + begin + s := Items[i].SessionId; + if ((AnsiCompareText(ReportName, Items[i].ReportName) = 0) and + EqualVariables(Items[i].Variables, Variables)) and (s = '') or + ((AnsiCompareText(SessionId, s) = 0) and (s <> '')) then + begin + Result := i; + break; + end; + end; +end; + +function TfrxServerCacheSpool.Insert(Index: Integer): TfrxServerCacheItem; +begin + Result := TfrxServerCacheItem(inherited Insert(Index)); +end; + +{ TfrxServerCacheItem } + +constructor TfrxServerCacheItem.Create(Collection: TCollection); +begin + inherited Create(Collection); + FStream := nil; +end; + +destructor TfrxServerCacheItem.Destroy; +begin + CacheCS1.Enter; + try + if Assigned(FStream) then + FStream.Free; + if Assigned(FVariables) then + FVariables.Free; + finally + CacheCS1.Leave; + end; + inherited; +end; + +{ TfrxServerCache } + +procedure TfrxServerCache.AddReport(const Report: TfrxReport; + const ReportName: String; const Variables: TfrxVariables; const Id: String); +var + Item: TfrxServerCacheItem; + Lat: TDateTime; +begin + if Active then + begin + CacheCS1.Enter; + try + Lat := GetReportLatency(ReportName) / 86400; + if Lat > 0 then + begin + Item := FHeap.Add; + Item.ReportName := ReportName; + if Assigned(Variables) then + begin + Item.Variables := TfrxVariables.Create; + Item.Variables.Assign(Variables); + end; + Item.ExpTime := Now + Lat; + if Id <> '' then + Item.ExpTime := Item.ExpTime * 20; + if FMemoryCache then + begin + Item.Stream := TMemoryStream.Create; + try + Report.PreviewPages.SaveToStream(Item.Stream); + Item.Stream.Position := 0; + except + Item.Stream.Free; + FMemoryCache := False; + end; + end; + if not FMemoryCache then + begin + Item.FileName := GetUniqueFileName(FCachePath, CACHE_PREFIX); + try + Report.PreviewPages.SaveToFile(Item.FileName); + except + Active := False; + end; + end; + Item.SessionId := Id; + end; + finally + CacheCS1.Leave; + end; + end; +end; + +procedure TfrxServerCache.CleanUpFiles; +var + SRec: TSearchRec; + i: Integer; +begin + if DirectoryExists(FCachePath) then + begin + i := FindFirst(FCachePath + CACHE_PREFIX + '*.*', 0, SRec); + try + while i = 0 do + begin + try + DeleteFile(FCachePath + SRec.Name); + except + end; + i := FindNext(SRec); + end; + finally + FindClose(SRec); + end; + end; +end; + +procedure TfrxServerCache.Clear; +begin + FHeap.Clear; + CleanUpFiles; +end; + +procedure TfrxServerCache.Close; +begin + if FActive then + begin + Suspend; + Clear; + FActive := False; + end; +end; + +constructor TfrxServerCache.Create; +begin + inherited Create(True); + FMemoryCache := ServerConfig.GetValue('server.cache.target') = 'memory'; + FLatencyReports := TStringList.Create; + FLatencyValues := TStringList.Create; + FCachePath := frxGetAbsPathDir(ServerConfig.GetValue('server.cache.path'), ServerConfig.ConfigFolder); + FActive := ServerConfig.GetValue('server.cache.active') = 'yes'; + FLatency := StrToInt(ServerConfig.GetValue('server.cache.defaultlatency')); + FHeap := TfrxServerCacheSpool.Create; + CleanUpFiles; + Resume; +end; + +destructor TfrxServerCache.Destroy; +begin + Clear; + Terminate; + while FThreadActive do + Sleep(10); +// WaitFor; + PMessages; + FHeap.Free; + FLatencyReports.Free; + FLatencyValues.Free; + inherited; +end; + +procedure TfrxServerCache.Execute; +var + i: Integer; +begin + FThreadActive := True; + while not Terminated do + begin + RemoveExpired; + i := 0; + while (not Terminated) and (i < 100) do + begin + Sleep(100); + Inc(i); + end; + end; + FThreadActive := False; +end; + +function TfrxServerCache.GetCachedStream(const Report: TfrxReport; + const ReportName: String; const Variables: TfrxVariables; const Id: String): Boolean; +var + i: Integer; +begin + Result := False; + if Active then + begin + CacheCS1.Enter; + try + i := FHeap.IndexOf(ReportName, Variables, Id); + if i <> -1 then + begin + try + if Assigned(FHeap.Items[i].Stream) then + begin + FHeap.Items[i].Stream.Position := 0; + Report.PreviewPages.LoadFromStream(FHeap.Items[i].Stream); + Result := True; + end + else if FileExists(FHeap.Items[i].FileName) then + begin + Report.PreviewPages.LoadFromFile(FHeap.Items[i].FileName); + Result := True; + end; + except + on e: Exception do + begin + LogWriter.Write(ERROR_LEVEL, DateTimeToStr(Now) + #9 + Id + #9'cache read error: ' + FHeap.Items[i].FileName + ' ' + Report.Errors.Text + e.Message); + LogWriter.ErrorReached; + Result := False; + end; + end; + end + finally + CacheCS1.Leave; + end; + end; + if Result then + LogWriter.StatAddCacheHit; +end; + +procedure TfrxServerCache.Open; +begin + if not FActive then + begin + Resume; + FActive := True; + end; +end; + +procedure TfrxServerCache.RemoveExpired; +var + i: Integer; +begin + i := 0; + CacheCS1.Enter; + try + while i < FHeap.Count do + begin + if FHeap.Items[i].ExpTime <= Now then + begin + if Assigned(FHeap.Items[i].Stream) then + begin + FHeap.Items[i].Stream.Free; + FHeap.Items[i].Stream := nil; + end; + if FileExists(FHeap.Items[i].FileName) then + DeleteFile(FHeap.Items[i].FileName); + FHeap.Items[i].Free; // Delete(i); + end else Inc(i); + end; + finally + CacheCS1.Leave; + end; +end; + +procedure TfrxServerCache.SetActive(const Value: Boolean); +begin + if Value <> FActive then + if Value then Open + else Close; +end; + +function TfrxServerCache.GetReportLatency(const ReportName: String): Integer; +var + i: Integer; +begin + i := FLatencyReports.IndexOf(ReportName); + if i <> -1 then + Result := StrToInt(FLatencyValues[i]) + else + Result := FLatency; +end; + +initialization + CacheCS1 := TCriticalSection.Create; + +finalization + CacheCS1.Free; + +end. diff --git a/official/4.2/LibD11/frxServerClient.pas b/official/4.2/LibD11/frxServerClient.pas new file mode 100644 index 0000000..d2d53a2 --- /dev/null +++ b/official/4.2/LibD11/frxServerClient.pas @@ -0,0 +1,356 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Server Client } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerClient; + +{$I frx.inc} + +interface + +uses + Windows, SysUtils, Classes, Forms, Controls, + + frxClass, ScktComp, + frxVariables, frxGZip, frxHTTPClient, frxMD5, + frxServerUtils, frxNetUtils, frxUnicodeUtils; + +type + + TfrxServerConnection = class (TComponent) + + private + FHost: String; + FLogin: String; + FMIC: Boolean; + FPassword: String; + FPort: Integer; + FProxyPort: Integer; + FProxyHost: String; + FRetryCount: Integer; + FRetryTimeout: Cardinal; + FTimeout: Cardinal; + FPath: String; + FCompression: Boolean; + procedure SetPath(const Value: String); + + public + constructor Create(AOwner: TComponent); override; + published + property Compression: Boolean read FCompression write FCompression; + property Host: String read FHost write FHost; + property Login: String read FLogin write FLogin; + property MIC: Boolean read FMIC write FMIC; + property Password: String read FPassword write FPassword; + property Port: Integer read FPort write FPort; + property ProxyHost: String read FProxyHost write FProxyHost; + property ProxyPort: Integer read FProxyPort write FProxyPort; + property RetryCount: Integer read FRetryCount write FRetryCount; + property RetryTimeout: Cardinal read FRetryTimeout write FRetryTimeout; + property Timeout: Cardinal read FTimeout write FTimeout; + property Path: String read FPath write SetPath; + end; + + + TfrxReportClient = class (TfrxReport) + + private + FClient: TfrxHTTPClient; + FConnection: TfrxServerConnection; + FReportName: String; + FSessionId: String; + FSecondPass: Boolean; + procedure FillPreviewPages; + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + + function PrepareReport: Boolean; + procedure LoadFromFile(FileName: String); + procedure ShowReport; + function GetServerVariable(const VariableName: String): String; + procedure Close; + + property Client: TfrxHTTPClient read FClient write FClient; + published + property Connection: TfrxServerConnection read FConnection write FConnection; + property ReportName: String read FReportName write FReportName; + end; + +implementation + +uses frxUtils +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + THackThread = class(TThread); + +{ TfrxReportClient } + +constructor TfrxReportClient.Create(AOwner: TComponent); +var + FBlankPage: TfrxReportPage; +begin + inherited; + FBlankPage := TfrxReportPage.Create(Self); + FBlankPage.PrintIfEmpty := True; + EngineOptions.DestroyForms := False; + if not Assigned(frxCompressorClass) then + frxCompressorClass := TfrxGZipCompressor; + FClient := TfrxHTTPClient.Create(nil); + FSecondPass := False; +end; + +destructor TfrxReportClient.Destroy; +begin + if FClient.Active then + FClient.Close; + FClient.Free; + + inherited; +end; + +procedure TfrxReportClient.Notification(AComponent: TComponent; + Operation: TOperation); +begin + inherited Notification(AComponent, Operation); + if Operation = opRemove then + if AComponent = FConnection then + FConnection := nil; +end; + + +procedure TfrxReportClient.ShowReport; +begin + Clear; + if PrepareReport then + ShowPreparedReport; +end; + + + + +function TfrxReportClient.PrepareReport: Boolean; +var + s: String; + i: Integer; + FPage: TfrxDialogPage; + FBlankPage: TfrxReportPage; +begin + Result := False; + if not FSecondPass then + begin + Errors.Clear; + PreviewPages.Clear; + Objects.Clear; + FBlankPage := TfrxReportpage.Create(Self); + FBlankPage.Name := 'Page_1'; + Engine.TotalPages := Engine.TotalPages + 1; + end; + if Assigned(FConnection) then + begin + try + if not EngineOptions.EnableThreadSafe then + Screen.Cursor := crHourGlass; + FClient.Host := FConnection.Host; + FClient.Port := FConnection.Port; + FClient.ProxyHost := FConnection.ProxyHost; + FClient.ProxyPort := FConnection.ProxyPort; + FClient.RetryCount := FConnection.RetryCount; + FClient.RetryTimeOut := FConnection.RetryTimeout; + FClient.TimeOut := FConnection.Timeout; + FClient.MIC := FConnection.MIC; + s := ''; + for i := 0 to Variables.Count - 1 do + s := s + '&' + Variables.Items[i].Name + '=' + + Str2HTML(UTF8Encode(VarToStr(Variables.Items[i].Value))); + if FClient.Stream.Size > 1 then + s := s + '&sessionid=' + FSessionId; + FClient.ClientFields.FileName := 'result?report=' + Str2HTML(FReportName) + '&format=FRP' + s; + if Connection.Path <> '' then + FClient.ClientFields.FileName := Connection.Path + StringReplace(FClient.ClientFields.FileName, ' ', '%20', [rfReplaceAll]); + if FConnection.Compression then + FClient.ClientFields.AcceptEncoding := 'gzip' + else + FClient.ClientFields.AcceptEncoding := ''; + if Length(FConnection.Login) > 0 then + begin + FClient.ClientFields.Login := FConnection.Login; + FClient.ClientFields.Password := FConnection.Password; + end; + FClient.ClientFields.QueryType := qtGet; + try + FClient.Open; + except + FClient.Close; + end; + if not FClient.Breaked then + begin + if FClient.Errors.Count = 0 then + begin + if (ExtractFileExt(FClient.ClientFields.FileName) = '.frm') and + (not EngineOptions.EnableThreadSafe) and + (Connection.Path = '') then + begin + FSessionId := FClient.ServerFields.SessionId; + FPage := TfrxDialogPage.Create(Self); + FPage.LoadFromStream(FClient.Stream); + inherited PrepareReport; + FClient.Stream.Clear; + Pages[1].SaveToStream(FClient.Stream); + Pages[1].Free; + FSecondPass := True; + PrepareReport; + end + else + try + FillPreviewPages; + except + end; + Result := True; + end else + Errors.AddStrings(FClient.Errors); + end; + finally + if not EngineOptions.EnableThreadSafe then + Screen.Cursor := crDefault; + end; + end; + if (Engine.TotalPages >= 0) and (not FSecondPass) then + begin + Pages[0].Free; + Engine.TotalPages := Engine.TotalPages - 1; + end + else + FSecondPass := False; + FClient.Stream.Clear; +end; + + +procedure TfrxReportClient.FillPreviewPages; +begin + FClient.Stream.Position := 0; + PreviewPages.LoadFromStream(FClient.Stream); +end; + + +procedure TfrxReportClient.LoadFromFile(FileName: String); +begin + FReportName := FileName; +end; + + + +function TfrxReportClient.GetServerVariable(const VariableName: String): String; +var + Lines: TStringList; +begin + + FClient.Errors.Clear; + Errors.Clear; + if Assigned(FConnection) then + begin + Lines := TStringList.Create; + try + if not EngineOptions.EnableThreadSafe then + Screen.Cursor := crHourGlass; + FClient.Host := FConnection.Host; + FClient.Port := FConnection.Port; + FClient.ProxyHost := FConnection.ProxyHost; + FClient.ProxyPort := FConnection.ProxyPort; + FClient.RetryCount := FConnection.RetryCount; + FClient.RetryTimeOut := FConnection.RetryTimeout; + FClient.TimeOut := FConnection.Timeout; + FClient.MIC := FConnection.MIC; + FClient.ClientFields.FileName := 'result?getvariable=' + VariableName; + if Connection.Path <> '' then + FClient.ClientFields.FileName := Connection.Path + FClient.ClientFields.FileName; + if FConnection.Compression then + FClient.ClientFields.AcceptEncoding := 'gzip' + else + FClient.ClientFields.AcceptEncoding := ''; + if Length(FConnection.Login) > 0 then + begin + FClient.ClientFields.Login := FConnection.Login; + FClient.ClientFields.Password := FConnection.Password; + end; + FClient.ClientFields.QueryType := qtGet; + try + FClient.Open; + except + FClient.Close; + end; + if not FClient.Breaked then + begin + if FClient.Errors.Count = 0 then + begin + if FClient.Stream.Size > 0 then + Lines.LoadFromStream(FClient.Stream); + FClient.Stream.Clear; + end else + Errors.AddStrings(FClient.Errors); + end; + finally + + Result := Lines.Text; + + Lines.Free; + if not EngineOptions.EnableThreadSafe then + Screen.Cursor := crDefault; + end; + end; +end; + +procedure TfrxReportClient.Close; +begin + if FClient.Active then + FClient.Close; +end; + + + +{ TfrxServerConnection } + +constructor TfrxServerConnection.Create(AOwner: TComponent); +begin + inherited; + FHost := '127.0.0.1'; + FPort := 80; + FLogin := ''; + FPassword := ''; + FTimeout := 120; + FRetryCount := 3; + FProxyHost := ''; + FProxyPort := 8080; + FRetryTimeout := 5; + FMIC := True; + FCompression := True; +end; + + + +procedure TfrxServerConnection.SetPath(const Value: String); +begin + if (Value = '') or (Value[Length(Value)] = '/') then + FPath := Value + else + FPath := Value + '/'; +end; + +initialization + RegisterClasses([TfrxServerConnection, TfrxReportClient]); + + +end. diff --git a/official/4.2/LibD11/frxServerConfig.pas b/official/4.2/LibD11/frxServerConfig.pas new file mode 100644 index 0000000..9bade1c --- /dev/null +++ b/official/4.2/LibD11/frxServerConfig.pas @@ -0,0 +1,469 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report Server Configurator } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerConfig; + +{$I frx.inc} + +interface + +{$R frxServerConfig.res} + +uses Windows, Classes, SysUtils, SyncObjs, frxXML, frxUtils, + frxServerUtils, inifiles, frxServerLog; + +type + TfrxConfig = class (TObject) + private + FXML: TfrxXMLDocument; + FErrors: TStrings; + FLines: TStringList; + FCS: TCriticalSection; + FFileName: String; + FConfigFolder: String; + procedure UpdateLines; + procedure AddLine(const Name: String; const Value: String; XMLItem: TfrxXMLItem); + function GetCount: Integer; + public + ServerMessage: String; + constructor Create; + destructor Destroy; override; + function LoadFromStream(Stream: TStream): HRESULT; + function SaveToStream(Stream: TStream): HRESULT; + function LoadFromFile(const FileName: String): HRESULT; + function SaveToFile(const FileName: String): HRESULT; + function GetValue(const Name: String): String; + function GetBool(const Name: String): Boolean; + function CheckValue(const Name: String; const Current: String): String; + procedure SetValue(const Name: String; const Value: String); + procedure SetBool(const Name: String; const Value: Boolean); + procedure Clear; + procedure ConfigListToFile(const FileName: String); + procedure Reload; + + property Lines: TStringList read FLines; + property XML: TfrxXMLDocument read FXML; + property Count: Integer read GetCount; + property ConfigFolder: String read FConfigFolder write FConfigFolder; + end; + + TfrxConfigItem = class (TObject) + private + FValue: String; + FXMLItem: TfrxXMLItem; + + property Value: String read FValue write FValue; + property XMLItem: TfrxXMLItem read FXMLItem write FXMLItem; + end; + + TfrxServerConfig = class(TPersistent) + private + FGzip: Boolean; + FIndexFileName: String; + FLogging: Boolean; + FLogin: String; + FLogPath: String; + FMIC: Boolean; + FNoCacheHeader: Boolean; + FOutputFormats: TfrxServerOutputFormats; + FPassword: String; + FPort: Integer; + FReportPath: String; + FRootPath: String; + FSessionTimeOut: Integer; + FSocketTimeOut: Integer; + FReportCachePath: String; + FDefaultCacheLatency: Integer; + FReportCaching: Boolean; + FMaxLogFiles: Integer; + FMaxLogSize: Integer; + FDatabase: String; + FDatabaseLogin: String; + FDatabasePassword: String; + FReportsList: Boolean; + FConfigFolder: String; + public + procedure LoadFromFile(const FileName: String); + procedure SaveToFile(const FileName: String); + published + property Compression: Boolean read FGzip write FGzip; + property IndexFileName: String read FIndexFileName write FIndexFileName; + property Logging: Boolean read FLogging write FLogging; + property MaxLogSize: Integer read FMaxLogSize write FMaxLogSize; + property MaxLogFiles: Integer read FMaxLogFiles write FMaxLogFiles; + property Login: String read FLogin write FLogin; + property LogPath: String read FLogPath write FLogPath; + property MIC: Boolean read FMIC write FMIC; + property NoCacheHeader: Boolean read FNoCacheHeader write FNoCacheHeader; + property OutputFormats: TfrxServerOutputFormats read FOutputFormats + write FOutputFormats; + property Password: String read FPassword write FPassword; + property Port: Integer read FPort write FPort; + property ReportPath: String read FReportPath write FReportPath; + property ReportCachePath: String read FReportCachePath write FReportCachePath; + property ReportCaching: Boolean read FReportCaching write FReportCaching; + property DefaultCacheLatency: Integer read FDefaultCacheLatency write FDefaultCacheLatency; + property RootPath: String read FRootPath write FRootPath; + property SessionTimeOut: Integer read FSessionTimeOut write FSessionTimeOut; + property SocketTimeOut: Integer read FSocketTimeOut write FSocketTimeOut; + property Database: String read FDatabase write FDatabase; + property DatabaseLogin: String read FDatabaseLogin write FDatabaseLogin; + property DatabasePassword: String read FDatabasePassword write FDatabasePassword; + property ReportsList: Boolean read FReportsList write FReportsList; + property ConfigFolder: String read FConfigFolder write FConfigFolder; + end; + +var + ServerConfig: TfrxConfig; + +const + FR_SERVER_CONFIG_VERSION = '1.0'; + + +implementation + +{ TfrxConfig } + +procedure TfrxConfig.AddLine(const Name: String; const Value: String; XMLItem: TfrxXMLItem); +var + FValue: TfrxConfigItem; +begin + FValue := TfrxConfigItem.Create; + FValue.Value := Value; + FValue.XMLItem := XMLItem; + FLines.AddObject(LowerCase(Name), FValue); +end; + +function TfrxConfig.CheckValue(const Name, Current: String): String; +begin + Result := GetValue(Name); + if Result = '' then + Result := Current; +end; + +procedure TfrxConfig.Clear; +var + i: Integer; +begin + for i:= 0 to FLines.Count - 1 do + TfrxConfigItem(FLines.Objects[i]).Free; + FLines.Clear; +end; + +procedure TfrxConfig.ConfigListToFile(const FileName: String); +var + f: TFileStream; + s: String; + i: Integer; +begin + f := TFileStream.Create(FileName, fmCreate); + try + for i := 0 to FLines.Count - 1 do + begin + s := FLines[i] + ' = ' + TfrxConfigItem(FLines.Objects[i]).Value + #13#10; + f.Write(s[1], Length(s)); + end; + finally + f.Free; + end; +end; + +constructor TfrxConfig.Create; +begin + FCS := TCriticalSection.Create; + FXML := TfrxXMLDocument.Create; + FXML.AutoIndent := True; + FErrors := TStringList.Create; + FLines := TStringList.Create; + FLines.Sorted := True; + FConfigFolder := GetAppPath; +end; + +destructor TfrxConfig.Destroy; +begin + Clear; + FLines.Free; + FErrors.Free; + FXML.Free; + FCS.Free; + inherited; +end; + +function TfrxConfig.GetBool(const Name: String): Boolean; +begin + Result := GetValue(Name) = 'yes'; +end; + +function TfrxConfig.GetCount: Integer; +begin + Result := FLines.Count; +end; + +function TfrxConfig.GetValue(const Name: String): String; +var + i: Integer; +begin + FCS.Enter; + try + i := FLines.IndexOf(LowerCase(Name)); + if i <> -1 then + Result := TfrxConfigItem(FLines.Objects[i]).Value + else + Result := ''; + finally + FCS.Leave; + end; +end; + +function TfrxConfig.LoadFromFile(const FileName: String): HRESULT; +var + f: TFileStream; + frc: TResourceStream; +begin + if FileExists(FileName) then + begin + try + f := TFileStream.Create(FileName, fmOpenRead + fmShareDenyWrite); + try + Result := LoadFromStream(f); + FFileName := FileName; + finally + f.Free; + end; + except + Result := E_FAIL; + end; + end + else + begin + try + frc := TResourceStream.Create(HInstance, 'TfrxConfig', RT_RCDATA); + try + Result := LoadFromStream(frc); + finally + frc.Free; + end; + except + Result := E_FAIL; + end; + end +end; + +function TfrxConfig.LoadFromStream(Stream: TStream): HRESULT; +begin + Result := S_OK; + FCS.Enter; + try + try + FXML.LoadFromStream(Stream); + UpdateLines; + except + Result := E_FAIL; + end; + finally + FCS.Leave; + end; +end; + +procedure TfrxConfig.Reload; +begin + LoadFromFile(FFileName); +end; + +function TfrxConfig.SaveToFile(const FileName: String): HRESULT; +var + f: TFileStream; +begin + try + f := TFileStream.Create(FileName, fmCreate); + try + Result := SaveToStream(f); + FFileName := FileName; + finally + f.Free; + end; + except + Result := E_FAIL; + end; +end; + +function TfrxConfig.SaveToStream(Stream: TStream): HRESULT; +begin + Result := S_OK; + FCS.Enter; + try + try + FXML.Root.Prop['configversion'] := FR_SERVER_CONFIG_VERSION; + FXML.SaveToStream(Stream); + UpdateLines; + except + Result := E_FAIL; + end; + finally + FCS.Leave; + end; +end; + +procedure TfrxConfig.SetBool(const Name: String; const Value: Boolean); +begin + if Value then + SetValue(Name, 'yes') + else + SetValue(Name, 'no'); +end; + +procedure TfrxConfig.SetValue(const Name, Value: String); +var + i: Integer; +begin + i := FLines.IndexOf(Name); + if (i <> -1) and (FLines.Objects[i] <> nil) then + begin + TfrxConfigItem(FLines.Objects[i]).Value := Value; + if TfrxConfigItem(FLines.Objects[i]).XMLItem.Name = 'set' then + TfrxConfigItem(FLines.Objects[i]).XMLItem.Prop['value'] := Value; + end; +end; + +procedure TfrxConfig.UpdateLines; + + procedure AddItemToLines(const Prefix: String; Item: TfrxXMLItem); + var + s: String; + i: Integer; + begin + if Item <> nil then + begin + s := Prefix; + if s = '' then + s := Item.Name + else if Item.PropExists('desc') and (Item.Name <> 'set') then + s := s + '.' + Item.Name; + if Item.Name = 'set' then + AddLine(s + '.' + Item.Prop['name'], Item.Prop['value'], Item) + else + begin + if Item.PropExists('name') then + AddLine(s + '.name', Item.Prop['name'], Item); + for i := 0 to Item.Count - 1 do + AddItemToLines(s, Item.Items[i]); + end; + end; + end; + +begin + Clear; + AddLine('configversion', FXML.Root.Prop['configversion'], nil); + AddItemToLines('', FXML.Root.FindItem('server')); +end; + +{ TfrxServerConfig } + +procedure TfrxServerConfig.LoadFromFile(const FileName: String); +var + Ini: TIniFile; +begin +// compatibility code + if FileExists(FileName) then + begin + LogWriter.Write(SERVER_LEVEL, 'Borrow old-style config. You should delete the file ' + FileName + ' after this launch.'); + Ini := TIniFile.Create(FileName); + try + Port := Ini.ReadInteger('Server', 'Port', 80); + ServerConfig.SetValue('server.http.port', IntToStr(Port)); + + SessionTimeOut := Ini.ReadInteger('Server', 'SessionTimeOut', 300); + ServerConfig.SetValue('server.http.sessiontimeout', IntToStr(SessionTimeOut)); + + SocketTimeOut := Ini.ReadInteger('Server', 'SocketTimeOut', 300); + ServerConfig.SetValue('server.http.sockettimeout', IntToStr(SocketTimeOut)); + + IndexFileName := Ini.ReadString('Server', 'IndexFileName', 'index.html'); + ServerConfig.SetValue('server.http.indexfile', IndexFileName); + + LogPath := frxGetAbsPath(Ini.ReadString('Server', 'LogPath', 'logs')); + ServerConfig.SetValue('server.logs.path', frxGetRelPath(LogPath)); + + ReportPath := frxGetAbsPath(Ini.ReadString('Server', 'ReportPath', 'reports')); + ServerConfig.SetValue('server.reports.path', frxGetRelPath(ReportPath)); + + RootPath := frxGetAbsPath(Ini.ReadString('Server', 'RootPath', 'htdocs')); + ServerConfig.SetValue('server.http.rootpath', frxGetRelPath(RootPath)); + + NoCacheHeader := Ini.ReadBool('Server', 'NoCacheHeader', True); + ServerConfig.SetBool('server.http.nocacheheader', NoCacheHeader); + + Compression := Ini.ReadBool('Server', 'Compression', True); + ServerConfig.SetBool('server.http.compression', Compression); + + Login := Ini.ReadString('Server', 'Login', ''); + ServerConfig.SetValue('server.security.login', Login); + + Password := Ini.ReadString('Server', 'Password', ''); + ServerConfig.SetValue('server.security.password', Password); + + MIC := Ini.ReadBool('Server', 'MessageIntegrityCheck', True); + ServerConfig.SetBool('server.http.mic', MIC); + + ReportsList := Ini.ReadBool('Server', 'ReportsList', True); + ServerConfig.SetBool('server.security.reportslist', ReportsList); + + Logging := Ini.ReadBool('Server', 'WriteLogs', False); + ServerConfig.SetBool('server.logs.active', Logging); + + MaxLogSize := Ini.ReadInteger('Server', 'MaxLogSize', 1024); + ServerConfig.SetValue('server.logs.rotatesize', IntToStr(MaxLogSize)); + + MaxLogFiles := Ini.ReadInteger('Server', 'MaxLogFiles', 5); + ServerConfig.SetValue('server.logs.rotatefiles', IntToStr(MaxLogFiles)); + + ReportCaching := Ini.ReadBool('ReportsCache', 'Enabled', False); + ServerConfig.SetBool('server.cache.active', ReportCaching); + + ReportCachePath := frxGetAbsPath(Ini.ReadString('ReportsCache', 'CachePath', 'cache')); + ServerConfig.SetValue('server.cache.path', frxGetRelPath(ReportCachePath)); + + DefaultCacheLatency := Ini.ReadInteger('ReportsCache', 'DefaultLatency', 300); + ServerConfig.SetValue('server.cache.defaultlatency', IntToStr(DefaultCacheLatency)); + + { Ini.ReadSection('ReportsLatency', ReportCache.LatencyReports); + Ini.ReadSectionValues('ReportsLatency', ReportCache.LatencyValues); + for i := 0 to ReportCache.LatencyValues.Count - 1 do + begin + j := Pos('=', ReportCache.LatencyValues[i]); + ReportCache.LatencyValues[i] := Copy(ReportCache.LatencyValues[i], j + 1, + Length(ReportCache.LatencyValues[i]) - j + 1); + end; } + + Database := frxGetAbsPath(Ini.ReadString('Database', 'Connection', '')); + ServerConfig.SetValue('server.database.pathtodatabase', frxGetRelPath(Database)); + ServerConfig.SaveToFile(frxGetAbsPath('config.xml')); + ServerConfig.ServerMessage := 'Please restart server!'; + finally + Ini.Free; + end; + end; +end; + +procedure TfrxServerConfig.SaveToFile(const FileName: String); +begin +// compatibility code + ServerConfig.SaveToFile(FileName); +end; + +initialization + ServerConfig := TfrxConfig.Create; + +finalization + ServerConfig.Free; + +end. diff --git a/official/4.2/LibD11/frxServerConfig.res b/official/4.2/LibD11/frxServerConfig.res new file mode 100644 index 0000000..8eee57c Binary files /dev/null and b/official/4.2/LibD11/frxServerConfig.res differ diff --git a/official/4.2/LibD11/frxServerFormControls.pas b/official/4.2/LibD11/frxServerFormControls.pas new file mode 100644 index 0000000..6fe12b5 --- /dev/null +++ b/official/4.2/LibD11/frxServerFormControls.pas @@ -0,0 +1,641 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Server HTTP Form Controls } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerFormControls; + +{$I frx.inc} + +interface + +uses + Windows, Classes, SysUtils, Graphics, frxClass, frxDCtrl, frxUtils, + frxServerTemplates; + +type + TfrxCustomWebControl = class(TObject) + private + FAlignment: TAlignment; + FColor: TColor; + FEnabled: Boolean; + FFont: TFont; + FHeight: Extended; + FLeft: Extended; + FName: String; + FReadonly: Boolean; + FTabindex: Integer; + FTop: Extended; + FWidth: Extended; + FVisible: Boolean; + FTemplate: TfrxServerTemplate; + procedure SetFont(Value: TFont); + public + constructor Create; virtual; + destructor Destroy; override; + function Build: String; virtual; abstract; + function PadText(s: String; width: Integer): String; + procedure Assign(Value: TfrxDialogControl); virtual; + + property Name: String read FName write FName; + property Left: Extended read FLeft write FLeft; + property Top: Extended read FTop write FTop; + property Width: Extended read FWidth write FWidth; + property Height: Extended read FHeight write FHeight; + property Font: TFont read FFont write SetFont; + property Color: TColor read FColor write FColor; + property Alignment: TAlignment read FAlignment write FAlignment; + property Enabled: Boolean read FEnabled write FEnabled; + property Readonly: Boolean read FReadonly write FReadonly; + property Tabindex: Integer read FTabindex write FTabindex; + property HTML: String read Build; + property Visible: Boolean read FVisible write FVisible; + property Template: TfrxServerTemplate read FTemplate; + end; + +// TLabel + TfrxWebLabelControl = class(TfrxCustomWebControl) + private + FCaption: String; + public + constructor Create; override; + destructor Destroy; override; + function Build: String; override; + procedure Assign(Value: TfrxDialogControl); override; + + property Caption: String read FCaption write FCaption; + end; + +// TEdit + TfrxWebTextControl = class(TfrxCustomWebControl) + private + FText: String; + FSize: Integer; + FMaxlength: Integer; + FPassword: Boolean; + public + constructor Create; override; + destructor Destroy; override; + function Build: String; override; + procedure Assign(Value: TfrxDialogControl); override; + + property Text: String read Ftext write FText; + property Size: Integer read FSize write FSize; + property Maxlength: Integer read FMaxlength write FMaxlength; + property Password: Boolean read FPassword write FPassword; + end; + +// TDateEdit + TfrxWebDateControl = class(TfrxCustomWebControl) + private + FText: String; + FSize: Integer; + FMaxlength: Integer; + public + constructor Create; override; + destructor Destroy; override; + function Build: String; override; + procedure Assign(Value: TfrxDialogControl); override; + + property Text: String read Ftext write FText; + property Size: Integer read FSize write FSize; + property Maxlength: Integer read FMaxlength write FMaxlength; + end; + +// TMemo + TfrxWebTextAreaControl = class(TfrxCustomWebControl) + private + FText: TStrings; + FCols: Integer; + FRows: Integer; + procedure SetText(Value: TStrings); + public + constructor Create; override; + destructor Destroy; override; + function Build: String; override; + procedure Assign(Value: TfrxDialogControl); override; + + property Text: TStrings read FText write SetText; + property Cols: Integer read FCols write FCols; + property Rows: Integer read FRows write FRows; + end; + +// TCheckBox + TfrxWebCheckBoxControl = class(TfrxCustomWebControl) + private + FCaption: String; + FChecked: Boolean; + public + constructor Create; override; + destructor Destroy; override; + function Build: String; override; + procedure Assign(Value: TfrxDialogControl); override; + + property Caption: String read FCaption write FCaption; + property Checked: Boolean read FChecked write FChecked; + end; + +// TRadioButton + TfrxWebRadioControl = class(TfrxCustomWebControl) + private + FCaption: String; + FChecked: Boolean; + public + constructor Create; override; + destructor Destroy; override; + function Build: String; override; + procedure Assign(Value: TfrxDialogControl); override; + + property Caption: String read FCaption write FCaption; + property Checked: Boolean read FChecked write FChecked; + end; + + +// TListBox + TfrxWebSelectControl = class(TfrxCustomWebControl) + private + FItems: TStrings; + FCheckedValue: Integer; + procedure SetItems(Value: TStrings); + public + constructor Create; override; + destructor Destroy; override; + function Build: String; override; + procedure Assign(Value: TfrxDialogControl); override; + + property Items: TStrings read FItems write SetItems; + property CheckedValue: Integer read FCheckedValue write FCheckedValue; + end; + +// TButton + TfrxWebSubmitControl = class(TfrxCustomWebControl) + private + FCaption: String; + public + constructor Create; override; + destructor Destroy; override; + function Build: String; override; + procedure Assign(Value: TfrxDialogControl); override; + + property Caption: String read FCaption write FCaption; + end; + +implementation + +{ TfrxCustomWebControl } + +constructor TfrxCustomWebControl.Create; +begin + FName := ''; + FLeft := 0; + FTop := 0; + FWidth := 1; + FHeight := 1; + FFont := TFont.Create; + FFont.Color := clBlack; + FFont.Size := 10; + FFont.Style := []; + FFont.Name := 'Arial'; + FColor := clWhite; + FAlignment := taLeftJustify; + FEnabled := True; + FReadonly := False; + FTabindex := 0; + FTemplate := TfrxServerTemplate.Create; +end; + +destructor TfrxCustomWebControl.Destroy; +begin + FTemplate.Free; + FFont.Free; + inherited; +end; + +procedure TfrxCustomWebControl.Assign(Value: TfrxDialogControl); +begin + if Value.Parent <> nil then + Name := Value.Parent.Name + '_' + Value.Name + else Name := Value.Name; + Left := Value.Left; + Top := Value.Top; + Width := Value.Width; + Height := Value.Height; + Font := Value.Font; + Color := Value.Color; + Enabled := Value.Enabled; + Visible := Value.Visible; +end; + +procedure TfrxCustomWebControl.SetFont(Value: TFont); +begin + FFont.Assign(Value); +end; + +function TfrxCustomWebControl.PadText(s: String; width: Integer): String; +var + i: Integer; +begin + i := ((width div 10) - Length(s)) div 2; + Result := StringOfChar(' ', i) + Trim(s) + StringOfChar(' ', i); +end; + +{ TfrxWebLabelControl } + +constructor TfrxWebLabelControl.Create; +begin + inherited; + FCaption := 'Label'; +end; + +destructor TfrxWebLabelControl.Destroy; +begin + inherited; +end; + +procedure TfrxWebLabelControl.Assign(Value: TfrxDialogControl); +var + b: TfrxLabelControl; +begin + inherited Assign(Value); + if Value is TfrxLabelControl then + begin + b := TfrxLabelControl(Value); + FCaption := b.Caption; + end; +end; + +function TfrxWebLabelControl.Build: String; +begin + if Visible then + begin + Template.SetTemplate('form_label'); + Template.Variables.AddVariable('FONT_NAME', FFont.Name); + Template.Variables.AddVariable('FONT_SIZE', IntToStr(Round(FFont.Size * 96 / 72))); + Template.Variables.AddVariable('FONT_COLOR', HTMLRGBColor(FFont.Color)); + Template.Variables.AddVariable('BCOLOR', HTMLRGBColor(FColor)); + Template.Variables.AddVariable('CAPTION', FCaption); + Template.Prepare; + Result := Template.TemplateStrings.Text; + end + else + Result := ''; +end; + +{ TfrxWebTextControl } + +constructor TfrxWebTextControl.Create; +begin + inherited; + FText := ''; + FSize := 10; + FMaxlength := 50; + FPassword := False; +end; + +destructor TfrxWebTextControl.Destroy; +begin + inherited; +end; + +function TfrxWebTextControl.Build: String; +const + a: array [Boolean] of String = ('hidden', 'text'); +var + s: String; +begin + Template.SetTemplate('form_text'); + Template.Variables.AddVariable('VISIBLE', a[Visible]); + Template.Variables.AddVariable('NAME', FName); + Template.Variables.AddVariable('VALUE', FText); + Template.Variables.AddVariable('SIZE', IntToStr(Round(Width / 10))); + Template.Variables.AddVariable('LENGTH', IntToStr(FMaxlength)); + if FReadonly then + s := 'readonly' + else + s := ''; + Template.Variables.AddVariable('READONLY', s); + Template.Prepare; + Result := Template.TemplateStrings.Text; +end; + +procedure TfrxWebTextControl.Assign(Value: TfrxDialogControl); +var + b: TfrxEditControl; +begin + inherited Assign(Value); + if Value is TfrxEditControl then + begin + b := TfrxEditControl(Value); + FText := b.Text; + end; +end; + +{ TfrxWebTextAreaControl } + +constructor TfrxWebTextAreaControl.Create; +begin + inherited; + FText := TStringList.Create; + FCols := 40; + FRows := 3; +end; + +destructor TfrxWebTextAreaControl.Destroy; +begin + FText.Free; + inherited; +end; + +procedure TfrxWebTextAreaControl.SetText(Value: TStrings); +begin + FText.Clear; + FText.Assign(Value); +end; + +function TfrxWebTextAreaControl.Build: String; +begin + if Visible then + begin + Template.SetTemplate('form_memo'); + Template.Variables.AddVariable('NAME', FName); + Template.Variables.AddVariable('ROWS', IntToStr(FRows)); + Template.Variables.AddVariable('COLS', IntToStr(FCols)); + Template.Variables.AddVariable('TEXT', Text.Text); + Template.Prepare; + Result := Template.TemplateStrings.Text; + end + else + Result := ''; +end; + +procedure TfrxWebTextAreaControl.Assign(Value: TfrxDialogControl); +var + b: TfrxMemoControl; +begin + inherited Assign(Value); + if Value is TfrxMemoControl then + begin + b := TfrxMemoControl(Value); + Text := b.Lines; + FRows := Round(b.Height / 10); + FCols := Round(b.Width / 10); + end; +end; + +{ TfrxWebCheckBoxControl } + +constructor TfrxWebCheckBoxControl.Create; +begin + inherited; + FCaption := 'Checkbox'; + FChecked := False; +end; + +destructor TfrxWebCheckBoxControl.Destroy; +begin + inherited; +end; + +procedure TfrxWebCheckBoxControl.Assign(Value: TfrxDialogControl); +var + b: TfrxCheckBoxControl; +begin + inherited Assign(Value); + if Value is TfrxCheckBoxControl then + begin + b := TfrxCheckBoxControl(Value); + FCaption := b.Caption; + FChecked := b.Checked; + end; +end; + +function TfrxWebCheckBoxControl.Build: String; +var + s: String; +begin + if Visible then + begin + if FChecked then + s := 'checked' + else s := ''; + Template.SetTemplate('form_checkbox'); + Template.Variables.AddVariable('NAME', Name); + Template.Variables.AddVariable('CHECKED', s); + Template.Variables.AddVariable('FONT_NAME', FFont.Name); + Template.Variables.AddVariable('FONT_SIZE', IntToStr(Round(FFont.Size * 96 / 72))); + Template.Variables.AddVariable('FONT_COLOR', HTMLRGBColor(FFont.Color)); + Template.Variables.AddVariable('BOLOR', HTMLRGBColor(FColor)); + Template.Variables.AddVariable('CAPTION', FCaption); + Template.Prepare; + Result := Template.TemplateStrings.Text; + end + else Result := ''; +end; + +{ TfrxWebRadioControl } + +constructor TfrxWebRadioControl.Create; +begin + inherited; + FCaption := 'Radiobutton'; + FChecked := False; +end; + +destructor TfrxWebRadioControl.Destroy; +begin + inherited; +end; + +procedure TfrxWebRadioControl.Assign(Value: TfrxDialogControl); +var + b: TfrxRadioButtonControl; +begin + inherited Assign(Value); + if Value is TfrxRadioButtonControl then + begin + b := TfrxRadioButtonControl(Value); + FCaption := b.Caption; + FChecked := b.Checked; + end; +end; + +function TfrxWebRadioControl.Build: String; +var + s, n: String; + i: Integer; +begin + if Visible then + begin + if FChecked then + s := 'checked' + else s := ''; + i := Pos('_', Name); + if i > 0 then + n := Copy(Name, 1, i - 1) + else + n := Name; + Template.SetTemplate('form_radio'); + Template.Variables.AddVariable('NAME', n); + Template.Variables.AddVariable('VALUE', Name); + Template.Variables.AddVariable('CHECKED', s); + Template.Variables.AddVariable('NAME', n); + Template.Variables.AddVariable('NAME', n); + Template.Variables.AddVariable('FONT_NAME', FFont.Name); + Template.Variables.AddVariable('FONT_SIZE', IntToStr(Round(FFont.Size * 96 / 72))); + Template.Variables.AddVariable('FONT_COLOR', HTMLRGBColor(FFont.Color)); + Template.Variables.AddVariable('BOLOR', HTMLRGBColor(FColor)); + Template.Variables.AddVariable('CAPTION', FCaption); + Template.Prepare; + Result := Template.TemplateStrings.Text; + end + else Result:= ''; +end; + +{ TfrxWebSelectControl } + +constructor TfrxWebSelectControl.Create; +begin + inherited; + FItems := TStringList.Create; +end; + +destructor TfrxWebSelectControl.Destroy; +begin + FItems.Free; + inherited; +end; + +procedure TfrxWebSelectControl.SetItems(Value: TStrings); +begin + FItems.Clear; + FItems.Assign(Value); +end; + +procedure TfrxWebSelectControl.Assign(Value: TfrxDialogControl); +var i:integer; +begin + inherited Assign(Value); + if Value is TfrxComboboxControl then + begin + Items.Clear; + for i:=0 to TfrxComboBoxControl(Value).Items.count-1 do + Items.Add(TfrxComboBoxControl(Value).Items[i]); + CheckedValue:=TfrxComboBoxControl(Value).ItemIndex; + end; +end; + +function TfrxWebSelectControl.Build: String; +const + a: array[boolean] of string=('',' selected'); +var + i: integer; +begin + if Visible then + begin + Template.SetTemplate('form_select'); + Template.Variables.AddVariable('NAME', Name); + Template.Prepare; + Result := Template.TemplateStrings.Text; + for i := 0 to Items.count - 1 do + Result := Result + #13#10 + format('', + [a[i = CheckedValue], IntTostr(i), Items[i]]); + Result := Result + #13#10 + ''; + end + else Result := ''; +end; + +{ TfrxWebSubmitControl } + +constructor TfrxWebSubmitControl.Create; +begin + inherited; + FCaption := 'Button'; +end; + +destructor TfrxWebSubmitControl.Destroy; +begin + inherited; +end; + +procedure TfrxWebSubmitControl.Assign(Value: TfrxDialogControl); +var + b: TfrxButtonControl; +begin + inherited Assign(Value); + if Value is TfrxButtonControl then + begin + b := TfrxButtonControl(Value); + FCaption := b.Caption; + end; +end; + +function TfrxWebSubmitControl.Build: String; +begin + if Visible then + begin + Template.SetTemplate('form_button'); + Template.Variables.AddVariable('SIZE', IntToStr(Round(Width))); + Template.Variables.AddVariable('VALUE', PadText(Caption, Round(Width))); + Template.Prepare; + Result := Template.TemplateStrings.Text; + end + else Result := ''; +end; + +{ TfrxWebDateControl } + +procedure TfrxWebDateControl.Assign(Value: TfrxDialogControl); +var + b: TfrxDateEditControl; +begin + inherited Assign(Value); + if Value is TfrxDateEditControl then + begin + b := TfrxDateEditControl(Value); + FText := DateToStr(b.Date); + end; +end; + +function TfrxWebDateControl.Build: String; +const + a: array [Boolean] of String = ('hidden', 'text'); +var + s: String; +begin + Template.SetTemplate('form_text'); + Template.Variables.AddVariable('VISIBLE', a[Visible]); + Template.Variables.AddVariable('NAME', FName); + Template.Variables.AddVariable('VALUE', FText); + Template.Variables.AddVariable('SIZE', IntToStr(Round(Width / 10))); + Template.Variables.AddVariable('LENGTH', IntToStr(FMaxlength)); + if FReadonly then + s := 'readonly' + else + s := ''; + Template.Variables.AddVariable('READONLY', s); + Template.Prepare; + Result := Template.TemplateStrings.Text; +end; + +constructor TfrxWebDateControl.Create; +begin + inherited; + FText := ''; + FSize := 10; + FMaxlength := 50; +end; + +destructor TfrxWebDateControl.Destroy; +begin + + inherited; +end; + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxServerForms.pas b/official/4.2/LibD11/frxServerForms.pas new file mode 100644 index 0000000..0654781 --- /dev/null +++ b/official/4.2/LibD11/frxServerForms.pas @@ -0,0 +1,239 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Server HTTP Forms } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerForms; + +{$I frx.inc} + +interface + +uses + Windows, Classes, SysUtils, Graphics, frxClass, frxDCtrl, frxUtils, + frxExportMatrix, frxServerFormControls, frxUnicodeUtils, frxServerTemplates; + +type + TfrxWebForm = class(Tobject) + private + Exp: TFileStream; + FMatrix: TfrxIEMatrix; + FDialog: TfrxDialogPage; + FRepName: String; + FSession: String; + procedure WriteExpLn(const str: string); + function GetHTML(Obj: TfrxDialogControl): String; + public + constructor Create(Dialog: TfrxDialogPage; Session: String); + destructor Destroy; override; + procedure Prepare; + procedure Clear; + procedure SaveFormToFile(FName: String); + property ReportName: String read FRepName write FRepName; + end; + +implementation + +{ TfrxWebForm } + +constructor TfrxWebForm.Create(Dialog: TfrxDialogPage; Session: String); +begin + FDialog := Dialog; + FSession := Session; + FMatrix := TfrxIEMatrix.Create(False, ''); + FMatrix.ShowProgress := False; + FMatrix.Inaccuracy := 10; + FMatrix.AreaFill := True; + FMatrix.FramesOptimization := False; +end; + +destructor TfrxWebForm.Destroy; +begin + Clear; + FMatrix.Free; + inherited; +end; + +procedure TfrxWebForm.Clear; +begin + FMatrix.Clear; +end; + +procedure TfrxWebForm.WriteExpLn(const str: string); +begin + if Length(str) > 0 then + begin + Exp.Write(str[1], Length(str)); + Exp.Write(#13#10, 2); + end; +end; + +procedure TfrxWebForm.Prepare; +var + i: Integer; +begin + for i := 0 to FDialog.AllObjects.Count - 1 do + FMatrix.AddDialogObject(FDialog.AllObjects[i]); + FMatrix.Prepare; +end; + +procedure TfrxWebForm.SaveFormToFile(FName: String); +var + i, x, y, fx, fy, dx, dy: Integer; + drow, dcol: Integer; + s, sb, st: String; //ss + obj: TfrxIEMObject; + FTemplate: TfrxServerTemplate; + +begin + FTemplate := TfrxServerTemplate.Create; + try + try + Exp := TFileStream.Create(FName, fmCreate); + try + FTemplate.SetTemplate('form_begin'); + FTemplate.Variables.AddVariable('TITLE', UTF8Encode(FDialog.Caption)); + FTemplate.Variables.AddVariable('HTML_INIT', ''); + FTemplate.Variables.AddVariable('HTML_CODE', ''); + FTemplate.Variables.AddVariable('REPORT', FRepName); + FTemplate.Variables.AddVariable('SESSION', FSession); + FTemplate.Variables.AddVariable('BCOLOR', HTMLRGBColor(FDialog.Color)); + FTemplate.Variables.AddVariable('COLSPAN', IntToStr(FMatrix.Width - 1)); + FTemplate.Variables.AddVariable('CAPTION', UTF8Encode(FDialog.Caption)); + FTemplate.Prepare; + st := FTemplate.TemplateStrings.Text; + WriteExpLn(st); + for y := 0 to FMatrix.Height - 2 do + begin + drow := Round(FMatrix.GetYPosById(y + 1) - FMatrix.GetYPosById(y)); + WriteExpLn(''); + for x := 0 to FMatrix.Width - 2 do + begin + i := FMatrix.GetCell(x, y); + if (i <> -1) then + begin + Obj := FMatrix.GetObjectById(i); + dcol := Round(Obj.Width); + if Obj.Counter = 0 then + begin + FMatrix.GetObjectPos(i, fx, fy, dx, dy); + Obj.Counter := 1; + if dx > 1 then + s := ' colspan="' + IntToStr(dx) + '"' + else s := ''; + if dy > 1 then + sb := ' rowspan="' + IntToStr(dy) + '"' + else sb := ''; + if Obj.Link = nil then + st := ' style="font-size:1px"' + else + st := ''; + WriteExpLn(''); + if Obj.Link <> nil then + WriteExpLn(GetHTML(TfrxDialogControl(Obj.Link))) + else + WriteExpLn(' '); + WriteExpLn(''); + end + end else + begin + dcol := Round(FMatrix.GetXPosById(x + 1) - FMatrix.GetXPosById(x)); + WriteExpLn(' '); + end + end; + WriteExpLn(''); + end; + FTemplate.SetTemplate('form_end'); + FTemplate.Variables.AddVariable('COLSPAN', IntToStr(FMatrix.Width - 1)); + FTemplate.Prepare; + WriteExpLn(FTemplate.TemplateStrings.Text); + finally + FlushFileBuffers(Exp.Handle); + Exp.Free; + end; + except + end; + finally + FTemplate.Free; + end +end; + +function TfrxWebForm.GetHTML(Obj: TfrxDialogControl): String; +var + wLabel: TfrxWebLabelControl; + wEdit: TfrxWebTextControl; + wButton: TfrxWebSubmitControl; + wRadio: TfrxWebRadioControl; + wCheckBox: TfrxWebCheckBoxControl; + wText: TfrxWebTextAreaControl; + wCombo: TfrxWebSelectControl; + wDate: TfrxWebDateControl; +begin + Result := ''; + if Obj is TfrxLabelControl then + begin + wLabel := TfrxWebLabelControl.Create; + wLabel.Assign(Obj); + Result := wLabel.HTML; + wLabel.Free; + end else + if Obj is TfrxEditControl then + begin + wEdit := TfrxWebTextControl.Create; + wEdit.Assign(Obj); + Result := wEdit.HTML; + wEdit.Free; + end else + if Obj is TfrxDateEditControl then + begin + wDate := TfrxWebDateControl.Create; + wDate.Assign(Obj); + Result := wDate.HTML; + wDate.Free; + end else + if Obj is TfrxButtonControl then + begin + wButton := TfrxWebSubmitControl.Create; + wButton.Assign(Obj); + Result := wButton.HTML; + wButton.Free; + end else + if Obj is TfrxRadioButtonControl then + begin + wRadio := TfrxWebRadioControl.Create; + wRadio.Assign(Obj); + Result := wRadio.HTML; + wRadio.Free; + end else + if Obj is TfrxCheckBoxControl then + begin + wCheckBox := TfrxWebCheckBoxControl.Create; + wCheckBox.Assign(Obj); + Result := wCheckBox.HTML; + wCheckBox.Free; + end else + if Obj is TfrxMemoControl then + begin + wText := TfrxWebTextAreaControl.Create; + wText.Assign(Obj); + Result := wText.HTML; + wText.Free; + end else + if Obj is TfrxComboBoxControl then + begin + wCombo:=TfrxWebSelectControl.Create; + wCombo.Assign(Obj); + Result := wCombo.HTML; + wCombo.Free; + end; + Result := UTF8Encode(Result); +end; + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxServerLog.pas b/official/4.2/LibD11/frxServerLog.pas new file mode 100644 index 0000000..851284d --- /dev/null +++ b/official/4.2/LibD11/frxServerLog.pas @@ -0,0 +1,398 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ HTTP Report Server Logs } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerLog; + +{$I frx.inc} + +interface + +uses + Windows, SysUtils, Classes, SyncObjs, frxUtils, frxServerUtils, frxNetUtils; + +type + TfrxServerLog = class(TThread) + private + FCurrentReports: Integer; + FCurrentSessions: Integer; + FErrorsCount: Integer; + FLevelFName: TStringList; + FLevels: TList; + FLogDir: String; + FLogging: Boolean; + FMaxReports: Integer; + FMaxReportTime: Integer; + FMaxSessions: Integer; + FTotalReports: Integer; + FTotalReportTime: Integer; + FTotalSessions: Integer; + FMaxLogSize: Integer; + FMaxLogFiles: Integer; + FCS: TCriticalSection; + FTotalCacheHits: Integer; + FThreadActive: Boolean; + procedure WriteFile(const FName: String; const Text: String); + procedure LogRotate(const FName: String); + protected + procedure Execute; override; + public + constructor Create; + destructor Destroy; override; + function AddLevel(const FileName: String): Integer; + procedure Clear; + procedure Flush; + procedure ErrorReached; + procedure StartAddReportTime(i: Integer); + procedure StatAddCurrentReport; + procedure StatAddCurrentSession; + procedure StatAddCacheHit; + procedure StatAddReports(i: Integer); + procedure StatAddSessions(i: Integer); + procedure StatRemoveCurrentReport; + procedure StatRemoveCurrentSession; + procedure Write(const Level: Integer; const Msg: String); + + property Active: Boolean read FLogging write FLogging; + property CurrentReports: Integer read FCurrentSessions write FCurrentReports; + property CurrentSessions: Integer read FCurrentSessions write FCurrentSessions; + property ErrorsCount: Integer read FErrorsCount write FErrorsCount; + property LogDir: String read FLogDir write FLogDir; + property MaxReports: Integer read FMaxReports write FMaxReports; + property MaxReportTime: Integer read FMaxReportTime write FMaxReportTime; + property MaxSessions: Integer read FMaxSessions write FMaxSessions; + property TotalReports: Integer read FTotalReports write FTotalReports; + property TotalReportTime: Integer read FTotalReportTime write FTotalReportTime; + property TotalSessions: Integer read FTotalSessions write FTotalSessions; + property MaxLogSize: Integer read FMaxLogSize write FMaxLogSize; + property MaxLogFiles: Integer read FMaxLogFiles write FMaxLogFiles; + property TotalCacheHits: Integer read FTotalCacheHits write FTotalCacheHits; + end; + +var + LogWriter: TfrxServerLog; + +const + ERROR_LEVEL = 0; + ACCESS_LEVEL = 1; + REFERER_LEVEL = 2; + AGENT_LEVEL = 3; + SERVER_LEVEL = 4; + +implementation + +{ TfrxServerLog } + +constructor TfrxServerLog.Create; +begin + inherited Create(True); + FLogging := False; + Priority := tpLowest; + FLevels := TList.Create; + FLevelFName := TStringList.Create; + FTotalSessions := 0; + FMaxSessions := 0; + FTotalReports := 0; + FMaxReports := 0; + FMaxReportTime := 0; + FTotalReportTime := 0; + FTotalCacheHits := 0; + FCurrentSessions := 0; + FCurrentReports := 0; + FErrorsCount := 0; + FCS := TCriticalSection.Create; + FThreadActive := False; + Resume; +end; + +destructor TfrxServerLog.Destroy; +begin + Clear; + Terminate; + while FThreadActive do + begin + Sleep(10); + PMessages; + end; + FLevels.Free; + FLevelFName.Free; + FCS.Free; + inherited; +end; + +procedure TfrxServerLog.Clear; +var + i: Integer; +begin + Flush; + for i := 0 to FLevels.Count - 1 do + TStringList(FLevels[i]).Free; + FLevels.Clear; + FLevelFName.Clear; +end; + +function TfrxServerLog.AddLevel(const FileName: String): Integer; +var + Level: TStringList; +begin + Level := TStringList.Create; + FLevels.Add(Level); + FLevelFName.Add(FileName); + Result := FLevels.Count - 1; +end; + +procedure TfrxServerLog.Write(const Level: Integer; const Msg: String); +begin + if Length(Msg) > 0 then + TStringList(FLevels[Level]).Add(Msg); +end; + +procedure TfrxServerLog.Execute; +var + i: Integer; +begin + FThreadActive := True; + while not Terminated do + begin + Flush; + i := 0; + while (not Terminated) and (i < 100) do + begin + Sleep(10); + Inc(i); + end; + end; + FThreadActive := False; +end; + +procedure TfrxServerLog.Flush; +var + i: Integer; + Level: TStringList; + Msg: String; +begin + FCS.Enter; + try + for i := 0 to FLevels.Count - 1 do + begin + Level := TStringList(FLevels[i]); + if (Level.Count > 0) then + begin + Msg := Level.Text; + Level.Clear; + if FLogging then + WriteFile(FLevelFName[i], Msg); + end; + end; + finally + FCS.Leave; + end; +end; + +procedure TfrxServerLog.WriteFile(const FName, Text: String); +var + FStream: TFileStream; + FSize: Extended; +begin + FSize := 0; + if FLogging and (Length(Trim(Text)) > 0) then + begin + if not FileExists(FLogDir + FName) then + begin + try + FStream := TFileStream.Create(FLogDir + FName, fmCreate); + FStream.Free; + except + FLogging := False; + end; + end; + try + FStream := TFileStream.Create(FLogDir + FName, fmOpenWrite + fmShareDenyWrite); + try + FStream.Seek(0, soFromEnd); + FStream.Write(Text[1], Length(Text)); + FSize := FStream.Size div 1024; + finally + FStream.Free; + if FSize > FMaxLogSize then + LogRotate(FLogDir + FName); + end; + except + FLogging := False; + end; + end; +end; + +procedure TfrxServerLog.StatAddReports(i: Integer); +begin + FCS.Enter; + try + FTotalReports := FTotalReports + i; + finally + FCS.Leave; + end; +end; + +procedure TfrxServerLog.StatAddSessions(i: Integer); +begin + FCS.Enter; + try + FTotalSessions := FTotalSessions + i; + finally + FCS.Leave; + end; +end; + +procedure TfrxServerLog.StartAddReportTime(i: Integer); +begin + FCS.Enter; + try + FTotalReportTime := FTotalReportTime + i; + if i > FMaxReportTime then + FMaxReportTime := i; + finally + FCS.Leave; + end; +end; + +procedure TfrxServerLog.StatAddCurrentReport; +begin + FCS.Enter; + try + FCurrentReports := FCurrentReports + 1; + if FCurrentReports > FMaxReports then + FMaxReports := FCurrentReports; + finally + FCS.Leave; + end; + StatAddReports(1); +end; + +procedure TfrxServerLog.StatAddCurrentSession; +begin + FCS.Enter; + try + FCurrentSessions := FCurrentSessions + 1; + if FCurrentSessions > FMaxSessions then + FMaxSessions := FCurrentSessions; + finally + FCS.Leave; + end; + StatAddSessions(1); +end; + +procedure TfrxServerLog.StatAddCacheHit; +begin + FCS.Enter; + try + Inc(FTotalCacheHits); + finally + FCS.Leave; + end; +end; + +procedure TfrxServerLog.StatRemoveCurrentReport; +begin + FCS.Enter; + try + FCurrentReports := FCurrentReports - 1; + finally + FCS.Leave; + end; +end; + +procedure TfrxServerLog.StatRemoveCurrentSession; +begin + FCS.Enter; + try + FCurrentSessions := FCurrentSessions - 1; + finally + FCS.Leave; + end; +end; + +procedure TfrxServerLog.ErrorReached; +begin + FCS.Enter; + try + Inc(FErrorsCount); + finally + FCS.Leave; + end; +end; + +procedure TfrxServerLog.LogRotate(const FName: String); +var + TmpStream: TFileStream; + OutStream: TFileStream; + i: Integer; + s: String; + FRotated: Boolean; +begin + FRotated := False; + if FMaxLogFiles > 1 then + begin + i := FMaxLogFiles - 1; + while i > 0 do + begin + s := ChangeFileExt(FName, '.log-' + IntToStr(i)); + if FileExists(s) then + if i < (FMaxLogFiles - 1) then + RenameFile(s, ChangeFileExt(s, '.log-' + IntToStr(i + 1))) + else + DeleteFile(s); + i := i - 1; + end; + RenameFile(FName, ChangeFileExt(FName, '.log-1')) + end + else begin + try + TmpStream := TFileStream.Create(FName, fmOpenRead + fmShareDenyWrite); + try + if TmpStream.Size > FMaxLogSize * 1024 then + begin + TmpStream.Position := TmpStream.Size - FMaxLogSize * 1024; + s := ' '; + while (s[1] <> #13) and (TmpStream.Position < TmpStream.Size) do + TmpStream.Read(s[1], 1); + if s[1] = #13 then + begin + TmpStream.Read(s[1], 1); + if s[1] = #10 then + begin + try + s := ChangeFileExt(FName, '.tmp'); + OutStream := TFileStream.Create(s, fmCreate); + try + OutStream.CopyFrom(TmpStream, TmpStream.Size - TmpStream.Position); + FRotated := True; + finally + OutStream.Free; + end; + except + end; + end; + end; + end; + finally + TmpStream.Free; + if FRotated then + begin + DeleteFile(FName); + RenameFile(s, FName); + end; + end; + except + end; + end; +end; + +end. diff --git a/official/4.2/LibD11/frxServerReports.pas b/official/4.2/LibD11/frxServerReports.pas new file mode 100644 index 0000000..676612c --- /dev/null +++ b/official/4.2/LibD11/frxServerReports.pas @@ -0,0 +1,740 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report Server engine } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerReports; + +{$I frx.inc} + +interface + +uses + Windows, SysUtils, Classes, frxClass, frxExportHTML, frxExportRTF, StdCtrls, + frxExportText, frxExportCSV, frxExportPDF, frxExportXML, frxExportImage, frxVariables, + frxXML, frxServerForms, frxServerCache, frxDCtrl, frxServerUtils, frxNetUtils, + frxUnicodeUtils, frxServerLog, frxExportODF; + +type + TfrxReportSession = class(TThread) + private + FPath: String; + FBasePath: String; + FSessionId: String; + FReportPath: String; + FPageRange: String; + FFormat: TfrxServerFormat; + FMainDocument: String; + FName: String; + FVariables: TfrxVariables; + FReportErrors: Boolean; + FError: String; + FResultPage: String; + FReport: TfrxReport; + FHTMLExport: TfrxHTMLExport; + FXMLExport: TfrxXMLExport; + FRTFExport: TfrxRTFExport; + FTXTExport: TfrxSimpleTextExport; + FJPGExport: TfrxJPEGExport; + FBMPExport: TfrxBMPExport; + FGIFExport: TfrxGIFExport; + FTIFFExport: TfrxTIFFExport; + FPDFExport: TfrxPDFExport; + FCSVExport: TfrxCSVExport; + FODSExport: TfrxODSExport; + FODTExport: TfrxODTExport; + FParentThread: TThread; + CurPage: TfrxDialogPage; + FParentReportServer: TComponent; + FCached: Boolean; + FNativeClient: Boolean; + FStream: TMemoryStream; + FCacheId: String; + FPassword: String; + FAuth: Boolean; + FMessage: String; + FPageNav: Boolean; + FMultipage: Boolean; + FUserLogin: String; + procedure DoError; + procedure DoFillForm; + procedure DoSaveForm; + procedure DoOnGetReport; + procedure ShowReportDialog(Page: TfrxDialogPage); + procedure DoAfterBuildReport; + function ExtractReportName(const FileName: String): String; + protected + procedure Execute; override; + public + Active: Boolean; + Continue: Boolean; + DialogActive: Boolean; + Readed: Boolean; + constructor Create; + destructor Destroy; override; + + property FileName: String read FName write FName; + property Format: TfrxServerFormat read FFormat write FFormat; + property IndexFileName: String read FMainDocument write FMainDocument; + property PageRange: String read FPageRange write FPageRange; + property ParentThread: TThread read FParentThread write FParentThread; + property ReportPath: String read FReportPath write FReportPath; + property ResultPage: String read FResultPage; + property RootPath: String read FBasePath write FBasePath; + property SessionId: String read FSessionId write FSessionId; + property CacheId: String read FCacheId write FCacheId; + property Variables: TfrxVariables read FVariables write FVariables; + property ParentReportServer: TComponent read FParentReportServer write FParentReportServer; + property NativeClient: Boolean read FNativeClient write FNativeClient; + property Stream: TMemoryStream read FStream write FStream; + property Password: String read FPassword write FPassword; + property Auth: Boolean read FAuth; + property ReportMessage: String read FMessage; + + property PageNav: Boolean read FPageNav write FPageNav; + property Multipage: Boolean read FMultipage write FMultipage; + property UserLogin: String read FUserLogin write FUserLogin; + end; + +implementation + +uses frxServer, frxXMLSerializer, frxServerConfig; + +{ TfrxReportSession } + +constructor TfrxReportSession.Create; +begin + inherited Create(True); + Active := True; + try + FReport := TfrxReport.Create(nil); + FReport.Engine.OnRunDialog := ShowReportDialog; + FReport.EngineOptions.SilentMode := True; + FReport.EngineOptions.EnableThreadSafe := True; + FReport.EngineOptions.UseFileCache := ServerConfig.GetBool('server.reports.usefilecache'); + FReport.EngineOptions.MaxMemSize := StrToInt(ServerConfig.CheckValue('server.reports.maxmemsize', '10')); + FReport.EngineOptions.TempDir := ServerConfig.CheckValue('server.reports.temp', ''); + FReport.ShowProgress := False; + except + FReport := nil; + FError := 'TfrxReport create error'; + DoError; + end; +end; + +destructor TfrxReportSession.Destroy; +begin + Terminate; + while DialogActive do + begin + Sleep(10); + PMessages; + end; + if Assigned(FReport) then + try + FReport.Free; + except + on e: Exception do + begin + FError := 'TfrxReport destroy error ' + e.Message; + DoError; + end; + end; + inherited; +end; + +procedure TfrxReportSession.Execute; +var + i: Integer; + VName: String; + VValue: Variant; + s: String; + FResPrep: Boolean; +begin + LogWriter.StatAddCurrentReport; + + FResultPage := ''; + DialogActive := False; + Readed := False; + FCached := True; + FAuth := False; + +// CoInitialize(nil); + + if Assigned(FReport) then + begin + FPath := FBasePath + FSessionId; + try + if Assigned(TfrxReportServer(FParentReportServer).OnGetReport) then + Synchronize(DoOnGetReport) + else + if FileExists(FName) then + try + FReport.LoadFromFile(FName) + except + end + else + begin + FError := 'Report not found: ' + FName; + DoError; + end; + except + FError := 'Report load error: ' + FName; + DoError; + end; + if FReport.ReportOptions.Password <> '' then + s := FPassword + else + s := ''; + if FReport.ReportOptions.Password = s then + begin + if Assigned(FVariables) then + begin + for i := 0 to FVariables.Count - 1 do + begin + VName := FVariables.Items[i].Name; + VValue := TfrxVariable(FVariables.Items[i]).Value; + VValue := '''' + StringReplace(UnQuoteStr(VValue), '''', '''''', [rfReplaceAll]) + ''''; + FReport.Variables[VName] := VValue; + end; + end; + + FReport.Variables['PathToDatabase'] := + '''' + frxGetAbsPathDir(ServerConfig.GetValue('server.database.pathtodatabase'), ServerConfig.ConfigFolder) + ''''; + FReport.ReportOptions.ConnectionName := ServerConfig.GetValue('server.database.connection'); + + if not ReportCache.GetCachedStream(FReport, ExtractReportName(FName), FReport.Variables, FCacheId) then + try + FResPrep := False; + try + FResPrep := FReport.PrepareReport; + except + end; + if FResPrep then + begin + if FCached then + ReportCache.AddReport(FReport, ExtractReportName(FName), FReport.Variables, '') + else + ReportCache.AddReport(FReport, ExtractReportName(FName), FReport.Variables, FSessionId); + end + else begin + FError := 'Report prepare error: ' + FReport.Errors.Text; + DoError; + end; + except + on e: Exception do + begin + FError := 'Report prepare exception: ' + FReport.Errors.Text + e.Message; + DoError; + end; + end; + + if Assigned(TfrxReportServer(FParentReportServer).OnAfterBuildReport) then + Synchronize(DoAfterBuildReport); + + if (not FReportErrors) and (not DialogActive) and (not Terminated) then + if (FFormat = sfXML) and (ServerConfig.GetBool('server.exports.xml.active')) then + begin + FXMLExport := TfrxXMLExport.Create(nil); + try + FXMLExport.ShowDialog := False; + FXMLExport.ShowProgress := False; + FXMLExport.PageNumbers := FPageRange; + FXMLExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FXMLExport.SuppressPageHeadersFooters := ServerConfig.GetBool('server.exports.xml.continuous'); + FXMLExport.EmptyLines := ServerConfig.GetBool('server.exports.xml.emptylines'); + FXMLExport.ExportPageBreaks := ServerConfig.GetBool('server.exports.xml.pagebreaks'); + FXMLExport.ExportStyles := ServerConfig.GetBool('server.exports.xml.styles'); + FXMLExport.Wysiwyg := ServerConfig.GetBool('server.exports.xml.wysiwyg'); + FXMLExport.Background := ServerConfig.GetBool('server.exports.xml.background'); + FResultPage := '\' + 'result.xml'; + FXMLExport.FileName := FPath + FResultPage; + try + FReport.Export(FXMLExport); + except + FError := 'XML export error'; + DoError; + end; + finally + FXMLExport.Free; + end + end else if (FFormat = sfXLS) and (ServerConfig.GetBool('server.exports.xml.active')) then + begin + FXMLExport := TfrxXMLExport.Create(nil); + try + FXMLExport.ShowDialog := False; + FXMLExport.ShowProgress := False; + FXMLExport.PageNumbers := FPageRange; + FXMLExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FXMLExport.SuppressPageHeadersFooters := ServerConfig.GetBool('server.exports.xml.continuous'); + FXMLExport.EmptyLines := ServerConfig.GetBool('server.exports.xml.emptylines'); + FXMLExport.ExportPageBreaks := ServerConfig.GetBool('server.exports.xml.pagebreaks'); + FXMLExport.ExportStyles := ServerConfig.GetBool('server.exports.xml.styles'); + FXMLExport.Wysiwyg := ServerConfig.GetBool('server.exports.xml.wysiwyg'); + FXMLExport.Background := ServerConfig.GetBool('server.exports.xml.background'); + FResultPage := '\' + 'result.xls'; + FXMLExport.FileName := FPath + FResultPage; + try + FReport.Export(FXMLExport); + except + FError := 'XLS export error'; + DoError; + end; + finally + FXMLExport.Free; + end +// + end else if (FFormat = sfODS) and (ServerConfig.GetBool('server.exports.ods.active')) then + begin + FODSExport := TfrxODSExport.Create(nil); + try + FODSExport.ShowDialog := False; + FODSExport.ShowProgress := False; + FODSExport.PageNumbers := FPageRange; + FODSExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FODSExport.SuppressPageHeadersFooters := ServerConfig.GetBool('server.exports.ods.continuous'); + FODSExport.EmptyLines := ServerConfig.GetBool('server.exports.ods.emptylines'); + FODSExport.ExportPageBreaks := ServerConfig.GetBool('server.exports.ods.pagebreaks'); + FODSExport.Wysiwyg := ServerConfig.GetBool('server.exports.ods.wysiwyg'); + FODSExport.Background := ServerConfig.GetBool('server.exports.ods.background'); + FResultPage := '\' + 'result.ods'; + FODSExport.FileName := FPath + FResultPage; + try + FReport.Export(FODSExport); + except + FError := 'ODS export error'; + DoError; + end; + finally + FODSExport.Free; + end + end else if (FFormat = sfODT) and (ServerConfig.GetBool('server.exports.odt.active')) then + begin + FODTExport := TfrxODTExport.Create(nil); + try + FODTExport.ShowDialog := False; + FODTExport.ShowProgress := False; + FODTExport.PageNumbers := FPageRange; + FODTExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FODTExport.SuppressPageHeadersFooters := ServerConfig.GetBool('server.exports.odt.continuous'); + FODTExport.EmptyLines := ServerConfig.GetBool('server.exports.odt.emptylines'); + FODTExport.ExportPageBreaks := ServerConfig.GetBool('server.exports.odt.pagebreaks'); + FODTExport.Wysiwyg := ServerConfig.GetBool('server.exports.odt.wysiwyg'); + FODTExport.Background := ServerConfig.GetBool('server.exports.odt.background'); + FResultPage := '\' + 'result.odt'; + FODTExport.FileName := FPath + FResultPage; + try + FReport.Export(FODTExport); + except + FError := 'ODT export error'; + DoError; + end; + finally + FODTExport.Free; + end +// + end else if (FFormat = sfRTF) and (ServerConfig.GetBool('server.exports.rtf.active')) then + begin + FRTFExport := TfrxRTFExport.Create(nil); + try + FRTFExport.ShowDialog := False; + FRTFExport.ShowProgress := False; + FRTFExport.PageNumbers := FPageRange; + FRTFExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FRTFExport.ExportPageBreaks := ServerConfig.GetBool('server.exports.rtf.pagebreaks'); + FRTFExport.ExportPictures := ServerConfig.GetBool('server.exports.rtf.pictures'); + FRTFExport.Wysiwyg := ServerConfig.GetBool('server.exports.rtf.wysiwyg'); + FResultPage := '\' + 'result.rtf'; + FRTFExport.FileName := FPath + FResultPage; + try + FReport.Export(FRTFExport); + except + FError := 'RTF export error'; + DoError; + end; + finally + FRTFExport.Free; + end + end else if (FFormat = sfCSV) and (ServerConfig.GetBool('server.exports.csv.active')) then + begin + FCSVExport := TfrxCSVExport.Create(nil); + try + FCSVExport.ShowDialog := False; + FCSVExport.ShowProgress := False; + FCSVExport.PageNumbers := FPageRange; + FCSVExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FCSVExport.OEMCodepage := ServerConfig.GetBool('server.exports.csv.oemcodepage'); + FCSVExport.Separator := ServerConfig.CheckValue('server.exports.csv.separator', ';'); + FResultPage := '\' + 'result.csv'; + FCSVExport.FileName := FPath + FResultPage; + try + FReport.Export(FCSVExport); + except + FError := 'CSV export error'; + DoError; + end; + finally + FCSVExport.Free; + end + end else if (FFormat = sfTXT) and (ServerConfig.GetBool('server.exports.txt.active')) then + begin + FTXTExport := TfrxSimpleTextExport.Create(nil); + try + FTXTExport.ShowDialog := False; + FTXTExport.ShowProgress := False; + FTXTExport.PageNumbers := FPageRange; + FTXTExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FTXTExport.PageBreaks := ServerConfig.GetBool('server.exports.txt.pagebreaks'); + FTXTExport.OEMCodepage := ServerConfig.GetBool('server.exports.txt.oemcodepage'); + FResultPage := '\' + 'result.txt'; + FTXTExport.FileName := FPath + FResultPage; + try + FReport.Export(FTXTExport); + except + FError := 'TXT export error'; + DoError; + end; + finally + FTXTExport.Free; + end + end else if (FFormat = sfJPG) and (ServerConfig.GetBool('server.exports.jpg.active')) then + begin + FJPGExport := TfrxJPEGExport.Create(nil); + try + FJPGExport.ShowDialog := False; + FJPGExport.PageNumbers := FPageRange; + FJPGExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FJPGExport.CropImages := ServerConfig.GetBool('server.exports.jpg.crop'); + FJPGExport.Monochrome := ServerConfig.GetBool('server.exports.jpg.monochrome'); + FJPGExport.JPEGQuality := StrToInt(ServerConfig.CheckValue('server.exports.jpg.quality', '80')); + FJPGExport.Resolution := StrToInt(ServerConfig.CheckValue('server.exports.jpg.resolution', '72')); + FJPGExport.SeparateFiles := not ServerConfig.GetBool('server.exports.jpg.singlefile'); + FResultPage := '\' + 'result.jpg'; + FJPGExport.FileName := FPath + FResultPage; + try + FReport.Export(FJPGExport); + except + FError := 'JPG export error'; + DoError; + end; + FResultPage := '\' + 'result.1.jpg'; + finally + FJPGExport.Free; + end + end else if (FFormat = sfBMP) and (ServerConfig.GetBool('server.exports.bmp.active')) then + begin + FBMPExport := TfrxBMPExport.Create(nil); + try + FBMPExport.ShowDialog := False; + FBMPExport.PageNumbers := FPageRange; + FBMPExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FBMPExport.CropImages := ServerConfig.GetBool('server.exports.bmp.crop'); + FBMPExport.Monochrome := ServerConfig.GetBool('server.exports.bmp.monochrome'); + FBMPExport.Resolution := StrToInt(ServerConfig.CheckValue('server.exports.bmp.resolution', '72')); + FBMPExport.SeparateFiles := not ServerConfig.GetBool('server.exports.bmp.singlefile'); + FResultPage := '\' + 'result.bmp'; + FBMPExport.FileName := FPath + FResultPage; + try + FReport.Export(FBMPExport); + except + FError := 'BMP export error'; + DoError; + end; + FResultPage := '\' + 'result.1.bmp'; + finally + FBMPExport.Free; + end + end else if (FFormat = sfGIF) and (ServerConfig.GetBool('server.exports.gif.active')) then + begin + FGIFExport := TfrxGIFExport.Create(nil); + try + FGIFExport.ShowDialog := False; + FGIFExport.PageNumbers := FPageRange; + FGIFExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FGIFExport.CropImages := ServerConfig.GetBool('server.exports.gif.crop'); + FGIFExport.Resolution := StrToInt(ServerConfig.CheckValue('server.exports.gif.resolution', '72')); + FGIFExport.SeparateFiles := not ServerConfig.GetBool('server.exports.gif.singlefile'); + FResultPage := '\' + 'result.gif'; + FGIFExport.FileName := FPath + FResultPage; + try + FReport.Export(FGIFExport); + except + FError := 'GIF export error'; + DoError; + end; + FResultPage := '\' + 'result.1.gif'; + finally + FGIFExport.Free; + end + end else if (FFormat = sfTIFF) and (ServerConfig.GetBool('server.exports.tiff.active')) then + begin + FTIFFExport := TfrxTIFFExport.Create(nil); + try + FTIFFExport.ShowDialog := False; + FTIFFExport.PageNumbers := FPageRange; + FTIFFExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FTIFFExport.CropImages := ServerConfig.GetBool('server.exports.tiff.crop'); + FTIFFExport.Monochrome := ServerConfig.GetBool('server.exports.tiff.monochrome'); + FTIFFExport.Resolution := StrToInt(ServerConfig.CheckValue('server.exports.tiff.resolution', '72')); + FTIFFExport.SeparateFiles := not ServerConfig.GetBool('server.exports.tiff.singlefile'); + FResultPage := '\' + 'result.tif'; + FTIFFExport.FileName := FPath + FResultPage; + try + FReport.Export(FTIFFExport); + except + FError := 'TIFF export error'; + DoError; + end; + FResultPage := '\' + 'result.1.tif'; + finally + FTIFFExport.Free; + end + end else if (FFormat = sfPDF) and (ServerConfig.GetBool('server.exports.pdf.active')) then + begin + FPDFExport := TfrxPDFExport.Create(nil); + try + FPDFExport.ShowDialog := False; + FPDFExport.PageNumbers := FPageRange; + FPDFExport.EmbeddedFonts := ServerConfig.GetBool('server.exports.pdf.embeddedfonts'); + FResultPage := '\' + 'result.pdf'; + FPDFExport.FileName := FPath + FResultPage; + FPDFExport.Background := ServerConfig.GetBool('server.exports.pdf.background'); + FPDFExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FPDFExport.Outline := ServerConfig.GetBool('server.exports.pdf.outline') and FReport.PreviewOptions.OutlineVisible; + FPDFExport.HTMLTags := ServerConfig.GetBool('server.exports.pdf.htmltags'); + FPDFExport.PrintOptimized := ServerConfig.GetBool('server.exports.pdf.printoptimized'); + try + FReport.Export(FPDFExport); + except + FError := 'PDF export error'; + DoError; + end; + finally + FPDFExport.Free; + end + end else if (FFormat = sfFRP) and (ServerConfig.GetBool('server.exports.fp3.active')) then + begin + FResultPage := '\' + 'result.fp3'; + try + FReport.PreviewPages.SaveToFile(FPath + FResultPage); + except + FError := 'FP3 save error ' + FReport.Errors.Text; + DoError; + end + end else + if (ServerConfig.GetBool('server.exports.html.active')) then + begin + FHTMLExport := TfrxHTMLExport.Create(nil); + try + FHTMLExport.ShowDialog := False; + FHTMLExport.ShowProgress := False; + FHTMLExport.AbsLinks := True; + FHTMLExport.Server := True; + FHTMLExport.PageNumbers := FPageRange; + FHTMLExport.FixedWidth := ServerConfig.GetBool('server.exports.html.fixedwidth'); + FHTMLExport.PicsInSameFolder := ServerConfig.GetBool('server.exports.html.allinonefolder'); + FHTMLExport.Multipage := FMultipage; + FHTMLExport.Navigator := FPageNav; + s := ServerConfig.GetValue('server.exports.html.picsformat'); + FHTMLExport.UseJpeg := s = 'jpeg'; + FHTMLExport.UseGif := s = 'gif'; + FHTMLExport.ExportPictures := ServerConfig.GetBool('server.exports.html.pictures'); + FHTMLExport.ExportStyles := ServerConfig.GetBool('server.exports.html.styles'); + FHTMLExport.Background := ServerConfig.GetBool('server.exports.html.background'); + FHTMLExport.UseFileCache := FReport.EngineOptions.UseFileCache; + FHTMLExport.ReportPath := frxGetAbsPathDir(ServerConfig.GetValue('server.reports.path'), ServerConfig.ConfigFolder); + if Assigned(FParentReportServer) then + if TfrxReportServer(FParentReportServer).PrintPDF then + FHTMLExport.PrintLink := 'result?report=' + Str2HTML(ExtractReportName(FName)) + + '&format=PDF&pagerange=' + FPageRange + + '&cacheid=' + FSessionId; + + FHTMLExport.RefreshLink := 'result?report=' + Str2HTML(ExtractReportName(FName)) + '&multipage=' + IntToStr(ord(FHTMLExport.Multipage)); + + if Assigned(FVariables) then + begin + for i := 0 to FVariables.Count - 1 do + FHTMLExport.PrintLink := FHTMLExport.PrintLink + '&' + + UnQuoteStr(Str2HTML(FVariables.Items[i].Name)) + '=' + + UnQuoteStr(Str2HTML(FVariables.Items[i].Value)); + for i := 0 to FVariables.Count - 1 do + FHTMLExport.RefreshLink := FHTMLExport.RefreshLink + '&' + + UnQuoteStr(Str2HTML(FVariables.Items[i].Name)) + '=' + + UnQuoteStr(Str2HTML(FVariables.Items[i].Value)); + end; + + s := ServerConfig.GetValue('server.http.indexfile'); + FResultPage := '\' + s; + FHTMLExport.FileName := FPath + FResultPage; + try + FReport.Export(FHTMLExport); + if (not FHTMLExport.Navigator) and FHTMLExport.Multipage then + FResultPage := '\' + ChangeFileExt(s, '.1.html') + except + FError := 'HTML export error'; + DoError; + end; + finally + FHTMLExport.Free; + end + end; + end + else + begin + FAuth := True; + FReport.Errors.Add('Authentification required') + end; + end; + FMessage := FReport.Errors.Text; + Active := False; + LogWriter.StatRemoveCurrentReport; + Sleep(3000); +end; + +procedure TfrxReportSession.DoError; +begin + FReportErrors := True; + LogWriter.Write(ERROR_LEVEL, DateTimeToStr(Now) + #9 + FSessionId + #9'report session error: ' + FError); + LogWriter.ErrorReached; +end; + +procedure TfrxReportSession.ShowReportDialog(Page: TfrxDialogPage); +begin + CurPage := Page; + FCached := False; + DoSaveForm; + Continue := False; + DialogActive := True; + FReport.DoNotifyEvent(Page, Page.OnActivate); + while (not Continue) and (not Terminated) do + PMessages; + DoFillForm; + DialogActive := False; + FReport.DoNotifyEvent(Page, Page.OnDeactivate); + while (not Readed) and (not Terminated) do + PMessages; + Sleep(300); +end; + +procedure TfrxReportSession.DoFillForm; +var + i, j: Integer; + Control: TfrxDialogControl; + s: String; + Reader: TfrxXMLSerializer; +begin + if FNativeClient and (FStream.Size > 0) then + begin + FStream.Position := 0; + Reader := TfrxXMLSerializer.Create(FStream); + try + Reader.Owner := FReport; + try + Reader.ReadRootComponent(CurPage, nil); + except + end; + finally + Reader.Free; + end + end + else if (not Terminated) and Assigned(FVariables) then + begin + for i := 0 to CurPage.AllObjects.Count - 1 do + begin + Control := TfrxDialogControl(CurPage.AllObjects[i]); + if Control.Parent <> nil then + s := Control.Parent.Name + '_' + Control.Name + else + s:= Control.Name; + j := FVariables.IndexOf(s); + if (j = -1) and (Control.Parent <> nil) and (Pos('_', s) > 0) then + j := FVariables.IndexOf(Control.Parent.Name); + if j <> -1 then + begin + s := FVariables.Items[j].Value; + s := UnQuoteStr(s); + if Control is TfrxEditControl then + TfrxEditControl(Control).Text := s; + if Control is TfrxDateEditControl then + TfrxDateEditControl(Control).Date := StrToDate(s); + if (Control is TfrxCheckBoxControl) then + begin + if (Pos(Control.Name, s) > 0) then + TfrxCheckBoxControl(Control).Checked := True + else + TfrxCheckBoxControl(Control).Checked := False; + end; + if (Control is TfrxRadioButtonControl) then + begin + if (Pos(Control.Name, s) > 0) then + TfrxRadioButtonControl(Control).Checked := True + else + TfrxRadioButtonControl(Control).Checked := False; + end; + if Control is TfrxMemoControl then + TfrxMemoControl(Control).Text := s; + if Control is TfrxComboBoxControl then + TfrxComboBoxControl(Control).ItemIndex := StrToInt(s); + end else + begin + if Control is TfrxCheckBoxControl then + TfrxCheckBoxControl(Control).Checked := False; + if Control is TfrxRadioButtonControl then + TfrxRadioButtonControl(Control).Checked := False; + end; + end; + end; +end; + +procedure TfrxReportSession.DoSaveForm; +var + WebForm: TfrxWebForm; + f: TFileStream; +begin + if not FNativeClient then + begin + WebForm := TfrxWebForm.Create(CurPage, FSessionId); + try + WebForm.ReportName := ExtractReportName(FReport.FileName); + WebForm.Prepare; + FResultPage := '\' + 'form.html'; + WebForm.SaveFormToFile(FPath + FResultPage); + finally + WebForm.Free; + end; + end + else begin + FResultPage := '\' + 'result.frm'; + f := TFileStream.Create(FPath + FResultPage, fmCreate); + try + CurPage.SaveToStream(f); + finally + FlushFileBuffers(f.Handle); + f.Free; + end; + end; +end; + +procedure TfrxReportSession.DoOnGetReport; +begin + TfrxReportServer(FParentReportServer).OnGetReport(ExtractReportName(FName), FReport, FUserLogin); +end; + +procedure TfrxReportSession.DoAfterBuildReport; +begin + TfrxReportServer(ParentReportServer).OnAfterBuildReport(FName, FVariables, FUserLogin); +end; + +function TfrxReportSession.ExtractReportName(const FileName: String): String; +begin + Result := StringReplace(FileName, frxGetAbsPathDir(ServerConfig.GetValue('server.reports.path'), ServerConfig.ConfigFolder), '', []) +end; + +end. diff --git a/official/4.2/LibD11/frxServerReportsList.pas b/official/4.2/LibD11/frxServerReportsList.pas new file mode 100644 index 0000000..11d10b7 --- /dev/null +++ b/official/4.2/LibD11/frxServerReportsList.pas @@ -0,0 +1,222 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ } +{ List of available reports } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerReportsList; + +{$I frx.inc} + +interface + +uses + SysUtils, Classes, frxClass, frxServerTemplates; + +type + TfrxServerReportsListItem = class (TCollectionItem) + private + FFileName: String; + FDescription: String; + FName: String; + public + constructor Create(Collection: TCollection); override; + destructor Destroy; override; + published + property FileName: String read FFileName write FFileName; + property ReportName: String read FName write FName; + property Description: String read FDescription write FDescription; + end; + + TfrxServerReportsList = class (TCollection) + private + FReportsPath: String; + Report: TfrxReport; + FHtml: String; + FLines: TStrings; + function GetItems(Index: Integer): TfrxServerReportsListItem; + procedure BuildListInFolder(const Folder: String); + public + constructor Create; + destructor Destroy; override; + property Items[Index: Integer]: TfrxServerReportsListItem read GetItems; + procedure BuildListOfReports; + published + function Add: TfrxServerReportsListItem; + property ReportsPath: String read FReportsPath write FReportsPath; + property Html: String read FHtml; + property Lines: TStrings read FLines; + end; + +implementation + +uses frxServerUtils, frxNetUtils; + +{ TfrxServerReportsList } + +function TfrxServerReportsList.Add: TfrxServerReportsListItem; +begin + Result := TfrxServerReportsListItem.Create(Self); +end; + +procedure TfrxServerReportsList.BuildListInFolder(const Folder: String); +var + SRec: TSearchRec; + i: Integer; + s: String; + List: TStringList; + ListFolders: TStringList; +begin + List := TStringList.Create; + ListFolders := TStringList.Create; + try + i := FindFirst(FReportsPath + Folder + '*.*', faDirectory + faArchive, SRec); + try + while i = 0 do + begin + if (SRec.Name <> '.') and (SRec.Name <> '..') then + begin + if (LowerCase(ExtractFileExt(SRec.Name)) = '.fr3') then + List.Add(Folder + SRec.Name) + else + if (SRec.Attr and faDirectory) = faDirectory then + ListFolders.Add(SRec.Name); + end; + i := FindNext(SRec); + PMessages; + end; + finally + FindClose(SRec); + end; + ListFolders.Sort; + for i := 0 to ListFolders.Count - 1 do + BuildListInFolder(Folder + ListFolders[i] + '\'); + List.Sort; + + for i := 0 to List.Count - 1 do + begin + Report := TfrxReport.Create(nil); + try + Report.ReportOptions.Info := True; + Report.ShowProgress :=False; + Report.EngineOptions.SilentMode := True; + try + Report.LoadFromFile(FReportsPath + List[i]); + except + end; + with Add do + begin + if Report.ReportOptions.Name = '' then + begin + s := ExtractFileName(List[i]); + SetLength(s, Length(s) - 4); + ReportName := s; + end + else + ReportName := Report.ReportOptions.Name; + Description := Report.ReportOptions.Description.Text; + FileName := List[i]; + end; + finally + Report.Free; + end; + PMessages; + end; + finally + List.Free; + ListFolders.Free; + end; +end; + +procedure TfrxServerReportsList.BuildListOfReports; +var + i: Integer; + s, t: String; + FTemplate: TfrxServerTemplate; +begin + FTemplate := TfrxServerTemplate.Create; + try + Clear; + FLines.Clear; + if DirectoryExists(FReportsPath) then + BuildListInFolder(''); + FTemplate.SetTemplate('list_begin'); + FTemplate.Prepare; + FHtml := FTemplate.TemplateStrings.Text; + FTemplate.Clear; + s := ''; + t := ''; + for i := 0 to Count - 1 do + begin + if Pos('\', Items[i].FileName) > 0 then + begin + s := StringReplace(StringReplace(Items[i].FileName, + ExtractFileName(Items[i].FileName), '', + [rfReplaceAll]), '\', ' ', [rfReplaceAll]); + if s <> t then + begin + FTemplate.SetTemplate('list_header'); + FTemplate.Variables.AddVariable('HEADER', s); + FTemplate.Prepare; + FHtml := FHtml + FTemplate.TemplateStrings.Text; + FTemplate.Clear; + t := s; + end; + end; + FTemplate.SetTemplate('list_line'); + FTemplate.Variables.AddVariable('FILE', items[i].FileName); + FTemplate.Variables.AddVariable('NAME', items[i].ReportName); + FTemplate.Variables.AddVariable('DESCRIPTION', Items[i].Description); + FTemplate.Prepare; + FHtml := FHtml + FTemplate.TemplateStrings.Text; + FTemplate.Clear; + FLines.Add(items[i].ReportName); + FLines.Add(items[i].FileName); + FLines.Add(StringReplace(items[i].Description, #13#10, ' ', [rfReplaceAll])); + end; + FTemplate.SetTemplate('list_end'); + FTemplate.Prepare; + FHtml := FHtml + FTemplate.TemplateStrings.Text; + finally + FTemplate.Free; + end; +end; + +constructor TfrxServerReportsList.Create; +begin + inherited Create(TfrxServerReportsListItem); + ReportsPath := ''; + FLines := TStringList.Create; +end; + +destructor TfrxServerReportsList.Destroy; +begin + FLines.Free; + Clear; + inherited; +end; + +function TfrxServerReportsList.GetItems(Index: Integer): TfrxServerReportsListItem; +begin + Result := TfrxServerReportsListItem(inherited Items[Index]); +end; + +{ TfrxServerReportsListItem } + +constructor TfrxServerReportsListItem.Create(Collection: TCollection); +begin + inherited Create(Collection); +end; + +destructor TfrxServerReportsListItem.Destroy; +begin + inherited; +end; + +end. diff --git a/official/4.2/LibD11/frxServerSSI.pas b/official/4.2/LibD11/frxServerSSI.pas new file mode 100644 index 0000000..da2a5b1 --- /dev/null +++ b/official/4.2/LibD11/frxServerSSI.pas @@ -0,0 +1,192 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Server SSI support } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerSSI; + +{$I frx.inc} + +interface + +uses Classes, SysUtils, frxServerVariables; + +type + TfrxSSIStream = class; + + TfrxSSIStream = class(TMemoryStream) + private + FBasePath: String; + FTempStream: TMemoryStream; + FVariables: TfrxServerVariables; + function ParseVarName(VarPos: Integer; VarLen: Integer; Src: PChar): String; + function SearchSign(const Sign: String; Src: PChar; StartPos: Integer; + Len: Integer): Integer; + public + constructor Create; + destructor Destroy; override; + procedure Prepare; + + property BasePath: String read FBasePath write FBasePath; + property Variables: TfrxServerVariables read FVariables write FVariables; + end; + +implementation + + +{ TfrxSSIStream } + +constructor TfrxSSIStream.Create; +begin + FTempStream := TMemoryStream.Create; + FBasePath := '.\'; +end; + +destructor TfrxSSIStream.Destroy; +begin + FTempStream.Free; + inherited; +end; + +function TfrxSSIStream.ParseVarName(VarPos: Integer; + VarLen: Integer; Src: PChar): String; +var + i: Integer; +begin + Result := ''; + i := 0; + while (Src[VarPos + i] <> '"') and (i <= VarLen) do + i := i + 1; + i := i + 1; + while (Src[VarPos + i] <> '"') and (i <= VarLen) do + begin + Result := Result + Src[VarPos + i]; + i := i + 1; + end; +end; + +procedure TfrxSSIStream.Prepare; +var + BegPos, EndPos, SignPos, delta, StreamPos: Integer; + BufPos: PChar; + Sign, VarName, Value: String; + FileStream: TFileStream; + InsideSSI: TfrxSSIStream; +begin + FTempStream.Clear; + FTempStream.CopyFrom(Self, 0); + Clear; + BegPos := 0; + StreamPos := 0; + FTempStream.Position := 0; + delta := 1; + while BegPos >= 0 do + begin + BegPos := SearchSign('', FTempStream.Memory, BegPos + 5, + FTempStream.Size - BegPos); + if EndPos >=0 then + begin + Sign := 'echo var'; + SignPos := SearchSign(Sign, FTempStream.Memory, BegPos + 5, + EndPos - BegPos); + if SignPos >= 0 then + begin + VarName := ParseVarName(SignPos, EndPos - SignPos, + FTempStream.Memory); + Value := FVariables.GetValue(VarName); + if Length(Value) > 0 then + Write(Value[1], Length(Value)); + StreamPos := EndPos + 3; + end else + begin + Sign := 'include virtual'; + SignPos := SearchSign(Sign, FTempStream.Memory, BegPos + 5, + EndPos - BegPos); + if SignPos >= 0 then + begin + VarName := ParseVarName(SignPos, EndPos - SignPos, + FTempStream.Memory); + if FileExists(FBasePath + VarName) then + begin + try + FileStream := TFileStream.Create(FBasePath + VarName, + fmOpenRead); + try + InsideSSI := TfrxSSIStream.Create; + try + InsideSSI.Variables := FVariables; + InsideSSI.BasePath := FBasePath; + InsideSSI.CopyFrom(FileStream, 0); + InsideSSI.Prepare; + CopyFrom(InsideSSI, 0); + finally + InsideSSI.Free; + end; + finally + FileStream.Free; + end; + except + end; + end; + end; + StreamPos := EndPos + 3; + end; + delta := EndPos - BegPos + 3; + end else + break; + end else + break; + BegPos := BegPos + delta; + end; + if StreamPos < FTempStream.Size then + begin + BufPos := PChar(FTempStream.Memory) + StreamPos; + Write(BufPos^, FTempStream.Size - StreamPos); + end; + Position := 0; +end; + +function TfrxSSIStream.SearchSign(const Sign: String; Src: PChar; + StartPos: Integer; Len: Integer): Integer; +var + i, j, r: Integer; +begin + i := 0; + r := -1; + while i < len do + if Src[StartPos + i] = Sign[1] then + begin + r := i; + j := 1; + while (Src[StartPos + i] = Sign[j]) and (i <= len) and + (j < (Length(Sign))) do + begin + i := i + 1; + j := j + 1; + end; + if (j = Length(Sign)) and ((Src[StartPos + i] = Sign[j])) then + break + else + r := -1 + end else + i := i + 1; + if r >= 0 then + Result := StartPos + r + else + Result := -1; +end; + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxServerSessionManager.pas b/official/4.2/LibD11/frxServerSessionManager.pas new file mode 100644 index 0000000..82e97d3 --- /dev/null +++ b/official/4.2/LibD11/frxServerSessionManager.pas @@ -0,0 +1,400 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ HTTP Report Server Session Manager } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerSessionManager; + +{$I frx.inc} + +interface + +uses + Windows, SysUtils, Classes, Forms, ScktComp, frxServerReports; + +type + TfrxSessionItem = class(TObject) + private + FActive: Boolean; + FCompleted: Boolean; + FName: String; + FReportThread: TfrxReportSession; + FSessionId: String; + FSocket: TCustomWinSocket; + FTimeComplete: TDateTime; + FTimeCreated: TDateTime; + public + constructor Create; + destructor Destroy; override; + + property Active: Boolean read FActive write FActive; + property SessionId: String read FSessionId write FSessionId; + property Socket: TCustomWinSocket read FSocket write FSocket; + property Completed: Boolean read FCompleted write FCompleted; + property TimeCreated: TDateTime read FTimeCreated write FTimeCreated; + property TimeComplete: TDateTime read FTimeComplete write FTimeComplete; + property FileName: String read FName write FName; + property ReportThread: TfrxReportSession read FReportThread + write FReportThread; + end; + + TfrxSessionManager = class(TThread) + private + FCleanUpTimeOut: Integer; + FSession: TfrxSessionItem; + FSessionList: TList; + FSessionPath: String; + FShutDown: Boolean; + FThreadActive: Boolean; + function CleanUpSession(SessionId: String): Boolean; + procedure Clear; + procedure DeleteSession; + procedure DeleteSessionFolder(const DirName: String); + procedure SetSessionPath(const Value: String); + function GetCount: Integer; + protected + procedure Execute; override; + public + constructor Create; + destructor Destroy; override; + function AddSession(SessionId: String; + Socket: TCustomWinSocket): TfrxSessionItem; + procedure CompleteSession(Socket: TCustomWinSocket); + procedure CompleteSessionId(SessionId: String); + function FindSessionBySocket(Socket: TCustomWinSocket): TfrxSessionItem; + function FindSessionById(SessionId: String): TfrxSessionItem; + procedure CleanUp; + + property CleanUpTimeOut: Integer read FCleanUpTimeOut write FCleanUpTimeOut; + property SessionPath: String read FSessionPath write SetSessionPath; + property Count: Integer read GetCount; + end; + + TfrxOldSessionsCleanupThread = class(TThread) + private + FPath: String; + protected + procedure Execute; override; + public + constructor Create(const Dir: String); + public + property Path: String read FPath write FPath; + end; + +var + SessionManager: TfrxSessionManager; + +implementation + +uses frxServer, frxFileUtils, frxServerUtils, frxNetUtils, frxServerConfig; + +{ TfrxSessionItem } + +constructor TfrxSessionItem.Create; +begin + FSessionId := ''; + FName := ''; + FSocket := nil; + FCompleted := False; + FTimeCreated := Now; + FTimeComplete := 0; +end; + +destructor TfrxSessionItem.Destroy; +begin + if FReportThread <> nil then + ReportThread.Terminate; + PMessages; + inherited; +end; + +{ TfrxSessionManager } + +constructor TfrxSessionManager.Create; +begin + inherited Create(True); + FSessionList := TList.Create; + FCleanUpTimeOut := StrToInt(ServerConfig.GetValue('server.http.sessiontimeout')); + SessionPath := frxGetAbsPathDir(ServerConfig.GetValue('server.http.rootpath'), ServerConfig.ConfigFolder); + Priority := tpLowest; + FShutDown := False; + Resume; +end; + +destructor TfrxSessionManager.Destroy; +begin + Terminate; + while FThreadActive do + begin + Sleep(10); + PMessages; + end; + Clear; + FSessionList.Free; + inherited; +end; + +function TfrxSessionManager.AddSession(SessionId: String; + Socket: TCustomWinSocket): TfrxSessionItem; +var + Session: TfrxSessionItem; +begin + Session := TfrxSessionItem.Create; + Session.SessionId := SessionId; + Session.Socket := Socket; + Session.FReportThread := nil; + FSessionList.Add(Session); + Result := Session; +end; + +function TfrxSessionManager.CleanUpSession(SessionId: String): Boolean; +var + DirName: String; + Approved: Boolean; + i: Integer; + Session: TfrxSessionItem; + t, t1: TDateTime; +begin + Result := False; + Approved := True; + if not FShutDown then + begin + t1 := FCleanUpTimeOut / 100000; + for i := 0 to FSessionList.Count - 1 do + begin + if i < FSessionList.Count then + begin + Session := TfrxSessionItem(FSessionList[i]); + t := Now; + if (t < (Session.TimeComplete + t1)) and + (Pos(SessionId, Session.FName) > 0) then + begin + Approved := False; + break; + end; + end; + end; + end; + DirName := FSessionPath + SessionId; + if Approved then + begin + DeleteSessionFolder(DirName); + Result := True; + end; +end; + +procedure TfrxSessionManager.CompleteSession(Socket: TCustomWinSocket); +var + Session: TfrxSessionItem; +begin + Session := FindSessionBySocket(Socket); + if Session <> nil then + begin + Session.Completed := True; + Session.TimeComplete := Now; + end; +end; + +procedure TfrxSessionManager.CompleteSessionId(SessionId: String); +var + Session: TfrxSessionItem; +begin + Session := FindSessionById(SessionId); + if Session <> nil then + begin + Session.Completed := True; + Session.TimeComplete := Now; + end; +end; + +procedure TfrxSessionManager.DeleteSession; +var + i: Integer; +begin + i := FSessionList.IndexOf(FSession); + if i <> -1 then + begin + if CleanUpSession(TfrxSessionItem(FSessionList[i]).SessionId) then + begin + TfrxSessionItem(FSessionList[i]).Free; + FSessionList.Delete(i); + end; + end; +end; + +procedure TfrxSessionManager.Execute; +var + i: Integer; +begin + FThreadActive := True; + while not Terminated do + begin + i := 0; + CleanUp; + while (not Terminated) and (i < 1000) do + begin + Inc(i); + Sleep(10); + PMessages; + end; + end; + FThreadActive := False; +end; + +function TfrxSessionManager.FindSessionById(SessionId: String): TfrxSessionItem; +var + i: Integer; + Session: TfrxSessionItem; +begin + Result := nil; + for i := 0 to FSessionList.Count - 1 do + begin + Session := TfrxSessionItem(FSessionList[i]); + if Session.FSessionId = SessionId then + begin + Result := Session; + break; + end + end; +end; + +function TfrxSessionManager.FindSessionBySocket(Socket: TCustomWinSocket): TfrxSessionItem; +var + i: Integer; + Session: TfrxSessionItem; +begin + Result := nil; + for i := 0 to FSessionList.Count - 1 do + begin + Session := TfrxSessionItem(FSessionList[i]); + if Session.Socket = Socket then + begin + Result := Session; + break; + end + end; +end; + +procedure TfrxSessionManager.Clear; +var + i: Integer; +begin + FShutDown := True; + for i := 0 to FSessionList.Count - 1 do + begin + if i < FSessionList.Count then + CleanUpSession(TfrxSessionItem(FSessionList[i]).SessionId); + if i < FSessionList.Count + then TfrxSessionItem(FSessionList[i]).Free; + Application.ProcessMessages; + end; + FSessionList.Clear; + FShutDown := False; +end; + +procedure TfrxSessionManager.DeleteSessionFolder(const DirName: String); +var + SearchRec: TSearchRec; + i: Integer; +begin + if DirectoryExists(DirName) and (Pos(SID_SIGN, DirName) > 0) then + begin + i := FindFirst(DirName + '\*.*', 0, SearchRec); + try + while i = 0 do + begin + try + DeleteFile(PChar(DirName + '\' + SearchRec.Name)); + except + end; + i := FindNext(SearchRec); + PMessages; + end; + finally + FindClose(SearchRec); + end; + try + RemoveDirectory(PChar(DirName)); + except + end; + end; +end; + +procedure TfrxSessionManager.SetSessionPath(const Value: String); +begin + FSessionPath := Value; + TfrxOldSessionsCleanupThread.Create(FSessionPath); +end; + +procedure TfrxSessionManager.CleanUp; +var + i, j: Integer; + t, t1: TDateTime; +begin + i := 0; + t1 := FCleanUpTimeOut / 100000; + j := 30; + while (i < FSessionList.Count) and (j > 0) do + begin + FSession := TfrxSessionItem(FSessionList[i]); + t := Now; + if Assigned(FSession) and FSession.Completed then + if t > (FSession.FTimeComplete + t1) then + begin + DeleteSession; + Dec(j); + end + else Inc(i) + else Inc(i); + end; +end; + +function TfrxSessionManager.GetCount: Integer; +begin + Result := FSessionList.Count; +end; + +{ TfrxOldSessionsCleanupThread } + +constructor TfrxOldSessionsCleanupThread.Create(const Dir: String); +begin + inherited Create(True); + FPath := Dir; + FreeOnTerminate := True; + Resume; +end; + +procedure TfrxOldSessionsCleanupThread.Execute; +var + SearchRec: TSearchRec; + i: Integer; +begin + if DirectoryExists(FPath) and (not Terminated) then + begin + i := FindFirst(FPath + SID_SIGN + '*', faDirectory , SearchRec); + try + while (i = 0) and not Terminated do + begin + try + DeleteFolder(FPath + SearchRec.Name); + except + end; + i := FindNext(SearchRec); + PMessages; + end; + finally + FindClose(SearchRec); + end; + end; +end; + + +end. + diff --git a/official/4.2/LibD11/frxServerStat.pas b/official/4.2/LibD11/frxServerStat.pas new file mode 100644 index 0000000..1b7dfd5 --- /dev/null +++ b/official/4.2/LibD11/frxServerStat.pas @@ -0,0 +1,146 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ HTTP Report Server Statistic } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerStat; + +{$I frx.inc} + +interface + +uses + SysUtils, Classes; + +type + TfrxServerStatistic = class(TPersistent) + private + FStartTime: TDateTime; + function GetCurrentReportsCount: Integer; + function GetCurrentSessionsCount: Integer; + function GetMaxReportsCount: Integer; + function GetMaxSessionsCount: Integer; + function GetTotalErrors: Integer; + function GetTotalReportsCount: Integer; + function GetTotalSessionsCount: Integer; + function GetUpTimeDays: Integer; + function GetUpTimeHours: Integer; + function GetUpTimeMins: Integer; + function GetUpTimeSecs: Integer; + function GetTotalCacheHits: Integer; + function GetFormatUpTime: String; + function GetCacheCount: Integer; + public + constructor Create; + published + property CurrentReportsCount: Integer read GetCurrentReportsCount; + property CurrentSessionsCount: Integer read GetCurrentSessionsCount; + property MaxReportsCount: Integer read GetMaxReportsCount; + property MaxSessionsCount: Integer read GetMaxSessionsCount; + property TotalErrors: Integer read GetTotalErrors; + property TotalReportsCount: Integer read GetTotalReportsCount; + property TotalSessionsCount: Integer read GetTotalSessionsCount; + property UpTimeDays: Integer read GetUpTimeDays; + property UpTimeHours: Integer read GetUpTimeHours; + property UpTimeMins: Integer read GetUpTimeMins; + property UpTimeSecs: Integer read GetUpTimeSecs; + property TotalCacheHits: Integer read GetTotalCacheHits; + property CurrentCacheCount: Integer read GetCacheCount; + property FormatUpTime: String read GetFormatUpTime; + end; + +var + ServerStatistic: TfrxServerStatistic; + +implementation + +uses frxServer, frxServerLog, frxServerCache; + +{ TfrxServerStatistic } + +function TfrxServerStatistic.GetCurrentReportsCount: Integer; +begin + Result := LogWriter.CurrentReports; +end; + +function TfrxServerStatistic.GetCurrentSessionsCount: Integer; +begin + Result := LogWriter.CurrentSessions; +end; + +function TfrxServerStatistic.GetMaxReportsCount: Integer; +begin + Result := LogWriter.MaxReports; +end; + +function TfrxServerStatistic.GetMaxSessionsCount: Integer; +begin + Result := LogWriter.MaxSessions; +end; + +function TfrxServerStatistic.GetTotalReportsCount: Integer; +begin + Result := LogWriter.TotalReports; +end; + +function TfrxServerStatistic.GetTotalSessionsCount: Integer; +begin + Result := LogWriter.TotalSessions; +end; + +function TfrxServerStatistic.GetTotalErrors: Integer; +begin + Result := LogWriter.ErrorsCount; +end; + +constructor TfrxServerStatistic.Create; +begin + FStartTime := Now; +end; + +function TfrxServerStatistic.GetUpTimeDays: Integer; +begin + Result := Trunc(Now - FStartTime); +end; + +function TfrxServerStatistic.GetUpTimeHours: Integer; +begin + Result := StrToInt(FormatDateTime('h', Frac(Now - FStartTime))); +end; + +function TfrxServerStatistic.GetUpTimeMins: Integer; +begin + Result := StrToInt(FormatDateTime('n', Frac(Now - FStartTime))); +end; + +function TfrxServerStatistic.GetUpTimeSecs: Integer; +begin + Result := StrToInt(FormatDateTime('s', Frac(Now - FStartTime))); +end; + +function TfrxServerStatistic.GetTotalCacheHits: Integer; +begin + Result := LogWriter.TotalCacheHits; +end; + +function TfrxServerStatistic.GetFormatUpTime: String; +begin + Result := IntToStr(UpTimeDays) + ' days ' + + IntToStr(UpTimeHours) + ' hours ' + + IntToStr(UpTimeMins) + ' minutes ' + + IntToStr(UpTimeSecs) + ' seconds' +end; + +function TfrxServerStatistic.GetCacheCount: Integer; +begin + Result := ReportCache.Heap.Count; +end; + +end. diff --git a/official/4.2/LibD11/frxServerTemplates.pas b/official/4.2/LibD11/frxServerTemplates.pas new file mode 100644 index 0000000..dae34f3 --- /dev/null +++ b/official/4.2/LibD11/frxServerTemplates.pas @@ -0,0 +1,169 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Server templates support } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerTemplates; + +{$I frx.inc} + +interface + +uses Classes, SysUtils, frxServerVariables, frxServerSSI, + frxServerUtils, frxServerConfig; + + +type + TfrxServerTemplate = class(TObject) + private + FVariables: TfrxServerVariables; + FSSI: TfrxSSIStream; + FTemplate: TStringList; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + procedure Prepare; + procedure SetTemplate(const Name: String); + + property TemplateStrings: TStringList read FTemplate; + property Variables: TfrxServerVariables read FVariables; + end; + +implementation + +const + error403 = 'Forbidden

ERROR 403
Forbidden

'; + error404 = 'Not found

ERROR 404
Not found

'; + error500 = 'Internal error

ERROR 500
Internal error

'; + list_begin = ''; + list_header = ''; + list_line = ''; + list_end = '
" target=_blank>
'; + form_begin = '' + + '' + + '' + + '<!--#echo var="TITLE"-->' + + '>' + + '' + + '' + + '' + + '
' + + '
' + + '">' + + '' + + '' + + '">' + + '" align="center" style="border: solid 1px #000000">' + + ''; + form_end = '
">
"> 
'; + form_checkbox = '" value="" >' + + '; font-size: px;' + + 'color: ; background-color: ;">'; + form_label = '; font-size: px; color: ; background-color: ;">'; + form_memo = ''; + form_text = '" name="" value="" id="" size="" maxlength="" >'; + form_radio = '" value="" >' + + '; font-size: px; color: ; background-color: ;">'; + form_button = '" value="">'; + form_select = '" name="" value="" id="" size="" maxlength="" >'; + main = ''; + navigator = ''; + outline = ''; + report = ''; + +{ TfrxServerTemplate } + +procedure TfrxServerTemplate.Clear; +begin + FVariables.Clear; + FSSI.Clear; + FTemplate.Clear; +end; + +constructor TfrxServerTemplate.Create; +begin + FVariables := TfrxServerVariables.Create; + FSSI := TfrxSSIStream.Create; + FSSI.Variables := FVariables; + FTemplate := TStringList.Create; +end; + +destructor TfrxServerTemplate.Destroy; +begin + FSSI.Free; + FVariables.Free; + FTemplate.Free; + inherited; +end; + +procedure TfrxServerTemplate.Prepare; +begin + FSSI.Clear; + FTemplate.SaveToStream(FSSI); + FSSI.Prepare; + FTemplate.Clear; + FSSI.Position := 0; + FTemplate.LoadFromStream(FSSI); +end; + +procedure TfrxServerTemplate.SetTemplate(const Name: String); +var + path: String; +begin + path := frxGetAbsPathDir(ServerConfig.GetValue('server.http.templatespath'), ServerConfig.ConfigFolder) + name + '.html'; + if FileExists(path) then + FTemplate.LoadFromFile(path ) + else if name = 'error403' then + FTemplate.Text := error403 + else if name = 'error404' then + FTemplate.Text := error403 + else if name = 'error500' then + FTemplate.Text := error403 + else if name = 'list_begin' then + FTemplate.Text := list_begin + else if name = 'list_header' then + FTemplate.Text := list_header + else if name = 'list_line' then + FTemplate.Text := list_line + else if name = 'list_end' then + FTemplate.Text := list_end + else if name = 'form_begin' then + FTemplate.Text := form_begin + else if name = 'form_button' then + FTemplate.Text := form_button + else if name = 'form_checkbox' then + FTemplate.Text := form_checkbox + else if name = 'form_end' then + FTemplate.Text := form_end + else if name = 'form_label' then + FTemplate.Text := form_label + else if name = 'form_memo' then + FTemplate.Text := form_memo + else if name = 'form_radio' then + FTemplate.Text := form_radio + else if name = 'form_select' then + FTemplate.Text := form_select + else if name = 'form_text' then + FTemplate.Text := form_text + else if name = 'form_date' then + FTemplate.Text := form_date + else if name = 'main' then + FTemplate.Text := main + else if name = 'navigator' then + FTemplate.Text := navigator + else if name = 'outline' then + FTemplate.Text := outline + else if name = 'report' then + FTemplate.Text := report +end; + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxServerUtils.pas b/official/4.2/LibD11/frxServerUtils.pas new file mode 100644 index 0000000..20dd1e5 --- /dev/null +++ b/official/4.2/LibD11/frxServerUtils.pas @@ -0,0 +1,342 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Report Server misc utils } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerUtils; + +{$I frx.inc} + +interface + +uses Windows, SysUtils, Messages, ActiveX, frxUtils; + +function StrToHex(const s: String): String; +function HexToStr(const s : String) : String; +function Byte2Hex(const b: byte): String; +function GetHTTPErrorText(const ErrorCode: integer):string; +function GetUniqueFileName(const Path: String; const Prefix: String): String; +function Str2HTML(const Str: String): String; +function HTML2Str(const Line: String): String; +{$IFNDEF Delphi6} +function DirectoryExists(const Name: string): Boolean; +{$ENDIF} +function UnQuoteStr(const s: String): String; +function GetEnvVar(const VarName: string): string; +function MakeSessionId: String; + +function frxGetAbsPath(const Path: String): String; +function frxGetRelPath(const Path: String): String; +function frxGetAbsPathDir(const Path: String; const Dir: String): String; +function frxGetRelPathDir(const Path: String; const Dir: String): String; + +procedure frxTouchDir(const Path: String); + +type + TfrxServerFormat = (sfHTM, sfXML, sfXLS, sfRTF, sfCSV, sfTXT, sfPDF, sfJPG, sfBMP, sfTIFF, sfGIF, sfFRP, sfODS, sfODT); + TfrxServerOutputFormats = set of TfrxServerFormat; + TfrxHTTPQueryType = (qtGet, qtPost, qtHead); + +implementation + + +{$IFNDEF Delphi6} +function DirectoryExists(const Name: string): Boolean; +var + Code: Integer; +begin + Code := GetFileAttributes(PChar(Name)); + Result := (Code <> -1) and (FILE_ATTRIBUTE_DIRECTORY and Code <> 0); +end; +{$ENDIF} + +function StrToHex(const s: String): String; +var + Len, i: Integer; + C, H, L: Byte; + + function HexChar(N : Byte) : Char; + begin + if (N < 10) then Result := Chr(Ord('0') + N) + else Result := Chr(Ord('A') + (N - 10)); + end; + +begin + Len := Length(s); + SetLength(Result, Len shl 1); + for i := 1 to Len do begin + C := Ord(s[i]); + H := (C shr 4) and $f; + L := C and $f; + Result[i shl 1 - 1] := HexChar(H); + Result[i shl 1]:= HexChar(L); + end; +end; + +function HexToStr(const s : String) : String; +var + Len, i: Integer; + C, H, L: Byte; + + function CharHex(C: Char): Byte; + begin + C := UpCase(C); + if (C <= '9') then Result := Ord(C) - Ord('0') + else Result := Ord(C) - Ord('A') + 10; + end; + +begin + Len := Length(s); + SetLength(Result, Len shr 1); + for i := 1 to Len shr 1 do begin + H := CharHex(s[i shl 1 - 1]); + L := CharHex(s[i shl 1]); + C := H shl 4 or L; + Result[i] := Chr(C); + end; +end; + +function Byte2Hex(const b: byte): String; +var + H, L: Byte; + function HexChar(N : Byte) : Char; + begin + if (N < 10) then Result := Chr(Ord('0') + N) + else Result := Chr(Ord('A') + (N - 10)); + end; +begin + SetLength(Result, 2); + H := (b shr 4) and $f; + L := b and $f; + Result[1] := HexChar(H); + Result[2]:= HexChar(L); +end; + +function GetHTTPErrorText(const ErrorCode: integer):string; +begin + case errorcode of + 400: result:= 'Bad Request'; + 401: result:= 'Unauthorized'; + 402: result:= 'Payment Required'; + 403: result:= 'Forbidden'; + 404: result:= 'Not Found'; + 405: result:= 'Method Not Allowed'; + 406: result:= 'Not Acceptable'; + 407: result:= 'Proxy Authentication Required'; + 408: result:= 'Request Timeout'; + 409: result:= 'Conflict'; + 410: result:= 'Gone'; + 411: result:= 'Length Required'; + 412: result:= 'Precondition Failed'; + 413: result:= 'Request Entity Too Large'; + 414: result:= 'Request-URI Too Long'; + 415: result:= 'Unsupported Media Type'; + 500: result:= 'Internal Server Error'; + 501: result:= 'Not Implemented' + else + Result := '' + end; + if Length(Result) > 0 then + Result := Result + ' (' + IntToStr(errorcode) + ')'; +end; + +function GetUniqueFileName(const Path: String; const Prefix: String): String; +begin + Result := Path + '\' + Prefix + MakeSessionId + '.tmp'; +end; + +function Str2HTML(const Str: String): String; +var + i: Integer; + c: Char; + s: String; +begin + Result := ''; + for i := 1 to Length(Str) do + begin + c := Str[i]; + case c of + '0'..'9', 'A'..'Z', 'a'..'z', '.', '-': Result := Result + c; + else begin + s := c; + Result := Result + '%' + StrToHex(s); + end + end; + end; +end; + +function HTML2Str(const Line: String): String; +var + i: Integer; + s, buf: String; +begin + Result := Line; + if Length(Result) > 0 then + begin + i := 1; + while i <= Length(Result) do + begin + if Result[i] = '%' then + begin + if i <= Length(Result) - 2 then + begin + s := Result[i + 1] + Result[i + 2]; + buf := HexToStr(s); + Delete(Result, i, 2); + Result[i] := buf[1]; + end + end + else + if Result[i] = '+' then + Result[i] := ' '; + i := i + 1; + end; + end; +end; + +function UnQuoteStr(const s: String): String; +begin + Result := s; + if Length(Result) > 0 then + begin + if (Result[1] = #39) and (Result[Length(Result)] = #39) then + begin + Delete(Result, 1, 1); + Delete(Result, Length(Result), 1); + end; + end; +end; + +function GetEnvVar(const VarName: string): string; +var + buffer: PChar; + size: Integer; +const + BUF_SIZE = 4096; +begin + Result := ''; + size := 0; + GetMem(buffer, BUF_SIZE); + if buffer <> nil then + size := GetEnvironmentVariable(PChar(VarName), buffer, BUF_SIZE); + if size > 0 then + Result := String(buffer); + FreeMem(buffer); +end; + +function MakeSessionId: String; +var + AGUID: TGUID; + AGUIDString: widestring; +begin + CoCreateGUID(AGUID); + SetLength(AGUIDString, 39); + StringFromGUID2(AGUID, PWideChar(AGUIDString), 39); + Result := string(PWideChar(AGUIDString)); + Result := Copy(Result, 2, 36); + Result := StringReplace(Result, '-', '', [rfReplaceAll]); +end; + +function frxGetAbsPath(const Path: String): String; +begin + Result := frxGetAbsPathDir(Path, GetAppPath); +end; + +function frxGetAbsPathDir(const Path: String; const Dir: String): String; +var + s: String; + i: Integer; + + function PosEx(const SubStr, S: string; Offset: Cardinal = 1): Integer; + var + I,X: Integer; + Len, LenSubStr: Integer; + begin + if Offset = 1 then + Result := Pos(SubStr, S) + else + begin + I := Offset; + LenSubStr := Length(SubStr); + Len := Length(S) - LenSubStr + 1; + while I <= Len do + begin + if S[I] = SubStr[1] then + begin + X := 1; + while (X < LenSubStr) and (S[I + X] = SubStr[X + 1]) do + Inc(X); + if (X = LenSubStr) then + begin + Result := I; + exit; + end; + end; + Inc(I); + end; + Result := 0; + end; + end; + +begin + s := Dir; + if Pos('.\', Path) = 1 then + Result := StringReplace(Path, '.\', s, []) + else + if Pos('..\', Path) = 1 then + begin + s := frxReverseString(s); + i := PosEx('\', s, 2); + if i > 0 then + s := Copy(s, i, Length(s) - i + 1); + Result := frxReverseString(s) + Copy(Path, 4, Length(Path) - 3); + end + else + if (Pos('\', Path) = 1) or (Pos(':', Path) = 2) then + Result := Path + else + Result := s + Path; +end; + +function frxGetRelPath(const Path: String): String; +begin + Result := frxGetRelPathDir(Path, GetAppPath); +end; + +function frxGetRelPathDir(const Path: String; const Dir: String): String; +var + s1, s2: String; +begin + s1 := Dir; + s2 := frxGetAbsPathDir('..\', Dir); + if Pos(s1, Path) = 1 then + Result := StringReplace(Path, s1, '.\', [rfIgnoreCase]) + else + if Pos(s2, Path) = 1 then + Result := StringReplace(Path, s2, '..\', [rfIgnoreCase]) + else + Result := Path; +end; + +procedure frxTouchDir(const Path: String); +var + SecAtrtrs: TSecurityAttributes; +begin + if not DirectoryExists(Path) then + begin + SecAtrtrs.nLength := SizeOf(TSecurityAttributes); + SecAtrtrs.lpSecurityDescriptor := nil; + SecAtrtrs.bInheritHandle := true; + CreateDirectory(PChar(Path), @SecAtrtrs); + end; +end; + + +end. diff --git a/official/4.2/LibD11/frxServerVariables.pas b/official/4.2/LibD11/frxServerVariables.pas new file mode 100644 index 0000000..285000b --- /dev/null +++ b/official/4.2/LibD11/frxServerVariables.pas @@ -0,0 +1,77 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Server variables } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxServerVariables; + +{$I frx.inc} + +interface + +uses Windows, Classes, SysUtils; + +type + TfrxServerVariable = class(TCollectionItem) + private + FName: String; + FValue: String; + published + property Name: String read FName write FName; + property Value: String read FValue write FValue; + end; + + TfrxServerVariables = class(TCollection) + public + constructor Create; + function GetValue(const Name: String): String; + procedure AddVariable(const Name: String; const Value:String); + end; + +implementation + +{ TfrxServerVarables } + +procedure TfrxServerVariables.AddVariable(const Name, Value: String); +var + i, j: Integer; + s: String; + v: TfrxServerVariable; +begin + j := -1; + s := UpperCase(Name); + for i := 0 to Count - 1 do + if TfrxServerVariable(Items[i]).Name = Name then + j := i; + if j > 0 then + v := TfrxServerVariable(Items[j]) + else begin + v := TfrxServerVariable(Add); + v.Name := Name; + end; + v.Value := Value; +end; + +constructor TfrxServerVariables.Create; +begin + inherited Create(TfrxServerVariable); +end; + +function TfrxServerVariables.GetValue(const Name: String): String; +var + i: Integer; +begin + Result := ''; + for i := 0 to Count - 1 do + if TfrxServerVariable(Items[i]).Name = Name then + Result := TfrxServerVariable(Items[i]).Value; +end; + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxServerVersion.inc b/official/4.2/LibD11/frxServerVersion.inc new file mode 100644 index 0000000..61d8aae --- /dev/null +++ b/official/4.2/LibD11/frxServerVersion.inc @@ -0,0 +1 @@ +'1.0.10' \ No newline at end of file diff --git a/official/4.2/LibD11/frxStdWizard.dfm b/official/4.2/LibD11/frxStdWizard.dfm new file mode 100644 index 0000000..ed4335d Binary files /dev/null and b/official/4.2/LibD11/frxStdWizard.dfm differ diff --git a/official/4.2/LibD11/frxStdWizard.pas b/official/4.2/LibD11/frxStdWizard.pas new file mode 100644 index 0000000..f9d8692 --- /dev/null +++ b/official/4.2/LibD11/frxStdWizard.pas @@ -0,0 +1,1092 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Standard Report wizard } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxStdWizard; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, Buttons, ComCtrls, ExtCtrls, frxClass, frxDesgn; + +type + TfrxStdWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxDotMatrixWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxStdEmptyWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxDMPEmptyWizard = class(TfrxCustomWizard) + public + class function GetDescription: String; override; + function Execute: Boolean; override; + end; + + TfrxStdWizardForm = class(TForm) + Pages: TPageControl; + FieldsTab: TTabSheet; + GroupsTab: TTabSheet; + LayoutTab: TTabSheet; + FieldsLB: TListBox; + AddFieldB: TSpeedButton; + AddAllFieldsB: TSpeedButton; + RemoveFieldB: TSpeedButton; + RemoveAllFieldsB: TSpeedButton; + SelectedFieldsLB: TListBox; + SelectedFieldsL: TLabel; + FieldUpB: TSpeedButton; + FieldDownB: TSpeedButton; + AvailableFieldsLB: TListBox; + AddGroupB: TSpeedButton; + RemoveGroupB: TSpeedButton; + GroupsLB: TListBox; + GroupsL: TLabel; + GroupUpB: TSpeedButton; + GroupDownB: TSpeedButton; + AvailableFieldsL: TLabel; + BackB: TButton; + NextB: TButton; + FinishB: TButton; + FitWidthCB: TCheckBox; + Step2L: TLabel; + Step3L: TLabel; + Step4L: TLabel; + StyleTab: TTabSheet; + Step5L: TLabel; + ScrollBox1: TScrollBox; + StylePB: TPaintBox; + StyleLB: TListBox; + OrientationL: TGroupBox; + LayoutL: TGroupBox; + PortraitImg: TImage; + LandscapeImg: TImage; + PortraitRB: TRadioButton; + LandscapeRB: TRadioButton; + TabularRB: TRadioButton; + ColumnarRB: TRadioButton; + DataTab: TTabSheet; + DatasetsCB: TComboBox; + Step1L: TLabel; + NewTableB: TButton; + NewQueryB: TButton; + ScrollBox2: TScrollBox; + LayoutPB: TPaintBox; + AvailableFieldsL1: TLabel; + procedure FormCreate(Sender: TObject); + procedure FormShow(Sender: TObject); + procedure DatasetsCBClick(Sender: TObject); + procedure AddFieldBClick(Sender: TObject); + procedure AddAllFieldsBClick(Sender: TObject); + procedure RemoveFieldBClick(Sender: TObject); + procedure RemoveAllFieldsBClick(Sender: TObject); + procedure AddGroupBClick(Sender: TObject); + procedure RemoveGroupBClick(Sender: TObject); + procedure FieldUpBClick(Sender: TObject); + procedure FieldDownBClick(Sender: TObject); + procedure GroupUpBClick(Sender: TObject); + procedure GroupDownBClick(Sender: TObject); + procedure NextBClick(Sender: TObject); + procedure BackBClick(Sender: TObject); + procedure GroupsTabShow(Sender: TObject); + procedure StylePBPaint(Sender: TObject); + procedure PortraitRBClick(Sender: TObject); + procedure PagesChange(Sender: TObject); + procedure StyleLBClick(Sender: TObject); + procedure FinishBClick(Sender: TObject); + procedure NewTableBClick(Sender: TObject); + procedure NewQueryBClick(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure LayoutPBPaint(Sender: TObject); + procedure TabularRBClick(Sender: TObject); + private + FDesigner: TfrxDesignerForm; + FDotMatrix: Boolean; + FLayoutReport: TfrxReport; + FReport: TfrxReport; + FStyleReport: TfrxReport; + FStyleSheet: TfrxStyleSheet; + procedure DrawSample(PaintBox: TPaintBox; Report: TfrxReport); + procedure FillDatasets; + procedure FillFields; + procedure NewDBItem(const wizName: String); + procedure UpdateAvailableFields; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + + +implementation + +{$R *.DFM} +{$R *.RES} + +uses + frxEditReportData, frxDsgnIntf, frxRes, frxUtils, frxDMPClass, + IniFiles, Registry, Printers; + +const + StyleReport = +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +''; + + LayoutTabularReport = +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +''; + + LayoutColumnarReport = +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +'' + +''; + + + Style = +'' + +'' + +'' + +'' + +'' + +'' + +''; + + + +{ TfrxStdWizard } + +class function TfrxStdWizard.GetDescription: String; +begin + Result := frxResources.Get('wzStd'); +end; + +function TfrxStdWizard.Execute: Boolean; +begin + with TfrxStdWizardForm.Create(Owner) do + begin + FDesigner := TfrxDesignerForm(Self.Designer); + FReport := Report; + Result := ShowModal = mrOk; + Free; + end; +end; + + +{ TfrxDotMatrixWizard } + +class function TfrxDotMatrixWizard.GetDescription: String; +begin + Result := frxResources.Get('wzDMP'); +end; + +function TfrxDotMatrixWizard.Execute: Boolean; +begin + with TfrxStdWizardForm.Create(Owner) do + begin + FDesigner := TfrxDesignerForm(Self.Designer); + FDotMatrix := True; + FReport := Report; + Result := ShowModal = mrOk; + Free; + end; +end; + + +{ TfrxStdEmptyWizard } + +class function TfrxStdEmptyWizard.GetDescription: String; +begin + Result := frxResources.Get('wzStdEmpty'); +end; + +function TfrxStdEmptyWizard.Execute: Boolean; +var + Page: TfrxPage; +begin + Result := True; + try + Designer.Lock; + Report.Clear; + Report.FileName := ''; + Report.DotMatrixReport := False; + + Page := TfrxDataPage.Create(Report); + Page.Name := 'Data'; + Page := TfrxReportPage.Create(Report); + Page.Name := 'Page1'; + TfrxReportPage(Page).SetDefaults; + finally + Designer.ReloadReport; + end; +end; + + +{ TfrxDMPEmptyWizard } + +class function TfrxDMPEmptyWizard.GetDescription: String; +begin + Result := frxResources.Get('wzDMPEmpty'); +end; + +function TfrxDMPEmptyWizard.Execute: Boolean; +var + Page: TfrxPage; +begin + Result := True; + try + Designer.Lock; + Report.Clear; + Report.FileName := ''; + Report.DotMatrixReport := True; + + Page := TfrxDataPage.Create(Report); + Page.Name := 'Data'; + Page := TfrxDMPPage.Create(Report); + Page.Name := 'Page1'; + TfrxReportPage(Page).SetDefaults; + finally + Designer.ReloadReport; + end; +end; + + +{ TfrxStdWizardForm } + +constructor TfrxStdWizardForm.Create(AOwner: TComponent); +var + s: TStringStream; +begin + inherited; + FStyleReport := TfrxReport.Create(nil); + s := TStringStream.Create(StyleReport); + FStyleReport.LoadFromStream(s); + s.Free; + FLayoutReport := TfrxReport.Create(nil); + + FStyleSheet := TfrxStyleSheet.Create; + if FileExists(ExtractFilePath(Application.ExeName) + 'wizstyle.xml') then + FStyleSheet.LoadFromFile(ExtractFilePath(Application.ExeName) + 'wizstyle.xml') + else + begin + s := TStringStream.Create(Style); + FStyleSheet.LoadFromStream(s); + s.Free; + end; +end; + +destructor TfrxStdWizardForm.Destroy; +begin + FStyleReport.Free; + FLayoutReport.Free; + FStyleSheet.Free; + inherited; +end; + +procedure TfrxStdWizardForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(5600); + DataTab.Caption := frxGet(5601); + FieldsTab.Caption := frxGet(5602); + GroupsTab.Caption := frxGet(5603); + LayoutTab.Caption := frxGet(5604); + StyleTab.Caption := frxGet(5605); + Step1L.Caption := frxGet(5606); + Step2L.Caption := frxGet(5607); + Step3L.Caption := frxGet(5608); + Step4L.Caption := frxGet(5609); + Step5L.Caption := frxGet(5610); + AddFieldB.Caption := frxGet(5611); + AddAllFieldsB.Caption := frxGet(5612); + RemoveFieldB.Caption := frxGet(5613); + RemoveAllFieldsB.Caption := frxGet(5614); + AddGroupB.Caption := frxGet(5615); + RemoveGroupB.Caption := frxGet(5616); + SelectedFieldsL.Caption := frxGet(5617); + AvailableFieldsL.Caption := frxGet(5618); + AvailableFieldsL1.Caption := frxGet(5618); + GroupsL.Caption := frxGet(5619); + OrientationL.Caption := frxGet(5620); + LayoutL.Caption := frxGet(5621); + PortraitRB.Caption := frxGet(5622); + LandscapeRB.Caption := frxGet(5623); + TabularRB.Caption := frxGet(5624); + ColumnarRB.Caption := frxGet(5625); + FitWidthCB.Caption := frxGet(5626); + BackB.Caption := frxGet(5627); + NextB.Caption := frxGet(5628); + FinishB.Caption := frxGet(5629); + NewTableB.Caption := frxGet(5630); + NewQueryB.Caption := frxGet(5631); + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxStdWizardForm.FormShow(Sender: TObject); +var + Page: TfrxPage; +begin + FDesigner.Lock; + FReport.Clear; + + Page := TfrxDataPage.Create(FReport); + Page.Name := 'Data'; + + if FDotMatrix then + Page := TfrxDMPPage.Create(FReport) else + Page := TfrxReportPage.Create(FReport); + Page.Name := 'Page1'; + TfrxReportPage(Page).SetDefaults; + FDesigner.ReloadReport; + + FillDatasets; + DatasetsCB.ItemIndex := 0; + DatasetsCBClick(nil); + + FStyleSheet.GetList(StyleLB.Items); + StyleLB.ItemIndex := 0; + StyleLBClick(nil); + + TabularRBClick(nil); + if FDotMatrix then + StyleTab.Free; +end; + +procedure TfrxStdWizardForm.FillDatasets; +var + i: Integer; + ds: TfrxDataSet; + dsList: TStringList; +begin + dsList := TStringList.Create; + frxGetDataSetList(dsList); + dsList.Sort; + + DatasetsCB.Clear; + + for i := 0 to dsList.Count - 1 do + begin + ds := TfrxDataSet(dsList.Objects[i]); + if ds is TfrxCustomDBDataSet then + DatasetsCB.Items.AddObject(ds.UserName, ds); + end; + + dsList.Free; +end; + +procedure TfrxStdWizardForm.FillFields; +var + ds: TfrxDataSet; +begin + FieldsLB.Clear; + SelectedFieldsLB.Clear; + UpdateAvailableFields; + + if DatasetsCB.ItemIndex <> -1 then + begin + ds := TfrxDataSet(DatasetsCB.Items.Objects[DatasetsCB.ItemIndex]); + ds.GetFieldList(FieldsLB.Items); + end; + + if FieldsLB.Items.Count <> 0 then + begin + FieldsLB.ItemIndex := 0; + FieldsLB.Selected[0] := True; + end; +end; + +procedure TfrxStdWizardForm.UpdateAvailableFields; +begin + AvailableFieldsLB.Items := SelectedFieldsLB.Items; + GroupsLB.Clear; +end; + +procedure TfrxStdWizardForm.NewDBItem(const wizName: String); +var + i: Integer; + wiz: TfrxCustomWizard; +begin + for i := 0 to frxWizards.Count - 1 do + if frxWizards[i].ClassRef.ClassName = wizName then + begin + wiz := TfrxCustomWizard(frxWizards[i].ClassRef.NewInstance); + wiz.Create(FDesigner); + try + FReport.Datasets.Clear; + if wiz.Execute then + begin + FillDatasets; + DatasetsCB.ItemIndex := DatasetsCB.Items.IndexOf(FReport.Datasets[0].Dataset.UserName); + DatasetsCBClick(nil); + FReport.Datasets.Clear; + FDesigner.ReloadReport; + end; + finally + wiz.Free; + end; + break; + end; +end; + +procedure TfrxStdWizardForm.DrawSample(PaintBox: TPaintBox; Report: TfrxReport); +var + i: Integer; + c: TfrxComponent; +begin + with PaintBox do + begin + Canvas.Pen.Color := clBlack; + Canvas.Brush.Color := clWindow; + Canvas.Rectangle(0, 0, Width, Height); + + for i := 0 to Report.AllObjects.Count - 1 do + begin + c := Report.AllObjects[i]; + if c is TfrxCustomMemoView then + with TfrxCustomMemoView(c) do + Draw(Canvas, 1, 1, 10, 10); + end; + end; +end; + +procedure TfrxStdWizardForm.DatasetsCBClick(Sender: TObject); +begin + FillFields; +end; + +procedure TfrxStdWizardForm.NewTableBClick(Sender: TObject); +begin + NewDBItem('TfrxDBTableWizard'); +end; + +procedure TfrxStdWizardForm.NewQueryBClick(Sender: TObject); +begin + NewDBItem('TfrxDBQueryWizard'); +end; + +procedure TfrxStdWizardForm.AddFieldBClick(Sender: TObject); +var + i, j: Integer; +begin + if FieldsLB.ItemIndex = -1 then Exit; + + i := 0; + j := -1; + while i < FieldsLB.Items.Count do + if FieldsLB.Selected[i] then + begin + if j = -1 then + j := i; + SelectedFieldsLB.Items.Add(FieldsLB.Items[i]); + FieldsLB.Items.Delete(i); + end + else + Inc(i); + + if j = FieldsLB.Items.Count then + Dec(j); + if j <> -1 then + begin + FieldsLB.ItemIndex := j; + FieldsLB.Selected[j] := True; + end; + + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.AddAllFieldsBClick(Sender: TObject); +begin + if FieldsLB.Items.Count = 0 then Exit; + FillFields; + SelectedFieldsLB.Items := FieldsLB.Items; + FieldsLB.Items.Clear; + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.RemoveFieldBClick(Sender: TObject); +var + i, j: Integer; +begin + if SelectedFieldsLB.ItemIndex = -1 then Exit; + + i := 0; + j := -1; + while i < SelectedFieldsLB.Items.Count do + if SelectedFieldsLB.Selected[i] then + begin + if j = -1 then + j := i; + FieldsLB.Items.Add(SelectedFieldsLB.Items[i]); + SelectedFieldsLB.Items.Delete(i); + end + else + Inc(i); + + if j = SelectedFieldsLB.Items.Count then + Dec(j); + if j <> -1 then + begin + SelectedFieldsLB.ItemIndex := j; + SelectedFieldsLB.Selected[j] := True; + end; + + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.RemoveAllFieldsBClick(Sender: TObject); +begin + FillFields; +end; + +procedure TfrxStdWizardForm.AddGroupBClick(Sender: TObject); +var + i: Integer; +begin + i := AvailableFieldsLB.ItemIndex; + if i = -1 then Exit; + GroupsLB.Items.Add(AvailableFieldsLB.Items[i]); + AvailableFieldsLB.Items.Delete(i); + AvailableFieldsLB.ItemIndex := i; +end; + +procedure TfrxStdWizardForm.RemoveGroupBClick(Sender: TObject); +var + i: Integer; +begin + i := GroupsLB.ItemIndex; + if i = -1 then Exit; + AvailableFieldsLB.Items.Add(GroupsLB.Items[i]); + GroupsLB.Items.Delete(i); + GroupsLB.ItemIndex := i; +end; + +procedure TfrxStdWizardForm.FieldUpBClick(Sender: TObject); +var + i: Integer; +begin + i := SelectedFieldsLB.ItemIndex; + if i < 1 then Exit; + SelectedFieldsLB.Items.Exchange(i, i - 1); + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.FieldDownBClick(Sender: TObject); +var + i: Integer; +begin + i := SelectedFieldsLB.ItemIndex; + if (i = -1) or (SelectedFieldsLB.Items.Count = 0) or + (i = SelectedFieldsLB.Items.Count - 1) then Exit; + SelectedFieldsLB.Items.Exchange(i, i + 1); + SelectedFieldsLB.ItemIndex := i + 1; + UpdateAvailableFields; +end; + +procedure TfrxStdWizardForm.GroupUpBClick(Sender: TObject); +var + i: Integer; +begin + i := GroupsLB.ItemIndex; + if i < 1 then Exit; + GroupsLB.Items.Exchange(i, i - 1); +end; + +procedure TfrxStdWizardForm.GroupDownBClick(Sender: TObject); +var + i: Integer; +begin + i := GroupsLB.ItemIndex; + if (i = -1) or (i = GroupsLB.Items.Count - 1) then Exit; + GroupsLB.Items.Exchange(i, i + 1); + GroupsLB.ItemIndex := i + 1; +end; + +procedure TfrxStdWizardForm.NextBClick(Sender: TObject); +begin + Pages.SelectNextPage(True); + PagesChange(nil); +end; + +procedure TfrxStdWizardForm.BackBClick(Sender: TObject); +begin + Pages.SelectNextPage(False); + PagesChange(nil); +end; + +procedure TfrxStdWizardForm.PagesChange(Sender: TObject); +begin + if not FDotMatrix then + NextB.Enabled := Pages.ActivePage <> StyleTab else + NextB.Enabled := Pages.ActivePage <> LayoutTab; + BackB.Enabled := Pages.ActivePage <> DataTab; +end; + +procedure TfrxStdWizardForm.GroupsTabShow(Sender: TObject); +begin + AvailableFieldsLB.ItemIndex := 0; +end; + +procedure TfrxStdWizardForm.StylePBPaint(Sender: TObject); +begin + DrawSample(StylePB, FStyleReport); +end; + +procedure TfrxStdWizardForm.LayoutPBPaint(Sender: TObject); +begin + DrawSample(LayoutPB, FLayoutReport); +end; + +procedure TfrxStdWizardForm.PortraitRBClick(Sender: TObject); +begin + PortraitImg.Visible := PortraitRB.Checked; + LandscapeImg.Visible := LandscapeRB.Checked; +end; + +procedure TfrxStdWizardForm.StyleLBClick(Sender: TObject); +begin + FStyleReport.Styles := FStyleSheet.Find(StyleLB.Items[StyleLB.ItemIndex]); + StylePBPaint(nil); +end; + +procedure TfrxStdWizardForm.TabularRBClick(Sender: TObject); +var + s: TStringStream; +begin + if TabularRB.Checked then + s := TStringStream.Create(LayoutTabularReport) + else + s := TStringStream.Create(LayoutColumnarReport); + FLayoutReport.LoadFromStream(s); + s.Free; + FLayoutReport.Styles := FStyleSheet[0]; + LayoutPBPaint(nil); +end; + +procedure TfrxStdWizardForm.FinishBClick(Sender: TObject); +var + DataSet: TfrxDataSet; + Page: TfrxReportPage; + Band: TfrxBand; + Memo: TfrxCustomMemoView; + CurY, PageWidth, MaxHeaderWidth: Extended; + Widths, HeaderWidths, DataWidths: array of Extended; + + function Duplicate(n: Integer): String; + begin + Result := ''; + SetLength(Result, n); + FillChar(Result[1], n, '0'); + end; + + function CreateMemo(Parent: TfrxComponent): TfrxCustomMemoView; + begin + if FDotMatrix then + Result := TfrxDMPMemoView.Create(Parent) else + Result := TfrxMemoView.Create(Parent); + if Parent <> nil then + Result.CreateUniqueName; + end; + + procedure CreatePage; + begin + Page := TfrxReportPage(FReport.Pages[1]); + if PortraitRB.Checked then + Page.Orientation := poPortrait else + Page.Orientation := poLandscape; + PageWidth := (Page.PaperWidth - Page.LeftMargin - Page.RightMargin) * 96 / 25.4; + end; + + procedure CreateWidthsArray; + var + i, FieldsCount: Integer; + HeaderMemo, DataMemo: TfrxCustomMemoView; + MaxWidth, HeadersWidth, GapWidth: Extended; + Style: TfrxStyles; + begin + FieldsCount := AvailableFieldsLB.Items.Count; + SetLength(Widths, FieldsCount); + SetLength(HeaderWidths, FieldsCount); + SetLength(DataWidths, FieldsCount); + + HeaderMemo := CreateMemo(nil); + DataMemo := CreateMemo(nil); + if not FDotMatrix then + begin + Style := FStyleSheet.Find(StyleLB.Items[StyleLB.ItemIndex]); + HeaderMemo.ApplyStyle(Style.Find('Header')); + DataMemo.ApplyStyle(Style.Find('Data')); + end; + + MaxWidth := 0; + HeadersWidth := 0; + MaxHeaderWidth := 0; + GapWidth := 0; + for i := 0 to FieldsCount - 1 do + begin + HeaderMemo.Text := AvailableFieldsLB.Items[i]; + DataMemo.Text := Duplicate(DataSet.DisplayWidth[AvailableFieldsLB.Items[i]]); + HeaderWidths[i] := HeaderMemo.CalcWidth; + DataWidths[i] := DataMemo.CalcWidth; + if HeaderWidths[i] > DataWidths[i] then + Widths[i] := HeaderWidths[i] + else + begin + Widths[i] := DataWidths[i]; + GapWidth := GapWidth + DataWidths[i] - HeaderWidths[i]; + end; + MaxWidth := MaxWidth + Widths[i]; + HeadersWidth := HeadersWidth + HeaderWidths[i]; + if HeaderWidths[i] > MaxHeaderWidth then + MaxHeaderWidth := HeaderWidths[i]; + end; + + if FitWidthCB.Checked and (MaxWidth > PageWidth) then + begin + if HeadersWidth > PageWidth then + begin + for i := 0 to FieldsCount - 1 do + Widths[i] := HeaderWidths[i] / (HeadersWidth / PageWidth); + end + else + begin + for i := 0 to FieldsCount - 1 do + if HeaderWidths[i] < DataWidths[i] then + Widths[i] := Widths[i] - (DataWidths[i] - HeaderWidths[i]) / + GapWidth * (MaxWidth - PageWidth); + end; + end; + + HeaderMemo.Free; + DataMemo.Free; + end; + + procedure CreateTitle; + begin + Band := TfrxReportTitle.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, 0, 0, fr01cm * 7); + CurY := 30; + + Memo := CreateMemo(Band); + Memo.SetBounds(0, 0, 0, fr01cm * 6); + Memo.Align := baWidth; + Memo.HAlign := haCenter; + Memo.VAlign := vaCenter; + Memo.Text := 'Report'; + Memo.Style := 'Title'; + end; + + procedure CreateHeader; + var + i: Integer; + X, Y: Extended; + HeaderMemo: TfrxCustomMemoView; + begin + if ColumnarRB.Checked then Exit; + + Band := TfrxPageHeader.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, CurY, 0, fr01cm * 7); + + HeaderMemo := CreateMemo(Band); + HeaderMemo.SetBounds(0, 0, PageWidth, 0); + HeaderMemo.Style := 'Header line'; + + X := 0; + Y := 0; + for i := 0 to AvailableFieldsLB.Items.Count - 1 do + begin + if X + Widths[i] > PageWidth + 1 then + begin + X := 0; + Y := Y + fr01cm * 6; + end; + + Memo := CreateMemo(Band); + Memo.SetBounds(X, Y, Widths[i], fr01cm * 6); + Memo.Text := AvailableFieldsLB.Items[i]; + Memo.Style := 'Header'; + + X := X + Widths[i]; + end; + + Band.Height := Y + fr01cm * 6; + HeaderMemo.Height := Band.Height; + if FDotMatrix then + HeaderMemo.Free; + CurY := CurY + Band.Height; + end; + + procedure CreateGroupHeaders; + var + i: Integer; + begin + for i := 0 to GroupsLB.Items.Count - 1 do + begin + Band := TfrxGroupHeader.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, CurY, 0, fr01cm * 7); + TfrxGroupHeader(Band).Condition := DataSet.UserName + '."' + GroupsLB.Items[i] + '"'; + CurY := CurY + 30; + + Memo := CreateMemo(Band); + Memo.SetBounds(0, 0, 0, fr01cm * 6); + Memo.Align := baWidth; + Memo.VAlign := vaCenter; + Memo.DataSet := DataSet; + Memo.DataField := GroupsLB.Items[i]; + Memo.Style := 'Group header'; + end; + end; + + procedure CreateData; + var + i: Integer; + X, Y: Extended; + begin + Band := TfrxMasterData.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, CurY, 0, 0); + TfrxMasterData(Band).DataSet := DataSet; + CurY := CurY + 30; + + X := 0; + Y := 0; + for i := 0 to AvailableFieldsLB.Items.Count - 1 do + begin + if ColumnarRB.Checked then + begin + Memo := CreateMemo(Band); + Memo.SetBounds(0, Y, MaxHeaderWidth, fr01cm * 5); + Memo.Text := AvailableFieldsLB.Items[i]; + Memo.Style := 'Header'; + + Memo := CreateMemo(Band); + Memo.SetBounds(MaxHeaderWidth + fr01cm * 5, Y, DataWidths[i], fr01cm * 5); + Memo.DataSet := DataSet; + Memo.DataField := AvailableFieldsLB.Items[i]; + Memo.Style := 'Data'; + + Y := Y + fr01cm * 5; + end + else + begin + if X + Widths[i] > PageWidth + 1 then + begin + X := 0; + Y := Y + fr01cm * 5; + end; + + Memo := CreateMemo(Band); + Memo.SetBounds(X, Y, Widths[i], fr01cm * 5); + Memo.DataSet := DataSet; + Memo.DataField := AvailableFieldsLB.Items[i]; + Memo.Style := 'Data'; + + X := X + Widths[i]; + end; + end; + + Band.Height := Y + fr01cm * 5; + CurY := CurY + Band.Height; + end; + + procedure CreateGroupFooters; + var + i: Integer; + begin + CurY := 1000; + for i := GroupsLB.Items.Count - 1 downto 0 do + begin + Band := TfrxGroupFooter.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, CurY, 0, 0); + CurY := CurY - 30; + end; + end; + + procedure CreateFooter; + begin + Band := TfrxPageFooter.Create(Page); + Band.CreateUniqueName; + Band.SetBounds(0, 1000, 0, fr01cm * 7); + + Memo := CreateMemo(Band); + Memo.Align := baWidth; + Memo.Frame.Typ := [ftTop]; + Memo.Frame.Width := 2; + + Memo := CreateMemo(Band); + Memo.SetBounds(0, 1, 0, fr01cm * 6); + Memo.AutoWidth := True; + Memo.Text := '[Date] [Time]'; + + Memo := CreateMemo(Band); + Memo.SetBounds(100, 1, fr1cm * 2, fr01cm * 6); + Memo.Align := baRight; + Memo.HAlign := haRight; + Memo.Text := 'Page [Page#]'; + end; + +begin + try + FDesigner.Lock; + FReport.FileName := ''; + FReport.DotMatrixReport := FDotMatrix; + + DataSet := nil; + FReport.DataSets.Clear; + if DatasetsCB.ItemIndex <> -1 then + begin + DataSet := TfrxDataSet(DatasetsCB.Items.Objects[DatasetsCB.ItemIndex]); + FReport.DataSets.Add(DataSet); + end; + + CreatePage; + CreateWidthsArray; + CreateTitle; + CreateHeader; + CreateGroupHeaders; + CreateData; + CreateGroupFooters; + CreateFooter; + + if not FDotMatrix then + FReport.Styles := FStyleSheet.Find(StyleLB.Items[StyleLB.ItemIndex]); + + finally + FDesigner.ReloadReport; + Widths := nil; + HeaderWidths := nil; + DataWidths := nil; + end; +end; + +procedure TfrxStdWizardForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + + +initialization + frxWizards.Register1(TfrxStdWizard, 1); + frxWizards.Register1(TfrxStdEmptyWizard, 0); +{$IFNDEF FR_LITE} + frxWizards.Register1(TfrxDotMatrixWizard, 1); + frxWizards.Register1(TfrxDMPEmptyWizard, 0); +{$ENDIF} + +finalization + frxWizards.Unregister(TfrxStdWizard); + frxWizards.Unregister(TfrxStdEmptyWizard); +{$IFNDEF FR_LITE} + frxWizards.Unregister(TfrxDotMatrixWizard); + frxWizards.Unregister(TfrxDMPEmptyWizard); +{$ENDIF} + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxStdWizard.res b/official/4.2/LibD11/frxStdWizard.res new file mode 100644 index 0000000..cee610b Binary files /dev/null and b/official/4.2/LibD11/frxStdWizard.res differ diff --git a/official/4.2/LibD11/frxSynMemo.pas b/official/4.2/LibD11/frxSynMemo.pas new file mode 100644 index 0000000..e706d2c --- /dev/null +++ b/official/4.2/LibD11/frxSynMemo.pas @@ -0,0 +1,1996 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Syntax memo control } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxSynMemo; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, StdCtrls, + Forms, frxCtrls, fs_iparser, frxPopupForm; + +type + TCharAttr = (caNo, caText, caBlock, caComment, caKeyword, caString, + caNumber); + TCharAttributes = set of TCharAttr; + + TfrxCodeCompletionEvent = procedure(const Name: String; List: TStrings) of object; + + TfrxSyntaxMemo = class(TfrxScrollWin) + private + FActiveLine: Integer; + FAllowLinesChange: Boolean; + FBlockColor: TColor; + FBlockFontColor: TColor; + FBookmarks: array[0..9] of Integer; + FCharHeight: Integer; + FCharWidth: Integer; + FCommentAttr: TFont; + FCompletionForm: TfrxPopupForm; + FCompletionLB: TListBox; + FDoubleClicked: Boolean; + FDown: Boolean; + FGutterWidth: Integer; + FIsMonoType: Boolean; + FKeywordAttr: TFont; + FMaxLength: Integer; + FMessage: String; + FModified: Boolean; + FMoved: Boolean; + FNumberAttr: TFont; + FOffset: TPoint; + FOnChangePos: TNotifyEvent; + FOnChangeText: TNotifyEvent; + FOnCodeCompletion: TfrxCodeCompletionEvent; + FParser: TfsParser; + FPos: TPoint; + FStringAttr: TFont; + FSelEnd: TPoint; + FSelStart: TPoint; + FShowGutter: boolean; + FSynStrings: TStrings; + FSyntax: String; + FTempPos: TPoint; + FText: TStringList; + FTextAttr: TFont; + FUndo: TStringList; + FUpdatingSyntax: Boolean; + FWindowSize: TPoint; + FBreakPoints: TStringList; + function GetCharAttr(Pos: TPoint): TCharAttributes; + function GetLineBegin(Index: Integer): Integer; + function GetPlainTextPos(Pos: TPoint): Integer; + function GetPosPlainText(Pos: Integer): TPoint; + function GetRunLine(Index: Integer): Boolean; + function GetSelText: String; + function GetText: TStrings; + function LineAt(Index: Integer): String; + function LineLength(Index: Integer): Integer; + function Pad(n: Integer): String; + procedure AddSel; + procedure AddUndo; + procedure ClearSel; + procedure ClearSyntax(ClearFrom: Integer); + procedure CompletionLBDblClick(Sender: TObject); + procedure CompletionLBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); + procedure CompletionLBKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); + procedure CorrectBookmark(Line, Delta: Integer); + procedure CreateSynArray(EndLine: Integer); + procedure DoBackspace; + procedure DoChange; + procedure DoChar(Ch: Char); + procedure DoCodeCompletion; + procedure DoCtrlI; + procedure DoCtrlU; + procedure DoCtrlR; + procedure DoCtrlL; + procedure DoDel; + procedure DoDown; + procedure DoEnd(Ctrl: Boolean); + procedure DoHome(Ctrl: Boolean); + procedure DoLeft; + procedure DoPgUp; + procedure DoPgDn; + procedure DoReturn; + procedure DoRight; + procedure DoUp; + procedure EnterIndent; + procedure LinesChange(Sender: TObject); + procedure SetActiveLine(Line: Integer); + procedure SetCommentAttr(Value: TFont); + procedure SetKeywordAttr(Value: TFont); + procedure SetNumberAttr(const Value: TFont); + procedure SetRunLine(Index: Integer; const Value: Boolean); + procedure SetSelText(const Value: String); + procedure SetShowGutter(Value: Boolean); + procedure SetStringAttr(Value: TFont); + procedure SetSyntax(const Value: String); + procedure SetText(Value: TStrings); + procedure SetTextAttr(Value: TFont); + procedure ShiftSelected(ShiftRight: Boolean); + procedure ShowCaretPos; + procedure TabIndent; + procedure UnIndent; + procedure UpdateScrollBar; + procedure WMKillFocus(var Msg: TWMKillFocus); message WM_KILLFOCUS; + procedure WMSetFocus(var Msg: TWMSetFocus); message WM_SETFOCUS; + procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED; + protected + procedure DblClick; override; + procedure KeyDown(var Key: Word; Shift: TShiftState); override; + procedure KeyPress(var Key: Char); override; + procedure MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure MouseMove(Shift: TShiftState; X, Y: Integer); override; + procedure MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); override; + procedure MouseWheelDown(Sender: TObject; Shift: TShiftState; + MousePos: TPoint; var Handled: Boolean); + procedure MouseWheelUp(Sender: TObject; Shift: TShiftState; + MousePos: TPoint; var Handled: Boolean); + procedure OnHScrollChange(Sender: TObject); override; + procedure OnVScrollChange(Sender: TObject); override; + procedure Resize; override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Paint; override; + procedure CopyToClipboard; + procedure CutToClipboard; + procedure PasteFromClipboard; + procedure SelectAll; + procedure SetPos(x, y: Integer); + procedure ShowMessage(const s: String); + procedure Undo; + procedure UpdateView; + function Find(const SearchText: String; CaseSensitive: Boolean; + var SearchFrom: Integer): Boolean; + function GetPlainPos: Integer; + function GetPos: TPoint; + function IsBookmark(Line: Integer): Integer; + procedure AddBookmark(Line, Number: Integer); + procedure DeleteBookmark(Number: Integer); + procedure GotoBookmark(Number: Integer); + procedure AddBreakPoint(Number: Integer; const Condition: String); + procedure ToggleBreakPoint(Number: Integer; const Condition: String); + procedure DeleteBreakPoint(Number: Integer); + procedure DeleteF4BreakPoints; + function IsBreakPoint(Number: Integer): Boolean; + function GetBreakPointCondition(Number: Integer): String; + + property ActiveLine: Integer read FActiveLine write SetActiveLine; + property BlockColor: TColor read FBlockColor write FBlockColor; + property BlockFontColor: TColor read FBlockFontColor write FBlockFontColor; + property BreakPoints: TStringList read FBreakPoints; + property Color; + property CommentAttr: TFont read FCommentAttr write SetCommentAttr; + property Font; + property GutterWidth: Integer read FGutterWidth write FGutterWidth; + property KeywordAttr: TFont read FKeywordAttr write SetKeywordAttr; + property Modified: Boolean read FModified write FModified; + property NumberAttr: TFont read FNumberAttr write SetNumberAttr; + property RunLine[Index: Integer]: Boolean read GetRunLine write SetRunLine; + property SelText: String read GetSelText write SetSelText; + property StringAttr: TFont read FStringAttr write SetStringAttr; + property TextAttr: TFont read FTextAttr write SetTextAttr; + property Lines: TStrings read GetText write SetText; + property Syntax: String read FSyntax write SetSyntax; + property ShowGutter: boolean read FShowGutter write SetShowGutter; + property OnChangePos: TNotifyEvent read FOnChangePos write FOnChangePos; + property OnChangeText: TNotifyEvent read FOnChangeText write FOnChangeText; + property OnCodeCompletion: TfrxCodeCompletionEvent read FOnCodeCompletion + write FOnCodeCompletion; + property OnDragDrop; + property OnDragOver; + property OnKeyDown; + end; + + +implementation + + +uses Clipbrd, fs_itools, frxXML; + +const + SQLKeywords = + 'active,after,all,alter,and,any,as,asc,ascending,at,auto,' + + 'base_name,before,begin,between,by,cache,call,cast,check,column,commit,' + + 'committed,computed,conditional,constraint,containing,count,create,' + + 'current,cursor,database,debug,declare,default,delete,desc,descending,' + + 'distinct,do,domain,drop,else,end,entry_point,escape,exception,execute,' + + 'exists,exit,external,extract,filter,for,foreign,from,full,function,' + + 'generator,grant,group,having,if,in,inactive,index,inner,insert,into,is,' + + 'isolation,join,key,left,level,like,merge,names,no,not,null,of,on,only,' + + 'or,order,outer,parameter,password,plan,position,primary,privileges,' + + 'procedure,protected,read,retain,returns,revoke,right,rollback,schema,' + + 'select,set,shadow,shared,snapshot,some,suspend,table,then,to,' + + 'transaction,trigger,uncommitted,union,unique,update,user,using,values,' + + 'view,wait,when,where,while,with,work'; + + WordChars = ['a'..'z', 'A'..'Z', ''..'', ''..'', '0'..'9', '_']; + + +{ TfrxSyntaxMemo } + +constructor TfrxSyntaxMemo.Create(AOwner: TComponent); +var + i: Integer; +begin + inherited; + DoubleBuffered := True; + TabStop := True; + Cursor := crIBeam; + Color := clWindow; + + FBreakPoints := TStringList.Create; + + FBlockColor := clHighlight; + FBlockFontColor := clHighlightText; + + FCommentAttr := TFont.Create; + FCommentAttr.Color := clNavy; + FCommentAttr.Style := [fsItalic]; + + FKeywordAttr := TFont.Create; + FKeywordAttr.Color := clWindowText; + FKeywordAttr.Style := [fsBold]; + + FNumberAttr := TFont.Create; + FNumberAttr.Color := clGreen; + FNumberAttr.Style := []; + + FStringAttr := TFont.Create; + FStringAttr.Color := clNavy; + FStringAttr.Style := []; + + FTextAttr := TFont.Create; + FTextAttr.Color := clWindowText; + FTextAttr.Style := []; + + Font.Size := 10; + Font.Name := 'Courier New'; + + FText := TStringList.Create; + FParser := TfsParser.Create; + FParser.SkipSpace := False; + FParser.UseY := False; + FSynStrings := TStringList.Create; + FUndo := TStringList.Create; + FText.Add(''); + FText.OnChange := LinesChange; + FMaxLength := 1024; + FMoved := True; + SetPos(1, 1); + + ShowGutter := True; + OnMouseWheelUp := MouseWheelUp; + OnMouseWheelDown := MouseWheelDown; + + FActiveLine := -1; + for i := 0 to 9 do + FBookmarks[i] := -1; +end; + +destructor TfrxSyntaxMemo.Destroy; +begin + FBreakPoints.Free; + FCommentAttr.Free; + FKeywordAttr.Free; + FNumberAttr.Free; + FStringAttr.Free; + FTextAttr.Free; + FText.Free; + FUndo.Free; + FSynStrings.Free; + FParser.Free; + inherited; +end; + +procedure TfrxSyntaxMemo.WMKillFocus(var Msg: TWMKillFocus); +begin + inherited; + HideCaret(Handle); + DestroyCaret; +end; + +procedure TfrxSyntaxMemo.WMSetFocus(var Msg: TWMSetFocus); +begin + inherited; + CreateCaret(Handle, 0, 2, FCharHeight); + ShowCaretPos; +end; + +procedure TfrxSyntaxMemo.ShowCaretPos; +begin + if FPos.X > FOffset.X then + begin + SetCaretPos(FCharWidth * (FPos.X - 1 - FOffset.X) + FGutterWidth, + FCharHeight * (FPos.Y - 1 - FOffset.Y)); + ShowCaret(Handle); + end + else + SetCaretPos(-100, -100); + if Assigned(FOnChangePos) then + FOnChangePos(Self); +end; + +procedure TfrxSyntaxMemo.CMFontChanged(var Message: TMessage); +var + b: TBitmap; +begin + FCommentAttr.Size := Font.Size; + FCommentAttr.Name := Font.Name; + FKeywordAttr.Size := Font.Size; + FKeywordAttr.Name := Font.Name; + FNumberAttr.Size := Font.Size; + FNumberAttr.Name := Font.Name; + FStringAttr.Size := Font.Size; + FStringAttr.Name := Font.Name; + FTextAttr.Size := Font.Size; + FTextAttr.Name := Font.Name; + + b := TBitmap.Create; + with b.Canvas do + begin + Font.Assign(Self.Font); + Font.Style := [fsBold]; + FCharHeight := TextHeight('Wg') + 1; + FCharWidth := TextWidth('W'); + FIsMonoType := Pos('COURIER NEW', AnsiUppercase(Self.Font.Name)) <> 0; + end; + b.Free; +end; + +procedure TfrxSyntaxMemo.Resize; +begin + inherited; + if FCharWidth = 0 then Exit; + FWindowSize := Point((ClientWidth - FGutterWidth) div FCharWidth, + ClientHeight div FCharHeight); + HorzPage := FWindowSize.X; + VertPage := FWindowSize.Y; + UpdateScrollBar; +end; + +procedure TfrxSyntaxMemo.UpdateScrollBar; +begin + VertRange := FText.Count; + HorzRange := FMaxLength; + LargeChange := FWindowSize.Y; + VertPosition := FOffset.Y; + HorzPosition := FOffset.X; +end; + +function TfrxSyntaxMemo.GetText: TStrings; +//var +// i: Integer; +begin +// FAllowLinesChange := False; +// for i := 0 to FText.Count - 1 do +// FText[i] := LineAt(i); + Result := FText; + FAllowLinesChange := True; +end; + +function TfrxSyntaxMemo.GetPlainPos: Integer; +begin + Result := GetPlainTextPos(FPos); +end; + +function TfrxSyntaxMemo.GetPos: TPoint; +begin + Result := FPos; +end; + +procedure TfrxSyntaxMemo.SetText(Value: TStrings); +begin + FAllowLinesChange := True; + FText.Assign(Value); +end; + +procedure TfrxSyntaxMemo.SetSyntax(const Value: String); +var + sl: TStringList; + + procedure GetGrammar; + var + Grammar: TfrxXMLDocument; + ss: TStringStream; + ParserRoot, xi: TfrxXMLItem; + i: Integer; + Name, PropText: String; + begin + Grammar := TfrxXMLDocument.Create; + ss := TStringStream.Create(fsGetLanguage(Value)); + Grammar.LoadFromStream(ss); + ss.Free; + + ParserRoot := Grammar.Root.FindItem('parser'); + xi := ParserRoot.FindItem('keywords'); + for i := 0 to xi.Count - 1 do + FParser.Keywords.Add(xi[i].Name); + + for i := 0 to ParserRoot.Count - 1 do + begin + Name := LowerCase(ParserRoot[i].Name); + PropText := ParserRoot[i].Prop['text']; + if Name = 'identchars' then + FParser.ConstructCharset(PropText) + else if Name = 'commentline1' then + FParser.CommentLine1 := PropText + else if Name = 'commentline2' then + FParser.CommentLine2 := PropText + else if Name = 'commentblock1' then + FParser.CommentBlock1 := PropText + else if Name = 'commentblock2' then + FParser.CommentBlock2 := PropText + else if Name = 'stringquotes' then + FParser.StringQuotes := PropText + else if Name = 'hexsequence' then + FParser.HexSequence := PropText + end; + + Grammar.Free; + end; + +begin + FSyntax := Value; + FParser.Keywords.Clear; + sl := TStringList.Create; + if AnsiCompareText(Value, 'SQL') = 0 then + begin + sl.CommaText := SQLKeywords; + FParser.Keywords.Assign(sl); + FParser.CommentLine1 := '--'; + FParser.CommentLine2 := ''; + FParser.CommentBlock1 := '/*,*/'; + FParser.CommentBlock2 := ''; + FParser.StringQuotes := '"'; + FParser.HexSequence := '0x'; + end + else + begin + fsGetLanguageList(sl); + if sl.IndexOf(Value) <> -1 then + GetGrammar; + end; + + ClearSyntax(1); + sl.Free; +end; + +procedure TfrxSyntaxMemo.SetCommentAttr(Value: TFont); +begin + FCommentAttr.Assign(Value); + Repaint; +end; + +procedure TfrxSyntaxMemo.SetKeywordAttr(Value: TFont); +begin + FKeywordAttr.Assign(Value); + Repaint; +end; + +procedure TfrxSyntaxMemo.SetNumberAttr(const Value: TFont); +begin + FNumberAttr.Assign(Value); + Repaint; +end; + +procedure TfrxSyntaxMemo.SetStringAttr(Value: TFont); +begin + FStringAttr.Assign(Value); + Repaint; +end; + +procedure TfrxSyntaxMemo.SetTextAttr(Value: TFont); +begin + FTextAttr.Assign(Value); + Repaint; +end; + +procedure TfrxSyntaxMemo.SetActiveLine(Line: Integer); +begin + FActiveLine := Line; + Repaint; +end; + +procedure TfrxSyntaxMemo.DoChange; +begin + FModified := True; + if Assigned(FOnChangeText) then + FOnChangeText(Self); +end; + +procedure TfrxSyntaxMemo.LinesChange(Sender: TObject); +begin + if FAllowLinesChange then + begin + FAllowLinesChange := False; + if FText.Count = 0 then + FText.Add(''); + ClearSyntax(1); + FMoved := True; + FUndo.Clear; + FPos := Point(1, 1); + FOffset := Point(0, 0); + ClearSel; + ShowCaretPos; + UpdateScrollBar; + end; +end; + +procedure TfrxSyntaxMemo.ShowMessage(const s: String); +begin + FMessage := s; + Repaint; +end; + +procedure TfrxSyntaxMemo.CopyToClipboard; +begin + if FSelStart.X <> 0 then + Clipboard.AsText := SelText; +end; + +procedure TfrxSyntaxMemo.CutToClipboard; +begin + if FSelStart.X <> 0 then + begin + Clipboard.AsText := SelText; + SelText := ''; + end; + CorrectBookmark(FSelStart.Y, FSelStart.Y - FSelEnd.Y); + Repaint; +end; + +procedure TfrxSyntaxMemo.PasteFromClipboard; +begin + SelText := Clipboard.AsText; +end; + +procedure TfrxSyntaxMemo.SelectAll; +begin + SetPos(0, 0); + FSelStart := FPos; + SetPos(LineLength(FText.Count - 1) + 1, FText.Count); + FSelEnd := FPos; + Repaint; +end; + +function TfrxSyntaxMemo.LineAt(Index: Integer): String; +begin + if Index < FText.Count then + Result := TrimRight(FText[Index]) + else + Result := ''; +end; + +function TfrxSyntaxMemo.LineLength(Index: Integer): Integer; +begin + Result := Length(LineAt(Index)); +end; + +function TfrxSyntaxMemo.Pad(n: Integer): String; +begin + Result := ''; + SetLength(result, n); + FillChar(result[1], n, ' '); +end; + +procedure TfrxSyntaxMemo.AddUndo; +begin + if not FMoved then exit; + FUndo.Add(Format('%5d%5d', [FPos.X, FPos.Y]) + FText.Text); + if FUndo.Count > 32 then + FUndo.Delete(0); + FMoved := False; +end; + +procedure TfrxSyntaxMemo.Undo; +var + s: String; +begin + FMoved := True; + if FUndo.Count = 0 then exit; + s := FUndo[FUndo.Count - 1]; + FPos.X := StrToInt(Copy(s, 1, 5)); + FPos.Y := StrToInt(Copy(s, 6, 5)); + FAllowLinesChange := False; + FText.Text := Copy(s, 11, Length(s) - 10); + FAllowLinesChange := True; + FUndo.Delete(FUndo.Count - 1); + SetPos(FPos.X, FPos.Y); + ClearSyntax(1); + DoChange; +end; + +function TfrxSyntaxMemo.GetPlainTextPos(Pos: TPoint): Integer; +var + i: Integer; +begin + Result := 0; + for i := 0 to Pos.Y - 2 do + Result := Result + Length(FText[i]) + 2; + Result := Result + Pos.X; +end; + +function TfrxSyntaxMemo.GetPosPlainText(Pos: Integer): TPoint; +var + i: Integer; + s: String; +begin + Result := Point(0, 1); + s := FText.Text; + i := 1; + while i <= Pos do + if s[i] = #13 then + begin + Inc(i, 2); + if i <= Pos then + begin + Inc(Result.Y); + Result.X := 0; + end + else + Inc(Result.X); + end + else + begin + Inc(i); + Inc(Result.X); + end; +end; + +function TfrxSyntaxMemo.GetLineBegin(Index: Integer): Integer; +var + s: String; +begin + s := FText[Index]; + Result := 1; + if Trim(s) <> '' then + for Result := 1 to Length(s) do + if s[Result] <> ' ' then + break; +end; + +procedure TfrxSyntaxMemo.TabIndent; +begin + SelText := Pad((FPos.X div 8 + 1) * 8 - FPos.X); +end; + +procedure TfrxSyntaxMemo.EnterIndent; +var + res: Integer; +begin + if Trim(FText[FPos.Y - 1]) = '' then + res := FPos.X else + res := GetLineBegin(FPos.Y - 1); + + if FPos.X = 1 then + CorrectBookmark(FPos.Y - 1, 1) else + CorrectBookmark(FPos.Y, 1); + + FPos := Point(1, FPos.Y + 1); + SelText := Pad(res - 1); +end; + +procedure TfrxSyntaxMemo.UnIndent; +var + i, res: Integer; +begin + i := FPos.Y - 2; + res := FPos.X - 1; + CorrectBookmark(FPos.Y, -1); + while i >= 0 do + begin + res := GetLineBegin(i); + if (res < FPos.X) and (Trim(FText[i]) <> '') then + break else + Dec(i); + end; + FSelStart := FPos; + FSelEnd := FPos; + Dec(FSelEnd.X, FPos.X - res); + SelText := ''; +end; + +procedure TfrxSyntaxMemo.ShiftSelected(ShiftRight: Boolean); +var + i, ib, ie: Integer; + s: String; + Shift: Integer; +begin + AddUndo; + if FSelStart.X + FSelStart.Y * FMaxLength < FSelEnd.X + FSelEnd.Y * FMaxLength then + begin + ib := FSelStart.Y - 1; + ie := FSelEnd.Y - 1; + end + else + begin + ib := FSelEnd.Y - 1; + ie := FSelStart.Y - 1; + end; + if FSelEnd.X = 1 then + Dec(ie); + + Shift := 2; + if not ShiftRight then + for i := ib to ie do + begin + s := FText[i]; + if (Trim(s) <> '') and (GetLineBegin(i) - 1 < Shift) then + Shift := GetLineBegin(i) - 1; + end; + + for i := ib to ie do + begin + s := FText[i]; + if ShiftRight then + s := Pad(Shift) + s + else if Trim(s) <> '' then + Delete(s, 1, Shift); + FText[i] := s; + end; + + ClearSyntax(FSelStart.Y); + DoChange; +end; + +function TfrxSyntaxMemo.GetSelText: String; +var + p1, p2: TPoint; + i: Integer; +begin + if FSelStart.X = 0 then + begin + Result := ''; + Exit; + end; + + if FSelStart.X + FSelStart.Y * FMaxLength < FSelEnd.X + FSelEnd.Y * FMaxLength then + begin + p1 := FSelStart; + p2 := FSelEnd; + Dec(p2.X); + end + else + begin + p1 := FSelEnd; + p2 := FSelStart; + Dec(p2.X); + end; + + if LineLength(p1.Y - 1) < p1.X then + begin + Inc(p1.Y); + p1.X := 1; + end; + if LineLength(p2.Y - 1) < p2.X then + p2.X := LineLength(p2.Y - 1); + + i := GetPlainTextPos(p1); + Result := Copy(FText.Text, i, GetPlainTextPos(p2) - i + 1); +end; + +procedure TfrxSyntaxMemo.SetSelText(const Value: String); +var + p1, p2, p3: TPoint; + i: Integer; + s: String; +begin + AddUndo; + if FSelStart.X = 0 then + begin + p1 := FPos; + p2 := p1; + Dec(p2.X); + end + else if FSelStart.X + FSelStart.Y * FMaxLength < FSelEnd.X + FSelEnd.Y * FMaxLength then + begin + p1 := FSelStart; + p2 := FSelEnd; + Dec(p2.X); + end + else + begin + p1 := FSelEnd; + p2 := FSelStart; + Dec(p2.X); + end; + + if LineLength(p1.Y - 1) < p1.X then + FText[p1.Y - 1] := FText[p1.Y - 1] + Pad(p1.X - LineLength(p1.Y - 1) + 1); + if LineLength(p2.Y - 1) < p2.X then + p2.X := LineLength(p2.Y - 1); + + i := GetPlainTextPos(p1); + s := FText.Text; + Delete(s, i, GetPlainTextPos(p2) - i + 1); + Insert(Value, s, i); + FText.Text := s; + p3 := GetPosPlainText(i + Length(Value)); + + CorrectBookmark(FPos.Y, p3.y - FPos.Y); + + SetPos(p3.X, p3.Y); + FSelStart.X := 0; + DoChange; + i := p3.Y; + if p2.Y < i then + i := p2.Y; + if p1.Y < i then + i := p1.Y; + ClearSyntax(i); +end; + +procedure TfrxSyntaxMemo.ClearSel; +begin + if FSelStart.X <> 0 then + begin + FSelStart := Point(0, 0); + Repaint; + end; +end; + +procedure TfrxSyntaxMemo.AddSel; +begin + if FSelStart.X = 0 then + FSelStart := FTempPos; + FSelEnd := FPos; + Repaint; +end; + +procedure TfrxSyntaxMemo.SetPos(x, y: Integer); +begin + if FMessage <> '' then + begin + FMessage := ''; + Repaint; + end; + + if x > FMaxLength then x := FMaxLength; + if x < 1 then x := 1; + if y > FText.Count then y := FText.Count; + if y < 1 then y := 1; + + FPos := Point(x, y); + if (FWindowSize.X = 0) or (FWindowSize.Y = 0) then exit; + + if FOffset.Y >= FText.Count then + FOffset.Y := FText.Count - 1; + + if FPos.X > FOffset.X + FWindowSize.X then + begin + Inc(FOffset.X, FPos.X - (FOffset.X + FWindowSize.X)); + Repaint; + end + else if FPos.X <= FOffset.X then + begin + Dec(FOffset.X, FOffset.X - FPos.X + 1); + Repaint; + end + else if FPos.Y > FOffset.Y + FWindowSize.Y then + begin + Inc(FOffset.Y, FPos.Y - (FOffset.Y + FWindowSize.Y)); + Repaint; + end + else if FPos.Y <= FOffset.Y then + begin + Dec(FOffset.Y, FOffset.Y - FPos.Y + 1); + Repaint; + end; + + ShowCaretPos; + UpdateScrollBar; + +end; + +procedure TfrxSyntaxMemo.OnHScrollChange(Sender: TObject); +begin + FOffset.X := HorzPosition; + if FOffset.X > 1024 then + FOffset.X := 1024; + ShowCaretPos; + Repaint; +end; + +procedure TfrxSyntaxMemo.OnVScrollChange(Sender: TObject); +begin + FOffset.Y := VertPosition; + if FOffset.Y > FText.Count then + FOffset.Y := FText.Count; + ShowCaretPos; + Repaint; +end; + +procedure TfrxSyntaxMemo.DblClick; +var + s: String; +begin + FDoubleClicked := True; + DoCtrlL; + FSelStart := FPos; + s := LineAt(FPos.Y - 1); + if s <> '' then + while s[FPos.X] in WordChars do + Inc(FPos.X); + FSelEnd := FPos; + Repaint; +end; + +procedure TfrxSyntaxMemo.MouseDown(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + if FDoubleClicked then + begin + FDoubleClicked := False; + Exit; + end; + + FMoved := True; + if not Focused then + SetFocus; + FDown := True; + + X := (X - FGutterWidth) div FCharWidth + 1 + FOffset.X; + Y := Y div FCharHeight + 1 + FOffset.Y; + FTempPos := FPos; + SetPos(X, Y); + if ssShift in Shift then + AddSel + else + ClearSel; +end; + +procedure TfrxSyntaxMemo.MouseMove(Shift: TShiftState; X, Y: Integer); +begin + if FDown then + begin + FTempPos := FPos; + FPos.X := (X - FGutterWidth) div FCharWidth + 1 + FOffset.X; + FPos.Y := Y div FCharHeight + 1 + FOffset.Y; + if (FPos.X <> FTempPos.X) or (FPos.Y <> FTempPos.Y) then + begin + SetPos(FPos.X, FPos.Y); + AddSel; + end; + end; + + if X < FGutterWidth then + Cursor := crArrow + else + Cursor := crIBeam; +end; + +procedure TfrxSyntaxMemo.MouseUp(Button: TMouseButton; Shift: TShiftState; + X, Y: Integer); +begin + FDown := False; + if X < FGutterWidth then + ToggleBreakPoint(FPos.Y, ''); +end; + +procedure TfrxSyntaxMemo.KeyDown(var Key: Word; Shift: TShiftState); +var + MyKey: Boolean; +begin + inherited; + FAllowLinesChange := False; + + FTempPos := FPos; + MyKey := True; + case Key of + vk_Left: + if ssCtrl in Shift then + DoCtrlL else + DoLeft; + + vk_Right: + if ssCtrl in Shift then + DoCtrlR else + DoRight; + + vk_Up: + DoUp; + + vk_Down: + DoDown; + + vk_Home: + DoHome(ssCtrl in Shift); + + vk_End: + DoEnd(ssCtrl in Shift); + + vk_Prior: + DoPgUp; + + vk_Next: + DoPgDn; + + vk_Return: + if Shift = [] then + DoReturn; + + vk_Delete: + if ssShift in Shift then + CutToClipboard else + DoDel; + + vk_Back: + DoBackspace; + + vk_Insert: + if ssCtrl in Shift then + CopyToClipboard + else if ssShift in Shift then + PasteFromClipboard; + + vk_Tab: + TabIndent; + + else + MyKey := False; + end; + + if Shift = [ssCtrl] then + if Key = 65 then // Ctrl+A Select all + begin + SelectAll; + end + else if Key = 89 then // Ctrl+Y Delete line + begin + if FText.Count > FPos.Y then + begin + FMoved := True; + AddUndo; + FText.Delete(FPos.Y - 1); + CorrectBookmark(FPos.Y, -1); + DoChange; + end + else if FText.Count = FPos.Y then + begin + FMoved := True; + AddUndo; + FText[FPos.Y - 1] := ''; + FPos.X := 1; + SetPos(FPos.X, FPos.Y); + DoChange; + end; + ClearSyntax(FPos.Y); + end + else if Key in [48..57] then + GotoBookmark(Key - 48) + else if Key = 32 then // Ctrl+Space code completion + begin + if Assigned(FOnCodeCompletion) then + DoCodeCompletion; + MyKey := True; + end + else if Key = Ord('C') then + begin + CopyToClipboard; + MyKey := True; + end + else if Key = Ord('V') then + begin + PasteFromClipboard; + MyKey := True; + end + else if Key = Ord('X') then + begin + CutToClipboard; + MyKey := True; + end + else if Key = Ord('I') then + begin + DoCtrlI; + MyKey := True; + end + else if Key = Ord('U') then + begin + DoCtrlU; + MyKey := True; + end + else if Key = Ord('Z') then + begin + Undo; + MyKey := True; + end; + + if Shift = [ssCtrl, ssShift] then + if Key in [48..57] then + if IsBookmark(FPos.Y - 1) < 0 then + AddBookmark(FPos.Y - 1, Key - 48) + else if IsBookmark(FPos.Y - 1) = (Key - 48) then + DeleteBookmark(Key - 48); + + if Key in [vk_Left, vk_Right, vk_Up, vk_Down, vk_Home, vk_End, vk_Prior, vk_Next] then + begin + FMoved := True; + if ssShift in Shift then + AddSel else + ClearSel; + end + else if Key in [vk_Return, vk_Delete, vk_Back, vk_Insert, vk_Tab] then + FMoved := True; + + if MyKey then + Key := 0; +end; + +procedure TfrxSyntaxMemo.KeyPress(var Key: Char); +var + MyKey, ControlKeyDown: Boolean; +begin + inherited; + + ControlKeyDown := (((GetKeyState(VK_LCONTROL) and not $7FFF) <> 0) or + ((GetKeyState(VK_RCONTROL) and not $7FFF) <> 0)) and + (GetKeyState(VK_RMENU) >= 0); + MyKey := True; + + if ((Key = #32) and not ControlKeyDown) or (Key in [#33..#255]) then + begin + DoChar(Key); + FMoved := False; + end + else + MyKey := False; + + if MyKey then + Key := #0; +end; + +procedure TfrxSyntaxMemo.DoCodeCompletion; +var + p: TPoint; + + function GetCompletionString: String; + var + i: Integer; + s: String; + fl1, fl2: Boolean; + fl3, fl4: Integer; + begin + Result := ''; + s := LineAt(FPos.Y - 1); + s := Trim(Copy(s, 1, FPos.X)); + + fl1 := False; + fl2 := False; + fl3 := 0; + fl4 := 0; + + i := Length(s); + while i > 1 do + begin + Dec(i); + if (s[i] = '''') and not fl2 then + fl1 := not fl1 + else if (s[i] = '"') and not fl1 then + fl2 := not fl2 + else if not fl1 and not fl2 and (s[i] = ')') then + Inc(fl3) + else if not fl1 and not fl2 and (s[i] = '(') and (fl3 > 0) then + Dec(fl3) + else if not fl1 and not fl2 and (s[i] = ']') then + Inc(fl4) + else if not fl1 and not fl2 and (s[i] = '[') and (fl4 > 0) then + Dec(fl4) + else if not fl1 and not fl2 and (fl3 = 0) and (fl4 = 0) then + if s[i] in ['A'..'Z', 'a'..'z', '0'..'9', '_', '.', ' '] then + Result := s[i] + Result + else + break; + end; + end; + +begin + FCompletionForm := TfrxPopupForm.Create(Self); + FCompletionLB := TListBox.Create(FCompletionForm); + with FCompletionLB do + begin + Parent := FCompletionForm; + Ctl3D := False; + Align := alClient; + ItemHeight := ItemHeight + 2; + Style := lbOwnerDrawFixed; + Sorted := True; + OnDblClick := CompletionLBDblClick; + OnKeyDown := CompletionLBKeyDown; + OnDrawItem := CompletionLBDrawItem; + if Assigned(FOnCodeCompletion) then + FOnCodeCompletion(GetCompletionString, Items); + + p := Self.ClientToScreen( + Point(FCharWidth * (FPos.X - 1 - FOffset.X) + FGutterWidth, + FCharHeight * (FPos.Y - FOffset.Y))); + FCompletionForm.SetBounds(p.X, p.Y, 300, 100); + FCompletionForm.Show; + end; +end; + +procedure TfrxSyntaxMemo.CompletionLBDblClick(Sender: TObject); +var + s, s1: String; + i: Integer; + stepBack: Boolean; +begin + if FCompletionLB.ItemIndex <> -1 then + begin + s := FCompletionLB.Items[FCompletionLB.ItemIndex]; + i := 2; + while (i <= Length(s)) and (s[i] in WordChars) do + Inc(i); + s1 := Copy(s, 1, i - 1); + stepBack := (i <= Length(s)) and (s[i] = '('); + if stepBack then + s1 := s1 + '()'; + SelText := s1; + if stepBack then + DoLeft; + end; + FCompletionForm.Close; +end; + +procedure TfrxSyntaxMemo.CompletionLBKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_ESCAPE then + FCompletionForm.Close; + if Key = VK_RETURN then + CompletionLBDblClick(nil); +end; + +procedure TfrxSyntaxMemo.CompletionLBDrawItem(Control: TWinControl; Index: Integer; + ARect: TRect; State: TOwnerDrawState); +var + i, w: Integer; + s: String; +begin + with FCompletionLB.Canvas do + begin + FillRect(ARect); + if Index <> -1 then + begin + i := Integer(FCompletionLB.Items.Objects[Index]); + s := ''; + Font.Color := clFuchsia; + if Pos('Constructor', FCompletionLB.Items[Index]) <> 0 then + s := 'constructor' + else + case i of + 0: begin s := 'var'; Font.Color := clBlue; end; + 1: begin s := 'property'; Font.Color := clBlue; end; + 2: s := 'procedure'; + 3: s := 'function'; + end; + + if odSelected in State then + Font.Color := clWhite; + Font.Style := []; + TextOut(ARect.Left + 2, ARect.Top + 2, s); + w := TextWidth('constructor'); + Font.Color := clBlack; + if odSelected in State then + Font.Color := clWhite; + Font.Style := [fsBold]; + s := FCompletionLB.Items[Index]; + i := 1; + while (i <= Length(s)) and (s[i] in WordChars) do + Inc(i); + s := Copy(s, 1, i - 1); + TextOut(ARect.Left + w + 6, ARect.Top + 2, s); + w := w + TextWidth(s); + Font.Style := []; + s := Copy(FCompletionLB.Items[Index], i, 255); + if Pos(': Constructor', s) <> 0 then + s := Copy(s, 1, Pos(': Constructor', s) - 1); + TextOut(ARect.Left + w + 6, ARect.Top + 2, s); + end; + end; +end; + +procedure TfrxSyntaxMemo.DoLeft; +begin + Dec(FPos.X); + if FPos.X < 1 then + FPos.X := 1; + SetPos(FPos.X, FPos.Y); +end; + +procedure TfrxSyntaxMemo.DoRight; +begin + Inc(FPos.X); + if FPos.X > FMaxLength then + FPos.X := FMaxLength; + SetPos(FPos.X, FPos.Y); +end; + +procedure TfrxSyntaxMemo.DoUp; +begin + Dec(FPos.Y); + if FPos.Y < 1 then + FPos.Y := 1; + SetPos(FPos.X, FPos.Y); +end; + +procedure TfrxSyntaxMemo.DoDown; +begin + Inc(FPos.Y); + if FPos.Y > FText.Count then + FPos.Y := FText.Count; + SetPos(FPos.X, FPos.Y); +end; + +procedure TfrxSyntaxMemo.DoHome(Ctrl: Boolean); +begin + if Ctrl then + SetPos(1, 1) else + SetPos(1, FPos.Y); +end; + +procedure TfrxSyntaxMemo.DoEnd(Ctrl: Boolean); +begin + if Ctrl then + SetPos(LineLength(FText.Count - 1) + 1, FText.Count) else + SetPos(LineLength(FPos.Y - 1) + 1, FPos.Y); +end; + +procedure TfrxSyntaxMemo.DoPgUp; +begin + if FOffset.Y > FWindowSize.Y then + begin + Dec(FOffset.Y, FWindowSize.Y - 1); + Dec(FPos.Y, FWindowSize.Y - 1); + end + else + begin + if FOffset.Y > 0 then + begin + Dec(FPos.Y, FOffset.Y); + FOffset.Y := 0; + end + else + FPos.Y := 1; + end; + SetPos(FPos.X, FPos.Y); + Repaint; +end; + +procedure TfrxSyntaxMemo.DoPgDn; +begin + if FOffset.Y + FWindowSize.Y < FText.Count then + begin + Inc(FOffset.Y, FWindowSize.Y - 1); + Inc(FPos.Y, FWindowSize.Y - 1); + end + else + begin + FOffset.Y := FText.Count; + FPos.Y := FText.Count; + end; + SetPos(FPos.X, FPos.Y); + Repaint; +end; + +procedure TfrxSyntaxMemo.DoReturn; +var + s: String; +begin + s := LineAt(FPos.Y - 1); + FText[FPos.Y - 1] := Copy(s, 1, FPos.X - 1); + FText.Insert(FPos.Y, Copy(s, FPos.X, FMaxLength)); + EnterIndent; +end; + +procedure TfrxSyntaxMemo.DoDel; +var + s: String; +begin + FMessage := ''; + if FSelStart.X <> 0 then + SelText := '' + else + begin + s := FText[FPos.Y - 1]; + AddUndo; + if FPos.X <= LineLength(FPos.Y - 1) then + begin + Delete(s, FPos.X, 1); + FText[FPos.Y - 1] := s; + end + else if FPos.Y < FText.Count then + begin + s := s + Pad(FPos.X - Length(s) - 1) + LineAt(FPos.Y); + FText[FPos.Y - 1] := s; + FText.Delete(FPos.Y); + CorrectBookmark(FPos.Y, -1); + end; + UpdateScrollBar; + ClearSyntax(FPos.Y); + DoChange; + end; +end; + +procedure TfrxSyntaxMemo.DoBackspace; +var + s: String; +begin + FMessage := ''; + if FSelStart.X <> 0 then + SelText := '' + else + begin + s := FText[FPos.Y - 1]; + if FPos.X > 1 then + begin + if (GetLineBegin(FPos.Y - 1) = FPos.X) or (Trim(s) = '') then + UnIndent + else + begin + AddUndo; + if Trim(s) <> '' then + begin + Delete(s, FPos.X - 1, 1); + FText[FPos.Y - 1] := s; + DoLeft; + end + else + DoHome(False); + ClearSyntax(FPos.Y); + DoChange; + end; + end + else if FPos.Y > 1 then + begin + AddUndo; + CorrectBookmark(FPos.Y, -1); + s := LineAt(FPos.Y - 2); + FText[FPos.Y - 2] := s + FText[FPos.Y - 1]; + FText.Delete(FPos.Y - 1); + SetPos(Length(s) + 1, FPos.Y - 1); + ClearSyntax(FPos.Y); + DoChange; + end; + end; +end; + +procedure TfrxSyntaxMemo.DoCtrlI; +begin + if FSelStart.X <> 0 then + ShiftSelected(True); +end; + +procedure TfrxSyntaxMemo.DoCtrlU; +begin + if FSelStart.X <> 0 then + ShiftSelected(False); +end; + +procedure TfrxSyntaxMemo.DoCtrlL; +var + i: Integer; + s: String; +begin + s := FText.Text; + i := Length(LineAt(FPos.Y - 1)); + if FPos.X > i then + FPos.X := i; + + i := GetPlainTextPos(FPos); + + Dec(i); + while (i > 0) and not (s[i] in WordChars) do + if s[i] = #13 then + break else + Dec(i); + while (i > 0) and (s[i] in WordChars) do + Dec(i); + Inc(i); + + FPos := GetPosPlainText(i); + SetPos(FPos.X, FPos.Y); +end; + +procedure TfrxSyntaxMemo.DoCtrlR; +var + i: Integer; + s: String; +begin + s := FText.Text; + i := Length(LineAt(FPos.Y - 1)); + if FPos.X > i then + begin + DoDown; + DoHome(False); + FPos.X := 0; + end; + + i := GetPlainTextPos(FPos); + + while (i < Length(s)) and (s[i] in WordChars) do + Inc(i); + while (i < Length(s)) and not (s[i] in WordChars) do + if s[i] = #13 then + begin + while (i > 1) and (s[i - 1] = ' ') do + Dec(i); + break; + end + else + Inc(i); + + FPos := GetPosPlainText(i); + SetPos(FPos.X, FPos.Y); +end; + +procedure TfrxSyntaxMemo.DoChar(Ch: Char); +begin + SelText := Ch; +end; + +function TfrxSyntaxMemo.GetCharAttr(Pos: TPoint): TCharAttributes; + + function IsBlock: Boolean; + var + p1, p2, p3: Integer; + begin + Result := False; + if FSelStart.X = 0 then Exit; + + p1 := FSelStart.X + FSelStart.Y * FMaxLength; + p2 := FSelEnd.X + FSelEnd.Y * FMaxLength; + if p1 > p2 then + begin + p3 := p1; + p1 := p2; + p2 := p3; + end; + p3 := Pos.X + Pos.Y * FMaxLength; + Result := (p3 >= p1) and (p3 < p2); + end; + + function CharAttr: TCharAttr; + var + s: String; + begin + if Pos.Y - 1 < FSynStrings.Count then + begin + s := FSynStrings[Pos.Y - 1]; + if Pos.X <= Length(s) then + Result := TCharAttr(Ord(s[Pos.X])) else + Result := caText; + end + else + Result := caText; + end; + +begin + Result := [CharAttr]; + if IsBlock then + Result := Result + [caBlock]; +end; + +procedure TfrxSyntaxMemo.Paint; +var + i, j, j1: Integer; + a, a1: TCharAttributes; + s: String; + + procedure SetAttr(a: TCharAttributes; Line: Integer); + begin + with Canvas do + begin + Brush.Color := Color; + + if caText in a then + Font.Assign(FTextAttr); + + if caComment in a then + Font.Assign(FCommentAttr); + + if caKeyword in a then + Font.Assign(FKeywordAttr); + + if caNumber in a then + Font.Assign(FNumberAttr); + + if caString in a then + Font.Assign(FStringAttr); + + if (caBlock in a) or (Line = FActiveLine - 1) then + begin + Brush.Color := FBlockColor; + Font.Color := FBlockFontColor; + end; + + Font.Charset := Self.Font.Charset; + end; + end; + + procedure MyTextOut(x, y: Integer; const s: String); + var + i: Integer; + begin + if FIsMonoType then + begin + Canvas.FillRect(Rect(x, y, x + Length(s) * FCharWidth, y + FCharHeight)); + Canvas.TextOut(x, y, s) + end + else + with Canvas do + begin + FillRect(Rect(x, y, x + Length(s) * FCharWidth, y + FCharHeight)); + for i := 1 to Length(s) do + TextOut(x + (i - 1) * FCharWidth, y, s[i]); + MoveTo(x + Length(s) * FCharWidth, y); + end; + end; + + procedure DrawLineMarks(Line, Y: Integer); + begin + if not FShowGutter then Exit; + if IsBookmark(Line) >= 0 then + with Canvas do + begin + Brush.Color := clBlack; + FillRect(Rect(13, Y + 3, 23, Y + 14)); + Brush.Color := clGreen; + FillRect(Rect(12, Y + 4, 22, Y + 15)); + Font.Name := 'Tahoma'; + Font.Color := clWhite; + Font.Style := [fsBold]; + Font.Size := 7; + TextOut(14, Y + 4, IntToStr(IsBookmark(Line))); + end; + if RunLine[Line + 1] then + with Canvas do + begin + Brush.Color := clBlue; + Pen.Color := clBlack; + Ellipse(4, Y + 7, 8, Y + 11); + Pixels[5, Y + 7] := clAqua; + Pixels[4, Y + 8] := clAqua; + end; + if IsBreakPoint(Line + 1) then + with Canvas do + begin + Brush.Color := clRed; + Pen.Color := clRed; + Ellipse(2, Y + 4, 13, Y + 15); + end; + end; + +begin + inherited; + + with Canvas do + begin + Brush.Color := clBtnFace; + FillRect(Rect(0, 0, FGutterWidth - 2, Height)); + Pen.Color := clBtnHighlight; + MoveTo(FGutterWidth - 4, 0); + LineTo(FGutterWidth - 4, Height + 1); + + if FUpdatingSyntax then Exit; + CreateSynArray(FOffset.Y + FWindowSize.Y - 1); + + for i := FOffset.Y to FOffset.Y + FWindowSize.Y - 1 do + begin + if i >= FText.Count then break; + + s := FText[i]; + PenPos := Point(FGutterWidth, (i - FOffset.Y) * FCharHeight); + j1 := FOffset.X + 1; + a := GetCharAttr(Point(j1, i + 1)); + a1 := a; + + for j := j1 to FOffset.X + FWindowSize.X do + begin + if j > Length(s) then break; + + a1 := GetCharAttr(Point(j, i + 1)); + if a1 <> a then + begin + SetAttr(a, i); + MyTextOut(PenPos.X, PenPos.Y, Copy(FText[i], j1, j - j1)); + a := a1; + j1 := j; + end; + end; + + SetAttr(a, i); + MyTextOut(PenPos.X, PenPos.Y, Copy(s, j1, FMaxLength)); + if (caBlock in GetCharAttr(Point(1, i + 1))) or (i = FActiveLine - 1) then + MyTextOut(PenPos.X, PenPos.Y, Pad(FWindowSize.X - Length(s) - FOffset.X + 3)); + + DrawLineMarks(i, PenPos.Y); + end; + + if FMessage <> '' then + begin + Font.Name := 'Tahoma'; + Font.Color := clWhite; + Font.Style := [fsBold]; + Font.Size := 8; + Brush.Color := clMaroon; + FillRect(Rect(0, ClientHeight - TextHeight('|') - 6, ClientWidth, ClientHeight)); + TextOut(6, ClientHeight - TextHeight('|') - 5, FMessage); + end + end; +end; + +procedure TfrxSyntaxMemo.ClearSyntax(ClearFrom: Integer); +begin + Dec(ClearFrom); + if ClearFrom < 1 then + ClearFrom := 1; + FUpdatingSyntax := True; + while FSynStrings.Count > ClearFrom - 1 do + FSynStrings.Delete(FSynStrings.Count - 1); + FUpdatingSyntax := False; + Repaint; +end; + +procedure TfrxSyntaxMemo.CreateSynArray(EndLine: Integer); +var + i, j, n, Max: Integer; + FSyn, s: String; + attr: TCharAttr; +begin + if EndLine >= FText.Count then + EndLine := FText.Count - 1; + if EndLine <= FSynStrings.Count - 1 then Exit; + + FUpdatingSyntax := True; + FAllowLinesChange := False; + + for i := FSynStrings.Count to EndLine do + FSynStrings.Add(FText[i]); + FSyn := FSynStrings.Text; + FParser.Text := FText.Text; + Max := Length(FSyn); + + for i := Length(FSyn) downto 1 do + if FSyn[i] = Chr(Ord(caText)) then + begin + j := i; + while (j > 1) and (FSyn[j] = Chr(Ord(caText))) do + Dec(j); + FParser.Position := j + 1; + break; + end; + + while FParser.Position < Max do + begin + n := FParser.Position; + FParser.SkipSpaces; + for i := n to FParser.Position - 1 do + if i <= Max then + if FSyn[i] > #31 then + FSyn[i] := Chr(Ord(caComment)); + + attr := caText; + n := FParser.Position; + s := FParser.GetWord; + if s <> '' then + begin + if FParser.IsKeyword(s) then + attr := caKeyword; + end + else + begin + s := FParser.GetNumber; + if s <> '' then + attr := caNumber + else + begin + s := FParser.GetString; + if s <> '' then + attr := caString else + FParser.Position := FParser.Position + 1 + end + end; + + for i := n to FParser.Position - 1 do + if i <= Max then + if FSyn[i] > #31 then + FSyn[i] := Chr(Ord(attr)); + end; + + FSynStrings.Text := FSyn; + FUpdatingSyntax := False; + FAllowLinesChange := True; +end; + +procedure TfrxSyntaxMemo.UpdateView; +begin + Invalidate; +end; + +procedure TfrxSyntaxMemo.MouseWheelUp(Sender: TObject; + Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); +begin + VertPosition := VertPosition - SmallChange; +end; + +procedure TfrxSyntaxMemo.MouseWheelDown(Sender: TObject; + Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); +begin + VertPosition := VertPosition + SmallChange; +end; + +procedure TfrxSyntaxMemo.SetShowGutter(Value: Boolean); +begin + FShowGutter := Value; + if Value then + FGutterWidth := 30 else + FGutterWidth := 0; + Repaint; +end; + +function TfrxSyntaxMemo.IsBookmark(Line: Integer): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to 9 do + if FBookmarks[i] = Line then + begin + Result := i; + break; + end; +end; + +procedure TfrxSyntaxMemo.AddBookmark(Line, Number: Integer); +begin + if Number < Length(FBookmarks) then + begin + FBookmarks[Number] := Line; + Repaint; + end; +end; + +procedure TfrxSyntaxMemo.DeleteBookmark(Number: Integer); +begin + if Number < Length(FBookmarks) then + begin + FBookmarks[Number] := -1; + Repaint; + end; +end; + +procedure TfrxSyntaxMemo.CorrectBookmark(Line, Delta: Integer); +var + i: Integer; +begin + for i := 0 to Length(FBookmarks) - 1 do + if FBookmarks[i] >= Line then + Inc(FBookmarks[i], Delta); +end; + +procedure TfrxSyntaxMemo.GotoBookmark(Number : Integer); +begin + if Number < Length(FBookmarks) then + if FBookmarks[Number] >= 0 then + SetPos(0, FBookmarks[Number] + 1); +end; + +function TfrxSyntaxMemo.GetRunLine(Index: Integer): Boolean; +begin + if (Index < 1) or (Index > FText.Count) then + Result := False else + Result := FText.Objects[Index - 1] = Pointer(1); +end; + +procedure TfrxSyntaxMemo.SetRunLine(Index: Integer; const Value: Boolean); +begin + if (Index < 1) or (Index > FText.Count) then Exit; + if Value then + FText.Objects[Index - 1] := Pointer(1) else + FText.Objects[Index - 1] := Pointer(0); +end; + +function TfrxSyntaxMemo.Find(const SearchText: String; + CaseSensitive: Boolean; var SearchFrom: Integer): Boolean; +var + i: Integer; + s: String; +begin + i := 0; + Result := False; + if FText.Count > 1 then + begin + s := FText.Text; + if SearchFrom = 0 then + SearchFrom := 1; + s := Copy(s, SearchFrom, Length(s) - SearchFrom + 1); + if CaseSensitive then + begin + i := Pos(SearchText, s); + if i <> 0 then + Result := True; + end + else + begin + i := Pos(AnsiUpperCase(SearchText), AnsiUpperCase(s)); + if i <> 0 then + Result := True; + end; + end; + + if Result then + begin + Inc(SearchFrom, i); + FSelStart := GetPosPlainText(SearchFrom - 1); + FSelEnd := Point(FSelStart.X + Length(SearchText), FSelStart.Y); + Inc(SearchFrom, Length(SearchText)); + SetPos(FSelStart.X, FSelStart.Y); + Repaint; + end; +end; + +procedure TfrxSyntaxMemo.AddBreakPoint(Number: Integer; const Condition: String); +begin + FBreakPoints.AddObject(Condition, TObject(Number)); + Repaint; +end; + +procedure TfrxSyntaxMemo.ToggleBreakPoint(Number: Integer; const Condition: String); +begin + if IsBreakPoint(Number) then + DeleteBreakPoint(Number) + else + AddBreakPoint(Number, Condition); +end; + +procedure TfrxSyntaxMemo.DeleteBreakPoint(Number: Integer); +begin + if IsBreakPoint(Number) then + FBreakPoints.Delete(FBreakPoints.IndexOfObject(TObject(Number))); + Repaint; +end; + +function TfrxSyntaxMemo.IsBreakPoint(Number: Integer): Boolean; +begin + Result := FBreakPoints.IndexOfObject(TObject(Number)) <> -1; +end; + +function TfrxSyntaxMemo.GetBreakPointCondition(Number: Integer): String; +begin + Result := ''; + if IsBreakPoint(Number) then + Result := FBreakPoints[FBreakPoints.IndexOfObject(TObject(Number))]; +end; + +procedure TfrxSyntaxMemo.DeleteF4BreakPoints; +var + i: Integer; +begin + i := 0; + while i < FBreakPoints.Count do + if FBreakPoints[i] = 'F4' then + FBreakPoints.Delete(i) + else + Inc(i); +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxTee10.bdsproj b/official/4.2/LibD11/frxTee10.bdsproj new file mode 100644 index 0000000..833a6b8 --- /dev/null +++ b/official/4.2/LibD11/frxTee10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxTee10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxTee10.dpk b/official/4.2/LibD11/frxTee10.dpk new file mode 100644 index 0000000..f7a741c --- /dev/null +++ b/official/4.2/LibD11/frxTee10.dpk @@ -0,0 +1,50 @@ +// Package file for Delphi 2006 + +package frxTee10; + +{$I frx.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, TEEUI, {$ENDIF} +{$IFDEF TeeChartStd7}TEE710, TEEUI710, {$ENDIF} +{$IFDEF TeeChart4} TEE410, TEEPRO410, {$ENDIF} +{$IFDEF TeeChart5} TEE510, TEEPRO510, {$ENDIF} +{$IFDEF TeeChart6} TEE610, TEEPRO610, {$ENDIF} +{$IFDEF TeeChart7} TEE710, TEEPRO710, {$ENDIF} + fs10, + fsTee10, + frx10; + +contains + frxChart in 'frxChart.pas', + frxChartEditor in 'frxChartEditor.pas', + frxChartHelpers in 'frxChartHelpers.pas', + frxChartRTTI in 'frxChartRTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxTee11.bdsproj b/official/4.2/LibD11/frxTee11.bdsproj new file mode 100644 index 0000000..e0fc17b --- /dev/null +++ b/official/4.2/LibD11/frxTee11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxTee11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxTee11.dpk b/official/4.2/LibD11/frxTee11.dpk new file mode 100644 index 0000000..cbe6ebf --- /dev/null +++ b/official/4.2/LibD11/frxTee11.dpk @@ -0,0 +1,50 @@ +// Package file for Delphi 2007 + +package frxTee11; + +{$I frx.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, TEEUI, {$ENDIF} +{$IFDEF TeeChartStd7}TEE710, TEEUI710, {$ENDIF} +{$IFDEF TeeChart4} TEE410, TEEPRO410, {$ENDIF} +{$IFDEF TeeChart5} TEE510, TEEPRO510, {$ENDIF} +{$IFDEF TeeChart6} TEE610, TEEPRO610, {$ENDIF} +{$IFDEF TeeChart7} TEE710, TEEPRO710, {$ENDIF} + fs11, + fsTee11, + frx11; + +contains + frxChart in 'frxChart.pas', + frxChartEditor in 'frxChartEditor.pas', + frxChartHelpers in 'frxChartHelpers.pas', + frxChartRTTI in 'frxChartRTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxTee4.bpk b/official/4.2/LibD11/frxTee4.bpk new file mode 100644 index 0000000..c246e5b --- /dev/null +++ b/official/4.2/LibD11/frxTee4.bpk @@ -0,0 +1,189 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = frxTee4.bpl +OBJFILES = frxRegTee.obj frxTee4.obj frxChart.obj frxChartEditor.obj frxChartRTTI.obj +RESFILES = frx4.res frxReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +LIBRARIES = +SPARELIBS = VCL40.lib +PACKAGES = vcl40.bpi vclsmp40.bpi vcljpg40.bpi tee40.bpi teeui40.bpi vclx40.bpi fs4.bpi fsTee4.bpi frx4.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release;..\FastScript;..\FastQB +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -D"FastReport 4.0 Tee Components" -aa \ + -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName=Fast Reports Inc. +FileDescription=FastReport +FileVersion=4.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=4.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxTee4.cpp b/official/4.2/LibD11/frxTee4.cpp new file mode 100644 index 0000000..bb0c6a4 --- /dev/null +++ b/official/4.2/LibD11/frxTee4.cpp @@ -0,0 +1,28 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frx4.res"); +USEPACKAGE("vcl40.bpi"); +USEUNIT("frxRegTee.pas"); +USEUNIT("frxChart.pas"); +USEUNIT("frxChartEditor.pas"); +USEUNIT("frxChartRTTI.pas"); +USERES("frxReg.dcr"); +USEPACKAGE("vclsmp40.bpi"); +USEPACKAGE("vclx40.bpi"); +USEPACKAGE("vcljpg40.bpi"); +USEPACKAGE("tee40.bpi"); +USEPACKAGE("teeui40.bpi"); +USEPACKAGE("fs4.bpi"); +USEPACKAGE("fsTee4.bpi"); +USEPACKAGE("frx4.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxTee4.dpk b/official/4.2/LibD11/frxTee4.dpk new file mode 100644 index 0000000..45fa6d8 --- /dev/null +++ b/official/4.2/LibD11/frxTee4.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 4 + +package frxTee4; + +{$I frx.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, +{$IFDEF TeeChartStd} TEE40, TEEUI40, {$ENDIF} +{$IFDEF TeeChart4} TEE44, TEEPRO44, {$ENDIF} +{$IFDEF TeeChart5} TEE54, TEEPRO54, {$ENDIF} +{$IFDEF TeeChart6} TEE64, TEEPRO64, {$ENDIF} +{$IFDEF TeeChart7} TEE74, TEEPRO74, {$ENDIF} + fs4, + fsTee4, + frx4; + +contains + frxChart in 'frxChart.pas', + frxChartEditor in 'frxChartEditor.pas', + frxChartHelpers in 'frxChartHelpers.pas', + frxChartRTTI in 'frxChartRTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxTee5.bpk b/official/4.2/LibD11/frxTee5.bpk new file mode 100644 index 0000000..5838bc8 --- /dev/null +++ b/official/4.2/LibD11/frxTee5.bpk @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName=Fast Reports Inc. +FileDescription=FastReport +FileVersion=4.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=4.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxTee5.cpp b/official/4.2/LibD11/frxTee5.cpp new file mode 100644 index 0000000..2d987a5 --- /dev/null +++ b/official/4.2/LibD11/frxTee5.cpp @@ -0,0 +1,28 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frx5.res"); +USEUNIT("frxRegTee.pas"); +USEUNIT("frxChart.pas"); +USEUNIT("frxChartEditor.pas"); +USEUNIT("frxChartRTTI.pas"); +USERES("frxReg.dcr"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vclsmp50.bpi"); +USEPACKAGE("vclx50.bpi"); +USEPACKAGE("vcljpg50.bpi"); +USEPACKAGE("tee50.bpi"); +USEPACKAGE("teeui50.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("fsTee5.bpi"); +USEPACKAGE("frx5.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxTee5.dpk b/official/4.2/LibD11/frxTee5.dpk new file mode 100644 index 0000000..49fd7d1 --- /dev/null +++ b/official/4.2/LibD11/frxTee5.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 5 + +package frxTee5; + +{$I frx.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, +{$IFDEF TeeChartStd} TEE50, TEEUI50, {$ENDIF} +{$IFDEF TeeChart4} TEE45, TEEPRO45, {$ENDIF} +{$IFDEF TeeChart5} TEE55, TEEPRO55, {$ENDIF} +{$IFDEF TeeChart6} TEE65, TEEPRO65, {$ENDIF} +{$IFDEF TeeChart7} TEE75, TEEPRO75, {$ENDIF} + fs5, + fsTee5, + frx5; + +contains + frxChart in 'frxChart.pas', + frxChartEditor in 'frxChartEditor.pas', + frxChartHelpers in 'frxChartHelpers.pas', + frxChartRTTI in 'frxChartRTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxTee6.bpk b/official/4.2/LibD11/frxTee6.bpk new file mode 100644 index 0000000..7866c5a --- /dev/null +++ b/official/4.2/LibD11/frxTee6.bpk @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName=Fast Reports Inc. +FileDescription=FastReport +FileVersion=4.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=4.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxTee6.cpp b/official/4.2/LibD11/frxTee6.cpp new file mode 100644 index 0000000..48ce892 --- /dev/null +++ b/official/4.2/LibD11/frxTee6.cpp @@ -0,0 +1,18 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frxTee6.dpk b/official/4.2/LibD11/frxTee6.dpk new file mode 100644 index 0000000..02d205d --- /dev/null +++ b/official/4.2/LibD11/frxTee6.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 6 + +package frxTee6; + +{$I frx.inc} +{$I tee.inc} + +{$ALIGN 8} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, TEEUI, {$ENDIF} +{$IFDEF TeeChart4} TEE46, TEEPRO46, {$ENDIF} +{$IFDEF TeeChart5} TEE56, TEEPRO56, {$ENDIF} +{$IFDEF TeeChart6} TEE66, TEEPRO66, {$ENDIF} +{$IFDEF TeeChart7} TEE76, TEEPRO76, {$ENDIF} + fs6, + fsTee6, + frx6; + +contains + frxChart in 'frxChart.pas', + frxChartEditor in 'frxChartEditor.pas', + frxChartHelpers in 'frxChartHelpers.pas', + frxChartRTTI in 'frxChartRTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxTee7.dpk b/official/4.2/LibD11/frxTee7.dpk new file mode 100644 index 0000000..c34f08d --- /dev/null +++ b/official/4.2/LibD11/frxTee7.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 7 + +package frxTee7; + +{$I frx.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, TEEUI, {$ENDIF} +{$IFDEF TeeChart4} TEE47, TEEPRO47, {$ENDIF} +{$IFDEF TeeChart5} TEE57, TEEPRO57, {$ENDIF} +{$IFDEF TeeChart6} TEE67, TEEPRO67, {$ENDIF} +{$IFDEF TeeChart7} TEE77, TEEPRO77, {$ENDIF} + fs7, + fsTee7, + frx7; + +contains + frxChart in 'frxChart.pas', + frxChartEditor in 'frxChartEditor.pas', + frxChartHelpers in 'frxChartHelpers.pas', + frxChartRTTI in 'frxChartRTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxTee9.bdsproj b/official/4.2/LibD11/frxTee9.bdsproj new file mode 100644 index 0000000..ee432f3 --- /dev/null +++ b/official/4.2/LibD11/frxTee9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxTee9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxTee9.dpk b/official/4.2/LibD11/frxTee9.dpk new file mode 100644 index 0000000..2a6cd3d --- /dev/null +++ b/official/4.2/LibD11/frxTee9.dpk @@ -0,0 +1,49 @@ +// Package file for Delphi 2005 + +package frxTee9; + +{$I frx.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, TEEUI, {$ENDIF} +{$IFDEF TeeChart4} TEE49, TEEPRO49, {$ENDIF} +{$IFDEF TeeChart5} TEE59, TEEPRO59, {$ENDIF} +{$IFDEF TeeChart6} TEE69, TEEPRO69, {$ENDIF} +{$IFDEF TeeChart7} TEE79, TEEPRO79, {$ENDIF} + fs9, + fsTee9, + frx9; + +contains + frxChart in 'frxChart.pas', + frxChartEditor in 'frxChartEditor.pas', + frxChartHelpers in 'frxChartHelpers.pas', + frxChartRTTI in 'frxChartRTTI.pas'; + +end. diff --git a/official/4.2/LibD11/frxUnicodeCtrls.pas b/official/4.2/LibD11/frxUnicodeCtrls.pas new file mode 100644 index 0000000..c70f4b4 --- /dev/null +++ b/official/4.2/LibD11/frxUnicodeCtrls.pas @@ -0,0 +1,582 @@ +{*******************************************************} +{ The Delphi Unicode Controls Project } +{ } +{ http://home.ccci.org/wolbrink } +{ } +{ Copyright (c) 2002, Troy Wolbrink (wolbrink@ccci.org) } +{ } +{*******************************************************} + +unit frxUnicodeCtrls; + +interface + +{$I frx.inc} + +uses Windows, Messages, Classes, Controls, Forms, StdCtrls; + +type + TUnicodeEdit = class(TEdit) + private + procedure SetSelText(const Value: WideString); + function GetText: WideString; + procedure SetText(const Value: WideString); + protected + procedure CreateWindowHandle(const Params: TCreateParams); override; + function GetSelText: WideString; reintroduce; + public + property SelText: WideString read GetSelText write SetSelText; + property Text: WideString read GetText write SetText; + end; + + TUnicodeMemo = class(TMemo) + private + procedure SetSelText(const Value: WideString); + function GetText: WideString; + procedure SetText(const Value: WideString); + protected + procedure CreateWindowHandle(const Params: TCreateParams); override; + function GetSelText: WideString; reintroduce; + public + property SelText: WideString read GetSelText write SetSelText; + property Text: WideString read GetText write SetText; + end; + + +implementation + +uses SysUtils, Graphics, Imm; + +const + UNICODE_CLASS_EXT = '.UnicodeClass'; + ANSI_UNICODE_HOLDER = $FF; + +var + UnicodeCreationControl: TWinControl = nil; + Win32PlatformIsUnicode: Boolean; + Win32PlatformIsXP: Boolean; + +{$IFDEF Delphi6} +function MakeObjectInstance(Method: TWndMethod): Pointer; +begin + Result := Classes.MakeObjectInstance(Method); +end; + +procedure FreeObjectInstance(ObjectInstance: Pointer); +begin + Classes.FreeObjectInstance(ObjectInstance); +end; +{$ENDIF} + +function IsUnicodeCreationControl(Handle: HWND): Boolean; +begin + Result := (UnicodeCreationControl <> nil) + and (UnicodeCreationControl.HandleAllocated) + and (UnicodeCreationControl.Handle = Handle); +end; + +function WMNotifyFormatResult(FromHandle: HWND): Integer; +begin + if Win32PlatformIsUnicode + and (IsWindowUnicode(FromHandle) or IsUnicodeCreationControl(FromHandle)) then + Result := NFR_UNICODE + else + Result := NFR_ANSI; +end; + +function IsTextMessage(Msg: UINT): Boolean; +begin + // WM_CHAR is omitted because of the special handling it receives + Result := (Msg = WM_SETTEXT) + or (Msg = WM_GETTEXT) + or (Msg = WM_GETTEXTLENGTH); +end; + +procedure MakeWMCharMsgSafeForAnsi(var Message: TMessage); +begin + with TWMChar(Message) do begin + Assert(Msg = WM_CHAR); + Assert(Unused = 0); + if (CharCode > Word(High(AnsiChar))) then begin + Unused := CharCode; + CharCode := ANSI_UNICODE_HOLDER; + end; + end; +end; + +procedure RestoreWMCharMsg(var Message: TMessage); +begin + with TWMChar(Message) do begin + Assert(Message.Msg = WM_CHAR); + if (Unused > 0) + and (CharCode = ANSI_UNICODE_HOLDER) then + CharCode := Unused; + Unused := 0; + end; +end; + +//----------------------------------------------------------------------------------- +type + TAccessControl = class(TControl); + TAccessWinControl = class(TWinControl); + + TWinControlTrap = class(TComponent) + private + WinControl_ObjectInstance: Pointer; + ObjectInstance: Pointer; + DefObjectInstance: Pointer; + function IsInSubclassChain(Control: TWinControl): Boolean; + procedure SubClassWindowProc; + private + FControl: TAccessWinControl; + Handle: THandle; + PrevWin32Proc: Pointer; + PrevDefWin32Proc: Pointer; + PrevWindowProc: TWndMethod; + private + LastWin32Msg: UINT; + Win32ProcLevel: Integer; + IDEWindow: Boolean; + DestroyTrap: Boolean; + TestForNull: Boolean; + FoundNull: Boolean; + {$IFDEF TNT_VERIFY_WINDOWPROC} + LastVerifiedWindowProc: TWndMethod; + {$ENDIF} + procedure Win32Proc(var Message: TMessage); + procedure DefWin32Proc(var Message: TMessage); + procedure WindowProc(var Message: TMessage); + private + procedure SubClassControl(Params_Caption: PAnsiChar); + procedure UnSubClassUnicodeControl; + protected + procedure Notification(AComponent: TComponent; Operation: TOperation); override; + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + end; + +constructor TWinControlTrap.Create(AOwner: TComponent); +begin + FControl := TAccessWinControl(AOwner as TWinControl); + inherited Create(nil); + FControl.FreeNotification(Self); + + WinControl_ObjectInstance := MakeObjectInstance(FControl.MainWndProc); + ObjectInstance := MakeObjectInstance(Win32Proc); + DefObjectInstance := MakeObjectInstance(DefWin32Proc); +end; + +destructor TWinControlTrap.Destroy; +begin + FreeObjectInstance(ObjectInstance); + FreeObjectInstance(DefObjectInstance); + FreeObjectInstance(WinControl_ObjectInstance); + inherited; +end; + +procedure TWinControlTrap.Notification(AComponent: TComponent; Operation: TOperation); +begin + inherited; + if (AComponent = FControl) and (Operation = opRemove) then begin + FControl := nil; + if Win32ProcLevel = 0 then + Free + else + DestroyTrap := True; + end; +end; + +procedure TWinControlTrap.SubClassWindowProc; +begin + if not IsInSubclassChain(FControl) then begin + PrevWindowProc := FControl.WindowProc; + FControl.WindowProc := Self.WindowProc; + end; +end; + +procedure TWinControlTrap.SubClassControl(Params_Caption: PAnsiChar); +begin + // initialize trap object + Handle := FControl.Handle; + PrevWin32Proc := Pointer(GetWindowLongW(FControl.Handle, GWL_WNDPROC)); + PrevDefWin32Proc := FControl.DefWndProc; + + // subclass Window Procedures + SetWindowLongW(FControl.Handle, GWL_WNDPROC, Integer(ObjectInstance)); + FControl.DefWndProc := DefObjectInstance; + SubClassWindowProc; +end; + +function SameWndMethod(A, B: TWndMethod): Boolean; +begin + Result := @A = @B; +end; + +var + PendingRecreateWndTrapList: TList = nil; + +procedure TWinControlTrap.UnSubClassUnicodeControl; +begin + // restore window procs (restore WindowProc only if we are still the direct subclass) + if SameWndMethod(FControl.WindowProc, Self.WindowProc) then + FControl.WindowProc := PrevWindowProc; + TAccessWinControl(FControl).DefWndProc := PrevDefWin32Proc; + SetWindowLongW(FControl.Handle, GWL_WNDPROC, Integer(PrevWin32Proc)); + + if IDEWindow then + DestroyTrap := True + else if not (csDestroying in FControl.ComponentState) then + // control not being destroyed, probably recreating window + PendingRecreateWndTrapList.Add(Self); +end; + +var + Finalized: Boolean; { If any tnt controls are still around after finalization it must be due to a memory leak. + Windows will still try to send a WM_DESTROY, but we will just ignore it if we're finalized. } + +procedure TWinControlTrap.Win32Proc(var Message: TMessage); +begin + if (not Finalized) then begin + Inc(Win32ProcLevel); + try + with Message do begin + LastWin32Msg := Msg; + Result := CallWindowProcW(PrevWin32Proc, Handle, Msg, wParam, lParam); + end; + finally + Dec(Win32ProcLevel); + end; + if (Win32ProcLevel = 0) and (DestroyTrap) then + Free; + end else if (Message.Msg = WM_DESTROY) then + FControl.WindowHandle := 0 +end; + +procedure TWinControlTrap.DefWin32Proc(var Message: TMessage); +begin + with Message do begin + if Msg = WM_NOTIFYFORMAT then + Result := WMNotifyFormatResult(Message.wParam) + else begin + if (Msg = WM_CHAR) then begin + RestoreWMCharMsg(Message) + end; + if (Msg = WM_IME_CHAR) and (not Win32PlatformIsXP) then + begin + { In Windows XP, DefWindowProc handles WM_IME_CHAR fine for VCL windows. } + { Before XP, DefWindowProc will sometimes produce incorrect, non-Unicode WM_CHAR. } + { Also, using PostMessageW on Windows 2000 didn't always produce the correct results. } + Message.Result := SendMessageW(Handle, WM_CHAR, wParam, lParam) + end else begin + if (Msg = WM_DESTROY) then begin + UnSubClassUnicodeControl; {The reason for doing this in DefWin32Proc is because in D9, TWinControl.WMDestroy() does a perform(WM_TEXT) operation. } + end; + { Normal DefWindowProc } + Result := CallWindowProcW(PrevDefWin32Proc, Handle, Msg, wParam, lParam); + end; + end; + end; +end; + +function TWinControlTrap.IsInSubclassChain(Control: TWinControl): Boolean; +var + Message: TMessage; +begin + if SameWndMethod(Control.WindowProc, TAccessWinControl(Control).WndProc) then + Result := False { no subclassing } + else if SameWndMethod(Control.WindowProc, Self.WindowProc) then + Result := True { directly subclassed } + else begin + TestForNull := True; + FoundNull := False; + ZeroMemory(@Message, SizeOf(Message)); + Message.Msg := WM_NULL; + Control.WindowProc(Message); + Result := FoundNull; { indirectly subclassed } + end; +end; + +procedure TWinControlTrap.WindowProc(var Message: TMessage); +var + CameFromWindows: Boolean; +begin + if TestForNull and (Message.Msg = WM_NULL) then + FoundNull := True; + + if (not FControl.HandleAllocated) then + FControl.WndProc(Message) + else begin + CameFromWindows := LastWin32Msg <> WM_NULL; + LastWin32Msg := WM_NULL; + with Message do begin + if (not CameFromWindows) + and (IsTextMessage(Msg)) then + Result := SendMessageA(Handle, Msg, wParam, lParam) + else begin + if (Msg = WM_CHAR) then begin + MakeWMCharMsgSafeForAnsi(Message); + end; + PrevWindowProc(Message) + end; + end; + end; +end; + +//---------------------------------------------------------------------------------- + +function FindOrCreateWinControlTrap(Control: TWinControl): TWinControlTrap; +var + i: integer; +begin + // find or create trap object + Result := nil; + for i := PendingRecreateWndTrapList.Count - 1 downto 0 do begin + if TWinControlTrap(PendingRecreateWndTrapList[i]).FControl = Control then begin + Result := TWinControlTrap(PendingRecreateWndTrapList[i]); + PendingRecreateWndTrapList.Delete(i); + break; { found it } + end; + end; + if Result = nil then + Result := TWinControlTrap.Create(Control); +end; + +procedure SubClassUnicodeControl(Control: TWinControl; Params_Caption: PAnsiChar; IDEWindow: Boolean = False); +var + WinControlTrap: TWinControlTrap; +begin + if not IsWindowUnicode(Control.Handle) then + raise Exception.Create('Internal Error: SubClassUnicodeControl.Control is not Unicode.'); + + WinControlTrap := FindOrCreateWinControlTrap(Control); + WinControlTrap.SubClassControl(Params_Caption); + WinControlTrap.IDEWindow := IDEWindow; +end; + + +//----------------------------------------------- CREATE/DESTROY UNICODE HANDLE + +var + WindowAtom: TAtom; + ControlAtom: TAtom; + WindowAtomString: AnsiString; + ControlAtomString: AnsiString; + +type + TWndProc = function(HWindow: HWnd; Message, WParam, LParam: Longint): Longint; stdcall; + +function InitWndProcW(HWindow: HWnd; Message, WParam, LParam: Longint): Longint; stdcall; + + function GetObjectInstance(Control: TWinControl): Pointer; + var + WinControlTrap: TWinControlTrap; + begin + WinControlTrap := FindOrCreateWinControlTrap(Control); + PendingRecreateWndTrapList.Add(WinControlTrap); + Result := WinControlTrap.WinControl_ObjectInstance; + end; + +var + ObjectInstance: Pointer; +begin + TAccessWinControl(CreationControl).WindowHandle := HWindow; + ObjectInstance := GetObjectInstance(CreationControl); + {Controls.InitWndProc converts control to ANSI here by calling SetWindowLongA()!} + SetWindowLongW(HWindow, GWL_WNDPROC, Integer(ObjectInstance)); + if (GetWindowLongW(HWindow, GWL_STYLE) and WS_CHILD <> 0) + and (GetWindowLongW(HWindow, GWL_ID) = 0) then + SetWindowLongW(HWindow, GWL_ID, Integer(HWindow)); + SetProp(HWindow, MakeIntAtom(ControlAtom), THandle(CreationControl)); + SetProp(HWindow, MakeIntAtom(WindowAtom), THandle(CreationControl)); + CreationControl := nil; + Result := TWndProc(ObjectInstance)(HWindow, Message, WParam, lParam); +end; + +procedure RegisterUnicodeClass(Params: TCreateParams; out WideWinClassName: WideString; IDEWindow: Boolean = False); +var + TempClass: TWndClassW; + WideClass: TWndClassW; + ClassRegistered: Boolean; + InitialProc: TFNWndProc; +begin + if IDEWindow then + InitialProc := @InitWndProc + else + InitialProc := @InitWndProcW; + + with Params do begin + WideWinClassName := WinClassName + UNICODE_CLASS_EXT; + ClassRegistered := GetClassInfoW(hInstance, PWideChar(WideWinClassName), TempClass); + if (not ClassRegistered) or (TempClass.lpfnWndProc <> InitialProc) + then begin + if ClassRegistered then Win32Check(Windows.UnregisterClassW(PWideChar(WideWinClassName), hInstance)); + // Prepare a TWndClassW record + WideClass := TWndClassW(WindowClass); + WideClass.hInstance := hInstance; + WideClass.lpfnWndProc := InitialProc; + WideClass.lpszMenuName := PWideChar(WideString(WindowClass.lpszMenuName)); + WideClass.lpszClassName := PWideChar(WideWinClassName); + + // Register the UNICODE class + RegisterClassW(WideClass); + end; + end; +end; + +procedure CreateUnicodeHandle(Control: TWinControl; const Params: TCreateParams; + const SubClass: WideString; IDEWindow: Boolean = False); +var + TempSubClass: TWndClassW; + WideWinClassName: WideString; + Handle: THandle; +begin + if (not Win32PlatformIsUnicode) then begin + with Params do + TAccessWinControl(Control).WindowHandle := CreateWindowEx(ExStyle, WinClassName, + Caption, Style, X, Y, Width, Height, WndParent, 0, WindowClass.hInstance, Param); + end else begin + // SubClass the unicode version of this control by getting the correct DefWndProc + if (SubClass <> '') + and GetClassInfoW(Params.WindowClass.hInstance, PWideChar(SubClass), TempSubClass) then + TAccessWinControl(Control).DefWndProc := TempSubClass.lpfnWndProc + else + TAccessWinControl(Control).DefWndProc := @DefWindowProcW; + + // make sure Unicode window class is registered + RegisterUnicodeClass(Params, WideWinClassName, IDEWindow); + + // Create UNICODE window handle + UnicodeCreationControl := Control; + try + with Params do + Handle := CreateWindowExW(ExStyle, PWideChar(WideWinClassName), nil, + Style, X, Y, Width, Height, WndParent, 0, hInstance, Param); + TAccessWinControl(Control).WindowHandle := Handle; + if IDEWindow then + SetWindowLongW(Handle, GWL_WNDPROC, GetWindowLong(Handle, GWL_WNDPROC)); + finally + UnicodeCreationControl := nil; + end; + + SubClassUnicodeControl(Control, Params.Caption, IDEWindow); + end; +end; + + +//----------------------------------------------- GET/SET WINDOW TEXT + +function WideGetWindowText(Control: TWinControl): WideString; +begin + if (not Control.HandleAllocated) + or (not IsWindowUnicode(Control.Handle)) then begin + // NO HANDLE -OR- NOT UNICODE + result := TAccessWinControl(Control).Text; + end else begin + // UNICODE & HANDLE + SetLength(Result, GetWindowTextLengthW(Control.Handle) + 1); + GetWindowTextW(Control.Handle, PWideChar(Result), Length(Result)); + SetLength(Result, Length(Result) - 1); + end; +end; + +procedure WideSetWindowText(Control: TWinControl; const Text: WideString); +begin + if (not Control.HandleAllocated) + or (not IsWindowUnicode(Control.Handle)) then begin + // NO HANDLE -OR- NOT UNICODE + TAccessWinControl(Control).Text := Text; + end else if WideGetWindowText(Control) <> Text then begin + // UNICODE & HANDLE + SetWindowTextW(Control.Handle, PWideChar(Text)); + Control.Perform(CM_TEXTCHANGED, 0, 0); + end; +end; + + + +{ TUnicodeEdit } + +procedure TUnicodeEdit.CreateWindowHandle(const Params: TCreateParams); +begin + CreateUnicodeHandle(Self, Params, 'EDIT'); +end; + +function TUnicodeEdit.GetSelText: WideString; +begin + Result := Copy(GetText, SelStart + 1, SelLength); +end; + +function TUnicodeEdit.GetText: WideString; +begin + Result := WideGetWindowText(Self); +end; + +procedure TUnicodeEdit.SetSelText(const Value: WideString); +begin + SendMessageW(Handle, EM_REPLACESEL, 0, Longint(PWideChar(Value))); +end; + +procedure TUnicodeEdit.SetText(const Value: WideString); +begin + WideSetWindowText(Self, Value); +end; + + +{ TUnicodeMemo } + +procedure TUnicodeMemo.CreateWindowHandle(const Params: TCreateParams); +begin + CreateUnicodeHandle(Self, Params, 'EDIT'); +end; + +function TUnicodeMemo.GetSelText: WideString; +begin + Result := Copy(GetText, SelStart + 1, SelLength); +end; + +function TUnicodeMemo.GetText: WideString; +begin + Result := WideGetWindowText(Self); +end; + +procedure TUnicodeMemo.SetSelText(const Value: WideString); +begin + SendMessageW(Handle, EM_REPLACESEL, 0, Longint(PWideChar(Value))); +end; + +procedure TUnicodeMemo.SetText(const Value: WideString); +begin + WideSetWindowText(Self, Value); +end; + + +procedure InitControls; +var + Controls_HInstance: Cardinal; +begin + Controls_HInstance := FindClassHInstance(TWinControl); + WindowAtomString := Format('Delphi%.8X',[GetCurrentProcessID]); + ControlAtomString := Format('ControlOfs%.8X%.8X', [Controls_HInstance, GetCurrentThreadID]); + WindowAtom := (GlobalAddAtom(PAnsiChar(WindowAtomString))); + ControlAtom := (GlobalAddAtom(PAnsiChar(ControlAtomString))); +end; + +initialization + Win32PlatformIsUnicode := (Win32Platform = VER_PLATFORM_WIN32_NT); + Win32PlatformIsXP := ((Win32MajorVersion = 5) and (Win32MinorVersion >= 1)) + or (Win32MajorVersion > 5); + PendingRecreateWndTrapList := TList.Create; + InitControls; + +finalization + GlobalDeleteAtom(ControlAtom); + GlobalDeleteAtom(WindowAtom); + PendingRecreateWndTrapList.Free; + PendingRecreateWndTrapList := nil; + Finalized := True; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxUnicodeUtils.pas b/official/4.2/LibD11/frxUnicodeUtils.pas new file mode 100644 index 0000000..6f1524c --- /dev/null +++ b/official/4.2/LibD11/frxUnicodeUtils.pas @@ -0,0 +1,637 @@ +{*******************************************************} +{ The Delphi Unicode Controls Project } +{ } +{ http://home.ccci.org/wolbrink } +{ } +{ Copyright (c) 2002, Troy Wolbrink (wolbrink@ccci.org) } +{ } +{*******************************************************} + +unit frxUnicodeUtils; + +interface + +{$I frx.inc} + +uses Windows, Classes, SysUtils; + +type + TWString = record + WString: WideString; + Obj: TObject; + end; + + TWideStrings = class(TPersistent) + private + FWideStringList: TList; + function Get(Index: Integer): WideString; + procedure Put(Index: Integer; const S: WideString); + function GetObject(Index: Integer): TObject; + procedure PutObject(Index: Integer; const Value: TObject); + procedure ReadData(Reader: TReader); + procedure ReadDataW(Reader: TReader); + procedure WriteDataW(Writer: TWriter); + function GetTextStr: WideString; + procedure SetTextStr(const Value: WideString); + protected + procedure AssignTo(Dest: TPersistent); override; + procedure DefineProperties(Filer: TFiler); override; + public + constructor Create; + destructor Destroy; override; + procedure Assign(Source: TPersistent); override; + function Count: Integer; + procedure Clear; + procedure Delete(Index: Integer); + function Add(const S: WideString): Integer; + procedure AddStrings(Strings: TWideStrings); + function AddObject(const S: WideString; AObject: TObject): Integer; + function IndexOf(const S: WideString): Integer; + procedure Insert(Index: Integer; const S: WideString); + procedure LoadFromFile(const FileName: WideString); + procedure LoadFromStream(Stream: TStream); + procedure LoadFromWStream(Stream: TStream); + procedure SaveToFile(const FileName: WideString); + procedure SaveToStream(Stream: TStream); + property Objects[Index: Integer]: TObject read GetObject write PutObject; + property Strings[Index: Integer]: WideString read Get write Put; default; + property Text: WideString read GetTextStr write SetTextStr; + end; + + +{$IFNDEF Delphi6} +function Utf8Encode(const WS: WideString): String; +function UTF8Decode(const S: String): WideString; +function VarToWideStr(const V: Variant): WideString; +{$ENDIF} +function AnsiToUnicode(const s: String; Charset: UINT): WideString; + + +implementation + +const + sLineBreak = #13#10; + WideLineSeparator = WideChar($2028); + NameValueSeparator = '='; + + +{$IFNDEF Delphi6} +function Utf8Encode(const WS: WideString): String; +var + L: Integer; + Temp: String; + + function ToUtf8(Dest: PChar; MaxDestBytes: Cardinal; + Source: PWideChar; SourceChars: Cardinal): Cardinal; + var + i, count: Cardinal; + c: Cardinal; + begin + Result := 0; + if Source = nil then Exit; + count := 0; + i := 0; + if Dest <> nil then + begin + while (i < SourceChars) and (count < MaxDestBytes) do + begin + c := Cardinal(Source[i]); + Inc(i); + if c <= $7F then + begin + Dest[count] := Char(c); + Inc(count); + end + else if c > $7FF then + begin + if count + 3 > MaxDestBytes then + break; + Dest[count] := Char($E0 or (c shr 12)); + Dest[count+1] := Char($80 or ((c shr 6) and $3F)); + Dest[count+2] := Char($80 or (c and $3F)); + Inc(count,3); + end + else // $7F < Source[i] <= $7FF + begin + if count + 2 > MaxDestBytes then + break; + Dest[count] := Char($C0 or (c shr 6)); + Dest[count+1] := Char($80 or (c and $3F)); + Inc(count,2); + end; + end; + if count >= MaxDestBytes then count := MaxDestBytes-1; + Dest[count] := #0; + end + else + begin + while i < SourceChars do + begin + c := Integer(Source[i]); + Inc(i); + if c > $7F then + begin + if c > $7FF then + Inc(count); + Inc(count); + end; + Inc(count); + end; + end; + Result := count+1; + end; + +begin + Result := ''; + if WS = '' then Exit; + SetLength(Temp, Length(WS) * 3); + L := ToUtf8(PChar(Temp), Length(Temp)+1, PWideChar(WS), Length(WS)); + if L > 0 then + SetLength(Temp, L-1) + else + Temp := ''; + Result := Temp; +end; + +function Utf8Decode(const S: String): WideString; +var + L: Integer; + Temp: WideString; + + function Utf8ToUnicode(Dest: PWideChar; MaxDestChars: Cardinal; Source: PChar; SourceBytes: Cardinal): Cardinal; + var + i, count: Cardinal; + c: Byte; + wc: Cardinal; + begin + if Source = nil then + begin + Result := 0; + Exit; + end; + Result := Cardinal(-1); + count := 0; + i := 0; + if Dest <> nil then + begin + while (i < SourceBytes) and (count < MaxDestChars) do + begin + wc := Cardinal(Source[i]); + Inc(i); + if (wc and $80) <> 0 then + begin + wc := wc and $3F; + if i > SourceBytes then Exit; // incomplete multibyte char + if (wc and $20) <> 0 then + begin + c := Byte(Source[i]); + Inc(i); + if (c and $C0) <> $80 then Exit; // malformed trail byte or out of range char + if i > SourceBytes then Exit; // incomplete multibyte char + wc := (wc shl 6) or (c and $3F); + end; + c := Byte(Source[i]); + Inc(i); + if (c and $C0) <> $80 then Exit; // malformed trail byte + + Dest[count] := WideChar((wc shl 6) or (c and $3F)); + end + else + Dest[count] := WideChar(wc); + Inc(count); + end; + if count >= MaxDestChars then count := MaxDestChars-1; + Dest[count] := #0; + end + else + begin + while (i <= SourceBytes) do + begin + c := Byte(Source[i]); + Inc(i); + if (c and $80) <> 0 then + begin + if (c and $F0) = $F0 then Exit; // too many bytes for UCS2 + if (c and $40) = 0 then Exit; // malformed lead byte + if i > SourceBytes then Exit; // incomplete multibyte char + + if (Byte(Source[i]) and $C0) <> $80 then Exit; // malformed trail byte + Inc(i); + if i > SourceBytes then Exit; // incomplete multibyte char + if ((c and $20) <> 0) and ((Byte(Source[i]) and $C0) <> $80) then Exit; // malformed trail byte + Inc(i); + end; + Inc(count); + end; + end; + Result := count+1; + end; + +begin + Result := ''; + if S = '' then Exit; + SetLength(Temp, Length(S)); + + L := Utf8ToUnicode(PWideChar(Temp), Length(Temp)+1, PChar(S), Length(S)); + if L > 0 then + SetLength(Temp, L-1) + else + Temp := ''; + Result := Temp; +end; + +function VarToWideStrDef(const V: Variant; const ADefault: WideString): WideString; +begin + if not VarIsNull(V) then + Result := V + else + Result := ADefault; +end; + +function VarToWideStr(const V: Variant): WideString; +begin + Result := VarToWideStrDef(V, ''); +end; +{$ENDIF} + + +{ TWideStrings } + +constructor TWideStrings.Create; +begin + FWideStringList := TList.Create; +end; + +destructor TWideStrings.Destroy; +begin + Clear; + FWideStringList.Free; + inherited; +end; + +procedure TWideStrings.Clear; +var + Index: Integer; + PWStr: ^TWString; +begin + for Index := 0 to FWideStringList.Count-1 do + begin + PWStr := FWideStringList.Items[Index]; + if PWStr <> nil then + Dispose(PWStr); + end; + FWideStringList.Clear; +end; + +function TWideStrings.Get(Index: Integer): WideString; +var + PWStr: ^TWString; +begin + Result := ''; + if ( (Index >= 0) and (Index < FWideStringList.Count) ) then + begin + PWStr := FWideStringList.Items[Index]; + if PWStr <> nil then + Result := PWStr^.WString; + end; +end; + +procedure TWideStrings.Put(Index: Integer; const S: WideString); +begin + Insert(Index, S); +end; + +function TWideStrings.GetObject(Index: Integer): TObject; +var + PWStr: ^TWString; +begin + Result := nil; + if ( (Index >= 0) and (Index < FWideStringList.Count) ) then + begin + PWStr := FWideStringList.Items[Index]; + if PWStr <> nil then + Result := PWStr^.Obj; + end; +end; + +procedure TWideStrings.PutObject(Index: Integer; const Value: TObject); +var + PWStr: ^TWString; +begin + if ( (Index >= 0) and (Index < FWideStringList.Count) ) then + begin + PWStr := FWideStringList.Items[Index]; + if PWStr <> nil then + PWStr^.Obj := Value; + end; +end; + +function TWideStrings.Add(const S: WideString): Integer; +var + PWStr: ^TWString; +begin + New(PWStr); + PWStr^.WString := S; + PWStr^.Obj := nil; + Result := FWideStringList.Add(PWStr); +end; + +procedure TWideStrings.Delete(Index: Integer); +var + PWStr: ^TWString; +begin + PWStr := FWideStringList.Items[Index]; + if PWStr <> nil then + Dispose(PWStr); + FWideStringList.Delete(Index); +end; + +function TWideStrings.IndexOf(const S: WideString): Integer; +var + Index: Integer; + PWStr: ^TWString; +begin + Result := -1; + for Index := 0 to FWideStringList.Count -1 do + begin + PWStr := FWideStringList.Items[Index]; + if PWStr <> nil then + begin + if S = PWStr^.WString then + begin + Result := Index; + break; + end; + end; + end; +end; + +function TWideStrings.Count: Integer; +begin + Result := FWideStringList.Count; +end; + +procedure TWideStrings.Insert(Index: Integer; const S: WideString); +var + PWStr: ^TWString; +begin + if((Index < 0) or (Index > FWideStringList.Count)) then + raise Exception.Create('Wide String Out of Bounds'); + if Index < FWideStringList.Count then + begin + PWStr := FWideStringList.Items[Index]; + if PWStr <> nil then + PWStr.WString := S; + end + else + Add(S); +end; + +procedure TWideStrings.AddStrings(Strings: TWideStrings); +var + I: Integer; +begin + for I := 0 to Strings.Count - 1 do + AddObject(Strings[I], Strings.Objects[I]); +end; + +function TWideStrings.AddObject(const S: WideString; AObject: TObject): Integer; +begin + Result := Add(S); + PutObject(Result, AObject); +end; + +procedure TWideStrings.Assign(Source: TPersistent); +var + I: Integer; +begin + if Source is TWideStrings then + begin + Clear; + AddStrings(TWideStrings(Source)); + end + else if Source is TStrings then + begin + Clear; + for I := 0 to TStrings(Source).Count - 1 do + AddObject(TStrings(Source)[I], TStrings(Source).Objects[I]); + end + else + inherited Assign(Source); +end; + +procedure TWideStrings.AssignTo(Dest: TPersistent); +var + I: Integer; +begin + if Dest is TWideStrings then + Dest.Assign(Self) + else if Dest is TStrings then + begin + TStrings(Dest).BeginUpdate; + try + TStrings(Dest).Clear; + for I := 0 to Count - 1 do + TStrings(Dest).AddObject(Strings[I], Objects[I]); + finally + TStrings(Dest).EndUpdate; + end; + end + else + inherited AssignTo(Dest); +end; + +procedure TWideStrings.DefineProperties(Filer: TFiler); +begin + // compatibility + Filer.DefineProperty('Strings', ReadData, nil, Count > 0); + Filer.DefineProperty('UTF8', ReadDataW, WriteDataW, Count > 0); +end; + +function TWideStrings.GetTextStr: WideString; +var + I, L, Size, Count: Integer; + P: PWideChar; + S, LB: WideString; +begin + Count := FWideStringList.Count; + Size := 0; + LB := sLineBreak; + for I := 0 to Count - 1 do Inc(Size, Length(Get(I)) + Length(LB)); + SetString(Result, nil, Size); + P := Pointer(Result); + for I := 0 to Count - 1 do + begin + S := Get(I); + L := Length(S); + if L <> 0 then + begin + System.Move(Pointer(S)^, P^, L * SizeOf(WideChar)); + Inc(P, L); + end; + L := Length(LB); + if L <> 0 then + begin + System.Move(Pointer(LB)^, P^, L * SizeOf(WideChar)); + Inc(P, L); + end; + end; +end; + +procedure TWideStrings.LoadFromFile(const FileName: WideString); +var + Stream: TStream; +begin + Stream := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); + try + LoadFromStream(Stream); + finally + Stream.Free; + end; +end; + +procedure TWideStrings.LoadFromStream(Stream: TStream); +var + Size: Integer; + S: WideString; + ansiS: String; + sign: Word; +begin + Size := Stream.Size - Stream.Position; + sign := 0; + if Size > 2 then + Stream.Read(sign, 2); + + if sign = $FEFF then + begin + Dec(Size, 2); + SetLength(S, Size div 2); + Stream.Read(S[1], Size); + SetTextStr(S); + end + else + begin + Stream.Seek(-2, soFromCurrent); + SetLength(ansiS, Size); + Stream.Read(ansiS[1], Size); + SetTextStr(ansiS); + end; +end; + +procedure TWideStrings.LoadFromWStream(Stream: TStream); +var + Size: Integer; + S: WideString; +begin + Size := Stream.Size - Stream.Position; + SetLength(S, Size div 2); + Stream.Read(S[1], Size); + SetTextStr(S); +end; + +procedure TWideStrings.ReadData(Reader: TReader); +begin + Clear; + Reader.ReadListBegin; + while not Reader.EndOfList do + if Reader.NextValue in [vaString, vaLString] then + Add(Reader.ReadString) {TStrings compatiblity} + else + Add(Reader.ReadWideString); + Reader.ReadListEnd; +end; + +procedure TWideStrings.ReadDataW(Reader: TReader); +begin + Clear; + Reader.ReadListBegin; + while not Reader.EndOfList do + Add(Utf8Decode(Reader.ReadString)); + Reader.ReadListEnd; +end; + +procedure TWideStrings.SaveToFile(const FileName: WideString); +var + Stream: TStream; +begin + Stream := TFileStream.Create(FileName, fmCreate); + try + SaveToStream(Stream); + finally + Stream.Free; + end; +end; + +procedure TWideStrings.SaveToStream(Stream: TStream); +var + SW: WideString; +begin + SW := GetTextStr; + Stream.WriteBuffer(PWideChar(SW)^, Length(SW) * SizeOf(WideChar)); +end; + +procedure TWideStrings.SetTextStr(const Value: WideString); +var + P, Start: PWideChar; + S: WideString; +begin + Clear; + P := Pointer(Value); + if P <> nil then + while P^ <> #0 do + begin + Start := P; + while not (P^ in [WideChar(#0), WideChar(#10), WideChar(#13)]) and (P^ <> WideLineSeparator) do + Inc(P); + SetString(S, Start, P - Start); + Add(S); + if P^ = #13 then Inc(P); + if P^ = #10 then Inc(P); + if P^ = WideLineSeparator then Inc(P); + end; +end; + +procedure TWideStrings.WriteDataW(Writer: TWriter); +var + I: Integer; +begin + Writer.WriteListBegin; + for I := 0 to Count - 1 do + Writer.WriteString(Utf8Encode(Get(I))); + Writer.WriteListEnd; +end; + +function TranslateCharsetInfo(lpSrc: DWORD; var lpCs: TCharsetInfo; + dwFlags: DWORD): BOOL; stdcall; external gdi32 name 'TranslateCharsetInfo'; + +function CharSetToCodePage(ciCharset: DWORD): Cardinal; +var + C: TCharsetInfo; +begin + if ciCharset = DEFAULT_CHARSET then + Result := GetACP + else + begin + Win32Check(TranslateCharsetInfo(ciCharset, C, TCI_SRCCHARSET)); + Result := C.ciACP; + end; +end; + +function AnsiToUnicode(const s: String; Charset: UINT): WideString; +var + CodePage: Integer; + InputLength, OutputLength: Integer; +begin + CodePage := CharSetToCodePage(Charset); + InputLength := Length(S); + OutputLength := MultiByteToWideChar(CodePage, 0, PAnsiChar(S), InputLength, nil, 0); + SetLength(Result, OutputLength); + MultiByteToWideChar(CodePage, 0, PAnsiChar(S), InputLength, PWideChar(Result), OutputLength); +end; + + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxUsers.pas b/official/4.2/LibD11/frxUsers.pas new file mode 100644 index 0000000..ab87ee3 --- /dev/null +++ b/official/4.2/LibD11/frxUsers.pas @@ -0,0 +1,488 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Server users/groups } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxusers; + +interface + +uses + Windows, Messages, SysUtils, Classes, frxXML, frxFileUtils, + frxUtils, frxMD5 +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxUserGroupItem = class; + + TfrxUsers = class (TObject) + private + FXML: TfrxXMLDocument; + FUsersList: TStringList; + FGroupsList: TStringList; + procedure UnpackUsersTree; + procedure PackUsersTree; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + function CheckPassword(const UserName, Password: String): Boolean; + function AllowLogin(const UserName, Password: String): Boolean; + function AllowGroupLogin(const UserName: String): Boolean; + function UserExists(const UserName: String): Boolean; + function GroupExists(const GroupName: String): Boolean; + function ChPasswd(const UserName, NewPassword: String): Boolean; + function AddUser(const UserName: String): TfrxUserGroupItem; + function AddGroup(const GroupName: String): TfrxUserGroupItem; + function GetGroup(const GroupName: String): TfrxUserGroupItem; + function GetUser(const UserName: String): TfrxUserGroupItem; + function MemberOfGroup(const User, Group: String): Boolean; + function GetUserIndex(const User: String): String; + procedure LoadFromFile(const FileName: String); + procedure AddUserToGroup(const UserName, GroupName: String); + procedure RemoveUserFromGroup(const Username, GroupName: String); + procedure RemoveGroupFromUser(const GroupName, Username: String); + procedure DeleteUser(const UserName: String); + procedure DeleteGroup(const GroupName: String); + procedure SaveToFile(const FileName: String); + + property UserList: TStringList read FUsersList; + property GroupList: TStringList read FGroupsList; + end; + + TfrxUserGroupItem = class (TObject) + private + FActive: Boolean; + FPassword: String; + FName: String; + FEmail: String; + FFullName: String; + FAuthType: String; + FIsGroup: Boolean; + FMembers: TStringList; + FIndexFile: String; + public + constructor Create; + destructor Destroy; override; + + property Name: String read FName write FName; + property Active: Boolean read FActive write FActive; + property FullName: String read FFullName write FFullName; + property Email: String read FEmail write FEmail; + property Password: String read FPassword write FPassword; + property AuthType: String read FAuthType write FAuthType; + property IsGroup: Boolean read FIsGroup write FIsGroup; + property Members: TStringList read FMembers; + property IndexFile: String read FIndexFile write FIndexFile; + end; + +var + ServerUsers: TfrxUsers; + +implementation + + +uses frxServerConfig; + +{ TfrxUsers } + +function TfrxUsers.AddGroup(const GroupName: String): TfrxUserGroupItem; +begin + if not GroupExists(GroupName) then + begin + Result := TfrxUserGroupItem.Create; + Result.Name := GroupName; + Result.IsGroup := True; + FGroupsList.AddObject(Result.Name, Result); + end else + Result := nil; +end; + +function TfrxUsers.AddUser(const UserName: String): TfrxUserGroupItem; +begin + if not UserExists(UserName) then + begin + Result := TfrxUserGroupItem.Create; + Result.Name := UserName; + Result.IsGroup := False; + FUsersList.AddObject(Result.Name, Result); + end else + Result := nil; +end; + +procedure TfrxUsers.AddUserToGroup(const UserName, GroupName: String); +var + Group, User: TfrxUserGroupItem; +begin + if (UserName <> '') and (GroupName <> '') then + begin + Group := GetGroup(GroupName); + User := GetUser(UserName); + if (Group <> nil) and (User <> nil) then + begin + User.Members.BeginUpdate; + Group.Members.BeginUpdate; + if Group.Members.IndexOf(UserName) = -1 then + Group.Members.AddObject(UserName, User); + if User.Members.IndexOf(GroupName) = -1 then + User.Members.AddObject(GroupName, Group); + Group.Members.EndUpdate; + User.Members.EndUpdate; + end; + end; +end; + +function TfrxUsers.AllowGroupLogin(const UserName: String): Boolean; +var + i: Integer; + User, Group: TfrxUserGroupItem; +begin + Result := False; + User := GetUser(UserName); + for i := 0 to User.Members.Count - 1 do + begin + Group := TfrxUserGroupItem(User.Members.Objects[i]); + if Group.Active then + Result := True; + end; +end; + +function TfrxUsers.AllowLogin(const UserName, Password: String): Boolean; +var + User: TfrxUserGroupItem; +begin + Result := False; + User := GetUser(UserName); + if User <> nil then + Result := User.Active and CheckPassword(UserName, Password) and AllowGroupLogin(UserName); +end; + +function TfrxUsers.CheckPassword(const UserName, + Password: String): Boolean; +var + User: TfrxUserGroupItem; +begin + Result := False; + User := GetUser(UserName); + if User <> nil then + Result := MD5String(Password) = User.Password; +end; + +function TfrxUsers.ChPasswd(const UserName, + NewPassword: String): Boolean; +var + User: TfrxUserGroupItem; +begin + Result := False; + User := GetUser(UserName); + if User <> nil then + begin + User.Password := MD5String(NewPassword); + Result := True; + end; +end; + +procedure TfrxUsers.Clear; +var + i: Integer; +begin + for i := 0 to FUsersList.Count - 1 do + TfrxUserGroupItem(FUsersList.Objects[i]).Free; + FUsersList.Clear; + for i := 0 to FGroupsList.Count - 1 do + TfrxUserGroupItem(FGroupsList.Objects[i]).Free; + FGroupsList.Clear; +end; + +constructor TfrxUsers.Create; +begin + FXML := TfrxXMLDocument.Create; + FXML.AutoIndent := True; + FUsersList := TStringList.Create; + FGroupsList := TStringList.Create; + FUsersList.Sorted := True; + FGroupsList.Sorted := True; +end; + +procedure TfrxUsers.DeleteGroup(const GroupName: String); +var + Group: TfrxUserGroupItem; + i: Integer; +begin + Group := GetGroup(GroupName); + if Group <> nil then + begin + for i := 0 to Group.Members.Count - 1 do + RemoveGroupFromUser(GroupName, Group.Members[i]); + Group.Free; + i := FGroupsList.IndexOf(GroupName); + FGroupsList.Delete(i); + end; +end; + +procedure TfrxUsers.DeleteUser(const UserName: String); +var + User: TfrxUserGroupItem; + i: Integer; +begin + User := GetUser(UserName); + if User <> nil then + begin + for i := 0 to User.Members.Count - 1 do + RemoveUserFromGroup(UserName, User.Members[i]); + User.Free; + i := FUsersList.IndexOf(UserName); + FUsersList.Delete(i); + end; +end; + +destructor TfrxUsers.Destroy; +begin + FXML.Free; + FUsersList.Free; + FGroupsList.Free; + inherited; +end; + +function TfrxUsers.GetGroup(const GroupName: String): TfrxUserGroupItem; +var + i: Integer; +begin + i := FGroupsList.IndexOf(GroupName); + if i <> -1 then + Result := TfrxUserGroupItem(FGroupsList.Objects[i]) + else + Result := nil; +end; + +function TfrxUsers.GetUser(const UserName: String): TfrxUserGroupItem; +var + i: Integer; +begin + i := FUsersList.IndexOf(UserName); + if i <> -1 then + Result := TfrxUserGroupItem(FUsersList.Objects[i]) + else + Result := nil; +end; + +function TfrxUsers.GetUserIndex(const User: String): String; +var + U: TfrxUserGroupItem; +begin + U := GetUser(User); + Result := ''; + if (U <> nil) and (U.Members.Count > 0) then + Result := TfrxUserGroupItem(U.Members.Objects[0]).IndexFile; + if Result = '' then + Result := ServerConfig.GetValue('server.http.indexfile'); +end; + +function TfrxUsers.GroupExists(const GroupName: String): Boolean; +begin + Result := FGroupsList.IndexOf(GroupName) <> -1; +end; + +procedure TfrxUsers.LoadFromFile(const FileName: String); +var + f: TFileStream; +begin + if FileExists(FileName) then + begin + f := TFileStream.Create(FileName, fmOpenRead + fmShareDenyWrite); + try + FXML.Clear; + try + FXML.LoadFromStream(f, False); + finally + UnpackUsersTree; + end; + finally + f.Free; + end; + end; +end; + +function TfrxUsers.MemberOfGroup(const User, Group: String): Boolean; +begin + Result := GetUser(User).Members.IndexOf(Group) <> -1; +end; + +procedure TfrxUsers.PackUsersTree; +var + x: TfrxXMLItem; + i, j: Integer; + User: TfrxUserGroupItem; +begin + FXML.Clear; + FXML.Root.Name := 'server'; + x := FXML.Root.Add; + x.Name := 'groups'; + x.Prop['desc'] := 'Groups list'; + for i := 0 to FGroupsList.Count - 1 do + with x.Add do + begin + Name := 'group'; + User := TfrxUserGroupItem(FGroupsList.Objects[i]); + Prop['name'] := User.Name; + Prop['index'] := User.IndexFile; + if User.Active then + Prop['active'] := 'yes' + else + Prop['active'] := 'no'; + Prop['fullname'] := User.FullName; + end; + x := FXML.Root.Add; + x.Name := 'users'; + x.Prop['desc'] := 'Users list'; + for i := 0 to FUsersList.Count - 1 do + with x.Add do + begin + Name := 'user'; + User := TfrxUserGroupItem(FUsersList.Objects[i]); + Prop['name'] := User.Name; + if User.Active then + Prop['active'] := 'yes' + else + Prop['active'] := 'no'; + Prop['fullname'] := User.FullName; + Prop['email'] := User.Email; + Prop['password'] := User.Password; + end; + x := FXML.Root.Add; + x.Name := 'membership'; + x.Prop['desc'] := 'Membership relations'; + for i := 0 to FGroupsList.Count - 1 do + begin + User := TfrxUserGroupItem(FGroupsList.Objects[i]); + if User.Members.Count > 0 then + begin + with x.Add do + begin + Name := 'group'; + Prop['name'] := User.Name; + for j := 0 to User.Members.Count - 1 do + with Add do + begin + Name := 'user'; + Prop['name'] := User.Members[j]; + end; + end; + end; + end; +end; + +procedure TfrxUsers.RemoveGroupFromUser(const GroupName, Username: String); +var + User: TfrxUserGroupItem; + i: Integer; +begin + User := GetUser(Username); + if User <> nil then + begin + i := User.Members.IndexOf(GroupName); + if i <> -1 then + User.Members.Delete(i); + end; +end; + +procedure TfrxUsers.RemoveUserFromGroup(const Username, GroupName: String); +var + Group: TfrxUserGroupItem; + i: Integer; +begin + Group := GetGroup(GroupName); + if Group <> nil then + begin + i := Group.Members.IndexOf(UserName); + if i <> -1 then + Group.Members.Delete(i); + end; +end; + +procedure TfrxUsers.SaveToFile(const FileName: String); +begin + PackUsersTree; + FXML.SaveToFile(FileName); +end; + +procedure TfrxUsers.UnpackUsersTree; +var + x: TfrxXMLItem; + Item: TfrxUserGroupItem; + i, j: Integer; +begin + Clear; + x := FXML.Root.FindItem('groups'); + for i := 0 to x.Count - 1 do + begin + Item := AddGroup(x.Items[i].Prop['name']); + if Item <> nil then + begin + Item.FullName := x.Items[i].Prop['fullname']; + Item.Active := (x.Items[i].Prop['active'] = 'yes') or (x.Items[i].Prop['active'] = ''); + Item.AuthType := x.Items[i].Prop['auth']; + Item.IndexFile := x.Items[i].Prop['index']; + end; + end; + x := FXML.Root.FindItem('users'); + for i := 0 to x.Count - 1 do + begin + Item := AddUser(x.Items[i].Prop['name']); + if Item <> nil then + begin + Item.FullName := x.Items[i].Prop['fullname']; + Item.Active := (x.Items[i].Prop['active'] = 'yes') or (x.Items[i].Prop['active'] = ''); + Item.AuthType := x.Items[i].Prop['auth']; + if x.Items[i].Prop['auth'] <> '' then + Item.Password := x.Items[i].Prop['auth']; + Item.Email := x.Items[i].Prop['email']; + if x.Items[i].Prop['password'] <> '' then + Item.Password := x.Items[i].Prop['password']; + end; + end; + x := FXML.Root.FindItem('membership'); + for i := 0 to x.Count - 1 do + for j := 0 to x.Items[i].Count - 1 do + AddUserToGroup(x.Items[i].Items[j].Prop['name'], x.Items[i].Prop['name']); +end; + +function TfrxUsers.UserExists(const UserName: String): Boolean; +begin + Result := FUsersList.IndexOf(UserName) <> -1; +end; + +{ TfrxUserGroupItem } + +constructor TfrxUserGroupItem.Create; +begin + FActive := True; + FAuthType := 'internal'; + FIsGroup := False; + FMembers := TStringList.Create; + FMembers.Sorted := True; + FPassword := MD5String(''); +end; + +destructor TfrxUserGroupItem.Destroy; +begin + FMembers.Free; + inherited; +end; + +initialization + ServerUsers := TfrxUsers.Create; + +finalization + ServerUsers.Free; + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxUtils.pas b/official/4.2/LibD11/frxUtils.pas new file mode 100644 index 0000000..dc22ba6 --- /dev/null +++ b/official/4.2/LibD11/frxUtils.pas @@ -0,0 +1,1030 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Various routines } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxUtils; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, + StdCtrls, Menus, ImgList, ActnList, ComCtrls, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxRectArea = class + public + X, Y, X1, Y1: Extended; + constructor Create(c: TfrxComponent); overload; + constructor Create(Left, Top, Right, Bottom: Extended); overload; + function InterceptsX(a: TfrxRectArea): Boolean; + function InterceptsY(a: TfrxRectArea): Boolean; + function InterceptX(a: TfrxRectArea): TfrxRectArea; + function InterceptY(a: TfrxRectArea): TfrxRectArea; + function Max(x1, x2: Extended): Extended; + function Min(x1, x2: Extended): Extended; + end; + + +function frxFindComponent(Owner: TComponent; const Name: String): TComponent; +procedure frxGetComponents(Owner: TComponent; ClassRef: TClass; + List: TStrings; Skip: TComponent); +function frxGetFullName(Owner: TComponent; c: TComponent): String; +procedure frxSetCommaText(const Text: String; sl: TStrings; Comma: Char = ';'); +function frxRemoveQuotes(const s: String): String; +function frxStreamToString(Stream: TStream): String; +procedure frxStringToStream(const s: String; Stream: TStream); +function frxStrToFloat(s: String): Extended; +function frxFloatToStr(d: Extended): String; +function frxRect(ALeft, ATop, ARight, ABottom: Extended): TfrxRect; +function frxPoint(X, Y: Extended): TfrxPoint; +function frxGetBrackedVariable(const Str, OpenBracket, CloseBracket: String; + var i, j: Integer): String; +function frxGetBrackedVariableW(const Str, OpenBracket, CloseBracket: WideString; + var i, j: Integer): WideString; +procedure frxCommonErrorHandler(Report: TfrxReport; const Text: String); +procedure frxErrorMsg(const Text: String); +procedure frxInfoMsg(const Text: String); +function frxConfirmMsg(const Text: String; Buttons: Integer): Integer; +function frxIsValidFloat(const Value: string): Boolean; +procedure frxAssignImages(Bitmap: TBitmap; dx, dy: Integer; + ImgList1: TImageList; ImgList2: TImageList = nil); +procedure frxDrawTransparent(Canvas: TCanvas; x, y: Integer; bmp: TBitmap); +procedure frxDrawGraphic(Canvas: TCanvas; DestRect: TRect; aGraph: TGraphic; + IsPrinting: Boolean); +procedure frxParsePageNumbers(const PageNumbers: String; List: TStrings; + Total: Integer); +function HTMLRGBColor(Color: TColor): string; +procedure frxWriteCollection(Collection: TCollection; Writer: TWriter; + Owner: TfrxComponent); +procedure frxReadCollection(Collection: TCollection; Reader: TReader; + Owner: TfrxComponent); +function GetAppFileName: String; +function GetAppPath: String; +function GetTemporaryFolder: String; +function GetTempFile: String; +function frxCreateTempFile(const TempDir: String): String; +{$IFNDEF Delphi7} +function frFloat2Str(const Value: Extended; const Prec: Integer = 2): String; +{$ELSE} +function frFloat2Str(const Value: Extended; const Prec: Integer = 2; const Sep: Char = '.'): String; +{$ENDIF} +function frxReverseString(const AText: string): string; +function frxStreamCRC32(Stream: TStream): Cardinal; +function frxUnixPath2WinPath(const Path: string): string; + + +implementation + +uses frxXMLSerializer, frxRes, TypInfo; + + +{ TfrxRectArea } + +constructor TfrxRectArea.Create(c: TfrxComponent); +begin + Create(c.AbsLeft, c.AbsTop, c.AbsLeft + c.Width, c.AbsTop + c.Height); +end; + +constructor TfrxRectArea.Create(Left, Top, Right, Bottom: Extended); +begin + X := Left; + Y := Top; + X1 := Right; + Y1 := Bottom; +end; + +function TfrxRectArea.InterceptsX(a: TfrxRectArea): Boolean; +begin + Result := False; + if (a.X < X1 - 1e-4) and (a.X1 > X + 1e-4) then + Result := True; +end; + +function TfrxRectArea.InterceptsY(a: TfrxRectArea): Boolean; +begin + Result := False; + if (a.Y < Y1 - 1e-4) and (a.Y1 > Y + 1e-4) then + Result := True; +end; + +function TfrxRectArea.InterceptX(a: TfrxRectArea): TfrxRectArea; +begin + Result := nil; + if InterceptsX(a) then + Result := TfrxRectArea.Create(Max(a.X, X), 0, Min(a.X1, X1), 0); +end; + +function TfrxRectArea.InterceptY(a: TfrxRectArea): TfrxRectArea; +begin + Result := nil; + if InterceptsY(a) then + Result := TfrxRectArea.Create(0, Max(a.Y, Y), 0, Min(a.Y1, Y1)); +end; + +function TfrxRectArea.Max(x1, x2: Extended): Extended; +begin + if x1 > x2 then + Result := x1 + else + Result := x2; +end; + +function TfrxRectArea.Min(x1, x2: Extended): Extended; +begin + if x1 < x2 then + Result := x1 + else + Result := x2; +end; + + + +const + CRCTable: array [0..255] of Cardinal = ( + 0000000000, 1996959894, 3993919788, 2567524794, + 0124634137, 1886057615, 3915621685, 2657392035, + 0249268274, 2044508324, 3772115230, 2547177864, + 0162941995, 2125561021, 3887607047, 2428444049, + 0498536548, 1789927666, 4089016648, 2227061214, + 0450548861, 1843258603, 4107580753, 2211677639, + 0325883990, 1684777152, 4251122042, 2321926636, + 0335633487, 1661365465, 4195302755, 2366115317, + 0997073096, 1281953886, 3579855332, 2724688242, + 1006888145, 1258607687, 3524101629, 2768942443, + 0901097722, 1119000684, 3686517206, 2898065728, + 0853044451, 1172266101, 3705015759, 2882616665, + 0651767980, 1373503546, 3369554304, 3218104598, + 0565507253, 1454621731, 3485111705, 3099436303, + 0671266974, 1594198024, 3322730930, 2970347812, + 0795835527, 1483230225, 3244367275, 3060149565, + 1994146192, 0031158534, 2563907772, 4023717930, + 1907459465, 0112637215, 2680153253, 3904427059, + 2013776290, 0251722036, 2517215374, 3775830040, + 2137656763, 0141376813, 2439277719, 3865271297, + 1802195444, 0476864866, 2238001368, 4066508878, + 1812370925, 0453092731, 2181625025, 4111451223, + 1706088902, 0314042704, 2344532202, 4240017532, + 1658658271, 0366619977, 2362670323, 4224994405, + 1303535960, 0984961486, 2747007092, 3569037538, + 1256170817, 1037604311, 2765210733, 3554079995, + 1131014506, 0879679996, 2909243462, 3663771856, + 1141124467, 0855842277, 2852801631, 3708648649, + 1342533948, 0654459306, 3188396048, 3373015174, + 1466479909, 0544179635, 3110523913, 3462522015, + 1591671054, 0702138776, 2966460450, 3352799412, + 1504918807, 0783551873, 3082640443, 3233442989, + 3988292384, 2596254646, 0062317068, 1957810842, + 3939845945, 2647816111, 0081470997, 1943803523, + 3814918930, 2489596804, 0225274430, 2053790376, + 3826175755, 2466906013, 0167816743, 2097651377, + 4027552580, 2265490386, 0503444072, 1762050814, + 4150417245, 2154129355, 0426522225, 1852507879, + 4275313526, 2312317920, 0282753626, 1742555852, + 4189708143, 2394877945, 0397917763, 1622183637, + 3604390888, 2714866558, 0953729732, 1340076626, + 3518719985, 2797360999, 1068828381, 1219638859, + 3624741850, 2936675148, 0906185462, 1090812512, + 3747672003, 2825379669, 0829329135, 1181335161, + 3412177804, 3160834842, 0628085408, 1382605366, + 3423369109, 3138078467, 0570562233, 1426400815, + 3317316542, 2998733608, 0733239954, 1555261956, + 3268935591, 3050360625, 0752459403, 1541320221, + 2607071920, 3965973030, 1969922972, 0040735498, + 2617837225, 3943577151, 1913087877, 0083908371, + 2512341634, 3803740692, 2075208622, 0213261112, + 2463272603, 3855990285, 2094854071, 0198958881, + 2262029012, 4057260610, 1759359992, 0534414190, + 2176718541, 4139329115, 1873836001, 0414664567, + 2282248934, 4279200368, 1711684554, 0285281116, + 2405801727, 4167216745, 1634467795, 0376229701, + 2685067896, 3608007406, 1308918612, 0956543938, + 2808555105, 3495958263, 1231636301, 1047427035, + 2932959818, 3654703836, 1088359270, 0936918000, + 2847714899, 3736837829, 1202900863, 0817233897, + 3183342108, 3401237130, 1404277552, 0615818150, + 3134207493, 3453421203, 1423857449, 0601450431, + 3009837614, 3294710456, 1567103746, 0711928724, + 3020668471, 3272380065, 1510334235, 0755167117); + +function frxStreamCRC32(Stream: TStream): Cardinal; +var + OldPos: Integer; + b: Byte; + c: Cardinal; +begin + OldPos := Stream.Position; + Stream.Position := 0; + c := $ffffffff; + while Stream.Position < Stream.Size do + begin + Stream.Read(b,1); + c := CrcTable[(c xor Cardinal(b)) and $ff] xor (c shr 8); + end; + Stream.Position := OldPos; + Result := c xor $ffffffff; +end; + +function frxFindComponent(Owner: TComponent; const Name: String): TComponent; +var + n: Integer; + s1, s2: String; +begin + Result := nil; + n := Pos('.', Name); + try + if n = 0 then + begin + if Owner <> nil then + Result := Owner.FindComponent(Name); + if (Result = nil) and (Owner is TfrxReport) and (Owner.Owner <> nil) then + Result := Owner.Owner.FindComponent(Name); + end + else + begin + s1 := Copy(Name, 1, n - 1); // module name + s2 := Copy(Name, n + 1, 255); // component name + Owner := FindGlobalComponent(s1); + if Owner <> nil then + begin + n := Pos('.', s2); + if n <> 0 then // frame name - Delphi5 + begin + s1 := Copy(s2, 1, n - 1); + s2 := Copy(s2, n + 1, 255); + Owner := Owner.FindComponent(s1); + if Owner <> nil then + Result := Owner.FindComponent(s2); + end + else + Result := Owner.FindComponent(s2); + end; + end; + except + on Exception do + raise EClassNotFound.Create('Missing ' + Name); + end; +end; + +{$HINTS OFF} +procedure frxGetComponents(Owner: TComponent; ClassRef: TClass; + List: TStrings; Skip: TComponent); +var + i, j: Integer; + + procedure EnumComponents(f: TComponent); + var + i: Integer; + c: TComponent; + begin +{$IFDEF Delphi5} + if f is TForm then + for i := 0 to TForm(f).ControlCount - 1 do + begin + c := TForm(f).Controls[i]; + if c is TFrame then + EnumComponents(c); + end; +{$ENDIF} + for i := 0 to f.ComponentCount - 1 do + begin + c := f.Components[i]; + if (c <> Skip) and (c is ClassRef) then + List.AddObject(frxGetFullName(Owner, c), c); + end; + end; + +begin + List.Clear; + if Owner is TfrxReport then + EnumComponents(Owner); + for i := 0 to Screen.FormCount - 1 do + EnumComponents(Screen.Forms[i]); + for i := 0 to Screen.DataModuleCount - 1 do + EnumComponents(Screen.DataModules[i]); +{$IFDEF Delphi6} // D6 bugfix + with Screen do + for i := 0 to CustomFormCount - 1 do + with CustomForms[i] do + if (ClassName = 'TDataModuleForm') then + for j := 0 to ComponentCount - 1 do + begin + if (Components[j] is TDataModule) then + EnumComponents(Components[j]); + end; +{$ENDIF} +end; +{$HINTS ON} + +function frxGetFullName(Owner: TComponent; c: TComponent): String; +var + o: TComponent; +begin + Result := ''; + if c = nil then Exit; + + o := c.Owner; + if (o = nil) or (o = Owner) or ((Owner is TfrxReport) and (o = Owner.Owner)) then + Result := c.Name + else if ((o is TForm) or (o is TDataModule)) then + Result := o.Name + '.' + c.Name +{$IFDEF Delphi5} + else if o is TFrame then + Result := o.Owner.Name + '.' + c.Owner.Name + '.' + c.Name +{$ENDIF} +end; + +procedure frxSetCommaText(const Text: String; sl: TStrings; Comma: Char = ';'); +var + i: Integer; + + function ExtractCommaName(s: string; var Pos: Integer): string; + var + i: Integer; + begin + i := Pos; + while (i <= Length(s)) and (s[i] <> Comma) do Inc(i); + Result := Copy(s, Pos, i - Pos); + if (i <= Length(s)) and (s[i] = Comma) then Inc(i); + Pos := i; + end; + +begin + i := 1; + sl.Clear; + while i <= Length(Text) do + sl.Add(ExtractCommaName(Text, i)); +end; + +function frxRemoveQuotes(const s: String): String; +begin + if (Length(s) > 2) and (s[1] = '"') and (s[Length(s)] = '"') then + Result := Copy(s, 2, Length(s) - 2) else + Result := s; +end; + +function frxStreamToString(Stream: TStream): String; +var + Size: Integer; + p: PChar; +begin + Size := Stream.Size; + SetLength(Result, Size * 2); + GetMem(p, Size); + + Stream.Position := 0; + Stream.Read(p^, Size); + + BinToHex(p, @Result[1], Size); + + FreeMem(p, Size); +end; + +procedure frxStringToStream(const s: String; Stream: TStream); +var + Size: Integer; + p: PChar; +begin + Size := Length(s) div 2; + GetMem(p, Size); + + HexToBin(@s[1], p, Size * 2); + + Stream.Position := 0; + Stream.Write(p^, Size); + + FreeMem(p, Size); +end; + +function frxStrToFloat(s: String): Extended; +var + i: Integer; +begin + for i := 1 to Length(s) do + if s[i] in [',', '.'] then + s[i] := DecimalSeparator; + while Pos(' ', s) <> 0 do + Delete(s, Pos(' ', s), 1); + Result := StrToFloat(s); +end; + +function frxFloatToStr(d: Extended): String; +begin + if Int(d) = d then + Result := FloatToStr(d) else + Result := Format('%2.2f', [d]); +end; + +function frxRect(ALeft, ATop, ARight, ABottom: Extended): TfrxRect; +begin + with Result do + begin + Left := ALeft; + Top := ATop; + Right := ARight; + Bottom := ABottom; + end; +end; + +function frxPoint(X, Y: Extended): TfrxPoint; +begin + Result.X := X; + Result.Y := Y; +end; + +function frxGetBrackedVariable(const Str, OpenBracket, CloseBracket: String; + var i, j: Integer): String; +var + c: Integer; + fl1, fl2: Boolean; +begin + Result := ''; + j := i; + fl1 := True; + fl2 := True; + c := 0; + if (Str = '') or (j > Length(Str)) then Exit; + + Dec(j); + repeat + Inc(j); + if isDBCSLeadByte(Byte(Str[j])) then { if DBCS then skip 2 bytes } + Inc(j, 2); + + if fl1 and fl2 then + if Copy(Str, j, Length(OpenBracket)) = OpenBracket then + begin + if c = 0 then i := j; + Inc(c); + end + else if Copy(Str, j, Length(CloseBracket)) = CloseBracket then + Dec(c); + if fl1 then + if Str[j] = '"' then fl2 := not fl2; + if fl2 then + if Str[j] = '''' then fl1 := not fl1; + until (c = 0) or (j >= Length(Str)); + + Result := Copy(Str, i + Length(OpenBracket), j - i - Length(OpenBracket)); + if i <> j then + Inc(j, Length(CloseBracket) - 1); +end; + +function frxGetBrackedVariableW(const Str, OpenBracket, CloseBracket: WideString; + var i, j: Integer): WideString; +var + c: Integer; + fl1, fl2: Boolean; +begin + Result := ''; + j := i; + fl1 := True; + fl2 := True; + c := 0; + if (Str = '') or (j > Length(Str)) then Exit; + + Dec(j); + repeat + Inc(j); + if fl1 and fl2 then + if Copy(Str, j, Length(OpenBracket)) = OpenBracket then + begin + if c = 0 then i := j; + Inc(c); + end + else if Copy(Str, j, Length(CloseBracket)) = CloseBracket then + Dec(c); + if fl1 then + if Str[j] = '"' then fl2 := not fl2; + if fl2 then + if Str[j] = '''' then fl1 := not fl1; + until (c = 0) or (j >= Length(Str)); + + Result := Copy(Str, i + Length(OpenBracket), j - i - Length(OpenBracket)); + if i <> j then + Inc(j, Length(CloseBracket) - 1); +end; + +procedure frxCommonErrorHandler(Report: TfrxReport; const Text: String); +var + e: Exception; +begin + case Report.EngineOptions.NewSilentMode of + simMessageBoxes: frxErrorMsg(Text); + simReThrow: begin e := Exception.Create(Text); raise e; end; + end; +end; + +procedure frxErrorMsg(const Text: String); +begin + Application.MessageBox(PChar(Text), PChar(frxResources.Get('mbError')), + mb_Ok + mb_IconError); +end; + +function frxConfirmMsg(const Text: String; Buttons: Integer): Integer; +begin + Result := Application.MessageBox(PChar(Text), + PChar(frxResources.Get('mbConfirm')), mb_IconQuestion + Buttons); +end; + +procedure frxInfoMsg(const Text: String); +begin + Application.MessageBox(PChar(Text), PChar(frxResources.Get('mbInfo')), + mb_Ok + mb_IconInformation); +end; + +function frxIsValidFloat(const Value: string): Boolean; +begin + Result := True; + try + frxStrToFloat(Value); + except + Result := False; + end; +end; + +procedure frxAssignImages(Bitmap: TBitmap; dx, dy: Integer; + ImgList1: TImageList; ImgList2: TImageList = nil); +var + b: TBitmap; + x, y: Integer; + Done: Boolean; +begin + b := TBitmap.Create; + b.Width := dx; + b.Height := dy; + + x := 0; y := 0; + + repeat + b.Canvas.CopyRect(Rect(0, 0, dx, dy), Bitmap.Canvas, Rect(x, y, x + dx, y + dy)); + Done := y > Bitmap.Height; + + if not Done then + begin + ImgList1.AddMasked(b, b.TransparentColor); + if ImgList2 <> nil then + begin + Inc(x, dx); + b.Canvas.CopyRect(Rect(0, 0, dx, dy), Bitmap.Canvas, Rect(x, y, x + dx, y + dy)); + ImgList2.AddMasked(b, b.TransparentColor); + end; + end; + + Inc(x, dx); + if x >= Bitmap.Width then + begin + x := 0; + Inc(y, dy); + end; + until Done; + + b.Free; +end; + +procedure frxDrawTransparent(Canvas: TCanvas; x, y: Integer; bmp: TBitmap); +var + img: TImageList; +begin + if Assigned(bmp) then + begin + img := TImageList.Create(nil); + try + img.Width := bmp.Width; + img.Height := bmp.Height; + img.AddMasked(bmp, bmp.TransparentColor); + img.Draw(Canvas, x, y, 0); + img.Clear; + finally + img.Free; + end; + end; +end; + +procedure DrawBitmap(aCanvas: TCanvas; Dest: TRect; Bitmap: TBitmap); +var + Info: PBitmapInfo; + HInfo: HGLOBAL; + InfoSize: DWord; + Image: Pointer; + HImage: HGLOBAL; + ImageSize: DWord; +begin + with Bitmap do + begin + GetDIBSizes(Handle, InfoSize, ImageSize); + HInfo := GlobalAlloc(GMEM_MOVEABLE or GMEM_SHARE, InfoSize); + Info := PBitmapInfo(GlobalLock(HInfo)); + try + HImage := GlobalAlloc(GMEM_MOVEABLE or GMEM_SHARE, ImageSize); + Image := Pointer(GlobalLock(HImage)); + try + GetDIB(Handle, Palette, Info^, Image^); + SetStretchBltMode(ACanvas.Handle, STRETCH_HALFTONE); + with Info^.bmiHeader do + StretchDIBits(aCanvas.Handle, Dest.Left, Dest.Top, + Dest.RIght - Dest.Left, Dest.Bottom - Dest.Top, + 0, 0, biWidth, biHeight, Image, Info^, DIB_RGB_COLORS, SRCCOPY); + finally + GlobalUnlock(HImage); + GlobalFree(HImage); + end; + finally + GlobalUnlock(HInfo); + GlobalFree(HInfo); + end; + end; +end; + +procedure frxDrawGraphic(Canvas: TCanvas; DestRect: TRect; aGraph: TGraphic; + IsPrinting: Boolean); +var + Bitmap: TBitmap; +begin + if (aGraph is TMetaFile) or not IsPrinting then + Canvas.StretchDraw(DestRect, aGraph) + else + begin + Bitmap := TBitmap.Create; + try + Bitmap.Width := aGraph.Width; + Bitmap.Height := aGraph.Height; + Bitmap.PixelFormat := pf32Bit; + Bitmap.Canvas.Draw(0, 0, aGraph); + DrawBitmap(Canvas, DestRect, Bitmap); + finally + Bitmap.Free; + end; + end +end; + +procedure frxParsePageNumbers(const PageNumbers: String; List: TStrings; + Total: Integer); +var + i, j, n1, n2: Integer; + s: String; + IsRange: Boolean; +begin + List.Clear; + s := PageNumbers; + while Pos(' ', s) <> 0 do + Delete(s, Pos(' ', s), 1); + if s = '' then Exit; + + if s[Length(s)] = '-' then + s := s + IntToStr(Total); + s := s + ','; + i := 1; j := 1; n1 := 1; + IsRange := False; + + while i <= Length(s) do + begin + if s[i] = ',' then + begin + n2 := StrToInt(Copy(s, j, i - j)); + j := i + 1; + if IsRange then + while n1 <= n2 do + begin + List.Add(IntToStr(n1)); + Inc(n1); + end + else + List.Add(IntToStr(n2)); + IsRange := False; + end + else if s[i] = '-' then + begin + IsRange := True; + n1 := StrToInt(Copy(s, j, i - j)); + j := i + 1; + end; + Inc(i); + end; +end; + +function HTMLRGBColor(Color: TColor): string; +var + TheRgbValue : TColorRef; +begin + TheRgbValue := ColorToRGB(Color); + Result := '#' + Format('%.2x%.2x%.2x', [GetRValue(TheRGBValue), GetGValue(TheRGBValue), GetBValue(TheRGBValue)]); +end; + + +procedure ConvertOneItem(Item: TCollectionItem; ToAnsi: Boolean); +var + i: Integer; + TypeInfo: PTypeInfo; + PropCount: Integer; + PropList: PPropList; + + function Convert(const Value: String): String; + var + i: Integer; + begin + Result := ''; + i := 1; + while i <= Length(Value) do + begin + if ToAnsi then + begin + if Value[i] >= #128 then + Result := Result + #1 + Chr(Ord(Value[i]) - 128) else + Result := Result + Value[i]; + end + else + begin + if (Value[i] = #1) and (i < Length(Value)) then + begin + Result := Result + Chr(Ord(Value[i + 1]) + 128); + Inc(i); + end + else + Result := Result + Value[i]; + end; + + Inc(i); + end; + end; + + procedure DoStrProp; + var + Value, NewValue: String; + begin + Value := GetStrProp(Item, PropList[i]); + NewValue := Convert(Value); + if Value <> NewValue then + SetStrProp(Item, PropList[i], NewValue); + end; + + procedure DoVariantProp; + var + Value: Variant; + begin + Value := GetVariantProp(Item, PropList[i]); + if (TVarData(Value).VType = varString) or (TVarData(Value).VType = varOleStr) then + begin + Value := Convert(Value); + SetVariantProp(Item, PropList[i], Value); + end; + end; + +begin + TypeInfo := Item.ClassInfo; + PropCount := GetTypeData(TypeInfo).PropCount; + GetMem(PropList, PropCount * SizeOf(PPropInfo)); + GetPropInfos(TypeInfo, PropList); + + try + for i := 0 to PropCount - 1 do + begin + case PropList[i].PropType^.Kind of + tkString, tkLString, tkWString: + DoStrProp; + + tkVariant: + DoVariantProp; + end; + end; + + finally + FreeMem(PropList, PropCount * SizeOf(PPropInfo)); + end; +end; + +procedure frxWriteCollection(Collection: TCollection; Writer: TWriter; + Owner: TfrxComponent); +var + i, l: Integer; + xs: TfrxXMLSerializer; + s: String; + vt: TValueType; +begin + if Owner.IsWriting then + begin + { called from SaveToStream } + Writer.WriteListBegin; + xs := TfrxXMLSerializer.Create(nil); + try + xs.Owner := Owner.Report; + for i := 0 to Collection.Count - 1 do + begin + Writer.WriteListBegin; + s := xs.ObjToXML(Collection.Items[i]); + vt := vaLString; + Writer.Write(vt, SizeOf(vt)); + l := Length(s); + Writer.Write(l, SizeOf(l)); + Writer.Write(s[1], l); + Writer.WriteListEnd; + end; + finally + Writer.WriteListEnd; + xs.Free; + end; + end + else + begin + { called from Delphi streamer } + Writer.WriteCollection(Collection); + end; +end; + +procedure frxReadCollection(Collection: TCollection; Reader: TReader; + Owner: TfrxComponent); +var + i: Integer; + vt: TValueType; + xs: TfrxXMLSerializer; + s: String; + Item: TCollectionItem; + NeedFree: Boolean; +begin + vt := Reader.ReadValue; + if vt <> vaCollection then + begin + { called from LoadFromStream } + NeedFree := False; + xs := nil; + if Owner.Report <> nil then + xs := TfrxXMLSerializer(Owner.Report.XMLSerializer); + + if xs = nil then + begin + xs := TfrxXMLSerializer.Create(nil); + xs.Owner := Owner.Report; + NeedFree := True; + end; + + try + Collection.Clear; + + while not Reader.EndOfList do + begin + Reader.ReadListBegin; + Item := Collection.Add; + s := Reader.ReadString; + if NeedFree then + xs.ReadPersistentStr(Owner.Report, Item, s) + else + xs.XMLToObj(s, Item); + Reader.ReadListEnd; + end; + finally + Reader.ReadListEnd; + if NeedFree then + xs.Free; + end; + end + else + begin + { called from Delphi streamer } + Reader.ReadCollection(Collection); + for i := 0 to Collection.Count - 1 do + ConvertOneItem(Collection.Items[i], False); + end; +end; + +function GetTemporaryFolder: String; +var + Path: String; +begin + Setlength(Path, MAX_PATH); + SetLength(Path, GetTempPath(MAX_PATH, @Path[1])); + Result := StrPas(@Path[1]); +end; + +function GetTempFile: String; +var + Path: String; + FileName: String; +begin + SetLength(Path, MAX_PATH); + SetLength(Path, GetTempPath(MAX_PATH, @Path[1])); + SetLength(FileName, MAX_PATH); + GetTempFileName(@Path[1], PChar('fr'), 0, @FileName[1]); + Result := StrPas(@FileName[1]); +end; + +function frxCreateTempFile(const TempDir: String): String; +var + Path: String; + FileName: String; +begin + Path := TempDir; + if (Path <> '') and (Path[Length(Path)] <> '\') then + Path := Path + '\'; + SetLength(FileName, MAX_PATH); + if Path = '' then + begin + SetLength(Path, MAX_PATH); + SetLength(Path, GetTempPath(MAX_PATH, @Path[1])); + end + else begin + Path := Path + #0; + SetLength(Path, MAX_PATH); + end; + GetTempFileName(@Path[1], PChar('fr'), 0, @FileName[1]); + Result := StrPas(@FileName[1]); +end; + +function GetAppFileName: String; +var + fName: String; + nsize: cardinal; +begin + nsize := MAX_PATH; + SetLength(fName,nsize); + SetLength(fName, GetModuleFileName(hinstance, pchar(fName), nsize)); + Result := fName; +end; + +function GetAppPath: String; +begin + Result := ExtractFilePath(GetAppFileName); +end; + +{$IFNDEF Delphi7} +function frFloat2Str(const Value: Extended; const Prec: Integer = 2): String; +var + i: Integer; + IntVal: Integer; +begin + IntVal := Trunc(Value); + if IntVal <> Value then + Result := Format('%.' + IntToStr(Prec)+ 'f', [Value]) + else + Result := IntToStr(IntVal); + if DecimalSeparator <> '.' then + begin + i := Pos(DecimalSeparator, Result); + if i > 0 then + Result[i] := '.'; + end; +end; +{$ELSE} +function frFloat2Str(const Value: Extended; const Prec: Integer = 2; const Sep: Char = '.'): String; +var + IntVal: Integer; + FormatSettings: TFormatSettings; +begin + IntVal := Trunc(Value); + if IntVal <> Value then + begin + GetLocaleFormatSettings(0, FormatSettings); + FormatSettings.DecimalSeparator := Sep; + FormatSettings.ThousandSeparator := Char(0); + Result := Format('%.' + IntToStr(Prec)+ 'f', [Value], FormatSettings) + end + else + Result := IntToStr(IntVal); +end; +{$ENDIF} + +function frxReverseString(const AText: string): string; +var + I: Integer; + P: PChar; +begin + SetLength(Result, Length(AText)); + P := PChar(Result); + for I := Length(AText) downto 1 do + begin + P^ := AText[I]; + Inc(P); + end; +end; + +function ChangeChars(const Str: string; FromChar, ToChar: Char): string; +var + I: Integer; +begin + Result := Str; + for I := 1 to Length(Result) do + if Result[I] = FromChar then + Result[I] := ToChar; +end; + +function frxUnixPath2WinPath(const Path: string): string; +begin + Result := ChangeChars(Path, '/', '\'); +end; + + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxVariables.pas b/official/4.2/LibD11/frxVariables.pas new file mode 100644 index 0000000..7264c82 --- /dev/null +++ b/official/4.2/LibD11/frxVariables.pas @@ -0,0 +1,406 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ FR Variables } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxVariables; + +interface + +{$I frx.inc} + +uses + SysUtils, Windows, Messages, Classes, Graphics, Controls, Forms, Dialogs, + frxXML +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxVariable = class(TCollectionItem) + private + FName: String; + FValue: Variant; + public + constructor Create(Collection: TCollection); override; + procedure Assign(Source: TPersistent); override; + published + property Name: String read FName write FName; + property Value: Variant read FValue write FValue; + end; + + TfrxVariables = class(TCollection) + private + function GetItems(Index: Integer): TfrxVariable; + function GetVariable(Index: String): Variant; + procedure SetVariable(Index: String; const Value: Variant); + public + constructor Create; + function Add: TfrxVariable; + function Insert(Index: Integer): TfrxVariable; + function IndexOf(const Name: String): Integer; + procedure AddVariable(const ACategory, AName: String; const AValue: Variant); + procedure DeleteCategory(const Name: String); + procedure DeleteVariable(const Name: String); + procedure GetCategoriesList(List: TStrings; ClearList: Boolean = True); + procedure GetVariablesList(const Category: String; List: TStrings); + procedure LoadFromFile(const FileName: String); + procedure LoadFromStream(Stream: TStream); + procedure LoadFromXMLItem(Item: TfrxXMLItem); + procedure SaveToFile(const FileName: String); + procedure SaveToStream(Stream: TStream); + procedure SaveToXMLItem(Item: TfrxXMLItem); + property Items[Index: Integer]: TfrxVariable read GetItems; + property Variables[Index: String]: Variant read GetVariable + write SetVariable; default; + end; + + TfrxArray = class(TCollection) + private + function GetItems(Index: Integer): TfrxVariable; + function GetVariable(Index: Variant): Variant; + procedure SetVariable(Index: Variant; const Value: Variant); + public + constructor Create; + function IndexOf(const Name: Variant): Integer; + property Items[Index: Integer]: TfrxVariable read GetItems; + property Variables[Index: Variant]: Variant read GetVariable + write SetVariable; default; + end; + + +implementation + +uses frxXMLSerializer; + + +{ TfrxVariable } + +constructor TfrxVariable.Create(Collection: TCollection); +begin + inherited; + FValue := Null; +end; + +procedure TfrxVariable.Assign(Source: TPersistent); +begin + if Source is TfrxVariable then + begin + FName := TfrxVariable(Source).Name; + FValue := TfrxVariable(Source).Value; + end; +end; + + +{ TfrxVariables } + +constructor TfrxVariables.Create; +begin + inherited Create(TfrxVariable); +end; + +function TfrxVariables.Add: TfrxVariable; +begin + Result := TfrxVariable(inherited Add); +end; + +function TfrxVariables.Insert(Index: Integer): TfrxVariable; +begin + Result := TfrxVariable(inherited Insert(Index)); +end; + +function TfrxVariables.GetItems(Index: Integer): TfrxVariable; +begin + Result := TfrxVariable(inherited Items[Index]); +end; + +function TfrxVariables.IndexOf(const Name: String): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to Count - 1 do + if AnsiCompareText(Name, Items[i].Name) = 0 then + begin + Result := i; + break; + end; +end; + +function TfrxVariables.GetVariable(Index: String): Variant; +var + i: Integer; +begin + i := IndexOf(Index); + if i <> -1 then + Result := Items[i].Value else + Result := Null; +end; + +procedure TfrxVariables.SetVariable(Index: String; const Value: Variant); +var + i: Integer; + v: TfrxVariable; +begin + i := IndexOf(Index); + if i <> -1 then + Items[i].Value := Value + else + begin + v := Add; + v.Name := Index; + v.Value := Value; + end; +end; + +procedure TfrxVariables.GetCategoriesList(List: TStrings; ClearList: Boolean = True); +var + i: Integer; + s: String; +begin + if ClearList then + List.Clear; + + for i := 0 to Count - 1 do + begin + s := Items[i].Name; + if (s <> '') and (s[1] = ' ') then + List.Add(Copy(s, 2, 255)); + end; +end; + +procedure TfrxVariables.GetVariablesList(const Category: String; List: TStrings); +var + i, j: Integer; + s: String; +begin + List.Clear; + for i := 0 to Count - 1 do + if (Category = '') or (AnsiCompareText(Items[i].Name, ' ' + Category) = 0) then + begin + if Category <> '' then + j := i + 1 else + j := i; + while j < Count do + begin + s := Items[j].Name; + Inc(j); + if (s <> '') and (s[1] <> ' ') then + List.Add(s) else + break + end; + break; + end; +end; + +procedure TfrxVariables.DeleteCategory(const Name: String); +var + i: Integer; +begin + i := 0; + while i < Count do + begin + if AnsiCompareText(Items[i].Name, ' ' + Name) = 0 then + begin + Items[i].Free; + while (i < Count) and (Items[i].Name[1] <> ' ') do + Items[i].Free; + break; + end; + Inc(i); + end; +end; + +procedure TfrxVariables.DeleteVariable(const Name: String); +var + i: Integer; +begin + i := IndexOf(Name); + if i <> -1 then + Items[i].Free; +end; + +procedure TfrxVariables.AddVariable(const ACategory, AName: String; + const AValue: Variant); +var + i: Integer; +begin + i := 0; + while i < Count do + begin + if AnsiCompareText(Items[i].Name, ' ' + ACategory) = 0 then + begin + Inc(i); + while (i < Count) and (Items[i].Name[1] <> ' ') do + Inc(i); + if i = Count then + with Add do + begin + Name := AName; + Value := AValue; + end + else + with Insert(i) do + begin + Name := AName; + Value := AValue; + end; + break; + end; + Inc(i); + end; +end; + +procedure TfrxVariables.LoadFromFile(const FileName: String); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmOpenRead); + try + LoadFromStream(f); + finally + f.Free; + end; +end; + +procedure TfrxVariables.LoadFromStream(Stream: TStream); +var + x: TfrxXMLDocument; +begin + Clear; + x := TfrxXMLDocument.Create; + try + x.LoadFromStream(Stream); + if CompareText(x.Root.Name, 'variables') = 0 then + LoadFromXMLItem(x.Root); + finally + x.Free; + end; +end; + +procedure TfrxVariables.LoadFromXMLItem(Item: TfrxXMLItem); +var + xs: TfrxXMLSerializer; + i: Integer; +begin + Clear; + xs := TfrxXMLSerializer.Create(nil); + try + for i := 0 to Item.Count - 1 do + if CompareText(Item[i].Name, 'item') = 0 then + xs.XMLToObj(Item[i].Text, Add); + finally + xs.Free; + end; +end; + +procedure TfrxVariables.SaveToFile(const FileName: String); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmCreate); + try + SaveToStream(f); + finally + f.Free; + end; +end; + +procedure TfrxVariables.SaveToStream(Stream: TStream); +var + x: TfrxXMLDocument; +begin + x := TfrxXMLDocument.Create; + x.AutoIndent := True; + try + x.Root.Name := 'variables'; + SaveToXMLItem(x.Root); + x.SaveToStream(Stream); + finally + x.Free; + end; +end; + +procedure TfrxVariables.SaveToXMLItem(Item: TfrxXMLItem); +var + xi: TfrxXMLItem; + xs: TfrxXMLSerializer; + i: Integer; +begin + xs := TfrxXMLSerializer.Create(nil); + try + for i := 0 to Count - 1 do + begin + xi := Item.Add; + xi.Name := 'item'; + xi.Text := xs.ObjToXML(Items[i]); + end; + finally + xs.Free; + end; +end; + + +{ TfrxArray } + +constructor TfrxArray.Create; +begin + inherited Create(TfrxVariable); +end; + +function TfrxArray.GetItems(Index: Integer): TfrxVariable; +begin + Result := TfrxVariable(inherited Items[Index]); +end; + +function TfrxArray.IndexOf(const Name: Variant): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to Count - 1 do + if AnsiCompareText(VarToStr(Name), Items[i].Name) = 0 then + begin + Result := i; + break; + end; +end; + +function TfrxArray.GetVariable(Index: Variant): Variant; +var + i: Integer; +begin + i := IndexOf(Index); + if i <> -1 then + Result := Items[i].Value else + Result := Null; +end; + +procedure TfrxArray.SetVariable(Index: Variant; const Value: Variant); +var + i: Integer; + v: TfrxVariable; +begin + i := IndexOf(Index); + if i <> -1 then + Items[i].Value := Value + else + begin + v := TfrxVariable(inherited Add); + v.Name := Index; + v.Value := Value; + end; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxVersion.inc b/official/4.2/LibD11/frxVersion.inc new file mode 100644 index 0000000..b51d74e --- /dev/null +++ b/official/4.2/LibD11/frxVersion.inc @@ -0,0 +1 @@ +'4.3' \ No newline at end of file diff --git a/official/4.2/LibD11/frxWatchForm.dfm b/official/4.2/LibD11/frxWatchForm.dfm new file mode 100644 index 0000000..cf7458a Binary files /dev/null and b/official/4.2/LibD11/frxWatchForm.dfm differ diff --git a/official/4.2/LibD11/frxWatchForm.pas b/official/4.2/LibD11/frxWatchForm.pas new file mode 100644 index 0000000..85b4f25 --- /dev/null +++ b/official/4.2/LibD11/frxWatchForm.pas @@ -0,0 +1,178 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Watches toolwindow } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxWatchForm; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + StdCtrls, ComCtrls, ToolWin, fs_iinterpreter +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + +type + TfrxWatchForm = class(TForm) + ToolBar1: TToolBar; + AddB: TToolButton; + DeleteB: TToolButton; + EditB: TToolButton; + WatchLB: TListBox; + procedure FormShow(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); + procedure FormDestroy(Sender: TObject); + procedure AddBClick(Sender: TObject); + procedure DeleteBClick(Sender: TObject); + procedure EditBClick(Sender: TObject); + procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); + private + FScript: TfsScript; + FScriptRunning: Boolean; + FWatches: TStrings; + function CalcWatch(const s: String): String; + public + procedure UpdateWatches; + property Script: TfsScript read FScript write FScript; + property ScriptRunning: Boolean read FScriptRunning write FScriptRunning; + property Watches: TStrings read FWatches; + end; + + +implementation + +{$R *.DFM} + +uses frxRes, frxEvaluateForm; + +type + THackWinControl = class(TWinControl); + + +procedure TfrxWatchForm.FormCreate(Sender: TObject); +begin + Caption := frxGet(5900); + AddB.Hint := frxGet(5901); + DeleteB.Hint := frxGet(5902); + EditB.Hint := frxGet(5903); + FWatches := TStringList.Create; +{$IFDEF UseTabset} + WatchLB.BevelKind := bkFlat; +{$ELSE} + WatchLB.BorderStyle := bsSingle; +{$ENDIF} + + if UseRightToLeftAlignment then + FlipChildren(True); +end; + +procedure TfrxWatchForm.FormDestroy(Sender: TObject); +begin + FWatches.Free; +end; + +procedure TfrxWatchForm.FormShow(Sender: TObject); +begin + Toolbar1.Images := frxResources.MainButtonImages; +end; + +procedure TfrxWatchForm.FormKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + if Key = VK_F1 then + frxResources.Help(Self); +end; + +procedure TfrxWatchForm.AddBClick(Sender: TObject); +begin + with TfrxEvaluateForm.Create(Owner) do + begin + IsWatch := True; + if ShowModal = mrOk then + begin + Watches.Add(ExpressionE.Text); + UpdateWatches; + end; + Free; + end; +end; + +procedure TfrxWatchForm.DeleteBClick(Sender: TObject); +begin + if WatchLB.ItemIndex <> -1 then + begin + Watches.Delete(WatchLB.ItemIndex); + UpdateWatches; + end; +end; + +procedure TfrxWatchForm.EditBClick(Sender: TObject); +begin + if WatchLB.ItemIndex <> -1 then + with TfrxEvaluateForm.Create(Owner) do + begin + IsWatch := True; + ExpressionE.Text := Watches[WatchLB.ItemIndex]; + if ShowModal = mrOk then + begin + Watches[WatchLB.ItemIndex] := ExpressionE.Text; + UpdateWatches; + end; + Free; + end; +end; + +function TfrxWatchForm.CalcWatch(const s: String): String; +var + v: Variant; +begin + if (FScript <> nil) and (FScriptRunning) then + begin + v := FScript.Evaluate(s); + Result := VarToStr(v); + if TVarData(v).VType = varBoolean then + if Boolean(v) = True then + Result := 'True' else + Result := 'False' + else if (TVarData(v).VType = varString) or (TVarData(v).VType = varOleStr) then + Result := '''' + v + '''' + else if v = Null then + Result := 'Null'; + end + else + Result := 'not accessible'; +end; + +procedure TfrxWatchForm.UpdateWatches; +var + i: Integer; +begin + WatchLB.Items.BeginUpdate; + WatchLB.Items.Clear; + for i := 0 to Watches.Count - 1 do + WatchLB.Items.Add(Watches[i] + ': ' + CalcWatch(Watches[i])); + WatchLB.Items.EndUpdate; +end; + +procedure TfrxWatchForm.FormCloseQuery(Sender: TObject; var CanClose: Boolean); +begin + CanClose := False; +end; + +end. + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxXML.pas b/official/4.2/LibD11/frxXML.pas new file mode 100644 index 0000000..6ba934e --- /dev/null +++ b/official/4.2/LibD11/frxXML.pas @@ -0,0 +1,944 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ XML document } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxXML; + +interface + +{$I frx.inc} + +uses + Windows, SysUtils, Classes +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxInvalidXMLException = class(Exception); + + TfrxXMLItem = class(TObject) + private + FData: Pointer; { optional item data } + FHiOffset: Byte; { hi-part of the offset } + FItems: TList; { subitems } + FLoaded: Boolean; { item is loaded, no need to call LoadItem } + FLoOffset: Integer; { lo-part of the offset } + FModified: Boolean; { item is modified (used by preview designer) } + FName: String; { item name } + FParent: TfrxXMLItem; { item parent } + FText: String; { item attributes } + FUnloadable: Boolean; + FValue: String; { item value Value } + function GetCount: Integer; + function GetItems(Index: Integer): TfrxXMLItem; + function GetOffset: Int64; + procedure SetOffset(const Value: Int64); + function GetProp(Index: String): String; + procedure SetProp(Index: String; const Value: String); + public + constructor Create; + destructor Destroy; override; + procedure AddItem(Item: TfrxXMLItem); + procedure Clear; + procedure InsertItem(Index: Integer; Item: TfrxXMLItem); + + function Add: TfrxXMLItem; + function Find(const Name: String): Integer; + function FindItem(const Name: String): TfrxXMLItem; + function IndexOf(Item: TfrxXMLItem): Integer; + function PropExists(const Index: String): Boolean; + function Root: TfrxXMLItem; + procedure DeleteProp(const Index: String); + + property Count: Integer read GetCount; + property Data: Pointer read FData write FData; + property Items[Index: Integer]: TfrxXMLItem read GetItems; default; + property Loaded: Boolean read FLoaded; + property Modified: Boolean read FModified write FModified; + property Name: String read FName write FName; +{ offset is the position of the item in the tempstream. This parameter is needed + for dynamically loading large files. Items that can be loaded on-demand must + have Unloadable = True (in run-time) or have 'ld="0"' parameter (in the file) } + property Offset: Int64 read GetOffset write SetOffset; + property Parent: TfrxXMLItem read FParent; + property Prop[Index: String]: String read GetProp write SetProp; + property Text: String read FText write FText; + property Unloadable: Boolean read FUnloadable write FUnloadable; + property Value: String read FValue write FValue; + end; + + TfrxXMLDocument = class(TObject) + private + FAutoIndent: Boolean; { use indents when writing document to a file } + FRoot: TfrxXMLItem; { root item } + FTempDir: String; { folder for temporary files } + FTempFile: String; { tempfile name } + FTempStream: TStream; { temp stream associated with tempfile } + FTempFileCreated: Boolean; { tempfile has been created - need to delete it } + procedure CreateTempFile; + procedure DeleteTempFile; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + procedure LoadItem(Item: TfrxXMLItem); + procedure UnloadItem(Item: TfrxXMLItem); + procedure SaveToStream(Stream: TStream); + procedure LoadFromStream(Stream: TStream; AllowPartialLoading: Boolean = False); + procedure SaveToFile(const FileName: String); + procedure LoadFromFile(const FileName: String); + + property AutoIndent: Boolean read FAutoIndent write FAutoIndent; + property Root: TfrxXMLItem read FRoot; + property TempDir: String read FTempDir write FTempDir; + end; + +{ TfrxXMLReader and TfrxXMLWriter are doing actual read/write to the XML file. + Read/write process is buffered. } + + TfrxXMLReader = class(TObject) + private + FBuffer: PChar; + FBufPos: Integer; + FBufEnd: Integer; + FPosition: Int64; + FSize: Int64; + FStream: TStream; + procedure SetPosition(const Value: Int64); + procedure ReadBuffer; + procedure ReadItem(var Name, Text: String); + public + constructor Create(Stream: TStream); + destructor Destroy; override; + procedure RaiseException; + procedure ReadHeader; + procedure ReadRootItem(Item: TfrxXMLItem; ReadChildren: Boolean = True); + property Position: Int64 read FPosition write SetPosition; + property Size: Int64 read FSize; + end; + + TfrxXMLWriter = class(TObject) + private + FAutoIndent: Boolean; + FBuffer: String; + FStream: TStream; + FTempStream: TStream; + procedure FlushBuffer; + procedure WriteLn(const s: String); + procedure WriteItem(Item: TfrxXMLItem; Level: Integer = 0); + public + constructor Create(Stream: TStream); + procedure WriteHeader; + procedure WriteRootItem(RootItem: TfrxXMLItem); + property TempStream: TStream read FTempStream write FTempStream; + end; + + +{ StrToXML changes '<', '>', '"', cr, lf symbols to its ascii codes } +function frxStrToXML(const s: String): String; + +{ ValueToXML convert a value to the valid XML string } +function frxValueToXML(const Value: Variant): String; + +{ XMLToStr is opposite to StrToXML function } +function frxXMLToStr(const s: String): String; + + +implementation + + +function frxStrToXML(const s: String): String; +const + SpecChars = ['<', '>', '"', #10, #13, '&']; +var + i, lenRes, resI, ch: Integer; + pRes: PChar; + + procedure ReplaceChars(var s: String; i: Integer); + begin + Insert('#' + IntToStr(Ord(s[i])) + ';', s, i + 1); + s[i] := '&'; + end; + +begin + lenRes := Length(s); + + if lenRes < 32 then + begin + Result := s; + for i := lenRes downto 1 do + if s[i] in SpecChars then + if s[i] <> '&' then + ReplaceChars(Result, i) + else + begin + if Copy(s, i + 1, 5) = 'quot;' then + begin + Delete(Result, i, 6); + Insert('"', Result, i); + end; + end; + Exit; + end; + + { speed optimized code } + SetLength(Result, lenRes); + pRes := PChar(Result) - 1; + resI := 1; + i := 1; + + while i <= Length(s) do + begin + if resI + 5 > lenRes then + begin + Inc(lenRes, 256); + SetLength(Result, lenRes); + pRes := PChar(Result) - 1; + end; + + if s[i] in SpecChars then + begin + if (s[i] = '&') and (i <= Length(s) - 5) and (s[i + 1] = 'q') and + (s[i + 2] = 'u') and (s[i + 3] = 'o') and (s[i + 4] = 't') and (s[i + 5] = ';') then + begin + pRes[resI] := '&'; + pRes[resI + 1] := '#'; + pRes[resI + 2] := '3'; + pRes[resI + 3] := '4'; + pRes[resI + 4] := ';'; + Inc(resI, 4); + Inc(i, 5); + end + else + begin + pRes[resI] := '&'; + pRes[resI + 1] := '#'; + + ch := Ord(s[i]); + if ch < 10 then + begin + pRes[resI + 2] := Chr(ch + $30); + Inc(resI, 3); + end + else if ch < 100 then + begin + pRes[resI + 2] := Chr(ch div 10 + $30); + pRes[resI + 3] := Chr(ch mod 10 + $30); + Inc(resI, 4); + end + else + begin + pRes[resI + 2] := Chr(ch div 100 + $30); + pRes[resI + 3] := Chr(ch mod 100 div 10 + $30); + pRes[resI + 4] := Chr(ch mod 10 + $30); + Inc(resI, 5); + end; + pRes[resI] := ';'; + end; + end + else + pRes[resI] := s[i]; + Inc(resI); + Inc(i); + end; + + SetLength(Result, resI - 1); +end; + +function frxXMLToStr(const s: String): String; +var + i, j, h, n: Integer; +begin + Result := s; + + i := 1; + n := Length(s); + while i < n do + begin + if Result[i] = '&' then + if (i + 3 <= n) and (Result[i + 1] = '#') then + begin + j := i + 3; + while Result[j] <> ';' do + Inc(j); + h := StrToInt(Copy(Result, i + 2, j - i - 2)); + Delete(Result, i, j - i); + Result[i] := Chr(h); + Dec(n, j - i); + end + else if Copy(Result, i + 1, 5) = 'quot;' then + begin + Delete(Result, i, 5); + Result[i] := '"'; + Dec(n, 5); + end; + Inc(i); + end; +end; + +function frxValueToXML(const Value: Variant): String; +begin + case TVarData(Value).VType of + varSmallint, varInteger, varByte: + Result := IntToStr(Value); + + varSingle, varDouble, varCurrency: + Result := FloatToStr(Value); + + varDate: + Result := DateToStr(Value); + + varOleStr, varString, varVariant: + Result := frxStrToXML(Value); + + varBoolean: + if Value = True then Result := '1' else Result := '0'; + + else + Result := ''; + end; +end; + + +{ TfrxXMLItem } + +constructor TfrxXMLItem.Create; +begin + FLoaded := True; +end; + +destructor TfrxXMLItem.Destroy; +begin + Clear; + if FParent <> nil then + FParent.FItems.Remove(Self); + inherited; +end; + +procedure TfrxXMLItem.Clear; +begin + if FItems <> nil then + begin + while FItems.Count > 0 do + TfrxXMLItem(FItems[0]).Free; + FItems.Free; + FItems := nil; + end; + if FUnloadable then + FLoaded := False; +end; + +function TfrxXMLItem.GetItems(Index: Integer): TfrxXMLItem; +begin + Result := TfrxXMLItem(FItems[Index]); +end; + +function TfrxXMLItem.GetCount: Integer; +begin + if FItems = nil then + Result := 0 else + Result := FItems.Count; +end; + +function TfrxXMLItem.Add: TfrxXMLItem; +begin + Result := TfrxXMLItem.Create; + AddItem(Result); +end; + +procedure TfrxXMLItem.AddItem(Item: TfrxXMLItem); +begin + if FItems = nil then + FItems := TList.Create; + + FItems.Add(Item); + if Item.FParent <> nil then + Item.FParent.FItems.Remove(Item); + Item.FParent := Self; +end; + +procedure TfrxXMLItem.InsertItem(Index: Integer; Item: TfrxXMLItem); +begin + AddItem(Item); + FItems.Delete(FItems.Count - 1); + FItems.Insert(Index, Item); +end; + +function TfrxXMLItem.Find(const Name: String): Integer; +var + i: Integer; +begin + Result := -1; + for i := 0 to Count - 1 do + if AnsiCompareText(Items[i].Name, Name) = 0 then + begin + Result := i; + break; + end; +end; + +function TfrxXMLItem.FindItem(const Name: String): TfrxXMLItem; +var + i: Integer; +begin + i := Find(Name); + if i = -1 then + begin + Result := Add; + Result.Name := Name; + end + else + Result := Items[i]; +end; + +function TfrxXMLItem.GetOffset: Int64; +begin + Result := Int64(FHiOffset) * $100000000 + Int64(FLoOffset); +end; + +procedure TfrxXMLItem.SetOffset(const Value: Int64); +begin + FHiOffset := Value div $100000000; + FLoOffset := Value mod $100000000; +end; + +function TfrxXMLItem.Root: TfrxXMLItem; +begin + Result := Self; + while Result.Parent <> nil do + Result := Result.Parent; +end; + +function TfrxXMLItem.GetProp(Index: String): String; +var + i: Integer; +begin + i := Pos(' ' + AnsiUppercase(Index) + '="', AnsiUppercase(' ' + FText)); + if i <> 0 then + begin + Result := Copy(FText, i + Length(Index + '="'), MaxInt); + Result := frxXMLToStr(Copy(Result, 1, Pos('"', Result) - 1)); + end + else + Result := ''; +end; + +procedure TfrxXMLItem.SetProp(Index: String; const Value: String); +var + i, j: Integer; + s: String; +begin + i := Pos(' ' + AnsiUppercase(Index) + '="', AnsiUppercase(' ' + FText)); + if i <> 0 then + begin + j := i + Length(Index + '="'); + while (j <= Length(FText)) and (FText[j] <> '"') do + Inc(j); + Delete(FText, i, j - i + 1); + end + else + i := Length(FText) + 1; + + s := Index + '="' + frxStrToXML(Value) + '"'; + if (i > 1) and (FText[i - 1] <> ' ') then + s := ' ' + s; + Insert(s, FText, i); +end; + +function TfrxXMLItem.PropExists(const Index: String): Boolean; +begin + Result := Pos(' ' + AnsiUppercase(Index) + '="', ' ' + AnsiUppercase(FText)) > 0; +end; + +procedure TfrxXMLItem.DeleteProp(const Index: String); +var + i: Integer; +begin + i := Pos(' ' + AnsiUppercase(Index) + '="', ' ' + AnsiUppercase(FText)); + if i > 0 then + begin + SetProp(Index, ''); + Delete(FText, i, Length(Index) + 4); + end; +end; + +function TfrxXMLItem.IndexOf(Item: TfrxXMLItem): Integer; +begin + Result := FItems.IndexOf(Item); +end; + + +{ TfrxXMLDocument } + +constructor TfrxXMLDocument.Create; +begin + FRoot := TfrxXMLItem.Create; +end; + +destructor TfrxXMLDocument.Destroy; +begin + DeleteTempFile; + FRoot.Free; + inherited; +end; + +procedure TfrxXMLDocument.Clear; +begin + FRoot.Clear; + DeleteTempFile; +end; + +procedure TfrxXMLDocument.CreateTempFile; +var + Path: String[64]; + FileName: String[255]; +begin + if FTempFileCreated then Exit; + + Path := FTempDir; + if Path = '' then + Path[0] := Chr(GetTempPath(64, @Path[1])) else + Path := Path + #0; + if (Path <> '') and (Path[Length(Path)] <> '\') then + Path := Path + '\'; + + GetTempFileName(@Path[1], PChar('fr'), 0, @FileName[1]); + FTempFile := StrPas(@FileName[1]); + FTempStream := TFileStream.Create(FTempFile, fmOpenReadWrite); + FTempFileCreated := True; +end; + +procedure TfrxXMLDocument.DeleteTempFile; +begin + if FTempFileCreated then + begin + FTempStream.Free; + FTempStream := nil; + DeleteFile(FTempFile); + FTempFileCreated := False; + end; + if FTempStream <> nil then + FTempStream.Free; + FTempStream := nil; +end; + +procedure TfrxXMLDocument.LoadItem(Item: TfrxXMLItem); +var + rd: TfrxXMLReader; + Text: String; +begin + if (FTempStream = nil) or Item.FLoaded or not Item.FUnloadable then Exit; + + rd := TfrxXMLReader.Create(FTempStream); + try + rd.Position := Item.Offset; + Text := Item.Text; + rd.ReadRootItem(Item); + Item.Text := Text; + Item.FLoaded := True; + finally + rd.Free; + end; +end; + +procedure TfrxXMLDocument.UnloadItem(Item: TfrxXMLItem); +var + wr: TfrxXMLWriter; +begin + if not Item.FLoaded or not Item.FUnloadable then Exit; + + CreateTempFile; + FTempStream.Position := FTempStream.Size; + wr := TfrxXMLWriter.Create(FTempStream); + try + Item.Offset := FTempStream.Size; + wr.WriteRootItem(Item); + Item.Clear; + finally + wr.Free; + end; +end; + +procedure TfrxXMLDocument.LoadFromStream(Stream: TStream; + AllowPartialLoading: Boolean = False); +var + rd: TfrxXMLReader; +begin + DeleteTempFile; + + rd := TfrxXMLReader.Create(Stream); + try + FRoot.Clear; + FRoot.Offset := 0; + rd.ReadHeader; + rd.ReadRootItem(FRoot, not AllowPartialLoading); + finally + rd.Free; + end; + + if AllowPartialLoading then + FTempStream := Stream else + FTempStream := nil; +end; + +procedure TfrxXMLDocument.SaveToStream(Stream: TStream); +var + wr: TfrxXMLWriter; +begin + wr := TfrxXMLWriter.Create(Stream); + wr.TempStream := FTempStream; + wr.FAutoIndent := FAutoIndent; + + try + wr.WriteHeader; + wr.WriteRootItem(FRoot); + finally + wr.Free; + end; +end; + +procedure TfrxXMLDocument.LoadFromFile(const FileName: String); +var + s: TFileStream; +begin + s := TFileStream.Create(FileName, fmOpenRead or fmShareDenyWrite); + LoadFromStream(s, True); +end; + +procedure TfrxXMLDocument.SaveToFile(const FileName: String); +var + s: TFileStream; +begin + s := TFileStream.Create(FileName + '.tmp', fmCreate); + try + SaveToStream(s); + finally + s.Free; + end; + + DeleteTempFile; + DeleteFile(FileName); + RenameFile(FileName + '.tmp', FileName); + LoadFromFile(FileName); +end; + + +{ TfrxXMLReader } + +constructor TfrxXMLReader.Create(Stream: TStream); +begin + FStream := Stream; + FSize := Stream.Size; + FPosition := Stream.Position; + GetMem(FBuffer, 4096); +end; + +destructor TfrxXMLReader.Destroy; +begin + FreeMem(FBuffer, 4096); + FStream.Position := FPosition; + inherited; +end; + +procedure TfrxXMLReader.ReadBuffer; +begin + FBufEnd := FStream.Read(FBuffer^, 4096); + FBufPos := 0; +end; + +procedure TfrxXMLReader.SetPosition(const Value: Int64); +begin + FPosition := Value; + FStream.Position := Value; + FBufPos := 0; + FBufEnd := 0; +end; + +procedure TfrxXMLReader.RaiseException; +begin + raise TfrxInvalidXMLException.Create('Invalid file format'); +end; + +procedure TfrxXMLReader.ReadHeader; +var + s1, s2: String; +begin + ReadItem(s1, s2); + if Pos('?xml', s1) <> 1 then + RaiseException; +end; + +procedure TfrxXMLReader.ReadItem(var Name, Text: String); +var + c: Integer; + curpos, len: Integer; + state: (FindLeft, FindRight, FindComment, Done); + i, comment: Integer; + ps: PChar; +begin + Text := ''; + comment := 0; + state := FindLeft; + curpos := 0; + len := 4096; + SetLength(Name, len); + ps := @Name[1]; + + while FPosition < FSize do + begin + if FBufPos = FBufEnd then + ReadBuffer; + c := Ord(FBuffer[FBufPos]); + Inc(FBufPos); + Inc(FPosition); + + if state = FindLeft then + begin + if c = Ord('<') then + state := FindRight + end + else if state = FindRight then + begin + if c = Ord('>') then + begin + state := Done; + break; + end + else if c = Ord('<') then + RaiseException + else + begin + ps[curpos] := Chr(c); + Inc(curpos); + if (curpos = 3) and (Pos('!--', Name) = 1) then + begin + state := FindComment; + comment := 0; + curpos := 0; + end; + if curpos >= len - 1 then + begin + Inc(len, 4096); + SetLength(Name, len); + ps := @Name[1]; + end; + end; + end + else if State = FindComment then + begin + if comment = 2 then + begin + if c = Ord('>') then + state := FindLeft + else + comment := 0; + end + else begin + if c = Ord('-') then + Inc(comment) + else + comment := 0; + end; + end; + end; + + len := curpos; + SetLength(Name, len); + + if state = FindRight then + RaiseException; + if (Name <> '') and (Name[len] = ' ') then + SetLength(Name, len - 1); + + i := Pos(' ', Name); + if i <> 0 then + begin + Text := Copy(Name, i + 1, len - i); + Delete(Name, i, len - i + 1); + end; +end; + +procedure TfrxXMLReader.ReadRootItem(Item: TfrxXMLItem; ReadChildren: Boolean = True); +var + LastName: String; + + function DoRead(RootItem: TfrxXMLItem): Boolean; + var + n: Integer; + ChildItem: TfrxXMLItem; + Done: Boolean; + CurPos: Int64; + begin + Result := False; + CurPos := Position; + ReadItem(RootItem.FName, RootItem.FText); + LastName := RootItem.FName; + + if (RootItem.Name = '') or (RootItem.Name[1] = '/') then + begin + Result := True; + Exit; + end; + + n := Length(RootItem.Name); + if RootItem.Name[n] = '/' then + begin + SetLength(RootItem.FName, n - 1); + Exit; + end; + + n := Length(RootItem.Text); + if (n > 0) and (RootItem.Text[n] = '/') then + begin + SetLength(RootItem.FText, n - 1); + Exit; + end; + + repeat + ChildItem := TfrxXMLItem.Create; + Done := DoRead(ChildItem); + if not Done then + RootItem.AddItem(ChildItem) else + ChildItem.Free; + until Done; + + if (LastName <> '') and (AnsiCompareText(LastName, '/' + RootItem.Name) <> 0) then + RaiseException; + + n := Pos(' ld="0"', LowerCase(RootItem.Text)); + if n <> 0 then + Delete(RootItem.FText, n, 7); + if not ReadChildren and (n <> 0) then + begin + RootItem.Clear; + RootItem.Offset := CurPos; + RootItem.FUnloadable := True; + RootItem.FLoaded := False; + end; + end; + +begin + DoRead(Item); +end; + + +{ TfrxXMLWriter } + +constructor TfrxXMLWriter.Create(Stream: TStream); +begin + FStream := Stream; +end; + +procedure TfrxXMLWriter.FlushBuffer; +begin + if FBuffer <> '' then + FStream.Write(FBuffer[1], Length(FBuffer)); + FBuffer := ''; +end; + +procedure TfrxXMLWriter.WriteLn(const s: String); +begin + if not FAutoIndent then + Insert(s, FBuffer, MaxInt) else + Insert(s + #13#10, FBuffer, MaxInt); + if Length(FBuffer) > 4096 then + FlushBuffer; +end; + +procedure TfrxXMLWriter.WriteHeader; +begin + WriteLn(''); +end; + +function Dup(n: Integer): String; +begin + SetLength(Result, n); + FillChar(Result[1], n, ' '); +end; + +procedure TfrxXMLWriter.WriteItem(Item: TfrxXMLItem; Level: Integer = 0); +var + s: String; +begin + if (Item.FText <> '') or Item.FUnloadable then + begin + s := Item.FText; + if (s = '') or (s[1] <> ' ') then + s := ' ' + s; + if Item.FUnloadable then + s := s + 'ld="0"'; + end + else + s := ''; + + if Item.Count = 0 then + begin + if Item.Value = '' then + s := s + '/>' + else + s := s + '>' + Item.Value + '' + end + else + s := s + '>'; + if not FAutoIndent then + s := '<' + Item.Name + s else + s := Dup(Level) + '<' + Item.Name + s; + WriteLn(s); +end; + +procedure TfrxXMLWriter.WriteRootItem(RootItem: TfrxXMLItem); + + procedure DoWrite(RootItem: TfrxXMLItem; Level: Integer = 0); + var + i: Integer; + rd: TfrxXMLReader; + NeedClear: Boolean; + begin + NeedClear := False; + if not FAutoIndent then + Level := 0; + + if (FTempStream <> nil) and RootItem.FUnloadable and not RootItem.FLoaded then + begin + rd := TfrxXMLReader.Create(FTempStream); + try + rd.Position := RootItem.Offset; + rd.ReadRootItem(RootItem); + NeedClear := True; + finally + rd.Free; + end; + end; + + WriteItem(RootItem, Level); + for i := 0 to RootItem.Count - 1 do + DoWrite(RootItem[i], Level + 2); + if RootItem.Count > 0 then + if not FAutoIndent then + WriteLn('') else + WriteLn(Dup(Level) + ''); + + if NeedClear then + RootItem.Clear; + end; + +begin + DoWrite(RootItem); + FlushBuffer; +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxXMLSerializer.pas b/official/4.2/LibD11/frxXMLSerializer.pas new file mode 100644 index 0000000..5383d59 --- /dev/null +++ b/official/4.2/LibD11/frxXMLSerializer.pas @@ -0,0 +1,806 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ XML serializer } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxXMLSerializer; + +interface + +{$I frx.inc} + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, + TypInfo, frxXML, frxClass +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfrxGetAncestorEvent = procedure(const ComponentName: String; + var Ancestor: TPersistent) of object; + +{ TfrxXMLSerializer is the XML analogue of the Delphi component streaming - + TReader and TWriter } + + TfrxXMLSerializer = class(TObject) + private + FErrors: TStringList; + FFixups: TList; + FOwner: TfrxComponent; + FReader: TReader; + FReaderStream: TMemoryStream; + FSerializeDefaultValues: Boolean; + FStream: TStream; + FOnGetAncestor: TfrxGetAncestorEvent; + procedure AddFixup(Obj: TPersistent; p: PPropInfo; Value: String); + procedure ClearFixups; + procedure FixupReferences; + public + constructor Create(Stream: TStream); + destructor Destroy; override; + function ObjToXML(Obj: TPersistent; const Add: String = ''; Ancestor: TPersistent = nil): String; + function ReadComponent(Root: TfrxComponent): TfrxComponent; + function ReadComponentStr(Root: TfrxComponent; s: String; DontFixup: Boolean = False): TfrxComponent; + function WriteComponentStr(c: TfrxComponent): String; + procedure ReadRootComponent(Root: TfrxComponent; XMLItem: TfrxXMLItem = nil); + procedure ReadPersistentStr(Root: TComponent; Obj: TPersistent; const s: String); + procedure WriteComponent(c: TfrxComponent); + procedure WriteRootComponent(Root: TfrxComponent; SaveChildren: Boolean = True; + XMLItem: TfrxXMLItem = nil); + procedure XMLToObj(const s: String; Obj: TPersistent); + property Errors: TStringList read FErrors; + property Owner: TfrxComponent read FOwner write FOwner; + property Stream: TStream read FStream; + property SerializeDefaultValues: Boolean read FSerializeDefaultValues + write FSerializeDefaultValues; + property OnGetAncestor: TfrxGetAncestorEvent read FOnGetAncestor write FOnGetAncestor; + end; + + +implementation + +uses frxUtils, frxRes, frxUnicodeUtils; + + +type + TfrxFixupItem = class(TObject) + public + Obj: TPersistent; + PropInfo: PPropInfo; + Value: String; + end; + + THackComponent = class(TComponent); + THackPersistent = class(TPersistent); + THackReader = class(TReader); + + +{ TfrxXMLSerializer } + +constructor TfrxXMLSerializer.Create(Stream: TStream); +begin + FErrors := TStringList.Create; + FErrors.Sorted := True; + FErrors.Duplicates := dupIgnore; + FFixups := TList.Create; + FStream := Stream; + FReaderStream := TMemoryStream.Create; + FReader := TReader.Create(FReaderStream, 4096); +end; + +destructor TfrxXMLSerializer.Destroy; +begin + FErrors.Free; + FReader.Free; + FReaderStream.Free; + ClearFixups; + FFixups.Free; + inherited; +end; + +procedure TfrxXMLSerializer.ClearFixups; +begin + while FFixups.Count > 0 do + begin + TfrxFixupItem(FFixups[0]).Free; + FFixups.Delete(0); + end; +end; + +procedure TfrxXMLSerializer.AddFixup(Obj: TPersistent; p: PPropInfo; + Value: String); +var + Item: TfrxFixupItem; +begin + Item := TfrxFixupItem.Create; + Item.Obj := Obj; + Item.PropInfo := p; + Item.Value := Value; + FFixups.Add(Item); +end; + +procedure TfrxXMLSerializer.FixupReferences; +var + i: Integer; + Item: TfrxFixupItem; + Ref: TObject; +begin + for i := 0 to FFixups.Count - 1 do + begin + Item := FFixups[i]; + Ref := nil; + if FOwner <> nil then + Ref := FOwner.FindObject(Item.Value); + if Ref = nil then + Ref := frxFindComponent(FOwner, Item.Value); + if Ref <> nil then + SetOrdProp(Item.Obj, Item.PropInfo, Integer(Ref)); + end; + + FReader.FixupReferences; + FReader.EndReferences; + ClearFixups; +end; + +procedure TfrxXMLSerializer.XMLToObj(const s: String; Obj: TPersistent); +var + i, j, start, len, code: Integer; + i1, start1, len1: Integer; + Name, Value: String; + Obj1: TPersistent; + p: PPropInfo; + ps, ps1: PChar; + + procedure DoNonPublishedProps; + begin + FReaderStream.Clear; + frxStringToStream(Value, FReaderStream); + FReaderStream.Position := 0; + FReader.Position := 0; + + try + while FReader.Position < FReaderStream.Size do + THackReader(FReader).ReadProperty(Obj1); + except + end; + end; + +begin + { speed optimized code. affects the speed of loading prepared page in the preview } + len := Length(s); + i := 1; + ps := PChar(s) - 1; + while i < len do + begin + j := i; + len1 := len; + ps1 := ps; + while (j < len1) and (ps1[j] = ' ') do + Inc(j); + start := j; + while (j < len1) and (ps1[j] <> '=') do + Inc(j); + i := j; + if i < len then + begin + j := i - 1; + while (j > 0) and (ps1[j] = ' ') do + Dec(j); + Name := Copy(s, start, j - start + 1); + if Name = '' then break; + j := i; + len1 := len; + while (j < len1) and (ps1[j] <> '"') do + Inc(j); + start := j + 1; + Inc(j); + while (j < len1) and (ps1[j] <> '"') do + Inc(j); + i := j; + Value := Copy(s, start, i - start); + Inc(i); + + Obj1 := Obj; + + { check multiple properties } + len1 := Length(Name); + start1 := 1; + i1 := 1; + while (i1 < len1) and (Name[i1] <> '.') do + Inc(i1); + if i1 < len1 then + begin + while i1 < len1 do + begin + p := GetPropInfo(Obj1.ClassInfo, Copy(Name, start1, i1 - start1)); + if p = nil then + break; + Obj1 := TPersistent(GetOrdProp(Obj1, p)); + start1 := i1 + 1; + Inc(i1); + while (i1 < len1) and (Name[i1] <> '.') do + Inc(i1); + end; + Name := Copy(Name, start1, MaxInt); + end; + + try + if Length(Name) = 1 then + begin + { special properties } + case Name[1] of + 'x': + begin + TfrxCustomMemoView(Obj1).Text := frxXMLToStr(Value); + continue; + end; + 'u': + begin + TfrxCustomMemoView(Obj1).Text := Utf8Decode(frxXMLToStr(Value)); + continue; + end; + 'l': + begin + TfrxComponent(Obj1).Left := frxStrToFloat(Value); + continue; + end; + 't': + begin + TfrxComponent(Obj1).Top := frxStrToFloat(Value); + continue; + end; + 'w': + begin + TfrxComponent(Obj1).Width := frxStrToFloat(Value); + continue; + end; + 'h': + begin + TfrxComponent(Obj1).Height := frxStrToFloat(Value); + continue; + end; + end; + end + else + begin + if Name = 'Text' then + begin + if Obj1 is TStrings then + begin + TStrings(Obj1).Text := frxXMLToStr(Value); + continue; + end + else if Obj1 is TWideStrings then + begin + TWideStrings(Obj1).Text := frxXMLToStr(Value); + continue; + end + else if Obj1 is TfrxCustomMemoView then + begin + TfrxCustomMemoView(Obj1).Text := Utf8Decode(frxXMLToStr(Value)); + continue; + end + end + else if Name = 'PropData' then + begin + DoNonPublishedProps; + continue; + end + else if (Obj1 is TfrxReport) and (Name = 'Name') then + continue; + end; + + p := GetPropInfo(Obj1.ClassInfo, Name); + if (p <> nil) and (p.SetProc <> nil) then + case p.PropType^.Kind of + tkInteger, tkSet, tkChar, tkWChar: + SetOrdProp(Obj1, p, StrToInt(Value)); + + tkEnumeration: + begin + Val(Value, j, code); + if code = 0 then + SetOrdProp(Obj1, p, j) else + SetOrdProp(Obj1, p, GetEnumValue(p.PropType^, Value)); + end; + + tkFloat: + SetFloatProp(Obj1, p, frxStrToFloat(Value)); + + tkString, tkLString, tkWString: + SetStrProp(Obj1, p, frxXMLToStr(Value)); + + tkClass: + AddFixup(Obj1, p, Value); + + tkVariant: + SetVariantProp(Obj1, p, frxXMLToStr(Value)); + end; + except + on E: Exception do + FErrors.Add(E.Message); + end; + end; + end; +end; + +function TfrxXMLSerializer.ObjToXML(Obj: TPersistent; const Add: String = ''; + Ancestor: TPersistent = nil): String; +var + TypeInfo: PTypeInfo; + PropCount: Integer; + PropList: PPropList; + i: Integer; + s: String; + ws: WideString; + Flag: Boolean; + + procedure DoOrdProp; + var + Value: Integer; + + function IsDefault: Boolean; + begin + if Ancestor <> nil then + Result := Value = GetOrdProp(Ancestor, PropList[i]) + else + Result := Value = PropList[i].Default; + end; + + begin + Value := GetOrdProp(Obj, PropList[i]); + if not IsDefault or FSerializeDefaultValues then + if PropList[i].PropType^.Kind = tkEnumeration then + s := GetEnumName(PropList[i].PropType^, Value) + else + s := IntToStr(Value); + end; + + procedure DoFloatProp; + var + Value: Extended; + + function IsDefault: Boolean; + begin + if Ancestor <> nil then + Result := Abs(Value - GetFloatProp(Ancestor, PropList[i])) < 1e-6 + else + Result := False; + end; + + begin + Value := GetFloatProp(Obj, PropList[i]); +// commented out due to bug with tfrxmemoview.linespacing=0 + if not IsDefault or FSerializeDefaultValues then + s := FloatToStr(Value); + end; + + procedure DoStrProp; + var + Value: String; + + function IsDefault: Boolean; + begin + if Ancestor <> nil then + Result := Value = GetStrProp(Ancestor, PropList[i]) + else + Result := Value = ''; + end; + + begin + Value := GetStrProp(Obj, PropList[i]); + if not IsDefault or FSerializeDefaultValues then + s := frxStrToXML(Value); + end; + + procedure DoVariantProp; + var + Value: Variant; + + function IsDefault: Boolean; + begin + if Ancestor <> nil then + Result := Value = GetVariantProp(Ancestor, PropList[i]) + else + Result := False; + end; + + begin + Value := GetVariantProp(Obj, PropList[i]); + if not IsDefault or FSerializeDefaultValues then + s := frxStrToXML(VarToStr(Value)); + end; + + procedure DoClassProp; + var + FClass: TClass; + FComp, FAncComp: TComponent; + FObj, FAncObj: TPersistent; + begin + FClass := GetTypeData(PropList[i].PropType^).ClassType; + if FClass.InheritsFrom(TComponent) then + begin + FComp := TComponent(GetOrdProp(Obj, PropList[i])); + if Ancestor <> nil then + FAncComp := TComponent(GetOrdProp(Ancestor, PropList[i])) + else + FAncComp := nil; + + if Ancestor <> nil then + begin + if (FComp = nil) and (FAncComp = nil) then Exit; + if (FComp <> nil) and (FAncComp <> nil) then + if CompareText(FComp.Name, FAncComp.Name) = 0 then Exit; + if (FComp = nil) and (FAncComp <> nil) then + begin + s := 'nil'; + Exit; + end; + end; + + if FComp <> nil then + s := frxGetFullName(FOwner, FComp); + end + else if FClass.InheritsFrom(TPersistent) then + begin + FObj := TPersistent(GetOrdProp(Obj, PropList[i])); + if Ancestor <> nil then + FAncObj := TPersistent(GetOrdProp(Ancestor, PropList[i])) + else + FAncObj := nil; + + if FObj is TStrings then + begin + if Ancestor <> nil then + if TStrings(FObj).Text = TStrings(FAncObj).Text then + Exit; + + s := TStrings(FObj).Text; + if (Length(s) >= 2) and + (s[Length(s) - 1] = #13) and (s[Length(s)] = #10) then + Delete(s, Length(s) - 1, 2); + s := ' ' + Add + PropList[i].Name + '.Text="' + + frxStrToXML(s) + '"'; + + end + else if FObj is TWideStrings then + begin + // skip, handle separately + end + else + s := ObjToXML(FObj, Add + PropList[i].Name + '.', FAncObj); + Flag := True; + end; + end; + + procedure DoNonPublishedProps; + var + wr: TWriter; + ms, AncMs: TMemoryStream; + begin + ms := TMemoryStream.Create; + try + wr := TWriter.Create(ms, 4096); + wr.Root := FOwner; + + try + THackPersistent(Obj).DefineProperties(wr); + finally + wr.Free; + end; + + if ms.Size > 0 then + begin + if Ancestor <> nil then + begin + AncMs := TMemoryStream.Create; + try + wr := TWriter.Create(AncMs, 4096); + wr.Root := FOwner; + + try + THackPersistent(Ancestor).DefineProperties(wr); + finally + wr.Free; + end; + if frxStreamCRC32(ms) = frxStreamCRC32(AncMs) then + Exit; + finally + AncMs.Free; + end; + end; + + s := frxStreamToString(ms); + Result := Result + ' ' + Add + 'PropData="' + s + '"'; + end; + finally + ms.Free; + end; + end; + +begin + Result := ''; + + TypeInfo := Obj.ClassInfo; + PropCount := GetTypeData(TypeInfo).PropCount; + GetMem(PropList, PropCount * SizeOf(PPropInfo)); + GetPropInfos(TypeInfo, PropList); + + try + if Obj is TfrxComponent then + begin + TfrxComponent(Obj).IsWriting := True; + if (Ancestor = nil) and Assigned(FOnGetAncestor) then + FOnGetAncestor(TfrxComponent(Obj).Name, Ancestor); + end; + + for i := 0 to PropCount - 1 do + begin + s := ''; + Flag := False; + + if IsStoredProp(Obj, PropList[i]) then + case PropList[i].PropType^.Kind of + tkInteger, tkSet, tkChar, tkWChar, tkEnumeration: + DoOrdProp; + + tkFloat: + DoFloatProp; + + tkString, tkLString, tkWString: + DoStrProp; + + tkClass: + DoClassProp; + + tkVariant: + DoVariantProp; + end; + + if s <> '' then + if Flag then + Result := Result + s + else + Result := Result + ' ' + Add + PropList[i].Name + '="' + s + '"'; + end; + + if Obj is TfrxCustomMemoView then + if (Ancestor = nil) or + (TfrxCustomMemoView(Obj).Text <> TfrxCustomMemoView(Ancestor).Text) then + begin + ws := TfrxCustomMemoView(Obj).Text; + if (Length(ws) >= 2) and + (ws[Length(ws) - 1] = #13) and (ws[Length(ws)] = #10) then + Delete(ws, Length(ws) - 1, 2); + Result := Result + ' Text="' + frxStrToXML(Utf8Encode(ws)) + '"'; + end; + + DoNonPublishedProps; + + finally + if Obj is TfrxComponent then + TfrxComponent(Obj).IsWriting := False; + FreeMem(PropList, PropCount * SizeOf(PPropInfo)); + end; +end; + +procedure TfrxXMLSerializer.ReadRootComponent(Root: TfrxComponent; + XMLItem: TfrxXMLItem = nil); +var + XMLDoc: TfrxXMLDocument; + CompList: TList; + + procedure DoRead(Item: TfrxXMLItem; Owner: TfrxComponent); + var + i: Integer; + c: TfrxComponent; + IsAncestor: Boolean; + begin + IsAncestor := CompareText(Item.Name, 'inherited') = 0; + if not IsAncestor then + try + FindClass(Item.Name); + except + FErrors.Add(frxResources.Get('xrCantFindClass') + ' ' + Item.Name); + Exit; + end; + + if Owner <> nil then + begin + c := FOwner.FindComponent(Item.Prop['Name']) as TfrxComponent; + if not IsAncestor and (c = nil) then + begin + c := TfrxComponent(FindClass(Item.Name).NewInstance); + c.Create(Owner); + end; + end + else + c := Root; + + if c <> nil then + begin + c.IsLoading := True; + XMLToObj(Item.Text, c); + CompList.Add(c); + + for i := 0 to Item.Count - 1 do + DoRead(Item[i], c); + end; + end; + + procedure DoLoaded; + var + i: Integer; + c: TfrxComponent; + begin + for i := 0 to CompList.Count - 1 do + begin + c := CompList[i]; + c.IsLoading := False; + if not (c is TfrxReport) then + THackComponent(c).Loaded; + end; + end; + +begin + if Owner = nil then + Owner := Root; + XMLDoc := nil; + CompList := TList.Create; + + if XMLItem = nil then + begin + XMLDoc := TfrxXMLDocument.Create; + XMLItem := XMLDoc.Root; + XMLDoc.LoadFromStream(FStream); + end; + + FReader.Root := FOwner; + FReader.BeginReferences; + try + DoRead(XMLItem, nil); + FixupReferences; + DoLoaded; + finally + if XMLDoc <> nil then + XMLDoc.Free; + CompList.Free; + end; +end; + +procedure TfrxXMLSerializer.WriteRootComponent(Root: TfrxComponent; + SaveChildren: Boolean = True; XMLItem: TfrxXMLItem = nil); +var + XMLDoc: TfrxXMLDocument; + + procedure DoWrite(Item: TfrxXMLItem; ARoot: TfrxComponent); + var + i: Integer; + begin + if ARoot.IsAncestor then + Item.Name := 'inherited' + else + Item.Name := ARoot.ClassName; + if ARoot = Root then + Item.Text := ObjToXML(ARoot) + else + Item.Text := 'Name="' + ARoot.Name + '"' + ObjToXML(ARoot); + + if SaveChildren then + for i := 0 to ARoot.Objects.Count - 1 do + DoWrite(Item.Add, ARoot.Objects[i]); + end; + +begin + if Owner = nil then + Owner := Root; + XMLDoc := nil; + + if XMLItem = nil then + begin + XMLDoc := TfrxXMLDocument.Create; + XMLItem := XMLDoc.Root; + XMLDoc.AutoIndent := True; + end; + + try + DoWrite(XMLItem, Root); + if XMLDoc <> nil then + XMLDoc.SaveToStream(FStream); + finally + if XMLDoc <> nil then + XMLDoc.Free; + end; +end; + +function TfrxXMLSerializer.ReadComponent(Root: TfrxComponent): TfrxComponent; +var + rd: TfrxXMLReader; + RootItem: TfrxXMLItem; +begin + rd := TfrxXMLReader.Create(FStream); + RootItem := TfrxXMLItem.Create; + + try + rd.ReadRootItem(RootItem, False); + Result := ReadComponentStr(Root, RootItem.Name + ' ' + RootItem.Text); + finally + rd.Free; + RootItem.Free; + end; +end; + +procedure TfrxXMLSerializer.WriteComponent(c: TfrxComponent); +var + s: String; +begin + s := '<' + WriteComponentStr(c) + '/>'; + FStream.Write(s[1], Length(s)); +end; + +function TfrxXMLSerializer.ReadComponentStr(Root: TfrxComponent; + s: String; DontFixup: Boolean = False): TfrxComponent; +var + n: Integer; + s1: String; +begin + Owner := Root; + if Trim(s) = '' then + Result := nil + else + begin + n := Pos(' ', s); + s1 := Copy(s, n + 1, MaxInt); + Delete(s, n, MaxInt); + + Result := TfrxComponent(FindClass(s).NewInstance); + Result.Create(Root); + + FReader.Root := Root; + FReader.BeginReferences; + try + Result.IsLoading := True; + XMLToObj(s1, Result); + finally + if DontFixup then + begin + FReader.EndReferences; + ClearFixups; + end + else + FixupReferences; + Result.IsLoading := False; + if not (Result is TfrxReport) then + THackComponent(Result).Loaded; + end; + end; +end; + +function TfrxXMLSerializer.WriteComponentStr(c: TfrxComponent): String; +begin + Result := c.ClassName + ObjToXML(c); +end; + +procedure TfrxXMLSerializer.ReadPersistentStr(Root: TComponent; + Obj: TPersistent; const s: String); +begin + FReader.Root := Root; + FReader.BeginReferences; + XMLToObj(s, Obj); + FixupReferences; +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxZLib.pas b/official/4.2/LibD11/frxZLib.pas new file mode 100644 index 0000000..8b56abe --- /dev/null +++ b/official/4.2/LibD11/frxZLib.pas @@ -0,0 +1,629 @@ +{***************************************************************************** +* ZLibEx.pas (zlib 1.2.1) * +* * +* copyright (c) 2002-2003 Roberto Della Pasqua (www.dellapasqua.com) * +* copyright (c) 2000-2002 base2 technologies (www.base2ti.com) * +* copyright (c) 1997 Borland International (www.borland.com) * +* * +* revision history * +* 2003.12.18 updated with latest zlib 1.2.1 (see www.zlib.org) * +* obj's compiled with fastest speed optimizations (bcc 5.6.4) * +* (hint:see basm newsgroup about a Move RTL fast replacement) * +* Thanks to Cosmin Truta for the pascal zlib reference * +* * +* 2002.11.02 ZSendToBrowser: deflate algorithm for HTTP1.1 compression * +* 2002.10.24 ZFastCompressString and ZFastDecompressString:300% faster * +* 2002.10.15 recompiled zlib 1.1.4 c sources with speed optimizations * +* (and targeting 686+ cpu) and changes to accomodate Borland * +* standards (C++ v5.6 compiler) * +* 2002.10.15 optimized move mem for not aligned structures (strings,etc)* +* 2002.10.15 little changes to avoid system unique string calls * +* * +* 2002.03.15 updated to zlib version 1.1.4 * +* 2001.11.27 enhanced TZDecompressionStream.Read to adjust source * +* stream position upon end of compression data * +* fixed endless loop in TZDecompressionStream.Read when * +* destination count was greater than uncompressed data * +* 2001.10.26 renamed unit to integrate "nicely" with delphi 6 * +* 2000.11.24 added soFromEnd condition to TZDecompressionStream.Seek * +* added ZCompressStream and ZDecompressStream * +* 2000.06.13 optimized, fixed, rewrote, and enhanced the zlib.pas unit * +* included on the delphi cd (zlib version 1.1.3) * +* * +* acknowledgements * +* erik turner Z*Stream routines * +* david bennion finding the nastly little endless loop quirk with the * +* TZDecompressionStream.Read method * +* burak kalayci informing me about the zlib 1.1.4 update * +*****************************************************************************} + +unit frxZLib; + +interface + +{$I frx.inc} + +uses + Windows, + Sysutils, + Classes; + +const + ZLIB_VERSION = '1.2.1'; + +type + TZAlloc = function(opaque: Pointer; items, size: Integer): Pointer; + TZFree = procedure(opaque, block: Pointer); + TZCompressionLevel = (zcNone, zcFastest, zcDefault, zcMax); + + {** TZStreamRec ***********************************************************} + + TZStreamRec = packed record + next_in: PChar; // next input byte + avail_in: Longint; // number of bytes available at next_in + total_in: Longint; // total nb of input bytes read so far + next_out: PChar; // next output byte should be put here + avail_out: Longint; // remaining free space at next_out + total_out: Longint; // total nb of bytes output so far + msg: PChar; // last error message, NULL if no error + state: Pointer; // not visible by applications + zalloc: TZAlloc; // used to allocate the internal state + zfree: TZFree; // used to free the internal state + opaque: Pointer; // private data object passed to zalloc and zfree + data_type: Integer; // best guess about the data type: ascii or binary + adler: Longint; // adler32 value of the uncompressed data + reserved: Longint; // reserved for future use + end; + + {** TCustomZStream ********************************************************} + + TCustomZStream = class(TStream) + private + FStream: TStream; + FStreamPos: Integer; + FOnProgress: TNotifyEvent; + FZStream: TZStreamRec; + FBuffer: array[Word] of Char; + protected + constructor Create(stream: TStream); + procedure DoProgress; dynamic; + property OnProgress: TNotifyEvent read FOnProgress write FOnProgress; + end; + + {** TZCompressionStream ***************************************************} + + TZCompressionStream = class(TCustomZStream) + private + function GetCompressionRate: Single; + public + constructor Create(dest: TStream; compressionLevel: TZCompressionLevel = zcDefault); + destructor Destroy; override; + function Read(var buffer; count: Longint): Longint; override; + function Write(const buffer; count: Longint): Longint; override; + function Seek(offset: Longint; origin: Word): Longint; override; + property CompressionRate: Single read GetCompressionRate; + property OnProgress; + end; + + {** TZDecompressionStream *************************************************} + + TZDecompressionStream = class(TCustomZStream) + public + constructor Create(source: TStream); + destructor Destroy; override; + function Read(var buffer; count: Longint): Longint; override; + function Write(const buffer; count: Longint): Longint; override; + function Seek(offset: Longint; origin: Word): Longint; override; + property OnProgress; + end; + +{** zlib public routines ****************************************************} + +{***************************************************************************** +* ZCompress * +* * +* pre-conditions * +* inBuffer = pointer to uncompressed data * +* inSize = size of inBuffer (bytes) * +* outBuffer = pointer (unallocated) * +* level = compression level * +* * +* post-conditions * +* outBuffer = pointer to compressed data (allocated) * +* outSize = size of outBuffer (bytes) * +*****************************************************************************} + +procedure ZCompress(const inBuffer: Pointer; inSize: Integer; + out outBuffer: Pointer; out outSize: Integer; + level: TZCompressionLevel = zcDefault); + +{***************************************************************************** +* ZDecompress * +* * +* pre-conditions * +* inBuffer = pointer to compressed data * +* inSize = size of inBuffer (bytes) * +* outBuffer = pointer (unallocated) * +* outEstimate = estimated size of uncompressed data (bytes) * +* * +* post-conditions * +* outBuffer = pointer to decompressed data (allocated) * +* outSize = size of outBuffer (bytes) * +*****************************************************************************} + +procedure ZDecompress(const inBuffer: Pointer; inSize: Integer; + out outBuffer: Pointer; out outSize: Integer; outEstimate: Integer = 0); + +{** utility routines ********************************************************} + +function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; +function crc32(crc: LongInt; const buf: PChar; len: Integer): LongInt; +function compressBound(sourceLen: LongInt): LongInt; + +function inflateInit_(var strm: TZStreamRec; version: PChar; + recsize: Integer): Integer; forward; +function inflate(var strm: TZStreamRec; flush: Integer): Integer; forward; +function inflateEnd(var strm: TZStreamRec): Integer; forward; +function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; + recsize: Integer): Integer; forward; +function deflate(var strm: TZStreamRec; flush: Integer): Integer; forward; +function deflateEnd(var strm: TZStreamRec): Integer; forward; +{****************************************************************************} + + +type + EZLibError = class(Exception); + EZCompressionError = class(EZLibError); + EZDecompressionError = class(EZLibError); + +implementation + +{** link zlib 1.2.1 **************************************************************} +{** bcc32 flags: -c -6 -O2 -Ve -X- -pr -a8 -b -d -k- -vi -tWM -r -RT- -DFASTEST **} + +{$L adler32.zobj} +{$L compress.zobj} +{$L crc32.zobj} +{$L deflate.zobj} +{$L infback.zobj} +{$L inffast.zobj} +{$L inflate.zobj} +{$L inftrees.zobj} +{$L trees.zobj} + +{***************************************************************************** +* note: do not reorder the above -- doing so will result in external * +* functions being undefined * +*****************************************************************************} + +const + {** flush constants *******************************************************} + + Z_NO_FLUSH = 0; + Z_FINISH = 4; + + {** return codes **********************************************************} + + Z_OK = 0; + Z_STREAM_END = 1; + Z_NEED_DICT = 2; + Z_ERRNO = (-1); + Z_STREAM_ERROR = (-2); + Z_DATA_ERROR = (-3); + Z_MEM_ERROR = (-4); + Z_BUF_ERROR = (-5); + Z_VERSION_ERROR = (-6); + + {** compression levels ****************************************************} + + Z_NO_COMPRESSION = 0; + Z_BEST_SPEED = 1; + Z_BEST_COMPRESSION = 9; + Z_DEFAULT_COMPRESSION = (-1); + + {** compression methods ***************************************************} + + Z_DEFLATED = 8; + + {** return code messages **************************************************} + + _z_errmsg: array[0..9] of PChar = ( + 'need dictionary', // Z_NEED_DICT (2) + 'stream end', // Z_STREAM_END (1) + '', // Z_OK (0) + 'file error', // Z_ERRNO (-1) + 'stream error', // Z_STREAM_ERROR (-2) + 'data error', // Z_DATA_ERROR (-3) + 'insufficient memory', // Z_MEM_ERROR (-4) + 'buffer error', // Z_BUF_ERROR (-5) + 'incompatible version', // Z_VERSION_ERROR (-6) + '' + ); + + ZLevels: array[TZCompressionLevel] of Shortint = ( + Z_NO_COMPRESSION, + Z_BEST_SPEED, + Z_DEFAULT_COMPRESSION, + Z_BEST_COMPRESSION + ); + + SZInvalid = 'Invalid ZStream operation!'; + +{** deflate routines ********************************************************} + +function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; + recsize: Integer): Integer; external; + +function deflate(var strm: TZStreamRec; flush: Integer): Integer; + external; + +function deflateEnd(var strm: TZStreamRec): Integer; external; + +{** inflate routines ********************************************************} + +function inflateInit_(var strm: TZStreamRec; version: PChar; + recsize: Integer): Integer; external; + +function inflate(var strm: TZStreamRec; flush: Integer): Integer; + external; + +function inflateEnd(var strm: TZStreamRec): Integer; external; + +function inflateReset(var strm: TZStreamRec): Integer; external; + +{** utility routines *******************************************************} + +function adler32; external; +function crc32; external; +function compressBound; external; + +{** zlib function implementations *******************************************} + +function zcalloc(opaque: Pointer; items, size: Integer): Pointer; +begin + GetMem(result, items * size); +end; + +procedure zcfree(opaque, block: Pointer); +begin + FreeMem(block); +end; + +{** c function implementations **********************************************} + +procedure _memset(p: Pointer; b: Byte; count: Integer); cdecl; +begin + FillChar(p^, count, b); +end; + +procedure _memcpy(dest, source: Pointer; count: Integer); cdecl; +begin + Move(source^, dest^, count); +end; + +{** custom zlib routines ****************************************************} + +function DeflateInit(var stream: TZStreamRec; level: Integer): Integer; +begin + result := DeflateInit_(stream, level, ZLIB_VERSION, SizeOf(TZStreamRec)); +end; + +function InflateInit(var stream: TZStreamRec): Integer; +begin + result := InflateInit_(stream, ZLIB_VERSION, SizeOf(TZStreamRec)); +end; + +{****************************************************************************} + +function ZCompressCheck(code: Integer): Integer; +begin + result := code; + + if code < 0 then + begin + raise EZCompressionError.Create(_z_errmsg[2 - code]); + end; +end; + +function ZDecompressCheck(code: Integer): Integer; +begin + Result := code; + + if code < 0 then + begin + raise EZDecompressionError.Create(_z_errmsg[2 - code]); + end; +end; + +procedure ZCompress(const inBuffer: Pointer; inSize: Integer; + out outBuffer: Pointer; out outSize: Integer; + level: TZCompressionLevel); +const + delta = 256; +var + zstream: TZStreamRec; +begin + FillChar(zstream, SizeOf(TZStreamRec), 0); + + outSize := ((inSize + (inSize div 10) + 12) + 255) and not 255; + GetMem(outBuffer, outSize); + + try + zstream.next_in := inBuffer; + zstream.avail_in := inSize; + zstream.next_out := outBuffer; + zstream.avail_out := outSize; + + ZCompressCheck(DeflateInit(zstream, ZLevels[level])); + + try + while ZCompressCheck(deflate(zstream, Z_FINISH)) <> Z_STREAM_END do + begin + Inc(outSize, delta); + ReallocMem(outBuffer, outSize); + + zstream.next_out := PChar(Integer(outBuffer) + zstream.total_out); + zstream.avail_out := delta; + end; + finally + ZCompressCheck(deflateEnd(zstream)); + end; + + ReallocMem(outBuffer, zstream.total_out); + outSize := zstream.total_out; + except + FreeMem(outBuffer); + raise; + end; +end; + +procedure ZDecompress(const inBuffer: Pointer; inSize: Integer; + out outBuffer: Pointer; out outSize: Integer; outEstimate: Integer); +var + zstream: TZStreamRec; + delta: Integer; +begin + FillChar(zstream, SizeOf(TZStreamRec), 0); + + delta := (inSize + 255) and not 255; + + if outEstimate = 0 then outSize := delta + else outSize := outEstimate; + + GetMem(outBuffer, outSize); + + try + zstream.next_in := inBuffer; + zstream.avail_in := inSize; + zstream.next_out := outBuffer; + zstream.avail_out := outSize; + + ZDecompressCheck(InflateInit(zstream)); + + try + while ZDecompressCheck(inflate(zstream, Z_NO_FLUSH)) <> Z_STREAM_END do + begin + Inc(outSize, delta); + ReallocMem(outBuffer, outSize); + + zstream.next_out := PChar(Integer(outBuffer) + zstream.total_out); + zstream.avail_out := delta; + end; + finally + ZDecompressCheck(inflateEnd(zstream)); + end; + + ReallocMem(outBuffer, zstream.total_out); + outSize := zstream.total_out; + except + FreeMem(outBuffer); + raise; + end; +end; + +{** TCustomZStream **********************************************************} + +constructor TCustomZStream.Create(stream: TStream); +begin + inherited Create; + FStream := stream; + FStreamPos := stream.Position; +end; + +procedure TCustomZStream.DoProgress; +begin + if Assigned(FOnProgress) then FOnProgress(Self); +end; + +{** TZCompressionStream *****************************************************} + +constructor TZCompressionStream.Create(dest: TStream; + compressionLevel: TZCompressionLevel); +begin + inherited Create(dest); + + FZStream.next_out := FBuffer; + FZStream.avail_out := SizeOf(FBuffer); + + ZCompressCheck(DeflateInit(FZStream, ZLevels[compressionLevel])); +end; + +destructor TZCompressionStream.Destroy; +begin + FZStream.next_in := nil; + FZStream.avail_in := 0; + + try + if FStream.Position <> FStreamPos then FStream.Position := FStreamPos; + + while ZCompressCheck(deflate(FZStream, Z_FINISH)) <> Z_STREAM_END do + begin + FStream.WriteBuffer(FBuffer, SizeOf(FBuffer) - FZStream.avail_out); + + FZStream.next_out := FBuffer; + FZStream.avail_out := SizeOf(FBuffer); + end; + + if FZStream.avail_out < SizeOf(FBuffer) then + begin + FStream.WriteBuffer(FBuffer, SizeOf(FBuffer) - FZStream.avail_out); + end; + finally + deflateEnd(FZStream); + end; + + inherited Destroy; +end; + +function TZCompressionStream.Read(var buffer; count: Longint): Longint; +begin + raise EZCompressionError.Create(SZInvalid); +end; + +function TZCompressionStream.Write(const buffer; count: Longint): Longint; +begin + FZStream.next_in := @buffer; + FZStream.avail_in := count; + + if FStream.Position <> FStreamPos then FStream.Position := FStreamPos; + + while FZStream.avail_in > 0 do + begin + ZCompressCheck(deflate(FZStream, Z_NO_FLUSH)); + + if FZStream.avail_out = 0 then + begin + FStream.WriteBuffer(FBuffer, SizeOf(FBuffer)); + + FZStream.next_out := FBuffer; + FZStream.avail_out := SizeOf(FBuffer); + + FStreamPos := FStream.Position; + + DoProgress; + end; + end; + + result := Count; +end; + +function TZCompressionStream.Seek(offset: Longint; origin: Word): Longint; +begin + if (offset = 0) and (origin = soFromCurrent) then + begin + result := FZStream.total_in; + end + else raise EZCompressionError.Create(SZInvalid); +end; + +function TZCompressionStream.GetCompressionRate: Single; +begin + if FZStream.total_in = 0 then result := 0 + else result := (1.0 - (FZStream.total_out / FZStream.total_in)) * 100.0; +end; + +{** TZDecompressionStream ***************************************************} + +constructor TZDecompressionStream.Create(source: TStream); +begin + inherited Create(source); + FZStream.next_in := FBuffer; + FZStream.avail_in := 0; + ZDecompressCheck(InflateInit(FZStream)); +end; + +destructor TZDecompressionStream.Destroy; +begin + inflateEnd(FZStream); + inherited Destroy; +end; + +function TZDecompressionStream.Read(var buffer; count: Longint): Longint; +var + zresult: Integer; +begin + FZStream.next_out := @buffer; + FZStream.avail_out := count; + + if FStream.Position <> FStreamPos then FStream.Position := FStreamPos; + + zresult := Z_OK; + + while (FZStream.avail_out > 0) and (zresult <> Z_STREAM_END) do + begin + if FZStream.avail_in = 0 then + begin + FZStream.avail_in := FStream.Read(FBuffer, SizeOf(FBuffer)); + + if FZStream.avail_in = 0 then + begin + result := count - FZStream.avail_out; + + Exit; + end; + + FZStream.next_in := FBuffer; + FStreamPos := FStream.Position; + + DoProgress; + end; + + zresult := ZDecompressCheck(inflate(FZStream, Z_NO_FLUSH)); + end; + + if (zresult = Z_STREAM_END) and (FZStream.avail_in > 0) then + begin + FStream.Position := FStream.Position - FZStream.avail_in; + FStreamPos := FStream.Position; + + FZStream.avail_in := 0; + end; + + result := count - FZStream.avail_out; +end; + +function TZDecompressionStream.Write(const Buffer; Count: Longint): Longint; +begin + raise EZDecompressionError.Create(SZInvalid); +end; + +function TZDecompressionStream.Seek(Offset: Longint; Origin: Word): Longint; +var + buf: array[0..8191] of Char; + i: Integer; +begin + if (offset = 0) and (origin = soFromBeginning) then + begin + ZDecompressCheck(inflateReset(FZStream)); + + FZStream.next_in := FBuffer; + FZStream.avail_in := 0; + + FStream.Position := 0; + FStreamPos := 0; + end + else if ((offset >= 0) and (origin = soFromCurrent)) or + (((offset - FZStream.total_out) > 0) and (origin = soFromBeginning)) then + begin + if origin = soFromBeginning then Dec(offset, FZStream.total_out); + + if offset > 0 then + begin + for i := 1 to offset div SizeOf(buf) do ReadBuffer(buf, SizeOf(buf)); + ReadBuffer(buf, offset mod SizeOf(buf)); + end; + end + else if (offset = 0) and (origin = soFromEnd) then + begin + while Read(buf, SizeOf(buf)) > 0 do ; + end + else raise EZDecompressionError.Create(SZInvalid); + + result := FZStream.total_out; +end; + +end. + + + +//862fd5d6aa1a637203d9b08a3c0bcfb0 \ No newline at end of file diff --git a/official/4.2/LibD11/frxZip.pas b/official/4.2/LibD11/frxZip.pas new file mode 100644 index 0000000..276051b --- /dev/null +++ b/official/4.2/LibD11/frxZip.pas @@ -0,0 +1,549 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ ZIP archiver support unit } +{ } +{ Copyright (c) 2006-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxZip; + +{$I frx.inc} + +interface + +uses Classes, Windows, frxZLib, frxGZip, frxUtils, frxFileUtils; + +type + DWORD = Longword; + TfrxZipLocalFileHeader = class; + TfrxZipCentralDirectory = class; + TfrxZipFileHeader = class; + + TfrxZipArchive = class(TObject) + private + FRootFolder: String; + FErrors: TStringList; + FFileList: TStringList; + FComment: String; + FProgress: TNotifyEvent; + function GetCount: Integer; + public + constructor Create; + destructor Destroy; override; + procedure Clear; + procedure AddFile(const FileName: String); + procedure AddDir(const DirName: String); + procedure SaveToStream(const Stream: TStream); + procedure SaveToFile(const Filename: String); + property RootFolder: String read FRootFolder write FRootFolder; + property Errors: TStringList read FErrors; + property Comment: String read FComment write FComment; + property FileCount: Integer read GetCount; + property OnProgress: TNotifyEvent read FProgress write FProgress; + end; + + TfrxZipLocalFileHeader = class(TObject) + private + FLocalFileHeaderSignature: DWORD; + FVersion: WORD; + FGeneralPurpose: WORD; + FCompressionMethod: WORD; + FCrc32: DWORD; + FLastModFileDate: WORD; + FLastModFileTime: WORD; + FCompressedSize: DWORD; + FUnCompressedSize: DWORD; + FExtraField: String; + FFileName: String; + FFileNameLength: WORD; + FExtraFieldLength: WORD; + procedure SetExtraField(const Value: String); + procedure SetFileName(const Value: String); + public + constructor Create; + procedure SaveToStream(const Stream: TStream); + property LocalFileHeaderSignature: DWORD read FLocalFileHeaderSignature; + property Version: WORD read FVersion write FVersion; + property GeneralPurpose: WORD read FGeneralPurpose write FGeneralPurpose; + property CompressionMethod: WORD read FCompressionMethod write FCompressionMethod; + property LastModFileTime: WORD read FLastModFileTime write FLastModFileTime; + property LastModFileDate: WORD read FLastModFileDate write FLastModFileDate; + property Crc32: DWORD read FCrc32 write FCrc32; + property CompressedSize: DWORD read FCompressedSize write FCompressedSize; + property UnCompressedSize: DWORD read FUnCompressedSize write FUnCompressedSize; + property FileNameLength: WORD read FFileNameLength write FFileNameLength; + property ExtraFieldLength: WORD read FExtraFieldLength write FExtraFieldLength; + property FileName: String read FFileName write SetFileName; + property ExtraField: String read FExtraField write SetExtraField; + end; + + TfrxZipCentralDirectory = class(TObject) + private + FEndOfChentralDirSignature: DWORD; + FNumberOfTheDisk: WORD; + FTotalOfEntriesCentralDirOnDisk: WORD; + FNumberOfTheDiskStartCentralDir: WORD; + FTotalOfEntriesCentralDir: WORD; + FSizeOfCentralDir: DWORD; + FOffsetStartingDiskDir: DWORD; + FComment: String; + FCommentLength: WORD; + procedure SetComment(const Value: String); + public + constructor Create; + procedure SaveToStream(const Stream: TStream); + property EndOfChentralDirSignature: DWORD read FEndOfChentralDirSignature; + property NumberOfTheDisk: WORD read FNumberOfTheDisk write FNumberOfTheDisk; + property NumberOfTheDiskStartCentralDir: WORD + read FNumberOfTheDiskStartCentralDir write FNumberOfTheDiskStartCentralDir; + property TotalOfEntriesCentralDirOnDisk: WORD + read FTotalOfEntriesCentralDirOnDisk write FTotalOfEntriesCentralDirOnDisk; + property TotalOfEntriesCentralDir: WORD + read FTotalOfEntriesCentralDir write FTotalOfEntriesCentralDir; + property SizeOfCentralDir: DWORD read FSizeOfCentralDir write FSizeOfCentralDir; + property OffsetStartingDiskDir: DWORD read FOffsetStartingDiskDir write FOffsetStartingDiskDir; + property CommentLength: WORD read FCommentLength write FCommentLength; + property Comment: String read FComment write SetComment; + end; + + TfrxZipFileHeader = class(TObject) + private + FCentralFileHeaderSignature: DWORD; + FRelativeOffsetLocalHeader: DWORD; + FUnCompressedSize: DWORD; + FCompressedSize: DWORD; + FCrc32: DWORD; + FExternalFileAttribute: DWORD; + FExtraField: String; + FFileComment: String; + FFileName: String; + FCompressionMethod: WORD; + FDiskNumberStart: WORD; + FLastModFileDate: WORD; + FLastModFileTime: WORD; + FVersionMadeBy: WORD; + FGeneralPurpose: WORD; + FFileNameLength: WORD; + FInternalFileAttribute: WORD; + FExtraFieldLength: WORD; + FVersionNeeded: WORD; + FFileCommentLength: WORD; + procedure SetExtraField(const Value: String); + procedure SetFileComment(const Value: String); + procedure SetFileName(const Value: String); + public + constructor Create; + procedure SaveToStream(const Stream: TStream); + property CentralFileHeaderSignature: DWORD read FCentralFileHeaderSignature; + property VersionMadeBy: WORD read FVersionMadeBy; + property VersionNeeded: WORD read FVersionNeeded; + property GeneralPurpose: WORD read FGeneralPurpose write FGeneralPurpose; + property CompressionMethod: WORD read FCompressionMethod write FCompressionMethod; + property LastModFileTime: WORD read FLastModFileTime write FLastModFileTime; + property LastModFileDate: WORD read FLastModFileDate write FLastModFileDate; + property Crc32: DWORD read FCrc32 write FCrc32; + property CompressedSize: DWORD read FCompressedSize write FCompressedSize; + property UnCompressedSize: DWORD read FUnCompressedSize write FUnCompressedSize; + property FileNameLength: WORD read FFileNameLength write FFileNameLength; + property ExtraFieldLength: WORD read FExtraFieldLength write FExtraFieldLength; + property FileCommentLength: WORD read FFileCommentLength write FFileCommentLength; + property DiskNumberStart: WORD read FDiskNumberStart write FDiskNumberStart; + property InternalFileAttribute: WORD read FInternalFileAttribute write FInternalFileAttribute; + property ExternalFileAttribute: DWORD read FExternalFileAttribute write FExternalFileAttribute; + property RelativeOffsetLocalHeader: DWORD read FRelativeOffsetLocalHeader write FRelativeOffsetLocalHeader; + property FileName: String read FFileName write SetFileName; + property ExtraField: String read FExtraField write SetExtraField; + property FileComment: String read FFileComment write SetFileComment; + end; + + TfrxZipLocalFile = class(TObject) + private + FLoacalFileHeader: TfrxZipLocalFileHeader; + FFileData: TMemoryStream; + FOffset: DWORD; + public + constructor Create; + destructor Destroy; override; + procedure SaveToStream(const Stream: TStream); + property LocalFileHeader: TfrxZipLocalFileHeader read FLoacalFileHeader; + property FileData: TMemoryStream read FFileData write FFileData; + property Offset: DWORD read FOffset write FOffset; + end; + +implementation + +uses SysUtils; + +const + ZIP_VERSIONMADEBY = 20; + ZIP_NONE = 0; + ZIP_DEFLATED = 8; + ZIP_MINSIZE = 128; + +{ TfrxZipLocalFile } + +constructor TfrxZipLocalFile.Create; +begin + FLoacalFileHeader := TfrxZipLocalFileHeader.Create; + FOffset := 0; +end; + +destructor TfrxZipLocalFile.Destroy; +begin + FLoacalFileHeader.Free; + inherited; +end; + +procedure TfrxZipLocalFile.SaveToStream(const Stream: TStream); +begin + FLoacalFileHeader.SaveToStream(Stream); + FFileData.Position := 0; + FFileData.SaveToStream(Stream); +end; + +{ TfrxZipLocalFileHeader } + +constructor TfrxZipLocalFileHeader.Create; +begin + inherited; + FLocalFileHeaderSignature := $04034b50; + FVersion := ZIP_VERSIONMADEBY; + FGeneralPurpose := 0; + FCompressionMethod := ZIP_NONE; + FCrc32 := 0; + FLastModFileDate := 0; + FLastModFileTime := 0; + FCompressedSize := 0; + FUnCompressedSize := 0; + FExtraField := ''; + FFileName := ''; + FFileNameLength := 0; + FExtraFieldLength := 0; +end; + +procedure TfrxZipLocalFileHeader.SaveToStream(const Stream: TStream); +begin + Stream.Write(FLocalFileHeaderSignature, 4); + Stream.Write(FVersion, 2); + Stream.Write(FGeneralPurpose, 2); + Stream.Write(FCompressionMethod, 2); + Stream.Write(FLastModFileTime, 2); + Stream.Write(FLastModFileDate, 2); + Stream.Write(FCrc32, 4); + Stream.Write(FCompressedSize, 4); + Stream.Write(FUnCompressedSize, 4); + Stream.Write(FFileNameLength, 2); + Stream.Write(FExtraFieldLength, 2); + if FFileNameLength > 0 then + Stream.Write(FFileName[1], FFileNameLength); + if FExtraFieldLength > 0 then + Stream.Write(FExtraField[1], FExtraFieldLength); +end; + +procedure TfrxZipLocalFileHeader.SetExtraField(const Value: String); +begin + FExtraField := Value; + FExtraFieldLength := Length(Value); +end; + +procedure TfrxZipLocalFileHeader.SetFileName(const Value: String); +begin + FFileName := StringReplace(Value, '\', '/', [rfReplaceAll]); + FFileNameLength := Length(Value); +end; + +{ TfrxZipCentralDirectory } + +constructor TfrxZipCentralDirectory.Create; +begin + inherited; + FEndOfChentralDirSignature := $06054b50; + FNumberOfTheDisk := 0; + FNumberOfTheDiskStartCentralDir := 0; + FTotalOfEntriesCentralDirOnDisk := 0; + FTotalOfEntriesCentralDir := 0; + FSizeOfCentralDir := 0; + FOffsetStartingDiskDir := 0; + FCommentLength := 0; + FComment := ''; +end; + +procedure TfrxZipCentralDirectory.SaveToStream(const Stream: TStream); +begin + Stream.Write(FEndOfChentralDirSignature, 4); + Stream.Write(FNumberOfTheDisk, 2); + Stream.Write(FNumberOfTheDiskStartCentralDir, 2); + Stream.Write(FTotalOfEntriesCentralDirOnDisk, 2); + Stream.Write(FTotalOfEntriesCentralDir, 2); + Stream.Write(FSizeOfCentralDir, 4); + Stream.Write(FOffsetStartingDiskDir, 4); + Stream.Write(FCommentLength, 2); + if FCommentLength > 0 then + Stream.Write(FComment[1], FCommentLength); +end; + +procedure TfrxZipCentralDirectory.SetComment(const Value: String); +begin + FComment := Value; + FCommentLength := Length(Value); +end; + +{ TfrxZipFileHeader } + +constructor TfrxZipFileHeader.Create; +begin + FCentralFileHeaderSignature := $02014b50; + FRelativeOffsetLocalHeader := 0; + FUnCompressedSize := 0; + FCompressedSize := 0; + FCrc32 := 0; + FExternalFileAttribute := 0; + FExtraField := ''; + FFileComment := ''; + FFileName := ''; + FCompressionMethod := 0; + FDiskNumberStart := 0; + FLastModFileDate := 0; + FLastModFileTime := 0; + FVersionMadeBy := ZIP_VERSIONMADEBY; + FGeneralPurpose := 0; + FFileNameLength := 0; + FInternalFileAttribute := 0; + FExtraFieldLength := 0; + FVersionNeeded := ZIP_VERSIONMADEBY; + FFileCommentLength := 0; +end; + +procedure TfrxZipFileHeader.SaveToStream(const Stream: TStream); +begin + Stream.Write(FCentralFileHeaderSignature, 4); + Stream.Write(FVersionMadeBy, 2); + Stream.Write(FVersionNeeded, 2); + Stream.Write(FGeneralPurpose, 2); + Stream.Write(FCompressionMethod, 2); + Stream.Write(FLastModFileTime, 2); + Stream.Write(FLastModFileDate, 2); + Stream.Write(FCrc32, 4); + Stream.Write(FCompressedSize, 4); + Stream.Write(FUnCompressedSize, 4); + Stream.Write(FFileNameLength, 2); + Stream.Write(FExtraFieldLength, 2); + Stream.Write(FFileCommentLength, 2); + Stream.Write(FDiskNumberStart, 2); + Stream.Write(FInternalFileAttribute, 2); + Stream.Write(FExternalFileAttribute, 4); + Stream.Write(FRelativeOffsetLocalHeader, 4); + Stream.Write(FFilename[1], FFileNameLength); + Stream.Write(FExtraField[1], FExtraFieldLength); + Stream.Write(FFileComment[1], FFileCommentLength); +end; + +procedure TfrxZipFileHeader.SetExtraField(const Value: String); +begin + FExtraField := Value; + FExtraFieldLength := Length(Value); +end; + +procedure TfrxZipFileHeader.SetFileComment(const Value: String); +begin + FFileComment := Value; + FFileNameLength := Length(Value); +end; + +procedure TfrxZipFileHeader.SetFileName(const Value: String); +begin + FFileName := StringReplace(Value, '\', '/', [rfReplaceAll]); + FFileNameLength := Length(Value); +end; + +{ TfrxZipArchive } + +procedure TfrxZipArchive.AddDir(const DirName: String); +var + SRec: TSearchRec; + i: Integer; + s: String; +begin + if DirectoryExists(DirName) then + begin + s := DirName; + if s[Length(s)] <> '\' then + s := s + '\'; + i := FindFirst(s + '*.*', faDirectory + faArchive, SRec); + try + while i = 0 do + begin + if (SRec.Name <> '.') and (SRec.Name <> '..') then + begin + if (SRec.Attr and faDirectory) = faDirectory then + AddDir(s + SRec.Name) + else + AddFile(s + SRec.Name); + end; + i := FindNext(SRec); + end; + finally + FindClose(SRec); + end; + end; +end; + +procedure TfrxZipArchive.AddFile(const FileName: String); +begin + if FileExists(FileName) then + begin + FFileList.Add(FileName); + if FRootFolder = '' then + FRootFolder := ExtractFilePath(FileName); + end + else + FErrors.Add('File ' + FileName + ' not found!'); +end; + +procedure TfrxZipArchive.Clear; +begin + FErrors.Clear; + FFileList.Clear; + FRootFolder := ''; + FComment := ''; +end; + +constructor TfrxZipArchive.Create; +begin + FProgress := nil; + FErrors := TStringList.Create; + FFileList := TStringList.Create; + Clear; +end; + +destructor TfrxZipArchive.Destroy; +begin + FErrors.Free; + FFileList.Free; + inherited; +end; + +function TfrxZipArchive.GetCount: Integer; +begin + Result := FFileList.Count; +end; + +procedure TfrxZipArchive.SaveToFile(const FileName: String); +var + f: TFileStream; +begin + f := TFileStream.Create(FileName, fmCreate); + try + SaveToStream(f); + finally + f.Free; + end; +end; + +procedure TfrxZipArchive.SaveToStream(const Stream: TStream); +var + i: Integer; + ZipFile: TfrxZipLocalFile; + ZipFileHeader: TfrxZipFileHeader; + ZipDir: TfrxZipCentralDirectory; + FileStream: TFileStream; + TempStream: TMemoryStream; + FileName: String; + CentralStartPos, CentralEndPos: DWORD; + LFT, LFT2: TFileTime; + FDate, FTime: WORD; +begin + for i := 0 to FFileList.Count - 1 do + begin + ZipFile := TfrxZipLocalFile.Create; + ZipFile.FileData := TMemoryStream.Create; + try + FileName := StringReplace(FFileList[i], FRootFolder, '', []); + ZipFile.LocalFileHeader.FileName := FileName; + FileStream := TFileStream.Create(FFileList[i], fmOpenRead + fmShareDenyWrite); + try + if FileStream.Size > ZIP_MINSIZE then + begin + FileStream.Position := 0; + TempStream := TMemoryStream.Create; + try + frxDeflateStream(FileStream, TempStream); + TempStream.Position := 2; + ZipFile.FileData.CopyFrom(TempStream, TempStream.Size - 6); + finally + TempStream.Free; + end; + ZipFile.LocalFileHeader.CompressionMethod := ZIP_DEFLATED; + end + else + begin + ZipFile.FileData.CopyFrom(FileStream, 0); + ZipFile.LocalFileHeader.CompressionMethod := ZIP_NONE; + end; + ZipFile.LocalFileHeader.CompressedSize := ZipFile.FileData.Size; + ZipFile.LocalFileHeader.UnCompressedSize := FileStream.Size; + TempStream := TMemoryStream.Create; + try + TempStream.CopyFrom(FileStream, 0); + ZipFile.LocalFileHeader.Crc32 := frxStreamCRC32(TempStream); + finally + TempStream.Free; + end; + ZipFile.Offset := Stream.Position; + GetFileTime(FileStream.Handle, @LFT, nil, nil); + FileTimeToLocalFileTime(LFT, LFT2); + FileTimeToDosDateTime(LFT2, FDate, FTime); + ZipFile.LocalFileHeader.LastModFileDate := FDate; + ZipFile.LocalFileHeader.LastModFileTime := FTime; + finally + FileStream.Free; + end; + ZipFile.SaveToStream(Stream); + if Assigned(FProgress) then + FProgress(Self); + finally + ZipFile.FileData.Free; + ZipFile.FileData := nil; + end; + FFileList.Objects[i] := ZipFile; + end; + CentralStartPos := Stream.Position; + for i := 0 to FFileList.Count - 1 do + begin + ZipFile := TfrxZipLocalFile(FFileList.Objects[i]); + ZipFileHeader := TfrxZipFileHeader.Create; + try + ZipFileHeader.CompressionMethod := ZipFile.LocalFileHeader.CompressionMethod; + ZipFileHeader.LastModFileTime := ZipFile.LocalFileHeader.LastModFileTime; + ZipFileHeader.LastModFileDate := ZipFile.LocalFileHeader.LastModFileDate; + ZipFileHeader.GeneralPurpose := ZipFile.LocalFileHeader.GeneralPurpose; + ZipFileHeader.Crc32 := ZipFile.LocalFileHeader.Crc32; + ZipFileHeader.CompressedSize := ZipFile.LocalFileHeader.CompressedSize; + ZipFileHeader.UnCompressedSize := ZipFile.LocalFileHeader.UnCompressedSize; + ZipFileHeader.RelativeOffsetLocalHeader := ZipFile.Offset; + ZipFileHeader.FileName := ZipFile.LocalFileHeader.FileName; + ZipFileHeader.SaveToStream(Stream); + finally + ZipFileHeader.Free; + end; + ZipFile.Free; + end; + CentralEndPos := Stream.Position; + ZipDir := TfrxZipCentralDirectory.Create; + try + ZipDir.TotalOfEntriesCentralDirOnDisk := FFileList.Count; + ZipDir.TotalOfEntriesCentralDir := FFileList.Count; + ZipDir.SizeOfCentralDir := CentralEndPos - CentralStartPos; + ZipDir.OffsetStartingDiskDir := CentralStartPos; + ZipDir.SaveToStream(Stream); + finally + ZipDir.Free; + end; +end; + +end. \ No newline at end of file diff --git a/official/4.2/LibD11/frxcs10.bdsproj b/official/4.2/LibD11/frxcs10.bdsproj new file mode 100644 index 0000000..47a8308 --- /dev/null +++ b/official/4.2/LibD11/frxcs10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxcs10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxcs10.res b/official/4.2/LibD11/frxcs10.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frxcs10.res differ diff --git a/official/4.2/LibD11/frxcs11.bdsproj b/official/4.2/LibD11/frxcs11.bdsproj new file mode 100644 index 0000000..056b8b5 --- /dev/null +++ b/official/4.2/LibD11/frxcs11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxcs11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxcs4.bpk b/official/4.2/LibD11/frxcs4.bpk new file mode 100644 index 0000000..cab887e --- /dev/null +++ b/official/4.2/LibD11/frxcs4.bpk @@ -0,0 +1,189 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = frxcs4.bpl +OBJFILES = frxRegCS.obj frxcs4.obj +RESFILES = frxcs4.res frxRegCS.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +LIBRARIES = +SPARELIBS = VCL40.lib +PACKAGES = vcl40.bpi vcldb40.bpi frx4.bpi frxe4.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release;.. +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -D"FastReport 4.0 Client/Server Components" -aa \ + -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxcs4.cpp b/official/4.2/LibD11/frxcs4.cpp new file mode 100644 index 0000000..bdbec0c --- /dev/null +++ b/official/4.2/LibD11/frxcs4.cpp @@ -0,0 +1,19 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frxcs4.res"); +USEPACKAGE("vcl40.bpi"); +USEUNIT("frxRegCS.pas"); +USERES("frxRegCS.dcr"); +USEPACKAGE("frx4.bpi"); +USEPACKAGE("frxe4.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxcs4.dpk b/official/4.2/LibD11/frxcs4.dpk new file mode 100644 index 0000000..ea8ebb0 --- /dev/null +++ b/official/4.2/LibD11/frxcs4.dpk @@ -0,0 +1,55 @@ +// Package file for Delphi 4 + +package frxcs4; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + frx4, + frxe4; + +contains + { core files } + frxServer in 'frxServer.pas', + frxMD5 in 'frxMD5.pas', + frxServerClient in 'frxServerClient.pas', + frxServerConfig in 'frxServerConfig.pas', + frxServerFormControls in 'frxServerFormControls.pas', + frxServerForms in 'frxServerForms.pas', + frxServerLog in 'frxServerLog.pas', + frxServerReports in 'frxServerReports.pas', + frxServerSessionManager in 'frxServerSessionManager.pas', + frxUsers in 'frxUsers.pas', + frxServerSSI in 'frxServerSSI.pas', + frxServerStat in 'frxServerStat.pas', + frxServerUtils in 'frxServerUtils.pas', + frxHTTPClient in 'frxHTTPClient.pas', + frxCGIClient in 'frxCGIClient.pas', + frxServerCache in 'frxServerCache.pas', + frxServerReportsList in 'frxServerReportsList.pas', + frxServerTemplates in 'frxServerTemplates.pas', + frxServerVariables in 'frxServerVariables.pas'; +end. diff --git a/official/4.2/LibD11/frxcs4.res b/official/4.2/LibD11/frxcs4.res new file mode 100644 index 0000000..eb2597a Binary files /dev/null and b/official/4.2/LibD11/frxcs4.res differ diff --git a/official/4.2/LibD11/frxcs5.bpk b/official/4.2/LibD11/frxcs5.bpk new file mode 100644 index 0000000..5374f12 --- /dev/null +++ b/official/4.2/LibD11/frxcs5.bpk @@ -0,0 +1,92 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxcs5.cpp b/official/4.2/LibD11/frxcs5.cpp new file mode 100644 index 0000000..8b2a009 --- /dev/null +++ b/official/4.2/LibD11/frxcs5.cpp @@ -0,0 +1,23 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("frxcs5.res"); +USEPACKAGE("vcl50.bpi"); +USEUNIT("frxRegCS.pas"); +USERES("frxRegCS.dcr"); +USEPACKAGE("frx5.bpi"); +USEPACKAGE("frxe5.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxcs5.dpk b/official/4.2/LibD11/frxcs5.dpk new file mode 100644 index 0000000..b1da56a --- /dev/null +++ b/official/4.2/LibD11/frxcs5.dpk @@ -0,0 +1,55 @@ +// Package file for Delphi 5 + +package frxcs5; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + frx5, + frxe5; + +contains + { core files } + frxServer in 'frxServer.pas', + frxMD5 in 'frxMD5.pas', + frxServerClient in 'frxServerClient.pas', + frxServerConfig in 'frxServerConfig.pas', + frxServerFormControls in 'frxServerFormControls.pas', + frxServerForms in 'frxServerForms.pas', + frxServerLog in 'frxServerLog.pas', + frxServerReports in 'frxServerReports.pas', + frxServerSessionManager in 'frxServerSessionManager.pas', + frxUsers in 'frxUsers.pas', + frxServerSSI in 'frxServerSSI.pas', + frxServerStat in 'frxServerStat.pas', + frxServerUtils in 'frxServerUtils.pas', + frxHTTPClient in 'frxHTTPClient.pas', + frxCGIClient in 'frxCGIClient.pas', + frxServerCache in 'frxServerCache.pas', + frxServerReportsList in 'frxServerReportsList.pas', + frxServerTemplates in 'frxServerTemplates.pas', + frxServerVariables in 'frxServerVariables.pas'; +end. diff --git a/official/4.2/LibD11/frxcs5.res b/official/4.2/LibD11/frxcs5.res new file mode 100644 index 0000000..da3d366 Binary files /dev/null and b/official/4.2/LibD11/frxcs5.res differ diff --git a/official/4.2/LibD11/frxcs6.bpk b/official/4.2/LibD11/frxcs6.bpk new file mode 100644 index 0000000..b8fb5c5 --- /dev/null +++ b/official/4.2/LibD11/frxcs6.bpk @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=2 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib;..\ +Item1=$(BCB)\Projects;..\..\FR\SOURCE\ADO;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[HistoryLists\hlConditionals] +Count=1 +Item0=_DEBUG + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxcs6.cpp b/official/4.2/LibD11/frxcs6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/frxcs6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frxcs6.dpk b/official/4.2/LibD11/frxcs6.dpk new file mode 100644 index 0000000..56ee10b --- /dev/null +++ b/official/4.2/LibD11/frxcs6.dpk @@ -0,0 +1,55 @@ +// Package file for Delphi 6 + +package frxcs6; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + frx6, + frxe6; + +contains + { core files } + frxServer in 'frxServer.pas', + frxMD5 in 'frxMD5.pas', + frxServerClient in 'frxServerClient.pas', + frxServerConfig in 'frxServerConfig.pas', + frxServerFormControls in 'frxServerFormControls.pas', + frxServerForms in 'frxServerForms.pas', + frxServerLog in 'frxServerLog.pas', + frxServerReports in 'frxServerReports.pas', + frxServerSessionManager in 'frxServerSessionManager.pas', + frxUsers in 'frxUsers.pas', + frxServerSSI in 'frxServerSSI.pas', + frxServerStat in 'frxServerStat.pas', + frxServerUtils in 'frxServerUtils.pas', + frxHTTPClient in 'frxHTTPClient.pas', + frxCGIClient in 'frxCGIClient.pas', + frxServerCache in 'frxServerCache.pas', + frxServerReportsList in 'frxServerReportsList.pas', + frxServerTemplates in 'frxServerTemplates.pas', + frxServerVariables in 'frxServerVariables.pas'; +end. diff --git a/official/4.2/LibD11/frxcs6.res b/official/4.2/LibD11/frxcs6.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frxcs6.res differ diff --git a/official/4.2/LibD11/frxcs7.dpk b/official/4.2/LibD11/frxcs7.dpk new file mode 100644 index 0000000..a8c4441 --- /dev/null +++ b/official/4.2/LibD11/frxcs7.dpk @@ -0,0 +1,55 @@ +// Package file for Delphi 7 + +package frxcs7; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + frx7, + frxe7; + +contains + { core files } + frxServer in 'frxServer.pas', + frxMD5 in 'frxMD5.pas', + frxServerClient in 'frxServerClient.pas', + frxServerConfig in 'frxServerConfig.pas', + frxServerFormControls in 'frxServerFormControls.pas', + frxServerForms in 'frxServerForms.pas', + frxServerLog in 'frxServerLog.pas', + frxServerReports in 'frxServerReports.pas', + frxServerSessionManager in 'frxServerSessionManager.pas', + frxUsers in 'frxUsers.pas', + frxServerSSI in 'frxServerSSI.pas', + frxServerStat in 'frxServerStat.pas', + frxServerUtils in 'frxServerUtils.pas', + frxHTTPClient in 'frxHTTPClient.pas', + frxCGIClient in 'frxCGIClient.pas', + frxServerCache in 'frxServerCache.pas', + frxServerReportsList in 'frxServerReportsList.pas', + frxServerTemplates in 'frxServerTemplates.pas', + frxServerVariables in 'frxServerVariables.pas'; +end. diff --git a/official/4.2/LibD11/frxcs7.res b/official/4.2/LibD11/frxcs7.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frxcs7.res differ diff --git a/official/4.2/LibD11/frxcs9.bdsproj b/official/4.2/LibD11/frxcs9.bdsproj new file mode 100644 index 0000000..0e4e22a --- /dev/null +++ b/official/4.2/LibD11/frxcs9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + frxcs9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/frxcs9.res b/official/4.2/LibD11/frxcs9.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frxcs9.res differ diff --git a/official/4.2/LibD11/frxe10.bdsproj b/official/4.2/LibD11/frxe10.bdsproj new file mode 100644 index 0000000..0698555 --- /dev/null +++ b/official/4.2/LibD11/frxe10.bdsproj @@ -0,0 +1,16 @@ + + + + + + + + + + + + frxe10.dpk + + + diff --git a/official/4.2/LibD11/frxe11.bdsproj b/official/4.2/LibD11/frxe11.bdsproj new file mode 100644 index 0000000..2a2e100 --- /dev/null +++ b/official/4.2/LibD11/frxe11.bdsproj @@ -0,0 +1,16 @@ + + + + + + + + + + + + frxe11.dpk + + + diff --git a/official/4.2/LibD11/frxe4.bpk b/official/4.2/LibD11/frxe4.bpk new file mode 100644 index 0000000..1137d76 --- /dev/null +++ b/official/4.2/LibD11/frxe4.bpk @@ -0,0 +1,189 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = frxe4.bpl +OBJFILES = frxeReg.obj frxe4.obj frxrcExports.obj +RESFILES = frxe4.res frxeReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +LIBRARIES = +SPARELIBS = VCL40.lib +PACKAGES = vcl40.bpi vcljpg40.bpi vclx40.bpi frx4.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release;..\;..\..\FastScript +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) -D"FastReport 4.0 Exports" -aa \ + -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxe4.cpp b/official/4.2/LibD11/frxe4.cpp new file mode 100644 index 0000000..fe06622 --- /dev/null +++ b/official/4.2/LibD11/frxe4.cpp @@ -0,0 +1,21 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frxe4.res"); +USEPACKAGE("vcl40.bpi"); +USEUNIT("frxeReg.pas"); +USEUNIT("frxrcExports.pas"); +USERES("frxeReg.dcr"); +USEPACKAGE("vcljpg40.bpi"); +USEPACKAGE("vclx40.bpi"); +USEPACKAGE("frx4.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxe4.dpk b/official/4.2/LibD11/frxe4.dpk new file mode 100644 index 0000000..74877a2 --- /dev/null +++ b/official/4.2/LibD11/frxe4.dpk @@ -0,0 +1,55 @@ +// Package file for Delphi 4 + +package frxe4; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + vcl40, + vcljpg40, + frx4; + +contains + frxExportHTML in 'frxExportHTML.pas', + frxExportImage in 'frxExportImage.pas', + frxExportMatrix in 'frxExportMatrix.pas', + frxExportPDF in 'frxExportPDF.pas', + frxExportRTF in 'frxExportRTF.pas', + frxExportTXT in 'frxExportTXT.pas', + frxExportTxtPrn in 'frxExportTxtPrn.pas', + frxExportXLS in 'frxExportXLS.pas', + frxExportXML in 'frxExportXML.pas', + frxExportCSV in 'frxExportCSV.pas', + frxExportText in 'frxExportText.pas', + frxExportMail in 'frxExportMail.pas', + frxExportODF in 'frxExportODF.pas', + frxZip in 'frxZip.pas', + frxFileUtils in 'frxFileUtils.pas', + frxNetUtils in 'frxNetUtils.pas', + frxPDFFile in 'frxPDFFile.pas', + frxSMTP in 'frxSMTP.pas', + frxrcExports in 'frxrcExports.pas'; + +end. diff --git a/official/4.2/LibD11/frxe4.res b/official/4.2/LibD11/frxe4.res new file mode 100644 index 0000000..eb2597a Binary files /dev/null and b/official/4.2/LibD11/frxe4.res differ diff --git a/official/4.2/LibD11/frxe5.bpk b/official/4.2/LibD11/frxe5.bpk new file mode 100644 index 0000000..9a5abd4 --- /dev/null +++ b/official/4.2/LibD11/frxe5.bpk @@ -0,0 +1,105 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxe5.cpp b/official/4.2/LibD11/frxe5.cpp new file mode 100644 index 0000000..b14d7ee --- /dev/null +++ b/official/4.2/LibD11/frxe5.cpp @@ -0,0 +1,21 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("frxe5.res"); +USEUNIT("frxeReg.pas"); +USEUNIT("frxrcExports.pas"); +USERES("frxeReg.dcr"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vcljpg50.bpi"); +USEPACKAGE("vclx50.bpi"); +USEPACKAGE("frx5.bpi"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/frxe5.dpk b/official/4.2/LibD11/frxe5.dpk new file mode 100644 index 0000000..4ebd905 --- /dev/null +++ b/official/4.2/LibD11/frxe5.dpk @@ -0,0 +1,55 @@ +// Package file for Delphi 5 + +package frxe5; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + vcl50, + vcljpg50, + frx5; + +contains + frxExportHTML in 'frxExportHTML.pas', + frxExportImage in 'frxExportImage.pas', + frxExportMatrix in 'frxExportMatrix.pas', + frxExportPDF in 'frxExportPDF.pas', + frxExportRTF in 'frxExportRTF.pas', + frxExportTXT in 'frxExportTXT.pas', + frxExportTxtPrn in 'frxExportTxtPrn.pas', + frxExportXLS in 'frxExportXLS.pas', + frxExportXML in 'frxExportXML.pas', + frxExportCSV in 'frxExportCSV.pas', + frxExportText in 'frxExportText.pas', + frxExportMail in 'frxExportMail.pas', + frxExportODF in 'frxExportODF.pas', + frxZip in 'frxZip.pas', + frxFileUtils in 'frxFileUtils.pas', + frxNetUtils in 'frxNetUtils.pas', + frxPDFFile in 'frxPDFFile.pas', + frxSMTP in 'frxSMTP.pas', + frxrcExports in 'frxrcExports.pas'; + +end. diff --git a/official/4.2/LibD11/frxe5.res b/official/4.2/LibD11/frxe5.res new file mode 100644 index 0000000..eb2597a Binary files /dev/null and b/official/4.2/LibD11/frxe5.res differ diff --git a/official/4.2/LibD11/frxe6.bpk b/official/4.2/LibD11/frxe6.bpk new file mode 100644 index 0000000..af05d1f --- /dev/null +++ b/official/4.2/LibD11/frxe6.bpk @@ -0,0 +1,133 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\Projects;$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/frxe6.cpp b/official/4.2/LibD11/frxe6.cpp new file mode 100644 index 0000000..48ce892 --- /dev/null +++ b/official/4.2/LibD11/frxe6.cpp @@ -0,0 +1,18 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/frxe6.dpk b/official/4.2/LibD11/frxe6.dpk new file mode 100644 index 0000000..6178b75 --- /dev/null +++ b/official/4.2/LibD11/frxe6.dpk @@ -0,0 +1,55 @@ +// Package file for Delphi 6 + +package frxe6; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + vcl, + vcljpg, + frx6; + +contains + frxExportHTML in 'frxExportHTML.pas', + frxExportImage in 'frxExportImage.pas', + frxExportMatrix in 'frxExportMatrix.pas', + frxExportPDF in 'frxExportPDF.pas', + frxExportRTF in 'frxExportRTF.pas', + frxExportTXT in 'frxExportTXT.pas', + frxExportTxtPrn in 'frxExportTxtPrn.pas', + frxExportXLS in 'frxExportXLS.pas', + frxExportXML in 'frxExportXML.pas', + frxExportCSV in 'frxExportCSV.pas', + frxExportText in 'frxExportText.pas', + frxExportMail in 'frxExportMail.pas', + frxExportODF in 'frxExportODF.pas', + frxZip in 'frxZip.pas', + frxFileUtils in 'frxFileUtils.pas', + frxNetUtils in 'frxNetUtils.pas', + frxPDFFile in 'frxPDFFile.pas', + frxSMTP in 'frxSMTP.pas', + frxrcExports in 'frxrcExports.pas'; + +end. diff --git a/official/4.2/LibD11/frxe6.res b/official/4.2/LibD11/frxe6.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/frxe6.res differ diff --git a/official/4.2/LibD11/frxe7.dpk b/official/4.2/LibD11/frxe7.dpk new file mode 100644 index 0000000..300a52f --- /dev/null +++ b/official/4.2/LibD11/frxe7.dpk @@ -0,0 +1,55 @@ +// Package file for Delphi 7 + +package frxe7; + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} +{$DEBUGINFO ON} +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + vcl, + vcljpg, + frx7; + +contains + frxExportHTML in 'frxExportHTML.pas', + frxExportImage in 'frxExportImage.pas', + frxExportMatrix in 'frxExportMatrix.pas', + frxExportPDF in 'frxExportPDF.pas', + frxExportRTF in 'frxExportRTF.pas', + frxExportTXT in 'frxExportTXT.pas', + frxExportTxtPrn in 'frxExportTxtPrn.pas', + frxExportXLS in 'frxExportXLS.pas', + frxExportXML in 'frxExportXML.pas', + frxExportCSV in 'frxExportCSV.pas', + frxExportText in 'frxExportText.pas', + frxExportMail in 'frxExportMail.pas', + frxExportODF in 'frxExportODF.pas', + frxZip in 'frxZip.pas', + frxFileUtils in 'frxFileUtils.pas', + frxNetUtils in 'frxNetUtils.pas', + frxPDFFile in 'frxPDFFile.pas', + frxSMTP in 'frxSMTP.pas', + frxrcExports in 'frxrcExports.pas'; + +end. diff --git a/official/4.2/LibD11/frxe9.bdsproj b/official/4.2/LibD11/frxe9.bdsproj new file mode 100644 index 0000000..07068d4 --- /dev/null +++ b/official/4.2/LibD11/frxe9.bdsproj @@ -0,0 +1,16 @@ + + + + + + + + + + + + frxe9.dpk + + + diff --git a/official/4.2/LibD11/frxeReg.dcr b/official/4.2/LibD11/frxeReg.dcr new file mode 100644 index 0000000..3eafaaf Binary files /dev/null and b/official/4.2/LibD11/frxeReg.dcr differ diff --git a/official/4.2/LibD11/frxeReg.pas b/official/4.2/LibD11/frxeReg.pas new file mode 100644 index 0000000..66e4e97 --- /dev/null +++ b/official/4.2/LibD11/frxeReg.pas @@ -0,0 +1,46 @@ + +{******************************************} +{ } +{ FastReport v4.0 } +{ Exports Registration unit } +{ } +{ Copyright (c) 1998-2007 } +{ by Alexander Fediachov, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxeReg; + +{$I frx.inc} + +interface + + +procedure Register; + +implementation + +uses + Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, +{$IFNDEF Delphi6} + DsgnIntf, +{$ELSE} + DesignIntf, DesignEditors, +{$ENDIF} + frxExportXML, frxExportHTML, frxExportXLS, frxExportTXT, frxExportImage, + frxExportRTF, frxExportPDF, frxExportText, frxExportCSV, frxExportMail, + frxExportODF; + +{-----------------------------------------------------------------------} + +procedure Register; +begin + RegisterComponents('FastReport 4 exports', + [TfrxPDFExport, TfrxHTMLExport, TfrxXLSExport, + TfrxXMLExport, TfrxRTFExport, TfrxBMPExport, TfrxJPEGExport, + TfrxTIFFExport, TfrxGIFExport, TfrxSimpleTextExport, + TfrxCSVExport, TfrxMailExport, TfrxTXTExport, TfrxODSExport, TfrxODTExport]); +end; + +end. diff --git a/official/4.2/LibD11/frxrcClass.frc b/official/4.2/LibD11/frxrcClass.frc new file mode 100644 index 0000000..79c9e72 --- /dev/null +++ b/official/4.2/LibD11/frxrcClass.frc @@ -0,0 +1,192 @@ +1=OK +2=Cancelar +3=Todo +4=Pgina actual +5=Pginas: +6=Separador de pgina +7=Rango de Pginas +8=Opciones de Exportar +9=Indique los nmeros de pgina y/o un rango, separado por comas. Por ejemplo: 1,3,5-12 +======== TfrxPreviewForm ======== +100=Vista Previa +101=Imprimir +102=Imprimir +103=Abrir +104=Abrir +105=Guardar +106=Guardar +107=Exportar +108=Exportar +109=Buscar +110=Buscar +111=Ver pgina completa +112=Ver pgina completa +113=Ajustar al ancho +114=Ajustar al ancho +115=100% +116=100% +117=Dos pginas +118=Dos pginas +119=Zoom +120=Mrgenes +121=Mrgenes +122=Resumen +123=Resumen +124=Acercar +125=Acercar +126=Alejar +127=Alejar +128=Indice +129=Indice del Informe +130=Diapositivas +131=Diapositivas +132=Editar +133=Editar Pgina +134=Primera +135=Primera pgina +136=Anterior +137=Pgina anterior +138=Siguiente +139=Pgina siguiente +140=Ultima +141=Ultima pgina +142=Ir a la pgina + +150=Pantalla completa +151=Exportar a PDF +152=Enviar por E-mail +zmPageWidth=Ajustar al ancho +zmWholePage=Ver pgina completa +======== TfrxPrintDialog ======== +200=Imprimir +201=Impresora +202=Pginas +203=Nmero de copias +204=Intercalar +205=Copias +206=Imprimir +207=!Other +208=Condicin: +209=Propiedades... +210=Imprimir en fichero +211=!Order +212=Nombre: +213=Modo de Impresin +214=Tamao del papel +216=Duplex + +ppAll=Todas las pginas +ppOdd=Pginas impares +ppEven=Pginas impares +pgDefault=Predefinido +pmDefault=Predefinido +pmSplit=Partir pginas grandes +pmJoin=Unir pginas pequeas +pmScale=Escala +poDirect=!Direct (1-9) +poReverse=!Reverse (9-1) +======== TfrxSearchDialog ======== +300=Buscar texto +301=Texto a buscar: +302=Opciones de bsqueda +303=Reemplazar con +304=Desde el principio +305=Distinguir Mayus/Minus. + +======== TfrxPageSettingsForm ======== +400=Configurar pgina +401=Ancho +402=Largo +403=Tamao +404=Orientacin +405=Izquierda +406=Arriba +407=Derecha +408=Abajo +409=Mrgenes +410=Vertical +411=Horizontal +412=Otros +413=Aplicar a la pgina actual +414=Aplicar a todas las pginas + +======== TfrxDMPExportDialog ======== +500=Imprimir +501=Impresora +502=Pginas +503=Copias +504=Nmero de copias +505=Opciones +506=Cdigos de Escape +507=Imprimir en archivo +508=Cdigos de pgina OEM +509=Pseudo graficos +510=Archivos de impresora (*.prn)|*.prn + +======== TfrxProgress ======== + +mbConfirm=Confirmar +mbError=Error +mbInfo=Informacin +xrCantFindClass=Clase no encontrada +prVirtual=Virtual +prDefault=Por defecto +prCustom=Personalizar +enUnconnHeader=Cabecera/Pie no conectadas +enUnconnGroup=No hay banda de datos para el grupo +enUnconnGFooter=No hay cabecera de grupo para +enBandPos=Posicin incorrecta para la banda: +dbNotConn=El DataSet %s no est conectado a datos +dbFldNotFound=Campo no encontrado: +clDSNotIncl=(El Dataset no est incluido en los dataset del informe) +clUnknownVar=Variable o campo desconocido: +clScrError=Error en el script en %s: %s +clDSNotExist=El Dataset "%s" no existe +clErrors=Ha ocurrido el siguiente error: +clExprError=Error en la expresin +clFP3files=Preparando el informe +clSaving=Guardando archivo... +clCancel=Cancelar +clClose=Cerrar +clPrinting=Imprimiendo pgina +clLoading=Cargando archivo... +clPageOf=Pgina %d de %d +clFirstPass=Primera pasada: pgina +clNoPrinters=No hay impresoras instaladas en su sistema +clDecompressError=Error al descomprimir el contenedor +prRunningFirst=Primera pasada: pgina %d +prRunning=Preparando pgina %d +prPrinting=Imprimiendo pgina %d +prExporting=Exportando pgina %d +uCm=cm +uInch=in +uPix=px +uChar=chr +dupDefault=Predeterminada +dupVert=Vertical +dupHorz=Horizontal +dupSimpl=Simple +crFillMx=Llenando los datos cruzados +crBuildMx=Construyendo los datos cruzados + +=========== FS strings =============== +SLangNotFound=Lenguaje '%s' no encontrado +SInvalidLanguage=Lenguaje no vlido +SIdRedeclared=Identificador redeclarado: +SUnknownType=Tipo desconocido: +SIncompatibleTypes=Tipos incompatibles +SIdUndeclared=Identificador no declarado: +SClassRequired=Se requiere el tipo de la clase +SIndexRequired=Se requiere un ndice +SStringError=La cadena no est entre las propiedades o mtodos +SClassError=La clase %s no tiene propiedad por defecto +SArrayRequired=Se requiere un Array +SVarRequired=Variable requirida +SNotEnoughParams=Faltan parmetros +STooManyParams=Sobran parmetros +SLeftCantAssigned=El lado izquierdo no se puede asignar a +SForError=Los bucles For necesitan una variable numrica +SEventError=El manejador del evento ha de ser un procedimiento +======== TfrxPreviewOutlineForm ======== +600=Expandir todo +601=Contraer todo diff --git a/official/4.2/LibD11/frxrcClass.pas b/official/4.2/LibD11/frxrcClass.pas new file mode 100644 index 0000000..19dbe5e --- /dev/null +++ b/official/4.2/LibD11/frxrcClass.pas @@ -0,0 +1,218 @@ +{******************************************} +{ } +{ FastReport v4.0 } +{ Language resource file } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxrcClass; + +interface + +implementation + +uses frxRes; + +const resStr = +'1=OK' + #13#10 + +'2=Cancelar' + #13#10 + +'3=Todo' + #13#10 + +'4=Pgina actual' + #13#10 + +'5=Pginas:' + #13#10 + +'6=Separador de pgina' + #13#10 + +'7=Rango de Pginas' + #13#10 + +'8=Opciones de Exportar' + #13#10 + +'9=Indique los nmeros de pgina y/o un rango, separado por comas. Por ejemplo: 1,3,5-12' + #13#10 + +'======== TfrxPreviewForm ========' + #13#10 + +'100=Vista Previa' + #13#10 + +'101=Imprimir' + #13#10 + +'102=Imprimir' + #13#10 + +'103=Abrir' + #13#10 + +'104=Abrir' + #13#10 + +'105=Guardar' + #13#10 + +'106=Guardar' + #13#10 + +'107=Exportar' + #13#10 + +'108=Exportar' + #13#10 + +'109=Buscar' + #13#10 + +'110=Buscar' + #13#10 + +'111=Ver pgina completa' + #13#10 + +'112=Ver pgina completa' + #13#10 + +'113=Ajustar al ancho' + #13#10 + +'114=Ajustar al ancho' + #13#10 + +'115=100%' + #13#10 + +'116=100%' + #13#10 + +'117=Dos pginas' + #13#10 + +'118=Dos pginas' + #13#10 + +'119=Zoom' + #13#10 + +'120=Mrgenes' + #13#10 + +'121=Mrgenes' + #13#10 + +'122=Resumen' + #13#10 + +'123=Resumen' + #13#10 + +'124=Acercar' + #13#10 + +'125=Acercar' + #13#10 + +'126=Alejar' + #13#10 + +'127=Alejar' + #13#10 + +'128=Indice' + #13#10 + +'129=Indice del Informe' + #13#10 + +'130=Diapositivas' + #13#10 + +'131=Diapositivas' + #13#10 + +'132=Editar' + #13#10 + +'133=Editar Pgina' + #13#10 + +'134=Primera' + #13#10 + +'135=Primera pgina' + #13#10 + +'136=Anterior' + #13#10 + +'137=Pgina anterior' + #13#10 + +'138=Siguiente' + #13#10 + +'139=Pgina siguiente' + #13#10 + +'140=Ultima' + #13#10 + +'141=Ultima pgina' + #13#10 + +'142=Ir a la pgina' + #13#10 + +'' + #13#10 + +'150=Pantalla completa' + #13#10 + +'151=Exportar a PDF' + #13#10 + +'152=Enviar por E-mail' + #13#10 + +'zmPageWidth=Ajustar al ancho' + #13#10 + +'zmWholePage=Ver pgina completa' + #13#10 + +'======== TfrxPrintDialog ========' + #13#10 + +'200=Imprimir' + #13#10 + +'201=Impresora' + #13#10 + +'202=Pginas' + #13#10 + +'203=Nmero de copias' + #13#10 + +'204=Intercalar' + #13#10 + +'205=Copias' + #13#10 + +'206=Imprimir' + #13#10 + +'207=!Other' + #13#10 + +'208=Condicin:' + #13#10 + +'209=Propiedades...' + #13#10 + +'210=Imprimir en fichero' + #13#10 + +'211=!Order' + #13#10 + +'212=Nombre:' + #13#10 + +'213=Modo de Impresin' + #13#10 + +'214=Tamao del papel' + #13#10 + +'216=Duplex' + #13#10 + +'' + #13#10 + +'ppAll=Todas las pginas' + #13#10 + +'ppOdd=Pginas impares' + #13#10 + +'ppEven=Pginas impares' + #13#10 + +'pgDefault=Predefinido' + #13#10 + +'pmDefault=Predefinido' + #13#10 + +'pmSplit=Partir pginas grandes' + #13#10 + +'pmJoin=Unir pginas pequeas' + #13#10 + +'pmScale=Escala' + #13#10 + +'poDirect=!Direct (1-9)' + #13#10 + +'poReverse=!Reverse (9-1)' + #13#10 + +'======== TfrxSearchDialog ========' + #13#10 + +'300=Buscar texto' + #13#10 + +'301=Texto a buscar:' + #13#10 + +'302=Opciones de bsqueda' + #13#10 + +'303=Reemplazar con' + #13#10 + +'304=Desde el principio' + #13#10 + +'305=Distinguir Mayus/Minus.' + #13#10 + +'' + #13#10 + +'======== TfrxPageSettingsForm ========' + #13#10 + +'400=Configurar pgina' + #13#10 + +'401=Ancho' + #13#10 + +'402=Largo' + #13#10 + +'403=Tamao' + #13#10 + +'404=Orientacin' + #13#10 + +'405=Izquierda' + #13#10 + +'406=Arriba' + #13#10 + +'407=Derecha' + #13#10 + +'408=Abajo' + #13#10 + +'409=Mrgenes' + #13#10 + +'410=Vertical' + #13#10 + +'411=Horizontal' + #13#10 + +'412=Otros' + #13#10 + +'413=Aplicar a la pgina actual' + #13#10 + +'414=Aplicar a todas las pginas' + #13#10 + +'' + #13#10 + +'======== TfrxDMPExportDialog ========' + #13#10 + +'500=Imprimir' + #13#10 + +'501=Impresora' + #13#10 + +'502=Pginas' + #13#10 + +'503=Copias' + #13#10 + +'504=Nmero de copias' + #13#10 + +'505=Opciones' + #13#10 + +'506=Cdigos de Escape' + #13#10 + +'507=Imprimir en archivo' + #13#10 + +'508=Cdigos de pgina OEM' + #13#10 + +'509=Pseudo graficos' + #13#10 + +'510=Archivos de impresora (*.prn)|*.prn' + #13#10 + +'' + #13#10 + +'======== TfrxProgress ========' + #13#10 + +'' + #13#10 + +'mbConfirm=Confirmar' + #13#10 + +'mbError=Error' + #13#10 + +'mbInfo=Informacin' + #13#10 + +'xrCantFindClass=Clase no encontrada' + #13#10 + +'prVirtual=Virtual' + #13#10 + +'prDefault=Por defecto' + #13#10 + +'prCustom=Personalizar' + #13#10 + +'enUnconnHeader=Cabecera/Pie no conectadas' + #13#10 + +'enUnconnGroup=No hay banda de datos para el grupo' + #13#10 + +'enUnconnGFooter=No hay cabecera de grupo para' + #13#10 + +'enBandPos=Posicin incorrecta para la banda:' + #13#10 + +'dbNotConn=El DataSet %s no est conectado a datos' + #13#10 + +'dbFldNotFound=Campo no encontrado:' + #13#10 + +'clDSNotIncl=(El Dataset no est incluido en los dataset del informe)' + #13#10 + +'clUnknownVar=Variable o campo desconocido:' + #13#10 + +'clScrError=Error en el script en %s: %s' + #13#10 + +'clDSNotExist=El Dataset "%s" no existe' + #13#10 + +'clErrors=Ha ocurrido el siguiente error:' + #13#10 + +'clExprError=Error en la expresin' + #13#10 + +'clFP3files=Preparando el informe' + #13#10 + +'clSaving=Guardando archivo...' + #13#10 + +'clCancel=Cancelar' + #13#10 + +'clClose=Cerrar' + #13#10 + +'clPrinting=Imprimiendo pgina' + #13#10 + +'clLoading=Cargando archivo...' + #13#10 + +'clPageOf=Pgina %d de %d' + #13#10 + +'clFirstPass=Primera pasada: pgina' + #13#10 + +'clNoPrinters=No hay impresoras instaladas en su sistema' + #13#10 + +'clDecompressError=Error al descomprimir el contenedor' + #13#10 + +'prRunningFirst=Primera pasada: pgina %d' + #13#10 + +'prRunning=Preparando pgina %d' + #13#10 + +'prPrinting=Imprimiendo pgina %d' + #13#10 + +'prExporting=Exportando pgina %d' + #13#10 + +'uCm=cm' + #13#10 + +'uInch=in' + #13#10 + +'uPix=px' + #13#10 + +'uChar=chr' + #13#10 + +'dupDefault=Predeterminada' + #13#10 + +'dupVert=Vertical' + #13#10 + +'dupHorz=Horizontal' + #13#10 + +'dupSimpl=Simple' + #13#10 + +'crFillMx=Llenando los datos cruzados' + #13#10 + +'crBuildMx=Construyendo los datos cruzados' + #13#10 + +'' + #13#10 + +'=========== FS strings ===============' + #13#10 + +'SLangNotFound=Lenguaje ''%s'' no encontrado' + #13#10 + +'SInvalidLanguage=Lenguaje no vlido' + #13#10 + +'SIdRedeclared=Identificador redeclarado:' + #13#10 + +'SUnknownType=Tipo desconocido:' + #13#10 + +'SIncompatibleTypes=Tipos incompatibles' + #13#10 + +'SIdUndeclared=Identificador no declarado:' + #13#10 + +'SClassRequired=Se requiere el tipo de la clase' + #13#10 + +'SIndexRequired=Se requiere un ndice' + #13#10 + +'SStringError=La cadena no est entre las propiedades o mtodos' + #13#10 + +'SClassError=La clase %s no tiene propiedad por defecto' + #13#10 + +'SArrayRequired=Se requiere un Array' + #13#10 + +'SVarRequired=Variable requirida' + #13#10 + +'SNotEnoughParams=Faltan parmetros' + #13#10 + +'STooManyParams=Sobran parmetros' + #13#10 + +'SLeftCantAssigned=El lado izquierdo no se puede asignar a' + #13#10 + +'SForError=Los bucles For necesitan una variable numrica' + #13#10 + +'SEventError=El manejador del evento ha de ser un procedimiento' + #13#10 + +'======== TfrxPreviewOutlineForm ========' + #13#10 + +'600=Expandir todo' + #13#10 + +'601=Contraer todo' + #13#10 + +''; + +initialization + frxResources.AddStrings(resStr); + +end. diff --git a/official/4.2/LibD11/frxrcDesgn.frc b/official/4.2/LibD11/frxrcDesgn.frc new file mode 100644 index 0000000..286c625 --- /dev/null +++ b/official/4.2/LibD11/frxrcDesgn.frc @@ -0,0 +1,920 @@ +======== TfrxObjectInspector ======== +2000=Inspector de Objetos + +oiProp=Propiedades +oiEvent=Eventos +======== TfrxDataTreeForm ======== +2100=Arbol de datos +2101=Datos +2102=Variables +2103=Funciones +2104=Crear campo +2105=Crear ttulo +2106=Clases + +dtNoData=Datos no disponibles +dtNoData1=Ir a "Informe/Datos..." menu para aadir orgenes de datos existentes a tu informe, o desde la ventana Datos crear nuevos orgenes de datos +dtData=Datos +dtSysVar=Variables de sistema +dtVar=Variables +dtFunc=Funciones +======== TfrxReportTreeForm ======== +2200=Indice del informe + +======== TfrxDesignerForm ======== +2300=Abrir archivo de script +2301=Guardar Script en archivo +2302=Ejecutar Script +2303=Depurar en +2304=Terminar Script +2305=Evaluar +2306=Lenguaje: +2307=Alineacin +2308=Alinear al borde Izquierdo +2309=Alinear al centro +2310=Alinear a la derecha +2311=Alinear arriba +2312=Alinear al Centro +2313=Alinear Abajo +2314=Mismo espacio horizontal +2315=Mismo espacio vertical +2316=Centrar horizontalmente en la banda +2317=Centrar Verticalmente en la banda +2318=Mismo ancho +2319=Mismo largo +2320=Texto +2321=Estilo +2322=Fuente +2323=Tamao +2324=Negrita +2325=Cursiva +2326=Subrayado +2327=Color +2328=Resaltar +2329=Rotacin del Texto +2330=Ajuste izquierda +2331=Centrado +2332=Ajuste derecha +2333=Justificado +2334=Ajuste arriba +2335=Centrado +2336=Ajuste abajo +2337=Marco +2338=Lnea de arriba del marco +2339=Lnea de abajo del marco +2340=Lnea izquierda del marco +2341=Lnea derecha del marco +2342=Todas las lneas del marco +2343=Sin marco +2344=Sombra +2345=Color de fondo +2346=Color del marco +2347=Estilo de lnea +2348=Grosor de lneas +2349=Estandard +2350=Nuevo informe +2351=Abrir informe +2352=Guardar informe +2353=Vista previa +2354=Aadir pgina +2355=Aadir dilogo +2356=Eliminar pgina +2357=Opciones de pgina +2358=Variables +2359=Cortar +2360=Copiar +2361=Pegar +2362=Formato de Copiado +2363=Deshacer +2364=Rehacer +2365=Group +2366=Ungroup +2367=Mostrar rejilla +2368=Alinear a rejilla +2369=Ajustar a rejilla +2370=Acercamiento +2371=Herramientas Extra +2372=Seleccionar herramienta +2373=Arrastrar +2374=Acercamiento +2375=Editar Texto +2376=Formato de copia +2377=Insertar Banda +2378=&Archivo +2379=&Editar +2380=Buscar... +2381=Buscar siguiente +2382=Reemplazar... +2383=&Informe +2384=Datos... +2385=Opciones... +2386=Estilos... +2387=&Ver +2388=Barras de Herramientas +2389=Estandard +2390=Texto +2391=Marco +2392=Paleta de Alineacin +2393=Herramientas Extra +2394=Inspector de Objetos +2395=Arbol de Datos +2396=Arbol del Informe +2397=Reglas +2398=Guias +2399=Eliminar Guias +2400=Opciones... +2401=A&yuda +2402=Contenido de la ayuda... +2403=Sobre FastReport... +2404=Orden de tabulacin... +2405=Deshacer +2406=Rehacer +2407=Cortar +2408=Copiar +2409=Pegar +2410=Agrupar +2411=Desagrupar +2412=Borrar +2413=Eliminar pgina +2414=Seleccionar Todo +2415=Editar... +2416=Traer al frente +2417=Enviar Atrs +2418=Nuevo... +2419=Nuevo informe +2420=Aadir pgina +2421=Aadir dilogo +2422=Abrir... +2423=Guardar +2424=Guardar como... +2425=Variables... +2426=Opciones de pgina... +2427=Vista Previa +2428=Salir +2429=Ttulo del Informe +2430=Sumario del Informe +2431=Cabecera de pgina +2432=Pie de pgina +2433=Cabecera +2434=Pie +2435=Datos maestros +2436=Datos de detalle +2437=Datos de subdetalle +2438=Datos de 4 nivel +2439=Datos de 5 nivel +2440=Datos de 6 nivel +2441=Cabecera de grupo +2442=Pie de grupo +2443=Hija +2444=Cabecera de columna +2445=Pie de columna +2446=Superpuesto +2447=Banda vertical +2448=Cabecera +2449=Pie +2450=Datos maestros +2451=Datos de detalle +2452=Datos de subdetalle +2453=Cabecera de grupo +2454=Pie de grupo +2455=Hija +2456=0 +2457=45 +2458=90 +2459=180 +2460=270 +2461=Opciones de Fuentes +2462=Negrita +2463=Cursiva +2464=Subrayado +2465=SuperScript +2466=SubScript +2467=Condensada +2468=Ancho +2469=12 cpi +2470=15 cpi +2471=Informe (*.fr3)|*.fr3 +2472=Archivos Pascal (*.pas)|*.pas|C++ files (*.cpp)|*.cpp|JavaScript files (*.js)|*.js|Basic files (*.vb)|*.vb|All files|*.* +2473=Archivos Pascal (*.pas)|*.pas|C++ files (*.cpp)|*.cpp|JavaScript files (*.js)|*.js|Basic files (*.vb)|*.vb|All files|*.* +2474=Conexiones... + +2475=Idioma +2476=Toggle breakpoint +2477=Ejecutar hasta el cursor +2478=!Add child band +dsCm=Centmetros +dsInch=Pulgadas +dsPix=Pixeles +dsChars=Caracteres +dsCode=Cdigo +dsData=Data +dsPage=Pgina +dsRepFilter=Informe (*.fr3)|*.fr3 +dsComprRepFilter=Informe Comprimido (*.fr3)|*.fr3 +dsSavePreviewChanges=Guardar los cambios de la vista previa? +dsSaveChangesTo=Guardar cambios en +dsCantLoad=No se puede cargar el archivo +dsStyleFile=Estilo +dsCantFindProc=No se puede localizar el procedimiento principal +dsClearScript=Esto borrarr todo el cdigo Desea continuar? +dsNoStyle=Sin estilo +dsStyleSample=Estilos de ejemplo +dsTextNotFound=Texto '%s' no encontrado +dsReplace=Reemplazar '%s'? +======== TfrxAboutForm ======== +2600=Acerca de FastReport +2601=Para ms informacin, visite: +2602=Ventas: +2603=Soporte: + +======== TfrxPageEditorForm ======== +2700=Opciones de Pgina +2701=Papel +2702=Ancho +2703=Largo +2704=Tamao +2705=Orientacin +2706=Izquierda +2707=Arriba +2708=Derecha +2709=Abajo +2710=Margenes +2711=Origen del Papel +2712=Primera pgina +2713=Otras pginas +2714=Vertical +2715=Horizontal +2716=Otras Opciones +2717=Columnas +2718=Nmero +2719=Ancho +2720=Posiciones +2721=Otros +2722=Duplex +2723=Imprimir la pgina previa +2724=Mrgenes idnticos +2725=Gran altura en modo diseo +2726=Anchura sin fin de la pgina +2727=Altura sin fin en la pgina + +======== TfrxReportDataForm ======== +2800=Seleccionar Datos del Informe + +======== TfrxVarEditorForm ======== +2900=Editar Variables +2901=Categora +2902=Variable +2903=Editar +2904=Borrar +2905=Lista +2906=Abrir +2907=Guardar +2908= Expresin: +2909=Diccionario (*.fd3)|*.fd3 +2910=Diccionario (*.fd3)|*.fd3 + +vaNoVar=(no hay variables definidas) +vaVar=Variables +vaDupName=Nombre Duplicado +======== TfrxOptionsEditor ======== +3000=Opciones del diseador +3001=Rejilla +3002=Tipo +3003=Tamao +3004=Ventana de dilogo: +3005=Otros +3006=Fuentes +3007=Ventana de Cdigo +3008=Editor de Memo +3009=Tamao +3010=Tamao +3011=Colores +3012=Separacin entre bandas: +3013=cm +3014=in +3015=pt +3016=pt +3017=pt +3018=Centimetros: +3019=Pulgadas: +3020=Pixeles: +3021=Mostrar rejilla +3022=Alinear a la Rejilla +3023=Mostrar el editor despus de insertar +3024=Usar las opciones de fuentes +3025=Area de trabajo +3026=Ventana de herramientas +3027=Color LCD en rejilla +3028=Colocacin libre de las bandas +3029=Mostrar lista de campos +3030=Mostrar pantalla de inicio +3031=Valores por defecto +3032=Mostrar el nombre de las bandas + +======== TfrxDataBandEditorForm ======== +3100=Seleccionar DataSet +3101=Nmero de registros: + +dbNotAssigned=[no asignado] +======== TfrxGroupEditorForm ======== +3200=Grupo +3201=Romper en +3202=Opciones +3203=Campo +3204=Expresin +3205=Unir grupos +3206=Empezar con pgina en blanco +3207=Mostrar resumen + +======== TfrxSysMemoEditorForm ======== +3300=Memo de sistema +3301=Banda de Datos +3302=Datos +3303=Campo +3304=Funcin +3305=Expresin +3306=Agregar valor +3307=Variable de Sistema +3308=Contar bandas no visibles +3309=Texto +3310=Ejecutar + +agAggregate=Insertar agregacin +vt1=[FECHA] +vt2=[HORA] +vt3=[PAGINA#] +vt4=[TOTALPAGINAS#] +vt5=[PAGINA#] of [TOTALPAGINAS#] +vt6=[LINEA#] +======== TfrxOleEditorForm ======== +3400=Objeto OLE +3401=Insertar... +3402=Editar... +3403=Cerrar + +olStretched=Ajustado +======== TfrxBarcodeEditorForm ======== +3500=Editor de cdigos de barras +3501=Cdigo +3502=Tipo de Barra +3503=Acercamiento: +3504=Opciones +3505=Rotacin +3506=Verificacin +3507=Texto +3508=0 +3509=90 +3510=180 +3511=270 + +bcCalcChecksum=Verificacin +bcShowText=Mostrar Texto +======== TfrxAliasesEditorForm ======== +3600=Editar Alias +3601=Presionar INTRO para editar el item +3602=Alias de Dataset +3603=Campos de alias +3604=Resetear +3605=Actualizar + +alUserName=Nombre de Usuario +alOriginal=Nombre Original +======== TfrxParamsEditorForm ======== +3700=Editor de Parametros + +qpName=Nombre +qpDataType=Tipo de Dato +qpValue=Valor +======== TfrxMDEditorForm ======== +3800=Union Maestro-Detalle +3801=Campos de Detalle +3802=Campos Maestros +3803=Campos de Unin +3804=Aadir +3805=Borrar + +======== TfrxMemoEditorForm ======== +3900=Memo +3901=Insertar Expresin +3902=Insertar Agregate +3903=Insertar Formateando +3904=Ajuste de palabras +3905=Texto +3906=Formato +3907=Resaltado + +======== TfrxPictureEditorForm ======== +4000=Imagen +4001=Cargar +4002=Copiar +4003=Pegar +4004=Limpiar + +piEmpty=Vaco +======== TfrxChartEditorForm ======== +4100=Editor de caracteres +4101=Aadir Series +4102=Borrar Series +4103=Editar Grfico +4104=Banda origen +4105=Datos fijos +4106=Datos +4107=Data Source +4108=Values +4109=Select the chart series or add a new one. +4114=Otras opciones +4115=Valores TopN +4116=Ttulo TopN +4117=Ordenado +4126=X Axis + +ch3D=Ver en 3D +chAxis=Mostrar ejes +chsoNone=Ninguno +chsoAscending=Ascendente +chsoDescending=Descendente +chxtText=Text +chxtNumber=Numeric +chxtDate=Date +======== TfrxRichEditorForm ======== +4200=Editor de texto enriquecido +4201=Abrir archivo +4202=Guardar en archivo +4203=Deshacer +4204=Fuente +4205=Insertar Expresin +4206=Negrita +4207=Cursiva +4208=Subrayado +4209=Ajuste Izquierda +4210=Centrado +4211=Ajuste derecha +4212=Justificado +4213=Vietas + +======== TfrxCrossEditorForm ======== +4300=Editor de datos cruzados +4301=Datos +4302=Dimensiones +4303=Filas +4304=Columnas +4305=Celdas +4306=Estructura de datos cruzados +4307=Cabecera de fila +4308=Cabecera de columna +4309=Totales de la fila +4310=Totales de la columna +4311=Intercambio filas/columnas +4312=!Select style +4313=!Save current style... +4314=!Show title +4315=!Show corner +4316=!Reprint headers on new page +4317=!Auto size +4318=!Border around cells +4319=!Print down then across +4320=!Side-by-side cells +4321=!Join equal cells +4322=Ninguno +4323=Suma +4324=Minimo +4325=Mximo +4326=Promedio +4327=Contar +4328=Ascendente (A-Z) +4329=Descendente (Z-A) +4330=Ninguno + +crStName=!Enter the style name: +crResize=!To resize a cross-tab, set its "AutoSize" property to False. +crSubtotal=Subtotal +crNone=Ninguno +crSum=Suma +crMin=Mnimo +crMax=Mximo +crAvg=Promedio +crCount=Contar +crAsc=A-Z +crDesc=Z-A +crFillMx=Llenando los datos cruzados... +crBuildMx=Construyendo datos cruzados... +======== TfrxExprEditorForm ======== +4400=Editor de expresiones +4401=Expresin: + +======== TfrxFormatEditorForm ======== +4500=Formato de visualizacin +4501=Categora +4502=Formato +4503=Formato texto: +4504=Separador de decimales: + +fkText=Texto (ninguno) +fkNumber=Nmero +fkDateTime=Fecha/Hora +fkBoolean=Lgico +fkNumber1=1234.5;%g +fkNumber2=1234.50;%2.2f +fkNumber3=1,234.50;%2.2n +fkNumber4=$1,234.50;%2.2m +fkDateTime1=11.28.2002;mm.dd.aaaa +fkDateTime2=28 nov 2002;dd mmm aaaa +fkDateTime3=Noviembre 28, 2002;mmmm dd, aaaa +fkDateTime4=02:14;hh:mm +fkDateTime5=02:14am;hh:mm am/pm +fkDateTime6=02:14:00;hh:mm:ss +fkDateTime7=02:14am, Noviembre 28, 2002;hh:mm am/pm, mmmm dd, aaaa +fkBoolean1=0,1;0,1 +fkBoolean2=No,Si;No,Si +fkBoolean3=_,x;_,x +fkBoolean4=Falso,Verdadero;Falso,Verdadero +======== TfrxHighlightEditorForm ======== +4600=Resaltado +4601=Color... +4602=Color... +4603=Condicin +4604=Fuente +4605=Fondo +4606=Negrita +4607=Cursiva +4608=Subrayado +4609=Transparente +4610=Otros + +======== TfrxReportEditorForm ======== +4700=Opciones del informe +4701=General +4702=Impresora +4703=Copias +4704=General +4705=Contrasea +4706=Copias intercaladas +4707=Doble pasada +4708=Imprimir aunque est en blanco +4709=Descripcin +4710=Nombre +4711=Descripcin +4712=Imagen +4713=Autor +4714=Mayor +4715=Menor +4716=Revisin +4717=Acumulado +4718=Creado +4719=Modificado +4720=Descripcin +4721=Version +4722=Examinar... +4723=Ajustes de la Herencia +4724=Seleccione una Opcin: +4725=Sin cambios +4726=Separar el informe base +4727=Heredar del informe base +4728=Herencia + +rePrnOnPort=en +riNotInherited=No heredar de este informe +riInherited=Este informe se ha heredado de: %s +======== TfrxStringsEditorForm ======== +4800=Lneas + +======== TfrxSQLEditorForm ======== +4900=SQL +4901=Constructor de consultas + +======== TfrxPasswordForm ======== +5000=Contrasea +5001=Introduzca contrasea: + +======== TfrxStyleEditorForm ======== +5100=Editor de Estilos +5101=Color... +5102=Fuente... +5103=Marco... +5104=Aadir +5105=Borrar +5106=Editar +5107=Cargar +5108=Guardar + +======== TfrxFrameEditorForm ======== +5200=Editor de Marcos +5201=Marco +5202=Lnea de Marco +5203=Sombra +5204=Lnea de arriba +5205=Lnea de abajo +5206=Lnea de la izquierda +5207=Lnea de la derecha +5208=Marco completo +5209=Sin marco +5210=Color del marco +5211=Estilo del marco +5212=Grosor de lnea +5213=Sombra +5214=Color de sombra +5215=Grosor de la sombra + +======== TfrxNewItemForm ======== +5300=Nuevo elemento +5301=Elementos +5302=Plantillas +5303=Heredar el informe + +======== TfrxTabOrderEditorForm ======== +5400=Orden de edicin +5401=Lista de Controles: +5402=Arriba +5403=Abajo + +======== TfrxEvaluateForm ======== +5500=Evaluar +5501=Expresin +5502=Resultado + +======== TfrxStdWizardForm ======== +5600=Asistente de informes +5601=Datos +5602=Campos +5603=Grupos +5604=Disposicin +5605=Estilo +5606=Paso 1. Seleccionar los Datos. +5607=Paso 2. Seleccionar los campos que se mostrarn. +5608=Paso 3. Crear grupos (opcional). +5609=Paso 4. Definir la orientacin de pgina y la disposicin de los datos. +5610=Paso 5. Escoger el estilo del informe. +5611=Aadir > +5612=Aadir todos >> +5613=< Quitar +5614=<< Quitar todos +5615=Aadir > +5616=< Quitar +5617=Seleccionar campos: +5618=Campos disponibles: +5619=Grupos: +5620=Orientacin +5621=Disposicin +5622=Vertical +5623=Horizontal +5624=Datos tabulados +5625=En Columnas +5626=Ajustar los campos a la anchura de pgina +5627=Atrs +5628=Siguiente +5629=Finalizar +5630=Nueva tabla... +5631=Nueva consulta... +5632=Seleccionar la base de datos: +5633=Seleccionar una tabla: +5634=o +5635=Crear una consulta... +5636=Configurar la conexin + +wzStd=Asistente para Informes Estandard +wzDMP=Asistente para Informes en Matricial +wzStdEmpty=Informe Estandard +wzDMPEmpty=Informe para Matricial +======== TfrxConnectionWizardForm ======== +5700=Asistente de Conexin +5701=Conexin +5702=Escoger el tipo de conexin: +5703=Escoger la base de datos: +5704=Usuario +5705=Contrasea +5706=Pedir Usuario +5707=Usar Usuario/contrasea: +5708=Tabla +5709=Escoger nombre de tabla: +5710=Filtrar registros: +5711=Consulta +5712=Sentencia SQL: +5713=Constructor de Consultas +5714=Editar los Parmetros de la Consulta + +ftAllFiles=Todos los archivos +ftPictures=Imgenes +ftDB=Bases de datos +ftRichFile=Texto enriquecido +ftTextFile=Archivo de texto +prNotAssigned=(No asignado) +prInvProp=Valor no vlido +prDupl=Nombre Duplicado +prPict=(Imagen) +mvExpr=Permitir Expresiones +mvStretch=Ajustado +mvStretchToMax=Ajustar al ancho mximo +mvShift=Cambiao +mvShiftOver=Shift When Overlapped +mvVisible=Visible +mvPrintable=Imprimible +mvFont=Fuente... +mvFormat=Formato de visualizacin... +mvClear=Borrar Contenido +mvAutoWidth=Ancho Automtico +mvWWrap=Ajuste de palabras +mvSuppress=Suprimir Valores Repetidos +mvHideZ=Ocultar ceros +mvHTML=Permitir etiquetas HTML +lvDiagonal=Diagonal +pvAutoSize=Tamao Automtico +pvCenter=Centrado +pvAspect=Conservar el aspecto +bvSplit=Permitir separacin +bvKeepChild=Conservar junto al hijo +bvPrintChild=Imprimir Hija si Invisible +bvStartPage=Iniciar pgina nueva +bvPrintIfEmpty=Imprimir si Detalle Vaco +bvKeepDetail=Conservar Junto al Detalle +bvKeepFooter=Conservar Junto a su Pie +bvReprint=Reimprimir en Nueva Pgina +bvOnFirst=Imprimir en Primera Pgina +bvOnLast=Imprimir En Ultima Pgina +bvKeepGroup=Conservar Junto +bvFooterAfterEach=Pi despus de cada fila +bvDrillDown=Perforar-Abajo +bvResetPageNo=Reinicializa el nmero de Pginas +srParent=Imprimir en el Padre +obCatDraw=Arrastrar +obCatOther=Otros objetos +obCatOtherControls=Otros controles +obDiagLine=Lnea Diagonal +obRect=Rectangulo +obRoundRect=Rectngulo Redondeado +obEllipse=Elipse +obTrian=Triangulo +obDiamond=Diamante +obLabel=Etiqueta +obEdit=Control de Edicin +obMemoC=Memo +obButton=Botn +obChBoxC=Casilla de verificacin +obRButton=Botn de opcin +obLBox=Cuadro de Lista +obCBox=Cuadro Combinado +obDateEdit=Editor de Fechas +obImageC=Imagen +obPanel=Panel +obGrBox=Grupo de opciones +obBBtn=Botn con imagen +obSBtn=Botn de men +obMEdit=Editor con Formato +obChLB=Lista de verificacin +obDBLookup=Lista de seleccin de datos +obBevel=Biselado +obShape=Dibujo +obText=Texto +obSysText=Texto de Sistema +obLine=Lnea +obPicture=Imagen +obBand=Banda +obDataBand=Banda de Datos +obSubRep=SubInforme +obDlgPage=Dilogo +obRepPage=Pgina +obReport=Informe +obRich=Texto enriquecido +obOLE=Objeto OLE +obChBox=Casilla de verificacin +obChart=Grfico +obBarC=Cdigo de Barras +obCross=Informe cruzado +obDBCross=Datos cruzados +obGrad=Gradiente +obDMPText=Texto para Matricial +obDMPLine=Lnea para Matricial +obDMPCmd=Dot-matrix Command object +obBDEDB=Base de Datos BDE +obBDETb=Tabla BDE +obBDEQ=Consulta BDE +obBDEComps=Componentes BDE +obIBXDB=Base de Datos IBX +obIBXTb=Tabla IBX +obIBXQ=Consulta IBX +obIBXComps=Componentes IBX +obADODB=Base de Datos ADO +obADOTb=Tabla ADO +obADOQ=Consulta ADO +obADOComps=Componentes ADO +obDBXDB=Base de Datos DBX +obDBXTb=Tabla DBX +obDBXQ=Consulta DBX +obDBXComps=Componentes DBX +obFIBDB=FIB Database +obFIBTb=FIB Table +obFIBQ=FIB Query +obFIBComps=FIB Components +ctString=Texto +ctDate=Fecha y Hora +ctConv=Conversiones +ctFormat=Formato +ctMath=Matemticas +ctOther=Otros +IntToStr=Convertir un valor numrico entero en cadena alfanumrica +FloatToStr=Convierte un valor decimal en cadena alfanumrica +DateToStr=Convierte una fecha en cadena alfanumrica +TimeToStr=Convierte un valor de hora en cadena alfanumrica +DateTimeToStr=Convierte un valor fecha y hora en una cadena alfanumrica +VarToStr=Convierte un valor variable en una cadena alfanumrica +StrToInt=Convierte una cadena alfanumrica en un valor numrico entero +StrToInt64=Converts a string to an Int64 value +StrToFloat=Convierte una cadena alfanumrica en un valor decimal +StrToDate=Convierte una cadena alfanumrica en fecha +StrToTime=Convierte una cadena alfanumrica en hora +StrToDateTime=Convierte una cadena alfanumrica en fecha/hora +Format=Aplica una mscara a un array de argumentos y devuelve una cadena formateada +FormatFloat=Aplica un formato a un valor decimal +FormatDateTime=Aplica un formato a un valor de Fecha/Hora +FormatMaskText=Devuelve una cadena alfanumrica formateada +EncodeDate=Devuelve la fecha del Ao, Mes y Da especificados +DecodeDate=Descompone una fecha especificada en el Ao, Mes y Da +EncodeTime=Devuelve la hora para la Horas, Minutos, Segundos y Milidegundos +DecodeTime=Descompone la hora en Horas, Minutos, Segundos y Milisegundos +Date=Devuelve la fecha actual +Time=Devuelve la hora actual +Now=Devuelve la fecha y la hora actual +DayOfWeek=Devuelve el da de la semana de una fecha especificada +IsLeapYear=Indica si el ao especificado es bisiesto +DaysInMonth=Devuelve el nmero de das de un ms especificado +Length=Devuelve la longitud de una cadena alfanumrica +Copy=Devuelve una subcadena dentro de una cadena alfanumrica +Pos=Devuelve la posicin de una subcadena dentro de una cadena alfanumrica +Delete=Borra una subcadena de una cadena alfanumrica +Insert=Inserta una subcadena en una cadena alfanumrica +Uppercase=Convierte todos los caracteres de una cadena en maysculas +Lowercase=Convierte todos los caracteres de una cadena en minsculas +Trim=Descarta todos los espacios en blanco de una cadena +NameCase=Convierte el primer caracter de cada palabra de una cadena en mayscula. El resto lo pasa a minscula +CompareText=Compara dos Cadenas alfanumricas +Chr=Convierte valor numrico entero a caracter +Ord=Convierte un caracter en un valor numrico entero +SetLength=Establece la longitud para una cadena alfanumrica +Round=Redondea un valor decimal +Trunc=Trunca un valor decimal +Int=Devuelve la parte entera de un valor decimal +Frac=Devuelve la parte decimal de un valor decimal +Sqrt=Devuelve la raiz cuadrada del nmero especificado +Abs=Devuelve el valor absoluto +Sin=Devuelve el Seno de un ngulo (en radianes) +Cos=Devuelve el Coseno de un ngulo (en radianes) +ArcTan=Devuelve la ArcoTangente +Tan=Devuelve la Tangente +Exp=Devuelve el Exponencial +Ln=Returns the natural log of a real expression +Pi=Devuelve 3.1415926... +Inc=Incrementa un valor +Dec=Decrementa un valor +RaiseException=Lanza una excepcin +ShowMessage=Mostrar mensajes +Randomize=Inicializar el generador de nmeros aleatorios +Random=Devuelve un nmero aleatorio +ValidInt=Devuelve Verdadero si la cadena alfanumrica especificada contiene un nmero entero vlido +ValidFloat=Devuelve Verdadero si la cadena alfanumrica especificada contiene un nmero decimal vlido +ValidDate=Devuelve Verdadero si la cadena alfanumrica especificada contiene una fecha vlida +IIF=Devuelve el valor1 si la expresin es verdadera. En caso contrario devuelve el valor2 +Get=Solo para uso interno +Set=Solo para uso interno +InputBox=Muestra una ventana de dilogo para que el usuario introduzca una cadena +InputQuery=Muestra una ventana de dilogo para que el usuario introduzca una cadena +MessageDlg=Muestra una ventana con un mensaje +CreateOleObject=Crea un objeto OLE +VarArrayCreate=Crea un array de variantes +VarType=Devuelve el tipo de valor contenido en un variante +ctAggregate=Agregacin +Sum=Calcula la suma de para una banda de datos +Avg=Calcula la media de para una banda de datos +Min=Calcula el mnimo de para una banda de datos +Max=Calcula el mximo de para una banda de datos +Count=Calcula el nmero de filas de datos +wzDBConn=Nuevo Asistente de Conexin +wzDBTable=Nuevo Asistente de Tabla +wzDBQuery=Nuevo Asistente de Consulta +DayOf=Devuelve el nmero del da (1..31) de la fecha pasada +MonthOf=Devuelve el nmero del mes (1..12) de la fecha pasada +YearOf=Devuelve el ao de la fecha pasada +bvKeepHeader=Conservar Junto a la Cabecera +======== TfrxConnEditorForm ======== +5800=Conexiones +5801=Nuevo +5802=Borrar + +cpName=Nombre +cpConnStr=Cadena para la Conexin +startCreateNew=Crear un nuevo informe +startCreateBlank=Crear un informe en blanco +startOpenReport=Abrir un Informe +startOpenLast=Abrir el ltimo informe +startEditAliases=Editar Alias de la Conexin +startHelp=Ayuda + +======== TfrxWatchForm ======== +5900=Relojes +5901=Aadir reloj +5902=Borrar reloj +5903=Editar Reloj + +======== TfrxInheritErrorForm ======== +6000=Error al Heredar +6001=Los informes Base y el Heredado tienen objetos duplicados. Que debemos hacer ? +6002=Borrar duplicados +6003=Renombrar duplicados diff --git a/official/4.2/LibD11/frxrcDesgn.pas b/official/4.2/LibD11/frxrcDesgn.pas new file mode 100644 index 0000000..b15ea3c --- /dev/null +++ b/official/4.2/LibD11/frxrcDesgn.pas @@ -0,0 +1,946 @@ +{******************************************} +{ } +{ FastReport v4.0 } +{ Language resource file } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxrcDesgn; + +interface + +implementation + +uses frxRes; + +const resStr = +'======== TfrxObjectInspector ========' + #13#10 + +'2000=Inspector de Objetos' + #13#10 + +'' + #13#10 + +'oiProp=Propiedades' + #13#10 + +'oiEvent=Eventos' + #13#10 + +'======== TfrxDataTreeForm ========' + #13#10 + +'2100=Arbol de datos' + #13#10 + +'2101=Datos' + #13#10 + +'2102=Variables' + #13#10 + +'2103=Funciones' + #13#10 + +'2104=Crear campo' + #13#10 + +'2105=Crear ttulo' + #13#10 + +'2106=Clases' + #13#10 + +'' + #13#10 + +'dtNoData=Datos no disponibles' + #13#10 + +'dtNoData1=Ir a "Informe/Datos..." menu para aadir orgenes de datos existentes a tu informe, o desde la ventana Datos crear nuevos orgenes de datos' + #13#10 + +'dtData=Datos' + #13#10 + +'dtSysVar=Variables de sistema' + #13#10 + +'dtVar=Variables' + #13#10 + +'dtFunc=Funciones' + #13#10 + +'======== TfrxReportTreeForm ========' + #13#10 + +'2200=Indice del informe' + #13#10 + +'' + #13#10 + +'======== TfrxDesignerForm ========' + #13#10 + +'2300=Abrir archivo de script' + #13#10 + +'2301=Guardar Script en archivo' + #13#10 + +'2302=Ejecutar Script' + #13#10 + +'2303=Depurar en' + #13#10 + +'2304=Terminar Script' + #13#10 + +'2305=Evaluar' + #13#10 + +'2306=Lenguaje:' + #13#10 + +'2307=Alineacin' + #13#10 + +'2308=Alinear al borde Izquierdo' + #13#10 + +'2309=Alinear al centro' + #13#10 + +'2310=Alinear a la derecha' + #13#10 + +'2311=Alinear arriba' + #13#10 + +'2312=Alinear al Centro' + #13#10 + +'2313=Alinear Abajo' + #13#10 + +'2314=Mismo espacio horizontal' + #13#10 + +'2315=Mismo espacio vertical' + #13#10 + +'2316=Centrar horizontalmente en la banda' + #13#10 + +'2317=Centrar Verticalmente en la banda' + #13#10 + +'2318=Mismo ancho' + #13#10 + +'2319=Mismo largo' + #13#10 + +'2320=Texto' + #13#10 + +'2321=Estilo' + #13#10 + +'2322=Fuente' + #13#10 + +'2323=Tamao' + #13#10 + +'2324=Negrita' + #13#10 + +'2325=Cursiva' + #13#10 + +'2326=Subrayado' + #13#10 + +'2327=Color' + #13#10 + +'2328=Resaltar' + #13#10 + +'2329=Rotacin del Texto' + #13#10 + +'2330=Ajuste izquierda' + #13#10 + +'2331=Centrado' + #13#10 + +'2332=Ajuste derecha' + #13#10 + +'2333=Justificado' + #13#10 + +'2334=Ajuste arriba' + #13#10 + +'2335=Centrado' + #13#10 + +'2336=Ajuste abajo' + #13#10 + +'2337=Marco' + #13#10 + +'2338=Lnea de arriba del marco' + #13#10 + +'2339=Lnea de abajo del marco' + #13#10 + +'2340=Lnea izquierda del marco' + #13#10 + +'2341=Lnea derecha del marco' + #13#10 + +'2342=Todas las lneas del marco' + #13#10 + +'2343=Sin marco' + #13#10 + +'2344=Sombra' + #13#10 + +'2345=Color de fondo' + #13#10 + +'2346=Color del marco' + #13#10 + +'2347=Estilo de lnea' + #13#10 + +'2348=Grosor de lneas' + #13#10 + +'2349=Estandard' + #13#10 + +'2350=Nuevo informe' + #13#10 + +'2351=Abrir informe' + #13#10 + +'2352=Guardar informe' + #13#10 + +'2353=Vista previa' + #13#10 + +'2354=Aadir pgina' + #13#10 + +'2355=Aadir dilogo' + #13#10 + +'2356=Eliminar pgina' + #13#10 + +'2357=Opciones de pgina' + #13#10 + +'2358=Variables' + #13#10 + +'2359=Cortar' + #13#10 + +'2360=Copiar' + #13#10 + +'2361=Pegar' + #13#10 + +'2362=Formato de Copiado' + #13#10 + +'2363=Deshacer' + #13#10 + +'2364=Rehacer' + #13#10 + +'2365=Group' + #13#10 + +'2366=Ungroup' + #13#10 + +'2367=Mostrar rejilla' + #13#10 + +'2368=Alinear a rejilla' + #13#10 + +'2369=Ajustar a rejilla' + #13#10 + +'2370=Acercamiento' + #13#10 + +'2371=Herramientas Extra' + #13#10 + +'2372=Seleccionar herramienta' + #13#10 + +'2373=Arrastrar' + #13#10 + +'2374=Acercamiento' + #13#10 + +'2375=Editar Texto' + #13#10 + +'2376=Formato de copia' + #13#10 + +'2377=Insertar Banda' + #13#10 + +'2378=&Archivo' + #13#10 + +'2379=&Editar' + #13#10 + +'2380=Buscar...' + #13#10 + +'2381=Buscar siguiente' + #13#10 + +'2382=Reemplazar...' + #13#10 + +'2383=&Informe' + #13#10 + +'2384=Datos...' + #13#10 + +'2385=Opciones...' + #13#10 + +'2386=Estilos...' + #13#10 + +'2387=&Ver' + #13#10 + +'2388=Barras de Herramientas' + #13#10 + +'2389=Estandard' + #13#10 + +'2390=Texto' + #13#10 + +'2391=Marco' + #13#10 + +'2392=Paleta de Alineacin' + #13#10 + +'2393=Herramientas Extra' + #13#10 + +'2394=Inspector de Objetos' + #13#10 + +'2395=Arbol de Datos' + #13#10 + +'2396=Arbol del Informe' + #13#10 + +'2397=Reglas' + #13#10 + +'2398=Guias' + #13#10 + +'2399=Eliminar Guias' + #13#10 + +'2400=Opciones...' + #13#10 + +'2401=A&yuda' + #13#10 + +'2402=Contenido de la ayuda...' + #13#10 + +'2403=Sobre FastReport...' + #13#10 + +'2404=Orden de tabulacin...' + #13#10 + +'2405=Deshacer' + #13#10 + +'2406=Rehacer' + #13#10 + +'2407=Cortar' + #13#10 + +'2408=Copiar' + #13#10 + +'2409=Pegar' + #13#10 + +'2410=Agrupar' + #13#10 + +'2411=Desagrupar' + #13#10 + +'2412=Borrar' + #13#10 + +'2413=Eliminar pgina' + #13#10 + +'2414=Seleccionar Todo' + #13#10 + +'2415=Editar...' + #13#10 + +'2416=Traer al frente' + #13#10 + +'2417=Enviar Atrs' + #13#10 + +'2418=Nuevo...' + #13#10 + +'2419=Nuevo informe' + #13#10 + +'2420=Aadir pgina' + #13#10 + +'2421=Aadir dilogo' + #13#10 + +'2422=Abrir...' + #13#10 + +'2423=Guardar' + #13#10 + +'2424=Guardar como...' + #13#10 + +'2425=Variables...' + #13#10 + +'2426=Opciones de pgina...' + #13#10 + +'2427=Vista Previa' + #13#10 + +'2428=Salir' + #13#10 + +'2429=Ttulo del Informe' + #13#10 + +'2430=Sumario del Informe' + #13#10 + +'2431=Cabecera de pgina' + #13#10 + +'2432=Pie de pgina' + #13#10 + +'2433=Cabecera' + #13#10 + +'2434=Pie' + #13#10 + +'2435=Datos maestros' + #13#10 + +'2436=Datos de detalle' + #13#10 + +'2437=Datos de subdetalle' + #13#10 + +'2438=Datos de 4 nivel' + #13#10 + +'2439=Datos de 5 nivel' + #13#10 + +'2440=Datos de 6 nivel' + #13#10 + +'2441=Cabecera de grupo' + #13#10 + +'2442=Pie de grupo' + #13#10 + +'2443=Hija' + #13#10 + +'2444=Cabecera de columna' + #13#10 + +'2445=Pie de columna' + #13#10 + +'2446=Superpuesto' + #13#10 + +'2447=Banda vertical' + #13#10 + +'2448=Cabecera' + #13#10 + +'2449=Pie' + #13#10 + +'2450=Datos maestros' + #13#10 + +'2451=Datos de detalle' + #13#10 + +'2452=Datos de subdetalle' + #13#10 + +'2453=Cabecera de grupo' + #13#10 + +'2454=Pie de grupo' + #13#10 + +'2455=Hija' + #13#10 + +'2456=0' + #13#10 + +'2457=45' + #13#10 + +'2458=90' + #13#10 + +'2459=180' + #13#10 + +'2460=270' + #13#10 + +'2461=Opciones de Fuentes' + #13#10 + +'2462=Negrita' + #13#10 + +'2463=Cursiva' + #13#10 + +'2464=Subrayado' + #13#10 + +'2465=SuperScript' + #13#10 + +'2466=SubScript' + #13#10 + +'2467=Condensada' + #13#10 + +'2468=Ancho' + #13#10 + +'2469=12 cpi' + #13#10 + +'2470=15 cpi' + #13#10 + +'2471=Informe (*.fr3)|*.fr3' + #13#10 + +'2472=Archivos Pascal (*.pas)|*.pas|C++ files (*.cpp)|*.cpp|JavaScript files (*.js)|*.js|Basic files (*.vb)|*.vb|All files|*.*' + #13#10 + +'2473=Archivos Pascal (*.pas)|*.pas|C++ files (*.cpp)|*.cpp|JavaScript files (*.js)|*.js|Basic files (*.vb)|*.vb|All files|*.*' + #13#10 + +'2474=Conexiones...' + #13#10 + +'' + #13#10 + +'2475=Idioma' + #13#10 + +'2476=Toggle breakpoint' + #13#10 + +'2477=Ejecutar hasta el cursor' + #13#10 + +'2478=!Add child band' + #13#10 + +'dsCm=Centmetros' + #13#10 + +'dsInch=Pulgadas' + #13#10 + +'dsPix=Pixeles' + #13#10 + +'dsChars=Caracteres' + #13#10 + +'dsCode=Cdigo' + #13#10 + +'dsData=Data' + #13#10 + +'dsPage=Pgina' + #13#10 + +'dsRepFilter=Informe (*.fr3)|*.fr3' + #13#10 + +'dsComprRepFilter=Informe Comprimido (*.fr3)|*.fr3' + #13#10 + +'dsSavePreviewChanges=Guardar los cambios de la vista previa?' + #13#10 + +'dsSaveChangesTo=Guardar cambios en' + #13#10 + +'dsCantLoad=No se puede cargar el archivo' + #13#10 + +'dsStyleFile=Estilo' + #13#10 + +'dsCantFindProc=No se puede localizar el procedimiento principal' + #13#10 + +'dsClearScript=Esto borrarr todo el cdigo Desea continuar?' + #13#10 + +'dsNoStyle=Sin estilo' + #13#10 + +'dsStyleSample=Estilos de ejemplo' + #13#10 + +'dsTextNotFound=Texto ''%s'' no encontrado' + #13#10 + +'dsReplace=Reemplazar ''%s''?' + #13#10 + +'======== TfrxAboutForm ========' + #13#10 + +'2600=Acerca de FastReport' + #13#10 + +'2601=Para ms informacin, visite:' + #13#10 + +'2602=Ventas:' + #13#10 + +'2603=Soporte:' + #13#10 + +'' + #13#10 + +'======== TfrxPageEditorForm ========' + #13#10 + +'2700=Opciones de Pgina' + #13#10 + +'2701=Papel' + #13#10 + +'2702=Ancho' + #13#10 + +'2703=Largo' + #13#10 + +'2704=Tamao' + #13#10 + +'2705=Orientacin' + #13#10 + +'2706=Izquierda' + #13#10 + +'2707=Arriba' + #13#10 + +'2708=Derecha' + #13#10 + +'2709=Abajo' + #13#10 + +'2710=Margenes' + #13#10 + +'2711=Origen del Papel' + #13#10 + +'2712=Primera pgina' + #13#10 + +'2713=Otras pginas' + #13#10 + +'2714=Vertical' + #13#10 + +'2715=Horizontal' + #13#10 + +'2716=Otras Opciones' + #13#10 + +'2717=Columnas' + #13#10 + +'2718=Nmero' + #13#10 + +'2719=Ancho' + #13#10 + +'2720=Posiciones' + #13#10 + +'2721=Otros' + #13#10 + +'2722=Duplex' + #13#10 + +'2723=Imprimir la pgina previa' + #13#10 + +'2724=Mrgenes idnticos' + #13#10 + +'2725=Gran altura en modo diseo' + #13#10 + +'2726=Anchura sin fin de la pgina' + #13#10 + +'2727=Altura sin fin en la pgina' + #13#10 + +'' + #13#10 + +'======== TfrxReportDataForm ========' + #13#10 + +'2800=Seleccionar Datos del Informe' + #13#10 + +'' + #13#10 + +'======== TfrxVarEditorForm ========' + #13#10 + +'2900=Editar Variables' + #13#10 + +'2901=Categora' + #13#10 + +'2902=Variable' + #13#10 + +'2903=Editar' + #13#10 + +'2904=Borrar' + #13#10 + +'2905=Lista' + #13#10 + +'2906=Abrir' + #13#10 + +'2907=Guardar' + #13#10 + +'2908= Expresin:' + #13#10 + +'2909=Diccionario (*.fd3)|*.fd3' + #13#10 + +'2910=Diccionario (*.fd3)|*.fd3' + #13#10 + +'' + #13#10 + +'vaNoVar=(no hay variables definidas)' + #13#10 + +'vaVar=Variables' + #13#10 + +'vaDupName=Nombre Duplicado' + #13#10 + +'======== TfrxOptionsEditor ========' + #13#10 + +'3000=Opciones del diseador' + #13#10 + +'3001=Rejilla' + #13#10 + +'3002=Tipo' + #13#10 + +'3003=Tamao' + #13#10 + +'3004=Ventana de dilogo:' + #13#10 + +'3005=Otros' + #13#10 + +'3006=Fuentes' + #13#10 + +'3007=Ventana de Cdigo' + #13#10 + +'3008=Editor de Memo' + #13#10 + +'3009=Tamao' + #13#10 + +'3010=Tamao' + #13#10 + +'3011=Colores' + #13#10 + +'3012=Separacin entre bandas:' + #13#10 + +'3013=cm' + #13#10 + +'3014=in' + #13#10 + +'3015=pt' + #13#10 + +'3016=pt' + #13#10 + +'3017=pt' + #13#10 + +'3018=Centimetros:' + #13#10 + +'3019=Pulgadas:' + #13#10 + +'3020=Pixeles:' + #13#10 + +'3021=Mostrar rejilla' + #13#10 + +'3022=Alinear a la Rejilla' + #13#10 + +'3023=Mostrar el editor despus de insertar' + #13#10 + +'3024=Usar las opciones de fuentes' + #13#10 + +'3025=Area de trabajo' + #13#10 + +'3026=Ventana de herramientas' + #13#10 + +'3027=Color LCD en rejilla' + #13#10 + +'3028=Colocacin libre de las bandas' + #13#10 + +'3029=Mostrar lista de campos' + #13#10 + +'3030=Mostrar pantalla de inicio' + #13#10 + +'3031=Valores por defecto' + #13#10 + +'3032=Mostrar el nombre de las bandas' + #13#10 + +'' + #13#10 + +'======== TfrxDataBandEditorForm ========' + #13#10 + +'3100=Seleccionar DataSet' + #13#10 + +'3101=Nmero de registros:' + #13#10 + +'' + #13#10 + +'dbNotAssigned=[no asignado]' + #13#10 + +'======== TfrxGroupEditorForm ========' + #13#10 + +'3200=Grupo' + #13#10 + +'3201=Romper en' + #13#10 + +'3202=Opciones' + #13#10 + +'3203=Campo' + #13#10 + +'3204=Expresin' + #13#10 + +'3205=Unir grupos' + #13#10 + +'3206=Empezar con pgina en blanco' + #13#10 + +'3207=Mostrar resumen' + #13#10 + +'' + #13#10 + +'======== TfrxSysMemoEditorForm ========' + #13#10 + +'3300=Memo de sistema' + #13#10 + +'3301=Banda de Datos' + #13#10 + +'3302=Datos' + #13#10 + +'3303=Campo' + #13#10 + +'3304=Funcin' + #13#10 + +'3305=Expresin' + #13#10 + +'3306=Agregar valor' + #13#10 + +'3307=Variable de Sistema' + #13#10 + +'3308=Contar bandas no visibles' + #13#10 + +'3309=Texto' + #13#10 + +'3310=Ejecutar' + #13#10 + +'' + #13#10 + +'agAggregate=Insertar agregacin' + #13#10 + +'vt1=[FECHA]' + #13#10 + +'vt2=[HORA]' + #13#10 + +'vt3=[PAGINA#]' + #13#10 + +'vt4=[TOTALPAGINAS#]' + #13#10 + +'vt5=[PAGINA#] of [TOTALPAGINAS#]' + #13#10 + +'vt6=[LINEA#]' + #13#10 + +'======== TfrxOleEditorForm ========' + #13#10 + +'3400=Objeto OLE' + #13#10 + +'3401=Insertar...' + #13#10 + +'3402=Editar...' + #13#10 + +'3403=Cerrar' + #13#10 + +'' + #13#10 + +'olStretched=Ajustado' + #13#10 + +'======== TfrxBarcodeEditorForm ========' + #13#10 + +'3500=Editor de cdigos de barras' + #13#10 + +'3501=Cdigo' + #13#10 + +'3502=Tipo de Barra' + #13#10 + +'3503=Acercamiento:' + #13#10 + +'3504=Opciones' + #13#10 + +'3505=Rotacin' + #13#10 + +'3506=Verificacin' + #13#10 + +'3507=Texto' + #13#10 + +'3508=0' + #13#10 + +'3509=90' + #13#10 + +'3510=180' + #13#10 + +'3511=270' + #13#10 + +'' + #13#10 + +'bcCalcChecksum=Verificacin' + #13#10 + +'bcShowText=Mostrar Texto' + #13#10 + +'======== TfrxAliasesEditorForm ========' + #13#10 + +'3600=Editar Alias' + #13#10 + +'3601=Presionar INTRO para editar el item' + #13#10 + +'3602=Alias de Dataset' + #13#10 + +'3603=Campos de alias' + #13#10 + +'3604=Resetear' + #13#10 + +'3605=Actualizar' + #13#10 + +'' + #13#10 + +'alUserName=Nombre de Usuario' + #13#10 + +'alOriginal=Nombre Original' + #13#10 + +'======== TfrxParamsEditorForm ========' + #13#10 + +'3700=Editor de Parametros' + #13#10 + +'' + #13#10 + +'qpName=Nombre' + #13#10 + +'qpDataType=Tipo de Dato' + #13#10 + +'qpValue=Valor' + #13#10 + +'======== TfrxMDEditorForm ========' + #13#10 + +'3800=Union Maestro-Detalle' + #13#10 + +'3801=Campos de Detalle' + #13#10 + +'3802=Campos Maestros' + #13#10 + +'3803=Campos de Unin' + #13#10 + +'3804=Aadir' + #13#10 + +'3805=Borrar' + #13#10 + +'' + #13#10 + +'======== TfrxMemoEditorForm ========' + #13#10 + +'3900=Memo' + #13#10 + +'3901=Insertar Expresin' + #13#10 + +'3902=Insertar Agregate' + #13#10 + +'3903=Insertar Formateando' + #13#10 + +'3904=Ajuste de palabras' + #13#10 + +'3905=Texto' + #13#10 + +'3906=Formato' + #13#10 + +'3907=Resaltado' + #13#10 + +'' + #13#10 + +'======== TfrxPictureEditorForm ========' + #13#10 + +'4000=Imagen' + #13#10 + +'4001=Cargar' + #13#10 + +'4002=Copiar' + #13#10 + +'4003=Pegar' + #13#10 + +'4004=Limpiar' + #13#10 + +'' + #13#10 + +'piEmpty=Vaco' + #13#10 + +'======== TfrxChartEditorForm ========' + #13#10 + +'4100=Editor de caracteres' + #13#10 + +'4101=Aadir Series' + #13#10 + +'4102=Borrar Series' + #13#10 + +'4103=Editar Grfico' + #13#10 + +'4104=Banda origen' + #13#10 + +'4105=Datos fijos' + #13#10 + +'4106=Datos' + #13#10 + +'4107=Data Source' + #13#10 + +'4108=Values' + #13#10 + +'4109=Select the chart series or add a new one.' + #13#10 + +'4114=Otras opciones' + #13#10 + +'4115=Valores TopN' + #13#10 + +'4116=Ttulo TopN' + #13#10 + +'4117=Ordenado' + #13#10 + +'4126=X Axis' + #13#10 + +'' + #13#10 + +'ch3D=Ver en 3D' + #13#10 + +'chAxis=Mostrar ejes' + #13#10 + +'chsoNone=Ninguno' + #13#10 + +'chsoAscending=Ascendente' + #13#10 + +'chsoDescending=Descendente' + #13#10 + +'chxtText=Text' + #13#10 + +'chxtNumber=Numeric' + #13#10 + +'chxtDate=Date' + #13#10 + +'======== TfrxRichEditorForm ========' + #13#10 + +'4200=Editor de texto enriquecido' + #13#10 + +'4201=Abrir archivo' + #13#10 + +'4202=Guardar en archivo' + #13#10 + +'4203=Deshacer' + #13#10 + +'4204=Fuente' + #13#10 + +'4205=Insertar Expresin' + #13#10 + +'4206=Negrita' + #13#10 + +'4207=Cursiva' + #13#10 + +'4208=Subrayado' + #13#10 + +'4209=Ajuste Izquierda' + #13#10 + +'4210=Centrado' + #13#10 + +'4211=Ajuste derecha' + #13#10 + +'4212=Justificado' + #13#10 + +'4213=Vietas' + #13#10 + +'' + #13#10 + +'======== TfrxCrossEditorForm ========' + #13#10 + +'4300=Editor de datos cruzados' + #13#10 + +'4301=Datos' + #13#10 + +'4302=Dimensiones' + #13#10 + +'4303=Filas' + #13#10 + +'4304=Columnas' + #13#10 + +'4305=Celdas' + #13#10 + +'4306=Estructura de datos cruzados' + #13#10 + +'4307=Cabecera de fila' + #13#10 + +'4308=Cabecera de columna' + #13#10 + +'4309=Totales de la fila' + #13#10 + +'4310=Totales de la columna' + #13#10 + +'4311=Intercambio filas/columnas' + #13#10 + +'4312=!Select style' + #13#10 + +'4313=!Save current style...' + #13#10 + +'4314=!Show title' + #13#10 + +'4315=!Show corner' + #13#10 + +'4316=!Reprint headers on new page' + #13#10 + +'4317=!Auto size' + #13#10 + +'4318=!Border around cells' + #13#10 + +'4319=!Print down then across' + #13#10 + +'4320=!Side-by-side cells' + #13#10 + +'4321=!Join equal cells' + #13#10 + +'4322=Ninguno' + #13#10 + +'4323=Suma' + #13#10 + +'4324=Minimo' + #13#10 + +'4325=Mximo' + #13#10 + +'4326=Promedio' + #13#10 + +'4327=Contar' + #13#10 + +'4328=Ascendente (A-Z)' + #13#10 + +'4329=Descendente (Z-A)' + #13#10 + +'4330=Ninguno' + #13#10 + +'' + #13#10 + +'crStName=!Enter the style name:' + #13#10 + +'crResize=!To resize a cross-tab, set its "AutoSize" property to False.' + #13#10 + +'crSubtotal=Subtotal' + #13#10 + +'crNone=Ninguno' + #13#10 + +'crSum=Suma' + #13#10 + +'crMin=Mnimo' + #13#10 + +'crMax=Mximo' + #13#10 + +'crAvg=Promedio' + #13#10 + +'crCount=Contar' + #13#10 + +'crAsc=A-Z' + #13#10 + +'crDesc=Z-A' + #13#10 + +'crFillMx=Llenando los datos cruzados...' + #13#10 + +'crBuildMx=Construyendo datos cruzados...' + #13#10 + +'======== TfrxExprEditorForm ========' + #13#10 + +'4400=Editor de expresiones' + #13#10 + +'4401=Expresin:' + #13#10 + +'' + #13#10 + +'======== TfrxFormatEditorForm ========' + #13#10 + +'4500=Formato de visualizacin' + #13#10 + +'4501=Categora' + #13#10 + +'4502=Formato' + #13#10 + +'4503=Formato texto:' + #13#10 + +'4504=Separador de decimales:' + #13#10 + +'' + #13#10 + +'fkText=Texto (ninguno)' + #13#10 + +'fkNumber=Nmero' + #13#10 + +'fkDateTime=Fecha/Hora' + #13#10 + +'fkBoolean=Lgico' + #13#10 + +'fkNumber1=1234.5;%g' + #13#10 + +'fkNumber2=1234.50;%2.2f' + #13#10 + +'fkNumber3=1,234.50;%2.2n' + #13#10 + +'fkNumber4=$1,234.50;%2.2m' + #13#10 + +'fkDateTime1=11.28.2002;mm.dd.aaaa' + #13#10 + +'fkDateTime2=28 nov 2002;dd mmm aaaa' + #13#10 + +'fkDateTime3=Noviembre 28, 2002;mmmm dd, aaaa' + #13#10 + +'fkDateTime4=02:14;hh:mm' + #13#10 + +'fkDateTime5=02:14am;hh:mm am/pm' + #13#10 + +'fkDateTime6=02:14:00;hh:mm:ss' + #13#10 + +'fkDateTime7=02:14am, Noviembre 28, 2002;hh:mm am/pm, mmmm dd, aaaa' + #13#10 + +'fkBoolean1=0,1;0,1' + #13#10 + +'fkBoolean2=No,Si;No,Si' + #13#10 + +'fkBoolean3=_,x;_,x' + #13#10 + +'fkBoolean4=Falso,Verdadero;Falso,Verdadero' + #13#10 + +'======== TfrxHighlightEditorForm ========' + #13#10 + +'4600=Resaltado' + #13#10 + +'4601=Color...' + #13#10 + +'4602=Color...' + #13#10 + +'4603=Condicin' + #13#10 + +'4604=Fuente' + #13#10 + +'4605=Fondo' + #13#10 + +'4606=Negrita' + #13#10 + +'4607=Cursiva' + #13#10 + +'4608=Subrayado' + #13#10 + +'4609=Transparente' + #13#10 + +'4610=Otros' + #13#10 + +'' + #13#10 + +'======== TfrxReportEditorForm ========' + #13#10 + +'4700=Opciones del informe' + #13#10 + +'4701=General' + #13#10 + +'4702=Impresora' + #13#10 + +'4703=Copias' + #13#10 + +'4704=General' + #13#10 + +'4705=Contrasea' + #13#10 + +'4706=Copias intercaladas' + #13#10 + +'4707=Doble pasada' + #13#10 + +'4708=Imprimir aunque est en blanco' + #13#10 + +'4709=Descripcin' + #13#10 + +'4710=Nombre' + #13#10 + +'4711=Descripcin' + #13#10 + +'4712=Imagen' + #13#10 + +'4713=Autor' + #13#10 + +'4714=Mayor' + #13#10 + +'4715=Menor' + #13#10 + +'4716=Revisin' + #13#10 + +'4717=Acumulado' + #13#10 + +'4718=Creado' + #13#10 + +'4719=Modificado' + #13#10 + +'4720=Descripcin' + #13#10 + +'4721=Version' + #13#10 + +'4722=Examinar...' + #13#10 + +'4723=Ajustes de la Herencia' + #13#10 + +'4724=Seleccione una Opcin:' + #13#10 + +'4725=Sin cambios' + #13#10 + +'4726=Separar el informe base' + #13#10 + +'4727=Heredar del informe base' + #13#10 + +'4728=Herencia' + #13#10 + +'' + #13#10 + +'rePrnOnPort=en' + #13#10 + +'riNotInherited=No heredar de este informe' + #13#10 + +'riInherited=Este informe se ha heredado de: %s' + #13#10 + +'======== TfrxStringsEditorForm ========' + #13#10 + +'4800=Lneas' + #13#10 + +'' + #13#10 + +'======== TfrxSQLEditorForm ========' + #13#10 + +'4900=SQL' + #13#10 + +'4901=Constructor de consultas' + #13#10 + +'' + #13#10 + +'======== TfrxPasswordForm ========' + #13#10 + +'5000=Contrasea' + #13#10 + +'5001=Introduzca contrasea:' + #13#10 + +'' + #13#10 + +'======== TfrxStyleEditorForm ========' + #13#10 + +'5100=Editor de Estilos' + #13#10 + +'5101=Color...' + #13#10 + +'5102=Fuente...' + #13#10 + +'5103=Marco...' + #13#10 + +'5104=Aadir' + #13#10 + +'5105=Borrar' + #13#10 + +'5106=Editar' + #13#10 + +'5107=Cargar' + #13#10 + +'5108=Guardar' + #13#10 + +'' + #13#10 + +'======== TfrxFrameEditorForm ========' + #13#10 + +'5200=Editor de Marcos' + #13#10 + +'5201=Marco' + #13#10 + +'5202=Lnea de Marco' + #13#10 + +'5203=Sombra' + #13#10 + +'5204=Lnea de arriba' + #13#10 + +'5205=Lnea de abajo' + #13#10 + +'5206=Lnea de la izquierda' + #13#10 + +'5207=Lnea de la derecha' + #13#10 + +'5208=Marco completo' + #13#10 + +'5209=Sin marco' + #13#10 + +'5210=Color del marco' + #13#10 + +'5211=Estilo del marco' + #13#10 + +'5212=Grosor de lnea' + #13#10 + +'5213=Sombra' + #13#10 + +'5214=Color de sombra' + #13#10 + +'5215=Grosor de la sombra' + #13#10 + +'' + #13#10 + +'======== TfrxNewItemForm ========' + #13#10 + +'5300=Nuevo elemento' + #13#10 + +'5301=Elementos' + #13#10 + +'5302=Plantillas' + #13#10 + +'5303=Heredar el informe' + #13#10 + +'' + #13#10 + +'======== TfrxTabOrderEditorForm ========' + #13#10 + +'5400=Orden de edicin' + #13#10 + +'5401=Lista de Controles:' + #13#10 + +'5402=Arriba' + #13#10 + +'5403=Abajo' + #13#10 + +'' + #13#10 + +'======== TfrxEvaluateForm ========' + #13#10 + +'5500=Evaluar' + #13#10 + +'5501=Expresin' + #13#10 + +'5502=Resultado' + #13#10 + +'' + #13#10 + +'======== TfrxStdWizardForm ========' + #13#10 + +'5600=Asistente de informes' + #13#10 + +'5601=Datos' + #13#10 + +'5602=Campos' + #13#10 + +'5603=Grupos' + #13#10 + +'5604=Disposicin' + #13#10 + +'5605=Estilo' + #13#10 + +'5606=Paso 1. Seleccionar los Datos.' + #13#10 + +'5607=Paso 2. Seleccionar los campos que se mostrarn.' + #13#10 + +'5608=Paso 3. Crear grupos (opcional).' + #13#10 + +'5609=Paso 4. Definir la orientacin de pgina y la disposicin de los datos.' + #13#10 + +'5610=Paso 5. Escoger el estilo del informe.' + #13#10 + +'5611=Aadir >' + #13#10 + +'5612=Aadir todos >>' + #13#10 + +'5613=< Quitar' + #13#10 + +'5614=<< Quitar todos' + #13#10 + +'5615=Aadir >' + #13#10 + +'5616=< Quitar' + #13#10 + +'5617=Seleccionar campos:' + #13#10 + +'5618=Campos disponibles:' + #13#10 + +'5619=Grupos:' + #13#10 + +'5620=Orientacin' + #13#10 + +'5621=Disposicin' + #13#10 + +'5622=Vertical' + #13#10 + +'5623=Horizontal' + #13#10 + +'5624=Datos tabulados' + #13#10 + +'5625=En Columnas' + #13#10 + +'5626=Ajustar los campos a la anchura de pgina' + #13#10 + +'5627=Atrs' + #13#10 + +'5628=Siguiente' + #13#10 + +'5629=Finalizar' + #13#10 + +'5630=Nueva tabla...' + #13#10 + +'5631=Nueva consulta...' + #13#10 + +'5632=Seleccionar la base de datos:' + #13#10 + +'5633=Seleccionar una tabla:' + #13#10 + +'5634=o' + #13#10 + +'5635=Crear una consulta...' + #13#10 + +'5636=Configurar la conexin' + #13#10 + +'' + #13#10 + +'wzStd=Asistente para Informes Estandard' + #13#10 + +'wzDMP=Asistente para Informes en Matricial' + #13#10 + +'wzStdEmpty=Informe Estandard' + #13#10 + +'wzDMPEmpty=Informe para Matricial' + #13#10 + +'======== TfrxConnectionWizardForm ========' + #13#10 + +'5700=Asistente de Conexin' + #13#10 + +'5701=Conexin' + #13#10 + +'5702=Escoger el tipo de conexin:' + #13#10 + +'5703=Escoger la base de datos:' + #13#10 + +'5704=Usuario' + #13#10 + +'5705=Contrasea' + #13#10 + +'5706=Pedir Usuario' + #13#10 + +'5707=Usar Usuario/contrasea:' + #13#10 + +'5708=Tabla' + #13#10 + +'5709=Escoger nombre de tabla:' + #13#10 + +'5710=Filtrar registros:' + #13#10 + +'5711=Consulta' + #13#10 + +'5712=Sentencia SQL:' + #13#10 + +'5713=Constructor de Consultas' + #13#10 + +'5714=Editar los Parmetros de la Consulta' + #13#10 + +'' + #13#10 + +'ftAllFiles=Todos los archivos' + #13#10 + +'ftPictures=Imgenes' + #13#10 + +'ftDB=Bases de datos' + #13#10 + +'ftRichFile=Texto enriquecido' + #13#10 + +'ftTextFile=Archivo de texto' + #13#10 + +'prNotAssigned=(No asignado)' + #13#10 + +'prInvProp=Valor no vlido' + #13#10 + +'prDupl=Nombre Duplicado' + #13#10 + +'prPict=(Imagen)' + #13#10 + +'mvExpr=Permitir Expresiones' + #13#10 + +'mvStretch=Ajustado' + #13#10 + +'mvStretchToMax=Ajustar al ancho mximo' + #13#10 + +'mvShift=Cambiao' + #13#10 + +'mvShiftOver=Shift When Overlapped' + #13#10 + +'mvVisible=Visible' + #13#10 + +'mvPrintable=Imprimible' + #13#10 + +'mvFont=Fuente...' + #13#10 + +'mvFormat=Formato de visualizacin...' + #13#10 + +'mvClear=Borrar Contenido' + #13#10 + +'mvAutoWidth=Ancho Automtico' + #13#10 + +'mvWWrap=Ajuste de palabras' + #13#10 + +'mvSuppress=Suprimir Valores Repetidos' + #13#10 + +'mvHideZ=Ocultar ceros' + #13#10 + +'mvHTML=Permitir etiquetas HTML' + #13#10 + +'lvDiagonal=Diagonal' + #13#10 + +'pvAutoSize=Tamao Automtico' + #13#10 + +'pvCenter=Centrado' + #13#10 + +'pvAspect=Conservar el aspecto' + #13#10 + +'bvSplit=Permitir separacin' + #13#10 + +'bvKeepChild=Conservar junto al hijo' + #13#10 + +'bvPrintChild=Imprimir Hija si Invisible' + #13#10 + +'bvStartPage=Iniciar pgina nueva' + #13#10 + +'bvPrintIfEmpty=Imprimir si Detalle Vaco' + #13#10 + +'bvKeepDetail=Conservar Junto al Detalle' + #13#10 + +'bvKeepFooter=Conservar Junto a su Pie' + #13#10 + +'bvReprint=Reimprimir en Nueva Pgina' + #13#10 + +'bvOnFirst=Imprimir en Primera Pgina' + #13#10 + +'bvOnLast=Imprimir En Ultima Pgina' + #13#10 + +'bvKeepGroup=Conservar Junto' + #13#10 + +'bvFooterAfterEach=Pi despus de cada fila' + #13#10 + +'bvDrillDown=Perforar-Abajo' + #13#10 + +'bvResetPageNo=Reinicializa el nmero de Pginas' + #13#10 + +'srParent=Imprimir en el Padre' + #13#10 + +'obCatDraw=Arrastrar' + #13#10 + +'obCatOther=Otros objetos' + #13#10 + +'obCatOtherControls=Otros controles' + #13#10 + +'obDiagLine=Lnea Diagonal' + #13#10 + +'obRect=Rectangulo' + #13#10 + +'obRoundRect=Rectngulo Redondeado' + #13#10 + +'obEllipse=Elipse' + #13#10 + +'obTrian=Triangulo' + #13#10 + +'obDiamond=Diamante' + #13#10 + +'obLabel=Etiqueta' + #13#10 + +'obEdit=Control de Edicin' + #13#10 + +'obMemoC=Memo' + #13#10 + +'obButton=Botn' + #13#10 + +'obChBoxC=Casilla de verificacin' + #13#10 + +'obRButton=Botn de opcin' + #13#10 + +'obLBox=Cuadro de Lista' + #13#10 + +'obCBox=Cuadro Combinado' + #13#10 + +'obDateEdit=Editor de Fechas' + #13#10 + +'obImageC=Imagen' + #13#10 + +'obPanel=Panel' + #13#10 + +'obGrBox=Grupo de opciones' + #13#10 + +'obBBtn=Botn con imagen' + #13#10 + +'obSBtn=Botn de men' + #13#10 + +'obMEdit=Editor con Formato' + #13#10 + +'obChLB=Lista de verificacin' + #13#10 + +'obDBLookup=Lista de seleccin de datos' + #13#10 + +'obBevel=Biselado' + #13#10 + +'obShape=Dibujo' + #13#10 + +'obText=Texto' + #13#10 + +'obSysText=Texto de Sistema' + #13#10 + +'obLine=Lnea' + #13#10 + +'obPicture=Imagen' + #13#10 + +'obBand=Banda' + #13#10 + +'obDataBand=Banda de Datos' + #13#10 + +'obSubRep=SubInforme' + #13#10 + +'obDlgPage=Dilogo' + #13#10 + +'obRepPage=Pgina' + #13#10 + +'obReport=Informe' + #13#10 + +'obRich=Texto enriquecido' + #13#10 + +'obOLE=Objeto OLE' + #13#10 + +'obChBox=Casilla de verificacin' + #13#10 + +'obChart=Grfico' + #13#10 + +'obBarC=Cdigo de Barras' + #13#10 + +'obCross=Informe cruzado' + #13#10 + +'obDBCross=Datos cruzados' + #13#10 + +'obGrad=Gradiente' + #13#10 + +'obDMPText=Texto para Matricial' + #13#10 + +'obDMPLine=Lnea para Matricial' + #13#10 + +'obDMPCmd=Dot-matrix Command object' + #13#10 + +'obBDEDB=Base de Datos BDE' + #13#10 + +'obBDETb=Tabla BDE' + #13#10 + +'obBDEQ=Consulta BDE' + #13#10 + +'obBDEComps=Componentes BDE' + #13#10 + +'obIBXDB=Base de Datos IBX' + #13#10 + +'obIBXTb=Tabla IBX' + #13#10 + +'obIBXQ=Consulta IBX' + #13#10 + +'obIBXComps=Componentes IBX' + #13#10 + +'obADODB=Base de Datos ADO' + #13#10 + +'obADOTb=Tabla ADO' + #13#10 + +'obADOQ=Consulta ADO' + #13#10 + +'obADOComps=Componentes ADO' + #13#10 + +'obDBXDB=Base de Datos DBX' + #13#10 + +'obDBXTb=Tabla DBX' + #13#10 + +'obDBXQ=Consulta DBX' + #13#10 + +'obDBXComps=Componentes DBX' + #13#10 + +'obFIBDB=FIB Database' + #13#10 + +'obFIBTb=FIB Table' + #13#10 + +'obFIBQ=FIB Query' + #13#10 + +'obFIBComps=FIB Components' + #13#10 + +'ctString=Texto' + #13#10 + +'ctDate=Fecha y Hora' + #13#10 + +'ctConv=Conversiones' + #13#10 + +'ctFormat=Formato' + #13#10 + +'ctMath=Matemticas' + #13#10 + +'ctOther=Otros' + #13#10 + +'IntToStr=Convertir un valor numrico entero en cadena alfanumrica' + #13#10 + +'FloatToStr=Convierte un valor decimal en cadena alfanumrica' + #13#10 + +'DateToStr=Convierte una fecha en cadena alfanumrica' + #13#10 + +'TimeToStr=Convierte un valor de hora en cadena alfanumrica' + #13#10 + +'DateTimeToStr=Convierte un valor fecha y hora en una cadena alfanumrica' + #13#10 + +'VarToStr=Convierte un valor variable en una cadena alfanumrica' + #13#10 + +'StrToInt=Convierte una cadena alfanumrica en un valor numrico entero' + #13#10 + +'StrToInt64=Converts a string to an Int64 value' + #13#10 + +'StrToFloat=Convierte una cadena alfanumrica en un valor decimal' + #13#10 + +'StrToDate=Convierte una cadena alfanumrica en fecha' + #13#10 + +'StrToTime=Convierte una cadena alfanumrica en hora' + #13#10 + +'StrToDateTime=Convierte una cadena alfanumrica en fecha/hora' + #13#10 + +'Format=Aplica una mscara a un array de argumentos y devuelve una cadena formateada' + #13#10 + +'FormatFloat=Aplica un formato a un valor decimal' + #13#10 + +'FormatDateTime=Aplica un formato a un valor de Fecha/Hora' + #13#10 + +'FormatMaskText=Devuelve una cadena alfanumrica formateada' + #13#10 + +'EncodeDate=Devuelve la fecha del Ao, Mes y Da especificados' + #13#10 + +'DecodeDate=Descompone una fecha especificada en el Ao, Mes y Da' + #13#10 + +'EncodeTime=Devuelve la hora para la Horas, Minutos, Segundos y Milidegundos' + #13#10 + +'DecodeTime=Descompone la hora en Horas, Minutos, Segundos y Milisegundos' + #13#10 + +'Date=Devuelve la fecha actual' + #13#10 + +'Time=Devuelve la hora actual' + #13#10 + +'Now=Devuelve la fecha y la hora actual' + #13#10 + +'DayOfWeek=Devuelve el da de la semana de una fecha especificada' + #13#10 + +'IsLeapYear=Indica si el ao especificado es bisiesto' + #13#10 + +'DaysInMonth=Devuelve el nmero de das de un ms especificado' + #13#10 + +'Length=Devuelve la longitud de una cadena alfanumrica' + #13#10 + +'Copy=Devuelve una subcadena dentro de una cadena alfanumrica' + #13#10 + +'Pos=Devuelve la posicin de una subcadena dentro de una cadena alfanumrica' + #13#10 + +'Delete=Borra una subcadena de una cadena alfanumrica' + #13#10 + +'Insert=Inserta una subcadena en una cadena alfanumrica' + #13#10 + +'Uppercase=Convierte todos los caracteres de una cadena en maysculas' + #13#10 + +'Lowercase=Convierte todos los caracteres de una cadena en minsculas' + #13#10 + +'Trim=Descarta todos los espacios en blanco de una cadena' + #13#10 + +'NameCase=Convierte el primer caracter de cada palabra de una cadena en mayscula. El resto lo pasa a minscula' + #13#10 + +'CompareText=Compara dos Cadenas alfanumricas' + #13#10 + +'Chr=Convierte valor numrico entero a caracter' + #13#10 + +'Ord=Convierte un caracter en un valor numrico entero' + #13#10 + +'SetLength=Establece la longitud para una cadena alfanumrica' + #13#10 + +'Round=Redondea un valor decimal' + #13#10 + +'Trunc=Trunca un valor decimal' + #13#10 + +'Int=Devuelve la parte entera de un valor decimal' + #13#10 + +'Frac=Devuelve la parte decimal de un valor decimal' + #13#10 + +'Sqrt=Devuelve la raiz cuadrada del nmero especificado' + #13#10 + +'Abs=Devuelve el valor absoluto' + #13#10 + +'Sin=Devuelve el Seno de un ngulo (en radianes)' + #13#10 + +'Cos=Devuelve el Coseno de un ngulo (en radianes)' + #13#10 + +'ArcTan=Devuelve la ArcoTangente' + #13#10 + +'Tan=Devuelve la Tangente' + #13#10 + +'Exp=Devuelve el Exponencial' + #13#10 + +'Ln=Returns the natural log of a real expression' + #13#10 + +'Pi=Devuelve 3.1415926...' + #13#10 + +'Inc=Incrementa un valor' + #13#10 + +'Dec=Decrementa un valor' + #13#10 + +'RaiseException=Lanza una excepcin' + #13#10 + +'ShowMessage=Mostrar mensajes' + #13#10 + +'Randomize=Inicializar el generador de nmeros aleatorios' + #13#10 + +'Random=Devuelve un nmero aleatorio' + #13#10 + +'ValidInt=Devuelve Verdadero si la cadena alfanumrica especificada contiene un nmero entero vlido' + #13#10 + +'ValidFloat=Devuelve Verdadero si la cadena alfanumrica especificada contiene un nmero decimal vlido' + #13#10 + +'ValidDate=Devuelve Verdadero si la cadena alfanumrica especificada contiene una fecha vlida' + #13#10 + +'IIF=Devuelve el valor1 si la expresin es verdadera. En caso contrario devuelve el valor2' + #13#10 + +'Get=Solo para uso interno' + #13#10 + +'Set=Solo para uso interno' + #13#10 + +'InputBox=Muestra una ventana de dilogo para que el usuario introduzca una cadena' + #13#10 + +'InputQuery=Muestra una ventana de dilogo para que el usuario introduzca una cadena' + #13#10 + +'MessageDlg=Muestra una ventana con un mensaje' + #13#10 + +'CreateOleObject=Crea un objeto OLE' + #13#10 + +'VarArrayCreate=Crea un array de variantes' + #13#10 + +'VarType=Devuelve el tipo de valor contenido en un variante' + #13#10 + +'ctAggregate=Agregacin' + #13#10 + +'Sum=Calcula la suma de para una banda de datos' + #13#10 + +'Avg=Calcula la media de para una banda de datos' + #13#10 + +'Min=Calcula el mnimo de para una banda de datos' + #13#10 + +'Max=Calcula el mximo de para una banda de datos' + #13#10 + +'Count=Calcula el nmero de filas de datos' + #13#10 + +'wzDBConn=Nuevo Asistente de Conexin' + #13#10 + +'wzDBTable=Nuevo Asistente de Tabla' + #13#10 + +'wzDBQuery=Nuevo Asistente de Consulta' + #13#10 + +'DayOf=Devuelve el nmero del da (1..31) de la fecha pasada' + #13#10 + +'MonthOf=Devuelve el nmero del mes (1..12) de la fecha pasada' + #13#10 + +'YearOf=Devuelve el ao de la fecha pasada' + #13#10 + +'bvKeepHeader=Conservar Junto a la Cabecera' + #13#10 + +'======== TfrxConnEditorForm ========' + #13#10 + +'5800=Conexiones' + #13#10 + +'5801=Nuevo' + #13#10 + +'5802=Borrar' + #13#10 + +'' + #13#10 + +'cpName=Nombre' + #13#10 + +'cpConnStr=Cadena para la Conexin' + #13#10 + +'startCreateNew=Crear un nuevo informe' + #13#10 + +'startCreateBlank=Crear un informe en blanco' + #13#10 + +'startOpenReport=Abrir un Informe' + #13#10 + +'startOpenLast=Abrir el ltimo informe' + #13#10 + +'startEditAliases=Editar Alias de la Conexin' + #13#10 + +'startHelp=Ayuda' + #13#10 + +'' + #13#10 + +'======== TfrxWatchForm ========' + #13#10 + +'5900=Relojes' + #13#10 + +'5901=Aadir reloj' + #13#10 + +'5902=Borrar reloj' + #13#10 + +'5903=Editar Reloj' + #13#10 + +'' + #13#10 + +'======== TfrxInheritErrorForm ========' + #13#10 + +'6000=Error al Heredar' + #13#10 + +'6001=Los informes Base y el Heredado tienen objetos duplicados. Que debemos hacer ?' + #13#10 + +'6002=Borrar duplicados' + #13#10 + +'6003=Renombrar duplicados' + #13#10 + +''; + +initialization + frxResources.AddStrings(resStr); + +end. diff --git a/official/4.2/LibD11/frxrcExports.frc b/official/4.2/LibD11/frxrcExports.frc new file mode 100644 index 0000000..d93a8a4 --- /dev/null +++ b/official/4.2/LibD11/frxrcExports.frc @@ -0,0 +1,186 @@ +======== TfrxXLSExportDialog ======== +8000=Exportar Excel +8001=Estilos +8002=Imgenes +8003=Combinar celdas +8004=Exportar Rpido +8005=Tal como lo vs +8006=Como texto +8007=Segundo plano +8008=Abrir Excel despus de exportar +8009=Archivo de Excel (*.xls)|*.xls +8010=.xls + +======== TfrxXMLExportDialog ======== +8100=Exportar a Excel +8101=Estilos +8102=Tal como lo vs +8103=Abrir Excel despus de exportar +8104=Segundo Plano +8105=Archivo XML Excel (*.xls)|*.xls +8106=.xls + +======== TfrxHTMLExportDialog ======== +8200=Exportar a HTML +8201=Abrir despus de exportar +8202=Estilos +8203=Imgenes +8204=Todo en una misma carpeta +8205=Ancho fijo +8206=Navegador +8207=Multipgina +8208=Navegador Mozilla +8209=Segundo Plano +8210=Archivo HTML (*.html)|*.html +8211=.html + +======== TfrxTXTExportDialog ======== +8300=Exportar a texto (Impresoras matriciales) +8301=Vista previa Si/No +8302= Propiedades de Exportar +8303=Separador de pginas +8304=Cdigo de pgina OEM +8305=Lneas vacas +8306=Lead spaces +8307=Pginas: +8308=Indique los nmeros de pgina y/o un rango, separado por comas. Por ejemplo: 1,3,5-12 +8309= Escalado +8310=Escala X +8311=Escala Y +8312= Marcos +8313=Ninguno +8314=Simple +8315=Grfico +8316=Solo cdigos de pgina OEM +8317=Imprimir despus de exportar +8318=Guardar opciones +8319= Vista previa +8320=Ancho: +8321=Alto: +8322=Pgina +8323=Ms Zoom +8324=Menos Zoom +8325=Archivo de texto (Impresoras matriciales)(*.prn)|*.prn +8326=.prn + +======== TfrxPrnInit ======== +8400=Imprimir +8401=Impresora +8402=Nombre +8403=Configurar... +8404=Copias +8405=Nmero de copias +8406= Configuracin +8407=Tipo de impresora +8408=.fpi +8409=Printer init template (*.fpi)|*.fpi +8410=.fpi +8411=Printer init template (*.fpi)|*.fpi + +======== TfrxRTFExportDialog ======== +8500=Exportar a RTF +8501=Imgenes +8502=Tal como lo vs +8503=Abrir despus de exportar +8504=Archivo RTF (*.rtf)|*.rtf +8505=.rtf + +======== TfrxIMGExportDialog ======== +8600=Opciones de Exportar +8601= Opciones de imagen +8602=Calidad JPEG +8603=Resolution (dpi) +8604=Archivos Separados +8605=Crop pginas +8606=Monocromo + +======== TfrxPDFExportDialog ======== +8700=Exportar a PDF +8701=Comprimir +8702=Fuentes Embebidas +8703=Impresin Optimizada +8704=Segundo Plano +8705=Abrir despus de exportar +8706=Outline +8707=Archivos de Adobe PDF (*.pdf)|*.pdf +8708=.pdf + +RTFexport=Archivo RTF +BMPexport=Imagen BMP +JPEGexport=Imagen JPEG +TIFFexport=Imagen TIFF +TextExport=Texto (Impresora matricial) +XlsOLEexport=Tabla Excel (OLE) +HTMLexport=Archivo HTML +XlsXMLexport=Tabla Excel (XML) +PDFexport=Archivo PDF +ProgressWait=Espere por favor +ProgressRows=Opciones de filas +ProgressColumns=Opciones de columnas +ProgressStyles=Opciones de Estilos +ProgressObjects=Exportando objetos +TIFFexportFilter=Imagen Tiff (*.tif)|*.tif +BMPexportFilter=Imagen BMP (*.bmp)|*.bmp +JPEGexportFilter=Imagen Jpeg (*.jpg)|*.jpg +HTMLNavFirst=Primera +HTMLNavPrev=Anterior +HTMLNavNext=Siguiente +HTMLNavLast=Ultima +HTMLNavRefresh=Refrescar +HTMLNavPrint=Imprimir +HTMLNavTotal=Total pginas +======== TfrxSimpleTextExportDialog ======== +8800=Exportar a Texto +8801=Archivo de Texto (*.txt)|*.txt +8802=.txt +SimpleTextExport=Archivo de Texto +======== TfrxCSVExportDialog ======== +8850=Exportar a CSV +8851=Archivo CSV (*.csv)|*.csv +8852=.csv +8853=Separador +CSVExport=Archivo CSV +======== TfrxMailExportDialog ======== +8900=Enviar por E-mail +8901=E-mail +8902=Cuenta +8903=Conexin +8904=Direccin +8905=Adjunto +8906=Formato +8907=De la Direccin +8908=Del Nombre +8909=Servidor +8910=Usuario +8911=Correo +8912=Mensage +8913=Texto +8914=Organizacin +8915=Contrasea +8916=Puerto +8917=Recordar propiedades +8918=Algunos campos obligatorios no se han rellenado +8919=Configuracin avanzada +8920=Firma +8921=Construir +8922=Asunto +8923=Un saludo +8924=Enviar el correo a +EmailExport=E-mail +FastReportFile=Archivo FastReport +======== TfrxGIFExport ======== +GifexportFilter=Archivo Gif (*.gif)|*.gif +GIFexport=Imagen Gif +======== 3.21 ======== +8950=Continuo +======== 3.22 ======== +8951=Cabecera de pgina/Pi +8952=Texto +8953=Cabecera/Pi +8954=Ninguno +ODSExportFilter=!Open Document Spreadsheet file (*.ods)|*.ods +ODSExport=!Open Document Spreadsheet +ODTExportFilter=!Open Document Text file (*.odt)|*.odt +ODTExport=!Open Document Text +8960=!.ods +8961=!.odt diff --git a/official/4.2/LibD11/frxrcExports.pas b/official/4.2/LibD11/frxrcExports.pas new file mode 100644 index 0000000..c553ec6 --- /dev/null +++ b/official/4.2/LibD11/frxrcExports.pas @@ -0,0 +1,212 @@ +{******************************************} +{ } +{ FastReport v4.0 } +{ Language resource file } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxrcExports; + +interface + +implementation + +uses frxRes; + +const resStr = +'======== TfrxXLSExportDialog ========' + #13#10 + +'8000=Exportar Excel' + #13#10 + +'8001=Estilos' + #13#10 + +'8002=Imgenes' + #13#10 + +'8003=Combinar celdas' + #13#10 + +'8004=Exportar Rpido' + #13#10 + +'8005=Tal como lo vs' + #13#10 + +'8006=Como texto' + #13#10 + +'8007=Segundo plano' + #13#10 + +'8008=Abrir Excel despus de exportar' + #13#10 + +'8009=Archivo de Excel (*.xls)|*.xls' + #13#10 + +'8010=.xls' + #13#10 + +'' + #13#10 + +'======== TfrxXMLExportDialog ========' + #13#10 + +'8100=Exportar a Excel' + #13#10 + +'8101=Estilos' + #13#10 + +'8102=Tal como lo vs' + #13#10 + +'8103=Abrir Excel despus de exportar' + #13#10 + +'8104=Segundo Plano' + #13#10 + +'8105=Archivo XML Excel (*.xls)|*.xls' + #13#10 + +'8106=.xls' + #13#10 + +'' + #13#10 + +'======== TfrxHTMLExportDialog ========' + #13#10 + +'8200=Exportar a HTML' + #13#10 + +'8201=Abrir despus de exportar' + #13#10 + +'8202=Estilos' + #13#10 + +'8203=Imgenes' + #13#10 + +'8204=Todo en una misma carpeta' + #13#10 + +'8205=Ancho fijo' + #13#10 + +'8206=Navegador' + #13#10 + +'8207=Multipgina' + #13#10 + +'8208=Navegador Mozilla' + #13#10 + +'8209=Segundo Plano' + #13#10 + +'8210=Archivo HTML (*.html)|*.html' + #13#10 + +'8211=.html' + #13#10 + +'' + #13#10 + +'======== TfrxTXTExportDialog ========' + #13#10 + +'8300=Exportar a texto (Impresoras matriciales)' + #13#10 + +'8301=Vista previa Si/No' + #13#10 + +'8302= Propiedades de Exportar' + #13#10 + +'8303=Separador de pginas' + #13#10 + +'8304=Cdigo de pgina OEM' + #13#10 + +'8305=Lneas vacas' + #13#10 + +'8306=Lead spaces' + #13#10 + +'8307=Pginas:' + #13#10 + +'8308=Indique los nmeros de pgina y/o un rango, separado por comas. Por ejemplo: 1,3,5-12' + #13#10 + +'8309= Escalado' + #13#10 + +'8310=Escala X' + #13#10 + +'8311=Escala Y' + #13#10 + +'8312= Marcos' + #13#10 + +'8313=Ninguno' + #13#10 + +'8314=Simple' + #13#10 + +'8315=Grfico' + #13#10 + +'8316=Solo cdigos de pgina OEM' + #13#10 + +'8317=Imprimir despus de exportar' + #13#10 + +'8318=Guardar opciones' + #13#10 + +'8319= Vista previa' + #13#10 + +'8320=Ancho:' + #13#10 + +'8321=Alto:' + #13#10 + +'8322=Pgina' + #13#10 + +'8323=Ms Zoom' + #13#10 + +'8324=Menos Zoom' + #13#10 + +'8325=Archivo de texto (Impresoras matriciales)(*.prn)|*.prn' + #13#10 + +'8326=.prn' + #13#10 + +'' + #13#10 + +'======== TfrxPrnInit ========' + #13#10 + +'8400=Imprimir' + #13#10 + +'8401=Impresora' + #13#10 + +'8402=Nombre' + #13#10 + +'8403=Configurar...' + #13#10 + +'8404=Copias' + #13#10 + +'8405=Nmero de copias' + #13#10 + +'8406= Configuracin' + #13#10 + +'8407=Tipo de impresora' + #13#10 + +'8408=.fpi' + #13#10 + +'8409=Printer init template (*.fpi)|*.fpi' + #13#10 + +'8410=.fpi' + #13#10 + +'8411=Printer init template (*.fpi)|*.fpi' + #13#10 + +'' + #13#10 + +'======== TfrxRTFExportDialog ========' + #13#10 + +'8500=Exportar a RTF' + #13#10 + +'8501=Imgenes' + #13#10 + +'8502=Tal como lo vs' + #13#10 + +'8503=Abrir despus de exportar' + #13#10 + +'8504=Archivo RTF (*.rtf)|*.rtf' + #13#10 + +'8505=.rtf' + #13#10 + +'' + #13#10 + +'======== TfrxIMGExportDialog ========' + #13#10 + +'8600=Opciones de Exportar' + #13#10 + +'8601= Opciones de imagen' + #13#10 + +'8602=Calidad JPEG' + #13#10 + +'8603=Resolution (dpi)' + #13#10 + +'8604=Archivos Separados' + #13#10 + +'8605=Crop pginas' + #13#10 + +'8606=Monocromo' + #13#10 + +'' + #13#10 + +'======== TfrxPDFExportDialog ========' + #13#10 + +'8700=Exportar a PDF' + #13#10 + +'8701=Comprimir' + #13#10 + +'8702=Fuentes Embebidas' + #13#10 + +'8703=Impresin Optimizada' + #13#10 + +'8704=Segundo Plano' + #13#10 + +'8705=Abrir despus de exportar' + #13#10 + +'8706=Outline' + #13#10 + +'8707=Archivos de Adobe PDF (*.pdf)|*.pdf' + #13#10 + +'8708=.pdf' + #13#10 + +'' + #13#10 + +'RTFexport=Archivo RTF' + #13#10 + +'BMPexport=Imagen BMP' + #13#10 + +'JPEGexport=Imagen JPEG' + #13#10 + +'TIFFexport=Imagen TIFF' + #13#10 + +'TextExport=Texto (Impresora matricial)' + #13#10 + +'XlsOLEexport=Tabla Excel (OLE)' + #13#10 + +'HTMLexport=Archivo HTML' + #13#10 + +'XlsXMLexport=Tabla Excel (XML)' + #13#10 + +'PDFexport=Archivo PDF' + #13#10 + +'ProgressWait=Espere por favor' + #13#10 + +'ProgressRows=Opciones de filas' + #13#10 + +'ProgressColumns=Opciones de columnas' + #13#10 + +'ProgressStyles=Opciones de Estilos' + #13#10 + +'ProgressObjects=Exportando objetos' + #13#10 + +'TIFFexportFilter=Imagen Tiff (*.tif)|*.tif' + #13#10 + +'BMPexportFilter=Imagen BMP (*.bmp)|*.bmp' + #13#10 + +'JPEGexportFilter=Imagen Jpeg (*.jpg)|*.jpg' + #13#10 + +'HTMLNavFirst=Primera' + #13#10 + +'HTMLNavPrev=Anterior' + #13#10 + +'HTMLNavNext=Siguiente' + #13#10 + +'HTMLNavLast=Ultima' + #13#10 + +'HTMLNavRefresh=Refrescar' + #13#10 + +'HTMLNavPrint=Imprimir' + #13#10 + +'HTMLNavTotal=Total pginas' + #13#10 + +'======== TfrxSimpleTextExportDialog ========' + #13#10 + +'8800=Exportar a Texto' + #13#10 + +'8801=Archivo de Texto (*.txt)|*.txt' + #13#10 + +'8802=.txt' + #13#10 + +'SimpleTextExport=Archivo de Texto' + #13#10 + +'======== TfrxCSVExportDialog ========' + #13#10 + +'8850=Exportar a CSV' + #13#10 + +'8851=Archivo CSV (*.csv)|*.csv' + #13#10 + +'8852=.csv' + #13#10 + +'8853=Separador' + #13#10 + +'CSVExport=Archivo CSV' + #13#10 + +'======== TfrxMailExportDialog ========' + #13#10 + +'8900=Enviar por E-mail' + #13#10 + +'8901=E-mail' + #13#10 + +'8902=Cuenta' + #13#10 + +'8903=Conexin' + #13#10 + +'8904=Direccin' + #13#10 + +'8905=Adjunto' + #13#10 + +'8906=Formato' + #13#10 + +'8907=De la Direccin' + #13#10 + +'8908=Del Nombre' + #13#10 + +'8909=Servidor' + #13#10 + +'8910=Usuario' + #13#10 + +'8911=Correo' + #13#10 + +'8912=Mensage' + #13#10 + +'8913=Texto' + #13#10 + +'8914=Organizacin' + #13#10 + +'8915=Contrasea' + #13#10 + +'8916=Puerto' + #13#10 + +'8917=Recordar propiedades' + #13#10 + +'8918=Algunos campos obligatorios no se han rellenado' + #13#10 + +'8919=Configuracin avanzada' + #13#10 + +'8920=Firma' + #13#10 + +'8921=Construir' + #13#10 + +'8922=Asunto' + #13#10 + +'8923=Un saludo' + #13#10 + +'8924=Enviar el correo a' + #13#10 + +'EmailExport=E-mail' + #13#10 + +'FastReportFile=Archivo FastReport' + #13#10 + +'======== TfrxGIFExport ========' + #13#10 + +'GifexportFilter=Archivo Gif (*.gif)|*.gif' + #13#10 + +'GIFexport=Imagen Gif' + #13#10 + +'======== 3.21 ========' + #13#10 + +'8950=Continuo' + #13#10 + +'======== 3.22 ========' + #13#10 + +'8951=Cabecera de pgina/Pi' + #13#10 + +'8952=Texto' + #13#10 + +'8953=Cabecera/Pi' + #13#10 + +'8954=Ninguno' + #13#10 + +'ODSExportFilter=!Open Document Spreadsheet file (*.ods)|*.ods' + #13#10 + +'ODSExport=!Open Document Spreadsheet' + #13#10 + +'ODTExportFilter=!Open Document Text file (*.odt)|*.odt' + #13#10 + +'ODTExport=!Open Document Text' + #13#10 + +'8960=!.ods' + #13#10 + +'8961=!.odt' + #13#10 + +''; + +initialization + frxResources.AddStrings(resStr); + +end. diff --git a/official/4.2/LibD11/frxrcInsp.frc b/official/4.2/LibD11/frxrcInsp.frc new file mode 100644 index 0000000..cda0c8d --- /dev/null +++ b/official/4.2/LibD11/frxrcInsp.frc @@ -0,0 +1,259 @@ +propActive=Especifica si un Dataset est abierto o no +propActive.TfrxHighlight=Especifica si el resaltado est activo o no +propAliasName=El nombre del Alias BDE +propAlign=Determina la alineacin del objeto relativa a la banda o la pgina +propAlignment=Justifica el texto de un objeto +propAllowAllUp=Especifica si todos los botones de un grupo pueden estar deseleccionados al mismo tiempo +propAllowEdit=Determina si el usuario puede editar las pginas del informe +propAllowExpressions=Determina si el texto contiene expresiones +propAllowGrayed=Permitir que las casillas de verificacin, tengan el estado indefinido +propAllowHTMLTags=Determina si el texto contiene etiquetas HTML +propAllowSplit=Determina si una banda contiene pginas cruzadas +propAuthor=El autor del informe +propAutoSize.TfrxPictureView=Determina si la imagen debe redimensionarse automticamente +propAutoWidth=Determina si el objeto debe redimensionarse a la longitud del texto +propBackPicture=Imagen de fondo para la pgina +propBarType=Tipo de cdigo de barra +propBevelInner=Tipo de biselado +propBevelOuter=Tipo de biselado +propBevelWidth=Grueso del biselado +propBorder=Determina si se muestra el borde del biselado o no +propBorderStyle=Estilo de ventana +propBottomMargin=Tamao para el margen de abajo +propBrushStyle=Estilo de brocha que se usar para pintar el fondo del objeto +propCalcCheckSum=Determina si el cdigo de barras debe calcular el dgito de control automticamente +propCancel=Determina si el botn debe activarse cuando se pulse la tecla ESCAPE +propCaption=Ttulo del control +propCellFields=Nombres de campos representados en las celdas +propCellLevels=Nmero de celdas del nivel +propCenter=Determina si la imagen deber estar centrada en el control +propCharset=Fuente +propCharSpacing=Cantidad de Pxeles entre dos caracteres +propCheckColor=Color de la marca de verificacin +propChecked=Indica si la casilla del control tiene la marca de seleccin +propCheckStyle=Estilo de marca de seleccin +propChild=Banda hija conectada a esta banda +propClipped=Determines whether the text should be clipped inside the objects bounds +propCollate=Opciones predeterminadas de la colacin +propColor.TFont=Color del texto +propColor=Color del objeto +propColor.TfrxFrame=Color del marco +propColor.TfrxHighlight=Detrmina si el color resaltado del objeto est activo +propColumnFields=Nombre de campos representados en las columnas +propColumnGap=Separacin entre las columnas de la banda +propColumnLevels=Nmero de columnas para este nivel +propColumns=Nmero de columnas en esta banda +propColumnWidth=Ancho de columnas de esta banda +propCondition=Condicin por la que se agrupar. El grupo de romper si el valor de esta expresin cambia +propCondition.TfrxHighlight=Cadena de la expresin. Si esta expresin es verdadera, el resaltado se activar +propConnected=Indica si la conexin con la base de datos est activa +propConvertNulls=Determina si un campo con valor nulo se convertir a 0 o a la cadena "Vaco" +propCopies=Nmero de copias por defecto +propCursor=Tipo de cursor para este objeto +propDatabaseName=Nombre de la base de datos +propDataField=Especifica el campo del cual el objeto obtendr los datos +propDataSet=Dataset ligado a este objeto +propDate=Fecha +propDateFormat=Formato para la fecha +propDecimalSeparator=Separador de decimales +propDefault=Determina si el botn estar seleccionado por defecto +propDefHeight=Alto por defecto para la fila +propDescription.TfrxReportOptions=Descripcin del informe +propDescription=Descripcin de los objetos +propDiagonal=Indica si esta lnea es diagonal +propDisplayFormat=Formato que se usar para la visualizacin de los valores +propDoublePass=Determina si el motor de informes debe hacer una segunda pasada +propDown=Determina si el botn de men est pulsado o no +propDownThenAcross=Determina como de larga ser la tabla cruzada +propDriverName=Nombre del driver del BDE +propDropShadow=Determina si el objeto tiene sombra +propDuplex=Especifica si se activa el modo duplex para esta pgina +propEditMask=Especifica la mscara que se usar para la edicin en este control +propEnabled=Determina si el control estar accesible +propEngineOptions=Opciones del motor de informes +propExpression=Valor de la expresin que contiene el objeto +propExpressionDelimiters=Caracteres que srn usados para delimitar las expresiones contenidas en el texto +propFieldAliases=Campos del dataset +propFilter=Condicin del filtro para el Dataset +propFiltered=Determina si el Dataset debe aplicar el filtro contenido en la propiedad Filter +propFlowTo=The text object that will show the text that not fit in the object +propFont=Fuente usada en este objeto +propFooterAfterEach=Determina si la banda de pie debe mostrarse despus de cada fila de datos +propFormatStr=Formato para texto +propFrame=Atributos para el marco del objeto +propGapX=Indentado a la izquierda para el texto +propGapY=Indentado arriba para el texto +propGlyph=Imagen del control +propGroupIndex=Indica el grupo de botones con los que interactuar el botn +propHAlign=Alineacin horizontal del texto +propHeight=Alto del objeto +propHideZeros=Determina si se mostrar o no el valor cero +propHighlight=Atributos para el resaltado +propIndexName=Nombre del ndice +propInitString=Printer init string for dot-matrix reports +propItems=Lista de items +propKeepAspectRatio=Mantener el aspecto original de la imagen +propKeepChild=Determina si la banda ha de imprimirse junto a su hija +propKeepFooter=Determina si la banda ha de imprimirse junto a su pie +propKeepTogether=Determina si la banda ha de imprimirse junto a todas sus subbandas +propKind.TfrxFormat=Tipo de formateo +propKind=The kind of the button +propLargeDesignHeight=Determines whether the page will have large height in the design mode +propLayout=Disposicin de la imagen en el botn +propLeft=Posicin izquierda del objeto +propLeftMargin=Tamao del margen izquierdo de la pgina +propLines=Texto del objeto +propLineSpacing=Nmero de pxeles entre dos lneas de texto +propLoginPrompt=Dtermina si se mostrar el dilogo de peticin de login +propMargin=Determina el nmero de pxeles entre el borde de la imagen y el borde del botn +propMaster=Dataset maestro +propMasterFields=Campos por los que se establece la relacin Maestro-Detalle +propMaxLength=Mxima longitud del texto +propMaxWidth=Anchura mxima de la columna +propMemo=Texto del objeto +propMinWidth=Anchura mnima de la columna +propMirrorMargins=Mrgenes de pgina iguales en las pginas pares +propModalResult=Determina el valor que devolver cuando se cierre con este botn una ventana modal +propName.TFont=Nombre de la fuente +propName.TfrxReportOptions=Nombre del informe +propName=Nombre del objeto +propNumGlyphs=Indica el nmero de imgenes contenidas en la imagen indicada en la propiedad Glyph +propOpenDataSource=Determina si la fuente de datos ser abierta automticamente o no +propOrientation=Orientacin de la pgina +propOutlineText=Texto que se mostrar en el ndice de la vista previa +propOutlineVisible=Indica si se mostrar el ndice en la vista previa +propOutlineWidth=Anchura que ocupar el ndice en la vista previa +propPageNumbers.TfrxPrintOptions=Nmero de pginas que se imprimirn +propPaperHeight=Alto de la pgina +propPaperWidth=Ancho de la pgina +propParagraphGap=Indentacin para la primera lnea del prrafo +propParams.TfrxBDEDatabase=Parmetros de la conexin +propParams=Parmetros de la consulta +propParentFont=Indica si el objeto usar la misma fuente que su contenedor +propPassword=Contrasea del informe +propPasswordChar=Indica el caracter que se mostrar en sustitucin de los que realmente se teclean +propPicture=Imagen +propPicture.TfrxReportOptions=Imagen que describe el informe +propPosition=Posicin inicial de la ventana +propPreviewOptions=Opciones de vista previa del informe +propPrintable=Indica si el objeto es imprimible. Si se establece a False, el objeto ser mostrado en la vista previa, pero no se imprimir +propPrintChildIfInvisible=Indica si la banda hija se imprimir en el caso de que la banda padre sea invisible +propPrinter=Nombre de la impresora que aparecer seleccionada al abrir o ejecutar el informe +propPrintIfDetailEmpty=Indica si la banda de datos se imprimir en el caso de que sus subbandas estn vacas +propPrintIfEmpty=Indica si la pgina se imprimir en el caso de que los Datasets estn vacos +propPrintOnFirstPage=Indica si la banda se imprimir en la primera pgina +propPrintOnLastPage=Indica si la banda se imprimir en la ltima pgina +propPrintOnParent=Determina si el subreport se puede imprimir en la banda padre +propPrintOnPreviousPage=Determina si la pgina se puede generar en el espacio libre de la pgina previamente generada +propPrintOptions=Opciones de impresin del informe +propPrintPages=Determina si se imprime todo o solo las pginas pares o las impares +propRangeBegin=Determina el punto de comienzo en la navegacin en el dataset +propRangeEnd=Determina el punto de terminacin en la navegacin en el dataset +propRangeEndCount=Determina el nmero de registros que se leern del Dataset Si la propiedad RangeEnd es reCount +propReadOnly=Determina si el texto del objeto es de solo lectura +propRepeatHeaders=Determina si la columna y la fila de cabecera s4e imprimir en la pgina nueva +propReportOptions=Opciones del informe +propReprintOnNewPage=Determina si la banda ser reimpresa en la nueva pgina +propRestrictions=Establecer restricciones +propRightMargin=Tamao del margen derecho de la pgina +propRotation.TfrxBarCodeView=Orientacin del cdigo de barras +propRotation=Rotacin del texto +propRowCount=Nmero de registros virtuales en la banda de datos +propRowFields=Nombres de campos que representan las filas cruzadas +propRowLevels=Nmero de niveles en la fila +propRTLReading=Determina si el texto del objeto, se pintar de derecha a izquierda +propSessionName=Nombre de la sesin del BDE +propShadowColor=Color de la sombra +propShadowWidth=Ancho de la sombra +propShape=Tipo de dibujo +propShiftMode=Cambia el comportamiento del objeto +propShowColumnHeader=Determina si se mostrarn las cabeceras de columna en los cruces +propShowColumnTotal=Determina si se mostrar la columna de Total +propShowRowHeader=Determina si se mostrarn las cabeceras de fila +propShowRowTotal=Determina si se mostrar la fila de Total +propShowDialog=Determina si se mostrar el dilogo de impresin en la vista previa +propShowText=Determina si se mostrar el texto del cdigo de barras +propSize=Tamao de fuente +propSorted=Determina si los items sern ordenados o no +propSpacing=Determina el nmero de pxeles entre la imagen y el texto +propSQL=Sentencia SQL +propStartNewPage=Lanzar una nueva pgina antes de imprimir la banda +propStretch=Ajusta la imagen a los lmetes del objeto +propStretched=Determina si el objeto puede ser ajustado +propStretchMode=Comportamiento del ajuste al objeto +propStyle.TFont=Estilo de fuente +propStyle=Estilo de control +propStyle.TfrxFrame=Estilo del marco +propSuppressRepeated=Suprime los valores repetidos +propTableName=Nombre de la tabla de datos +propTag=Tag +propTagStr=Tag string of the object +propText=Texto del objeto +propTitleBeforeHeader=Determina si se mostrar el ttulo del informe antes de la cabecera de pgina +propTop=Posicin arriba del objeto +propTopMargin=Tamao del margen arriba de la pgina +propTyp=Tipo de marco +propUnderlines=Determina si el texto aparecer subrayado +propURL=URL del objeto +propUserName=Nombre del usuario. Este nombre ser usado para mostrarlo en el rbol de datos +propVAlign=Alineacin vertical del texto +propVersionBuild=Informacin de versin +propVersionMajor=Informacin de versin, mayor version +propVersionMinor=Informacin de versin info, menor version +propVersionRelease=Informacin de versin +propVisible=Indica si el objeto se ver o no +propWidth=Anchura del objeto +propWidth.TfrxFrame=Anchura del marco +propWindowState=Estado inicial de la ventana +propWordBreak=Break russian words +propWordWrap=Determina si se insertarn retornos de carro en el texto cuando la longitud de este sobrepase el margen derecho +propZoom.TfrxBarCodeView=Zoom del cdigo de barras +propKeepHeader=Determina si la banda se imprimir junto a su banda de cabecera +propConnectionName=Nombre de la conexin con la base de datos usada en el informe +propCurve=Curvatura de los angulos redondeados del rectngulo +propDrillDown=Determina si el grupo puede ser perforado abajo +propFontStyle=Fuentes Estilo Matricial +propHideIfSingleDataRecord=Ocultar el pie si el grupo solo tiene una fila +propOutlineExpand=Determines whether to expand the report outline or not +propPlainCells=Determina si se imprimen varias celdas de lado a lado o apiladas +propPrintMode=Print mode: normal, split big pages to small one, or print several small pages on a big one +propPrintOnSheet=Tamao del papel. Usado si PrintMode no es pmDefault +propResetPageNumbers=Reinicializa el nmero de pginas/total pginas cuando se imprime el grupo. +Reset page number/total pages numbers when print a group. Debe ser usado con StartNewPage = TRUE +propReverse=Determina si las pginas se imprimirn en orden descendente +propShowFooterIfDrillDown=Determina si se ha de mostrar el pie de grupo si el grupo es drilldown +propSizeMode=Como mostrar el Objeto OLE +propVersion=Versin de FastReport +propWideBarRatio=Relative with of wide bars of the barcode +propWysiwyg=Determina si un objeto Richview debe usar la impresora para formatear el texto. Una impresora debe estar instalada y lista. +propArrowEnd=Determina si se debe dibujar una flecha en el extremo de la lnea. +propArrowLength=Longitud de la flecha +propArrowSolid=Determina si la flecha a dibujar ser slida +propArrowStart=Determina si se ha de dibujar una flecha en el comienzo de la lnea +propArrowWidth=Anchura de la flecha +propCloseDataSource=Determina si se ha de cerrar el DataSet cuando se cierre el informe +propDatabase=Conexin a la Base de Datos +propIndexFieldNames=Nombre del Indice +propCommandTimeOut=Cantidad de tiempo necesario para ejecutar una consulta +propExpandDrillDown=Determines whether to expand all drill-down elements at first start of a report +propWysiwyg.TfrxMemoView=Determina si el texto se ver tal y como se v +propLeftLine=Lnea Izquierda del marco +propTopLine=Lnea de arriba del marco +propRightLine=Lnea derecha del marco +propBottomLine=Lnea de abajo del marco +propColor.TfrxFrameLine=Color de la lnea del marco +propStyle.TfrxFrameLine=Estilo de la lnea del marco +propWidth.TfrxFrameLine=Anchura de la lnea del marco +propFileLink=Expresin o nombre del archivo que contiene la imagen +propEndlessWidth=Modo sin fin de la pgina. Si se configura a TRUE, la pgina crecer dependiendo del nmero de registros de datos +propEndlessHeight=Modo sin fin de la pgina. Si se configura a TRUE, la pgina crecer dependiendo del nmero de registros de datos +propAddHeight=Agrega la cantidad de espacio especificada a la altura de la celda +propAddWidth=Agrega la cantidad de espacio especificada a la anchura de la celda +propAllowDuplicates=Determina si la celda puede aceptar valores duplicados +propJoinEqualCells=Determina si los datos cruzados deben ensamblar las celdas con datos iguales +propNextCross=Pointer to the next crosstab that will be displayed side-by-side +propNextCrossGap=Gap between side-by-side crosstabs +propShowCorner=Determines whether the crosstab should display a left-top corner elements +propSuppressNullRecords=!Determines if the crosstab should suppress records with all NULL values +propShowTitle=!Determines if the crosstab should display a title +propAutoSize=!Determines if the crosstab should handle its size automatically diff --git a/official/4.2/LibD11/frxrcInsp.pas b/official/4.2/LibD11/frxrcInsp.pas new file mode 100644 index 0000000..6b61cad --- /dev/null +++ b/official/4.2/LibD11/frxrcInsp.pas @@ -0,0 +1,285 @@ +{******************************************} +{ } +{ FastReport v4.0 } +{ Language resource file } +{ } +{ Copyright (c) 1998-2006 } +{ by Alexander Tzyganenko, } +{ Fast Reports Inc. } +{ } +{******************************************} + +unit frxrcInsp; + +interface + +implementation + +uses frxRes; + +const resStr = +'propActive=Especifica si un Dataset est abierto o no' + #13#10 + +'propActive.TfrxHighlight=Especifica si el resaltado est activo o no' + #13#10 + +'propAliasName=El nombre del Alias BDE' + #13#10 + +'propAlign=Determina la alineacin del objeto relativa a la banda o la pgina' + #13#10 + +'propAlignment=Justifica el texto de un objeto' + #13#10 + +'propAllowAllUp=Especifica si todos los botones de un grupo pueden estar deseleccionados al mismo tiempo' + #13#10 + +'propAllowEdit=Determina si el usuario puede editar las pginas del informe' + #13#10 + +'propAllowExpressions=Determina si el texto contiene expresiones' + #13#10 + +'propAllowGrayed=Permitir que las casillas de verificacin, tengan el estado indefinido' + #13#10 + +'propAllowHTMLTags=Determina si el texto contiene etiquetas HTML' + #13#10 + +'propAllowSplit=Determina si una banda contiene pginas cruzadas' + #13#10 + +'propAuthor=El autor del informe' + #13#10 + +'propAutoSize.TfrxPictureView=Determina si la imagen debe redimensionarse automticamente' + #13#10 + +'propAutoWidth=Determina si el objeto debe redimensionarse a la longitud del texto' + #13#10 + +'propBackPicture=Imagen de fondo para la pgina' + #13#10 + +'propBarType=Tipo de cdigo de barra' + #13#10 + +'propBevelInner=Tipo de biselado' + #13#10 + +'propBevelOuter=Tipo de biselado' + #13#10 + +'propBevelWidth=Grueso del biselado' + #13#10 + +'propBorder=Determina si se muestra el borde del biselado o no' + #13#10 + +'propBorderStyle=Estilo de ventana' + #13#10 + +'propBottomMargin=Tamao para el margen de abajo' + #13#10 + +'propBrushStyle=Estilo de brocha que se usar para pintar el fondo del objeto' + #13#10 + +'propCalcCheckSum=Determina si el cdigo de barras debe calcular el dgito de control automticamente' + #13#10 + +'propCancel=Determina si el botn debe activarse cuando se pulse la tecla ESCAPE' + #13#10 + +'propCaption=Ttulo del control' + #13#10 + +'propCellFields=Nombres de campos representados en las celdas' + #13#10 + +'propCellLevels=Nmero de celdas del nivel' + #13#10 + +'propCenter=Determina si la imagen deber estar centrada en el control' + #13#10 + +'propCharset=Fuente' + #13#10 + +'propCharSpacing=Cantidad de Pxeles entre dos caracteres' + #13#10 + +'propCheckColor=Color de la marca de verificacin' + #13#10 + +'propChecked=Indica si la casilla del control tiene la marca de seleccin' + #13#10 + +'propCheckStyle=Estilo de marca de seleccin' + #13#10 + +'propChild=Banda hija conectada a esta banda' + #13#10 + +'propClipped=Determines whether the text should be clipped inside the objects bounds' + #13#10 + +'propCollate=Opciones predeterminadas de la colacin' + #13#10 + +'propColor.TFont=Color del texto' + #13#10 + +'propColor=Color del objeto' + #13#10 + +'propColor.TfrxFrame=Color del marco' + #13#10 + +'propColor.TfrxHighlight=Detrmina si el color resaltado del objeto est activo' + #13#10 + +'propColumnFields=Nombre de campos representados en las columnas' + #13#10 + +'propColumnGap=Separacin entre las columnas de la banda' + #13#10 + +'propColumnLevels=Nmero de columnas para este nivel' + #13#10 + +'propColumns=Nmero de columnas en esta banda' + #13#10 + +'propColumnWidth=Ancho de columnas de esta banda' + #13#10 + +'propCondition=Condicin por la que se agrupar. El grupo de romper si el valor de esta expresin cambia' + #13#10 + +'propCondition.TfrxHighlight=Cadena de la expresin. Si esta expresin es verdadera, el resaltado se activar' + #13#10 + +'propConnected=Indica si la conexin con la base de datos est activa' + #13#10 + +'propConvertNulls=Determina si un campo con valor nulo se convertir a 0 o a la cadena "Vaco"' + #13#10 + +'propCopies=Nmero de copias por defecto' + #13#10 + +'propCursor=Tipo de cursor para este objeto' + #13#10 + +'propDatabaseName=Nombre de la base de datos' + #13#10 + +'propDataField=Especifica el campo del cual el objeto obtendr los datos' + #13#10 + +'propDataSet=Dataset ligado a este objeto' + #13#10 + +'propDate=Fecha' + #13#10 + +'propDateFormat=Formato para la fecha' + #13#10 + +'propDecimalSeparator=Separador de decimales' + #13#10 + +'propDefault=Determina si el botn estar seleccionado por defecto' + #13#10 + +'propDefHeight=Alto por defecto para la fila' + #13#10 + +'propDescription.TfrxReportOptions=Descripcin del informe' + #13#10 + +'propDescription=Descripcin de los objetos' + #13#10 + +'propDiagonal=Indica si esta lnea es diagonal' + #13#10 + +'propDisplayFormat=Formato que se usar para la visualizacin de los valores' + #13#10 + +'propDoublePass=Determina si el motor de informes debe hacer una segunda pasada' + #13#10 + +'propDown=Determina si el botn de men est pulsado o no' + #13#10 + +'propDownThenAcross=Determina como de larga ser la tabla cruzada' + #13#10 + +'propDriverName=Nombre del driver del BDE' + #13#10 + +'propDropShadow=Determina si el objeto tiene sombra' + #13#10 + +'propDuplex=Especifica si se activa el modo duplex para esta pgina' + #13#10 + +'propEditMask=Especifica la mscara que se usar para la edicin en este control' + #13#10 + +'propEnabled=Determina si el control estar accesible' + #13#10 + +'propEngineOptions=Opciones del motor de informes' + #13#10 + +'propExpression=Valor de la expresin que contiene el objeto' + #13#10 + +'propExpressionDelimiters=Caracteres que srn usados para delimitar las expresiones contenidas en el texto' + #13#10 + +'propFieldAliases=Campos del dataset' + #13#10 + +'propFilter=Condicin del filtro para el Dataset' + #13#10 + +'propFiltered=Determina si el Dataset debe aplicar el filtro contenido en la propiedad Filter' + #13#10 + +'propFlowTo=The text object that will show the text that not fit in the object' + #13#10 + +'propFont=Fuente usada en este objeto' + #13#10 + +'propFooterAfterEach=Determina si la banda de pie debe mostrarse despus de cada fila de datos' + #13#10 + +'propFormatStr=Formato para texto' + #13#10 + +'propFrame=Atributos para el marco del objeto' + #13#10 + +'propGapX=Indentado a la izquierda para el texto' + #13#10 + +'propGapY=Indentado arriba para el texto' + #13#10 + +'propGlyph=Imagen del control' + #13#10 + +'propGroupIndex=Indica el grupo de botones con los que interactuar el botn' + #13#10 + +'propHAlign=Alineacin horizontal del texto' + #13#10 + +'propHeight=Alto del objeto' + #13#10 + +'propHideZeros=Determina si se mostrar o no el valor cero' + #13#10 + +'propHighlight=Atributos para el resaltado' + #13#10 + +'propIndexName=Nombre del ndice' + #13#10 + +'propInitString=Printer init string for dot-matrix reports' + #13#10 + +'propItems=Lista de items' + #13#10 + +'propKeepAspectRatio=Mantener el aspecto original de la imagen' + #13#10 + +'propKeepChild=Determina si la banda ha de imprimirse junto a su hija' + #13#10 + +'propKeepFooter=Determina si la banda ha de imprimirse junto a su pie' + #13#10 + +'propKeepTogether=Determina si la banda ha de imprimirse junto a todas sus subbandas' + #13#10 + +'propKind.TfrxFormat=Tipo de formateo' + #13#10 + +'propKind=The kind of the button' + #13#10 + +'propLargeDesignHeight=Determines whether the page will have large height in the design mode' + #13#10 + +'propLayout=Disposicin de la imagen en el botn' + #13#10 + +'propLeft=Posicin izquierda del objeto' + #13#10 + +'propLeftMargin=Tamao del margen izquierdo de la pgina' + #13#10 + +'propLines=Texto del objeto' + #13#10 + +'propLineSpacing=Nmero de pxeles entre dos lneas de texto' + #13#10 + +'propLoginPrompt=Dtermina si se mostrar el dilogo de peticin de login' + #13#10 + +'propMargin=Determina el nmero de pxeles entre el borde de la imagen y el borde del botn' + #13#10 + +'propMaster=Dataset maestro' + #13#10 + +'propMasterFields=Campos por los que se establece la relacin Maestro-Detalle' + #13#10 + +'propMaxLength=Mxima longitud del texto' + #13#10 + +'propMaxWidth=Anchura mxima de la columna' + #13#10 + +'propMemo=Texto del objeto' + #13#10 + +'propMinWidth=Anchura mnima de la columna' + #13#10 + +'propMirrorMargins=Mrgenes de pgina iguales en las pginas pares' + #13#10 + +'propModalResult=Determina el valor que devolver cuando se cierre con este botn una ventana modal' + #13#10 + +'propName.TFont=Nombre de la fuente' + #13#10 + +'propName.TfrxReportOptions=Nombre del informe' + #13#10 + +'propName=Nombre del objeto' + #13#10 + +'propNumGlyphs=Indica el nmero de imgenes contenidas en la imagen indicada en la propiedad Glyph' + #13#10 + +'propOpenDataSource=Determina si la fuente de datos ser abierta automticamente o no' + #13#10 + +'propOrientation=Orientacin de la pgina' + #13#10 + +'propOutlineText=Texto que se mostrar en el ndice de la vista previa' + #13#10 + +'propOutlineVisible=Indica si se mostrar el ndice en la vista previa' + #13#10 + +'propOutlineWidth=Anchura que ocupar el ndice en la vista previa' + #13#10 + +'propPageNumbers.TfrxPrintOptions=Nmero de pginas que se imprimirn' + #13#10 + +'propPaperHeight=Alto de la pgina' + #13#10 + +'propPaperWidth=Ancho de la pgina' + #13#10 + +'propParagraphGap=Indentacin para la primera lnea del prrafo' + #13#10 + +'propParams.TfrxBDEDatabase=Parmetros de la conexin' + #13#10 + +'propParams=Parmetros de la consulta' + #13#10 + +'propParentFont=Indica si el objeto usar la misma fuente que su contenedor' + #13#10 + +'propPassword=Contrasea del informe' + #13#10 + +'propPasswordChar=Indica el caracter que se mostrar en sustitucin de los que realmente se teclean' + #13#10 + +'propPicture=Imagen' + #13#10 + +'propPicture.TfrxReportOptions=Imagen que describe el informe' + #13#10 + +'propPosition=Posicin inicial de la ventana' + #13#10 + +'propPreviewOptions=Opciones de vista previa del informe' + #13#10 + +'propPrintable=Indica si el objeto es imprimible. Si se establece a False, el objeto ser mostrado en la vista previa, pero no se imprimir' + #13#10 + +'propPrintChildIfInvisible=Indica si la banda hija se imprimir en el caso de que la banda padre sea invisible' + #13#10 + +'propPrinter=Nombre de la impresora que aparecer seleccionada al abrir o ejecutar el informe' + #13#10 + +'propPrintIfDetailEmpty=Indica si la banda de datos se imprimir en el caso de que sus subbandas estn vacas' + #13#10 + +'propPrintIfEmpty=Indica si la pgina se imprimir en el caso de que los Datasets estn vacos' + #13#10 + +'propPrintOnFirstPage=Indica si la banda se imprimir en la primera pgina' + #13#10 + +'propPrintOnLastPage=Indica si la banda se imprimir en la ltima pgina' + #13#10 + +'propPrintOnParent=Determina si el subreport se puede imprimir en la banda padre' + #13#10 + +'propPrintOnPreviousPage=Determina si la pgina se puede generar en el espacio libre de la pgina previamente generada' + #13#10 + +'propPrintOptions=Opciones de impresin del informe' + #13#10 + +'propPrintPages=Determina si se imprime todo o solo las pginas pares o las impares' + #13#10 + +'propRangeBegin=Determina el punto de comienzo en la navegacin en el dataset' + #13#10 + +'propRangeEnd=Determina el punto de terminacin en la navegacin en el dataset' + #13#10 + +'propRangeEndCount=Determina el nmero de registros que se leern del Dataset Si la propiedad RangeEnd es reCount' + #13#10 + +'propReadOnly=Determina si el texto del objeto es de solo lectura' + #13#10 + +'propRepeatHeaders=Determina si la columna y la fila de cabecera s4e imprimir en la pgina nueva' + #13#10 + +'propReportOptions=Opciones del informe' + #13#10 + +'propReprintOnNewPage=Determina si la banda ser reimpresa en la nueva pgina' + #13#10 + +'propRestrictions=Establecer restricciones' + #13#10 + +'propRightMargin=Tamao del margen derecho de la pgina' + #13#10 + +'propRotation.TfrxBarCodeView=Orientacin del cdigo de barras' + #13#10 + +'propRotation=Rotacin del texto' + #13#10 + +'propRowCount=Nmero de registros virtuales en la banda de datos' + #13#10 + +'propRowFields=Nombres de campos que representan las filas cruzadas' + #13#10 + +'propRowLevels=Nmero de niveles en la fila' + #13#10 + +'propRTLReading=Determina si el texto del objeto, se pintar de derecha a izquierda' + #13#10 + +'propSessionName=Nombre de la sesin del BDE' + #13#10 + +'propShadowColor=Color de la sombra' + #13#10 + +'propShadowWidth=Ancho de la sombra' + #13#10 + +'propShape=Tipo de dibujo' + #13#10 + +'propShiftMode=Cambia el comportamiento del objeto' + #13#10 + +'propShowColumnHeader=Determina si se mostrarn las cabeceras de columna en los cruces' + #13#10 + +'propShowColumnTotal=Determina si se mostrar la columna de Total' + #13#10 + +'propShowRowHeader=Determina si se mostrarn las cabeceras de fila' + #13#10 + +'propShowRowTotal=Determina si se mostrar la fila de Total' + #13#10 + +'propShowDialog=Determina si se mostrar el dilogo de impresin en la vista previa' + #13#10 + +'propShowText=Determina si se mostrar el texto del cdigo de barras' + #13#10 + +'propSize=Tamao de fuente' + #13#10 + +'propSorted=Determina si los items sern ordenados o no' + #13#10 + +'propSpacing=Determina el nmero de pxeles entre la imagen y el texto' + #13#10 + +'propSQL=Sentencia SQL' + #13#10 + +'propStartNewPage=Lanzar una nueva pgina antes de imprimir la banda' + #13#10 + +'propStretch=Ajusta la imagen a los lmetes del objeto' + #13#10 + +'propStretched=Determina si el objeto puede ser ajustado' + #13#10 + +'propStretchMode=Comportamiento del ajuste al objeto' + #13#10 + +'propStyle.TFont=Estilo de fuente' + #13#10 + +'propStyle=Estilo de control' + #13#10 + +'propStyle.TfrxFrame=Estilo del marco' + #13#10 + +'propSuppressRepeated=Suprime los valores repetidos' + #13#10 + +'propTableName=Nombre de la tabla de datos' + #13#10 + +'propTag=Tag' + #13#10 + +'propTagStr=Tag string of the object' + #13#10 + +'propText=Texto del objeto' + #13#10 + +'propTitleBeforeHeader=Determina si se mostrar el ttulo del informe antes de la cabecera de pgina' + #13#10 + +'propTop=Posicin arriba del objeto' + #13#10 + +'propTopMargin=Tamao del margen arriba de la pgina' + #13#10 + +'propTyp=Tipo de marco' + #13#10 + +'propUnderlines=Determina si el texto aparecer subrayado' + #13#10 + +'propURL=URL del objeto' + #13#10 + +'propUserName=Nombre del usuario. Este nombre ser usado para mostrarlo en el rbol de datos' + #13#10 + +'propVAlign=Alineacin vertical del texto' + #13#10 + +'propVersionBuild=Informacin de versin' + #13#10 + +'propVersionMajor=Informacin de versin, mayor version' + #13#10 + +'propVersionMinor=Informacin de versin info, menor version' + #13#10 + +'propVersionRelease=Informacin de versin' + #13#10 + +'propVisible=Indica si el objeto se ver o no' + #13#10 + +'propWidth=Anchura del objeto' + #13#10 + +'propWidth.TfrxFrame=Anchura del marco' + #13#10 + +'propWindowState=Estado inicial de la ventana' + #13#10 + +'propWordBreak=Break russian words' + #13#10 + +'propWordWrap=Determina si se insertarn retornos de carro en el texto cuando la longitud de este sobrepase el margen derecho' + #13#10 + +'propZoom.TfrxBarCodeView=Zoom del cdigo de barras' + #13#10 + +'propKeepHeader=Determina si la banda se imprimir junto a su banda de cabecera' + #13#10 + +'propConnectionName=Nombre de la conexin con la base de datos usada en el informe' + #13#10 + +'propCurve=Curvatura de los angulos redondeados del rectngulo' + #13#10 + +'propDrillDown=Determina si el grupo puede ser perforado abajo' + #13#10 + +'propFontStyle=Fuentes Estilo Matricial' + #13#10 + +'propHideIfSingleDataRecord=Ocultar el pie si el grupo solo tiene una fila' + #13#10 + +'propOutlineExpand=Determines whether to expand the report outline or not' + #13#10 + +'propPlainCells=Determina si se imprimen varias celdas de lado a lado o apiladas' + #13#10 + +'propPrintMode=Print mode: normal, split big pages to small one, or print several small pages on a big one' + #13#10 + +'propPrintOnSheet=Tamao del papel. Usado si PrintMode no es pmDefault' + #13#10 + +'propResetPageNumbers=Reinicializa el nmero de pginas/total pginas cuando se imprime el grupo.' + #13#10 + +'Reset page number/total pages numbers when print a group. Debe ser usado con StartNewPage = TRUE' + #13#10 + +'propReverse=Determina si las pginas se imprimirn en orden descendente' + #13#10 + +'propShowFooterIfDrillDown=Determina si se ha de mostrar el pie de grupo si el grupo es drilldown' + #13#10 + +'propSizeMode=Como mostrar el Objeto OLE' + #13#10 + +'propVersion=Versin de FastReport' + #13#10 + +'propWideBarRatio=Relative with of wide bars of the barcode' + #13#10 + +'propWysiwyg=Determina si un objeto Richview debe usar la impresora para formatear el texto. Una impresora debe estar instalada y lista.' + #13#10 + +'propArrowEnd=Determina si se debe dibujar una flecha en el extremo de la lnea.' + #13#10 + +'propArrowLength=Longitud de la flecha' + #13#10 + +'propArrowSolid=Determina si la flecha a dibujar ser slida' + #13#10 + +'propArrowStart=Determina si se ha de dibujar una flecha en el comienzo de la lnea' + #13#10 + +'propArrowWidth=Anchura de la flecha' + #13#10 + +'propCloseDataSource=Determina si se ha de cerrar el DataSet cuando se cierre el informe' + #13#10 + +'propDatabase=Conexin a la Base de Datos' + #13#10 + +'propIndexFieldNames=Nombre del Indice' + #13#10 + +'propCommandTimeOut=Cantidad de tiempo necesario para ejecutar una consulta' + #13#10 + +'propExpandDrillDown=Determines whether to expand all drill-down elements at first start of a report' + #13#10 + +'propWysiwyg.TfrxMemoView=Determina si el texto se ver tal y como se v' + #13#10 + +'propLeftLine=Lnea Izquierda del marco' + #13#10 + +'propTopLine=Lnea de arriba del marco' + #13#10 + +'propRightLine=Lnea derecha del marco' + #13#10 + +'propBottomLine=Lnea de abajo del marco' + #13#10 + +'propColor.TfrxFrameLine=Color de la lnea del marco' + #13#10 + +'propStyle.TfrxFrameLine=Estilo de la lnea del marco' + #13#10 + +'propWidth.TfrxFrameLine=Anchura de la lnea del marco' + #13#10 + +'propFileLink=Expresin o nombre del archivo que contiene la imagen' + #13#10 + +'propEndlessWidth=Modo sin fin de la pgina. Si se configura a TRUE, la pgina crecer dependiendo del nmero de registros de datos' + #13#10 + +'propEndlessHeight=Modo sin fin de la pgina. Si se configura a TRUE, la pgina crecer dependiendo del nmero de registros de datos' + #13#10 + +'propAddHeight=Agrega la cantidad de espacio especificada a la altura de la celda' + #13#10 + +'propAddWidth=Agrega la cantidad de espacio especificada a la anchura de la celda' + #13#10 + +'propAllowDuplicates=Determina si la celda puede aceptar valores duplicados' + #13#10 + +'propJoinEqualCells=Determina si los datos cruzados deben ensamblar las celdas con datos iguales' + #13#10 + +'propNextCross=Pointer to the next crosstab that will be displayed side-by-side' + #13#10 + +'propNextCrossGap=Gap between side-by-side crosstabs' + #13#10 + +'propShowCorner=Determines whether the crosstab should display a left-top corner elements' + #13#10 + +'propSuppressNullRecords=!Determines if the crosstab should suppress records with all NULL values' + #13#10 + +'propShowTitle=!Determines if the crosstab should display a title' + #13#10 + +'propAutoSize=!Determines if the crosstab should handle its size automatically' + #13#10 + +''; + +initialization + frxResources.AddStrings(resStr); + +end. diff --git a/official/4.2/LibD11/fs.inc b/official/4.2/LibD11/fs.inc new file mode 100644 index 0000000..0b562ba --- /dev/null +++ b/official/4.2/LibD11/fs.inc @@ -0,0 +1,157 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Include file } +{ } +{ (c) 2003, 2004 by Alexander Tzyganenko, } +{ Fast Reports, Inc } +{ } +{******************************************} + + +{$R-} {- Range-Checking } +{$H+} {- Use long strings by default } +{$B-} {- Complete Boolean Evaluation } +{$T-} {- Typed @ operator } +{$P+} {- Open string params } + +{$IFNDEF FPC} + {$V-} {- Var-String Checking } + {$X+} {- Extended syntax } + {$J+} {- Writeable structured consts } +{$ENDIF} + +{$IFDEF VER120} // Delphi 4.0 + {$DEFINE Delphi4} +{$ENDIF} + +{$IFDEF VER130} // Delphi 5.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} +{$ENDIF} + +{$IFDEF VER140} // Delphi 6.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} +{$ENDIF} + +{$IFDEF VER150} // Delphi 7.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} +{$ENDIF} + +{$IFDEF VER170} // Delphi 9.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN SYMBOL_DEPRECATED OFF} +{$ENDIF} + +{$IFDEF VER180} // Delphi 10.0 + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$DEFINE Delphi10} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN SYMBOL_DEPRECATED OFF} +{$ENDIF} + +{$IFDEF VER185} // Delphi 11.0 (Spacely) + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$DEFINE Delphi10} + {$DEFINE Delphi11} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN SYMBOL_DEPRECATED OFF} +{$ENDIF} + +{$IFDEF VER190} // Delphi 11.0 (Highlander) + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE Delphi7} + {$DEFINE Delphi9} + {$DEFINE Delphi10} + {$DEFINE Delphi11} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} + {$WARN SYMBOL_DEPRECATED OFF} +{$ENDIF} + +{$IFDEF VER125} // Borland C++ Builder 4.0 + {$DEFINE Delphi4} + {$ObjExportAll on} +{$ENDIF} + +{$IFDEF VER130} // Borland C++ Builder 5.0 + {$IFDEF BCB} + {$ObjExportAll on} + {$ENDIF} +{$ENDIF} + +{$IFDEF VER140} // Borland C++ Builder 6.0 + {$IFDEF BCB} + {$ObjExportAll on} + {$ENDIF} +{$ENDIF} + +{$IFDEF VER150} // Borland C++ Builder 7.0 + {$IFDEF BCB} + {$ObjExportAll on} + {$ENDIF} +{$ENDIF} + +{$IFDEF FPC} // Free pascal compiler + {$MODE DELPHI} + + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} +{$ELSE} + {$IFDEF LINUX} // KYLIX + {$DEFINE Delphi4} + {$DEFINE Delphi5} + {$DEFINE Delphi6} + {$DEFINE CLX} + {$IFDEF BCB} + {$DEFINE CLXCPP} + {$ENDIF} + {$ENDIF} +{$ENDIF} + +{$IFDEF FPC} + {$DEFINE CROSS_COMPILE} +{$ENDIF} + +{$IFDEF CLX} + {$DEFINE CROSS_COMPILE} +{$ENDIF} + +// Uncomment below line for CLX compilation +//{$DEFINE CLX} + +// include ole dispatch module +{$IFNDEF CROSS_COMPILE} + {$DEFINE OLE} +{$ENDIF} diff --git a/official/4.2/LibD11/fs10.bdsproj b/official/4.2/LibD11/fs10.bdsproj new file mode 100644 index 0000000..78c733f --- /dev/null +++ b/official/4.2/LibD11/fs10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fs10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fs10.dpk b/official/4.2/LibD11/fs10.dpk new file mode 100644 index 0000000..44f0b04 --- /dev/null +++ b/official/4.2/LibD11/fs10.dpk @@ -0,0 +1,66 @@ +// Package file for Delphi 2006 + +package fs10; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLX; + + +contains + fs_ipascal in 'fs_ipascal.pas', + fs_icpp in 'fs_icpp.pas', + fs_ijs in 'fs_ijs.pas', + fs_ibasic in 'fs_ibasic.pas', + + fs_iclassesrtti in 'fs_iclassesrtti.pas', + fs_iconst in 'fs_iconst.pas', + fs_idialogsrtti in 'fs_idialogsrtti.pas', +{$IFDEF OLE} + fs_idisp in 'fs_idisp.pas', +{$ENDIF} + fs_ievents in 'fs_ievents.pas', + fs_iexpression in 'fs_iexpression.pas', + fs_iextctrlsrtti in 'fs_iextctrlsrtti.pas', + fs_iformsrtti in 'fs_iformsrtti.pas', + fs_igraphicsrtti in 'fs_igraphicsrtti.pas', + fs_iilparser in 'fs_iilparser.pas', + fs_iinirtti in 'fs_iinirtti.pas', + fs_iinterpreter in 'fs_iinterpreter.pas', + fs_iparser in 'fs_iparser.pas', + fs_isysrtti in 'fs_isysrtti.pas', + fs_imenusrtti in 'fs_imenusrtti.pas', + fs_itools in 'fs_itools.pas', + fs_xml in 'fs_xml.pas', + fs_synmemo in 'fs_synmemo.pas', + fs_tree in 'fs_tree.pas'; + + + +end. diff --git a/official/4.2/LibD11/fs11.bdsproj b/official/4.2/LibD11/fs11.bdsproj new file mode 100644 index 0000000..b3494e9 --- /dev/null +++ b/official/4.2/LibD11/fs11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fs11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fs11.dpk b/official/4.2/LibD11/fs11.dpk new file mode 100644 index 0000000..b993ab0 --- /dev/null +++ b/official/4.2/LibD11/fs11.dpk @@ -0,0 +1,66 @@ +// Package file for Delphi 2007 + +package fs11; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLX; + + +contains + fs_ipascal in 'fs_ipascal.pas', + fs_icpp in 'fs_icpp.pas', + fs_ijs in 'fs_ijs.pas', + fs_ibasic in 'fs_ibasic.pas', + + fs_iclassesrtti in 'fs_iclassesrtti.pas', + fs_iconst in 'fs_iconst.pas', + fs_idialogsrtti in 'fs_idialogsrtti.pas', +{$IFDEF OLE} + fs_idisp in 'fs_idisp.pas', +{$ENDIF} + fs_ievents in 'fs_ievents.pas', + fs_iexpression in 'fs_iexpression.pas', + fs_iextctrlsrtti in 'fs_iextctrlsrtti.pas', + fs_iformsrtti in 'fs_iformsrtti.pas', + fs_igraphicsrtti in 'fs_igraphicsrtti.pas', + fs_iilparser in 'fs_iilparser.pas', + fs_iinirtti in 'fs_iinirtti.pas', + fs_iinterpreter in 'fs_iinterpreter.pas', + fs_iparser in 'fs_iparser.pas', + fs_isysrtti in 'fs_isysrtti.pas', + fs_imenusrtti in 'fs_imenusrtti.pas', + fs_itools in 'fs_itools.pas', + fs_xml in 'fs_xml.pas', + fs_synmemo in 'fs_synmemo.pas', + fs_tree in 'fs_tree.pas'; + + + +end. diff --git a/official/4.2/LibD11/fs4.bpk b/official/4.2/LibD11/fs4.bpk new file mode 100644 index 0000000..fd7b16a --- /dev/null +++ b/official/4.2/LibD11/fs4.bpk @@ -0,0 +1,187 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = FS4.bpl +OBJFILES = fs_iReg.obj FS4.obj fs_iconst.obj +RESFILES = FS4.res fs_iReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +PACKAGES = vcl40.bpi vclx40.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -D"FastScript 1.9 Components" -aa -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fs4.cpp b/official/4.2/LibD11/fs4.cpp new file mode 100644 index 0000000..43953d6 --- /dev/null +++ b/official/4.2/LibD11/fs4.cpp @@ -0,0 +1,19 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("FS4.res"); +USEPACKAGE("vcl40.bpi"); +USEPACKAGE("vclx40.bpi"); +USEUNIT("fs_iReg.pas"); +USEUNIT("fs_iconst.pas"); +USERES("fs_iReg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fs4.dpk b/official/4.2/LibD11/fs4.dpk new file mode 100644 index 0000000..0397c54 --- /dev/null +++ b/official/4.2/LibD11/fs4.dpk @@ -0,0 +1,65 @@ +// Package file for Delphi 4 + +package fs4; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + VCLX40; + + +contains + fs_ipascal in 'fs_ipascal.pas', + fs_icpp in 'fs_icpp.pas', + fs_ijs in 'fs_ijs.pas', + fs_ibasic in 'fs_ibasic.pas', + + fs_iclassesrtti in 'fs_iclassesrtti.pas', + fs_iconst in 'fs_iconst.pas', + fs_idialogsrtti in 'fs_idialogsrtti.pas', +{$IFDEF OLE} + fs_idisp in 'fs_idisp.pas', +{$ENDIF} + fs_ievents in 'fs_ievents.pas', + fs_iexpression in 'fs_iexpression.pas', + fs_iextctrlsrtti in 'fs_iextctrlsrtti.pas', + fs_iformsrtti in 'fs_iformsrtti.pas', + fs_igraphicsrtti in 'fs_igraphicsrtti.pas', + fs_iilparser in 'fs_iilparser.pas', + fs_iinirtti in 'fs_iinirtti.pas', + fs_iinterpreter in 'fs_iinterpreter.pas', + fs_iparser in 'fs_iparser.pas', + fs_isysrtti in 'fs_isysrtti.pas', + fs_imenusrtti in 'fs_imenusrtti.pas', + fs_itools in 'fs_itools.pas', + fs_xml in 'fs_xml.pas', + fs_synmemo in 'fs_synmemo.pas', + fs_tree in 'fs_tree.pas'; + + +end. diff --git a/official/4.2/LibD11/fs4.res b/official/4.2/LibD11/fs4.res new file mode 100644 index 0000000..eb2597a Binary files /dev/null and b/official/4.2/LibD11/fs4.res differ diff --git a/official/4.2/LibD11/fs5.bpk b/official/4.2/LibD11/fs5.bpk new file mode 100644 index 0000000..8b10919 --- /dev/null +++ b/official/4.2/LibD11/fs5.bpk @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fs5.cpp b/official/4.2/LibD11/fs5.cpp new file mode 100644 index 0000000..daadee8 --- /dev/null +++ b/official/4.2/LibD11/fs5.cpp @@ -0,0 +1,23 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("FS5.res"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vclx50.bpi"); +USEUNIT("fs_ireg.pas"); +USEUNIT("fs_iconst.pas"); +USERES("fs_iReg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fs5.dpk b/official/4.2/LibD11/fs5.dpk new file mode 100644 index 0000000..c803adb --- /dev/null +++ b/official/4.2/LibD11/fs5.dpk @@ -0,0 +1,66 @@ +// Package file for Delphi 5 + +package fs5; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + VCLX50; + + +contains + fs_ipascal in 'fs_ipascal.pas', + fs_icpp in 'fs_icpp.pas', + fs_ijs in 'fs_ijs.pas', + fs_ibasic in 'fs_ibasic.pas', + + fs_iclassesrtti in 'fs_iclassesrtti.pas', + fs_iconst in 'fs_iconst.pas', + fs_idialogsrtti in 'fs_idialogsrtti.pas', +{$IFDEF OLE} + fs_idisp in 'fs_idisp.pas', +{$ENDIF} + fs_ievents in 'fs_ievents.pas', + fs_iexpression in 'fs_iexpression.pas', + fs_iextctrlsrtti in 'fs_iextctrlsrtti.pas', + fs_iformsrtti in 'fs_iformsrtti.pas', + fs_igraphicsrtti in 'fs_igraphicsrtti.pas', + fs_iilparser in 'fs_iilparser.pas', + fs_iinirtti in 'fs_iinirtti.pas', + fs_iinterpreter in 'fs_iinterpreter.pas', + fs_iparser in 'fs_iparser.pas', + fs_isysrtti in 'fs_isysrtti.pas', + fs_imenusrtti in 'fs_imenusrtti.pas', + fs_itools in 'fs_itools.pas', + fs_xml in 'fs_xml.pas', + fs_synmemo in 'fs_synmemo.pas', + fs_tree in 'fs_tree.pas'; + + + +end. diff --git a/official/4.2/LibD11/fs5.res b/official/4.2/LibD11/fs5.res new file mode 100644 index 0000000..da3d366 Binary files /dev/null and b/official/4.2/LibD11/fs5.res differ diff --git a/official/4.2/LibD11/fs6.bpk b/official/4.2/LibD11/fs6.bpk new file mode 100644 index 0000000..822a6d2 --- /dev/null +++ b/official/4.2/LibD11/fs6.bpk @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Excluded Packages] +d:\delphi\builder6\Projects\Bpl\FR6.bpl=FastReport 2.4 Components + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fs6.cpp b/official/4.2/LibD11/fs6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/fs6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/fs6.dpk b/official/4.2/LibD11/fs6.dpk new file mode 100644 index 0000000..425a1b9 --- /dev/null +++ b/official/4.2/LibD11/fs6.dpk @@ -0,0 +1,66 @@ +// Package file for Delphi 6 + +package fs6; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLX; + + +contains + fs_ipascal in 'fs_ipascal.pas', + fs_icpp in 'fs_icpp.pas', + fs_ijs in 'fs_ijs.pas', + fs_ibasic in 'fs_ibasic.pas', + + fs_iclassesrtti in 'fs_iclassesrtti.pas', + fs_iconst in 'fs_iconst.pas', + fs_idialogsrtti in 'fs_idialogsrtti.pas', +{$IFDEF OLE} + fs_idisp in 'fs_idisp.pas', +{$ENDIF} + fs_ievents in 'fs_ievents.pas', + fs_iexpression in 'fs_iexpression.pas', + fs_iextctrlsrtti in 'fs_iextctrlsrtti.pas', + fs_iformsrtti in 'fs_iformsrtti.pas', + fs_igraphicsrtti in 'fs_igraphicsrtti.pas', + fs_iilparser in 'fs_iilparser.pas', + fs_iinirtti in 'fs_iinirtti.pas', + fs_iinterpreter in 'fs_iinterpreter.pas', + fs_iparser in 'fs_iparser.pas', + fs_isysrtti in 'fs_isysrtti.pas', + fs_imenusrtti in 'fs_imenusrtti.pas', + fs_itools in 'fs_itools.pas', + fs_xml in 'fs_xml.pas', + fs_synmemo in 'fs_synmemo.pas', + fs_tree in 'fs_tree.pas'; + + + +end. diff --git a/official/4.2/LibD11/fs6.res b/official/4.2/LibD11/fs6.res new file mode 100644 index 0000000..2bbdbc1 Binary files /dev/null and b/official/4.2/LibD11/fs6.res differ diff --git a/official/4.2/LibD11/fs7.dpk b/official/4.2/LibD11/fs7.dpk new file mode 100644 index 0000000..623a47e --- /dev/null +++ b/official/4.2/LibD11/fs7.dpk @@ -0,0 +1,66 @@ +// Package file for Delphi 7 + +package fs7; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLX; + + +contains + fs_ipascal in 'fs_ipascal.pas', + fs_icpp in 'fs_icpp.pas', + fs_ijs in 'fs_ijs.pas', + fs_ibasic in 'fs_ibasic.pas', + + fs_iclassesrtti in 'fs_iclassesrtti.pas', + fs_iconst in 'fs_iconst.pas', + fs_idialogsrtti in 'fs_idialogsrtti.pas', +{$IFDEF OLE} + fs_idisp in 'fs_idisp.pas', +{$ENDIF} + fs_ievents in 'fs_ievents.pas', + fs_iexpression in 'fs_iexpression.pas', + fs_iextctrlsrtti in 'fs_iextctrlsrtti.pas', + fs_iformsrtti in 'fs_iformsrtti.pas', + fs_igraphicsrtti in 'fs_igraphicsrtti.pas', + fs_iilparser in 'fs_iilparser.pas', + fs_iinirtti in 'fs_iinirtti.pas', + fs_iinterpreter in 'fs_iinterpreter.pas', + fs_iparser in 'fs_iparser.pas', + fs_isysrtti in 'fs_isysrtti.pas', + fs_imenusrtti in 'fs_imenusrtti.pas', + fs_itools in 'fs_itools.pas', + fs_xml in 'fs_xml.pas', + fs_synmemo in 'fs_synmemo.pas', + fs_tree in 'fs_tree.pas'; + + + +end. diff --git a/official/4.2/LibD11/fs9.bdsproj b/official/4.2/LibD11/fs9.bdsproj new file mode 100644 index 0000000..6cd3ca1 --- /dev/null +++ b/official/4.2/LibD11/fs9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fs9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fs9.dpk b/official/4.2/LibD11/fs9.dpk new file mode 100644 index 0000000..7dfd9b9 --- /dev/null +++ b/official/4.2/LibD11/fs9.dpk @@ -0,0 +1,66 @@ +// Package file for Delphi 2005 + +package fs9; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLX; + + +contains + fs_ipascal in 'fs_ipascal.pas', + fs_icpp in 'fs_icpp.pas', + fs_ijs in 'fs_ijs.pas', + fs_ibasic in 'fs_ibasic.pas', + + fs_iclassesrtti in 'fs_iclassesrtti.pas', + fs_iconst in 'fs_iconst.pas', + fs_idialogsrtti in 'fs_idialogsrtti.pas', +{$IFDEF OLE} + fs_idisp in 'fs_idisp.pas', +{$ENDIF} + fs_ievents in 'fs_ievents.pas', + fs_iexpression in 'fs_iexpression.pas', + fs_iextctrlsrtti in 'fs_iextctrlsrtti.pas', + fs_iformsrtti in 'fs_iformsrtti.pas', + fs_igraphicsrtti in 'fs_igraphicsrtti.pas', + fs_iilparser in 'fs_iilparser.pas', + fs_iinirtti in 'fs_iinirtti.pas', + fs_iinterpreter in 'fs_iinterpreter.pas', + fs_iparser in 'fs_iparser.pas', + fs_isysrtti in 'fs_isysrtti.pas', + fs_imenusrtti in 'fs_imenusrtti.pas', + fs_itools in 'fs_itools.pas', + fs_xml in 'fs_xml.pas', + fs_synmemo in 'fs_synmemo.pas', + fs_tree in 'fs_tree.pas'; + + + +end. diff --git a/official/4.2/LibD11/fsADO10.bdsproj b/official/4.2/LibD11/fsADO10.bdsproj new file mode 100644 index 0000000..34727e5 --- /dev/null +++ b/official/4.2/LibD11/fsADO10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsADO10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsADO10.dpk b/official/4.2/LibD11/fsADO10.dpk new file mode 100644 index 0000000..d44b469 --- /dev/null +++ b/official/4.2/LibD11/fsADO10.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 2006 + +package fsADO10; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + fs10, + fsDB10; + +contains + fs_iadortti in 'fs_iadortti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsADO11.bdsproj b/official/4.2/LibD11/fsADO11.bdsproj new file mode 100644 index 0000000..79495ed --- /dev/null +++ b/official/4.2/LibD11/fsADO11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsADO11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsADO11.dpk b/official/4.2/LibD11/fsADO11.dpk new file mode 100644 index 0000000..3a61b1e --- /dev/null +++ b/official/4.2/LibD11/fsADO11.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 2007 + +package fsADO11; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + fs11, + fsDB11; + +contains + fs_iadortti in 'fs_iadortti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsADO5.bpk b/official/4.2/LibD11/fsADO5.bpk new file mode 100644 index 0000000..5aa3c2b --- /dev/null +++ b/official/4.2/LibD11/fsADO5.bpk @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsADO5.cpp b/official/4.2/LibD11/fsADO5.cpp new file mode 100644 index 0000000..1701cde --- /dev/null +++ b/official/4.2/LibD11/fsADO5.cpp @@ -0,0 +1,25 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("FS5.res"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vcldb50.bpi"); +USEPACKAGE("vclado50.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("fsDB5.bpi"); +USEUNIT("fs_iadoreg.pas"); +USERES("fs_iReg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsADO5.dpk b/official/4.2/LibD11/fsADO5.dpk new file mode 100644 index 0000000..9e0732a --- /dev/null +++ b/official/4.2/LibD11/fsADO5.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 5 + +package fsADO5; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + VCLDB50, + VCLADO50, + fs5, + fsDB5; + +contains + fs_iadortti in 'fs_iadortti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsADO6.bpk b/official/4.2/LibD11/fsADO6.bpk new file mode 100644 index 0000000..324e945 --- /dev/null +++ b/official/4.2/LibD11/fsADO6.bpk @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Excluded Packages] + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsADO6.cpp b/official/4.2/LibD11/fsADO6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/fsADO6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/fsADO6.dpk b/official/4.2/LibD11/fsADO6.dpk new file mode 100644 index 0000000..0397a08 --- /dev/null +++ b/official/4.2/LibD11/fsADO6.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 6 + +package fsADO6; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + fs6, + fsDB6; + +contains + fs_iadortti in 'fs_iadortti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsADO7.dpk b/official/4.2/LibD11/fsADO7.dpk new file mode 100644 index 0000000..3975c14 --- /dev/null +++ b/official/4.2/LibD11/fsADO7.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 7 + +package fsADO7; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + fs7, + fsDB7; + +contains + fs_iadortti in 'fs_iadortti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsADO9.bdsproj b/official/4.2/LibD11/fsADO9.bdsproj new file mode 100644 index 0000000..9d0a211 --- /dev/null +++ b/official/4.2/LibD11/fsADO9.bdsproj @@ -0,0 +1,168 @@ + + + + + + + + + + + + fsADO9.dpk + + + 7.0 + + + 8 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + False + False + False + True + True + True + + + 0 + 0 + 1 + False + False + False + 16384 + 1048576 + 4194304 + + + + + + + + + + + + False + + + + + + False + + + + + + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + diff --git a/official/4.2/LibD11/fsADO9.dpk b/official/4.2/LibD11/fsADO9.dpk new file mode 100644 index 0000000..92811e4 --- /dev/null +++ b/official/4.2/LibD11/fsADO9.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 2005 + +package fsADO9; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + ADORTL, + fs9, + fsDB9; + +contains + fs_iadortti in 'fs_iadortti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsBDE10.bdsproj b/official/4.2/LibD11/fsBDE10.bdsproj new file mode 100644 index 0000000..f085ba5 --- /dev/null +++ b/official/4.2/LibD11/fsBDE10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsBDE10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsBDE10.dpk b/official/4.2/LibD11/fsBDE10.dpk new file mode 100644 index 0000000..b731095 --- /dev/null +++ b/official/4.2/LibD11/fsBDE10.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 2006 + +package fsBDE10; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + fs10, + fsDB10; + +contains + fs_ibdertti in 'fs_ibdertti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsBDE11.bdsproj b/official/4.2/LibD11/fsBDE11.bdsproj new file mode 100644 index 0000000..7ec05f1 --- /dev/null +++ b/official/4.2/LibD11/fsBDE11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsBDE11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsBDE11.dpk b/official/4.2/LibD11/fsBDE11.dpk new file mode 100644 index 0000000..999e182 --- /dev/null +++ b/official/4.2/LibD11/fsBDE11.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 2007 + +package fsBDE11; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + fs11, + fsDB11; + +contains + fs_ibdertti in 'fs_ibdertti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsBDE4.bpk b/official/4.2/LibD11/fsBDE4.bpk new file mode 100644 index 0000000..72be8ad --- /dev/null +++ b/official/4.2/LibD11/fsBDE4.bpk @@ -0,0 +1,187 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = FSBDE4.bpl +OBJFILES = fs_iReg.obj FSBDE4.obj +RESFILES = FS4.res fs_iReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +PACKAGES = vcl40.bpi vcldb40.bpi fs4.bpi fsDB4.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -D"FastScript 1.9 BDE Components" -aa -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsBDE4.cpp b/official/4.2/LibD11/fsBDE4.cpp new file mode 100644 index 0000000..cb7bb1d --- /dev/null +++ b/official/4.2/LibD11/fsBDE4.cpp @@ -0,0 +1,20 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("FS4.res"); +USEPACKAGE("vcl40.bpi"); +USEPACKAGE("vcldb40.bpi"); +USEPACKAGE("fs4.bpi"); +USEPACKAGE("fsDB4.bpi"); +USEUNIT("fs_ibdereg.pas"); +USERES("fs_ireg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsBDE4.dpk b/official/4.2/LibD11/fsBDE4.dpk new file mode 100644 index 0000000..6047735 --- /dev/null +++ b/official/4.2/LibD11/fsBDE4.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 4 + +package fsBDE4; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + VCLDB40, + fs4, + fsDB4; + +contains + fs_ibdertti in 'fs_ibdertti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsBDE5.bpk b/official/4.2/LibD11/fsBDE5.bpk new file mode 100644 index 0000000..17a4c8d --- /dev/null +++ b/official/4.2/LibD11/fsBDE5.bpk @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsBDE5.cpp b/official/4.2/LibD11/fsBDE5.cpp new file mode 100644 index 0000000..b2619a0 --- /dev/null +++ b/official/4.2/LibD11/fsBDE5.cpp @@ -0,0 +1,25 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("FS5.res"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vcldb50.bpi"); +USEPACKAGE("vclbde50.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("fsDB5.bpi"); +USEUNIT("fs_ibdereg.pas"); +USERES("fs_iReg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsBDE5.dpk b/official/4.2/LibD11/fsBDE5.dpk new file mode 100644 index 0000000..3953b88 --- /dev/null +++ b/official/4.2/LibD11/fsBDE5.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 5 + +package fsBDE5; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + VCLDB50, + VCLBDE50, + fs5, + fsDB5; + +contains + fs_ibdertti in 'fs_ibdertti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsBDE6.bpk b/official/4.2/LibD11/fsBDE6.bpk new file mode 100644 index 0000000..5db87d1 --- /dev/null +++ b/official/4.2/LibD11/fsBDE6.bpk @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Excluded Packages] +d:\delphi\builder6\Projects\Bpl\FR6.bpl=FastReport 2.4 Components + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsBDE6.cpp b/official/4.2/LibD11/fsBDE6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/fsBDE6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/fsBDE6.dpk b/official/4.2/LibD11/fsBDE6.dpk new file mode 100644 index 0000000..df93c1c --- /dev/null +++ b/official/4.2/LibD11/fsBDE6.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 6 + +package fsBDE6; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + fs6, + fsDB6; + +contains + fs_ibdertti in 'fs_ibdertti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsBDE7.dpk b/official/4.2/LibD11/fsBDE7.dpk new file mode 100644 index 0000000..98314cb --- /dev/null +++ b/official/4.2/LibD11/fsBDE7.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 7 + +package fsBDE7; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + fs7, + fsDB7; + +contains + fs_ibdertti in 'fs_ibdertti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsBDE9.bdsproj b/official/4.2/LibD11/fsBDE9.bdsproj new file mode 100644 index 0000000..acd77ea --- /dev/null +++ b/official/4.2/LibD11/fsBDE9.bdsproj @@ -0,0 +1,168 @@ + + + + + + + + + + + + fsBDE9.dpk + + + 7.0 + + + 8 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + False + False + False + True + True + True + + + 0 + 0 + 1 + False + False + False + 16384 + 1048576 + 4194304 + + + + + + + + + + + + False + + + + + + False + + + + + + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + diff --git a/official/4.2/LibD11/fsBDE9.dpk b/official/4.2/LibD11/fsBDE9.dpk new file mode 100644 index 0000000..8d1fc5b --- /dev/null +++ b/official/4.2/LibD11/fsBDE9.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 2005 + +package fsBDE9; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + BDERTL, + fs9, + fsDB9; + +contains + fs_ibdertti in 'fs_ibdertti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsDB10.bdsproj b/official/4.2/LibD11/fsDB10.bdsproj new file mode 100644 index 0000000..7627517 --- /dev/null +++ b/official/4.2/LibD11/fsDB10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsDB10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsDB10.dpk b/official/4.2/LibD11/fsDB10.dpk new file mode 100644 index 0000000..b313981 --- /dev/null +++ b/official/4.2/LibD11/fsDB10.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2006 + +package fsDB10; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + fs10; + +contains + fs_idbctrlsrtti in 'fs_idbctrlsrtti.pas', + fs_idbrtti in 'fs_idbrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsDB11.bdsproj b/official/4.2/LibD11/fsDB11.bdsproj new file mode 100644 index 0000000..d69a33c --- /dev/null +++ b/official/4.2/LibD11/fsDB11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsDB11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsDB11.dpk b/official/4.2/LibD11/fsDB11.dpk new file mode 100644 index 0000000..118eaf9 --- /dev/null +++ b/official/4.2/LibD11/fsDB11.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2007 + +package fsDB11; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + fs11; + +contains + fs_idbctrlsrtti in 'fs_idbctrlsrtti.pas', + fs_idbrtti in 'fs_idbrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsDB4.bpk b/official/4.2/LibD11/fsDB4.bpk new file mode 100644 index 0000000..a4df936 --- /dev/null +++ b/official/4.2/LibD11/fsDB4.bpk @@ -0,0 +1,187 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = FSDB4.bpl +OBJFILES = fs_iReg.obj FSDB4.obj +RESFILES = FS4.res fs_iReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +PACKAGES = vcl40.bpi vcldb40.bpi fs4.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -D"FastScript 1.9 DB Components" -aa -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsDB4.cpp b/official/4.2/LibD11/fsDB4.cpp new file mode 100644 index 0000000..4fe67af --- /dev/null +++ b/official/4.2/LibD11/fsDB4.cpp @@ -0,0 +1,19 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("FS4.res"); +USEPACKAGE("vcl40.bpi"); +USEPACKAGE("vcldb40.bpi"); +USEPACKAGE("fs4.bpi"); +USEUNIT("fs_idbreg.pas"); +USERES("fs_ireg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsDB4.dpk b/official/4.2/LibD11/fsDB4.dpk new file mode 100644 index 0000000..e5e5f62 --- /dev/null +++ b/official/4.2/LibD11/fsDB4.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 4 + +package fsDB4; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, + VCLDB40, + fs4; + +contains + fs_idbctrlsrtti in 'fs_idbctrlsrtti.pas', + fs_idbrtti in 'fs_idbrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsDB5.bpk b/official/4.2/LibD11/fsDB5.bpk new file mode 100644 index 0000000..f12ab61 --- /dev/null +++ b/official/4.2/LibD11/fsDB5.bpk @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsDB5.cpp b/official/4.2/LibD11/fsDB5.cpp new file mode 100644 index 0000000..d782c17 --- /dev/null +++ b/official/4.2/LibD11/fsDB5.cpp @@ -0,0 +1,23 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("FS5.res"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vcldb50.bpi"); +USEPACKAGE("fs5.bpi"); +USEUNIT("fs_idbreg.pas"); +USERES("fs_iReg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsDB5.dpk b/official/4.2/LibD11/fsDB5.dpk new file mode 100644 index 0000000..d9761da --- /dev/null +++ b/official/4.2/LibD11/fsDB5.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 5 + +package fsDB5; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + VCLDB50, + fs5; + +contains + fs_idbctrlsrtti in 'fs_idbctrlsrtti.pas', + fs_idbrtti in 'fs_idbrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsDB6.bpk b/official/4.2/LibD11/fsDB6.bpk new file mode 100644 index 0000000..8a6dc71 --- /dev/null +++ b/official/4.2/LibD11/fsDB6.bpk @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Excluded Packages] +d:\delphi\builder6\Projects\Bpl\FR6.bpl=FastReport 2.4 Components + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsDB6.cpp b/official/4.2/LibD11/fsDB6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/fsDB6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/fsDB6.dpk b/official/4.2/LibD11/fsDB6.dpk new file mode 100644 index 0000000..8c41f34 --- /dev/null +++ b/official/4.2/LibD11/fsDB6.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 6 + +package fsDB6; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + fs6; + +contains + fs_idbctrlsrtti in 'fs_idbctrlsrtti.pas', + fs_idbrtti in 'fs_idbrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsDB7.dpk b/official/4.2/LibD11/fsDB7.dpk new file mode 100644 index 0000000..672282e --- /dev/null +++ b/official/4.2/LibD11/fsDB7.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 7 + +package fsDB7; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + fs7; + +contains + fs_idbctrlsrtti in 'fs_idbctrlsrtti.pas', + fs_idbrtti in 'fs_idbrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsDB9.bdsproj b/official/4.2/LibD11/fsDB9.bdsproj new file mode 100644 index 0000000..4f121f2 --- /dev/null +++ b/official/4.2/LibD11/fsDB9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsDB9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsDB9.dpk b/official/4.2/LibD11/fsDB9.dpk new file mode 100644 index 0000000..4769461 --- /dev/null +++ b/official/4.2/LibD11/fsDB9.dpk @@ -0,0 +1,41 @@ +// Package file for Delphi 2005 + +package fsDB9; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + fs9; + +contains + fs_idbctrlsrtti in 'fs_idbctrlsrtti.pas', + fs_idbrtti in 'fs_idbrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsIBX10.bdsproj b/official/4.2/LibD11/fsIBX10.bdsproj new file mode 100644 index 0000000..4e8e760 --- /dev/null +++ b/official/4.2/LibD11/fsIBX10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsIBX10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsIBX10.dpk b/official/4.2/LibD11/fsIBX10.dpk new file mode 100644 index 0000000..6281b11 --- /dev/null +++ b/official/4.2/LibD11/fsIBX10.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 2006 + +package fsIBX10; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + fs10, + fsDB10; + +contains + fs_iibxrtti in 'fs_iibxrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsIBX11.bdsproj b/official/4.2/LibD11/fsIBX11.bdsproj new file mode 100644 index 0000000..1cbf2d6 --- /dev/null +++ b/official/4.2/LibD11/fsIBX11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsIBX11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsIBX11.dpk b/official/4.2/LibD11/fsIBX11.dpk new file mode 100644 index 0000000..1b0d14f --- /dev/null +++ b/official/4.2/LibD11/fsIBX11.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 2007 + +package fsIBX11; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + fs11, + fsDB11; + +contains + fs_iibxrtti in 'fs_iibxrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsIBX5.bpk b/official/4.2/LibD11/fsIBX5.bpk new file mode 100644 index 0000000..f58100b --- /dev/null +++ b/official/4.2/LibD11/fsIBX5.bpk @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsIBX5.cpp b/official/4.2/LibD11/fsIBX5.cpp new file mode 100644 index 0000000..3b8be05 --- /dev/null +++ b/official/4.2/LibD11/fsIBX5.cpp @@ -0,0 +1,26 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("FS5.res"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vcldb50.bpi"); +USEPACKAGE("vclib50.bpi"); +USEPACKAGE("fs5.bpi"); +USEPACKAGE("fsDB5.bpi"); +USEUNIT("fs_iibxreg.pas"); +USEUNIT("fs_iibxrtti.pas"); +USERES("fs_iReg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsIBX5.dpk b/official/4.2/LibD11/fsIBX5.dpk new file mode 100644 index 0000000..c3f4244 --- /dev/null +++ b/official/4.2/LibD11/fsIBX5.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 5 + +package fsIBX5; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, + VCLDB50, + VCLIB50, + fs5, + fsDB5; + +contains + fs_iibxrtti in 'fs_iibxrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsIBX6.bpk b/official/4.2/LibD11/fsIBX6.bpk new file mode 100644 index 0000000..3ece52b --- /dev/null +++ b/official/4.2/LibD11/fsIBX6.bpk @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Excluded Packages] + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsIBX6.cpp b/official/4.2/LibD11/fsIBX6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/fsIBX6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/fsIBX6.dpk b/official/4.2/LibD11/fsIBX6.dpk new file mode 100644 index 0000000..2961327 --- /dev/null +++ b/official/4.2/LibD11/fsIBX6.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 6 + +package fsIBX6; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + fs6, + fsDB6; + +contains + fs_iibxrtti in 'fs_iibxrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsIBX7.dpk b/official/4.2/LibD11/fsIBX7.dpk new file mode 100644 index 0000000..6ec8ab0 --- /dev/null +++ b/official/4.2/LibD11/fsIBX7.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 7 + +package fsIBX7; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + fs7, + fsDB7; + +contains + fs_iibxrtti in 'fs_iibxrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsIBX9.bdsproj b/official/4.2/LibD11/fsIBX9.bdsproj new file mode 100644 index 0000000..013ea63 --- /dev/null +++ b/official/4.2/LibD11/fsIBX9.bdsproj @@ -0,0 +1,168 @@ + + + + + + + + + + + + fsIBX9.dpk + + + 7.0 + + + 8 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 1 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + False + False + False + True + True + True + + + 0 + 0 + 1 + False + False + False + 16384 + 1048576 + 4194304 + + + + + + + + + + + + False + + + + + + False + + + + + + False + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 1049 + 1251 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + diff --git a/official/4.2/LibD11/fsIBX9.dpk b/official/4.2/LibD11/fsIBX9.dpk new file mode 100644 index 0000000..bdc5c57 --- /dev/null +++ b/official/4.2/LibD11/fsIBX9.dpk @@ -0,0 +1,42 @@ +// Package file for Delphi 2005 + +package fsIBX9; + +{$I fs.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, + VCLDB, + IBXPRESS, + fs9, + fsDB9; + +contains + fs_iibxrtti in 'fs_iibxrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsTee10.bdsproj b/official/4.2/LibD11/fsTee10.bdsproj new file mode 100644 index 0000000..49aba99 --- /dev/null +++ b/official/4.2/LibD11/fsTee10.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsTee10.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsTee10.dpk b/official/4.2/LibD11/fsTee10.dpk new file mode 100644 index 0000000..a1e0383 --- /dev/null +++ b/official/4.2/LibD11/fsTee10.dpk @@ -0,0 +1,48 @@ +// Package file for Delphi 2006 + +package fsTee10; + +{$I fs.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, {$ENDIF} +{$IFDEF TeeChartStd7}TEE710, {$ENDIF} +{$IFDEF TeeChart4} TEE410, {$ENDIF} +{$IFDEF TeeChart5} TEE510, {$ENDIF} +{$IFDEF TeeChart6} TEE610, {$ENDIF} +{$IFDEF TeeChart7} TEE710, {$ENDIF} + VCLX, + fs10; + + +contains + fs_ichartrtti in 'fs_ichartrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsTee11.bdsproj b/official/4.2/LibD11/fsTee11.bdsproj new file mode 100644 index 0000000..4526b0a --- /dev/null +++ b/official/4.2/LibD11/fsTee11.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsTee11.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsTee11.dpk b/official/4.2/LibD11/fsTee11.dpk new file mode 100644 index 0000000..b00465d --- /dev/null +++ b/official/4.2/LibD11/fsTee11.dpk @@ -0,0 +1,48 @@ +// Package file for Delphi 2007 + +package fsTee11; + +{$I fs.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, {$ENDIF} +{$IFDEF TeeChartStd7}TEE710, {$ENDIF} +{$IFDEF TeeChart4} TEE410, {$ENDIF} +{$IFDEF TeeChart5} TEE510, {$ENDIF} +{$IFDEF TeeChart6} TEE610, {$ENDIF} +{$IFDEF TeeChart7} TEE710, {$ENDIF} + VCLX, + fs11; + + +contains + fs_ichartrtti in 'fs_ichartrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsTee4.bpk b/official/4.2/LibD11/fsTee4.bpk new file mode 100644 index 0000000..cd082cc --- /dev/null +++ b/official/4.2/LibD11/fsTee4.bpk @@ -0,0 +1,187 @@ +# --------------------------------------------------------------------------- +!if !$d(BCB) +BCB = $(MAKEDIR)\.. +!endif + +# --------------------------------------------------------------------------- +# IDE SECTION +# --------------------------------------------------------------------------- +# The following section of the project makefile is managed by the BCB IDE. +# It is recommended to use the IDE to change any of the values in this +# section. +# --------------------------------------------------------------------------- + +VERSION = BCB.04.04 +# --------------------------------------------------------------------------- +PROJECT = FSTee4.bpl +OBJFILES = fs_iteereg.obj FSTee4.obj fs_ichartrtti.obj +RESFILES = FS4.res fs_iReg.dcr +RESDEPEN = $(RESFILES) +LIBFILES = +PACKAGES = vcl40.bpi vclx40.bpi tee40.bpi fs4.bpi +DEFFILE = +# --------------------------------------------------------------------------- +PATHCPP = .; +PATHASM = .; +PATHPAS = .; +PATHRC = .; +DEBUGLIBPATH = $(BCB)\lib\debug +RELEASELIBPATH = $(BCB)\lib\release +USERDEFINES = +SYSDEFINES = _RTLDLL;NO_STRICT;USEPACKAGES +# --------------------------------------------------------------------------- +CFLAG1 = -I$(BCB)\include;$(BCB)\include\vcl -O2 -Hc -H=$(BCB)\lib\vcl40.csm -w -Ve -a8 \ + -k- -vi -c -b- -w-par -w-inl -Vx -tWM -D$(SYSDEFINES);$(USERDEFINES) +PFLAGS = -U$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -I$(BCB)\include;$(BCB)\include\vcl -$Y- -$L- -$D- -v -JPHNE -M +RFLAGS = -i$(BCB)\include;$(BCB)\include\vcl +AFLAGS = /i$(BCB)\include /i$(BCB)\include\vcl /mx /w2 /zn +LFLAGS = -L$(BCB)\Projects\Lib;$(BCB)\lib\obj;$(BCB)\lib;$(RELEASELIBPATH) \ + -D"FastScript 1.9 Tee Components" -aa -Tpp -x -Gn -Gl -Gi +# --------------------------------------------------------------------------- +ALLOBJ = c0pkg32.obj Memmgr.Lib $(PACKAGES) sysinit.obj $(OBJFILES) +ALLRES = $(RESFILES) +ALLLIB = $(LIBFILES) $(LIBRARIES) import32.lib cp32mti.lib +# --------------------------------------------------------------------------- +!ifdef IDEOPTIONS + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +InMemoryExe=0 +ShowInfoMsgs=0 + +!endif + +# --------------------------------------------------------------------------- +# MAKE SECTION +# --------------------------------------------------------------------------- +# This section of the project file is not used by the BCB IDE. It is for +# the benefit of building from the command-line using the MAKE utility. +# --------------------------------------------------------------------------- + +.autodepend +# --------------------------------------------------------------------------- +!if !$d(BCC32) +BCC32 = bcc32 +!endif + +!if !$d(CPP32) +CPP32 = cpp32 +!endif + +!if !$d(DCC32) +DCC32 = dcc32 +!endif + +!if !$d(TASM32) +TASM32 = tasm32 +!endif + +!if !$d(LINKER) +LINKER = ilink32 +!endif + +!if !$d(BRCC32) +BRCC32 = brcc32 +!endif + +# --------------------------------------------------------------------------- +!if $d(PATHCPP) +.PATH.CPP = $(PATHCPP) +.PATH.C = $(PATHCPP) +!endif + +!if $d(PATHPAS) +.PATH.PAS = $(PATHPAS) +!endif + +!if $d(PATHASM) +.PATH.ASM = $(PATHASM) +!endif + +!if $d(PATHRC) +.PATH.RC = $(PATHRC) +!endif +# --------------------------------------------------------------------------- +$(PROJECT): $(OBJFILES) $(RESDEPEN) $(DEFFILE) + $(BCB)\BIN\$(LINKER) @&&! + $(LFLAGS) + + $(ALLOBJ), + + $(PROJECT),, + + $(ALLLIB), + + $(DEFFILE), + + $(ALLRES) +! +# --------------------------------------------------------------------------- +.pas.hpp: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.pas.obj: + $(BCB)\BIN\$(DCC32) $(PFLAGS) {$< } + +.cpp.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.obj: + $(BCB)\BIN\$(BCC32) $(CFLAG1) -n$(@D) {$< } + +.c.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.cpp.i: + $(BCB)\BIN\$(CPP32) $(CFLAG1) -n. {$< } + +.asm.obj: + $(BCB)\BIN\$(TASM32) $(AFLAGS) $<, $@ + +.rc.res: + $(BCB)\BIN\$(BRCC32) $(RFLAGS) -fo$@ $< +# --------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsTee4.cpp b/official/4.2/LibD11/fsTee4.cpp new file mode 100644 index 0000000..396b5fd --- /dev/null +++ b/official/4.2/LibD11/fsTee4.cpp @@ -0,0 +1,21 @@ +//--------------------------------------------------------------------------- +#include +#pragma hdrstop +USERES("FS4.res"); +USEPACKAGE("vcl40.bpi"); +USEPACKAGE("vclx40.bpi"); +USEPACKAGE("tee40.bpi"); +USEPACKAGE("fs4.bpi"); +USEUNIT("fs_iteeReg.pas"); +USEUNIT("fs_ichartrtti.pas"); +USERES("fs_iReg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- +// Package source. +//--------------------------------------------------------------------------- +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsTee4.dpk b/official/4.2/LibD11/fsTee4.dpk new file mode 100644 index 0000000..24b32f9 --- /dev/null +++ b/official/4.2/LibD11/fsTee4.dpk @@ -0,0 +1,47 @@ +// Package file for Delphi 4 + +package fsTee4; + +{$I fs.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL40, +{$IFDEF TeeChartStd} TEE40, {$ENDIF} +{$IFDEF TeeChart4} TEE44, {$ENDIF} +{$IFDEF TeeChart5} TEE54, {$ENDIF} +{$IFDEF TeeChart6} TEE64, {$ENDIF} +{$IFDEF TeeChart7} TEE74, {$ENDIF} + VCLX40, + fs4; + + +contains + fs_ichartrtti in 'fs_ichartrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsTee5.bpk b/official/4.2/LibD11/fsTee5.bpk new file mode 100644 index 0000000..f19b65b --- /dev/null +++ b/official/4.2/LibD11/fsTee5.bpk @@ -0,0 +1,108 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[HistoryLists\hlIncludePath] +Count=1 +Item0=$(BCB)\include;$(BCB)\include\vcl + +[HistoryLists\hlLibraryPath] +Count=1 +Item0=$(BCB)\lib\obj;$(BCB)\lib + +[HistoryLists\hlDebugSourcePath] +Count=1 +Item0=$(BCB)\source\vcl + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +HostApplication= +RemoteHost= +RemotePath= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Language] +ActiveLang= +ProjectLang= +RootDir= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsTee5.cpp b/official/4.2/LibD11/fsTee5.cpp new file mode 100644 index 0000000..1f8f0ba --- /dev/null +++ b/official/4.2/LibD11/fsTee5.cpp @@ -0,0 +1,25 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +USERES("FS5.res"); +USEPACKAGE("vcl50.bpi"); +USEPACKAGE("vclx50.bpi"); +USEPACKAGE("tee50.bpi"); +USEPACKAGE("fs5.bpi"); +USEUNIT("fs_iteereg.pas"); +USEUNIT("fs_ichartrtti.pas"); +USERES("fs_iReg.dcr"); +//--------------------------------------------------------------------------- +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- diff --git a/official/4.2/LibD11/fsTee5.dpk b/official/4.2/LibD11/fsTee5.dpk new file mode 100644 index 0000000..1c89308 --- /dev/null +++ b/official/4.2/LibD11/fsTee5.dpk @@ -0,0 +1,47 @@ +// Package file for Delphi 5 + +package fsTee5; + +{$I fs.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL50, +{$IFDEF TeeChartStd} TEE50, {$ENDIF} +{$IFDEF TeeChart4} TEE45, {$ENDIF} +{$IFDEF TeeChart5} TEE55, {$ENDIF} +{$IFDEF TeeChart6} TEE65, {$ENDIF} +{$IFDEF TeeChart7} TEE75, {$ENDIF} + VCLX50, + fs5; + + +contains + fs_ichartrtti in 'fs_ichartrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsTee6.bpk b/official/4.2/LibD11/fsTee6.bpk new file mode 100644 index 0000000..2d92b4c --- /dev/null +++ b/official/4.2/LibD11/fsTee6.bpk @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +[Version Info] +IncludeVerInfo=1 +AutoIncBuild=0 +MajorVer=1 +MinorVer=0 +Release=0 +Build=0 +Debug=0 +PreRelease=0 +Special=0 +Private=0 +DLL=0 +Locale=1049 +CodePage=1251 + +[Version Info Keys] +CompanyName= +FileDescription= +FileVersion=1.0.0.0 +InternalName= +LegalCopyright= +LegalTrademarks= +OriginalFilename= +ProductName= +ProductVersion=1.0.0.0 +Comments= + +[Excluded Packages] +d:\delphi\builder6\Projects\Bpl\FR6.bpl=FastReport 2.4 Components + +[Debugging] +DebugSourceDirs=$(BCB)\source\vcl + +[Parameters] +RunParams= +Launcher= +UseLauncher=0 +DebugCWD= +HostApplication= +RemoteHost= +RemotePath= +RemoteLauncher= +RemoteCWD= +RemoteDebug=0 + +[Compiler] +ShowInfoMsgs=0 +LinkDebugVcl=0 +LinkCGLIB=0 + +[CORBA] +AddServerUnit=1 +AddClientUnit=1 +PrecompiledHeaders=1 + +[Linker] +LibPrefix= +LibSuffix= +LibVersion= + + \ No newline at end of file diff --git a/official/4.2/LibD11/fsTee6.cpp b/official/4.2/LibD11/fsTee6.cpp new file mode 100644 index 0000000..59b8711 --- /dev/null +++ b/official/4.2/LibD11/fsTee6.cpp @@ -0,0 +1,17 @@ +//--------------------------------------------------------------------------- + +#include +#pragma hdrstop +#pragma package(smart_init) +//--------------------------------------------------------------------------- + +// Package source. +//--------------------------------------------------------------------------- + +#pragma argsused +int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) +{ + return 1; +} +//--------------------------------------------------------------------------- + \ No newline at end of file diff --git a/official/4.2/LibD11/fsTee6.dpk b/official/4.2/LibD11/fsTee6.dpk new file mode 100644 index 0000000..6f63b06 --- /dev/null +++ b/official/4.2/LibD11/fsTee6.dpk @@ -0,0 +1,47 @@ +// Package file for Delphi 6 + +package fsTee6; + +{$I fs.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, {$ENDIF} +{$IFDEF TeeChart4} TEE46, {$ENDIF} +{$IFDEF TeeChart5} TEE56, {$ENDIF} +{$IFDEF TeeChart6} TEE66, {$ENDIF} +{$IFDEF TeeChart7} TEE76, {$ENDIF} + VCLX, + fs6; + + +contains + fs_ichartrtti in 'fs_ichartrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsTee7.dpk b/official/4.2/LibD11/fsTee7.dpk new file mode 100644 index 0000000..c3ce936 --- /dev/null +++ b/official/4.2/LibD11/fsTee7.dpk @@ -0,0 +1,47 @@ +// Package file for Delphi 7 + +package fsTee7; + +{$I fs.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, {$ENDIF} +{$IFDEF TeeChart4} TEE47, {$ENDIF} +{$IFDEF TeeChart5} TEE57, {$ENDIF} +{$IFDEF TeeChart6} TEE67, {$ENDIF} +{$IFDEF TeeChart7} TEE77, {$ENDIF} + VCLX, + fs7; + + +contains + fs_ichartrtti in 'fs_ichartrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fsTee9.bdsproj b/official/4.2/LibD11/fsTee9.bdsproj new file mode 100644 index 0000000..5baa922 --- /dev/null +++ b/official/4.2/LibD11/fsTee9.bdsproj @@ -0,0 +1,19 @@ + + + + + + + + + + + + fsTee9.dpk + + + 7.0 + + + diff --git a/official/4.2/LibD11/fsTee9.dpk b/official/4.2/LibD11/fsTee9.dpk new file mode 100644 index 0000000..9806b15 --- /dev/null +++ b/official/4.2/LibD11/fsTee9.dpk @@ -0,0 +1,47 @@ +// Package file for Delphi 2005 + +package fsTee9; + +{$I fs.inc} +{$I tee.inc} + +{$ALIGN ON} +{$ASSERTIONS ON} +{$BOOLEVAL OFF} + +{$EXTENDEDSYNTAX ON} +{$IMPORTEDDATA ON} +{$IOCHECKS ON} +{$LOCALSYMBOLS ON} +{$LONGSTRINGS ON} +{$OPENSTRINGS ON} +{$OPTIMIZATION ON} +{$OVERFLOWCHECKS OFF} +{$RANGECHECKS OFF} +{$REFERENCEINFO ON} +{$SAFEDIVIDE OFF} +{$STACKFRAMES OFF} +{$TYPEDADDRESS OFF} +{$VARSTRINGCHECKS ON} +{$WRITEABLECONST ON} +{$MINENUMSIZE 1} +{$IMAGEBASE $00400000} +{$RUNONLY} +{$IMPLICITBUILD OFF} + +requires + VCL, +{$IFDEF TeeChartStd} TEE, {$ENDIF} +{$IFDEF TeeChart4} TEE49, {$ENDIF} +{$IFDEF TeeChart5} TEE59, {$ENDIF} +{$IFDEF TeeChart6} TEE69, {$ENDIF} +{$IFDEF TeeChart7} TEE79, {$ENDIF} + VCLX, + fs9; + + +contains + fs_ichartrtti in 'fs_ichartrtti.pas'; + + +end. diff --git a/official/4.2/LibD11/fs_iadoreg.pas b/official/4.2/LibD11/fs_iadoreg.pas new file mode 100644 index 0000000..ed795c1 --- /dev/null +++ b/official/4.2/LibD11/fs_iadoreg.pas @@ -0,0 +1,39 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Registration unit } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iadoreg; + +{$i fs.inc} + +interface + + +procedure Register; + +implementation + +uses + Classes +{$IFNDEF Delphi6} +, DsgnIntf +{$ELSE} +, DesignIntf +{$ENDIF} +, fs_iadortti; + +{-----------------------------------------------------------------------} + +procedure Register; +begin + RegisterComponents('FastScript', [TfsADORTTI]); +end; + +end. diff --git a/official/4.2/LibD11/fs_iadortti.pas b/official/4.2/LibD11/fs_iadortti.pas new file mode 100644 index 0000000..cf204c9 --- /dev/null +++ b/official/4.2/LibD11/fs_iadortti.pas @@ -0,0 +1,126 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ ADO classes and functions } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iadortti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_itools, fs_idbrtti, + DB, ADODB, ADOInt; + +type + TfsADORTTI = class(TComponent); // fake component + + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddType('TDataType', fvtInt); + AddClass(TADOConnection, 'TComponent'); + AddClass(TParameter, 'TCollectionItem'); + with AddClass(TParameters, 'TCollection') do + begin + AddMethod('function AddParameter: TParameter', CallMethod); + AddDefaultProperty('Items', 'Integer', 'TParameter', CallMethod, True); + end; + with AddClass(TCustomADODataSet, 'TDataSet') do + begin + AddProperty('Sort', 'WideString', GetProp, SetProp); + end; + AddClass(TADOTable, 'TCustomADODataSet'); + with AddClass(TADOQuery, 'TCustomADODataSet') do + AddMethod('procedure ExecSQL', CallMethod); + with AddClass(TADOStoredProc, 'TCustomADODataSet') do + AddMethod('procedure ExecProc', CallMethod); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TParameters then + begin + if MethodName = 'ADDPARAMETER' then + Result := Integer(TParameters(Instance).AddParameter) + else if MethodName = 'ITEMS.GET' then + Result := Integer(TParameters(Instance).Items[Caller.Params[0]]) + end + else if ClassType = TADOQuery then + begin + if MethodName = 'EXECSQL' then + TADOQuery(Instance).ExecSQL + end + else if ClassType = TADOStoredProc then + begin + if MethodName = 'EXECPROC' then + TADOStoredProc(Instance).ExecProc + end +end; + + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TCustomADODataSet then + begin + if PropName = 'SORT' then + Result := TCustomADODataSet(Instance).Sort; + end +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin + + if ClassType = TCustomADODataSet then + begin + if PropName = 'SORT' then + TCustomADODataSet(Instance).Sort := Value; + end + +end; + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. + diff --git a/official/4.2/LibD11/fs_ibasic.pas b/official/4.2/LibD11/fs_ibasic.pas new file mode 100644 index 0000000..48e3a50 --- /dev/null +++ b/official/4.2/LibD11/fs_ibasic.pas @@ -0,0 +1,171 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Basic grammar } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_ibasic; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_itools; + +type + TfsBasic = class(TComponent); + + +implementation + +const + BASIC_GRAMMAR = + '' + + '<' + + '/keywords>' + + '<' + + 'string add="file" err="err1"/><' + + 'char text="(" add="op"/><' + + '/sequence>' + + '' + + '<' + + 'keyword text="OR" add="op" addtext="or"/><' + + 'char text="[" add="node"/>' + + '<' + + 'sequence><' + + '/sequence><' + + 'caseselector/><' + + 'optional>' + + '<' + + 'keyword text="FINALLY"/>'; + + +initialization + fsRegisterLanguage('BasicScript', BASIC_GRAMMAR); + +end. diff --git a/official/4.2/LibD11/fs_ibdereg.pas b/official/4.2/LibD11/fs_ibdereg.pas new file mode 100644 index 0000000..515b5da --- /dev/null +++ b/official/4.2/LibD11/fs_ibdereg.pas @@ -0,0 +1,39 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Registration unit } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_ibdereg; + +{$i fs.inc} + +interface + + +procedure Register; + +implementation + +uses + Classes +{$IFNDEF Delphi6} +, DsgnIntf +{$ELSE} +, DesignIntf +{$ENDIF} +, fs_ibdertti; + +{-----------------------------------------------------------------------} + +procedure Register; +begin + RegisterComponents('FastScript', [TfsBDERTTI]); +end; + +end. diff --git a/official/4.2/LibD11/fs_ibdertti.pas b/official/4.2/LibD11/fs_ibdertti.pas new file mode 100644 index 0000000..f1c0782 --- /dev/null +++ b/official/4.2/LibD11/fs_ibdertti.pas @@ -0,0 +1,164 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ BDE classes and functions } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_ibdertti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_itools, fs_idbrtti, + DB, DBTables; + +type + TfsBDERTTI = class(TComponent); // fake component + + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnum('TTableType', 'ttDefault, ttParadox, ttDBase, ttFoxPro, ttASCII'); + AddEnum('TParamBindMode', 'pbByName, pbByNumber'); + + AddClass(TSession, 'TComponent'); + AddClass(TDatabase, 'TComponent'); + AddClass(TBDEDataSet, 'TDataSet'); + AddClass(TDBDataSet, 'TBDEDataSet'); + with AddClass(TTable, 'TDBDataSet') do + begin + AddMethod('procedure CreateTable', CallMethod); + AddMethod('procedure DeleteTable', CallMethod); + AddMethod('procedure EmptyTable', CallMethod); + AddMethod('function FindKey(const KeyValues: array): Boolean', CallMethod); + AddMethod('procedure FindNearest(const KeyValues: array)', CallMethod); + AddMethod('procedure RenameTable(const NewTableName: string)', CallMethod); + end; + with AddClass(TQuery, 'TDBDataSet') do + begin + AddMethod('procedure ExecSQL', CallMethod); + AddMethod('function ParamByName(const Value: string): TParam', CallMethod); + AddMethod('procedure Prepare', CallMethod); + AddProperty('ParamCount', 'Word', GetProp, nil); + end; + with AddClass(TStoredProc, 'TDBDataSet') do + begin + AddMethod('procedure ExecProc', CallMethod); + AddMethod('function ParamByName(const Value: string): TParam', CallMethod); + AddMethod('procedure Prepare', CallMethod); + AddProperty('ParamCount', 'Word', GetProp, nil); + end; + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + + function DoFindKey: Boolean; + var + ar: TVarRecArray; + begin + VariantToVarRec(Caller.Params[0], ar); + Result := TTable(Instance).FindKey(ar); + ClearVarRec(ar); + end; + + procedure DoFindNearest; + var + ar: TVarRecArray; + begin + VariantToVarRec(Caller.Params[0], ar); + TTable(Instance).FindNearest(ar); + ClearVarRec(ar); + end; + +begin + Result := 0; + + if ClassType = TTable then + begin + if MethodName = 'CREATETABLE' then + TTable(Instance).CreateTable + else if MethodName = 'DELETETABLE' then + TTable(Instance).DeleteTable + else if MethodName = 'EMPTYTABLE' then + TTable(Instance).EmptyTable + else if MethodName = 'FINDKEY' then + Result := DoFindKey + else if MethodName = 'FINDNEAREST' then + DoFindNearest + else if MethodName = 'RENAMETABLE' then + TTable(Instance).RenameTable(Caller.Params[0]) + end + else if ClassType = TQuery then + begin + if MethodName = 'EXECSQL' then + TQuery(Instance).ExecSQL + else if MethodName = 'PARAMBYNAME' then + Result := Integer(TQuery(Instance).ParamByName(Caller.Params[0])) + else if MethodName = 'PREPARE' then + TQuery(Instance).Prepare + end + else if ClassType = TStoredProc then + begin + if MethodName = 'EXECPROC' then + TStoredProc(Instance).ExecProc + else if MethodName = 'PARAMBYNAME' then + Result := Integer(TStoredProc(Instance).ParamByName(Caller.Params[0])) + else if MethodName = 'PREPARE' then + TStoredProc(Instance).Prepare + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TQuery then + begin + if PropName = 'PARAMCOUNT' then + Result := TQuery(Instance).ParamCount + end + else if ClassType = TStoredProc then + begin + if PropName = 'PARAMCOUNT' then + Result := TStoredProc(Instance).ParamCount + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_ichartrtti.pas b/official/4.2/LibD11/fs_ichartrtti.pas new file mode 100644 index 0000000..4b396d1 --- /dev/null +++ b/official/4.2/LibD11/fs_ichartrtti.pas @@ -0,0 +1,121 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Chart } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_ichartrtti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_itools, fs_iformsrtti, Chart, + Series, TeEngine, TeeProcs, TeCanvas; + + +type + TfsChartRTTI = class(TComponent); // fake component + + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddType('TChartValue', fvtFloat); + AddEnum('TLegendStyle', 'lsAuto, lsSeries, lsValues, lsLastValues'); + AddEnum('TLegendAlignment', 'laLeft, laRight, laTop, laBottom'); + AddEnum('TLegendTextStyle', 'ltsPlain, ltsLeftValue, ltsRightValue, ltsLeftPercent,' + + 'ltsRightPercent, ltsXValue'); + AddEnum('TChartListOrder', 'loNone, loAscending, loDescending'); + AddEnum('TGradientDirection', 'gdTopBottom, gdBottomTop, gdLeftRight, gdRightLeft'); + AddEnum('TSeriesMarksStyle', 'smsValue, smsPercent, smsLabel, smsLabelPercent, ' + + 'smsLabelValue, smsLegend, smsPercentTotal, smsLabelPercentTotal, smsXValue'); + AddEnum('TAxisLabelStyle', 'talAuto, talNone, talValue, talMark, talText'); + AddEnum('THorizAxis', 'aTopAxis, aBottomAxis'); + AddEnum('TVertAxis', 'aLeftAxis, aRightAxis'); + AddEnum('TTeeBackImageMode', 'pbmStretch, pbmTile, pbmCenter'); + AddEnum('TPanningMode', 'pmNone, pmHorizontal, pmVertical, pmBoth'); + AddEnum('TSeriesPointerStyle', 'psRectangle, psCircle, psTriangle, ' + + 'psDownTriangle, psCross, psDiagCross, psStar, psDiamond, psSmallDot'); + AddEnum('TMultiArea', 'maNone, maStacked, maStacked100'); + AddEnum('TMultiBar', 'mbNone, mbSide, mbStacked, mbStacked100'); + AddEnum('TBarStyle', 'bsRectangle, bsPyramid, bsInvPyramid, bsCilinder, ' + + 'bsEllipse, bsArrow, bsRectGradient'); + + AddClass(TChartValueList, 'TPersistent'); + AddClass(TChartAxisTitle, 'TPersistent'); + AddClass(TChartAxis, 'TPersistent'); + AddClass(TCustomChartLegend, 'TPersistent'); + AddClass(TChartLegend, 'TCustomChartLegend'); + AddClass(TSeriesMarks, 'TPersistent'); + AddClass(TChartGradient, 'TPersistent'); + AddClass(TChartWall, 'TPersistent'); + AddClass(TChartBrush, 'TBrush'); + AddClass(TChartTitle, 'TPersistent'); + AddClass(TView3DOptions, 'TPersistent'); + with AddClass(TChartSeries, 'TComponent') do + begin + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure Add(const AValue: Double; const ALabel: String; AColor: TColor)', CallMethod); + end; + AddClass(TSeriesPointer, 'TPersistent'); + AddClass(TCustomSeries, 'TChartSeries'); + AddClass(TLineSeries, 'TCustomSeries'); + AddClass(TPointSeries, 'TCustomSeries'); + AddClass(TAreaSeries, 'TCustomSeries'); + AddClass(TCustomBarSeries, 'TChartSeries'); + AddClass(TBarSeries, 'TCustomBarSeries'); + AddClass(THorizBarSeries, 'TCustomBarSeries'); + AddClass(TCircledSeries, 'TChartSeries'); + AddClass(TPieSeries, 'TCircledSeries'); + AddClass(TFastLineSeries, 'TChartSeries'); + AddClass(TCustomChart, 'TWinControl'); + AddClass(TChart, 'TCustomChart'); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TChartSeries then + begin + if MethodName = 'CLEAR' then + TChartSeries(Instance).Clear + else if MethodName = 'ADD' then + TChartSeries(Instance).Add(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_iclassesrtti.pas b/official/4.2/LibD11/fs_iclassesrtti.pas new file mode 100644 index 0000000..c8523fe --- /dev/null +++ b/official/4.2/LibD11/fs_iclassesrtti.pas @@ -0,0 +1,476 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Classes.pas classes and functions } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iclassesrtti; + +interface + +{$i fs.inc} + +uses SysUtils, Classes, fs_iinterpreter, fs_xml; + +type + TfsClassesRTTI = class(TComponent); // fake component + + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddConst('fmCreate', 'Integer', fmCreate); + AddConst('fmOpenRead', 'Integer', fmOpenRead); + AddConst('fmOpenWrite', 'Integer', fmOpenWrite); + AddConst('fmOpenReadWrite', 'Integer', fmOpenReadWrite); + AddConst('fmShareExclusive', 'Integer', fmShareExclusive); + AddConst('fmShareDenyWrite', 'Integer', fmShareDenyWrite); + AddConst('fmShareDenyNone', 'Integer', fmShareDenyNone); + AddConst('soFromBeginning', 'Integer', soFromBeginning); + AddConst('soFromCurrent', 'Integer', soFromCurrent); + AddConst('soFromEnd', 'Integer', soFromEnd); + AddEnum('TDuplicates', 'dupIgnore, dupAccept, dupError'); + AddEnum('TPrinterOrientation', 'poPortrait, poLandscape'); + + with AddClass(TObject, '') do + begin + AddConstructor('constructor Create', CallMethod); + AddMethod('procedure Free', CallMethod); + AddMethod('function ClassName: String', CallMethod); + end; + with AddClass(TPersistent, 'TObject') do + AddMethod('procedure Assign(Source: TPersistent)', CallMethod); + AddClass(TCollectionItem, 'TPersistent'); + with AddClass(TCollection, 'TPersistent') do + begin + AddMethod('procedure Clear', CallMethod); + AddProperty('Count', 'Integer', GetProp, nil); + AddDefaultProperty('Items', 'Integer', 'TCollectionItem', CallMethod, True); + end; + with AddClass(TList, 'TObject') do + begin + AddMethod('function Add(Item: TObject): Integer', CallMethod); + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure Delete(Index: Integer)', CallMethod); + AddMethod('function IndexOf(Item: TObject): Integer', CallMethod); + AddMethod('procedure Insert(Index: Integer; Item: TObject)', CallMethod); + AddMethod('function Remove(Item: TObject): Integer', CallMethod); + AddProperty('Count', 'Integer', GetProp, nil); + AddDefaultProperty('Items', 'Integer', 'TObject', CallMethod); + end; + with AddClass(TStrings, 'TPersistent') do + begin + AddMethod('function Add(const S: string): Integer', CallMethod); + AddMethod('function AddObject(const S: string; AObject: TObject): Integer', CallMethod); + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure Delete(Index: Integer)', CallMethod); + AddMethod('function IndexOf(const S: string): Integer', CallMethod); + AddMethod('function IndexOfName(const Name: string): Integer', CallMethod); + AddMethod('function IndexOfObject(AObject: TObject): Integer', CallMethod); + AddMethod('procedure Insert(Index: Integer; const S: string)', CallMethod); + AddMethod('procedure InsertObject(Index: Integer; const S: string; AObject: TObject)', CallMethod); + AddMethod('procedure LoadFromFile(const FileName: string)', CallMethod); + AddMethod('procedure LoadFromStream(Stream: TStream)', CallMethod); + AddMethod('procedure SaveToFile(const FileName: string)', CallMethod); + AddMethod('procedure Move(CurIndex, NewIndex: Integer)', CallMethod); + AddMethod('procedure SaveToStream(Stream: TStream)', CallMethod); + + AddProperty('CommaText', 'string', GetProp, SetProp); + AddProperty('Count', 'Integer', GetProp, nil); + AddIndexProperty('Names', 'Integer', 'string', CallMethod, True); + AddIndexProperty('Objects', 'Integer', 'TObject', CallMethod); + AddIndexProperty('Values', 'String', 'string', CallMethod); + AddDefaultProperty('Strings', 'Integer', 'string', CallMethod); + AddProperty('Text', 'string', GetProp, SetProp); + end; + with AddClass(TStringList, 'TStrings') do + begin + AddMethod('function Find(s: String; var Index: Integer): Boolean', CallMethod); + AddMethod('procedure Sort', CallMethod); + AddProperty('Duplicates', 'TDuplicates', GetProp, SetProp); + AddProperty('Sorted', 'Boolean', GetProp, SetProp); + end; + with AddClass(TStream, 'TObject') do + begin + AddMethod('function Read(var Buffer: string; Count: Longint): Longint', CallMethod); + AddMethod('function Write(Buffer: string; Count: Longint): Longint', CallMethod); + AddMethod('function Seek(Offset: Longint; Origin: Word): Longint', CallMethod); + AddMethod('function CopyFrom(Source: TStream; Count: Longint): Longint', CallMethod); + AddProperty('Position', 'Longint', GetProp, SetProp); + AddProperty('Size', 'Longint', GetProp, nil); + end; + with AddClass(TFileStream, 'TStream') do + AddConstructor('constructor Create(Filename: String; Mode: Word)', CallMethod); + with AddClass(TMemoryStream, 'TStream') do + begin + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure LoadFromStream(Stream: TStream)', CallMethod); + AddMethod('procedure LoadFromFile(Filename: String)', CallMethod); + AddMethod('procedure SaveToStream(Stream: TStream)', CallMethod); + AddMethod('procedure SaveToFile(Filename: String)', CallMethod); + end; + with AddClass(TComponent, 'TPersistent') do + begin + AddConstructor('constructor Create(AOwner: TComponent)', CallMethod); + AddProperty('Owner', 'TComponent', GetProp, nil); + end; + with AddClass(TfsXMLItem, 'TObject') do + begin + AddConstructor('constructor Create', CallMethod); + AddMethod('procedure AddItem(Item: TfsXMLItem)', CallMethod); + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure InsertItem(Index: Integer; Item: TfsXMLItem)', CallMethod); + AddMethod('function Add: TfsXMLItem', CallMethod); + AddMethod('function Find(const Name: String): Integer', CallMethod); + AddMethod('function FindItem(const Name: String): TfsXMLItem', CallMethod); + AddMethod('function Root: TfsXMLItem', CallMethod); + AddProperty('Data', 'Integer', GetProp, SetProp); + AddProperty('Count', 'Integer', GetProp, nil); + AddDefaultProperty('Items', 'Integer', 'TfsXMLItem', CallMethod, True); + AddIndexProperty('Prop', 'String', 'String', CallMethod); + AddProperty('Name', 'String', GetProp, SetProp); + AddProperty('Parent', 'TfsXMLItem', GetProp, nil); + AddProperty('Text', 'String', GetProp, SetProp); + end; + with AddClass(TfsXMLDocument, 'TObject') do + begin + AddConstructor('constructor Create', CallMethod); + AddMethod('procedure SaveToStream(Stream: TStream)', CallMethod); + AddMethod('procedure LoadFromStream(Stream: TStream)', CallMethod); + AddMethod('procedure SaveToFile(const FileName: String)', CallMethod); + AddMethod('procedure LoadFromFile(const FileName: String)', CallMethod); + AddProperty('Root', 'TfsXMLItem', GetProp, nil); + end; + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +var + i: Integer; + s: String; + _TList: TList; + _TStrings: TStrings; + _TStream: TStream; + _TMemoryStream: TMemoryStream; + _TfsXMLItem: TfsXMLItem; + _TfsXMLDocument: TfsXMLDocument; +begin + Result := 0; + + if ClassType = TObject then + begin + if MethodName = 'CREATE' then + Result := Integer(Instance.Create) + else if MethodName = 'FREE' then + Instance.Free + else if MethodName = 'CLASSNAME' then + Result := Instance.ClassName + end + else if ClassType = TPersistent then + begin + if MethodName = 'ASSIGN' then + TPersistent(Instance).Assign(TPersistent(Integer(Caller.Params[0]))); + end + else if ClassType = TCollection then + begin + if MethodName = 'CLEAR' then + TCollection(Instance).Clear + else if MethodName = 'ITEMS.GET' then + Result := Integer(TCollection(Instance).Items[Caller.Params[0]]) + end + else if ClassType = TList then + begin + _TList := TList(Instance); + if MethodName = 'ADD' then + _TList.Add(Pointer(Integer(Caller.Params[0]))) + else if MethodName = 'CLEAR' then + _TList.Clear + else if MethodName = 'DELETE' then + _TList.Delete(Caller.Params[0]) + else if MethodName = 'INDEXOF' then + Result := _TList.IndexOf(Pointer(Integer(Caller.Params[0]))) + else if MethodName = 'INSERT' then + _TList.Insert(Caller.Params[0], Pointer(Integer(Caller.Params[1]))) + else if MethodName = 'REMOVE' then + _TList.Remove(Pointer(Integer(Caller.Params[0]))) + else if MethodName = 'ITEMS.GET' then + Result := Integer(_TList.Items[Caller.Params[0]]) + else if MethodName = 'ITEMS.SET' then + _TList.Items[Caller.Params[0]] := Pointer(Integer(Caller.Params[1])) + end + else if ClassType = TStrings then + begin + _TStrings := TStrings(Instance); + if MethodName = 'ADD' then + Result := _TStrings.Add(Caller.Params[0]) + else if MethodName = 'ADDOBJECT' then + Result := _TStrings.AddObject(Caller.Params[0], TObject(Integer(Caller.Params[1]))) + else if MethodName = 'CLEAR' then + _TStrings.Clear + else if MethodName = 'DELETE' then + _TStrings.Delete(Caller.Params[0]) + else if MethodName = 'INDEXOF' then + Result := _TStrings.IndexOf(Caller.Params[0]) + else if MethodName = 'INDEXOFNAME' then + Result := _TStrings.IndexOfName(Caller.Params[0]) + else if MethodName = 'INDEXOFOBJECT' then + Result := _TStrings.IndexOfObject(TObject(Integer(Caller.Params[0]))) + else if MethodName = 'INSERT' then + _TStrings.Insert(Caller.Params[0], Caller.Params[1]) + else if MethodName = 'INSERTOBJECT' then + _TStrings.InsertObject(Caller.Params[0], Caller.Params[1], TObject(Integer(Caller.Params[2]))) + else if MethodName = 'LOADFROMFILE' then + _TStrings.LoadFromFile(Caller.Params[0]) + else if MethodName = 'LOADFROMSTREAM' then + _TStrings.LoadFromStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'MOVE' then + _TStrings.Move(Caller.Params[0], Caller.Params[1]) + else if MethodName = 'SAVETOFILE' then + _TStrings.SaveToFile(Caller.Params[0]) + else if MethodName = 'SAVETOSTREAM' then + _TStrings.SaveToStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'NAMES.GET' then + Result := _TStrings.Names[Caller.Params[0]] + else if MethodName = 'OBJECTS.GET' then + Result := Integer(_TStrings.Objects[Caller.Params[0]]) + else if MethodName = 'OBJECTS.SET' then + _TStrings.Objects[Caller.Params[0]] := TObject(Integer(Caller.Params[1])) + else if MethodName = 'VALUES.GET' then + Result := _TStrings.Values[Caller.Params[0]] + else if MethodName = 'VALUES.SET' then + _TStrings.Values[Caller.Params[0]] := Caller.Params[1] + else if MethodName = 'STRINGS.GET' then + Result := _TStrings.Strings[Caller.Params[0]] + else if MethodName = 'STRINGS.SET' then + _TStrings.Strings[Caller.Params[0]] := Caller.Params[1] + end + else if ClassType = TStringList then + begin + if MethodName = 'FIND' then + begin + Result := TStringList(Instance).Find(Caller.Params[0], i); + Caller.Params[1] := i; + end + else if MethodName = 'SORT' then + TStringList(Instance).Sort + end + else if ClassType = TStream then + begin + _TStream := TStream(Instance); + if MethodName = 'READ' then + begin + SetLength(s, Integer(Caller.Params[1])); + Result := _TStream.Read(s[1], Caller.Params[1]); + SetLength(s, Integer(Result)); + Caller.Params[0] := s; + end + else if MethodName = 'WRITE' then + begin + s := Caller.Params[0]; + Result := _TStream.Write(s[1], Caller.Params[1]); + end + else if MethodName = 'SEEK' then + Result := _TStream.Seek(Caller.Params[0], Caller.Params[1]) + else if MethodName = 'COPYFROM' then + Result := _TStream.CopyFrom(TStream(Integer(Caller.Params[0])), Caller.Params[1]) + end + else if ClassType = TFileStream then + begin + if MethodName = 'CREATE' then + Result := Integer(TFileStream(Instance).Create(Caller.Params[0], Caller.Params[1])) + end + else if ClassType = TMemoryStream then + begin + _TMemoryStream := TMemoryStream(Instance); + if MethodName = 'CLEAR' then + _TMemoryStream.Clear + else if MethodName = 'LOADFROMSTREAM' then + _TMemoryStream.LoadFromStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'LOADFROMFILE' then + _TMemoryStream.LoadFromFile(Caller.Params[0]) + else if MethodName = 'SAVETOSTREAM' then + _TMemoryStream.SaveToStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'SAVETOFILE' then + _TMemoryStream.SaveToFile(Caller.Params[0]) + end + else if ClassType = TComponent then + begin + if MethodName = 'CREATE' then + Result := Integer(TComponent(Instance).Create(TComponent(Integer(Caller.Params[0])))) + end + else if ClassType = TfsXMLItem then + begin + _TfsXMLItem := TfsXMLItem(Instance); + if MethodName = 'CREATE' then + Result := Integer(_TfsXMLItem.Create) + else if MethodName = 'ADDITEM' then + _TfsXMLItem.AddItem(TfsXMLItem(Integer(Caller.Params[0]))) + else if MethodName = 'CLEAR' then + _TfsXMLItem.Clear + else if MethodName = 'INSERTITEM' then + _TfsXMLItem.InsertItem(Caller.Params[0], TfsXMLItem(Integer(Caller.Params[1]))) + else if MethodName = 'ADD' then + Result := Integer(_TfsXMLItem.Add) + else if MethodName = 'FIND' then + Result := _TfsXMLItem.Find(Caller.Params[0]) + else if MethodName = 'FINDITEM' then + Result := Integer(_TfsXMLItem.FindItem(Caller.Params[0])) + else if MethodName = 'PROP.GET' then + Result := _TfsXMLItem.Prop[Caller.Params[0]] + else if MethodName = 'PROP.SET' then + _TfsXMLItem.Prop[Caller.Params[0]] := Caller.Params[1] + else if MethodName = 'ROOT' then + Result := Integer(_TfsXMLItem.Root) + else if MethodName = 'ROOT' then + Result := Integer(_TfsXMLItem.Root) + else if MethodName = 'ITEMS.GET' then + Result := Integer(_TfsXMLItem[Caller.Params[0]]) + end + else if ClassType = TfsXMLDocument then + begin + _TfsXMLDocument := TfsXMLDocument(Instance); + if MethodName = 'CREATE' then + Result := Integer(_TfsXMLDocument.Create) + else if MethodName = 'SAVETOSTREAM' then + _TfsXMLDocument.SaveToStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'LOADFROMSTREAM' then + _TfsXMLDocument.LoadFromStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'SAVETOFILE' then + _TfsXMLDocument.SaveToFile(Caller.Params[0]) + else if MethodName = 'LOADFROMFILE' then + _TfsXMLDocument.LoadFromFile(Caller.Params[0]) + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TCollection then + begin + if PropName = 'COUNT' then + Result := TCollection(Instance).Count + end + else if ClassType = TList then + begin + if PropName = 'COUNT' then + Result := TList(Instance).Count + end + else if ClassType = TStrings then + begin + if PropName = 'COMMATEXT' then + Result := TStrings(Instance).CommaText + else if PropName = 'COUNT' then + Result := TStrings(Instance).Count + else if PropName = 'TEXT' then + Result := TStrings(Instance).Text + end + else if ClassType = TStringList then + begin + if PropName = 'DUPLICATES' then + Result := TStringList(Instance).Duplicates + else if PropName = 'SORTED' then + Result := TStringList(Instance).Sorted + end + else if ClassType = TStream then + begin + if PropName = 'POSITION' then + Result := TStream(Instance).Position + else if PropName = 'SIZE' then + Result := TStream(Instance).Size + end + else if ClassType = TComponent then + begin + if PropName = 'OWNER' then + Result := Integer(TComponent(Instance).Owner) + end + else if ClassType = TfsXMLItem then + begin + if PropName = 'DATA' then + Result := Integer(TfsXMLItem(Instance).Data) + else if PropName = 'COUNT' then + Result := TfsXMLItem(Instance).Count + else if PropName = 'NAME' then + Result := TfsXMLItem(Instance).Name + else if PropName = 'PARENT' then + Result := Integer(TfsXMLItem(Instance).Parent) + else if PropName = 'TEXT' then + Result := TfsXMLItem(Instance).Text + end + else if ClassType = TfsXMLDocument then + begin + if PropName = 'ROOT' then + Result := Integer(TfsXMLDocument(Instance).Root) + end +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin + if ClassType = TStrings then + begin + if PropName = 'COMMATEXT' then + TStrings(Instance).CommaText := Value + else if PropName = 'TEXT' then + TStrings(Instance).Text := Value + end + else if ClassType = TStringList then + begin + if PropName = 'DUPLICATES' then + TStringList(Instance).Duplicates := Value + else if PropName = 'SORTED' then + TStringList(Instance).Sorted := Value + end + else if ClassType = TStream then + begin + if PropName = 'POSITION' then + TStream(Instance).Position := Value + end + else if ClassType = TfsXMLItem then + begin + if PropName = 'DATA' then + TfsXMLItem(Instance).Data := Pointer(Integer(Value)) + else if PropName = 'NAME' then + TfsXMLItem(Instance).Name := Value + else if PropName = 'TEXT' then + TfsXMLItem(Instance).Text := Value + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_iconst.pas b/official/4.2/LibD11/fs_iconst.pas new file mode 100644 index 0000000..bbcdd0e --- /dev/null +++ b/official/4.2/LibD11/fs_iconst.pas @@ -0,0 +1,59 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Resources } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iconst; + +interface + +{$i fs.inc} + +var + SLangNotFound: String; + SInvalidLanguage: String; + SIdRedeclared: String; + SUnknownType: String; + SIncompatibleTypes: String; + SIdUndeclared: String; + SClassRequired: String; + SIndexRequired: String; + SStringError: String; + SClassError: String; + SArrayRequired: String; + SVarRequired: String; + SNotEnoughParams: String; + STooManyParams: String; + SLeftCantAssigned: String; + SForError: String; + SEventError: String; + + +implementation + +initialization + SLangNotFound := 'Language ''%s'' not found'; + SInvalidLanguage := 'Invalid language definition'; + SIdRedeclared := 'Identifier redeclared: '; + SUnknownType := 'Unknown type: '; + SIncompatibleTypes := 'Incompatible types'; + SIdUndeclared := 'Undeclared identifier: '; + SClassRequired := 'Class type required'; + SIndexRequired := 'Index required'; + SStringError := 'Strings doesn''t have properties or methods'; + SClassError := 'Class %s does not have a default property'; + SArrayRequired := 'Array type required'; + SVarRequired := 'Variable required'; + SNotEnoughParams := 'Not enough actual parameters'; + STooManyParams := 'Too many actual parameters'; + SLeftCantAssigned := 'Left side cannot be assigned to'; + SForError := 'For loop variable must be numeric variable'; + SEventError := 'Event handler must be a procedure'; + +end. diff --git a/official/4.2/LibD11/fs_icpp.pas b/official/4.2/LibD11/fs_icpp.pas new file mode 100644 index 0000000..df80918 --- /dev/null +++ b/official/4.2/LibD11/fs_icpp.pas @@ -0,0 +1,159 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ C++ grammar } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_icpp; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_itools; + +type + TfsCPP = class(TComponent); + + +implementation + +const + CPP_GRAMMAR = + '' + + '<' + + 'err20 text="''>'' expected"/>' + + '' + + '' + + '<' + + 'sequence>' + + '<' + + 'sequence>' + + '' + + '' + + '' + + ''; + + +initialization + fsRegisterLanguage('C++Script', CPP_GRAMMAR); + +end. diff --git a/official/4.2/LibD11/fs_idbctrlsrtti.pas b/official/4.2/LibD11/fs_idbctrlsrtti.pas new file mode 100644 index 0000000..0948213 --- /dev/null +++ b/official/4.2/LibD11/fs_idbctrlsrtti.pas @@ -0,0 +1,182 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ DB controls } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_idbctrlsrtti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_itools, fs_iformsrtti, fs_idbrtti, DB +{$IFDEF CLX} +, QDBCtrls, QDBGrids +{$ELSE} +, DBCtrls, DBGrids +{$ENDIF}; + + +type + TfsDBCtrlsRTTI = class(TComponent); // fake component + + +implementation + +type +{$IFNDEF FPC} + THackDBLookupControl = class(TDBLookupControl); +{$ENDIF} + + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnumSet('TButtonSet', 'nbFirst, nbPrior, nbNext, nbLast,' + + 'nbInsert, nbDelete, nbEdit, nbPost, nbCancel, nbRefresh'); + AddEnum('TColumnButtonStyle', 'cbsAuto, cbsEllipsis, cbsNone'); + AddEnumSet('TDBGridOptions', 'dgEditing, dgAlwaysShowEditor, dgTitles,' + + 'dgIndicator, dgColumnResize, dgColLines, dgRowLines, dgTabs, dgRowSelect,' + + 'dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgMultiSelect'); + + AddClass(TDBEdit, 'TWinControl'); + AddClass(TDBText, 'TGraphicControl'); + with AddClass(TDBCheckBox, 'TWinControl') do + AddProperty('Checked', 'Boolean', GetProp, nil); + with AddClass(TDBComboBox, 'TCustomComboBox') do + AddProperty('Text', 'String', GetProp, nil); + AddClass(TDBListBox, 'TCustomListBox'); + with AddClass(TDBRadioGroup, 'TWinControl') do + begin + AddProperty('ItemIndex', 'Integer', GetProp, nil); + AddProperty('Value', 'String', GetProp, nil); + end; + AddClass(TDBMemo, 'TWinControl'); + AddClass(TDBImage, 'TCustomControl'); + AddClass(TDBNavigator, 'TWinControl'); +{$IFNDEF FPC} + with AddClass(TDBLookupControl, 'TCustomControl') do + AddProperty('KeyValue', 'Variant', GetProp, SetProp); + with AddClass(TDBLookupListBox, 'TDBLookupControl') do + AddProperty('SelectedItem', 'String', GetProp, nil); + with AddClass(TDBLookupComboBox, 'TDBLookupControl') do + AddProperty('Text', 'String', GetProp, nil); +{$ENDIF} + AddClass(TColumnTitle, 'TPersistent'); + AddClass(TColumn, 'TPersistent'); + with AddClass(TDBGridColumns, 'TCollection') do + begin + AddMethod('function Add: TColumn', CallMethod); + AddMethod('procedure RebuildColumns', CallMethod); + AddMethod('procedure RestoreDefaults', CallMethod); + AddDefaultProperty('Items', 'Integer', 'TColumn', CallMethod, True); + end; + AddClass(TDBGrid, 'TWinControl'); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TDBGridColumns then + begin + if MethodName = 'ADD' then + Result := Integer(TDBGridColumns(Instance).Add) + else if MethodName = 'ITEMS.GET' then + Result := Integer(TDBGridColumns(Instance).Items[Caller.Params[0]]) +{$IFNDEF FPC} + else if MethodName = 'REBUILDCOLUMNS' then + TDBGridColumns(Instance).RebuildColumns + else if MethodName = 'RESTOREDEFAULTS' then + TDBGridColumns(Instance).RestoreDefaults +{$ENDIF} + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TDBCheckBox then + begin + if PropName = 'CHECKED' then + Result := TDBCheckBox(Instance).Checked + end + else if ClassType = TDBComboBox then + begin + if PropName = 'TEXT' then + Result := TDBComboBox(Instance).Text + end + else if ClassType = TDBRadioGroup then + begin + if PropName = 'ITEMINDEX' then + Result := TDBRadioGroup(Instance).ItemIndex + else if PropName = 'VALUE' then + Result := TDBRadioGroup(Instance).Value + end +{$IFNDEF FPC} + else if ClassType = TDBLookupControl then + begin + if PropName = 'KEYVALUE' then + Result := THackDBLookupControl(Instance).KeyValue + end + else if ClassType = TDBLookupListBox then + begin + if PropName = 'SELECTEDITEM' then + Result := TDBLookupListBox(Instance).SelectedItem + end + else if ClassType = TDBLookupComboBox then + begin + if PropName = 'TEXT' then + Result := TDBLookupComboBox(Instance).Text + end +{$ENDIF} +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin +{$IFNDEF FPC} + if ClassType = TDBLookupControl then + begin + if PropName = 'KEYVALUE' then + THackDBLookupControl(Instance).KeyValue := Value + end +{$ENDIF} +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_idbreg.pas b/official/4.2/LibD11/fs_idbreg.pas new file mode 100644 index 0000000..54d6231 --- /dev/null +++ b/official/4.2/LibD11/fs_idbreg.pas @@ -0,0 +1,39 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Registration unit } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_idbreg; + +{$i fs.inc} + +interface + + +procedure Register; + +implementation + +uses + Classes +{$IFNDEF Delphi6} +, DsgnIntf +{$ELSE} +, DesignIntf +{$ENDIF} +, fs_idbrtti, fs_idbctrlsrtti; + +{-----------------------------------------------------------------------} + +procedure Register; +begin + RegisterComponents('FastScript', [TfsDBRTTI, TfsDBCtrlsRTTI]); +end; + +end. diff --git a/official/4.2/LibD11/fs_idbrtti.pas b/official/4.2/LibD11/fs_idbrtti.pas new file mode 100644 index 0000000..421f796 --- /dev/null +++ b/official/4.2/LibD11/fs_idbrtti.pas @@ -0,0 +1,562 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ DB.pas classes and functions } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_idbrtti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_itools, fs_iclassesrtti, fs_ievents, + DB; + +type + TfsDBRTTI = class(TComponent); // fake component + + TfsDatasetNotifyEvent = class(TfsCustomEvent) + public + procedure DoEvent(Dataset: TDataset); + function GetMethod: Pointer; override; + end; + + TfsFilterRecordEvent = class(TfsCustomEvent) + public + procedure DoEvent(DataSet: TDataSet; var Accept: Boolean); + function GetMethod: Pointer; override; + end; + + TfsFieldGetTextEvent = class(TfsCustomEvent) + public + procedure DoEvent(Sender: TField; var Text: String; DisplayText: Boolean); + function GetMethod: Pointer; override; + end; + + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TfsDatasetNotifyEvent } + +procedure TfsDatasetNotifyEvent.DoEvent(Dataset: TDataset); +begin + CallHandler([Dataset]); +end; + +function TfsDatasetNotifyEvent.GetMethod: Pointer; +begin + Result := @TfsDatasetNotifyEvent.DoEvent; +end; + + +{ TfsFilterRecordEvent } + +procedure TfsFilterRecordEvent.DoEvent(DataSet: TDataSet; var Accept: Boolean); +begin + CallHandler([DataSet, Accept]); + Accept := Handler.Params[1].Value; +end; + +function TfsFilterRecordEvent.GetMethod: Pointer; +begin + Result := @TfsFilterRecordEvent.DoEvent; +end; + + +{ TfsFieldGetTextEvent } + +procedure TfsFieldGetTextEvent.DoEvent(Sender: TField; var Text: String; DisplayText: Boolean); +begin + CallHandler([Sender, Text, DisplayText]); + Text := Handler.Params[1].Value; +end; + +function TfsFieldGetTextEvent.GetMethod: Pointer; +begin + Result := @TfsFieldGetTextEvent.DoEvent; +end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnum('TFieldType', 'ftUnknown, ftString, ftSmallint, ftInteger, ftWord,' + + 'ftBoolean, ftFloat, ftCurrency, ftBCD, ftDate, ftTime, ftDateTime,' + + 'ftBytes, ftVarBytes, ftAutoInc, ftBlob, ftMemo, ftGraphic, ftFmtMemo,' + + 'ftParadoxOle, ftDBaseOle, ftTypedBinary, ftCursor, ftFixedChar, ftWideString,' + + 'ftLargeint, ftADT, ftArray, ftReference, ftDataSet, ftOraBlob, ftOraClob,' + + 'ftVariant, ftInterface, ftIDispatch, ftGuid, ftTimeStamp, ftFMTBcd'); + AddEnum('TBlobStreamMode', 'bmRead, bmWrite, bmReadWrite'); + AddEnumSet('TLocateOptions', 'loCaseInsensitive, loPartialKey'); + AddEnumSet('TFilterOptions', 'foCaseInsensitive, foNoPartialCompare'); + AddEnum('TParamType', 'ptUnknown, ptInput, ptOutput, ptInputOutput, ptResult'); + + with AddClass(TField, 'TComponent') do + begin + AddProperty('AsBoolean', 'Boolean', GetProp, SetProp); + AddProperty('AsCurrency', 'Currency', GetProp, SetProp); + AddProperty('AsDateTime', 'TDateTime', GetProp, SetProp); + AddProperty('AsFloat', 'Double', GetProp, SetProp); + AddProperty('AsInteger', 'Integer', GetProp, SetProp); + AddProperty('AsString', 'String', GetProp, SetProp); + AddProperty('AsVariant', 'Variant', GetProp, SetProp); + AddProperty('DataType', 'TFieldType', GetProp, nil); + AddProperty('DisplayName', 'String', GetProp, nil); + AddProperty('DisplayText', 'String', GetProp, nil); + AddProperty('IsNull', 'Boolean', GetProp, nil); + AddProperty('Size', 'Integer', GetProp, SetProp); + AddProperty('Value', 'Variant', GetProp, SetProp); + AddEvent('OnGetText', TfsFieldGetTextEvent); + end; + with AddClass(TFields, 'TObject') do + AddDefaultProperty('Fields', 'Integer', 'TField', CallMethod, True); + AddClass(TStringField, 'TField'); + AddClass(TNumericField, 'TField'); + AddClass(TIntegerField, 'TNumericField'); + AddClass(TSmallIntField, 'TIntegerField'); + AddClass(TWordField, 'TIntegerField'); + AddClass(TAutoIncField, 'TIntegerField'); + AddClass(TFloatField, 'TNumericField'); + AddClass(TCurrencyField, 'TFloatField'); + AddClass(TBooleanField, 'TField'); + AddClass(TDateTimeField, 'TField'); + AddClass(TDateField, 'TDateTimeField'); + AddClass(TTimeField, 'TDateTimeField'); + AddClass(TBinaryField, 'TField'); + AddClass(TBytesField, 'TBinaryField'); + AddClass(TVarBytesField, 'TBinaryField'); + AddClass(TBCDField, 'TNumericField'); + with AddClass(TBlobField, 'TField') do + begin + AddMethod('procedure LoadFromFile(const FileName: String)', CallMethod); + AddMethod('procedure LoadFromStream(Stream: TStream)', CallMethod); + AddMethod('procedure SaveToFile(const FileName: String)', CallMethod); + AddMethod('procedure SaveToStream(Stream: TStream)', CallMethod); + end; + AddClass(TMemoField, 'TBlobField'); + AddClass(TGraphicField, 'TBlobField'); + AddClass(TFieldDef, 'TPersistent'); + with AddClass(TFieldDefs, 'TObject') do + begin + AddMethod('function AddFieldDef: TFieldDef', CallMethod); + AddMethod('function Find(const Name: string): TFieldDef', CallMethod); + AddMethod('procedure Add(const Name: string; DataType: TFieldType; Size: Word; Required: Boolean)', CallMethod); + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure Update', CallMethod); + AddDefaultProperty('Items', 'Integer', 'TFieldDef', CallMethod, True); + end; + AddClass(TDataSource, 'TComponent'); + AddType('TBookmark', fvtVariant); + with AddClass(TDataSet, 'TComponent') do + begin + AddMethod('procedure Open', CallMethod); + AddMethod('procedure Close', CallMethod); + AddMethod('procedure First', CallMethod); + AddMethod('procedure Last', CallMethod); + AddMethod('procedure Next', CallMethod); + AddMethod('procedure Prior', CallMethod); + AddMethod('procedure Cancel', CallMethod); + AddMethod('procedure Delete', CallMethod); + AddMethod('procedure Post', CallMethod); + AddMethod('procedure Append', CallMethod); + AddMethod('procedure Insert', CallMethod); + AddMethod('procedure Edit', CallMethod); + + AddMethod('function FieldByName(const FieldName: string): TField', CallMethod); + AddMethod('procedure GetFieldNames(List: TStrings)', CallMethod); + AddMethod('function FindFirst: Boolean', CallMethod); + AddMethod('function FindLast: Boolean', CallMethod); + AddMethod('function FindNext: Boolean', CallMethod); + AddMethod('function FindPrior: Boolean', CallMethod); + AddMethod('procedure FreeBookmark(Bookmark: TBookmark)', CallMethod); + AddMethod('function GetBookmark: TBookmark', CallMethod); + AddMethod('procedure GotoBookmark(Bookmark: TBookmark)', CallMethod); + AddMethod('function Locate(const KeyFields: string; const KeyValues: Variant;' + + 'Options: TLocateOptions): Boolean', CallMethod); + AddMethod('function IsEmpty: Boolean', CallMethod); + AddMethod('procedure EnableControls', CallMethod); + AddMethod('procedure DisableControls', CallMethod); + + AddProperty('Bof', 'Boolean', GetProp, nil); + AddProperty('Eof', 'Boolean', GetProp, nil); + AddProperty('FieldCount', 'Integer', GetProp, nil); + AddProperty('FieldDefs', 'TFieldDefs', GetProp, nil); + AddProperty('Fields', 'TFields', GetProp, nil); + AddProperty('Filter', 'string', GetProp, SetProp); + AddProperty('Filtered', 'Boolean', GetProp, SetProp); + AddProperty('FilterOptions', 'TFilterOptions', GetProp, SetProp); + AddProperty('Active', 'Boolean', GetProp, SetProp); + + AddEvent('BeforeOpen', TfsDatasetNotifyEvent); + AddEvent('AfterOpen', TfsDatasetNotifyEvent); + AddEvent('BeforeClose', TfsDatasetNotifyEvent); + AddEvent('AfterClose', TfsDatasetNotifyEvent); + AddEvent('BeforeInsert', TfsDatasetNotifyEvent); + AddEvent('AfterInsert', TfsDatasetNotifyEvent); + AddEvent('BeforeEdit', TfsDatasetNotifyEvent); + AddEvent('AfterEdit', TfsDatasetNotifyEvent); + AddEvent('BeforePost', TfsDatasetNotifyEvent); + AddEvent('AfterPost', TfsDatasetNotifyEvent); + AddEvent('BeforeCancel', TfsDatasetNotifyEvent); + AddEvent('AfterCancel', TfsDatasetNotifyEvent); + AddEvent('BeforeDelete', TfsDatasetNotifyEvent); + AddEvent('AfterDelete', TfsDatasetNotifyEvent); + AddEvent('BeforeScroll', TfsDatasetNotifyEvent); + AddEvent('AfterScroll', TfsDatasetNotifyEvent); + AddEvent('OnCalcFields', TfsDatasetNotifyEvent); + AddEvent('OnFilterRecord', TfsFilterRecordEvent); + AddEvent('OnNewRecord', TfsDatasetNotifyEvent); + end; + + with AddClass(TParam, 'TPersistent') do + begin + AddMethod('procedure Clear', CallMethod); + AddProperty('AsBoolean', 'Boolean', GetProp, SetProp); + AddProperty('AsCurrency', 'Currency', GetProp, SetProp); + AddProperty('AsDateTime', 'TDateTime', GetProp, SetProp); + AddProperty('AsFloat', 'Double', GetProp, SetProp); + AddProperty('AsInteger', 'Integer', GetProp, SetProp); + AddProperty('AsDate', 'TDate', GetProp, SetProp); + AddProperty('AsTime', 'TTime', GetProp, SetProp); + AddProperty('AsString', 'String', GetProp, SetProp); + AddProperty('Bound', 'Boolean', GetProp, SetProp); + AddProperty('IsNull', 'Boolean', GetProp, nil); + AddProperty('Text', 'String', GetProp, SetProp); + end; + with AddClass(TParams, 'TPersistent') do + begin + AddMethod('function ParamByName(const Value: string): TParam', CallMethod); + AddMethod('function FindParam(const Value: string): TParam', CallMethod); + AddDefaultProperty('Items', 'Integer', 'TParam', CallMethod, True); + end; + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +var + _TDataSet: TDataSet; + + function IntToLocateOptions(i: Integer): TLocateOptions; + begin + Result := []; + if (i and 1) <> 0 then + Result := Result + [loCaseInsensitive]; + if (i and 2) <> 0 then + Result := Result + [loPartialKey]; + end; + +begin + Result := 0; + + if ClassType = TFields then + begin + if MethodName = 'FIELDS.GET' then + Result := Integer(TFields(Instance)[Caller.Params[0]]) + end + else if ClassType = TFieldDefs then + begin + if MethodName = 'ITEMS.GET' then + Result := Integer(TFieldDefs(Instance)[Caller.Params[0]]) + else if MethodName = 'ADD' then + TFieldDefs(Instance).Add(Caller.Params[0], TFieldType(Caller.Params[1]), Caller.Params[2], Caller.Params[3]) + else if MethodName = 'ADDFIELDDEF' then + Result := Integer(TFieldDefs(Instance).AddFieldDef) + else if MethodName = 'CLEAR' then + TFieldDefs(Instance).Clear + else if MethodName = 'FIND' then + Result := Integer(TFieldDefs(Instance).Find(Caller.Params[0])) + else if MethodName = 'UPDATE' then + TFieldDefs(Instance).Update + end + else if ClassType = TBlobField then + begin + if MethodName = 'LOADFROMFILE' then + TBlobField(Instance).LoadFromFile(Caller.Params[0]) + else if MethodName = 'LOADFROMSTREAM' then + TBlobField(Instance).LoadFromStream(TStream(Integer(Caller.Params[0]))) + else if MethodName = 'SAVETOFILE' then + TBlobField(Instance).SaveToFile(Caller.Params[0]) + else if MethodName = 'SAVETOSTREAM' then + TBlobField(Instance).SaveToStream(TStream(Integer(Caller.Params[0]))) + end + else if ClassType = TDataSet then + begin + _TDataSet := TDataSet(Instance); + if MethodName = 'OPEN' then + _TDataSet.Open + else if MethodName = 'CLOSE' then + _TDataSet.Close + else if MethodName = 'FIRST' then + _TDataSet.First + else if MethodName = 'LAST' then + _TDataSet.Last + else if MethodName = 'NEXT' then + _TDataSet.Next + else if MethodName = 'PRIOR' then + _TDataSet.Prior + else if MethodName = 'CANCEL' then + _TDataSet.Cancel + else if MethodName = 'DELETE' then + _TDataSet.Delete + else if MethodName = 'POST' then + _TDataSet.Post + else if MethodName = 'APPEND' then + _TDataSet.Append + else if MethodName = 'INSERT' then + _TDataSet.Insert + else if MethodName = 'EDIT' then + _TDataSet.Edit + else if MethodName = 'FIELDBYNAME' then + Result := Integer(_TDataSet.FieldByName(Caller.Params[0])) + else if MethodName = 'GETFIELDNAMES' then + _TDataSet.GetFieldNames(TStrings(Integer(Caller.Params[0]))) + else if MethodName = 'FINDFIRST' then + Result := _TDataSet.FindFirst + else if MethodName = 'FINDLAST' then + Result := _TDataSet.FindLast + else if MethodName = 'FINDNEXT' then + Result := _TDataSet.FindNext + else if MethodName = 'FINDPRIOR' then + Result := _TDataSet.FindPrior + else if MethodName = 'FREEBOOKMARK' then + _TDataSet.FreeBookmark(TBookMark(Integer(Caller.Params[0]))) + else if MethodName = 'GETBOOKMARK' then + Result := Integer(_TDataSet.GetBookmark) + else if MethodName = 'GOTOBOOKMARK' then + _TDataSet.GotoBookmark(TBookMark(Integer(Caller.Params[0]))) + else if MethodName = 'LOCATE' then + Result := _TDataSet.Locate(Caller.Params[0], Caller.Params[1], IntToLocateOptions(Caller.Params[2])) + else if MethodName = 'ISEMPTY' then + Result := _TDataSet.IsEmpty + else if MethodName = 'ENABLECONTROLS' then + _TDataSet.EnableControls + else if MethodName = 'DISABLECONTROLS' then + _TDataSet.DisableControls + end + else if ClassType = TParam then + begin + if MethodName = 'CLEAR' then + TParam(Instance).Clear + end + else if ClassType = TParams then + begin + if MethodName = 'PARAMBYNAME' then + Result := Integer(TParams(Instance).ParamByName(Caller.Params[0])) + else if MethodName = 'FINDPARAM' then + Result := Integer(TParams(Instance).FindParam(Caller.Params[0])) + else if MethodName = 'ITEMS.GET' then + Result := Integer(TParams(Instance)[Caller.Params[0]]) + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +var + _TField: TField; + _TParam: TParam; + _TDataSet: TDataSet; + + function FilterOptionsToInt(f: TFilterOptions): Integer; + begin + Result := 0; + if foCaseInsensitive in f then + Result := Result or 1; + if foNoPartialCompare in f then + Result := Result or 2; + end; + +begin + Result := 0; + + if ClassType = TField then + begin + _TField := TField(Instance); + if PropName = 'ASBOOLEAN' then + Result := _TField.AsBoolean + else if PropName = 'ASCURRENCY' then + Result := _TField.AsCurrency + else if PropName = 'ASDATETIME' then + Result := _TField.AsDateTime + else if PropName = 'ASFLOAT' then + Result := _TField.AsFloat + else if PropName = 'ASINTEGER' then + Result := _TField.AsInteger + else if PropName = 'ASSTRING' then + Result := _TField.AsString + else if PropName = 'ASVARIANT' then + Result := _TField.AsVariant + else if PropName = 'DATATYPE' then + Result := _TField.DataType + else if PropName = 'DISPLAYNAME' then + Result := _TField.DisplayName + else if PropName = 'DISPLAYTEXT' then + Result := _TField.DisplayText + else if PropName = 'ISNULL' then + Result := _TField.IsNull + else if PropName = 'SIZE' then + Result := _TField.Size + else if PropName = 'VALUE' then + Result := _TField.Value + end + else if ClassType = TDataSet then + begin + _TDataSet := TDataSet(Instance); + if PropName = 'BOF' then + Result := _TDataSet.Bof + else if PropName = 'EOF' then + Result := _TDataSet.Eof + else if PropName = 'FIELDCOUNT' then + Result := _TDataSet.FieldCount + else if PropName = 'FIELDDEFS' then + Result := Integer(_TDataSet.FieldDefs) + else if PropName = 'FIELDS' then + Result := Integer(_TDataSet.Fields) + else if PropName = 'FILTER' then + Result := _TDataSet.Filter + else if PropName = 'FILTERED' then + Result := _TDataSet.Filtered + else if PropName = 'FILTEROPTIONS' then + Result := FilterOptionsToInt(_TDataSet.FilterOptions) + else if PropName = 'ACTIVE' then + Result := _TDataSet.Active + end + else if ClassType = TParam then + begin + _TParam := TParam(Instance); + if PropName = 'BOUND' then + Result := _TParam.Bound + else if PropName = 'ISNULL' then + Result := _TParam.IsNull + else if PropName = 'TEXT' then + Result := _TParam.Text + else if PropName = 'ASBOOLEAN' then + Result := _TParam.AsBoolean + else if PropName = 'ASCURRENCY' then + Result := _TParam.AsCurrency + else if PropName = 'ASDATETIME' then + Result := _TParam.AsDateTime + else if PropName = 'ASFLOAT' then + Result := _TParam.AsFloat + else if PropName = 'ASINTEGER' then + Result := _TParam.AsInteger + else if PropName = 'ASDATE' then + Result := _TParam.AsDate + else if PropName = 'ASTIME' then + Result := _TParam.AsTime + else if PropName = 'ASSTRING' then + Result := _TParam.AsString + end +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +var + _TField: TField; + _TParam: TParam; + _TDataSet: TDataSet; + + function IntToFilterOptions(i: Integer): TFilterOptions; + begin + Result := []; + if (i and 1) <> 0 then + Result := Result + [foCaseInsensitive]; + if (i and 2) <> 0 then + Result := Result + [foNoPartialCompare]; + end; + +begin + if ClassType = TField then + begin + _TField := TField(Instance); + if PropName = 'ASBOOLEAN' then + _TField.AsBoolean := Value + else if PropName = 'ASCURRENCY' then + _TField.AsCurrency := Value + else if PropName = 'ASDATETIME' then + _TField.AsDateTime := Value + else if PropName = 'ASFLOAT' then + _TField.AsFloat := Value + else if PropName = 'ASINTEGER' then + _TField.AsInteger := Value + else if PropName = 'ASSTRING' then + _TField.AsString := Value + else if PropName = 'ASVARIANT' then + _TField.AsVariant := Value + else if PropName = 'VALUE' then + _TField.Value := Value + else if PropName = 'SIZE' then + _TField.Size := Value + end + else if ClassType = TDataSet then + begin + _TDataSet := TDataSet(Instance); + if PropName = 'FILTER' then + _TDataSet.Filter := Value + else if PropName = 'FILTERED' then + _TDataSet.Filtered := Value + else if PropName = 'FILTEROPTIONS' then + _TDataSet.FilterOptions := IntToFilterOptions(Value) + else if PropName = 'ACTIVE' then + _TDataSet.Active := Value + end + else if ClassType = TParam then + begin + _TParam := TParam(Instance); + if PropName = 'ASBOOLEAN' then + _TParam.AsBoolean := Value + else if PropName = 'ASCURRENCY' then + _TParam.AsCurrency := Value + else if PropName = 'ASDATETIME' then + _TParam.AsDateTime := Value + else if PropName = 'ASFLOAT' then + _TParam.AsFloat := Value + else if PropName = 'ASINTEGER' then + _TParam.AsInteger := Value + else if PropName = 'ASDATE' then + _TParam.AsDate := Value + else if PropName = 'ASTIME' then + _TParam.AsTime := Value + else if PropName = 'ASSTRING' then + _TParam.AsString := Value + else if PropName = 'BOUND' then + _TParam.Bound := Value + else if PropName = 'TEXT' then + _TParam.Text := Value + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_idialogsrtti.pas b/official/4.2/LibD11/fs_idialogsrtti.pas new file mode 100644 index 0000000..2018f24 --- /dev/null +++ b/official/4.2/LibD11/fs_idialogsrtti.pas @@ -0,0 +1,157 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Dialogs.pas classes and functions } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_idialogsrtti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_iclassesrtti +{$IFDEF CLX} +, QDialogs +{$ELSE} +, Dialogs +{$ENDIF}; + +type + TfsDialogsRTTI = class(TComponent); // fake component + + +implementation + +type +{$IFDEF CLX} + THackDialog = class(TDialog); +{$ELSE} + THackDialog = class(TCommonDialog); +{$ENDIF} + + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + +type + TWordSet = set of 0..15; + PWordSet = ^TWordSet; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +var + dlg: String; +begin + inherited Create(AScript); + with AScript do + begin + AddEnumSet('TOpenOptions', 'ofReadOnly, ofOverwritePrompt, ofHideReadOnly,' + + 'ofNoChangeDir, ofShowHelp, ofNoValidate, ofAllowMultiSelect,' + + 'ofExtensionDifferent, ofPathMustExist, ofFileMustExist, ofCreatePrompt,' + + 'ofShareAware, ofNoReadOnlyReturn, ofNoTestFileCreate, ofNoNetworkButton,' + + 'ofNoLongNames, ofOldStyleDialog, ofNoDereferenceLinks, ofEnableIncludeNotify,' + + 'ofEnableSizing'); + AddEnum('TFileEditStyle', 'fsEdit, fsComboBox'); + AddEnumSet('TColorDialogOptions', 'cdFullOpen, cdPreventFullOpen, cdShowHelp,' + + 'cdSolidColor, cdAnyColor'); + AddEnumSet('TFontDialogOptions', 'fdAnsiOnly, fdTrueTypeOnly, fdEffects,' + + 'fdFixedPitchOnly, fdForceFontExist, fdNoFaceSel, fdNoOEMFonts,' + + 'fdNoSimulations, fdNoSizeSel, fdNoStyleSel, fdNoVectorFonts,' + + 'fdShowHelp, fdWysiwyg, fdLimitSize, fdScalableOnly, fdApplyButton'); + AddEnum('TFontDialogDevice', 'fdScreen, fdPrinter, fdBoth'); + AddEnum('TPrintRange', 'prAllPages, prSelection, prPageNums'); + AddEnumSet('TPrintDialogOptions', 'poPrintToFile, poPageNums, poSelection,' + + 'poWarning, poHelp, poDisablePrintToFile'); +{$IFNDEF CLX} + AddEnum('TMsgDlgType', 'mtWarning, mtError, mtInformation, mtConfirmation, mtCustom'); + AddEnumSet('TMsgDlgButtons', 'mbYes, mbNo, mbOK, mbCancel, mbAbort, mbRetry, ' + + 'mbIgnore, mbAll, mbNoToAll, mbYesToAll, mbHelp'); +{$ELSE} + AddEnum('TMsgDlgType', 'mtCustom, mtInformation, mtWarning, mtError, mtConfirmation'); + AddEnumSet('TMsgDlgButtons', 'mbNone, mbOk, mbCancel, mbYes, mbNo, mbAbort, ' + + 'mbRetry, mbIgnore'); +{$ENDIF} + +{$IFDEF CLX} + dlg := 'TDialog'; + with AddClass(TDialog, 'TComponent') do +{$ELSE} + dlg := 'TCommonDialog'; + with AddClass(TCommonDialog, 'TComponent') do +{$ENDIF} + AddMethod('function Execute: Boolean', CallMethod); + AddClass(TOpenDialog, dlg); + AddClass(TSaveDialog, dlg); + AddClass(TColorDialog, dlg); + AddClass(TFontDialog, dlg); +{$IFNDEF CLX} + {$IFNDEF FPC} + // todo: wait lazarus 1.0 TPrintDialog is targeted in Mantis to 1.0 + AddClass(TPrintDialog, dlg); + AddClass(TPrinterSetupDialog, dlg); + {$ENDIF} +{$ENDIF} + AddMethod('function MessageDlg(Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Integer', CallMethod, 'ctOther'); + AddMethod('function InputBox(ACaption, APrompt, ADefault: string): string', CallMethod, 'ctOther'); + AddMethod('function InputQuery(ACaption, APrompt: string; var Value: string): Boolean', CallMethod, 'ctOther'); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +var + s: String; + b: TMsgDlgButtons; +begin + Result := 0; + +{$IFDEF CLX} + if ClassType = TDialog then +{$ELSE} + if ClassType = TCommonDialog then +{$ENDIF} + begin + if MethodName = 'EXECUTE' then + Result := THackDialog(Instance).Execute + end + else if MethodName = 'INPUTBOX' then + Result := InputBox(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'INPUTQUERY' then + begin + s := Caller.Params[2]; + Result := InputQuery(Caller.Params[0], Caller.Params[1], s); + Caller.Params[2] := s; + end + else if MethodName = 'MESSAGEDLG' then + begin + {$IFNDEF FPC} + Word(PWordSet(@b)^) := Caller.Params[2]; + {$ELSE} + Integer(PWordSet(@b)^) := Caller.Params[2]; + {$ENDIF} + Result := MessageDlg(Caller.Params[0], Caller.Params[1], b, Caller.Params[3]); + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_idisp.pas b/official/4.2/LibD11/fs_idisp.pas new file mode 100644 index 0000000..512d05d --- /dev/null +++ b/official/4.2/LibD11/fs_idisp.pas @@ -0,0 +1,126 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ OLE dispatch module } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_idisp; + +interface + +{$I fs.inc} + +uses + Windows, Classes, SysUtils, ActiveX, ComObj, fs_iinterpreter +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfsOLEHelper = class(TfsCustomHelper) + private + function DispatchInvoke(const ParamArray: Variant; ParamCount: Integer; + Flags: Word): Variant; + protected + procedure SetValue(const Value: Variant); override; + function GetValue: Variant; override; + public + constructor Create(const AName: String); + end; + + +implementation + + +constructor TfsOLEHelper.Create(const AName: String); +begin + inherited Create(AName, fvtVariant, ''); +end; + +function TfsOLEHelper.DispatchInvoke(const ParamArray: Variant; ParamCount: Integer; + Flags: Word): Variant; +const + DispIDArgs: Longint = DISPID_PROPERTYPUT; +var + DispId: TDispId; + Params: TDISPPARAMS; + pName: WideString; + ExcepMess: WideString; + Args: array[0..63] of Variant; + i: Integer; + PResult: PVariant; + Status: Integer; + ExcepInfo: TExcepInfo; +begin + ExcepMess := ''; + pName := Name; + IDispatch(ParentValue).GetIDsOfNames(GUID_NULL, @pName, 1, GetThreadLocale, @DispId); + + for i := 0 to ParamCount - 1 do + Args[i] := ParamArray[ParamCount - i - 1]; + + Params.rgvarg := @Args; + Params.rgdispidNamedArgs := nil; + Params.cArgs := ParamCount; + Params.cNamedArgs := 0; + if Flags = DISPATCH_PROPERTYPUT then + begin + Params.rgdispidNamedArgs := @DispIDArgs; + Params.cNamedArgs := 1; + end; + + if NeedResult and (Flags <> DISPATCH_PROPERTYPUT) then + PResult := @Result else + PResult := nil; + if PResult <> nil then + VarClear(PResult^); + if (Flags = DISPATCH_METHOD) {and (ParamCount = 0)} and (PResult <> nil) then + Flags := DISPATCH_METHOD or DISPATCH_PROPERTYGET; + + Status := IDispatch(ParentValue).Invoke(DispId, GUID_NULL, 0, + Flags, Params, PResult, @ExcepInfo, nil); + if Status <> 0 then + begin + if ExcepInfo.bstrSource <> '' then + ExcepMess := #13+#10 + 'Source :: '+ ExcepInfo.bstrSource; + if ExcepInfo.bstrDescription <> '' then + ExcepMess := ExcepMess + #13#10 + 'Description :: '+ ExcepInfo.bstrDescription; + if ExcepInfo.bstrHelpFile <> '' then + ExcepMess := ExcepMess + #13#10 + 'Help File :: '+ ExcepInfo.bstrHelpFile; + raise Exception.Create('OLE error ' + IntToHex(Status, 8) + ': ' + + Name + ': ' + SysErrorMessage(Status) + ExcepMess); + end; +end; + +procedure TfsOLEHelper.SetValue(const Value: Variant); +var + i: Integer; + v: Variant; +begin + v := VarArrayCreate([0, Count], varVariant); + for i := 0 to Count - 1 do + v[i] := Params[i].Value; + v[Count] := Value; + + DispatchInvoke(v, Count + 1, DISPATCH_PROPERTYPUT); +end; + +function TfsOLEHelper.GetValue: Variant; +var + i: Integer; + v: Variant; +begin + v := VarArrayCreate([0, Count - 1], varVariant); + for i := 0 to Count - 1 do + v[i] := Params[i].Value; + + Result := DispatchInvoke(v, Count, DISPATCH_METHOD); +end; + +end. diff --git a/official/4.2/LibD11/fs_ievents.pas b/official/4.2/LibD11/fs_ievents.pas new file mode 100644 index 0000000..777b637 --- /dev/null +++ b/official/4.2/LibD11/fs_ievents.pas @@ -0,0 +1,228 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Standard events } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_ievents; + +interface + +{$i fs.inc} + +uses SysUtils, Classes, fs_iinterpreter +{$IFDEF CLX} +, QControls, QForms +{$ELSE} +, Controls, Forms +{$ENDIF}; + +type + TfsNotifyEvent = class(TfsCustomEvent) + public + procedure DoEvent(Sender: TObject); + function GetMethod: Pointer; override; + end; + + TfsMouseEvent = class(TfsCustomEvent) + public + procedure DoEvent(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); + function GetMethod: Pointer; override; + end; + + TfsMouseMoveEvent = class(TfsCustomEvent) + public + procedure DoEvent(Sender: TObject; Shift: TShiftState; X, Y: Integer); + function GetMethod: Pointer; override; + end; + + TfsKeyEvent = class(TfsCustomEvent) + public + procedure DoEvent(Sender: TObject; var Key: Word; Shift: TShiftState); + function GetMethod: Pointer; override; + end; + + TfsKeyPressEvent = class(TfsCustomEvent) + public + procedure DoEvent(Sender: TObject; var Key: Char); + function GetMethod: Pointer; override; + end; + + TfsCloseEvent = class(TfsCustomEvent) + public + procedure DoEvent(Sender: TObject; var Action: TCloseAction); + function GetMethod: Pointer; override; + end; + + TfsCloseQueryEvent = class(TfsCustomEvent) + public + procedure DoEvent(Sender: TObject; var CanClose: Boolean); + function GetMethod: Pointer; override; + end; + + TfsCanResizeEvent = class(TfsCustomEvent) + public + procedure DoEvent(Sender: TObject; var NewWidth, NewHeight: Integer; + var Resize: Boolean); + function GetMethod: Pointer; override; + end; + + +implementation + + +type + TByteSet = set of 0..7; + PByteSet = ^TByteSet; + + +{ TfsNotifyEvent } + +procedure TfsNotifyEvent.DoEvent(Sender: TObject); +begin + CallHandler([Sender]); +end; + +function TfsNotifyEvent.GetMethod: Pointer; +begin + Result := @TfsNotifyEvent.DoEvent; +end; + +{ TfsMouseEvent } + +procedure TfsMouseEvent.DoEvent(Sender: TObject; Button: TMouseButton; + Shift: TShiftState; X, Y: Integer); +var +{$IFNDEF FPC} + b: Byte; +{$ELSE} + i: integer; +{$ENDIF} +begin +{$IFNDEF FPC} + b := Byte(PByteSet(@Shift)^); + CallHandler([Sender, Integer(Button), b, X, Y]); +{$ELSE} + i := Integer(PByteSet(@Shift)^); + CallHandler([Sender, Integer(Button), i, X, Y]); +{$ENDIF} +end; + +function TfsMouseEvent.GetMethod: Pointer; +begin + Result := @TfsMouseEvent.DoEvent; +end; + +{ TfsMouseMoveEvent } + +procedure TfsMouseMoveEvent.DoEvent(Sender: TObject; Shift: TShiftState; X, + Y: Integer); +var +{$IFNDEF FPC} + b: Byte; +{$ELSE} + i: integer; +{$ENDIF} +begin +{$IFNDEF FPC} + b := Byte(PByteSet(@Shift)^); + CallHandler([Sender, b, X, Y]); +{$ELSE} + i := Integer(PByteSet(@Shift)^); + CallHandler([Sender, i, X, Y]); +{$ENDIF} +end; + +function TfsMouseMoveEvent.GetMethod: Pointer; +begin + Result := @TfsMouseMoveEvent.DoEvent; +end; + +{ TfsKeyEvent } + +procedure TfsKeyEvent.DoEvent(Sender: TObject; var Key: Word; + Shift: TShiftState); +var +{$IFNDEF FPC} + b: Byte; +{$ELSE} + i: integer; +{$ENDIF} +begin +{$IFNDEF FPC} + b := Byte(PByteSet(@Shift)^); + CallHandler([Sender, Key, b]); +{$ELSE} + i := Integer(PByteSet(@Shift)^); + CallHandler([Sender, Key, i]); +{$ENDIF} + Key := Handler.Params[1].Value; +end; + +function TfsKeyEvent.GetMethod: Pointer; +begin + Result := @TfsKeyEvent.DoEvent; +end; + +{ TfsKeyPressEvent } + +procedure TfsKeyPressEvent.DoEvent(Sender: TObject; var Key: Char); +begin + CallHandler([Sender, Key]); + Key := String(Handler.Params[1].Value)[1]; +end; + +function TfsKeyPressEvent.GetMethod: Pointer; +begin + Result := @TfsKeyPressEvent.DoEvent; +end; + +{ TfsCloseEvent } + +procedure TfsCloseEvent.DoEvent(Sender: TObject; var Action: TCloseAction); +begin + CallHandler([Sender, Integer(Action)]); + Action := Handler.Params[1].Value; +end; + +function TfsCloseEvent.GetMethod: Pointer; +begin + Result := @TfsCloseEvent.DoEvent; +end; + +{ TfsCloseQueryEvent } + +procedure TfsCloseQueryEvent.DoEvent(Sender: TObject; var CanClose: Boolean); +begin + CallHandler([Sender, CanClose]); + CanClose := Handler.Params[1].Value; +end; + +function TfsCloseQueryEvent.GetMethod: Pointer; +begin + Result := @TfsCloseQueryEvent.DoEvent; +end; + +{ TfsCanResizeEvent } + +procedure TfsCanResizeEvent.DoEvent(Sender: TObject; var NewWidth, + NewHeight: Integer; var Resize: Boolean); +begin + CallHandler([Sender, NewWidth, NewHeight, Resize]); + NewWidth := Handler.Params[1].Value; + NewHeight := Handler.Params[2].Value; + Resize := Handler.Params[3].Value; +end; + +function TfsCanResizeEvent.GetMethod: Pointer; +begin + Result := @TfsCanResizeEvent.DoEvent; +end; + +end. diff --git a/official/4.2/LibD11/fs_iexpression.pas b/official/4.2/LibD11/fs_iexpression.pas new file mode 100644 index 0000000..e83b6b7 --- /dev/null +++ b/official/4.2/LibD11/fs_iexpression.pas @@ -0,0 +1,878 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Expression parser } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iexpression; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + { List of operators } + + TfsOperatorType = (opNone, opGreat, opLess, opLessEq, opGreatEq, opNonEq, opEq, + opPlus, opMinus, opOr, opXor, opMul, opDivFloat, opDivInt, opMod, opAnd, + opShl, opShr, opLeftBracket, opRightBracket, opNot, opUnMinus, opIn, opIs); + +{ TfsExpression class holds a list of operands and operators. + List is represented in the tree form. + Call to methods AddXXX puts an expression element to the list. + Call to function Value calculates and returns the expression value } + + TfsExpressionNode = class(TfsCustomVariable) + private + FLeft, FRight, FParent: TfsExpressionNode; + procedure AddNode(Node: TfsExpressionNode); + procedure RemoveNode(Node: TfsExpressionNode); + public + destructor Destroy; override; + function Priority: Integer; virtual; abstract; + end; + + TfsOperandNode = class(TfsExpressionNode) + public + constructor Create(const AValue: Variant); + function Priority: Integer; override; + end; + + TfsOperatorNode = class(TfsExpressionNode) + private + FOp: TfsOperatorType; + FOptimizeInt: Boolean; + FOptimizeBool: Boolean; + public + constructor Create(Op: TfsOperatorType); + function Priority: Integer; override; + end; + + TfsDesignatorNode = class(TfsOperandNode) + private + FDesignator: TfsDesignator; + FVar: TfsCustomVariable; + protected + function GetValue: Variant; override; + public + constructor Create(ADesignator: TfsDesignator); + destructor Destroy; override; + end; + + TfsSetNode = class(TfsOperandNode) + private + FSetExpression: TfsSetExpression; + protected + function GetValue: Variant; override; + public + constructor Create(ASet: TfsSetExpression); + destructor Destroy; override; + end; + + TfsExpression = class(TfsCustomExpression) + private + FCurNode: TfsExpressionNode; + FNode: TfsExpressionNode; + FScript: TfsScript; + FSource: String; + procedure AddOperand(Node: TfsExpressionNode); + protected + function GetValue: Variant; override; + procedure SetValue(const Value: Variant); override; + public + constructor Create(Script: TfsScript); + destructor Destroy; override; + procedure AddConst(const AValue: Variant); + procedure AddDesignator(ADesignator: TfsDesignator); + procedure AddOperator(const Op: String); + procedure AddSet(ASet: TfsSetExpression); + + function Finalize: String; + function Optimize(Designator: TfsDesignator): String; + function SingleItem: TfsCustomVariable; + + property Source: String read FSource write FSource; + end; + + +implementation + +uses fs_itools; + +type + TNoneNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TGreatNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TLessNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TLessEqNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TGreatEqNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TNonEqNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TEqNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TPlusNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TStrCatNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TMinusNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TOrNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TXorNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TMulNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TDivFloatNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TDivIntNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TModNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TAndNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TShlNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TShrNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TLeftBracketNode = class(TfsOperatorNode); + + TRightBracketNode = class(TfsOperatorNode); + + TNotNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TUnMinusNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TInNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + TIsNode = class(TfsOperatorNode) + protected + function GetValue: Variant; override; + end; + + +function TNoneNode.GetValue: Variant; +begin + Result := FLeft.Value; +end; + +function TGreatNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result > FRight.Value; +end; + +function TLessNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result < FRight.Value; +end; + +function TLessEqNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result <= FRight.Value; +end; + +function TGreatEqNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result >= FRight.Value; +end; + +function TNonEqNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result <> FRight.Value; +end; + +function TEqNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result = FRight.Value; +end; + +function TPlusNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result + FRight.Value; +end; + +function TStrCatNode.GetValue: Variant; +begin + Result := FLeft.Value; + if TVarData(Result).VType = varString then + Result := VarToStr(Result) + VarToStr(FRight.Value) else + Result := Result + FRight.Value; +end; + +function TMinusNode.GetValue: Variant; +begin + Result := FLeft.Value; + if FOptimizeInt then + Result := Integer(Result) - Integer(FRight.Value) + else + Result := Result - FRight.Value; +end; + +function TOrNode.GetValue: Variant; +begin + Result := FLeft.Value; + + if FOptimizeBool then + begin + if Boolean(Result) = False then + Result := FRight.Value; + end + else + Result := Result or FRight.Value; +end; + +function TXorNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result xor FRight.Value; +end; + +function TMulNode.GetValue: Variant; +begin + Result := FLeft.Value; + if FOptimizeInt then + Result := Integer(Result) * Integer(FRight.Value) + else + Result := Result * FRight.Value; +end; + +function TDivFloatNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result / FRight.Value; +end; + +function TDivIntNode.GetValue: Variant; +begin + Result := FLeft.Value; + if FOptimizeInt then + Result := Integer(Result) div Integer(FRight.Value) + else + Result := Result div FRight.Value; +end; + +function TModNode.GetValue: Variant; +begin + Result := FLeft.Value; + if FOptimizeInt then + Result := Integer(Result) mod Integer(FRight.Value) + else + Result := Result mod FRight.Value; +end; + +function TAndNode.GetValue: Variant; +begin + Result := FLeft.Value; + if FOptimizeBool then + begin + if Boolean(Result) = True then + Result := FRight.Value; + end + else + Result := Result and FRight.Value; +end; + +function TShlNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result shl FRight.Value; +end; + +function TShrNode.GetValue: Variant; +begin + Result := FLeft.Value; + Result := Result shr FRight.Value; +end; + +function TNotNode.GetValue: Variant; +begin + Result := not FLeft.Value; +end; + +function TUnMinusNode.GetValue: Variant; +begin + Result := -FLeft.Value; +end; + +function TInNode.GetValue: Variant; +var + i: Integer; + ar, val, selfVal: Variant; + Count: Integer; +begin + if FRight is TfsSetNode then + Result := TfsSetNode(FRight).FSetExpression.Check(FLeft.Value) + else + begin + Result := False; + ar := FRight.Value; + Count := VarArrayHighBound(ar, 1); + selfVal := FLeft.Value; + + i := 0; + while i < Count do + begin + val := ar[i]; + + if (i < Count - 1) and (ar[i + 1] = Null) then { subrange } + begin + Result := (selfVal >= val) and (selfVal <= ar[i + 2]); + Inc(i, 2); + end + else + Result := selfVal = val; + + if Result then break; + Inc(i); + end; + end; +end; + +function TIsNode.GetValue: Variant; +begin + Result := TObject(Integer(FLeft.Value)) is + TfsClassVariable(TfsDesignatorNode(FRight).FDesignator[0].Ref).ClassRef; +end; + + +{ TfsExpressionNode } + +destructor TfsExpressionNode.Destroy; +begin + FLeft.Free; + FRight.Free; + inherited; +end; + +procedure TfsExpressionNode.AddNode(Node: TfsExpressionNode); +begin + if FLeft = nil then + FLeft := Node + else if FRight = nil then + FRight := Node; + if Node <> nil then + Node.FParent := Self; +end; + +procedure TfsExpressionNode.RemoveNode(Node: TfsExpressionNode); +begin + if FLeft = Node then + FLeft := nil + else if FRight = Node then + FRight := nil; +end; + + +{ TfsOperandNode } + +constructor TfsOperandNode.Create(const AValue: Variant); +var + t: TfsVarType; +begin + inherited Create('', fvtInt, ''); + Value := AValue; + + t := fvtInt; + if TVarData(AValue).VType = varBoolean then + t := fvtBool + else if TVarData(AValue).VType in [varSingle, varDouble, varCurrency] then + t := fvtFloat + else if (TVarData(AValue).VType = varOleStr) or + (TVarData(AValue).VType = varString) then + t := fvtString; + + Typ := t; +end; + +function TfsOperandNode.Priority: Integer; +begin + Result := 0; +end; + + +{ TfsOperatorNode } + +constructor TfsOperatorNode.Create(Op: TfsOperatorType); +begin + inherited Create('', fvtInt, ''); + FOp := Op; +end; + +function TfsOperatorNode.Priority: Integer; +begin + case FOp of + opNone: + Result := 7; + opLeftBracket: + Result := 6; + opRightBracket: + Result := 5; + opGreat, opLess, opGreatEq, opLessEq, opNonEq, opEq, opIn, opIs: + Result := 4; + opPlus, opMinus, opOr, opXor: + Result := 3; + opMul, opDivFloat, opDivInt, opMod, opAnd, opShr, opShl: + Result := 2; + opNot, opUnMinus: + Result := 1; + else + Result := 0; + end; +end; + + +{ TfsDesignatorNode } + +constructor TfsDesignatorNode.Create(ADesignator: TfsDesignator); +begin + inherited Create(0); + FDesignator := ADesignator; + Typ := ADesignator.Typ; + TypeName := ADesignator.TypeName; + if FDesignator is TfsVariableDesignator then + FVar := FDesignator.RefItem else + FVar := FDesignator; +end; + +destructor TfsDesignatorNode.Destroy; +begin + FDesignator.Free; + inherited; +end; + +function TfsDesignatorNode.GetValue: Variant; +begin + Result := FVar.Value; +end; + + +{ TfsSetNode } + +constructor TfsSetNode.Create(ASet: TfsSetExpression); +begin + inherited Create(0); + FSetExpression := ASet; + Typ := fvtVariant; +end; + +destructor TfsSetNode.Destroy; +begin + FSetExpression.Free; + inherited; +end; + +function TfsSetNode.GetValue: Variant; +begin + Result := FSetExpression.Value; +end; + + +{ TfsExpression } + +constructor TfsExpression.Create(Script: TfsScript); +begin + inherited Create('', fvtInt, ''); + FNode := TNoneNode.Create(opNone); + FCurNode := FNode; + FScript := Script; +end; + +destructor TfsExpression.Destroy; +begin + FNode.Free; + inherited; +end; + +function TfsExpression.GetValue: Variant; +begin + Result := FNode.Value; +end; + +procedure TfsExpression.AddOperand(Node: TfsExpressionNode); +begin + FCurNode.AddNode(Node); + FCurNode := Node; +end; + +procedure TfsExpression.AddOperator(const Op: String); +var + Node: TfsExpressionNode; + n, n1: TfsExpressionNode; + + function CreateOperatorNode(s: String): TfsOperatorNode; + begin + s := AnsiUpperCase(s); + if s = ' ' then + Result := TNoneNode.Create(opNone) + else if s = '>' then + Result := TGreatNode.Create(opGreat) + else if s = '<' then + Result := TLessNode.Create(opLess) + else if s = '<=' then + Result := TLessEqNode.Create(opLessEq) + else if s = '>=' then + Result := TGreatEqNode.Create(opGreatEq) + else if s = '<>' then + Result := TNonEqNode.Create(opNonEq) + else if s = '=' then + Result := TEqNode.Create(opEq) + else if s = '+' then + Result := TPlusNode.Create(opPlus) + else if s = 'STRCAT' then + Result := TStrCatNode.Create(opPlus) + else if s = '-' then + Result := TMinusNode.Create(opMinus) + else if s = 'OR' then + Result := TOrNode.Create(opOr) + else if s = 'XOR' then + Result := TXorNode.Create(opXor) + else if s = '*' then + Result := TMulNode.Create(opMul) + else if s = '/' then + Result := TDivFloatNode.Create(opDivFloat) + else if s = 'DIV' then + Result := TDivIntNode.Create(opDivInt) + else if s = 'MOD' then + Result := TModNode.Create(opMod) + else if s = 'AND' then + Result := TAndNode.Create(opAnd) + else if s = 'SHL' then + Result := TShlNode.Create(opShl) + else if s = 'SHR' then + Result := TShrNode.Create(opShr) + else if s = '(' then + Result := TLeftBracketNode.Create(opLeftBracket) + else if s = ')' then + Result := TRightBracketNode.Create(opRightBracket) + else if s = 'NOT' then + Result := TNotNode.Create(opNot) + else if s = 'UNMINUS' then + Result := TUnMinusNode.Create(opUnMinus) + else if s = 'IN' then + Result := TInNode.Create(opIn) + else if s = 'IS' then + Result := TIsNode.Create(opIs) + else + Result := nil; + end; + +begin + Node := CreateOperatorNode(Op); + Node.SourcePos := SourcePos; + + if (Op = '(') or (Op = 'unminus') or (Op = 'not') then + AddOperand(Node) + else if Op = ')' then + begin + n := FCurNode; + while n.Priority <= Node.Priority do + n := n.FParent; + + n.FParent.RemoveNode(n); + n.FParent.AddNode(n.FLeft); + + Node.Free; + Node := n.FLeft; + n.FLeft := nil; + n.Free; + end + else if FCurNode = FNode then + FNode.AddNode(Node) + else + begin + n := FCurNode; + n1 := nil; + if FCurNode.Priority <> 6 then + begin + n := FCurNode.FParent; + n1 := FCurNode; + end; + + while n.Priority <= Node.Priority do + begin + n1 := n; + n := n.FParent; + end; + + n.RemoveNode(n1); + n.AddNode(Node); + Node.AddNode(n1); + end; + + FCurNode := Node; +end; + +procedure TfsExpression.AddConst(const AValue: Variant); +var + Node: TfsOperandNode; +begin + Node := TfsOperandNode.Create(AValue); + Node.SourcePos := SourcePos; + AddOperand(Node); +end; + +procedure TfsExpression.AddDesignator(ADesignator: TfsDesignator); +var + Node: TfsDesignatorNode; +begin + Node := TfsDesignatorNode.Create(ADesignator); + Node.SourcePos := SourcePos; + AddOperand(Node); +end; + +procedure TfsExpression.AddSet(ASet: TfsSetExpression); +var + Node: TfsSetNode; +begin + Node := TfsSetNode.Create(ASet); + Node.SourcePos := SourcePos; + AddOperand(Node); +end; + +function TfsExpression.Finalize: String; +var + ErrorPos: String; + TypeRec: TfsTypeRec; + + function GetType(Item: TfsExpressionNode): TfsTypeRec; + var + Typ1, Typ2: TfsTypeRec; + op: TfsOperatorType; + Error: Boolean; + begin + if Item = nil then + Result.Typ := fvtVariant + else if Item is TfsOperandNode then + begin + Result.Typ := Item.Typ; + Result.TypeName := Item.TypeName; + end + else + begin + Typ1 := GetType(Item.FLeft); + Typ2 := GetType(Item.FRight); +// if (Typ1.Typ = fvtInt) and (Typ2.Typ = fvtInt) then +// TfsOperatorNode(Item).FOptimizeInt := True; + if (Typ1.Typ = fvtBool) and (Typ2.Typ = fvtBool) then + TfsOperatorNode(Item).FOptimizeBool := True; + + op := TfsOperatorNode(Item).FOp; + + if (op = opIs) and (Typ1.Typ = fvtClass) and (Typ2.Typ = fvtClass) then + Error := False + else + begin + { check types compatibility } + Error := not TypesCompatible(Typ1, Typ2, FScript); + { check operators applicability } + if not Error then + case Typ1.Typ of + fvtBool: + Error := not (op in [opNonEq, opEq, opOr, opXor, opAnd, opNot]); + fvtChar, fvtString: + Error := not (op in [opGreat, opLess, opLessEq, opGreatEq, opNonEq, opEq, opPlus, opIn]); + fvtClass, fvtArray: + Error := not (op in [opNonEq, opEq]); + end; + end; + + if not Error then + begin + Result := Typ1; + { if one type is Float, resulting type is float too } + if [Typ1.Typ] + [Typ2.Typ] = [fvtInt, fvtFloat] then + Result.Typ := fvtFloat; + { case int / int = float } + if (Typ1.Typ = fvtInt) and (Typ2.Typ = fvtInt) and (op = opDivFloat) then + Result.Typ := fvtFloat; + { result of comparing two types is always boolean } + if op in [opGreat, opLess, opLessEq, opGreatEq, opNonEq, opEq, opIn, opIs] then + Result.Typ := fvtBool; + end + else if ErrorPos = '' then + ErrorPos := Item.SourcePos; + + Item.Typ := Result.Typ; + end; + end; + +begin + { remove the empty root node } + FCurNode := FNode.FLeft; + FNode.RemoveNode(FCurNode); + FNode.Free; + FNode := FCurNode; + + { check and get the expression type } + ErrorPos := ''; + TypeRec := GetType(FNode); + Typ := TypeRec.Typ; + TypeName := TypeRec.TypeName; + Result := ErrorPos; + + { expression is assignable if it has only one node of type "Variable" } + if not ((FNode is TfsDesignatorNode) and not + (TfsDesignatorNode(FNode).FDesignator.IsReadOnly)) then + IsReadOnly := True; +end; + +procedure TfsExpression.SetValue(const Value: Variant); +begin + if not IsReadOnly then + TfsDesignatorNode(FNode).FDesignator.Value := Value; +end; + +function TfsExpression.Optimize(Designator: TfsDesignator): String; +var + Op: TfsOperatorType; +begin + Result := ' '; + + if not (Designator is TfsVariableDesignator) or + not (FNode is TfsOperatorNode) then Exit; + + Op := TfsOperatorNode(FNode).FOp; + if not (Op in [opPlus, opMinus, opDivFloat, opMul]) then Exit; + + { optimize a := a op b statement } + if (FNode.FLeft is TfsDesignatorNode) and + (TfsDesignatorNode(FNode.FLeft).FDesignator is TfsVariableDesignator) and + (TfsDesignatorNode(FNode.FLeft).FDesignator.RefItem = Designator.RefItem) then + begin + FCurNode := FNode.FRight; + FNode.RemoveNode(FCurNode); + FNode.Free; + FNode := FCurNode; + + if Op = opPlus then + Result := '+' + else if Op = opMinus then + Result := '-' + else if Op = opDivFloat then + Result := '/' + else if Op = opMul then + Result := '*'; + end + { optimize a := b op a statement } + else if (FNode.FRight is TfsDesignatorNode) and + (TfsDesignatorNode(FNode.FRight).FDesignator is TfsVariableDesignator) and + (TfsDesignatorNode(FNode.FRight).FDesignator.RefItem = Designator.RefItem) and + (Op in [opPlus, opMul]) and + not (Designator.RefItem.Typ in [fvtString, fvtVariant]) then + begin + FCurNode := FNode.FLeft; + FNode.RemoveNode(FCurNode); + FNode.Free; + FNode := FCurNode; + + if Op = opPlus then + Result := '+' + else if Op = opMul then + Result := '*'; + end; +end; + +function TfsExpression.SingleItem: TfsCustomVariable; +begin + { if expression contains only one item, returns reference to it } + Result := nil; + + if FNode is TfsDesignatorNode then + begin + if TfsDesignatorNode(FNode).FDesignator is TfsVariableDesignator then + Result := TfsDesignatorNode(FNode).FDesignator.RefItem else + Result := TfsDesignatorNode(FNode).FDesignator; + end + else if FNode is TfsOperandNode then + Result := FNode; +end; + +end. diff --git a/official/4.2/LibD11/fs_iextctrlsrtti.pas b/official/4.2/LibD11/fs_iextctrlsrtti.pas new file mode 100644 index 0000000..a256d01 --- /dev/null +++ b/official/4.2/LibD11/fs_iextctrlsrtti.pas @@ -0,0 +1,425 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ ExtCtrls } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iextctrlsrtti; + +interface + +{$i fs.inc} + +uses SysUtils, Classes, fs_iinterpreter, fs_ievents, fs_iformsrtti +{$IFDEF CLX} +, QExtCtrls, QButtons, QCheckLst, QComCtrls +{$ELSE} +, ExtCtrls, Buttons, CheckLst, ComCtrls +{$ENDIF}; + +type + TfsExtCtrlsRTTI = class(TComponent); // fake component + + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddEnum('TShapeType', 'stRectangle, stSquare, stRoundRect, stRoundSquare,' + + 'stEllipse, stCircle'); + AddEnum('TBevelStyle', 'bsLowered, bsRaised'); + AddEnum('TBevelShape', 'bsBox, bsFrame, bsTopLine, bsBottomLine, bsLeftLine,' + + 'bsRightLine, bsSpacer'); + AddEnum('TResizeStyle', 'rsNone, rsLine, rsUpdate, rsPattern'); + AddEnum('TButtonLayout', 'blGlyphLeft, blGlyphRight, blGlyphTop, blGlyphBottom'); + AddEnum('TButtonState', 'bsUp, bsDisabled, bsDown, bsExclusive'); + AddEnum('TButtonStyle', 'bsAutoDetect, bsWin31, bsNew'); + AddEnum('TBitBtnKind', 'bkCustom, bkOK, bkCancel, bkHelp, bkYes, bkNo,' + + 'bkClose, bkAbort, bkRetry, bkIgnore, bkAll'); + AddType('TNumGlyphs', fvtInt); + AddEnum('TTabPosition', 'tpTop, tpBottom, tpLeft, tpRight'); + AddEnum('TTabStyle', 'tsTabs, tsButtons, tsFlatButtons'); + AddEnum('TStatusPanelStyle', 'psText, psOwnerDraw'); + AddEnum('TStatusPanelBevel', 'pbNone, pbLowered, pbRaised'); + AddEnum('TSortType', 'stNone, stData, stText, stBoth'); + AddEnum('TTrackBarOrientation', 'trHorizontal, trVertical'); + AddEnum('TTickMark', 'tmBottomRight, tmTopLeft, tmBoth'); + AddEnum('TTickStyle', 'tsNone, tsAuto, tsManual'); + AddEnum('TProgressBarOrientation', 'pbHorizontal, pbVertical'); + AddEnum('TIconArrangement', 'iaTop, iaLeft'); + AddEnum('TListArrangement', 'arAlignBottom, arAlignLeft, arAlignRight,' + + 'arAlignTop, arDefault, arSnapToGrid'); + AddEnum('TViewStyle', 'vsIcon, vsSmallIcon, vsList, vsReport'); + AddEnum('TToolButtonStyle', 'tbsButton, tbsCheck, tbsDropDown, tbsSeparator, tbsDivider'); + AddEnum('TDateTimeKind', 'dtkDate, dtkTime'); + AddEnum('TDTDateMode', 'dmComboBox, dmUpDown'); + AddEnum('TDTDateFormat', 'dfShort, dfLong'); + AddEnum('TDTCalAlignment', 'dtaLeft, dtaRight'); + AddEnum('TCalDayOfWeek', 'dowMonday, dowTuesday, dowWednesday, dowThursday,' + + 'dowFriday, dowSaturday, dowSunday, dowLocaleDefault'); + + AddClass(TShape, 'TGraphicControl'); + with AddClass(TPaintBox, 'TGraphicControl') do + AddEvent('OnPaint', TfsNotifyEvent); + AddClass(TImage, 'TGraphicControl'); + AddClass(TBevel, 'TGraphicControl'); + with AddClass(TTimer, 'TComponent') do + AddEvent('OnTimer', TfsNotifyEvent); + AddClass(TPanel, 'TCustomControl'); + AddClass(TSplitter, 'TGraphicControl'); + AddClass(TBitBtn, 'TButton'); + AddClass(TSpeedButton, 'TGraphicControl'); + with AddClass(TCheckListBox, 'TCustomListBox') do + AddIndexProperty('Checked', 'Integer', 'Boolean', CallMethod); + AddClass(TTabControl, 'TWinControl'); + with AddClass(TTabSheet, 'TWinControl') do + AddProperty('PageControl', 'TPageControl', GetProp, SetProp); + with AddClass(TPageControl, 'TWinControl') do + begin + AddMethod('procedure SelectNextPage(GoForward: Boolean)', CallMethod); + AddProperty('PageCount', 'Integer', GetProp, nil); + AddIndexProperty('Pages', 'Integer', 'TTabSheet', CallMethod, True); + end; + AddClass(TStatusPanel, 'TPersistent'); + with AddClass(TStatusPanels, 'TPersistent') do + begin + AddMethod('function Add: TStatusPanel', CallMethod); + AddIndexProperty('Items', 'Integer', 'TStatusPanel', CallMethod, True); + end; + AddClass(TStatusBar, 'TWinControl'); + with AddClass(TTreeNode, 'TPersistent') do + begin + AddMethod('procedure Delete', CallMethod); + AddMethod('function EditText: Boolean', CallMethod); + AddProperty('Count', 'Integer', GetProp, nil); + AddProperty('Data', 'Pointer', GetProp, SetProp); + AddProperty('ImageIndex', 'Integer', GetProp, SetProp); + AddProperty('SelectedIndex', 'Integer', GetProp, SetProp); + AddProperty('StateIndex', 'Integer', GetProp, SetProp); + AddProperty('Text', 'String', GetProp, SetProp); + end; + with AddClass(TTreeNodes, 'TPersistent') do + begin + AddMethod('function Add(Node: TTreeNode; const S: string): TTreeNode', CallMethod); + AddMethod('function AddChild(Node: TTreeNode; const S: string): TTreeNode', CallMethod); + AddMethod('procedure BeginUpdate', CallMethod); + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure Delete(Node: TTreeNode)', CallMethod); + AddMethod('procedure EndUpdate', CallMethod); + AddProperty('Count', 'Integer', GetProp, nil); + AddDefaultProperty('Item', 'Integer', 'TTreeNode', CallMethod, True); + end; + with AddClass(TTreeView, 'TWinControl') do + begin + AddMethod('procedure FullCollapse', CallMethod); + AddMethod('procedure FullExpand', CallMethod); + AddProperty('Items', 'TTreeNodes', GetProp, nil); + AddProperty('Selected', 'TTreeNode', GetProp, SetProp); + AddProperty('TopItem', 'TTreeNode', GetProp, SetProp); + end; + AddClass(TTrackBar, 'TWinControl'); + AddClass(TProgressBar, 'TWinControl'); + AddClass(TListColumn, 'TPersistent'); + with AddClass(TListColumns, 'TPersistent') do + begin + AddMethod('function Add: TListColumn', CallMethod); + AddDefaultProperty('Items', 'Integer', 'TListColumn', CallMethod, True); + end; + with AddClass(TListItem, 'TPersistent') do + begin + AddMethod('procedure Delete', CallMethod); + AddMethod('function EditCaption: Boolean', CallMethod); + AddProperty('Caption', 'String', GetProp, SetProp); + AddProperty('Checked', 'Boolean', GetProp, SetProp); + AddProperty('Data', 'Pointer', GetProp, SetProp); + AddProperty('ImageIndex', 'Integer', GetProp, SetProp); + AddProperty('Selected', 'Boolean', GetProp, SetProp); + AddProperty('StateIndex', 'Integer', GetProp, SetProp); + AddProperty('SubItems', 'TStrings', GetProp, SetProp); + end; + with AddClass(TListItems, 'TPersistent') do + begin + AddMethod('function Add: TListItem', CallMethod); + AddMethod('procedure BeginUpdate', CallMethod); + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure Delete(Index: Integer)', CallMethod); + AddMethod('procedure EndUpdate', CallMethod); + AddProperty('Count', 'Integer', GetProp, nil); + AddDefaultProperty('Item', 'Integer', 'TListItem', CallMethod, True); + end; +{$IFNDEF FPC} + AddClass(TIconOptions, 'TPersistent'); +{$ENDIF} + AddClass(TListView, 'TWinControl'); + AddClass(TToolButton, 'TGraphicControl'); + AddClass(TToolBar, 'TWinControl'); +{$IFNDEF CLX} + {$IFNDEF FPC} + AddClass(TMonthCalColors, 'TPersistent'); + AddClass(TDateTimePicker, 'TWinControl'); + AddClass(TMonthCalendar, 'TWinControl'); + AddClass(TCustomRichEdit, 'TWinControl'); + AddClass(TRichEdit, 'TCustomRichEdit'); + {$ENDIF} +{$ENDIF} + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TCheckListBox then + begin + if MethodName = 'CHECKED.GET' then + Result := TCheckListBox(Instance).Checked[Caller.Params[0]] + else if MethodName = 'CHECKED.SET' then + TCheckListBox(Instance).Checked[Caller.Params[0]] := Caller.Params[1] + end + else if ClassType = TPageControl then + begin + if MethodName = 'SELECTNEXTPAGE' then + TPageControl(Instance).SelectNextPage(Caller.Params[0]) + else if MethodName = 'PAGES.GET' then + Result := Integer(TPageControl(Instance).Pages[Caller.Params[0]]) + end + else if ClassType = TStatusPanels then + begin + if MethodName = 'ADD' then + Result := Integer(TStatusPanels(Instance).Add) + else if MethodName = 'ITEMS.GET' then + Result := Integer(TStatusPanels(Instance).Items[Caller.Params[0]]) + end + else if ClassType = TTreeNode then + begin + if MethodName = 'DELETE' then + TTreeNode(Instance).Delete + else if MethodName = 'EDITTEXT' then + Result := TTreeNode(Instance).EditText + end + else if ClassType = TTreeNodes then + begin + if MethodName = 'ADD' then + Result := Integer(TTreeNodes(Instance).Add(TTreeNode(Integer(Caller.Params[0])), + Caller.Params[1])) + else if MethodName = 'ADDCHILD' then + Result := Integer(TTreeNodes(Instance).AddChild(TTreeNode(Integer(Caller.Params[0])), + Caller.Params[1])) + else if MethodName = 'BEGINUPDATE' then + TTreeNodes(Instance).BeginUpdate + else if MethodName = 'CLEAR' then + TTreeNodes(Instance).Clear + else if MethodName = 'DELETE' then + TTreeNodes(Instance).Delete(TTreeNode(Integer(Caller.Params[0]))) + else if MethodName = 'ENDUPDATE' then + TTreeNodes(Instance).EndUpdate + else if MethodName = 'ITEM.GET' then + Result := Integer(TTreeNodes(Instance).Item[Caller.Params[0]]) + end + else if ClassType = TTreeView then + begin + if MethodName = 'FULLCOLLAPSE' then + TTreeView(Instance).FullCollapse + else if MethodName = 'FULLEXPAND' then + TTreeView(Instance).FullExpand + end + else if ClassType = TListColumns then + begin + if MethodName = 'ADD' then + Result := Integer(TListColumns(Instance).Add) + else if MethodName = 'ITEMS.GET' then + Result := Integer(TListColumns(Instance).Items[Caller.Params[0]]) + end + else if ClassType = TListItem then + begin + if MethodName = 'DELETE' then + TListItem(Instance).Delete +{$IFNDEF CLX} + {$IFNDEF FPC} + else if MethodName = 'EDITCAPTION' then + Result := TListItem(Instance).EditCaption + {$ENDIF} +{$ENDIF} + end + else if ClassType = TListItems then + begin + if MethodName = 'ADD' then + Result := Integer(TListItems(Instance).Add) +{$IFNDEF FPC} + else if MethodName = 'BEGINUPDATE' then + TListItems(Instance).BeginUpdate +{$ENDIF} + else if MethodName = 'CLEAR' then + TListItems(Instance).Clear + else if MethodName = 'DELETE' then + TListItems(Instance).Delete(Caller.Params[0]) +{$IFNDEF FPC} + else if MethodName = 'ENDUPDATE' then + TListItems(Instance).EndUpdate +{$ENDIF} + else if MethodName = 'ITEM.GET' then + Result := Integer(TListItems(Instance).Item[Caller.Params[0]]) + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TPageControl then + begin + if PropName = 'PAGECOUNT' then + Result := TPageControl(Instance).PageCount + end + else if ClassType = TTabSheet then + begin + if PropName = 'PAGECONTROL' then + Result := Integer(TTabSheet(Instance).PageControl) + end + else if ClassType = TTreeNode then + begin + if PropName = 'COUNT' then + Result := TTreeNode(Instance).Count + else if PropName = 'DATA' then + Result := Integer(TTreeNode(Instance).Data) + else if PropName = 'IMAGEINDEX' then + Result := TTreeNode(Instance).ImageIndex + else if PropName = 'SELECTEDINDEX' then + Result := TTreeNode(Instance).SelectedIndex +{$IFNDEF CLX} + else if PropName = 'STATEINDEX' then + Result := TTreeNode(Instance).StateIndex +{$ENDIF} + else if PropName = 'TEXT' then + Result := TTreeNode(Instance).Text + end + else if ClassType = TTreeNodes then + begin + if PropName = 'COUNT' then + Result := TTreeNodes(Instance).Count + end + else if ClassType = TTreeView then + begin + if PropName = 'ITEMS' then + Result := Integer(TTreeView(Instance).Items) + else if PropName = 'SELECTED' then + Result := Integer(TTreeView(Instance).Selected) + else if PropName = 'TOPITEM' then + Result := Integer(TTreeView(Instance).TopItem) + end + else if ClassType = TListItem then + begin + if PropName = 'CAPTION' then + Result := TListItem(Instance).Caption + else if PropName = 'CHECKED' then + Result := TListItem(Instance).Checked + else if PropName = 'DATA' then + Result := Integer(TListItem(Instance).Data) + else if PropName = 'IMAGEINDEX' then + Result := TListItem(Instance).ImageIndex + else if PropName = 'SELECTED' then + Result := TListItem(Instance).Selected +{$IFNDEF CLX} + {$IFNDEF FPC} + else if PropName = 'STATEINDEX' then + Result := TListItem(Instance).StateIndex + {$ENDIF} +{$ENDIF} + else if PropName = 'SUBITEMS' then + Result := Integer(TListItem(Instance).SubItems) + end + else if ClassType = TListItems then + begin + if PropName = 'COUNT' then + Result := TListItems(Instance).Count + end +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin + if ClassType = TTabSheet then + begin + if PropName = 'PAGECONTROL' then + TTabSheet(Instance).PageControl := TPageControl(Integer(Value)) + end + else if ClassType = TTreeNode then + begin + if PropName = 'DATA' then + TTreeNode(Instance).Data := Pointer(Integer(Value)) + else if PropName = 'IMAGEINDEX' then + TTreeNode(Instance).ImageIndex := Value + else if PropName = 'SELECTEDINDEX' then + TTreeNode(Instance).SelectedIndex := Value +{$IFNDEF CLX} + else if PropName = 'STATEINDEX' then + TTreeNode(Instance).StateIndex := Value +{$ENDIF} + else if PropName = 'TEXT' then + TTreeNode(Instance).Text := Value + end + else if ClassType = TTreeView then + begin + if PropName = 'SELECTED' then + TTreeView(Instance).Selected := TTreeNode(Integer(Value)) + else if PropName = 'TOPITEM' then + TTreeView(Instance).TopItem := TTreeNode(Integer(Value)) + end + else if ClassType = TListItem then + begin + if PropName = 'CAPTION' then + TListItem(Instance).Caption := Value + else if PropName = 'CHECKED' then + TListItem(Instance).Checked := Value + else if PropName = 'DATA' then + TListItem(Instance).Data := Pointer(Integer(Value)) + else if PropName = 'IMAGEINDEX' then + TListItem(Instance).ImageIndex := Value + else if PropName = 'SELECTED' then + TListItem(Instance).Selected := Value +{$IFNDEF CLX} + {$IFNDEF FPC} + else if PropName = 'STATEINDEX' then + TListItem(Instance).StateIndex := Value + {$ENDIF} +{$ENDIF} + else if PropName = 'SUBITEMS' then + TListItem(Instance).SubItems := TStrings(Integer(Value)) + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_iformsrtti.pas b/official/4.2/LibD11/fs_iformsrtti.pas new file mode 100644 index 0000000..5058a94 --- /dev/null +++ b/official/4.2/LibD11/fs_iformsrtti.pas @@ -0,0 +1,428 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Forms and StdCtrls } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iformsrtti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_ievents, fs_iclassesrtti, + fs_igraphicsrtti +{$IFDEF CLX} + , QControls, QForms, QStdCtrls +{$ELSE} + {$IFNDEF FPC} + , Windows + {$ELSE} + , LCLType, Buttons + {$ENDIF} + , Controls, Forms, StdCtrls +{$ENDIF}; + +type + TfsFormsRTTI = class(TComponent); // fake component + + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddConst('mrNone', 'Integer', mrNone); + AddConst('mrOk', 'Integer', mrOk); + AddConst('mrCancel', 'Integer', mrCancel); + AddConst('mrAbort', 'Integer', mrAbort); + AddConst('mrRetry', 'Integer', mrRetry); + AddConst('mrIgnore', 'Integer', mrIgnore); + AddConst('mrYes', 'Integer', mrYes); + AddConst('mrNo', 'Integer', mrNo); + AddConst('mrAll', 'Integer', mrAll); + AddConst('mrNoToAll', 'Integer', mrNoToAll); + AddConst('mrYesToAll', 'Integer', mrYesToAll); + + AddConst('crDefault', 'Integer', crDefault); + AddConst('crNone', 'Integer', crNone); + AddConst('crArrow', 'Integer', crArrow); + AddConst('crCross', 'Integer', crCross); + AddConst('crIBeam', 'Integer', crIBeam); + AddConst('crSize', 'Integer', crSize); + AddConst('crSizeNESW', 'Integer', crSizeNESW); + AddConst('crSizeNS', 'Integer', crSizeNS); + AddConst('crSizeNWSE', 'Integer', crSizeNWSE); + AddConst('crSizeWE', 'Integer', crSizeWE); + AddConst('crUpArrow', 'Integer', crUpArrow); + AddConst('crHourGlass', 'Integer', crHourGlass); + AddConst('crDrag', 'Integer', crDrag); + AddConst('crNoDrop', 'Integer', crNoDrop); + AddConst('crHSplit', 'Integer', crHSplit); + AddConst('crVSplit', 'Integer', crVSplit); + AddConst('crMultiDrag', 'Integer', crMultiDrag); + AddConst('crSQLWait', 'Integer', crSQLWait); + AddConst('crNo', 'Integer', crNo); + AddConst('crAppStart', 'Integer', crAppStart); + AddConst('crHelp', 'Integer', crHelp); + AddConst('crHandPoint', 'Integer', crHandPoint); + AddConst('crSizeAll', 'Integer', crSizeAll); + +{$IFDEF CLX} + AddConst('bsNone', 'Integer', fbsNone); + AddConst('bsSingle', 'Integer', fbsSingle); + AddConst('bsSizeable', 'Integer', fbsSizeable); + AddConst('bsDialog', 'Integer', fbsDialog); + AddConst('bsToolWindow', 'Integer', fbsToolWindow); + AddConst('bsSizeToolWin', 'Integer', fbsSizeToolWin); +{$ELSE} + AddConst('bsNone', 'Integer', bsNone); + AddConst('bsSingle', 'Integer', bsSingle); + AddConst('bsSizeable', 'Integer', bsSizeable); + AddConst('bsDialog', 'Integer', bsDialog); + AddConst('bsToolWindow', 'Integer', bsToolWindow); + AddConst('bsSizeToolWin', 'Integer', bsSizeToolWin); +{$ENDIF} + +{$IFNDEF CLX} + AddConst('VK_RBUTTON', 'Integer', VK_RBUTTON); + AddConst('VK_CANCEL', 'Integer', VK_CANCEL); + AddConst('VK_MBUTTON', 'Integer', VK_MBUTTON); + AddConst('VK_BACK', 'Integer', VK_BACK);//Backspace key + AddConst('VK_TAB', 'Integer', VK_TAB);//Tab key + AddConst('VK_RETURN', 'Integer', VK_RETURN);//Enter key + AddConst('VK_SHIFT', 'Integer', VK_SHIFT);//Shift key + AddConst('VK_CONTROL', 'Integer', VK_CONTROL);//Ctrl key + AddConst('VK_MENU', 'Integer', VK_MENU);//Alt key + AddConst('VK_PAUSE', 'Integer', VK_PAUSE);//Pause key + AddConst('VK_CAPITAL', 'Integer', VK_CAPITAL);//Caps Lock key + AddConst('VK_ESCAPE', 'Integer', VK_ESCAPE);//Esc key + AddConst('VK_SPACE', 'Integer', VK_SPACE);//Space bar + AddConst('VK_PRIOR', 'Integer', VK_PRIOR);//Page Up key + AddConst('VK_NEXT', 'Integer', VK_NEXT);// Page Down key + AddConst('VK_END', 'Integer', VK_END);// End key + AddConst('VK_HOME', 'Integer', VK_HOME);// Home key + AddConst('VK_LEFT', 'Integer', VK_LEFT);// Left Arrow key + AddConst('VK_UP', 'Integer', VK_UP);// Up Arrow key + AddConst('VK_RIGHT', 'Integer', VK_RIGHT);// Right Arrow key + AddConst('VK_DOWN', 'Integer', VK_DOWN);// Down Arrow key + AddConst('VK_INSERT', 'Integer', VK_INSERT);// Insert key + AddConst('VK_DELETE', 'Integer', VK_DELETE);// Delete key + AddConst('VK_HELP', 'Integer', VK_HELP);// Help key + AddConst('VK_LWIN', 'Integer', VK_LWIN);// Left Windows key (Microsoft keyboard) + AddConst('VK_RWIN', 'Integer', VK_RWIN);// Right Windows key (Microsoft keyboard) + AddConst('VK_APPS', 'Integer', VK_APPS);// Applications key (Microsoft keyboard) + AddConst('VK_NUMPAD0', 'Integer', VK_NUMPAD0);// 0 key (numeric keypad) + AddConst('VK_NUMPAD1', 'Integer', VK_NUMPAD1);// 1 key (numeric keypad) + AddConst('VK_NUMPAD2', 'Integer', VK_NUMPAD2);// 2 key (numeric keypad) + AddConst('VK_NUMPAD3', 'Integer', VK_NUMPAD3);// 3 key (numeric keypad) + AddConst('VK_NUMPAD4', 'Integer', VK_NUMPAD4);// 4 key (numeric keypad) + AddConst('VK_NUMPAD5', 'Integer', VK_NUMPAD5);// 5 key (numeric keypad) + AddConst('VK_NUMPAD6', 'Integer', VK_NUMPAD6);// 6 key (numeric keypad) + AddConst('VK_NUMPAD7', 'Integer', VK_NUMPAD7);// 7 key (numeric keypad) + AddConst('VK_NUMPAD8', 'Integer', VK_NUMPAD8);// 8 key (numeric keypad) + AddConst('VK_NUMPAD9', 'Integer', VK_NUMPAD9);// 9 key (numeric keypad) + AddConst('VK_MULTIPLY', 'Integer', VK_MULTIPLY);// Multiply key (numeric keypad) + AddConst('VK_ADD', 'Integer', VK_ADD);// Add key (numeric keypad) + AddConst('VK_SEPARATOR', 'Integer', VK_SEPARATOR);// Separator key (numeric keypad) + AddConst('VK_SUBTRACT', 'Integer', VK_SUBTRACT);// Subtract key (numeric keypad) + AddConst('VK_DECIMAL', 'Integer', VK_DECIMAL);// Decimal key (numeric keypad) + AddConst('VK_DIVIDE', 'Integer', VK_DIVIDE);// Divide key (numeric keypad) + AddConst('VK_F1', 'Integer', VK_F1);// F1 key + AddConst('VK_F1', 'Integer', VK_F2);// F2 key + AddConst('VK_F3', 'Integer', VK_F3);// F3 key + AddConst('VK_F4', 'Integer', VK_F4);// F4 key + AddConst('VK_F5', 'Integer', VK_F5);// F5 key + AddConst('VK_F6', 'Integer', VK_F6);// F6 key + AddConst('VK_F7', 'Integer', VK_F7);// F7 key + AddConst('VK_F8', 'Integer', VK_F8);// F8 key + AddConst('VK_F9', 'Integer', VK_F9);// F9 key + AddConst('VK_F10', 'Integer', VK_F10);// F10 key + AddConst('VK_F11', 'Integer', VK_F11);// F11 key + AddConst('VK_F12', 'Integer', VK_F12);// F12 key + AddConst('VK_NUMLOCK', 'Integer', VK_NUMLOCK);// Num Lock key + AddConst('VK_SCROLL', 'Integer', VK_SCROLL);// Scroll Lock key +{$ENDIF} + + AddConst('crDefault', 'Integer', crDefault); + AddConst('crNone', 'Integer', crNone); + AddConst('crArrow', 'Integer', crArrow); + AddConst('crCross', 'Integer', crCross); + AddConst('crIBeam', 'Integer', crIBeam); + AddConst('crSize', 'Integer', crSize); + AddConst('crSizeNESW', 'Integer', crSizeNESW); + AddConst('crSizeNS', 'Integer', crSizeNS); + AddConst('crSizeNWSE', 'Integer', crSizeNWSE); + AddConst('crSizeWE', 'Integer', crSizeWE); + AddConst('crUpArrow', 'Integer', crUpArrow); + AddConst('crHourGlass', 'Integer', crHourGlass); + AddConst('crDrag', 'Integer', crDrag); + AddConst('crNoDrop', 'Integer', crNoDrop); + AddConst('crHSplit', 'Integer', crHSplit); + AddConst('crVSplit', 'Integer', crVSplit); + AddConst('crMultiDrag', 'Integer', crMultiDrag); + AddConst('crSQLWait', 'Integer', crSQLWait); + AddConst('crNo', 'Integer', crNo); + AddConst('crAppStart', 'Integer', crAppStart); + AddConst('crHelp', 'Integer', crHelp); + AddConst('crHandPoint', 'Integer', crHandPoint); + AddConst('crSizeAll', 'Integer', crSizeAll); + + AddType('TFormBorderStyle', fvtInt); + AddType('TBorderStyle', fvtInt); + AddType('TAlignment', fvtInt); + AddType('TLeftRight', fvtInt); + AddConst('taLeftJustify', 'Integer', taLeftJustify); + AddConst('taRightJustify', 'Integer', taRightJustify); + AddConst('taCenter', 'Integer', taCenter); + + AddEnumSet('TShiftState', 'ssShift, ssAlt, ssCtrl, ssLeft, ssRight, ssMiddle, ssDouble'); +// AddEnum('TAlignment', 'taLeftJustify, taRightJustify, taCenter'); + AddEnum('TAlign', 'alNone, alTop, alBottom, alLeft, alRight, alClient'); + AddEnum('TMouseButton', 'mbLeft, mbRight, mbMiddle'); + AddEnumSet('TAnchors', 'akLeft, akTop, akRight, akBottom'); + AddEnum('TBevelCut', 'bvNone, bvLowered, bvRaised, bvSpace'); + AddEnum('TTextLayout', 'tlTop, tlCenter, tlBottom'); + AddEnum('TEditCharCase', 'ecNormal, ecUpperCase, ecLowerCase'); + AddEnum('TScrollStyle', 'ssNone, ssHorizontal, ssVertical, ssBoth'); + AddEnum('TComboBoxStyle', 'csDropDown, csSimple, csDropDownList, csOwnerDrawFixed, csOwnerDrawVariable'); + AddEnum('TCheckBoxState', 'cbUnchecked, cbChecked, cbGrayed'); + AddEnum('TListBoxStyle', 'lbStandard, lbOwnerDrawFixed, lbOwnerDrawVariable'); + AddEnum('TWindowState', 'wsNormal, wsMinimized, wsMaximized'); + AddEnum('TFormStyle', 'fsNormal, fsMDIChild, fsMDIForm, fsStayOnTop'); + AddEnumSet('TBorderIcons', 'biSystemMenu, biMinimize, biMaximize, biHelp'); + AddEnum('TPosition', 'poDesigned, poDefault, poDefaultPosOnly, poDefaultSizeOnly, poScreenCenter, poDesktopCenter'); + AddEnum('TCloseAction', 'caNone, caHide, caFree, caMinimize'); + + with AddClass(TControl, 'TComponent') do + begin + AddProperty('Parent', 'TWinControl', GetProp, SetProp); + AddMethod('procedure Hide', CallMethod); + AddMethod('procedure Show', CallMethod); + AddMethod('procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer)', CallMethod); + AddEvent('OnCanResize', TfsCanResizeEvent); + AddEvent('OnClick', TfsNotifyEvent); + AddEvent('OnDblClick', TfsNotifyEvent); + AddEvent('OnMouseDown', TfsMouseEvent); + AddEvent('OnMouseMove', TfsMouseMoveEvent); + AddEvent('OnMouseUp', TfsMouseEvent); + AddEvent('OnResize', TfsNotifyEvent); + end; + with AddClass(TWinControl, 'TControl') do + begin + AddMethod('procedure SetFocus', CallMethod); + AddEvent('OnEnter', TfsNotifyEvent); + AddEvent('OnExit', TfsNotifyEvent); + AddEvent('OnKeyDown', TfsKeyEvent); + AddEvent('OnKeyPress', TfsKeyPressEvent); + AddEvent('OnKeyUp', TfsKeyEvent); + end; + AddClass(TCustomControl, 'TWinControl'); + AddClass(TGraphicControl, 'TControl'); + AddClass(TGroupBox, 'TWinControl'); + AddClass(TLabel, 'TControl'); + AddClass(TEdit, 'TWinControl'); + AddClass(TMemo, 'TWinControl'); + with AddClass(TCustomComboBox, 'TWinControl') do + begin + AddProperty('DroppedDown', 'Boolean', GetProp, SetProp); + AddProperty('ItemIndex', 'Integer', GetProp, SetProp); + AddEvent('OnChange', TfsNotifyEvent); + AddEvent('OnDropDown', TfsNotifyEvent); + AddEvent('OnCloseUp', TfsNotifyEvent); + end; + AddClass(TComboBox, 'TCustomComboBox'); + AddClass(TButton, 'TWinControl'); + AddClass(TCheckBox, 'TWinControl'); + AddClass(TRadioButton, 'TWinControl'); + with AddClass(TCustomListBox, 'TWinControl') do + begin + AddProperty('ItemIndex', 'Integer', GetProp, SetProp); + AddProperty('SelCount', 'Integer', GetProp, nil); + AddIndexProperty('Selected', 'Integer', 'Boolean', CallMethod); + end; + AddClass(TListBox, 'TCustomListBox'); + AddClass(TControlScrollBar, 'TPersistent'); + AddClass(TScrollingWinControl, 'TWinControl'); + AddClass(TScrollBox, 'TScrollingWinControl'); + with AddClass(TCustomForm, 'TScrollingWinControl') do + begin + AddMethod('procedure Close', CallMethod); + AddMethod('procedure Hide', CallMethod); + AddMethod('procedure Show', CallMethod); + AddMethod('function ShowModal: Integer', CallMethod); + AddEvent('OnActivate', TfsNotifyEvent); + AddEvent('OnClose', TfsCloseEvent); + AddEvent('OnCloseQuery', TfsCloseQueryEvent); + AddEvent('OnCreate', TfsNotifyEvent); + AddEvent('OnDestroy', TfsNotifyEvent); + AddEvent('OnDeactivate', TfsNotifyEvent); + AddEvent('OnHide', TfsNotifyEvent); + AddEvent('OnPaint', TfsNotifyEvent); + AddEvent('OnShow', TfsNotifyEvent); + AddProperty('Canvas', 'TCanvas', GetProp, nil); + AddProperty('ModalResult', 'Integer', GetProp, SetProp); + end; + AddClass(TForm, 'TCustomForm'); + AddClass(TDataModule, 'TComponent'); + with AddClass(TApplication, 'TComponent') do + begin + AddMethod('procedure Minimize', CallMethod); + AddMethod('procedure ProcessMessages', CallMethod); + AddMethod('procedure Restore', CallMethod); + AddProperty('ExeName', 'String', GetProp, nil); + end; + AddObject('Application', Application); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +var + Form: TCustomForm; +begin + Result := 0; + + if ClassType = TControl then + begin + if MethodName = 'HIDE' then + TControl(Instance).Hide + else if MethodName = 'SHOW' then + TControl(Instance).Show + else if MethodName = 'SETBOUNDS' then + TControl(Instance).SetBounds(Caller.Params[0], Caller.Params[1], Caller.Params[2], Caller.Params[3]) + end + else if ClassType = TWinControl then + begin + if MethodName = 'SETFOCUS' then + TWinControl(Instance).SetFocus + end + else if ClassType = TCustomListBox then + begin + if MethodName = 'SELECTED.GET' then + Result := TCustomListBox(Instance).Selected[Caller.Params[0]] + else if MethodName = 'SELECTED.SET' then + TCustomListBox(Instance).Selected[Caller.Params[0]] := Caller.Params[1] + end + else if ClassType = TCustomForm then + begin + Form := TCustomForm(Instance); + if MethodName = 'CLOSE' then + Form.Close + else if MethodName = 'HIDE' then + Form.Hide + else if MethodName = 'SHOW' then + Form.Show + else if MethodName = 'SHOWMODAL' then + Result := Form.ShowModal; + end + else if ClassType = TApplication then + begin + if MethodName = 'MINIMIZE' then + TApplication(Instance).Minimize + else if MethodName = 'PROCESSMESSAGES' then + TApplication(Instance).ProcessMessages + else if MethodName = 'RESTORE' then + TApplication(Instance).Restore + end +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TControl then + begin + if PropName = 'PARENT' then + Result := Integer(TControl(Instance).Parent) + end + else if ClassType = TCustomComboBox then + begin + if PropName = 'DROPPEDDOWN' then + Result := TCustomComboBox(Instance).DroppedDown + else if PropName = 'ITEMINDEX' then + Result := TCustomComboBox(Instance).ItemIndex + end + else if ClassType = TCustomListBox then + begin + if PropName = 'SELCOUNT' then + Result := TCustomListBox(Instance).SelCount + else if PropName = 'ITEMINDEX' then + Result := TCustomListBox(Instance).ItemIndex + end + else if ClassType = TCustomForm then + begin + if PropName = 'MODALRESULT' then + Result := TCustomForm(Instance).ModalResult + else if PropName = 'CANVAS' then + Result := Integer(TCustomForm(Instance).Canvas) + end + else if ClassType = TApplication then + begin + if PropName = 'EXENAME' then + Result := TApplication(Instance).ExeName + end +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin + if ClassType = TControl then + begin + if PropName = 'PARENT' then + TControl(Instance).Parent := TWinControl(Integer(Value)) + end + else if ClassType = TCustomComboBox then + begin + if PropName = 'DROPPEDDOWN' then + TCustomComboBox(Instance).DroppedDown := Value + else if PropName = 'ITEMINDEX' then + TCustomComboBox(Instance).ItemIndex := Value + end + else if ClassType = TCustomListBox then + begin + if PropName = 'ITEMINDEX' then + TCustomListBox(Instance).ItemIndex := Value + end + else if ClassType = TCustomForm then + begin + if PropName = 'MODALRESULT' then + TCustomForm(Instance).ModalResult := Value + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_igraphicsrtti.pas b/official/4.2/LibD11/fs_igraphicsrtti.pas new file mode 100644 index 0000000..172a41b --- /dev/null +++ b/official/4.2/LibD11/fs_igraphicsrtti.pas @@ -0,0 +1,249 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Graphics.pas classes and functions } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_igraphicsrtti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_iclassesrtti +{$IFDEF CLX} +, QGraphics +{$ELSE} +, Graphics +{$ENDIF}; + +type + TfsGraphicsRTTI = class(TComponent); // fake component + + +implementation + +type + THackGraphic = class(TGraphic) + end; + + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); + procedure GetColorProc(const Name: String); + public + constructor Create(AScript: TfsScript); override; + end; + + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + GetColorValues(GetColorProc); + AddEnumSet('TFontStyles', 'fsBold, fsItalic, fsUnderline, fsStrikeout'); + AddEnum('TFontPitch', 'fpDefault, fpVariable, fpFixed'); + AddEnum('TPenStyle', 'psSolid, psDash, psDot, psDashDot, psDashDotDot, psClear, psInsideFrame'); + AddEnum('TPenMode', 'pmBlack, pmWhite, pmNop, pmNot, pmCopy, pmNotCopy, pmMergePenNot, ' + + 'pmMaskPenNot, pmMergeNotPen, pmMaskNotPen, pmMerge, pmNotMerge, pmMask, pmNotMask, pmXor, pmNotXor'); + AddEnum('TBrushStyle', 'bsSolid, bsClear, bsHorizontal, bsVertical, ' + + 'bsFDiagonal, bsBDiagonal, bsCross, bsDiagCross'); + + with AddClass(TFont, 'TPersistent') do + AddConstructor('constructor Create', CallMethod); + with AddClass(TPen, 'TPersistent') do + AddConstructor('constructor Create', CallMethod); + with AddClass(TBrush, 'TPersistent') do + AddConstructor('constructor Create', CallMethod); + with AddClass(TCanvas, 'TPersistent') do + begin + AddConstructor('constructor Create', CallMethod); + AddMethod('procedure Draw(X, Y: Integer; Graphic: TGraphic)', CallMethod); + AddMethod('procedure Ellipse(X1, Y1, X2, Y2: Integer)', CallMethod); + AddMethod('procedure LineTo(X, Y: Integer)', CallMethod); + AddMethod('procedure MoveTo(X, Y: Integer)', CallMethod); + AddMethod('procedure Rectangle(X1, Y1, X2, Y2: Integer)', CallMethod); + AddMethod('procedure RoundRect(X1, Y1, X2, Y2, X3, Y3: Integer)', CallMethod); + AddMethod('procedure StretchDraw(X1, Y1, X2, Y2: Integer; Graphic: TGraphic)', CallMethod); + AddMethod('function TextHeight(const Text: string): Integer', CallMethod); + AddMethod('procedure TextOut(X, Y: Integer; const Text: string)', CallMethod); + AddMethod('function TextWidth(const Text: string): Integer', CallMethod); +{$IFNDEF CLX} + AddIndexProperty('Pixels', 'Integer, Integer', 'TColor', CallMethod); +{$ENDIF} + end; + with AddClass(TGraphic, 'TPersistent') do + begin + AddConstructor('constructor Create', CallMethod); + AddMethod('procedure LoadFromFile(const Filename: string)', CallMethod); + AddMethod('procedure SaveToFile(const Filename: string)', CallMethod); + AddProperty('Height', 'Integer', GetProp, SetProp); + AddProperty('Width', 'Integer', GetProp, SetProp); + end; + with AddClass(TPicture, 'TPersistent') do + begin + AddMethod('procedure LoadFromFile(const Filename: string)', CallMethod); + AddMethod('procedure SaveToFile(const Filename: string)', CallMethod); + AddProperty('Height', 'Integer', GetProp, nil); + AddProperty('Width', 'Integer', GetProp, nil); + end; +{$IFNDEF CROSS_COMPILE} + AddClass(TMetafile, 'TGraphic'); + with AddClass(TMetafileCanvas, 'TCanvas') do + AddConstructor('constructor Create(AMetafile: TMetafile; ReferenceDevice: Integer)', CallMethod); +{$ENDIF} + with AddClass(TBitmap, 'TGraphic') do + AddProperty('Canvas', 'TCanvas', GetProp); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +var + _Canvas: TCanvas; +begin + Result := 0; + + if ClassType = TFont then + begin + if MethodName = 'CREATE' then + Result := Integer(TFont(Instance).Create) + end + else if ClassType = TPen then + begin + if MethodName = 'CREATE' then + Result := Integer(TPen(Instance).Create) + end + else if ClassType = TBrush then + begin + if MethodName = 'CREATE' then + Result := Integer(TBrush(Instance).Create) + end + else if ClassType = TCanvas then + begin + _Canvas := TCanvas(Instance); + + if MethodName = 'CREATE' then + Result := Integer(TCanvas(Instance).Create) + else if MethodName = 'DRAW' then + _Canvas.Draw(Caller.Params[0], Caller.Params[1], TGraphic(Integer(Caller.Params[2]))) + else if MethodName = 'ELLIPSE' then + _Canvas.Ellipse(Caller.Params[0], Caller.Params[1], Caller.Params[2], Caller.Params[3]) + else if MethodName = 'LINETO' then + _Canvas.LineTo(Caller.Params[0], Caller.Params[1]) + else if MethodName = 'MOVETO' then + _Canvas.MoveTo(Caller.Params[0], Caller.Params[1]) + else if MethodName = 'RECTANGLE' then + _Canvas.Rectangle(Caller.Params[0], Caller.Params[1], Caller.Params[2], Caller.Params[3]) + else if MethodName = 'ROUNDRECT' then + _Canvas.RoundRect(Caller.Params[0], Caller.Params[1], Caller.Params[2], Caller.Params[3], Caller.Params[4], Caller.Params[5]) + else if MethodName = 'STRETCHDRAW' then + _Canvas.StretchDraw(Rect(Caller.Params[0], Caller.Params[1], Caller.Params[2], Caller.Params[3]), TGraphic(Integer(Caller.Params[2]))) + else if MethodName = 'TEXTHEIGHT' then + Result := _Canvas.TextHeight(Caller.Params[0]) + else if MethodName = 'TEXTOUT' then + _Canvas.TextOut(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'TEXTWIDTH' then + Result := _Canvas.TextWidth(Caller.Params[0]) +{$IFNDEF CLX} + else if MethodName = 'PIXELS.GET' then + Result := _Canvas.Pixels[Caller.Params[0], Caller.Params[1]] + else if MethodName = 'PIXELS.SET' then + _Canvas.Pixels[Caller.Params[0], Caller.Params[1]] := Caller.Params[2] +{$ENDIF} + end + else if ClassType = TGraphic then + begin + if MethodName = 'CREATE' then + Result := Integer(THackGraphic(Instance).Create) + else if MethodName = 'LOADFROMFILE' then + TGraphic(Instance).LoadFromFile(Caller.Params[0]) + else if MethodName = 'SAVETOFILE' then + TGraphic(Instance).SaveToFile(Caller.Params[0]) + end + else if ClassType = TPicture then + begin + if MethodName = 'LOADFROMFILE' then + TPicture(Instance).LoadFromFile(Caller.Params[0]) + else if MethodName = 'SAVETOFILE' then + TPicture(Instance).SaveToFile(Caller.Params[0]) + end +{$IFNDEF CROSS_COMPILE} + else if ClassType = TMetafileCanvas then + begin + if MethodName = 'CREATE' then + Result := Integer(TMetafileCanvas(Instance).Create(TMetafile(Integer(Caller.Params[0])), Caller.Params[1])) + end +{$ENDIF} +end; + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; + const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TGraphic then + begin + if PropName = 'HEIGHT' then + Result := TGraphic(Instance).Height + else if PropName = 'WIDTH' then + Result := TGraphic(Instance).Width + end + else if ClassType = TPicture then + begin + if PropName = 'HEIGHT' then + Result := TPicture(Instance).Height + else if PropName = 'WIDTH' then + Result := TPicture(Instance).Width + end + else if ClassType = TBitmap then + begin + if PropName = 'CANVAS' then + Result := Integer(TBitmap(Instance).Canvas) + end +end; + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant); +begin + if ClassType = TGraphic then + begin + if PropName = 'HEIGHT' then + TGraphic(Instance).Height := Value + else if PropName = 'WIDTH' then + TGraphic(Instance).Width := Value + end +end; + +procedure TFunctions.GetColorProc(const Name: String); +var + c: Integer; +begin + IdentToColor(Name, c); + Script.AddConst(Name, 'Integer', c); +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_iibxreg.pas b/official/4.2/LibD11/fs_iibxreg.pas new file mode 100644 index 0000000..1ceab8b --- /dev/null +++ b/official/4.2/LibD11/fs_iibxreg.pas @@ -0,0 +1,39 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Registration unit } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iibxreg; + +{$i fs.inc} + +interface + + +procedure Register; + +implementation + +uses + Classes +{$IFNDEF Delphi6} +, DsgnIntf +{$ELSE} +, DesignIntf +{$ENDIF} +, fs_iibxrtti; + +{-----------------------------------------------------------------------} + +procedure Register; +begin + RegisterComponents('FastScript', [TfsIBXRTTI]); +end; + +end. diff --git a/official/4.2/LibD11/fs_iibxrtti.pas b/official/4.2/LibD11/fs_iibxrtti.pas new file mode 100644 index 0000000..f61a9e0 --- /dev/null +++ b/official/4.2/LibD11/fs_iibxrtti.pas @@ -0,0 +1,81 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ IBX classes and functions } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iibxrtti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_itools, fs_idbrtti, db, ibdatabase, + IBCustomDataSet, IBQuery, IBTable, IBStoredProc; + +type + TfsIBXRTTI = class(TComponent); // fake component + + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + with AScript do + begin + AddClass(TIBDataBase, 'TComponent'); + AddClass(TIBTransaction, 'TComponent'); + AddClass(TIBCustomDataSet, 'TDataSet'); + AddClass(TIBTable, 'TIBCustomDataSet'); + with AddClass(TIBQuery, 'TIBCustomDataSet') do + AddMethod('procedure ExecSQL', CallMethod); + with AddClass(TIBStoredProc, 'TIBCustomDataSet') do + AddMethod('procedure ExecProc', CallMethod); + end; +end; + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant; +begin + Result := 0; + + if ClassType = TIBQuery then + begin + if MethodName = 'EXECSQL' then + TIBQuery(Instance).ExecSQL + end + else if ClassType = TIBStoredProc then + begin + if MethodName = 'EXECPROC' then + TIBStoredProc(Instance).ExecProc + end +end; + + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + if fsRTTIModules <> nil then + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_iilparser.pas b/official/4.2/LibD11/fs_iilparser.pas new file mode 100644 index 0000000..d0b2d9a --- /dev/null +++ b/official/4.2/LibD11/fs_iilparser.pas @@ -0,0 +1,2014 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Intermediate Language parser } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iilparser; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, fs_iparser, fs_iexpression, fs_xml +{$IFDEF Delphi6} +, Variants +{$ENDIF}; + + +type + TfsEmitOp = (emNone, emCreate, emFree); + +{ TfsILParser performs the syntax analyze of source code. Source code + can be on ANY language. Grammars are stored in the XML file and + can be easily changed to support any structured language. Currently + supported languages are Pascal, C++, Basic and Java subsets. + + The result of the analyze (function MakeScript) is the output XML script + (called Intermediate Language). This output processed by the ParseILScript + method. This method creates the program structure (defined in the + fs_Interpreter unit) and fills it by the data } + + TfsILParser = class(TObject) + private + FErrorPos: String; + FGrammar: TfsXMLDocument; + FILScript: TfsXMLDocument; + FLangName: String; + FNeedDeclareVars: Boolean; + FParser: TfsParser; + FProgram: TfsScript; + FProgRoot: TfsXMLItem; + FRoot: TfsXMLItem; + FUnitName: String; + FUsesList: TStrings; + FWithList: TStringList; + function PropPos(xi: TfsXMLItem): String; + procedure ErrorPos(xi: TfsXMLItem); + procedure CheckIdent(Prog: TfsScript; const Name: String); + function FindClass(const TypeName: String): TfsClassVariable; + procedure CheckTypeCompatibility(Var1, Var2: TfsCustomVariable); + function FindVar(Prog: TfsScript; const Name: String): TfsCustomVariable; + function FindType(s: String): TfsVarType; + function CreateVar(xi: TfsXMLItem; Prog: TfsScript; const Name: String; + Statement: TfsStatement = nil; CreateParam: Boolean = False; + IsVarParam: Boolean = False): TfsCustomVariable; + function DoSet(xi: TfsXMLItem; Prog: TfsScript): TfsSetExpression; + function DoExpression(xi: TfsXMLItem; Prog: TfsScript): TfsExpression; + procedure DoUses(xi: TfsXMLItem; Prog: TfsScript); + procedure DoVar(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoConst(xi: TfsXMLItem; Prog: TfsScript); + procedure DoParameters(xi: TfsXMLItem; v: TfsProcVariable); + procedure DoProc1(xi: TfsXMLItem; Prog: TfsScript); + procedure DoProc2(xi: TfsXMLItem; Prog: TfsScript); + procedure DoFunc1(xi: TfsXMLItem; Prog: TfsScript); + procedure DoFunc2(xi: TfsXMLItem; Prog: TfsScript); + procedure DoAssign(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoCall(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoIf(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoFor(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoVbFor(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoCppFor(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoWhile(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoRepeat(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoCase(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoTry(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoBreak(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoContinue(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoExit(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoReturn(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoWith(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoDelete(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoCompoundStmt(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoStmt(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); + procedure DoProgram(xi: TfsXMLItem; Prog: TfsScript); + public + constructor Create(AProgram: TfsScript); + destructor Destroy; override; + + procedure SelectLanguage(const LangName: String); + { convert the input script to the Intermediate Language } + function MakeILScript(const Text: String): Boolean; + { parse IL } + procedure ParseILScript; + { this method is needed here to implement late-binding } + function DoDesignator(xi: TfsXMLItem; Prog: TfsScript; + EmitOp: TfsEmitOp = emNone): TfsDesignator; + property ILScript: TfsXMLDocument read FILScript; + end; + + +implementation + +uses fs_itools, fs_iconst +{$IFDEF CROSS_COMPILE} +, Types +{$ELSE} +, Windows +{$ENDIF} +{$IFDEF OLE} +, fs_idisp +{$ENDIF}; + + +{ TfsILParser } + +constructor TfsILParser.Create(AProgram: TfsScript); +begin + FNeedDeclareVars := True; + FProgram := AProgram; + FGrammar := TfsXMLDocument.Create; + FILScript := TfsXMLDocument.Create; + FParser := TfsParser.Create; + FUsesList := TStringList.Create; + FWithList := TStringList.Create; +end; + +destructor TfsILParser.Destroy; +begin + FGrammar.Free; + FILScript.Free; + FParser.Free; + FUsesList.Free; + FWithList.Free; + inherited; +end; + +procedure TfsILParser.SelectLanguage(const LangName: String); +var + i: Integer; + Name, PropText: String; + xi: TfsXMLItem; + ParserRoot: TfsXMLItem; + ss: TStringStream; +begin + FParser.Clear; + FLangName := LangName; + ss := TStringStream.Create(fsGetLanguage(LangName)); + try + FGrammar.LoadFromStream(ss); + finally + ss.Free; + end; + + FRoot := FGrammar.Root; + ParserRoot := FRoot.FindItem('parser'); + + xi := ParserRoot.FindItem('keywords'); + for i := 0 to xi.Count - 1 do + FParser.Keywords.Add(xi[i].Name); + + for i := 0 to ParserRoot.Count - 1 do + begin + Name := LowerCase(ParserRoot[i].Name); + PropText := ParserRoot[i].Prop['text']; + if Name = 'identchars' then + FParser.ConstructCharset(PropText) + else if Name = 'commentline1' then + FParser.CommentLine1 := PropText + else if Name = 'commentline2' then + FParser.CommentLine2 := PropText + else if Name = 'commentblock1' then + FParser.CommentBlock1 := PropText + else if Name = 'commentblock2' then + FParser.CommentBlock2 := PropText + else if Name = 'stringquotes' then + FParser.StringQuotes := PropText + else if Name = 'hexsequence' then + FParser.HexSequence := PropText + else if Name = 'declarevars' then + begin + if PropText = '0' then + FNeedDeclareVars := False; + end + else if Name = 'skipeol' then + begin + if PropText = '0' then + FParser.SkipEOL := False; + end + else if Name = 'skipchar' then + FParser.SkipChar := PropText + else if Name = 'casesensitive' then + begin + if PropText = '1' then + FParser.CaseSensitive := True; + end + end; + + if FProgram.ExtendedCharset then + for i := 128 to 255 do + FParser.IdentifierCharset := FParser.IdentifierCharset + [Chr(i)]; +end; + +function TfsILParser.MakeILScript(const Text: String): Boolean; +var + FList: TStrings; + FStream: TStream; + FErrorMsg: String; + FErrorPos: String; + FTermError: Boolean; + i: Integer; + + function Run(xi: TfsXMLItem): Boolean; + var + i, j, ParsPos, ParsPos1, LoopPos, ListPos: Integer; + s, NodeName, Token, PropText, PropAdd, PropAddText, PropNode: String; + Completed, TopLevelNode, Flag: Boolean; + + procedure DoInclude(const Name: String); + var + sl: TStringList; + p: TfsILParser; + ss: TStringStream; + s: String; + begin + if FUsesList.IndexOf(Name) <> -1 then + Exit; + FUsesList.Add(Name); + + sl := TStringList.Create; + try + if Assigned(FProgram.OnGetUnit) then + begin + s := ''; + FProgram.OnGetUnit(FProgram, Name, s); + sl.Text := s; + end + else + sl.LoadFromFile(Name); + + p := TfsILParser.Create(FProgram); + p.FUnitName := Name; + ss := TStringStream.Create(''); + try + s := ''; + if sl.Count > 0 then + begin + p.SelectLanguage(FLangName); + p.FUsesList.Assign(FUsesList); + if p.MakeILScript(sl.Text) then + begin + FUsesList.Assign(p.FUsesList); + p.ILScript.SaveToStream(ss); + s := ss.DataString; + Delete(s, 1, Pos('?>', s) + 1); + end + else + begin + FErrorMsg := FProgram.ErrorMsg; + FErrorPos := FProgram.ErrorPos; + if FProgram.ErrorUnit = '' then + FProgram.ErrorUnit := Name; + end; + end; + + FList.Insert(ListPos, ''); + FList.Insert(ListPos, s); + FList.Insert(ListPos, ''); + Inc(ListPos, 3); + finally + p.Free; + ss.Free; + end; + finally + sl.Free; + end; + end; + + procedure CheckPropNode(Flag: Boolean); + var + i, ParsPos1: Integer; + s: String; + begin + if CompareText(PropNode, 'uses') = 0 then + begin + while FList.Count > ListPos do + begin + s := FList[FList.Count - 1]; + i := Pos('text="', s); + Delete(s, 1, i + 5); + i := Pos('" ', s); + Delete(s, i, 255); + DoInclude(Copy(s, 2, Length(s) - 2)); + FList.Delete(FList.Count - 1); + end; + end + else if PropNode <> '' then + if Flag then + begin + ParsPos1 := FParser.Position; + FParser.Position := ParsPos; + FParser.SkipSpaces; + + s := '<' + PropNode + ' pos="' + FParser.GetXYPosition + '"'; + FParser.Position := ParsPos1; + + if PropNode = 'expr' then + s := s + ' pos1="' + FParser.GetXYPosition + '"'; + s := s + '>'; + + FList.Insert(ListPos, s); + FList.Add(''); + end + else + begin + while FList.Count > ListPos do + FList.Delete(FList.Count - 1); + end; + end; + + procedure AddError(xi: TfsXMLItem); + var + PropErr: String; + xi1: TfsXMLItem; + begin + PropErr := xi.Prop['err']; + if (PropErr <> '') and (FErrorMsg = '') then + begin + xi1 := FRoot.FindItem('parser'); + xi1 := xi1.FindItem('errors'); + FErrorMsg := xi1.FindItem(PropErr).Prop['text']; + FParser.Position := ParsPos; + FParser.SkipSpaces; + FErrorPos := FParser.GetXYPosition; + FTermError := xi.Prop['term'] = '1'; + end; + end; + + begin + Result := True; + ParsPos := FParser.Position; + ListPos := FList.Count; + + NodeName := AnsiLowerCase(xi.Name); + PropText := AnsiLowerCase(xi.Prop['text']); + PropNode := LowerCase(xi.Prop['node']); + TopLevelNode := xi.Parent = FRoot; + + Completed := False; + Flag := False; + Token := ''; + + if TopLevelNode then + Completed := True + else if NodeName = 'char' then + begin + if xi.Prop['skip'] <> '0' then + FParser.SkipSpaces; + Token := FParser.GetChar; + Flag := True; + end + else if NodeName = 'keyword' then + begin + Token := FParser.GetWord; + Flag := True; + end + else if NodeName = 'ident' then + begin + Token := FParser.GetIdent; + Flag := True; + end + else if NodeName = 'number' then + begin + Token := FParser.GetNumber; + Flag := True; + end + else if NodeName = 'string' then + begin + Token := FParser.GetString; + Flag := True; + end + else if NodeName = 'frstring' then + begin + Token := FParser.GetFRString; + s := FParser.GetXYPosition; + FList.Add(''); + FList.Add(''); + FList.Add(''); + FList.Add(''); + FList.Add(''); + FList.Add(''); + Flag := True; + end + else if NodeName = 'eol' then + Completed := FParser.GetEOL + else if NodeName = 'sequence' then + Completed := True + else if (NodeName = 'switch') or (NodeName = 'optionalswitch') then + begin + Completed := True; + + for i := 0 to xi.Count - 1 do + begin + Completed := Run(xi[i]); + if Completed then + break; + end; + + if not Completed then + if NodeName <> 'optionalswitch' then + begin + Result := False; + AddError(xi); + end; + Exit; + end + else if (NodeName = 'loop') or (NodeName = 'optionalloop') then + begin + j := 0; + repeat + Inc(j); + Flag := False; + LoopPos := FParser.Position; + + for i := 0 to xi.Count - 1 do + begin + Result := Run(xi[i]); + if not Result then + begin + Flag := True; + break; + end; + end; + + { try loop delimiter } + ParsPos1 := FParser.Position; + if Result and (PropText <> '') then + begin + FParser.SkipSpaces; + if FParser.GetChar <> PropText then + begin + FParser.Position := ParsPos1; + Flag := True; + end; + end; + + { avoid infinity loop } + if FParser.Position = LoopPos then + Flag := True; + until Flag; + + { at least one loop was succesful } + if j > 1 then + begin + { special case - now implemented only in "case" statement } + if (xi.Prop['skip'] = '1') or FTermError then + FErrorMsg := ''; + FParser.Position := ParsPos1; + Result := True; + end; + + if NodeName = 'optionalloop' then + begin + if not Result then + FParser.Position := ParsPos; + Result := True; + end; + Exit; + end + else if NodeName = 'optional' then + begin + for i := 0 to xi.Count - 1 do + if not Run(xi[i]) then + begin + FParser.Position := ParsPos; + break; + end; + Exit; + end + else + begin + j := FRoot.Find(NodeName); + if j = -1 then + raise Exception.Create(SInvalidLanguage); + + Completed := Run(FRoot[j]); + end; + + if Flag then + begin + if FParser.CaseSensitive then + Completed := (Token <> '') and + ((PropText = '') or (Token = PropText)) + else + Completed := (Token <> '') and + ((PropText = '') or (AnsiCompareText(Token, PropText) = 0)); + end; + + if not Completed then + begin + Result := False; + AddError(xi); + end + else + begin + if not TopLevelNode then + CheckPropNode(True); + + PropAdd := xi.Prop['add']; + PropAddText := xi.Prop['addtext']; + if PropAdd <> '' then + begin + if PropAddText = '' then + s := Token else + s := PropAddText; + FList.Add('<' + PropAdd + ' text="' + StrToXML(s) + '" pos="' + + FParser.GetXYPosition + '"/>'); + end; + + for i := 0 to xi.Count - 1 do + begin + Result := Run(xi[i]); + if not Result then + break; + end; + end; + + if not Result then + FParser.Position := ParsPos; + if TopLevelNode then + CheckPropNode(Result); + end; + +begin + FList := TStringList.Create; + FErrorMsg := ''; + FErrorPos := ''; + Result := False; + + try + FParser.Text := Text; + + i := 1; + if FParser.GetChar = '#' then + begin + if CompareText(FParser.GetIdent, 'language') = 0 then + begin + i := FParser.Position; +{$IFDEF LINUX} + while (i <= Length(Text)) and (Text[i] <> #10) do +{$ELSE} + while (i <= Length(Text)) and (Text[i] <> #13) do +{$ENDIF} + Inc(i); + SelectLanguage(Trim(Copy(Text, FParser.Position, i - FParser.Position))); + Inc(i, 2); + end; + end; + + FParser.Position := i; + + if Run(FRoot.FindItem('program')) and (FErrorMsg = '') then + begin + FErrorMsg := ''; + FErrorPos := ''; + FStream := TMemoryStream.Create; + try + FList.Insert(0, ''); + FList.Insert(1, ''); + FList.Add(''); + FList.SaveToStream(FStream); + FStream.Position := 0; + FILScript.LoadFromStream(FStream); + FILScript.Root.Add.Assign(FRoot.FindItem('types')); +// uncomment the following lines to see what is IL script +// FILScript.AutoIndent := True; +// FILScript.SaveToFile(ExtractFilePath(ParamStr(0)) + 'out.xml'); + Result := True; + finally + FStream.Free; + end; + end; + + FProgram.ErrorPos := FErrorPos; + FProgram.ErrorMsg := FErrorMsg; + finally + FList.Free; + end; +end; + +procedure TfsILParser.ParseILScript; +begin + FWithList.Clear; + FProgram.ErrorUnit := ''; + FUnitName := ''; + + try + DoProgram(FILScript.Root, FProgram); + FProgram.ErrorPos := ''; + except + on e: Exception do + begin + FProgram.ErrorMsg := e.Message; + FProgram.ErrorPos := FErrorPos; + FProgram.ErrorUnit := FUnitName; + end; + end; +end; + +function TfsILParser.PropPos(xi: TfsXMLItem): String; +begin + Result := xi.Prop['pos']; +end; + +procedure TfsILParser.ErrorPos(xi: TfsXMLItem); +begin + FErrorPos := PropPos(xi); +end; + +procedure TfsILParser.CheckIdent(Prog: TfsScript; const Name: String); +begin + if Prog.FindLocal(Name) <> nil then + raise Exception.Create(SIdRedeclared + '''' + Name + ''''); +end; + +function TfsILParser.FindClass(const TypeName: String): TfsClassVariable; +begin + Result := FProgram.FindClass(TypeName); + if Result = nil then + raise Exception.Create(SUnknownType + '''' + TypeName + ''''); +end; + +procedure TfsILParser.CheckTypeCompatibility(Var1, Var2: TfsCustomVariable); +begin + if not AssignCompatible(Var1, Var2, FProgram) then + raise Exception.Create(SIncompatibleTypes + ': ''' + Var1.GetFullTypeName + + ''', ''' + Var2.GetFullTypeName + ''''); +end; + +function TfsILParser.FindVar(Prog: TfsScript; const Name: String): TfsCustomVariable; +begin + Result := Prog.Find(Name); + if Result = nil then + if not FNeedDeclareVars then + begin + Result := TfsVariable.Create(Name, fvtVariant, ''); + FProgram.Add(Name, Result); + end + else + raise Exception.Create(SIdUndeclared + '''' + Name + ''''); +end; + +function TfsILParser.FindType(s: String): TfsVarType; +var + xi: TfsXMLItem; +begin + xi := FProgRoot.FindItem('types'); + if xi.Find(s) <> -1 then + s := xi[xi.Find(s)].Prop['type'] + else + begin + xi := FGrammar.Root.FindItem('types'); + if xi.Find(s) <> -1 then + s := xi[xi.Find(s)].Prop['type'] + end; + Result := StrToVarType(s, FProgram); + if Result = fvtClass then + FindClass(s); +end; + +function TfsILParser.CreateVar(xi: TfsXMLItem; Prog: TfsScript; const Name: String; + Statement: TfsStatement = nil; CreateParam: Boolean = False; + IsVarParam: Boolean = False): TfsCustomVariable; +var + i, j: Integer; + Typ: TfsVarType; + TypeName: String; + RefItem: TfsCustomVariable; + InitValue: Variant; + InitItem: TfsXMLItem; + AssignStmt: TfsAssignmentStmt; + IsPascal: Boolean; + SourcePos: String; + + procedure DoArray(xi: TfsXMLItem); + var + i, n: Integer; + v: array of Integer; + Expr: TfsExpression; + begin + n := xi.Count; + SetLength(v, n * 2); + + for i := 0 to n - 1 do + begin + Expr := DoExpression(xi[i][0], Prog); + v[i * 2] := Expr.Value; + Expr.Free; + + if xi[i].Count = 2 then + begin + Expr := DoExpression(xi[i][1], Prog); + v[i * 2 + 1] := Expr.Value; + Expr.Free; + end + else + begin + v[i * 2 + 1] := v[i * 2] - 1; + v[i * 2] := 0; + end; + end; + + if n = 0 then + begin + SetLength(v, 2); + v[0] := 0; + v[1] := 0; + n := 1; + end; + + InitValue := VarArrayCreate(v, varVariant); + RefItem := TfsArrayHelper.Create('', n, Typ, TypeName); + Prog.Add('', RefItem); + v := nil; + Typ := fvtArray; + end; + + procedure DoInit(xi: TfsXMLItem); + var + Expr: TfsExpression; + Temp: TfsVariable; + begin + Temp := TfsVariable.Create('', Typ, TypeName); + try + Expr := DoExpression(xi[0], Prog); + InitValue := Expr.Value; + try + CheckTypeCompatibility(Temp, Expr); + finally + Expr.Free; + end; + finally + Temp.Free; + end; + end; + +begin + RefItem := nil; + InitItem := nil; + TypeName := 'Variant'; + IsPascal := False; + SourcePos := FErrorPos; + +(* + + + + + + + + ... + + + + + + + + - type may be first (in C-like languages) or last (in Pascal-like ones) + - type may be skipped (treated as variant) + - array and init may be either skipped, or after each + - array and init may be after each + - do not handle tags - they are handled in calling part +*) + + + { find the type } + for i := 0 to xi.Count - 1 do + if CompareText(xi[i].name, 'type') = 0 then + begin + IsPascal := i <> 0; + TypeName := xi[i].Prop['text']; + ErrorPos(xi[i]); + break; + end; + + Typ := FindType(TypeName); + case Typ of + fvtInt, fvtFloat, fvtClass: + InitValue := 0; + fvtBool: + InitValue := False; + fvtChar, fvtString: + InitValue := ''; + else + InitValue := Null; + end; + + { fing the tag corresponding to our variable } + for i := 0 to xi.Count - 1 do + if CompareText(xi[i].Prop['text'], Name) = 0 then + begin + { process and tags if any } + j := i + 1; + while (j < xi.Count) and (IsPascal or (CompareText(xi[j].Name, 'ident') <> 0)) do + begin + if CompareText(xi[j].Name, 'array') = 0 then + DoArray(xi[j]) + else if CompareText(xi[j].Name, 'init') = 0 then + begin + if Statement = nil then + DoInit(xi[j]); + InitItem := xi[j]; + end; + Inc(j); + end; + break; + end; + + if CreateParam then + Result := TfsParamItem.Create(Name, Typ, TypeName, InitItem <> nil, IsVarParam) + else if Typ in [fvtChar, fvtString] then + Result := TfsStringVariable.Create(Name, Typ, TypeName) else + Result := TfsVariable.Create(Name, Typ, TypeName); + + try + Result.Value := InitValue; + Result.RefItem := RefItem; + Result.SourcePos := SourcePos; + Result.SourceUnit := FUnitName; + + { create init statement } + if (InitItem <> nil) and (Statement <> nil) then + begin + AssignStmt := TfsAssignmentStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(AssignStmt); + AssignStmt.Designator := TfsVariableDesignator.Create(Prog); + AssignStmt.Designator.RefItem := Result; + AssignStmt.Expression := DoExpression(InitItem[0], Prog); + CheckTypeCompatibility(Result, AssignStmt.Expression); + AssignStmt.Optimize; + end; + + except + on e: Exception do + begin + Result.Free; + raise; + end; + end; +end; + +function TfsILParser.DoDesignator(xi: TfsXMLItem; Prog: TfsScript; + EmitOp: TfsEmitOp = emNone): TfsDesignator; +var + i, j: Integer; + NodeName, NodeText, TypeName: String; + Expr: TfsExpression; + Item, PriorItem: TfsDesignatorItem; + ClassVar: TfsClassVariable; + StringVar: TfsStringVariable; + Typ: TfsVarType; + LateBinding, PriorIsIndex: Boolean; + NewDesignator: TfsDesignator; + PriorValue: Variant; + Component: TComponent; + + function FindInWithList(const Name: String; ResultDS: TfsDesignator; + Item: TfsDesignatorItem): Boolean; + var + i: Integer; + WithStmt: TfsWithStmt; + WithItem: TfsDesignatorItem; + ClassVar: TfsClassVariable; + xi1: TfsXMLItem; + begin + Result := False; + LateBinding := False; + for i := FWithList.Count - 1 downto 0 do + begin + { prevent checking non-local 'with' } + if Prog.FindLocal(FWithList[i]) = nil then + continue; + + WithStmt := TfsWithStmt(FWithList.Objects[i]); + + if WithStmt.Variable.Typ = fvtVariant then + begin + { first check all known variables } + if Prog.Find(Name) <> nil then + Exit; + { if nothing found, create late binding information } + Item.Ref := WithStmt.Variable; + ResultDS.Finalize; + ResultDS.LateBindingXMLSource := TfsXMLItem.Create; + ResultDS.LateBindingXMLSource.Assign(xi); + xi1 := TfsXMLItem.Create; + xi1.Name := 'node'; + xi1.Text := 'text="' + FWithList[i] + '"'; + ResultDS.LateBindingXMLSource.InsertItem(0, xi1); + LateBinding := True; + Result := True; + break; + end + else + begin + ClassVar := FindClass(WithStmt.Variable.TypeName); + Item.Ref := ClassVar.Find(NodeText); + end; + + if Item.Ref <> nil then + begin + WithItem := TfsDesignatorItem.Create; + WithItem.Ref := WithStmt.Variable; + WithItem.SourcePos := Item.SourcePos; + + ResultDS.Remove(Item); + ResultDS.Add(WithItem); + ResultDS.Add(Item); + Result := True; + break; + end; + end; + end; + +{$IFDEF OLE} + procedure CreateOLEHelpers(Index: Integer); + var + i: Integer; + OLEHelper: TfsOLEHelper; + begin + for i := Index to xi.Count - 1 do + begin + ErrorPos(xi[i]); + NodeName := LowerCase(xi[i].Name); + NodeText := xi[i].Prop['text']; + + if (NodeName = 'node') and (NodeText <> '[') then + begin + Item := TfsDesignatorItem.Create; + Result.Add(Item); + Item.SourcePos := FErrorPos; + OLEHelper := TfsOLEHelper.Create(NodeText); + Prog.Add('', OLEHelper); + Item.Ref := OLEHelper; + end + else if NodeName = 'expr' then + begin + Expr := DoExpression(xi[i], Prog); + PriorItem := Result.Items[Result.Count - 1]; + PriorItem.Add(Expr); + PriorItem.Ref.Add(TfsParamItem.Create('', fvtVariant, '', False, False)); + end + end; + end; +{$ENDIF} + +begin + Result := TfsDesignator.Create(Prog); + try + + for i := 0 to xi.Count - 1 do + begin + ErrorPos(xi[i]); + NodeName := LowerCase(xi[i].Name); + NodeText := xi[i].Prop['text']; + + if NodeName = 'node' then + begin + Item := TfsDesignatorItem.Create; + Result.Add(Item); + Item.SourcePos := FErrorPos; + + if Result.Count = 1 then + begin + if not FindInWithList(NodeText, Result, Item) then + Item.Ref := FindVar(Prog, NodeText); + + { LateBinding flag turned on in the FindInWithList } + if LateBinding then + Exit; + { add .Create for cpp NEW statement, i.e convert o = new TObject + to o = TObject.Create } + if EmitOp = emCreate then + begin + if not (Item.Ref is TfsClassVariable) then + raise Exception.Create(SClassRequired); + ClassVar := TfsClassVariable(Item.Ref); + Item := TfsDesignatorItem.Create; + Result.Add(Item); + Item.Ref := ClassVar.Find('Create'); + end; + end + else + begin + PriorItem := Result.Items[Result.Count - 2]; + PriorIsIndex := (PriorItem.Ref is TfsMethodHelper) and + TfsMethodHelper(PriorItem.Ref).IndexMethod and not PriorItem.Flag; + Typ := PriorItem.Ref.Typ; + { late binding } + if (Typ = fvtVariant) and not PriorIsIndex then + begin + PriorValue := PriorItem.Ref.Value; + if VarIsNull(PriorValue) then + begin + Result.Remove(Item); + Item.Free; + Result.Finalize; + Result.LateBindingXMLSource := TfsXMLItem.Create; + Result.LateBindingXMLSource.Assign(xi); + Exit; + end + else + begin + if TVarData(PriorValue).VType = varString then + { accessing string elements } + Typ := fvtString + {$IFDEF OLE} + else if TVarData(PriorValue).VType = varDispatch then + begin + { calling ole } + Result.Remove(Item); + Item.Free; + CreateOLEHelpers(i); + Result.Finalize; + Exit; + end + {$ENDIF} + else if (TVarData(PriorValue).VType and varArray) = varArray then + begin + { accessing array elements } + if NodeText = '[' then { set ref to arrayhelper } + Item.Ref := FindVar(Prog, '__ArrayHelper') + else + raise Exception.Create(SIndexRequired); + continue; + end + else + begin + { accessing class items } + Typ := fvtClass; + PriorItem.Ref.TypeName := TObject(Integer(PriorItem.Ref.Value)).ClassName; + end; + end; + end; + + if PriorIsIndex then + begin + PriorItem.Flag := True; + Result.Remove(Item); { previous item is set up already } + Item.Free; + FErrorPos := PriorItem.SourcePos; + if NodeText <> '[' then + raise Exception.Create(SIndexRequired); + end + else if Typ = fvtString then + begin + if NodeText = '[' then { set ref to stringhelper } + Item.Ref := FindVar(Prog, '__StringHelper') + else + raise Exception.Create(SStringError); + end + else if Typ = fvtClass then + begin + TypeName := PriorItem.Ref.TypeName; + ClassVar := FindClass(TypeName); + + if NodeText = '[' then { default property } + begin + Item.Flag := True; + Item.Ref := ClassVar.DefProperty; + if Item.Ref = nil then + raise Exception.CreateFmt(SClassError, [TypeName]); + end + else { property or method } + begin + Item.Ref := ClassVar.Find(NodeText); + { property not found. Probably it's a form element such as button? } + if Item.Ref = nil then + begin + PriorValue := PriorItem.Ref.Value; + if VarIsNull(PriorValue) or (PriorValue = 0) then + begin + { at compile time, we don't know anything about form elements. + So clear the designator items and use the late binding. } + Result.Remove(Item); + Item.Free; + while Result.Count > 1 do + begin + Item := Result.Items[Result.Count - 1]; + Result.Remove(Item); + Item.Free; + end; + Item := Result.Items[0]; + Result.Finalize; + Result.Typ := fvtVariant; + Result.LateBindingXMLSource := TfsXMLItem.Create; + Result.LateBindingXMLSource.Assign(xi); + Exit; + end + else + begin + { we at run time now. Try to search in the form's elements. } + if TObject(Integer(PriorValue)) is TComponent then + begin + Component := TComponent(Integer(PriorValue)).FindComponent(NodeText); + if Component <> nil then + begin + Item.Ref := TfsCustomVariable.Create('', fvtClass, Component.ClassName); + Item.Ref.Value := Integer(Component); + end; + end; + if Item.Ref = nil then + raise Exception.Create(SIdUndeclared + '''' + NodeText + ''''); + end + end; + end; + end + else if Typ = fvtArray then { set ref to array helper } + Item.Ref := PriorItem.Ref.RefItem + else + raise Exception.Create(SArrayRequired); + end; + end + else if NodeName = 'expr' then + begin + Expr := DoExpression(xi[i], Prog); + Result.Items[Result.Count - 1].Add(Expr); + end + else if NodeName = 'addr' then { @ operator } + begin + if xi.Count <> 2 then + raise Exception.Create(SVarRequired); + + Item := TfsDesignatorItem.Create; + Result.Add(Item); + ErrorPos(xi[1]); + Item.SourcePos := FErrorPos; + + { we just return the string containing a referenced item name. For + example, var s: String; procedure B1; begin end; s := @B1 + will assign 'B1' to the s } + StringVar := TfsStringVariable.Create('', fvtString, ''); + StringVar.Value := xi[1].Prop['text']; + Prog.Add('', StringVar); + Item.Ref := StringVar; + + break; + end; + end; + + if EmitOp = emFree then + begin + PriorItem := Result.Items[Result.Count - 1]; + if (PriorItem.Ref.Typ <> fvtClass) and (PriorItem.Ref.Typ <> fvtVariant) then + raise Exception.Create(SClassRequired); + Item := TfsDesignatorItem.Create; + Result.Add(Item); + ClassVar := FindClass('TObject'); + Item.Ref := ClassVar.Find('Free'); + end; + + Result.Finalize; + if Result.Kind <> dkOther then + begin + NewDesignator := nil; + if Result.Kind = dkVariable then + NewDesignator := TfsVariableDesignator.Create(Prog) + else if Result.Kind = dkStringArray then + NewDesignator := TfsStringDesignator.Create(Prog) + else if Result.Kind = dkArray then + NewDesignator := TfsArrayDesignator.Create(Prog); + + NewDesignator.Borrow(Result); + Result.Free; + Result := NewDesignator; + end; + + for i := 0 to Result.Count - 1 do + begin + Item := Result[i]; + FErrorPos := Item.SourcePos; + if Item.Ref is TfsDesignator then continue; + + if Item.Count < Item.Ref.GetNumberOfRequiredParams then + raise Exception.Create(SNotEnoughParams) + else if Item.Count > Item.Ref.Count then + raise Exception.Create(STooManyParams) + else if Item.Count <> Item.Ref.Count then { construct the default params } + for j := Item.Count to Item.Ref.Count - 1 do + begin + Expr := TfsExpression.Create(FProgram); + Item.Add(Expr); + Expr.AddConst(Item.Ref[j].DefValue); + Expr.Finalize; + end; + + for j := 0 to Item.Count - 1 do + begin + FErrorPos := Item[j].SourcePos; + CheckTypeCompatibility(Item.Ref[j], Item[j]); + end; + end; + + except + on e: Exception do + begin + Result.Free; + raise; + end; + end; +end; + +function TfsILParser.DoSet(xi: TfsXMLItem; Prog: TfsScript): TfsSetExpression; +var + i: Integer; + Name: String; +begin + Result := TfsSetExpression.Create('', fvtVariant, ''); + try + for i := 0 to xi.Count - 1 do + begin + Name := LowerCase(xi[i].Name); + if Name = 'expr' then + Result.Add(DoExpression(xi[i], Prog)) + else if Name = 'range' then + Result.Add(nil); + end; + + except + on e: Exception do + begin + Result.Free; + raise; + end; + end; +end; + +function TfsILParser.DoExpression(xi: TfsXMLItem; Prog: TfsScript): TfsExpression; +var + ErPos: String; + SourcePos1, SourcePos2: TPoint; + + procedure DoExpressionItems(xi: TfsXMLItem; Expression: TfsExpression); + var + i: Integer; + NodeName, OpName: String; + begin + i := 0; + while i < xi.Count do + begin + ErrorPos(xi[i]); + Expression.SourcePos := FErrorPos; + NodeName := Lowercase(xi[i].Name); + OpName := xi[i].Prop['text']; + + if (NodeName = 'op') then + begin + OpName := LowerCase(OpName); + if (OpName = ')') or (i < xi.Count - 1) then + Expression.AddOperator(OpName); + end + else if (NodeName = 'number') or (NodeName = 'string') then + Expression.AddConst(ParserStringToVariant(OpName)) + else if NodeName = 'dsgn' then + Expression.AddDesignator(DoDesignator(xi[i], Prog)) + else if NodeName = 'set' then + Expression.AddSet(DoSet(xi[i], Prog)) + else if NodeName = 'new' then + Expression.AddDesignator(DoDesignator(xi[i][0], Prog, emCreate)) + else if NodeName = 'expr' then + DoExpressionItems(xi[i], Expression); + + Inc(i); + end; + end; + + function GetSource(pt1, pt2: TPoint): String; + var + i1, i2: Integer; + begin + i1 := FParser.GetPlainPosition(pt1); + i2 := FParser.GetPlainPosition(pt2); + if (i1 = -1) or (i2 = -1) then + Result := '' + else + Result := Copy(FParser.Text, i1, i2 - i1); + end; + +begin + Result := TfsExpression.Create(FProgram); + try + DoExpressionItems(xi, Result); + SourcePos1 := fsPosToPoint(PropPos(xi)); + SourcePos2 := fsPosToPoint(xi.Prop['pos1']); + Result.Source := GetSource(SourcePos1, SourcePos2); + + ErPos := Result.Finalize; + if ErPos <> '' then + begin + FErrorPos := ErPos; + raise Exception.Create(SIncompatibleTypes); + end; + + except + on e: Exception do + begin + Result.Free; + raise; + end; + end; +end; + +procedure TfsILParser.DoUses(xi: TfsXMLItem; Prog: TfsScript); +var + i: Integer; + SaveUnitName: String; + s: String; + sl: TStringList; + ms: TMemoryStream; + xd: TfsXMLDocument; +begin + SaveUnitName := FUnitName; + FUnitName := xi.Prop['unit']; + xd := nil; + + if Assigned(FProgram.OnGetILUnit) then + begin + s := ''; + FProgram.OnGetILUnit(FProgram, FUnitName, s); + if s <> '' then + begin + sl := TStringList.Create; + sl.Text := s; + + ms := TMemoryStream.Create; + sl.SaveToStream(ms); + sl.Free; + ms.Position := 0; + + xd := TfsXMLDocument.Create; + xd.LoadFromStream(ms); + ms.Free; + end; + end; + + if xd <> nil then + begin + try + DoProgram(xd.Root, Prog); + finally + xd.Free; + end; + end + else + begin + for i := 0 to xi.Count - 1 do + DoProgram(xi[i], Prog); + end; + + FUnitName := SaveUnitName; +end; + +procedure TfsILParser.DoVar(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + i: Integer; + Name: String; +begin + for i := 0 to xi.Count - 1 do + begin + ErrorPos(xi[i]); + if CompareText(xi[i].Name, 'ident') = 0 then + begin + Name := xi[i].Prop['text']; + CheckIdent(Prog, Name); + Prog.Add(Name, CreateVar(xi, Prog, Name, Statement)); + end; + end; +end; + +procedure TfsILParser.DoConst(xi: TfsXMLItem; Prog: TfsScript); +var + Name: String; + Expr: TfsExpression; + v: TfsVariable; +begin + Name := xi[0].Prop['text']; + ErrorPos(xi[0]); + CheckIdent(Prog, Name); + + Expr := DoExpression(xi[1], Prog); + v := TfsVariable.Create(Name, Expr.Typ, Expr.TypeName); + v.Value := Expr.Value; + v.IsReadOnly := True; + Expr.Free; + + Prog.Add(Name, v); +end; + +procedure TfsILParser.DoParameters(xi: TfsXMLItem; v: TfsProcVariable); +var + i: Integer; + s: String; + varParams: Boolean; + + procedure DoParam(xi: TfsXMLItem); + var + i: Integer; + Name: String; + Param: TfsParamItem; + varParam: Boolean; + begin + varParam := False; + + for i := 0 to xi.Count - 1 do + begin + ErrorPos(xi[i]); + if CompareText(xi[i].Name, 'varparam') = 0 then + varParam := True + else if CompareText(xi[i].Name, 'ident') = 0 then + begin + Name := xi[i].Prop['text']; + CheckIdent(v.Prog, Name); + Param := TfsParamItem(CreateVar(xi, v.Prog, Name, nil, True, + varParams or VarParam)); + Param.DefValue := Param.Value; + v.Add(Param); + v.Prog.Add(Name, Param); + varParam := False; + end; + end; + end; + +begin + if CompareText(xi.Name, 'parameters') <> 0 then Exit; + + varParams := False; + for i := 0 to xi.Count - 1 do + begin + s := LowerCase(xi[i].Name); + if s = 'varparams' then + varParams := True + else if s = 'var' then + begin + DoParam(xi[i]); + varParams := False; + end; + end; +end; + +procedure TfsILParser.DoProc1(xi: TfsXMLItem; Prog: TfsScript); +var + i: Integer; + s, Name: String; + Proc: TfsProcVariable; +begin + ErrorPos(xi[0]); + Name := xi[0].Prop['text']; + CheckIdent(Prog, Name); + + Proc := TfsProcVariable.Create(Name, fvtInt, '', Prog, False); + Proc.SourcePos := PropPos(xi); + Proc.SourceUnit := FUnitName; + Prog.Add(Name, Proc); + + for i := 0 to xi.Count - 1 do + begin + s := LowerCase(xi[i].Name); + if s = 'parameters' then + DoParameters(xi[i], Proc); + end; +end; + +procedure TfsILParser.DoProc2(xi: TfsXMLItem; Prog: TfsScript); +var + Name: String; + Proc: TfsProcVariable; +begin + Name := xi[0].Prop['text']; + Proc := TfsProcVariable(FindVar(Prog, Name)); + DoProgram(xi, Proc.Prog); +end; + +procedure TfsILParser.DoFunc1(xi: TfsXMLItem; Prog: TfsScript); +var + i: Integer; + s, Name, TypeName: String; + Typ: TfsVarType; + Func: TfsProcVariable; +begin + Name := ''; + TypeName := ''; + Typ := fvtVariant; + + for i := 0 to xi.Count - 1 do + begin + ErrorPos(xi[i]); + s := LowerCase(xi[i].Name); + if s = 'type' then + begin + TypeName := xi[i].Prop['text']; + Typ := FindType(TypeName); + end + else if s = 'name' then + begin + Name := xi[i].Prop['text']; + CheckIdent(Prog, Name); + end + end; + + Func := TfsProcVariable.Create(Name, Typ, TypeName, Prog, + CompareText(TypeName, 'void') <> 0); + Func.SourcePos := PropPos(xi); + Func.SourceUnit := FUnitName; + Prog.Add(Name, Func); + + for i := 0 to xi.Count - 1 do + begin + s := LowerCase(xi[i].Name); + if s = 'parameters' then + DoParameters(xi[i], Func); + end; +end; + +procedure TfsILParser.DoFunc2(xi: TfsXMLItem; Prog: TfsScript); +var + i: Integer; + s, Name: String; + Func: TfsProcVariable; +begin + Name := ''; + + for i := 0 to xi.Count - 1 do + begin + s := LowerCase(xi[i].Name); + if s = 'name' then + Name := xi[i].Prop['text']; + end; + + Func := TfsProcVariable(FindVar(Prog, Name)); + DoProgram(xi, Func.Prog); +end; + +procedure TfsILParser.DoAssign(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + i: Integer; + Stmt: TfsAssignmentStmt; + Designator: TfsDesignator; + Expression: TfsExpression; + Modificator: String; +begin + Designator := nil; + Expression := nil; + + try + Modificator := ' '; + Designator := DoDesignator(xi[0], Prog); + + i := 1; + if CompareText(xi[1].Name, 'modificator') = 0 then + begin + Modificator := xi[1].Prop['text']; + Inc(i); + end; + Expression := DoExpression(xi[i], Prog); + + if Designator.IsReadOnly then + raise Exception.Create(SLeftCantAssigned); + + CheckTypeCompatibility(Designator, Expression); + if Modificator = ' ' then + Modificator := Expression.Optimize(Designator); + except + on e: Exception do + begin + if Designator <> nil then + Designator.Free; + if Expression <> nil then + Expression.Free; + raise; + end; + end; + + case Modificator[1] of + '+': + Stmt := TfsAssignPlusStmt.Create(Prog, FUnitName, PropPos(xi)); + '-': + Stmt := TfsAssignMinusStmt.Create(Prog, FUnitName, PropPos(xi)); + '*': + Stmt := TfsAssignMulStmt.Create(Prog, FUnitName, PropPos(xi)); + '/': + Stmt := TfsAssignDivStmt.Create(Prog, FUnitName, PropPos(xi)); + else + Stmt := TfsAssignmentStmt.Create(Prog, FUnitName, PropPos(xi)); + end; + + Statement.Add(Stmt); + Stmt.Designator := Designator; + Stmt.Expression := Expression; + Stmt.Optimize; + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoCall(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + Stmt: TfsCallStmt; +begin + Stmt := TfsCallStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + Stmt.Designator := DoDesignator(xi[0], Prog); + if xi.Count > 1 then + begin + Stmt.Modificator := xi[1].Prop['text']; + if Stmt.Designator.IsReadOnly then + raise Exception.Create(SLeftCantAssigned); + end; + + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoIf(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + i: Integer; + s: String; + Stmt: TfsIfStmt; +begin + Stmt := TfsIfStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + Stmt.Condition := DoExpression(xi[0], Prog); + + for i := 1 to xi.Count - 1 do + begin + s := Lowercase(xi[i].Name); + if s = 'thenstmt' then + DoCompoundStmt(xi[1], Prog, Stmt) + else if s = 'elsestmt' then + DoCompoundStmt(xi[2], Prog, Stmt.ElseStmt); + end; + + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoFor(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + i: Integer; + Stmt: TfsForStmt; +begin + Stmt := TfsForStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + ErrorPos(xi[0]); + Stmt.Variable := FindVar(Prog, xi[0].Prop['text']); + if not ((Stmt.Variable is TfsVariable) and + (Stmt.Variable.Typ in [fvtInt, fvtVariant, fvtFloat])) then + raise Exception.Create(SForError); + + Stmt.BeginValue := DoExpression(xi[1], Prog); + CheckTypeCompatibility(Stmt.Variable, Stmt.BeginValue); + + i := 2; + if CompareText(xi[2].Name, 'downto') = 0 then + begin + Stmt.Down := True; + Inc(i); + end; + + Stmt.EndValue := DoExpression(xi[i], Prog); + CheckTypeCompatibility(Stmt.Variable, Stmt.EndValue); + if i + 1 < xi.Count then + DoStmt(xi[i + 1], Prog, Stmt); + + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoVbFor(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + i: Integer; + Stmt: TfsVbForStmt; +begin + Stmt := TfsVbForStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + ErrorPos(xi[0]); + Stmt.Variable := FindVar(Prog, xi[0].Prop['text']); + if not ((Stmt.Variable is TfsVariable) and + (Stmt.Variable.Typ in [fvtInt, fvtVariant, fvtFloat])) then + raise Exception.Create(SForError); + + Stmt.BeginValue := DoExpression(xi[1], Prog); + CheckTypeCompatibility(Stmt.Variable, Stmt.BeginValue); + + Stmt.EndValue := DoExpression(xi[2], Prog); + CheckTypeCompatibility(Stmt.Variable, Stmt.EndValue); + + i := 3; + if i < xi.Count then + if CompareText(xi[i].Name, 'expr') = 0 then + begin + Stmt.Step := DoExpression(xi[i], Prog); + CheckTypeCompatibility(Stmt.Variable, Stmt.Step); + Inc(i); + end; + + if i < xi.Count then + DoStmt(xi[i], Prog, Stmt); + + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoCppFor(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + Stmt: TfsCppForStmt; +begin + Stmt := TfsCppForStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + DoStmt(xi[0], Prog, Stmt.FirstStmt); + Stmt.Expression := DoExpression(xi[1], Prog); + DoStmt(xi[2], Prog, Stmt.SecondStmt); + DoStmt(xi[3], Prog, Stmt); + + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoWhile(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + Stmt: TfsWhileStmt; +begin + Stmt := TfsWhileStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + Stmt.Condition := DoExpression(xi[0], Prog); + if xi.Count > 1 then + DoStmt(xi[1], Prog, Stmt); + + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoRepeat(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + i, j: Integer; + Stmt: TfsRepeatStmt; +begin + Stmt := TfsRepeatStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + + j := xi.Count - 1; + if CompareText(xi[j].Name, 'inverse') = 0 then + begin + Stmt.InverseCondition := True; + Dec(j); + end; + Stmt.Condition := DoExpression(xi[j], Prog); + Dec(j); + + for i := 0 to j do + DoStmt(xi[i], Prog, Stmt); + + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoCase(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + i: Integer; + Stmt: TfsCaseStmt; + + procedure DoCaseSelector(xi: TfsXMLItem); + var + Selector: TfsCaseSelector; + begin + if (CompareText(xi.Name, 'caseselector') <> 0) or (xi.Count <> 2) then Exit; + Selector := TfsCaseSelector.Create(Prog, FUnitName, PropPos(xi)); + Stmt.Add(Selector); + + Selector.SetExpression := DoSet(xi[0], Prog); + DoStmt(xi[1], Prog, Selector); + end; + +begin + Stmt := TfsCaseStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + Stmt.Condition := DoExpression(xi[0], Prog); + + for i := 1 to xi.Count - 1 do + DoCaseSelector(xi[i]); + + if CompareText(xi[xi.Count - 1].Name, 'caseselector') <> 0 then + DoStmt(xi[xi.Count - 1], Prog, Stmt.ElseStmt); + + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoTry(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + i: Integer; + Stmt: TfsTryStmt; +begin + Stmt := TfsTryStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + + for i := 0 to xi.Count - 1 do + if CompareText(xi[i].Name, 'exceptstmt') = 0 then + begin + Stmt.IsExcept := True; + DoCompoundStmt(xi[i], Prog, Stmt.ExceptStmt); + end + else if CompareText(xi[i].Name, 'finallystmt') = 0 then + DoCompoundStmt(xi[i], Prog, Stmt.ExceptStmt) + else + DoStmt(xi[i], Prog, Stmt); + + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoBreak(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + Stmt: TfsBreakStmt; +begin + Stmt := TfsBreakStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoContinue(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + Stmt: TfsContinueStmt; +begin + Stmt := TfsContinueStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoExit(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + Stmt: TfsExitStmt; +begin + Stmt := TfsExitStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoReturn(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + xi1: TfsXMLItem; +begin + if xi.Count = 1 then { "return expr" } + begin + xi1 := TfsXMLItem.Create; + xi1.Name := 'dsgn'; + xi.InsertItem(0, xi1); + with xi1.Add do + begin + Name := 'node'; + Text := 'text="Result" pos="' + xi[1].Prop['pos'] + '"'; + end; + + DoAssign(xi, Prog, Statement); + end; + + DoExit(xi, Prog, Statement); +end; + +procedure TfsILParser.DoWith(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + d: TfsDesignator; + i, n: Integer; + s: String; + v: TfsVariable; + Stmt: TfsWithStmt; + + function CreateUniqueVariable: String; + var + i: Integer; + begin + i := 0; + while (Prog.FindLocal(IntToStr(i)) <> nil) or + (FWithList.IndexOf(IntToStr(i)) <> -1) do + Inc(i); + Result := IntToStr(i); + end; + +begin + n := xi.Count - 1; + + for i := 0 to n - 1 do + begin + d := DoDesignator(xi[i], Prog); + if not ((d.Typ = fvtClass) or (d.Typ = fvtVariant)) then + begin + d.Free; + raise Exception.Create(SClassRequired); + end; + + { create local variable with unique name } + s := CreateUniqueVariable; + v := TfsVariable.Create(s, d.Typ, d.TypeName); + Prog.Add(s, v); + + Stmt := TfsWithStmt.Create(Prog, FUnitName, PropPos(xi)); + Stmt.Variable := v; + Stmt.Designator := d; + Statement.Add(Stmt); + FWithList.AddObject(s, Stmt); + end; + + DoStmt(xi[xi.Count - 1], Prog, Statement); + + for i := 0 to n - 1 do + FWithList.Delete(FWithList.Count - 1); + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoDelete(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + Stmt: TfsCallStmt; +begin + Stmt := TfsCallStmt.Create(Prog, FUnitName, PropPos(xi)); + Statement.Add(Stmt); + Stmt.Designator := DoDesignator(xi[0], Prog, emFree); + FProgram.AddCodeLine(FUnitName, PropPos(xi)); +end; + +procedure TfsILParser.DoCompoundStmt(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + i: Integer; +begin + for i := 0 to xi.Count - 1 do + DoStmt(xi[i], Prog, Statement); +end; + +procedure TfsILParser.DoStmt(xi: TfsXMLItem; Prog: TfsScript; Statement: TfsStatement); +var + s: String; +begin + s := LowerCase(xi.Name); + if s = 'assignstmt' then + DoAssign(xi, Prog, Statement) + else if s = 'callstmt' then + DoCall(xi, Prog, Statement) + else if s = 'ifstmt' then + DoIf(xi, Prog, Statement) + else if s = 'casestmt' then + DoCase(xi, Prog, Statement) + else if s = 'forstmt' then + DoFor(xi, Prog, Statement) + else if s = 'vbforstmt' then + DoVbFor(xi, Prog, Statement) + else if s = 'cppforstmt' then + DoCppFor(xi, Prog, Statement) + else if s = 'whilestmt' then + DoWhile(xi, Prog, Statement) + else if s = 'repeatstmt' then + DoRepeat(xi, Prog, Statement) + else if s = 'trystmt' then + DoTry(xi, Prog, Statement) + else if s = 'break' then + DoBreak(xi, Prog, Statement) + else if s = 'continue' then + DoContinue(xi, Prog, Statement) + else if s = 'exit' then + DoExit(xi, Prog, Statement) + else if s = 'return' then + DoReturn(xi, Prog, Statement) + else if s = 'with' then + DoWith(xi, Prog, Statement) + else if s = 'delete' then + DoDelete(xi, Prog, Statement) + else if s = 'compoundstmt' then + DoCompoundStmt(xi, Prog, Statement) + else if s = 'uses' then + DoUses(xi, Prog) + else if s = 'var' then + DoVar(xi, Prog, Statement) + else if s = 'const' then + DoConst(xi, Prog) + else if s = 'procedure' then + DoProc2(xi, Prog) + else if s = 'function' then + DoFunc2(xi, Prog) +end; + +procedure TfsILParser.DoProgram(xi: TfsXMLItem; Prog: TfsScript); +var + TempRoot: TfsXMLItem; + + procedure DoFirstPass(xi: TfsXMLItem); + var + i: Integer; + s: String; + begin + for i := 0 to xi.Count - 1 do + begin + s := LowerCase(xi[i].Name); + if s = 'compoundstmt' then + DoFirstPass(xi[i]) + else if s = 'procedure' then + DoProc1(xi[i], Prog) + else if s = 'function' then + DoFunc1(xi[i], Prog) + end; + end; + +begin + TempRoot := FProgRoot; + FProgRoot := xi; + DoFirstPass(xi); + DoCompoundStmt(xi, Prog, Prog.Statement); + FProgRoot := TempRoot; +end; + + +end. diff --git a/official/4.2/LibD11/fs_iinirtti.pas b/official/4.2/LibD11/fs_iinirtti.pas new file mode 100644 index 0000000..5d060a4 --- /dev/null +++ b/official/4.2/LibD11/fs_iinirtti.pas @@ -0,0 +1,327 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ IniFiles.pas classes and functions } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{ Copyright (c) 2004-2006 } +{ by Stalker SoftWare } +{ } +{******************************************} + +unit fs_iinirtti; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_iinterpreter, IniFiles; + +type + TfsIniRTTI = class(TComponent); // fake component + + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; const PropName: String): Variant; + procedure SaveIniFileToStream(oIniFile: TCustomIniFile; oStream: TStream); + procedure LoadIniFileFromStream(oIniFile :TCustomIniFile; oStream :TStream); + public + constructor Create(AScript: TfsScript); override; + end; + + +{ TFunctions } + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + + with AScript do + begin + with AddClass(TCustomIniFile, 'TObject') do + begin + AddConstructor('constructor Create(const FileName: String)', CallMethod); + AddMethod('function ReadInteger(const Section, Ident: String; Default: LongInt): LongInt', CallMethod); + AddMethod('procedure WriteInteger(const Section, Ident: String; Value: LongInt)', CallMethod); + AddMethod('function ReadBool(const Section, Ident: String; Default: Boolean): Boolean', CallMethod); + AddMethod('procedure WriteBool(const Section, Ident: String; Value: Boolean)', CallMethod); + AddMethod('function ReadDate(const Section, Name: String; Default: TDateTime): TDateTime', CallMethod); + AddMethod('procedure WriteDate(const Section, Name: String; Value: TDateTime)', CallMethod); + AddMethod('function ReadDateTime(const Section, Name: String; Default: TDateTime): TDateTime', CallMethod); + AddMethod('procedure WriteDateTime(const Section, Name: String; Value: TDateTime)', CallMethod); + AddMethod('function ReadFloat(const Section, Name: String; Default: Double): Double', CallMethod); + AddMethod('procedure WriteFloat(const Section, Name: String; Value: Double)', CallMethod); + AddMethod('function ReadTime(const Section, Name: String; Default: TDateTime): TDateTime', CallMethod); + AddMethod('procedure WriteTime(const Section, Name: String; Value: TDateTime);', CallMethod); +{$IFDEF DELPHI6} + AddMethod('function ReadBinaryStream(const Section, Name: String; Value: TStream): Integer', CallMethod); + AddMethod('procedure WriteBinaryStream(const Section, Name: String; Value: TStream)', CallMethod); +{$ENDIF} + AddMethod('function SectionExists(const Section: String): Boolean', CallMethod); + AddMethod('function ValueExists(const Section, Ident: String): Boolean', CallMethod); + + AddProperty('FileName', 'String', GetProp); + end; + + with AddClass(TMemIniFile, 'TCustomIniFile') do + begin + AddConstructor('constructor Create(const FileName: String)', CallMethod); + AddMethod('procedure WriteString(const Section, Ident, Value: String)', CallMethod); + AddMethod('function ReadString(const Section, Ident, Default: String): String;', CallMethod); +{$IFDEF DELPHI6} + AddMethod('procedure ReadSectionValuesEx(const Section: String; Strings: TStrings)', CallMethod); +{$ENDIF} + AddMethod('procedure DeleteKey(const Section, Ident: String)', CallMethod); + AddMethod('procedure ReadSection(const Section: String; Strings: TStrings)', CallMethod); + AddMethod('procedure ReadSections(Strings: TStrings)', CallMethod); + AddMethod('procedure ReadSectionValues(const Section: String; Strings: TStrings)', CallMethod); + AddMethod('procedure EraseSection(const Section: String)', CallMethod); + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure GetStrings(List: TStrings)', CallMethod); + AddMethod('procedure SetStrings(List: TStrings)', CallMethod); + AddMethod('procedure SaveIniFileToStream(oStream: TStream)', CallMethod); + AddMethod('procedure LoadIniFileFromStream(oStream: TStream)', CallMethod); + end; + + with AddClass(TIniFile, 'TCustomIniFile') do + begin + AddMethod('procedure WriteString(const Section, Ident, Value: String)', CallMethod); + AddMethod('function ReadString(const Section, Ident, Default: String): String;', CallMethod); +{$IFDEF DELPHI6} + AddMethod('procedure ReadSectionValuesEx(const Section: String; Strings: TStrings)', CallMethod); +{$ENDIF} + AddMethod('procedure DeleteKey(const Section, Ident: String)', CallMethod); + AddMethod('procedure ReadSection(const Section: String; Strings: TStrings)', CallMethod); + AddMethod('procedure ReadSections(Strings: TStrings)', CallMethod); + AddMethod('procedure ReadSectionValues(const Section: String; Strings: TStrings)', CallMethod); + AddMethod('procedure EraseSection(const Section: String)', CallMethod); + AddMethod('procedure SaveIniFileToStream(oStream: TStream)', CallMethod); + AddMethod('procedure LoadIniFileFromStream(oStream: TStream)', CallMethod); + end; + + end; + +end; + +{$HINTS OFF} +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; const MethodName: String; Caller: TfsMethodHelper): Variant; +var + oCustomIniFile: TCustomIniFile; + oMemIniFile: TMemIniFile; + oIniFile: TIniFile; + oList: TStrings; + nCou: Integer; + +begin + + Result := 0; + + if ClassType = TCustomIniFile then + begin + oCustomIniFile := TCustomIniFile(Instance); + if MethodName = 'CREATE' then + Result := Integer(oCustomIniFile.Create(Caller.Params[0])) + else if MethodName = 'WRITEINTEGER' then + oCustomIniFile.WriteInteger(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'READINTEGER' then + Result := oCustomIniFile.ReadInteger(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'WRITEBOOL' then + oCustomIniFile.WriteBool(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'READBOOL' then + Result := oCustomIniFile.ReadBool(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'WRITEDATE' then + oCustomIniFile.WriteDate(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'READDATE' then + Result := oCustomIniFile.ReadDate(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'WRITEDATETIME' then + oCustomIniFile.WriteDateTime(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'READDATETIME' then + Result := oCustomIniFile.ReadDateTime(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'WRITEFLOAT' then + oCustomIniFile.WriteFloat(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'READFLOAT' then + Result := oCustomIniFile.ReadFloat(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'WRITETIME' then + oCustomIniFile.WriteTime(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'READTIME' then + Result := oCustomIniFile.ReadTime(Caller.Params[0], Caller.Params[1], Caller.Params[2]) +{$IFDEF DELPHI6} + else if MethodName = 'WRITEBINARYSTREAM' then + oCustomIniFile.WriteBinaryStream(Caller.Params[0], Caller.Params[1], TStream(Integer(Caller.Params[2]))) + else if MethodName = 'READBINARYSTREAM' then + Result := oCustomIniFile.ReadBinaryStream(Caller.Params[0], Caller.Params[1], TStream(Integer(Caller.Params[2]))) +{$ENDIF} + else if MethodName = 'SECTIONEXISTS' then + Result := oCustomIniFile.SectionExists(Caller.Params[0]) + else if MethodName = 'VALUEEXISTS' then + Result := oCustomIniFile.ValueExists(Caller.Params[0], Caller.Params[1]) + end; + + if ClassType = TMemIniFile then + begin + oMemIniFile := TMemIniFile(Instance); + if MethodName = 'CREATE' then + Result := Integer(oMemIniFile.Create(Caller.Params[0])) + else if MethodName = 'WRITESTRING' then + oMemIniFile.WriteString(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'READSTRING' then + Result := oMemIniFile.ReadString(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'DELETEKEY' then + oMemIniFile.DeleteKey(Caller.Params[0], Caller.Params[1]) + else if MethodName = 'READSECTION' then + oMemIniFile.ReadSection(Caller.Params[0], TStrings(Integer(Caller.Params[1]))) + else if MethodName = 'READSECTIONS' then + oMemIniFile.ReadSections(TStrings(Integer(Caller.Params[0]))) + else if MethodName = 'READSECTIONVALUES' then + oMemIniFile.ReadSectionValues(Caller.Params[0], TStrings(Integer(Caller.Params[1]))) + else if MethodName = 'ERASESECTION' then + oMemIniFile.EraseSection(Caller.Params[0]) +{$IFDEF DELPHI6} + else if MethodName = 'READSECTIONVALUESEX' then + begin + oList := TStringList.Create; + try + oMemIniFile.ReadSectionValues(Caller.Params[0], oList); + TStrings(Integer(Caller.Params[1])).Clear; + for nCou := 0 to oList.Count-1 do +// TStrings(Integer(Caller.Params[1])).Add(oList.ValueFromIndex[nCou]); + TStrings(Integer(Caller.Params[1])).Add(oList.Values[oList.Names[nCou]]); + finally + oList.Free; + end; + end +{$ENDIF} + else if MethodName = 'CLEAR' then + oMemIniFile.Clear + else if MethodName = 'GETSTRINGS' then + oMemIniFile.GetStrings(TStrings(Integer(Caller.Params[0]))) + else if MethodName = 'SETSTRINGS' then + oMemIniFile.SetStrings(TStrings(Integer(Caller.Params[0]))) + else if MethodName = 'SAVEINIFILETOSTREAM' then + SaveIniFileToStream(oMemIniFile, TStream(Integer(Caller.Params[0]))) + else if MethodName = 'LOADINIFILEFROMSTREAM' then + LoadIniFileFromStream(oMemIniFile, TStream(Integer(Caller.Params[0]))) + end; + + if ClassType = TIniFile then + begin + oIniFile := TIniFile(Instance); + if MethodName = 'WRITESTRING' then + oIniFile.WriteString(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'READSTRING' then + Result := oIniFile.ReadString(Caller.Params[0], Caller.Params[1], Caller.Params[2]) + else if MethodName = 'DELETEKEY' then + oIniFile.DeleteKey(Caller.Params[0], Caller.Params[1]) + else if MethodName = 'READSECTION' then + oIniFile.ReadSection(Caller.Params[0], TStrings(Integer(Caller.Params[1]))) + else if MethodName = 'READSECTIONS' then + oIniFile.ReadSections(TStrings(Integer(Caller.Params[0]))) + else if MethodName = 'READSECTIONVALUES' then + oIniFile.ReadSectionValues(Caller.Params[0], TStrings(Integer(Caller.Params[1]))) + else if MethodName = 'ERASESECTION' then + oIniFile.EraseSection(Caller.Params[0]) +{$IFDEF DELPHI6} + else if MethodName = 'READSECTIONVALUESEX' then + begin + oList := TStringList.Create; + try + oIniFile.ReadSectionValues(Caller.Params[0], oList); + TStrings(Integer(Caller.Params[1])).Clear; + for nCou := 0 to oList.Count-1 do +// TStrings(Integer(Caller.Params[1])).Add(oList.ValueFromIndex[nCou]); + TStrings(Integer(Caller.Params[1])).Add(oList.Values[oList.Names[nCou]]); + finally + oList.Free; + end; + end +{$ENDIF} + else if MethodName = 'SAVEINIFILETOSTREAM' then + SaveIniFileToStream(oIniFile, TStream(Integer(Caller.Params[0]))) + else if MethodName = 'LOADINIFILEFROMSTREAM' then + LoadIniFileFromStream(oIniFile, TStream(Integer(Caller.Params[0]))) + end; + +end; +{$HINTS ON} + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; const PropName: String): Variant; +begin + Result := 0; + + if ClassType = TCustomIniFile then + begin + if PropName = 'FILENAME' then + Result := TIniFile(Instance).FileName + end; +end; + +procedure TFunctions.SaveIniFileToStream(oIniFile :TCustomIniFile; oStream :TStream); +var + oStrings :TStrings; + +begin + + if (not Assigned(oIniFile)) or (not Assigned(oStream)) then Exit; + + if not ((oIniFile is TIniFile) or (oIniFile is TMemIniFile)) then Exit; + + oStrings:= TStringList.Create; + try + + if oIniFile is TIniFile then + oStrings.LoadFromFile(oIniFile.FileName) + else + if oIniFile is TMemIniFile then + TMemIniFile(oIniFile).GetStrings(oStrings); + + oStrings.SaveToStream(oStream); + + finally + oStrings.Free; + end; + +end; + +procedure TFunctions.LoadIniFileFromStream(oIniFile :TCustomIniFile; oStream :TStream); +var + oStrings :TStrings; + +begin + + if (not Assigned(oIniFile)) or (not Assigned(oStream)) then Exit; + + if not ((oIniFile is TIniFile) or (oIniFile is TMemIniFile)) then Exit; + + oStrings:= TStringList.Create; + try + + oStrings.LoadFromStream(oStream); + + if oIniFile is TIniFile then + oStrings.SaveToFile(oIniFile.FileName) + else + if oIniFile is TMemIniFile then + TMemIniFile(oIniFile).SetStrings(oStrings); + + finally + oStrings.Free; + end; + +end; + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + fsRTTIModules.Remove(TFunctions); + +end. diff --git a/official/4.2/LibD11/fs_iinterpreter.pas b/official/4.2/LibD11/fs_iinterpreter.pas new file mode 100644 index 0000000..2c75585 --- /dev/null +++ b/official/4.2/LibD11/fs_iinterpreter.pas @@ -0,0 +1,3128 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Main module } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iinterpreter; + +interface + +{$I fs.inc} + +uses + SysUtils, Classes, fs_xml +{$IFDEF Delphi6} +, Variants +{$ENDIF} + +, SyncObjs; + + +type + TfsStatement = class; + TfsDesignator = class; + TfsCustomVariable = class; + TfsClassVariable = class; + TfsProcVariable = class; + TfsMethodHelper = class; + TfsScript = class; + +{ List of supported types. Actually all values are variants; types needed + only to know what kind of operations can be implemented to the variable } + + TfsVarType = (fvtInt, fvtBool, fvtFloat, fvtChar, fvtString, fvtClass, + fvtArray, fvtVariant, fvtEnum, fvtConstructor); + + TfsTypeRec = packed record + Typ: TfsVarType; + TypeName: String[32]; + end; + +{ Events for get/set non-published property values and call methods } + + TfsGetValueEvent = function(Instance: TObject; ClassType: TClass; + const PropName: String): Variant of object; + TfsSetValueEvent = procedure(Instance: TObject; ClassType: TClass; + const PropName: String; Value: Variant) of object; + TfsCallMethodNewEvent = function(Instance: TObject; ClassType: TClass; + const MethodName: String; Caller: TfsMethodHelper): Variant of object; + TfsCallMethodEvent = function(Instance: TObject; ClassType: TClass; + const MethodName: String; var Params: Variant): Variant of object; + TfsRunLineEvent = procedure(Sender: TfsScript; + const UnitName, SourcePos: String) of object; + TfsGetUnitEvent = procedure(Sender: TfsScript; + const UnitName: String; var UnitText: String) of object; + +{ List of objects. Unlike TList, Destructor frees all objects in the list } + + TfsItemList = class(TObject) + protected + FItems: TList; + protected + procedure Clear; virtual; + public + constructor Create; + destructor Destroy; override; + procedure Add(Item: TObject); + function Count: Integer; + procedure Remove(Item: TObject); + end; + + +{ TfsScript represents the main script. It holds the list of local variables, + constants, procedures in the Items. Entry point is the Statement. + + There is one global object fsGlobalUnit: TfsScript that holds all information + about external classes, global variables, methods and constants. To use + such globals, pass fsGlobalUnit to the TfsScript.Create. + If you want, you can add classes/variables/methods to the TfsScript - they + will be local for it and not visible in other programs. + + To execute a program, compile it first by calling Compile method. If error + occurs, the ErrorMsg will contain the error message and ErrorPos will point + to an error position in the source text. For example: + + if not Prg.Compile then + begin + ErrorLabel.Caption := Prg.ErrorMsg; + Memo1.SetFocus; + Memo1.Perform(EM_SETSEL, Prg.ErrorPos - 1, Prg.ErrorPos - 1); + Memo1.Perform(EM_SCROLLCARET, 0, 0); + end; + + If no errors occured, call Execute method to execute the program } + + + TfsScript = class(TComponent) + + private + FAddedBy: TObject; + FBreakCalled: Boolean; + FContinueCalled: Boolean; + FExitCalled: Boolean; + FErrorMsg: String; + FErrorPos: String; + FErrorUnit: String; + FExtendedCharset: Boolean; + FItems: TStringList; + FIsRunning: Boolean; + FLines: TStrings; + FMacros: TStrings; + FMainProg: Boolean; + FOnGetILUnit: TfsGetUnitEvent; + FOnGetUnit: TfsGetUnitEvent; + FOnRunLine: TfsRunLineEvent; + FParent: TfsScript; + FProgRunning: TfsScript; + FRTTIAdded: Boolean; + FStatement: TfsStatement; + FSyntaxType: String; + FTerminated: Boolean; + FUnitLines: TStringList; + function GetItem(Index: Integer): TfsCustomVariable; + procedure RunLine(const UnitName, Index: String); + function GetVariables(Index: String): Variant; + procedure SetVariables(Index: String; const Value: Variant); + procedure SetLines(const Value: TStrings); + + public + constructor Create(AOwner: TComponent); override; + destructor Destroy; override; + procedure Add(const Name: String; Item: TObject); + procedure AddCodeLine(const UnitName, APos: String); + procedure AddRTTI; + procedure Remove(Item: TObject); + procedure RemoveItems(Owner: TObject); + procedure Clear; + procedure ClearItems(Owner: TObject); + procedure ClearRTTI; + function Count: Integer; + + { Adds a class. Example: + with AddClass(TComponent, 'TPersistent') do + begin + ... add properties and methods ... + end } + function AddClass(AClass: TClass; const Ancestor: String): TfsClassVariable; dynamic; + { Adds a constant. Example: + AddConst('pi', 'Double', 3.14159) } + procedure AddConst(const Name, Typ: String; const Value: Variant); dynamic; + { Adds an enumeration constant. Example: + AddEnum('TFontPitch', 'fpDefault, fpFixed, fpVariable') + all constants gets type fvtEnum and values 0,1,2,3.. } + procedure AddEnum(const Typ, Names: String); dynamic; + { Adds an set constant. Example: + AddEnumSet('TFontStyles', 'fsBold, fsItalic, fsUnderline') + all constants gets type fvtEnum and values 1,2,4,8,.. } + procedure AddEnumSet(const Typ, Names: String); dynamic; + { Adds a form or datamodule with all its child components } + procedure AddComponent(Form: TComponent); dynamic; + procedure AddForm(Form: TComponent); dynamic; + { Adds a method. Syntax is the same as for TfsClassVariable.AddMethod } + procedure AddMethod(const Syntax: String; CallEvent: TfsCallMethodNewEvent; + const Category: String = ''; const Description: String = ''); overload; dynamic; + procedure AddMethod(const Syntax: String; CallEvent: TfsCallMethodEvent; + const Category: String = ''; const Description: String = ''); overload; dynamic; + { Adds an external object. Example: + AddObject('Memo1', Memo1) } + procedure AddObject(const Name: String; Obj: TObject); dynamic; + { Adds a variable. Example: + AddVariable('n', 'Variant', 0) } + procedure AddVariable(const Name, Typ: String; const Value: Variant); dynamic; + { Adds a type. Example: + AddType('TDateTime', fvtFloat) } + procedure AddType(const TypeName: String; ParentType: TfsVarType); dynamic; + { Calls internal procedure or function. Example: + val := CallFunction('ScriptFunc1', VarArrayOf([2003, 3])) } + function CallFunction(const Name: String; const Params: Variant): Variant; + function CallFunction1(const Name: String; var Params: Variant): Variant; + function CallFunction2(const Func: TfsProcVariable; const Params: Variant): Variant; + + { Compiles the source code. Example: + Lines.Text := 'begin i := 0 end.'; + SyntaxType := 'PascalScript'; + if Compile then ... } + function Compile: Boolean; + { Executes compiled code } + procedure Execute; + { Same as if Compile then Execute. Returns False if compile failed } + function Run: Boolean; + { terminates the script } + procedure Terminate; + { Evaluates an expression (useful for debugging purposes). Example: + val := Evaluate('i+1'); } + function Evaluate(const Expression: String): Variant; + { checks whether is the line is executable } + function IsExecutableLine(LineN: Integer; const UnitName: String = ''): Boolean; + + { Generates intermediate language. You can save it and compile later + by SetILCode method } + function GetILCode(Stream: TStream): Boolean; + { Compiles intermediate language } + function SetILCode(Stream: TStream): Boolean; + + function Find(const Name: String): TfsCustomVariable; + function FindClass(const Name: String): TfsClassVariable; + function FindLocal(const Name: String): TfsCustomVariable; + + property AddedBy: TObject read FAddedBy write FAddedBy; + property ErrorMsg: String read FErrorMsg write FErrorMsg; + property ErrorPos: String read FErrorPos write FErrorPos; + property ErrorUnit: String read FErrorUnit write FErrorUnit; + property ExtendedCharset: Boolean read FExtendedCharset write FExtendedCharset; + property Items[Index: Integer]: TfsCustomVariable read GetItem; + property IsRunning: Boolean read FIsRunning; + property Macros: TStrings read FMacros; + property MainProg: Boolean read FMainProg write FMainProg; + property Parent: TfsScript read FParent write FParent; + property ProgRunning: TfsScript read FProgRunning; + property Statement: TfsStatement read FStatement; + property Variables[Index: String]: Variant read GetVariables write SetVariables; + published + { the source code } + property Lines: TStrings read FLines write SetLines; + { the language name } + property SyntaxType: String read FSyntaxType write FSyntaxType; + property OnGetILUnit: TfsGetUnitEvent read FOnGetILUnit write FOnGetILUnit; + property OnGetUnit: TfsGetUnitEvent read FOnGetUnit write FOnGetUnit; + property OnRunLine: TfsRunLineEvent read FOnRunLine write FOnRunLine; + end; + + + TfsCustomExpression = class; + TfsSetExpression = class; + +{ Statements } + + TfsStatement = class(TfsItemList) + private + FProgram: TfsScript; + FSourcePos: String; + FUnitName: String; + function GetItem(Index: Integer): TfsStatement; + procedure RunLine; + public + constructor Create(AProgram: TfsScript; const UnitName, SourcePos: String); virtual; + procedure Execute; virtual; + property Items[Index: Integer]: TfsStatement read GetItem; + end; + + TfsAssignmentStmt = class(TfsStatement) + private + FDesignator: TfsDesignator; + FExpression: TfsCustomExpression; + FVar: TfsCustomVariable; + FExpr: TfsCustomVariable; + public + destructor Destroy; override; + procedure Execute; override; + procedure Optimize; + property Designator: TfsDesignator read FDesignator write FDesignator; + property Expression: TfsCustomExpression read FExpression write FExpression; + end; + + TfsAssignPlusStmt = class(TfsAssignmentStmt) + public + procedure Execute; override; + end; + + TfsAssignMinusStmt = class(TfsAssignmentStmt) + public + procedure Execute; override; + end; + + TfsAssignMulStmt = class(TfsAssignmentStmt) + public + procedure Execute; override; + end; + + TfsAssignDivStmt = class(TfsAssignmentStmt) + public + procedure Execute; override; + end; + + TfsCallStmt = class(TfsStatement) + private + FDesignator: TfsDesignator; + FModificator: String; + public + destructor Destroy; override; + procedure Execute; override; + property Designator: TfsDesignator read FDesignator write FDesignator; + property Modificator: String read FModificator write FModificator; + end; + + TfsIfStmt = class(TfsStatement) + private + FCondition: TfsCustomExpression; + FElseStmt: TfsStatement; + public + constructor Create(AProgram: TfsScript; const UnitName, SourcePos: String); override; + destructor Destroy; override; + procedure Execute; override; + property Condition: TfsCustomExpression read FCondition write FCondition; + property ElseStmt: TfsStatement read FElseStmt write FElseStmt; + end; + + TfsCaseSelector = class(TfsStatement) + private + FSetExpression: TfsSetExpression; + public + destructor Destroy; override; + function Check(const Value: Variant): Boolean; + property SetExpression: TfsSetExpression read FSetExpression write FSetExpression; + end; + + TfsCaseStmt = class(TfsStatement) + private + FCondition: TfsCustomExpression; + FElseStmt: TfsStatement; + public + constructor Create(AProgram: TfsScript; const UnitName, SourcePos: String); override; + destructor Destroy; override; + procedure Execute; override; + property Condition: TfsCustomExpression read FCondition write FCondition; + property ElseStmt: TfsStatement read FElseStmt write FElseStmt; + end; + + TfsRepeatStmt = class(TfsStatement) + private + FCondition: TfsCustomExpression; + FInverseCondition: Boolean; + public + destructor Destroy; override; + procedure Execute; override; + property Condition: TfsCustomExpression read FCondition write FCondition; + property InverseCondition: Boolean read FInverseCondition write FInverseCondition; + end; + + TfsWhileStmt = class(TfsStatement) + private + FCondition: TfsCustomExpression; + public + destructor Destroy; override; + procedure Execute; override; + property Condition: TfsCustomExpression read FCondition write FCondition; + end; + + TfsForStmt = class(TfsStatement) + private + FBeginValue: TfsCustomExpression; + FDown: Boolean; + FEndValue: TfsCustomExpression; + FVariable: TfsCustomVariable; + public + destructor Destroy; override; + procedure Execute; override; + property BeginValue: TfsCustomExpression read FBeginValue write FBeginValue; + property Down: Boolean read FDown write FDown; + property EndValue: TfsCustomExpression read FEndValue write FEndValue; + property Variable: TfsCustomVariable read FVariable write FVariable; + end; + + TfsVbForStmt = class(TfsStatement) + private + FBeginValue: TfsCustomExpression; + FEndValue: TfsCustomExpression; + FStep: TfsCustomExpression; + FVariable: TfsCustomVariable; + public + destructor Destroy; override; + procedure Execute; override; + property BeginValue: TfsCustomExpression read FBeginValue write FBeginValue; + property EndValue: TfsCustomExpression read FEndValue write FEndValue; + property Step: TfsCustomExpression read FStep write FStep; + property Variable: TfsCustomVariable read FVariable write FVariable; + end; + + TfsCppForStmt = class(TfsStatement) + private + FFirstStmt: TfsStatement; + FExpression: TfsCustomExpression; + FSecondStmt: TfsStatement; + public + constructor Create(AProgram: TfsScript; const UnitName, SourcePos: String); override; + destructor Destroy; override; + procedure Execute; override; + property FirstStmt: TfsStatement read FFirstStmt write FFirstStmt; + property Expression: TfsCustomExpression read FExpression write FExpression; + property SecondStmt: TfsStatement read FSecondStmt write FSecondStmt; + end; + + TfsTryStmt = class(TfsStatement) + private + FIsExcept: Boolean; + FExceptStmt: TfsStatement; + public + constructor Create(AProgram: TfsScript; const UnitName, SourcePos: String); override; + destructor Destroy; override; + procedure Execute; override; + property IsExcept: Boolean read FIsExcept write FIsExcept; + property ExceptStmt: TfsStatement read FExceptStmt write FExceptStmt; + end; + + TfsBreakStmt = class(TfsStatement) + public + procedure Execute; override; + end; + + TfsContinueStmt = class(TfsStatement) + public + procedure Execute; override; + end; + + TfsExitStmt = class(TfsStatement) + public + procedure Execute; override; + end; + + TfsWithStmt = class(TfsStatement) + private + FDesignator: TfsDesignator; + FVariable: TfsCustomVariable; + public + destructor Destroy; override; + procedure Execute; override; + property Designator: TfsDesignator read FDesignator write FDesignator; + property Variable: TfsCustomVariable read FVariable write FVariable; + end; + +{ TfsCustomVariable is the generic class for variables, constants, arrays, + properties, methods and procedures/functions } + + TfsParamItem = class; + + TfsCustomVariable = class(TfsItemList) + private + FAddedBy: TObject; + FIsMacro: Boolean; + FIsReadOnly: Boolean; + FName: String; + FNeedResult: Boolean; + FRefItem: TfsCustomVariable; + FSourcePos: String; + FSourceUnit: String; + FTyp: TfsVarType; + FTypeName: String; + FUppercaseName: String; + FValue: Variant; + function GetParam(Index: Integer): TfsParamItem; + function GetPValue: PVariant; + protected + procedure SetValue(const Value: Variant); virtual; + function GetValue: Variant; virtual; + public + constructor Create(const AName: String; ATyp: TfsVarType; + const ATypeName: String); + function GetFullTypeName: String; + function GetNumberOfRequiredParams: Integer; + + property AddedBy: TObject read FAddedBy write FAddedBy; + property IsMacro: Boolean read FIsMacro write FIsMacro; + property IsReadOnly: Boolean read FIsReadOnly write FIsReadOnly; + property Name: String read FName; + property NeedResult: Boolean read FNeedResult write FNeedResult; + property Params[Index: Integer]: TfsParamItem read GetParam; default; + property PValue: PVariant read GetPValue; + property RefItem: TfsCustomVariable read FRefItem write FRefItem; + property SourcePos: String read FSourcePos write FSourcePos; + property SourceUnit: String read FSourceUnit write FSourceUnit; + property Typ: TfsVarType read FTyp write FTyp; + property TypeName: String read FTypeName write FTypeName; + property Value: Variant read GetValue write SetValue; + end; + +{ TfsVariable represents constant or variable } + + TfsVariable = class(TfsCustomVariable) + end; + + TfsTypeVariable = class(TfsCustomVariable) + end; + + TfsStringVariable = class(TfsVariable) + private + FStr: String; + protected + procedure SetValue(const Value: Variant); override; + function GetValue: Variant; override; + end; + +{ TfsParamItem describes one parameter of procedure/function/method call } + + TfsParamItem = class(TfsCustomVariable) + private + FDefValue: Variant; + FIsOptional: Boolean; + FIsVarParam: Boolean; + public + constructor Create(const AName: String; ATyp: TfsVarType; + const ATypeName: String; AIsOptional, AIsVarParam: Boolean); + property DefValue: Variant read FDefValue write FDefValue; + property IsOptional: Boolean read FIsOptional; + property IsVarParam: Boolean read FIsVarParam; + end; + +{ TfsProcVariable is a local internal procedure/function. Formal parameters + are in Params, and statement to execute is in Prog: TfsScript } + + TfsProcVariable = class(TfsCustomVariable) + private + FExecuting: Boolean; + FIsFunc: Boolean; + FProgram: TfsScript; + protected + function GetValue: Variant; override; + public + constructor Create(const AName: String; ATyp: TfsVarType; + const ATypeName: String; AParent: TfsScript; AIsFunc: Boolean = True); + destructor Destroy; override; + + property Executing: Boolean read FExecuting; + property IsFunc: Boolean read FIsFunc; + property Prog: TfsScript read FProgram; + end; + + TfsCustomExpression = class(TfsCustomVariable) + end; + +{ TfsCustomHelper is the generic class for the "helpers". Helper is + a object that takes the data from the parent object and performs some + actions. Helpers needed for properties, methods and arrays } + + TfsCustomHelper = class(TfsCustomVariable) + private + FParentRef: TfsCustomVariable; + FParentValue: Variant; + FProgram: TfsScript; + public + property ParentRef: TfsCustomVariable read FParentRef write FParentRef; + + property ParentValue: Variant read FParentValue write FParentValue; + + property Prog: TfsScript read FProgram write FProgram; + end; + +{ TfsArrayHelper performs access to array elements } + + TfsArrayHelper = class(TfsCustomHelper) + protected + procedure SetValue(const Value: Variant); override; + function GetValue: Variant; override; + public + constructor Create(const AName: String; DimCount: Integer; Typ: TfsVarType; + const TypeName: String); + destructor Destroy; override; + end; + +{ TfsStringHelper performs access to string elements } + + TfsStringHelper = class(TfsCustomHelper) + protected + procedure SetValue(const Value: Variant); override; + function GetValue: Variant; override; + public + constructor Create; + end; + +{ TfsPropertyHelper gets/sets the property value. Object instance is + stored as Integer in the ParentValue property } + + TfsPropertyHelper = class(TfsCustomHelper) + private + FClassRef: TClass; + FIsPublished: Boolean; + FOnGetValue: TfsGetValueEvent; + FOnSetValue: TfsSetValueEvent; + protected + procedure SetValue(const Value: Variant); override; + function GetValue: Variant; override; + public + property IsPublished: Boolean read FIsPublished; + property OnGetValue: TfsGetValueEvent read FOnGetValue write FOnGetValue; + property OnSetValue: TfsSetValueEvent read FOnSetValue write FOnSetValue; + end; + +{ TfsMethodHelper gets/sets the method value. Object instance is + stored as Integer in the ParentValue property. SetValue is called + if the method represents the indexes property. } + + TfsMethodHelper = class(TfsCustomHelper) + private + FCategory: String; + FClassRef: TClass; + FDescription: String; + FIndexMethod: Boolean; + FOnCall: TfsCallMethodEvent; + FOnCallNew: TfsCallMethodNewEvent; + FSetValue: Variant; + FSyntax: String; + FVarArray: Variant; + function GetVParam(Index: Integer): Variant; + procedure SetVParam(Index: Integer; const Value: Variant); + protected + procedure SetValue(const Value: Variant); override; + function GetValue: Variant; override; + public + constructor Create(const Syntax: String; Script: TfsScript); + destructor Destroy; override; + + property Category: String read FCategory write FCategory; + property Description: String read FDescription write FDescription; + property IndexMethod: Boolean read FIndexMethod; + property Params[Index: Integer]: Variant read GetVParam write SetVParam; default; + property Syntax: String read FSyntax; + property OnCall: TfsCallMethodEvent read FOnCall write FOnCall; + property OnCallNew: TfsCallMethodNewEvent read FOnCallNew write FOnCallNew; + end; + +{ TfsComponentHelper gets the component inside an owner, e.g. Form1.Button1 } + + TfsComponentHelper = class(TfsCustomHelper) + private + FComponent: TComponent; + protected + function GetValue: Variant; override; + public + constructor Create(Component: TComponent); + end; + +{ Event helper maintains VCL events } + + TfsCustomEvent = class(TObject) + private + FHandler: TfsProcVariable; + FInstance: TObject; + protected + procedure CallHandler(Params: array of const); + public + constructor Create(AObject: TObject; AHandler: TfsProcVariable); virtual; + function GetMethod: Pointer; virtual; abstract; + property Handler: TfsProcVariable read FHandler; + property Instance: TObject read FInstance; + end; + + TfsEventClass = class of TfsCustomEvent; + + TfsEventHelper = class(TfsCustomHelper) + private + FClassRef: TClass; + FEvent: TfsEventClass; + protected + procedure SetValue(const Value: Variant); override; + function GetValue: Variant; override; + public + constructor Create(const Name: String; AEvent: TfsEventClass); + end; + +{ TfsClassVariable holds information about external class. Call to + AddXXX methods adds properties and methods items to the items list } + + TfsClassVariable = class(TfsCustomVariable) + private + FAncestor: String; + FClassRef: TClass; + FDefProperty: TfsCustomHelper; + FMembers: TfsItemList; + FProgram: TfsScript; + procedure AddComponent(c: TComponent); + procedure AddPublishedProperties(AClass: TClass); + function GetMembers(Index: Integer): TfsCustomHelper; + function GetMembersCount: Integer; + protected + function GetValue: Variant; override; + public + constructor Create(AClass: TClass; const Ancestor: String); + destructor Destroy; override; + + { Adds a contructor. Example: + AddConstructor('constructor Create(AOwner: TComponent)', MyCallEvent) } + procedure AddConstructor(Syntax: String; CallEvent: TfsCallMethodNewEvent); overload; + procedure AddConstructor(Syntax: String; CallEvent: TfsCallMethodEvent); overload; + { Adds a property. Example: + AddProperty('Font', 'TFont', MyGetEvent, MySetEvent) } + procedure AddProperty(const Name, Typ: String; + GetEvent: TfsGetValueEvent; SetEvent: TfsSetValueEvent = nil); + { Adds a default property. Example: + AddDefaultProperty('Cell', 'Integer,Integer', 'String', MyCallEvent) + will describe real property Cell[Index1, Index2: Integer]: String + Note: in the CallEvent you'll get the MethodName parameter + 'CELL.GET' and 'CELL.SET', not 'CELL' } + procedure AddDefaultProperty(const Name, Params, Typ: String; + CallEvent: TfsCallMethodNewEvent; AReadOnly: Boolean = False); overload; + procedure AddDefaultProperty(const Name, Params, Typ: String; + CallEvent: TfsCallMethodEvent; AReadOnly: Boolean = False); overload; + { Adds an indexed property. Example and behavior are the same as + for AddDefaultProperty } + procedure AddIndexProperty(const Name, Params, Typ: String; + CallEvent: TfsCallMethodNewEvent; AReadOnly: Boolean = False); overload; + procedure AddIndexProperty(const Name, Params, Typ: String; + CallEvent: TfsCallMethodEvent; AReadOnly: Boolean = False); overload; + { Adds a method. Example: + AddMethod('function IsVisible: Boolean', MyCallEvent) } + procedure AddMethod(const Syntax: String; CallEvent: TfsCallMethodNewEvent); overload; + procedure AddMethod(const Syntax: String; CallEvent: TfsCallMethodEvent); overload; + { Adds an event. Example: + AddEvent('OnClick', TfsNotifyEvent) } + procedure AddEvent(const Name: String; AEvent: TfsEventClass); + function Find(const Name: String): TfsCustomHelper; + + property Ancestor: String read FAncestor; + property ClassRef: TClass read FClassRef; + property DefProperty: TfsCustomHelper read FDefProperty; + property Members[Index: Integer]: TfsCustomHelper read GetMembers; + property MembersCount: Integer read GetMembersCount; + end; + +{ TfsDesignator holds the parts of function/procedure/variable/method/property + calls. Items are of type TfsDesignatorItem. + For example, Table1.FieldByName('N').AsString[1] will be represented as + items[0]: name 'Table1', no params + items[1]: name 'FieldByName', 1 param: 'N' + items[2]: name 'AsString', no params + items[3]: name '[', 1 param: '1' + Call to Value calculates and returns the designator value } + + TfsDesignatorKind = (dkOther, dkVariable, dkStringArray, dkArray); + + TfsDesignatorItem = class(TfsItemList) + private + FFlag: Boolean; { needed for index methods } + FRef: TfsCustomVariable; + FSourcePos: String; + function GetItem(Index: Integer): TfsCustomExpression; + public + property Items[Index: Integer]: TfsCustomExpression read GetItem; default; + property Flag: Boolean read FFlag write FFlag; + property Ref: TfsCustomVariable read FRef write FRef; + property SourcePos: String read FSourcePos write FSourcePos; + end; + + TfsDesignator = class(TfsCustomVariable) + private + FKind: TfsDesignatorKind; + FMainProg: TfsScript; + FProgram: TfsScript; + FRef1: TfsCustomVariable; + FRef2: TfsDesignatorItem; + FLateBindingXmlSource: TfsXMLItem; + procedure CheckLateBinding; + function DoCalc(const AValue: Variant; Flag: Boolean): Variant; + function GetItem(Index: Integer): TfsDesignatorItem; + protected + function GetValue: Variant; override; + procedure SetValue(const Value: Variant); override; + public + constructor Create(AProgram: TfsScript); + destructor Destroy; override; + procedure Borrow(ADesignator: TfsDesignator); + procedure Finalize; + property Items[Index: Integer]: TfsDesignatorItem read GetItem; default; + property Kind: TfsDesignatorKind read FKind; + property LateBindingXmlSource: TfsXMLItem read FLateBindingXmlSource + write FLateBindingXmlSource; + end; + + TfsVariableDesignator = class(TfsDesignator) + protected + function GetValue: Variant; override; + procedure SetValue(const Value: Variant); override; + end; + + TfsStringDesignator = class(TfsDesignator) + protected + function GetValue: Variant; override; + procedure SetValue(const Value: Variant); override; + end; + + TfsArrayDesignator = class(TfsDesignator) + protected + function GetValue: Variant; override; + procedure SetValue(const Value: Variant); override; + end; + +{ TfsSetExpression represents a set of values like ['_', '0'..'9'] } + + TfsSetExpression = class(TfsCustomVariable) + private + function GetItem(Index: Integer): TfsCustomExpression; + protected + function GetValue: Variant; override; + public + function Check(const Value: Variant): Boolean; + property Items[Index: Integer]: TfsCustomExpression read GetItem; + end; + + TfsRTTIModule = class(TObject) + private + FScript: TfsScript; + public + constructor Create(AScript: TfsScript); virtual; + property Script: TfsScript read FScript; + end; + + +function fsGlobalUnit: TfsScript; +function fsRTTIModules: TList; + + +implementation + +uses + TypInfo, fs_isysrtti, fs_iexpression, fs_iparser, fs_iilparser, + fs_itools, fs_iconst +{$IFDEF CLX} +, QForms, QDialogs, Types +{$ELSE} + {$IFDEF FPC} + {$IFDEF NOFORMS} + .TODO. + {$ELSE} + , Forms, Dialogs + {$ENDIF} + {$ELSE} + , Windows + {$IFDEF NOFORMS} + , Messages + {$ELSE} + , Forms, Dialogs + {$ENDIF} + {$ENDIF} +{$ENDIF}; + +var + FGlobalUnit: TfsScript = nil; + FGlobalUnitDestroyed: Boolean = False; + FRTTIModules: TList = nil; + FRTTIModulesDestroyed: Boolean = False; + + +{ TfsItemsList } + +constructor TfsItemList.Create; +begin + FItems := TList.Create; +end; + +destructor TfsItemList.Destroy; +begin + Clear; + FItems.Free; + inherited; +end; + +procedure TfsItemList.Clear; +begin + while FItems.Count > 0 do + begin + TObject(FItems[0]).Free; + FItems.Delete(0); + end; +end; + +function TfsItemList.Count: Integer; +begin + Result := FItems.Count; +end; + +procedure TfsItemList.Add(Item: TObject); +begin + FItems.Add(Item); +end; + +procedure TfsItemList.Remove(Item: TObject); +begin + FItems.Remove(Item); +end; + + +{ TfsCustomVariable } + +constructor TfsCustomVariable.Create(const AName: String; ATyp: TfsVarType; + const ATypeName: String); +begin + inherited Create; + FName := AName; + FTyp := ATyp; + FTypeName := ATypeName; + FValue := Null; + FNeedResult := True; + FUppercaseName := AnsiUppercase(FName); +end; + +function TfsCustomVariable.GetValue: Variant; +begin + Result := FValue; +end; + +procedure TfsCustomVariable.SetValue(const Value: Variant); +begin + if not FIsReadOnly then + FValue := Value; +end; + +function TfsCustomVariable.GetParam(Index: Integer): TfsParamItem; +begin + Result := FItems[Index]; +end; + +function TfsCustomVariable.GetPValue: PVariant; +begin + Result := @FValue; +end; + +function TfsCustomVariable.GetFullTypeName: String; +begin + case FTyp of + fvtInt: Result := 'Integer'; + fvtBool: Result := 'Boolean'; + fvtFloat: Result := 'Extended'; + fvtChar: Result := 'Char'; + fvtString: Result := 'String'; + fvtClass: Result := FTypeName; + fvtArray: Result := 'Array'; + fvtEnum: Result := FTypeName; + else + Result := 'Variant'; + end; +end; + +function TfsCustomVariable.GetNumberOfRequiredParams: Integer; +var + i: Integer; +begin + Result := 0; + for i := 0 to Count - 1 do + if not Params[i].IsOptional then + Inc(Result); +end; + + +{ TfsStringVariable } + +function TfsStringVariable.GetValue: Variant; +begin + Result := FStr; +end; + +procedure TfsStringVariable.SetValue(const Value: Variant); +begin + FStr := Value; +end; + + +{ TfsParamItem } + +constructor TfsParamItem.Create(const AName: String; ATyp: TfsVarType; + const ATypeName: String; AIsOptional, AIsVarParam: Boolean); +begin + inherited Create(AName, ATyp, ATypeName); + FIsOptional := AIsOptional; + FIsVarParam := AIsVarParam; + FDefValue := Null; +end; + + +{ TfsProcVariable } + +constructor TfsProcVariable.Create(const AName: String; ATyp: TfsVarType; + const ATypeName: String; AParent: TfsScript; AIsFunc: Boolean = True); +begin + inherited Create(AName, ATyp, ATypeName); + FIsReadOnly := True; + FIsFunc := AIsFunc; + FProgram := TfsScript.Create(nil); + FProgram.Parent := AParent; + if FIsFunc then + begin + FRefItem := TfsVariable.Create('Result', ATyp, ATypeName); + FProgram.Add('Result', FRefItem); + end; +end; + + + +destructor TfsProcVariable.Destroy; +var + i: Integer; +begin + { avoid destroying the param objects twice } + for i := 0 to Count - 1 do + FProgram.FItems.Delete(FProgram.FItems.IndexOfObject(Params[i])); + + FProgram.Free; + inherited; +end; + +function TfsProcVariable.GetValue: Variant; +var + Temp: Boolean; + ParentProg, SaveProg: TfsScript; +begin + Temp := FExecuting; + FExecuting := True; + + ParentProg := FProgram; + SaveProg := nil; + while ParentProg <> nil do + if ParentProg.FMainProg then + begin + SaveProg := ParentProg.FProgRunning; + ParentProg.FProgRunning := FProgram; + break; + end + else + ParentProg := ParentProg.FParent; + + try +// avoid trial message +// same as FProgram.Execute + with FProgram do + begin + FExitCalled := False; + FTerminated := False; + FIsRunning := True; + try + FStatement.Execute; + finally + FExitCalled := False; + FTerminated := False; + FIsRunning := False; + end; + end; +// + + if FIsFunc then + Result := FRefItem.Value else + Result := Null; + finally + if ParentProg <> nil then + ParentProg.FProgRunning := SaveProg; + FExecuting := Temp; + end; +end; + + +{ TfsPropertyHelper } + +function TfsPropertyHelper.GetValue: Variant; +var + p: PPropInfo; + Instance: TObject; +begin + + Result := Null; + Instance := TObject(Integer(ParentValue)); + + if FIsPublished and Assigned(Instance) then + begin + p := GetPropInfo(Instance.ClassInfo, Name); + if p <> nil then + case p.PropType^.Kind of + tkInteger, tkSet, tkEnumeration, tkClass: + Result := GetOrdProp(Instance, p); + + tkFloat: + Result := GetFloatProp(Instance, p); + + tkString, tkLString, tkWString: + Result := GetStrProp(Instance, p); + + tkChar, tkWChar: + Result := Chr(GetOrdProp(Instance, p)); + + tkVariant: + Result := GetVariantProp(Instance, p); + end; + end + else if Assigned(FOnGetValue) then + Result := FOnGetValue(Instance, FClassRef, FUppercaseName); + + if Typ = fvtBool then + if Result = 0 then + Result := False else + Result := True; + +end; + +procedure TfsPropertyHelper.SetValue(const Value: Variant); +var + p: PPropInfo; + Instance: TObject; + IntVal: Integer; +begin + + if IsReadOnly then Exit; + Instance := TObject(Integer(ParentValue)); + + + + if FIsPublished then + begin + p := GetPropInfo(Instance.ClassInfo, Name); + if p <> nil then + case p.PropType^.Kind of + tkInteger, tkSet, tkEnumeration, tkClass: + begin +{$IFNDEF Delphi4} + if VarType(Value) <> varInteger then + begin + SetSetProp(Instance, p, fsSetToString(p, Value)); + end + else +{$ENDIF} + begin + if Typ = fvtBool then + if Value = True then + IntVal := 1 else + IntVal := 0 + else + IntVal := Integer(Value); + SetOrdProp(Instance, p, IntVal); + end; + end; + + tkFloat: + SetFloatProp(Instance, p, Extended(Value)); + + tkString, tkLString: + SetStrProp(Instance, p, String(Value)); + + tkWString: + SetStrProp(Instance, p, WideString(Value)); + + tkChar, tkWChar: + SetOrdProp(Instance, p, Ord(String(Value)[1])); + + tkVariant: + SetVariantProp(Instance, p, Value); + end; + end + else if Assigned(FOnSetValue) then + FOnSetValue(Instance, FClassRef, FUppercaseName, Value); + +end; + + +{ TfsMethodHelper } + +constructor TfsMethodHelper.Create(const Syntax: String; Script: TfsScript); +var + i: Integer; + v: TfsCustomVariable; +begin + v := ParseMethodSyntax(Syntax, Script); + inherited Create(v.Name, v.Typ, v.TypeName); + FIsReadOnly := True; + FSyntax := Syntax; + IsMacro := v.IsMacro; + + { copying params } + for i := 0 to v.Count - 1 do + Add(v.Params[i]); + while v.Count > 0 do + v.FItems.Delete(0); + v.Free; + + // FPC and Delphi do this different way. FPC implementation more honest, so + // if Count = 0 then we get exception about bad bounds + if Count > 0 then + FVarArray := VarArrayCreate([0, Count - 1], varVariant); +end; + +destructor TfsMethodHelper.Destroy; +begin + FVarArray := Null; + inherited; +end; + +function TfsMethodHelper.GetVParam(Index: Integer): Variant; +begin + if Index = Count then + Result := FSetValue + else + Result := TfsParamItem(FItems[Index]).Value; +end; + +procedure TfsMethodHelper.SetVParam(Index: Integer; const Value: Variant); +begin + TfsParamItem(FItems[Index]).Value := Value; +end; + +function TfsMethodHelper.GetValue: Variant; +var + i: Integer; + Instance: TObject; +begin + if Assigned(FOnCall) then + begin + for i := 0 to Count - 1 do + FVarArray[i] := inherited Params[i].Value; + + Instance := nil; + if not VarIsNull(ParentValue) then + Instance := TObject(Integer(ParentValue)); + + if FIndexMethod then + Result := FOnCall(Instance, FClassRef, FUppercaseName + '.GET', FVarArray) + else + Result := FOnCall(Instance, FClassRef, FUppercaseName, FVarArray); + for i := 0 to Count - 1 do + if inherited Params[i].IsVarParam then + inherited Params[i].Value := FVarArray[i]; + end + else if Assigned(FOnCallNew) then + begin + Instance := nil; + if not VarIsNull(ParentValue) then + Instance := TObject(Integer(ParentValue)); + + if FIndexMethod then + Result := FOnCallNew(Instance, FClassRef, FUppercaseName + '.GET', Self) + else + Result := FOnCallNew(Instance, FClassRef, FUppercaseName, Self); + end + else + Result := 0; +end; + +procedure TfsMethodHelper.SetValue(const Value: Variant); +var + v: Variant; + i: Integer; +begin + if FIndexMethod then + if Assigned(FOnCall) then + begin + v := VarArrayCreate([0, Count], varVariant); + for i := 0 to Count - 1 do + v[i] := inherited Params[i].Value; + v[Count] := Value; + + FOnCall(TObject(Integer(ParentValue)), FClassRef, FUppercaseName + '.SET', v); + v := Null; + end + else if Assigned(FOnCallNew) then + begin + FSetValue := Value; + FOnCallNew(TObject(Integer(ParentValue)), FClassRef, FUppercaseName + '.SET', Self); + FSetValue := Null; + end; +end; + + +{ TfsComponentHelper } + +constructor TfsComponentHelper.Create(Component: TComponent); +begin + inherited Create(Component.Name, fvtClass, Component.ClassName); + FComponent := Component; +end; + +function TfsComponentHelper.GetValue: Variant; +begin + Result := Integer(FComponent); +end; + + +{ TfsEventHelper } + +constructor TfsEventHelper.Create(const Name: String; AEvent: TfsEventClass); +begin + inherited Create(Name, fvtString, ''); + FEvent := AEvent; +end; + +function TfsEventHelper.GetValue: Variant; +begin + Result := ''; +end; + +procedure TfsEventHelper.SetValue(const Value: Variant); +var + Instance: TPersistent; + v: TfsCustomVariable; + e: TfsCustomEvent; + p: PPropInfo; + m: TMethod; +begin + + Instance := TPersistent(Integer(ParentValue)); + if VarToStr(Value) = '0' then + begin + m.Code := nil; + m.Data := nil; + end + else + begin + v := FProgram.Find(Value); + if (v = nil) or not (v is TfsProcVariable) then + raise Exception.Create(SEventError); + + e := TfsCustomEvent(FEvent.NewInstance); + e.Create(Instance, TfsProcVariable(v)); + FProgram.Add('', e); + m.Code := e.GetMethod; + m.Data := e; + end; + + p := GetPropInfo(Instance.ClassInfo, Name); + SetMethodProp(Instance, p, m); +end; + + +{ TfsClassVariable } + +constructor TfsClassVariable.Create(AClass: TClass; const Ancestor: String); +begin + inherited Create(AClass.ClassName, fvtClass, AClass.ClassName); + FMembers := TfsItemList.Create; + FAncestor := Ancestor; + FClassRef := AClass; + + AddPublishedProperties(AClass); + Add(TfsParamItem.Create('', fvtVariant, '', True, False)); +end; + +destructor TfsClassVariable.Destroy; +begin + FMembers.Free; + inherited; +end; + +function TfsClassVariable.GetMembers(Index: Integer): TfsCustomHelper; +begin + Result := FMembers.FItems[Index]; +end; + +function TfsClassVariable.GetMembersCount: Integer; +begin + Result := FMembers.Count; +end; + +procedure TfsClassVariable.AddConstructor(Syntax: String; CallEvent: TfsCallMethodEvent); +var + i: Integer; +begin + i := Pos(' ', Syntax); + Delete(Syntax, 1, i - 1); + Syntax := 'function' + Syntax + ': ' + 'Constructor'; + AddMethod(Syntax, CallEvent); +end; + +procedure TfsClassVariable.AddConstructor(Syntax: String; + CallEvent: TfsCallMethodNewEvent); +var + i: Integer; +begin + i := Pos(' ', Syntax); + Delete(Syntax, 1, i - 1); + Syntax := 'function' + Syntax + ': ' + 'Constructor'; + AddMethod(Syntax, CallEvent); +end; + +procedure TfsClassVariable.AddMethod(const Syntax: String; CallEvent: TfsCallMethodEvent); +var + m: TfsMethodHelper; +begin + m := TfsMethodHelper.Create(Syntax, FProgram); + m.FOnCall := CallEvent; + m.FClassRef := FClassRef; + FMembers.Add(m); +end; + +procedure TfsClassVariable.AddMethod(const Syntax: String; CallEvent: TfsCallMethodNewEvent); +var + m: TfsMethodHelper; +begin + m := TfsMethodHelper.Create(Syntax, FProgram); + m.FOnCallNew := CallEvent; + m.FClassRef := FClassRef; + FMembers.Add(m); +end; + +procedure TfsClassVariable.AddEvent(const Name: String; AEvent: TfsEventClass); +var + e: TfsEventHelper; +begin + e := TfsEventHelper.Create(Name, AEvent); + e.FClassRef := FClassRef; + FMembers.Add(e); +end; + +procedure TfsClassVariable.AddProperty(const Name, Typ: String; + GetEvent: TfsGetValueEvent; SetEvent: TfsSetValueEvent); +var + p: TfsPropertyHelper; +begin + p := TfsPropertyHelper.Create(Name, StrToVarType(Typ, FProgram), Typ); + p.FClassRef := FClassRef; + p.FOnGetValue := GetEvent; + p.FOnSetValue := SetEvent; + p.IsReadOnly := not Assigned(SetEvent); + FMembers.Add(p); +end; + +procedure TfsClassVariable.AddDefaultProperty(const Name, Params, Typ: String; + CallEvent: TfsCallMethodEvent; AReadOnly: Boolean = False); +begin + AddIndexProperty(Name, Params, Typ, CallEvent, AReadOnly); + FDefProperty := Members[FMembers.Count - 1]; +end; + +procedure TfsClassVariable.AddDefaultProperty(const Name, Params, + Typ: String; CallEvent: TfsCallMethodNewEvent; AReadOnly: Boolean); +begin + AddIndexProperty(Name, Params, Typ, CallEvent, AReadOnly); + FDefProperty := Members[FMembers.Count - 1]; +end; + +procedure TfsClassVariable.AddIndexProperty(const Name, Params, + Typ: String; CallEvent: TfsCallMethodEvent; AReadOnly: Boolean = False); +var + i: Integer; + sl: TStringList; + s: String; +begin + sl := TStringList.Create; + sl.CommaText := Params; + + s := ''; + for i := 0 to sl.Count - 1 do + s := s + 'p' + IntToStr(i) + ': ' + sl[i] + '; '; + + SetLength(s, Length(s) - 2); + try + AddMethod('function ' + Name + '(' + s + '): ' + Typ, CallEvent); + with TfsMethodHelper(Members[FMembers.Count - 1]) do + begin + IsReadOnly := AReadOnly; + FIndexMethod := True; + end; + finally + sl.Free; + end; +end; + +procedure TfsClassVariable.AddIndexProperty(const Name, Params, + Typ: String; CallEvent: TfsCallMethodNewEvent; AReadOnly: Boolean); +var + i: Integer; + sl: TStringList; + s: String; +begin + sl := TStringList.Create; + sl.CommaText := Params; + + s := ''; + for i := 0 to sl.Count - 1 do + s := s + 'p' + IntToStr(i) + ': ' + sl[i] + '; '; + + SetLength(s, Length(s) - 2); + try + AddMethod('function ' + Name + '(' + s + '): ' + Typ, CallEvent); + with TfsMethodHelper(Members[FMembers.Count - 1]) do + begin + IsReadOnly := AReadOnly; + FIndexMethod := True; + end; + finally + sl.Free; + end; +end; + +procedure TfsClassVariable.AddComponent(c: TComponent); +begin + FMembers.Add(TfsComponentHelper.Create(c)); +end; + +procedure TfsClassVariable.AddPublishedProperties(AClass: TClass); +var + TypeInfo: PTypeInfo; + PropCount: Integer; + PropList: PPropList; + i: Integer; + cl: String; + t: TfsVarType; + FClass: TClass; + p: TfsPropertyHelper; +begin + TypeInfo := AClass.ClassInfo; + if TypeInfo = nil then Exit; + + PropCount := GetPropList(TypeInfo, tkProperties, nil); + GetMem(PropList, PropCount * SizeOf(PPropInfo)); + GetPropList(TypeInfo, tkProperties, PropList); + + try + for i := 0 to PropCount - 1 do + begin + t := fvtInt; + cl := ''; + + case PropList[i].PropType^.Kind of + tkInteger: + t := fvtInt; + tkSet: + begin + t := fvtEnum; + cl := PropList[i].PropType^.Name; + end; + tkEnumeration: + begin + t := fvtEnum; + cl := PropList[i].PropType^.Name; + if (CompareText(cl, 'Boolean') = 0) or (CompareText(cl, 'bool') = 0) then + t := fvtBool; + end; + tkFloat: + t := fvtFloat; + tkChar, tkWChar: + t := fvtChar; + tkString, tkLString, tkWString: + t := fvtString; + tkVariant: + t := fvtVariant; + tkClass: + begin + t := fvtClass; + {$IFNDEF FPC} + FClass := GetTypeData(PropList[i].PropType^).ClassType; + {$ELSE} + FClass := GetTypeData(PropList[i].PropType).ClassType; + {$ENDIF} + cl := FClass.ClassName; + end; + end; + + p := TfsPropertyHelper.Create(PropList[i].Name, t, cl); + p.FClassRef := FClassRef; + p.FIsPublished := True; + FMembers.Add(p); + end; + + finally + FreeMem(PropList, PropCount * SizeOf(PPropInfo)); + end; +end; + +function TfsClassVariable.Find(const Name: String): TfsCustomHelper; +var + cl: TfsClassVariable; + + function DoFind(const Name: String): TfsCustomHelper; + var + i: Integer; + begin + Result := nil; + for i := 0 to FMembers.Count - 1 do + if CompareText(Name, Members[i].Name) = 0 then + begin + Result := Members[i]; + Exit; + end; + end; + +begin + Result := DoFind(Name); + if Result = nil then + begin + cl := FProgram.FindClass(FAncestor); + if cl <> nil then + Result := cl.Find(Name); + end; +end; + +function TfsClassVariable.GetValue: Variant; +begin + if Params[0].Value = Null then + Result := Integer(FClassRef.NewInstance) else { constructor call } + Result := Params[0].Value; { typecast } + Params[0].Value := Null; +end; + + +{ TfsDesignatorItem } + +function TfsDesignatorItem.GetItem(Index: Integer): TfsCustomExpression; +begin + Result := FItems[Index]; +end; + + +{ TfsDesignator } + +constructor TfsDesignator.Create(AProgram: TfsScript); +var + ParentProg: TfsScript; +begin + inherited Create('', fvtInt, ''); + FProgram := AProgram; + FMainProg := FProgram; + ParentProg := FProgram; + while ParentProg <> nil do + if ParentProg.FMainProg then + begin + FMainProg := ParentProg; + break; + end + else + ParentProg := ParentProg.FParent; +end; + +destructor TfsDesignator.Destroy; +begin + if FLateBindingXMLSource <> nil then + FLateBindingXMLSource.Free; + inherited; +end; + +procedure TfsDesignator.Borrow(ADesignator: TfsDesignator); +var + SaveItems: TList; +begin + SaveItems := FItems; + FItems := ADesignator.FItems; + ADesignator.FItems := SaveItems; + FKind := ADesignator.FKind; + FRef1 := ADesignator.FRef1; + FRef2 := ADesignator.FRef2; + FTyp := ADesignator.Typ; + FTypeName := ADesignator.TypeName; + FIsReadOnly := ADesignator.IsReadOnly; + RefItem := ADesignator.RefItem; +end; + +procedure TfsDesignator.Finalize; +var + Item: TfsDesignatorItem; +begin + Item := Items[Count - 1]; + FTyp := Item.Ref.Typ; + FTypeName := Item.Ref.TypeName; + if FTyp = fvtConstructor then + begin + FTyp := fvtClass; + FTypeName := Items[Count - 2].Ref.TypeName; + end; + + FIsReadOnly := Item.Ref.IsReadOnly; + + { speed optimization for access to single variable, string element or array } + if (Count = 1) and (Items[0].Ref is TfsVariable) then + begin + RefItem := Items[0].Ref; + FKind := dkVariable; + end + else if (Count = 2) and (Items[0].Ref is TfsStringVariable) then + begin + RefItem := Items[0].Ref; + FRef1 := Items[1][0]; + FKind := dkStringArray; + end + else if (Count = 2) and (Items[0].Ref is TfsVariable) and (Items[0].Ref.Typ = fvtArray) then + begin + RefItem := Items[0].Ref; + FRef1 := RefItem.RefItem; + FRef2 := Items[1]; + FKind := dkArray; + end + else + FKind := dkOther; +end; + +function TfsDesignator.GetItem(Index: Integer): TfsDesignatorItem; +begin + Result := FItems[Index]; +end; + +function TfsDesignator.DoCalc(const AValue: Variant; Flag: Boolean): Variant; +var + i, j: Integer; + Item: TfsCustomVariable; + Val: Variant; + Ref: TfsCustomVariable; + Temp, Temp1: array of Variant; + + { copy local variables to Temp } + procedure SaveLocalVariables(Item: TfsCustomVariable); + var + i: Integer; + begin + with TfsProcVariable(Item) do + begin + SetLength(Temp, Prog.Count); + + for i := 0 to Prog.Count - 1 do + if (Prog.Items[i] is TfsVariable) or (Prog.Items[i] is TfsParamItem) then + Temp[i] := Prog.Items[i].Value; + end; + end; + + { restore local variables from Temp} + procedure RestoreLocalVariables(Item: TfsCustomVariable); + var + i: Integer; + begin + with TfsProcVariable(Item) do + for i := 0 to Prog.Count - 1 do + if (Prog.Items[i] is TfsVariable) or (Prog.Items[i] is TfsParamItem) then + Prog.Items[i].Value := Temp[i]; + + Temp := nil; + end; + +begin + Ref := nil; + Val := Null; + + for i := 0 to Count - 1 do + begin + Item := Items[i].Ref; + + if Item is TfsDesignator then { it is true for "WITH" statements } + begin + Ref := Item; + Val := Item.Value; + continue; + end; + + try + { we're trying to call the local procedure that is already executing - + i.e. we have a recursion } + if (Item is TfsProcVariable) and TfsProcVariable(Item).Executing then + SaveLocalVariables(Item); + + if Item.Count > 0 then + begin + SetLength(Temp1, Item.Count); + try + { calculate params and copy param values to the temp1 array } + for j := 0 to Item.Count - 1 do + if Item.IsMacro then + Temp1[j] := TfsExpression(Items[i][j]).Source + else + Temp1[j] := Items[i][j].Value; + { copy calculated values to the item params } + for j := 0 to Item.Count - 1 do + Item.Params[j].Value := Temp1[j]; + finally + Temp1 := nil; + end; + end; + + { copy value and var reference to the helper object } + if Item is TfsCustomHelper then + begin + TfsCustomHelper(Item).ParentRef := Ref; + TfsCustomHelper(Item).ParentValue := Val; + TfsCustomHelper(Item).Prog := FProgram; + end; + + Ref := Item; + { assign a value to the last designator node if called from SetValue } + if Flag and (i = Count - 1) then + begin + Item.Value := AValue + end + else + begin + Item.NeedResult := (i <> Count - 1) or NeedResult; + Val := Item.Value; + end; + + { copy back var params } + for j := 0 to Item.Count - 1 do + if Item.Params[j].IsVarParam then + Items[i][j].Value := Item.Params[j].Value; + + finally + { restore proc variables if it was called from itself } + if (Item is TfsProcVariable) and TfsProcVariable(Item).Executing then + RestoreLocalVariables(Item); + end; + end; + + Result := Val; +end; + +procedure TfsDesignator.CheckLateBinding; +var + NewDesignator: TfsDesignator; + Parser: TfsILParser; +begin + if FLateBindingXMLSource <> nil then + begin + Parser := TfsILParser.Create(FProgram); + try + NewDesignator := Parser.DoDesignator(FLateBindingXMLSource, FProgram); + Borrow(NewDesignator); + NewDesignator.Free; + finally + Parser.Free; + FLateBindingXMLSource.Free; + FLateBindingXMLSource := nil; + end; + end; +end; + +function TfsDesignator.GetValue: Variant; +begin + CheckLateBinding; + Result := DoCalc(Null, False); +end; + +procedure TfsDesignator.SetValue(const Value: Variant); +begin + CheckLateBinding; + DoCalc(Value, True); +end; + + +{ TfsVariableDesignator } + +function TfsVariableDesignator.GetValue: Variant; +begin + Result := RefItem.Value; +end; + +procedure TfsVariableDesignator.SetValue(const Value: Variant); +begin + RefItem.Value := Value; +end; + + +{ TfsStringDesignator } + +function TfsStringDesignator.GetValue: Variant; +begin + Result := TfsStringVariable(RefItem).FStr[Integer(FRef1.Value)]; +end; + +procedure TfsStringDesignator.SetValue(const Value: Variant); +begin + TfsStringVariable(RefItem).FStr[Integer(FRef1.Value)] := VarToStr(Value)[1]; +end; + + +{ TfsArrayDesignator } + +function TfsArrayDesignator.GetValue: Variant; +var + i: Integer; +begin + TfsCustomHelper(FRef1).ParentRef := RefItem; + for i := 0 to FRef2.Count - 1 do + FRef1.Params[i].Value := FRef2[i].Value; + Result := FRef1.Value; +end; + +procedure TfsArrayDesignator.SetValue(const Value: Variant); +var + i: Integer; +begin + TfsCustomHelper(FRef1).ParentRef := RefItem; + for i := 0 to FRef2.Count - 1 do + FRef1.Params[i].Value := FRef2[i].Value; + FRef1.Value := Value; +end; + + +{ TfsSetExpression } + +function TfsSetExpression.Check(const Value: Variant): Boolean; +var + i: Integer; + Expr: TfsCustomExpression; +begin + Result := False; + + (* TfsSetExpression encapsulates the set like [1,2,3..10] + In the example above we'll have the following Items: + TfsExpression {1} + TfsExpression {2} + TfsExpression {3} + nil (indicates the range ) + TfsExpression {10} *) + + i := 0; + while i < Count do + begin + Expr := Items[i]; + + if (i < Count - 1) and (Items[i + 1] = nil) then { subrange } + begin + Result := (Value >= Expr.Value) and (Value <= Items[i + 2].Value); + Inc(i, 2); + end + else + Result := Value = Expr.Value; + + if Result then break; + Inc(i); + end; +end; + +function TfsSetExpression.GetItem(Index: Integer): TfsCustomExpression; +begin + Result := FItems[Index]; +end; + +function TfsSetExpression.GetValue: Variant; +var + i: Integer; +begin + Result := VarArrayCreate([0, Count - 1], varVariant); + + for i := 0 to Count - 1 do + if Items[i] = nil then + Result[i] := Null else + Result[i] := Items[i].Value; +end; + + +{ TfsScript } + +constructor TfsScript.Create(AOwner: TComponent); +begin + inherited; + FItems := TStringList.Create; + FItems.Sorted := True; + FItems.Duplicates := dupAccept; + FLines := TStringList.Create; + FMacros := TStringList.Create; + FStatement := TfsStatement.Create(Self, '', ''); + FSyntaxType := 'PascalScript'; + FUnitLines := TStringList.Create; +end; + +destructor TfsScript.Destroy; +begin + inherited; + Clear; + ClearRTTI; + FItems.Free; + FLines.Free; + FMacros.Free; + FStatement.Free; + FUnitLines.Free; +end; + +procedure TfsScript.Add(const Name: String; Item: TObject); +begin + FItems.AddObject(Name, Item); + if Item is TfsCustomVariable then + TfsCustomVariable(Item).AddedBy := FAddedBy; +end; + +function TfsScript.Count: Integer; +begin + Result := FItems.Count; +end; + +procedure TfsScript.Remove(Item: TObject); +begin + FItems.Delete(FItems.IndexOfObject(Item)); +end; + +procedure TfsScript.Clear; +var + i: Integer; + item: TObject; +begin + i := 0; + while i < FItems.Count do + begin + item := FItems.Objects[i]; + if (item is TfsRTTIModule) or + ((item is TfsCustomVariable) and + (TfsCustomVariable(item).AddedBy = TObject(1))) then + Inc(i) + else + begin + item.Free; + FItems.Delete(i); + end; + end; + FStatement.Clear; + FUnitLines.Clear; + FErrorPos := ''; + FErrorMsg := ''; + FErrorUnit := ''; +end; + +procedure TfsScript.ClearItems(Owner: TObject); +begin + RemoveItems(Owner); + FStatement.Clear; + FUnitLines.Clear; +end; + +procedure TfsScript.RemoveItems(Owner: TObject); +var + i: Integer; +begin + for i := Count - 1 downto 0 do + if Items[i].AddedBy = Owner then + begin + Items[i].Free; + Remove(Items[i]); + end; +end; + +function TfsScript.GetItem(Index: Integer): TfsCustomVariable; +begin + Result := TfsCustomVariable(FItems.Objects[Index]); +end; + +function TfsScript.Find(const Name: String): TfsCustomVariable; +begin + Result := FindLocal(Name); + + { trying to find the identifier in all parent programs } + if (Result = nil) and (FParent <> nil) then + Result := FParent.Find(Name); +end; + +function TfsScript.FindLocal(const Name: String): TfsCustomVariable; +var + i: Integer; +begin + Result := nil; + i := FItems.IndexOf(Name); + if (i <> -1) and (FItems.Objects[i] is TfsCustomVariable) then + Result := TfsCustomVariable(FItems.Objects[i]); +end; + +function TfsScript.Compile: Boolean; +var + p: TfsILParser; +begin + Result := False; + FErrorMsg := ''; + + p := TfsILParser.Create(Self); + try + p.SelectLanguage(FSyntaxType); + if p.MakeILScript(FLines.Text) then + p.ParseILScript; + finally + p.Free; + end; + + if FErrorMsg = '' then + begin + Result := True; + FErrorPos := ''; + end +end; + +procedure TfsScript.Execute; +begin + + FExitCalled := False; + FTerminated := False; + FIsRunning := True; + FMainProg := True; + try + FStatement.Execute; + finally + FExitCalled := False; + FTerminated := False; + FIsRunning := False; + end; +end; + +function TfsScript.Run: Boolean; +begin + Result := Compile; + if Result then + Execute; +end; + +function TfsScript.GetILCode(Stream: TStream): Boolean; +var + p: TfsILParser; +begin + Result := False; + FErrorMsg := ''; + + p := TfsILParser.Create(Self); + try + p.SelectLanguage(FSyntaxType); + if p.MakeILScript(FLines.Text) then + p.ILScript.SaveToStream(Stream); + finally + p.Free; + end; + + if FErrorMsg = '' then + begin + Result := True; + FErrorPos := ''; + end; +end; + +function TfsScript.SetILCode(Stream: TStream): Boolean; +var + p: TfsILParser; +begin + Result := False; + FErrorMsg := ''; + + p := TfsILParser.Create(Self); + try + p.ILScript.LoadFromStream(Stream); + p.ParseILScript; + finally + p.Free; + end; + + if FErrorMsg = '' then + begin + Result := True; + FErrorPos := ''; + end; +end; + +procedure TfsScript.AddType(const TypeName: String; ParentType: TfsVarType); +var + v: TfsTypeVariable; +begin + if Find(TypeName) <> nil then Exit; + v := TfsTypeVariable.Create(TypeName, ParentType, ''); + Add(TypeName, v); +end; + +function TfsScript.AddClass(AClass: TClass; const Ancestor: String): TfsClassVariable; +var + cl: TfsClassVariable; +begin + Result := nil; + if Find(AClass.ClassName) <> nil then Exit; + + Result := TfsClassVariable.Create(AClass, Ancestor); + Result.FProgram := Self; + Add(Result.Name, Result); + + cl := TfsClassVariable(Find(Ancestor)); + if cl <> nil then + Result.FDefProperty := cl.DefProperty; +end; + +procedure TfsScript.AddConst(const Name, Typ: String; const Value: Variant); +var + v: TfsVariable; +begin + if Find(Name) <> nil then Exit; + + v := TfsVariable.Create(Name, StrToVarType(Typ, Self), Typ); + v.Value := Value; + v.IsReadOnly := True; + Add(v.Name, v); +end; + +procedure TfsScript.AddEnum(const Typ, Names: String); +var + i: Integer; + v: TfsVariable; + sl: TStringList; +begin + v := TfsVariable.Create(Typ, fvtEnum, Typ); + Add(v.Name, v); + + sl := TStringList.Create; + sl.CommaText := Names; + + try + for i := 0 to sl.Count - 1 do + begin + v := TfsVariable.Create(Trim(sl[i]), fvtEnum, Typ); + v.Value := i; + v.IsReadOnly := True; + Add(v.Name, v); + end; + finally + sl.Free; + end; +end; + +procedure TfsScript.AddEnumSet(const Typ, Names: String); +var + i, j: Integer; + v: TfsVariable; + sl: TStringList; +begin + v := TfsVariable.Create(Typ, fvtEnum, Typ); + Add(v.Name, v); + + sl := TStringList.Create; + sl.CommaText := Names; + + try + j := 1; + for i := 0 to sl.Count - 1 do + begin + v := TfsVariable.Create(Trim(sl[i]), fvtEnum, Typ); + v.Value := j; + v.IsReadOnly := True; + Add(v.Name, v); + j := j * 2; + end; + finally + sl.Free; + end; +end; + +procedure TfsScript.AddMethod(const Syntax: String; CallEvent: TfsCallMethodEvent; + const Category: String = ''; const Description: String = ''); +var + v: TfsMethodHelper; +begin + v := TfsMethodHelper.Create(Syntax, Self); + v.FOnCall := CallEvent; + if Description = '' then + v.FDescription := v.Name else + v.FDescription := Description; + v.FCategory := Category; + Add(v.Name, v); +end; + +procedure TfsScript.AddMethod(const Syntax: String; CallEvent: TfsCallMethodNewEvent; + const Category: String = ''; const Description: String = ''); +var + v: TfsMethodHelper; +begin + v := TfsMethodHelper.Create(Syntax, Self); + v.FOnCallNew := CallEvent; + if Description = '' then + v.FDescription := v.Name else + v.FDescription := Description; + v.FCategory := Category; + Add(v.Name, v); +end; + +procedure TfsScript.AddObject(const Name: String; Obj: TObject); +begin + AddVariable(Name, Obj.ClassName, Integer(Obj)); +end; + +procedure TfsScript.AddVariable(const Name, Typ: String; const Value: Variant); +var + v: TfsVariable; +begin + if Find(Name) <> nil then Exit; + + v := TfsVariable.Create(Name, StrToVarType(Typ, Self), Typ); + v.Value := Value; + Add(v.Name, v); +end; + +procedure TfsScript.AddForm(Form: TComponent); +begin + AddComponent(Form); +end; + +procedure TfsScript.AddComponent(Form: TComponent); +var + i: Integer; + v: TfsClassVariable; +begin +{$IFNDEF NOFORMS} + v := FindClass(Form.ClassName); + if v = nil then + begin + if Form.InheritsFrom(TForm) then + AddClass(Form.ClassType, 'TForm') + else if Form.InheritsFrom(TDataModule) then + AddClass(Form.ClassType, 'TDataModule') + else + Exit; + v := FindClass(Form.ClassName); + end; + + for i := 0 to Form.ComponentCount - 1 do + v.AddComponent(Form.Components[i]); + AddObject(Form.Name, Form); +{$ENDIF} +end; + +procedure TfsScript.AddRTTI; +var + i: Integer; + rtti: TfsRTTIModule; + obj: TClass; +begin + if FRTTIAdded then Exit; + + AddedBy := TObject(1); // do not clear + for i := 0 to FRTTIModules.Count - 1 do + begin + obj := TClass(FRTTIModules[i]); + rtti := TfsRTTIModule(obj.NewInstance); + rtti.Create(Self); + Add('', rtti); + end; + AddedBy := nil; + + FRTTIAdded := True; +end; + +procedure TfsScript.ClearRTTI; +var + i: Integer; + item: TObject; +begin + if not FRTTIAdded then Exit; + + i := 0; + while i < FItems.Count do + begin + item := FItems.Objects[i]; + if (item is TfsRTTIModule) or + ((item is TfsCustomVariable) and + (TfsCustomVariable(item).AddedBy = TObject(1))) then + begin + item.Free; + FItems.Delete(i); + end + else + Inc(i); + end; + + FRTTIAdded := False; +end; + +function TfsScript.CallFunction(const Name: String; const Params: Variant): Variant; +var + i: Integer; + v: TfsCustomVariable; + p: TfsProcVariable; +begin + v := FindLocal(Name); + if (v <> nil) and (v is TfsProcVariable) then + begin + p := TfsProcVariable(v); + + if VarIsArray(Params) then + for i := 0 to VarArrayHighBound(Params, 1) do + p.Params[i].Value := Params[i]; + Result := p.Value; + end + else + begin + Result := Null; + end +end; + +function TfsScript.CallFunction1(const Name: String; var Params: Variant): Variant; +var + i: Integer; + v: TfsCustomVariable; + p: TfsProcVariable; +begin + v := FindLocal(Name); + if (v <> nil) and (v is TfsProcVariable) then + begin + p := TfsProcVariable(v); + + if VarIsArray(Params) then + for i := 0 to VarArrayHighBound(Params, 1) do + p.Params[i].Value := Params[i]; + Result := p.Value; + if VarIsArray(Params) then + for i := 0 to VarArrayHighBound(Params, 1) do + Params[i] := p.Params[i].Value; + end + else + Result := Null; +end; + +function TfsScript.CallFunction2(const Func: TfsProcVariable; const Params: Variant): Variant; +var + i: Integer; +begin + if (Func <> nil) then + begin + if VarIsArray(Params) then + for i := 0 to VarArrayHighBound(Params, 1) do + Func.Params[i].Value := Params[i]; + Result := Func.Value; + end + else + begin + Result := Null; + end +end; + +function TfsScript.Evaluate(const Expression: String): Variant; +var + p: TfsScript; + Prog: TfsScript; + SaveEvent: TfsRunLineEvent; +begin + Result := Null; + if FProgRunning = nil then + p := Self else + p := FProgRunning; + + Prog := TfsScript.Create(nil); + Prog.AddRTTI; + Prog.Parent := p; + SaveEvent := FOnRunLine; + FOnRunLine := nil; + try + prog.SyntaxType := SyntaxType; + if CompareText(SyntaxType, 'PascalScript') = 0 then + Prog.Lines.Text := 'function __f__: Variant; begin Result := ' + Expression + ' end; begin end.' + else if CompareText(SyntaxType, 'C++Script') = 0 then + Prog.Lines.Text := 'Variant __f__() { return ' + Expression + '; } {}' + else if CompareText(SyntaxType, 'BasicScript') = 0 then + Prog.Lines.Text := 'function __f__' + #13#10 + 'return ' + Expression + #13#10 + 'end function' + else if CompareText(SyntaxType, 'JScript') = 0 then + Prog.Lines.Text := 'function __f__() { return (' + Expression + '); }'; + if not Prog.Compile then + Result := Prog.ErrorMsg else + Result := Prog.FindLocal('__f__').Value; + finally + Prog.Free; + FOnRunLine := SaveEvent; + end; +end; + +function TfsScript.FindClass(const Name: String): TfsClassVariable; +var + Item: TfsCustomVariable; +begin + Item := Find(Name); + if (Item <> nil) and (Item is TfsClassVariable) then + Result := TfsClassVariable(Item) else + Result := nil +end; + +procedure TfsScript.RunLine(const UnitName, Index: String); +var + p: TfsScript; +begin + p := Self; + while p <> nil do + if Assigned(p.FOnRunLine) then + begin + p.FOnRunLine(Self, UnitName, Index); + break; + end + else + p := p.FParent; +end; + +function TfsScript.GetVariables(Index: String): Variant; +var + v: TfsCustomVariable; +begin + v := Find(Index); + if v <> nil then + Result := v.Value else + Result := Null; +end; + +procedure TfsScript.SetVariables(Index: String; const Value: Variant); +var + v: TfsCustomVariable; +begin + v := Find(Index); + if v <> nil then + v.Value := Value else + AddVariable(Index, 'Variant', Value); +end; + +procedure TfsScript.SetLines(const Value: TStrings); +begin + FLines.Assign(Value); +end; + +procedure TfsScript.Terminate; + + procedure TerminateAll(Script: TfsScript); + var + i: Integer; + begin + Script.FExitCalled := True; + Script.FTerminated := True; + for i := 0 to Script.Count - 1 do + if Script.Items[i] is TfsProcVariable then + TerminateAll(TfsProcVariable(Script.Items[i]).Prog); + end; + +begin + TerminateAll(Self); +end; + +procedure TfsScript.AddCodeLine(const UnitName, APos: String); +var + sl: TStringList; + LineN: String; +begin + if FUnitLines.IndexOfName(UnitName) = -1 then + FUnitLines.Add(UnitName + '='); + + sl := TStringList.Create; + sl.CommaText := FUnitLines.Values[UnitName]; + LineN := Copy(APos, 1, Pos(':', APos) - 1); + if sl.IndexOf(LineN) = -1 then + FUnitLines.Values[UnitName] := FUnitLines.Values[UnitName] + LineN + ','; + sl.Free; +end; + +function TfsScript.IsExecutableLine(LineN: Integer; const UnitName: String = ''): Boolean; +var + sl: TStringList; +begin + Result := False; + if FUnitLines.IndexOfName(UnitName) = -1 then Exit; + + sl := TStringList.Create; + sl.CommaText := FUnitLines.Values[UnitName]; + if sl.IndexOf(IntToStr(LineN)) <> -1 then + Result := True; + sl.Free; +end; + + + +{ TfsStatement } + +constructor TfsStatement.Create(AProgram: TfsScript; const UnitName, + SourcePos: String); +begin + inherited Create; + FProgram := AProgram; + FSourcePos := SourcePos; + FUnitName := UnitName; +end; + +function TfsStatement.GetItem(Index: Integer): TfsStatement; +begin + Result := FItems[Index]; +end; + +procedure TfsStatement.Execute; +var + i: Integer; +begin + for i := 0 to Count - 1 do + begin + if FProgram.FTerminated then break; + Items[i].Execute; + if FProgram.FBreakCalled or FProgram.FContinueCalled or + FProgram.FExitCalled then break; + end; +end; + +procedure TfsStatement.RunLine; +begin + FProgram.RunLine(FUnitName, FSourcePos); +end; + + +{ TfsAssignmentStmt } + +destructor TfsAssignmentStmt.Destroy; +begin + FDesignator.Free; + FExpression.Free; + inherited; +end; + +procedure TfsAssignmentStmt.Optimize; +begin + FVar := FDesignator; + FExpr := FExpression; + + if FDesignator is TfsVariableDesignator then + FVar := FDesignator.RefItem; + if TfsExpression(FExpression).SingleItem <> nil then + FExpr := TfsExpression(FExpression).SingleItem; +end; + +procedure TfsAssignmentStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + FVar.Value := FExpr.Value; +end; + +procedure TfsAssignPlusStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + FVar.Value := FVar.Value + FExpr.Value; +end; + +procedure TfsAssignMinusStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + FVar.Value := FVar.Value - FExpr.Value; +end; + +procedure TfsAssignMulStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + FVar.Value := FVar.Value * FExpr.Value; +end; + +procedure TfsAssignDivStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + FVar.Value := FVar.Value / FExpr.Value; +end; + + +{ TfsCallStmt } + +destructor TfsCallStmt.Destroy; +begin + FDesignator.Free; + inherited; +end; + +procedure TfsCallStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + if FModificator = '' then + begin + FDesignator.NeedResult := False; + FDesignator.Value; + end + else if FModificator = '+' then + FDesignator.Value := FDesignator.Value + 1 + else if FModificator = '-' then + FDesignator.Value := FDesignator.Value - 1 +end; + + +{ TfsIfStmt } + +constructor TfsIfStmt.Create(AProgram: TfsScript; const UnitName, + SourcePos: String); +begin + inherited; + FElseStmt := TfsStatement.Create(FProgram, UnitName, SourcePos); +end; + +destructor TfsIfStmt.Destroy; +begin + FCondition.Free; + FElseStmt.Free; + inherited; +end; + +procedure TfsIfStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + if Boolean(FCondition.Value) = True then + inherited Execute else + FElseStmt.Execute; +end; + + +{ TfsRepeatStmt } + +destructor TfsRepeatStmt.Destroy; +begin + FCondition.Free; + inherited; +end; + +procedure TfsRepeatStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + + repeat + inherited Execute; + if FProgram.FBreakCalled or FProgram.FExitCalled then break; + FProgram.FContinueCalled := False; + until Boolean(FCondition.Value) = not FInverseCondition; + + FProgram.FBreakCalled := False; +end; + + +{ TfsWhileStmt } + +destructor TfsWhileStmt.Destroy; +begin + FCondition.Free; + inherited; +end; + +procedure TfsWhileStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + + while Boolean(FCondition.Value) = True do + begin + inherited Execute; + if FProgram.FBreakCalled or FProgram.FExitCalled then break; + FProgram.FContinueCalled := False; + end; + + FProgram.FBreakCalled := False; +end; + + +{ TfsForStmt } + +destructor TfsForStmt.Destroy; +begin + FBeginValue.Free; + FEndValue.Free; + inherited; +end; + +procedure TfsForStmt.Execute; +var + i, bValue, eValue: Integer; +begin + bValue := FBeginValue.Value; + eValue := FEndValue.Value; + RunLine; + if FProgram.FTerminated then Exit; + + if FDown then + for i := bValue downto eValue do + begin + FVariable.FValue := i; + inherited Execute; + if FProgram.FBreakCalled or FProgram.FExitCalled then break; + FProgram.FContinueCalled := False; + end + else + for i := bValue to eValue do + begin + FVariable.FValue := i; + inherited Execute; + if FProgram.FBreakCalled or FProgram.FExitCalled then break; + FProgram.FContinueCalled := False; + end; + + FProgram.FBreakCalled := False; +end; + + +{ TfsVbForStmt } + +destructor TfsVbForStmt.Destroy; +begin + FBeginValue.Free; + FEndValue.Free; + if FStep <> nil then + FStep.Free; + inherited; +end; + +procedure TfsVbForStmt.Execute; +var + i, bValue, eValue, sValue: Variant; + Down: Boolean; +begin + bValue := FBeginValue.Value; + eValue := FEndValue.Value; + if FStep <> nil then + sValue := FStep.Value else + sValue := 1; + Down := sValue < 0; + + RunLine; + if FProgram.FTerminated then Exit; + i := bValue; + if Down then + while i >= eValue do + begin + FVariable.FValue := i; + inherited Execute; + if FProgram.FBreakCalled or FProgram.FExitCalled then break; + FProgram.FContinueCalled := False; + i := i + sValue; + end + else + while i <= eValue do + begin + FVariable.FValue := i; + inherited Execute; + if FProgram.FBreakCalled or FProgram.FExitCalled then break; + FProgram.FContinueCalled := False; + i := i + sValue; + end; + + FProgram.FBreakCalled := False; +end; + + +{ TfsCppForStmt } + +constructor TfsCppForStmt.Create(AProgram: TfsScript; const UnitName, + SourcePos: String); +begin + inherited; + FFirstStmt := TfsStatement.Create(FProgram, UnitName, SourcePos); + FSecondStmt := TfsStatement.Create(FProgram, UnitName, SourcePos); +end; + +destructor TfsCppForStmt.Destroy; +begin + FFirstStmt.Free; + FExpression.Free; + FSecondStmt.Free; + inherited; +end; + +procedure TfsCppForStmt.Execute; +begin + RunLine; + if FProgram.FTerminated then Exit; + FFirstStmt.Execute; + if FProgram.FTerminated then Exit; + while Boolean(FExpression.Value) = True do + begin + inherited Execute; + if FProgram.FBreakCalled or FProgram.FExitCalled then break; + FProgram.FContinueCalled := False; + FSecondStmt.Execute; + end; + + FProgram.FBreakCalled := False; +end; + + +{ TfsCaseSelector } + +destructor TfsCaseSelector.Destroy; +begin + FSetExpression.Free; + inherited; +end; + +function TfsCaseSelector.Check(const Value: Variant): Boolean; +begin + Result := FSetExpression.Check(Value); +end; + + +{ TfsCaseStmt } + +constructor TfsCaseStmt.Create(AProgram: TfsScript; const UnitName, + SourcePos: String); +begin + inherited; + FElseStmt := TfsStatement.Create(FProgram, UnitName, SourcePos); +end; + +destructor TfsCaseStmt.Destroy; +begin + FCondition.Free; + FElseStmt.Free; + inherited; +end; + +procedure TfsCaseStmt.Execute; +var + i: Integer; + Value: Variant; + Executed: Boolean; +begin + Value := FCondition.Value; + Executed := False; + + RunLine; + if FProgram.FTerminated then Exit; + for i := 0 to Count - 1 do + if TfsCaseSelector(Items[i]).Check(Value) then + begin + Items[i].Execute; + Executed := True; + break; + end; + + if not Executed then + FElseStmt.Execute; +end; + + +{ TfsTryStmt } + +constructor TfsTryStmt.Create(AProgram: TfsScript; const UnitName, + SourcePos: String); +begin + inherited; + FExceptStmt := TfsStatement.Create(AProgram, UnitName, SourcePos); +end; + +destructor TfsTryStmt.Destroy; +begin + FExceptStmt.Free; + inherited; +end; + +procedure TfsTryStmt.Execute; +var + SaveExitCalled: Boolean; +begin + RunLine; + if FProgram.FTerminated then Exit; + if IsExcept then + begin + try + inherited Execute; + except + on E: Exception do + begin + FProgram.SetVariables('ExceptionClassName', E.ClassName); + FProgram.SetVariables('ExceptionMessage', E.Message); + ExceptStmt.Execute; + end; + end; + end + else + begin + try + inherited Execute; + finally + SaveExitCalled := FProgram.FExitCalled; + FProgram.FExitCalled := False; + ExceptStmt.Execute; + FProgram.FExitCalled := SaveExitCalled; + end + end; +end; + + +{ TfsBreakStmt } + +procedure TfsBreakStmt.Execute; +begin + FProgram.FBreakCalled := True; +end; + + +{ TfsContinueStmt } + +procedure TfsContinueStmt.Execute; +begin + FProgram.FContinueCalled := True; +end; + + +{ TfsExitStmt } + +procedure TfsExitStmt.Execute; +begin + RunLine; + FProgram.FExitCalled := True; +end; + + +{ TfsWithStmt } + +destructor TfsWithStmt.Destroy; +begin + FDesignator.Free; + inherited; +end; + +procedure TfsWithStmt.Execute; +begin + inherited; + FVariable.Value := FDesignator.Value; +end; + + +{ TfsArrayHelper } + +constructor TfsArrayHelper.Create(const AName: String; DimCount: Integer; + Typ: TfsVarType; const TypeName: String); +var + i: Integer; +begin + inherited Create(AName, Typ, TypeName); + + if DimCount <> -1 then + begin + for i := 0 to DimCount - 1 do + Add(TfsParamItem.Create('', fvtInt, '', False, False)); + end + else + for i := 0 to 2 do + Add(TfsParamItem.Create('', fvtInt, '', i > 0, False)); +end; + +destructor TfsArrayHelper.Destroy; +begin + inherited; +end; + +function TfsArrayHelper.GetValue: Variant; +var + DimCount: Integer; +begin + DimCount := VarArrayDimCount(ParentRef.PValue^); + case DimCount of + 1: Result := ParentRef.PValue^[Params[0].Value]; + 2: Result := ParentRef.PValue^[Params[0].Value, Params[1].Value]; + 3: Result := ParentRef.PValue^[Params[0].Value, Params[1].Value, Params[2].Value]; + else + Result := Null; + end; +end; + +procedure TfsArrayHelper.SetValue(const Value: Variant); +var + DimCount: Integer; +begin + DimCount := VarArrayDimCount(ParentRef.PValue^); + case DimCount of + 1: ParentRef.PValue^[Params[0].Value] := Value; + 2: ParentRef.PValue^[Params[0].Value, Params[1].Value] := Value; + 3: ParentRef.PValue^[Params[0].Value, Params[1].Value, Params[2].Value] := Value; + end; +end; + + +{ TfsStringHelper } + +constructor TfsStringHelper.Create; +begin + inherited Create('__StringHelper', fvtChar, ''); + Add(TfsParamItem.Create('', fvtInt, '', False, False)); +end; + +function TfsStringHelper.GetValue: Variant; +begin + Result := String(ParentValue)[Integer(Params[0].Value)]; +end; + +procedure TfsStringHelper.SetValue(const Value: Variant); +var + s: String; +begin + s := ParentValue; + s[Integer(Params[0].Value)] := String(Value)[1]; + TfsCustomVariable(Integer(ParentRef)).Value := s; +end; + + +{ TfsCustomEvent } + +constructor TfsCustomEvent.Create(AObject: TObject; AHandler: TfsProcVariable); +begin + FInstance := AObject; + FHandler := AHandler; +end; + +procedure TfsCustomEvent.CallHandler(Params: array of const); +var + i: Integer; +begin + if FHandler.Executing then Exit; + for i := 0 to FHandler.Count - 1 do + FHandler.Params[i].Value := VarRecToVariant(Params[i]); + FHandler.Value; +end; + + +{ TfsRTTIModule } + +constructor TfsRTTIModule.Create(AScript: TfsScript); +begin + FScript := AScript; +end; + + +function fsGlobalUnit: TfsScript; +begin + if (FGlobalUnit = nil) and not FGlobalUnitDestroyed then + begin + FGlobalUnit := TfsScript.Create(nil); + FGlobalUnit.AddRTTI; + end; + Result := FGlobalUnit; +end; + +function fsRTTIModules: TList; +begin + if (FRTTIModules = nil) and not FRTTIModulesDestroyed then + begin + FRTTIModules := TList.Create; + FRTTIModules.Add(TfsSysFunctions); + end; + Result := FRTTIModules; +end; + + +initialization + FGlobalUnitDestroyed := False; + FRTTIModulesDestroyed := False; + fsRTTIModules; + +finalization + if FGlobalUnit <> nil then + FGlobalUnit.Free; + FGlobalUnit := nil; + FGlobalUnitDestroyed := True; + FRTTIModules.Free; + FRTTIModules := nil; + FRTTIModulesDestroyed := True; + +end. diff --git a/official/4.2/LibD11/fs_ijs.pas b/official/4.2/LibD11/fs_ijs.pas new file mode 100644 index 0000000..b248c2c --- /dev/null +++ b/official/4.2/LibD11/fs_ijs.pas @@ -0,0 +1,145 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ JScript grammar } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_ijs; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_itools; + +type + TfsJScript = class(TComponent); + + +implementation + +const + JS_GRAMMAR = + '' + + '<' + + 'loop text=","><' + + 'char text="!" add="op" addtext="not"/>' + + '<' + + 'char text="-" add="op"/><' + + 'expression err="err2"/>' + + '<' + + 'forstmtitem/>'; + + +initialization + fsRegisterLanguage('JScript', JS_GRAMMAR); + +end. diff --git a/official/4.2/LibD11/fs_imenusrtti.pas b/official/4.2/LibD11/fs_imenusrtti.pas new file mode 100644 index 0000000..eed5da5 --- /dev/null +++ b/official/4.2/LibD11/fs_imenusrtti.pas @@ -0,0 +1,176 @@ +{**********************************************} +{ } +{ FastScript v1.9 } +{ Menus } +{ } +{ Copyright (c) 1998-2007 } +{ by Fast Reports Inc. } +{ } +{ Copyright (c) 2006 by } +{ Copyright (c) 2006-2007 by Stalker SoftWare } +{ } +{**********************************************} + +unit fs_imenusrtti; + +interface + +{$I fs.inc} + +uses + SysUtils, Classes, Menus, fs_iinterpreter, fs_ievents, ImgList +{$IFDEF Delphi6} +, Types , Variants +{$ENDIF}; + +type + TfsMenusRTTI = class(TComponent); // fake component + +implementation + +type + TFunctions = class(TfsRTTIModule) + private + function CallMethod(Instance: TObject; ClassType: TClass; const MethodName: + string; Caller: TfsMethodHelper): Variant; + function GetProp(Instance: TObject; ClassType: TClass; const PropName: + string): Variant; + procedure SetProp(Instance: TObject; ClassType: TClass; const PropName: + string; Value: Variant); + public + constructor Create(AScript: TfsScript); override; + end; + +constructor TFunctions.Create(AScript: TfsScript); +begin + inherited Create(AScript); + + with AScript do + begin + + AddType('TPopupAlignment', fvtInt); + + AddClass(TCustomImageList, 'TComponent'); + + with AddClass(TMenuItem, 'TComponent') do + begin + AddMethod('procedure Add(Item: TMenuItem)', CallMethod); + AddMethod('procedure Clear', CallMethod); + AddMethod('procedure Delete(Index: Integer)', CallMethod); + AddMethod('procedure Insert(Index: Integer; Item: TMenuItem)', + CallMethod); + AddMethod('procedure Remove(Item: TMenuItem)', CallMethod); + AddMethod('function GetParentMenu: TMenu', CallMethod); + AddEvent('OnClick', TfsNotifyEvent); + AddProperty('Count', 'Integer', GetProp); + AddDefaultProperty('Items', 'Integer', 'TMenuItem', CallMethod, True); + end; { with } + + with AddClass(TMenu, 'TComponent') do + AddIndexProperty('Items', 'Integer', 'TMenuItem', CallMethod, True); + + with AddClass(TPopupMenu, 'TMenu') do + begin + AddEvent('OnPopup', TfsNotifyEvent); + AddMethod('procedure Popup(X, Y: Extended)', CallMethod); + AddProperty('PopupComponent', 'TComponent', GetProp, SetProp); + AddProperty('Images', 'TCustomImageList', GetProp, SetProp); + end; { with } + + end; { with } + +end; { Create } + +function TFunctions.CallMethod(Instance: TObject; ClassType: TClass; const + MethodName: string; Caller: TfsMethodHelper): Variant; +var + oMenuItem: TMenuItem; +begin + Result := 0; + + if ClassType = TMenuItem then + begin + + oMenuItem := TMenuItem(Instance); + + if MethodName = 'ADD' then + oMenuItem.Add(TMenuItem(Integer(Caller.Params[0]))) +{$IFDEF Delphi5} + else if MethodName = 'CLEAR' then + oMenuItem.Clear +{$ENDIF} + else if MethodName = 'DELETE' then + oMenuItem.Delete(Caller.Params[0]) + else if MethodName = 'INSERT' then + oMenuItem.Insert(Caller.Params[0], TMenuItem(Integer(Caller.Params[1]))) + else if MethodName = 'REMOVE' then + oMenuItem.Remove(TMenuItem(Integer(Caller.Params[0]))) + else if MethodName = 'ITEMS.GET' then + Result := Integer(oMenuItem.Items[Caller.Params[0]]) + else if MethodName = 'GETPARENTMENU' then + Result := Integer(oMenuItem.GetParentMenu()); + + end + else if ClassType = TMenu then + begin + + if MethodName = 'ITEMS.GET' then + Result := Integer(TMenu(Instance).Items[Caller.Params[0]]) + + end + else if ClassType = TPopupMenu then + begin + + if MethodName = 'POPUP' then + TPopupMenu(Instance).Popup(Caller.Params[0], Caller.Params[1]); + + end; { if } + +end; { CallMethod } + +function TFunctions.GetProp(Instance: TObject; ClassType: TClass; const + PropName: string): Variant; +begin + Result := 0; + + if ClassType = TMenuItem then + begin + + if PropName = 'COUNT' then + Result := TMenuItem(Instance).Count; + + end + else if ClassType = TPopupMenu then + begin + + if PropName = 'POPUPCOMPONENT' then + Result := Integer(TPopupMenu(Instance).PopupComponent) + else if PropName = 'IMAGES' then + Result := Integer(TPopupMenu(Instance).Images) + + end; { if } + +end; { GetProp } + +procedure TFunctions.SetProp(Instance: TObject; ClassType: TClass; const + PropName: string; Value: Variant); +begin + if ClassType = TPopupMenu then + begin + if PropName = 'IMAGES' then + TPopupMenu(Instance).Images := TCustomImageList(Integer(Value)) + else if PropName = 'POPUPCOMPONENT' then + TPopupMenu(Instance).PopupComponent := TComponent(Integer(Value)) + + end; { if } + +end; { SetProp } + +initialization + fsRTTIModules.Add(TFunctions); + +finalization + fsRTTIModules.Remove(TFunctions); + +end. + diff --git a/official/4.2/LibD11/fs_iparser.pas b/official/4.2/LibD11/fs_iparser.pas new file mode 100644 index 0000000..47dfc68 --- /dev/null +++ b/official/4.2/LibD11/fs_iparser.pas @@ -0,0 +1,686 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Parser } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_iparser; + +interface + +{$i fs.inc} + +uses +{$IFNDEF CROSS_COMPILE} + Windows, +{$ENDIF} + SysUtils, Classes; + + +type + TfsIdentifierCharset = set of Char; + + { TfsParser parser the source text and return such elements as identifiers, + keywords, punctuation, strings and numbers. } + + TfsParser = class(TObject) + private + FCaseSensitive: Boolean; + FCommentBlock1: String; + FCommentBlock11: String; + FCommentBlock12: String; + FCommentBlock2: String; + FCommentBlock21: String; + FCommentBlock22: String; + FCommentLine1: String; + FCommentLine2: String; + FHexSequence: String; + FIdentifierCharset: TfsIdentifierCharset; + FKeywords: TStrings; + FLastPosition: Integer; + FPosition: Integer; + FSize: Integer; + FSkipChar: String; + FSkipEOL: Boolean; + FSkipSpace: Boolean; + FStringQuotes: String; + FText: String; + FUseY: Boolean; + FYList: TList; + function DoDigitSequence: Boolean; + function DoHexDigitSequence: Boolean; + function DoScaleFactor: Boolean; + function DoUnsignedInteger: Boolean; + function DoUnsignedReal: Boolean; + procedure SetPosition(const Value: Integer); + procedure SetText(const Value: String); + function Ident: String; + procedure SetCommentBlock1(const Value: String); + procedure SetCommentBlock2(const Value: String); + public + constructor Create; + destructor Destroy; override; + procedure Clear; + procedure ConstructCharset(const s: String); + + { skip all #0..#31 symbols } + procedure SkipSpaces; + { get EOL symbol } + function GetEOL: Boolean; + { get any valid ident except keyword } + function GetIdent: String; + { get any valid punctuation symbol like ,.;: } + function GetChar: String; + { get any valid ident or keyword } + function GetWord: String; + { get valid hex/int/float number } + function GetNumber: String; + { get valid quoted/control string like 'It''s'#13#10'working' } + function GetString: String; + { get FR-specific string - variable or db field like [main data."field 1"] } + function GetFRString: String; + { get Y:X position } + function GetXYPosition: String; + { get plain position from X:Y } + function GetPlainPosition(pt: TPoint): Integer; + { is this keyword? } + function IsKeyWord(const s: String): Boolean; + + // Language-dependent elements + // For Pascal: + // CommentLine1 := '//'; + // CommentBlock1 := '{,}'; + // CommentBlock2 := '(*,*)'; + // HexSequence := '$' + // IdentifierCharset := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; + // Keywords: 'begin','end', ... + // StringQuotes := '''' + property CaseSensitive: Boolean read FCaseSensitive write FCaseSensitive; + property CommentBlock1: String read FCommentBlock1 write SetCommentBlock1; + property CommentBlock2: String read FCommentBlock2 write SetCommentBlock2; + property CommentLine1: String read FCommentLine1 write FCommentLine1; + property CommentLine2: String read FCommentLine2 write FCommentLine2; + property HexSequence: String read FHexSequence write FHexSequence; + property IdentifierCharset: TfsIdentifierCharset read FIdentifierCharset + write FIdentifierCharset; + property Keywords: TStrings read FKeywords; + property SkipChar: String read FSkipChar write FSkipChar; + property SkipEOL: Boolean read FSkipEOL write FSkipEOL; + property SkipSpace: Boolean read FSkipSpace write FSkipSpace; + property StringQuotes: String read FStringQuotes write FStringQuotes; + property UseY: Boolean read FUseY write FUseY; + + { Current position } + property Position: Integer read FPosition write SetPosition; + { Text to parse } + property Text: String read FText write SetText; + end; + + +implementation + + +{ TfsParser } + +constructor TfsParser.Create; +begin + FKeywords := TStringList.Create; + TStringList(FKeywords).Sorted := True; + FYList := TList.Create; + FUseY := True; + Clear; +end; + +destructor TfsParser.Destroy; +begin + FKeywords.Free; + FYList.Free; + inherited; +end; + +procedure TfsParser.Clear; +begin + FKeywords.Clear; + FCommentLine1 := '//'; + CommentBlock1 := '{,}'; + CommentBlock2 := '(*,*)'; + FHexSequence := '$'; + FIdentifierCharset := ['_', '0'..'9', 'a'..'z', 'A'..'Z']; + FSkipChar := ''; + FSkipEOL := True; + FStringQuotes := ''''; + FSkipSpace := True; +end; + +procedure TfsParser.SetCommentBlock1(const Value: String); +var + sl: TStringList; +begin + FCommentBlock1 := Value; + FCommentBlock11 := ''; + FCommentBlock12 := ''; + + sl := TStringList.Create; + sl.CommaText := FCommentBlock1; + if sl.Count > 0 then + FCommentBlock11 := sl[0]; + if sl.Count > 1 then + FCommentBlock12 := sl[1]; + sl.Free; +end; + +procedure TfsParser.SetCommentBlock2(const Value: String); +var + sl: TStringList; +begin + FCommentBlock2 := Value; + FCommentBlock21 := ''; + FCommentBlock22 := ''; + + sl := TStringList.Create; + sl.CommaText := FCommentBlock2; + if sl.Count > 0 then + FCommentBlock21 := sl[0]; + if sl.Count > 1 then + FCommentBlock22 := sl[1]; + sl.Free; +end; + +procedure TfsParser.SetPosition(const Value: Integer); +begin + FPosition := Value; + FLastPosition := Value; +end; + +procedure TfsParser.SetText(const Value: String); +var + i: Integer; +begin + FText := Value + #0; + FLastPosition := 1; + FPosition := 1; + FSize := Length(Value); + + if FUseY then + begin + FYList.Clear; + FYList.Add(TObject(0)); + for i := 1 to FSize do + if FText[i] = #10 then + FYList.Add(TObject(i)); + end; +end; + +procedure TfsParser.ConstructCharset(const s: String); +var + i: Integer; +begin + FIdentifierCharset := []; + for i := 1 to Length(s) do + FIdentifierCharset := FIdentifierCharset + [s[i]]; +end; + +function TfsParser.GetEOL: Boolean; +begin + SkipSpaces; + if FText[FPosition] in [#10, #13] then + begin + Result := True; + while FText[FPosition] in [#10, #13] do + Inc(FPosition); + end + else + Result := False; +end; + +procedure TfsParser.SkipSpaces; +var + s1, s2: String; + Flag: Boolean; + Spaces: set of Char; +begin + Spaces := [#0..#32]; + if not FSkipEOL then +{$IFDEF LINUX} + Spaces := Spaces - [#10]; +{$ELSE} + Spaces := Spaces - [#13]; +{$ENDIF} + while (FPosition <= FSize) and (FText[FPosition] in Spaces) do + Inc(FPosition); + { skip basic '_' } + if (FPosition <= FSize) and (FSkipChar <> '') and (FText[FPosition] = FSkipChar[1]) then + begin + Inc(FPosition); + GetEOL; + SkipSpaces; + end; + + if FPosition < FSize then + begin + if FCommentLine1 <> '' then + s1 := Copy(FText, FPosition, Length(FCommentLine1)) else + s1 := ' '; + if FCommentLine2 <> '' then + s2 := Copy(FText, FPosition, Length(FCommentLine2)) else + s2 := ' '; + + if (s1 = FCommentLine1) or (s2 = FCommentLine2) then + begin + while (FPosition <= FSize) and (FText[FPosition] <> #10) do + Inc(FPosition); + SkipSpaces; + end + else + begin + Flag := False; + + if FCommentBlock1 <> '' then + begin + s1 := Copy(FText, FPosition, Length(FCommentBlock11)); + if s1 = FCommentBlock11 then + begin + Flag := True; + s2 := FCommentBlock12; + end; + end; + + if not Flag and (FCommentBlock2 <> '') then + begin + s1 := Copy(FText, FPosition, Length(FCommentBlock21)); + if s1 = FCommentBlock21 then + begin + Flag := True; + s2 := FCommentBlock22; + end; + end; + + if Flag then + begin + Inc(FPosition, Length(s2)); + while (FPosition <= FSize) and (Copy(FText, FPosition, Length(s2)) <> s2) do + Inc(FPosition); + Inc(FPosition, Length(s2)); + SkipSpaces; + end; + end; + end; + + FLastPosition := FPosition; +end; + +function TfsParser.Ident: String; +begin + if FSkipSpace then + SkipSpaces; + + if (FText[FPosition] in FIdentifierCharset - ['0'..'9']) then + begin + while FText[FPosition] in FIdentifierCharset do + Inc(FPosition); + Result := Copy(FText, FLastPosition, FPosition - FLastPosition); + end + else + Result := ''; +end; + +function TfsParser.IsKeyWord(const s: String): Boolean; +var + i: Integer; +begin + if FCaseSensitive then + begin + Result := False; + for i := 0 to FKeywords.Count - 1 do + begin + Result := FKeywords[i] = s; + if Result then break; + end; + end + else + Result := FKeywords.IndexOf(s) <> -1; +end; + +function TfsParser.GetIdent: String; +begin + Result := Ident; + if IsKeyWord(Result) then + Result := ''; +end; + +function TfsParser.GetWord: String; +begin + Result := Ident; +end; + +function TfsParser.GetChar: String; +begin + if FText[FPosition] in ['!', '@', '#', '$', '%', '^', '&', '|', '\', + '.', ',', ':', ';', '?', '''', '"', '~', '`', '_', '[', ']', '{', '}', + '(', ')', '+', '-', '*', '/', '=', '<', '>'] then + begin + Result := FText[FPosition]; + Inc(FPosition); + end + else + Result := ''; +end; + +function TfsParser.GetString: String; +var + Flag: Boolean; + Str: String; + FError: Boolean; + FCpp: Boolean; + + function DoQuotedString: Boolean; + var + i, j: Integer; + begin + Result := False; + i := FPosition; + + if FText[FPosition] = FStringQuotes[1] then + begin + repeat + Inc(FPosition); + + if FCpp and (FText[FPosition] = '\') then + begin + {$IFNDEF FPC} + case Lowercase(FText[FPosition + 1])[1] of + {$ELSE} + case Lowercase(FText[FPosition + 1]) of + {$ENDIF} + 'n': + begin + Str := Str + #10; + Inc(FPosition); + end; + 'r': + begin + Str := Str + #13; + Inc(FPosition); + end; + 'x': + begin + Inc(FPosition, 2); + j := FPosition; + Result := DoHexDigitSequence; + if Result then + Str := Str + Chr(StrToInt('$' + Copy(FText, j, FPosition - j))) else + FPosition := j; + Dec(FPosition); + end + else + begin + Str := Str + FText[FPosition + 1]; + Inc(FPosition); + end; + end; + end + else if FText[FPosition] = FStringQuotes[1] then + begin + if not FCpp and (FText[FPosition + 1] = FStringQuotes[1]) then + begin + Str := Str + FStringQuotes[1]; + Inc(FPosition); + end + else + break + end + else + Str := Str + FText[FPosition]; + until FText[FPosition] in [#0..#31] - [#9]; + + if FText[FPosition] = FStringQuotes[1] then + begin + Inc(FPosition); + Result := True; + end + else + FPosition := i; + end; + end; + + function DoControlString: Boolean; + var + i: Integer; + begin + Result := False; + i := FPosition; + + if FText[FPosition] = '#' then + begin + Inc(FPosition); + Result := DoUnsignedInteger; + if Result then + Str := Chr(StrToInt(Copy(FText, i + 1, FPosition - i - 1))) else + FPosition := i; + end; + end; + +begin + Result := ''; + if FSkipSpace then + SkipSpaces; + Flag := True; + FError := False; + FCpp := FStringQuotes = '"'; + + repeat + Str := ''; + if DoQuotedString or DoControlString then + Result := Result + Str + else + begin + FError := Flag; + break; + end; + + Flag := False; + until False; + + if not FError then + Result := '''' + Result + ''''; +end; + +function TfsParser.DoDigitSequence: Boolean; +begin + Result := False; + + if FText[FPosition] in ['0'..'9'] then + begin + while FText[FPosition] in ['0'..'9'] do + Inc(FPosition); + Result := True; + end; +end; + +function TfsParser.DoHexDigitSequence: Boolean; +begin + Result := False; + + if FText[FPosition] in ['0'..'9', 'a'..'f', 'A'..'F'] then + begin + while FText[FPosition] in ['0'..'9', 'a'..'f', 'A'..'F'] do + Inc(FPosition); + Result := True; + end; +end; + +function TfsParser.DoUnsignedInteger: Boolean; +var + Pos1: Integer; + s: String; +begin + Pos1 := FPosition; + + s := Copy(FText, FPosition, Length(FHexSequence)); + if s = FHexSequence then + begin + Inc(FPosition, Length(s)); + Result := DoHexDigitSequence; + end + else + Result := DoDigitSequence; + + if not Result then + FPosition := Pos1; +end; + +function TfsParser.DoUnsignedReal: Boolean; +var + Pos1, Pos2: Integer; +begin + Pos1 := FPosition; + Result := DoUnsignedInteger; + + if Result then + begin + if FText[FPosition] = '.' then + begin + Inc(FPosition); + Result := DoDigitSequence; + end; + + if Result then + begin + Pos2 := FPosition; + if not DoScaleFactor then + FPosition := Pos2; + end; + end; + + if not Result then + FPosition := Pos1; +end; + +function TfsParser.DoScaleFactor: Boolean; +begin + Result := False; + + if FText[FPosition] in ['e', 'E'] then + begin + Inc(FPosition); + if FText[FPosition] in ['+', '-'] then + Inc(FPosition); + Result := DoDigitSequence; + end; +end; + +function TfsParser.GetNumber: String; +var + Pos1: Integer; +begin + Result := ''; + if FSkipSpace then + SkipSpaces; + Pos1 := FPosition; + + if DoUnsignedReal or DoUnsignedInteger then + Result := Copy(FText, FLastPosition, FPosition - FLastPosition) else + FPosition := Pos1; + + if FHexSequence <> '$' then + while Pos(FHexSequence, Result) <> 0 do + begin + Pos1 := Pos(FHexSequence, Result); + Delete(Result, Pos1, Length(FHexSequence)); + Insert('$', Result, Pos1); + end; +end; + +function TfsParser.GetFRString: String; +var + i, c: Integer; + fl1, fl2: Boolean; +begin + Result := ''; + i := FPosition; + fl1 := True; + fl2 := True; + c := 1; + + Dec(FPosition); + repeat + Inc(FPosition); +{ if FText[FPosition] in [#10, #13] then + begin + FPosition := i; + break; + end;} + if fl1 and fl2 then + if FText[FPosition] in ['<', '['] then + Inc(c) + else if FText[FPosition] in ['>', ']'] then + Dec(c); + if fl1 then + if FText[FPosition] = '"' then + fl2 := not fl2; + if fl2 then + if FText[FPosition] = '''' then + fl1 := not fl1; + until (c = 0) or (FPosition >= Length(FText)); + + Result := Copy(FText, i, FPosition - i); +end; + +function TfsParser.GetXYPosition: String; +var + i, i0, i1, c, pos, X, Y: Integer; +begin + i0 := 0; + i1 := FYList.Count - 1; + + while i0 <= i1 do + begin + i := (i0 + i1) div 2; + pos := Integer(FYList[i]); + + if pos = FPosition then + c := 0 + else if pos > FPosition then + c := 1 + else + c := -1; + + if c < 0 then + i0 := i + 1 + else + begin + i1 := i - 1; + if c = 0 then + i0 := i; + end; + end; + + X := 1; + Y := i0; + i := Integer(FYList[i0 - 1]) + 1; + + while i < FPosition do + begin + Inc(i); + Inc(X); + end; + + Result := IntToStr(Y) + ':' + IntToStr(X); +end; + +function TfsParser.GetPlainPosition(pt: TPoint): Integer; +var + i: Integer; +begin + Result := -1; + i := pt.Y - 1; + if (i >= 0) and (i < FYList.Count) then + Result := Integer(FYList[i]) + pt.X; +end; + +end. diff --git a/official/4.2/LibD11/fs_ipascal.pas b/official/4.2/LibD11/fs_ipascal.pas new file mode 100644 index 0000000..db4a941 --- /dev/null +++ b/official/4.2/LibD11/fs_ipascal.pas @@ -0,0 +1,183 @@ + +{******************************************} +{ } +{ FastScript v1.9 } +{ Pascal grammar } +{ } +{ (c) 2003-2007 by Alexander Tzyganenko, } +{ Fast Reports Inc } +{ } +{******************************************} + +unit fs_ipascal; + +interface + +{$i fs.inc} + +uses + SysUtils, Classes, fs_itools; + +type + TfsPascal = class(TComponent); + +procedure fsModifyPascalForFR2; + +implementation + +const + PASCAL_GRAMMAR = + '
<' + + 'except/>