poppler: fix drawImage*() parameters
[swftools.git] / lib / pdf / InfoOutputDev.h
1 /* InfoOutputDev.h
2    A special output device which collects information about a PDF file,
3    like fonts, Type3 glyphs and so on.
4
5    This file is part of swftools.
6
7    Swftools is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    Swftools is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with swftools; if not, write to the Free Software
19    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
20
21 #ifndef __infooutputdev_h__
22 #define __infooutputdev_h__
23
24 #include "popplercompat.h"
25 #include "GfxFont.h"
26 #include "OutputDev.h"
27 #include "SplashOutputDev.h"
28 #include "Page.h"
29
30 #ifdef HAVE_POPPLER
31   #include <splash/SplashTypes.h>
32   #include <splash/SplashPath.h>
33   #include <splash/SplashFont.h>
34   #include <splash/SplashFontFile.h>
35 #else
36   #include "xpdf/config.h"
37   #include "SplashTypes.h"
38   #include "SplashPath.h"
39   #include "SplashFont.h"
40   #include "SplashFontFile.h"
41 #endif
42
43 #ifdef HAVE_POPPLER
44 #include <goo/GooHash.h>
45 #else
46 #include "GHash.h"
47 #endif
48 #include "../gfxdevice.h"
49 #include "../gfxtools.h"
50 #include "../gfxfont.h"
51 #include "../q.h"
52
53 #define INTERNAL_FONT_SIZE 1024.0
54 #define GLYPH_IS_SPACE(g) ((!(g)->line || ((g)->line->type==gfx_moveTo && !(g)->line->next)) && (g)->advance)
55
56 struct GlyphInfo
57 {
58     SplashPath*path;
59     int unicode;
60     int glyphid;
61     double advance;
62     double x1,y1,x2,y2;
63
64     double advance_max;
65 };
66
67 class FontInfo
68 {
69     gfxfont_t*gfxfont;
70
71     char*id;
72 public:
73     FontInfo(char*id);
74     ~FontInfo();
75
76     gfxfont_t* getGfxFont();
77
78     double lastx,lasty;
79     int lastchar;
80     int lastadvance;
81
82     double ascender,descender;
83
84     void grow(int size);
85
86     GfxFont*font;
87     double max_size;
88     int num_glyphs;
89     GlyphInfo**glyphs;
90     dict_t**kerning;
91
92     SplashFont*splash_font;
93     char seen;
94     int space_char;
95     float average_advance;
96 };
97
98 extern char*getFontID(GfxFont*font);
99
100 class InfoOutputDev: public OutputDev 
101 {
102     GHash* id2font;
103     FontInfo* currentfont;
104     GlyphInfo* currentglyph;
105     SplashOutputDev*splash;
106     Page *page;
107
108     public:
109     int x1,y1,x2,y2;
110     int num_links;
111     int num_ppm_images;
112     int num_jpeg_images;
113     int num_fonts;
114     int num_polygons;
115     int num_textfields;
116
117     void dumpfonts(gfxdevice_t*dev);
118
119     InfoOutputDev(XRef*xref);
120     virtual ~InfoOutputDev(); 
121     virtual GBool useTilingPatternFill();
122     virtual GBool upsideDown();
123     virtual GBool useDrawChar();
124     virtual GBool interpretType3Chars();
125     virtual GBool checkPageSlice(Page *page, double hDPI, double vDPI,
126                                int rotate, GBool useMediaBox, GBool crop,
127                                int sliceX, int sliceY, int sliceW, int sliceH,
128                                GBool printing, Catalog *catalog,
129                                GBool (*abortCheckCbk)(void *data) = NULL,
130                                void *abortCheckCbkData = NULL);
131     virtual void startPage(int pageNum, GfxState *state);
132     virtual void endPage();
133     virtual void drawLink(Link *link, Catalog *catalog);
134     virtual double getMaximumFontSize(char*id);
135     virtual void updateFont(GfxState *state);
136   
137     virtual void saveState(GfxState *state);
138     virtual void restoreState(GfxState *state);
139
140     virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
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     virtual void endType3Char(GfxState *state);
144   
145     virtual void fill(GfxState *state);
146     virtual void eoFill(GfxState *state);
147
148     virtual void drawChar(GfxState *state, double x, double y,
149                           double dx, double dy,
150                           double originX, double originY,
151                           CharCode code, int nBytes, Unicode *u, int uLen);
152
153     virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
154                                int width, int height, GBool invert,
155                                POPPLER_INTERPOLATE
156                                GBool inlineImg);
157     virtual void drawImage(GfxState *state, Object *ref, Stream *str,
158                            int width, int height, GfxImageColorMap *colorMap,
159                            POPPLER_INTERPOLATE
160                            int *maskColors, GBool inlineImg);
161     virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
162                                   int width, int height,
163                                   GfxImageColorMap *colorMap,
164                                   POPPLER_INTERPOLATE
165                                   Stream *maskStr,
166                                   int maskWidth, int maskHeight,
167                                   GBool maskInvert
168                                   POPPLER_MASK_INTERPOLATE);
169     virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
170                                       int width, int height,
171                                       GfxImageColorMap *colorMap,
172                                       POPPLER_INTERPOLATE
173                                       Stream *maskStr,
174                                       int maskWidth, int maskHeight,
175                                       GfxImageColorMap *maskColorMap
176                                       POPPLER_MASK_INTERPOLATE);
177
178     virtual FontInfo* getFont(char*id);
179 };
180
181 #endif //__infooutputdev_h__