summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/QOutputDev.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/noncore/unsupported/qpdf/QOutputDev.cpp b/noncore/unsupported/qpdf/QOutputDev.cpp
index 15a58b1..f587a33 100644
--- a/noncore/unsupported/qpdf/QOutputDev.cpp
+++ b/noncore/unsupported/qpdf/QOutputDev.cpp
@@ -1,1040 +1,1038 @@
1///======================================================================== 1///========================================================================
2// 2//
3// QOutputDev.cc 3// QOutputDev.cc
4// 4//
5// Copyright 1996 Derek B. Noonburg 5// Copyright 1996 Derek B. Noonburg
6// CopyRight 2002 Robert Griebl 6// CopyRight 2002 Robert Griebl
7// 7//
8//======================================================================== 8//========================================================================
9 9
10#ifdef __GNUC__ 10#ifdef __GNUC__
11#pragma implementation 11#pragma implementation
12#endif 12#endif
13 13
14#include <aconf.h> 14#include <aconf.h>
15#include <stdio.h> 15#include <stdio.h>
16#include <stdlib.h> 16#include <stdlib.h>
17#include <stddef.h> 17#include <stddef.h>
18#include <unistd.h> 18#include <unistd.h>
19#include <string.h> 19#include <string.h>
20#include <ctype.h> 20#include <ctype.h>
21#include <math.h> 21#include <math.h>
22#include "GString.h" 22#include "GString.h"
23#include "Object.h" 23#include "Object.h"
24#include "Stream.h" 24#include "Stream.h"
25#include "Link.h" 25#include "Link.h"
26#include "GfxState.h" 26#include "GfxState.h"
27#include "GfxFont.h" 27#include "GfxFont.h"
28#include "UnicodeMap.h" 28#include "UnicodeMap.h"
29#include "CharCodeToUnicode.h" 29#include "CharCodeToUnicode.h"
30#include "FontFile.h" 30#include "FontFile.h"
31#include "Error.h" 31#include "Error.h"
32#include "TextOutputDev.h" 32#include "TextOutputDev.h"
33#include "QOutputDev.h" 33#include "QOutputDev.h"
34 34
35 35
36#include <qpixmap.h> 36#include <qpixmap.h>
37#include <qimage.h> 37#include <qimage.h>
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qdict.h> 39#include <qdict.h>
40#include <qtimer.h> 40#include <qtimer.h>
41#include <qapplication.h> 41#include <qapplication.h>
42#include <qclipboard.h> 42#include <qclipboard.h>
43 43
44 //#define QPDFDBG(x) x // special debug mode 44 //#define QPDFDBG(x) x // special debug mode
45 #define QPDFDBG(x) // normal compilation 45 #define QPDFDBG(x) // normal compilation
46 46
47 47
48//------------------------------------------------------------------------ 48//------------------------------------------------------------------------
49// Constants and macros 49// Constants and macros
50//------------------------------------------------------------------------ 50//------------------------------------------------------------------------
51 51
52 52
53static inline QColor q_col ( const GfxRGB &rgb ) 53static inline QColor q_col ( const GfxRGB &rgb )
54{ 54{
55 return QColor ( lrint ( rgb. r * 255 ), lrint ( rgb. g * 255 ), lrint ( rgb. b * 255 )); 55 return QColor ( lrint ( rgb. r * 255 ), lrint ( rgb. g * 255 ), lrint ( rgb. b * 255 ));
56} 56}
57 57
58 58
59//------------------------------------------------------------------------ 59//------------------------------------------------------------------------
60// Font substitutions 60// Font substitutions
61//------------------------------------------------------------------------ 61//------------------------------------------------------------------------
62 62
63struct QOutFontSubst { 63struct QOutFontSubst {
64 char * m_name; 64 char * m_name;
65 char * m_sname; 65 char * m_sname;
66 bool m_bold; 66 bool m_bold;
67 bool m_italic; 67 bool m_italic;
68 QFont::StyleHint m_hint; 68 QFont::StyleHint m_hint;
69}; 69};
70 70
71static QOutFontSubst qStdFonts [] = { 71static QOutFontSubst qStdFonts [] = {
72 { "Helvetica", "Helvetica", false, false, QFont::Helvetica }, 72 { "Helvetica", "Helvetica", false, false, QFont::Helvetica },
73 { "Helvetica-Oblique", "Helvetica", false, true, QFont::Helvetica }, 73 { "Helvetica-Oblique", "Helvetica", false, true, QFont::Helvetica },
74 { "Helvetica-Bold", "Helvetica", true, false, QFont::Helvetica }, 74 { "Helvetica-Bold", "Helvetica", true, false, QFont::Helvetica },
75 { "Helvetica-BoldOblique", "Helvetica", true, true, QFont::Helvetica }, 75 { "Helvetica-BoldOblique", "Helvetica", true, true, QFont::Helvetica },
76 { "Times-Roman", "Times", false, false, QFont::Times }, 76 { "Times-Roman", "Times", false, false, QFont::Times },
77 { "Times-Italic", "Times", false, true, QFont::Times }, 77 { "Times-Italic", "Times", false, true, QFont::Times },
78 { "Times-Bold", "Times", true, false, QFont::Times }, 78 { "Times-Bold", "Times", true, false, QFont::Times },
79 { "Times-BoldItalic", "Times", true, true, QFont::Times }, 79 { "Times-BoldItalic", "Times", true, true, QFont::Times },
80 { "Courier", "Courier", false, false, QFont::Courier }, 80 { "Courier", "Courier", false, false, QFont::Courier },
81 { "Courier-Oblique", "Courier", false, true, QFont::Courier }, 81 { "Courier-Oblique", "Courier", false, true, QFont::Courier },
82 { "Courier-Bold", "Courier", true, false, QFont::Courier }, 82 { "Courier-Bold", "Courier", true, false, QFont::Courier },
83 { "Courier-BoldOblique", "Courier", true, true, QFont::Courier }, 83 { "Courier-BoldOblique", "Courier", true, true, QFont::Courier },
84 84
85 { "Symbol", 0, false, false, QFont::AnyStyle }, 85 { "Symbol", 0, false, false, QFont::AnyStyle },
86 { "Zapf-Dingbats", 0, false, false, QFont::AnyStyle }, 86 { "Zapf-Dingbats", 0, false, false, QFont::AnyStyle },
87 87
88 { 0, 0, false, false, QFont::AnyStyle } 88 { 0, 0, false, false, QFont::AnyStyle }
89}; 89};
90 90
91 91
92 92
93 93
94 94
95 95
96 96
97QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp_t m22 ) 97QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp_t m22 )
98{ 98{
99 static QDict<QOutFontSubst> stdfonts; 99 static QDict<QOutFontSubst> stdfonts;
100 100
101 // build dict for std. fonts on first invocation 101 // build dict for std. fonts on first invocation
102 if ( stdfonts. isEmpty ( )) { 102 if ( stdfonts. isEmpty ( )) {
103 for ( QOutFontSubst *ptr = qStdFonts; ptr-> m_name; ptr++ ) { 103 for ( QOutFontSubst *ptr = qStdFonts; ptr-> m_name; ptr++ ) {
104 stdfonts. insert ( QString ( ptr-> m_name ), ptr ); 104 stdfonts. insert ( QString ( ptr-> m_name ), ptr );
105 } 105 }
106 } 106 }
107 107
108 // compute size and normalized transform matrix 108 // compute size and normalized transform matrix
109 int size = lrint ( sqrt ( m21 * m21 + m22 * m22 )); 109 int size = lrint ( sqrt ( m21 * m21 + m22 * m22 ));
110 110
111 QPDFDBG( printf ( "SET FONT: Name=%s, Size=%d, Bold=%d, Italic=%d, Mono=%d, Serif=%d, Symbol=%d, CID=%d, EmbFN=%s, M=(%f,%f,%f,%f)\n", 111 QPDFDBG( printf ( "SET FONT: Name=%s, Size=%d, Bold=%d, Italic=%d, Mono=%d, Serif=%d, Symbol=%d, CID=%d, EmbFN=%s, M=(%f,%f,%f,%f)\n",
112 (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ), 112 (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ),
113 size, 113 size,
114 gfxFont-> isBold ( ), 114 gfxFont-> isBold ( ),
115 gfxFont-> isItalic ( ), 115 gfxFont-> isItalic ( ),
116 gfxFont-> isFixedWidth ( ), 116 gfxFont-> isFixedWidth ( ),
117 gfxFont-> isSerif ( ), 117 gfxFont-> isSerif ( ),
118 gfxFont-> isSymbolic ( ), 118 gfxFont-> isSymbolic ( ),
119 gfxFont-> isCIDFont ( ), 119 gfxFont-> isCIDFont ( ),
120 ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName ( ) : "<n/a>" ), 120 ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName ( ) : "<n/a>" ),
121 (double) m11, (double) m12, (double) m21, (double) m22 )); 121 (double) m11, (double) m12, (double) m21, (double) m22 ));
122 122
123 123
124 QString fname (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ); 124 QString fname (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" );
125 125
126 QFont f; 126 QFont f;
127 f. setPixelSize ( size > 0 ? size : 8 ); // type3 fonts misbehave sometimes 127 f. setPixelSize ( size > 0 ? size : 8 ); // type3 fonts misbehave sometimes
128 128
129 // fast lookup for std. fonts 129 // fast lookup for std. fonts
130 QOutFontSubst *subst = stdfonts [fname]; 130 QOutFontSubst *subst = stdfonts [fname];
131 131
132 if ( subst ) { 132 if ( subst ) {
133 if ( subst-> m_sname ) 133 if ( subst-> m_sname )
134 f. setFamily ( subst-> m_sname ); 134 f. setFamily ( subst-> m_sname );
135 f. setStyleHint ( subst-> m_hint, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality )); 135 f. setStyleHint ( subst-> m_hint, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality ));
136 f. setBold ( subst-> m_bold ); 136 f. setBold ( subst-> m_bold );
137 f. setItalic ( subst-> m_italic ); 137 f. setItalic ( subst-> m_italic );
138 } 138 }
139 else { 139 else {
140 QFont::StyleHint sty; 140 QFont::StyleHint sty;
141 141
142 if ( gfxFont-> isSerif ( )) 142 if ( gfxFont-> isSerif ( ))
143 sty = QFont::Serif; 143 sty = QFont::Serif;
144 else if ( gfxFont-> isFixedWidth ( )) 144 else if ( gfxFont-> isFixedWidth ( ))
145 sty = QFont::TypeWriter; 145 sty = QFont::TypeWriter;
146 else 146 else
147 sty = QFont::Helvetica; 147 sty = QFont::Helvetica;
148 148
149 f. setStyleHint ( sty, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality )); 149 f. setStyleHint ( sty, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality ));
150 f. setBold ( gfxFont-> isBold ( ) > 0 ); 150 f. setBold ( gfxFont-> isBold ( ) > 0 );
151 f. setItalic ( gfxFont-> isItalic ( ) > 0 ); 151 f. setItalic ( gfxFont-> isItalic ( ) > 0 );
152 f. setFixedPitch ( gfxFont-> isFixedWidth ( ) > 0 ); 152 f. setFixedPitch ( gfxFont-> isFixedWidth ( ) > 0 );
153 153
154 // common specifiers in font names 154 // common specifiers in font names
155 if ( fname. contains ( "Oblique" ) || fname. contains ( "Italic" )) 155 if ( fname. contains ( "Oblique" ) || fname. contains ( "Italic" ))
156 f. setItalic ( true ); 156 f. setItalic ( true );
157 if ( fname. contains ( "Bold" )) 157 if ( fname. contains ( "Bold" ))
158 f. setWeight ( QFont::Bold ); 158 f. setWeight ( QFont::Bold );
159 if ( fname. contains ( "Demi" )) 159 if ( fname. contains ( "Demi" ))
160 f. setWeight ( QFont::DemiBold ); 160 f. setWeight ( QFont::DemiBold );
161 if ( fname. contains ( "Light" )) 161 if ( fname. contains ( "Light" ))
162 f. setWeight ( QFont::Light ); 162 f. setWeight ( QFont::Light );
163 if ( fname. contains ( "Black" )) 163 if ( fname. contains ( "Black" ))
164 f. setWeight ( QFont::Black ); 164 f. setWeight ( QFont::Black );
165 } 165 }
166 // Treat x-sheared fonts as italic 166 // Treat x-sheared fonts as italic
167 if (( m12 > -0.1 ) && ( m12 < 0.1 ) && ((( m21 > -5.0 ) && ( m21 < -0.1 )) || (( m21 > 0.1 ) && ( m21 < 5.0 )))) { 167 if (( m12 > -0.1 ) && ( m12 < 0.1 ) && ((( m21 > -5.0 ) && ( m21 < -0.1 )) || (( m21 > 0.1 ) && ( m21 < 5.0 )))) {
168 f. setItalic ( true ); 168 f. setItalic ( true );
169 } 169 }
170 return f; 170 return f;
171} 171}
172 172
173 173
174 174
175//------------------------------------------------------------------------ 175//------------------------------------------------------------------------
176// QOutputDev 176// QOutputDev
177//------------------------------------------------------------------------ 177//------------------------------------------------------------------------
178 178
179QOutputDev::QOutputDev ( QWidget *parent, const char *name, int flags ) : QScrollView ( parent, name, WRepaintNoErase | WResizeNoErase | flags ) 179QOutputDev::QOutputDev ( QWidget *parent, const char *name, int flags ) : QScrollView ( parent, name, WRepaintNoErase | WResizeNoErase | flags )
180{ 180{
181 m_pixmap = 0; 181 m_pixmap = 0;
182 m_painter = 0; 182 m_painter = 0;
183 183
184 m_use_string = true;
185
186 // create text object 184 // create text object
187 m_text = new TextPage ( gFalse ); 185 m_text = new TextPage ( gFalse );
188} 186}
189 187
190QOutputDev::~QOutputDev ( ) 188QOutputDev::~QOutputDev ( )
191{ 189{
192 delete m_painter; 190 delete m_painter;
193 delete m_pixmap; 191 delete m_pixmap;
194 delete m_text; 192 delete m_text;
195} 193}
196 194
197 195
198void QOutputDev::startPage ( int /*pageNum*/, GfxState *state ) 196void QOutputDev::startPage ( int /*pageNum*/, GfxState *state )
199{ 197{
200 delete m_pixmap; 198 delete m_pixmap;
201 delete m_painter; 199 delete m_painter;
202 200
203 m_pixmap = new QPixmap ( lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( ))); 201 m_pixmap = new QPixmap ( lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( )));
204 m_painter = new QPainter ( m_pixmap ); 202 m_painter = new QPainter ( m_pixmap );
205 203
206 QPDFDBG( printf ( "NEW PIXMAP (%ld x %ld)\n", lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( )))); 204 QPDFDBG( printf ( "NEW PIXMAP (%ld x %ld)\n", lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( ))));
207 205
208 resizeContents ( m_pixmap-> width ( ), m_pixmap-> height ( )); 206 resizeContents ( m_pixmap-> width ( ), m_pixmap-> height ( ));
209 setContentsPos ( 0, 0 ); 207 setContentsPos ( 0, 0 );
210 208
211 m_pixmap-> fill ( white ); // clear window 209 m_pixmap-> fill ( white ); // clear window
212 m_text-> clear ( ); // cleat text object 210 m_text-> clear ( ); // cleat text object
213 viewport ( )-> repaint ( ); 211 viewport ( )-> repaint ( );
214} 212}
215 213
216void QOutputDev::endPage ( ) 214void QOutputDev::endPage ( )
217{ 215{
218 m_text-> coalesce ( ); 216 m_text-> coalesce ( );
219 217
220 delete m_painter; 218 delete m_painter;
221 m_painter = 0; 219 m_painter = 0;
222 220
223 updateContents ( 0, 0, contentsWidth ( ), contentsHeight ( )); 221 updateContents ( 0, 0, contentsWidth ( ), contentsHeight ( ));
224} 222}
225 223
226void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ ) 224void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ )
227{ 225{
228 fp_t x1, y1, x2, y2, w; 226 fp_t x1, y1, x2, y2, w;
229 227
230 link-> getBorder ( &x1, &y1, &x2, &y2, &w ); 228 link-> getBorder ( &x1, &y1, &x2, &y2, &w );
231 229
232 if ( w > 0 ) { 230 if ( w > 0 ) {
233 int x, y, dx, dy; 231 int x, y, dx, dy;
234 232
235 cvtUserToDev ( x1, y1, &x, &y ); 233 cvtUserToDev ( x1, y1, &x, &y );
236 cvtUserToDev ( x2, y2, &dx, &dy ); 234 cvtUserToDev ( x2, y2, &dx, &dy );
237 235
238 QPen oldpen = m_painter-> pen ( ); 236 QPen oldpen = m_painter-> pen ( );
239 m_painter-> setPen ( blue ); 237 m_painter-> setPen ( blue );
240 m_painter-> drawRect ( x, y, dx, dy ); 238 m_painter-> drawRect ( x, y, dx, dy );
241 m_painter-> setPen ( oldpen ); 239 m_painter-> setPen ( oldpen );
242 } 240 }
243} 241}
244 242
245void QOutputDev::saveState ( GfxState */*state*/ ) 243void QOutputDev::saveState ( GfxState */*state*/ )
246{ 244{
247 QPDFDBG( printf ( "SAVE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( ))); 245 QPDFDBG( printf ( "SAVE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
248 246
249 m_painter-> save ( ); 247 m_painter-> save ( );
250} 248}
251 249
252void QOutputDev::restoreState ( GfxState */*state*/ ) 250void QOutputDev::restoreState ( GfxState */*state*/ )
253{ 251{
254 m_painter-> restore ( ); 252 m_painter-> restore ( );
255 253
256 //m_painter-> setClipRegion ( QRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ))); 254 //m_painter-> setClipRegion ( QRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( )));
257 //m_painter-> setClipping ( false ); 255 //m_painter-> setClipping ( false );
258 QPDFDBG ( printf ( "RESTORE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( ))); 256 QPDFDBG ( printf ( "RESTORE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
259} 257}
260 258
261void QOutputDev::updateAll ( GfxState *state ) 259void QOutputDev::updateAll ( GfxState *state )
262{ 260{
263 updateLineAttrs ( state, gTrue ); 261 updateLineAttrs ( state, gTrue );
264 //updateFlatness ( state ); 262 //updateFlatness ( state );
265 //updateMiterLimit ( state ); 263 //updateMiterLimit ( state );
266 updateFillColor ( state ); 264 updateFillColor ( state );
267 updateStrokeColor ( state ); 265 updateStrokeColor ( state );
268 updateFont ( state ); 266 updateFont ( state );
269} 267}
270 268
271void QOutputDev::updateCTM ( GfxState *state, fp_t /*m11*/, fp_t /*m12*/, fp_t /*m21*/, fp_t /*m22*/, fp_t /*m31*/, fp_t /*m32*/ ) 269void QOutputDev::updateCTM ( GfxState *state, fp_t /*m11*/, fp_t /*m12*/, fp_t /*m21*/, fp_t /*m22*/, fp_t /*m31*/, fp_t /*m32*/ )
272{ 270{
273 updateLineAttrs ( state, gTrue ); 271 updateLineAttrs ( state, gTrue );
274} 272}
275 273
276void QOutputDev::updateLineDash ( GfxState *state ) 274void QOutputDev::updateLineDash ( GfxState *state )
277{ 275{
278 updateLineAttrs ( state, gTrue ); 276 updateLineAttrs ( state, gTrue );
279} 277}
280 278
281void QOutputDev::updateFlatness ( GfxState */*state*/ ) 279void QOutputDev::updateFlatness ( GfxState */*state*/ )
282{ 280{
283 // not supported 281 // not supported
284 QPDFDBG( printf ( "updateFlatness not supported !\n" )); 282 QPDFDBG( printf ( "updateFlatness not supported !\n" ));
285} 283}
286 284
287void QOutputDev::updateLineJoin ( GfxState *state ) 285void QOutputDev::updateLineJoin ( GfxState *state )
288{ 286{
289 updateLineAttrs ( state, gFalse ); 287 updateLineAttrs ( state, gFalse );
290} 288}
291 289
292void QOutputDev::updateLineCap ( GfxState *state ) 290void QOutputDev::updateLineCap ( GfxState *state )
293{ 291{
294 updateLineAttrs ( state, gFalse ); 292 updateLineAttrs ( state, gFalse );
295} 293}
296 294
297// unimplemented 295// unimplemented
298void QOutputDev::updateMiterLimit ( GfxState */*state*/ ) 296void QOutputDev::updateMiterLimit ( GfxState */*state*/ )
299{ 297{
300 QPDFDBG( printf ( "updateMiterLimit not supported !\n" )); 298 QPDFDBG( printf ( "updateMiterLimit not supported !\n" ));
301} 299}
302 300
303void QOutputDev::updateLineWidth ( GfxState *state ) 301void QOutputDev::updateLineWidth ( GfxState *state )
304{ 302{
305 updateLineAttrs ( state, gFalse ); 303 updateLineAttrs ( state, gFalse );
306} 304}
307 305
308void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash ) 306void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash )
309{ 307{
310 fp_t *dashPattern; 308 fp_t *dashPattern;
311 int dashLength; 309 int dashLength;
312 fp_t dashStart; 310 fp_t dashStart;
313 311
314 Qt::PenCapStyle cap; 312 Qt::PenCapStyle cap;
315 Qt::PenJoinStyle join; 313 Qt::PenJoinStyle join;
316 int width; 314 int width;
317 315
318 width = lrint ( state-> getTransformedLineWidth ( )); 316 width = lrint ( state-> getTransformedLineWidth ( ));
319 317
320 switch ( state-> getLineCap ( )) { 318 switch ( state-> getLineCap ( )) {
321 case 0: cap = FlatCap; break; 319 case 0: cap = FlatCap; break;
322 case 1: cap = RoundCap; break; 320 case 1: cap = RoundCap; break;
323 case 2: cap = SquareCap; break; 321 case 2: cap = SquareCap; break;
324 default: 322 default:
325 qWarning ( "Bad line cap style (%d)\n", state-> getLineCap ( )); 323 qWarning ( "Bad line cap style (%d)\n", state-> getLineCap ( ));
326 cap = FlatCap; 324 cap = FlatCap;
327 break; 325 break;
328 } 326 }
329 327
330 switch (state->getLineJoin()) { 328 switch (state->getLineJoin()) {
331 case 0: join = MiterJoin; break; 329 case 0: join = MiterJoin; break;
332 case 1: join = RoundJoin; break; 330 case 1: join = RoundJoin; break;
333 case 2: join = BevelJoin; break; 331 case 2: join = BevelJoin; break;
334 default: 332 default:
335 qWarning ( "Bad line join style (%d)\n", state->getLineJoin ( )); 333 qWarning ( "Bad line join style (%d)\n", state->getLineJoin ( ));
336 join = MiterJoin; 334 join = MiterJoin;
337 break; 335 break;
338 } 336 }
339 337
340 state-> getLineDash ( &dashPattern, &dashLength, &dashStart ); 338 state-> getLineDash ( &dashPattern, &dashLength, &dashStart );
341 339
342 QColor oldcol = m_painter-> pen ( ). color ( ); 340 QColor oldcol = m_painter-> pen ( ). color ( );
343 GfxRGB rgb; 341 GfxRGB rgb;
344 342
345 state-> getStrokeRGB ( &rgb ); 343 state-> getStrokeRGB ( &rgb );
346 oldcol = q_col ( rgb ); 344 oldcol = q_col ( rgb );
347 345
348 m_painter-> setPen ( QPen ( oldcol, width, dashLength > 0 ? DashLine : SolidLine, cap, join )); 346 m_painter-> setPen ( QPen ( oldcol, width, dashLength > 0 ? DashLine : SolidLine, cap, join ));
349 347
350 if ( updateDash && ( dashLength > 0 )) { 348 if ( updateDash && ( dashLength > 0 )) {
351 // Not supported by QT 349 // Not supported by QT
352 /* 350 /*
353 char dashList[20]; 351 char dashList[20];
354 if (dashLength > 20) 352 if (dashLength > 20)
355 dashLength = 20; 353 dashLength = 20;
356 for ( int i = 0; i < dashLength; ++i ) { 354 for ( int i = 0; i < dashLength; ++i ) {
357 dashList[i] = xoutRound(state->transformWidth(dashPattern[i])); 355 dashList[i] = xoutRound(state->transformWidth(dashPattern[i]));
358 if (dashList[i] == 0) 356 if (dashList[i] == 0)
359 dashList[i] = 1; 357 dashList[i] = 1;
360 } 358 }
361 XSetDashes(display, strokeGC, xoutRound(dashStart), dashList, dashLength); 359 XSetDashes(display, strokeGC, xoutRound(dashStart), dashList, dashLength);
362*/ 360*/
363 } 361 }
364} 362}
365 363
366void QOutputDev::updateFillColor ( GfxState *state ) 364void QOutputDev::updateFillColor ( GfxState *state )
367{ 365{
368 GfxRGB rgb; 366 GfxRGB rgb;
369 state-> getFillRGB ( &rgb ); 367 state-> getFillRGB ( &rgb );
370 368
371 m_painter-> setBrush ( q_col ( rgb )); 369 m_painter-> setBrush ( q_col ( rgb ));
372} 370}
373 371
374void QOutputDev::updateStrokeColor ( GfxState *state ) 372void QOutputDev::updateStrokeColor ( GfxState *state )
375{ 373{
376 GfxRGB rgb; 374 GfxRGB rgb;
377 state-> getStrokeRGB ( &rgb ); 375 state-> getStrokeRGB ( &rgb );
378 376
379 QPen pen = m_painter-> pen ( ); 377 QPen pen = m_painter-> pen ( );
380 pen. setColor ( q_col ( rgb )); 378 pen. setColor ( q_col ( rgb ));
381 m_painter-> setPen ( pen ); 379 m_painter-> setPen ( pen );
382} 380}
383 381
384void QOutputDev::updateFont ( GfxState *state ) 382void QOutputDev::updateFont ( GfxState *state )
385{ 383{
386 fp_t m11, m12, m21, m22; 384 fp_t m11, m12, m21, m22;
387 GfxFont *gfxFont = state-> getFont ( ); 385 GfxFont *gfxFont = state-> getFont ( );
388 386
389 if ( !gfxFont ) 387 if ( !gfxFont )
390 return; 388 return;
391 389
392 state-> getFontTransMat ( &m11, &m12, &m21, &m22 ); 390 state-> getFontTransMat ( &m11, &m12, &m21, &m22 );
393 m11 *= state-> getHorizScaling ( ); 391 m11 *= state-> getHorizScaling ( );
394 m12 *= state-> getHorizScaling ( ); 392 m12 *= state-> getHorizScaling ( );
395 393
396 QFont font = matchFont ( gfxFont, m11, m12, m21, m22 ); 394 QFont font = matchFont ( gfxFont, m11, m12, m21, m22 );
397 395
398 m_painter-> setFont ( font ); 396 m_painter-> setFont ( font );
399 m_text-> updateFont ( state ); 397 m_text-> updateFont ( state );
400} 398}
401 399
402void QOutputDev::stroke ( GfxState *state ) 400void QOutputDev::stroke ( GfxState *state )
403{ 401{
404 QPointArray points; 402 QPointArray points;
405 QArray<int> lengths; 403 QArray<int> lengths;
406 404
407 // transform points 405 // transform points
408 int n = convertPath ( state, points, lengths ); 406 int n = convertPath ( state, points, lengths );
409 407
410 QPDFDBG( printf ( "DRAWING: %d POLYS\n", n )); 408 QPDFDBG( printf ( "DRAWING: %d POLYS\n", n ));
411 409
412 // draw each subpath 410 // draw each subpath
413 int j = 0; 411 int j = 0;
414 for ( int i = 0; i < n; i++ ) { 412 for ( int i = 0; i < n; i++ ) {
415 int len = lengths [i]; 413 int len = lengths [i];
416 414
417 if ( len >= 2 ) { 415 if ( len >= 2 ) {
418 QPDFDBG( printf ( " - POLY %d: ", i )); 416 QPDFDBG( printf ( " - POLY %d: ", i ));
419 QPDFDBG( for ( int ii = 0; ii < len; ii++ )) 417 QPDFDBG( for ( int ii = 0; ii < len; ii++ ))
420 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); 418 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
421 QPDFDBG( printf ( "\n" )); 419 QPDFDBG( printf ( "\n" ));
422 420
423 m_painter-> drawPolyline ( points, j, len ); 421 m_painter-> drawPolyline ( points, j, len );
424 } 422 }
425 j += len; 423 j += len;
426 } 424 }
427 qApp-> processEvents ( ); 425 qApp-> processEvents ( );
428} 426}
429 427
430void QOutputDev::fill ( GfxState *state ) 428void QOutputDev::fill ( GfxState *state )
431{ 429{
432 doFill ( state, true ); 430 doFill ( state, true );
433} 431}
434 432
435void QOutputDev::eoFill ( GfxState *state ) 433void QOutputDev::eoFill ( GfxState *state )
436{ 434{
437 doFill ( state, false ); 435 doFill ( state, false );
438} 436}
439 437
440// 438//
441// X doesn't color the pixels on the right-most and bottom-most 439// X doesn't color the pixels on the right-most and bottom-most
442// borders of a polygon. This means that one-pixel-thick polygons 440// borders of a polygon. This means that one-pixel-thick polygons
443// are not colored at all. I think this is supposed to be a 441// are not colored at all. I think this is supposed to be a
444// feature, but I can't figure out why. So after it fills a 442// feature, but I can't figure out why. So after it fills a
445// polygon, it also draws lines around the border. This is done 443// polygon, it also draws lines around the border. This is done
446// only for single-component polygons, since it's not very 444// only for single-component polygons, since it's not very
447// compatible with the compound polygon kludge (see convertPath()). 445// compatible with the compound polygon kludge (see convertPath()).
448// 446//
449void QOutputDev::doFill ( GfxState *state, bool winding ) 447void QOutputDev::doFill ( GfxState *state, bool winding )
450{ 448{
451 QPointArray points; 449 QPointArray points;
452 QArray<int> lengths; 450 QArray<int> lengths;
453 451
454 // transform points 452 // transform points
455 int n = convertPath ( state, points, lengths ); 453 int n = convertPath ( state, points, lengths );
456 454
457 QPDFDBG( printf ( "FILLING: %d POLYS\n", n )); 455 QPDFDBG( printf ( "FILLING: %d POLYS\n", n ));
458 456
459 QPen oldpen = m_painter-> pen ( ); 457 QPen oldpen = m_painter-> pen ( );
460 m_painter-> setPen ( QPen ( NoPen )); 458 m_painter-> setPen ( QPen ( NoPen ));
461 459
462 // draw each subpath 460 // draw each subpath
463 int j = 0; 461 int j = 0;
464 for ( int i = 0; i < n; i++ ) { 462 for ( int i = 0; i < n; i++ ) {
465 int len = lengths [i]; 463 int len = lengths [i];
466 464
467 if ( len >= 3 ) { 465 if ( len >= 3 ) {
468 QPDFDBG( printf ( " - POLY %d: ", i )); 466 QPDFDBG( printf ( " - POLY %d: ", i ));
469 QPDFDBG( for ( int ii = 0; ii < len; ii++ )) 467 QPDFDBG( for ( int ii = 0; ii < len; ii++ ))
470 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); 468 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
471 QPDFDBG( printf ( "\n" )); 469 QPDFDBG( printf ( "\n" ));
472 470
473 m_painter-> drawPolygon ( points, winding, j, len ); 471 m_painter-> drawPolygon ( points, winding, j, len );
474 } 472 }
475 j += len; 473 j += len;
476 } 474 }
477 m_painter-> setPen ( oldpen ); 475 m_painter-> setPen ( oldpen );
478 476
479 qApp-> processEvents ( ); 477 qApp-> processEvents ( );
480} 478}
481 479
482void QOutputDev::clip ( GfxState *state ) 480void QOutputDev::clip ( GfxState *state )
483{ 481{
484 doClip ( state, true ); 482 doClip ( state, true );
485} 483}
486 484
487void QOutputDev::eoClip ( GfxState *state ) 485void QOutputDev::eoClip ( GfxState *state )
488{ 486{
489 doClip ( state, false ); 487 doClip ( state, false );
490} 488}
491 489
492void QOutputDev::doClip ( GfxState *state, bool winding ) 490void QOutputDev::doClip ( GfxState *state, bool winding )
493{ 491{
494 QPointArray points; 492 QPointArray points;
495 QArray<int> lengths; 493 QArray<int> lengths;
496 494
497 // transform points 495 // transform points
498 int n = convertPath ( state, points, lengths ); 496 int n = convertPath ( state, points, lengths );
499 497
500 QRegion region; 498 QRegion region;
501 499
502 QPDFDBG( printf ( "CLIPPING: %d POLYS\n", n )); 500 QPDFDBG( printf ( "CLIPPING: %d POLYS\n", n ));
503 501
504 // draw each subpath 502 // draw each subpath
505 int j = 0; 503 int j = 0;
506 for ( int i = 0; i < n; i++ ) { 504 for ( int i = 0; i < n; i++ ) {
507 int len = lengths [i]; 505 int len = lengths [i];
508 506
509 if ( len >= 3 ) { 507 if ( len >= 3 ) {
510 QPointArray dummy; 508 QPointArray dummy;
511 dummy. setRawData ( points. data ( ) + j, len ); 509 dummy. setRawData ( points. data ( ) + j, len );
512 510
513 QPDFDBG( printf ( " - POLY %d: ", i )); 511 QPDFDBG( printf ( " - POLY %d: ", i ));
514 QPDFDBG( for ( int ii = 0; ii < len; ii++ ) printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); 512 QPDFDBG( for ( int ii = 0; ii < len; ii++ ) printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
515 QPDFDBG( printf ( "\n" )); 513 QPDFDBG( printf ( "\n" ));
516 514
517 region |= QRegion ( dummy, winding ); 515 region |= QRegion ( dummy, winding );
518 516
519 dummy. resetRawData ( points. data ( ) + j, len ); 517 dummy. resetRawData ( points. data ( ) + j, len );
520 } 518 }
521 j += len; 519 j += len;
522 } 520 }
523 521
524 if ( m_painter-> hasClipping ( )) 522 if ( m_painter-> hasClipping ( ))
525 region &= m_painter-> clipRegion ( ); 523 region &= m_painter-> clipRegion ( );
526 524
527 //m_painter-> setClipRegion ( region ); 525 //m_painter-> setClipRegion ( region );
528 //m_painter-> setClipping ( true ); 526 //m_painter-> setClipping ( true );
529 527
530 //m_painter-> fillRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ), red ); 528 //m_painter-> fillRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ), red );
531 //m_painter-> drawText ( points [0]. x ( ) + 10, points [0]. y ( ) + 10, "Bla bla" ); 529 //m_painter-> drawText ( points [0]. x ( ) + 10, points [0]. y ( ) + 10, "Bla bla" );
532 qApp-> processEvents ( ); 530 qApp-> processEvents ( );
533} 531}
534 532
535// 533//
536// Transform points in the path and convert curves to line segments. 534// Transform points in the path and convert curves to line segments.
537// Builds a set of subpaths and returns the number of subpaths. 535// Builds a set of subpaths and returns the number of subpaths.
538// If <fillHack> is set, close any unclosed subpaths and activate a 536// If <fillHack> is set, close any unclosed subpaths and activate a
539// kludge for polygon fills: First, it divides up the subpaths into 537// kludge for polygon fills: First, it divides up the subpaths into
540// non-overlapping polygons by simply comparing bounding rectangles. 538// non-overlapping polygons by simply comparing bounding rectangles.
541// Then it connects subaths within a single compound polygon to a single 539// Then it connects subaths within a single compound polygon to a single
542// point so that X can fill the polygon (sort of). 540// point so that X can fill the polygon (sort of).
543// 541//
544int QOutputDev::convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths ) 542int QOutputDev::convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths )
545{ 543{
546 GfxPath *path = state-> getPath ( ); 544 GfxPath *path = state-> getPath ( );
547 int n = path-> getNumSubpaths ( ); 545 int n = path-> getNumSubpaths ( );
548 546
549 lengths. resize ( n ); 547 lengths. resize ( n );
550 548
551 // do each subpath 549 // do each subpath
552 for ( int i = 0; i < n; i++ ) { 550 for ( int i = 0; i < n; i++ ) {
553 // transform the points 551 // transform the points
554 lengths [i] = convertSubpath ( state, path-> getSubpath ( i ), points ); 552 lengths [i] = convertSubpath ( state, path-> getSubpath ( i ), points );
555 } 553 }
556 554
557 return n; 555 return n;
558} 556}
559 557
560// 558//
561// Transform points in a single subpath and convert curves to line 559// Transform points in a single subpath and convert curves to line
562// segments. 560// segments.
563// 561//
564int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points ) 562int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points )
565{ 563{
566 int oldcnt = points. count ( ); 564 int oldcnt = points. count ( );
567 565
568 fp_t x0, y0, x1, y1, x2, y2, x3, y3; 566 fp_t x0, y0, x1, y1, x2, y2, x3, y3;
569 567
570 int m = subpath-> getNumPoints ( ); 568 int m = subpath-> getNumPoints ( );
571 int i = 0; 569 int i = 0;
572 570
573 while ( i < m ) { 571 while ( i < m ) {
574 if ( i >= 1 && subpath-> getCurve ( i )) { 572 if ( i >= 1 && subpath-> getCurve ( i )) {
575 state-> transform ( subpath-> getX ( i - 1 ), subpath-> getY ( i - 1 ), &x0, &y0 ); 573 state-> transform ( subpath-> getX ( i - 1 ), subpath-> getY ( i - 1 ), &x0, &y0 );
576 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); 574 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 );
577 state-> transform ( subpath-> getX ( i + 1 ), subpath-> getY ( i + 1 ), &x2, &y2 ); 575 state-> transform ( subpath-> getX ( i + 1 ), subpath-> getY ( i + 1 ), &x2, &y2 );
578 state-> transform ( subpath-> getX ( i + 2 ), subpath-> getY ( i + 2 ), &x3, &y3 ); 576 state-> transform ( subpath-> getX ( i + 2 ), subpath-> getY ( i + 2 ), &x3, &y3 );
579 577
580 QPointArray tmp; 578 QPointArray tmp;
581 tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ), 579 tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ),
582 lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 )); 580 lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 ));
583 581
584#if QT_VERSION < 300 582#if QT_VERSION < 300
585 tmp = tmp. quadBezier ( ); 583 tmp = tmp. quadBezier ( );
586 584
587 for ( uint loop = 0; loop < tmp. count ( ); loop++ ) { 585 for ( uint loop = 0; loop < tmp. count ( ); loop++ ) {
588 QPoint p = tmp. point ( loop ); 586 QPoint p = tmp. point ( loop );
589 points. putPoints ( points. count ( ), 1, p. x ( ), p. y ( )); 587 points. putPoints ( points. count ( ), 1, p. x ( ), p. y ( ));
590 } 588 }
591#else 589#else
592 tmp = tmp. cubicBezier ( ); 590 tmp = tmp. cubicBezier ( );
593 points. putPoints ( points. count ( ), tmp. count ( ), tmp ); 591 points. putPoints ( points. count ( ), tmp. count ( ), tmp );
594#endif 592#endif
595 593
596 i += 3; 594 i += 3;
597 } 595 }
598 else { 596 else {
599 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); 597 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 );
600 598
601 points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 )); 599 points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 ));
602 ++i; 600 ++i;
603 } 601 }
604 } 602 }
605 return points. count ( ) - oldcnt; 603 return points. count ( ) - oldcnt;
606} 604}
607 605
608 606
609void QOutputDev::beginString ( GfxState *state, GString */*s*/ ) 607void QOutputDev::beginString ( GfxState *state, GString */*s*/ )
610{ 608{
611 m_text-> beginString ( state ); 609 m_text-> beginString ( state );
612} 610}
613 611
614void QOutputDev::endString ( GfxState */*state*/ ) 612void QOutputDev::endString ( GfxState */*state*/ )
615{ 613{
616 m_text-> endString ( ); 614 m_text-> endString ( );
617} 615}
618 616
619void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y, 617void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
620 fp_t dx, fp_t dy, fp_t originX, fp_t originY, 618 fp_t dx, fp_t dy, fp_t originX, fp_t originY,
621 CharCode code, Unicode *u, int uLen ) 619 CharCode code, Unicode *u, int uLen )
622{ 620{
623 fp_t x1, y1, dx1, dy1; 621 fp_t x1, y1, dx1, dy1;
624 622
625 if ( uLen > 0 ) 623 if ( uLen > 0 )
626 m_text-> addChar ( state, x, y, dx, dy, u, uLen ); 624 m_text-> addChar ( state, x, y, dx, dy, u, uLen );
627 625
628 // check for invisible text -- this is used by Acrobat Capture 626 // check for invisible text -- this is used by Acrobat Capture
629 if (( state-> getRender ( ) & 3 ) == 3 ) { 627 if (( state-> getRender ( ) & 3 ) == 3 ) {
630 return; 628 return;
631 } 629 }
632 630
633 x -= originX; 631 x -= originX;
634 y -= originY; 632 y -= originY;
635 state-> transform ( x, y, &x1, &y1 ); 633 state-> transform ( x, y, &x1, &y1 );
636 state-> transformDelta ( dx, dy, &dx1, &dy1 ); 634 state-> transformDelta ( dx, dy, &dx1, &dy1 );
637 635
638 636
639 if ( uLen > 0 ) { 637 if ( uLen > 0 ) {
640 QString str; 638 QString str;
641 QFontMetrics fm = m_painter-> fontMetrics ( ); 639 QFontMetrics fm = m_painter-> fontMetrics ( );
642 640
643 for ( int i = 0; i < uLen; i++ ) { 641 for ( int i = 0; i < uLen; i++ ) {
644 QChar c = QChar ( u [i] ); 642 QChar c = QChar ( u [i] );
645 643
646 if ( fm. inFont ( c )) { 644 if ( fm. inFont ( c )) {
647 str [i] = QChar ( u [i] ); 645 str [i] = QChar ( u [i] );
648 } 646 }
649 else { 647 else {
650 str [i] = ' '; 648 str [i] = ' ';
651 QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( ))); 649 QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( )));
652 } 650 }
653 } 651 }
654 652
655 if (( uLen == 1 ) && ( str [0] == ' ' )) 653 if (( uLen == 1 ) && ( str [0] == ' ' ))
656 return; 654 return;
657 655
658 656
659 fp_t m11, m12, m21, m22; 657 fp_t m11, m12, m21, m22;
660 658
661 state-> getFontTransMat ( &m11, &m12, &m21, &m22 ); 659 state-> getFontTransMat ( &m11, &m12, &m21, &m22 );
662 m11 *= state-> getHorizScaling ( ); 660 m11 *= state-> getHorizScaling ( );
663 m12 *= state-> getHorizScaling ( ); 661 m12 *= state-> getHorizScaling ( );
664 662
665 fp_t fsize = m_painter-> font ( ). pixelSize ( ); 663 fp_t fsize = m_painter-> font ( ). pixelSize ( );
666 664
667#ifndef QT_NO_TRANSFORMATIONS 665#ifndef QT_NO_TRANSFORMATIONS
668 QWMatrix oldmat; 666 QWMatrix oldmat;
669 667
670 bool dorot = (( m12 < -0.1 ) || ( m12 > 0.1 )) && (( m21 < -0.1 ) || ( m21 > 0.1 )); 668 bool dorot = (( m12 < -0.1 ) || ( m12 > 0.1 )) && (( m21 < -0.1 ) || ( m21 > 0.1 ));
671 669
672 if ( dorot ) { 670 if ( dorot ) {
673 oldmat = m_painter-> worldMatrix ( ); 671 oldmat = m_painter-> worldMatrix ( );
674 672
675 cerr << endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl; 673 cerr << endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl;
676 674
677 QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 )); 675 QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 ));
678 676
679 m_painter-> setWorldMatrix ( mat ); 677 m_painter-> setWorldMatrix ( mat );
680 678
681 x1 = 0; 679 x1 = 0;
682 y1 = 0; 680 y1 = 0;
683 } 681 }
684#endif 682#endif
685 683
686 QPen oldpen = m_painter-> pen ( ); 684 QPen oldpen = m_painter-> pen ( );
687 685
688 if (!( state-> getRender ( ) & 1 )) { 686 if (!( state-> getRender ( ) & 1 )) {
689 QPen fillpen = oldpen; 687 QPen fillpen = oldpen;
690 688
691 fillpen. setColor ( m_painter-> brush ( ). color ( )); 689 fillpen. setColor ( m_painter-> brush ( ). color ( ));
692 m_painter-> setPen ( fillpen ); 690 m_painter-> setPen ( fillpen );
693 } 691 }
694 692
695 if ( fsize > 5 ) 693 if ( fsize > 5 )
696 m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str ); 694 m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str );
697 else 695 else
698 m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( )); 696 m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( ));
699 697
700 m_painter-> setPen ( oldpen ); 698 m_painter-> setPen ( oldpen );
701 699
702#ifndef QT_NO_TRANSFORMATIONS 700#ifndef QT_NO_TRANSFORMATIONS
703 if ( dorot ) 701 if ( dorot )
704 m_painter-> setWorldMatrix ( oldmat ); 702 m_painter-> setWorldMatrix ( oldmat );
705 #endif 703 #endif
706 704
707 QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 ))); 705 QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 )));
708 } 706 }
709 else if ( code != 0 ) { 707 else if ( code != 0 ) {
710 // some PDF files use CID 0, which is .notdef, so just ignore it 708 // some PDF files use CID 0, which is .notdef, so just ignore it
711 qWarning ( "Unknown character (CID=%d Unicode=%hx)\n", code, (unsigned short) ( uLen > 0 ? u [0] : (Unicode) 0 )); 709 qWarning ( "Unknown character (CID=%d Unicode=%hx)\n", code, (unsigned short) ( uLen > 0 ? u [0] : (Unicode) 0 ));
712 } 710 }
713 qApp-> processEvents ( ); 711 qApp-> processEvents ( );
714} 712}
715 713
716 714
717 715
718void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg ) 716void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg )
719{ 717{
720 // get CTM, check for singular matrix 718 // get CTM, check for singular matrix
721 fp_t *ctm = state-> getCTM ( ); 719 fp_t *ctm = state-> getCTM ( );
722 720
723 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) { 721 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) {
724 qWarning ( "Singular CTM in drawImage\n" ); 722 qWarning ( "Singular CTM in drawImage\n" );
725 723
726 if ( inlineImg ) { 724 if ( inlineImg ) {
727 str-> reset ( ); 725 str-> reset ( );
728 int j = height * (( width + 7 ) / 8 ); 726 int j = height * (( width + 7 ) / 8 );
729 for ( int i = 0; i < j; i++ ) 727 for ( int i = 0; i < j; i++ )
730 str->getChar(); 728 str->getChar();
731 729
732 str->close(); 730 str->close();
733 } 731 }
734 return; 732 return;
735 } 733 }
736 734
737 GfxRGB rgb; 735 GfxRGB rgb;
738 state-> getFillRGB ( &rgb ); 736 state-> getFillRGB ( &rgb );
739 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff ); 737 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
740 738
741 739
742 QImage img ( width, height, 32 ); 740 QImage img ( width, height, 32 );
743 img. setAlphaBuffer ( true ); 741 img. setAlphaBuffer ( true );
744 742
745 QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height )); 743 QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height ));
746 744
747 // initialize the image stream 745 // initialize the image stream
748 ImageStream *imgStr = new ImageStream ( str, width, 1, 1 ); 746 ImageStream *imgStr = new ImageStream ( str, width, 1, 1 );
749 imgStr-> reset ( ); 747 imgStr-> reset ( );
750 748
751 uchar **scanlines = img. jumpTable ( ); 749 uchar **scanlines = img. jumpTable ( );
752 750
753 if ( ctm [3] > 0 ) 751 if ( ctm [3] > 0 )
754 scanlines += ( height - 1 ); 752 scanlines += ( height - 1 );
755 753
756 for ( int y = 0; y < height; y++ ) { 754 for ( int y = 0; y < height; y++ ) {
757 QRgb *scanline = (QRgb *) *scanlines; 755 QRgb *scanline = (QRgb *) *scanlines;
758 756
759 if ( ctm [0] < 0 ) 757 if ( ctm [0] < 0 )
760 scanline += ( width - 1 ); 758 scanline += ( width - 1 );
761 759
762 for ( int x = 0; x < width; x++ ) { 760 for ( int x = 0; x < width; x++ ) {
763 Guchar alpha; 761 Guchar alpha;
764 762
765 imgStr-> getPixel ( &alpha ); 763 imgStr-> getPixel ( &alpha );
766 764
767 if ( invert ) 765 if ( invert )
768 alpha ^= 1; 766 alpha ^= 1;
769 767
770 *scanline = ( alpha == 0 ) ? 0xff000000 | val : val; 768 *scanline = ( alpha == 0 ) ? 0xff000000 | val : val;
771 769
772 ctm [0] < 0 ? scanline-- : scanline++; 770 ctm [0] < 0 ? scanline-- : scanline++;
773 } 771 }
774 ctm [3] > 0 ? scanlines-- : scanlines++; 772 ctm [3] > 0 ? scanlines-- : scanlines++;
775 773
776 qApp-> processEvents ( ); 774 qApp-> processEvents ( );
777 } 775 }
778 776
779 #ifndef QT_NO_TRANSFORMATIONS 777 #ifndef QT_NO_TRANSFORMATIONS
780 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] ); 778 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] );
781 779
782 cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << endl 780 cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << endl
783 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << endl; 781 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << endl;
784 782
785 QWMatrix oldmat = m_painter-> worldMatrix ( ); 783 QWMatrix oldmat = m_painter-> worldMatrix ( );
786 m_painter-> setWorldMatrix ( mat, true ); 784 m_painter-> setWorldMatrix ( mat, true );
787 785
788#ifdef QWS 786#ifdef QWS
789 QPixmap pm; 787 QPixmap pm;
790 pm. convertFromImage ( img ); 788 pm. convertFromImage ( img );
791 m_painter-> drawPixmap ( 0, 0, pm ); 789 m_painter-> drawPixmap ( 0, 0, pm );
792#else 790#else
793 m_painter-> drawImage ( QPoint ( 0, 0 ), img ); 791 m_painter-> drawImage ( QPoint ( 0, 0 ), img );
794#endif 792#endif
795 793
796 m_painter-> setWorldMatrix ( oldmat ); 794 m_painter-> setWorldMatrix ( oldmat );
797 795
798#else 796#else
799 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { 797 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) {
800 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); 798 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ));
801 } 799 }
802 else { 800 else {
803 int x = lrint ( ctm [4] ); 801 int x = lrint ( ctm [4] );
804 int y = lrint ( ctm [5] ); 802 int y = lrint ( ctm [5] );
805 803
806 int w = lrint ( ctm [0] ); 804 int w = lrint ( ctm [0] );
807 int h = lrint ( ctm [3] ); 805 int h = lrint ( ctm [3] );
808 806
809 if ( w < 0 ) { 807 if ( w < 0 ) {
810 x += w; 808 x += w;
811 w = -w; 809 w = -w;
812 } 810 }
813 if ( h < 0 ) { 811 if ( h < 0 ) {
814 y += h; 812 y += h;
815 h = -h; 813 h = -h;
816 } 814 }
817 815
818 QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h )); 816 QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h ));
819 817
820 img = img. smoothScale ( w, h ); 818 img = img. smoothScale ( w, h );
821 qApp-> processEvents ( ); 819 qApp-> processEvents ( );
822 m_painter-> drawImage ( x, y, img ); 820 m_painter-> drawImage ( x, y, img );
823 } 821 }
824 822
825#endif 823#endif
826 824
827 delete imgStr; 825 delete imgStr;
828 qApp-> processEvents ( ); 826 qApp-> processEvents ( );
829} 827}
830 828
831 829
832void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg ) 830void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg )
833{ 831{
834 int nComps, nVals, nBits; 832 int nComps, nVals, nBits;
835 833
836 // image parameters 834 // image parameters
837 nComps = colorMap->getNumPixelComps ( ); 835 nComps = colorMap->getNumPixelComps ( );
838 nVals = width * nComps; 836 nVals = width * nComps;
839 nBits = colorMap-> getBits ( ); 837 nBits = colorMap-> getBits ( );
840 838
841 // get CTM, check for singular matrix 839 // get CTM, check for singular matrix
842 fp_t *ctm = state-> getCTM ( ); 840 fp_t *ctm = state-> getCTM ( );
843 841
844 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) { 842 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) {
845 qWarning ( "Singular CTM in drawImage\n" ); 843 qWarning ( "Singular CTM in drawImage\n" );
846 844
847 if ( inlineImg ) { 845 if ( inlineImg ) {
848 str-> reset ( ); 846 str-> reset ( );
849 int j = height * (( nVals * nBits + 7 ) / 8 ); 847 int j = height * (( nVals * nBits + 7 ) / 8 );
850 for ( int i = 0; i < j; i++ ) 848 for ( int i = 0; i < j; i++ )
851 str->getChar(); 849 str->getChar();
852 850
853 str->close(); 851 str->close();
854 } 852 }
855 return; 853 return;
856 } 854 }
857 855
858 QImage img ( width, height, 32 ); 856 QImage img ( width, height, 32 );
859 857
860 if ( maskColors ) 858 if ( maskColors )
861 img. setAlphaBuffer ( true ); 859 img. setAlphaBuffer ( true );
862 860
863 QPDFDBG( printf ( "IMAGE (%dx%d)\n", width, height )); 861 QPDFDBG( printf ( "IMAGE (%dx%d)\n", width, height ));
864 862
865 // initialize the image stream 863 // initialize the image stream
866 ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits ); 864 ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits );
867 imgStr-> reset ( ); 865 imgStr-> reset ( );
868 866
869 Guchar pixBuf [gfxColorMaxComps]; 867 Guchar pixBuf [gfxColorMaxComps];
870 GfxRGB rgb; 868 GfxRGB rgb;
871 869
872 870
873 uchar **scanlines = img. jumpTable ( ); 871 uchar **scanlines = img. jumpTable ( );
874 872
875 if ( ctm [3] > 0 ) 873 if ( ctm [3] > 0 )
876 scanlines += ( height - 1 ); 874 scanlines += ( height - 1 );
877 875
878 for ( int y = 0; y < height; y++ ) { 876 for ( int y = 0; y < height; y++ ) {
879 QRgb *scanline = (QRgb *) *scanlines; 877 QRgb *scanline = (QRgb *) *scanlines;
880 878
881 if ( ctm [0] < 0 ) 879 if ( ctm [0] < 0 )
882 scanline += ( width - 1 ); 880 scanline += ( width - 1 );
883 881
884 for ( int x = 0; x < width; x++ ) { 882 for ( int x = 0; x < width; x++ ) {
885 imgStr-> getPixel ( pixBuf ); 883 imgStr-> getPixel ( pixBuf );
886 colorMap-> getRGB ( pixBuf, &rgb ); 884 colorMap-> getRGB ( pixBuf, &rgb );
887 885
888 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff ); 886 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
889 887
890 if ( maskColors ) { 888 if ( maskColors ) {
891 for ( int k = 0; k < nComps; ++k ) { 889 for ( int k = 0; k < nComps; ++k ) {
892 if (( pixBuf [k] < maskColors [2 * k] ) || ( pixBuf [k] > maskColors [2 * k] )) { 890 if (( pixBuf [k] < maskColors [2 * k] ) || ( pixBuf [k] > maskColors [2 * k] )) {
893 val |= 0xff000000; 891 val |= 0xff000000;
894 break; 892 break;
895 } 893 }
896 } 894 }
897 } 895 }
898 *scanline = val; 896 *scanline = val;
899 897
900 ctm [0] < 0 ? scanline-- : scanline++; 898 ctm [0] < 0 ? scanline-- : scanline++;
901 } 899 }
902 ctm [3] > 0 ? scanlines-- : scanlines++; 900 ctm [3] > 0 ? scanlines-- : scanlines++;
903 901
904 qApp-> processEvents ( ); 902 qApp-> processEvents ( );
905 } 903 }
906 904
907 905
908 #ifndef QT_NO_TRANSFORMATIONS 906 #ifndef QT_NO_TRANSFORMATIONS
909 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] ); 907 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] );
910 908
911 cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << endl 909 cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << endl
912 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << endl; 910 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << endl;
913 911
914 QWMatrix oldmat = m_painter-> worldMatrix ( ); 912 QWMatrix oldmat = m_painter-> worldMatrix ( );
915 m_painter-> setWorldMatrix ( mat, true ); 913 m_painter-> setWorldMatrix ( mat, true );
916 914
917#ifdef QWS 915#ifdef QWS
918 QPixmap pm; 916 QPixmap pm;
919 pm. convertFromImage ( img ); 917 pm. convertFromImage ( img );
920 m_painter-> drawPixmap ( 0, 0, pm ); 918 m_painter-> drawPixmap ( 0, 0, pm );
921 #else 919 #else
922 m_painter-> drawImage ( QPoint ( 0, 0 ), img ); 920 m_painter-> drawImage ( QPoint ( 0, 0 ), img );
923#endif 921#endif
924 922
925 m_painter-> setWorldMatrix ( oldmat ); 923 m_painter-> setWorldMatrix ( oldmat );
926 924
927#else // QT_NO_TRANSFORMATIONS 925#else // QT_NO_TRANSFORMATIONS
928 926
929 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { 927 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) {
930 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); 928 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ));
931 } 929 }
932 else { 930 else {
933 int x = lrint ( ctm [4] ); 931 int x = lrint ( ctm [4] );
934 int y = lrint ( ctm [5] ); 932 int y = lrint ( ctm [5] );
935 933
936 int w = lrint ( ctm [0] ); 934 int w = lrint ( ctm [0] );
937 int h = lrint ( ctm [3] ); 935 int h = lrint ( ctm [3] );
938 936
939 if ( w < 0 ) { 937 if ( w < 0 ) {
940 x += w; 938 x += w;
941 w = -w; 939 w = -w;
942 } 940 }
943 if ( h < 0 ) { 941 if ( h < 0 ) {
944 y += h; 942 y += h;
945 h = -h; 943 h = -h;
946 } 944 }
947 945
948 QPDFDBG( printf ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h )); 946 QPDFDBG( printf ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h ));
949 947
950 img = img. smoothScale ( w, h ); 948 img = img. smoothScale ( w, h );
951 qApp-> processEvents ( ); 949 qApp-> processEvents ( );
952 m_painter-> drawImage ( x, y, img ); 950 m_painter-> drawImage ( x, y, img );
953 } 951 }
954 952
955#endif 953#endif
956 954
957 955
958 delete imgStr; 956 delete imgStr;
959 qApp-> processEvents ( ); 957 qApp-> processEvents ( );
960} 958}
961 959
962 960
963 961
964bool QOutputDev::findText ( const QString &str, QRect &r, bool top, bool bottom ) 962bool QOutputDev::findText ( const QString &str, QRect &r, bool top, bool bottom )
965{ 963{
966 int l, t, w, h; 964 int l, t, w, h;
967 r. rect ( &l, &t, &w, &h ); 965 r. rect ( &l, &t, &w, &h );
968 966
969 bool res = findText ( str, l, t, w, h, top, bottom ); 967 bool res = findText ( str, l, t, w, h, top, bottom );
970 968
971 r. setRect ( l, t, w, h ); 969 r. setRect ( l, t, w, h );
972 return res; 970 return res;
973} 971}
974 972
975bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h, bool top, bool bottom ) 973bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h, bool top, bool bottom )
976{ 974{
977 bool found = false; 975 bool found = false;
978 uint len = str. length ( ); 976 uint len = str. length ( );
979 Unicode *s = new Unicode [len]; 977 Unicode *s = new Unicode [len];
980 978
981 for ( uint i = 0; i < len; i++ ) 979 for ( uint i = 0; i < len; i++ )
982 s [i] = str [i]. unicode ( ); 980 s [i] = str [i]. unicode ( );
983 981
984 fp_t x1 = (fp_t) l; 982 fp_t x1 = (fp_t) l;
985 fp_t y1 = (fp_t) t; 983 fp_t y1 = (fp_t) t;
986 fp_t x2 = (fp_t) l + w - 1; 984 fp_t x2 = (fp_t) l + w - 1;
987 fp_t y2 = (fp_t) t + h - 1; 985 fp_t y2 = (fp_t) t + h - 1;
988 986
989 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) { 987 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) {
990 l = lrint ( x1 ); 988 l = lrint ( x1 );
991 t = lrint ( y1 ); 989 t = lrint ( y1 );
992 w = lrint ( x2 ) - l + 1; 990 w = lrint ( x2 ) - l + 1;
993 h = lrint ( y2 ) - t + 1; 991 h = lrint ( y2 ) - t + 1;
994 found = true; 992 found = true;
995 } 993 }
996 delete [] s; 994 delete [] s;
997 995
998 return found; 996 return found;
999} 997}
1000 998
1001GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax ) 999GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax )
1002{ 1000{
1003 bool found = false; 1001 bool found = false;
1004 fp_t xMin1 = (double) *xMin; 1002 fp_t xMin1 = (double) *xMin;
1005 fp_t yMin1 = (double) *yMin; 1003 fp_t yMin1 = (double) *yMin;
1006 fp_t xMax1 = (double) *xMax; 1004 fp_t xMax1 = (double) *xMax;
1007 fp_t yMax1 = (double) *yMax; 1005 fp_t yMax1 = (double) *yMax;
1008 1006
1009 if ( m_text-> findText ( s, len, top, bottom, &xMin1, &yMin1, &xMax1, &yMax1 )) { 1007 if ( m_text-> findText ( s, len, top, bottom, &xMin1, &yMin1, &xMax1, &yMax1 )) {
1010 *xMin = lrint ( xMin1 ); 1008 *xMin = lrint ( xMin1 );
1011 *xMax = lrint ( xMax1 ); 1009 *xMax = lrint ( xMax1 );
1012 *yMin = lrint ( yMin1 ); 1010 *yMin = lrint ( yMin1 );
1013 *yMax = lrint ( yMax1 ); 1011 *yMax = lrint ( yMax1 );
1014 found = true; 1012 found = true;
1015 } 1013 }
1016 return found; 1014 return found;
1017} 1015}
1018 1016
1019QString QOutputDev::getText ( int l, int t, int w, int h ) 1017QString QOutputDev::getText ( int l, int t, int w, int h )
1020{ 1018{
1021 GString *gstr = m_text-> getText ( l, t, l + w - 1, t + h - 1 ); 1019 GString *gstr = m_text-> getText ( l, t, l + w - 1, t + h - 1 );
1022 QString str = gstr-> getCString ( ); 1020 QString str = gstr-> getCString ( );
1023 delete gstr; 1021 delete gstr;
1024 return str; 1022 return str;
1025} 1023}
1026 1024
1027QString QOutputDev::getText ( const QRect &r ) 1025QString QOutputDev::getText ( const QRect &r )
1028{ 1026{
1029 return getText ( r. left ( ), r. top ( ), r. width ( ), r. height ( )); 1027 return getText ( r. left ( ), r. top ( ), r. width ( ), r. height ( ));
1030} 1028}
1031 1029
1032 1030
1033 1031
1034void QOutputDev::drawContents ( QPainter *p, int clipx, int clipy, int clipw, int cliph ) 1032void QOutputDev::drawContents ( QPainter *p, int clipx, int clipy, int clipw, int cliph )
1035{ 1033{
1036 if ( m_pixmap ) 1034 if ( m_pixmap )
1037 p-> drawPixmap ( clipx, clipy, *m_pixmap, clipx, clipy, clipw, cliph ); 1035 p-> drawPixmap ( clipx, clipy, *m_pixmap, clipx, clipy, clipw, cliph );
1038 else 1036 else
1039 p-> fillRect ( clipx, clipy, clipw, cliph, white ); 1037 p-> fillRect ( clipx, clipy, clipw, cliph, white );
1040} 1038}