tried to fix links for newer xpdf versions
[swftools.git] / lib / xpdf / GFXOutputDev.h
1 #ifndef __gfxoutputdev_h__
2 #define __gfxoutputdev_h__
3
4 #include "../gfxdevice.h"
5 #include "../gfxsource.h"
6
7 #include "InfoOutputDev.h"
8 #include "PDFDoc.h"
9
10 typedef struct _fontlist
11 {
12     char*filename;
13     gfxfont_t*font;
14     _fontlist*next;
15 } fontlist_t;
16
17 class GFXOutputState {
18     public:
19     int clipping;
20     int textRender;
21     GFXOutputState();
22 };
23
24 typedef struct _parameter
25 {
26     char*name;
27     char*value;
28     struct _parameter*next;
29 } parameter_t;
30
31 void addGlobalFont(char*filename);
32 void addGlobalLanguageDir(char*dir);
33 void addGlobalFontDir(char*dirname);
34
35 class GFXOutputDev:  public OutputDev {
36 public:
37   gfxdevice_t* device;
38
39   // Constructor.
40   GFXOutputDev(parameter_t*p);
41   void setDevice(gfxdevice_t*dev);
42
43   // Destructor.
44   virtual ~GFXOutputDev() ;
45
46   void setMove(int x,int y);
47   void setClip(int x1,int y1,int x2,int y2);
48
49   void setInfo(InfoOutputDev*info) {this->info = info;}
50   
51   // Start a page.
52   void startFrame(int width, int height);
53
54   virtual void startPage(int pageNum, GfxState *state, double x1, double y1, double x2, double y2) ;
55
56   void endframe();
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();
63
64   // Does this device use drawChar() or drawString()?
65   virtual GBool useDrawChar();
66   
67   virtual GBool interpretType3Chars();
68   
69   //virtual GBool useShadedFills() { return gTrue; }
70
71   //----- initialization and control
72
73   void setXRef(PDFDoc*doc, XRef *xref);
74
75   //----- link borders
76   virtual void drawLink(Link *link, Catalog *catalog) ;
77
78   //----- save/restore graphics state
79   virtual void saveState(GfxState *state) ;
80   virtual void restoreState(GfxState *state) ;
81
82   //----- update graphics state
83
84   virtual void updateFont(GfxState *state);
85   virtual void updateFillColor(GfxState *state);
86   virtual void updateStrokeColor(GfxState *state);
87   virtual void updateLineWidth(GfxState *state);
88   virtual void updateLineJoin(GfxState *state);
89   virtual void updateLineCap(GfxState *state);
90   
91   virtual void updateAll(GfxState *state) 
92   {
93       updateFont(state);
94       updateFillColor(state);
95       updateStrokeColor(state);
96       updateLineWidth(state);
97       updateLineJoin(state);
98       updateLineCap(state);
99   };
100
101   //----- path painting
102   virtual void stroke(GfxState *state) ;
103   virtual void fill(GfxState *state) ;
104   virtual void eoFill(GfxState *state) ;
105
106   //----- path clipping
107   virtual void clip(GfxState *state) ;
108   virtual void eoClip(GfxState *state) ;
109
110   //----- text drawing
111   virtual void beginString(GfxState *state, GString *s) ;
112   virtual void endString(GfxState *state) ;
113   virtual void endTextObject(GfxState *state);
114   virtual void drawChar(GfxState *state, double x, double y,
115                         double dx, double dy,
116                         double originX, double originY,
117                         CharCode code, int nBytes, Unicode *u, int uLen);
118
119   //----- image drawing
120   virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
121                              int width, int height, GBool invert,
122                              GBool inlineImg);
123   virtual void drawImage(GfxState *state, Object *ref, Stream *str,
124                          int width, int height, GfxImageColorMap *colorMap,
125                          int *maskColors, GBool inlineImg);
126   virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
127                                int width, int height,
128                                GfxImageColorMap *colorMap,
129                                Stream *maskStr, int maskWidth, int maskHeight,
130                                GBool maskInvert);
131   virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
132                                    int width, int height,
133                                    GfxImageColorMap *colorMap,
134                                    Stream *maskStr,
135                                    int maskWidth, int maskHeight,
136                                    GfxImageColorMap *maskColorMap);
137   
138   virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
139   virtual void endType3Char(GfxState *state);
140
141   virtual void type3D0(GfxState *state, double wx, double wy);
142   virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
143
144   void preparePage(int pdfpage, int outputpage);
145
146   char* searchForSuitableFont(GfxFont*gfxFont);
147
148   void finish();
149
150   private:
151   void drawGeneralImage(GfxState *state, Object *ref, Stream *str,
152                                    int width, int height, GfxImageColorMap*colorMap, GBool invert,
153                                    GBool inlineImg, int mask, int *maskColors,
154                                    Stream *maskStr, int maskWidth, int maskHeight, GBool maskInvert, GfxImageColorMap*maskColorMap);
155   int setGfxFont(char*id, char*name, char*filename, double quality);
156   void strokeGfxline(GfxState *state, gfxline_t*line);
157   void clipToGfxLine(GfxState *state, gfxline_t*line);
158   void fillGfxLine(GfxState *state, gfxline_t*line);
159
160   char outer_clip_box; //whether the page clip box is still on
161
162   InfoOutputDev*info;
163   GFXOutputState states[64];
164   int statepos;
165
166   int currentpage;
167
168   PDFDoc*doc;
169   XRef*xref;
170
171   char* searchFont(char*name);
172   char* substituteFont(GfxFont*gfxFont, char*oldname);
173   char* writeEmbeddedFontToFile(XRef*ref, GfxFont*font);
174   int t1id;
175   int textmodeinfo; // did we write "Text will be rendered as polygon" yet?
176   int jpeginfo; // did we write "File contains jpegs" yet?
177   int pbminfo; // did we write "File contains jpegs" yet?
178   int linkinfo; // did we write "File contains links" yet?
179   int ttfinfo; // did we write "File contains TrueType Fonts" yet?
180   int gradientinfo; // did we write "File contains Gradients yet?
181
182   int type3active; // are we between beginType3()/endType3()?
183
184   GfxState *laststate;
185
186   char type3Warning;
187
188   char* substitutetarget[256];
189   char* substitutesource[256];
190   int substitutepos;
191
192   /* upper left corner of clipping rectangle (cropbox)- needs to be
193      added to all drawing coordinates to give the impression that all
194      pages start at (0,0)*/
195   int clipmovex,clipmovey;
196
197   int user_movex,user_movey;
198   int user_clipx1,user_clipx2,user_clipy1,user_clipy2;
199
200   gfxline_t* current_text_stroke;
201   gfxline_t* current_text_clip;
202   char* current_font_id;
203   gfxfont_t* current_gfxfont;
204   gfxmatrix_t current_font_matrix;
205
206   fontlist_t* fontlist;
207
208   int*pages;
209   int pagebuflen;
210   int pagepos;
211
212   /* config */
213   int forceType0Fonts;
214   int config_use_fontconfig;
215     
216   parameter_t*parameters;
217 };
218
219 #endif //__gfxoutputdev_h__