upgraded to xpdf-3.01pl1
[swftools.git] / pdf2swf / xpdf / OutputDev.h
1 //========================================================================
2 //
3 // OutputDev.h
4 //
5 // Copyright 1996-2003 Glyph & Cog, LLC
6 //
7 //========================================================================
8
9 #ifndef OUTPUTDEV_H
10 #define OUTPUTDEV_H
11
12 #include <aconf.h>
13
14 #ifdef USE_GCC_PRAGMAS
15 #pragma interface
16 #endif
17
18 #include "gtypes.h"
19 #include "CharTypes.h"
20
21 class GString;
22 class GfxState;
23 class GfxColorSpace;
24 class GfxImageColorMap;
25 class GfxFunctionShading;
26 class GfxAxialShading;
27 class GfxRadialShading;
28 class Stream;
29 class Link;
30 class Catalog;
31
32 //------------------------------------------------------------------------
33 // OutputDev
34 //------------------------------------------------------------------------
35
36 class OutputDev {
37 public:
38
39   // Constructor.
40   OutputDev() {}
41
42   // Destructor.
43   virtual ~OutputDev() {}
44
45   //----- get info about output device
46
47   // Does this device use upside-down coordinates?
48   // (Upside-down means (0,0) is the top left corner of the page.)
49   virtual GBool upsideDown() = 0;
50
51   // Does this device use drawChar() or drawString()?
52   virtual GBool useDrawChar() = 0;
53
54   // Does this device use tilingPatternFill()?  If this returns false,
55   // tiling pattern fills will be reduced to a series of other drawing
56   // operations.
57   virtual GBool useTilingPatternFill() { return gFalse; }
58
59   // Does this device use functionShadedFill(), axialShadedFill(), and
60   // radialShadedFill()?  If this returns false, these shaded fills
61   // will be reduced to a series of other drawing operations.
62   virtual GBool useShadedFills() { return gFalse; }
63
64   // Does this device use beginType3Char/endType3Char?  Otherwise,
65   // text in Type 3 fonts will be drawn with drawChar/drawString.
66   virtual GBool interpretType3Chars() = 0;
67
68   // Does this device need non-text content?
69   virtual GBool needNonText() { return gTrue; }
70
71   //----- initialization and control
72
73   // Set default transform matrix.
74   virtual void setDefaultCTM(double *ctm);
75
76   // Start a page.
77   virtual void startPage(int pageNum, GfxState *state) {}
78
79   // End a page.
80   virtual void endPage() {}
81
82   // Dump page contents to display.
83   virtual void dump() {}
84
85   //----- coordinate conversion
86
87   // Convert between device and user coordinates.
88   virtual void cvtDevToUser(double dx, double dy, double *ux, double *uy);
89   virtual void cvtUserToDev(double ux, double uy, int *dx, int *dy);
90
91   double *getDefCTM() { return defCTM; }
92   double *getDefICTM() { return defICTM; }
93
94   //----- link borders
95   virtual void drawLink(Link *link, Catalog *catalog) {}
96
97   //----- save/restore graphics state
98   virtual void saveState(GfxState *state) {}
99   virtual void restoreState(GfxState *state) {}
100
101   //----- update graphics state
102   virtual void updateAll(GfxState *state);
103   virtual void updateCTM(GfxState *state, double m11, double m12,
104                          double m21, double m22, double m31, double m32) {}
105   virtual void updateLineDash(GfxState *state) {}
106   virtual void updateFlatness(GfxState *state) {}
107   virtual void updateLineJoin(GfxState *state) {}
108   virtual void updateLineCap(GfxState *state) {}
109   virtual void updateMiterLimit(GfxState *state) {}
110   virtual void updateLineWidth(GfxState *state) {}
111   virtual void updateFillColorSpace(GfxState *state) {}
112   virtual void updateStrokeColorSpace(GfxState *state) {}
113   virtual void updateFillColor(GfxState *state) {}
114   virtual void updateStrokeColor(GfxState *state) {}
115   virtual void updateBlendMode(GfxState *state) {}
116   virtual void updateFillOpacity(GfxState *state) {}
117   virtual void updateStrokeOpacity(GfxState *state) {}
118   virtual void updateFillOverprint(GfxState *state) {}
119   virtual void updateStrokeOverprint(GfxState *state) {}
120
121   //----- update text state
122   virtual void updateFont(GfxState *state) {}
123   virtual void updateTextMat(GfxState *state) {}
124   virtual void updateCharSpace(GfxState *state) {}
125   virtual void updateRender(GfxState *state) {}
126   virtual void updateRise(GfxState *state) {}
127   virtual void updateWordSpace(GfxState *state) {}
128   virtual void updateHorizScaling(GfxState *state) {}
129   virtual void updateTextPos(GfxState *state) {}
130   virtual void updateTextShift(GfxState *state, double shift) {}
131
132   //----- path painting
133   virtual void stroke(GfxState *state) {}
134   virtual void fill(GfxState *state) {}
135   virtual void eoFill(GfxState *state) {}
136   virtual void tilingPatternFill(GfxState *state, Object *str,
137                                  int paintType, Dict *resDict,
138                                  double *mat, double *bbox,
139                                  int x0, int y0, int x1, int y1,
140                                  double xStep, double yStep) {}
141   virtual void functionShadedFill(GfxState *state,
142                                   GfxFunctionShading *shading) {}
143   virtual void axialShadedFill(GfxState *state, GfxAxialShading *shading) {}
144   virtual void radialShadedFill(GfxState *state, GfxRadialShading *shading) {}
145
146   //----- path clipping
147   virtual void clip(GfxState *state) {}
148   virtual void eoClip(GfxState *state) {}
149
150   //----- text drawing
151   virtual void beginStringOp(GfxState *state) {}
152   virtual void endStringOp(GfxState *state) {}
153   virtual void beginString(GfxState *state, GString *s) {}
154   virtual void endString(GfxState *state) {}
155   virtual void drawChar(GfxState *state, double x, double y,
156                         double dx, double dy,
157                         double originX, double originY,
158                         CharCode code, int nBytes, Unicode *u, int uLen) {}
159   virtual void drawString(GfxState *state, GString *s) {}
160   virtual GBool beginType3Char(GfxState *state, double x, double y,
161                                double dx, double dy,
162                                CharCode code, Unicode *u, int uLen);
163   virtual void endType3Char(GfxState *state) {}
164   virtual void endTextObject(GfxState *state) {}
165
166   //----- image drawing
167   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
168                              int width, int height, GBool invert,
169                              GBool inlineImg);
170   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
171                          int width, int height, GfxImageColorMap *colorMap,
172                          int *maskColors, GBool inlineImg);
173   virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
174                                int width, int height,
175                                GfxImageColorMap *colorMap,
176                                Stream *maskStr, int maskWidth, int maskHeight,
177                                GBool maskInvert);
178   virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
179                                    int width, int height,
180                                    GfxImageColorMap *colorMap,
181                                    Stream *maskStr,
182                                    int maskWidth, int maskHeight,
183                                    GfxImageColorMap *maskColorMap);
184
185 #if OPI_SUPPORT
186   //----- OPI functions
187   virtual void opiBegin(GfxState *state, Dict *opiDict);
188   virtual void opiEnd(GfxState *state, Dict *opiDict);
189 #endif
190
191   //----- Type 3 font operators
192   virtual void type3D0(GfxState *state, double wx, double wy) {}
193   virtual void type3D1(GfxState *state, double wx, double wy,
194                        double llx, double lly, double urx, double ury) {}
195
196   //----- PostScript XObjects
197   virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
198
199 private:
200
201   double defCTM[6];             // default coordinate transform matrix
202   double defICTM[6];            // inverse of default CTM
203 };
204
205 #endif