*--
*-- Implements a Report Preview in HTML format that shows the pages in a Navigation Page
*-- Author: Fabio Vazquez
*--
*-- Goal..: Brazilian Visual FoxPro Conference 2004
*-- Demonstrate the Report Listener funtionalities
*--
LOCAL lcPath as String
LOCAL loRL as ReportListener
LOCAL loIE as InternetExplorer.Application
lcPath = JUSTPATH(SYS(16))
CD (lcPath)
loRL = CREATEOBJECT("NavPaneListener", lcPath)
IF TYPE("loRL") != "O"
RETURN
ENDIF
*-- Renders the page but doesn't send it to to the output device.
*-- The events are triggered normally, giving us the chance to capture
*-- interesting events like "OutputPage"
loRL.ListenerType = 2
REPORT FORM ? OBJECT loRL
*================================================
DEFINE CLASS NavPaneListener as ReportListener
*================================================
HIDDEN cPathSaida as String
HIDDEN oVisualizador as MeuVisualizador
*---------------------------------------------------------------------------
PROCEDURE Init(tcPathSaida as String)
*---------------------------------------------------------------------------
IF MESSAGEBOX("You are about to preview a report. Are you sure?", 4+32, "VFP 9") = 7
RETURN .F.
ENDIF
IF !EMPTY(tcPathSaida)
This.cPathSaida = ADDBS(tcPathSaida)
ELSE
This.cPathSaida = ""
ENDIF
This.oVisualizador = NEWOBJECT("MeuVisualizador")
ENDPROC
*---------------------------------------------------------------------------
PROCEDURE OutputPage ;
( ;
nPageNo as Integer, ;
eDevice as Object, ;
nDeviceType as Integer ;
)
*---------------------------------------------------------------------------
WAIT WINDOW "Printing page <" + NVL(TRANSFORM(npageNo),"Null") + ">..." NOWAIT
DO CASE
CASE nDeviceType == -1 && None
nDeviceType = 103 && GIF
This.OutputPage(nPageNo, This.cPathSaida + "Pagina" + TRANSFORM(nPageNo) + ".GIF", nDeviceType)
CASE nDeviceType == 103
This.oVisualizador.AddPagina(eDevice)
ENDCASE
WAIT CLEAR
ENDPROC
*---------------------------------------------------------------------------
PROCEDURE AfterReport
*---------------------------------------------------------------------------
This.oVisualizador.GerarVisualizacao(This.cPathSaida)
ENDPROC
ENDDEFINE
*=========================================
DEFINE CLASS MeuVisualizador as Custom
*=========================================
HIDDEN oXML as MSXML2.DOMDocument
HIDDEN oXSL as MSXML2.DOMDocument
*---------------------------------------------------------------------------
PROCEDURE Init
*---------------------------------------------------------------------------
LOCAL lcXML as String
This.oXML = NEWOBJECT("MSXML2.DOMDocument")
This.oXSL = NEWOBJECT("MSXML2.DOMDocument")
TEXT TO lcXML NOSHOW TEXTMERGE PRETEXT 1+2+4