1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: pdfioutdev_gpl.hxx,v $
9 * last change: $Author: cmc $ $Date: 2008/08/25 16:17:55 $
11 * The Contents of this file are made available subject to
12 * the terms of GNU General Public License Version 2.
15 * GNU General Public License, version 2
16 * =============================================
17 * Copyright 2005 by Sun Microsystems, Inc.
18 * 901 San Antonio Road, Palo Alto, CA 94303, USA
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License as
22 * published by the Free Software Foundation; either version 2 of
23 * the License, or (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public
31 * License along with this program; if not, write to the Free
32 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
33 * Boston, MA 02110-1301, USA.
35 ************************************************************************/
37 #ifndef INCLUDED_PDFI_OUTDEV_HXX
38 #define INCLUDED_PDFI_OUTDEV_HXX
41 #pragma GCC system_header
42 #elif defined __SUNPRO_CC
44 #elif defined _MSC_VER
45 #pragma warning(push, 1)
50 #include "UnicodeMap.h"
53 #include "OutputDev.h"
54 #ifndef SYSTEM_POPPLER
55 # include "parseargs.h"
57 #include "GlobalParams.h"
60 #if defined __SUNPRO_CC
62 #elif defined _MSC_VER
72 #ifndef SYSTEM_POPPLER
73 typedef GString GooString
;
80 FontAttributes( const GooString
& familyName_
,
87 isEmbedded(isEmbedded_
),
90 isUnderline(isUnderline_
),
93 familyName
.append(const_cast<GooString
*>(&familyName_
));
105 // xdpf goo stuff is so totally borked...
106 // ...need to hand-code assignment
107 FontAttributes( const FontAttributes
& rSrc
) :
109 isEmbedded(rSrc
.isEmbedded
),
111 isItalic(rSrc
.isItalic
),
112 isUnderline(rSrc
.isUnderline
),
115 familyName
.append(const_cast<GooString
*>(&rSrc
.familyName
));
118 FontAttributes
& operator=( const FontAttributes
& rSrc
)
121 familyName
.append(const_cast<GooString
*>(&rSrc
.familyName
));
123 isEmbedded
= rSrc
.isEmbedded
;
124 isBold
= rSrc
.isBold
;
125 isItalic
= rSrc
.isItalic
;
126 isUnderline
= rSrc
.isUnderline
;
132 bool operator==(const FontAttributes
& rFont
) const
134 return const_cast<GooString
*>(&familyName
)->cmp(
135 const_cast<GooString
*>(&rFont
.familyName
))==0 &&
136 isEmbedded
== rFont
.isEmbedded
&&
137 isBold
== rFont
.isBold
&&
138 isItalic
== rFont
.isItalic
&&
139 isUnderline
== rFont
.isUnderline
&&
143 GooString familyName
;
151 class PDFOutDev
: public OutputDev
153 // not owned by this class
155 mutable std::hash_map
< long long,
156 FontAttributes
> m_aFontMap
;
157 UnicodeMap
* m_pUtf8Map
;
159 int parseFont( long long nNewId
, GfxFont
* pFont
, GfxState
* state
) const;
160 void writeFontFile( GfxFont
* gfxFont
) const;
161 void printPath( GfxPath
* pPath
) const;
164 explicit PDFOutDev( PDFDoc
* pDoc
);
166 //----- get info about output device
168 // Does this device use upside-down coordinates?
169 // (Upside-down means (0,0) is the top left corner of the page.)
170 virtual GBool
upsideDown() { return gTrue
; }
172 // Does this device use drawChar() or drawString()?
173 virtual GBool
useDrawChar() { return gTrue
; }
175 // Does this device use beginType3Char/endType3Char? Otherwise,
176 // text in Type 3 fonts will be drawn with drawChar/drawString.
177 virtual GBool
interpretType3Chars() { return gFalse
; }
179 // Does this device need non-text content?
180 virtual GBool
needNonText() { return gTrue
; }
182 //----- initialization and control
184 // Set default transform matrix.
185 virtual void setDefaultCTM(double *ctm
);
188 virtual void startPage(int pageNum
, GfxState
*state
);
191 virtual void endPage();
193 // Dump page contents to display.
194 // virtual void dump() {}
196 //----- coordinate conversion
198 // Convert between device and user coordinates.
199 // virtual void cvtDevToUser(double dx, double dy, double *ux, double *uy);
200 // virtual void cvtUserToDev(double ux, double uy, int *dx, int *dy);
203 virtual void processLink(Link
*link
, Catalog
*catalog
);
205 //----- save/restore graphics state
206 virtual void saveState(GfxState
*state
);
207 virtual void restoreState(GfxState
*state
);
209 //----- update graphics state
210 // virtual void updateAll(GfxState *state);
211 virtual void updateCTM(GfxState
*state
, double m11
, double m12
,
212 double m21
, double m22
, double m31
, double m32
);
213 virtual void updateLineDash(GfxState
*state
);
214 virtual void updateFlatness(GfxState
*state
);
215 virtual void updateLineJoin(GfxState
*state
);
216 virtual void updateLineCap(GfxState
*state
);
217 virtual void updateMiterLimit(GfxState
*state
);
218 virtual void updateLineWidth(GfxState
*state
);
219 virtual void updateFillColor(GfxState
*state
);
220 virtual void updateStrokeColor(GfxState
*state
);
221 virtual void updateFillOpacity(GfxState
*state
);
222 virtual void updateStrokeOpacity(GfxState
*state
);
223 virtual void updateBlendMode(GfxState
*state
);
225 //----- update text state
226 virtual void updateFont(GfxState
*state
);
227 // virtual void updateTextMat(GfxState *state);
228 // virtual void updateCharSpace(GfxState *state) {}
229 virtual void updateRender(GfxState
*state
);
230 // virtual void updateRise(GfxState *state) {}
231 // virtual void updateWordSpace(GfxState *state) {}
232 // virtual void updateHorizScaling(GfxState *state) {}
233 // virtual void updateTextPos(GfxState *state) {}
234 // virtual void updateTextShift(GfxState *state, double shift) {}
236 //----- path painting
237 virtual void stroke(GfxState
*state
);
238 virtual void fill(GfxState
*state
);
239 virtual void eoFill(GfxState
*state
);
241 //----- path clipping
242 virtual void clip(GfxState
*state
);
243 virtual void eoClip(GfxState
*state
);
246 virtual void drawChar(GfxState
*state
, double x
, double y
,
247 double dx
, double dy
,
248 double originX
, double originY
,
249 CharCode code
, int nBytes
, Unicode
*u
, int uLen
);
250 virtual void drawString(GfxState
*state
, GooString
*s
);
251 virtual void endTextObject(GfxState
*state
);
253 //----- image drawing
254 virtual void drawImageMask(GfxState
*state
, Object
*ref
, Stream
*str
,
255 int width
, int height
, GBool invert
,
257 virtual void drawImage(GfxState
*state
, Object
*ref
, Stream
*str
,
258 int width
, int height
, GfxImageColorMap
*colorMap
,
259 int *maskColors
, GBool inlineImg
);
260 virtual void drawMaskedImage(GfxState
*state
, Object
*ref
, Stream
*str
,
261 int width
, int height
,
262 GfxImageColorMap
*colorMap
,
263 Stream
*maskStr
, int maskWidth
, int maskHeight
,
265 virtual void drawSoftMaskedImage(GfxState
*state
, Object
*ref
, Stream
*str
,
266 int width
, int height
,
267 GfxImageColorMap
*colorMap
,
269 int maskWidth
, int maskHeight
,
270 GfxImageColorMap
*maskColorMap
);
272 //----- OPI functions
273 // virtual void opiBegin(GfxState *state, Dict *opiDict);
274 // virtual void opiEnd(GfxState *state, Dict *opiDict);
276 //----- Type 3 font operators
277 // virtual void type3D0(GfxState *state, double wx, double wy) {}
278 // virtual void type3D1(GfxState *state, double wx, double wy,
279 // double llx, double lly, double urx, double ury) {}
281 //----- PostScript XObjects
282 // virtual void psXObject(Stream *psStream, Stream *level1Stream) {}
284 void setPageNum( int nNumPages
);
288 extern FILE* g_binary_out
;
290 // note: if you ever hcange Output_t, please keep in mind that the current code
291 // relies on it being of 8 bit size
292 typedef char Output_t
;
293 typedef std::vector
< Output_t
> OutputBuffer
;
295 #endif /* INCLUDED_PDFI_OUTDEV_HXX */