home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / WordProcessors / slt-pgs3.lzx / PageStream3 / Scripts / ReplaceGraphic.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1996-10-20  |  3.4 KB  |  97 lines

  1. /* $VER: ReplaceGraphic.rexx 1.1a (4.10.96)
  2.    Copyright 1996 SoftLogik Publishing Corporation
  3.    May not be distributed without SoftLogik Publishing Corporation's express written permission
  4. */
  5.  
  6. OPTIONS RESULTS
  7. ADDRESS 'PAGESTREAM'
  8. call OPENLIBS()
  9.  
  10.  
  11. /* IS A BOX OR GRAPHIC SELECTED */
  12. 'getobject type iOType'
  13.     hOGraphic=result
  14.  
  15. /* OBJECT TYPES: 12:picture, 5:box, 2:drawing, 13:eps */
  16. if iOType=12 | iOType=5 | iOType=2 | iOType=13 then do
  17.     'refresh wait'
  18.     if iOType=5 then getbox position aOPos rotation aORotate about aORotate constrain sConstrain print sPrint
  19.     if iOType=12 then getpicture position aOPos rotation aORotate about aORotate contentoffset aOContent contentscale aOContent frame sFramed constrain sConstrain print sPrint
  20.     if iOType=2 then getdrawing position aOPos rotation aORotate about aORotate contentoffset aOContent contentscale aOContent frame sFramed constrain sConstrain print sPrint
  21.     if iOType=13 then geteps position aOPos rotation aORotate about aORotate contentoffset aOContent contentscale aOContent frame sFramed constrain sConstrain print sPrint
  22.     gettextwrap region wmode wrap wtype standoff aOWrap objectid hOGraphic
  23.  
  24.     /* PLACE THE NEW OBJECT */
  25.     placegraphic status
  26.         if rc~=0 then signal cancel
  27.     'getobject type iNType'
  28.         hNGraphic=result
  29.  
  30.     /* IF CONSTRAINED, SCALE PROPORTIONALLY TO FIT */
  31.     if sConstrain=ON  then do
  32.         if iNType=12 then getpicture position aNPos
  33.         if iNType=2 then getdrawing position aNPos
  34.         if iNType=13 then geteps position aNPos
  35.  
  36.         dOWidth = aOPos.right - aOPos.left
  37.         dOHeight = aOPos.bottom - aOPos.top
  38.         dOAspect = dOWidth / dOHeight
  39.  
  40.         dNWidth = aNPos.right - aNPos.left
  41.         dNHeight = aNPos.bottom - aNPos.top
  42.         dNAspect = dNWidth / dNHeight
  43.  
  44.         if dOAspect > dNAspect then do
  45.             aOContent.v=(dOHeight / dNHeight) * 100
  46.             aOContent.h=aOContent.v
  47.             sFramed=ON
  48.         end
  49.         if dOAspect < dNAspect then do
  50.             aOContent.h=(dOWidth / dNWidth) * 100
  51.             aOContent.v=aOContent.h
  52.             sFramed=ON
  53.         end
  54.     end
  55.  
  56.     /* SET THE NEW OBJECT TO MATCH THE OLD OBJECT */
  57.     pstring=position' 'aOPos.left' 'aOPos.top' 'aOPos.right' 'aOPos.bottom' skew 'aORotate.slant' 'aORotate.twist
  58.     if sFramed=ON then pstring=pstring' framed contentoffset 'aOContent.x' 'aOContent.y' contentscale 'aOContent.h' 'aOContent.v
  59.     if aORotate.mode=POINT then pstring=pstring' about 'aORotate.x' 'aORotate.y
  60.     if sConstrain=ON then pstring=pstring' constrain'
  61.     if sPrint=OFF then pstring=pstring' noprint'
  62.  
  63.     if iNType=12 then 'editpicture 'pstring
  64.     if iNType=2 then 'editdrawing 'pstring
  65.     if iNType=13 then 'editeps 'pstring
  66.     if wtype~=NOWRAP then settextwrap wmode wtype standoff aOWrap.x aOWrap.y
  67.  
  68.     /* DELETE THE OLD OBJECT */
  69.     deleteobject objectid hOGraphic
  70.     selectobject objectid hNGraphic
  71.     'refresh continue'
  72. end
  73. else do
  74.     allocarexxrequester '"Replace Graphic Error!"' 540 61
  75.         hAlertBox=result
  76.     addarexxgadget hAlertBox EXIT 235 44 70 label "Exit"
  77.     addarexxgadget hAlertBox TEXT 8 10 520 border none string "'A box or graphic must be selected to replace with a new graphic.'"
  78.     addarexxgadget hAlertBox TEXT 8 22 520 border none string "'Select one box or graphic and choose Replace Graphic again.'"
  79.     doarexxrequester hAlertBox
  80.     freearexxrequester hAlertBox
  81.     EXIT
  82. end
  83. EXIT
  84.  
  85. CANCEL:
  86. selectobject objectid hOGraphic
  87. 'refresh continue'
  88. EXIT
  89.  
  90. OPENLIBS:
  91.     /* OPEN LIBRARIES */
  92.     IF ~SHOW('L','rexxsupport.library') THEN
  93.         call addlib('rexxsupport.library',0,-30)
  94.     IF ~SHOW('L','softlogik:libs/slarexxsupport.library') THEN
  95.         call addlib("softlogik:libs/slarexxsupport.library", 0, -30)
  96. RETURN
  97.