]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/PSOutputDev.h
kill traces of ltk, incorporate new sources
[evince.git] / pdf / xpdf / PSOutputDev.h
1 //========================================================================
2 //
3 // PSOutputDev.h
4 //
5 // Copyright 1996-2002 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef PSOUTPUTDEV_H
10 #define PSOUTPUTDEV_H
11
12 #include <aconf.h>
13
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17
18 #include <stddef.h>
19 #include "config.h"
20 #include "Object.h"
21 #include "GlobalParams.h"
22 #include "OutputDev.h"
23
24 class GfxPath;
25 class GfxFont;
26 class GfxColorSpace;
27 class GfxSeparationColorSpace;
28 struct PSFont16Enc;
29 class PSOutCustomColor;
30
31 //------------------------------------------------------------------------
32 // PSOutputDev
33 //------------------------------------------------------------------------
34
35 enum PSOutMode {
36   psModePS,
37   psModeEPS,
38   psModeForm
39 };
40
41 enum PSFileType {
42   psFile,                       // write to file
43   psPipe,                       // write to pipe
44   psStdout,                     // write to stdout
45   psGeneric                     // write to a generic stream
46 };
47
48 typedef void (*PSOutputFunc)(void *stream, char *data, int len);
49
50 class PSOutputDev: public OutputDev {
51 public:
52
53   // Open a PostScript output file, and write the prolog.
54   PSOutputDev(char *fileName, XRef *xrefA, Catalog *catalog,
55               int firstPage, int lastPage, PSOutMode modeA);
56
57   // Open a PSOutputDev that will write to a generic stream.
58   PSOutputDev(PSOutputFunc outputFuncA, void *outputStreamA,
59               XRef *xrefA, Catalog *catalog,
60               int firstPage, int lastPage, PSOutMode modeA);
61
62   // Destructor -- writes the trailer and closes the file.
63   virtual ~PSOutputDev();
64
65   // Check if file was successfully created.
66   virtual GBool isOk() { return ok; }
67
68   //---- get info about output device
69
70   // Does this device use upside-down coordinates?
71   // (Upside-down means (0,0) is the top left corner of the page.)
72   virtual GBool upsideDown() { return gFalse; }
73
74   // Does this device use drawChar() or drawString()?
75   virtual GBool useDrawChar() { return gFalse; }
76
77   // Does this device use beginType3Char/endType3Char?  Otherwise,
78   // text in Type 3 fonts will be drawn with drawChar/drawString.
79   virtual GBool interpretType3Chars() { return gFalse; }
80
81   //----- initialization and control
82
83   // Start a page.
84   virtual void startPage(int pageNum, GfxState *state);
85
86   // End a page.
87   virtual void endPage();
88
89   //----- save/restore graphics state
90   virtual void saveState(GfxState *state);
91   virtual void restoreState(GfxState *state);
92
93   //----- update graphics state
94   virtual void updateCTM(GfxState *state, double m11, double m12,
95                          double m21, double m22, double m31, double m32);
96   virtual void updateLineDash(GfxState *state);
97   virtual void updateFlatness(GfxState *state);
98   virtual void updateLineJoin(GfxState *state);
99   virtual void updateLineCap(GfxState *state);
100   virtual void updateMiterLimit(GfxState *state);
101   virtual void updateLineWidth(GfxState *state);
102   virtual void updateFillColor(GfxState *state);
103   virtual void updateStrokeColor(GfxState *state);
104
105   //----- update text state
106   virtual void updateFont(GfxState *state);
107   virtual void updateTextMat(GfxState *state);
108   virtual void updateCharSpace(GfxState *state);
109   virtual void updateRender(GfxState *state);
110   virtual void updateRise(GfxState *state);
111   virtual void updateWordSpace(GfxState *state);
112   virtual void updateHorizScaling(GfxState *state);
113   virtual void updateTextPos(GfxState *state);
114   virtual void updateTextShift(GfxState *state, double shift);
115
116   //----- path painting
117   virtual void stroke(GfxState *state);
118   virtual void fill(GfxState *state);
119   virtual void eoFill(GfxState *state);
120
121   //----- path clipping
122   virtual void clip(GfxState *state);
123   virtual void eoClip(GfxState *state);
124
125   //----- text drawing
126   virtual void drawString(GfxState *state, GString *s);
127
128   //----- image drawing
129   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
130                              int width, int height, GBool invert,
131                              GBool inlineImg);
132   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
133                          int width, int height, GfxImageColorMap *colorMap,
134                          int *maskColors, GBool inlineImg);
135
136 #if OPI_SUPPORT
137   //----- OPI functions
138   virtual void opiBegin(GfxState *state, Dict *opiDict);
139   virtual void opiEnd(GfxState *state, Dict *opiDict);
140 #endif
141
142   //----- Type 3 font operators
143   virtual void type3D0(GfxState *state, double wx, double wy);
144   virtual void type3D1(GfxState *state, double wx, double wy,
145                        double llx, double lly, double urx, double ury);
146
147   //----- PostScript XObjects
148   virtual void psXObject(Stream *psStream, Stream *level1Stream);
149
150
151 private:
152
153   void init(PSOutputFunc outputFuncA, void *outputStreamA,
154             PSFileType fileTypeA, XRef *xrefA, Catalog *catalog,
155             int firstPage, int lastPage, PSOutMode modeA);
156   void setupResources(Dict *resDict);
157   void setupFonts(Dict *resDict);
158   void setupFont(GfxFont *font, Dict *parentResDict);
159   void setupEmbeddedType1Font(Ref *id, char *psName);
160   void setupExternalType1Font(GString *fileName, char *psName);
161   void setupEmbeddedType1CFont(GfxFont *font, Ref *id, char *psName);
162   void setupEmbeddedTrueTypeFont(GfxFont *font, Ref *id, char *psName);
163   void setupExternalTrueTypeFont(GfxFont *font, char *psName);
164   void setupEmbeddedCIDType0Font(GfxFont *font, Ref *id, char *psName);
165   void setupEmbeddedCIDTrueTypeFont(GfxFont *font, Ref *id, char *psName);
166   void setupType3Font(GfxFont *font, char *psName, Dict *parentResDict);
167   void setupImages(Dict *resDict);
168   void setupImage(Ref id, Stream *str);
169   void addProcessColor(double c, double m, double y, double k);
170   void addCustomColor(GfxSeparationColorSpace *sepCS);
171   void doPath(GfxPath *path);
172   void doImageL1(GfxImageColorMap *colorMap,
173                  GBool invert, GBool inlineImg,
174                  Stream *str, int width, int height, int len);
175   void doImageL1Sep(GfxImageColorMap *colorMap,
176                     GBool invert, GBool inlineImg,
177                     Stream *str, int width, int height, int len);
178   void doImageL2(Object *ref, GfxImageColorMap *colorMap,
179                  GBool invert, GBool inlineImg,
180                  Stream *str, int width, int height, int len);
181   void dumpColorSpaceL2(GfxColorSpace *colorSpace);
182 #if OPI_SUPPORT
183   void opiBegin20(GfxState *state, Dict *dict);
184   void opiBegin13(GfxState *state, Dict *dict);
185   void opiTransform(GfxState *state, double x0, double y0,
186                     double *x1, double *y1);
187   GBool getFileSpec(Object *fileSpec, Object *fileName);
188 #endif
189   void writePSChar(char c);
190   void writePS(char *s);
191   void writePSFmt(const char *fmt, ...);
192   void writePSString(GString *s);
193   void writePSName(char *s);
194   GString *filterPSName(GString *name);
195
196   PSLevel level;                // PostScript level (1, 2, separation)
197   PSOutMode mode;               // PostScript mode (PS, EPS, form)
198   int paperWidth;               // width of paper, in pts
199   int paperHeight;              // height of paper, in pts
200
201   PSOutputFunc outputFunc;
202   void *outputStream;
203   PSFileType fileType;          // file / pipe / stdout
204   int seqPage;                  // current sequential page number
205
206   XRef *xref;                   // the xref table for this PDF file
207
208   Ref *fontIDs;                 // list of object IDs of all used fonts
209   int fontIDLen;                // number of entries in fontIDs array
210   int fontIDSize;               // size of fontIDs array
211   Ref *fontFileIDs;             // list of object IDs of all embedded fonts
212   int fontFileIDLen;            // number of entries in fontFileIDs array
213   int fontFileIDSize;           // size of fontFileIDs array
214   GString **fontFileNames;      // list of names of all embedded external fonts
215   int fontFileNameLen;          // number of entries in fontFileNames array
216   int fontFileNameSize;         // size of fontFileNames array
217   PSFont16Enc *font16Enc;       // encodings for substitute 16-bit fonts
218   int font16EncLen;             // number of entries in font16Enc array
219   int font16EncSize;            // size of font16Enc array
220
221   double tx, ty;                // global translation
222   double xScale, yScale;        // global scaling
223   GBool landscape;              // true for landscape, false for portrait
224
225   GString *embFontList;         // resource comments for embedded fonts
226
227   int processColors;            // used process colors
228   PSOutCustomColor              // used custom colors
229     *customColors;
230
231   GBool inType3Char;            // inside a Type 3 CharProc
232   GString *t3String;            // Type 3 content string
233   double t3WX, t3WY,            // Type 3 character parameters
234          t3LLX, t3LLY, t3URX, t3URY;
235   GBool t3Cacheable;            // cleared if char is not cacheable
236
237 #if OPI_SUPPORT
238   int opi13Nest;                // nesting level of OPI 1.3 objects
239   int opi20Nest;                // nesting level of OPI 2.0 objects
240 #endif
241
242   GBool ok;                     // set up ok?
243
244 };
245
246 #endif