1 //========================================================================
3 // MarkedContentOutputDev.h
5 // This file is licensed under the GPLv2 or later
7 // Copyright 2013 Igalia S.L.
9 //========================================================================
11 #ifndef MARKEDCONTENTOUTPUTDEV_H
12 #define MARKEDCONTENTOUTPUTDEV_H
14 #include "goo/gtypes.h"
16 #include "OutputDev.h"
27 TextSpan(const TextSpan
& other
): data(other
.data
) {
31 TextSpan
& operator=(const TextSpan
& other
) {
40 if (data
&& --data
->refcount
== 0)
44 GfxFont
* getFont() const { return data
->font
; }
45 GooString
* getText() const { return data
->text
; }
46 GfxRGB
& getColor() const { return data
->color
; }
49 // Note: Takes ownership of strings, increases refcount for font.
50 TextSpan(GooString
*text
,
58 data
->font
->incRefCnt();
67 Data(): refcount(1) {}
70 assert(refcount
== 0);
79 friend class MarkedContentOutputDev
;
83 typedef std::vector
<TextSpan
> TextSpanArray
;
86 class MarkedContentOutputDev
: public OutputDev
{
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;
116 bool inMarkedContent() const { return mcidStack
.size() > 0; }
117 bool needFontChange(GfxFont
* font
) const;
119 GfxFont
*currentFont
;
120 GooString
*currentText
;
122 TextSpanArray textSpans
;
124 std::vector
<int> mcidStack
;
127 UnicodeMap
*unicodeMap
;
130 #endif /* !MARKEDCONTENTOUTPUTDEV_H */