$PBExportHeader$uo_print_preview.sru
forward
global type uo_print_preview from nonvisualobject
end type
end forward

global type uo_print_preview from nonvisualobject autoinstantiate
end type

type prototypes
function boolean IsWindowsNT() library "PrintCtrl.dll"
SUBROUTINE About() library "PrintCtrl.dll"
function boolean GetDefaultPrinter(ref string PrinterName, int BufferLen) library "PrintCtrl.dll" alias for "GetDefaultPrinter;Ansi"
function boolean GetPrinterPort(ref string PrinterName, ref string Port, int PortLen, ref string Driver, int DriverLen) library "PrintCtrl.dll" alias for "GetPrinterPort;Ansi"
function boolean GetPrinterList(ref string PrinterList, ref long bufferLen) library "PrintCtrl.dll" alias for "GetPrinterList;Ansi"
function boolean GetPrinterStatus(ref string Printer, ref long status) library "PrintCtrl.dll" alias for "GetPrinterStatus;Ansi"
function boolean GetPaperList(ref string Printer, ref string PaperList, ref long bufferLen) library "PrintCtrl.dll" alias for "GetPaperList;Ansi"
function boolean SetPrinterDefault(ref string Printer) library "PrintCtrl.dll" alias for "SetPrinterDefault;Ansi"
function boolean AddCustomPaper( ref string Printer, ref string PaperName, long pwidth, long pheight, long left, long right, long top, long bottom) library "PrintCtrl.dll" alias for "AddCustomPaper;Ansi"
function boolean DeleteCustomPaper(ref string Printer, ref string PaperName) library "PrintCtrl.dll" alias for "DeleteCustomPaper;Ansi"
function boolean SetUserDefinePaper(ref string Printer, ref long pWidth, ref long pHeight) library "PrintCtrl.dll" alias for "SetUserDefinePaper;Ansi"
function boolean GetUserDefinePaperMinMax(ref string Printer, ref long minWidth, ref long minHeight, ref long maxWidth, ref long maxHeight) library "PrintCtrl.dll" alias for "GetUserDefinePaperMinMax;Ansi"
function boolean GetDefaultPaper(ref string Printer, ref string PaperName, ref int nOrientation) library "PrintCtrl.dll" alias for "GetDefaultPaper;Ansi"
function boolean SetDefaultPaper(ref string Printer, ref string PaperName, int nOrientation) library "PrintCtrl.dll" alias for "SetDefaultPaper;Ansi"
function boolean GetDefaultPaper(ref string Printer, ref string PaperName,ref long nPapserSize, ref long nOrientation) library "PrintCtrl.dll" alias for "GetDefaultPaper;Ansi"
function boolean GetPaperName(ref string Printer, ref string PaperName, int PaperSize) library "PrintCtrl.dll" alias for "GetPaperName;Ansi"
function boolean GetPaperSize(ref string Printer, ref string PaperName, ref int PaperSize) library "PrintCtrl.dll" alias for "GetPaperSize;Ansi"
function boolean GetBinNameList(ref string Printer, ref string BinNameList) library "PrintCtrl.dll" alias for "GetBinNameList;Ansi"
function boolean GetBin(ref string Printer, ref string BinName, ref int Bin) library "PrintCtrl.dll" alias for "GetBin;Ansi"
function boolean GetBinName(ref string Printer, ref string BinName, int Bin) library "PrintCtrl.dll" alias for "GetBinName;Ansi"
end prototypes

type variables
S_print_MSG  FACT_PRINT_MSG
String dwdataobject
DataWindowChild ins_dwcld
s_childreportxwidth s_xwidth
dwobject dwod
Long retrieveid = 0,secondretrieveid = 0,scid = 0

uo_printer_setting  lnv_printer
String ins_printerlist [ ]
Int p_printerlist = 0
String dw_default_printer = '',default_printer = ''
String default_printer_info = ''

Long Print_row
String default_dwname,default_dname

datastore ds_print

Int i_cbx_ifprint_xj,i_cbx_ifprint_hj




end variables

forward prototypes
public subroutine uof_initprinterinfo ()
public function integer uof_trycreate_sys_dwnsyntax (ref string arg_msg)
public function integer uof_print_begin (ref string arg_msg)
public function integer uof_defdataobject (ref string arg_msg)
public function integer uof_dwcreate (string arg_dwname, string arg_formatname, ref string arg_msg)
public function integer ds_retrieve ()
public function integer uof_read_subdwpos (string arg_dwname, string arg_dname, ref s_childreportxwidth s_subdwwidth, ref string arg_msg)
public subroutine uof_subdwpos_blobtostru (blob arg_blob, ref s_childreportxwidth arg_s_xwidth)
public function integer uof_mdfmxreport (s_childreportxwidth s_xw)
public function integer uof_mdfx (s_childreportxwidth s_xw, integer pt)
public subroutine ds_print ()
public subroutine uof_nullrow (long arg_rowcnt, long arg_pagerow, ref long arg_nullrow)
end prototypes

public subroutine uof_initprinterinfo ();// 取PB缺省打印机
String printerName
Boolean rt_1
printerName = Space(255)
rt_1 = GetDefaultPrinter(REF printerName, 255)
IF rt_1 THEN
	default_printer = Trim(printerName)
ELSE
	default_printer = ''
END IF

//取PB缺省打印机设置字符串
default_printer_info = ProfileString ( "win.ini", "windows", "device", "" )





end subroutine

public function integer uof_trycreate_sys_dwnsyntax (ref string arg_msg);//wf_trycreate_sys_dwnsyntax

long rslt=1
long cnt
string createsql_string,t_str
createsql_string="CREATE TABLE sys_dwnSyntax (	dwname char (50) NOT NULL,dname char (50) NOT NULL,default_flag tinyint not null default (0),dwSyntaxB image not NULL DEFAULT (''),subdwSyntaxB image not NULL DEFAULT ('')) "+&
      " ~n ALTER TABLE sys_dwnSyntax WITH NOCHECK ADD CONSTRAINT PK_sys_dwnSyntax PRIMARY KEY  CLUSTERED (dwname,dname)"

t_str="select count(*) from sys_dwnSyntax"

Execute immediate :t_str;  
if sqlca.sqlcode=0 then //已经存在该表
	rslt=1
	goto ext	
end if

Execute immediate :createsql_string ;  
		
if sqlca.sqlcode<>0 then
	arg_msg='建立表sys_dwnSyntax失败>>'+sqlca.sqlerrtext
	rollback ;
	rslt=0
	goto ext	
end if
commit ;

ext:
return rslt


return 0
end function

public function integer uof_print_begin (ref string arg_msg);Int rslt = 1

TRY
	//------------------初始化打印机
	uof_initprinterinfo()
	
	
	
	retrieveid = fact_print_msg.retr_pramnmb
	scid = fact_print_msg.retr_scid
	
	
	//********************
	ds_print.DataObject = fact_print_msg.obj_dwname
	ds_print.SetTransObject(SQLCA)
	
	i_cbx_ifprint_xj = Long(f_ProfileString (sys_empid,ds_print.DataObject, "cbx_ifprint_xj", '1'))
	i_cbx_ifprint_hj = Long(f_ProfileString (sys_empid,ds_print.DataObject, "cbx_ifprint_hj", '1'))
	
	//------------------读默认行数
	
	IF fact_print_msg.printrow = 0  THEN
		fact_print_msg.printrow = Long(f_profilestring (sys_empid,ds_print.DataObject, "printrow", '10'))
	END IF
	
	IF Not IsNull(fact_print_msg.ini_GROUP) And Trim(ds_print.DataObject) <> '' THEN
		ds_print.Object.DataWindow.Print.MARGIN.Top = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "MARGIN_TOP",   "110"))
		ds_print.Object.DataWindow.Print.MARGIN.Left = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "MARGIN_LEFT", "96" ))
		
		ds_print.Object.DataWindow.Print.MARGIN.bottom = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "MARGIN_BOTTOM",   "110"))
		ds_print.Object.DataWindow.Print.MARGIN.Right = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "MARGIN_RIGHT", "96" ))
		
		ds_print.Object.DataWindow.Print.PAPER.SIZE = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "PAPER_SIZE",   "0"  ))
		ds_print.Object.DataWindow.Print.ORIENTATION = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "ORIENTATION", "0"  ))
		
		dw_default_printer  = f_ProfileString(sys_empid,ds_print.DataObject, "dw_default_printer ", ""  )
	END IF
	
Catch( runtimeerror err)
	arg_msg = err.Text
	RETURN 0
END TRY


//--------------------------------------------建表
//IF uof_trycreate_sys_dwnsyntax(arg_msg) = 0 THEN
//	rslt = 0
//	GOTO ext
//END IF

//IF uof_defdataobject(arg_msg) = 0 THEN
//	rslt = 0
//	GOTO ext
//END IF

Ds_Retrieve()
//IF uof_read_subdwpos(default_dwname,default_dname,s_xwidth,arg_msg) = 0 THEN
//	rslt = 0
//	GOTO ext
//ELSE
	uof_mdfmxreport(s_xwidth)
//END IF

GOTO ext

ext:
RETURN rslt



end function

public function integer uof_defdataobject (ref string arg_msg);int rslt=1

long ls_count
blob sqlblob

select count(*) into :ls_count from sys_dwnSyntax where dwname=:fact_print_msg.obj_dwname and default_flag=1 ;
if sqlca.sqlcode=-1 then
	arg_msg='查询单据格式失败'+sqlca.sqlerrtext
	rslt=0
	goto ext
end if

if ls_count=1 then
	select dwname,dname into :default_dwname,:default_dname from sys_dwnSyntax where dwname=:fact_print_msg.obj_dwname and default_flag=1 ;
	if sqlca.sqlcode=-1 then
		arg_msg='查询单据格式失败'+sqlca.sqlerrtext
		rslt=0
		goto ext
	end if
	
	if uof_dwcreate(default_dwname,default_dname,arg_msg)=0 then
		arg_msg='打开单据格式失败！原因：'+arg_msg
		rslt=0
		goto ext
	end if
	
	ds_print.settransobject(sqlca)

end if

ext:
return rslt


end function

public function integer uof_dwcreate (string arg_dwname, string arg_formatname, ref string arg_msg);blob dwSyntax

int rslt=1

selectblob dwSyntaxB into :dwSyntax from sys_dwnSyntax where dwname=:arg_dwname and dname=:arg_formatname;
if sqlca.sqlcode=-1 then
	arg_msg='查询单据格式失败,原因:'+sqlca.sqlerrtext
	rslt=0
	goto ext
end if
if ds_print.create(string(dwSyntax),arg_msg)<>1 then
	rslt=0
	goto ext
end if
ext:
return rslt

end function

public function integer ds_retrieve ();//ds_retrieve
CHOOSE CASE fact_print_msg.retr_pram_falg
	CASE 0 //SHARE DATAWINDOW
		DATASTORE LS_DW
		LS_DW = fact_print_msg.SHARE_DW
		LS_DW.ShareData(ds_print)
	CASE 1 //ONE STRING PRAM
		ds_print.Retrieve(fact_print_msg.retr_pramstr)
	CASE 2 //ONE NUMBER PRAM
		ds_print.Retrieve(fact_print_msg.retr_pramnmb)
		retrieveid = fact_print_msg.retr_pramnmb
	CASE 3 //ONE DATE PRAM
		ds_print.Retrieve(fact_print_msg.retr_pramfd)
	CASE 4 //TWO DATE PRAM
		ds_print.Retrieve(fact_print_msg.retr_pramfd,fact_print_msg.retr_pramed)
	CASE 5 //TWO NUMBER PRAM
		ds_print.Retrieve(fact_print_msg.retr_pramnmb,fact_print_msg.b_long)
	CASE 11 //scid string
		ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramstr)
	CASE 12 //scid long
		ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb)
	CASE 13 //scid long and TWO NUMBER PRAM
		ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.b_long)
	CASE 14 //TWO DATETIME PRAM
		ds_print.Retrieve(fact_print_msg.retr_pramfdt,fact_print_msg.retr_pramedt)
	CASE 15 //scid long and TWO NUMBER PRAM and null_row
		uof_nullrow(fact_print_msg.rowcnt,fact_print_msg.printrow,fact_print_msg.nullrow)
		ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.printrow,fact_print_msg.nullrow)
	CASE 16 //scid long and TWO NUMBER PRAM and null_row
		uof_nullrow(fact_print_msg.rowcnt,fact_print_msg.printrow,fact_print_msg.nullrow)
		ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.a_string_arr,fact_print_msg.printrow,fact_print_msg.nullrow)
	CASE 17
		uof_nullrow(fact_print_msg.rowcnt,fact_print_msg.printrow,fact_print_msg.nullrow)
		ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.a_string_arr,fact_print_msg.printrow,fact_print_msg.nullrow)
	CASE 18
		ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.b_long,fact_print_msg.c_long)
	CASE 19
		ds_print.Retrieve(fact_print_msg.a_string_arr)
	CASE 20
		ds_print.Retrieve(fact_print_msg.a_long_arr)
	CASE 25 //kjls特殊应用 20141228
		ds_print.Retrieve(fact_print_msg.retr_pramnmb,f_kjls_getfj(fact_print_msg.retr_pramnmb))
	CASE ELSE
		ds_print.Retrieve()
END CHOOSE
IF fact_print_msg.retr_pram_falg <> 0 THEN
	ds_print.SetFilter(fact_print_msg.FILTER_STRING)
	ds_print.Filter()
END IF
RETURN 0


end function

public function integer uof_read_subdwpos (string arg_dwname, string arg_dname, ref s_childreportxwidth s_subdwwidth, ref string arg_msg);//uof_read_subdwpos(arg_dwname,arg_dname,arg_msg)
blob ls_subdwSyntaxB
int rslt=1
 
selectblob subdwSyntaxB into :ls_subdwSyntaxB from sys_dwnSyntax  where dwname=:arg_dwname and dname=:arg_dname;
if sqlca.sqlcode=-1 then
	arg_msg='读取单据明细表格式失败！'+sqlca.sqlerrtext
	rslt=0 
	goto ext
end if

if len(ls_subdwSyntaxB)>0 then
	dwod=ds_print.object.mxreport
	uof_subdwpos_blobtostru(ls_subdwSyntaxB,s_subdwwidth)
end if
ext:
return rslt
end function

public subroutine uof_subdwpos_blobtostru (blob arg_blob, ref s_childreportxwidth arg_s_xwidth);//uof_subdwpos_blobtostru(arg_blob,arg_s_xwidth)
string subdwpos_str,clm_str,cmp_str,clm_strx,clm_strwidth,cmplp_x,cmplp_width
long clm_p,cmplp,i
subdwpos_str=string(arg_blob)
clm_str=mid(subdwpos_str,1,pos(subdwpos_str,'cmplp:') - 1)
cmp_str=mid(subdwpos_str,pos(subdwpos_str,'cmplp:'))

clm_strx=mid(clm_str,pos(clm_str,'x:')+2,pos(clm_str,';width:') - pos(clm_str,'x:') - 1 ) //x_str
clm_strwidth=mid(clm_str,pos(clm_str,'width:') + 6)   //width_str

cmplp_x=mid(cmp_str,pos(cmp_str,'x:')+2,pos(cmp_str,';width:') - pos(cmp_str,'x:') - 1 )
cmplp_width=mid(cmp_str,pos(cmp_str,'width:') + 6)   //cmplpwidth_str

clm_p=long(mid(clm_str,3,pos(clm_str,';') - 3)) //P
cmplp=long(mid(cmp_str,7,pos(cmp_str,';') - 7)) //cmplp

arg_s_xwidth.p=clm_p
arg_s_xwidth.cmplp=cmplp
//messagebox('all',subdwpos_str)
//MEssagebox('clm_str',clm_str)
//MEssagebox('cmp_str',cmp_str)
//
//MEssagebox('clm_p',clm_p)
//MEssagebox('cmplp',cmplp)
//
//MEssagebox('clm_strx',clm_strx)
//MEssagebox('clm_strwidth',clm_strwidth)



long xmx
string xstr
xmx=0
xstr=''
for i =1 to len(clm_strx)        //x
	if mid(clm_strx,i,1)<>',' and mid(clm_strx,i,1)<>';' then
		xstr=xstr+mid(clm_strx,i,1)
	else
		xmx++
		arg_s_xwidth.x[xmx]=long(xstr)
		xstr=''
	end if
next
	
xmx=0
xstr=''
for i =1 to len(clm_strwidth)        //width
	if mid(clm_strwidth,i,1)<>',' and mid(clm_strwidth,i,1)<>';' then
		xstr=xstr+mid(clm_strwidth,i,1)
	else
		xmx++
		arg_s_xwidth.width[xmx]=long(xstr)
		xstr=''
	end if
next
	
xmx=0
xstr=''
for i =1 to len(cmplp_x)        //cmplp_x
	if mid(cmplp_x,i,1)<>',' and mid(cmplp_x,i,1)<>';' then
		xstr=xstr+mid(cmplp_x,i,1)
	else
		xmx++
		arg_s_xwidth.cmplx[xmx]=long(xstr)
		xstr=''
	end if
next
	
xmx=0
xstr=''
for i =1 to len(cmplp_width)        //cmplp_width
	if mid(cmplp_width,i,1)<>',' and mid(cmplp_width,i,1)<>';' then
		xstr=xstr+mid(cmplp_width,i,1)
	else
		xmx++
		arg_s_xwidth.cmplwidth[xmx]=long(xstr)
		xstr=''
	end if
next
	
	

//messagebox('','sdfsdf')
	
	
	
	
	
	

end subroutine

public function integer uof_mdfmxreport (s_childreportxwidth s_xw);//uof_mdfmxreport(s_childreportxwidth)


if s_xw.p=0 then 
	return 0
end if

if mod(s_xw.cmplp,2)=1 then
	if s_xw.cmplx[1]>0 then dwod.object.cmpl1.width=s_xw.cmplwidth[1]
end if
if s_xw.cmplp=2 or s_xw.cmplp=3 then
	if s_xw.cmplx[2]>0 then dwod.object.cmpl2.width= s_xw.cmplwidth[2]
end if
if s_xw.cmplp=4 or s_xw.cmplp=6 or s_xw.cmplp=7  then
	if s_xw.cmplp=6 or s_xw.cmplp=7 then 
		if s_xw.cmplx[2]>0 then dwod.object.cmpl2.width= s_xw.cmplwidth[2] //yyx0609
	end if
	if s_xw.cmplx[3]>0 then dwod.object.cmpl3.width= s_xw.cmplwidth[3]
end if


if s_xw.x[1]>0 then dwod.object.#1.width=s_xw.width[1]
if s_xw.p<2 then goto mdfx
if s_xw.x[2]>0 then dwod.object.#2.width=s_xw.width[2]
if s_xw.p<3 then goto mdfx
if s_xw.x[3]>0 then dwod.object.#3.width=s_xw.width[3]
if s_xw.p<4 then goto mdfx
if s_xw.x[4]>0 then dwod.object.#4.width=s_xw.width[4]
if s_xw.p<5 then goto mdfx
if s_xw.x[5]>0 then dwod.object.#5.width=s_xw.width[5]
if s_xw.p<6 then goto mdfx
if s_xw.x[6]>0 then dwod.object.#6.width=s_xw.width[6]
if s_xw.p<7 then goto mdfx
if s_xw.x[7]>0 then dwod.object.#7.width=s_xw.width[7]
if s_xw.p<8 then goto mdfx
if s_xw.x[8]>0 then dwod.object.#8.width=s_xw.width[8]
if s_xw.p<9 then goto mdfx
if s_xw.x[9]>0 then dwod.object.#9.width=s_xw.width[9]
if s_xw.p<10 then goto mdfx
if s_xw.x[10]>0 then dwod.object.#10.width=s_xw.width[10]
if s_xw.p<11 then goto mdfx
if s_xw.x[11]>0 then dwod.object.#11.width=s_xw.width[11]
if s_xw.p<12 then goto mdfx
if s_xw.x[12]>0 then dwod.object.#12.width=s_xw.width[12]
if s_xw.p<13 then goto mdfx
if s_xw.x[13]>0 then dwod.object.#13.width=s_xw.width[13]
if s_xw.p<14 then goto mdfx
if s_xw.x[14]>0 then dwod.object.#14.width=s_xw.width[14]
if s_xw.p<15 then goto mdfx
if s_xw.x[15]>0 then dwod.object.#15.width=s_xw.width[15]
if s_xw.p<16 then goto mdfx
if s_xw.x[16]>0 then dwod.object.#16.width=s_xw.width[16]
if s_xw.p<17 then goto mdfx
if s_xw.x[17]>0 then dwod.object.#17.width=s_xw.width[17]
if s_xw.p<18 then goto mdfx
if s_xw.x[18]>0 then dwod.object.#18.width=s_xw.width[18]
if s_xw.p<19 then goto mdfx
if s_xw.x[19]>0 then dwod.object.#19.width=s_xw.width[19]
if s_xw.p<20 then goto mdfx
if s_xw.x[20]>0 then dwod.object.#20.width=s_xw.width[20]
if s_xw.p<21 then goto mdfx
if s_xw.x[21]>0 then dwod.object.#21.width=s_xw.width[21]
if s_xw.p<22 then goto mdfx
if s_xw.x[22]>0 then dwod.object.#22.width=s_xw.width[22]
if s_xw.p<23 then goto mdfx
if s_xw.x[23]>0 then dwod.object.#23.width=s_xw.width[23]
if s_xw.p<24 then goto mdfx
if s_xw.x[24]>0 then dwod.object.#24.width=s_xw.width[24]
if s_xw.p<25 then goto mdfx
if s_xw.x[25]>0 then dwod.object.#25.width=s_xw.width[25]
if s_xw.p<26 then goto mdfx
if s_xw.x[26]>0 then dwod.object.#26.width=s_xw.width[26]
if s_xw.p<27 then goto mdfx
if s_xw.x[27]>0 then dwod.object.#27.width=s_xw.width[27]
if s_xw.p<28 then goto mdfx
if s_xw.x[28]>0 then dwod.object.#28.width=s_xw.width[28]
if s_xw.p<29 then goto mdfx
if s_xw.x[29]>0 then dwod.object.#29.width=s_xw.width[29]



mdfx:

if mod(s_xw.cmplp,2)=1 then
	if s_xw.cmplx[1]>0 then dwod.object.cmpl1.x= s_xw.cmplx[1] - 9
end if
if s_xw.cmplp=2 or s_xw.cmplp=3 then
	if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9
end if
if s_xw.cmplp=4 or s_xw.cmplp=6 or s_xw.cmplp=7  then
	if s_xw.cmplp=6 or s_xw.cmplp=7 then 
		if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9 //yyx0609
	end if
	if s_xw.cmplx[3]>0 then dwod.object.cmpl3.x= s_xw.cmplx[3] - 9
end if

long obp,bp,bi,bj,bk
obp=0
for bi=1 to s_xw.p
	bp=50000
	bk=0
	for bj=1 to s_xw.p
		if s_xw.x[bj]<bp and s_xw.x[bj]>obp and s_xw.x[bj]>0 then 
			bp=s_xw.x[bj]
			bk=bj
		end if
	next
	if mod(s_xw.cmplp,2)=1 then
		if s_xw.cmplx[1]<bp and s_xw.cmplx[1]>obp and s_xw.cmplx[1]>0 then 
			bp=s_xw.cmplx[1]
			bk=0
			bi = bi -1
			dwod.object.cmpl1.x= s_xw.cmplx[1] - 9
		end if
	end if

	uof_mdfx(s_xw,bk)
	obp=bp
next

if mod(s_xw.cmplp,2)=1 then
	if s_xw.cmplx[1]>0 then dwod.object.cmpl1.x= s_xw.cmplx[1] - 9
end if
if s_xw.cmplp=2 or s_xw.cmplp=3 then
	if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9
end if
if s_xw.cmplp=4 or s_xw.cmplp=6 or s_xw.cmplp=7  then
	if s_xw.cmplp=6 or s_xw.cmplp=7 then 
		if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9 //yyx0609
	end if
	if s_xw.cmplx[3]>0 then dwod.object.cmpl3.x= s_xw.cmplx[3] - 9
end if

return 0

end function

public function integer uof_mdfx (s_childreportxwidth s_xw, integer pt);//uof_mdfx(s_childreportxwidth,int)

if s_xw.p=0 or pt=0 then 
	return 0
end if

CHOOSE CASE pt
	CASE 1
	if s_xw.p>=1 and s_xw.x[1]>0 then dwod.object.#1.x=s_xw.x[1] - 9
	CASE 2
	if s_xw.p>=2 and s_xw.x[2]>0 then dwod.object.#2.x=s_xw.x[2] - 9
	CASE 3
	if s_xw.p>=3 and s_xw.x[3]>0 then dwod.object.#3.x=s_xw.x[3] - 9
	CASE 4
	if s_xw.p>=4 and s_xw.x[4]>0 then dwod.object.#4.x=s_xw.x[4] - 9
	CASE 5
	if s_xw.p>=5 and s_xw.x[5]>0 then dwod.object.#5.x=s_xw.x[5] - 9
	CASE 6
	if s_xw.p>=6 and s_xw.x[6]>0 then dwod.object.#6.x=s_xw.x[6] - 9
	CASE 7
	if s_xw.p>=7 and s_xw.x[7]>0 then dwod.object.#7.x=s_xw.x[7] - 9
	CASE 8
	if s_xw.p>=8 and s_xw.x[8]>0 then dwod.object.#8.x=s_xw.x[8] - 9
	CASE 9
	if s_xw.p>=9 and s_xw.x[9]>0 then dwod.object.#9.x=s_xw.x[9] - 9
	CASE 10
	if s_xw.p>=10 and s_xw.x[10]>0 then dwod.object.#10.x=s_xw.x[10] - 9
	CASE 11
	if s_xw.p>=11 and s_xw.x[11]>0 then dwod.object.#11.x=s_xw.x[11] - 9
	CASE 12
	if s_xw.p>=12 and s_xw.x[12]>0 then dwod.object.#12.x=s_xw.x[12] - 9
	CASE 13
	if s_xw.p>=13 and s_xw.x[13]>0 then dwod.object.#13.x=s_xw.x[13] - 9
	CASE 14
	if s_xw.p>=14 and s_xw.x[14]>0 then dwod.object.#14.x=s_xw.x[14] - 9
	CASE 15
	if s_xw.p>=15 and s_xw.x[15]>0 then dwod.object.#15.x=s_xw.x[15] - 9
	CASE 16
	if s_xw.p>=16 and s_xw.x[16]>0 then dwod.object.#16.x=s_xw.x[16] - 9
	CASE 17
	if s_xw.p>=17 and s_xw.x[17]>0 then dwod.object.#17.x=s_xw.x[17] - 9
	CASE 18
	if s_xw.p>=18 and s_xw.x[18]>0 then dwod.object.#18.x=s_xw.x[18] - 9
	CASE 19
	if s_xw.p>=19 and s_xw.x[19]>0 then dwod.object.#19.x=s_xw.x[19] - 9
	CASE 20
	if s_xw.p>=20 and s_xw.x[20]>0 then dwod.object.#20.x=s_xw.x[20] - 9
	CASE 21
	if s_xw.p>=21 and s_xw.x[21]>0 then dwod.object.#21.x=s_xw.x[21] - 9
	CASE 22
	if s_xw.p>=22 and s_xw.x[22]>0 then dwod.object.#22.x=s_xw.x[22] - 9
	CASE 23
	if s_xw.p>=23 and s_xw.x[23]>0 then dwod.object.#23.x=s_xw.x[23] - 9
	CASE 24
	if s_xw.p>=24 and s_xw.x[24]>0 then dwod.object.#24.x=s_xw.x[24] - 9
	CASE 25
	if s_xw.p>=25 and s_xw.x[25]>0 then dwod.object.#25.x=s_xw.x[25] - 9
	CASE 26
	if s_xw.p>=26 and s_xw.x[26]>0 then dwod.object.#26.x=s_xw.x[26] - 9
	CASE 27
	if s_xw.p>=27 and s_xw.x[27]>0 then dwod.object.#27.x=s_xw.x[27] - 9
	CASE 28
	if s_xw.p>=28 and s_xw.x[28]>0 then dwod.object.#28.x=s_xw.x[28] - 9
	CASE 29
	if s_xw.p>=29 and s_xw.x[29]>0 then dwod.object.#29.x=s_xw.x[29] - 9
	
END CHOOSE


return 0

end function

public subroutine ds_print ();lnv_printer.of_SetDefault ( dw_default_printer )
ds_print.print()

end subroutine

public subroutine uof_nullrow (long arg_rowcnt, long arg_pagerow, ref long arg_nullrow);//====================================================================
// Function: uof_nullrow()
//--------------------------------------------------------------------
// Description:返回加空行数
//--------------------------------------------------------------------
// Arguments: 
//		value    	long	arg_rowcnt 		
//		value    	long	arg_pagerow		
//		reference	long	arg_nullrow		
//--------------------------------------------------------------------
// Returns:  (none)
//--------------------------------------------------------------------
// Author:	yyx		Date: 2004.09.13
//--------------------------------------------------------------------
// Modify History: 
//	
//====================================================================
Long pagecnt,tal_rowcnt

pagecnt = Long(arg_rowcnt / arg_pagerow)

tal_rowcnt += arg_rowcnt
IF i_cbx_ifprint_xj = 1 THEN
	tal_rowcnt += pagecnt
END IF

IF i_cbx_ifprint_hj = 1 THEN
	tal_rowcnt += 1
END IF

IF Mod(tal_rowcnt,arg_pagerow) <> 0 THEN
	arg_nullrow = arg_pagerow - Mod(tal_rowcnt,arg_pagerow)
ELSE
	arg_nullrow = 0
END IF






end subroutine

on uo_print_preview.create
call super::create
TriggerEvent( this, "constructor" )
end on

on uo_print_preview.destroy
TriggerEvent( this, "destructor" )
call super::destroy
end on

event constructor;ds_print = create datastore 
end event

