author | kergoth <kergoth> | 2003-08-09 16:24:58 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-08-09 16:24:58 (UTC) |
commit | e16d333ec2e8509fc665921ca106c25325bae9e0 (patch) (unidiff) | |
tree | 9e9068190a15bc9b2a52ab33b40881128f732c0e /noncore/unsupported | |
parent | 1c58d1407f9584fedcdae390a04e2b37e5853361 (diff) | |
download | opie-e16d333ec2e8509fc665921ca106c25325bae9e0.zip opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.gz opie-e16d333ec2e8509fc665921ca106c25325bae9e0.tar.bz2 |
Merge from BRANCH_1_0
-rw-r--r-- | noncore/unsupported/gsmtool/gsmtool.pro | 2 | ||||
-rw-r--r-- | noncore/unsupported/mail2/addresspicker.cpp | 1 | ||||
-rw-r--r-- | noncore/unsupported/mail2/bend/opie-mailapplet.control | 4 | ||||
-rw-r--r-- | noncore/unsupported/mail2/opie-mail2.control | 2 | ||||
-rw-r--r-- | noncore/unsupported/mailit/opie-mailit.control | 2 | ||||
-rw-r--r-- | noncore/unsupported/qpdf/QOutputDev.cpp | 367 | ||||
-rw-r--r-- | noncore/unsupported/qpdf/opie-qpdf.control | 2 | ||||
-rw-r--r-- | noncore/unsupported/qpdf/qpdf.cpp | 2 |
8 files changed, 198 insertions, 184 deletions
diff --git a/noncore/unsupported/gsmtool/gsmtool.pro b/noncore/unsupported/gsmtool/gsmtool.pro index 180195f..40d5942 100644 --- a/noncore/unsupported/gsmtool/gsmtool.pro +++ b/noncore/unsupported/gsmtool/gsmtool.pro | |||
@@ -1,36 +1,36 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | #CONFIG = qt warn_on debug | 2 | #CONFIG = qt warn_on debug |
3 | CONFIG = qt warn_on release | 3 | CONFIG = qt warn_on release |
4 | DESTDIR = $(OPIEDIR)/bin | 4 | DESTDIR = $(OPIEDIR)/bin |
5 | HEADERS = gsmtool.h | 5 | HEADERS = gsmtool.h |
6 | SOURCES = main.cpp gsmtool.cpp | 6 | SOURCES = main.cpp gsmtool.cpp |
7 | # This doesn't actually work... | 7 | # This doesn't actually work... |
8 | TMAKE_CXXFLAGS += -fexceptions | 8 | TMAKE_CXXFLAGS += -fexceptions |
9 | INCLUDEPATH+= $(OPIEDIR)/include | 9 | INCLUDEPATH+= $(OPIEDIR)/include |
10 | INCLUDEPATH+= $(GSMLIBDIR) | 10 | #INCLUDEPATH+= $(GSMLIBDIR) |
11 | DEPENDPATH+= $(OPIEDIR)/include | 11 | DEPENDPATH+= $(OPIEDIR)/include |
12 | LIBS += -lqpe -L$(GSMLIBDIR)/gsmlib/.libs -lgsmme | 12 | LIBS += -lqpe -L$(GSMLIBDIR)/gsmlib/.libs -lgsmme |
13 | INTERFACES= gsmtoolbase.ui | 13 | INTERFACES= gsmtoolbase.ui |
14 | TARGET = gsmtool | 14 | TARGET = gsmtool |
15 | 15 | ||
16 | TRANSLATIONS = ../../../i18n/de/gsmtool.ts \ | 16 | TRANSLATIONS = ../../../i18n/de/gsmtool.ts \ |
17 | ../../../i18n/nl/gsmtool.ts \ | 17 | ../../../i18n/nl/gsmtool.ts \ |
18 | ../../../i18n/da/gsmtool.ts \ | 18 | ../../../i18n/da/gsmtool.ts \ |
19 | ../../../i18n/xx/gsmtool.ts \ | 19 | ../../../i18n/xx/gsmtool.ts \ |
20 | ../../../i18n/en/gsmtool.ts \ | 20 | ../../../i18n/en/gsmtool.ts \ |
21 | ../../../i18n/es/gsmtool.ts \ | 21 | ../../../i18n/es/gsmtool.ts \ |
22 | ../../../i18n/fr/gsmtool.ts \ | 22 | ../../../i18n/fr/gsmtool.ts \ |
23 | ../../../i18n/hu/gsmtool.ts \ | 23 | ../../../i18n/hu/gsmtool.ts \ |
24 | ../../../i18n/ja/gsmtool.ts \ | 24 | ../../../i18n/ja/gsmtool.ts \ |
25 | ../../../i18n/ko/gsmtool.ts \ | 25 | ../../../i18n/ko/gsmtool.ts \ |
26 | ../../../i18n/no/gsmtool.ts \ | 26 | ../../../i18n/no/gsmtool.ts \ |
27 | ../../../i18n/pl/gsmtool.ts \ | 27 | ../../../i18n/pl/gsmtool.ts \ |
28 | ../../../i18n/pt/gsmtool.ts \ | 28 | ../../../i18n/pt/gsmtool.ts \ |
29 | ../../../i18n/pt_BR/gsmtool.ts \ | 29 | ../../../i18n/pt_BR/gsmtool.ts \ |
30 | ../../../i18n/sl/gsmtool.ts \ | 30 | ../../../i18n/sl/gsmtool.ts \ |
31 | ../../../i18n/zh_CN/gsmtool.ts \ | 31 | ../../../i18n/zh_CN/gsmtool.ts \ |
32 | ../../../i18n/zh_TW/gsmtool.ts | 32 | ../../../i18n/zh_TW/gsmtool.ts |
33 | 33 | ||
34 | 34 | ||
35 | 35 | ||
36 | include ( $(OPIEDIR)/include.pro ) | 36 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/unsupported/mail2/addresspicker.cpp b/noncore/unsupported/mail2/addresspicker.cpp index 7f32725..a97b33f 100644 --- a/noncore/unsupported/mail2/addresspicker.cpp +++ b/noncore/unsupported/mail2/addresspicker.cpp | |||
@@ -1,74 +1,75 @@ | |||
1 | #include <qpushbutton.h> | 1 | #include <qpushbutton.h> |
2 | #include <qmessagebox.h> | 2 | #include <qmessagebox.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | 6 | ||
7 | #include <qpe/resource.h> | 7 | #include <qpe/resource.h> |
8 | 8 | ||
9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
10 | 10 | ||
11 | #include "addresspicker.h" | 11 | #include "addresspicker.h" |
12 | 12 | ||
13 | AddressPicker::AddressPicker(QWidget *parent, const char *name, bool modal, | 13 | AddressPicker::AddressPicker(QWidget *parent, const char *name, bool modal, |
14 | WFlags fl) : AddressPickerBase(parent, name, modal, fl) | 14 | WFlags fl) : AddressPickerBase(parent, name, modal, fl) |
15 | { | 15 | { |
16 | okButton->setIconSet(Resource::loadPixmap("enter")); | 16 | okButton->setIconSet(Resource::loadPixmap("enter")); |
17 | cancelButton->setIconSet(Resource::loadPixmap("editdelete")); | 17 | cancelButton->setIconSet(Resource::loadPixmap("editdelete")); |
18 | 18 | ||
19 | connect(okButton, SIGNAL(clicked()), SLOT(accept())); | 19 | connect(okButton, SIGNAL(clicked()), SLOT(accept())); |
20 | connect(cancelButton, SIGNAL(clicked()), SLOT(close())); | 20 | connect(cancelButton, SIGNAL(clicked()), SLOT(close())); |
21 | 21 | ||
22 | QFile f((QString) getenv("HOME") + "/Applications/" | 22 | QFile f((QString) getenv("HOME") + "/Applications/" |
23 | + "addressbook/addressbook.xml"); | 23 | + "addressbook/addressbook.xml"); |
24 | 24 | ||
25 | if (f.open(IO_ReadOnly)) { | 25 | if (f.open(IO_ReadOnly)) { |
26 | QTextStream stream(&f); | 26 | QTextStream stream(&f); |
27 | stream.setEncoding( QTextStream::UnicodeUTF8 ); | ||
27 | QString content; | 28 | QString content; |
28 | while (!f.atEnd()) content += stream.readLine() + "\n"; | 29 | while (!f.atEnd()) content += stream.readLine() + "\n"; |
29 | QStringList lines = QStringList::split(QRegExp("\\n"), content); | 30 | QStringList lines = QStringList::split(QRegExp("\\n"), content); |
30 | QStringList::Iterator it; | 31 | QStringList::Iterator it; |
31 | for (it = lines.begin(); it != lines.end(); it++) { | 32 | for (it = lines.begin(); it != lines.end(); it++) { |
32 | if ((*it).find(QRegExp("^<Contact.*")) != -1) { | 33 | if ((*it).find(QRegExp("^<Contact.*")) != -1) { |
33 | int pos = (*it).find("FirstName=\""); | 34 | int pos = (*it).find("FirstName=\""); |
34 | QString fname; | 35 | QString fname; |
35 | if (pos != -1) { | 36 | if (pos != -1) { |
36 | int i = 1; | 37 | int i = 1; |
37 | QChar c; | 38 | QChar c; |
38 | while (c != '"') { | 39 | while (c != '"') { |
39 | c = (*it)[pos + 10 + i]; | 40 | c = (*it)[pos + 10 + i]; |
40 | if (c != '"') fname += c; | 41 | if (c != '"') fname += c; |
41 | i++; | 42 | i++; |
42 | } | 43 | } |
43 | } | 44 | } |
44 | pos = (*it).find("LastName=\""); | 45 | pos = (*it).find("LastName=\""); |
45 | QString lname; | 46 | QString lname; |
46 | if (pos != -1) { | 47 | if (pos != -1) { |
47 | int i = 1; | 48 | int i = 1; |
48 | QChar c; | 49 | QChar c; |
49 | while (c != '"') { | 50 | while (c != '"') { |
50 | c = (*it)[pos + 9 + i]; | 51 | c = (*it)[pos + 9 + i]; |
51 | if (c != '"') lname += c; | 52 | if (c != '"') lname += c; |
52 | i++; | 53 | i++; |
53 | } | 54 | } |
54 | } | 55 | } |
55 | pos = (*it).find("DefaultEmail=\""); | 56 | pos = (*it).find("DefaultEmail=\""); |
56 | QString email; | 57 | QString email; |
57 | if (pos != -1) { | 58 | if (pos != -1) { |
58 | int i = 1; | 59 | int i = 1; |
59 | QChar c; | 60 | QChar c; |
60 | while (c != '"') { | 61 | while (c != '"') { |
61 | c = (*it)[pos + 13 + i]; | 62 | c = (*it)[pos + 13 + i]; |
62 | if (c != '"') email += c; | 63 | if (c != '"') email += c; |
63 | i++; | 64 | i++; |
64 | } | 65 | } |
65 | } | 66 | } |
66 | QString tname, temail; | 67 | QString tname, temail; |
67 | if (!fname.isEmpty()) tname += fname; | 68 | if (!fname.isEmpty()) tname += fname; |
68 | if (!lname.isEmpty()) tname += fname.isEmpty() ? lname : (" " + lname); | 69 | if (!lname.isEmpty()) tname += fname.isEmpty() ? lname : (" " + lname); |
69 | if (!email.isEmpty()) temail += tname.isEmpty() ? email : (" <" + email + ">"); | 70 | if (!email.isEmpty()) temail += tname.isEmpty() ? email : (" <" + email + ">"); |
70 | if (!email.isEmpty()) addressList->insertItem(tname + temail); | 71 | if (!email.isEmpty()) addressList->insertItem(tname + temail); |
71 | } | 72 | } |
72 | } | 73 | } |
73 | } | 74 | } |
74 | if (addressList->count() <= 0) { | 75 | if (addressList->count() <= 0) { |
diff --git a/noncore/unsupported/mail2/bend/opie-mailapplet.control b/noncore/unsupported/mail2/bend/opie-mailapplet.control index e5d3c6e..d618643 100644 --- a/noncore/unsupported/mail2/bend/opie-mailapplet.control +++ b/noncore/unsupported/mail2/bend/opie-mailapplet.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-mailapplet | 1 | Package: opie-mailapplet |
2 | Files: plugins/applets/libbend.so* | 2 | Files: plugins/applets/libbend.so* |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Constantin Bergemann <cbergemann@lisa.de> | 5 | Maintainer: Constantin Bergemann <cbergemann@lisa.de> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 0.0.9-$SUB_VERSION | 7 | Version: $QPE_VERSION$EXTRAVERSION |
8 | Depends: task-opie-minimal libopie1 opie-mail2 | 8 | Depends: task-opie-minimal, libopie1, opie-mail2 |
9 | Description: A Biff-Like mailchecker | 9 | Description: A Biff-Like mailchecker |
10 | License: LGPL | 10 | License: LGPL |
diff --git a/noncore/unsupported/mail2/opie-mail2.control b/noncore/unsupported/mail2/opie-mail2.control index 7f8aeb6..976dc0b 100644 --- a/noncore/unsupported/mail2/opie-mail2.control +++ b/noncore/unsupported/mail2/opie-mail2.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opie-mail2 | 1 | Package: opie-mail2 |
2 | Files: bin/mail $OPIEDIR/lib/libmail.so* apps/1Pim/mail.desktop pics/mail/*.png sounds/mail/*.wav | 2 | Files: bin/mail $OPIEDIR/lib/libmail.so* apps/1Pim/mail.desktop pics/mail/*.png sounds/mail/*.wav |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Constantin Bergemann <cbergemann@lisa.de> | 5 | Maintainer: Constantin Bergemann <cbergemann@lisa.de> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 0.0.9-$SUB_VERSION | 7 | Version: $QPE_VERSION$EXTRAVERSION |
8 | Depends: task-opie-minimal, libopie1 | 8 | Depends: task-opie-minimal, libopie1 |
9 | Description: An IMAP mail client | 9 | Description: An IMAP mail client |
10 | License: LGPL | 10 | License: LGPL |
diff --git a/noncore/unsupported/mailit/opie-mailit.control b/noncore/unsupported/mailit/opie-mailit.control index 65b5b36..77d4102 100644 --- a/noncore/unsupported/mailit/opie-mailit.control +++ b/noncore/unsupported/mailit/opie-mailit.control | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-mailit | 1 | Package: opie-mailit |
2 | Files: bin/mailit apps/1Pim/mailit.desktop pics/mailit | 2 | Files: bin/mailit apps/1Pim/mailit.desktop pics/mailit |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie | 4 | Section: opie |
5 | Maintainer: L.J. Potter <llornkcor@handhelds.org> | 5 | Maintainer: L.J. Potter <llornkcor@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $OPIE_VERSION-$SUB_VERSION | 7 | Version: $QPE_VERSION$EXTRAVERSION |
8 | Description: EMail | 8 | Description: EMail |
9 | A simple POP3 email client for the Opie environment. | 9 | A simple POP3 email client for the Opie environment. |
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 | |||
@@ -41,1000 +41,1013 @@ | |||
41 | #include <qdict.h> | 41 | #include <qdict.h> |
42 | #include <qtimer.h> | 42 | #include <qtimer.h> |
43 | #include <qapplication.h> | 43 | #include <qapplication.h> |
44 | #include <qclipboard.h> | 44 | #include <qclipboard.h> |
45 | 45 | ||
46 | //#define QPDFDBG(x) x // special debug mode | 46 | //#define QPDFDBG(x) x // special debug mode |
47 | #define QPDFDBG(x) // normal compilation | 47 | #define QPDFDBG(x) // normal compilation |
48 | 48 | ||
49 | 49 | ||
50 | //------------------------------------------------------------------------ | 50 | //------------------------------------------------------------------------ |
51 | // Constants and macros | 51 | // Constants and macros |
52 | //------------------------------------------------------------------------ | 52 | //------------------------------------------------------------------------ |
53 | 53 | ||
54 | 54 | ||
55 | static inline QColor q_col ( const GfxRGB &rgb ) | 55 | static inline QColor q_col ( const GfxRGB &rgb ) |
56 | { | 56 | { |
57 | 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 )); |
58 | } | 58 | } |
59 | 59 | ||
60 | 60 | ||
61 | //------------------------------------------------------------------------ | 61 | //------------------------------------------------------------------------ |
62 | // Font substitutions | 62 | // Font substitutions |
63 | //------------------------------------------------------------------------ | 63 | //------------------------------------------------------------------------ |
64 | 64 | ||
65 | struct QOutFontSubst { | 65 | struct QOutFontSubst { |
66 | char * m_name; | 66 | char * m_name; |
67 | char * m_sname; | 67 | char * m_sname; |
68 | bool m_bold; | 68 | bool m_bold; |
69 | bool m_italic; | 69 | bool m_italic; |
70 | QFont::StyleHint m_hint; | 70 | QFont::StyleHint m_hint; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | static QOutFontSubst qStdFonts [] = { | 73 | static QOutFontSubst qStdFonts [] = { |
74 | { "Helvetica", "Helvetica", false, false, QFont::Helvetica }, | 74 | { "Helvetica", "Helvetica", false, false, QFont::Helvetica }, |
75 | { "Helvetica-Oblique", "Helvetica", false, true, QFont::Helvetica }, | 75 | { "Helvetica-Oblique", "Helvetica", false, true, QFont::Helvetica }, |
76 | { "Helvetica-Bold", "Helvetica", true, false, QFont::Helvetica }, | 76 | { "Helvetica-Bold", "Helvetica", true, false, QFont::Helvetica }, |
77 | { "Helvetica-BoldOblique", "Helvetica", true, true, QFont::Helvetica }, | 77 | { "Helvetica-BoldOblique", "Helvetica", true, true, QFont::Helvetica }, |
78 | { "Times-Roman", "Times", false, false, QFont::Times }, | 78 | { "Times-Roman", "Times", false, false, QFont::Times }, |
79 | { "Times-Italic", "Times", false, true, QFont::Times }, | 79 | { "Times-Italic", "Times", false, true, QFont::Times }, |
80 | { "Times-Bold", "Times", true, false, QFont::Times }, | 80 | { "Times-Bold", "Times", true, false, QFont::Times }, |
81 | { "Times-BoldItalic", "Times", true, true, QFont::Times }, | 81 | { "Times-BoldItalic", "Times", true, true, QFont::Times }, |
82 | { "Courier", "Courier", false, false, QFont::Courier }, | 82 | { "Courier", "Courier", false, false, QFont::Courier }, |
83 | { "Courier-Oblique", "Courier", false, true, QFont::Courier }, | 83 | { "Courier-Oblique", "Courier", false, true, QFont::Courier }, |
84 | { "Courier-Bold", "Courier", true, false, QFont::Courier }, | 84 | { "Courier-Bold", "Courier", true, false, QFont::Courier }, |
85 | { "Courier-BoldOblique", "Courier", true, true, QFont::Courier }, | 85 | { "Courier-BoldOblique", "Courier", true, true, QFont::Courier }, |
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 | ||
93 | 93 | ||
94 | 94 | ||
95 | 95 | ||
96 | 96 | ||
97 | 97 | ||
98 | 98 | ||
99 | QFont QOutputDev::matchFont ( GfxFont *gfxFont, fp_t m11, fp_t m12, fp_t m21, fp_t m22 ) | 99 | QFont 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 |
111 | int size = lrint ( sqrt ( m21 * m21 + m22 * m22 )); | 111 | int size = lrint ( sqrt ( m21 * m21 + m22 * m22 )); |
112 | 112 | ||
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", | 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", |
114 | (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ), | 114 | (( gfxFont-> getName ( )) ? gfxFont-> getName ( )-> getCString ( ) : "<n/a>" ), |
115 | size, | 115 | size, |
116 | gfxFont-> isBold ( ), | 116 | gfxFont-> isBold ( ), |
117 | gfxFont-> isItalic ( ), | 117 | gfxFont-> isItalic ( ), |
118 | gfxFont-> isFixedWidth ( ), | 118 | gfxFont-> isFixedWidth ( ), |
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>" ); |
127 | 127 | ||
128 | QFont f; | 128 | QFont f; |
129 | f. setPixelSize ( size > 0 ? size : 8 ); // type3 fonts misbehave sometimes | 129 | f. setPixelSize ( size > 0 ? size : 8 ); // type3 fonts misbehave sometimes |
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" )) |
162 | f. setWeight ( QFont::DemiBold ); | 162 | f. setWeight ( QFont::DemiBold ); |
163 | if ( fname. contains ( "Light" )) | 163 | if ( fname. contains ( "Light" )) |
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 | ||
175 | 175 | ||
176 | 176 | ||
177 | //------------------------------------------------------------------------ | 177 | //------------------------------------------------------------------------ |
178 | // QOutputDev | 178 | // QOutputDev |
179 | //------------------------------------------------------------------------ | 179 | //------------------------------------------------------------------------ |
180 | 180 | ||
181 | QOutputDev::QOutputDev ( QWidget *parent, const char *name, int flags ) : QScrollView ( parent, name, WRepaintNoErase | WResizeNoErase | flags ) | 181 | QOutputDev::QOutputDev ( QWidget *parent, const char *name, int flags ) : QScrollView ( parent, name, WRepaintNoErase | WResizeNoErase | flags ) |
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 | ||
190 | QOutputDev::~QOutputDev ( ) | 190 | QOutputDev::~QOutputDev ( ) |
191 | { | 191 | { |
192 | delete m_painter; | 192 | delete m_painter; |
193 | delete m_pixmap; | 193 | delete m_pixmap; |
194 | delete m_text; | 194 | delete m_text; |
195 | } | 195 | } |
196 | 196 | ||
197 | 197 | ||
198 | void QOutputDev::startPage ( int /*pageNum*/, GfxState *state ) | 198 | void 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 | ||
216 | void QOutputDev::endPage ( ) | 216 | void 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 | ||
226 | void QOutputDev::drawLink ( Link *link, Catalog */*catalog*/ ) | 233 | void 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 ); |
241 | m_painter-> setPen ( oldpen ); | 248 | m_painter-> setPen ( oldpen ); |
242 | } | 249 | } |
243 | } | 250 | } |
244 | 251 | ||
245 | void QOutputDev::saveState ( GfxState */*state*/ ) | 252 | void 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 | ||
252 | void QOutputDev::restoreState ( GfxState */*state*/ ) | 262 | void 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 | ||
261 | void QOutputDev::updateAll ( GfxState *state ) | 274 | void QOutputDev::updateAll ( GfxState *state ) |
262 | { | 275 | { |
263 | updateLineAttrs ( state, gTrue ); | 276 | updateLineAttrs ( state, gTrue ); |
264 | //updateFlatness ( state ); | 277 | //updateFlatness ( state ); |
265 | //updateMiterLimit ( state ); | 278 | //updateMiterLimit ( state ); |
266 | updateFillColor ( state ); | 279 | updateFillColor ( state ); |
267 | updateStrokeColor ( state ); | 280 | updateStrokeColor ( state ); |
268 | updateFont ( state ); | 281 | updateFont ( state ); |
269 | } | 282 | } |
270 | 283 | ||
271 | void QOutputDev::updateCTM ( GfxState *state, fp_t /*m11*/, fp_t /*m12*/, fp_t /*m21*/, fp_t /*m22*/, fp_t /*m31*/, fp_t /*m32*/ ) | 284 | void 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 | ||
276 | void QOutputDev::updateLineDash ( GfxState *state ) | 289 | void QOutputDev::updateLineDash ( GfxState *state ) |
277 | { | 290 | { |
278 | updateLineAttrs ( state, gTrue ); | 291 | updateLineAttrs ( state, gTrue ); |
279 | } | 292 | } |
280 | 293 | ||
281 | void QOutputDev::updateFlatness ( GfxState */*state*/ ) | 294 | void 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 | ||
287 | void QOutputDev::updateLineJoin ( GfxState *state ) | 300 | void QOutputDev::updateLineJoin ( GfxState *state ) |
288 | { | 301 | { |
289 | updateLineAttrs ( state, gFalse ); | 302 | updateLineAttrs ( state, gFalse ); |
290 | } | 303 | } |
291 | 304 | ||
292 | void QOutputDev::updateLineCap ( GfxState *state ) | 305 | void QOutputDev::updateLineCap ( GfxState *state ) |
293 | { | 306 | { |
294 | updateLineAttrs ( state, gFalse ); | 307 | updateLineAttrs ( state, gFalse ); |
295 | } | 308 | } |
296 | 309 | ||
297 | // unimplemented | 310 | // unimplemented |
298 | void QOutputDev::updateMiterLimit ( GfxState */*state*/ ) | 311 | void QOutputDev::updateMiterLimit ( GfxState */*state*/ ) |
299 | { | 312 | { |
300 | QPDFDBG( printf ( "updateMiterLimit not supported !\n" )); | 313 | QPDFDBG( printf ( "updateMiterLimit not supported !\n" )); |
301 | } | 314 | } |
302 | 315 | ||
303 | void QOutputDev::updateLineWidth ( GfxState *state ) | 316 | void QOutputDev::updateLineWidth ( GfxState *state ) |
304 | { | 317 | { |
305 | updateLineAttrs ( state, gFalse ); | 318 | updateLineAttrs ( state, gFalse ); |
306 | } | 319 | } |
307 | 320 | ||
308 | void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash ) | 321 | void QOutputDev::updateLineAttrs ( GfxState *state, GBool updateDash ) |
309 | { | 322 | { |
310 | fp_t *dashPattern; | 323 | fp_t *dashPattern; |
311 | int dashLength; | 324 | int dashLength; |
312 | fp_t dashStart; | 325 | fp_t dashStart; |
313 | 326 | ||
314 | Qt::PenCapStyle cap; | 327 | Qt::PenCapStyle cap; |
315 | Qt::PenJoinStyle join; | 328 | Qt::PenJoinStyle join; |
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; |
323 | case 2: cap = SquareCap; break; | 336 | case 2: cap = SquareCap; break; |
324 | default: | 337 | default: |
325 | qWarning ( "Bad line cap style (%d)\n", state-> getLineCap ( )); | 338 | qWarning ( "Bad line cap style (%d)\n", state-> getLineCap ( )); |
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; |
333 | case 2: join = BevelJoin; break; | 346 | case 2: join = BevelJoin; break; |
334 | default: | 347 | default: |
335 | qWarning ( "Bad line join style (%d)\n", state->getLineJoin ( )); | 348 | qWarning ( "Bad line join style (%d)\n", state->getLineJoin ( )); |
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 ( ); |
343 | GfxRGB rgb; | 356 | GfxRGB rgb; |
344 | 357 | ||
345 | state-> getStrokeRGB ( &rgb ); | 358 | state-> getStrokeRGB ( &rgb ); |
346 | oldcol = q_col ( rgb ); | 359 | oldcol = q_col ( rgb ); |
347 | 360 | ||
348 | m_painter-> setPen ( QPen ( oldcol, width, dashLength > 0 ? DashLine : SolidLine, cap, join )); | 361 | m_painter-> setPen ( QPen ( oldcol, width, dashLength > 0 ? DashLine : SolidLine, cap, join )); |
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; |
356 | for ( int i = 0; i < dashLength; ++i ) { | 369 | for ( int i = 0; i < dashLength; ++i ) { |
357 | dashList[i] = xoutRound(state->transformWidth(dashPattern[i])); | 370 | dashList[i] = xoutRound(state->transformWidth(dashPattern[i])); |
358 | if (dashList[i] == 0) | 371 | if (dashList[i] == 0) |
359 | dashList[i] = 1; | 372 | dashList[i] = 1; |
360 | } | 373 | } |
361 | XSetDashes(display, strokeGC, xoutRound(dashStart), dashList, dashLength); | 374 | XSetDashes(display, strokeGC, xoutRound(dashStart), dashList, dashLength); |
362 | */ | 375 | */ |
363 | } | 376 | } |
364 | } | 377 | } |
365 | 378 | ||
366 | void QOutputDev::updateFillColor ( GfxState *state ) | 379 | void QOutputDev::updateFillColor ( GfxState *state ) |
367 | { | 380 | { |
368 | GfxRGB rgb; | 381 | GfxRGB rgb; |
369 | state-> getFillRGB ( &rgb ); | 382 | state-> getFillRGB ( &rgb ); |
370 | 383 | ||
371 | m_painter-> setBrush ( q_col ( rgb )); | 384 | m_painter-> setBrush ( q_col ( rgb )); |
372 | } | 385 | } |
373 | 386 | ||
374 | void QOutputDev::updateStrokeColor ( GfxState *state ) | 387 | void 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 | ||
384 | void QOutputDev::updateFont ( GfxState *state ) | 397 | void 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 | ||
402 | void QOutputDev::stroke ( GfxState *state ) | 415 | void QOutputDev::stroke ( GfxState *state ) |
403 | { | 416 | { |
404 | QPointArray points; | 417 | QPointArray points; |
405 | QArray<int> lengths; | 418 | QArray<int> lengths; |
406 | 419 | ||
407 | // transform points | 420 | // transform points |
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 | ||
430 | void QOutputDev::fill ( GfxState *state ) | 443 | void QOutputDev::fill ( GfxState *state ) |
431 | { | 444 | { |
432 | doFill ( state, true ); | 445 | doFill ( state, true ); |
433 | } | 446 | } |
434 | 447 | ||
435 | void QOutputDev::eoFill ( GfxState *state ) | 448 | void QOutputDev::eoFill ( GfxState *state ) |
436 | { | 449 | { |
437 | doFill ( state, false ); | 450 | doFill ( state, false ); |
438 | } | 451 | } |
439 | 452 | ||
440 | // | 453 | // |
441 | // X doesn't color the pixels on the right-most and bottom-most | 454 | // X doesn't color the pixels on the right-most and bottom-most |
442 | // borders of a polygon. This means that one-pixel-thick polygons | 455 | // borders of a polygon. This means that one-pixel-thick polygons |
443 | // are not colored at all. I think this is supposed to be a | 456 | // are not colored at all. I think this is supposed to be a |
444 | // feature, but I can't figure out why. So after it fills a | 457 | // feature, but I can't figure out why. So after it fills a |
445 | // polygon, it also draws lines around the border. This is done | 458 | // polygon, it also draws lines around the border. This is done |
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 | // |
449 | void QOutputDev::doFill ( GfxState *state, bool winding ) | 462 | void QOutputDev::doFill ( GfxState *state, bool winding ) |
450 | { | 463 | { |
451 | QPointArray points; | 464 | QPointArray points; |
452 | QArray<int> lengths; | 465 | QArray<int> lengths; |
453 | 466 | ||
454 | // transform points | 467 | // transform points |
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 ); |
478 | 491 | ||
479 | qApp-> processEvents ( ); | 492 | qApp-> processEvents ( ); |
480 | } | 493 | } |
481 | 494 | ||
482 | void QOutputDev::clip ( GfxState *state ) | 495 | void QOutputDev::clip ( GfxState *state ) |
483 | { | 496 | { |
484 | doClip ( state, true ); | 497 | doClip ( state, true ); |
485 | } | 498 | } |
486 | 499 | ||
487 | void QOutputDev::eoClip ( GfxState *state ) | 500 | void QOutputDev::eoClip ( GfxState *state ) |
488 | { | 501 | { |
489 | doClip ( state, false ); | 502 | doClip ( state, false ); |
490 | } | 503 | } |
491 | 504 | ||
492 | void QOutputDev::doClip ( GfxState *state, bool winding ) | 505 | void QOutputDev::doClip ( GfxState *state, bool winding ) |
493 | { | 506 | { |
494 | QPointArray points; | 507 | QPointArray points; |
495 | QArray<int> lengths; | 508 | QArray<int> lengths; |
496 | 509 | ||
497 | // transform points | 510 | // transform points |
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 ( ); |
533 | } | 546 | } |
534 | 547 | ||
535 | // | 548 | // |
536 | // Transform points in the path and convert curves to line segments. | 549 | // Transform points in the path and convert curves to line segments. |
537 | // Builds a set of subpaths and returns the number of subpaths. | 550 | // Builds a set of subpaths and returns the number of subpaths. |
538 | // If <fillHack> is set, close any unclosed subpaths and activate a | 551 | // If <fillHack> is set, close any unclosed subpaths and activate a |
539 | // kludge for polygon fills: First, it divides up the subpaths into | 552 | // kludge for polygon fills: First, it divides up the subpaths into |
540 | // non-overlapping polygons by simply comparing bounding rectangles. | 553 | // non-overlapping polygons by simply comparing bounding rectangles. |
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 | // |
544 | int QOutputDev::convertPath ( GfxState *state, QPointArray &points, QArray<int> &lengths ) | 557 | int 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 ( ); |
548 | 561 | ||
549 | lengths. resize ( n ); | 562 | lengths. resize ( n ); |
550 | 563 | ||
551 | // do each subpath | 564 | // do each subpath |
552 | for ( int i = 0; i < n; i++ ) { | 565 | for ( int i = 0; i < n; i++ ) { |
553 | // transform the points | 566 | // transform the points |
554 | lengths [i] = convertSubpath ( state, path-> getSubpath ( i ), points ); | 567 | lengths [i] = convertSubpath ( state, path-> getSubpath ( i ), points ); |
555 | } | 568 | } |
556 | 569 | ||
557 | return n; | 570 | return n; |
558 | } | 571 | } |
559 | 572 | ||
560 | // | 573 | // |
561 | // Transform points in a single subpath and convert curves to line | 574 | // Transform points in a single subpath and convert curves to line |
562 | // segments. | 575 | // segments. |
563 | // | 576 | // |
564 | int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points ) | 577 | int QOutputDev::convertSubpath ( GfxState *state, GfxSubpath *subpath, QPointArray &points ) |
565 | { | 578 | { |
566 | int oldcnt = points. count ( ); | 579 | int oldcnt = points. count ( ); |
567 | 580 | ||
568 | fp_t x0, y0, x1, y1, x2, y2, x3, y3; | 581 | fp_t x0, y0, x1, y1, x2, y2, x3, y3; |
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 | } |
605 | return points. count ( ) - oldcnt; | 618 | return points. count ( ) - oldcnt; |
606 | } | 619 | } |
607 | 620 | ||
608 | 621 | ||
609 | void QOutputDev::beginString ( GfxState *state, GString */*s*/ ) | 622 | void QOutputDev::beginString ( GfxState *state, GString */*s*/ ) |
610 | { | 623 | { |
611 | m_text-> beginString ( state ); | 624 | m_text-> beginString ( state ); |
612 | } | 625 | } |
613 | 626 | ||
614 | void QOutputDev::endString ( GfxState */*state*/ ) | 627 | void QOutputDev::endString ( GfxState */*state*/ ) |
615 | { | 628 | { |
616 | m_text-> endString ( ); | 629 | m_text-> endString ( ); |
617 | } | 630 | } |
618 | 631 | ||
619 | void QOutputDev::drawChar ( GfxState *state, fp_t x, fp_t y, | 632 | void 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 | ||
628 | // check for invisible text -- this is used by Acrobat Capture | 641 | // check for invisible text -- this is used by Acrobat Capture |
629 | if (( state-> getRender ( ) & 3 ) == 3 ) { | 642 | if (( state-> getRender ( ) & 3 ) == 3 ) { |
630 | return; | 643 | return; |
631 | } | 644 | } |
632 | 645 | ||
633 | x -= originX; | 646 | x -= originX; |
634 | y -= originY; | 647 | y -= originY; |
635 | state-> transform ( x, y, &x1, &y1 ); | 648 | state-> transform ( x, y, &x1, &y1 ); |
636 | state-> transformDelta ( dx, dy, &dx1, &dy1 ); | 649 | state-> transformDelta ( dx, dy, &dx1, &dy1 ); |
637 | 650 | ||
638 | 651 | ||
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 | } |
649 | else { | 662 | else { |
650 | str [i] = ' '; | 663 | str [i] = ' '; |
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 )); |
712 | } | 725 | } |
713 | qApp-> processEvents ( ); | 726 | qApp-> processEvents ( ); |
714 | } | 727 | } |
715 | 728 | ||
716 | 729 | ||
717 | 730 | ||
718 | void QOutputDev::drawImageMask ( GfxState *state, Object */*ref*/, Stream *str, int width, int height, GBool invert, GBool inlineImg ) | 731 | void 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 ); |
729 | for ( int i = 0; i < j; i++ ) | 742 | for ( int i = 0; i < j; i++ ) |
730 | str->getChar(); | 743 | str->getChar(); |
731 | 744 | ||
732 | str->close(); | 745 | str->close(); |
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 )); |
746 | 759 | ||
747 | // initialize the image stream | 760 | // initialize the image stream |
748 | ImageStream *imgStr = new ImageStream ( str, width, 1, 1 ); | 761 | ImageStream *imgStr = new ImageStream ( str, width, 1, 1 ); |
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 | ||
788 | #ifdef QWS | 801 | #ifdef QWS |
789 | QPixmap pm; | 802 | QPixmap pm; |
790 | pm. convertFromImage ( img ); | 803 | pm. convertFromImage ( img ); |
791 | m_painter-> drawPixmap ( 0, 0, pm ); | 804 | m_painter-> drawPixmap ( 0, 0, pm ); |
792 | #else | 805 | #else |
793 | m_painter-> drawImage ( QPoint ( 0, 0 ), img ); | 806 | m_painter-> drawImage ( QPoint ( 0, 0 ), img ); |
794 | #endif | 807 | #endif |
795 | 808 | ||
796 | m_painter-> setWorldMatrix ( oldmat ); | 809 | m_painter-> setWorldMatrix ( oldmat ); |
797 | 810 | ||
798 | #else | 811 | #else |
799 | if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { | 812 | if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { |
800 | QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); | 813 | QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); |
801 | } | 814 | } |
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; |
812 | } | 825 | } |
813 | if ( h < 0 ) { | 826 | if ( h < 0 ) { |
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 | ||
832 | void QOutputDev::drawImage(GfxState *state, Object */*ref*/, Stream *str, int width, int height, GfxImageColorMap *colorMap, int *maskColors, GBool inlineImg ) | 845 | void 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; |
839 | nBits = colorMap-> getBits ( ); | 852 | nBits = colorMap-> getBits ( ); |
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 ); |
850 | for ( int i = 0; i < j; i++ ) | 863 | for ( int i = 0; i < j; i++ ) |
851 | str->getChar(); | 864 | str->getChar(); |
852 | 865 | ||
853 | str->close(); | 866 | str->close(); |
854 | } | 867 | } |
855 | return; | 868 | return; |
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 | ||
863 | QPDFDBG( printf ( "IMAGE (%dx%d)\n", width, height )); | 876 | QPDFDBG( printf ( "IMAGE (%dx%d)\n", width, height )); |
864 | 877 | ||
865 | // initialize the image stream | 878 | // initialize the image stream |
866 | ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits ); | 879 | ImageStream *imgStr = new ImageStream ( str, width, nComps, nBits ); |
867 | imgStr-> reset ( ); | 880 | imgStr-> reset ( ); |
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 ( ); |
915 | m_painter-> setWorldMatrix ( mat, true ); | 928 | m_painter-> setWorldMatrix ( mat, true ); |
916 | 929 | ||
917 | #ifdef QWS | 930 | #ifdef QWS |
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 ); |
926 | 939 | ||
927 | #else // QT_NO_TRANSFORMATIONS | 940 | #else // QT_NO_TRANSFORMATIONS |
928 | 941 | ||
929 | if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { | 942 | if (( ctm [1] < -0.1 ) || ( ctm [1] > 0.1 ) || ( ctm [2] < -0.1 ) || ( ctm [2] > 0.1 )) { |
930 | QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); | 943 | QPDFDBG( printf ( "### ROTATED / SHEARED / ETC -- CANNOT DISPLAY THIS IMAGE\n" )); |
931 | } | 944 | } |
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; |
942 | } | 955 | } |
943 | if ( h < 0 ) { | 956 | if ( h < 0 ) { |
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 | ||
958 | delete imgStr; | 971 | delete imgStr; |
959 | qApp-> processEvents ( ); | 972 | qApp-> processEvents ( ); |
960 | } | 973 | } |
961 | 974 | ||
962 | 975 | ||
963 | 976 | ||
964 | bool QOutputDev::findText ( const QString &str, QRect &r, bool top, bool bottom ) | 977 | bool QOutputDev::findText ( const QString &str, QRect &r, bool top, bool bottom ) |
965 | { | 978 | { |
966 | int l, t, w, h; | 979 | int l, t, w, h; |
967 | r. rect ( &l, &t, &w, &h ); | 980 | r. rect ( &l, &t, &w, &h ); |
968 | 981 | ||
969 | bool res = findText ( str, l, t, w, h, top, bottom ); | 982 | bool res = findText ( str, l, t, w, h, top, bottom ); |
970 | 983 | ||
971 | r. setRect ( l, t, w, h ); | 984 | r. setRect ( l, t, w, h ); |
972 | return res; | 985 | return res; |
973 | } | 986 | } |
974 | 987 | ||
975 | bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h, bool top, bool bottom ) | 988 | bool QOutputDev::findText ( const QString &str, int &l, int &t, int &w, int &h, bool top, bool bottom ) |
976 | { | 989 | { |
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 | ||
984 | fp_t x1 = (fp_t) l; | 997 | fp_t x1 = (fp_t) l; |
985 | fp_t y1 = (fp_t) t; | 998 | fp_t y1 = (fp_t) t; |
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; |
993 | h = lrint ( y2 ) - t + 1; | 1006 | h = lrint ( y2 ) - t + 1; |
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 | ||
1001 | GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax ) | 1014 | GBool QOutputDev::findText ( Unicode *s, int len, GBool top, GBool bottom, int *xMin, int *yMin, int *xMax, int *yMax ) |
1002 | { | 1015 | { |
1003 | bool found = false; | 1016 | bool found = false; |
1004 | fp_t xMin1 = (double) *xMin; | 1017 | fp_t xMin1 = (double) *xMin; |
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 ); |
1012 | *yMin = lrint ( yMin1 ); | 1025 | *yMin = lrint ( yMin1 ); |
1013 | *yMax = lrint ( yMax1 ); | 1026 | *yMax = lrint ( yMax1 ); |
1014 | found = true; | 1027 | found = true; |
1015 | } | 1028 | } |
1016 | return found; | 1029 | return found; |
1017 | } | 1030 | } |
1018 | 1031 | ||
1019 | QString QOutputDev::getText ( int l, int t, int w, int h ) | 1032 | QString QOutputDev::getText ( int l, int t, int w, int h ) |
1020 | { | 1033 | { |
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 | ||
1027 | QString QOutputDev::getText ( const QRect &r ) | 1040 | QString 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 | } |
1031 | 1044 | ||
1032 | 1045 | ||
1033 | 1046 | ||
1034 | void QOutputDev::drawContents ( QPainter *p, int clipx, int clipy, int clipw, int cliph ) | 1047 | void QOutputDev::drawContents ( QPainter *p, int clipx, int clipy, int clipw, int cliph ) |
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 | |||
@@ -1,9 +1,9 @@ | |||
1 | Package: opie-qpdf | 1 | Package: opie-qpdf |
2 | Files: bin/qpdf apps/Applications/qpdf.desktop pics/qpdf/qpdf_icon.png | 2 | Files: bin/qpdf apps/Applications/qpdf.desktop pics/qpdf/qpdf_icon.png |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: opie/applications | 4 | Section: opie/applications |
5 | Maintainer: Robert Griebl <sandman@handhelds.org> | 5 | Maintainer: Robert Griebl <sandman@handhelds.org> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: $QPE_VERSION-$SUB_VERSION | ||
8 | Depends: task-opie-minimal, gzip | 7 | Depends: task-opie-minimal, gzip |
9 | Description: A PDF viewer for OPIE. | 8 | Description: A PDF viewer for OPIE. |
9 | Version: $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 | |||
@@ -462,79 +462,79 @@ void QPdfDlg::openFile ( ) | |||
462 | { | 462 | { |
463 | m_tb_menu-> hide ( ); | 463 | m_tb_menu-> hide ( ); |
464 | m_tb_tool-> hide ( ); | 464 | m_tb_tool-> hide ( ); |
465 | m_tb_find-> hide ( ); | 465 | m_tb_find-> hide ( ); |
466 | m_stack-> raiseWidget ( m_filesel ); | 466 | m_stack-> raiseWidget ( m_filesel ); |
467 | } | 467 | } |
468 | 468 | ||
469 | void QPdfDlg::openFile ( const QString &f ) | 469 | void QPdfDlg::openFile ( const QString &f ) |
470 | { | 470 | { |
471 | DocLnk nf; | 471 | DocLnk nf; |
472 | nf. setType ( "application/pdf" ); | 472 | nf. setType ( "application/pdf" ); |
473 | nf. setFile ( f ); | 473 | nf. setFile ( f ); |
474 | QFileInfo fi ( f ); | 474 | QFileInfo fi ( f ); |
475 | nf. setName ( fi. baseName ( )); | 475 | nf. setName ( fi. baseName ( )); |
476 | openFile ( nf ); | 476 | openFile ( nf ); |
477 | } | 477 | } |
478 | 478 | ||
479 | void QPdfDlg::openFile ( const DocLnk &f ) | 479 | void QPdfDlg::openFile ( const DocLnk &f ) |
480 | { | 480 | { |
481 | QString fn = f. file ( ); | 481 | QString fn = f. file ( ); |
482 | QFileInfo fi ( fn ); | 482 | QFileInfo fi ( fn ); |
483 | 483 | ||
484 | if ( fi. exists ( )) { | 484 | if ( fi. exists ( )) { |
485 | delete m_doc; | 485 | delete m_doc; |
486 | 486 | ||
487 | m_doc = new PDFDoc ( new GString ( fn. local8Bit ( )), 0, 0 ); | 487 | m_doc = new PDFDoc ( new GString ( fn. local8Bit ( )), 0, 0 ); |
488 | 488 | ||
489 | if ( m_doc-> isOk ( )) { | 489 | if ( m_doc-> isOk ( )) { |
490 | m_currentdoc = f. name ( ); | 490 | m_currentdoc = f. name ( ); |
491 | int sep = m_currentdoc. findRev ( '/' ); | 491 | int sep = m_currentdoc. findRev ( '/' ); |
492 | if ( sep > 0 ) | 492 | if ( sep > 0 ) |
493 | m_currentdoc = m_currentdoc. mid ( sep + 1 ); | 493 | m_currentdoc = m_currentdoc. mid ( sep + 1 ); |
494 | 494 | ||
495 | m_pages = m_doc-> getNumPages ( ); | 495 | m_pages = m_doc-> getNumPages ( ); |
496 | m_currentpage = 0; | 496 | m_currentpage = 0; |
497 | 497 | ||
498 | QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); | 498 | QTimer::singleShot ( 0, this, SLOT( delayedInit ( ))); |
499 | } | 499 | } |
500 | else { | 500 | else { |
501 | delete m_doc; | 501 | delete m_doc; |
502 | m_doc = 0; | 502 | m_doc = 0; |
503 | 503 | ||
504 | m_currentdoc = QString::null; | 504 | m_currentdoc = QString::null; |
505 | } | 505 | } |
506 | 506 | ||
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 | ||
513 | void QPdfDlg::setDocument ( const QString &f ) | 513 | void QPdfDlg::setDocument ( const QString &f ) |
514 | { | 514 | { |
515 | if ( f. find ( ".desktop", 0, true ) == -1 ) | 515 | if ( f. find ( ".desktop", 0, true ) == -1 ) |
516 | openFile ( f ); | 516 | openFile ( f ); |
517 | else | 517 | else |
518 | openFile ( DocLnk ( f )); | 518 | openFile ( DocLnk ( f )); |
519 | 519 | ||
520 | closeFileSelector ( ); | 520 | closeFileSelector ( ); |
521 | } | 521 | } |
522 | 522 | ||
523 | void QPdfDlg::delayedInit ( ) | 523 | void QPdfDlg::delayedInit ( ) |
524 | { | 524 | { |
525 | closeFileSelector ( ); | 525 | closeFileSelector ( ); |
526 | 526 | ||
527 | m_currentpage = 0; | 527 | m_currentpage = 0; |
528 | m_zoom = 0; | 528 | m_zoom = 0; |
529 | m_renderok = false; | 529 | m_renderok = false; |
530 | 530 | ||
531 | setZoom ( 100 ); | 531 | setZoom ( 100 ); |
532 | gotoPage ( 1 ); | 532 | gotoPage ( 1 ); |
533 | 533 | ||
534 | m_renderok = true; | 534 | m_renderok = true; |
535 | 535 | ||
536 | renderPage ( ); | 536 | renderPage ( ); |
537 | 537 | ||
538 | m_outdev-> setFocus ( ); | 538 | m_outdev-> setFocus ( ); |
539 | } | 539 | } |
540 | 540 | ||