count number of polygons
[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 "GfxFont.h"
25 #include "OutputDev.h"
26 #include "SplashFont.h"
27 #include "SplashOutputDev.h"
28 #include "SplashPath.h"
29 #include "SplashFontFile.h"
30 #include "GHash.h"
31
32 struct GlyphInfo
33 {
34     SplashPath*path;
35     int unicode;
36     int glyphid;
37     double x1,y1,x2,y2;
38 };
39
40 struct FontInfo
41 {
42     FontInfo();
43     ~FontInfo();
44     void grow(int size);
45
46     GfxFont*font;
47     double max_size;
48     int num_glyphs;
49     GlyphInfo**glyphs;
50     int*charid2glyph;
51     SplashFont*splash_font;
52     char seen;
53 };
54
55 extern char*getFontID(GfxFont*font);
56
57 class InfoOutputDev: public OutputDev 
58 {
59     GHash* id2font;
60     FontInfo* currentfont;
61     GlyphInfo* currentglyph;
62     SplashOutputDev*splash;
63
64     public:
65     int x1,y1,x2,y2;
66     int num_links;
67     int num_images;
68     int num_fonts;
69     int num_polygons;
70
71     InfoOutputDev(XRef*xref);
72     virtual ~InfoOutputDev(); 
73     virtual GBool useTilingPatternFill();
74     virtual GBool upsideDown();
75     virtual GBool useDrawChar();
76     virtual GBool interpretType3Chars();
77     virtual void startPage(int pageNum, GfxState *state, double crop_x1, double crop_y1, double crop_x2, double crop_y2);
78     virtual void endPage();
79     virtual void drawLink(Link *link, Catalog *catalog);
80     virtual double getMaximumFontSize(char*id);
81     virtual void updateFont(GfxState *state);
82
83     virtual GBool beginType3Char(GfxState *state, double x, double y, double dx, double dy, CharCode code, Unicode *u, int uLen);
84     virtual void type3D0(GfxState *state, double wx, double wy);
85     virtual void type3D1(GfxState *state, double wx, double wy, double llx, double lly, double urx, double ury);
86     virtual void endType3Char(GfxState *state);
87   
88     virtual void fill(GfxState *state);
89     virtual void eoFill(GfxState *state);
90
91     virtual void drawChar(GfxState *state, double x, double y,
92                           double dx, double dy,
93                           double originX, double originY,
94                           CharCode code, int nBytes, Unicode *u, int uLen);
95     virtual void drawImageMask(GfxState *state, Object *ref, Stream *str,
96                                int width, int height, GBool invert,
97                                GBool inlineImg);
98     virtual void drawImage(GfxState *state, Object *ref, Stream *str,
99                            int width, int height, GfxImageColorMap *colorMap,
100                            int *maskColors, GBool inlineImg);
101     virtual void drawMaskedImage(GfxState *state, Object *ref, Stream *str,
102                                   int width, int height,
103                                   GfxImageColorMap *colorMap,
104                                   Stream *maskStr,
105                                   int maskWidth, int maskHeight,
106                                   GBool maskInvert);
107     virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
108                                       int width, int height,
109                                       GfxImageColorMap *colorMap,
110                                       Stream *maskStr,
111                                       int maskWidth, int maskHeight,
112                                       GfxImageColorMap *maskColorMap);
113     virtual FontInfo* getFont(char*id);
114 };
115
116 #endif //__infooutputdev_h__