DEFINE CLASS ReportExtender AS Custom ** Hidden/ protected properties HIDDEN _oPDFListener && Object reference to the PDFListener class HIDDEN _oHTMLListener && Object reference to the HTMLListener class ** Public properties sGSLocation = ADDBS(FULLPATH(".\GS")) && Location of the GhostScript files (PDF only) PROCEDURE RunReport(oReportParams AS Object) LOCAL oListener AS Object LOCAL sExtension AS String LOCAL sFileName AS String oListener = NULL sExtension = "" WITH This ** Set the data session to ensure that the report's data is avaialble SET DATASESSION TO (oReportParams.iDataSession) ** Determine which listener to call into DO CASE CASE oReportParams.iReportType = REPORT_TYPE_PDF oListener = ._oPDFListener sExtension = "pdf" CASE oReportParams.iReportType = REPORT_TYPE_HTML oListener = ._oHTMLListener sExtension = "html" ENDCASE ** If no destination file name was passed in... IF EMPTY(oReportParams.sFileName) ** Create a file name located in the user's temp folder sFileName = GETENV("TEMP") sFileName = ADDBS(sFileName) + SYS(2015) + "." + sExtension ELSE ** Use the name passed on the params object sFileName = oReportParams.sFileName ENDIF ** Set the file destination file name on the report listener class oListener.TargetFileName = sFileName oListener.QuietMode = TRUE ** Add the report to the listener class' reports collection oListener.AddReport(oReportParams.sReportFile) ** Call into the PDFListener class's RunReport method ** EXECUTING THIS LINE WILL CAUSE THE DATA SESSION TO CHANGE oListener.RunReports() ENDPROCThe Init of my wrapper has:
** Create an instance of the listener class ._oPDFListener = CREATEOBJECT("PDFListener") ** Set up needed properties on the listener class ._oPDFListener.GSLocation = .sGSLocation ._oPDFListener.PSDriverSetupName = DRIVER_NAME ._oPDFListener.GenerateNewStyleOutput = .F.Lisa has overwritten the RunReport method in her class:
PROCEDURE RunReports(tlRemoveReportsAfterRun, tlOmitListenerReferences) IF (NOT ISNULL(THIS.ReportFileNames)) AND ; (NOT EMPTY(THIS.ReportFileNames[1])) AND ; THIS.LoadPrinterInfo() IF EMPTY(JUSTEXT(THIS.TargetFileName)) THIS.TargetFileName = FORCEEXT(THIS.TargetFileName,THIS.TargetFileExt) ENDIF THIS.verifyTargetFile() IF PCOUNT() = 2 OR VARTYPE(THIS.generateNewStyleOutput) # "L" DODEFAULT(.F., tlOmitListenerReferences) ELSE DODEFAULT(.F.,NOT THIS.generateNewStyleOutput) ENDIF THIS.UnloadPrinterInfo() RETURN THIS.ProcessPDF(tlRemoveReportsAfterRun) ELSE RETURN .F. ENDIF ENDPROCSo, the moment the debugger steps into the line:
PROCEDURE RunReports(tlRemoveReportsAfterRun, tlOmitListenerReferences)
the datasession changes.