]> www.fi.muni.cz Git - evince.git/blob - pdf/xpdf/PSOutputDev.h
Synched with Xpdf 0.92
[evince.git] / pdf / xpdf / PSOutputDev.h
1 //========================================================================
2 //
3 // PSOutputDev.h
4 //
5 // Copyright 1996 Derek B. Noonburg
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 "OutputDev.h"
20
21 class GfxPath;
22 class GfxFont;
23 class GfxColorSpace;
24
25 //------------------------------------------------------------------------
26 // Parameters
27 //------------------------------------------------------------------------
28
29 // Generate Level 1 PostScript?
30 extern GBool psOutLevel1;
31
32 // Generate Level 1 separable PostScript?
33 extern GBool psOutLevel1Sep;
34
35 // Generate Encapsulated PostScript?
36 extern GBool psOutEPS;
37
38 #if OPI_SUPPORT
39 // Generate OPI comments?
40 extern GBool psOutOPI;
41 #endif
42
43 // Paper size.
44 extern int paperWidth;
45 extern int paperHeight;
46
47 //------------------------------------------------------------------------
48 // PSOutputDev
49 //------------------------------------------------------------------------
50
51 enum PSFileType {
52   psFile,                       // write to file
53   psPipe,                       // write to pipe
54   psStdout                      // write to stdout
55 };
56
57 class PSOutputDev: public OutputDev {
58 public:
59
60   // Open a PostScript output file, and write the prolog.
61   PSOutputDev(char *fileName, Catalog *catalog,
62               int firstPage, int lastPage,
63               GBool embedType11, GBool doForm1);
64
65   // Destructor -- writes the trailer and closes the file.
66   virtual ~PSOutputDev();
67
68   // Check if file was successfully created.
69   virtual GBool isOk() { return ok; }
70
71   //---- get info about output device
72
73   // Does this device use upside-down coordinates?
74   // (Upside-down means (0,0) is the top left corner of the page.)
75   virtual GBool upsideDown() { return gFalse; }
76
77   // Does this device use drawChar() or drawString()?
78   virtual GBool useDrawChar() { return gFalse; }
79
80   //----- initialization and control
81
82   // Start a page.
83   virtual void startPage(int pageNum, GfxState *state);
84
85   // End a page.
86   virtual void endPage();
87
88   //----- save/restore graphics state
89   virtual void saveState(GfxState *state);
90   virtual void restoreState(GfxState *state);
91
92   //----- update graphics state
93   virtual void updateCTM(GfxState *state, double m11, double m12,
94                          double m21, double m22, double m31, double m32);
95   virtual void updateLineDash(GfxState *state);
96   virtual void updateFlatness(GfxState *state);
97   virtual void updateLineJoin(GfxState *state);
98   virtual void updateLineCap(GfxState *state);
99   virtual void updateMiterLimit(GfxState *state);
100   virtual void updateLineWidth(GfxState *state);
101   virtual void updateFillColor(GfxState *state);
102   virtual void updateStrokeColor(GfxState *state);
103
104   //----- update text state
105   virtual void updateFont(GfxState *state);
106   virtual void updateTextMat(GfxState *state);
107   virtual void updateCharSpace(GfxState *state);
108   virtual void updateRender(GfxState *state);
109   virtual void updateRise(GfxState *state);
110   virtual void updateWordSpace(GfxState *state);
111   virtual void updateHorizScaling(GfxState *state);
112   virtual void updateTextPos(GfxState *state);
113   virtual void updateTextShift(GfxState *state, double shift);
114
115   //----- path painting
116   virtual void stroke(GfxState *state);
117   virtual void fill(GfxState *state);
118   virtual void eoFill(GfxState *state);
119
120   //----- path clipping
121   virtual void clip(GfxState *state);
122   virtual void eoClip(GfxState *state);
123
124   //----- text drawing
125   virtual void drawString(GfxState *state, GString *s);
126   virtual void drawString16(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                          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 private:
143
144   void setupResources(Dict *resDict);
145   void setupFonts(Dict *resDict);
146   void setupFont(GfxFont *font);
147   void setupEmbeddedType1Font(Ref *id, char *psName);
148   void setupEmbeddedType1Font(GString *fileName, char *psName);
149   void setupEmbeddedType1CFont(GfxFont *font, Ref *id, char *psName);
150   void setupImages(Dict *resDict);
151   void setupImage(Ref id, Stream *str);
152   void doPath(GfxPath *path);
153   void doImageL1(GfxImageColorMap *colorMap,
154                  GBool invert, GBool inlineImg,
155                  Stream *str, int width, int height, int len);
156   void doImageL1Sep(GfxImageColorMap *colorMap,
157                     GBool invert, GBool inlineImg,
158                     Stream *str, int width, int height, int len);
159   void doImageL2(Object *ref, GfxImageColorMap *colorMap,
160                  GBool invert, GBool inlineImg,
161                  Stream *str, int width, int height, int len);
162   void dumpColorSpaceL2(GfxColorSpace *colorSpace);
163   void opiBegin20(GfxState *state, Dict *dict);
164   void opiBegin13(GfxState *state, Dict *dict);
165   void opiTransform(GfxState *state, double x0, double y0,
166                     double *x1, double *y1);
167   GBool getFileSpec(Object *fileSpec, Object *fileName);
168   void writePS(const char *fmt, ...);
169   void writePSString(GString *s);
170
171   GBool embedType1;             // embed Type 1 fonts?
172   GBool doForm;                 // generate a form?
173
174   FILE *f;                      // PostScript file
175   PSFileType fileType;          // file / pipe / stdout
176   int seqPage;                  // current sequential page number
177
178   Ref *fontIDs;                 // list of object IDs of all used fonts
179   int fontIDLen;                // number of entries in fontIDs array
180   int fontIDSize;               // size of fontIDs array
181   Ref *fontFileIDs;             // list of object IDs of all embedded fonts
182   int fontFileIDLen;            // number of entries in fontFileIDs array
183   int fontFileIDSize;           // size of fontFileIDs array
184   GString **fontFileNames;      // list of names of all embedded external fonts
185   int fontFileNameLen;          // number of entries in fontFileNames array
186   int fontFileNameSize;         // size of fontFileNames array
187
188   double tx, ty;                // global translation
189   double xScale, yScale;        // global scaling
190   GBool landscape;              // true for landscape, false for portrait
191
192   GString *embFontList;         // resource comments for embedded fonts
193
194 #if OPI_SUPPORT
195   int opi13Nest;                // nesting level of OPI 1.3 objects
196   int opi20Nest;                // nesting level of OPI 2.0 objects
197 #endif
198
199   GBool type3Warning;           // only show the Type 3 font warning once
200
201   GBool ok;                     // set up ok?
202 };
203
204 #endif