summaryrefslogtreecommitdiff
path: root/noncore/unsupported/qpdf
authorkergoth <kergoth>2003-08-09 16:24:58 (UTC)
committer kergoth <kergoth>2003-08-09 16:24:58 (UTC)
commite16d333ec2e8509fc665921ca106c25325bae9e0 (patch) (unidiff)
tree9e9068190a15bc9b2a52ab33b40881128f732c0e /noncore/unsupported/qpdf
parent1c58d1407f9584fedcdae390a04e2b37e5853361 (diff)
downloadopie-e16d333ec2e8509fc665921ca106c25325bae9e0.zip
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.gz
opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.bz2
Merge from BRANCH_1_0
Diffstat (limited to 'noncore/unsupported/qpdf') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/qpdf/QOutputDev.cpp367
-rw-r--r--noncore/unsupported/qpdf/opie-qpdf.control2
-rw-r--r--noncore/unsupported/qpdf/qpdf.cpp2
3 files changed, 192 insertions, 179 deletions
diff --git a/noncore/unsupported/qpdf/QOutputDev.cpp b/noncore/unsupported/qpdf/QOutputDev.cpp
index 52237f5..022d938 100644
--- a/noncore/unsupported/qpdf/QOutputDev.cpp
+++ b/noncore/unsupported/qpdf/QOutputDev.cpp
@@ -86,7 +86,7 @@ static QOutFontSubst qStdFonts [] = {
86 86
87 { "Symbol", 0, false, false, QFont::AnyStyle }, 87 { "Symbol", 0, false, false, QFont::AnyStyle },
88 { "Zapf-Dingbats", 0, false, false, QFont::AnyStyle }, 88 { "Zapf-Dingbats", 0, false, false, QFont::AnyStyle },
89 89
90 { 0, 0, false, false, QFont::AnyStyle } 90 { 0, 0, false, false, QFont::AnyStyle }
91}; 91};
92 92
@@ -96,15 +96,15 @@ static QOutFontSubst qStdFonts [] = {
96 96
97 97
98 98
99QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp_t m22 ) 99QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp_t m22 )
100{ 100{
101 static QDict<QOutFontSubst> stdfonts; 101 static QDict<QOutFontSubst> stdfonts;
102 102
103 // build dict for std. fonts on first invocation 103 // build dict for std. fonts on first invocation
104 if ( stdfonts. isEmpty ( )) { 104 if ( stdfonts. isEmpty ( )) {
105 for ( QOutFontSubst *ptr = qStdFonts; ptr-> m_name; ptr++ ) { 105 for ( QOutFontSubst *ptr = qStdFonts; ptr-> m_name; ptr++ ) {
106 stdfonts. insert ( QString ( ptr-> m_name ), ptr ); 106 stdfonts. insert ( QString ( ptr-> m_name ), ptr );
107 } 107 }
108 } 108 }
109 109
110 // compute size and normalized transform matrix 110 // compute size and normalized transform matrix
@@ -119,8 +119,8 @@ QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp
119 gfxFont-> isSerif ( ), 119 gfxFont-> isSerif ( ),
120 gfxFont-> isSymbolic ( ), 120 gfxFont-> isSymbolic ( ),
121 gfxFont-> isCIDFont ( ), 121 gfxFont-> isCIDFont ( ),
122 ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName ( ) : "<n/a>" ), 122 ( gfxFont-> getEmbeddedFontName ( ) ? gfxFont-> getEmbeddedFontName()-> getCString ( ) : "<n/a>" ),
123 (double) m11, (double) m12, (double) m21, (double) m22 )); 123 (double) m11, (double) m12, (double) m21, (double) m22 ) );
124 124
125 125
126 QString fname (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ); 126 QString fname (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" );
@@ -130,32 +130,32 @@ QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp
130 130
131 // fast lookup for std. fonts 131 // fast lookup for std. fonts
132 QOutFontSubst *subst = stdfonts [fname]; 132 QOutFontSubst *subst = stdfonts [fname];
133 133
134 if ( subst ) { 134 if ( subst ) {
135 if ( subst-> m_sname ) 135 if ( subst-> m_sname )
136 f. setFamily ( subst-> m_sname ); 136 f. setFamily ( subst-> m_sname );
137 f. setStyleHint ( subst-> m_hint, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality )); 137 f. setStyleHint ( subst-> m_hint, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality ));
138 f. setBold ( subst-> m_bold ); 138 f. setBold ( subst-> m_bold );
139 f. setItalic ( subst-> m_italic ); 139 f. setItalic ( subst-> m_italic );
140 } 140 }
141 else { 141 else {
142 QFont::StyleHint sty; 142 QFont::StyleHint sty;
143 143
144 if ( gfxFont-> isSerif ( )) 144 if ( gfxFont-> isSerif ( ))
145 sty = QFont::Serif; 145 sty = QFont::Serif;
146 else if ( gfxFont-> isFixedWidth ( )) 146 else if ( gfxFont-> isFixedWidth ( ))
147 sty = QFont::TypeWriter; 147 sty = QFont::TypeWriter;
148 else 148 else
149 sty = QFont::Helvetica; 149 sty = QFont::Helvetica;
150 150
151 f. setStyleHint ( sty, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality )); 151 f. setStyleHint ( sty, (QFont::StyleStrategy) ( QFont::PreferOutline | QFont::PreferQuality ));
152 f. setBold ( gfxFont-> isBold ( ) > 0 ); 152 f. setBold ( gfxFont-> isBold ( ) > 0 );
153 f. setItalic ( gfxFont-> isItalic ( ) > 0 ); 153 f. setItalic ( gfxFont-> isItalic ( ) > 0 );
154 f. setFixedPitch ( gfxFont-> isFixedWidth ( ) > 0 ); 154 f. setFixedPitch ( gfxFont-> isFixedWidth ( ) > 0 );
155 155
156 // common specifiers in font names 156 // common specifiers in font names
157 if ( fname. contains ( "Oblique" ) || fname. contains ( "Italic" )) 157 if ( fname. contains ( "Oblique" ) || fname. contains ( "Italic" ))
158 f. setItalic ( true ); 158 f. setItalic ( true );
159 if ( fname. contains ( "Bold" )) 159 if ( fname. contains ( "Bold" ))
160 f. setWeight ( QFont::Bold ); 160 f. setWeight ( QFont::Bold );
161 if ( fname. contains ( "Demi" )) 161 if ( fname. contains ( "Demi" ))
@@ -164,11 +164,11 @@ QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp
164 f. setWeight ( QFont::Light ); 164 f. setWeight ( QFont::Light );
165 if ( fname. contains ( "Black" )) 165 if ( fname. contains ( "Black" ))
166 f. setWeight ( QFont::Black ); 166 f. setWeight ( QFont::Black );
167 } 167 }
168 // Treat x-sheared fonts as italic 168 // Treat x-sheared fonts as italic
169 if (( m12 > -0.1 ) && ( m12 < 0.1 ) && ((( m21 > -5.0 ) && ( m21 < -0.1 )) || (( m21 > 0.1 ) && ( m21 < 5.0 )))) { 169 if (( m12 > -0.1 ) && ( m12 < 0.1 ) && ((( m21 > -5.0 ) && ( m21 < -0.1 )) || (( m21 > 0.1 ) && ( m21 < 5.0 )))) {
170 f. setItalic ( true ); 170 f. setItalic ( true );
171 } 171 }
172 return f; 172 return f;
173} 173}
174 174
@@ -182,12 +182,12 @@ QOutputDev::QOutputDev ( QWidget *parent, const char *name, int flags ) : QScrol
182{ 182{
183 m_pixmap = 0; 183 m_pixmap = 0;
184 m_painter = 0; 184 m_painter = 0;
185 185
186 // create text object 186 // create text object
187 m_text = new TextPage ( gFalse ); 187 m_text = new TextPage ( gFalse );
188} 188}
189 189
190QOutputDev::~QOutputDev ( ) 190QOutputDev::~QOutputDev ( )
191{ 191{
192 delete m_painter; 192 delete m_painter;
193 delete m_pixmap; 193 delete m_pixmap;
@@ -195,46 +195,53 @@ QOutputDev::~QOutputDev ( )
195} 195}
196 196
197 197
198void QOutputDev::startPage ( int /*pageNum*/, GfxState *state ) 198void QOutputDev::startPage ( int /*pageNum*/, GfxState *state )
199{ 199{
200 delete m_pixmap; 200 delete m_pixmap;
201 delete m_painter; 201 delete m_painter;
202 202
203 m_pixmap = new QPixmap ( lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( ))); 203 m_pixmap = new QPixmap ( lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( )));
204 m_painter = new QPainter ( m_pixmap ); 204 m_painter = new QPainter ( m_pixmap );
205 205
206 QPDFDBG( printf ( "NEW PIXMAP (%ld x %ld)\n", lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( )))); 206 QPDFDBG( printf ( "NEW PIXMAP (%ld x %ld)\n", lrint ( state-> getPageWidth ( )), lrint ( state-> getPageHeight ( ))));
207 207
208 resizeContents ( m_pixmap-> width ( ), m_pixmap-> height ( )); 208 resizeContents ( m_pixmap-> width ( ), m_pixmap-> height ( ));
209 setContentsPos ( 0, 0 ); 209 setContentsPos ( 0, 0 );
210 210
211 m_pixmap-> fill ( white ); // clear window 211 m_pixmap-> fill ( white ); // clear window
212 m_text-> clear ( ); // cleat text object 212 m_text-> clear ( ); // cleat text object
213 viewport ( )-> repaint ( ); 213 viewport ( )-> repaint ( );
214} 214}
215 215
216void QOutputDev::endPage ( ) 216void QOutputDev::endPage ( )
217{ 217{
218 QPDFDBG( printf("End page\n") );
218 m_text-> coalesce ( ); 219 m_text-> coalesce ( );
219 220
221 /*
222 * I get stupid crashes after endPage is called and then we do clipping
223 * and other stuff.....
224 */
225#if 0
220 delete m_painter; 226 delete m_painter;
221 m_painter = 0; 227 m_painter = 0;
222 228#endif
229
223 updateContents ( 0, 0, contentsWidth ( ), contentsHeight ( )); 230 updateContents ( 0, 0, contentsWidth ( ), contentsHeight ( ));
224} 231}
225 232
226void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ ) 233void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ )
227{ 234{
228 fp_t x1, y1, x2, y2, w; 235 fp_t x1, y1, x2, y2, w;
229 236
230 link-> getBorder ( &x1, &y1, &x2, &y2, &w ); 237 link-> getBorder ( &x1, &y1, &x2, &y2, &w );
231 238
232 if ( w > 0 ) { 239 if ( w > 0 ) {
233 int x, y, dx, dy; 240 int x, y, dx, dy;
234 241
235 cvtUserToDev ( x1, y1, &x, &y ); 242 cvtUserToDev ( x1, y1, &x, &y );
236 cvtUserToDev ( x2, y2, &dx, &dy ); 243 cvtUserToDev ( x2, y2, &dx, &dy );
237 244
238 QPen oldpen = m_painter-> pen ( ); 245 QPen oldpen = m_painter-> pen ( );
239 m_painter-> setPen ( blue ); 246 m_painter-> setPen ( blue );
240 m_painter-> drawRect ( x, y, dx, dy ); 247 m_painter-> drawRect ( x, y, dx, dy );
@@ -242,23 +249,29 @@ void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ )
242 } 249 }
243} 250}
244 251
245void QOutputDev::saveState ( GfxState */*state*/ ) 252void QOutputDev::saveState ( GfxState */*state*/ )
246{ 253{
254 if ( ! m_painter )
255 return;
256
247 QPDFDBG( printf ( "SAVE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( ))); 257 QPDFDBG( printf ( "SAVE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
248 258
249 m_painter-> save ( ); 259 m_painter-> save ( );
250} 260}
251 261
252void QOutputDev::restoreState ( GfxState */*state*/ ) 262void QOutputDev::restoreState ( GfxState */*state*/ )
253{ 263{
264 if( ! m_painter )
265 return;
266
254 m_painter-> restore ( ); 267 m_painter-> restore ( );
255 268
256 //m_painter-> setClipRegion ( QRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ))); 269 //m_painter-> setClipRegion ( QRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( )));
257 //m_painter-> setClipping ( false ); 270 //m_painter-> setClipping ( false );
258 QPDFDBG ( printf ( "RESTORE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( ))); 271 QPDFDBG ( printf ( "RESTORE (CLIP=%d/%d)\n", m_painter-> hasClipping ( ), !m_painter-> clipRegion ( ). isEmpty ( )));
259} 272}
260 273
261void QOutputDev::updateAll ( GfxState *state ) 274void QOutputDev::updateAll ( GfxState *state )
262{ 275{
263 updateLineAttrs ( state, gTrue ); 276 updateLineAttrs ( state, gTrue );
264 //updateFlatness ( state ); 277 //updateFlatness ( state );
@@ -268,44 +281,44 @@ void QOutputDev::updateAll ( GfxState *state )
268 updateFont ( state ); 281 updateFont ( state );
269} 282}
270 283
271void QOutputDev::updateCTM ( GfxState *state, fp_t /*m11*/, fp_t /*m12*/, fp_t /*m21*/, fp_t /*m22*/, fp_t /*m31*/, fp_t /*m32*/ ) 284void QOutputDev::updateCTM ( GfxState *state, fp_t /*m11*/, fp_t /*m12*/, fp_t /*m21*/, fp_t /*m22*/, fp_t /*m31*/, fp_t /*m32*/ )
272{ 285{
273 updateLineAttrs ( state, gTrue ); 286 updateLineAttrs ( state, gTrue );
274} 287}
275 288
276void QOutputDev::updateLineDash ( GfxState *state ) 289void QOutputDev::updateLineDash ( GfxState *state )
277{ 290{
278 updateLineAttrs ( state, gTrue ); 291 updateLineAttrs ( state, gTrue );
279} 292}
280 293
281void QOutputDev::updateFlatness ( GfxState */*state*/ ) 294void QOutputDev::updateFlatness ( GfxState */*state*/ )
282{ 295{
283 // not supported 296 // not supported
284 QPDFDBG( printf ( "updateFlatness not supported !\n" )); 297 QPDFDBG( printf ( "updateFlatness not supported !\n" ));
285} 298}
286 299
287void QOutputDev::updateLineJoin ( GfxState *state ) 300void QOutputDev::updateLineJoin ( GfxState *state )
288{ 301{
289 updateLineAttrs ( state, gFalse ); 302 updateLineAttrs ( state, gFalse );
290} 303}
291 304
292void QOutputDev::updateLineCap ( GfxState *state ) 305void QOutputDev::updateLineCap ( GfxState *state )
293{ 306{
294 updateLineAttrs ( state, gFalse ); 307 updateLineAttrs ( state, gFalse );
295} 308}
296 309
297// unimplemented 310// unimplemented
298void QOutputDev::updateMiterLimit ( GfxState */*state*/ ) 311void QOutputDev::updateMiterLimit ( GfxState */*state*/ )
299{ 312{
300 QPDFDBG( printf ( "updateMiterLimit not supported !\n" )); 313 QPDFDBG( printf ( "updateMiterLimit not supported !\n" ));
301} 314}
302 315
303void QOutputDev::updateLineWidth ( GfxState *state ) 316void QOutputDev::updateLineWidth ( GfxState *state )
304{ 317{
305 updateLineAttrs ( state, gFalse ); 318 updateLineAttrs ( state, gFalse );
306} 319}
307 320
308void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash ) 321void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash )
309{ 322{
310 fp_t *dashPattern; 323 fp_t *dashPattern;
311 int dashLength; 324 int dashLength;
@@ -316,7 +329,7 @@ void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash )
316 int width; 329 int width;
317 330
318 width = lrint ( state-> getTransformedLineWidth ( )); 331 width = lrint ( state-> getTransformedLineWidth ( ));
319 332
320 switch ( state-> getLineCap ( )) { 333 switch ( state-> getLineCap ( )) {
321 case 0: cap = FlatCap; break; 334 case 0: cap = FlatCap; break;
322 case 1: cap = RoundCap; break; 335 case 1: cap = RoundCap; break;
@@ -326,7 +339,7 @@ void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash )
326 cap = FlatCap; 339 cap = FlatCap;
327 break; 340 break;
328 } 341 }
329 342
330 switch (state->getLineJoin()) { 343 switch (state->getLineJoin()) {
331 case 0: join = MiterJoin; break; 344 case 0: join = MiterJoin; break;
332 case 1: join = RoundJoin; break; 345 case 1: join = RoundJoin; break;
@@ -336,7 +349,7 @@ void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash )
336 join = MiterJoin; 349 join = MiterJoin;
337 break; 350 break;
338 } 351 }
339 352
340 state-> getLineDash ( &dashPattern, &dashLength, &dashStart ); 353 state-> getLineDash ( &dashPattern, &dashLength, &dashStart );
341 354
342 QColor oldcol = m_painter-> pen ( ). color ( ); 355 QColor oldcol = m_painter-> pen ( ). color ( );
@@ -349,7 +362,7 @@ void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash )
349 362
350 if ( updateDash && ( dashLength > 0 )) { 363 if ( updateDash && ( dashLength > 0 )) {
351 // Not supported by QT 364 // Not supported by QT
352 /* 365/*
353 char dashList[20]; 366 char dashList[20];
354 if (dashLength > 20) 367 if (dashLength > 20)
355 dashLength = 20; 368 dashLength = 20;
@@ -363,7 +376,7 @@ void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash )
363 } 376 }
364} 377}
365 378
366void QOutputDev::updateFillColor ( GfxState *state ) 379void QOutputDev::updateFillColor ( GfxState *state )
367{ 380{
368 GfxRGB rgb; 381 GfxRGB rgb;
369 state-> getFillRGB ( &rgb ); 382 state-> getFillRGB ( &rgb );
@@ -371,35 +384,35 @@ void QOutputDev::updateFillColor ( GfxState *state )
371 m_painter-> setBrush ( q_col ( rgb )); 384 m_painter-> setBrush ( q_col ( rgb ));
372} 385}
373 386
374void QOutputDev::updateStrokeColor ( GfxState *state ) 387void QOutputDev::updateStrokeColor ( GfxState *state )
375{ 388{
376 GfxRGB rgb; 389 GfxRGB rgb;
377 state-> getStrokeRGB ( &rgb ); 390 state-> getStrokeRGB ( &rgb );
378 391
379 QPen pen = m_painter-> pen ( ); 392 QPen pen = m_painter-> pen ( );
380 pen. setColor ( q_col ( rgb )); 393 pen. setColor ( q_col ( rgb ));
381 m_painter-> setPen ( pen ); 394 m_painter-> setPen ( pen );
382} 395}
383 396
384void QOutputDev::updateFont ( GfxState *state ) 397void QOutputDev::updateFont ( GfxState *state )
385{ 398{
386 fp_t m11, m12, m21, m22; 399 fp_t m11, m12, m21, m22;
387 GfxFont *gfxFont = state-> getFont ( ); 400 GfxFont *gfxFont = state-> getFont ( );
388 401
389 if ( !gfxFont ) 402 if ( !gfxFont )
390 return; 403 return;
391 404
392 state-> getFontTransMat ( &m11, &m12, &m21, &m22 ); 405 state-> getFontTransMat ( &m11, &m12, &m21, &m22 );
393 m11 *= state-> getHorizScaling ( ); 406 m11 *= state-> getHorizScaling ( );
394 m12 *= state-> getHorizScaling ( ); 407 m12 *= state-> getHorizScaling ( );
395 408
396 QFont font = matchFont ( gfxFont, m11, m12, m21, m22 ); 409 QFont font = matchFont ( gfxFont, m11, m12, m21, m22 );
397 410
398 m_painter-> setFont ( font ); 411 m_painter-> setFont ( font );
399 m_text-> updateFont ( state ); 412 m_text-> updateFont ( state );
400} 413}
401 414
402void QOutputDev::stroke ( GfxState *state ) 415void QOutputDev::stroke ( GfxState *state )
403{ 416{
404 QPointArray points; 417 QPointArray points;
405 QArray<int> lengths; 418 QArray<int> lengths;
@@ -408,31 +421,31 @@ void QOutputDev::stroke ( GfxState *state )
408 int n = convertPath ( state, points, lengths ); 421 int n = convertPath ( state, points, lengths );
409 422
410 QPDFDBG( printf ( "DRAWING: %d POLYS\n", n )); 423 QPDFDBG( printf ( "DRAWING: %d POLYS\n", n ));
411 424
412 // draw each subpath 425 // draw each subpath
413 int j = 0; 426 int j = 0;
414 for ( int i = 0; i < n; i++ ) { 427 for ( int i = 0; i < n; i++ ) {
415 int len = lengths [i]; 428 int len = lengths [i];
416 429
417 if ( len >= 2 ) { 430 if ( len >= 2 ) {
418 QPDFDBG( printf ( " - POLY %d: ", i )); 431 QPDFDBG( printf ( " - POLY %d: ", i ));
419 QPDFDBG( for ( int ii = 0; ii < len; ii++ )) 432 QPDFDBG( for ( int ii = 0; ii < len; ii++ ))
420 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); 433 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
421 QPDFDBG( printf ( "\n" )); 434 QPDFDBG( printf ( "\n" ));
422 435
423 m_painter-> drawPolyline ( points, j, len ); 436 m_painter-> drawPolyline ( points, j, len );
424 } 437 }
425 j += len; 438 j += len;
426 } 439 }
427 qApp-> processEvents ( ); 440 qApp-> processEvents ( );
428} 441}
429 442
430void QOutputDev::fill ( GfxState *state ) 443void QOutputDev::fill ( GfxState *state )
431{ 444{
432 doFill ( state, true ); 445 doFill ( state, true );
433} 446}
434 447
435void QOutputDev::eoFill ( GfxState *state ) 448void QOutputDev::eoFill ( GfxState *state )
436{ 449{
437 doFill ( state, false ); 450 doFill ( state, false );
438} 451}
@@ -446,7 +459,7 @@ void QOutputDev::eoFill ( GfxState *state )
446// only for single-component polygons, since it's not very 459// only for single-component polygons, since it's not very
447// compatible with the compound polygon kludge (see convertPath()). 460// compatible with the compound polygon kludge (see convertPath()).
448// 461//
449void QOutputDev::doFill ( GfxState *state, bool winding ) 462void QOutputDev::doFill ( GfxState *state, bool winding )
450{ 463{
451 QPointArray points; 464 QPointArray points;
452 QArray<int> lengths; 465 QArray<int> lengths;
@@ -455,23 +468,23 @@ void QOutputDev::doFill ( GfxState *state, bool winding )
455 int n = convertPath ( state, points, lengths ); 468 int n = convertPath ( state, points, lengths );
456 469
457 QPDFDBG( printf ( "FILLING: %d POLYS\n", n )); 470 QPDFDBG( printf ( "FILLING: %d POLYS\n", n ));
458 471
459 QPen oldpen = m_painter-> pen ( ); 472 QPen oldpen = m_painter-> pen ( );
460 m_painter-> setPen ( QPen ( NoPen )); 473 m_painter-> setPen ( QPen ( NoPen ));
461 474
462 // draw each subpath 475 // draw each subpath
463 int j = 0; 476 int j = 0;
464 for ( int i = 0; i < n; i++ ) { 477 for ( int i = 0; i < n; i++ ) {
465 int len = lengths [i]; 478 int len = lengths [i];
466 479
467 if ( len >= 3 ) { 480 if ( len >= 3 ) {
468 QPDFDBG( printf ( " - POLY %d: ", i )); 481 QPDFDBG( printf ( " - POLY %d: ", i ));
469 QPDFDBG( for ( int ii = 0; ii < len; ii++ )) 482 QPDFDBG( for ( int ii = 0; ii < len; ii++ ))
470 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( ))); 483 QPDFDBG( printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
471 QPDFDBG( printf ( "\n" )); 484 QPDFDBG( printf ( "\n" ));
472 485
473 m_painter-> drawPolygon ( points, winding, j, len ); 486 m_painter-> drawPolygon ( points, winding, j, len );
474 } 487 }
475 j += len; 488 j += len;
476 } 489 }
477 m_painter-> setPen ( oldpen ); 490 m_painter-> setPen ( oldpen );
@@ -479,17 +492,17 @@ void QOutputDev::doFill ( GfxState *state, bool winding )
479 qApp-> processEvents ( ); 492 qApp-> processEvents ( );
480} 493}
481 494
482void QOutputDev::clip ( GfxState *state ) 495void QOutputDev::clip ( GfxState *state )
483{ 496{
484 doClip ( state, true ); 497 doClip ( state, true );
485} 498}
486 499
487void QOutputDev::eoClip ( GfxState *state ) 500void QOutputDev::eoClip ( GfxState *state )
488{ 501{
489 doClip ( state, false ); 502 doClip ( state, false );
490} 503}
491 504
492void QOutputDev::doClip ( GfxState *state, bool winding ) 505void QOutputDev::doClip ( GfxState *state, bool winding )
493{ 506{
494 QPointArray points; 507 QPointArray points;
495 QArray<int> lengths; 508 QArray<int> lengths;
@@ -498,35 +511,35 @@ void QOutputDev::doClip ( GfxState *state, bool winding )
498 int n = convertPath ( state, points, lengths ); 511 int n = convertPath ( state, points, lengths );
499 512
500 QRegion region; 513 QRegion region;
501 514
502 QPDFDBG( printf ( "CLIPPING: %d POLYS\n", n )); 515 QPDFDBG( printf ( "CLIPPING: %d POLYS\n", n ));
503 516
504 // draw each subpath 517 // draw each subpath
505 int j = 0; 518 int j = 0;
506 for ( int i = 0; i < n; i++ ) { 519 for ( int i = 0; i < n; i++ ) {
507 int len = lengths [i]; 520 int len = lengths [i];
508 521
509 if ( len >= 3 ) { 522 if ( len >= 3 ) {
510 QPointArray dummy; 523 QPointArray dummy;
511 dummy. setRawData ( points. data ( ) + j, len ); 524 dummy. setRawData ( points. data ( ) + j, len );
512 525
513 QPDFDBG( printf ( " - POLY %d: ", i )); 526 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 ( ))); 527 QPDFDBG( for ( int ii = 0; ii < len; ii++ ) printf ( "(%d/%d) ", points [j+ii]. x ( ), points [j+ii]. y ( )));
515 QPDFDBG( printf ( "\n" )); 528 QPDFDBG( printf ( "\n" ));
516 529
517 region |= QRegion ( dummy, winding ); 530 region |= QRegion ( dummy, winding );
518 531
519 dummy. resetRawData ( points. data ( ) + j, len ); 532 dummy. resetRawData ( points. data ( ) + j, len );
520 } 533 }
521 j += len; 534 j += len;
522 } 535 }
523 536
524 if ( m_painter-> hasClipping ( )) 537 if ( m_painter && m_painter-> hasClipping ( ))
525 region &= m_painter-> clipRegion ( ); 538 region &= m_painter-> clipRegion ( );
526 539
527 //m_painter-> setClipRegion ( region ); 540 //m_painter-> setClipRegion ( region );
528 //m_painter-> setClipping ( true ); 541 //m_painter-> setClipping ( true );
529 542
530 //m_painter-> fillRect ( 0, 0, m_pixmap-> width ( ), m_pixmap-> height ( ), red ); 543 //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" ); 544 //m_painter-> drawText ( points [0]. x ( ) + 10, points [0]. y ( ) + 10, "Bla bla" );
532 qApp-> processEvents ( ); 545 qApp-> processEvents ( );
@@ -541,7 +554,7 @@ void QOutputDev::doClip ( GfxState *state, bool winding )
541// Then it connects subaths within a single compound polygon to a single 554// Then it connects subaths within a single compound polygon to a single
542// point so that X can fill the polygon (sort of). 555// point so that X can fill the polygon (sort of).
543// 556//
544int QOutputDev::convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths ) 557int QOutputDev::convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths )
545{ 558{
546 GfxPath *path = state-> getPath ( ); 559 GfxPath *path = state-> getPath ( );
547 int n = path-> getNumSubpaths ( ); 560 int n = path-> getNumSubpaths ( );
@@ -569,36 +582,36 @@ int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArr
569 582
570 int m = subpath-> getNumPoints ( ); 583 int m = subpath-> getNumPoints ( );
571 int i = 0; 584 int i = 0;
572 585
573 while ( i < m ) { 586 while ( i < m ) {
574 if ( i >= 1 && subpath-> getCurve ( i )) { 587 if ( i >= 1 && subpath-> getCurve ( i )) {
575 state-> transform ( subpath-> getX ( i - 1 ), subpath-> getY ( i - 1 ), &x0, &y0 ); 588 state-> transform ( subpath-> getX ( i - 1 ), subpath-> getY ( i - 1 ), &x0, &y0 );
576 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); 589 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 );
577 state-> transform ( subpath-> getX ( i + 1 ), subpath-> getY ( i + 1 ), &x2, &y2 ); 590 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 ); 591 state-> transform ( subpath-> getX ( i + 2 ), subpath-> getY ( i + 2 ), &x3, &y3 );
579 592
580 QPointArray tmp; 593 QPointArray tmp;
581 tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ), 594 tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ),
582 lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 )); 595 lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 ));
583 596
584#if QT_VERSION < 300 597#if QT_VERSION < 300
585 tmp = tmp. quadBezier ( ); 598 tmp = tmp. quadBezier ( );
586 599
587 for ( uint loop = 0; loop < tmp. count ( ); loop++ ) { 600 for ( uint loop = 0; loop < tmp. count ( ); loop++ ) {
588 QPoint p = tmp. point ( loop ); 601 QPoint p = tmp. point ( loop );
589 points. putPoints ( points. count ( ), 1, p. x ( ), p. y ( )); 602 points. putPoints ( points. count ( ), 1, p. x ( ), p. y ( ));
590 } 603 }
591#else 604#else
592 tmp = tmp. cubicBezier ( ); 605 tmp = tmp. cubicBezier ( );
593 points. putPoints ( points. count ( ), tmp. count ( ), tmp ); 606 points. putPoints ( points. count ( ), tmp. count ( ), tmp );
594#endif 607#endif
595 608
596 i += 3; 609 i += 3;
597 } 610 }
598 else { 611 else {
599 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); 612 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 );
600 613
601 points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 )); 614 points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 ));
602 ++i; 615 ++i;
603 } 616 }
604 } 617 }
@@ -606,22 +619,22 @@ int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArr
606} 619}
607 620
608 621
609void QOutputDev::beginString ( GfxState *state, GString */*s*/ ) 622void QOutputDev::beginString ( GfxState *state, GString */*s*/ )
610{ 623{
611 m_text-> beginString ( state ); 624 m_text-> beginString ( state );
612} 625}
613 626
614void QOutputDev::endString ( GfxState */*state*/ ) 627void QOutputDev::endString ( GfxState */*state*/ )
615{ 628{
616 m_text-> endString ( ); 629 m_text-> endString ( );
617} 630}
618 631
619void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y, 632void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
620 fp_t dx, fp_t dy, fp_t originX, fp_t originY, 633 fp_t dx, fp_t dy, fp_t originX, fp_t originY,
621 CharCode code, Unicode *u, int uLen ) 634 CharCode code, Unicode *u, int uLen )
622{ 635{
623 fp_t x1, y1, dx1, dy1; 636 fp_t x1, y1, dx1, dy1;
624 637
625 if ( uLen > 0 ) 638 if ( uLen > 0 )
626 m_text-> addChar ( state, x, y, dx, dy, u, uLen ); 639 m_text-> addChar ( state, x, y, dx, dy, u, uLen );
627 640
@@ -639,10 +652,10 @@ void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
639 if ( uLen > 0 ) { 652 if ( uLen > 0 ) {
640 QString str; 653 QString str;
641 QFontMetrics fm = m_painter-> fontMetrics ( ); 654 QFontMetrics fm = m_painter-> fontMetrics ( );
642 655
643 for ( int i = 0; i < uLen; i++ ) { 656 for ( int i = 0; i < uLen; i++ ) {
644 QChar c = QChar ( u [i] ); 657 QChar c = QChar ( u [i] );
645 658
646 if ( fm. inFont ( c )) { 659 if ( fm. inFont ( c )) {
647 str [i] = QChar ( u [i] ); 660 str [i] = QChar ( u [i] );
648 } 661 }
@@ -651,61 +664,61 @@ void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
651 QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( ))); 664 QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( )));
652 } 665 }
653 } 666 }
654 667
655 if (( uLen == 1 ) && ( str [0] == ' ' )) 668 if (( uLen == 1 ) && ( str [0] == ' ' ))
656 return; 669 return;
657 670
658 671
659 fp_t m11, m12, m21, m22; 672 fp_t m11, m12, m21, m22;
660 673
661 state-> getFontTransMat ( &m11, &m12, &m21, &m22 ); 674 state-> getFontTransMat ( &m11, &m12, &m21, &m22 );
662 m11 *= state-> getHorizScaling ( ); 675 m11 *= state-> getHorizScaling ( );
663 m12 *= state-> getHorizScaling ( ); 676 m12 *= state-> getHorizScaling ( );
664 677
665 fp_t fsize = m_painter-> font ( ). pixelSize ( ); 678 fp_t fsize = m_painter-> font ( ). pixelSize ( );
666 679
667#ifndef QT_NO_TRANSFORMATIONS 680#ifndef QT_NO_TRANSFORMATIONS
668 QWMatrix oldmat; 681 QWMatrix oldmat;
669
670 bool dorot = (( m12 < -0.1 ) || ( m12 > 0.1 )) && (( m21 < -0.1 ) || ( m21 > 0.1 ));
671 682
672 if ( dorot ) { 683 bool dorot = (( m12 < -0.1 ) || ( m12 > 0.1 )) && (( m21 < -0.1 ) || ( m21 > 0.1 ));
684
685 if ( dorot ) {
673 oldmat = m_painter-> worldMatrix ( ); 686 oldmat = m_painter-> worldMatrix ( );
674 687
675 std::cerr << std::endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl; 688 std::cerr << std::endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl;
676 689
677 QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 )); 690 QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 ));
678 691
679 m_painter-> setWorldMatrix ( mat ); 692 m_painter-> setWorldMatrix ( mat );
680 693
681 x1 = 0; 694 x1 = 0;
682 y1 = 0; 695 y1 = 0;
683 } 696 }
684#endif 697#endif
685 698
686 QPen oldpen = m_painter-> pen ( ); 699 QPen oldpen = m_painter-> pen ( );
687 700
688 if (!( state-> getRender ( ) & 1 )) { 701 if (!( state-> getRender ( ) & 1 )) {
689 QPen fillpen = oldpen; 702 QPen fillpen = oldpen;
690 703
691 fillpen. setColor ( m_painter-> brush ( ). color ( )); 704 fillpen. setColor ( m_painter-> brush ( ). color ( ));
692 m_painter-> setPen ( fillpen ); 705 m_painter-> setPen ( fillpen );
693 } 706 }
694 707
695 if ( fsize > 5 ) 708 if ( fsize > 5 )
696 m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str ); 709 m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str );
697 else 710 else
698 m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( )); 711 m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( ));
699 712
700 m_painter-> setPen ( oldpen ); 713 m_painter-> setPen ( oldpen );
701 714
702#ifndef QT_NO_TRANSFORMATIONS 715#ifndef QT_NO_TRANSFORMATIONS
703 if ( dorot ) 716 if ( dorot )
704 m_painter-> setWorldMatrix ( oldmat ); 717 m_painter-> setWorldMatrix ( oldmat );
705 #endif 718#endif
706 719
707 QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 ))); 720 QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 )));
708 } 721 }
709 else if ( code != 0 ) { 722 else if ( code != 0 ) {
710 // some PDF files use CID 0, which is .notdef, so just ignore it 723 // 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 )); 724 qWarning ( "Unknown character (CID=%d Unicode=%hx)\n", code, (unsigned short) ( uLen > 0 ? u [0] : (Unicode) 0 ));
@@ -715,14 +728,14 @@ void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
715 728
716 729
717 730
718void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg ) 731void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg )
719{ 732{
720 // get CTM, check for singular matrix 733 // get CTM, check for singular matrix
721 fp_t *ctm = state-> getCTM ( ); 734 fp_t *ctm = state-> getCTM ( );
722 735
723 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) { 736 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) {
724 qWarning ( "Singular CTM in drawImage\n" ); 737 qWarning ( "Singular CTM in drawImage\n" );
725 738
726 if ( inlineImg ) { 739 if ( inlineImg ) {
727 str-> reset ( ); 740 str-> reset ( );
728 int j = height * (( width + 7 ) / 8 ); 741 int j = height * (( width + 7 ) / 8 );
@@ -733,13 +746,13 @@ void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str,
733 } 746 }
734 return; 747 return;
735 } 748 }
736 749
737 GfxRGB rgb; 750 GfxRGB rgb;
738 state-> getFillRGB ( &rgb ); 751 state-> getFillRGB ( &rgb );
739 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff ); 752 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
740 753
741 754
742 QImage img ( width, height, 32 ); 755 QImage img ( width, height, 32 );
743 img. setAlphaBuffer ( true ); 756 img. setAlphaBuffer ( true );
744 757
745 QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height )); 758 QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height ));
@@ -749,39 +762,39 @@ void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str,
749 imgStr-> reset ( ); 762 imgStr-> reset ( );
750 763
751 uchar **scanlines = img. jumpTable ( ); 764 uchar **scanlines = img. jumpTable ( );
752 765
753 if ( ctm [3] > 0 ) 766 if ( ctm [3] > 0 )
754 scanlines += ( height - 1 ); 767 scanlines += ( height - 1 );
755 768
756 for ( int y = 0; y < height; y++ ) { 769 for ( int y = 0; y < height; y++ ) {
757 QRgb *scanline = (QRgb *) *scanlines; 770 QRgb *scanline = (QRgb *) *scanlines;
758 771
759 if ( ctm [0] < 0 ) 772 if ( ctm [0] < 0 )
760 scanline += ( width - 1 ); 773 scanline += ( width - 1 );
761 774
762 for ( int x = 0; x < width; x++ ) { 775 for ( int x = 0; x < width; x++ ) {
763 Guchar alpha; 776 Guchar alpha;
764 777
765 imgStr-> getPixel ( &alpha ); 778 imgStr-> getPixel ( &alpha );
766 779
767 if ( invert ) 780 if ( invert )
768 alpha ^= 1; 781 alpha ^= 1;
769 782
770 *scanline = ( alpha == 0 ) ? 0xff000000 | val : val; 783 *scanline = ( alpha == 0 ) ? 0xff000000 | val : val;
771 784
772 ctm [0] < 0 ? scanline-- : scanline++; 785 ctm [0] < 0 ? scanline-- : scanline++;
773 } 786 }
774 ctm [3] > 0 ? scanlines-- : scanlines++; 787 ctm [3] > 0 ? scanlines-- : scanlines++;
775 788
776 qApp-> processEvents ( ); 789 qApp-> processEvents ( );
777 } 790 }
778 791
779 #ifndef QT_NO_TRANSFORMATIONS 792#ifndef QT_NO_TRANSFORMATIONS
780 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] ); 793 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] );
781 794
782 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl 795 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl
783 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl; 796 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl;
784 797
785 QWMatrix oldmat = m_painter-> worldMatrix ( ); 798 QWMatrix oldmat = m_painter-> worldMatrix ( );
786 m_painter-> setWorldMatrix ( mat, true ); 799 m_painter-> setWorldMatrix ( mat, true );
787 800
@@ -802,10 +815,10 @@ void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str,
802 else { 815 else {
803 int x = lrint ( ctm [4] ); 816 int x = lrint ( ctm [4] );
804 int y = lrint ( ctm [5] ); 817 int y = lrint ( ctm [5] );
805 818
806 int w = lrint ( ctm [0] ); 819 int w = lrint ( ctm [0] );
807 int h = lrint ( ctm [3] ); 820 int h = lrint ( ctm [3] );
808 821
809 if ( w < 0 ) { 822 if ( w < 0 ) {
810 x += w; 823 x += w;
811 w = -w; 824 w = -w;
@@ -814,25 +827,25 @@ void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str,
814 y += h; 827 y += h;
815 h = -h; 828 h = -h;
816 } 829 }
817 830
818 QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h )); 831 QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h ));
819 832
820 img = img. smoothScale ( w, h ); 833 img = img. smoothScale ( w, h );
821 qApp-> processEvents ( ); 834 qApp-> processEvents ( );
822 m_painter-> drawImage ( x, y, img ); 835 m_painter-> drawImage ( x, y, img );
823 } 836 }
824 837
825#endif 838#endif
826 839
827 delete imgStr; 840 delete imgStr;
828 qApp-> processEvents ( ); 841 qApp-> processEvents ( );
829} 842}
830 843
831 844
832void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg ) 845void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg )
833{ 846{
834 int nComps, nVals, nBits; 847 int nComps, nVals, nBits;
835 848
836 // image parameters 849 // image parameters
837 nComps = colorMap->getNumPixelComps ( ); 850 nComps = colorMap->getNumPixelComps ( );
838 nVals = width * nComps; 851 nVals = width * nComps;
@@ -840,10 +853,10 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
840 853
841 // get CTM, check for singular matrix 854 // get CTM, check for singular matrix
842 fp_t *ctm = state-> getCTM ( ); 855 fp_t *ctm = state-> getCTM ( );
843 856
844 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) { 857 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) {
845 qWarning ( "Singular CTM in drawImage\n" ); 858 qWarning ( "Singular CTM in drawImage\n" );
846 859
847 if ( inlineImg ) { 860 if ( inlineImg ) {
848 str-> reset ( ); 861 str-> reset ( );
849 int j = height * (( nVals * nBits + 7 ) / 8 ); 862 int j = height * (( nVals * nBits + 7 ) / 8 );
@@ -856,7 +869,7 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
856 } 869 }
857 870
858 QImage img ( width, height, 32 ); 871 QImage img ( width, height, 32 );
859 872
860 if ( maskColors ) 873 if ( maskColors )
861 img. setAlphaBuffer ( true ); 874 img. setAlphaBuffer ( true );
862 875
@@ -868,47 +881,47 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
868 881
869 Guchar pixBuf [gfxColorMaxComps]; 882 Guchar pixBuf [gfxColorMaxComps];
870 GfxRGB rgb; 883 GfxRGB rgb;
871 884
872 885
873 uchar **scanlines = img. jumpTable ( ); 886 uchar **scanlines = img. jumpTable ( );
874 887
875 if ( ctm [3] > 0 ) 888 if ( ctm [3] > 0 )
876 scanlines += ( height - 1 ); 889 scanlines += ( height - 1 );
877 890
878 for ( int y = 0; y < height; y++ ) { 891 for ( int y = 0; y < height; y++ ) {
879 QRgb *scanline = (QRgb *) *scanlines; 892 QRgb *scanline = (QRgb *) *scanlines;
880 893
881 if ( ctm [0] < 0 ) 894 if ( ctm [0] < 0 )
882 scanline += ( width - 1 ); 895 scanline += ( width - 1 );
883 896
884 for ( int x = 0; x < width; x++ ) { 897 for ( int x = 0; x < width; x++ ) {
885 imgStr-> getPixel ( pixBuf ); 898 imgStr-> getPixel ( pixBuf );
886 colorMap-> getRGB ( pixBuf, &rgb ); 899 colorMap-> getRGB ( pixBuf, &rgb );
887 900
888 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff ); 901 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
889 902
890 if ( maskColors ) { 903 if ( maskColors ) {
891 for ( int k = 0; k < nComps; ++k ) { 904 for ( int k = 0; k < nComps; ++k ) {
892 if (( pixBuf [k] < maskColors [2 * k] ) || ( pixBuf [k] > maskColors [2 * k] )) { 905 if (( pixBuf [k] < maskColors [2 * k] ) || ( pixBuf [k] > maskColors [2 * k] )) {
893 val |= 0xff000000; 906 val |= 0xff000000;
894 break; 907 break;
895 } 908 }
896 } 909 }
897 } 910 }
898 *scanline = val; 911 *scanline = val;
899 912
900 ctm [0] < 0 ? scanline-- : scanline++; 913 ctm [0] < 0 ? scanline-- : scanline++;
901 } 914 }
902 ctm [3] > 0 ? scanlines-- : scanlines++; 915 ctm [3] > 0 ? scanlines-- : scanlines++;
903 916
904 qApp-> processEvents ( ); 917 qApp-> processEvents ( );
905 } 918 }
906 919
907 920
908 #ifndef QT_NO_TRANSFORMATIONS 921#ifndef QT_NO_TRANSFORMATIONS
909 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] ); 922 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] );
910 923
911 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl 924 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl
912 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl; 925 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl;
913 926
914 QWMatrix oldmat = m_painter-> worldMatrix ( ); 927 QWMatrix oldmat = m_painter-> worldMatrix ( );
@@ -918,8 +931,8 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
918 QPixmap pm; 931 QPixmap pm;
919 pm. convertFromImage ( img ); 932 pm. convertFromImage ( img );
920 m_painter-> drawPixmap ( 0, 0, pm ); 933 m_painter-> drawPixmap ( 0, 0, pm );
921 #else 934#else
922 m_painter-> drawImage ( QPoint ( 0, 0 ), img ); 935 m_painter-> drawImage ( QPoint ( 0, 0 ), img );
923#endif 936#endif
924 937
925 m_painter-> setWorldMatrix ( oldmat ); 938 m_painter-> setWorldMatrix ( oldmat );
@@ -932,10 +945,10 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
932 else { 945 else {
933 int x = lrint ( ctm [4] ); 946 int x = lrint ( ctm [4] );
934 int y = lrint ( ctm [5] ); 947 int y = lrint ( ctm [5] );
935 948
936 int w = lrint ( ctm [0] ); 949 int w = lrint ( ctm [0] );
937 int h = lrint ( ctm [3] ); 950 int h = lrint ( ctm [3] );
938 951
939 if ( w < 0 ) { 952 if ( w < 0 ) {
940 x += w; 953 x += w;
941 w = -w; 954 w = -w;
@@ -944,14 +957,14 @@ void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int wi
944 y += h; 957 y += h;
945 h = -h; 958 h = -h;
946 } 959 }
947 960
948 QPDFDBG( printf ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h )); 961 QPDFDBG( printf ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h ));
949 962
950 img = img. smoothScale ( w, h ); 963 img = img. smoothScale ( w, h );
951 qApp-> processEvents ( ); 964 qApp-> processEvents ( );
952 m_painter-> drawImage ( x, y, img ); 965 m_painter-> drawImage ( x, y, img );
953 } 966 }
954 967
955#endif 968#endif
956 969
957 970
@@ -977,7 +990,7 @@ bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h,
977 bool found = false; 990 bool found = false;
978 uint len = str. length ( ); 991 uint len = str. length ( );
979 Unicode *s = new Unicode [len]; 992 Unicode *s = new Unicode [len];
980 993
981 for ( uint i = 0; i < len; i++ ) 994 for ( uint i = 0; i < len; i++ )
982 s [i] = str [i]. unicode ( ); 995 s [i] = str [i]. unicode ( );
983 996
@@ -986,7 +999,7 @@ bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h,
986 fp_t x2 = (fp_t) l + w - 1; 999 fp_t x2 = (fp_t) l + w - 1;
987 fp_t y2 = (fp_t) t + h - 1; 1000 fp_t y2 = (fp_t) t + h - 1;
988 1001
989 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) { 1002 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) {
990 l = lrint ( x1 ); 1003 l = lrint ( x1 );
991 t = lrint ( y1 ); 1004 t = lrint ( y1 );
992 w = lrint ( x2 ) - l + 1; 1005 w = lrint ( x2 ) - l + 1;
@@ -994,7 +1007,7 @@ bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h,
994 found = true; 1007 found = true;
995 } 1008 }
996 delete [] s; 1009 delete [] s;
997 1010
998 return found; 1011 return found;
999} 1012}
1000 1013
@@ -1005,7 +1018,7 @@ GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *
1005 fp_t yMin1 = (double) *yMin; 1018 fp_t yMin1 = (double) *yMin;
1006 fp_t xMax1 = (double) *xMax; 1019 fp_t xMax1 = (double) *xMax;
1007 fp_t yMax1 = (double) *yMax; 1020 fp_t yMax1 = (double) *yMax;
1008 1021
1009 if ( m_text-> findText ( s, len, top, bottom, &xMin1, &yMin1, &xMax1, &yMax1 )) { 1022 if ( m_text-> findText ( s, len, top, bottom, &xMin1, &yMin1, &xMax1, &yMax1 )) {
1010 *xMin = lrint ( xMin1 ); 1023 *xMin = lrint ( xMin1 );
1011 *xMax = lrint ( xMax1 ); 1024 *xMax = lrint ( xMax1 );
@@ -1021,10 +1034,10 @@ QString QOutputDev::getText ( int l, int t, int w, int h )
1021 GString *gstr = m_text-> getText ( l, t, l + w - 1, t + h - 1 ); 1034 GString *gstr = m_text-> getText ( l, t, l + w - 1, t + h - 1 );
1022 QString str = gstr-> getCString ( ); 1035 QString str = gstr-> getCString ( );
1023 delete gstr; 1036 delete gstr;
1024 return str; 1037 return str;
1025} 1038}
1026 1039
1027QString QOutputDev::getText ( const QRect &r ) 1040QString QOutputDev::getText ( const QRect &r )
1028{ 1041{
1029 return getText ( r. left ( ), r. top ( ), r. width ( ), r. height ( )); 1042 return getText ( r. left ( ), r. top ( ), r. width ( ), r. height ( ));
1030} 1043}
@@ -1035,6 +1048,6 @@ void QOutputDev::drawContents ( QPainter *p, int clipx, int clipy, int clipw, in
1035{ 1048{
1036 if ( m_pixmap ) 1049 if ( m_pixmap )
1037 p-> drawPixmap ( clipx, clipy, *m_pixmap, clipx, clipy, clipw, cliph ); 1050 p-> drawPixmap ( clipx, clipy, *m_pixmap, clipx, clipy, clipw, cliph );
1038 else 1051 else
1039 p-> fillRect ( clipx, clipy, clipw, cliph, white ); 1052 p-> fillRect ( clipx, clipy, clipw, cliph, white );
1040} 1053}
diff --git a/noncore/unsupported/qpdf/opie-qpdf.control b/noncore/unsupported/qpdf/opie-qpdf.control
index 33df3e1..208dcb1 100644
--- a/noncore/unsupported/qpdf/opie-qpdf.control
+++ b/noncore/unsupported/qpdf/opie-qpdf.control
@@ -4,6 +4,6 @@ Priority: optional
4Section: opie/applications 4Section: opie/applications
5Maintainer: Robert Griebl <sandman@handhelds.org> 5Maintainer: Robert Griebl <sandman@handhelds.org>
6Architecture: arm 6Architecture: arm
7Version: $QPE_VERSION-$SUB_VERSION
8Depends: task-opie-minimal, gzip 7Depends: task-opie-minimal, gzip
9Description: A PDF viewer for OPIE. 8Description: A PDF viewer for OPIE.
9Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/unsupported/qpdf/qpdf.cpp b/noncore/unsupported/qpdf/qpdf.cpp
index 61f097b..de1dcf3 100644
--- a/noncore/unsupported/qpdf/qpdf.cpp
+++ b/noncore/unsupported/qpdf/qpdf.cpp
@@ -507,7 +507,7 @@ void QPdfDlg::openFile ( const DocLnk &f )
507 updateCaption ( ); 507 updateCaption ( );
508 } 508 }
509 else 509 else
510 QMessageBox::warning ( this, tr( "Error" ), tr( "File does not exist !" )); 510 QMessageBox::warning ( this, tr( "Error" ), tr( "File does not exist!" ));
511} 511}
512 512
513void QPdfDlg::setDocument ( const QString &f ) 513void QPdfDlg::setDocument ( const QString &f )