diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/oberdiek/atfidvips.def')
-rw-r--r-- | Master/texmf-dist/tex/latex/oberdiek/atfidvips.def | 512 |
1 files changed, 512 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/oberdiek/atfidvips.def b/Master/texmf-dist/tex/latex/oberdiek/atfidvips.def new file mode 100644 index 00000000000..9ee14c614ca --- /dev/null +++ b/Master/texmf-dist/tex/latex/oberdiek/atfidvips.def @@ -0,0 +1,512 @@ +%% +%% This is file `atfidvips.def', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% attachfile2.dtx (with options: `dvips') +%% +%% This is a generated file. +%% +%% Copyright (C) 2005, 2006 by Heiko Oberdiek <oberdiek@uni-freiburg.de> +%% +%% This work may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +%% This work has the LPPL maintenance status "maintained". +%% +%% This Current Maintainer of this work is Heiko Oberdiek. +%% +%% This work consists of the main source file attachfile2.dtx +%% and the derived files +%% attachfile2.sty, attachfile2.pdf, attachfile2.ins, attachfile2.drv, +%% atfidvips.def, atfipdftex.def, pdfatfi.pl. +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesFile{atfipdftex.def}% + [2006/08/16 v2.2 attachfile2 driver for dvips (HO)] +\def\atfi@literal#1{% + \special{ps:atfi_dict begin{#1}atfi_?pdfmark end}% +} + +\def\atfi@header#1{% + \special{! #1}% +} + + +\atfi@header{% + userdict begin 20 dict dup /atfi_dict exch def end begin + /atfi_?pdfmark systemdict + dup /pdfmark known + { + /exec get def + }{ + /pop get def + } ifelse + { + % + % x y width height atfi_re -> + languagelevel 2 ge { + /atfi_rectfill { rectfill } bind def + /atfi_rectstroke { rectstroke } bind def + }{% + /atfi_rect { + /atfi_height exch def + /atfi_width exch def + /atfi_x exch def + /atfi_y exch def + newpath + atfi_x atfi_y moveto + atfi_x atfi_width add atfi_y lineto + atfi_x atfi_width add atfi_y atfi_height add lineto + atfi_x atfi_y atfi_height add lineto + closepath + } bind def + /atfi_rectfill { + atfi_rect fill + } bind def + /atfi_rectstroke { + atfi_rect stroke + } bind def + } ifelse + /atfi_curveto_v { + currentpoint 6 2 roll curveto + } bind def + /atfi_curveto_y { + 2 copy curveto + } bind def + % + % help macro for atfi_convert_date + /atfi_two { + dup 10 lt + { + 1 string cvs + exch 1 add exch + }{ + 2 string cvs + } ifelse + putinterval + } bind def + % + % <seconds since 1970-01-01> atfi_convert_date -> (D:...Z) + /atfi_convert_date { + dup + /atfi_days exch 3600 idiv 24 idiv def + % calc date part + /atfi_year 1970 def + { + atfi_year 400 mod 0 eq + atfi_year 100 mod 0 ne + atfi_year 4 mod 0 eq + and or + { 366 } { 365 } ifelse + dup atfi_days lt + { + atfi_days exch sub /atfi_days exch def + /atfi_year atfi_year 1 add def + }{ + exit + } ifelse + } loop + /atfi_month 1 def + /atfi_days atfi_days 1 add def + 31 atfi_days lt + { + atfi_days 31 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 366 eq { 29 } { 28 } ifelse dup atfi_days lt + { + atfi_days exch sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 31 atfi_days lt + { + atfi_days 31 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 30 atfi_days lt + { + atfi_days 30 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 31 atfi_days lt + { + atfi_days 31 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 30 atfi_days lt + { + atfi_days 30 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 31 atfi_days lt + { + atfi_days 31 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 31 atfi_days lt + { + atfi_days 31 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 30 atfi_days lt + { + atfi_days 30 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 31 atfi_days lt + { + atfi_days 31 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 30 atfi_days lt + { + atfi_days 30 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + 31 atfi_days lt + { + atfi_days 31 sub /atfi_days exch def + /atfi_month atfi_month 1 add def + } if + } if + } if + } if + } if + } if + } if + } if + } if + } if + } { pop } ifelse + }{ pop } ifelse + % calc time part + 3600 24 mul mod + dup 3600 idiv dup /atfi_hour exch def + 3600 mul sub + dup 60 idiv dup /atfi_min exch def + 60 mul sub + /atfi_sec exch def + (D:19700101000000Z) + dup 2 atfi_year 4 string cvs putinterval + dup 6 atfi_month atfi_two + dup 8 atfi_days atfi_two + dup 10 atfi_hour atfi_two + dup 12 atfi_min atfi_two + dup 14 atfi_sec atfi_two + } bind def + % + % <filename> atfi_calc_checksum -> /CheckSum <checksum> + % or returns nothing, if MD5Encode is not given + false + languagelevel 2 ge { + (MD5Encode) + { pop true or } + (MD5Encode) length string + /Filter + resourceforall + } if + { + /atfi_calc_checksum { + /atfi_checksum 16 string def + /atfi_file exch (r) file def + /atfi_md5sum atfi_checksum /MD5Encode filter def + % not too efficient to read and write byte by byte, + % using a buffer is probably faster + atfi_size { + atfi_file read + { + atfi_md5sum exch write + } if + } repeat + atfi_md5sum closefile + atfi_file closefile + /CheckSum atfi_checksum + } bind def + }{ + /atfi_calc_checksum { pop } bind def + } ifelse + % + /atfi_pttobp { 72.27 div 72 mul } bind def + /atfi_pdftodvipsx { 72.27 div Resolution mul } bind def + /atfi_pdftodvipsy { 72.27 div VResolution mul } bind def + % + } atfi_?pdfmark + end +} + +\def\atfi@GSAVE{gsave } +\def\atfi@GRESTORE{grestore } +\def\atfi@SETLINEWIDTH{setlinewidth } +\def\atfi@LINETO{lineto } +\def\atfi@MOVETO{moveto } +\def\atfi@STROKE{stroke } +\def\atfi@FILL{fill } +\def\atfi@FILLSTROKE#1#2{gsave #1 fill grestore #2 stroke } +\def\atfi@SETRGBCOLORSTROKE{setrgbcolor } +\def\atfi@SETRGBCOLORFILL{setrgbcolor } +\def\atfi@SETGRAYSTROKE{setgray } +\def\atfi@SETGRAYFILL{setgray } +\def\atfi@RECTFILL{atfi_rectfill } +\def\atfi@RECTSTROKEFILL#1#2#3{% + #3% + #1% + gsave atfi_rectfill grestore + #2% + #3% + atfi_rectstroke + #1% +} +\def\atfi@SETMITERLIMIT{setmiterlimit } +\def\atfi@SETFLAT{setflat } +\def\atfi@SETLINECAP{setlinecap } +\def\atfi@CURVETO{curveto } +\def\atfi@CURVETOV{atfi_curveto_v } +\def\atfi@CURVETOY{atfi_curveto_y } +\def\atfi@CLOSEPATH{closepath } +\def\atfi@SETLINEJOIN{setlinejoin } + + +\newcounter{atfi@obj} +\renewcommand*{\theatfi@obj}{% + {atfi_obj_\number\c@atfi@obj}% +} + + +\define@key{AtFi@file}{Size}{} + +\def\atfi@embedfile#1{% + \@ifundefined{atfi@fileobj@#1}{% + \atfi@pdfstringdef\atfi@psfilename{#1}% + \stepcounter{atfi@obj}% + \expandafter\xdef\csname atfi@fileobj@#1\endcsname{\theatfi@obj}% + \begingroup + \let\atfi@params\@empty + \@ifundefined{atfi@file@#1}{}{% + \edef\x{\noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}}% + \x + }% + \atfi@literal{% + /atfi_filename (\atfi@psfilename) def + atfi_filename status + { + % ok: file found + % save parameters of status command + /atfi_created exch def + /atfi_referenced exch def + /atfi_size exch def + pop % drop parameter "pages" (storage space), never needed + % ghostscript: + % created: stat.st_ctime + % referenced: stat.st_mtime + % stat.st_ctime: interpretion depends on operating system: + % * unix: inode change time (not interesting) + % * win32: probably creation time + % --> /CreationDate + % stat.st_mtime: modification time --> /ModDate + % time values are seconds since 1970-01-01, GMT + % TODO: ghostscript offers "getenv" for getting the value + % of an environment variable. That could be used to + % to detect windows and settingthe /CreationDate entry. + % TODO: how are these values interpreted by other distiller + % programs? + % + [ + /_objdef \theatfi@obj + /type /stream + /OBJ pdfmark + [ + \theatfi@obj + << + /Type /EmbeddedFile + \atfi@mimetype + /Params + << + \atfi@params + % + /Size atfi_size + % + /product where + { + pop + % check for ghostscript + product (Ghostscript) search + { + pop pop pop + % ghostscript is running + % + \ifatfi@creationdate + \else + false % TODO: test for windows + { + /CreationDate atfi_created atfi_convert_date + } if + \fi + \ifatfi@moddate + \else + /ModDate atfi_referenced atfi_convert_date + \fi + } if + % + % look for MD5Encode filter and calculate CheckSum + } if + \ifatfi@checksum + \else + atfi_filename atfi_calc_checksum + \fi + >> + >> + /PUT pdfmark + [ + \theatfi@obj + atfi_filename (r) file + /PUT pdfmark + [ + \theatfi@obj + /CLOSE pdfmark + }{ + % error: file not found + % currently nothing is done + } ifelse + }% + \endgroup + }{% + % file already embedded + }% +} + + +\def\atfi@xform@icon{% + \stepcounter{atfi@obj}% + \edef\atfi@appearanceobj{\theatfi@obj}% + \atfi@literal{% + [ + /_objdef \atfi@appearanceobj + /BBox [ + 0 + 0 + \strip@pt\wd\atfi@appearancebox\space atfi_pttobp + \strip@pt\dimexpr\dp\atfi@appearancebox + +\ht\atfi@appearancebox\relax\space atfi_pttobp + ] + /BP pdfmark + \csname atfi@acro\atfi@icon@icon @data\endcsname + [ + /EP pdfmark + }% +} +\def\atfi@xform{% + \stepcounter{atfi@obj}% + \edef\atfi@appearanceobj{\theatfi@obj}% + \begingroup + \setbox0=\hbox{% + \atfi@literal{% + [ + /_objdef \atfi@appearanceobj + /BBox [ + currentpoint + \strip@pt\dp\atfi@appearancebox\space sub + currentpoint + exch \strip@pt\wd\atfi@appearancebox\space add + exch \strip@pt\ht\atfi@appearancebox\space add + ] + /BP pdfmark + gsave + currentpoint + 2 copy translate + 72.27 Resolution div 72.27 VResolution div neg scale + exch neg exch neg translate + }% + \usebox{\atfi@appearancebox}% + \atfi@literal{% + grestore + [ + /EP pdfmark + }% + }% + % do not allocate any space for xobject definition + \dp0=\z@ + \ht0=\z@ + \wd0=\z@ + \mbox{\usebox0}% + \endgroup +} + +\def\atfi@refxform#1{% + \raisebox{-\atfi@appearancedepth}{% + \atfi@literal{% + gsave + currentpoint translate + Resolution 72 div VResolution neg 72 div scale + [ #1 /SP pdfmark + grestore + }% + \makebox[\atfi@appearancewidth]{}% + }% + \rule{0pt}{\atfi@appearanceheight}% +} + + +\def\atfi@insert@file@annot#1{% + \rule{0pt}{0pt}% + \ifatfi@appearance + \def\atfi@appearance@dict{% + /AP<<% + /N \atfi@appearanceobj + /R \atfi@appearanceobj + /D \atfi@appearanceobj + >>% + }% + \else + \let\atfi@appearance@dict\@empty + \fi + \@ifundefined{atfi@fsobj@#1}{% + \stepcounter{atfi@obj}% + \expandafter\xdef\csname atfi@fsobj@#1\endcsname{\theatfi@obj}% + \atfi@pdfstringdef\atfi@file{#1}% + \atfi@literal{% + [ + /_objdef \theatfi@obj + /type /dict + /OBJ pdfmark + [ + \theatfi@obj + << + /Type /Filespec + /F (\atfi@file) + /EF << + /F \csname atfi@fileobj@#1\endcsname + >> + >> + /PUT pdfmark + }% + }{% + }% + \atfi@literal{% + [ + /Subtype/FileAttachment% + \atfi@icon + \atfi@color + \atfi@author + \atfi@date + \atfi@annotname + \atfi@description + \atfi@subject + \atfi@appearance@dict + /F \theatfi@flags + /FS \csname atfi@fsobj@#1\endcsname + /Rect [ + currentpoint + \strip@pt\dimexpr\atfi@scale\atfi@appearancedepth\relax + \space atfi_pdftodvipsy add + currentpoint + exch \strip@pt\dimexpr\atfi@scale\atfi@appearancewidth\relax + \space atfi_pdftodvipsx add + exch \strip@pt\dimexpr\atfi@scale\atfi@appearanceheight\relax + \space atfi_pdftodvipsy sub + ] + /ANN pdfmark + }% + \rule{0pt}{\atfi@appearanceheight}% + \rule[-\atfi@appearancedepth]{0pt}{\atfi@appearancedepth}% + \rule{\atfi@appearancewidth}{0pt}% +} + +\endinput +%% +%% End of file `atfidvips.def'. |