home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / gs_fform.ps < prev    next >
Text File  |  2002-02-22  |  3KB  |  93 lines

  1. %    Copyright (C) 1995, 1996, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_fform.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
  14. % Form caching implemented in PostScript.
  15.  
  16. % This implementation doesn't do the right thing about halftone or
  17. % Pattern phase, but the Pattern cache doesn't either....
  18.  
  19. % The Form cache key is the Form dictionary; the value is an array
  20. % of 2 elements [CTM pattern_instance].
  21. %
  22. % In order to prevent restore from clearing the cache, we explicitly
  23. % push the cache entries on the stack before a restore and reinstall them.
  24. currentglobal false setglobal
  25. /.formcachedict 20 dict def    % must be local
  26. true setglobal
  27. /restore {
  28.   mark .formcachedict { } forall
  29.   counttomark 1 add index { //restore } .internalstopped
  30.     { cleartomark //restore }
  31.     { counttomark 2 idiv { .formcachedict 3 1 roll put } repeat pop pop }
  32.   ifelse
  33. } bind odef
  34.  
  35. /.execform1 {
  36.   dup /Implementation known not {
  37.     dup /FormType get 1 ne { /rangecheck signalerror } if
  38.         % The Implementation is a Pattern that will draw the form.
  39.     currentglobal 1 index gcheck setglobal
  40.         % Stack: form global
  41.     10 dict begin
  42.       /PatternType 1 def
  43.       /PaintType 1 def    % colored
  44.       /TilingType 1 def    % irrelevant
  45.         % Copy the BBox to the correct VM.
  46.       /BBox 2 index /BBox get 4 array copy exch 1 index def
  47.         % Set XStep and YStep to very large numbers,
  48.         % so we won't get multiple copies of the form.
  49.       /XStep 1 index dup 2 get exch 0 get sub 100 mul def
  50.       /YStep exch dup 3 get exch 1 get sub 100 mul def
  51.       /PaintProc 2 index /PaintProc get def
  52.     currentdict end readonly
  53.         % Stack: form global impl
  54.     exch setglobal
  55.     1 index /Implementation 3 -1 roll .forceput
  56.   } if
  57.   .formcachedict 1 index .knownget {
  58.         % Check whether we can use the cached value.
  59.         % Stack: form cachevalue
  60.     matrix currentmatrix true 0 1 3 {
  61.         % Stack: form cachevalue curmat true index
  62.       3 index 0 get 1 index get exch 3 index exch get ne {
  63.     pop pop false exit
  64.       } if
  65.     } for exch pop
  66.   } {
  67.     false
  68.   } ifelse not
  69.   {        % Make a new cache entry.
  70.     gsave
  71.     matrix currentmatrix dup 4 0 put dup 5 0 put dup setmatrix
  72.         % Stack: form mat
  73.     1 index /Implementation get
  74.     2 index /Matrix get
  75.     makepattern 2 array astore
  76.     .formcachedict 2 index 2 index put
  77.     grestore
  78.   } if
  79.         % Stack: form cachevalue
  80.   -1 0 0 transform
  81.   2 { exch round cvi } repeat .setscreenphase
  82.   1 get setpattern
  83.   /BBox get aload pop
  84.   exch 3 index sub exch 2 index sub rectfill
  85. } .bind odef    % must bind .forceput
  86.  
  87. .formtypes 1 /.execform1 load put
  88.  
  89. setglobal
  90.