summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/oxygen/kmolcalc.cpp2
-rw-r--r--noncore/games/kbill/MCursor.cc6
-rw-r--r--noncore/games/kbill/Picture.cc6
-rw-r--r--noncore/unsupported/qpdf/QOutputDev.cpp12
4 files changed, 14 insertions, 12 deletions
diff --git a/noncore/apps/oxygen/kmolcalc.cpp b/noncore/apps/oxygen/kmolcalc.cpp
index 33666b1..1d41b0f 100644
--- a/noncore/apps/oxygen/kmolcalc.cpp
+++ b/noncore/apps/oxygen/kmolcalc.cpp
@@ -1,115 +1,115 @@
1/* 1/*
2 * kmolcalc.cpp 2 * kmolcalc.cpp
3 * 3 *
4 * Copyright (C) 2000,2001 Tomislav Gountchev <tomi@idiom.com> 4 * Copyright (C) 2000,2001 Tomislav Gountchev <tomi@idiom.com>
5 * Copyright (C) 2002 Carsten Niehaus <cniehaus@handhelds.org> 5 * Copyright (C) 2002 Carsten Niehaus <cniehaus@handhelds.org>
6 */ 6 */
7 7
8/** 8/**
9 * KMOLCALC is the calculation engine. It knows about a hashtable of user defined atomic 9 * KMOLCALC is the calculation engine. It knows about a hashtable of user defined atomic
10 * weights and group definitions ELSTABLE, and the currently processed formula, stored 10 * weights and group definitions ELSTABLE, and the currently processed formula, stored
11 * as a list of elements and their coefficients, ELEMENTS. 11 * as a list of elements and their coefficients, ELEMENTS.
12 */ 12 */
13 13
14#include "kmolcalc.h" 14#include "kmolcalc.h"
15#include <qdict.h> 15#include <qdict.h>
16#include <qdir.h> 16#include <qdir.h>
17#include <qfile.h> 17#include <qfile.h>
18#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <iostream.h> 19#include <iostream>
20 20
21 21
22/** 22/**
23 * Construct a new calculator object. 23 * Construct a new calculator object.
24 */ 24 */
25KMolCalc::KMolCalc() { 25KMolCalc::KMolCalc() {
26 elements = new ElementList; 26 elements = new ElementList;
27 elstable = NULL; 27 elstable = NULL;
28 readElstable(); 28 readElstable();
29} 29}
30 30
31KMolCalc::~KMolCalc() { 31KMolCalc::~KMolCalc() {
32 delete elements; 32 delete elements;
33} 33}
34 34
35void KMolCalc::readElstable() { 35void KMolCalc::readElstable() {
36 weight = -1; // not calculated yet 36 weight = -1; // not calculated yet
37 if (elstable) delete elstable; 37 if (elstable) delete elstable;
38 elstable = new QDict<SubUnit> (197, TRUE); 38 elstable = new QDict<SubUnit> (197, TRUE);
39 elstable->setAutoDelete(TRUE); 39 elstable->setAutoDelete(TRUE);
40 mwfile = QPEApplication::qpeDir() +"share/oxygen/kmolweights"; 40 mwfile = QPEApplication::qpeDir() +"share/oxygen/kmolweights";
41 QFile f(mwfile); 41 QFile f(mwfile);
42 if (f.exists()) readMwfile(f); 42 if (f.exists()) readMwfile(f);
43} 43}
44 44
45 45
46/** 46/**
47 * Parse a string S and construct the ElementList this->ELEMENTS, representing the 47 * Parse a string S and construct the ElementList this->ELEMENTS, representing the
48 * composition of S. Returns 0 if successful, or an error code (currently -1) if 48 * composition of S. Returns 0 if successful, or an error code (currently -1) if
49 * parsing failed. 49 * parsing failed.
50 * The elements is S must be valid element or group symbols, as stored in this->ELSTABLE. 50 * The elements is S must be valid element or group symbols, as stored in this->ELSTABLE.
51 * See help files for correct formula syntax. 51 * See help files for correct formula syntax.
52 */ 52 */
53QString KMolCalc::readFormula(const QString& s) { 53QString KMolCalc::readFormula(const QString& s) {
54 weight = -1; 54 weight = -1;
55 if (elements) delete elements; 55 if (elements) delete elements;
56 elements = new ElementList; 56 elements = new ElementList;
57 return KMolCalc::readGroup(s, elements); 57 return KMolCalc::readGroup(s, elements);
58} 58}
59 59
60// read a formula group recursively. Called by readFormula. 60// read a formula group recursively. Called by readFormula.
61QString KMolCalc::readGroup(const QString& s, ElementList* els) { 61QString KMolCalc::readGroup(const QString& s, ElementList* els) {
62 if (s.isEmpty()) return QString ("Enter a formula."); //ERROR 62 if (s.isEmpty()) return QString ("Enter a formula."); //ERROR
63 int sl = s.length(); 63 int sl = s.length();
64 int i = 0; 64 int i = 0;
65 QString errors ("OK"); 65 QString errors ("OK");
66 bool ok = TRUE; 66 bool ok = TRUE;
67 while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++; 67 while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++;
68 double prefix = (i == 0 ? 1 : s.left(i).toDouble(&ok)); 68 double prefix = (i == 0 ? 1 : s.left(i).toDouble(&ok));
69 if (! ok || i == sl || prefix == 0) return QString ("Bad formula."); // ERROR 69 if (! ok || i == sl || prefix == 0) return QString ("Bad formula."); // ERROR
70 ElementList* elstemp = new ElementList; 70 ElementList* elstemp = new ElementList;
71 while (i < sl) { 71 while (i < sl) {
72 int j = i; 72 int j = i;
73 if (s[i] == '(') { 73 if (s[i] == '(') {
74 ElementList* inner = new ElementList; 74 ElementList* inner = new ElementList;
75 int level = 1; // count levels of nested ( ). 75 int level = 1; // count levels of nested ( ).
76 while (1) { 76 while (1) {
77 if (i++ == sl) { 77 if (i++ == sl) {
78 delete inner; 78 delete inner;
79 delete elstemp; 79 delete elstemp;
80 return QString ("Bad formula."); //ERROR 80 return QString ("Bad formula."); //ERROR
81 } 81 }
82 if (s[i] == '(') level++; 82 if (s[i] == '(') level++;
83 if (s[i] == ')') level--; 83 if (s[i] == ')') level--;
84 if (level == 0) break; 84 if (level == 0) break;
85 } 85 }
86 errors = KMolCalc::readGroup(s.mid(j+1, i-j-1), inner); 86 errors = KMolCalc::readGroup(s.mid(j+1, i-j-1), inner);
87 j = ++i; 87 j = ++i;
88 while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++; 88 while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++;
89 double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok)); 89 double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok));
90 if (! ok || suffix == 0) { 90 if (! ok || suffix == 0) {
91 delete inner; 91 delete inner;
92 delete elstemp; 92 delete elstemp;
93 return QString ("Bad formula."); // ERROR 93 return QString ("Bad formula."); // ERROR
94 } 94 }
95 inner->addTo(*elstemp, suffix); 95 inner->addTo(*elstemp, suffix);
96 delete inner; 96 delete inner;
97 inner = NULL; 97 inner = NULL;
98 } else if ((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z')) { 98 } else if ((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z')) {
99 while (++i < sl && ((s[i] >= 'a' && s[i] <= 'z') || s[i] == '*' || 99 while (++i < sl && ((s[i] >= 'a' && s[i] <= 'z') || s[i] == '*' ||
100 s[i] == '\'')); 100 s[i] == '\''));
101 QString elname = s.mid(j, i-j); 101 QString elname = s.mid(j, i-j);
102 j = i; 102 j = i;
103 while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++; 103 while (i < sl && ((s[i] <= '9' && s[i] >= '0') || s[i] == '.')) i++;
104 double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok)); 104 double suffix = (i == j ? 1 : s.mid(j, i-j).toDouble(&ok));
105 if (! ok || suffix == 0) { 105 if (! ok || suffix == 0) {
106 delete elstemp; 106 delete elstemp;
107 return QString ("Bad formula."); // ERROR 107 return QString ("Bad formula."); // ERROR
108 } 108 }
109 SubUnit* group = elstable->find(elname); 109 SubUnit* group = elstable->find(elname);
110 if (group == 0) { 110 if (group == 0) {
111 delete elstemp; 111 delete elstemp;
112 return QString ("Undefined symbol: ") + elname; //ERROR 112 return QString ("Undefined symbol: ") + elname; //ERROR
113 } 113 }
114 group->addTo(*elstemp, suffix); 114 group->addTo(*elstemp, suffix);
115 } else if (s[i] == '+') { 115 } else if (s[i] == '+') {
diff --git a/noncore/games/kbill/MCursor.cc b/noncore/games/kbill/MCursor.cc
index 30f7577..a3cb340 100644
--- a/noncore/games/kbill/MCursor.cc
+++ b/noncore/games/kbill/MCursor.cc
@@ -1,69 +1,69 @@
1/*************************************************************************** 1/***************************************************************************
2 MCursor.cc - description 2 MCursor.cc - description
3 ------------------- 3 -------------------
4 begin : Thu Dec 30 1999 4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra 5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl 6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include "MCursor.h" 17#include "MCursor.h"
18#include "objects.h" 18#include "objects.h"
19 19
20#include <qcursor.h> 20#include <qcursor.h>
21#include <qbitmap.h> 21#include <qbitmap.h>
22#include <qwidget.h> 22#include <qwidget.h>
23#include <qstring.h> 23#include <qstring.h>
24#ifdef KDEVER 24#ifdef KDEVER
25#include <kapp.h> 25#include <kapp.h>
26#include <kstandarddirs.h> 26#include <kstandarddirs.h>
27#endif 27#endif
28#include <iostream.h> 28#include <iostream>
29#include <qpe/resource.h> 29#include <qpe/resource.h>
30MCursor::~MCursor() { 30MCursor::~MCursor() {
31 delete cursor; 31 delete cursor;
32} 32}
33 33
34void MCursor::load(const char *name, int masked) { 34void MCursor::load(const char *name, int masked) {
35 35
36 #ifdef KDEVER 36 #ifdef KDEVER
37 QString file, mfile; 37 QString file, mfile;
38 KStandardDirs dirs; 38 KStandardDirs dirs;
39 39
40 40
41 file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + ".xbm"); 41 file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + ".xbm");
42 42
43 QBitmap bitmap, mask; 43 QBitmap bitmap, mask;
44 if (bitmap.load(file) == FALSE) { 44 if (bitmap.load(file) == FALSE) {
45 cerr << "cannot open " << file << endl; 45 std::cerr << "cannot open " << file << std::endl;
46 exit(1); 46 exit(1);
47 } 47 }
48 if (masked == SEP_MASK) { 48 if (masked == SEP_MASK) {
49 // mfile.sprintf ("%sbitmaps/%s_mask.xbm", (const char*)dir, name); 49 // mfile.sprintf ("%sbitmaps/%s_mask.xbm", (const char*)dir, name);
50 mfile = file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm"); 50 mfile = file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm");
51 if (mask.load(mfile) == FALSE) { 51 if (mask.load(mfile) == FALSE) {
52 cerr << "cannot open " << file << endl; 52 std::cerr << "cannot open " << file << std::endl;
53 exit(1); 53 exit(1);
54 } 54 }
55 } 55 }
56 else 56 else
57 mask = bitmap; 57 mask = bitmap;
58 #endif 58 #endif
59 59
60 QBitmap bitmap, mask; 60 QBitmap bitmap, mask;
61 bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name)); 61 bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name));
62 62
63 if (masked == SEP_MASK) 63 if (masked == SEP_MASK)
64 mask = bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm"); 64 mask = bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm");
65 else 65 else
66 mask = bitmap; 66 mask = bitmap;
67 cursor = new QCursor(bitmap, mask, bitmap.width() / 2, bitmap.height() / 2); 67 cursor = new QCursor(bitmap, mask, bitmap.width() / 2, bitmap.height() / 2);
68} 68}
69 69
diff --git a/noncore/games/kbill/Picture.cc b/noncore/games/kbill/Picture.cc
index 79e19ba..fe0eff8 100644
--- a/noncore/games/kbill/Picture.cc
+++ b/noncore/games/kbill/Picture.cc
@@ -1,72 +1,72 @@
1/*************************************************************************** 1/***************************************************************************
2 Picture.cc - description 2 Picture.cc - description
3 ------------------- 3 -------------------
4 begin : Thu Dec 30 1999 4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra 5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl 6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include "Picture.h" 17#include "Picture.h"
18#include "objects.h" 18#include "objects.h"
19 19
20#include <iostream.h> 20#include <iostream>
21 21
22#include <qstring.h> 22#include <qstring.h>
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#ifdef KDEVER 24#ifdef KDEVER
25#include <kapp.h> 25#include <kapp.h>
26#include <kstandarddirs.h> 26#include <kstandarddirs.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#endif 28#endif
29void Picture::load(const char *name, int index) { 29void Picture::load(const char *name, int index) {
30 //QString dir = KApplication::kde_datadir(), file; 30 //QString dir = KApplication::kde_datadir(), file;
31 // QString dir = locate("data",""),file; 31 // QString dir = locate("data",""),file;
32 // dir += "/kbill/"; 32 // dir += "/kbill/";
33 // if (index>=0) 33 // if (index>=0)
34 // file.sprintf ("%spixmaps/%s_%d.xpm", (const char *)dir, name, index); 34 // file.sprintf ("%spixmaps/%s_%d.xpm", (const char *)dir, name, index);
35 // else 35 // else
36 // file.sprintf("%spixmaps/%s.xpm", (const char *)dir, name); 36 // file.sprintf("%spixmaps/%s.xpm", (const char *)dir, name);
37#ifdef KDEVER 37#ifdef KDEVER
38 KStandardDirs dirs; 38 KStandardDirs dirs;
39 QString file; 39 QString file;
40 40
41 if (index>=0) { 41 if (index>=0) {
42 //kdDebug() << "Here"; 42 //kdDebug() << "Here";
43 QString sindex; 43 QString sindex;
44 sindex.setNum(index); 44 sindex.setNum(index);
45 // kdDebug() << "kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm"; 45 // kdDebug() << "kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm";
46 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm"); 46 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm");
47 } else { 47 } else {
48 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + ".xpm"); 48 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + ".xpm");
49 } 49 }
50 kdDebug() << file << endl; 50 kdDebug() << file << std::endl;
51 pix = new QPixmap(); 51 pix = new QPixmap();
52 if (pix->load(file) == FALSE) 52 if (pix->load(file) == FALSE)
53 cerr << "cannot open " << file << endl; 53 std::cerr << "cannot open " << file << std::endl;
54 width = pix->width(); 54 width = pix->width();
55 height = pix->height(); 55 height = pix->height();
56#endif 56#endif
57QString sindex; 57QString sindex;
58pix = new QPixmap(); 58pix = new QPixmap();
59sindex.setNum(index); 59sindex.setNum(index);
60if (index>=0) 60if (index>=0)
61pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name) +"_"+ sindex)); 61pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name) +"_"+ sindex));
62else 62else
63pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name))); 63pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name)));
64 64
65 width = pix->width(); 65 width = pix->width();
66 height = pix->height(); 66 height = pix->height();
67 67
68} 68}
69 69
70QPixmap* Picture::getPixmap() { 70QPixmap* Picture::getPixmap() {
71 return pix; 71 return pix;
72} 72}
diff --git a/noncore/unsupported/qpdf/QOutputDev.cpp b/noncore/unsupported/qpdf/QOutputDev.cpp
index f587a33..52237f5 100644
--- a/noncore/unsupported/qpdf/QOutputDev.cpp
+++ b/noncore/unsupported/qpdf/QOutputDev.cpp
@@ -1,117 +1,119 @@
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 <iostream>
23
22#include "GString.h" 24#include "GString.h"
23#include "Object.h" 25#include "Object.h"
24#include "Stream.h" 26#include "Stream.h"
25#include "Link.h" 27#include "Link.h"
26#include "GfxState.h" 28#include "GfxState.h"
27#include "GfxFont.h" 29#include "GfxFont.h"
28#include "UnicodeMap.h" 30#include "UnicodeMap.h"
29#include "CharCodeToUnicode.h" 31#include "CharCodeToUnicode.h"
30#include "FontFile.h" 32#include "FontFile.h"
31#include "Error.h" 33#include "Error.h"
32#include "TextOutputDev.h" 34#include "TextOutputDev.h"
33#include "QOutputDev.h" 35#include "QOutputDev.h"
34 36
35 37
36#include <qpixmap.h> 38#include <qpixmap.h>
37#include <qimage.h> 39#include <qimage.h>
38#include <qpainter.h> 40#include <qpainter.h>
39#include <qdict.h> 41#include <qdict.h>
40#include <qtimer.h> 42#include <qtimer.h>
41#include <qapplication.h> 43#include <qapplication.h>
42#include <qclipboard.h> 44#include <qclipboard.h>
43 45
44 //#define QPDFDBG(x) x // special debug mode 46 //#define QPDFDBG(x) x // special debug mode
45 #define QPDFDBG(x) // normal compilation 47 #define QPDFDBG(x) // normal compilation
46 48
47 49
48//------------------------------------------------------------------------ 50//------------------------------------------------------------------------
49// Constants and macros 51// Constants and macros
50//------------------------------------------------------------------------ 52//------------------------------------------------------------------------
51 53
52 54
53static inline QColor q_col ( const GfxRGB &rgb ) 55static inline QColor q_col ( const GfxRGB &rgb )
54{ 56{
55 return QColor ( lrint ( rgb. r * 255 ), lrint ( rgb. g * 255 ), lrint ( rgb. b * 255 )); 57 return QColor ( lrint ( rgb. r * 255 ), lrint ( rgb. g * 255 ), lrint ( rgb. b * 255 ));
56} 58}
57 59
58 60
59//------------------------------------------------------------------------ 61//------------------------------------------------------------------------
60// Font substitutions 62// Font substitutions
61//------------------------------------------------------------------------ 63//------------------------------------------------------------------------
62 64
63struct QOutFontSubst { 65struct QOutFontSubst {
64 char * m_name; 66 char * m_name;
65 char * m_sname; 67 char * m_sname;
66 bool m_bold; 68 bool m_bold;
67 bool m_italic; 69 bool m_italic;
68 QFont::StyleHint m_hint; 70 QFont::StyleHint m_hint;
69}; 71};
70 72
71static QOutFontSubst qStdFonts [] = { 73static QOutFontSubst qStdFonts [] = {
72 { "Helvetica", "Helvetica", false, false, QFont::Helvetica }, 74 { "Helvetica", "Helvetica", false, false, QFont::Helvetica },
73 { "Helvetica-Oblique", "Helvetica", false, true, QFont::Helvetica }, 75 { "Helvetica-Oblique", "Helvetica", false, true, QFont::Helvetica },
74 { "Helvetica-Bold", "Helvetica", true, false, QFont::Helvetica }, 76 { "Helvetica-Bold", "Helvetica", true, false, QFont::Helvetica },
75 { "Helvetica-BoldOblique", "Helvetica", true, true, QFont::Helvetica }, 77 { "Helvetica-BoldOblique", "Helvetica", true, true, QFont::Helvetica },
76 { "Times-Roman", "Times", false, false, QFont::Times }, 78 { "Times-Roman", "Times", false, false, QFont::Times },
77 { "Times-Italic", "Times", false, true, QFont::Times }, 79 { "Times-Italic", "Times", false, true, QFont::Times },
78 { "Times-Bold", "Times", true, false, QFont::Times }, 80 { "Times-Bold", "Times", true, false, QFont::Times },
79 { "Times-BoldItalic", "Times", true, true, QFont::Times }, 81 { "Times-BoldItalic", "Times", true, true, QFont::Times },
80 { "Courier", "Courier", false, false, QFont::Courier }, 82 { "Courier", "Courier", false, false, QFont::Courier },
81 { "Courier-Oblique", "Courier", false, true, QFont::Courier }, 83 { "Courier-Oblique", "Courier", false, true, QFont::Courier },
82 { "Courier-Bold", "Courier", true, false, QFont::Courier }, 84 { "Courier-Bold", "Courier", true, false, QFont::Courier },
83 { "Courier-BoldOblique", "Courier", true, true, QFont::Courier }, 85 { "Courier-BoldOblique", "Courier", true, true, QFont::Courier },
84 86
85 { "Symbol", 0, false, false, QFont::AnyStyle }, 87 { "Symbol", 0, false, false, QFont::AnyStyle },
86 { "Zapf-Dingbats", 0, false, false, QFont::AnyStyle }, 88 { "Zapf-Dingbats", 0, false, false, QFont::AnyStyle },
87 89
88 { 0, 0, false, false, QFont::AnyStyle } 90 { 0, 0, false, false, QFont::AnyStyle }
89}; 91};
90 92
91 93
92 94
93 95
94 96
95 97
96 98
97QFont 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 )
98{ 100{
99 static QDict<QOutFontSubst> stdfonts; 101 static QDict<QOutFontSubst> stdfonts;
100 102
101 // build dict for std. fonts on first invocation 103 // build dict for std. fonts on first invocation
102 if ( stdfonts. isEmpty ( )) { 104 if ( stdfonts. isEmpty ( )) {
103 for ( QOutFontSubst *ptr = qStdFonts; ptr-> m_name; ptr++ ) { 105 for ( QOutFontSubst *ptr = qStdFonts; ptr-> m_name; ptr++ ) {
104 stdfonts. insert ( QString ( ptr-> m_name ), ptr ); 106 stdfonts. insert ( QString ( ptr-> m_name ), ptr );
105 } 107 }
106 } 108 }
107 109
108 // compute size and normalized transform matrix 110 // compute size and normalized transform matrix
109 int size = lrint ( sqrt ( m21 * m21 + m22 * m22 )); 111 int size = lrint ( sqrt ( m21 * m21 + m22 * m22 ));
110 112
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", 113 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>" ), 114 (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ),
113 size, 115 size,
114 gfxFont-> isBold ( ), 116 gfxFont-> isBold ( ),
115 gfxFont-> isItalic ( ), 117 gfxFont-> isItalic ( ),
116 gfxFont-> isFixedWidth ( ), 118 gfxFont-> isFixedWidth ( ),
117 gfxFont-> isSerif ( ), 119 gfxFont-> isSerif ( ),
@@ -577,430 +579,430 @@ int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArr
577 579
578 QPointArray tmp; 580 QPointArray tmp;
579 tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ), 581 tmp. setPoints ( 4, lrint ( x0 ), lrint ( y0 ), lrint ( x1 ), lrint ( y1 ),
580 lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 )); 582 lrint ( x2 ), lrint ( y2 ), lrint ( x3 ), lrint ( y3 ));
581 583
582#if QT_VERSION < 300 584#if QT_VERSION < 300
583 tmp = tmp. quadBezier ( ); 585 tmp = tmp. quadBezier ( );
584 586
585 for ( uint loop = 0; loop < tmp. count ( ); loop++ ) { 587 for ( uint loop = 0; loop < tmp. count ( ); loop++ ) {
586 QPoint p = tmp. point ( loop ); 588 QPoint p = tmp. point ( loop );
587 points. putPoints ( points. count ( ), 1, p. x ( ), p. y ( )); 589 points. putPoints ( points. count ( ), 1, p. x ( ), p. y ( ));
588 } 590 }
589#else 591#else
590 tmp = tmp. cubicBezier ( ); 592 tmp = tmp. cubicBezier ( );
591 points. putPoints ( points. count ( ), tmp. count ( ), tmp ); 593 points. putPoints ( points. count ( ), tmp. count ( ), tmp );
592#endif 594#endif
593 595
594 i += 3; 596 i += 3;
595 } 597 }
596 else { 598 else {
597 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 ); 599 state-> transform ( subpath-> getX ( i ), subpath-> getY ( i ), &x1, &y1 );
598 600
599 points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 )); 601 points. putPoints ( points. count ( ), 1, lrint ( x1 ), lrint ( y1 ));
600 ++i; 602 ++i;
601 } 603 }
602 } 604 }
603 return points. count ( ) - oldcnt; 605 return points. count ( ) - oldcnt;
604} 606}
605 607
606 608
607void QOutputDev::beginString ( GfxState *state, GString */*s*/ ) 609void QOutputDev::beginString ( GfxState *state, GString */*s*/ )
608{ 610{
609 m_text-> beginString ( state ); 611 m_text-> beginString ( state );
610} 612}
611 613
612void QOutputDev::endString ( GfxState */*state*/ ) 614void QOutputDev::endString ( GfxState */*state*/ )
613{ 615{
614 m_text-> endString ( ); 616 m_text-> endString ( );
615} 617}
616 618
617void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y, 619void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y,
618 fp_t dx, fp_t dy, fp_t originX, fp_t originY, 620 fp_t dx, fp_t dy, fp_t originX, fp_t originY,
619 CharCode code, Unicode *u, int uLen ) 621 CharCode code, Unicode *u, int uLen )
620{ 622{
621 fp_t x1, y1, dx1, dy1; 623 fp_t x1, y1, dx1, dy1;
622 624
623 if ( uLen > 0 ) 625 if ( uLen > 0 )
624 m_text-> addChar ( state, x, y, dx, dy, u, uLen ); 626 m_text-> addChar ( state, x, y, dx, dy, u, uLen );
625 627
626 // check for invisible text -- this is used by Acrobat Capture 628 // check for invisible text -- this is used by Acrobat Capture
627 if (( state-> getRender ( ) & 3 ) == 3 ) { 629 if (( state-> getRender ( ) & 3 ) == 3 ) {
628 return; 630 return;
629 } 631 }
630 632
631 x -= originX; 633 x -= originX;
632 y -= originY; 634 y -= originY;
633 state-> transform ( x, y, &x1, &y1 ); 635 state-> transform ( x, y, &x1, &y1 );
634 state-> transformDelta ( dx, dy, &dx1, &dy1 ); 636 state-> transformDelta ( dx, dy, &dx1, &dy1 );
635 637
636 638
637 if ( uLen > 0 ) { 639 if ( uLen > 0 ) {
638 QString str; 640 QString str;
639 QFontMetrics fm = m_painter-> fontMetrics ( ); 641 QFontMetrics fm = m_painter-> fontMetrics ( );
640 642
641 for ( int i = 0; i < uLen; i++ ) { 643 for ( int i = 0; i < uLen; i++ ) {
642 QChar c = QChar ( u [i] ); 644 QChar c = QChar ( u [i] );
643 645
644 if ( fm. inFont ( c )) { 646 if ( fm. inFont ( c )) {
645 str [i] = QChar ( u [i] ); 647 str [i] = QChar ( u [i] );
646 } 648 }
647 else { 649 else {
648 str [i] = ' '; 650 str [i] = ' ';
649 QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( ))); 651 QPDFDBG( printf ( "CHARACTER NOT IN FONT: %hx\n", c. unicode ( )));
650 } 652 }
651 } 653 }
652 654
653 if (( uLen == 1 ) && ( str [0] == ' ' )) 655 if (( uLen == 1 ) && ( str [0] == ' ' ))
654 return; 656 return;
655 657
656 658
657 fp_t m11, m12, m21, m22; 659 fp_t m11, m12, m21, m22;
658 660
659 state-> getFontTransMat ( &m11, &m12, &m21, &m22 ); 661 state-> getFontTransMat ( &m11, &m12, &m21, &m22 );
660 m11 *= state-> getHorizScaling ( ); 662 m11 *= state-> getHorizScaling ( );
661 m12 *= state-> getHorizScaling ( ); 663 m12 *= state-> getHorizScaling ( );
662 664
663 fp_t fsize = m_painter-> font ( ). pixelSize ( ); 665 fp_t fsize = m_painter-> font ( ). pixelSize ( );
664 666
665#ifndef QT_NO_TRANSFORMATIONS 667#ifndef QT_NO_TRANSFORMATIONS
666 QWMatrix oldmat; 668 QWMatrix oldmat;
667 669
668 bool dorot = (( m12 < -0.1 ) || ( m12 > 0.1 )) && (( m21 < -0.1 ) || ( m21 > 0.1 )); 670 bool dorot = (( m12 < -0.1 ) || ( m12 > 0.1 )) && (( m21 < -0.1 ) || ( m21 > 0.1 ));
669 671
670 if ( dorot ) { 672 if ( dorot ) {
671 oldmat = m_painter-> worldMatrix ( ); 673 oldmat = m_painter-> worldMatrix ( );
672 674
673 cerr << endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl; 675 std::cerr << std::endl << "ROTATED: " << m11 << ", " << m12 << ", " << m21 << ", " << m22 << " / SIZE: " << fsize << " / TEXT: " << str. local8Bit ( ) << endl << endl;
674 676
675 QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 )); 677 QWMatrix mat ( lrint ( m11 / fsize ), lrint ( m12 / fsize ), -lrint ( m21 / fsize ), -lrint ( m22 / fsize ), lrint ( x1 ), lrint ( y1 ));
676 678
677 m_painter-> setWorldMatrix ( mat ); 679 m_painter-> setWorldMatrix ( mat );
678 680
679 x1 = 0; 681 x1 = 0;
680 y1 = 0; 682 y1 = 0;
681 } 683 }
682#endif 684#endif
683 685
684 QPen oldpen = m_painter-> pen ( ); 686 QPen oldpen = m_painter-> pen ( );
685 687
686 if (!( state-> getRender ( ) & 1 )) { 688 if (!( state-> getRender ( ) & 1 )) {
687 QPen fillpen = oldpen; 689 QPen fillpen = oldpen;
688 690
689 fillpen. setColor ( m_painter-> brush ( ). color ( )); 691 fillpen. setColor ( m_painter-> brush ( ). color ( ));
690 m_painter-> setPen ( fillpen ); 692 m_painter-> setPen ( fillpen );
691 } 693 }
692 694
693 if ( fsize > 5 ) 695 if ( fsize > 5 )
694 m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str ); 696 m_painter-> drawText ( lrint ( x1 ), lrint ( y1 ), str );
695 else 697 else
696 m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( )); 698 m_painter-> fillRect ( lrint ( x1 ), lrint ( y1 ), lrint ( QMAX( fp_t(1), dx1 )), lrint ( QMAX( fsize, dy1 )), m_painter-> pen ( ). color ( ));
697 699
698 m_painter-> setPen ( oldpen ); 700 m_painter-> setPen ( oldpen );
699 701
700#ifndef QT_NO_TRANSFORMATIONS 702#ifndef QT_NO_TRANSFORMATIONS
701 if ( dorot ) 703 if ( dorot )
702 m_painter-> setWorldMatrix ( oldmat ); 704 m_painter-> setWorldMatrix ( oldmat );
703 #endif 705 #endif
704 706
705 QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 ))); 707 QPDFDBG( printf ( "DRAW TEXT: \"%s\" at (%ld/%ld)\n", str. local8Bit ( ). data ( ), lrint ( x1 ), lrint ( y1 )));
706 } 708 }
707 else if ( code != 0 ) { 709 else if ( code != 0 ) {
708 // some PDF files use CID 0, which is .notdef, so just ignore it 710 // some PDF files use CID 0, which is .notdef, so just ignore it
709 qWarning ( "Unknown character (CID=%d Unicode=%hx)\n", code, (unsigned short) ( uLen > 0 ? u [0] : (Unicode) 0 )); 711 qWarning ( "Unknown character (CID=%d Unicode=%hx)\n", code, (unsigned short) ( uLen > 0 ? u [0] : (Unicode) 0 ));
710 } 712 }
711 qApp-> processEvents ( ); 713 qApp-> processEvents ( );
712} 714}
713 715
714 716
715 717
716void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg ) 718void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg )
717{ 719{
718 // get CTM, check for singular matrix 720 // get CTM, check for singular matrix
719 fp_t *ctm = state-> getCTM ( ); 721 fp_t *ctm = state-> getCTM ( );
720 722
721 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) { 723 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) {
722 qWarning ( "Singular CTM in drawImage\n" ); 724 qWarning ( "Singular CTM in drawImage\n" );
723 725
724 if ( inlineImg ) { 726 if ( inlineImg ) {
725 str-> reset ( ); 727 str-> reset ( );
726 int j = height * (( width + 7 ) / 8 ); 728 int j = height * (( width + 7 ) / 8 );
727 for ( int i = 0; i < j; i++ ) 729 for ( int i = 0; i < j; i++ )
728 str->getChar(); 730 str->getChar();
729 731
730 str->close(); 732 str->close();
731 } 733 }
732 return; 734 return;
733 } 735 }
734 736
735 GfxRGB rgb; 737 GfxRGB rgb;
736 state-> getFillRGB ( &rgb ); 738 state-> getFillRGB ( &rgb );
737 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff ); 739 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
738 740
739 741
740 QImage img ( width, height, 32 ); 742 QImage img ( width, height, 32 );
741 img. setAlphaBuffer ( true ); 743 img. setAlphaBuffer ( true );
742 744
743 QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height )); 745 QPDFDBG( printf ( "IMAGE MASK (%dx%d)\n", width, height ));
744 746
745 // initialize the image stream 747 // initialize the image stream
746 ImageStream *imgStr = new ImageStream ( str, width, 1, 1 ); 748 ImageStream *imgStr = new ImageStream ( str, width, 1, 1 );
747 imgStr-> reset ( ); 749 imgStr-> reset ( );
748 750
749 uchar **scanlines = img. jumpTable ( ); 751 uchar **scanlines = img. jumpTable ( );
750 752
751 if ( ctm [3] > 0 ) 753 if ( ctm [3] > 0 )
752 scanlines += ( height - 1 ); 754 scanlines += ( height - 1 );
753 755
754 for ( int y = 0; y < height; y++ ) { 756 for ( int y = 0; y < height; y++ ) {
755 QRgb *scanline = (QRgb *) *scanlines; 757 QRgb *scanline = (QRgb *) *scanlines;
756 758
757 if ( ctm [0] < 0 ) 759 if ( ctm [0] < 0 )
758 scanline += ( width - 1 ); 760 scanline += ( width - 1 );
759 761
760 for ( int x = 0; x < width; x++ ) { 762 for ( int x = 0; x < width; x++ ) {
761 Guchar alpha; 763 Guchar alpha;
762 764
763 imgStr-> getPixel ( &alpha ); 765 imgStr-> getPixel ( &alpha );
764 766
765 if ( invert ) 767 if ( invert )
766 alpha ^= 1; 768 alpha ^= 1;
767 769
768 *scanline = ( alpha == 0 ) ? 0xff000000 | val : val; 770 *scanline = ( alpha == 0 ) ? 0xff000000 | val : val;
769 771
770 ctm [0] < 0 ? scanline-- : scanline++; 772 ctm [0] < 0 ? scanline-- : scanline++;
771 } 773 }
772 ctm [3] > 0 ? scanlines-- : scanlines++; 774 ctm [3] > 0 ? scanlines-- : scanlines++;
773 775
774 qApp-> processEvents ( ); 776 qApp-> processEvents ( );
775 } 777 }
776 778
777 #ifndef QT_NO_TRANSFORMATIONS 779 #ifndef QT_NO_TRANSFORMATIONS
778 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] ); 780 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] );
779 781
780 cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << endl 782 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl
781 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << endl; 783 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl;
782 784
783 QWMatrix oldmat = m_painter-> worldMatrix ( ); 785 QWMatrix oldmat = m_painter-> worldMatrix ( );
784 m_painter-> setWorldMatrix ( mat, true ); 786 m_painter-> setWorldMatrix ( mat, true );
785 787
786#ifdef QWS 788#ifdef QWS
787 QPixmap pm; 789 QPixmap pm;
788 pm. convertFromImage ( img ); 790 pm. convertFromImage ( img );
789 m_painter-> drawPixmap ( 0, 0, pm ); 791 m_painter-> drawPixmap ( 0, 0, pm );
790#else 792#else
791 m_painter-> drawImage ( QPoint ( 0, 0 ), img ); 793 m_painter-> drawImage ( QPoint ( 0, 0 ), img );
792#endif 794#endif
793 795
794 m_painter-> setWorldMatrix ( oldmat ); 796 m_painter-> setWorldMatrix ( oldmat );
795 797
796#else 798#else
797 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { 799 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) {
798 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); 800 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ));
799 } 801 }
800 else { 802 else {
801 int x = lrint ( ctm [4] ); 803 int x = lrint ( ctm [4] );
802 int y = lrint ( ctm [5] ); 804 int y = lrint ( ctm [5] );
803 805
804 int w = lrint ( ctm [0] ); 806 int w = lrint ( ctm [0] );
805 int h = lrint ( ctm [3] ); 807 int h = lrint ( ctm [3] );
806 808
807 if ( w < 0 ) { 809 if ( w < 0 ) {
808 x += w; 810 x += w;
809 w = -w; 811 w = -w;
810 } 812 }
811 if ( h < 0 ) { 813 if ( h < 0 ) {
812 y += h; 814 y += h;
813 h = -h; 815 h = -h;
814 } 816 }
815 817
816 QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h )); 818 QPDFDBG( printf ( "DRAWING IMAGE MASKED: %d/%d - %dx%d\n", x, y, w, h ));
817 819
818 img = img. smoothScale ( w, h ); 820 img = img. smoothScale ( w, h );
819 qApp-> processEvents ( ); 821 qApp-> processEvents ( );
820 m_painter-> drawImage ( x, y, img ); 822 m_painter-> drawImage ( x, y, img );
821 } 823 }
822 824
823#endif 825#endif
824 826
825 delete imgStr; 827 delete imgStr;
826 qApp-> processEvents ( ); 828 qApp-> processEvents ( );
827} 829}
828 830
829 831
830void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg ) 832void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg )
831{ 833{
832 int nComps, nVals, nBits; 834 int nComps, nVals, nBits;
833 835
834 // image parameters 836 // image parameters
835 nComps = colorMap->getNumPixelComps ( ); 837 nComps = colorMap->getNumPixelComps ( );
836 nVals = width * nComps; 838 nVals = width * nComps;
837 nBits = colorMap-> getBits ( ); 839 nBits = colorMap-> getBits ( );
838 840
839 // get CTM, check for singular matrix 841 // get CTM, check for singular matrix
840 fp_t *ctm = state-> getCTM ( ); 842 fp_t *ctm = state-> getCTM ( );
841 843
842 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) { 844 if ( fabs ( ctm [0] * ctm [3] - ctm [1] * ctm [2] ) < 0.000001 ) {
843 qWarning ( "Singular CTM in drawImage\n" ); 845 qWarning ( "Singular CTM in drawImage\n" );
844 846
845 if ( inlineImg ) { 847 if ( inlineImg ) {
846 str-> reset ( ); 848 str-> reset ( );
847 int j = height * (( nVals * nBits + 7 ) / 8 ); 849 int j = height * (( nVals * nBits + 7 ) / 8 );
848 for ( int i = 0; i < j; i++ ) 850 for ( int i = 0; i < j; i++ )
849 str->getChar(); 851 str->getChar();
850 852
851 str->close(); 853 str->close();
852 } 854 }
853 return; 855 return;
854 } 856 }
855 857
856 QImage img ( width, height, 32 ); 858 QImage img ( width, height, 32 );
857 859
858 if ( maskColors ) 860 if ( maskColors )
859 img. setAlphaBuffer ( true ); 861 img. setAlphaBuffer ( true );
860 862
861 QPDFDBG( printf ( "IMAGE (%dx%d)\n", width, height )); 863 QPDFDBG( printf ( "IMAGE (%dx%d)\n", width, height ));
862 864
863 // initialize the image stream 865 // initialize the image stream
864 ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits ); 866 ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits );
865 imgStr-> reset ( ); 867 imgStr-> reset ( );
866 868
867 Guchar pixBuf [gfxColorMaxComps]; 869 Guchar pixBuf [gfxColorMaxComps];
868 GfxRGB rgb; 870 GfxRGB rgb;
869 871
870 872
871 uchar **scanlines = img. jumpTable ( ); 873 uchar **scanlines = img. jumpTable ( );
872 874
873 if ( ctm [3] > 0 ) 875 if ( ctm [3] > 0 )
874 scanlines += ( height - 1 ); 876 scanlines += ( height - 1 );
875 877
876 for ( int y = 0; y < height; y++ ) { 878 for ( int y = 0; y < height; y++ ) {
877 QRgb *scanline = (QRgb *) *scanlines; 879 QRgb *scanline = (QRgb *) *scanlines;
878 880
879 if ( ctm [0] < 0 ) 881 if ( ctm [0] < 0 )
880 scanline += ( width - 1 ); 882 scanline += ( width - 1 );
881 883
882 for ( int x = 0; x < width; x++ ) { 884 for ( int x = 0; x < width; x++ ) {
883 imgStr-> getPixel ( pixBuf ); 885 imgStr-> getPixel ( pixBuf );
884 colorMap-> getRGB ( pixBuf, &rgb ); 886 colorMap-> getRGB ( pixBuf, &rgb );
885 887
886 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff ); 888 uint val = ( lrint ( rgb. r * 255 ) & 0xff ) << 16 | ( lrint ( rgb. g * 255 ) & 0xff ) << 8 | ( lrint ( rgb. b * 255 ) & 0xff );
887 889
888 if ( maskColors ) { 890 if ( maskColors ) {
889 for ( int k = 0; k < nComps; ++k ) { 891 for ( int k = 0; k < nComps; ++k ) {
890 if (( pixBuf [k] < maskColors [2 * k] ) || ( pixBuf [k] > maskColors [2 * k] )) { 892 if (( pixBuf [k] < maskColors [2 * k] ) || ( pixBuf [k] > maskColors [2 * k] )) {
891 val |= 0xff000000; 893 val |= 0xff000000;
892 break; 894 break;
893 } 895 }
894 } 896 }
895 } 897 }
896 *scanline = val; 898 *scanline = val;
897 899
898 ctm [0] < 0 ? scanline-- : scanline++; 900 ctm [0] < 0 ? scanline-- : scanline++;
899 } 901 }
900 ctm [3] > 0 ? scanlines-- : scanlines++; 902 ctm [3] > 0 ? scanlines-- : scanlines++;
901 903
902 qApp-> processEvents ( ); 904 qApp-> processEvents ( );
903 } 905 }
904 906
905 907
906 #ifndef QT_NO_TRANSFORMATIONS 908 #ifndef QT_NO_TRANSFORMATIONS
907 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] ); 909 QWMatrix mat ( ctm [0] / width, ctm [1], ctm [2], ctm [3] / height, ctm [4], ctm [5] );
908 910
909 cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << endl 911 std::cerr << "MATRIX T=" << mat. dx ( ) << "/" << mat. dy ( ) << std::endl
910 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << endl; 912 << " - M=" << mat. m11 ( ) << "/" << mat. m12 ( ) << "/" << mat. m21 ( ) << "/" << mat. m22 ( ) << std::endl;
911 913
912 QWMatrix oldmat = m_painter-> worldMatrix ( ); 914 QWMatrix oldmat = m_painter-> worldMatrix ( );
913 m_painter-> setWorldMatrix ( mat, true ); 915 m_painter-> setWorldMatrix ( mat, true );
914 916
915#ifdef QWS 917#ifdef QWS
916 QPixmap pm; 918 QPixmap pm;
917 pm. convertFromImage ( img ); 919 pm. convertFromImage ( img );
918 m_painter-> drawPixmap ( 0, 0, pm ); 920 m_painter-> drawPixmap ( 0, 0, pm );
919 #else 921 #else
920 m_painter-> drawImage ( QPoint ( 0, 0 ), img ); 922 m_painter-> drawImage ( QPoint ( 0, 0 ), img );
921#endif 923#endif
922 924
923 m_painter-> setWorldMatrix ( oldmat ); 925 m_painter-> setWorldMatrix ( oldmat );
924 926
925#else // QT_NO_TRANSFORMATIONS 927#else // QT_NO_TRANSFORMATIONS
926 928
927 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { 929 if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) {
928 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); 930 QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" ));
929 } 931 }
930 else { 932 else {
931 int x = lrint ( ctm [4] ); 933 int x = lrint ( ctm [4] );
932 int y = lrint ( ctm [5] ); 934 int y = lrint ( ctm [5] );
933 935
934 int w = lrint ( ctm [0] ); 936 int w = lrint ( ctm [0] );
935 int h = lrint ( ctm [3] ); 937 int h = lrint ( ctm [3] );
936 938
937 if ( w < 0 ) { 939 if ( w < 0 ) {
938 x += w; 940 x += w;
939 w = -w; 941 w = -w;
940 } 942 }
941 if ( h < 0 ) { 943 if ( h < 0 ) {
942 y += h; 944 y += h;
943 h = -h; 945 h = -h;
944 } 946 }
945 947
946 QPDFDBG( printf ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h )); 948 QPDFDBG( printf ( "DRAWING IMAGE: %d/%d - %dx%d\n", x, y, w, h ));
947 949
948 img = img. smoothScale ( w, h ); 950 img = img. smoothScale ( w, h );
949 qApp-> processEvents ( ); 951 qApp-> processEvents ( );
950 m_painter-> drawImage ( x, y, img ); 952 m_painter-> drawImage ( x, y, img );
951 } 953 }
952 954
953#endif 955#endif
954 956
955 957
956 delete imgStr; 958 delete imgStr;
957 qApp-> processEvents ( ); 959 qApp-> processEvents ( );
958} 960}
959 961
960 962
961 963
962bool QOutputDev::findText ( const QString &str, QRect &r, bool top, bool bottom ) 964bool QOutputDev::findText ( const QString &str, QRect &r, bool top, bool bottom )
963{ 965{
964 int l, t, w, h; 966 int l, t, w, h;
965 r. rect ( &l, &t, &w, &h ); 967 r. rect ( &l, &t, &w, &h );
966 968
967 bool res = findText ( str, l, t, w, h, top, bottom ); 969 bool res = findText ( str, l, t, w, h, top, bottom );
968 970
969 r. setRect ( l, t, w, h ); 971 r. setRect ( l, t, w, h );
970 return res; 972 return res;
971} 973}
972 974
973bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h, bool top, bool bottom ) 975bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h, bool top, bool bottom )
974{ 976{
975 bool found = false; 977 bool found = false;
976 uint len = str. length ( ); 978 uint len = str. length ( );
977 Unicode *s = new Unicode [len]; 979 Unicode *s = new Unicode [len];
978 980
979 for ( uint i = 0; i < len; i++ ) 981 for ( uint i = 0; i < len; i++ )
980 s [i] = str [i]. unicode ( ); 982 s [i] = str [i]. unicode ( );
981 983
982 fp_t x1 = (fp_t) l; 984 fp_t x1 = (fp_t) l;
983 fp_t y1 = (fp_t) t; 985 fp_t y1 = (fp_t) t;
984 fp_t x2 = (fp_t) l + w - 1; 986 fp_t x2 = (fp_t) l + w - 1;
985 fp_t y2 = (fp_t) t + h - 1; 987 fp_t y2 = (fp_t) t + h - 1;
986 988
987 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) { 989 if ( m_text-> findText ( s, len, top, bottom, &x1, &y1, &x2, &y2 )) {
988 l = lrint ( x1 ); 990 l = lrint ( x1 );
989 t = lrint ( y1 ); 991 t = lrint ( y1 );
990 w = lrint ( x2 ) - l + 1; 992 w = lrint ( x2 ) - l + 1;
991 h = lrint ( y2 ) - t + 1; 993 h = lrint ( y2 ) - t + 1;
992 found = true; 994 found = true;
993 } 995 }
994 delete [] s; 996 delete [] s;
995 997
996 return found; 998 return found;
997} 999}
998 1000
999GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax ) 1001GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax )
1000{ 1002{
1001 bool found = false; 1003 bool found = false;
1002 fp_t xMin1 = (double) *xMin; 1004 fp_t xMin1 = (double) *xMin;
1003 fp_t yMin1 = (double) *yMin; 1005 fp_t yMin1 = (double) *yMin;
1004 fp_t xMax1 = (double) *xMax; 1006 fp_t xMax1 = (double) *xMax;
1005 fp_t yMax1 = (double) *yMax; 1007 fp_t yMax1 = (double) *yMax;
1006 1008