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