*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="test.scx" CPID="1250" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS dataenvironment AS dataenvironment 
 	*< CLASSDATA: Baseclass="dataenvironment" Timestamp="" Scale="" Uniqueid="" ClassIcon="1" />

	*<PropValue>
		DataSource = .NULL.
		Height = 0
		Left = 0
		Name = "Dataenvironment"
		Top = 0
		Width = 0
	*</PropValue>

ENDDEFINE

DEFINE CLASS form1 AS form 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Shape1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="frx" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdBrowseFrx" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label2" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="pdf" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdSaveasPDF" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="encrypt" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="preview" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="userpwd" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Command3" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Command4" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkPrint" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkCopy" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Label5" UniqueID="" Timestamp="" />

	*<PropValue>
		AlwaysOnTop = .F.
		AutoCenter = .T.
		Caption = "Test PDF Listener class"
		DoCreate = .T.
		Height = 348
		Name = "Form1"
		Width = 385
	*</PropValue>

	ADD OBJECT 'chkCopy' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		Caption = "User can copy text/images from document", ;
		Enabled = .F., ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 15, ;
		Left = 112, ;
		Name = "chkCopy", ;
		TabIndex = 14, ;
		Top = 220, ;
		Value = .T., ;
		Width = 221
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'chkPrint' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		Caption = "User can print document", ;
		Enabled = .F., ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 15, ;
		Left = 112, ;
		Name = "chkPrint", ;
		TabIndex = 13, ;
		Top = 196, ;
		Value = .T., ;
		Width = 135
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'cmdBrowseFrx' AS commandbutton WITH ;
		Caption = "...", ;
		FontName = "Tahoma", ;
		Height = 23, ;
		Left = 304, ;
		Name = "cmdBrowseFrx", ;
		StatusBarText = "Browse For Report", ;
		TabIndex = 3, ;
		ToolTipText = "Browse For Report", ;
		Top = 16, ;
		Width = 28
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmdSaveasPDF' AS commandbutton WITH ;
		Caption = "...", ;
		FontName = "Tahoma", ;
		Height = 23, ;
		Left = 304, ;
		Name = "cmdSaveasPDF", ;
		StatusBarText = "Save as", ;
		TabIndex = 6, ;
		ToolTipText = "Save as", ;
		Top = 44, ;
		Width = 28
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'Command3' AS commandbutton WITH ;
		Caption = "\<Run report", ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 27, ;
		Left = 72, ;
		Name = "Command3", ;
		StatusBarText = "Runs the Report", ;
		TabIndex = 15, ;
		ToolTipText = "Runs the Report", ;
		Top = 280, ;
		Width = 84
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'Command4' AS commandbutton WITH ;
		Cancel = .T., ;
		Caption = "\<Cancel", ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 27, ;
		Left = 192, ;
		Name = "Command4", ;
		StatusBarText = "Closes the Window", ;
		TabIndex = 16, ;
		ToolTipText = "Closes the Window", ;
		Top = 280, ;
		Width = 84
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'encrypt' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		Caption = "Encrypt PDF.", ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 15, ;
		Left = 120, ;
		Name = "encrypt", ;
		StatusBarText = "If Checked PDF Will Be Encrypted", ;
		TabIndex = 8, ;
		ToolTipText = "If Checked PDF Will Be Encrypted", ;
		Top = 96, ;
		Value = .F., ;
		Width = 81
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'frx' AS textbox WITH ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 23, ;
		Left = 76, ;
		Name = "frx", ;
		StatusBarText = "Report File Name", ;
		TabIndex = 2, ;
		ToolTipText = "Report File Name", ;
		Top = 16, ;
		Width = 213
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'Label1' AS label WITH ;
		AutoSize = .T., ;
		Caption = "FRX", ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 15, ;
		Left = 25, ;
		Name = "Label1", ;
		StatusBarText = "Report File Name", ;
		TabIndex = 1, ;
		ToolTipText = "Report File Name", ;
		Top = 19, ;
		Width = 21
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label2' AS label WITH ;
		AutoSize = .T., ;
		Caption = "PDF File ", ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 15, ;
		Left = 24, ;
		Name = "Label2", ;
		StatusBarText = "Name of the PDF File to Create", ;
		TabIndex = 4, ;
		ToolTipText = "Name of the PDF File to Create", ;
		Top = 48, ;
		Width = 43
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label4' AS label WITH ;
		AutoSize = .T., ;
		Caption = "Password to open:", ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 15, ;
		Left = 48, ;
		Name = "Label4", ;
		StatusBarText = "PDF Document User Password", ;
		TabIndex = 11, ;
		ToolTipText = "PDF Document User Password", ;
		Top = 164, ;
		Width = 92
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'Label5' AS label WITH ;
		AutoSize = .T., ;
		Caption = "Permissions/encryption", ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 15, ;
		Left = 36, ;
		Name = "Label5", ;
		StatusBarText = "Name of the PDF File to Create", ;
		TabIndex = 17, ;
		ToolTipText = "Name of the PDF File to Create", ;
		Top = 124, ;
		Width = 112
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'pdf' AS textbox WITH ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 23, ;
		Left = 76, ;
		Name = "pdf", ;
		StatusBarText = "Name of the PDF File to Create", ;
		TabIndex = 5, ;
		ToolTipText = "Name of the PDF File to Create", ;
		Top = 44, ;
		Value = output.pdf, ;
		Width = 213
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'preview' AS checkbox WITH ;
		Alignment = 0, ;
		AutoSize = .T., ;
		Caption = "Preview in Adobe Reader", ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 15, ;
		Left = 120, ;
		Name = "preview", ;
		StatusBarText = "If Checked PDF  Reader Will Be Opened", ;
		TabIndex = 7, ;
		ToolTipText = "If Checked PDF  Reader Will Be Opened", ;
		Top = 76, ;
		Value = .T., ;
		Width = 139
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'Shape1' AS shape WITH ;
		Height = 136, ;
		Left = 28, ;
		Name = "Shape1", ;
		SpecialEffect = 0, ;
		Style = 3, ;
		Top = 132, ;
		Width = 328
		*< END OBJECT: BaseClass="shape" />

	ADD OBJECT 'userpwd' AS textbox WITH ;
		Enabled = .F., ;
		FontName = "Tahoma", ;
		FontSize = 8, ;
		Height = 23, ;
		Left = 152, ;
		Name = "userpwd", ;
		StatusBarText = "PDF Document User Password", ;
		TabIndex = 12, ;
		ToolTipText = "PDF Document User Password", ;
		Top = 160, ;
		Width = 104
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE cmdBrowseFrx.Click
		Thisform.frx.Value = GetFile("frx")
		
	ENDPROC

	PROCEDURE cmdSaveasPDF.Click
		Thisform.pdf.Value = Putfile("Save generated PDF as:","","pdf")
	ENDPROC

	PROCEDURE Command3.Click
		local oL as pdflistener of pdflistener.prg
		
		*set path to correctly initialize PDF Listener, as it is based on UpdateListener
		set path to REPORTOUTPUT 
		
		if Empty(thisform.frX.Value) or Empty(thisform.pdf.Value)
			wait window 'Nothing to do!' nowait 
			return
		endif
		
		oL = Newobject('pdflistener','pdflistener.prg')
		
		oL.enable_copy = thisform.chkCopy.Value 
		oL.enable_print = thisform.chkPrint.Value
		
		oL.user_passwd = Trim(thisform.userpwd.Value) 
		
		if thisform.preview.Value 
			report form (thisform.frx.Value) preview object oL
		else
			report form (thisform.frx.Value) object oL
		endif 
		
		
		
	ENDPROC

	PROCEDURE Command4.Click
		Thisform.Release
	ENDPROC

	PROCEDURE encrypt.Valid
		store this.Value to ;
			thisform.chkCopy.Enabled  ;
			,thisform.chkPrint.Enabled  ;
			,thisform.userpwd.Enabled  
		
	ENDPROC

ENDDEFINE
