merge the formfield patch from ooo-build
[ooovba.git] / sdext / source / pdfimport / xpdfwrapper / pdfioutdev_gpl.hxx
blobaf5827668d5864805acc2b3adc276f6457d4be9c
1 /*************************************************************************
3 * OpenOffice.org - a multi-platform office productivity suite
5 * $RCSfile: pdfioutdev_gpl.hxx,v $
7 * $Revision: 1.1.2.1 $
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
40 #if defined __GNUC__
41 #pragma GCC system_header
42 #elif defined __SUNPRO_CC
43 #pragma disable_warn
44 #elif defined _MSC_VER
45 #pragma warning(push, 1)
46 #endif
48 #include "GfxState.h"
49 #include "GfxFont.h"
50 #include "UnicodeMap.h"
51 #include "Link.h"
52 #include "Object.h"
53 #include "OutputDev.h"
54 #ifndef SYSTEM_POPPLER
55 # include "parseargs.h"
56 #endif
57 #include "GlobalParams.h"
58 #include "PDFDoc.h"
60 #if defined __SUNPRO_CC
61 #pragma enable_warn
62 #elif defined _MSC_VER
63 #pragma warning(pop)
64 #endif
66 #include <hash_map>
67 #include <vector>
69 class GfxPath;
70 class GfxFont;
71 class PDFDoc;
72 #ifndef SYSTEM_POPPLER
73 typedef GString GooString;
74 #endif
76 namespace pdfi
78 struct FontAttributes
80 FontAttributes( const GooString& familyName_,
81 bool isEmbedded_,
82 bool isBold_,
83 bool isItalic_,
84 bool isUnderline_,
85 double size_ ) :
86 familyName(),
87 isEmbedded(isEmbedded_),
88 isBold(isBold_),
89 isItalic(isItalic_),
90 isUnderline(isUnderline_),
91 size(size_)
93 familyName.append(const_cast<GooString*>(&familyName_));
96 FontAttributes() :
97 familyName(),
98 isEmbedded(false),
99 isBold(false),
100 isItalic(false),
101 isUnderline(false),
102 size(0.0)
105 // xdpf goo stuff is so totally borked...
106 // ...need to hand-code assignment
107 FontAttributes( const FontAttributes& rSrc ) :
108 familyName(),
109 isEmbedded(rSrc.isEmbedded),
110 isBold(rSrc.isBold),
111 isItalic(rSrc.isItalic),
112 isUnderline(rSrc.isUnderline),
113 size(rSrc.size)
115 familyName.append(const_cast<GooString*>(&rSrc.familyName));
118 FontAttributes& operator=( const FontAttributes& rSrc )
120 familyName.clear();
121 familyName.append(const_cast<GooString*>(&rSrc.familyName));
123 isEmbedded = rSrc.isEmbedded;
124 isBold = rSrc.isBold;
125 isItalic = rSrc.isItalic;
126 isUnderline = rSrc.isUnderline;
127 size = rSrc.size;
129 return *this;
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 &&
140 size == rFont.size;
143 GooString familyName;
144 bool isEmbedded;
145 bool isBold;
146 bool isItalic;
147 bool isUnderline;
148 double size;
151 class PDFOutDev : public OutputDev
153 // not owned by this class
154 PDFDoc* m_pDoc;
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;
163 public:
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);
187 // Start a page.
188 virtual void startPage(int pageNum, GfxState *state);
190 // End a page.
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);
202 //----- link borders
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);
245 //----- text drawing
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,
256 GBool inlineImg);
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,
264 GBool maskInvert);
265 virtual void drawSoftMaskedImage(GfxState *state, Object *ref, Stream *str,
266 int width, int height,
267 GfxImageColorMap *colorMap,
268 Stream *maskStr,
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 */