uo_print_preview.sru 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. $PBExportHeader$uo_print_preview.sru
  2. forward
  3. global type uo_print_preview from nonvisualobject
  4. end type
  5. end forward
  6. global type uo_print_preview from nonvisualobject autoinstantiate
  7. end type
  8. type prototypes
  9. function boolean IsWindowsNT() library "PrintCtrl.dll"
  10. SUBROUTINE About() library "PrintCtrl.dll"
  11. function boolean GetDefaultPrinter(ref string PrinterName, int BufferLen) library "PrintCtrl.dll" alias for "GetDefaultPrinter;Ansi"
  12. function boolean GetPrinterPort(ref string PrinterName, ref string Port, int PortLen, ref string Driver, int DriverLen) library "PrintCtrl.dll" alias for "GetPrinterPort;Ansi"
  13. function boolean GetPrinterList(ref string PrinterList, ref long bufferLen) library "PrintCtrl.dll" alias for "GetPrinterList;Ansi"
  14. function boolean GetPrinterStatus(ref string Printer, ref long status) library "PrintCtrl.dll" alias for "GetPrinterStatus;Ansi"
  15. function boolean GetPaperList(ref string Printer, ref string PaperList, ref long bufferLen) library "PrintCtrl.dll" alias for "GetPaperList;Ansi"
  16. function boolean SetPrinterDefault(ref string Printer) library "PrintCtrl.dll" alias for "SetPrinterDefault;Ansi"
  17. 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"
  18. function boolean DeleteCustomPaper(ref string Printer, ref string PaperName) library "PrintCtrl.dll" alias for "DeleteCustomPaper;Ansi"
  19. function boolean SetUserDefinePaper(ref string Printer, ref long pWidth, ref long pHeight) library "PrintCtrl.dll" alias for "SetUserDefinePaper;Ansi"
  20. 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"
  21. function boolean GetDefaultPaper(ref string Printer, ref string PaperName, ref int nOrientation) library "PrintCtrl.dll" alias for "GetDefaultPaper;Ansi"
  22. function boolean SetDefaultPaper(ref string Printer, ref string PaperName, int nOrientation) library "PrintCtrl.dll" alias for "SetDefaultPaper;Ansi"
  23. function boolean GetDefaultPaper(ref string Printer, ref string PaperName,ref long nPapserSize, ref long nOrientation) library "PrintCtrl.dll" alias for "GetDefaultPaper;Ansi"
  24. function boolean GetPaperName(ref string Printer, ref string PaperName, int PaperSize) library "PrintCtrl.dll" alias for "GetPaperName;Ansi"
  25. function boolean GetPaperSize(ref string Printer, ref string PaperName, ref int PaperSize) library "PrintCtrl.dll" alias for "GetPaperSize;Ansi"
  26. function boolean GetBinNameList(ref string Printer, ref string BinNameList) library "PrintCtrl.dll" alias for "GetBinNameList;Ansi"
  27. function boolean GetBin(ref string Printer, ref string BinName, ref int Bin) library "PrintCtrl.dll" alias for "GetBin;Ansi"
  28. function boolean GetBinName(ref string Printer, ref string BinName, int Bin) library "PrintCtrl.dll" alias for "GetBinName;Ansi"
  29. end prototypes
  30. type variables
  31. S_print_MSG FACT_PRINT_MSG
  32. string dwdataobject
  33. DataWindowChild ins_dwcld
  34. s_childreportxwidth s_xwidth
  35. dwobject dwod
  36. long retrieveid=0,secondretrieveid=0,scid=0
  37. uo_printer_setting lnv_printer
  38. String ins_printerlist [ ]
  39. int p_printerlist =0
  40. string dw_default_printer ='',default_printer =''
  41. string default_printer_info=''
  42. LONG Print_row
  43. string default_dwname,default_dname
  44. datastore ds_print
  45. end variables
  46. forward prototypes
  47. public subroutine uof_initprinterinfo ()
  48. public function integer uof_trycreate_sys_dwnsyntax (ref string arg_msg)
  49. public function integer uof_print_begin (ref string arg_msg)
  50. public function integer uof_defdataobject (ref string arg_msg)
  51. public function integer uof_dwcreate (string arg_dwname, string arg_formatname, ref string arg_msg)
  52. public function integer uof_read_subdwpos (string arg_dwname, string arg_dname, ref s_childreportxwidth s_subdwwidth, ref string arg_msg)
  53. public subroutine uof_subdwpos_blobtostru (blob arg_blob, ref s_childreportxwidth arg_s_xwidth)
  54. public function integer uof_mdfmxreport (s_childreportxwidth s_xw)
  55. public function integer uof_mdfx (s_childreportxwidth s_xw, integer pt)
  56. public subroutine ds_print ()
  57. public subroutine uof_nullrow (long arg_rowcnt, long arg_pagerow, ref long arg_nullrow)
  58. public subroutine ds_retrieve ()
  59. public subroutine uof_add_pic ()
  60. end prototypes
  61. public subroutine uof_initprinterinfo ();// 取PB缺省打印机
  62. String printerName
  63. Boolean rt_1
  64. printerName = Space(255)
  65. rt_1 = GetDefaultPrinter(REF printerName, 255)
  66. IF rt_1 THEN
  67. default_printer = Trim(printerName)
  68. ELSE
  69. default_printer = ''
  70. END IF
  71. //取PB缺省打印机设置字符串
  72. default_printer_info = ProfileString ( "win.ini", "windows", "device", "" )
  73. end subroutine
  74. public function integer uof_trycreate_sys_dwnsyntax (ref string arg_msg);//wf_trycreate_sys_dwnsyntax
  75. long rslt=1
  76. long cnt
  77. string createsql_string,t_str
  78. 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 ('')) "+&
  79. " ~n ALTER TABLE sys_dwnSyntax WITH NOCHECK ADD CONSTRAINT PK_sys_dwnSyntax PRIMARY KEY CLUSTERED (dwname,dname)"
  80. t_str="select count(*) from sys_dwnSyntax"
  81. Execute immediate :t_str;
  82. if sqlca.sqlcode=0 then //已经存在该表
  83. rslt=1
  84. goto ext
  85. end if
  86. Execute immediate :createsql_string ;
  87. if sqlca.sqlcode<>0 then
  88. arg_msg='建立表sys_dwnSyntax失败>>'+sqlca.sqlerrtext
  89. rollback ;
  90. rslt=0
  91. goto ext
  92. end if
  93. commit ;
  94. ext:
  95. return rslt
  96. return 0
  97. end function
  98. public function integer uof_print_begin (ref string arg_msg);Int rslt = 1
  99. //------------------初始化打印机
  100. uof_initprinterinfo()
  101. retrieveid = fact_print_msg.retr_pramnmb
  102. scid = fact_print_msg.retr_scid
  103. //获取DW嵌套子DW
  104. String ls_pblname,ls_pblpath,dwsyntax
  105. String ls_dw_arr[]
  106. String ls_comments[]
  107. Long ll_beg,ll_end,it_max
  108. Select pblname
  109. Into :ls_pblname
  110. From sys_dft_dwprint_dynamic
  111. Where dft_new_dwname = :fact_print_msg.obj_dwname;
  112. If sqlca.SQLCode <> 0 Then
  113. ls_pblname = ''
  114. End If
  115. If ls_pblname <> '' Then
  116. If f_init_dftpbl(ls_pblname,fact_print_msg.obj_dwname,arg_msg) = 0 Then
  117. rslt = 0
  118. Goto ext
  119. End If
  120. End If
  121. //********************
  122. ds_print.DataObject = fact_print_msg.obj_dwname
  123. ds_print.SetTransObject(sqlca)
  124. If ds_print.Describe("DataWindow.Objects") = "" Then
  125. arg_msg = '初始化打印格式失败,请检查重定向设置'
  126. ds_print.DataObject = ''
  127. rslt = 0
  128. Goto ext
  129. End If
  130. //------------------读默认行数
  131. If fact_print_msg.printrow = 0 Then
  132. fact_print_msg.printrow = Long(ProfileString (sys_inifilename,ds_print.DataObject, "printrow", '10'))
  133. End If
  134. //--------------------------------------------建表
  135. If uof_trycreate_sys_dwnsyntax(arg_msg) = 0 Then
  136. rslt = 0
  137. Goto ext
  138. End If
  139. If uof_defdataobject(arg_msg) = 0 Then
  140. rslt = 0
  141. Goto ext
  142. End If
  143. Ds_Retrieve()
  144. If uof_read_subdwpos(default_dwname,default_dname,s_xwidth,arg_msg) = 0 Then
  145. rslt = 0
  146. Goto ext
  147. Else
  148. uof_mdfmxreport(s_xwidth)
  149. End If
  150. If Not IsNull(fact_print_msg.ini_GROUP) And Trim(ds_print.DataObject) <> '' Then
  151. // ds_print.Object.DataWindow.Print.MARGIN.Top = Integer(ProfileString(sys_inifilename,ds_print.DataObject, "MARGIN_TOP", "110"))
  152. // ds_print.Object.DataWindow.Print.MARGIN.Left = Integer(ProfileString(sys_inifilename,ds_print.DataObject, "MARGIN_LEFT", "96" ))
  153. //
  154. // ds_print.Object.DataWindow.Print.MARGIN.bottom = Integer(ProfileString(sys_inifilename,ds_print.DataObject, "MARGIN_BOTTOM", "110"))
  155. // ds_print.Object.DataWindow.Print.MARGIN.Right = Integer(ProfileString(sys_inifilename,ds_print.DataObject, "MARGIN_RIGHT", "96" ))
  156. //
  157. // ds_print.Object.DataWindow.Print.PAPER.SIZE = Integer(ProfileString(sys_inifilename,ds_print.DataObject, "PAPER_SIZE", "0" ))
  158. // ds_print.Object.DataWindow.Print.ORIENTATION = Integer(ProfileString(sys_inifilename,ds_print.DataObject, "ORIENTATION", "0" ))
  159. //
  160. // dw_default_printer = ProfileString(sys_inifilename,ds_print.DataObject, "dw_default_printer ", "" )
  161. Integer margin_top = -1,margin_left = -1,margin_bottom = -1,margin_right = -1,paper_size = -1,orientation = -1
  162. margin_top = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "margin_top", "-1"))
  163. margin_left = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "margin_left", "-1" ))
  164. margin_bottom = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "margin_bottom", "-1"))
  165. margin_right = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "margin_right", "-1" ))
  166. paper_size = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "paper_size", "-1" ))
  167. orientation = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "orientation", "-1" ))
  168. // ds_print.Object.DataWindow.Print.MARGIN.Top = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "margin_top", "110"))
  169. // ds_print.Object.DataWindow.Print.MARGIN.Left = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "margin_left", "96" ))
  170. //
  171. // ds_print.Object.DataWindow.Print.MARGIN.bottom = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "margin_bottom", "110"))
  172. // ds_print.Object.DataWindow.Print.MARGIN.Right = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "margin_right", "96" ))
  173. //
  174. // ds_print.Object.DataWindow.Print.PAPER.SIZE = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "paper_size", "0" ))
  175. // ds_print.Object.DataWindow.Print.ORIENTATION = Integer(f_ProfileString(sys_empid,ds_print.DataObject, "orientation", "0" ))
  176. //
  177. If margin_top > 0 Then
  178. ds_print.Object.datawindow.Print.margin.Top = margin_top
  179. End If
  180. If margin_left > 0 Then
  181. ds_print.Object.datawindow.Print.margin.Left = margin_left
  182. End If
  183. If margin_bottom > 0 Then
  184. ds_print.Object.datawindow.Print.margin.bottom = margin_bottom
  185. End If
  186. If margin_right > 0 Then
  187. ds_print.Object.datawindow.Print.margin.Right = margin_right
  188. End If
  189. If paper_size > 0 Then
  190. ds_print.Object.datawindow.Print.paper.size = paper_size
  191. End If
  192. If orientation > 0 Then
  193. ds_print.Object.datawindow.Print.orientation = orientation
  194. End If
  195. dw_default_printer = f_ProfileString(sys_empid,ds_print.DataObject, "dw_default_printer ", "" )
  196. End If
  197. ext:
  198. Return rslt
  199. end function
  200. public function integer uof_defdataobject (ref string arg_msg);int rslt=1
  201. long ls_count
  202. blob sqlblob
  203. select count(*) into :ls_count from sys_dwnSyntax where dwname=:fact_print_msg.obj_dwname and default_flag=1 ;
  204. if sqlca.sqlcode=-1 then
  205. arg_msg='查询单据格式失败'+sqlca.sqlerrtext
  206. rslt=0
  207. goto ext
  208. end if
  209. if ls_count=1 then
  210. select dwname,dname into :default_dwname,:default_dname from sys_dwnSyntax where dwname=:fact_print_msg.obj_dwname and default_flag=1 ;
  211. if sqlca.sqlcode=-1 then
  212. arg_msg='查询单据格式失败'+sqlca.sqlerrtext
  213. rslt=0
  214. goto ext
  215. end if
  216. if uof_dwcreate(default_dwname,default_dname,arg_msg)=0 then
  217. arg_msg='打开单据格式失败!原因:'+arg_msg
  218. rslt=0
  219. goto ext
  220. end if
  221. ds_print.settransobject(sqlca)
  222. end if
  223. ext:
  224. return rslt
  225. end function
  226. public function integer uof_dwcreate (string arg_dwname, string arg_formatname, ref string arg_msg);blob dwSyntax
  227. int rslt=1
  228. selectblob dwSyntaxB into :dwSyntax from sys_dwnSyntax where dwname=:arg_dwname and dname=:arg_formatname;
  229. if sqlca.sqlcode=-1 then
  230. arg_msg='查询单据格式失败,原因:'+sqlca.sqlerrtext
  231. rslt=0
  232. goto ext
  233. end if
  234. if ds_print.create(string(dwSyntax),arg_msg)<>1 then
  235. rslt=0
  236. goto ext
  237. end if
  238. ext:
  239. return rslt
  240. end function
  241. 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)
  242. blob ls_subdwSyntaxB
  243. int rslt=1
  244. selectblob subdwSyntaxB into :ls_subdwSyntaxB from sys_dwnSyntax where dwname=:arg_dwname and dname=:arg_dname;
  245. if sqlca.sqlcode=-1 then
  246. arg_msg='读取单据明细表格式失败!'+sqlca.sqlerrtext
  247. rslt=0
  248. goto ext
  249. end if
  250. if len(ls_subdwSyntaxB)>0 then
  251. dwod=ds_print.object.mxreport
  252. uof_subdwpos_blobtostru(ls_subdwSyntaxB,s_subdwwidth)
  253. end if
  254. ext:
  255. return rslt
  256. end function
  257. public subroutine uof_subdwpos_blobtostru (blob arg_blob, ref s_childreportxwidth arg_s_xwidth);//uof_subdwpos_blobtostru(arg_blob,arg_s_xwidth)
  258. string subdwpos_str,clm_str,cmp_str,clm_strx,clm_strwidth,cmplp_x,cmplp_width
  259. long clm_p,cmplp,i
  260. subdwpos_str=string(arg_blob)
  261. clm_str=mid(subdwpos_str,1,pos(subdwpos_str,'cmplp:') - 1)
  262. cmp_str=mid(subdwpos_str,pos(subdwpos_str,'cmplp:'))
  263. clm_strx=mid(clm_str,pos(clm_str,'x:')+2,pos(clm_str,';width:') - pos(clm_str,'x:') - 1 ) //x_str
  264. clm_strwidth=mid(clm_str,pos(clm_str,'width:') + 6) //width_str
  265. cmplp_x=mid(cmp_str,pos(cmp_str,'x:')+2,pos(cmp_str,';width:') - pos(cmp_str,'x:') - 1 )
  266. cmplp_width=mid(cmp_str,pos(cmp_str,'width:') + 6) //cmplpwidth_str
  267. clm_p=long(mid(clm_str,3,pos(clm_str,';') - 3)) //P
  268. cmplp=long(mid(cmp_str,7,pos(cmp_str,';') - 7)) //cmplp
  269. arg_s_xwidth.p=clm_p
  270. arg_s_xwidth.cmplp=cmplp
  271. //messagebox('all',subdwpos_str)
  272. //MEssagebox('clm_str',clm_str)
  273. //MEssagebox('cmp_str',cmp_str)
  274. //
  275. //MEssagebox('clm_p',clm_p)
  276. //MEssagebox('cmplp',cmplp)
  277. //
  278. //MEssagebox('clm_strx',clm_strx)
  279. //MEssagebox('clm_strwidth',clm_strwidth)
  280. long xmx
  281. string xstr
  282. xmx=0
  283. xstr=''
  284. for i =1 to len(clm_strx) //x
  285. if mid(clm_strx,i,1)<>',' and mid(clm_strx,i,1)<>';' then
  286. xstr=xstr+mid(clm_strx,i,1)
  287. else
  288. xmx++
  289. arg_s_xwidth.x[xmx]=long(xstr)
  290. xstr=''
  291. end if
  292. next
  293. xmx=0
  294. xstr=''
  295. for i =1 to len(clm_strwidth) //width
  296. if mid(clm_strwidth,i,1)<>',' and mid(clm_strwidth,i,1)<>';' then
  297. xstr=xstr+mid(clm_strwidth,i,1)
  298. else
  299. xmx++
  300. arg_s_xwidth.width[xmx]=long(xstr)
  301. xstr=''
  302. end if
  303. next
  304. xmx=0
  305. xstr=''
  306. for i =1 to len(cmplp_x) //cmplp_x
  307. if mid(cmplp_x,i,1)<>',' and mid(cmplp_x,i,1)<>';' then
  308. xstr=xstr+mid(cmplp_x,i,1)
  309. else
  310. xmx++
  311. arg_s_xwidth.cmplx[xmx]=long(xstr)
  312. xstr=''
  313. end if
  314. next
  315. xmx=0
  316. xstr=''
  317. for i =1 to len(cmplp_width) //cmplp_width
  318. if mid(cmplp_width,i,1)<>',' and mid(cmplp_width,i,1)<>';' then
  319. xstr=xstr+mid(cmplp_width,i,1)
  320. else
  321. xmx++
  322. arg_s_xwidth.cmplwidth[xmx]=long(xstr)
  323. xstr=''
  324. end if
  325. next
  326. //messagebox('','sdfsdf')
  327. end subroutine
  328. public function integer uof_mdfmxreport (s_childreportxwidth s_xw);//uof_mdfmxreport(s_childreportxwidth)
  329. if s_xw.p=0 then
  330. return 0
  331. end if
  332. if mod(s_xw.cmplp,2)=1 then
  333. if s_xw.cmplx[1]>0 then dwod.object.cmpl1.width=s_xw.cmplwidth[1]
  334. end if
  335. if s_xw.cmplp=2 or s_xw.cmplp=3 then
  336. if s_xw.cmplx[2]>0 then dwod.object.cmpl2.width= s_xw.cmplwidth[2]
  337. end if
  338. if s_xw.cmplp=4 or s_xw.cmplp=6 or s_xw.cmplp=7 then
  339. if s_xw.cmplp=6 or s_xw.cmplp=7 then
  340. if s_xw.cmplx[2]>0 then dwod.object.cmpl2.width= s_xw.cmplwidth[2] //yyx0609
  341. end if
  342. if s_xw.cmplx[3]>0 then dwod.object.cmpl3.width= s_xw.cmplwidth[3]
  343. end if
  344. if s_xw.x[1]>0 then dwod.object.#1.width=s_xw.width[1]
  345. if s_xw.p<2 then goto mdfx
  346. if s_xw.x[2]>0 then dwod.object.#2.width=s_xw.width[2]
  347. if s_xw.p<3 then goto mdfx
  348. if s_xw.x[3]>0 then dwod.object.#3.width=s_xw.width[3]
  349. if s_xw.p<4 then goto mdfx
  350. if s_xw.x[4]>0 then dwod.object.#4.width=s_xw.width[4]
  351. if s_xw.p<5 then goto mdfx
  352. if s_xw.x[5]>0 then dwod.object.#5.width=s_xw.width[5]
  353. if s_xw.p<6 then goto mdfx
  354. if s_xw.x[6]>0 then dwod.object.#6.width=s_xw.width[6]
  355. if s_xw.p<7 then goto mdfx
  356. if s_xw.x[7]>0 then dwod.object.#7.width=s_xw.width[7]
  357. if s_xw.p<8 then goto mdfx
  358. if s_xw.x[8]>0 then dwod.object.#8.width=s_xw.width[8]
  359. if s_xw.p<9 then goto mdfx
  360. if s_xw.x[9]>0 then dwod.object.#9.width=s_xw.width[9]
  361. if s_xw.p<10 then goto mdfx
  362. if s_xw.x[10]>0 then dwod.object.#10.width=s_xw.width[10]
  363. if s_xw.p<11 then goto mdfx
  364. if s_xw.x[11]>0 then dwod.object.#11.width=s_xw.width[11]
  365. if s_xw.p<12 then goto mdfx
  366. if s_xw.x[12]>0 then dwod.object.#12.width=s_xw.width[12]
  367. if s_xw.p<13 then goto mdfx
  368. if s_xw.x[13]>0 then dwod.object.#13.width=s_xw.width[13]
  369. if s_xw.p<14 then goto mdfx
  370. if s_xw.x[14]>0 then dwod.object.#14.width=s_xw.width[14]
  371. if s_xw.p<15 then goto mdfx
  372. if s_xw.x[15]>0 then dwod.object.#15.width=s_xw.width[15]
  373. if s_xw.p<16 then goto mdfx
  374. if s_xw.x[16]>0 then dwod.object.#16.width=s_xw.width[16]
  375. if s_xw.p<17 then goto mdfx
  376. if s_xw.x[17]>0 then dwod.object.#17.width=s_xw.width[17]
  377. if s_xw.p<18 then goto mdfx
  378. if s_xw.x[18]>0 then dwod.object.#18.width=s_xw.width[18]
  379. if s_xw.p<19 then goto mdfx
  380. if s_xw.x[19]>0 then dwod.object.#19.width=s_xw.width[19]
  381. if s_xw.p<20 then goto mdfx
  382. if s_xw.x[20]>0 then dwod.object.#20.width=s_xw.width[20]
  383. if s_xw.p<21 then goto mdfx
  384. if s_xw.x[21]>0 then dwod.object.#21.width=s_xw.width[21]
  385. if s_xw.p<22 then goto mdfx
  386. if s_xw.x[22]>0 then dwod.object.#22.width=s_xw.width[22]
  387. if s_xw.p<23 then goto mdfx
  388. if s_xw.x[23]>0 then dwod.object.#23.width=s_xw.width[23]
  389. if s_xw.p<24 then goto mdfx
  390. if s_xw.x[24]>0 then dwod.object.#24.width=s_xw.width[24]
  391. if s_xw.p<25 then goto mdfx
  392. if s_xw.x[25]>0 then dwod.object.#25.width=s_xw.width[25]
  393. if s_xw.p<26 then goto mdfx
  394. if s_xw.x[26]>0 then dwod.object.#26.width=s_xw.width[26]
  395. if s_xw.p<27 then goto mdfx
  396. if s_xw.x[27]>0 then dwod.object.#27.width=s_xw.width[27]
  397. if s_xw.p<28 then goto mdfx
  398. if s_xw.x[28]>0 then dwod.object.#28.width=s_xw.width[28]
  399. if s_xw.p<29 then goto mdfx
  400. if s_xw.x[29]>0 then dwod.object.#29.width=s_xw.width[29]
  401. mdfx:
  402. if mod(s_xw.cmplp,2)=1 then
  403. if s_xw.cmplx[1]>0 then dwod.object.cmpl1.x= s_xw.cmplx[1] - 9
  404. end if
  405. if s_xw.cmplp=2 or s_xw.cmplp=3 then
  406. if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9
  407. end if
  408. if s_xw.cmplp=4 or s_xw.cmplp=6 or s_xw.cmplp=7 then
  409. if s_xw.cmplp=6 or s_xw.cmplp=7 then
  410. if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9 //yyx0609
  411. end if
  412. if s_xw.cmplx[3]>0 then dwod.object.cmpl3.x= s_xw.cmplx[3] - 9
  413. end if
  414. long obp,bp,bi,bj,bk
  415. obp=0
  416. for bi=1 to s_xw.p
  417. bp=50000
  418. bk=0
  419. for bj=1 to s_xw.p
  420. if s_xw.x[bj]<bp and s_xw.x[bj]>obp and s_xw.x[bj]>0 then
  421. bp=s_xw.x[bj]
  422. bk=bj
  423. end if
  424. next
  425. if mod(s_xw.cmplp,2)=1 then
  426. if s_xw.cmplx[1]<bp and s_xw.cmplx[1]>obp and s_xw.cmplx[1]>0 then
  427. bp=s_xw.cmplx[1]
  428. bk=0
  429. bi = bi -1
  430. dwod.object.cmpl1.x= s_xw.cmplx[1] - 9
  431. end if
  432. end if
  433. uof_mdfx(s_xw,bk)
  434. obp=bp
  435. next
  436. if mod(s_xw.cmplp,2)=1 then
  437. if s_xw.cmplx[1]>0 then dwod.object.cmpl1.x= s_xw.cmplx[1] - 9
  438. end if
  439. if s_xw.cmplp=2 or s_xw.cmplp=3 then
  440. if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9
  441. end if
  442. if s_xw.cmplp=4 or s_xw.cmplp=6 or s_xw.cmplp=7 then
  443. if s_xw.cmplp=6 or s_xw.cmplp=7 then
  444. if s_xw.cmplx[2]>0 then dwod.object.cmpl2.x= s_xw.cmplx[2] - 9 //yyx0609
  445. end if
  446. if s_xw.cmplx[3]>0 then dwod.object.cmpl3.x= s_xw.cmplx[3] - 9
  447. end if
  448. return 0
  449. end function
  450. public function integer uof_mdfx (s_childreportxwidth s_xw, integer pt);//uof_mdfx(s_childreportxwidth,int)
  451. if s_xw.p=0 or pt=0 then
  452. return 0
  453. end if
  454. CHOOSE CASE pt
  455. CASE 1
  456. if s_xw.p>=1 and s_xw.x[1]>0 then dwod.object.#1.x=s_xw.x[1] - 9
  457. CASE 2
  458. if s_xw.p>=2 and s_xw.x[2]>0 then dwod.object.#2.x=s_xw.x[2] - 9
  459. CASE 3
  460. if s_xw.p>=3 and s_xw.x[3]>0 then dwod.object.#3.x=s_xw.x[3] - 9
  461. CASE 4
  462. if s_xw.p>=4 and s_xw.x[4]>0 then dwod.object.#4.x=s_xw.x[4] - 9
  463. CASE 5
  464. if s_xw.p>=5 and s_xw.x[5]>0 then dwod.object.#5.x=s_xw.x[5] - 9
  465. CASE 6
  466. if s_xw.p>=6 and s_xw.x[6]>0 then dwod.object.#6.x=s_xw.x[6] - 9
  467. CASE 7
  468. if s_xw.p>=7 and s_xw.x[7]>0 then dwod.object.#7.x=s_xw.x[7] - 9
  469. CASE 8
  470. if s_xw.p>=8 and s_xw.x[8]>0 then dwod.object.#8.x=s_xw.x[8] - 9
  471. CASE 9
  472. if s_xw.p>=9 and s_xw.x[9]>0 then dwod.object.#9.x=s_xw.x[9] - 9
  473. CASE 10
  474. if s_xw.p>=10 and s_xw.x[10]>0 then dwod.object.#10.x=s_xw.x[10] - 9
  475. CASE 11
  476. if s_xw.p>=11 and s_xw.x[11]>0 then dwod.object.#11.x=s_xw.x[11] - 9
  477. CASE 12
  478. if s_xw.p>=12 and s_xw.x[12]>0 then dwod.object.#12.x=s_xw.x[12] - 9
  479. CASE 13
  480. if s_xw.p>=13 and s_xw.x[13]>0 then dwod.object.#13.x=s_xw.x[13] - 9
  481. CASE 14
  482. if s_xw.p>=14 and s_xw.x[14]>0 then dwod.object.#14.x=s_xw.x[14] - 9
  483. CASE 15
  484. if s_xw.p>=15 and s_xw.x[15]>0 then dwod.object.#15.x=s_xw.x[15] - 9
  485. CASE 16
  486. if s_xw.p>=16 and s_xw.x[16]>0 then dwod.object.#16.x=s_xw.x[16] - 9
  487. CASE 17
  488. if s_xw.p>=17 and s_xw.x[17]>0 then dwod.object.#17.x=s_xw.x[17] - 9
  489. CASE 18
  490. if s_xw.p>=18 and s_xw.x[18]>0 then dwod.object.#18.x=s_xw.x[18] - 9
  491. CASE 19
  492. if s_xw.p>=19 and s_xw.x[19]>0 then dwod.object.#19.x=s_xw.x[19] - 9
  493. CASE 20
  494. if s_xw.p>=20 and s_xw.x[20]>0 then dwod.object.#20.x=s_xw.x[20] - 9
  495. CASE 21
  496. if s_xw.p>=21 and s_xw.x[21]>0 then dwod.object.#21.x=s_xw.x[21] - 9
  497. CASE 22
  498. if s_xw.p>=22 and s_xw.x[22]>0 then dwod.object.#22.x=s_xw.x[22] - 9
  499. CASE 23
  500. if s_xw.p>=23 and s_xw.x[23]>0 then dwod.object.#23.x=s_xw.x[23] - 9
  501. CASE 24
  502. if s_xw.p>=24 and s_xw.x[24]>0 then dwod.object.#24.x=s_xw.x[24] - 9
  503. CASE 25
  504. if s_xw.p>=25 and s_xw.x[25]>0 then dwod.object.#25.x=s_xw.x[25] - 9
  505. CASE 26
  506. if s_xw.p>=26 and s_xw.x[26]>0 then dwod.object.#26.x=s_xw.x[26] - 9
  507. CASE 27
  508. if s_xw.p>=27 and s_xw.x[27]>0 then dwod.object.#27.x=s_xw.x[27] - 9
  509. CASE 28
  510. if s_xw.p>=28 and s_xw.x[28]>0 then dwod.object.#28.x=s_xw.x[28] - 9
  511. CASE 29
  512. if s_xw.p>=29 and s_xw.x[29]>0 then dwod.object.#29.x=s_xw.x[29] - 9
  513. END CHOOSE
  514. return 0
  515. end function
  516. public subroutine ds_print ();lnv_printer.of_SetDefault ( dw_default_printer )
  517. ds_print.print()
  518. end subroutine
  519. public subroutine uof_nullrow (long arg_rowcnt, long arg_pagerow, ref long arg_nullrow);//====================================================================
  520. // Function: uof_nullrow()
  521. //--------------------------------------------------------------------
  522. // Description:返回加空行数
  523. //--------------------------------------------------------------------
  524. // Arguments:
  525. // value long arg_rowcnt
  526. // value long arg_pagerow
  527. // reference long arg_nullrow
  528. //--------------------------------------------------------------------
  529. // Returns: (none)
  530. //--------------------------------------------------------------------
  531. // Author: yyx Date: 2004.09.13
  532. //--------------------------------------------------------------------
  533. // Modify History:
  534. //
  535. //====================================================================
  536. long pagecnt,tal_rowcnt
  537. pagecnt = long(arg_rowcnt / arg_pagerow)
  538. tal_rowcnt = arg_rowcnt + pagecnt + 1
  539. if mod(tal_rowcnt,arg_pagerow)<>0 then
  540. arg_nullrow = arg_pagerow - mod(tal_rowcnt,arg_pagerow)
  541. else
  542. arg_nullrow = 0
  543. end if
  544. end subroutine
  545. public subroutine ds_retrieve ();//ds_retrieve
  546. CHOOSE CASE fact_print_msg.retr_pram_falg
  547. CASE 0 //SHARE DATAWINDOW
  548. DATAWINDOW LS_DW
  549. LS_DW = fact_print_msg.SHARE_DW
  550. LS_DW.ShareData(ds_print)
  551. CASE 1 //ONE STRING PRAM
  552. ds_print.Retrieve(fact_print_msg.retr_pramstr)
  553. CASE 2 //ONE NUMBER PRAM
  554. ds_print.Retrieve(fact_print_msg.retr_pramnmb)
  555. retrieveid = fact_print_msg.retr_pramnmb
  556. CASE 3 //ONE DATE PRAM
  557. ds_print.Retrieve(fact_print_msg.retr_pramfd)
  558. CASE 4 //TWO DATE PRAM
  559. ds_print.Retrieve(fact_print_msg.retr_pramfd,fact_print_msg.retr_pramed)
  560. CASE 5 //TWO NUMBER PRAM
  561. ds_print.Retrieve(fact_print_msg.retr_pramnmb,fact_print_msg.b_long)
  562. CASE 11 //scid string
  563. ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramstr)
  564. CASE 12 //scid long
  565. ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb)
  566. CASE 13 //scid long and TWO NUMBER PRAM
  567. ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.b_long)
  568. CASE 14 //TWO DATETIME PRAM
  569. ds_print.Retrieve(fact_print_msg.retr_pramfdt,fact_print_msg.retr_pramedt)
  570. CASE 15 //scid long and TWO NUMBER PRAM and null_row
  571. uof_nullrow(fact_print_msg.rowcnt,fact_print_msg.printrow,fact_print_msg.nullrow)
  572. ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.printrow,fact_print_msg.nullrow)
  573. CASE 16 //scid long and TWO NUMBER PRAM and null_row
  574. uof_nullrow(fact_print_msg.rowcnt,fact_print_msg.printrow,fact_print_msg.nullrow)
  575. ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.a_string_arr,fact_print_msg.printrow,fact_print_msg.nullrow)
  576. CASE 17
  577. uof_nullrow(fact_print_msg.rowcnt,fact_print_msg.printrow,fact_print_msg.nullrow)
  578. ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.a_string_arr,fact_print_msg.printrow,fact_print_msg.nullrow)
  579. case 18
  580. ds_print.Retrieve(fact_print_msg.retr_scid,fact_print_msg.retr_pramnmb,fact_print_msg.b_long,fact_print_msg.c_long)
  581. CASE ELSE
  582. ds_print.Retrieve()
  583. END CHOOSE
  584. IF fact_print_msg.retr_pram_falg <> 0 THEN
  585. ds_print.SetFilter(fact_print_msg.FILTER_STRING)
  586. ds_print.Filter()
  587. END IF
  588. IF fact_print_msg.ifpic = 1 THEN
  589. uof_add_pic()
  590. END IF
  591. end subroutine
  592. public subroutine uof_add_pic ();Long Columns,i,j,k
  593. String ls_modify_str
  594. Boolean lb_find = False
  595. IF Pos(Lower(ds_print.Describe("DataWindow.Objects")),'print_picture') > 0 THEN
  596. Columns = Long(ds_print.Describe("DataWindow.Column.Count"))
  597. FOR i = 1 To Columns
  598. ls_modify_str = ds_print.Describe("#" + String(i) + ".name")
  599. ls_modify_str = Lower(ls_modify_str)
  600. IF Pos(ls_modify_str,'mtrlid') > 0 Or Pos(ls_modify_str,'_mtrlid') > 0 THEN
  601. lb_find = True
  602. EXIT
  603. END IF
  604. NEXT
  605. IF lb_find THEN
  606. FOR j = 1 To ds_print.RowCount()
  607. IF ds_print.GetItemNumber( j, ls_modify_str ) > 0 THEN
  608. FOR k = 1 To UpperBound(fact_print_msg.s_pic.path)
  609. IF ds_print.GetItemNumber( j, ls_modify_str ) = fact_print_msg.s_pic.mtrlid[k] THEN
  610. ds_print.Object.Print_Picture[j] = fact_print_msg.s_pic.path[k]
  611. END IF
  612. NEXT
  613. ELSE
  614. EXIT
  615. END IF
  616. NEXT
  617. END IF
  618. END IF
  619. //String a,c
  620. //a = childwod.dataobject
  621. //datastore b
  622. //b = create datastore
  623. //b.DataObject = a
  624. //b.SetTransObject (sqlca)
  625. //IF ds_print.Describe('mxreport.type') = 'report' And Pos(Lower(b.Describe("DataWindow.Objects")),'print_picture') > 0 THEN
  626. // Columns = Long(b.Describe("DataWindow.Column.Count"))
  627. // childwod = ds_print.Object.mxreport
  628. //
  629. // FOR i = 1 To Columns
  630. // ls_modify_str = b.Describe("#" + String(i) + ".name")
  631. // ls_modify_str = Lower(ls_modify_str)
  632. // IF Pos(Lower(ls_modify_str),'mtrlid') > 0 Or Pos(Lower(ls_modify_str),'_mtrlid') > 0 THEN
  633. // FOR j = 1 To 1
  634. // FOR k = 1 To UpperBound(fact_print_msg.s_pic.path)
  635. //// IF childwod.GetItemNumber( j, ls_modify_str ) = fact_print_msg.s_pic.mtrlid[k] THEN
  636. // childwod.Object.Print_Picture[j] = fact_print_msg.s_pic.path[k]
  637. //// END IF
  638. // NEXT
  639. // NEXT
  640. // END IF
  641. // NEXT
  642. //ELSE
  643. //END IF
  644. end subroutine
  645. on uo_print_preview.create
  646. call super::create
  647. TriggerEvent( this, "constructor" )
  648. end on
  649. on uo_print_preview.destroy
  650. TriggerEvent( this, "destructor" )
  651. call super::destroy
  652. end on
  653. event constructor;ds_print = create datastore
  654. end event