home *** CD-ROM | disk | FTP | other *** search
- /* $VER: PrintSignature.rexx 1.2 (09.10.96)
- Copyright 1996 SoftLogik Publishing Corporation
- May not be distributed without SoftLogik Publishing Corporation's express written permission */
-
- OPTIONS RESULTS
- ADDRESS 'PAGESTREAM'
-
-
- /* MAIN LOOP */
- call OPENLIBS()
-
- iTemp = GETDOCINFO() /* get page size */
-
- if iTemp = 0 then do
-
- iTemp = SIGREQ() /* get creep from user */
- if iTemp = 0 then do
- if dCreep > 0 then call CALCCREEP() /* calculate creep */
- call OPENBUSY()
- call CHANGESIZE() /* double the document width */
- 'refresh wait'
- call MOVEONPAGE() /* move objects to correct page sides */
- call MOVETOPAGE() /* move objects to correct spreads */
- call CLOSEBUSY()
- 'refreshwindow'
- 'refresh continue'
- end
-
- end
-
- EXIT
-
- GETDOCINFO:
- /* LET'S CHECK OUT THE DOCUMENT */
-
- /* IS A DOCUMENT OPEN? */
- sError = 'A document must be open to use this macro.'
- signal on error
- currentdocument
-
- /* GET PAGE COUNT */
- 'getpagenumbering 'aPage
-
- /* IS THE PAGE COUNT DIVISABLE BY 4? */
- sError = 'The page count must be a multiple of four to use this macro.'
- if trunc(aPage.length/4) ~= aPage.length/4 then signal error
-
- /* GET PAGE SIZE */
- 'getpagemasterpage masterpage 'sMpage' page 1'
- 'getdimensions 'aMpage' masterpage "'sMpage'"'
- dMpageX = aMpage.width
- dMpageY = aMpage.height
-
- /* GET DOCUMENT NAME. CREATE SIGNATURE NAME */
- 'currentdocument'
- aDoc.name = result
- aDoc.tname = aDoc.name
- if length(aDoc.name) > 20 then aDoc.tname = left(aDoc.name,20)
- aSig.name = aDoc.tname||'.signature'
-
- /* CALCULATE THE SPREAD SIZE */
- dSpageX = 2 * dMpageX
- dSpageY = dMpageY
-
- RETURN 0
-
- SIGREQ:
- /* PRINT SIGNATURE REQUESTER */
- rcode=0
-
- /* ALLOCATE REQUESTER */
- allocarexxrequester '"Print Signature"' 338 71
- hSigReq=result
-
- /* ADD GADGETS */
- addarexxgadget hSigReq EXIT 12 54 70 label "OK"
- hOkGadget=result
- addarexxgadget hSigReq EXIT 256 54 70 label "Cancel"
- hCancelGadget=result
- addarexxgadget hSigReq TEXT 8 8 80 border none string "Signature"
- sMpageX = dSpageX
- sMpageY = dSpageY
- addarexxgadget hSigReq TEXT 136 8 70 border recessed label "_Horz" string sMpageX
- addarexxgadget hSigReq TEXT 256 8 70 border recessed label "V_ert" string sMpageY
- addarexxgadget hSigReq STRING 136 26 70 label "'Paper C_reep'" string '0'
- hCreepGadget=result
-
- /* SHOW REQUESTER */
- doarexxrequester hSigReq
- if result=hCancelGadget then rcode=9
- else do
- /* GET GADGET STATUS */
- getarexxgadget hSigReq hCreepGadget string
- dCreep=result
- end
-
- /* FREE REQUESTER */
- freearexxrequester hSigReq
- freearexxlist hSignatureList
-
- RETURN rcode
-
- CALCCREEP:
- /* CALCULATE CREEP OFFSET */
-
- dcreep=3/32
- iStart = 1 /* define start/end values */
- iEnd = aPage.length
- iHalf= aPage.length / 2
-
- aCreep.iStart = 0 /* zero creep for start and end */
- aCreep.iEnd = 0
-
- dCreep = dCreep / (aPage.length/4 - 1) /* calculate incremental creep value */
-
- do i = iStart+1 to iEnd-1 /* repeat for all pages except first and last */
- if i <= iHalf then aCreep.i = trunc((i-iStart)/2)*dCreep
- if i > iHalf then aCreep.i = trunc((iEnd-i)/2)*dCreep
- end i
-
- RETURN
-
- CHANGESIZE:
- /* CREATE THE SIGNATURE */
- 'setdocumentname 'aSig.name' document 'aDoc.name
- 'setdimensions 'dSpageX' 'dSpageY' portrait single masterpage "'sMpage'"'
- RETURN
-
- MOVEONPAGE:
- /* MOVE OBJECTS TO CORRECT PAGE SIDES AND SHIFT FOR CREEP */
-
- do i = 1 to aPage.length by 2 /* repeat for each odd page */
- if dCreep = 0 then aCreep.i = 0
- 'selectobject all page 'i
- dOffset = dMpageX - aCreep.i
- 'move offset 'dOffset' '0' nosnap'
- iBRcurrent = iBRcurrent + 1
- call setbusy(iBRcurrent/iBRtotal*100)
- end i
-
- do i = 2 to aPage.length by 2 /* repeat for each even page */
- if dCreep = 0 then aCreep.i = 0
- 'selectobject all page 'i
- 'move offset 'aCreep.i' '0' nosnap'
- iBRcurrent = iBRcurrent + 1
- call setbusy(iBRcurrent/iBRtotal*100)
- end i
-
- RETURN
-
- MOVETOPAGE:
- /* MOVE OBJECTS TO CORRECT SPREADS */
-
- do i = aPage.length to (aPage.length/2)+1 by -1 /* repeat for all pages > page.count/2 */
- 'selectobject all page 'i
- 'movetopage page 'aPage.length-(i-1)
- iBRcurrent = iBRcurrent + 1
- call setbusy(iBRcurrent/iBRtotal*100)
- end i
-
- RETURN
-
- OPENLIBS:
- /* OPEN LIBRARIES */
- IF ~SHOW('L','rexxsupport.library') THEN
- call addlib('rexxsupport.library',0,-30)
- IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN
- call addlib("softlogik:libs/slarexxsupport.library", 0, -30)
- RETURN
-
- DOALERT:
- parse arg sAlertText
- iAlertLength=length(sAlertText)
- /* Display an alert requester */
- allocarexxrequester '"Macro Alert"' iAlertLength*8+24 55
- hAlertReq=result
- addarexxgadget hAlertReq TEXT 8 12 iAlertLength*8+8 border none string '"'sAlertText'"'
- addarexxgadget hAlertReq EXIT iALertLength*8-58 38 70 label "Exit"
- doarexxrequester hAlertReq
- freearexxrequester hAlertReq
- RETURN
-
- OPENBUSY:
- openbusyrequester message "'Preparing Signature...'" thermometer enabled abort enabled total 100 current 0
- hBusyReq=result
- iBRcurrent = 0
- iBRtotal = aPage.length * 1.5
- RETURN
-
- SETBUSY:
- parse arg value
- setbusyrequester hBusyReq current value
- getbusyrequester hBusyReq
- if result=1 then do
- call closebusy()
- exit
- end
- RETURN 0
-
- CLOSEBUSY:
- 'closebusyrequester 'hBusyReq
- RETURN
-
- ERROR:
- /* TRAP ERRORS */
- call doalert(sError)
-
- RETURN 9
-