beta-0.89.2
[luatex.git] / source / libs / poppler / poppler-src / poppler / MarkedContentOutputDev.h
blob4ea60c255a142ea27cbe82b04fff78224546192b
1 //========================================================================
2 //
3 // MarkedContentOutputDev.h
4 //
5 // This file is licensed under the GPLv2 or later
6 //
7 // Copyright 2013 Igalia S.L.
8 //
9 //========================================================================
11 #ifndef MARKEDCONTENTOUTPUTDEV_H
12 #define MARKEDCONTENTOUTPUTDEV_H
14 #include "goo/gtypes.h"
15 #include "goo/gmem.h"
16 #include "OutputDev.h"
17 #include "GfxState.h"
18 #include "GfxFont.h"
19 #include <vector>
21 class Dict;
22 class UnicodeMap;
25 class TextSpan {
26 public:
27 TextSpan(const TextSpan& other): data(other.data) {
28 data->refcount++;
31 TextSpan& operator=(const TextSpan& other) {
32 if (this != &other) {
33 data = other.data;
34 data->refcount++;
36 return *this;
39 ~TextSpan() {
40 if (data && --data->refcount == 0)
41 delete data;
44 GfxFont* getFont() const { return data->font; }
45 GooString* getText() const { return data->text; }
46 GfxRGB& getColor() const { return data->color; }
48 private:
49 // Note: Takes ownership of strings, increases refcount for font.
50 TextSpan(GooString *text,
51 GfxFont *font,
52 const GfxRGB& color)
53 : data(new Data) {
54 data->text = text;
55 data->font = font;
56 data->color = color;
57 if (data->font)
58 data->font->incRefCnt();
61 struct Data {
62 GfxFont *font;
63 GooString *text;
64 GfxRGB color;
65 unsigned refcount;
67 Data(): refcount(1) {}
69 ~Data() {
70 assert(refcount == 0);
71 if (font)
72 font->decRefCnt();
73 delete text;
77 Data *data;
79 friend class MarkedContentOutputDev;
83 typedef std::vector<TextSpan> TextSpanArray;
86 class MarkedContentOutputDev: public OutputDev {
87 public:
88 MarkedContentOutputDev(int mcidA);
89 virtual ~MarkedContentOutputDev();
91 virtual GBool isOk() { return gTrue; }
92 virtual GBool upsideDown() { return gTrue; }
93 virtual GBool useDrawChar() { return gTrue; }
94 virtual GBool interpretType3Chars() { return gFalse; }
95 virtual GBool needNonText() { return gFalse; }
96 virtual GBool needCharCount() { return gFalse; }
98 virtual void startPage(int pageNum, GfxState *state, XRef *xref);
99 virtual void endPage();
101 virtual void drawChar(GfxState *state,
102 double xx, double yy,
103 double dx, double dy,
104 double ox, double oy,
105 CharCode c, int nBytes,
106 Unicode *u, int uLen);
108 virtual void beginMarkedContent(char *name, Dict *properties);
109 virtual void endMarkedContent(GfxState *state);
111 const TextSpanArray& getTextSpans() const;
113 private:
115 void endSpan();
116 bool inMarkedContent() const { return mcidStack.size() > 0; }
117 bool needFontChange(GfxFont* font) const;
119 GfxFont *currentFont;
120 GooString *currentText;
121 GfxRGB currentColor;
122 TextSpanArray textSpans;
123 int mcid;
124 std::vector<int> mcidStack;
125 double pageWidth;
126 double pageHeight;
127 UnicodeMap *unicodeMap;
130 #endif /* !MARKEDCONTENTOUTPUTDEV_H */