$PBExportHeader$f_rpt_unit.srf global type f_rpt_unit from function_object end type forward prototypes global function string f_rpt_unit (string as_dw, integer ai_unit) end prototypes global function string f_rpt_unit (string as_dw, integer ai_unit);datastore lds string ls[],sx[],ls1,ls2,ls3,ls4,ls5,ls6,lss,ls_type//暂时先用以下方法处理,如果发现有问题,最好不要采用先MODIFY的方法 long j,m,n,o,q,ll,k,p decimal ln_bl=2.65295//单位换算比例 lds=create datastore lss=as_dw lds.create(lss) q=long(lds.describe('datawindow.units'))//0=Pb单位,1=象素单位,3=0.1毫米 if q=ai_unit then goto f_end p=f_atab(ls[],lds.describe('datawindow.bands')) k=f_atab(ls[],lds.describe('datawindow.bands')+'~t'+lds.describe('datawindow.objects')+'~tdatawindow') for j=1 to k ls_type=lds.describe(ls[j]+'.type') m=0 choose case ls_type case 'line' m=5 sx[1]='x1' sx[2]='y1' sx[3]='x2' sx[4]='y2' sx[5]='pen.width' case 'rectangle','ellipse','roundrectangle' m=5 sx[1]='x' sx[2]='y' sx[3]='width' sx[4]='height' sx[5]='pen.width' case 'text','column','compute','bitmap','tableblob','report','button','groupbox','graph' m=5 sx[1]='x' sx[2]='y' sx[3]='width' sx[4]='height' sx[5]='font.height' if ai_unit=1 or ls_type='graph' then m=4 end if case else if j<=p then//'band' m=1 sx[1]='height' elseif j=k then//'datawindow' m=4 sx[1]='print.margin.left' sx[2]='print.margin.right' sx[3]='print.margin.top' sx[4]='print.margin.bottom' if lds.describe('datawindow.processing')='2' then m=10 sx[5]='label.width' sx[6]='label.height' sx[7]='label.rows.spacing' sx[8]='label.columns.spacing' sx[9]='label.ellipse_height' sx[10]='label.ellipse_width' end if else continue end if end choose for n=1 to m if j<=p then//'band' ls5='datawindow.'+ls[j]+'.'+sx[n] else ls5=ls[j]+'.'+sx[n] end if ls1=lds.describe(ls5) if left(ls1,1)='"' then ls1=mid(ls1,2,len(ls1) -2)//有待检验 o=pos(ls1,'~t') if o>0 then ls2=left(ls1,o -1) ls3=mid(ls1,o+1) else ls2=ls1 ls3='' end if if pos('?!',ls2)>0 then continue choose case ai_unit case 1//目标单位为象素 choose case q//原来计量单位 case 0//PB if pos(',x,x1,x2,width,print.margin.left,print.margin.right,',','+sx[n]+',')>0 then ll=UnitsToPixels(long(ls2),xUnitsToPixels!) else ll=UnitsToPixels(long(ls2),yUnitsToPixels!) end if case 2//1/1000英寸 ll=int(long(ls2)*2.54/(ln_bl*10)) case 3//0.1毫米 ll=int(long(ls2)/(ln_bl*10)) end choose case 0//目标单位为PB choose case q//原来计量单位 case 1//象素 if pos(',x,x1,x2,width,print.margin.left,print.margin.right,',','+sx[n]+',')>0 then ll=PixelsToUnits(long(ls2),XPixelsToUnits!) else ll=PixelsToUnits(long(ls2),YPixelsToUnits!) end if case 2//1/1000英寸 ll=PixelsToUnits(int(long(ls2)*2.54/(ln_bl*10)),XPixelsToUnits!) case 3//0.1毫米 ll=PixelsToUnits(int(long(ls2)/(ln_bl*10)),XPixelsToUnits!) end choose end choose ls4=string(ll,'0') if ls3>'' then ls4=ls4+'~t'+ls3 if j<=p then//'band' if ls[j]='background' then continue else ls5='datawindow.'+ls[j]+'.'+sx[n]+"="+ls4 end if else ls5=ls[j]+'.'+sx[n]+"='"+ls4+"'" end if ls6=ls6+' '+ls5 // ls1=lds.modify(ls5)//对于crosstab,单个column就modify会出现没有修改到的情况,所有对象一起modify反而没有问题 next next lds.modify(ls6)//对于crosstab,单个column就modify会出现没有修改到的情况,所有对象一起modify反而没有问题 lss=lds.describe('DataWindow.Syntax') lss=f_replace(lss,'units='+string(q),'units='+string(ai_unit)) goto f_end f_end: destroy lds return lss end function