author | pohly <pohly> | 2004-08-26 05:57:55 (UTC) |
---|---|---|
committer | pohly <pohly> | 2004-08-26 05:57:55 (UTC) |
commit | 3f36482d9a6c096fdf5d8ab8831eb736746c0565 (patch) (unidiff) | |
tree | fb213ba05e20c9a02bca3d805f8f5c96c1c45da0 | |
parent | e00962edd9d4be58c6184e5b6c5f6ef07f449689 (diff) | |
download | opie-3f36482d9a6c096fdf5d8ab8831eb736746c0565.zip opie-3f36482d9a6c096fdf5d8ab8831eb736746c0565.tar.gz opie-3f36482d9a6c096fdf5d8ab8831eb736746c0565.tar.bz2 |
removed obsolete static.h and useqpe.h
44 files changed, 21 insertions, 61 deletions
diff --git a/noncore/apps/opie-reader/Aportis.cpp b/noncore/apps/opie-reader/Aportis.cpp index 7528e78..353996c 100644 --- a/noncore/apps/opie-reader/Aportis.cpp +++ b/noncore/apps/opie-reader/Aportis.cpp | |||
@@ -1,198 +1,197 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include "Aportis.h" | 3 | #include "Aportis.h" |
4 | #include "my_list.h" | 4 | #include "my_list.h" |
5 | #include "Bkmks.h" | 5 | #include "Bkmks.h" |
6 | #include "static.h" | ||
7 | 6 | ||
8 | Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ } | 7 | Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ } |
9 | 8 | ||
10 | void Aportis::dePeanut(int& ch) | 9 | void Aportis::dePeanut(int& ch) |
11 | { | 10 | { |
12 | if (peanutfile && ch != EOF) | 11 | if (peanutfile && ch != EOF) |
13 | { | 12 | { |
14 | unsigned char c = ch; | 13 | unsigned char c = ch; |
15 | if (peanutfile) c ^= 0xa5; | 14 | if (peanutfile) c ^= 0xa5; |
16 | ch = c; | 15 | ch = c; |
17 | } | 16 | } |
18 | } | 17 | } |
19 | 18 | ||
20 | CList<Bkmk>* Aportis::getbkmklist() | 19 | CList<Bkmk>* Aportis::getbkmklist() |
21 | { | 20 | { |
22 | /* | 21 | /* |
23 | if (peanutfile) | 22 | if (peanutfile) |
24 | { | 23 | { |
25 | if (nRecs2 > nRecs) | 24 | if (nRecs2 > nRecs) |
26 | { | 25 | { |
27 | CList<Bkmk>* t = new CList<Bkmk>; | 26 | CList<Bkmk>* t = new CList<Bkmk>; |
28 | for (int i = nRecs; i < nRecs2; i++) | 27 | for (int i = nRecs; i < nRecs2; i++) |
29 | { | 28 | { |
30 | char name[17]; | 29 | char name[17]; |
31 | name[16] = '\0'; | 30 | name[16] = '\0'; |
32 | // qDebug("Record:%d, Length:%u",i,recordlength(i)); | 31 | // qDebug("Record:%d, Length:%u",i,recordlength(i)); |
33 | gotorecordnumber(i); | 32 | gotorecordnumber(i); |
34 | fread(name,1,16,fin); | 33 | fread(name,1,16,fin); |
35 | unsigned long lcn; | 34 | unsigned long lcn; |
36 | fread(&lcn,sizeof(lcn),1,fin); | 35 | fread(&lcn,sizeof(lcn),1,fin); |
37 | lcn ^= 0xa5a5a5a5; | 36 | lcn ^= 0xa5a5a5a5; |
38 | lcn = SwapLong(lcn); | 37 | lcn = SwapLong(lcn); |
39 | // qDebug("Bookmark:%s:%u", name,lcn); | 38 | // qDebug("Bookmark:%s:%u", name,lcn); |
40 | tchar tname[17]; | 39 | tchar tname[17]; |
41 | memset(tname, 0, sizeof(tname)); | 40 | memset(tname, 0, sizeof(tname)); |
42 | for (int i = 0; name[i] != 0; i++) | 41 | for (int i = 0; name[i] != 0; i++) |
43 | { | 42 | { |
44 | tname[i] = name[i] ^ 0xa5; | 43 | tname[i] = name[i] ^ 0xa5; |
45 | } | 44 | } |
46 | t->push_back(Bkmk(tname, NULL, lcn)); | 45 | t->push_back(Bkmk(tname, NULL, lcn)); |
47 | } | 46 | } |
48 | return t; | 47 | return t; |
49 | } | 48 | } |
50 | else | 49 | else |
51 | { | 50 | { |
52 | return NULL; | 51 | return NULL; |
53 | } | 52 | } |
54 | } | 53 | } |
55 | */ | 54 | */ |
56 | if (bCompressed != 4) return NULL; | 55 | if (bCompressed != 4) return NULL; |
57 | CList<Bkmk>* t = new CList<Bkmk>; | 56 | CList<Bkmk>* t = new CList<Bkmk>; |
58 | size_t cur = ftell(fin); | 57 | size_t cur = ftell(fin); |
59 | for (int i = 0; i < nRecs2; i++) | 58 | for (int i = 0; i < nRecs2; i++) |
60 | { | 59 | { |
61 | DWORD dwPos; | 60 | DWORD dwPos; |
62 | fseek(fin, 0x56 + 8*i, SEEK_SET); | 61 | fseek(fin, 0x56 + 8*i, SEEK_SET); |
63 | fread(&dwPos, 4, 1, fin); | 62 | fread(&dwPos, 4, 1, fin); |
64 | dwPos = SwapLong(dwPos); | 63 | dwPos = SwapLong(dwPos); |
65 | fseek(fin,dwPos,SEEK_SET); | 64 | fseek(fin,dwPos,SEEK_SET); |
66 | unsigned char ch; | 65 | unsigned char ch; |
67 | fread(&ch,1,1,fin); | 66 | fread(&ch,1,1,fin); |
68 | if (ch != 241) | 67 | if (ch != 241) |
69 | { | 68 | { |
70 | char name[17]; | 69 | char name[17]; |
71 | name[16] = '\0'; | 70 | name[16] = '\0'; |
72 | fseek(fin,dwPos,SEEK_SET); | 71 | fseek(fin,dwPos,SEEK_SET); |
73 | fread(name,1,16,fin); | 72 | fread(name,1,16,fin); |
74 | unsigned long lcn; | 73 | unsigned long lcn; |
75 | fread(&lcn,sizeof(lcn),1,fin); | 74 | fread(&lcn,sizeof(lcn),1,fin); |
76 | lcn = SwapLong(lcn); | 75 | lcn = SwapLong(lcn); |
77 | #ifdef _UNICODE | 76 | #ifdef _UNICODE |
78 | tchar tname[17]; | 77 | tchar tname[17]; |
79 | memset(tname, 0, sizeof(tname)); | 78 | memset(tname, 0, sizeof(tname)); |
80 | for (int i = 0; name[i] != 0; i++) | 79 | for (int i = 0; name[i] != 0; i++) |
81 | { | 80 | { |
82 | tname[i] = name[i]; | 81 | tname[i] = name[i]; |
83 | } | 82 | } |
84 | t->push_back(Bkmk(tname, NULL, lcn)); | 83 | t->push_back(Bkmk(tname, NULL, lcn)); |
85 | #else | 84 | #else |
86 | t->push_back(Bkmk(name,lcn)); | 85 | t->push_back(Bkmk(name,lcn)); |
87 | #endif | 86 | #endif |
88 | } | 87 | } |
89 | } | 88 | } |
90 | fseek(fin, cur, SEEK_SET); | 89 | fseek(fin, cur, SEEK_SET); |
91 | return t; | 90 | return t; |
92 | } | 91 | } |
93 | 92 | ||
94 | int Aportis::OpenFile(const char *src) | 93 | int Aportis::OpenFile(const char *src) |
95 | { | 94 | { |
96 | // printf("In openfile\n"); | 95 | // printf("In openfile\n"); |
97 | int ret = 0; | 96 | int ret = 0; |
98 | html = false; | 97 | html = false; |
99 | mobiimagerec = 0; | 98 | mobiimagerec = 0; |
100 | if (!Cpdb::openpdbfile(src)) return -1; | 99 | if (!Cpdb::openpdbfile(src)) return -1; |
101 | 100 | ||
102 | if (head.creator == 0x64414552 // 'dAER' | 101 | if (head.creator == 0x64414552 // 'dAER' |
103 | || head.type == 0x74584554) // 'tXET') | 102 | || head.type == 0x74584554) // 'tXET') |
104 | { | 103 | { |
105 | } | 104 | } |
106 | else if (memcmp(&head.creator, "PPrs", 4) == 0 && memcmp(&head.type, "PNRd", 4) == 0) | 105 | else if (memcmp(&head.creator, "PPrs", 4) == 0 && memcmp(&head.type, "PNRd", 4) == 0) |
107 | { | 106 | { |
108 | peanutfile = true; | 107 | peanutfile = true; |
109 | } | 108 | } |
110 | else if (memcmp(&head.creator, "MOBI", 4) == 0 && memcmp(&head.type, "BOOK", 4) == 0) | 109 | else if (memcmp(&head.creator, "MOBI", 4) == 0 && memcmp(&head.type, "BOOK", 4) == 0) |
111 | { | 110 | { |
112 | html = true; | 111 | html = true; |
113 | unsigned char vsn; | 112 | unsigned char vsn; |
114 | fseek(fin, recordpos(0)+39, SEEK_SET); | 113 | fseek(fin, recordpos(0)+39, SEEK_SET); |
115 | fread(&vsn, 1, sizeof(vsn), fin); | 114 | fread(&vsn, 1, sizeof(vsn), fin); |
116 | qDebug("Mobi version:%x", vsn); | 115 | qDebug("Mobi version:%x", vsn); |
117 | if (vsn > 2) | 116 | if (vsn > 2) |
118 | { | 117 | { |
119 | fseek(fin, recordpos(0)+110, SEEK_SET); | 118 | fseek(fin, recordpos(0)+110, SEEK_SET); |
120 | fread(&mobiimagerec, 1, sizeof(mobiimagerec), fin); | 119 | fread(&mobiimagerec, 1, sizeof(mobiimagerec), fin); |
121 | mobiimagerec = ntohs(mobiimagerec)-1; | 120 | mobiimagerec = ntohs(mobiimagerec)-1; |
122 | } | 121 | } |
123 | } | 122 | } |
124 | else | 123 | else |
125 | { | 124 | { |
126 | return -2; | 125 | return -2; |
127 | } | 126 | } |
128 | 127 | ||
129 | nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1; | 128 | nRecs2 = nRecs = SwapWord(head.recordList.numRecords) - 1; |
130 | 129 | ||
131 | struct stat _stat; | 130 | struct stat _stat; |
132 | stat(src,&_stat); | 131 | stat(src,&_stat); |
133 | dwLen = _stat.st_size; | 132 | dwLen = _stat.st_size; |
134 | 133 | ||
135 | //fseek(fin,0,SEEK_END); | 134 | //fseek(fin,0,SEEK_END); |
136 | //dwLen = ftell(fin); | 135 | //dwLen = ftell(fin); |
137 | 136 | ||
138 | if (peanutfile) | 137 | if (peanutfile) |
139 | { | 138 | { |
140 | 139 | ||
141 | PeanutHeader hdr0; | 140 | PeanutHeader hdr0; |
142 | gotorecordnumber(0); | 141 | gotorecordnumber(0); |
143 | fread(&hdr0, sizeof(hdr0), 1, fin); | 142 | fread(&hdr0, sizeof(hdr0), 1, fin); |
144 | // qDebug("Version:%x", ntohs(hdr0.Version)); | 143 | // qDebug("Version:%x", ntohs(hdr0.Version)); |
145 | if (hdr0.Version && 0x0200) | 144 | if (hdr0.Version && 0x0200) |
146 | { | 145 | { |
147 | bCompressed = 2; | 146 | bCompressed = 2; |
148 | } | 147 | } |
149 | else | 148 | else |
150 | { | 149 | { |
151 | bCompressed = 1; | 150 | bCompressed = 1; |
152 | } | 151 | } |
153 | BlockSize = 4096; | 152 | BlockSize = 4096; |
154 | nRecs = SwapWord(hdr0.Records)-1; | 153 | nRecs = SwapWord(hdr0.Records)-1; |
155 | dwTLen = nRecs*BlockSize; | 154 | dwTLen = nRecs*BlockSize; |
156 | } | 155 | } |
157 | else | 156 | else |
158 | { | 157 | { |
159 | gotorecordnumber(0); | 158 | gotorecordnumber(0); |
160 | tDocRecord0 hdr0; | 159 | tDocRecord0 hdr0; |
161 | fread(&hdr0, sizeof(hdr0), 1, fin); | 160 | fread(&hdr0, sizeof(hdr0), 1, fin); |
162 | bCompressed = SwapWord(hdr0.wVersion); | 161 | bCompressed = SwapWord(hdr0.wVersion); |
163 | if (bCompressed!=1 && bCompressed!=2 && bCompressed != 4) { | 162 | if (bCompressed!=1 && bCompressed!=2 && bCompressed != 4) { |
164 | qDebug("ERROR:Unrecognised compression type in Aportis:%u", bCompressed); | 163 | qDebug("ERROR:Unrecognised compression type in Aportis:%u", bCompressed); |
165 | ret = bCompressed; | 164 | ret = bCompressed; |
166 | bCompressed = 2; | 165 | bCompressed = 2; |
167 | } | 166 | } |
168 | switch (bCompressed) | 167 | switch (bCompressed) |
169 | { | 168 | { |
170 | case 4: | 169 | case 4: |
171 | { | 170 | { |
172 | dwTLen = 0; | 171 | dwTLen = 0; |
173 | int i; | 172 | int i; |
174 | for (i = 0; i < nRecs; i++) | 173 | for (i = 0; i < nRecs; i++) |
175 | { | 174 | { |
176 | unsigned int bs = GetBS(i); | 175 | unsigned int bs = GetBS(i); |
177 | if (bs == 0) break; | 176 | if (bs == 0) break; |
178 | else dwTLen += bs; | 177 | else dwTLen += bs; |
179 | } | 178 | } |
180 | nRecs = i; | 179 | nRecs = i; |
181 | BlockSize = 0; | 180 | BlockSize = 0; |
182 | } | 181 | } |
183 | break; | 182 | break; |
184 | case 1: | 183 | case 1: |
185 | case 2: | 184 | case 2: |
186 | default: | 185 | default: |
187 | nRecs = SwapWord(hdr0.wNumRecs); | 186 | nRecs = SwapWord(hdr0.wNumRecs); |
188 | if (mobiimagerec == 0 || mobiimagerec > nRecs2) mobiimagerec = nRecs; | 187 | if (mobiimagerec == 0 || mobiimagerec > nRecs2) mobiimagerec = nRecs; |
189 | dwTLen = SwapLong(hdr0.dwStoryLen); | 188 | dwTLen = SwapLong(hdr0.dwStoryLen); |
190 | BlockSize = SwapWord(hdr0.wRecSize); | 189 | BlockSize = SwapWord(hdr0.wRecSize); |
191 | if (BlockSize == 0) | 190 | if (BlockSize == 0) |
192 | { | 191 | { |
193 | BlockSize = 4096; | 192 | BlockSize = 4096; |
194 | printf("WARNING: Blocksize not set in source file\n"); | 193 | printf("WARNING: Blocksize not set in source file\n"); |
195 | } | 194 | } |
196 | } | 195 | } |
197 | } | 196 | } |
198 | 197 | ||
diff --git a/noncore/apps/opie-reader/AportisCodec/AportisCodec.pro b/noncore/apps/opie-reader/AportisCodec/AportisCodec.pro index 4b61a7a..fcab192 100644 --- a/noncore/apps/opie-reader/AportisCodec/AportisCodec.pro +++ b/noncore/apps/opie-reader/AportisCodec/AportisCodec.pro | |||
@@ -1,30 +1,29 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = Aportis.h \ | 5 | HEADERS = Aportis.h \ |
6 | CExpander.h \ | 6 | CExpander.h \ |
7 | ../OREADERINC/useqpe.h \ | ||
8 | config.h \ | 7 | config.h \ |
9 | ustring.h \ | 8 | ustring.h \ |
10 | StyleConsts.h \ | 9 | StyleConsts.h \ |
11 | Markups.h \ | 10 | Markups.h \ |
12 | names.h \ | 11 | names.h \ |
13 | linktype.h \ | 12 | linktype.h \ |
14 | pdb.h \ | 13 | pdb.h \ |
15 | my_list.h \ | 14 | my_list.h \ |
16 | Bkmks.h \ | 15 | Bkmks.h \ |
17 | Filedata.h | 16 | Filedata.h |
18 | 17 | ||
19 | SOURCES = Aportis.cpp | 18 | SOURCES = Aportis.cpp |
20 | 19 | ||
21 | 20 | ||
22 | INTERFACES= | 21 | INTERFACES= |
23 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 22 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
24 | TARGET = Aportis | 23 | TARGET = Aportis |
25 | LIBS += -lreader_pdb -lreader_codec | 24 | LIBS += -lreader_pdb -lreader_codec |
26 | 25 | ||
27 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 26 | INCLUDEPATH+= $(OPIEDIR)/include |
28 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 27 | DEPENDPATH+= $(OPIEDIR)/include |
29 | 28 | ||
30 | include ( $(OPIEDIR)/include.pro ) \ No newline at end of file | 29 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/BuffDoc.cpp b/noncore/apps/opie-reader/BuffDoc.cpp index 22934f9..1f0a524 100644 --- a/noncore/apps/opie-reader/BuffDoc.cpp +++ b/noncore/apps/opie-reader/BuffDoc.cpp | |||
@@ -1,199 +1,197 @@ | |||
1 | #include "static.h" | ||
2 | #include "names.h" | 1 | #include "names.h" |
3 | 2 | ||
4 | #define NEWLINEBREAK | 3 | #define NEWLINEBREAK |
5 | #define INCREMENTALWIDTH | 4 | #define INCREMENTALWIDTH |
6 | 5 | ||
7 | #include "useqpe.h" | ||
8 | #include "usenef.h" | 6 | #include "usenef.h" |
9 | #include "BuffDoc.h" | 7 | #include "BuffDoc.h" |
10 | #include "config.h" | 8 | #include "config.h" |
11 | #include "CDrawBuffer.h" | 9 | #include "CDrawBuffer.h" |
12 | #include "ZText.h" | 10 | #include "ZText.h" |
13 | #include "ebookcodec.h" | 11 | #include "ebookcodec.h" |
14 | 12 | ||
15 | #ifdef __STATIC | 13 | #ifdef __STATIC |
16 | #include "Aportis.h" | 14 | #include "Aportis.h" |
17 | #include "CHM.h" | 15 | #include "CHM.h" |
18 | #include "ppm_expander.h" | 16 | #include "ppm_expander.h" |
19 | #include "ztxt.h" | 17 | #include "ztxt.h" |
20 | #include "plucker.h" | 18 | #include "plucker.h" |
21 | #ifdef USENEF | 19 | #ifdef USENEF |
22 | #include "nef.h" | 20 | #include "nef.h" |
23 | #include "arrierego.h" | 21 | #include "arrierego.h" |
24 | #endif | 22 | #endif |
25 | #include "iSilo.h" | 23 | #include "iSilo.h" |
26 | #endif | 24 | #endif |
27 | 25 | ||
28 | 26 | ||
29 | linkType BuffDoc::hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) | 27 | linkType BuffDoc::hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) |
30 | { | 28 | { |
31 | linkType bRet = eNone; | 29 | linkType bRet = eNone; |
32 | if (exp != NULL) | 30 | if (exp != NULL) |
33 | { | 31 | { |
34 | bRet = filt->hyperlink(n, noff, wrd, nm); | 32 | bRet = filt->hyperlink(n, noff, wrd, nm); |
35 | if ((bRet & eLink) != 0) | 33 | if ((bRet & eLink) != 0) |
36 | { | 34 | { |
37 | lastword.empty(); | 35 | lastword.empty(); |
38 | lastsizes[0] = laststartline = n; | 36 | lastsizes[0] = laststartline = n; |
39 | #ifdef NEWLINEBREAK | 37 | #ifdef NEWLINEBREAK |
40 | lastispara = false; | 38 | lastispara = false; |
41 | #else | 39 | #else |
42 | lastispara = false; | 40 | lastispara = false; |
43 | #endif | 41 | #endif |
44 | lastsizes[0] = laststartline = exp->locate(); | 42 | lastsizes[0] = laststartline = exp->locate(); |
45 | } | 43 | } |
46 | } | 44 | } |
47 | return bRet; | 45 | return bRet; |
48 | } | 46 | } |
49 | 47 | ||
50 | void BuffDoc::locate(unsigned int n) | 48 | void BuffDoc::locate(unsigned int n) |
51 | { | 49 | { |
52 | // //qDebug("BuffDoc:locating:%u",n); | 50 | // //qDebug("BuffDoc:locating:%u",n); |
53 | lastword.empty(); | 51 | lastword.empty(); |
54 | lastsizes[0] = laststartline = n; | 52 | lastsizes[0] = laststartline = n; |
55 | #ifdef NEWLINEBREAK | 53 | #ifdef NEWLINEBREAK |
56 | lastispara = false; | 54 | lastispara = false; |
57 | #else | 55 | #else |
58 | lastispara = false; | 56 | lastispara = false; |
59 | #endif | 57 | #endif |
60 | // tchar linebuf[1024]; | 58 | // tchar linebuf[1024]; |
61 | if (exp != NULL) filt->locate(n); | 59 | if (exp != NULL) filt->locate(n); |
62 | // //qDebug("BuffDoc:Located"); | 60 | // //qDebug("BuffDoc:Located"); |
63 | } | 61 | } |
64 | 62 | ||
65 | static bool isletter(unsigned short c) | 63 | static bool isletter(unsigned short c) |
66 | { | 64 | { |
67 | if ('a' <= c && c <= 'z') return true; | 65 | if ('a' <= c && c <= 'z') return true; |
68 | if ('A' <= c && c <= 'Z') return true; | 66 | if ('A' <= c && c <= 'Z') return true; |
69 | // Cyrillic letters | 67 | // Cyrillic letters |
70 | if (0x400 <= c && c <= 0x52F) return true; | 68 | if (0x400 <= c && c <= 0x52F) return true; |
71 | return false; | 69 | return false; |
72 | } | 70 | } |
73 | 71 | ||
74 | static bool isvowel(unsigned short c) // Only want lower case vowels | 72 | static bool isvowel(unsigned short c) // Only want lower case vowels |
75 | { | 73 | { |
76 | switch (c) | 74 | switch (c) |
77 | { | 75 | { |
78 | case 'a': | 76 | case 'a': |
79 | case 'e': | 77 | case 'e': |
80 | case 'i': | 78 | case 'i': |
81 | case 'o': | 79 | case 'o': |
82 | case 'u': | 80 | case 'u': |
83 | // Cyrillic vowels | 81 | // Cyrillic vowels |
84 | case 0x430: | 82 | case 0x430: |
85 | case 0x435: | 83 | case 0x435: |
86 | case 0x438: | 84 | case 0x438: |
87 | case 0x43E: | 85 | case 0x43E: |
88 | case 0x443: | 86 | case 0x443: |
89 | case 0x44B: | 87 | case 0x44B: |
90 | case 0x44D: | 88 | case 0x44D: |
91 | case 0x44E: | 89 | case 0x44E: |
92 | case 0x44F: | 90 | case 0x44F: |
93 | case 0x451: | 91 | case 0x451: |
94 | 92 | ||
95 | case 0x450: | 93 | case 0x450: |
96 | case 0x454: | 94 | case 0x454: |
97 | case 0x456: | 95 | case 0x456: |
98 | case 0x457: | 96 | case 0x457: |
99 | case 0x45D: | 97 | case 0x45D: |
100 | 98 | ||
101 | case 0x463: | 99 | case 0x463: |
102 | 100 | ||
103 | case 0x4AF: | 101 | case 0x4AF: |
104 | case 0x4B1: | 102 | case 0x4B1: |
105 | case 0x4D1: | 103 | case 0x4D1: |
106 | case 0x4D3: | 104 | case 0x4D3: |
107 | 105 | ||
108 | case 0x4D5: | 106 | case 0x4D5: |
109 | case 0x4D7: | 107 | case 0x4D7: |
110 | case 0x4E3: | 108 | case 0x4E3: |
111 | case 0x4E5: | 109 | case 0x4E5: |
112 | case 0x4E7: | 110 | case 0x4E7: |
113 | case 0x4E9: | 111 | case 0x4E9: |
114 | case 0x4EB: | 112 | case 0x4EB: |
115 | case 0x4ED: | 113 | case 0x4ED: |
116 | case 0x4EF: | 114 | case 0x4EF: |
117 | case 0x4F1: | 115 | case 0x4F1: |
118 | case 0x4F3: | 116 | case 0x4F3: |
119 | case 0x4F9: | 117 | case 0x4F9: |
120 | return true; | 118 | return true; |
121 | default: | 119 | default: |
122 | return ((0xe0 <= c) && (c <= 0xfc) && (c != 0xf1) && (c != 0xf7) && (c != 0xe7)); | 120 | return ((0xe0 <= c) && (c <= 0xfc) && (c != 0xf1) && (c != 0xf7) && (c != 0xe7)); |
123 | } | 121 | } |
124 | } | 122 | } |
125 | 123 | ||
126 | inline bool isconsonant(unsigned short c) | 124 | inline bool isconsonant(unsigned short c) |
127 | { | 125 | { |
128 | switch( c ) | 126 | switch( c ) |
129 | { | 127 | { |
130 | // Some cyrillic letters are neither vowels, nor consonants, or otherwise | 128 | // Some cyrillic letters are neither vowels, nor consonants, or otherwise |
131 | // the letters no word can start from. | 129 | // the letters no word can start from. |
132 | case 0x439: | 130 | case 0x439: |
133 | case 0x44A: | 131 | case 0x44A: |
134 | case 0x44C: | 132 | case 0x44C: |
135 | 133 | ||
136 | case 0x45E: | 134 | case 0x45E: |
137 | 135 | ||
138 | return false; | 136 | return false; |
139 | 137 | ||
140 | default: | 138 | default: |
141 | return (isletter(c) && !isvowel(c)); | 139 | return (isletter(c) && !isvowel(c)); |
142 | } | 140 | } |
143 | return (isletter(c) && !isvowel(c)); | 141 | return (isletter(c) && !isvowel(c)); |
144 | } | 142 | } |
145 | 143 | ||
146 | #ifdef NEWLINEBREAK | 144 | #ifdef NEWLINEBREAK |
147 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht) | 145 | bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht) |
148 | { | 146 | { |
149 | bool moreleft = true; | 147 | bool moreleft = true; |
150 | bool margindone = false; | 148 | bool margindone = false; |
151 | int isCentred = -1; | 149 | int isCentred = -1; |
152 | int w = wth-(_lborder+_rborder); | 150 | int w = wth-(_lborder+_rborder); |
153 | tchar ch = 32; | 151 | tchar ch = 32; |
154 | CStyle cs; | 152 | CStyle cs; |
155 | buff->empty(); | 153 | buff->empty(); |
156 | if (exp == NULL) | 154 | if (exp == NULL) |
157 | { | 155 | { |
158 | buff->empty(); | 156 | buff->empty(); |
159 | buff->setEof(); | 157 | buff->setEof(); |
160 | return false; | 158 | return false; |
161 | } | 159 | } |
162 | int len = 0; | 160 | int len = 0; |
163 | if (lastword.length() > 0) | 161 | if (lastword.length() > 0) |
164 | { | 162 | { |
165 | if (isCentred < 0) | 163 | if (isCentred < 0) |
166 | { | 164 | { |
167 | isCentred = (lastword.firststyle().getJustify() == m_AlignCentre) ? 1 : 0; | 165 | isCentred = (lastword.firststyle().getJustify() == m_AlignCentre) ? 1 : 0; |
168 | } | 166 | } |
169 | *buff = lastword; | 167 | *buff = lastword; |
170 | cs = lastword.laststyle(); | 168 | cs = lastword.laststyle(); |
171 | w -= buff->leftMargin() + buff->rightMargin(); | 169 | w -= buff->leftMargin() + buff->rightMargin(); |
172 | margindone = true; | 170 | margindone = true; |
173 | len = lastword.length(); | 171 | len = lastword.length(); |
174 | } | 172 | } |
175 | else buff->empty(); | 173 | else buff->empty(); |
176 | lastword.empty(); | 174 | lastword.empty(); |
177 | unsigned int slen = buff->width(availht, len); | 175 | unsigned int slen = buff->width(availht, len); |
178 | if (lastispara) buff->setstartpara(); | 176 | if (lastispara) buff->setstartpara(); |
179 | int nospaces = 0; | 177 | int nospaces = 0; |
180 | while (1) | 178 | while (1) |
181 | { | 179 | { |
182 | getch(ch, cs, lastsizes[len]); | 180 | getch(ch, cs, lastsizes[len]); |
183 | if (isCentred < 0) | 181 | if (isCentred < 0) |
184 | { | 182 | { |
185 | isCentred = (cs.getJustify() == m_AlignCentre) ? 1 : 0; | 183 | isCentred = (cs.getJustify() == m_AlignCentre) ? 1 : 0; |
186 | } | 184 | } |
187 | if (ch == 10 && len == 0 && !lastispara) | 185 | if (ch == 10 && len == 0 && !lastispara) |
188 | { | 186 | { |
189 | getch(ch, cs, lastsizes[len]); | 187 | getch(ch, cs, lastsizes[len]); |
190 | buff->setstartpara(); | 188 | buff->setstartpara(); |
191 | } | 189 | } |
192 | if (ch == UEOF) | 190 | if (ch == UEOF) |
193 | { | 191 | { |
194 | buff->setendpara(cs); | 192 | buff->setendpara(cs); |
195 | if (len == 0) | 193 | if (len == 0) |
196 | { | 194 | { |
197 | buff->setEof(); | 195 | buff->setEof(); |
198 | moreleft = false; | 196 | moreleft = false; |
199 | } | 197 | } |
diff --git a/noncore/apps/opie-reader/BuffDoc.h b/noncore/apps/opie-reader/BuffDoc.h index a7dd7bf..2b4fb57 100644 --- a/noncore/apps/opie-reader/BuffDoc.h +++ b/noncore/apps/opie-reader/BuffDoc.h | |||
@@ -1,144 +1,143 @@ | |||
1 | #ifndef __BuffDoc_h | 1 | #ifndef __BuffDoc_h |
2 | #define __BuffDoc_h | 2 | #define __BuffDoc_h |
3 | 3 | ||
4 | #include "useqpe.h" | ||
5 | #include "CDrawBuffer.h" | 4 | #include "CDrawBuffer.h" |
6 | #include "CFilter.h" | 5 | #include "CFilter.h" |
7 | #include "CExpander.h" | 6 | #include "CExpander.h" |
8 | #include <qfontmetrics.h> | 7 | #include <qfontmetrics.h> |
9 | #include <qmessagebox.h> | 8 | #include <qmessagebox.h> |
10 | 9 | ||
11 | class BuffDoc | 10 | class BuffDoc |
12 | { | 11 | { |
13 | CDrawBuffer lastword; | 12 | CDrawBuffer lastword; |
14 | CSizeBuffer lastsizes, allsizes; | 13 | CSizeBuffer lastsizes, allsizes; |
15 | size_t laststartline; | 14 | size_t laststartline; |
16 | bool lastispara; | 15 | bool lastispara; |
17 | CExpander_Interface* exp; | 16 | CExpander_Interface* exp; |
18 | CFilterChain* filt; | 17 | CFilterChain* filt; |
19 | int m_hyphenthreshold; | 18 | int m_hyphenthreshold; |
20 | // bool m_customhyphen; | 19 | // bool m_customhyphen; |
21 | public: | 20 | public: |
22 | QString about(); | 21 | QString about(); |
23 | bool findanchor(const QString& nm) | 22 | bool findanchor(const QString& nm) |
24 | { | 23 | { |
25 | return filt->findanchor(nm); | 24 | return filt->findanchor(nm); |
26 | } | 25 | } |
27 | // void setCustomHyphen(bool _v) { m_customhyphen = _v; } | 26 | // void setCustomHyphen(bool _v) { m_customhyphen = _v; } |
28 | // bool getCustomHyphen() { return m_customhyphen; } | 27 | // bool getCustomHyphen() { return m_customhyphen; } |
29 | void setHyphenThreshold(int _v) { m_hyphenthreshold = _v; } | 28 | void setHyphenThreshold(int _v) { m_hyphenthreshold = _v; } |
30 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 29 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
31 | { | 30 | { |
32 | if (exp == NULL) | 31 | if (exp == NULL) |
33 | { | 32 | { |
34 | data = NULL; | 33 | data = NULL; |
35 | len = 0; | 34 | len = 0; |
36 | } | 35 | } |
37 | else | 36 | else |
38 | { | 37 | { |
39 | exp->setSaveData(data, len, src, srclen); | 38 | exp->setSaveData(data, len, src, srclen); |
40 | } | 39 | } |
41 | } | 40 | } |
42 | void putSaveData(unsigned char*& src, unsigned short& srclen) | 41 | void putSaveData(unsigned char*& src, unsigned short& srclen) |
43 | { | 42 | { |
44 | if (exp != NULL) | 43 | if (exp != NULL) |
45 | { | 44 | { |
46 | exp->putSaveData(src, srclen); | 45 | exp->putSaveData(src, srclen); |
47 | } | 46 | } |
48 | } | 47 | } |
49 | #ifdef USEQPE | 48 | #ifdef USEQPE |
50 | void suspend() { if (exp != NULL) exp->suspend(); } | 49 | void suspend() { if (exp != NULL) exp->suspend(); } |
51 | void unsuspend() { if (exp != NULL) exp->unsuspend(); } | 50 | void unsuspend() { if (exp != NULL) exp->unsuspend(); } |
52 | #else | 51 | #else |
53 | void suspend() {} | 52 | void suspend() {} |
54 | void unsuspend() {} | 53 | void unsuspend() {} |
55 | #endif | 54 | #endif |
56 | ~BuffDoc() | 55 | ~BuffDoc() |
57 | { | 56 | { |
58 | delete filt; | 57 | delete filt; |
59 | delete exp; | 58 | delete exp; |
60 | } | 59 | } |
61 | BuffDoc() | 60 | BuffDoc() |
62 | { | 61 | { |
63 | exp = NULL; | 62 | exp = NULL; |
64 | filt = NULL; | 63 | filt = NULL; |
65 | lastword.empty(); | 64 | lastword.empty(); |
66 | // // qDebug("Buffdoc created"); | 65 | // // qDebug("Buffdoc created"); |
67 | } | 66 | } |
68 | bool empty() { return (exp == NULL); } | 67 | bool empty() { return (exp == NULL); } |
69 | void setfilter(CFilterChain* _f) | 68 | void setfilter(CFilterChain* _f) |
70 | { | 69 | { |
71 | if (filt != NULL) delete filt; | 70 | if (filt != NULL) delete filt; |
72 | filt = _f; | 71 | filt = _f; |
73 | filt->setsource(exp); | 72 | filt->setsource(exp); |
74 | } | 73 | } |
75 | CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } | 74 | CList<Bkmk>* getbkmklist() { return exp->getbkmklist(); } |
76 | bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); } | 75 | bool hasrandomaccess() { return (exp == NULL) ? false : exp->hasrandomaccess(); } |
77 | bool iseol() { return (lastword[0] == '\0'); } | 76 | bool iseol() { return (lastword[0] == '\0'); } |
78 | int openfile(QWidget* _parent, const char *src); | 77 | int openfile(QWidget* _parent, const char *src); |
79 | tchar getch() | 78 | tchar getch() |
80 | { | 79 | { |
81 | tchar ch = UEOF; | 80 | tchar ch = UEOF; |
82 | CStyle sty; | 81 | CStyle sty; |
83 | if (exp != NULL) | 82 | if (exp != NULL) |
84 | { | 83 | { |
85 | unsigned long dummy; | 84 | unsigned long dummy; |
86 | filt->getch(ch, sty, dummy); | 85 | filt->getch(ch, sty, dummy); |
87 | } | 86 | } |
88 | return ch; | 87 | return ch; |
89 | } | 88 | } |
90 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 89 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
91 | { | 90 | { |
92 | if (exp != NULL) | 91 | if (exp != NULL) |
93 | { | 92 | { |
94 | filt->getch(ch, sty, pos); | 93 | filt->getch(ch, sty, pos); |
95 | } | 94 | } |
96 | else | 95 | else |
97 | ch = UEOF; | 96 | ch = UEOF; |
98 | } | 97 | } |
99 | void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } | 98 | void setwidth(int w) { if (exp != NULL) exp->setwidth(w); } |
100 | QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } | 99 | QImage* getPicture(unsigned long tgt) { return (exp == NULL) ? NULL : exp->getPicture(tgt); } |
101 | unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } | 100 | unsigned int startSection() { return (exp == NULL) ? 0 : exp->startSection(); } |
102 | unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } | 101 | unsigned int endSection() { return (exp == NULL) ? 0 : exp->endSection(); } |
103 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } | 102 | unsigned int locate() { return (exp == NULL) ? 0 : laststartline; } |
104 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } | 103 | unsigned int explocate() { return (exp == NULL) ? 0 : exp->locate(); } |
105 | void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } | 104 | void setContinuous(bool _b) { if (exp != NULL) exp->setContinuous(_b); } |
106 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } | 105 | MarkupType PreferredMarkup() { return (exp == NULL) ? cTEXT : exp->PreferredMarkup(); } |
107 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); | 106 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); |
108 | size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } | 107 | size_t getHome() { return ((exp != NULL) ? exp->getHome() : 0); } |
109 | void locate(unsigned int n); | 108 | void locate(unsigned int n); |
110 | bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht); | 109 | bool getline(CDrawBuffer* buff, int w, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht); |
111 | bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht); | 110 | bool getline(CDrawBuffer* buff, int w, int cw, unsigned short _lborder, unsigned short _rborder, int availht); |
112 | void sizes(unsigned long& fs, unsigned long& ts) | 111 | void sizes(unsigned long& fs, unsigned long& ts) |
113 | { | 112 | { |
114 | if (exp != NULL) | 113 | if (exp != NULL) |
115 | { | 114 | { |
116 | exp->sizes(fs,ts); | 115 | exp->sizes(fs,ts); |
117 | } | 116 | } |
118 | else | 117 | else |
119 | { | 118 | { |
120 | fs = ts = 0; | 119 | fs = ts = 0; |
121 | } | 120 | } |
122 | } | 121 | } |
123 | int getpara(CBuffer& buff) | 122 | int getpara(CBuffer& buff) |
124 | { | 123 | { |
125 | tchar ch; | 124 | tchar ch; |
126 | int i = 0; | 125 | int i = 0; |
127 | while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; | 126 | while ((ch = getch()) != 10 && ch != UEOF) buff[i++] = ch; |
128 | buff[i] = '\0'; | 127 | buff[i] = '\0'; |
129 | if (i == 0 && ch == UEOF) i = -1; | 128 | if (i == 0 && ch == UEOF) i = -1; |
130 | laststartline = exp->locate(); | 129 | laststartline = exp->locate(); |
131 | return i; | 130 | return i; |
132 | } | 131 | } |
133 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } | 132 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } |
134 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } | 133 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } |
135 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } | 134 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } |
136 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } | 135 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } |
137 | bool hasnavigation() { return filt->hasnavigation(); } | 136 | bool hasnavigation() { return filt->hasnavigation(); } |
138 | bool getFile(QString href) | 137 | bool getFile(QString href) |
139 | { | 138 | { |
140 | return (exp == NULL) ? false : exp->getFile(href); | 139 | return (exp == NULL) ? false : exp->getFile(href); |
141 | } | 140 | } |
142 | }; | 141 | }; |
143 | 142 | ||
144 | #endif | 143 | #endif |
diff --git a/noncore/apps/opie-reader/CDrawBuffer.cpp b/noncore/apps/opie-reader/CDrawBuffer.cpp index caccf1b..bfb3027 100644 --- a/noncore/apps/opie-reader/CDrawBuffer.cpp +++ b/noncore/apps/opie-reader/CDrawBuffer.cpp | |||
@@ -1,199 +1,198 @@ | |||
1 | #include "CDrawBuffer.h" | 1 | #include "CDrawBuffer.h" |
2 | #include "FontControl.h" | 2 | #include "FontControl.h" |
3 | #include <qfontmetrics.h> | 3 | #include <qfontmetrics.h> |
4 | #include <qpainter.h> | 4 | #include <qpainter.h> |
5 | #include <qpixmap.h> | 5 | #include <qpixmap.h> |
6 | #include <qimage.h> | 6 | #include <qimage.h> |
7 | #include "useqpe.h" | ||
8 | 7 | ||
9 | CDrawBuffer::~CDrawBuffer() | 8 | CDrawBuffer::~CDrawBuffer() |
10 | { | 9 | { |
11 | while (!segs.isEmpty()) segs.erase(0); | 10 | while (!segs.isEmpty()) segs.erase(0); |
12 | } | 11 | } |
13 | 12 | ||
14 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) | 13 | void CDrawBuffer::setright(CDrawBuffer& rhs, int f) |
15 | { | 14 | { |
16 | int i; | 15 | int i; |
17 | len = rhs.len; | 16 | len = rhs.len; |
18 | fc = rhs.fc; | 17 | fc = rhs.fc; |
19 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 18 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
20 | while (!segs.isEmpty()) | 19 | while (!segs.isEmpty()) |
21 | { | 20 | { |
22 | segs.erase(0); | 21 | segs.erase(0); |
23 | } | 22 | } |
24 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) | 23 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); ) |
25 | { | 24 | { |
26 | CList<textsegment>::iterator next = iter; | 25 | CList<textsegment>::iterator next = iter; |
27 | iter++; | 26 | iter++; |
28 | if (iter == rhs.segs.end() || iter->start > f) | 27 | if (iter == rhs.segs.end() || iter->start > f) |
29 | { | 28 | { |
30 | int st = next->start-f; | 29 | int st = next->start-f; |
31 | if (st < 0) st = 0; | 30 | if (st < 0) st = 0; |
32 | 31 | ||
33 | CStyle _style = next->style; | 32 | CStyle _style = next->style; |
34 | segs.push_back(textsegment(st,next->style)); | 33 | segs.push_back(textsegment(st,next->style)); |
35 | } | 34 | } |
36 | } | 35 | } |
37 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; | 36 | for (i = f; rhs[i] != '\0'; i++) (*this)[i-f] = rhs[i]; |
38 | (*this)[i-f] = '\0'; | 37 | (*this)[i-f] = '\0'; |
39 | len = i; | 38 | len = i; |
40 | } | 39 | } |
41 | 40 | ||
42 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) | 41 | CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) |
43 | { | 42 | { |
44 | int i; | 43 | int i; |
45 | // //qDebug("Trying 2"); | 44 | // //qDebug("Trying 2"); |
46 | len = rhs.len; | 45 | len = rhs.len; |
47 | m_ascent = rhs.m_ascent; | 46 | m_ascent = rhs.m_ascent; |
48 | m_descent = rhs.m_descent; | 47 | m_descent = rhs.m_descent; |
49 | m_lineSpacing = rhs.m_lineSpacing; | 48 | m_lineSpacing = rhs.m_lineSpacing; |
50 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; | 49 | m_lineExtraSpacing = rhs.m_lineExtraSpacing; |
51 | m_showPartial = rhs.m_showPartial; | 50 | m_showPartial = rhs.m_showPartial; |
52 | while (!segs.isEmpty()) | 51 | while (!segs.isEmpty()) |
53 | { | 52 | { |
54 | segs.erase(0); | 53 | segs.erase(0); |
55 | } | 54 | } |
56 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) | 55 | for (CList<textsegment>::iterator iter = rhs.segs.begin(); iter != rhs.segs.end(); iter++) |
57 | { | 56 | { |
58 | segs.push_back(*iter); | 57 | segs.push_back(*iter); |
59 | } | 58 | } |
60 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; | 59 | for (i = 0; rhs[i] != '\0'; i++) (*this)[i] = rhs[i]; |
61 | (*this)[i] = '\0'; | 60 | (*this)[i] = '\0'; |
62 | len = i; | 61 | len = i; |
63 | // //qDebug("Tried 2"); | 62 | // //qDebug("Tried 2"); |
64 | return *this; | 63 | return *this; |
65 | } | 64 | } |
66 | 65 | ||
67 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) | 66 | CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) |
68 | { | 67 | { |
69 | int i; | 68 | int i; |
70 | while (!segs.isEmpty()) | 69 | while (!segs.isEmpty()) |
71 | { | 70 | { |
72 | segs.erase(0); | 71 | segs.erase(0); |
73 | } | 72 | } |
74 | segs.push_back(textsegment(0, CStyle())); | 73 | segs.push_back(textsegment(0, CStyle())); |
75 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; | 74 | for (i = 0; sztmp[i] != '\0'; i++) (*this)[i] = sztmp[i]; |
76 | (*this)[i] = '\0'; | 75 | (*this)[i] = '\0'; |
77 | len = i; | 76 | len = i; |
78 | return *this; | 77 | return *this; |
79 | } | 78 | } |
80 | 79 | ||
81 | void CDrawBuffer::empty() | 80 | void CDrawBuffer::empty() |
82 | { | 81 | { |
83 | m_bSop = false; | 82 | m_bSop = false; |
84 | m_bEop = false; | 83 | m_bEop = false; |
85 | m_bBop = false; | 84 | m_bBop = false; |
86 | len = 0; | 85 | len = 0; |
87 | (*this)[0] = 0; | 86 | (*this)[0] = 0; |
88 | while (!segs.isEmpty()) | 87 | while (!segs.isEmpty()) |
89 | { | 88 | { |
90 | segs.erase(0); | 89 | segs.erase(0); |
91 | } | 90 | } |
92 | segs.push_back(textsegment(0,CStyle())); | 91 | segs.push_back(textsegment(0,CStyle())); |
93 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; | 92 | m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; |
94 | m_bEof = false; | 93 | m_bEof = false; |
95 | } | 94 | } |
96 | 95 | ||
97 | void CDrawBuffer::setendpara(const CStyle& _style/* = ucFontBase*/) | 96 | void CDrawBuffer::setendpara(const CStyle& _style/* = ucFontBase*/) |
98 | { | 97 | { |
99 | m_bEop = true; | 98 | m_bEop = true; |
100 | if (len == 0) | 99 | if (len == 0) |
101 | { | 100 | { |
102 | segs.first().start = 0; | 101 | segs.first().start = 0; |
103 | segs.first().style = _style; | 102 | segs.first().style = _style; |
104 | } | 103 | } |
105 | } | 104 | } |
106 | 105 | ||
107 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) | 106 | void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) |
108 | { | 107 | { |
109 | if (len == 0) | 108 | if (len == 0) |
110 | { | 109 | { |
111 | segs.first().start = 0; | 110 | segs.first().start = 0; |
112 | segs.first().style = _style; | 111 | segs.first().style = _style; |
113 | } | 112 | } |
114 | else if (_style != segs.last().style) | 113 | else if (_style != segs.last().style) |
115 | { | 114 | { |
116 | segs.push_back(textsegment(len, _style)); | 115 | segs.push_back(textsegment(len, _style)); |
117 | } | 116 | } |
118 | (*this)[len++] = ch; | 117 | (*this)[len++] = ch; |
119 | } | 118 | } |
120 | 119 | ||
121 | void CDrawBuffer::truncate(int n) | 120 | void CDrawBuffer::truncate(int n) |
122 | { | 121 | { |
123 | len = n; | 122 | len = n; |
124 | (*this)[n] = 0; | 123 | (*this)[n] = 0; |
125 | } | 124 | } |
126 | 125 | ||
127 | int CDrawBuffer::width(int availht, int numchars, bool onscreen, int scwidth, unsigned short _lborder, unsigned short _rborder) | 126 | int CDrawBuffer::width(int availht, int numchars, bool onscreen, int scwidth, unsigned short _lborder, unsigned short _rborder) |
128 | { | 127 | { |
129 | int gzoom = fc->gzoom(); | 128 | int gzoom = fc->gzoom(); |
130 | int currentx = 0, end = 0; | 129 | int currentx = 0, end = 0; |
131 | QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars); | 130 | QString text = (numchars < 0) ? toQString(data()) : toQString(data(), numchars); |
132 | CList<textsegment>::iterator textstart = segs.begin(); | 131 | CList<textsegment>::iterator textstart = segs.begin(); |
133 | int extraspace = 0; | 132 | int extraspace = 0; |
134 | bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify); | 133 | bool just = (onscreen && !m_bEop && textstart->style.getJustify() == m_AlignJustify); |
135 | int spaces = 0; | 134 | int spaces = 0; |
136 | int spacesofar = 0; | 135 | int spacesofar = 0; |
137 | int spacenumber = 0; | 136 | int spacenumber = 0; |
138 | int nonspace = 0; | 137 | int nonspace = 0; |
139 | if (just) | 138 | if (just) |
140 | { | 139 | { |
141 | for (int i = 0; i < len; i++) | 140 | for (int i = 0; i < len; i++) |
142 | { | 141 | { |
143 | if ((*this)[i] != ' ') | 142 | if ((*this)[i] != ' ') |
144 | { | 143 | { |
145 | nonspace = i; | 144 | nonspace = i; |
146 | break; | 145 | break; |
147 | } | 146 | } |
148 | } | 147 | } |
149 | #ifdef _WINDOWS | 148 | #ifdef _WINDOWS |
150 | for (i = nonspace; i < len; i++) | 149 | for (i = nonspace; i < len; i++) |
151 | #else | 150 | #else |
152 | for (int i = nonspace; i < len; i++) | 151 | for (int i = nonspace; i < len; i++) |
153 | #endif | 152 | #endif |
154 | { | 153 | { |
155 | if ((*this)[i] == ' ') | 154 | if ((*this)[i] == ' ') |
156 | { | 155 | { |
157 | spaces++; | 156 | spaces++; |
158 | } | 157 | } |
159 | } | 158 | } |
160 | if (spaces == 0) | 159 | if (spaces == 0) |
161 | { | 160 | { |
162 | just = false; | 161 | just = false; |
163 | } | 162 | } |
164 | else | 163 | else |
165 | { | 164 | { |
166 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); | 165 | extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); |
167 | if (extraspace == 0) just = false; | 166 | if (extraspace == 0) just = false; |
168 | } | 167 | } |
169 | } | 168 | } |
170 | CList<textsegment>::iterator textend = textstart; | 169 | CList<textsegment>::iterator textend = textstart; |
171 | do | 170 | do |
172 | { | 171 | { |
173 | textend++; | 172 | textend++; |
174 | end = (textend != segs.end()) ? textend->start : len; | 173 | end = (textend != segs.end()) ? textend->start : len; |
175 | if (numchars >= 0 && end > numchars) | 174 | if (numchars >= 0 && end > numchars) |
176 | { | 175 | { |
177 | end = numchars; | 176 | end = numchars; |
178 | } | 177 | } |
179 | CStyle currentstyle = textstart->style; | 178 | CStyle currentstyle = textstart->style; |
180 | if (currentstyle.isPicture()) | 179 | if (currentstyle.isPicture()) |
181 | { | 180 | { |
182 | if (currentstyle.canScale()) | 181 | if (currentstyle.canScale()) |
183 | { | 182 | { |
184 | int ht = (gzoom*currentstyle.getPicture()->height())/100; | 183 | int ht = (gzoom*currentstyle.getPicture()->height())/100; |
185 | int wt = (gzoom*currentstyle.getPicture()->width())/100; | 184 | int wt = (gzoom*currentstyle.getPicture()->width())/100; |
186 | if (ht > availht) | 185 | if (ht > availht) |
187 | { | 186 | { |
188 | wt = (wt*availht)/ht; | 187 | wt = (wt*availht)/ht; |
189 | } | 188 | } |
190 | currentx += wt; | 189 | currentx += wt; |
191 | } | 190 | } |
192 | else | 191 | else |
193 | { | 192 | { |
194 | currentx += currentstyle.getPicture()->width(); | 193 | currentx += currentstyle.getPicture()->width(); |
195 | } | 194 | } |
196 | } | 195 | } |
197 | else | 196 | else |
198 | { | 197 | { |
199 | if (currentstyle.isMono() && !fc->hasCourier()) | 198 | if (currentstyle.isMono() && !fc->hasCourier()) |
diff --git a/noncore/apps/opie-reader/CExpander.h b/noncore/apps/opie-reader/CExpander.h index e9aaf79..7fa84f9 100644 --- a/noncore/apps/opie-reader/CExpander.h +++ b/noncore/apps/opie-reader/CExpander.h | |||
@@ -1,149 +1,148 @@ | |||
1 | #ifndef __CExpander_h | 1 | #ifndef __CExpander_h |
2 | #define __CExpander_h | 2 | #define __CExpander_h |
3 | 3 | ||
4 | #ifndef _WINDOWS | 4 | #ifndef _WINDOWS |
5 | #include <unistd.h> | 5 | #include <unistd.h> |
6 | #endif | 6 | #endif |
7 | #include <stdio.h> | 7 | #include <stdio.h> |
8 | #include <time.h> | 8 | #include <time.h> |
9 | #include <sys/stat.h> | 9 | #include <sys/stat.h> |
10 | #include <qmessagebox.h> | 10 | #include <qmessagebox.h> |
11 | #include "useqpe.h" | ||
12 | #include "config.h" | 11 | #include "config.h" |
13 | #include "StyleConsts.h" | 12 | #include "StyleConsts.h" |
14 | #include "Markups.h" | 13 | #include "Markups.h" |
15 | #include "names.h" | 14 | #include "names.h" |
16 | #include "linktype.h" | 15 | #include "linktype.h" |
17 | 16 | ||
18 | class QImage; | 17 | class QImage; |
19 | class Bkmk; | 18 | class Bkmk; |
20 | class QString; | 19 | class QString; |
21 | 20 | ||
22 | template<class T> | 21 | template<class T> |
23 | class CList; | 22 | class CList; |
24 | 23 | ||
25 | class CCharacterSource | 24 | class CCharacterSource |
26 | { | 25 | { |
27 | public: | 26 | public: |
28 | virtual void getch(tchar&, CStyle&, unsigned long&) = 0; | 27 | virtual void getch(tchar&, CStyle&, unsigned long&) = 0; |
29 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0; | 28 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString&, QString& nm) = 0; |
30 | virtual void locate(unsigned int n) = 0; | 29 | virtual void locate(unsigned int n) = 0; |
31 | virtual bool findanchor(const QString& nm) = 0; | 30 | virtual bool findanchor(const QString& nm) = 0; |
32 | virtual void saveposn(const QString& f, size_t posn) = 0; | 31 | virtual void saveposn(const QString& f, size_t posn) = 0; |
33 | virtual void writeposn(const QString& f, size_t posn) = 0; | 32 | virtual void writeposn(const QString& f, size_t posn) = 0; |
34 | virtual linkType forward(QString& f, size_t& loc) = 0; | 33 | virtual linkType forward(QString& f, size_t& loc) = 0; |
35 | virtual linkType back(QString& f, size_t& loc) = 0; | 34 | virtual linkType back(QString& f, size_t& loc) = 0; |
36 | virtual bool hasnavigation() = 0; | 35 | virtual bool hasnavigation() = 0; |
37 | virtual int getwidth() = 0; | 36 | virtual int getwidth() = 0; |
38 | virtual QImage* getPicture(unsigned long) = 0; | 37 | virtual QImage* getPicture(unsigned long) = 0; |
39 | virtual QImage* getPicture(const QString& href) = 0; | 38 | virtual QImage* getPicture(const QString& href) = 0; |
40 | virtual bool getFile(const QString& href) = 0; | 39 | virtual bool getFile(const QString& href) = 0; |
41 | virtual QString about() = 0; | 40 | virtual QString about() = 0; |
42 | }; | 41 | }; |
43 | 42 | ||
44 | class CExpander_Interface | 43 | class CExpander_Interface |
45 | { | 44 | { |
46 | public: | 45 | public: |
47 | #ifdef USEQPE | 46 | #ifdef USEQPE |
48 | virtual void suspend() = 0; | 47 | virtual void suspend() = 0; |
49 | virtual void unsuspend() = 0; | 48 | virtual void unsuspend() = 0; |
50 | #endif | 49 | #endif |
51 | virtual QString about() = 0; | 50 | virtual QString about() = 0; |
52 | virtual size_t getHome() = 0; | 51 | virtual size_t getHome() = 0; |
53 | //CExpander_Interface(); | 52 | //CExpander_Interface(); |
54 | //virtual ~CExpander_Interface(); | 53 | //virtual ~CExpander_Interface(); |
55 | virtual int openfile(const char *src) = 0; | 54 | virtual int openfile(const char *src) = 0; |
56 | //virtual int OpenFile(const char *src) = 0; | 55 | //virtual int OpenFile(const char *src) = 0; |
57 | virtual unsigned int locate() = 0; | 56 | virtual unsigned int locate() = 0; |
58 | virtual void locate(unsigned int n) = 0; | 57 | virtual void locate(unsigned int n) = 0; |
59 | virtual bool hasrandomaccess() = 0; | 58 | virtual bool hasrandomaccess() = 0; |
60 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; | 59 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; |
61 | virtual CList<Bkmk>* getbkmklist() { return NULL; } | 60 | virtual CList<Bkmk>* getbkmklist() { return NULL; } |
62 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos) = 0; | 61 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos) = 0; |
63 | virtual int getch() = 0; | 62 | virtual int getch() = 0; |
64 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) = 0; | 63 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) = 0; |
65 | virtual MarkupType PreferredMarkup() = 0; | 64 | virtual MarkupType PreferredMarkup() = 0; |
66 | virtual void saveposn(size_t posn) {} | 65 | virtual void saveposn(size_t posn) {} |
67 | virtual void writeposn(size_t posn) {} | 66 | virtual void writeposn(size_t posn) {} |
68 | virtual linkType forward(size_t& loc) { return eNone; } | 67 | virtual linkType forward(size_t& loc) { return eNone; } |
69 | virtual linkType back(size_t& loc) { return eNone; } | 68 | virtual linkType back(size_t& loc) { return eNone; } |
70 | virtual bool hasnavigation() { return false; } | 69 | virtual bool hasnavigation() { return false; } |
71 | virtual unsigned long startSection() = 0; | 70 | virtual unsigned long startSection() = 0; |
72 | virtual unsigned long endSection() = 0; | 71 | virtual unsigned long endSection() = 0; |
73 | virtual void start2endSection() = 0; | 72 | virtual void start2endSection() = 0; |
74 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } | 73 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } |
75 | virtual void setContinuous(bool _b) = 0; | 74 | virtual void setContinuous(bool _b) = 0; |
76 | #ifdef USEQPE | 75 | #ifdef USEQPE |
77 | virtual void suspend(FILE*& fin) = 0; | 76 | virtual void suspend(FILE*& fin) = 0; |
78 | virtual void unsuspend(FILE*& fin) = 0; | 77 | virtual void unsuspend(FILE*& fin) = 0; |
79 | #endif | 78 | #endif |
80 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0; | 79 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) = 0; |
81 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0; | 80 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen) = 0; |
82 | virtual void setwidth(int w) = 0; | 81 | virtual void setwidth(int w) = 0; |
83 | // bool findstring(const QString& info); | 82 | // bool findstring(const QString& info); |
84 | // int getpara(CBuffer& buff); | 83 | // int getpara(CBuffer& buff); |
85 | virtual int getwidth() = 0; | 84 | virtual int getwidth() = 0; |
86 | virtual QImage* getPicture(const QString& href) = 0; | 85 | virtual QImage* getPicture(const QString& href) = 0; |
87 | virtual bool getFile(const QString& href) = 0; | 86 | virtual bool getFile(const QString& href) = 0; |
88 | }; | 87 | }; |
89 | 88 | ||
90 | class CExpander : public CExpander_Interface | 89 | class CExpander : public CExpander_Interface |
91 | { | 90 | { |
92 | protected: | 91 | protected: |
93 | size_t m_homepos; | 92 | size_t m_homepos; |
94 | bool m_continuous; | 93 | bool m_continuous; |
95 | char* fname; | 94 | char* fname; |
96 | bool bSuspended; | 95 | bool bSuspended; |
97 | size_t suspos; | 96 | size_t suspos; |
98 | time_t sustime; | 97 | time_t sustime; |
99 | int m_scrWidth; | 98 | int m_scrWidth; |
100 | unsigned long m_currentstart, m_currentend; | 99 | unsigned long m_currentstart, m_currentend; |
101 | public: | 100 | public: |
102 | #ifdef USEQPE | 101 | #ifdef USEQPE |
103 | virtual void suspend() = 0; | 102 | virtual void suspend() = 0; |
104 | virtual void unsuspend() = 0; | 103 | virtual void unsuspend() = 0; |
105 | #endif | 104 | #endif |
106 | size_t getHome(); | 105 | size_t getHome(); |
107 | CExpander(); | 106 | CExpander(); |
108 | virtual ~CExpander(); | 107 | virtual ~CExpander(); |
109 | int openfile(const char *src); | 108 | int openfile(const char *src); |
110 | virtual int OpenFile(const char *src) = 0; | 109 | virtual int OpenFile(const char *src) = 0; |
111 | virtual unsigned int locate() = 0; | 110 | virtual unsigned int locate() = 0; |
112 | virtual void locate(unsigned int n) = 0; | 111 | virtual void locate(unsigned int n) = 0; |
113 | virtual bool hasrandomaccess() = 0; | 112 | virtual bool hasrandomaccess() = 0; |
114 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; | 113 | virtual void sizes(unsigned long& file, unsigned long& text) = 0; |
115 | virtual CList<Bkmk>* getbkmklist() { return NULL; } | 114 | virtual CList<Bkmk>* getbkmklist() { return NULL; } |
116 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 115 | virtual void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
117 | virtual int getch() = 0; | 116 | virtual int getch() = 0; |
118 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); | 117 | virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm); |
119 | virtual MarkupType PreferredMarkup() = 0; | 118 | virtual MarkupType PreferredMarkup() = 0; |
120 | virtual void saveposn(size_t posn) {} | 119 | virtual void saveposn(size_t posn) {} |
121 | virtual void writeposn(size_t posn) {} | 120 | virtual void writeposn(size_t posn) {} |
122 | virtual linkType forward(size_t& loc) { return eNone; } | 121 | virtual linkType forward(size_t& loc) { return eNone; } |
123 | virtual linkType back(size_t& loc) { return eNone; } | 122 | virtual linkType back(size_t& loc) { return eNone; } |
124 | virtual bool hasnavigation() { return false; } | 123 | virtual bool hasnavigation() { return false; } |
125 | unsigned long startSection(); | 124 | unsigned long startSection(); |
126 | unsigned long endSection(); | 125 | unsigned long endSection(); |
127 | virtual void start2endSection(); | 126 | virtual void start2endSection(); |
128 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } | 127 | virtual QImage* getPicture(unsigned long tgt) { return NULL; } |
129 | void setContinuous(bool _b) { m_continuous = _b; } | 128 | void setContinuous(bool _b) { m_continuous = _b; } |
130 | #ifdef USEQPE | 129 | #ifdef USEQPE |
131 | virtual void suspend(FILE*& fin); | 130 | virtual void suspend(FILE*& fin); |
132 | virtual void unsuspend(FILE*& fin); | 131 | virtual void unsuspend(FILE*& fin); |
133 | #endif | 132 | #endif |
134 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); | 133 | virtual void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen); |
135 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen); | 134 | virtual void putSaveData(unsigned char*& src, unsigned short& srclen); |
136 | void setwidth(int w) | 135 | void setwidth(int w) |
137 | { | 136 | { |
138 | m_scrWidth = w; | 137 | m_scrWidth = w; |
139 | } | 138 | } |
140 | int getwidth() | 139 | int getwidth() |
141 | { | 140 | { |
142 | return m_scrWidth; | 141 | return m_scrWidth; |
143 | } | 142 | } |
144 | // bool findstring(const QString& info); | 143 | // bool findstring(const QString& info); |
145 | // int getpara(CBuffer& buff); | 144 | // int getpara(CBuffer& buff); |
146 | virtual QImage* getPicture(const QString& href) { return NULL; } | 145 | virtual QImage* getPicture(const QString& href) { return NULL; } |
147 | virtual bool getFile(const QString& href) { return false; } | 146 | virtual bool getFile(const QString& href) { return false; } |
148 | }; | 147 | }; |
149 | #endif | 148 | #endif |
diff --git a/noncore/apps/opie-reader/CFilter.cpp b/noncore/apps/opie-reader/CFilter.cpp index 6f76e9a..6d94d70 100644 --- a/noncore/apps/opie-reader/CFilter.cpp +++ b/noncore/apps/opie-reader/CFilter.cpp | |||
@@ -1,197 +1,196 @@ | |||
1 | #include <qmap.h> | 1 | #include <qmap.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | #include "useqpe.h" | ||
6 | #ifdef USEQPE | 5 | #ifdef USEQPE |
7 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
8 | #endif | 7 | #endif |
9 | #include "CDrawBuffer.h" | 8 | #include "CDrawBuffer.h" |
10 | #include "CFilter.h" | 9 | #include "CFilter.h" |
11 | #include "hrule.h" | 10 | #include "hrule.h" |
12 | #include "util.h" | 11 | #include "util.h" |
13 | 12 | ||
14 | #include <qregexp.h> | 13 | #include <qregexp.h> |
15 | #include <qimage.h> | 14 | #include <qimage.h> |
16 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
17 | //#include <qprogressdialog.h> | 16 | //#include <qprogressdialog.h> |
18 | //#include <qapplication.h> | 17 | //#include <qapplication.h> |
19 | 18 | ||
20 | void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) | 19 | void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) |
21 | { | 20 | { |
22 | if (uselast) | 21 | if (uselast) |
23 | { | 22 | { |
24 | ch = lastchar; | 23 | ch = lastchar; |
25 | uselast = false; | 24 | uselast = false; |
26 | } | 25 | } |
27 | else | 26 | else |
28 | { | 27 | { |
29 | parent->getch(ch, sty, pos); | 28 | parent->getch(ch, sty, pos); |
30 | } | 29 | } |
31 | } | 30 | } |
32 | 31 | ||
33 | void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 32 | void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
34 | { | 33 | { |
35 | mygetch(ch, sty, pos); | 34 | mygetch(ch, sty, pos); |
36 | do | 35 | do |
37 | { | 36 | { |
38 | sty = currentstyle; | 37 | sty = currentstyle; |
39 | switch (ch) | 38 | switch (ch) |
40 | { | 39 | { |
41 | case 10: | 40 | case 10: |
42 | currentstyle.unset(); | 41 | currentstyle.unset(); |
43 | sty = currentstyle; | 42 | sty = currentstyle; |
44 | break; | 43 | break; |
45 | // Use this if you want to replace -- by em-dash | 44 | // Use this if you want to replace -- by em-dash |
46 | case '-': | 45 | case '-': |
47 | // parent->getch(ch, sty); | 46 | // parent->getch(ch, sty); |
48 | mygetch(ch, sty, pos); | 47 | mygetch(ch, sty, pos); |
49 | if (ch == '-') | 48 | if (ch == '-') |
50 | { | 49 | { |
51 | ch = 0x2014; | 50 | ch = 0x2014; |
52 | } | 51 | } |
53 | else | 52 | else |
54 | { | 53 | { |
55 | lastchar = ch; | 54 | lastchar = ch; |
56 | uselast = true; | 55 | uselast = true; |
57 | ch = '-'; | 56 | ch = '-'; |
58 | } | 57 | } |
59 | break; | 58 | break; |
60 | case '*': | 59 | case '*': |
61 | if (currentstyle.isBold()) | 60 | if (currentstyle.isBold()) |
62 | { | 61 | { |
63 | // Already bold - time to turn it off? | 62 | // Already bold - time to turn it off? |
64 | // The next two lines ensure that * follows a character but it works better without | 63 | // The next two lines ensure that * follows a character but it works better without |
65 | // QChar c(lastchar); | 64 | // QChar c(lastchar); |
66 | // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber())) | 65 | // if ((lastchar != '*') && (c.isPunct() || c.isLetterOrNumber())) |
67 | if (lastchar != '*') | 66 | if (lastchar != '*') |
68 | { | 67 | { |
69 | currentstyle.unsetBold(); | 68 | currentstyle.unsetBold(); |
70 | CStyle dummy; | 69 | CStyle dummy; |
71 | // parent->getch(ch, dummy); | 70 | // parent->getch(ch, dummy); |
72 | mygetch(ch, dummy, pos); | 71 | mygetch(ch, dummy, pos); |
73 | } | 72 | } |
74 | } | 73 | } |
75 | else | 74 | else |
76 | { | 75 | { |
77 | // not bold - time to turn it on? | 76 | // not bold - time to turn it on? |
78 | CStyle dummy; | 77 | CStyle dummy; |
79 | // parent->getch(ch, dummy); | 78 | // parent->getch(ch, dummy); |
80 | mygetch(ch, dummy, pos); | 79 | mygetch(ch, dummy, pos); |
81 | QChar c(ch); | 80 | QChar c(ch); |
82 | if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber())) | 81 | if ((ch != '*') && (c.isPunct() || c.isLetterOrNumber())) |
83 | { | 82 | { |
84 | currentstyle.setBold(); | 83 | currentstyle.setBold(); |
85 | } | 84 | } |
86 | else | 85 | else |
87 | { | 86 | { |
88 | lastchar = ch; | 87 | lastchar = ch; |
89 | uselast = true; | 88 | uselast = true; |
90 | ch = '*'; | 89 | ch = '*'; |
91 | } | 90 | } |
92 | 91 | ||
93 | } | 92 | } |
94 | break; | 93 | break; |
95 | case '_': | 94 | case '_': |
96 | if (currentstyle.isItalic()) | 95 | if (currentstyle.isItalic()) |
97 | { | 96 | { |
98 | // Already bold - time to turn it off? | 97 | // Already bold - time to turn it off? |
99 | // The next two lines ensure that * follows a character but it works better without | 98 | // The next two lines ensure that * follows a character but it works better without |
100 | // QChar c(lastchar); | 99 | // QChar c(lastchar); |
101 | // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber())) | 100 | // if ((lastchar != '_') && (c.isPunct() || c.isLetterOrNumber())) |
102 | if (lastchar != '_') | 101 | if (lastchar != '_') |
103 | { | 102 | { |
104 | currentstyle.unsetItalic(); | 103 | currentstyle.unsetItalic(); |
105 | CStyle dummy; | 104 | CStyle dummy; |
106 | // parent->getch(ch, dummy); | 105 | // parent->getch(ch, dummy); |
107 | mygetch(ch, dummy, pos); | 106 | mygetch(ch, dummy, pos); |
108 | } | 107 | } |
109 | } | 108 | } |
110 | else | 109 | else |
111 | { | 110 | { |
112 | // not bold - time to turn it on? | 111 | // not bold - time to turn it on? |
113 | CStyle dummy; | 112 | CStyle dummy; |
114 | // parent->getch(ch, dummy); | 113 | // parent->getch(ch, dummy); |
115 | mygetch(ch, dummy, pos); | 114 | mygetch(ch, dummy, pos); |
116 | QChar c(ch); | 115 | QChar c(ch); |
117 | if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber())) | 116 | if ((ch != '_') && (c.isPunct() || c.isLetterOrNumber())) |
118 | { | 117 | { |
119 | currentstyle.setItalic(); | 118 | currentstyle.setItalic(); |
120 | } | 119 | } |
121 | else | 120 | else |
122 | { | 121 | { |
123 | lastchar = ch; | 122 | lastchar = ch; |
124 | uselast = true; | 123 | uselast = true; |
125 | ch = '_'; | 124 | ch = '_'; |
126 | } | 125 | } |
127 | 126 | ||
128 | } | 127 | } |
129 | break; | 128 | break; |
130 | } | 129 | } |
131 | } | 130 | } |
132 | while (sty != currentstyle); | 131 | while (sty != currentstyle); |
133 | if (!uselast) lastchar = ch; | 132 | if (!uselast) lastchar = ch; |
134 | return; | 133 | return; |
135 | } | 134 | } |
136 | 135 | ||
137 | void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 136 | void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
138 | { | 137 | { |
139 | if (q[offset] != 0) | 138 | if (q[offset] != 0) |
140 | { | 139 | { |
141 | q[offset++]; | 140 | q[offset++]; |
142 | sty = currentstyle; | 141 | sty = currentstyle; |
143 | return; | 142 | return; |
144 | } | 143 | } |
145 | parent->getch(ch, sty, pos); | 144 | parent->getch(ch, sty, pos); |
146 | switch (ch) | 145 | switch (ch) |
147 | { | 146 | { |
148 | case 0x201a: | 147 | case 0x201a: |
149 | ch = '\''; | 148 | ch = '\''; |
150 | break; | 149 | break; |
151 | case 0x0192: | 150 | case 0x0192: |
152 | ch = 'f'; | 151 | ch = 'f'; |
153 | break; | 152 | break; |
154 | case 0x201e: | 153 | case 0x201e: |
155 | ch = '"'; | 154 | ch = '"'; |
156 | break; | 155 | break; |
157 | case 0x2026: | 156 | case 0x2026: |
158 | offset = 0; | 157 | offset = 0; |
159 | q[0] = '.'; | 158 | q[0] = '.'; |
160 | q[1] = '.'; | 159 | q[1] = '.'; |
161 | q[2] = 0; | 160 | q[2] = 0; |
162 | ch = '.'; // should be ... | 161 | ch = '.'; // should be ... |
163 | break; | 162 | break; |
164 | case 0x0160: | 163 | case 0x0160: |
165 | ch = 'S'; | 164 | ch = 'S'; |
166 | break; | 165 | break; |
167 | case 0x2039: | 166 | case 0x2039: |
168 | ch = '<'; | 167 | ch = '<'; |
169 | break; | 168 | break; |
170 | case 0x0152: | 169 | case 0x0152: |
171 | offset = 0; | 170 | offset = 0; |
172 | q[0] = 'E'; | 171 | q[0] = 'E'; |
173 | q[1] = 0; | 172 | q[1] = 0; |
174 | ch = 'O'; | 173 | ch = 'O'; |
175 | break; | 174 | break; |
176 | case 0x017d: | 175 | case 0x017d: |
177 | ch = 'Z'; | 176 | ch = 'Z'; |
178 | break; | 177 | break; |
179 | case 0x2018: | 178 | case 0x2018: |
180 | ch = '\''; | 179 | ch = '\''; |
181 | break; | 180 | break; |
182 | case 0x2019: | 181 | case 0x2019: |
183 | ch = '\''; | 182 | ch = '\''; |
184 | break; | 183 | break; |
185 | case 0x201c: | 184 | case 0x201c: |
186 | ch = '"'; | 185 | ch = '"'; |
187 | break; | 186 | break; |
188 | case 0x201d: | 187 | case 0x201d: |
189 | ch = '"'; | 188 | ch = '"'; |
190 | break; | 189 | break; |
191 | case 0x2022: | 190 | case 0x2022: |
192 | ch = '>'; | 191 | ch = '>'; |
193 | break; | 192 | break; |
194 | case 0x2013: | 193 | case 0x2013: |
195 | ch = '-'; | 194 | ch = '-'; |
196 | break; | 195 | break; |
197 | case 0x2014: | 196 | case 0x2014: |
diff --git a/noncore/apps/opie-reader/CFilter.h b/noncore/apps/opie-reader/CFilter.h index cec9618..174e6b4 100644 --- a/noncore/apps/opie-reader/CFilter.h +++ b/noncore/apps/opie-reader/CFilter.h | |||
@@ -202,274 +202,273 @@ class unindent : public CFilter | |||
202 | else parent->getch(ch, sty, pos); | 202 | else parent->getch(ch, sty, pos); |
203 | lc = ch; | 203 | lc = ch; |
204 | return; | 204 | return; |
205 | } | 205 | } |
206 | QString about() { return QString("Unindent filter (c) Tim Wentford\n")+parent->about(); } | 206 | QString about() { return QString("Unindent filter (c) Tim Wentford\n")+parent->about(); } |
207 | }; | 207 | }; |
208 | 208 | ||
209 | class CRegExpFilt; | 209 | class CRegExpFilt; |
210 | class repara : public CFilter | 210 | class repara : public CFilter |
211 | { | 211 | { |
212 | tchar tch; | 212 | tchar tch; |
213 | CRegExpFilt* flt; | 213 | CRegExpFilt* flt; |
214 | public: | 214 | public: |
215 | repara(const QString&); | 215 | repara(const QString&); |
216 | ~repara(); | 216 | ~repara(); |
217 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 217 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
218 | QString about() { return QString("Reparagraph filter (c) Tim Wentford\n")+parent->about(); } | 218 | QString about() { return QString("Reparagraph filter (c) Tim Wentford\n")+parent->about(); } |
219 | }; | 219 | }; |
220 | 220 | ||
221 | class indenter : public CFilter | 221 | class indenter : public CFilter |
222 | { | 222 | { |
223 | int amnt; | 223 | int amnt; |
224 | int indent; | 224 | int indent; |
225 | CStyle lsty; | 225 | CStyle lsty; |
226 | public: | 226 | public: |
227 | indenter(int _a=5) : amnt(_a), indent(0) {} | 227 | indenter(int _a=5) : amnt(_a), indent(0) {} |
228 | ~indenter() {} | 228 | ~indenter() {} |
229 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 229 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
230 | { | 230 | { |
231 | if (indent > 0) | 231 | if (indent > 0) |
232 | { | 232 | { |
233 | indent--; | 233 | indent--; |
234 | ch = ' '; | 234 | ch = ' '; |
235 | sty = lsty; | 235 | sty = lsty; |
236 | return; | 236 | return; |
237 | } | 237 | } |
238 | parent->getch(ch, sty, pos); | 238 | parent->getch(ch, sty, pos); |
239 | if (ch == 10) | 239 | if (ch == 10) |
240 | { | 240 | { |
241 | indent = amnt; | 241 | indent = amnt; |
242 | lsty = sty; | 242 | lsty = sty; |
243 | } | 243 | } |
244 | return; | 244 | return; |
245 | } | 245 | } |
246 | QString about() { return QString("Indentation filter (c) Tim Wentford\n")+parent->about(); } | 246 | QString about() { return QString("Indentation filter (c) Tim Wentford\n")+parent->about(); } |
247 | }; | 247 | }; |
248 | 248 | ||
249 | class dblspce : public CFilter | 249 | class dblspce : public CFilter |
250 | { | 250 | { |
251 | bool lastlf; | 251 | bool lastlf; |
252 | CStyle lsty; | 252 | CStyle lsty; |
253 | public: | 253 | public: |
254 | dblspce() : lastlf(false) {} | 254 | dblspce() : lastlf(false) {} |
255 | ~dblspce() {} | 255 | ~dblspce() {} |
256 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 256 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
257 | { | 257 | { |
258 | if (lastlf) | 258 | if (lastlf) |
259 | { | 259 | { |
260 | lastlf = false; | 260 | lastlf = false; |
261 | ch = 10; | 261 | ch = 10; |
262 | sty = lsty; | 262 | sty = lsty; |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | parent->getch(ch, sty, pos); | 265 | parent->getch(ch, sty, pos); |
266 | if (lastlf = (ch == 10)) | 266 | if (lastlf = (ch == 10)) |
267 | { | 267 | { |
268 | lsty = sty; | 268 | lsty = sty; |
269 | } | 269 | } |
270 | return; | 270 | return; |
271 | } | 271 | } |
272 | QString about() { return QString("Double space (c) Tim Wentford\n")+parent->about(); } | 272 | QString about() { return QString("Double space (c) Tim Wentford\n")+parent->about(); } |
273 | }; | 273 | }; |
274 | 274 | ||
275 | class textfmt : public CFilter | 275 | class textfmt : public CFilter |
276 | { | 276 | { |
277 | CStyle currentstyle; | 277 | CStyle currentstyle; |
278 | tchar lastchar; | 278 | tchar lastchar; |
279 | bool uselast; | 279 | bool uselast; |
280 | void mygetch(tchar&, CStyle&, unsigned long& pos); | 280 | void mygetch(tchar&, CStyle&, unsigned long& pos); |
281 | public: | 281 | public: |
282 | textfmt() : lastchar(0), uselast(false) {} | 282 | textfmt() : lastchar(0), uselast(false) {} |
283 | ~textfmt() {} | 283 | ~textfmt() {} |
284 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 284 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
285 | QString about() { return QString("Text formatting filter (c) Tim Wentford\n")+parent->about(); } | 285 | QString about() { return QString("Text formatting filter (c) Tim Wentford\n")+parent->about(); } |
286 | }; | 286 | }; |
287 | 287 | ||
288 | class embolden : public CFilter | 288 | class embolden : public CFilter |
289 | { | 289 | { |
290 | public: | 290 | public: |
291 | embolden() {} | 291 | embolden() {} |
292 | ~embolden() {} | 292 | ~embolden() {} |
293 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 293 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
294 | { | 294 | { |
295 | parent->getch(ch, sty, pos); | 295 | parent->getch(ch, sty, pos); |
296 | sty.setBold(); | 296 | sty.setBold(); |
297 | } | 297 | } |
298 | QString about() { return QString("Emboldening filter (c) Tim Wentford\n")+parent->about(); } | 298 | QString about() { return QString("Emboldening filter (c) Tim Wentford\n")+parent->about(); } |
299 | }; | 299 | }; |
300 | 300 | ||
301 | class remap : public CFilter | 301 | class remap : public CFilter |
302 | { | 302 | { |
303 | tchar q[3]; | 303 | tchar q[3]; |
304 | int offset; | 304 | int offset; |
305 | CStyle currentstyle; | 305 | CStyle currentstyle; |
306 | public: | 306 | public: |
307 | remap() : offset(0) { q[0] = 0; } | 307 | remap() : offset(0) { q[0] = 0; } |
308 | ~remap() {} | 308 | ~remap() {} |
309 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 309 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
310 | QString about() { return QString("Character remapping filter (c) Tim Wentford\n")+parent->about(); } | 310 | QString about() { return QString("Character remapping filter (c) Tim Wentford\n")+parent->about(); } |
311 | }; | 311 | }; |
312 | 312 | ||
313 | class PeanutFormatter : public CFilter | 313 | class PeanutFormatter : public CFilter |
314 | { | 314 | { |
315 | CStyle currentstyle; | 315 | CStyle currentstyle; |
316 | public: | 316 | public: |
317 | ~PeanutFormatter() {} | 317 | ~PeanutFormatter() {} |
318 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 318 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
319 | QString about() { return QString("PML filter (c) Tim Wentford\n")+parent->about(); } | 319 | QString about() { return QString("PML filter (c) Tim Wentford\n")+parent->about(); } |
320 | }; | 320 | }; |
321 | 321 | ||
322 | class OnePara : public CFilter | 322 | class OnePara : public CFilter |
323 | { | 323 | { |
324 | tchar m_lastchar; | 324 | tchar m_lastchar; |
325 | public: | 325 | public: |
326 | OnePara() : m_lastchar(0) {} | 326 | OnePara() : m_lastchar(0) {} |
327 | ~OnePara() {} | 327 | ~OnePara() {} |
328 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 328 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
329 | QString about() { return QString("Single space filter (c) Tim Wentford\n")+parent->about(); } | 329 | QString about() { return QString("Single space filter (c) Tim Wentford\n")+parent->about(); } |
330 | }; | 330 | }; |
331 | 331 | ||
332 | class DePluck : public CFilter | 332 | class DePluck : public CFilter |
333 | { | 333 | { |
334 | tchar* nextpart; | 334 | tchar* nextpart; |
335 | tchar m_buffer; | 335 | tchar m_buffer; |
336 | int m_buffed; | 336 | int m_buffed; |
337 | int m_current; | 337 | int m_current; |
338 | bool m_debuff; | 338 | bool m_debuff; |
339 | CStyle m_laststyle; | 339 | CStyle m_laststyle; |
340 | public: | 340 | public: |
341 | DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {} | 341 | DePluck(tchar* t) : nextpart(t), m_buffer(0), m_buffed(0), m_current(0), m_debuff(false) {} |
342 | ~DePluck() {} | 342 | ~DePluck() {} |
343 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 343 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
344 | QString about() { return QString("Depluck filter (c) Tim Wentford\n")+parent->about(); } | 344 | QString about() { return QString("Depluck filter (c) Tim Wentford\n")+parent->about(); } |
345 | }; | 345 | }; |
346 | 346 | ||
347 | class repalm : public CFilter | 347 | class repalm : public CFilter |
348 | { | 348 | { |
349 | public: | 349 | public: |
350 | ~repalm() {} | 350 | ~repalm() {} |
351 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 351 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
352 | QString about() { return QString("Repalm filter (c) Tim Wentford\n")+parent->about(); } | 352 | QString about() { return QString("Repalm filter (c) Tim Wentford\n")+parent->about(); } |
353 | }; | 353 | }; |
354 | 354 | ||
355 | class FullJust : public CFilter | 355 | class FullJust : public CFilter |
356 | { | 356 | { |
357 | public: | 357 | public: |
358 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 358 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
359 | { | 359 | { |
360 | parent->getch(ch, sty, pos); | 360 | parent->getch(ch, sty, pos); |
361 | if (sty.getJustify() == m_AlignLeft) sty.setFullJustify(); | 361 | if (sty.getJustify() == m_AlignLeft) sty.setFullJustify(); |
362 | } | 362 | } |
363 | QString about() { return QString("Full justification filter (c) Tim Wentford\n")+parent->about(); } | 363 | QString about() { return QString("Full justification filter (c) Tim Wentford\n")+parent->about(); } |
364 | }; | 364 | }; |
365 | /* | 365 | /* |
366 | class AddSpace : public CFilter | 366 | class AddSpace : public CFilter |
367 | { | 367 | { |
368 | unsigned char m_espc; | 368 | unsigned char m_espc; |
369 | public: | 369 | public: |
370 | AddSpace(unsigned char s) : m_espc(s) {} | 370 | AddSpace(unsigned char s) : m_espc(s) {} |
371 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) | 371 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) |
372 | { | 372 | { |
373 | parent->getch(ch, sty, pos); | 373 | parent->getch(ch, sty, pos); |
374 | sty.setExtraSpace(m_espc); | 374 | sty.setExtraSpace(m_espc); |
375 | } | 375 | } |
376 | }; | 376 | }; |
377 | */ | 377 | */ |
378 | 378 | ||
379 | class QTReader; | 379 | class QTReader; |
380 | 380 | ||
381 | class HighlightFilter : public CFilter | 381 | class HighlightFilter : public CFilter |
382 | { | 382 | { |
383 | QTReader* pReader; | 383 | QTReader* pReader; |
384 | unsigned long lastpos, nextpos; | 384 | unsigned long lastpos, nextpos; |
385 | unsigned char red, green, blue; | 385 | unsigned char red, green, blue; |
386 | CList<Bkmk>* bkmks; | 386 | CList<Bkmk>* bkmks; |
387 | public: | 387 | public: |
388 | HighlightFilter(QTReader*); | 388 | HighlightFilter(QTReader*); |
389 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 389 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
390 | void refresh(unsigned long); | 390 | void refresh(unsigned long); |
391 | QString about() { return QString("High-lighting filter (c) Tim Wentford\n")+parent->about(); } | 391 | QString about() { return QString("High-lighting filter (c) Tim Wentford\n")+parent->about(); } |
392 | }; | 392 | }; |
393 | 393 | ||
394 | #include "static.h" | ||
395 | #ifndef __STATIC | 394 | #ifndef __STATIC |
396 | #include <dlfcn.h> | 395 | #include <dlfcn.h> |
397 | 396 | ||
398 | class ExternFilter : public CFilter_IFace | 397 | class ExternFilter : public CFilter_IFace |
399 | { | 398 | { |
400 | CFilter* filt; | 399 | CFilter* filt; |
401 | void *handle; | 400 | void *handle; |
402 | public: | 401 | public: |
403 | linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) | 402 | linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) |
404 | { | 403 | { |
405 | return filt->hyperlink(n, noff, w, nm); | 404 | return filt->hyperlink(n, noff, w, nm); |
406 | } | 405 | } |
407 | void setparent(CCharacterSource* p) { filt->setparent(p); } | 406 | void setparent(CCharacterSource* p) { filt->setparent(p); } |
408 | ExternFilter(const QString& nm, const QString& optional); | 407 | ExternFilter(const QString& nm, const QString& optional); |
409 | ~ExternFilter() | 408 | ~ExternFilter() |
410 | { | 409 | { |
411 | if (filt != NULL) delete filt; | 410 | if (filt != NULL) delete filt; |
412 | if (handle != NULL) dlclose(handle); | 411 | if (handle != NULL) dlclose(handle); |
413 | } | 412 | } |
414 | void locate(unsigned int n) { filt->locate(n); } | 413 | void locate(unsigned int n) { filt->locate(n); } |
415 | bool findanchor(const QString& nm) { return filt->findanchor(nm); } | 414 | bool findanchor(const QString& nm) { return filt->findanchor(nm); } |
416 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } | 415 | void saveposn(const QString& f, size_t posn) { filt->saveposn(f, posn); } |
417 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } | 416 | void writeposn(const QString& f, size_t posn) { filt->writeposn(f, posn); } |
418 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } | 417 | linkType forward(QString& f, size_t& loc) { return filt->forward(f, loc); } |
419 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } | 418 | linkType back(QString& f, size_t& loc) { return filt->back(f, loc); } |
420 | bool hasnavigation() { return filt->hasnavigation(); } | 419 | bool hasnavigation() { return filt->hasnavigation(); } |
421 | int getwidth() { return filt->getwidth(); } | 420 | int getwidth() { return filt->getwidth(); } |
422 | CCharacterSource* getparent() { return filt->getparent(); } | 421 | CCharacterSource* getparent() { return filt->getparent(); } |
423 | void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } | 422 | void getch(tchar& c, CStyle& s, unsigned long& l) { filt->getch(c, s, l); } |
424 | QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } | 423 | QImage* getPicture(unsigned long tgt) { return filt->getPicture(tgt); } |
425 | CFilter* filter() { return filt; } | 424 | CFilter* filter() { return filt; } |
426 | QImage* getPicture(const QString& href) { return filt->getPicture(href); } | 425 | QImage* getPicture(const QString& href) { return filt->getPicture(href); } |
427 | bool getFile(const QString& href) { return filt->getFile(href); } | 426 | bool getFile(const QString& href) { return filt->getFile(href); } |
428 | QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); } | 427 | QString about() { return QString("Filter plug-in (c) Tim Wentford\n")+filt->about(); } |
429 | }; | 428 | }; |
430 | #endif | 429 | #endif |
431 | 430 | ||
432 | class kern : public CFilter | 431 | class kern : public CFilter |
433 | { | 432 | { |
434 | tchar lastchar; | 433 | tchar lastchar; |
435 | bool uselast; | 434 | bool uselast; |
436 | CStyle laststy; | 435 | CStyle laststy; |
437 | public: | 436 | public: |
438 | kern() : lastchar(0), uselast(false) {} | 437 | kern() : lastchar(0), uselast(false) {} |
439 | ~kern() {} | 438 | ~kern() {} |
440 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 439 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
441 | QString about() { return QString("Kerning filter (c) Tim Wentford\n")+parent->about(); } | 440 | QString about() { return QString("Kerning filter (c) Tim Wentford\n")+parent->about(); } |
442 | }; | 441 | }; |
443 | 442 | ||
444 | class makeInverse : public CFilter | 443 | class makeInverse : public CFilter |
445 | { | 444 | { |
446 | public: | 445 | public: |
447 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 446 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
448 | QString about() { return QString("Colourmap inversion filter (c) Tim Wentford\n")+parent->about(); } | 447 | QString about() { return QString("Colourmap inversion filter (c) Tim Wentford\n")+parent->about(); } |
449 | }; | 448 | }; |
450 | /* | 449 | /* |
451 | class makeNegative : public CFilter | 450 | class makeNegative : public CFilter |
452 | { | 451 | { |
453 | public: | 452 | public: |
454 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 453 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
455 | }; | 454 | }; |
456 | */ | 455 | */ |
457 | class setbg : public CFilter | 456 | class setbg : public CFilter |
458 | { | 457 | { |
459 | int m_r, m_g, m_b; | 458 | int m_r, m_g, m_b; |
460 | public: | 459 | public: |
461 | setbg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} | 460 | setbg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} |
462 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 461 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
463 | QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } | 462 | QString about() { return QString("Background colour filter (c) Tim Wentford\n")+parent->about(); } |
464 | }; | 463 | }; |
465 | 464 | ||
466 | class setfg : public CFilter | 465 | class setfg : public CFilter |
467 | { | 466 | { |
468 | int m_r, m_g, m_b; | 467 | int m_r, m_g, m_b; |
469 | public: | 468 | public: |
470 | setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} | 469 | setfg(int _r, int _g, int _b) : m_r(_r), m_g(_g), m_b(_b) {} |
471 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); | 470 | void getch(tchar& ch, CStyle& sty, unsigned long& pos); |
472 | QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } | 471 | QString about() { return QString("Foreground colour filter (c) Tim Wentford\n")+parent->about(); } |
473 | }; | 472 | }; |
474 | 473 | ||
475 | #endif | 474 | #endif |
diff --git a/noncore/apps/opie-reader/CHM.cpp b/noncore/apps/opie-reader/CHM.cpp index 9d1eb87..88d53bf 100644 --- a/noncore/apps/opie-reader/CHM.cpp +++ b/noncore/apps/opie-reader/CHM.cpp | |||
@@ -1,195 +1,194 @@ | |||
1 | #include "CHM.h" | 1 | #include "CHM.h" |
2 | #include "chm_lib.h" | 2 | #include "chm_lib.h" |
3 | #include "static.h" | ||
4 | #include <qstring.h> | 3 | #include <qstring.h> |
5 | #include <qstringlist.h> | 4 | #include <qstringlist.h> |
6 | #include <stdio.h> | 5 | #include <stdio.h> |
7 | #include <qimage.h> | 6 | #include <qimage.h> |
8 | #include <qpixmap.h> | 7 | #include <qpixmap.h> |
9 | 8 | ||
10 | #ifndef __STATIC | 9 | #ifndef __STATIC |
11 | extern "C" | 10 | extern "C" |
12 | { | 11 | { |
13 | CExpander* newcodec() { return new CHM; } | 12 | CExpander* newcodec() { return new CHM; } |
14 | } | 13 | } |
15 | #endif | 14 | #endif |
16 | 15 | ||
17 | static int _print_ui_index(struct chmFile *h, struct chmUnitInfo *ui, | 16 | static int _print_ui_index(struct chmFile *h, struct chmUnitInfo *ui, |
18 | void *context) | 17 | void *context) |
19 | { | 18 | { |
20 | CHM *chm = (CHM *)context; | 19 | CHM *chm = (CHM *)context; |
21 | QString temp = "<tr>"; | 20 | QString temp = "<tr>"; |
22 | char buff[1024]; | 21 | char buff[1024]; |
23 | sprintf( buff,"<td align=right>%8d\n</td><td><a href=\"%s\">%s</a></td></tr>",(int)ui->length, ui->path, ui->path); | 22 | sprintf( buff,"<td align=right>%8d\n</td><td><a href=\"%s\">%s</a></td></tr>",(int)ui->length, ui->path, ui->path); |
24 | temp += buff; | 23 | temp += buff; |
25 | chm->addContent(temp); | 24 | chm->addContent(temp); |
26 | return CHM_ENUMERATOR_CONTINUE; | 25 | return CHM_ENUMERATOR_CONTINUE; |
27 | } | 26 | } |
28 | 27 | ||
29 | static int _get_hhc (struct chmFile *h, struct chmUnitInfo *ui, | 28 | static int _get_hhc (struct chmFile *h, struct chmUnitInfo *ui, |
30 | void *context) | 29 | void *context) |
31 | { | 30 | { |
32 | CHM *chm = (CHM *)context; | 31 | CHM *chm = (CHM *)context; |
33 | QString PathName = ui->path; | 32 | QString PathName = ui->path; |
34 | if (PathName.find(".hhc") > -1) { | 33 | if (PathName.find(".hhc") > -1) { |
35 | chm->setPath(PathName); | 34 | chm->setPath(PathName); |
36 | } | 35 | } |
37 | return CHM_ENUMERATOR_CONTINUE; | 36 | return CHM_ENUMERATOR_CONTINUE; |
38 | } | 37 | } |
39 | 38 | ||
40 | CHM::CHM() { | 39 | CHM::CHM() { |
41 | chmFile = NULL; | 40 | chmFile = NULL; |
42 | chmPath = ""; | 41 | chmPath = ""; |
43 | chmHHCPath = ""; | 42 | chmHHCPath = ""; |
44 | chmBuffer = ""; | 43 | chmBuffer = ""; |
45 | bufpos = 0; | 44 | bufpos = 0; |
46 | } | 45 | } |
47 | 46 | ||
48 | CHM::~CHM() { | 47 | CHM::~CHM() { |
49 | if (chmFile != NULL) | 48 | if (chmFile != NULL) |
50 | chm_close(chmFile); | 49 | chm_close(chmFile); |
51 | } | 50 | } |
52 | 51 | ||
53 | void CHM::suspend() { | 52 | void CHM::suspend() { |
54 | #ifdef USEQPE | 53 | #ifdef USEQPE |
55 | bSuspended = true; | 54 | bSuspended = true; |
56 | //suspos = gztell(file); | 55 | //suspos = gztell(file); |
57 | chm_close(chmFile); | 56 | chm_close(chmFile); |
58 | chmFile = NULL; | 57 | chmFile = NULL; |
59 | sustime = time(NULL); | 58 | sustime = time(NULL); |
60 | #endif | 59 | #endif |
61 | } | 60 | } |
62 | 61 | ||
63 | void CHM::unsuspend() { | 62 | void CHM::unsuspend() { |
64 | #ifdef USEQPE | 63 | #ifdef USEQPE |
65 | if (bSuspended) | 64 | if (bSuspended) |
66 | { | 65 | { |
67 | bSuspended = false; | 66 | bSuspended = false; |
68 | int delay = time(NULL) - sustime; | 67 | int delay = time(NULL) - sustime; |
69 | if (delay < 10) | 68 | if (delay < 10) |
70 | sleep(10-delay); | 69 | sleep(10-delay); |
71 | chmFile = chm_open(fname); | 70 | chmFile = chm_open(fname); |
72 | for (int i = 0; chmFile == NULL && i < 5; i++) { | 71 | for (int i = 0; chmFile == NULL && i < 5; i++) { |
73 | sleep(5); | 72 | sleep(5); |
74 | chmFile = chm_open(fname); | 73 | chmFile = chm_open(fname); |
75 | } | 74 | } |
76 | if (chmFile == NULL) { | 75 | if (chmFile == NULL) { |
77 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 76 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
78 | exit(0); | 77 | exit(0); |
79 | } | 78 | } |
80 | //suspos = gzseek(file, suspos, SEEK_SET); | 79 | //suspos = gzseek(file, suspos, SEEK_SET); |
81 | } | 80 | } |
82 | #endif | 81 | #endif |
83 | } | 82 | } |
84 | 83 | ||
85 | void CHM::addContent(QString content) { | 84 | void CHM::addContent(QString content) { |
86 | chmBuffer += content; | 85 | chmBuffer += content; |
87 | } | 86 | } |
88 | 87 | ||
89 | void CHM::FillHomeContent() { | 88 | void CHM::FillHomeContent() { |
90 | if (chmHHCPath != "") { | 89 | if (chmHHCPath != "") { |
91 | const char *ext; | 90 | const char *ext; |
92 | char buffer[65536]; | 91 | char buffer[65536]; |
93 | unsigned int swath, offset; | 92 | unsigned int swath, offset; |
94 | QString tmp=""; | 93 | QString tmp=""; |
95 | QString HTML=""; | 94 | QString HTML=""; |
96 | /* try to find the file */ | 95 | /* try to find the file */ |
97 | const char *filename = (const char *)chmHHCPath; | 96 | const char *filename = (const char *)chmHHCPath; |
98 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) | 97 | if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) |
99 | { | 98 | { |
100 | chmBuffer = "HELP"; | 99 | chmBuffer = "HELP"; |
101 | fsize = chmBuffer.length(); | 100 | fsize = chmBuffer.length(); |
102 | return; | 101 | return; |
103 | } | 102 | } |
104 | m_homestart = m_ui.start; | 103 | m_homestart = m_ui.start; |
105 | m_homeend = m_homestart + m_ui.length; | 104 | m_homeend = m_homestart + m_ui.length; |
106 | swath = 65536; | 105 | swath = 65536; |
107 | offset = 0; | 106 | offset = 0; |
108 | fsize = m_ui.length; | 107 | fsize = m_ui.length; |
109 | while (offset < m_ui.length) | 108 | while (offset < m_ui.length) |
110 | { | 109 | { |
111 | if ((m_ui.length - offset) < 65536) | 110 | if ((m_ui.length - offset) < 65536) |
112 | swath = m_ui.length - offset; | 111 | swath = m_ui.length - offset; |
113 | else | 112 | else |
114 | swath = 65536; | 113 | swath = 65536; |
115 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); | 114 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); |
116 | tmp += buffer; | 115 | tmp += buffer; |
117 | offset += swath; | 116 | offset += swath; |
118 | } | 117 | } |
119 | HTML +="<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN>\r\n"; | 118 | HTML +="<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN>\r\n"; |
120 | HTML +="<HTML>\r\n"; | 119 | HTML +="<HTML>\r\n"; |
121 | HTML +="<BODY>\r\n"; | 120 | HTML +="<BODY>\r\n"; |
122 | HTML +="<h2>Home Page</h2>\r\n"; | 121 | HTML +="<h2>Home Page</h2>\r\n"; |
123 | HTML +="<h3>\r\n"; | 122 | HTML +="<h3>\r\n"; |
124 | QStringList qsl = QStringList::split("\r\n",tmp); | 123 | QStringList qsl = QStringList::split("\r\n",tmp); |
125 | QString NameFind ="<param name=\"Name\" value=\""; | 124 | QString NameFind ="<param name=\"Name\" value=\""; |
126 | QString LocalFind = "<param name=\"Local\" value=\""; | 125 | QString LocalFind = "<param name=\"Local\" value=\""; |
127 | QString ULOpenFind = "<UL>"; | 126 | QString ULOpenFind = "<UL>"; |
128 | QString LIOpenFind = "<LI>"; | 127 | QString LIOpenFind = "<LI>"; |
129 | QString ULCloseFind = "</UL>"; | 128 | QString ULCloseFind = "</UL>"; |
130 | QString Name = ""; | 129 | QString Name = ""; |
131 | QString Local = ""; | 130 | QString Local = ""; |
132 | for ( QStringList::Iterator it = qsl.begin(); it != qsl.end(); ++it ) { | 131 | for ( QStringList::Iterator it = qsl.begin(); it != qsl.end(); ++it ) { |
133 | QString Line = (*it); | 132 | QString Line = (*it); |
134 | int NamePos = Line.find( NameFind); | 133 | int NamePos = Line.find( NameFind); |
135 | int LocalPos = Line.find( LocalFind); | 134 | int LocalPos = Line.find( LocalFind); |
136 | if (NamePos > -1) { | 135 | if (NamePos > -1) { |
137 | Name = Line.mid(NamePos+NameFind.length(),Line.length()); | 136 | Name = Line.mid(NamePos+NameFind.length(),Line.length()); |
138 | Name = Name.left(Name.length() - 2); | 137 | Name = Name.left(Name.length() - 2); |
139 | } | 138 | } |
140 | if (LocalPos > -1) { | 139 | if (LocalPos > -1) { |
141 | Local = Line.mid(LocalPos+LocalFind.length(),Line.length()); | 140 | Local = Line.mid(LocalPos+LocalFind.length(),Line.length()); |
142 | Local = Local.left(Local.length() - 2); | 141 | Local = Local.left(Local.length() - 2); |
143 | if (Name != "") { | 142 | if (Name != "") { |
144 | HTML += "<br>\r\n<a href="; | 143 | HTML += "<br>\r\n<a href="; |
145 | HTML += Local; | 144 | HTML += Local; |
146 | HTML += ">"; | 145 | HTML += ">"; |
147 | HTML += Name; | 146 | HTML += Name; |
148 | HTML += "</a>\r\n"; | 147 | HTML += "</a>\r\n"; |
149 | Name = ""; | 148 | Name = ""; |
150 | } | 149 | } |
151 | } | 150 | } |
152 | } | 151 | } |
153 | HTML +="</h3>"; | 152 | HTML +="</h3>"; |
154 | HTML +="</BODY>\r\n"; | 153 | HTML +="</BODY>\r\n"; |
155 | HTML +="</HTML>\r\n"; | 154 | HTML +="</HTML>\r\n"; |
156 | chmHomeBuffer = HTML; | 155 | chmHomeBuffer = HTML; |
157 | chmBuffer = HTML; | 156 | chmBuffer = HTML; |
158 | fsize = chmBuffer.length(); | 157 | fsize = chmBuffer.length(); |
159 | m_currentstart = m_ui.start; | 158 | m_currentstart = m_ui.start; |
160 | m_currentend = m_currentstart+chmBuffer.length(); | 159 | m_currentend = m_currentstart+chmBuffer.length(); |
161 | } | 160 | } |
162 | } | 161 | } |
163 | 162 | ||
164 | bool CHM::FillBuffer() | 163 | bool CHM::FillBuffer() |
165 | { | 164 | { |
166 | bool bRetVal = false; | 165 | bool bRetVal = false; |
167 | char buffer[65536]; | 166 | char buffer[65536]; |
168 | int swath, offset; | 167 | int swath, offset; |
169 | chmBuffer = ""; | 168 | chmBuffer = ""; |
170 | swath = 65536; | 169 | swath = 65536; |
171 | offset = 0; | 170 | offset = 0; |
172 | fsize = m_ui.length; | 171 | fsize = m_ui.length; |
173 | while (offset < m_ui.length) | 172 | while (offset < m_ui.length) |
174 | { | 173 | { |
175 | if ((m_ui.length - offset) < 65536) | 174 | if ((m_ui.length - offset) < 65536) |
176 | swath = m_ui.length - offset; | 175 | swath = m_ui.length - offset; |
177 | else | 176 | else |
178 | swath = 65536; | 177 | swath = 65536; |
179 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); | 178 | swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); |
180 | chmBuffer += buffer; | 179 | chmBuffer += buffer; |
181 | offset += swath; | 180 | offset += swath; |
182 | } | 181 | } |
183 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it | 182 | //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it |
184 | QString temp = chmBuffer.lower(); | 183 | QString temp = chmBuffer.lower(); |
185 | int lpos = temp.find("</html"); | 184 | int lpos = temp.find("</html"); |
186 | if (lpos > -1) { | 185 | if (lpos > -1) { |
187 | chmBuffer.truncate(lpos); | 186 | chmBuffer.truncate(lpos); |
188 | chmBuffer = chmBuffer+"</HTML>"; | 187 | chmBuffer = chmBuffer+"</HTML>"; |
189 | } | 188 | } |
190 | fsize = chmBuffer.length(); | 189 | fsize = chmBuffer.length(); |
191 | 190 | ||
192 | bufpos = 0; | 191 | bufpos = 0; |
193 | bRetVal = true; | 192 | bRetVal = true; |
194 | m_currentstart = m_ui.start; | 193 | m_currentstart = m_ui.start; |
195 | m_currentend = m_currentstart+chmBuffer.length(); | 194 | m_currentend = m_currentstart+chmBuffer.length(); |
diff --git a/noncore/apps/opie-reader/CHM.h b/noncore/apps/opie-reader/CHM.h index 7dac46f..001f7fc 100644 --- a/noncore/apps/opie-reader/CHM.h +++ b/noncore/apps/opie-reader/CHM.h | |||
@@ -1,68 +1,67 @@ | |||
1 | #ifndef __CHM_h | 1 | #ifndef __CHM_h |
2 | #define __CHM_h | 2 | #define __CHM_h |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <sys/stat.h> | 4 | #include <sys/stat.h> |
5 | #include "useqpe.h" | ||
6 | #include "CExpander.h" | 5 | #include "CExpander.h" |
7 | #include "chm_lib.h" | 6 | #include "chm_lib.h" |
8 | #include "my_list.h" | 7 | #include "my_list.h" |
9 | #include "CExpander.h" | 8 | #include "CExpander.h" |
10 | 9 | ||
11 | struct Ref { | 10 | struct Ref { |
12 | QString RefName; | 11 | QString RefName; |
13 | QString RefLoc; | 12 | QString RefLoc; |
14 | int beginpos; | 13 | int beginpos; |
15 | int endpos; | 14 | int endpos; |
16 | }; | 15 | }; |
17 | 16 | ||
18 | struct Pic { | 17 | struct Pic { |
19 | QString RefName; | 18 | QString RefName; |
20 | QString RefLoc; | 19 | QString RefLoc; |
21 | int beginpos; | 20 | int beginpos; |
22 | int endpos; | 21 | int endpos; |
23 | }; | 22 | }; |
24 | 23 | ||
25 | class CHM : public CExpander | 24 | class CHM : public CExpander |
26 | { | 25 | { |
27 | void start2endSection(); | 26 | void start2endSection(); |
28 | struct chmUnitInfo m_ui; | 27 | struct chmUnitInfo m_ui; |
29 | struct chmFile *chmFile; | 28 | struct chmFile *chmFile; |
30 | chmUnitInfo chmui; | 29 | chmUnitInfo chmui; |
31 | //alloc a meg to buffer | 30 | //alloc a meg to buffer |
32 | QString chmHomeBuffer; | 31 | QString chmHomeBuffer; |
33 | QString chmBuffer; | 32 | QString chmBuffer; |
34 | QString chmPath; | 33 | QString chmPath; |
35 | QString chmHHCPath; | 34 | QString chmHHCPath; |
36 | unsigned int bufpos; | 35 | unsigned int bufpos; |
37 | unsigned long fsize; | 36 | unsigned long fsize; |
38 | unsigned long m_homestart, m_homeend; | 37 | unsigned long m_homestart, m_homeend; |
39 | public: | 38 | public: |
40 | void suspend(); | 39 | void suspend(); |
41 | void unsuspend(); | 40 | void unsuspend(); |
42 | bool hasnavigation() { return true; } | 41 | bool hasnavigation() { return true; } |
43 | 42 | ||
44 | CHM(); | 43 | CHM(); |
45 | virtual ~CHM(); | 44 | virtual ~CHM(); |
46 | int OpenFile(const char *src); | 45 | int OpenFile(const char *src); |
47 | int getch(); | 46 | int getch(); |
48 | unsigned int locate(); | 47 | unsigned int locate(); |
49 | void locate(unsigned int n); | 48 | void locate(unsigned int n); |
50 | bool hasrandomaccess() { return true; } | 49 | bool hasrandomaccess() { return true; } |
51 | void sizes(unsigned long& _file, unsigned long& _text); | 50 | void sizes(unsigned long& _file, unsigned long& _text); |
52 | void addContent(QString content); | 51 | void addContent(QString content); |
53 | void getch(tchar& ch, CStyle& sty); | 52 | void getch(tchar& ch, CStyle& sty); |
54 | void setPath(QString PathName) {chmPath = PathName;}; | 53 | void setPath(QString PathName) {chmPath = PathName;}; |
55 | void setHomePath(QString PathName) {chmHHCPath = PathName;}; | 54 | void setHomePath(QString PathName) {chmHHCPath = PathName;}; |
56 | 55 | ||
57 | MarkupType PreferredMarkup() { | 56 | MarkupType PreferredMarkup() { |
58 | return cCHM; | 57 | return cCHM; |
59 | } | 58 | } |
60 | bool getFile(const QString& href); | 59 | bool getFile(const QString& href); |
61 | QImage *getPicture(const QString& href); | 60 | QImage *getPicture(const QString& href); |
62 | QString about() { return QString("CHM codec (c) Bob Griffin\nchm_lib (c) Jed Wing\nLZX code (c) Stuart Cale"); } | 61 | QString about() { return QString("CHM codec (c) Bob Griffin\nchm_lib (c) Jed Wing\nLZX code (c) Stuart Cale"); } |
63 | private : | 62 | private : |
64 | bool FillBuffer(); | 63 | bool FillBuffer(); |
65 | bool FillContent(); | 64 | bool FillContent(); |
66 | void FillHomeContent(); | 65 | void FillHomeContent(); |
67 | }; | 66 | }; |
68 | #endif | 67 | #endif |
diff --git a/noncore/apps/opie-reader/CHM/CHM.pro b/noncore/apps/opie-reader/CHM/CHM.pro index 6ed86f6..d3a2a28 100644 --- a/noncore/apps/opie-reader/CHM/CHM.pro +++ b/noncore/apps/opie-reader/CHM/CHM.pro | |||
@@ -1,18 +1,18 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = CHM.h chm_lib.h lzx.h | 5 | HEADERS = CHM.h chm_lib.h lzx.h |
6 | 6 | ||
7 | SOURCES = CHM.cpp chm_lib.c lzx.c | 7 | SOURCES = CHM.cpp chm_lib.c lzx.c |
8 | 8 | ||
9 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
12 | TARGET = CHM | 12 | TARGET = CHM |
13 | LIBS += -lreader_codec | 13 | LIBS += -lreader_codec |
14 | 14 | ||
15 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 17 | ||
18 | include ( $(OPIEDIR)/include.pro ) \ No newline at end of file | 18 | include ( $(OPIEDIR)/include.pro ) \ No newline at end of file |
diff --git a/noncore/apps/opie-reader/CloseDialog.h b/noncore/apps/opie-reader/CloseDialog.h index 62e6423..54aaf1c 100644 --- a/noncore/apps/opie-reader/CloseDialog.h +++ b/noncore/apps/opie-reader/CloseDialog.h | |||
@@ -1,62 +1,61 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form interface generated from reading ui file 'Prefs.ui' | 2 | ** Form interface generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:32 2003 | 4 | ** Created: Tue Feb 11 23:53:32 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #ifndef __CLOSEDIALOG_H | 9 | #ifndef __CLOSEDIALOG_H |
10 | #define __CLOSEDIALOG_H | 10 | #define __CLOSEDIALOG_H |
11 | 11 | ||
12 | #include "useqpe.h" | ||
13 | #include <qvariant.h> | 12 | #include <qvariant.h> |
14 | #include <qwidget.h> | 13 | #include <qwidget.h> |
15 | #include <qtabdialog.h> | 14 | #include <qtabdialog.h> |
16 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
17 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
18 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
19 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
20 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
21 | //#include <qpe/menubutton.h> | 20 | //#include <qpe/menubutton.h> |
22 | #include <qvbuttongroup.h> | 21 | #include <qvbuttongroup.h> |
23 | 22 | ||
24 | class QVBoxLayout; | 23 | class QVBoxLayout; |
25 | class QHBoxLayout; | 24 | class QHBoxLayout; |
26 | class QGridLayout; | 25 | class QGridLayout; |
27 | //class QCheckBox; | 26 | //class QCheckBox; |
28 | class QLabel; | 27 | class QLabel; |
29 | //class QSpinBox; | 28 | //class QSpinBox; |
30 | 29 | ||
31 | class CCloseDialog : public QDialog | 30 | class CCloseDialog : public QDialog |
32 | { | 31 | { |
33 | Q_OBJECT | 32 | Q_OBJECT |
34 | QCheckBox *file, *marks, *config; | 33 | QCheckBox *file, *marks, *config; |
35 | #ifndef USEQPE | 34 | #ifndef USEQPE |
36 | void keyPressEvent(QKeyEvent* e) | 35 | void keyPressEvent(QKeyEvent* e) |
37 | { | 36 | { |
38 | switch (e->key()) | 37 | switch (e->key()) |
39 | { | 38 | { |
40 | case Key_Escape: | 39 | case Key_Escape: |
41 | e->accept(); | 40 | e->accept(); |
42 | reject(); | 41 | reject(); |
43 | break; | 42 | break; |
44 | case Key_Space: | 43 | case Key_Space: |
45 | case Key_Return: | 44 | case Key_Return: |
46 | e->accept(); | 45 | e->accept(); |
47 | accept(); | 46 | accept(); |
48 | break; | 47 | break; |
49 | default: | 48 | default: |
50 | QWidget::keyPressEvent(e); | 49 | QWidget::keyPressEvent(e); |
51 | } | 50 | } |
52 | } | 51 | } |
53 | #endif | 52 | #endif |
54 | public: | 53 | public: |
55 | CCloseDialog(const QString&, bool fs = true, QWidget* parent = 0, const char* name = 0); | 54 | CCloseDialog(const QString&, bool fs = true, QWidget* parent = 0, const char* name = 0); |
56 | ~CCloseDialog() {} | 55 | ~CCloseDialog() {} |
57 | bool delFile() { return file->isChecked(); } | 56 | bool delFile() { return file->isChecked(); } |
58 | bool delMarks() { return marks->isChecked(); } | 57 | bool delMarks() { return marks->isChecked(); } |
59 | bool delConfig() { return config->isChecked(); } | 58 | bool delConfig() { return config->isChecked(); } |
60 | 59 | ||
61 | }; | 60 | }; |
62 | #endif // CPREFS_H | 61 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/FontControl.cpp b/noncore/apps/opie-reader/FontControl.cpp index bbd9fe0..9bb3bc0 100644 --- a/noncore/apps/opie-reader/FontControl.cpp +++ b/noncore/apps/opie-reader/FontControl.cpp | |||
@@ -1,67 +1,66 @@ | |||
1 | #include <qfontdatabase.h> | 1 | #include <qfontdatabase.h> |
2 | #include "useqpe.h" | ||
3 | #include "FontControl.h" | 2 | #include "FontControl.h" |
4 | 3 | ||
5 | int FontControl::gzoom() | 4 | int FontControl::gzoom() |
6 | { | 5 | { |
7 | if (m_fixgraphics) | 6 | if (m_fixgraphics) |
8 | { | 7 | { |
9 | return 100; | 8 | return 100; |
10 | } | 9 | } |
11 | else | 10 | else |
12 | { | 11 | { |
13 | int ret; | 12 | int ret; |
14 | if (m_size == g_size) | 13 | if (m_size == g_size) |
15 | { | 14 | { |
16 | ret = m_fontsizes[m_size]*m_basesize; | 15 | ret = m_fontsizes[m_size]*m_basesize; |
17 | } | 16 | } |
18 | else if (g_size < 0) | 17 | else if (g_size < 0) |
19 | { | 18 | { |
20 | int f = -g_size; | 19 | int f = -g_size; |
21 | ret = (m_fontsizes[0]*m_basesize) >> (f/2); | 20 | ret = (m_fontsizes[0]*m_basesize) >> (f/2); |
22 | if (f%2) ret = (2*ret/3); | 21 | if (f%2) ret = (2*ret/3); |
23 | } | 22 | } |
24 | else | 23 | else |
25 | { | 24 | { |
26 | int f = g_size - m_maxsize + 1; | 25 | int f = g_size - m_maxsize + 1; |
27 | ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2); | 26 | ret = (m_fontsizes[m_maxsize-1]*m_basesize) << (f/2); |
28 | if (f%2) ret = (3*ret/2); | 27 | if (f%2) ret = (3*ret/2); |
29 | } | 28 | } |
30 | return ret; | 29 | return ret; |
31 | } | 30 | } |
32 | } | 31 | } |
33 | 32 | ||
34 | bool FontControl::ChangeFont(QString& n, int tgt) | 33 | bool FontControl::ChangeFont(QString& n, int tgt) |
35 | { | 34 | { |
36 | QValueList<int>::Iterator it; | 35 | QValueList<int>::Iterator it; |
37 | QFontDatabase fdb; | 36 | QFontDatabase fdb; |
38 | QValueList<int> sizes = fdb.pointSizes(n); | 37 | QValueList<int> sizes = fdb.pointSizes(n); |
39 | if (sizes.count() == 0) | 38 | if (sizes.count() == 0) |
40 | { | 39 | { |
41 | return false; | 40 | return false; |
42 | } | 41 | } |
43 | else | 42 | else |
44 | { | 43 | { |
45 | m_fontname = n; | 44 | m_fontname = n; |
46 | m_maxsize = sizes.count(); | 45 | m_maxsize = sizes.count(); |
47 | if (m_fontsizes != NULL) delete [] m_fontsizes; | 46 | if (m_fontsizes != NULL) delete [] m_fontsizes; |
48 | m_fontsizes = new int[m_maxsize]; | 47 | m_fontsizes = new int[m_maxsize]; |
49 | uint i = 0; | 48 | uint i = 0; |
50 | uint best = 0; | 49 | uint best = 0; |
51 | for (it = sizes.begin(); it != sizes.end(); it++) | 50 | for (it = sizes.begin(); it != sizes.end(); it++) |
52 | { | 51 | { |
53 | #if defined(OPIE) || !defined(USEQPE) | 52 | #if defined(OPIE) || !defined(USEQPE) |
54 | m_fontsizes[i] = (*it); | 53 | m_fontsizes[i] = (*it); |
55 | #else | 54 | #else |
56 | m_fontsizes[i] = (*it)/10; | 55 | m_fontsizes[i] = (*it)/10; |
57 | #endif | 56 | #endif |
58 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) | 57 | if (abs(tgt-m_fontsizes[i]) < abs(tgt-m_fontsizes[best])) |
59 | { | 58 | { |
60 | best = i; | 59 | best = i; |
61 | } | 60 | } |
62 | i++; | 61 | i++; |
63 | } | 62 | } |
64 | g_size = m_size = best; | 63 | g_size = m_size = best; |
65 | } | 64 | } |
66 | return true; | 65 | return true; |
67 | } | 66 | } |
diff --git a/noncore/apps/opie-reader/HTMLFilter/HTMLFilter.pro b/noncore/apps/opie-reader/HTMLFilter/HTMLFilter.pro index cc049a9..8eb6f17 100644 --- a/noncore/apps/opie-reader/HTMLFilter/HTMLFilter.pro +++ b/noncore/apps/opie-reader/HTMLFilter/HTMLFilter.pro | |||
@@ -1,20 +1,20 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = CFilter.h \ | 5 | HEADERS = CFilter.h \ |
6 | util.h | 6 | util.h |
7 | 7 | ||
8 | SOURCES = striphtml.cpp | 8 | SOURCES = striphtml.cpp |
9 | 9 | ||
10 | # copy data file to install directory | 10 | # copy data file to install directory |
11 | QMAKE_PRE_LINK = mkdir -p $(OPIEDIR)/plugins/reader/data && cp ../HTMLentities $(OPIEDIR)/plugins/reader/data/HTMLentities | 11 | QMAKE_PRE_LINK = mkdir -p $(OPIEDIR)/plugins/reader/data && cp ../HTMLentities $(OPIEDIR)/plugins/reader/data/HTMLentities |
12 | 12 | ||
13 | INTERFACES= | 13 | INTERFACES= |
14 | DESTDIR = $(OPIEDIR)/plugins/reader/filters | 14 | DESTDIR = $(OPIEDIR)/plugins/reader/filters |
15 | TARGET = HTMLfilter | 15 | TARGET = HTMLfilter |
16 | 16 | ||
17 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 17 | INCLUDEPATH+= $(OPIEDIR)/include |
18 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 18 | DEPENDPATH+= $(OPIEDIR)/include |
19 | 19 | ||
20 | include ( $(OPIEDIR)/include.pro ) | 20 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp index c1b7b7a..c6907eb 100644 --- a/noncore/apps/opie-reader/Palm2QImage.cpp +++ b/noncore/apps/opie-reader/Palm2QImage.cpp | |||
@@ -1,194 +1,193 @@ | |||
1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ | 1 | /* -*- mode: c; indent-tabs-mode: nil; -*- */ |
2 | #include "useqpe.h" | ||
3 | #include <stdio.h> | 2 | #include <stdio.h> |
4 | #include <stdlib.h> | 3 | #include <stdlib.h> |
5 | #include <string.h> | 4 | #include <string.h> |
6 | #ifndef _WINDOWS | 5 | #ifndef _WINDOWS |
7 | #include <unistd.h> /* for link */ | 6 | #include <unistd.h> /* for link */ |
8 | #endif | 7 | #endif |
9 | #include <sys/types.h> | 8 | #include <sys/types.h> |
10 | #include <sys/stat.h> | 9 | #include <sys/stat.h> |
11 | #include <stdarg.h> | 10 | #include <stdarg.h> |
12 | 11 | ||
13 | #include <qimage.h> | 12 | #include <qimage.h> |
14 | 13 | ||
15 | /***********************************************************************/ | 14 | /***********************************************************************/ |
16 | /***********************************************************************/ | 15 | /***********************************************************************/ |
17 | /***** *****/ | 16 | /***** *****/ |
18 | /***** Code to decode the Palm image format to JPEG *****/ | 17 | /***** Code to decode the Palm image format to JPEG *****/ |
19 | /***** *****/ | 18 | /***** *****/ |
20 | /***********************************************************************/ | 19 | /***********************************************************************/ |
21 | /***********************************************************************/ | 20 | /***********************************************************************/ |
22 | 21 | ||
23 | #define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) | 22 | #define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1])) |
24 | #define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) | 23 | #define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3])) |
25 | 24 | ||
26 | #define PALM_IS_COMPRESSED_FLAG 0x8000 | 25 | #define PALM_IS_COMPRESSED_FLAG 0x8000 |
27 | #define PALM_HAS_COLORMAP_FLAG 0x4000 | 26 | #define PALM_HAS_COLORMAP_FLAG 0x4000 |
28 | #define PALM_HAS_TRANSPARENCY_FLAG 0x2000 | 27 | #define PALM_HAS_TRANSPARENCY_FLAG 0x2000 |
29 | #define PALM_DIRECT_COLOR_FLAG 0x0400 | 28 | #define PALM_DIRECT_COLOR_FLAG 0x0400 |
30 | #define PALM_4_BYTE_FIELD_FLAG 0x0200 | 29 | #define PALM_4_BYTE_FIELD_FLAG 0x0200 |
31 | 30 | ||
32 | #define PALM_COMPRESSION_SCANLINE 0x00 | 31 | #define PALM_COMPRESSION_SCANLINE 0x00 |
33 | #define PALM_COMPRESSION_RLE 0x01 | 32 | #define PALM_COMPRESSION_RLE 0x01 |
34 | #define PALM_COMPRESSION_PACKBITS 0x02 | 33 | #define PALM_COMPRESSION_PACKBITS 0x02 |
35 | #define PALM_COMPRESSION_NONE 0xFF | 34 | #define PALM_COMPRESSION_NONE 0xFF |
36 | 35 | ||
37 | #define PALM_COLORMAP_SIZE 232 | 36 | #define PALM_COLORMAP_SIZE 232 |
38 | 37 | ||
39 | typedef struct { | 38 | typedef struct { |
40 | unsigned char red; | 39 | unsigned char red; |
41 | unsigned char green; | 40 | unsigned char green; |
42 | unsigned char blue; | 41 | unsigned char blue; |
43 | } ColorMapEntry; | 42 | } ColorMapEntry; |
44 | 43 | ||
45 | static ColorMapEntry Palm8BitColormap[] = { | 44 | static ColorMapEntry Palm8BitColormap[] = { |
46 | { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, | 45 | { 255, 255, 255 }, { 255, 204, 255 }, { 255, 153, 255 }, { 255, 102, 255 }, |
47 | { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, | 46 | { 255, 51, 255 }, { 255, 0, 255 }, { 255, 255, 204 }, { 255, 204, 204 }, |
48 | { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, | 47 | { 255, 153, 204 }, { 255, 102, 204 }, { 255, 51, 204 }, { 255, 0, 204 }, |
49 | { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, | 48 | { 255, 255, 153 }, { 255, 204, 153 }, { 255, 153, 153 }, { 255, 102, 153 }, |
50 | { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, | 49 | { 255, 51, 153 }, { 255, 0, 153 }, { 204, 255, 255 }, { 204, 204, 255 }, |
51 | { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, | 50 | { 204, 153, 255 }, { 204, 102, 255 }, { 204, 51, 255 }, { 204, 0, 255 }, |
52 | { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, | 51 | { 204, 255, 204 }, { 204, 204, 204 }, { 204, 153, 204 }, { 204, 102, 204 }, |
53 | { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, | 52 | { 204, 51, 204 }, { 204, 0, 204 }, { 204, 255, 153 }, { 204, 204, 153 }, |
54 | { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, | 53 | { 204, 153, 153 }, { 204, 102, 153 }, { 204, 51, 153 }, { 204, 0, 153 }, |
55 | { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, | 54 | { 153, 255, 255 }, { 153, 204, 255 }, { 153, 153, 255 }, { 153, 102, 255 }, |
56 | { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, | 55 | { 153, 51, 255 }, { 153, 0, 255 }, { 153, 255, 204 }, { 153, 204, 204 }, |
57 | { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, | 56 | { 153, 153, 204 }, { 153, 102, 204 }, { 153, 51, 204 }, { 153, 0, 204 }, |
58 | { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, | 57 | { 153, 255, 153 }, { 153, 204, 153 }, { 153, 153, 153 }, { 153, 102, 153 }, |
59 | { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, | 58 | { 153, 51, 153 }, { 153, 0, 153 }, { 102, 255, 255 }, { 102, 204, 255 }, |
60 | { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, | 59 | { 102, 153, 255 }, { 102, 102, 255 }, { 102, 51, 255 }, { 102, 0, 255 }, |
61 | { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, | 60 | { 102, 255, 204 }, { 102, 204, 204 }, { 102, 153, 204 }, { 102, 102, 204 }, |
62 | { 102, 51, 204 }, { 102, 0, 204 }, { 102, 255, 153 }, { 102, 204, 153 }, | 61 | { 102, 51, 204 }, { 102, 0, 204 }, { 102, 255, 153 }, { 102, 204, 153 }, |
63 | { 102, 153, 153 }, { 102, 102, 153 }, { 102, 51, 153 }, { 102, 0, 153 }, | 62 | { 102, 153, 153 }, { 102, 102, 153 }, { 102, 51, 153 }, { 102, 0, 153 }, |
64 | { 51, 255, 255 }, { 51, 204, 255 }, { 51, 153, 255 }, { 51, 102, 255 }, | 63 | { 51, 255, 255 }, { 51, 204, 255 }, { 51, 153, 255 }, { 51, 102, 255 }, |
65 | { 51, 51, 255 }, { 51, 0, 255 }, { 51, 255, 204 }, { 51, 204, 204 }, | 64 | { 51, 51, 255 }, { 51, 0, 255 }, { 51, 255, 204 }, { 51, 204, 204 }, |
66 | { 51, 153, 204 }, { 51, 102, 204 }, { 51, 51, 204 }, { 51, 0, 204 }, | 65 | { 51, 153, 204 }, { 51, 102, 204 }, { 51, 51, 204 }, { 51, 0, 204 }, |
67 | { 51, 255, 153 }, { 51, 204, 153 }, { 51, 153, 153 }, { 51, 102, 153 }, | 66 | { 51, 255, 153 }, { 51, 204, 153 }, { 51, 153, 153 }, { 51, 102, 153 }, |
68 | { 51, 51, 153 }, { 51, 0, 153 }, { 0, 255, 255 }, { 0, 204, 255 }, | 67 | { 51, 51, 153 }, { 51, 0, 153 }, { 0, 255, 255 }, { 0, 204, 255 }, |
69 | { 0, 153, 255 }, { 0, 102, 255 }, { 0, 51, 255 }, { 0, 0, 255 }, | 68 | { 0, 153, 255 }, { 0, 102, 255 }, { 0, 51, 255 }, { 0, 0, 255 }, |
70 | { 0, 255, 204 }, { 0, 204, 204 }, { 0, 153, 204 }, { 0, 102, 204 }, | 69 | { 0, 255, 204 }, { 0, 204, 204 }, { 0, 153, 204 }, { 0, 102, 204 }, |
71 | { 0, 51, 204 }, { 0, 0, 204 }, { 0, 255, 153 }, { 0, 204, 153 }, | 70 | { 0, 51, 204 }, { 0, 0, 204 }, { 0, 255, 153 }, { 0, 204, 153 }, |
72 | { 0, 153, 153 }, { 0, 102, 153 }, { 0, 51, 153 }, { 0, 0, 153 }, | 71 | { 0, 153, 153 }, { 0, 102, 153 }, { 0, 51, 153 }, { 0, 0, 153 }, |
73 | { 255, 255, 102 }, { 255, 204, 102 }, { 255, 153, 102 }, { 255, 102, 102 }, | 72 | { 255, 255, 102 }, { 255, 204, 102 }, { 255, 153, 102 }, { 255, 102, 102 }, |
74 | { 255, 51, 102 }, { 255, 0, 102 }, { 255, 255, 51 }, { 255, 204, 51 }, | 73 | { 255, 51, 102 }, { 255, 0, 102 }, { 255, 255, 51 }, { 255, 204, 51 }, |
75 | { 255, 153, 51 }, { 255, 102, 51 }, { 255, 51, 51 }, { 255, 0, 51 }, | 74 | { 255, 153, 51 }, { 255, 102, 51 }, { 255, 51, 51 }, { 255, 0, 51 }, |
76 | { 255, 255, 0 }, { 255, 204, 0 }, { 255, 153, 0 }, { 255, 102, 0 }, | 75 | { 255, 255, 0 }, { 255, 204, 0 }, { 255, 153, 0 }, { 255, 102, 0 }, |
77 | { 255, 51, 0 }, { 255, 0, 0 }, { 204, 255, 102 }, { 204, 204, 102 }, | 76 | { 255, 51, 0 }, { 255, 0, 0 }, { 204, 255, 102 }, { 204, 204, 102 }, |
78 | { 204, 153, 102 }, { 204, 102, 102 }, { 204, 51, 102 }, { 204, 0, 102 }, | 77 | { 204, 153, 102 }, { 204, 102, 102 }, { 204, 51, 102 }, { 204, 0, 102 }, |
79 | { 204, 255, 51 }, { 204, 204, 51 }, { 204, 153, 51 }, { 204, 102, 51 }, | 78 | { 204, 255, 51 }, { 204, 204, 51 }, { 204, 153, 51 }, { 204, 102, 51 }, |
80 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, | 79 | { 204, 51, 51 }, { 204, 0, 51 }, { 204, 255, 0 }, { 204, 204, 0 }, |
81 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, | 80 | { 204, 153, 0 }, { 204, 102, 0 }, { 204, 51, 0 }, { 204, 0, 0 }, |
82 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, | 81 | { 153, 255, 102 }, { 153, 204, 102 }, { 153, 153, 102 }, { 153, 102, 102 }, |
83 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, | 82 | { 153, 51, 102 }, { 153, 0, 102 }, { 153, 255, 51 }, { 153, 204, 51 }, |
84 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, | 83 | { 153, 153, 51 }, { 153, 102, 51 }, { 153, 51, 51 }, { 153, 0, 51 }, |
85 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, | 84 | { 153, 255, 0 }, { 153, 204, 0 }, { 153, 153, 0 }, { 153, 102, 0 }, |
86 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, | 85 | { 153, 51, 0 }, { 153, 0, 0 }, { 102, 255, 102 }, { 102, 204, 102 }, |
87 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, | 86 | { 102, 153, 102 }, { 102, 102, 102 }, { 102, 51, 102 }, { 102, 0, 102 }, |
88 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, | 87 | { 102, 255, 51 }, { 102, 204, 51 }, { 102, 153, 51 }, { 102, 102, 51 }, |
89 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, | 88 | { 102, 51, 51 }, { 102, 0, 51 }, { 102, 255, 0 }, { 102, 204, 0 }, |
90 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, | 89 | { 102, 153, 0 }, { 102, 102, 0 }, { 102, 51, 0 }, { 102, 0, 0 }, |
91 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, | 90 | { 51, 255, 102 }, { 51, 204, 102 }, { 51, 153, 102 }, { 51, 102, 102 }, |
92 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, | 91 | { 51, 51, 102 }, { 51, 0, 102 }, { 51, 255, 51 }, { 51, 204, 51 }, |
93 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, | 92 | { 51, 153, 51 }, { 51, 102, 51 }, { 51, 51, 51 }, { 51, 0, 51 }, |
94 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, | 93 | { 51, 255, 0 }, { 51, 204, 0 }, { 51, 153, 0 }, { 51, 102, 0 }, |
95 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, | 94 | { 51, 51, 0 }, { 51, 0, 0 }, { 0, 255, 102 }, { 0, 204, 102 }, |
96 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, | 95 | { 0, 153, 102 }, { 0, 102, 102 }, { 0, 51, 102 }, { 0, 0, 102 }, |
97 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, | 96 | { 0, 255, 51 }, { 0, 204, 51 }, { 0, 153, 51 }, { 0, 102, 51 }, |
98 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, | 97 | { 0, 51, 51 }, { 0, 0, 51 }, { 0, 255, 0 }, { 0, 204, 0 }, |
99 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, | 98 | { 0, 153, 0 }, { 0, 102, 0 }, { 0, 51, 0 }, { 17, 17, 17 }, |
100 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, | 99 | { 34, 34, 34 }, { 68, 68, 68 }, { 85, 85, 85 }, { 119, 119, 119 }, |
101 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, | 100 | { 136, 136, 136 }, { 170, 170, 170 }, { 187, 187, 187 }, { 221, 221, 221 }, |
102 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, | 101 | { 238, 238, 238 }, { 192, 192, 192 }, { 128, 0, 0 }, { 128, 0, 128 }, |
103 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, | 102 | { 0, 128, 0 }, { 0, 128, 128 }, { 0, 0, 0 }, { 0, 0, 0 }, |
104 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 103 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
105 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 104 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
106 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 105 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
107 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 106 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
108 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, | 107 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, |
109 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; | 108 | { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }}; |
110 | 109 | ||
111 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; | 110 | static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; |
112 | 111 | ||
113 | static ColorMapEntry Palm2BitColormap[] = { | 112 | static ColorMapEntry Palm2BitColormap[] = { |
114 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; | 113 | { 255, 255, 255 }, { 192, 192, 192 }, { 128, 128, 128 }, { 0, 0, 0 }}; |
115 | 114 | ||
116 | static ColorMapEntry Palm4BitColormap[] = { | 115 | static ColorMapEntry Palm4BitColormap[] = { |
117 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, | 116 | { 255, 255, 255 }, { 238, 238, 238 }, { 221, 221, 221 }, { 204, 204, 204 }, |
118 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, | 117 | { 187, 187, 187 }, { 170, 170, 170 }, { 153, 153, 153 }, { 136, 136, 136 }, |
119 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, | 118 | { 119, 119, 119 }, { 102, 102, 102 }, { 85, 85, 85 }, { 68, 68, 68 }, |
120 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; | 119 | { 51, 51, 51 }, { 34, 34, 34 }, { 17, 17, 17 }, { 0, 0, 0 }}; |
121 | 120 | ||
122 | QImage* Palm2QImage | 121 | QImage* Palm2QImage |
123 | (unsigned char *image_bytes_in, int byte_count_in) | 122 | (unsigned char *image_bytes_in, int byte_count_in) |
124 | { | 123 | { |
125 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; | 124 | unsigned int width, height, bytes_per_row, flags, next_depth_offset; |
126 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; | 125 | unsigned int bits_per_pixel, version, transparent_index, compression_type, i, j, inval, inbit, mask, incount; |
127 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; | 126 | unsigned int palm_red_bits, palm_green_bits, palm_blue_bits; |
128 | unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, | 127 | unsigned char *palm_ptr, *x_ptr, *imagedata, *inbyte, *rowbuf, *lastrow, |
129 | *imagedatastart, *palmimage; | 128 | *imagedatastart, *palmimage; |
130 | ColorMapEntry *colormap; | 129 | ColorMapEntry *colormap; |
131 | 130 | ||
132 | palmimage = image_bytes_in; | 131 | palmimage = image_bytes_in; |
133 | width = READ_BIGENDIAN_SHORT(palmimage + 0); | 132 | width = READ_BIGENDIAN_SHORT(palmimage + 0); |
134 | height = READ_BIGENDIAN_SHORT(palmimage + 2); | 133 | height = READ_BIGENDIAN_SHORT(palmimage + 2); |
135 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); | 134 | bytes_per_row = READ_BIGENDIAN_SHORT(palmimage + 4); |
136 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); | 135 | flags = READ_BIGENDIAN_SHORT(palmimage + 6); |
137 | bits_per_pixel = palmimage[8]; | 136 | bits_per_pixel = palmimage[8]; |
138 | version = palmimage[9]; | 137 | version = palmimage[9]; |
139 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); | 138 | next_depth_offset = READ_BIGENDIAN_SHORT(palmimage + 10); |
140 | transparent_index = palmimage[12]; | 139 | transparent_index = palmimage[12]; |
141 | compression_type = palmimage[13]; | 140 | compression_type = palmimage[13]; |
142 | /* bytes 14 and 15 are reserved by Palm and always 0 */ | 141 | /* bytes 14 and 15 are reserved by Palm and always 0 */ |
143 | 142 | ||
144 | #if 0 | 143 | #if 0 |
145 | // qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); | 144 | // qDebug ("Palm image is %dx%d, %d bpp, version %d, flags 0x%x, compression %d", width, height, bits_per_pixel, version, flags, compression_type); |
146 | #endif | 145 | #endif |
147 | 146 | ||
148 | if (compression_type == PALM_COMPRESSION_PACKBITS) { | 147 | if (compression_type == PALM_COMPRESSION_PACKBITS) { |
149 | // qDebug ("Image uses packbits compression; not yet supported"); | 148 | // qDebug ("Image uses packbits compression; not yet supported"); |
150 | return NULL; | 149 | return NULL; |
151 | } else if ((compression_type != PALM_COMPRESSION_NONE) && | 150 | } else if ((compression_type != PALM_COMPRESSION_NONE) && |
152 | (compression_type != PALM_COMPRESSION_RLE) && | 151 | (compression_type != PALM_COMPRESSION_RLE) && |
153 | (compression_type != PALM_COMPRESSION_SCANLINE)) { | 152 | (compression_type != PALM_COMPRESSION_SCANLINE)) { |
154 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); | 153 | // qDebug ("Image uses unknown compression, code 0x%x", compression_type); |
155 | return NULL; | 154 | return NULL; |
156 | } | 155 | } |
157 | 156 | ||
158 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: | 157 | /* as of PalmOS 4.0, there are 6 different kinds of Palm pixmaps: |
159 | 158 | ||
160 | 1, 2, or 4 bit grayscale | 159 | 1, 2, or 4 bit grayscale |
161 | 8-bit StaticColor using the Palm standard colormap | 160 | 8-bit StaticColor using the Palm standard colormap |
162 | 8-bit PseudoColor using a user-specified colormap | 161 | 8-bit PseudoColor using a user-specified colormap |
163 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue | 162 | 16-bit DirectColor using 5 bits for red, 6 for green, and 5 for blue |
164 | 163 | ||
165 | Each of these can be compressed with one of four compression schemes, | 164 | Each of these can be compressed with one of four compression schemes, |
166 | "RLE", "Scanline", "PackBits", or none. | 165 | "RLE", "Scanline", "PackBits", or none. |
167 | 166 | ||
168 | We begin by constructing the colormap. | 167 | We begin by constructing the colormap. |
169 | */ | 168 | */ |
170 | 169 | ||
171 | if (flags & PALM_HAS_COLORMAP_FLAG) { | 170 | if (flags & PALM_HAS_COLORMAP_FLAG) { |
172 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); | 171 | // qDebug("Palm images with custom colormaps are not currently supported.\n"); |
173 | return NULL; | 172 | return NULL; |
174 | } else if (bits_per_pixel == 1) { | 173 | } else if (bits_per_pixel == 1) { |
175 | colormap = Palm1BitColormap; | 174 | colormap = Palm1BitColormap; |
176 | imagedatastart = palmimage + 16; | 175 | imagedatastart = palmimage + 16; |
177 | } else if (bits_per_pixel == 2) { | 176 | } else if (bits_per_pixel == 2) { |
178 | colormap = Palm2BitColormap; | 177 | colormap = Palm2BitColormap; |
179 | imagedatastart = palmimage + 16; | 178 | imagedatastart = palmimage + 16; |
180 | } else if (bits_per_pixel == 4) { | 179 | } else if (bits_per_pixel == 4) { |
181 | colormap = Palm4BitColormap; | 180 | colormap = Palm4BitColormap; |
182 | imagedatastart = palmimage + 16; | 181 | imagedatastart = palmimage + 16; |
183 | } else if (bits_per_pixel == 8) { | 182 | } else if (bits_per_pixel == 8) { |
184 | colormap = Palm8BitColormap; | 183 | colormap = Palm8BitColormap; |
185 | imagedatastart = palmimage + 16; | 184 | imagedatastart = palmimage + 16; |
186 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { | 185 | } else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) { |
187 | colormap = NULL; | 186 | colormap = NULL; |
188 | palm_red_bits = palmimage[16]; | 187 | palm_red_bits = palmimage[16]; |
189 | palm_green_bits = palmimage[17]; | 188 | palm_green_bits = palmimage[17]; |
190 | palm_blue_bits = palmimage[18]; | 189 | palm_blue_bits = palmimage[18]; |
191 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); | 190 | // qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits); |
192 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { | 191 | if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) { |
193 | // qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); | 192 | // qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits); |
194 | return NULL; | 193 | return NULL; |
diff --git a/noncore/apps/opie-reader/PluckerCodec/PluckerCodec.pro b/noncore/apps/opie-reader/PluckerCodec/PluckerCodec.pro index 6ed4032..7042542 100644 --- a/noncore/apps/opie-reader/PluckerCodec/PluckerCodec.pro +++ b/noncore/apps/opie-reader/PluckerCodec/PluckerCodec.pro | |||
@@ -1,18 +1,18 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = plucker.h | 5 | HEADERS = plucker.h |
6 | 6 | ||
7 | SOURCES = plucker.cpp \ | 7 | SOURCES = plucker.cpp \ |
8 | Palm2QImage.cpp | 8 | Palm2QImage.cpp |
9 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
12 | TARGET = Plucker | 12 | TARGET = Plucker |
13 | LIBS += -lreader_pdb -lreader_pluckerbase -lreader_codec | 13 | LIBS += -lreader_pdb -lreader_pluckerbase -lreader_codec |
14 | 14 | ||
15 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 17 | ||
18 | include ( $(OPIEDIR)/include.pro ) | 18 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/QTReader.cpp b/noncore/apps/opie-reader/QTReader.cpp index dfdba28..33884a0 100644 --- a/noncore/apps/opie-reader/QTReader.cpp +++ b/noncore/apps/opie-reader/QTReader.cpp | |||
@@ -1,205 +1,204 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | *****************************************************************************/ | 9 | *****************************************************************************/ |
10 | 10 | ||
11 | const int _SBARHEIGHT = 3; | 11 | const int _SBARHEIGHT = 3; |
12 | 12 | ||
13 | #include "useqpe.h" | ||
14 | #include <qpainter.h> | 13 | #include <qpainter.h> |
15 | //#include <qdirectpainter_qws.h> | 14 | //#include <qdirectpainter_qws.h> |
16 | #include <qimage.h> | 15 | #include <qimage.h> |
17 | #include <qtimer.h> | 16 | #include <qtimer.h> |
18 | #include "config.h" | 17 | #include "config.h" |
19 | #include "QTReader.h" | 18 | #include "QTReader.h" |
20 | //#include "QTReaderApp.h" | 19 | //#include "QTReaderApp.h" |
21 | #include "CDrawBuffer.h" | 20 | #include "CDrawBuffer.h" |
22 | #ifdef USEQPE | 21 | #ifdef USEQPE |
23 | #include <qpe/qpeapplication.h> | 22 | #include <qpe/qpeapplication.h> |
24 | #endif | 23 | #endif |
25 | #include <math.h> | 24 | #include <math.h> |
26 | #include <ctype.h> | 25 | #include <ctype.h> |
27 | #include <stdio.h> //for sprintf | 26 | #include <stdio.h> //for sprintf |
28 | #ifdef USEQPE | 27 | #ifdef USEQPE |
29 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
30 | #include <qpe/applnk.h> | 29 | #include <qpe/applnk.h> |
31 | #include <qpe/global.h> | 30 | #include <qpe/global.h> |
32 | #include <qpe/qcopenvelope_qws.h> | 31 | #include <qpe/qcopenvelope_qws.h> |
33 | #endif | 32 | #endif |
34 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
35 | #include <qdir.h> | 34 | #include <qdir.h> |
36 | 35 | ||
37 | #ifdef _UNICODE | 36 | #ifdef _UNICODE |
38 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; | 37 | const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; |
39 | #else | 38 | #else |
40 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; | 39 | const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; |
41 | #endif | 40 | #endif |
42 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; | 41 | //const int QTReader::fontsizes[] = { 8, 10, 12, 14, 18, 24, 30, 40, 50, 60, 70, 80, 90, 100, 0 }; |
43 | 42 | ||
44 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; | 43 | //const tchar *QTReader::fonts[] = { "unifont", "fixed", "micro", "smoothtimes", "Courier", "Times", 0 }; |
45 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; | 44 | //const int QTReader::fontsizes[] = {10,16,17,22,0}; |
46 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; | 45 | //const tchar *QTReader::fonts[] = { "verdana", "Courier", "Times", 0 }; |
47 | //const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; | 46 | //const int QTReader::fontsizes[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,0}; |
48 | 47 | ||
49 | tchar QTReader::pluckernextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; | 48 | tchar QTReader::pluckernextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; |
50 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 49 | tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
51 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; | 50 | //tchar QTReader::jplucknextpart[] = { 10,'#',10,'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; |
52 | 51 | ||
53 | 52 | ||
54 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : | 53 | QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : |
55 | QWidget(parent, name, f), | 54 | QWidget(parent, name, f), |
56 | m_default_fg(0,0,0), | 55 | m_default_fg(0,0,0), |
57 | m_default_bg(255,255,255), | 56 | m_default_bg(255,255,255), |
58 | m_bg(255,255,255), | 57 | m_bg(255,255,255), |
59 | m_delay(100), | 58 | m_delay(100), |
60 | m_scrolldy1(0), | 59 | m_scrolldy1(0), |
61 | m_scrolldy2(0), | 60 | m_scrolldy2(0), |
62 | m_totalscroll(0), | 61 | m_totalscroll(0), |
63 | m_autoScroll(false), | 62 | m_autoScroll(false), |
64 | //textarray(NULL), | 63 | //textarray(NULL), |
65 | //locnarray(NULL), | 64 | //locnarray(NULL), |
66 | numlines(0), | 65 | numlines(0), |
67 | m_fontname("unifont"), | 66 | m_fontname("unifont"), |
68 | m_fm(NULL), | 67 | m_fm(NULL), |
69 | mouseUpOn(true), | 68 | mouseUpOn(true), |
70 | m_twotouch(true), | 69 | m_twotouch(true), |
71 | m_touchone(true), | 70 | m_touchone(true), |
72 | bDoUpdates(false), | 71 | bDoUpdates(false), |
73 | #ifdef _SCROLLPIPE | 72 | #ifdef _SCROLLPIPE |
74 | m_pipeout(NULL), | 73 | m_pipeout(NULL), |
75 | #endif | 74 | #endif |
76 | m_left_border(2), | 75 | m_left_border(2), |
77 | m_right_border(2), | 76 | m_right_border(2), |
78 | m_rotated(true), | 77 | m_rotated(true), |
79 | pBkmklist(NULL), | 78 | pBkmklist(NULL), |
80 | m_scrollpos(0), | 79 | m_scrollpos(0), |
81 | // bNegative(false), | 80 | // bNegative(false), |
82 | bInverse(false), | 81 | bInverse(false), |
83 | m_highlightfilter(NULL), | 82 | m_highlightfilter(NULL), |
84 | m_bgIsScaled(false), | 83 | m_bgIsScaled(false), |
85 | m_scrollstep(2), | 84 | m_scrollstep(2), |
86 | m_topmargin(5), | 85 | m_topmargin(5), |
87 | m_bottommargin(5), | 86 | m_bottommargin(5), |
88 | m_reparastring("{\\n[\\n ]}"), | 87 | m_reparastring("{\\n[\\n ]}"), |
89 | m_currentlinkstyle(NULL), | 88 | m_currentlinkstyle(NULL), |
90 | m_currentlinkoffset(-1), | 89 | m_currentlinkoffset(-1), |
91 | m_currentlink(-1) | 90 | m_currentlink(-1) |
92 | { | 91 | { |
93 | m_overlap = 1; | 92 | m_overlap = 1; |
94 | setKeyCompression ( true ); | 93 | setKeyCompression ( true ); |
95 | #ifdef DOUBLEBUFFER | 94 | #ifdef DOUBLEBUFFER |
96 | dbuff = new QPixmap(); | 95 | dbuff = new QPixmap(); |
97 | dbp = new QPainter(); | 96 | dbp = new QPainter(); |
98 | // if (painter->isActive()) painter->end(); | 97 | // if (painter->isActive()) painter->end(); |
99 | // painter->begin(frame); | 98 | // painter->begin(frame); |
100 | #endif | 99 | #endif |
101 | // init(); | 100 | // init(); |
102 | 101 | ||
103 | } | 102 | } |
104 | 103 | ||
105 | /* | 104 | /* |
106 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : | 105 | QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : |
107 | QWidget(parent, name, f), | 106 | QWidget(parent, name, f), |
108 | m_textfont(0), | 107 | m_textfont(0), |
109 | m_textsize(1), | 108 | m_textsize(1), |
110 | textarray(NULL), | 109 | textarray(NULL), |
111 | numlines(0), | 110 | numlines(0), |
112 | bstripcr(true), | 111 | bstripcr(true), |
113 | bunindent(false), | 112 | bunindent(false), |
114 | brepara(false), | 113 | brepara(false), |
115 | bdblspce(false), | 114 | bdblspce(false), |
116 | btight(false), | 115 | btight(false), |
117 | bindenter(0), | 116 | bindenter(0), |
118 | m_fm(NULL) | 117 | m_fm(NULL) |
119 | { | 118 | { |
120 | init(); | 119 | init(); |
121 | // // qDebug("Load_file(1)"); | 120 | // // qDebug("Load_file(1)"); |
122 | load_file((const tchar*)filename); | 121 | load_file((const tchar*)filename); |
123 | } | 122 | } |
124 | */ | 123 | */ |
125 | 124 | ||
126 | /* | 125 | /* |
127 | void QTReader::mouseMoveEvent(QMouseEvent* _e) | 126 | void QTReader::mouseMoveEvent(QMouseEvent* _e) |
128 | { | 127 | { |
129 | 128 | ||
130 | mouseUpOn = !(_e->pos().x() == -1); | 129 | mouseUpOn = !(_e->pos().x() == -1); |
131 | 130 | ||
132 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); | 131 | qDebug("MouseMove:[%d, %d]", _e->pos().x(), _e->pos().y()); |
133 | } | 132 | } |
134 | */ | 133 | */ |
135 | long QTReader::real_delay() | 134 | long QTReader::real_delay() |
136 | { | 135 | { |
137 | return m_scrollstep*( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); | 136 | return m_scrollstep*( 8976 + m_delay ) / ( m_linespacing * m_linespacing ); |
138 | } | 137 | } |
139 | 138 | ||
140 | void QTReader::mousePressEvent( QMouseEvent* _e ) | 139 | void QTReader::mousePressEvent( QMouseEvent* _e ) |
141 | { | 140 | { |
142 | buffdoc.unsuspend(); | 141 | buffdoc.unsuspend(); |
143 | int x, y, ht, wh; | 142 | int x, y, ht, wh; |
144 | if (m_rotated) | 143 | if (m_rotated) |
145 | { | 144 | { |
146 | x = _e->y(); | 145 | x = _e->y(); |
147 | y = width()-_e->x(); | 146 | y = width()-_e->x(); |
148 | ht = width(); | 147 | ht = width(); |
149 | wh = height(); | 148 | wh = height(); |
150 | } | 149 | } |
151 | else | 150 | else |
152 | { | 151 | { |
153 | x = _e->x(); | 152 | x = _e->x(); |
154 | y = _e->y(); | 153 | y = _e->y(); |
155 | ht = height(); | 154 | ht = height(); |
156 | wh = width(); | 155 | wh = width(); |
157 | } | 156 | } |
158 | if (_e->button() == RightButton) | 157 | if (_e->button() == RightButton) |
159 | { | 158 | { |
160 | //qDebug("MousePress"); | 159 | //qDebug("MousePress"); |
161 | mouseUpOn = false; | 160 | mouseUpOn = false; |
162 | if (m_swapmouse) | 161 | if (m_swapmouse) |
163 | { | 162 | { |
164 | int lineno = 0; | 163 | int lineno = 0; |
165 | /* | 164 | /* |
166 | int hgt = textarray[0]->lineSpacing(); | 165 | int hgt = textarray[0]->lineSpacing(); |
167 | while ((hgt < y) && (lineno < numlines)) | 166 | while ((hgt < y) && (lineno < numlines)) |
168 | { | 167 | { |
169 | hgt += textarray[++lineno]->lineSpacing(); | 168 | hgt += textarray[++lineno]->lineSpacing(); |
170 | } | 169 | } |
171 | */ | 170 | */ |
172 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; | 171 | size_t startpos, startoffset, tgt, tgtoffset, pictgt; |
173 | QImage* img; | 172 | QImage* img; |
174 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); | 173 | getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); |
175 | processmousewordevent(startpos, startoffset, _e, lineno); | 174 | processmousewordevent(startpos, startoffset, _e, lineno); |
176 | } | 175 | } |
177 | else | 176 | else |
178 | processmousepositionevent(_e); | 177 | processmousepositionevent(_e); |
179 | } | 178 | } |
180 | } | 179 | } |
181 | 180 | ||
182 | void QTReader::processmousepositionevent( QMouseEvent* _e ) | 181 | void QTReader::processmousepositionevent( QMouseEvent* _e ) |
183 | { | 182 | { |
184 | int x, y, ht, wh; | 183 | int x, y, ht, wh; |
185 | if (m_rotated) | 184 | if (m_rotated) |
186 | { | 185 | { |
187 | x = _e->y(); | 186 | x = _e->y(); |
188 | y = width()-_e->x(); | 187 | y = width()-_e->x(); |
189 | ht = width(); | 188 | ht = width(); |
190 | wh = height(); | 189 | wh = height(); |
191 | } | 190 | } |
192 | else | 191 | else |
193 | { | 192 | { |
194 | x = _e->x(); | 193 | x = _e->x(); |
195 | y = _e->y(); | 194 | y = _e->y(); |
196 | ht = height(); | 195 | ht = height(); |
197 | wh = width(); | 196 | wh = width(); |
198 | } | 197 | } |
199 | if (buffdoc.hasnavigation()) | 198 | if (buffdoc.hasnavigation()) |
200 | { | 199 | { |
201 | if (y > (2*ht)/3) | 200 | if (y > (2*ht)/3) |
202 | { | 201 | { |
203 | goDown(); | 202 | goDown(); |
204 | } | 203 | } |
205 | else if (y < ht/3) | 204 | else if (y < ht/3) |
diff --git a/noncore/apps/opie-reader/QTReader.h b/noncore/apps/opie-reader/QTReader.h index 7b0ebc8..3bcdde4 100644 --- a/noncore/apps/opie-reader/QTReader.h +++ b/noncore/apps/opie-reader/QTReader.h | |||
@@ -1,197 +1,196 @@ | |||
1 | #ifndef __QTREADER_H | 1 | #ifndef __QTREADER_H |
2 | #define __QTREADER_H | 2 | #define __QTREADER_H |
3 | 3 | ||
4 | //#define _SCROLLPIPE | 4 | //#define _SCROLLPIPE |
5 | #include "static.h" | ||
6 | #include <qwidget.h> | 5 | #include <qwidget.h> |
7 | //#include <qpainter.h> | 6 | //#include <qpainter.h> |
8 | #include "my_list.h" | 7 | #include "my_list.h" |
9 | #include "BuffDoc.h" | 8 | #include "BuffDoc.h" |
10 | #include "FontControl.h" | 9 | #include "FontControl.h" |
11 | 10 | ||
12 | //#include <qtimer.h> | 11 | //#include <qtimer.h> |
13 | 12 | ||
14 | class CDrawBuffer; | 13 | class CDrawBuffer; |
15 | //class CBuffer; | 14 | //class CBuffer; |
16 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
17 | class QPainter; | 16 | class QPainter; |
18 | class QTimer; | 17 | class QTimer; |
19 | class QImage; | 18 | class QImage; |
20 | 19 | ||
21 | #include "BGType.h" | 20 | #include "BGType.h" |
22 | #include "striphtml.h" | 21 | #include "striphtml.h" |
23 | 22 | ||
24 | #define ROTATION_ENABLED | 23 | #define ROTATION_ENABLED |
25 | #define SPECIALSCROLL | 24 | #define SPECIALSCROLL |
26 | #define DOUBLEBUFFER | 25 | #define DOUBLEBUFFER |
27 | #ifdef DOUBLEBUFFER | 26 | #ifdef DOUBLEBUFFER |
28 | class QPainter; | 27 | class QPainter; |
29 | #endif | 28 | #endif |
30 | 29 | ||
31 | class CStyle; | 30 | class CStyle; |
32 | 31 | ||
33 | class QTReader : public QWidget | 32 | class QTReader : public QWidget |
34 | { | 33 | { |
35 | Q_OBJECT | 34 | Q_OBJECT |
36 | friend class QTReaderApp; | 35 | friend class QTReaderApp; |
37 | #ifdef DOUBLEBUFFER | 36 | #ifdef DOUBLEBUFFER |
38 | QPixmap *dbuff; | 37 | QPixmap *dbuff; |
39 | QPainter* dbp; | 38 | QPainter* dbp; |
40 | #endif | 39 | #endif |
41 | void drawSingleLine(int lineno); | 40 | void drawSingleLine(int lineno); |
42 | void gotoLink(); | 41 | void gotoLink(); |
43 | void emitRedraw(); | 42 | void emitRedraw(); |
44 | CStyle* m_currentlinkstyle; | 43 | CStyle* m_currentlinkstyle; |
45 | int m_currentlink; | 44 | int m_currentlink; |
46 | int m_currentlinkoffset; | 45 | int m_currentlinkoffset; |
47 | QPixmap m_bgpm; | 46 | QPixmap m_bgpm; |
48 | bool m_bgIsScaled; | 47 | bool m_bgIsScaled; |
49 | bground m_bgtype; | 48 | bground m_bgtype; |
50 | int m_scrollpos; | 49 | int m_scrollpos; |
51 | unsigned short m_scrollstep; | 50 | unsigned short m_scrollstep; |
52 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); | 51 | void blitRot(int dx, int sx, int sw, int sh, CDrawBuffer* txt); |
53 | void setBackgroundBitmap(const QPixmap& _pm, bground bg) | 52 | void setBackgroundBitmap(const QPixmap& _pm, bground bg) |
54 | { | 53 | { |
55 | m_bgpm = _pm; | 54 | m_bgpm = _pm; |
56 | m_bgtype = bg; | 55 | m_bgtype = bg; |
57 | m_bgIsScaled = false; | 56 | m_bgIsScaled = false; |
58 | } | 57 | } |
59 | 58 | ||
60 | QColor m_bg, m_default_bg, m_default_fg, m_negative_fg; | 59 | QColor m_bg, m_default_bg, m_default_fg, m_negative_fg; |
61 | static tchar pluckernextpart[]; | 60 | static tchar pluckernextpart[]; |
62 | static tchar jplucknextpart[]; | 61 | static tchar jplucknextpart[]; |
63 | CList<Bkmk>* pBkmklist; | 62 | CList<Bkmk>* pBkmklist; |
64 | void setHyphenThreshold(int _v) { buffdoc.setHyphenThreshold(_v); } | 63 | void setHyphenThreshold(int _v) { buffdoc.setHyphenThreshold(_v); } |
65 | void ResetScroll(); | 64 | void ResetScroll(); |
66 | void increaseScroll(); | 65 | void increaseScroll(); |
67 | void reduceScroll(); | 66 | void reduceScroll(); |
68 | void drawText(QPainter& p, int x, int y, tchar* text); | 67 | void drawText(QPainter& p, int x, int y, tchar* text); |
69 | void DrawScroll( QPainter *p, int w, int h ); | 68 | void DrawScroll( QPainter *p, int w, int h ); |
70 | void dorollingscroll(bool); | 69 | void dorollingscroll(bool); |
71 | void doinplacescroll(); | 70 | void doinplacescroll(); |
72 | void dostaticscroll(); | 71 | void dostaticscroll(); |
73 | void suspend(); | 72 | void suspend(); |
74 | void redrawScroll(QPainter* p); | 73 | void redrawScroll(QPainter* p); |
75 | int m_delay, m_scrolltype; | 74 | int m_delay, m_scrolltype; |
76 | unsigned int m_overlap; | 75 | unsigned int m_overlap; |
77 | bool m_autoScroll, m_swapmouse; | 76 | bool m_autoScroll, m_swapmouse; |
78 | void drawBackground(); | 77 | void drawBackground(); |
79 | #ifdef ROTATION_ENABLED | 78 | #ifdef ROTATION_ENABLED |
80 | bool m_rotated; | 79 | bool m_rotated; |
81 | void setrotated(bool); | 80 | void setrotated(bool); |
82 | #endif | 81 | #endif |
83 | void autoscroll(); | 82 | void autoscroll(); |
84 | QTimer* timer; | 83 | QTimer* timer; |
85 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; | 84 | int m_scrolldy1, m_scrolldy2, m_encd, m_scrollpart, m_totalscroll; |
86 | void focusInEvent(QFocusEvent*); | 85 | void focusInEvent(QFocusEvent*); |
87 | void focusOutEvent(QFocusEvent*); | 86 | void focusOutEvent(QFocusEvent*); |
88 | void processmousepositionevent( QMouseEvent* _e ); | 87 | void processmousepositionevent( QMouseEvent* _e ); |
89 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); | 88 | void processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno); |
90 | bool ChangeFont(int); | 89 | bool ChangeFont(int); |
91 | bool getline(CDrawBuffer*); | 90 | bool getline(CDrawBuffer*); |
92 | int m_charWidth; | 91 | int m_charWidth; |
93 | int m_charpc; | 92 | int m_charpc; |
94 | unsigned short m_absleft_border, m_absright_border; | 93 | unsigned short m_absleft_border, m_absright_border; |
95 | unsigned short m_left_border, m_right_border; | 94 | unsigned short m_left_border, m_right_border; |
96 | FontControl m_fontControl; | 95 | FontControl m_fontControl; |
97 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } | 96 | void setBaseSize(unsigned char _s) { m_fontControl.setBaseSize(_s); } |
98 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } | 97 | unsigned char getBaseSize() { return m_fontControl.getBaseSize(); } |
99 | #ifdef _SCROLLPIPE | 98 | #ifdef _SCROLLPIPE |
100 | FILE* m_pipeout; | 99 | FILE* m_pipeout; |
101 | QString m_pipetarget; | 100 | QString m_pipetarget; |
102 | bool m_isPaused; | 101 | bool m_isPaused; |
103 | bool m_pauseAfterEachPara; | 102 | bool m_pauseAfterEachPara; |
104 | #endif | 103 | #endif |
105 | public: | 104 | public: |
106 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); | 105 | QTReader( QWidget *parent=0, const char *name=0, WFlags f = 0); |
107 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); | 106 | // QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0); |
108 | ~QTReader(); | 107 | ~QTReader(); |
109 | QString about(); | 108 | QString about(); |
110 | CList<Bkmk>* Bkmklist() { return pBkmklist; } | 109 | CList<Bkmk>* Bkmklist() { return pBkmklist; } |
111 | void setBackground(const QColor& _c) | 110 | void setBackground(const QColor& _c) |
112 | { | 111 | { |
113 | m_default_bg = _c; | 112 | m_default_bg = _c; |
114 | reset_bg(); | 113 | reset_bg(); |
115 | } | 114 | } |
116 | void setForeground(const QColor& _c) | 115 | void setForeground(const QColor& _c) |
117 | { | 116 | { |
118 | m_default_fg = _c; | 117 | m_default_fg = _c; |
119 | int r,g,b; | 118 | int r,g,b; |
120 | m_default_fg.rgb(&r, &g, &b); | 119 | m_default_fg.rgb(&r, &g, &b); |
121 | r = 255-r; | 120 | r = 255-r; |
122 | g = 255-g; | 121 | g = 255-g; |
123 | b = 255-b; | 122 | b = 255-b; |
124 | m_negative_fg.setRgb(r,g,b); | 123 | m_negative_fg.setRgb(r,g,b); |
125 | } | 124 | } |
126 | void zoomin(); | 125 | void zoomin(); |
127 | void zoomout(); | 126 | void zoomout(); |
128 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) | 127 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) |
129 | { | 128 | { |
130 | buffdoc.setSaveData(data, len, src, srclen); | 129 | buffdoc.setSaveData(data, len, src, srclen); |
131 | } | 130 | } |
132 | void putSaveData(unsigned char*& src, unsigned short& srclen) | 131 | void putSaveData(unsigned char*& src, unsigned short& srclen) |
133 | { | 132 | { |
134 | buffdoc.putSaveData(src, srclen); | 133 | buffdoc.putSaveData(src, srclen); |
135 | } | 134 | } |
136 | bool empty(); | 135 | bool empty(); |
137 | void setContinuous(bool _b); | 136 | void setContinuous(bool _b); |
138 | void toggle_autoscroll(); | 137 | void toggle_autoscroll(); |
139 | void setautoscroll(bool); | 138 | void setautoscroll(bool); |
140 | void disableAutoscroll() { m_autoScroll = false; } | 139 | void disableAutoscroll() { m_autoScroll = false; } |
141 | void copy() | 140 | void copy() |
142 | { | 141 | { |
143 | /* | 142 | /* |
144 | size_t nd = locate(); | 143 | size_t nd = locate(); |
145 | jumpto(m_mark); | 144 | jumpto(m_mark); |
146 | QString text; | 145 | QString text; |
147 | while (m_mark < nd) | 146 | while (m_mark < nd) |
148 | { | 147 | { |
149 | text += buffdoc.getch(); | 148 | text += buffdoc.getch(); |
150 | m_mark++; | 149 | m_mark++; |
151 | } | 150 | } |
152 | QApplication::clipboard()->setText(text); | 151 | QApplication::clipboard()->setText(text); |
153 | jumpto(nd); | 152 | jumpto(nd); |
154 | */ | 153 | */ |
155 | }; | 154 | }; |
156 | void clear() {}; | 155 | void clear() {}; |
157 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; | 156 | void setText(const QString& n, const QString& s) { m_string = n; load_file((const char*)s); }; |
158 | /* | 157 | /* |
159 | void setText(bool oldfile) | 158 | void setText(bool oldfile) |
160 | { | 159 | { |
161 | if (oldfile) | 160 | if (oldfile) |
162 | { | 161 | { |
163 | m_string = m_lastfile; | 162 | m_string = m_lastfile; |
164 | load_file((const tchar*)m_string); | 163 | load_file((const tchar*)m_string); |
165 | } | 164 | } |
166 | else | 165 | else |
167 | { | 166 | { |
168 | m_string = QString::null; | 167 | m_string = QString::null; |
169 | } | 168 | } |
170 | }; | 169 | }; |
171 | */ | 170 | */ |
172 | void setlead(int _lead) | 171 | void setlead(int _lead) |
173 | { | 172 | { |
174 | m_fontControl.setlead(_lead); | 173 | m_fontControl.setlead(_lead); |
175 | } | 174 | } |
176 | int getlead() | 175 | int getlead() |
177 | { | 176 | { |
178 | return m_fontControl.getlead(); | 177 | return m_fontControl.getlead(); |
179 | } | 178 | } |
180 | void setextraspace(int _lead) | 179 | void setextraspace(int _lead) |
181 | { | 180 | { |
182 | m_fontControl.setextraspace(_lead); | 181 | m_fontControl.setextraspace(_lead); |
183 | } | 182 | } |
184 | int getextraspace() | 183 | int getextraspace() |
185 | { | 184 | { |
186 | return m_fontControl.getextraspace(); | 185 | return m_fontControl.getextraspace(); |
187 | } | 186 | } |
188 | void setpagemode(bool _b) | 187 | void setpagemode(bool _b) |
189 | { | 188 | { |
190 | m_bpagemode = _b; | 189 | m_bpagemode = _b; |
191 | } | 190 | } |
192 | void setmono(bool _b) | 191 | void setmono(bool _b) |
193 | { | 192 | { |
194 | m_bMonoSpaced = _b; | 193 | m_bMonoSpaced = _b; |
195 | ChangeFont(m_fontControl.currentsize()); | 194 | ChangeFont(m_fontControl.currentsize()); |
196 | locate(pagelocate()); | 195 | locate(pagelocate()); |
197 | } | 196 | } |
diff --git a/noncore/apps/opie-reader/QTReaderApp.cpp b/noncore/apps/opie-reader/QTReaderApp.cpp index ec7a29c..876b65a 100644 --- a/noncore/apps/opie-reader/QTReaderApp.cpp +++ b/noncore/apps/opie-reader/QTReaderApp.cpp | |||
@@ -1,278 +1,276 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. Allrights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. Allrights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #include "useqpe.h" | ||
21 | #include <qregexp.h> | 20 | #include <qregexp.h> |
22 | #include <qclipboard.h> | 21 | #include <qclipboard.h> |
23 | #include <qwidgetstack.h> | 22 | #include <qwidgetstack.h> |
24 | #ifdef USEQPE | 23 | #ifdef USEQPE |
25 | #include <qpe/qpemenubar.h> | 24 | #include <qpe/qpemenubar.h> |
26 | #include <qpe/qpetoolbar.h> | 25 | #include <qpe/qpetoolbar.h> |
27 | #endif | 26 | #endif |
28 | #include <qmenubar.h> | 27 | #include <qmenubar.h> |
29 | #include <qtoolbar.h> | 28 | #include <qtoolbar.h> |
30 | #ifdef USEQPE | 29 | #ifdef USEQPE |
31 | #include <qpe/menubutton.h> | 30 | #include <qpe/menubutton.h> |
32 | #endif | 31 | #endif |
33 | #include <qcombobox.h> | 32 | #include <qcombobox.h> |
34 | #include <qpopupmenu.h> | 33 | #include <qpopupmenu.h> |
35 | #include <qaction.h> | 34 | #include <qaction.h> |
36 | #include <qapplication.h> | 35 | #include <qapplication.h> |
37 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
38 | #include <qtoolbutton.h> | 37 | #include <qtoolbutton.h> |
39 | #include <qspinbox.h> | 38 | #include <qspinbox.h> |
40 | #include <qobjectlist.h> | 39 | #include <qobjectlist.h> |
41 | #include <qstatusbar.h> | 40 | #include <qstatusbar.h> |
42 | #ifdef USEQPE | 41 | #ifdef USEQPE |
43 | #include <qpe/global.h> | 42 | #include <qpe/global.h> |
44 | #include <qpe/applnk.h> | 43 | #include <qpe/applnk.h> |
45 | #endif | 44 | #endif |
46 | #include <qfileinfo.h> | 45 | #include <qfileinfo.h> |
47 | #include <stdlib.h> //getenv | 46 | #include <stdlib.h> //getenv |
48 | #include <qprogressbar.h> | 47 | #include <qprogressbar.h> |
49 | #ifdef USEQPE | 48 | #ifdef USEQPE |
50 | #include <qpe/config.h> | 49 | #include <qpe/config.h> |
51 | #endif | 50 | #endif |
52 | #include <qbuttongroup.h> | 51 | #include <qbuttongroup.h> |
53 | #include <qradiobutton.h> | 52 | #include <qradiobutton.h> |
54 | #ifdef USEQPE | 53 | #ifdef USEQPE |
55 | #include <qpe/qcopenvelope_qws.h> | 54 | #include <qpe/qcopenvelope_qws.h> |
56 | #endif | 55 | #endif |
57 | #include "QTReader.h" | 56 | #include "QTReader.h" |
58 | #include "GraphicWin.h" | 57 | #include "GraphicWin.h" |
59 | #include "Bkmks.h" | 58 | #include "Bkmks.h" |
60 | #include "cbkmkselector.h" | 59 | #include "cbkmkselector.h" |
61 | #include "infowin.h" | 60 | #include "infowin.h" |
62 | #include "ToolbarPrefs.h" | 61 | #include "ToolbarPrefs.h" |
63 | #include "Prefs.h" | 62 | #include "Prefs.h" |
64 | #include "CAnnoEdit.h" | 63 | #include "CAnnoEdit.h" |
65 | #include "QFloatBar.h" | 64 | #include "QFloatBar.h" |
66 | #include "FixedFont.h" | 65 | #include "FixedFont.h" |
67 | #include "URLDialog.h" | 66 | #include "URLDialog.h" |
68 | #include "util.h" | 67 | #include "util.h" |
69 | #include <qfontdatabase.h> | 68 | #include <qfontdatabase.h> |
70 | #ifdef USEQPE | 69 | #ifdef USEQPE |
71 | #include <qpe/resource.h> | 70 | #include <qpe/resource.h> |
72 | #ifdef OPIE | 71 | #ifdef OPIE |
73 | //#include <qpe/applnk.h> | 72 | //#include <qpe/applnk.h> |
74 | #include <opie2/ofiledialog.h> | 73 | #include <opie2/ofiledialog.h> |
75 | using namespace Opie::Ui; | 74 | using namespace Opie::Ui; |
76 | #else | 75 | #else |
77 | #include "fileBrowser.h" | 76 | #include "fileBrowser.h" |
78 | #endif | 77 | #endif |
79 | #else | 78 | #else |
80 | #include "qfiledialog.h" | 79 | #include "qfiledialog.h" |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | #include "QTReaderApp.h" | 82 | #include "QTReaderApp.h" |
84 | #include "CDrawBuffer.h" | 83 | #include "CDrawBuffer.h" |
85 | #include "Filedata.h" | 84 | #include "Filedata.h" |
86 | #include "useqpe.h" | ||
87 | #include "names.h" | 85 | #include "names.h" |
88 | #include "CEncoding_tables.h" | 86 | #include "CEncoding_tables.h" |
89 | #include "CloseDialog.h" | 87 | #include "CloseDialog.h" |
90 | 88 | ||
91 | #include "ButtonPrefs.h" | 89 | #include "ButtonPrefs.h" |
92 | 90 | ||
93 | bool CheckVersion(int&, int&, char&); | 91 | bool CheckVersion(int&, int&, char&); |
94 | 92 | ||
95 | #ifdef _WINDOWS | 93 | #ifdef _WINDOWS |
96 | #define PICDIR "c:\\uqtreader\\pics\\" | 94 | #define PICDIR "c:\\uqtreader\\pics\\" |
97 | #else | 95 | #else |
98 | #ifdef USEQPE | 96 | #ifdef USEQPE |
99 | #define USEMSGS | 97 | #define USEMSGS |
100 | #define PICDIR "opie-reader/" | 98 | #define PICDIR "opie-reader/" |
101 | #else | 99 | #else |
102 | //#define PICDIR "/home/tim/uqtreader/pics/" | 100 | //#define PICDIR "/home/tim/uqtreader/pics/" |
103 | QString picdir() | 101 | QString picdir() |
104 | { | 102 | { |
105 | QString hd(getenv("READERDIR")); | 103 | QString hd(getenv("READERDIR")); |
106 | return hd + "/pics"; | 104 | return hd + "/pics"; |
107 | } | 105 | } |
108 | #define PICDIR picdir() | 106 | #define PICDIR picdir() |
109 | #endif | 107 | #endif |
110 | #endif | 108 | #endif |
111 | 109 | ||
112 | unsigned long QTReaderApp::m_uid = 0; | 110 | unsigned long QTReaderApp::m_uid = 0; |
113 | 111 | ||
114 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } | 112 | void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } |
115 | 113 | ||
116 | #ifdef USEQPE | 114 | #ifdef USEQPE |
117 | #define geticon(iconname) Resource::loadPixmap( iconname ) | 115 | #define geticon(iconname) Resource::loadPixmap( iconname ) |
118 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) | 116 | #define getmyicon(iconname) Resource::loadPixmap( PICDIR iconname ) |
119 | #else | 117 | #else |
120 | //#define geticon(iconname) QPixmap(PICDIR iconname ".png") | 118 | //#define geticon(iconname) QPixmap(PICDIR iconname ".png") |
121 | #define geticon(iconname) QPixmap(PICDIR +"/"+iconname+".png") | 119 | #define geticon(iconname) QPixmap(PICDIR +"/"+iconname+".png") |
122 | #define getmyicon(iconname) geticon(iconname) | 120 | #define getmyicon(iconname) geticon(iconname) |
123 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) | 121 | //#define geticon(iconname) QIconSet( QPixmap(PICDIR iconname) ) |
124 | #endif | 122 | #endif |
125 | 123 | ||
126 | #ifndef _WINDOWS | 124 | #ifndef _WINDOWS |
127 | #include <unistd.h> | 125 | #include <unistd.h> |
128 | #endif | 126 | #endif |
129 | #include <stddef.h> | 127 | #include <stddef.h> |
130 | #ifndef _WINDOWS | 128 | #ifndef _WINDOWS |
131 | #include <dirent.h> | 129 | #include <dirent.h> |
132 | #endif | 130 | #endif |
133 | 131 | ||
134 | void QTReaderApp::listBkmkFiles() | 132 | void QTReaderApp::listBkmkFiles() |
135 | { | 133 | { |
136 | bkmkselector->clear(); | 134 | bkmkselector->clear(); |
137 | bkmkselector->setText("Cancel"); | 135 | bkmkselector->setText("Cancel"); |
138 | #ifndef USEQPE | 136 | #ifndef USEQPE |
139 | int cnt = 0; | 137 | int cnt = 0; |
140 | 138 | ||
141 | QDir d = QDir::home(); // "/" | 139 | QDir d = QDir::home(); // "/" |
142 | if ( !d.cd(APPDIR) ) { // "/tmp" | 140 | if ( !d.cd(APPDIR) ) { // "/tmp" |
143 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); | 141 | qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); |
144 | d = QDir::home(); | 142 | d = QDir::home(); |
145 | d.mkdir(APPDIR); | 143 | d.mkdir(APPDIR); |
146 | d.cd(APPDIR); | 144 | d.cd(APPDIR); |
147 | } | 145 | } |
148 | 146 | ||
149 | 147 | ||
150 | 148 | ||
151 | 149 | ||
152 | d.setFilter( QDir::Files | QDir::NoSymLinks ); | 150 | d.setFilter( QDir::Files | QDir::NoSymLinks ); |
153 | // d.setSorting( QDir::Size | QDir::Reversed ); | 151 | // d.setSorting( QDir::Size | QDir::Reversed ); |
154 | 152 | ||
155 | const QFileInfoList *list = d.entryInfoList(); | 153 | const QFileInfoList *list = d.entryInfoList(); |
156 | QFileInfoListIterator it( *list ); // create list iterator | 154 | QFileInfoListIterator it( *list ); // create list iterator |
157 | QFileInfo *fi; // pointer for traversing | 155 | QFileInfo *fi; // pointer for traversing |
158 | 156 | ||
159 | while ( (fi=it.current()) ) { // for each file... | 157 | while ( (fi=it.current()) ) { // for each file... |
160 | 158 | ||
161 | bkmkselector->insertItem(fi->fileName()); | 159 | bkmkselector->insertItem(fi->fileName()); |
162 | cnt++; | 160 | cnt++; |
163 | 161 | ||
164 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); | 162 | //qDebug( "%10li %s", fi->size(), fi->fileName().data() ); |
165 | ++it; // goto next list element | 163 | ++it; // goto next list element |
166 | } | 164 | } |
167 | 165 | ||
168 | #else /* USEQPE */ | 166 | #else /* USEQPE */ |
169 | int cnt = 0; | 167 | int cnt = 0; |
170 | DIR *d; | 168 | DIR *d; |
171 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); | 169 | d = opendir((const char *)Global::applicationFileName(APPDIR,"")); |
172 | 170 | ||
173 | while(1) | 171 | while(1) |
174 | { | 172 | { |
175 | struct dirent* de; | 173 | struct dirent* de; |
176 | struct stat buf; | 174 | struct stat buf; |
177 | de = readdir(d); | 175 | de = readdir(d); |
178 | if (de == NULL) break; | 176 | if (de == NULL) break; |
179 | 177 | ||
180 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) | 178 | if (lstat((const char *)Global::applicationFileName(APPDIR,de->d_name),&buf) == 0 && S_ISREG(buf.st_mode)) |
181 | { | 179 | { |
182 | bkmkselector->insertItem(de->d_name); | 180 | bkmkselector->insertItem(de->d_name); |
183 | cnt++; | 181 | cnt++; |
184 | } | 182 | } |
185 | } | 183 | } |
186 | 184 | ||
187 | closedir(d); | 185 | closedir(d); |
188 | #endif | 186 | #endif |
189 | if (cnt > 0) | 187 | if (cnt > 0) |
190 | { | 188 | { |
191 | //tjw menu->hide(); | 189 | //tjw menu->hide(); |
192 | 190 | ||
193 | 191 | ||
194 | editorStack->raiseWidget( bkmkselector ); | 192 | editorStack->raiseWidget( bkmkselector ); |
195 | hidetoolbars(); | 193 | hidetoolbars(); |
196 | m_nBkmkAction = cRmBkmkFile; | 194 | m_nBkmkAction = cRmBkmkFile; |
197 | } | 195 | } |
198 | else | 196 | else |
199 | QMessageBox::information(this, PROGNAME, "No bookmark files"); | 197 | QMessageBox::information(this, PROGNAME, "No bookmark files"); |
200 | } | 198 | } |
201 | 199 | ||
202 | void QTReaderApp::hidetoolbars() | 200 | void QTReaderApp::hidetoolbars() |
203 | { | 201 | { |
204 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 202 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
205 | if (m_prog != NULL) m_prog->hide(); | 203 | if (m_prog != NULL) m_prog->hide(); |
206 | 204 | ||
207 | #ifdef USEQPE | 205 | #ifdef USEQPE |
208 | menubar->hide(); | 206 | menubar->hide(); |
209 | #endif | 207 | #endif |
210 | 208 | ||
211 | if (m_scrollbar != NULL) m_scrollbar->hide(); | 209 | if (m_scrollbar != NULL) m_scrollbar->hide(); |
212 | 210 | ||
213 | if (fileBar != NULL) fileBar->hide(); | 211 | if (fileBar != NULL) fileBar->hide(); |
214 | if (viewBar != NULL) viewBar->hide(); | 212 | if (viewBar != NULL) viewBar->hide(); |
215 | if (navBar != NULL) navBar->hide(); | 213 | if (navBar != NULL) navBar->hide(); |
216 | if (markBar != NULL) markBar->hide(); | 214 | if (markBar != NULL) markBar->hide(); |
217 | if (m_fontVisible) m_fontBar->hide(); | 215 | if (m_fontVisible) m_fontBar->hide(); |
218 | if (regVisible) | 216 | if (regVisible) |
219 | { | 217 | { |
220 | #ifdef USEQPE | 218 | #ifdef USEQPE |
221 | Global::hideInputMethod(); | 219 | Global::hideInputMethod(); |
222 | #endif | 220 | #endif |
223 | regBar->hide(); | 221 | regBar->hide(); |
224 | } | 222 | } |
225 | if (searchVisible) | 223 | if (searchVisible) |
226 | { | 224 | { |
227 | #ifdef USEQPE | 225 | #ifdef USEQPE |
228 | Global::hideInputMethod(); | 226 | Global::hideInputMethod(); |
229 | #endif | 227 | #endif |
230 | searchBar->hide(); | 228 | searchBar->hide(); |
231 | } | 229 | } |
232 | } | 230 | } |
233 | 231 | ||
234 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) | 232 | QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) |
235 | : QMainWindow( parent, name, f ), m_dontSave(false), | 233 | : QMainWindow( parent, name, f ), m_dontSave(false), |
236 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL), m_scrollbar(NULL), m_localscroll(2), m_hidebars(false), m_kmapchanged(false) | 234 | fileBar(NULL), navBar(NULL), viewBar(NULL), markBar(NULL), m_scrollbar(NULL), m_localscroll(2), m_hidebars(false), m_kmapchanged(false) |
237 | { | 235 | { |
238 | { | 236 | { |
239 | setKeyCompression ( true ); | 237 | setKeyCompression ( true ); |
240 | #ifndef USEQPE | 238 | #ifndef USEQPE |
241 | QDir d = QDir::home(); // "/" | 239 | QDir d = QDir::home(); // "/" |
242 | d.cd(APPDIR); | 240 | d.cd(APPDIR); |
243 | QFileInfo fi(d, ".keymap"); | 241 | QFileInfo fi(d, ".keymap"); |
244 | FILE* f = fopen((const char *)fi.absFilePath(), "r"); | 242 | FILE* f = fopen((const char *)fi.absFilePath(), "r"); |
245 | #else /* USEQPE */ | 243 | #else /* USEQPE */ |
246 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "r"); | 244 | FILE* f = fopen((const char *)Global::applicationFileName(APPDIR,".keymap"), "r"); |
247 | #endif /* USEQPE */ | 245 | #endif /* USEQPE */ |
248 | if (f != NULL) | 246 | if (f != NULL) |
249 | { | 247 | { |
250 | uint cnt; | 248 | uint cnt; |
251 | if ((fread(&cnt, sizeof(cnt), 1, f) != 0) && (cnt == KEYMAPVERSION)) | 249 | if ((fread(&cnt, sizeof(cnt), 1, f) != 0) && (cnt == KEYMAPVERSION)) |
252 | { | 250 | { |
253 | if (fread(&cnt, sizeof(cnt), 1, f) == 0) cnt = 0; | 251 | if (fread(&cnt, sizeof(cnt), 1, f) == 0) cnt = 0; |
254 | for (uint i = 0; i != cnt; i++) | 252 | for (uint i = 0; i != cnt; i++) |
255 | { | 253 | { |
256 | orKey key; | 254 | orKey key; |
257 | int data; | 255 | int data; |
258 | fread(&key, sizeof(key), 1, f); | 256 | fread(&key, sizeof(key), 1, f); |
259 | fread(&data, sizeof(data), 1, f); | 257 | fread(&data, sizeof(data), 1, f); |
260 | kmap[key] = data; | 258 | kmap[key] = data; |
261 | } | 259 | } |
262 | } | 260 | } |
263 | fclose(f); | 261 | fclose(f); |
264 | } | 262 | } |
265 | } | 263 | } |
266 | 264 | ||
267 | m_url_clipboard = false; | 265 | m_url_clipboard = false; |
268 | m_url_localfile = false; | 266 | m_url_localfile = false; |
269 | m_url_globalfile = false; | 267 | m_url_globalfile = false; |
270 | ftime(&m_lastkeytime); | 268 | ftime(&m_lastkeytime); |
271 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); | 269 | //// qDebug("Application directory = %s", (const tchar *)QPEApplication::documentDir()); |
272 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); | 270 | //// qDebug("Application directory = %s", (const tchar *)Global::applicationFileName("uqtreader","bkmks.xml")); |
273 | 271 | ||
274 | m_bcloseDisabled = true; | 272 | m_bcloseDisabled = true; |
275 | m_disableesckey = false; | 273 | m_disableesckey = false; |
276 | pBkmklist = NULL; | 274 | pBkmklist = NULL; |
277 | pOpenlist = NULL; | 275 | pOpenlist = NULL; |
278 | // doc = 0; | 276 | // doc = 0; |
diff --git a/noncore/apps/opie-reader/QTReaderApp.h b/noncore/apps/opie-reader/QTReaderApp.h index 5ecc42d..ad47fc9 100644 --- a/noncore/apps/opie-reader/QTReaderApp.h +++ b/noncore/apps/opie-reader/QTReaderApp.h | |||
@@ -1,221 +1,220 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qt Palmtop Environment. | 4 | ** This file is part of Qt Palmtop Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #ifndef __QTREADERAPP_H | 20 | #ifndef __QTREADERAPP_H |
21 | #define __QTREADERAPP_H | 21 | #define __QTREADERAPP_H |
22 | 22 | ||
23 | //#define _SCROLLPIPE | 23 | //#define _SCROLLPIPE |
24 | //#define __ISEARCH | 24 | //#define __ISEARCH |
25 | 25 | ||
26 | //#define MAX_ENCODING 6 | 26 | //#define MAX_ENCODING 6 |
27 | #define MAX_ACTIONS 5 | 27 | #define MAX_ACTIONS 5 |
28 | 28 | ||
29 | #include "useqpe.h" | ||
30 | #include <sys/timeb.h> | 29 | #include <sys/timeb.h> |
31 | #include <qmainwindow.h> | 30 | #include <qmainwindow.h> |
32 | #include "CExpander.h" | 31 | #include "CExpander.h" |
33 | #include "CEncoding.h" | 32 | #include "CEncoding.h" |
34 | #include <qlist.h> | 33 | #include <qlist.h> |
35 | //#include <qpe/filemanager.h> | 34 | //#include <qpe/filemanager.h> |
36 | #include <qmap.h> | 35 | #include <qmap.h> |
37 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
38 | #include <qstack.h> | 37 | #include <qstack.h> |
39 | #include <qlistbox.h> | 38 | #include <qlistbox.h> |
40 | #ifdef USEQPE | 39 | #ifdef USEQPE |
41 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
42 | #endif | 41 | #endif |
43 | #include "orkey.h" | 42 | #include "orkey.h" |
44 | //#include "Queue.h" | 43 | //#include "Queue.h" |
45 | #include "BGType.h" | 44 | #include "BGType.h" |
46 | 45 | ||
47 | class QBoxLayout; | 46 | class QBoxLayout; |
48 | class QWidgetStack; | 47 | class QWidgetStack; |
49 | class QToolButton; | 48 | class QToolButton; |
50 | class QPopupMenu; | 49 | class QPopupMenu; |
51 | class QToolBar; | 50 | class QToolBar; |
52 | #ifdef USEQPE | 51 | #ifdef USEQPE |
53 | class QPEToolBar; | 52 | class QPEToolBar; |
54 | class QPEMenuBar; | 53 | class QPEMenuBar; |
55 | #endif | 54 | #endif |
56 | class QScrollBar; | 55 | class QScrollBar; |
57 | class CBkmkSelector; | 56 | class CBkmkSelector; |
58 | class QProgressBar; | 57 | class QProgressBar; |
59 | class QAction; | 58 | class QAction; |
60 | class CAnnoEdit; | 59 | class CAnnoEdit; |
61 | class QFloatBar; | 60 | class QFloatBar; |
62 | class CDrawBuffer; | 61 | class CDrawBuffer; |
63 | class QTReader; | 62 | class QTReader; |
64 | class QImage; | 63 | class QImage; |
65 | class Config; | 64 | class Config; |
66 | class CButtonPrefs; | 65 | class CButtonPrefs; |
67 | 66 | ||
68 | #ifdef USEQPE | 67 | #ifdef USEQPE |
69 | enum ToolbarPolicy | 68 | enum ToolbarPolicy |
70 | { | 69 | { |
71 | cesSingle = 0, | 70 | cesSingle = 0, |
72 | cesMenuTool, | 71 | cesMenuTool, |
73 | cesMultiple | 72 | cesMultiple |
74 | }; | 73 | }; |
75 | #else | 74 | #else |
76 | enum ToolbarPolicy | 75 | enum ToolbarPolicy |
77 | { | 76 | { |
78 | cesMenuTool = 0, | 77 | cesMenuTool = 0, |
79 | cesMultiple | 78 | cesMultiple |
80 | }; | 79 | }; |
81 | #endif | 80 | #endif |
82 | 81 | ||
83 | enum regedit_type | 82 | enum regedit_type |
84 | { | 83 | { |
85 | cAutoGen, | 84 | cAutoGen, |
86 | cAddBkmk, | 85 | cAddBkmk, |
87 | cJump, | 86 | cJump, |
88 | cMonoSpace, | 87 | cMonoSpace, |
89 | cSetTarget, | 88 | cSetTarget, |
90 | #ifdef _SCROLLPIPE | 89 | #ifdef _SCROLLPIPE |
91 | cSetPipeTarget, | 90 | cSetPipeTarget, |
92 | #endif | 91 | #endif |
93 | cSetConfigName, | 92 | cSetConfigName, |
94 | cMargin, | 93 | cMargin, |
95 | cExtraSpace, | 94 | cExtraSpace, |
96 | cExtraLead, | 95 | cExtraLead, |
97 | cRepara | 96 | cRepara |
98 | }; | 97 | }; |
99 | 98 | ||
100 | enum bkmk_action | 99 | enum bkmk_action |
101 | { | 100 | { |
102 | cOpenFile, | 101 | cOpenFile, |
103 | cGotoBkmk, | 102 | cGotoBkmk, |
104 | cDelBkmk, | 103 | cDelBkmk, |
105 | cRmBkmkFile, | 104 | cRmBkmkFile, |
106 | cLdConfig, | 105 | cLdConfig, |
107 | cRmConfig, | 106 | cRmConfig, |
108 | cExportLinks, | 107 | cExportLinks, |
109 | cLdTheme | 108 | cLdTheme |
110 | }; | 109 | }; |
111 | 110 | ||
112 | enum fontselector_action | 111 | enum fontselector_action |
113 | { | 112 | { |
114 | cChooseFont, | 113 | cChooseFont, |
115 | cChooseEncoding | 114 | cChooseEncoding |
116 | }; | 115 | }; |
117 | 116 | ||
118 | #ifdef __ISEARCH | 117 | #ifdef __ISEARCH |
119 | struct searchrecord | 118 | struct searchrecord |
120 | { | 119 | { |
121 | QString s; | 120 | QString s; |
122 | size_t pos; | 121 | size_t pos; |
123 | searchrecord(const QString& _s, size_t _pos) : s(_s), pos(_pos) {} | 122 | searchrecord(const QString& _s, size_t _pos) : s(_s), pos(_pos) {} |
124 | }; | 123 | }; |
125 | #endif | 124 | #endif |
126 | 125 | ||
127 | class infowin; | 126 | class infowin; |
128 | class GraphicWin; | 127 | class GraphicWin; |
129 | 128 | ||
130 | class QTReaderApp : public QMainWindow | 129 | class QTReaderApp : public QMainWindow |
131 | { | 130 | { |
132 | Q_OBJECT | 131 | Q_OBJECT |
133 | 132 | ||
134 | QColor getcolour(int c); | 133 | QColor getcolour(int c); |
135 | 134 | ||
136 | QMap<orKey, int> kmap; | 135 | QMap<orKey, int> kmap; |
137 | unsigned long m_savedpos; | 136 | unsigned long m_savedpos; |
138 | int m_debounce; | 137 | int m_debounce; |
139 | bool m_kmapchanged; | 138 | bool m_kmapchanged; |
140 | bground m_bgtype; | 139 | bground m_bgtype; |
141 | timeb m_lastkeytime; | 140 | timeb m_lastkeytime; |
142 | QScrollBar* m_scrollbar; | 141 | QScrollBar* m_scrollbar; |
143 | QScrollBar* scrollbar; | 142 | QScrollBar* scrollbar; |
144 | int m_qtscroll, m_localscroll; | 143 | int m_qtscroll, m_localscroll; |
145 | bool m_hidebars, m_scrollishidden, m_statusishidden; | 144 | bool m_hidebars, m_scrollishidden, m_statusishidden; |
146 | QBoxLayout *m_layout; | 145 | QBoxLayout *m_layout; |
147 | QLabel* m_prog; | 146 | QLabel* m_prog; |
148 | bool m_annoIsEditing; | 147 | bool m_annoIsEditing; |
149 | bool m_propogatefontchange, m_bFloatingDialog; | 148 | bool m_propogatefontchange, m_bFloatingDialog; |
150 | bool m_url_clipboard, m_url_localfile, m_url_globalfile; | 149 | bool m_url_clipboard, m_url_localfile, m_url_globalfile; |
151 | CButtonPrefs* m_buttonprefs; | 150 | CButtonPrefs* m_buttonprefs; |
152 | fontselector_action m_fontAction; | 151 | fontselector_action m_fontAction; |
153 | void doAction(QKeyEvent* e); | 152 | void doAction(QKeyEvent* e); |
154 | 153 | ||
155 | public: | 154 | public: |
156 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); | 155 | QTReaderApp( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); |
157 | ~QTReaderApp(); | 156 | ~QTReaderApp(); |
158 | 157 | ||
159 | void hideEvent(QHideEvent*) | 158 | void hideEvent(QHideEvent*) |
160 | { | 159 | { |
161 | #ifdef USEQPE | 160 | #ifdef USEQPE |
162 | if (m_grabkeyboard) | 161 | if (m_grabkeyboard) |
163 | { | 162 | { |
164 | ((QPEApplication*)qApp)->ungrabKeyboard(); | 163 | ((QPEApplication*)qApp)->ungrabKeyboard(); |
165 | } | 164 | } |
166 | #endif | 165 | #endif |
167 | suspend(); | 166 | suspend(); |
168 | } | 167 | } |
169 | #ifdef USEQPE | 168 | #ifdef USEQPE |
170 | void showEvent(QShowEvent*) | 169 | void showEvent(QShowEvent*) |
171 | { | 170 | { |
172 | if (m_grabkeyboard) | 171 | if (m_grabkeyboard) |
173 | { | 172 | { |
174 | ((QPEApplication*)qApp)->grabKeyboard(); | 173 | ((QPEApplication*)qApp)->grabKeyboard(); |
175 | } | 174 | } |
176 | } | 175 | } |
177 | #endif | 176 | #endif |
178 | void suspend(); | 177 | void suspend(); |
179 | void openFile( const QString & ); | 178 | void openFile( const QString & ); |
180 | 179 | ||
181 | 180 | ||
182 | protected: | 181 | protected: |
183 | void setfontHelper(const QString& lcn, int size = 0); | 182 | void setfontHelper(const QString& lcn, int size = 0); |
184 | QAction* m_bkmkAvail, *m_actFullscreen; | 183 | QAction* m_bkmkAvail, *m_actFullscreen; |
185 | CAnnoEdit* m_annoWin; | 184 | CAnnoEdit* m_annoWin; |
186 | Bkmk* m_anno; | 185 | Bkmk* m_anno; |
187 | int m_scrollcolor, m_scrollbarcolor, m_background, m_foreground; | 186 | int m_scrollcolor, m_scrollbarcolor, m_background, m_foreground; |
188 | // void resizeEvent(QResizeEvent* e); | 187 | // void resizeEvent(QResizeEvent* e); |
189 | void closeEvent( QCloseEvent *e ); | 188 | void closeEvent( QCloseEvent *e ); |
190 | #ifdef NEWFULLSCREEN | 189 | #ifdef NEWFULLSCREEN |
191 | void resizeEvent(QResizeEvent *); | 190 | void resizeEvent(QResizeEvent *); |
192 | void focusInEvent(QFocusEvent*); | 191 | void focusInEvent(QFocusEvent*); |
193 | void enableFullscreen(); | 192 | void enableFullscreen(); |
194 | #endif | 193 | #endif |
195 | void readbkmks(); | 194 | void readbkmks(); |
196 | void do_mono(const QString&); | 195 | void do_mono(const QString&); |
197 | void do_jump(const QString&); | 196 | void do_jump(const QString&); |
198 | void do_reparastring(const QString&); | 197 | void do_reparastring(const QString&); |
199 | void do_settarget(const QString&); | 198 | void do_settarget(const QString&); |
200 | #ifdef _SCROLLPIPE | 199 | #ifdef _SCROLLPIPE |
201 | //void do_setpipetarget(const QString&); | 200 | //void do_setpipetarget(const QString&); |
202 | #endif | 201 | #endif |
203 | void do_saveconfig(const QString&, bool); | 202 | void do_saveconfig(const QString&, bool); |
204 | bool readconfig(const QString&, const QString&, bool); | 203 | bool readconfig(const QString&, const QString&, bool); |
205 | bool PopulateConfig(const char*, bool usedirs = false); | 204 | bool PopulateConfig(const char*, bool usedirs = false); |
206 | ActionTypes ActNameToInt(const QString&); | 205 | ActionTypes ActNameToInt(const QString&); |
207 | #ifdef USEQPE | 206 | #ifdef USEQPE |
208 | bool m_grabkeyboard; | 207 | bool m_grabkeyboard; |
209 | #endif | 208 | #endif |
210 | bool m_doAnnotation; | 209 | bool m_doAnnotation; |
211 | bool m_doDictionary; | 210 | bool m_doDictionary; |
212 | bool m_doClipboard; | 211 | bool m_doClipboard; |
213 | bool m_fullscreen; | 212 | bool m_fullscreen; |
214 | bool m_loadedconfig; | 213 | bool m_loadedconfig; |
215 | public: | 214 | public: |
216 | void saveprefs(); | 215 | void saveprefs(); |
217 | public slots: | 216 | public slots: |
218 | void setBackgroundBitmap(); | 217 | void setBackgroundBitmap(); |
219 | void UpdateStatus(); | 218 | void UpdateStatus(); |
220 | void setScrollState(bool _b); | 219 | void setScrollState(bool _b); |
221 | void handlekey(QKeyEvent* e); | 220 | void handlekey(QKeyEvent* e); |
diff --git a/noncore/apps/opie-reader/ToolbarPrefs.cpp b/noncore/apps/opie-reader/ToolbarPrefs.cpp index 5cf220a..56c4e9b 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.cpp +++ b/noncore/apps/opie-reader/ToolbarPrefs.cpp | |||
@@ -1,201 +1,200 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form implementation generated from reading ui file 'Prefs.ui' | 2 | ** Form implementation generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:35 2003 | 4 | ** Created: Tue Feb 11 23:53:35 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #include "useqpe.h" | ||
10 | #include "ToolbarPrefs.h" | 9 | #include "ToolbarPrefs.h" |
11 | 10 | ||
12 | #include <qcheckbox.h> | 11 | #include <qcheckbox.h> |
13 | #include <qlabel.h> | 12 | #include <qlabel.h> |
14 | #include <qpushbutton.h> | 13 | #include <qpushbutton.h> |
15 | #include <qspinbox.h> | 14 | #include <qspinbox.h> |
16 | #include <qlayout.h> | 15 | #include <qlayout.h> |
17 | #include <qvariant.h> | 16 | #include <qvariant.h> |
18 | #include <qtooltip.h> | 17 | #include <qtooltip.h> |
19 | #include <qwhatsthis.h> | 18 | #include <qwhatsthis.h> |
20 | #include <qcombobox.h> | 19 | #include <qcombobox.h> |
21 | #include <qbuttongroup.h> | 20 | #include <qbuttongroup.h> |
22 | #include <qlineedit.h> | 21 | #include <qlineedit.h> |
23 | #ifdef USEQPE | 22 | #ifdef USEQPE |
24 | #include <qpe/menubutton.h> | 23 | #include <qpe/menubutton.h> |
25 | #endif | 24 | #endif |
26 | 25 | ||
27 | CBarPrefs::CBarPrefs(const QString& appdir, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true), config( appdir ) | 26 | CBarPrefs::CBarPrefs(const QString& appdir, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true), config( appdir ) |
28 | { | 27 | { |
29 | setCaption(tr( "Toolbar Settings" ) ); | 28 | setCaption(tr( "Toolbar Settings" ) ); |
30 | QTabWidget* td = new QTabWidget(this); | 29 | QTabWidget* td = new QTabWidget(this); |
31 | misc = new CMiscBarPrefs(this); | 30 | misc = new CMiscBarPrefs(this); |
32 | filebar = new CFileBarPrefs(config, this); | 31 | filebar = new CFileBarPrefs(config, this); |
33 | navbar = new CNavBarPrefs(config, this); | 32 | navbar = new CNavBarPrefs(config, this); |
34 | viewbar = new CViewBarPrefs(config, this); | 33 | viewbar = new CViewBarPrefs(config, this); |
35 | markbar = new CMarkBarPrefs(config, this); | 34 | markbar = new CMarkBarPrefs(config, this); |
36 | indbar = new CIndBarPrefs(config, this); | 35 | indbar = new CIndBarPrefs(config, this); |
37 | td->addTab(filebar, tr("File")); | 36 | td->addTab(filebar, tr("File")); |
38 | td->addTab(navbar, tr("Navigation")); | 37 | td->addTab(navbar, tr("Navigation")); |
39 | td->addTab(viewbar, tr("View")); | 38 | td->addTab(viewbar, tr("View")); |
40 | td->addTab(markbar, tr("Marks")); | 39 | td->addTab(markbar, tr("Marks")); |
41 | td->addTab(indbar, tr("Indicators")); | 40 | td->addTab(indbar, tr("Indicators")); |
42 | td->addTab(misc, tr("Policy")); | 41 | td->addTab(misc, tr("Policy")); |
43 | QVBoxLayout* v = new QVBoxLayout(this); | 42 | QVBoxLayout* v = new QVBoxLayout(this); |
44 | v->addWidget(td); | 43 | v->addWidget(td); |
45 | 44 | ||
46 | if (fs) showMaximized(); | 45 | if (fs) showMaximized(); |
47 | } | 46 | } |
48 | 47 | ||
49 | /* | 48 | /* |
50 | CBarPrefs1::CBarPrefs1( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 49 | CBarPrefs1::CBarPrefs1( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
51 | : QWidget( parent, name, fl ), config(_config) | 50 | : QWidget( parent, name, fl ), config(_config) |
52 | { | 51 | { |
53 | config.setGroup( "Toolbar" ); | 52 | config.setGroup( "Toolbar" ); |
54 | QVBoxLayout* vb = new QVBoxLayout(this); | 53 | QVBoxLayout* vb = new QVBoxLayout(this); |
55 | 54 | ||
56 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "File", this); | 55 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "File", this); |
57 | vb->addWidget(bg); | 56 | vb->addWidget(bg); |
58 | 57 | ||
59 | open = new QCheckBox( tr("Open"), bg ); | 58 | open = new QCheckBox( tr("Open"), bg ); |
60 | open->setChecked(config.readBoolEntry( "Open", false )); | 59 | open->setChecked(config.readBoolEntry( "Open", false )); |
61 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 60 | connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
62 | close = new QCheckBox( tr("Close"), bg ); | 61 | close = new QCheckBox( tr("Close"), bg ); |
63 | close->setChecked(config.readBoolEntry( "Close", false )); | 62 | close->setChecked(config.readBoolEntry( "Close", false )); |
64 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 63 | connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
65 | info = new QCheckBox( tr("Info"), bg ); | 64 | info = new QCheckBox( tr("Info"), bg ); |
66 | info->setChecked(config.readBoolEntry( "Info", false )); | 65 | info->setChecked(config.readBoolEntry( "Info", false )); |
67 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 66 | connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
68 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); | 67 | twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); |
69 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); | 68 | twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); |
70 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 69 | connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
71 | find = new QCheckBox( tr("Find"), bg ); | 70 | find = new QCheckBox( tr("Find"), bg ); |
72 | find->setChecked(config.readBoolEntry( "Find", false )); | 71 | find->setChecked(config.readBoolEntry( "Find", false )); |
73 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 72 | connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
74 | 73 | ||
75 | bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); | 74 | bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); |
76 | vb->addWidget(bg); | 75 | vb->addWidget(bg); |
77 | scroll = new QCheckBox( tr("Scroll"), bg ); | 76 | scroll = new QCheckBox( tr("Scroll"), bg ); |
78 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); | 77 | scroll->setChecked(config.readBoolEntry( "Scroll", false )); |
79 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 78 | connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
80 | navigation = new QCheckBox( tr("Back/Home/Forward"), bg ); | 79 | navigation = new QCheckBox( tr("Back/Home/Forward"), bg ); |
81 | navigation->setChecked(config.readBoolEntry( "Back/Home/Forward", false )); | 80 | navigation->setChecked(config.readBoolEntry( "Back/Home/Forward", false )); |
82 | connect(navigation, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 81 | connect(navigation, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
83 | page = new QCheckBox( tr("Page\nUp/Down"), bg ); | 82 | page = new QCheckBox( tr("Page\nUp/Down"), bg ); |
84 | page->setChecked(config.readBoolEntry( "Page Up/Down", false )); | 83 | page->setChecked(config.readBoolEntry( "Page Up/Down", false )); |
85 | connect(page, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 84 | connect(page, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
86 | startend = new QCheckBox( tr("Goto Start/End"), bg ); | 85 | startend = new QCheckBox( tr("Goto Start/End"), bg ); |
87 | startend->setChecked(config.readBoolEntry( "Goto Start/End", false )); | 86 | startend->setChecked(config.readBoolEntry( "Goto Start/End", false )); |
88 | connect(startend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 87 | connect(startend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
89 | jump = new QCheckBox( tr("Jump"), bg ); | 88 | jump = new QCheckBox( tr("Jump"), bg ); |
90 | jump->setChecked(config.readBoolEntry( "Jump", false )); | 89 | jump->setChecked(config.readBoolEntry( "Jump", false )); |
91 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 90 | connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
92 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); | 91 | pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); |
93 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); | 92 | pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); |
94 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 93 | connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
95 | m_isChanged = false; | 94 | m_isChanged = false; |
96 | } | 95 | } |
97 | 96 | ||
98 | void CBarPrefs1::saveall() | 97 | void CBarPrefs1::saveall() |
99 | { | 98 | { |
100 | config.setGroup( "Toolbar" ); | 99 | config.setGroup( "Toolbar" ); |
101 | config.writeEntry( "Open", open->isChecked()); | 100 | config.writeEntry( "Open", open->isChecked()); |
102 | config.writeEntry( "Close", close->isChecked()); | 101 | config.writeEntry( "Close", close->isChecked()); |
103 | config.writeEntry( "Info", info->isChecked()); | 102 | config.writeEntry( "Info", info->isChecked()); |
104 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); | 103 | config.writeEntry( "Two/One Touch", twotouch->isChecked()); |
105 | config.writeEntry( "Find", find->isChecked()); | 104 | config.writeEntry( "Find", find->isChecked()); |
106 | config.writeEntry( "Scroll", scroll->isChecked()); | 105 | config.writeEntry( "Scroll", scroll->isChecked()); |
107 | config.writeEntry( "Back/Home/Forward", navigation->isChecked()); | 106 | config.writeEntry( "Back/Home/Forward", navigation->isChecked()); |
108 | config.writeEntry( "Page Up/Down", page->isChecked()); | 107 | config.writeEntry( "Page Up/Down", page->isChecked()); |
109 | config.writeEntry( "Goto Start/End", startend->isChecked()); | 108 | config.writeEntry( "Goto Start/End", startend->isChecked()); |
110 | config.writeEntry( "Jump", jump->isChecked()); | 109 | config.writeEntry( "Jump", jump->isChecked()); |
111 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); | 110 | config.writeEntry( "Page/Line Scroll", pageline->isChecked()); |
112 | } | 111 | } |
113 | 112 | ||
114 | CBarPrefs1::~CBarPrefs1() | 113 | CBarPrefs1::~CBarPrefs1() |
115 | { | 114 | { |
116 | } | 115 | } |
117 | */ | 116 | */ |
118 | /* | 117 | /* |
119 | CBarPrefs2::CBarPrefs2( Config& _config, QWidget* parent, const char* name, WFlags fl ) | 118 | CBarPrefs2::CBarPrefs2( Config& _config, QWidget* parent, const char* name, WFlags fl ) |
120 | : QWidget( parent, name, fl ), config(_config) | 119 | : QWidget( parent, name, fl ), config(_config) |
121 | { | 120 | { |
122 | QVBoxLayout* vb = new QVBoxLayout(this); | 121 | QVBoxLayout* vb = new QVBoxLayout(this); |
123 | 122 | ||
124 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "View", this); | 123 | QGroupBox* bg = new QGroupBox(3, Qt::Horizontal, "View", this); |
125 | vb->addWidget(bg); | 124 | vb->addWidget(bg); |
126 | 125 | ||
127 | config.setGroup( "Toolbar" ); | 126 | config.setGroup( "Toolbar" ); |
128 | 127 | ||
129 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); | 128 | fullscreen = new QCheckBox( tr("Fullscreen"), bg ); |
130 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); | 129 | fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); |
131 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 130 | connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
132 | rotate = new QCheckBox( tr("Rotate"), bg ); | 131 | rotate = new QCheckBox( tr("Rotate"), bg ); |
133 | rotate->setChecked(config.readBoolEntry( "Rotate", false )); | 132 | rotate->setChecked(config.readBoolEntry( "Rotate", false )); |
134 | connect(rotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 133 | connect(rotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
135 | 134 | ||
136 | invert = new QCheckBox( tr("Invert"), bg ); | 135 | invert = new QCheckBox( tr("Invert"), bg ); |
137 | invert->setChecked(config.readBoolEntry( "Invert Action", false )); | 136 | invert->setChecked(config.readBoolEntry( "Invert Action", false )); |
138 | connect(invert, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 137 | connect(invert, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
139 | 138 | ||
140 | zoom = new QCheckBox( tr("Zoom"), bg ); | 139 | zoom = new QCheckBox( tr("Zoom"), bg ); |
141 | zoom->setChecked(config.readBoolEntry( "Zoom In/Out", false )); | 140 | zoom->setChecked(config.readBoolEntry( "Zoom In/Out", false )); |
142 | connect(zoom, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 141 | connect(zoom, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
143 | setfont = new QCheckBox( tr("Set Font"), bg ); | 142 | setfont = new QCheckBox( tr("Set Font"), bg ); |
144 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); | 143 | setfont->setChecked(config.readBoolEntry( "Set Font", false )); |
145 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 144 | connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
146 | 145 | ||
147 | encoding = new QCheckBox( tr("Encoding"), bg ); | 146 | encoding = new QCheckBox( tr("Encoding"), bg ); |
148 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); | 147 | encoding->setChecked(config.readBoolEntry("Encoding Select", false)); |
149 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 148 | connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
150 | ideogram = new QCheckBox( tr("Ideogram"), bg ); | 149 | ideogram = new QCheckBox( tr("Ideogram"), bg ); |
151 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); | 150 | ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); |
152 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 151 | connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
153 | 152 | ||
154 | bg = new QGroupBox(3, Qt::Horizontal, "Marks", this); | 153 | bg = new QGroupBox(3, Qt::Horizontal, "Marks", this); |
155 | vb->addWidget(bg); | 154 | vb->addWidget(bg); |
156 | mark = new QCheckBox( tr("Bookmark"), bg ); | 155 | mark = new QCheckBox( tr("Bookmark"), bg ); |
157 | mark->setChecked(config.readBoolEntry( "Mark", false )); | 156 | mark->setChecked(config.readBoolEntry( "Mark", false )); |
158 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 157 | connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
159 | annotate = new QCheckBox( tr("Annotate"), bg ); | 158 | annotate = new QCheckBox( tr("Annotate"), bg ); |
160 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); | 159 | annotate->setChecked(config.readBoolEntry( "Annotate", false )); |
161 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 160 | connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
162 | go_to = new QCheckBox( tr("Goto"), bg ); | 161 | go_to = new QCheckBox( tr("Goto"), bg ); |
163 | go_to->setChecked(config.readBoolEntry( "Goto", false )); | 162 | go_to->setChecked(config.readBoolEntry( "Goto", false )); |
164 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 163 | connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
165 | Delete = new QCheckBox( tr("Delete"), bg ); | 164 | Delete = new QCheckBox( tr("Delete"), bg ); |
166 | Delete->setChecked(config.readBoolEntry( "Delete", false )); | 165 | Delete->setChecked(config.readBoolEntry( "Delete", false )); |
167 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 166 | connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
168 | autogen = new QCheckBox( tr("Autogen"), bg ); | 167 | autogen = new QCheckBox( tr("Autogen"), bg ); |
169 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); | 168 | autogen->setChecked(config.readBoolEntry( "Autogen", false )); |
170 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 169 | connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
171 | clear = new QCheckBox( tr("Clear"), bg ); | 170 | clear = new QCheckBox( tr("Clear"), bg ); |
172 | clear->setChecked(config.readBoolEntry( "Clear", false )); | 171 | clear->setChecked(config.readBoolEntry( "Clear", false )); |
173 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 172 | connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
174 | save = new QCheckBox( tr("Save"), bg ); | 173 | save = new QCheckBox( tr("Save"), bg ); |
175 | save->setChecked(config.readBoolEntry( "Save", false )); | 174 | save->setChecked(config.readBoolEntry( "Save", false )); |
176 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 175 | connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
177 | tidy = new QCheckBox( tr("Tidy"), bg ); | 176 | tidy = new QCheckBox( tr("Tidy"), bg ); |
178 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); | 177 | tidy->setChecked(config.readBoolEntry( "Tidy", false )); |
179 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 178 | connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
180 | block = new QCheckBox( tr("Mark/Copy"), bg ); | 179 | block = new QCheckBox( tr("Mark/Copy"), bg ); |
181 | block->setChecked(config.readBoolEntry( "Start/Copy Block", false )); | 180 | block->setChecked(config.readBoolEntry( "Start/Copy Block", false )); |
182 | connect(block, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 181 | connect(block, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
183 | 182 | ||
184 | bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); | 183 | bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); |
185 | vb->addWidget(bg); | 184 | vb->addWidget(bg); |
186 | indannotate = new QCheckBox( tr("Annotation"), bg ); | 185 | indannotate = new QCheckBox( tr("Annotation"), bg ); |
187 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); | 186 | indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); |
188 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); | 187 | connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); |
189 | m_isChanged = false; | 188 | m_isChanged = false; |
190 | } | 189 | } |
191 | 190 | ||
192 | void CBarPrefs2::saveall() | 191 | void CBarPrefs2::saveall() |
193 | { | 192 | { |
194 | config.setGroup( "Toolbar" ); | 193 | config.setGroup( "Toolbar" ); |
195 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); | 194 | config.writeEntry( "Fullscreen", fullscreen->isChecked()); |
196 | config.writeEntry( "Rotate", rotate->isChecked()); | 195 | config.writeEntry( "Rotate", rotate->isChecked()); |
197 | config.writeEntry( "Invert Action", invert->isChecked()); | 196 | config.writeEntry( "Invert Action", invert->isChecked()); |
198 | config.writeEntry( "Zoom In/Out", zoom->isChecked()); | 197 | config.writeEntry( "Zoom In/Out", zoom->isChecked()); |
199 | config.writeEntry( "Set Font", setfont->isChecked()); | 198 | config.writeEntry( "Set Font", setfont->isChecked()); |
200 | config.writeEntry("Encoding Select", encoding->isChecked()); | 199 | config.writeEntry("Encoding Select", encoding->isChecked()); |
201 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); | 200 | config.writeEntry("Ideogram Mode", ideogram->isChecked()); |
diff --git a/noncore/apps/opie-reader/ToolbarPrefs.h b/noncore/apps/opie-reader/ToolbarPrefs.h index a2686e5..0bdae6b 100644 --- a/noncore/apps/opie-reader/ToolbarPrefs.h +++ b/noncore/apps/opie-reader/ToolbarPrefs.h | |||
@@ -1,218 +1,216 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form interface generated from reading ui file 'Prefs.ui' | 2 | ** Form interface generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:32 2003 | 4 | ** Created: Tue Feb 11 23:53:32 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #ifndef CTOOLBARPREFS_H | 9 | #ifndef CTOOLBARPREFS_H |
10 | #define CTOOLBARPREFS_H | 10 | #define CTOOLBARPREFS_H |
11 | #include "useqpe.h" | ||
12 | #include <qvariant.h> | 11 | #include <qvariant.h> |
13 | #include <qwidget.h> | 12 | #include <qwidget.h> |
14 | #include <qtabdialog.h> | 13 | #include <qtabdialog.h> |
15 | #include <qtabwidget.h> | 14 | #include <qtabwidget.h> |
16 | #include <qspinbox.h> | 15 | #include <qspinbox.h> |
17 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
18 | #include <qcombobox.h> | 17 | #include <qcombobox.h> |
19 | #include <qlineedit.h> | 18 | #include <qlineedit.h> |
20 | #ifdef USEQPE | 19 | #ifdef USEQPE |
21 | #include <qpe/menubutton.h> | 20 | #include <qpe/menubutton.h> |
22 | #include <qpe/config.h> | 21 | #include <qpe/config.h> |
23 | #else | 22 | #else |
24 | #include "preferences.h" | 23 | #include "preferences.h" |
25 | #endif | 24 | #endif |
26 | //#include "opie.h" | ||
27 | //#ifdef OPIE | 25 | //#ifdef OPIE |
28 | #define USECOMBO | 26 | #define USECOMBO |
29 | //#endif | 27 | //#endif |
30 | 28 | ||
31 | class QVBoxLayout; | 29 | class QVBoxLayout; |
32 | class QHBoxLayout; | 30 | class QHBoxLayout; |
33 | class QGridLayout; | 31 | class QGridLayout; |
34 | //class QCheckBox; | 32 | //class QCheckBox; |
35 | class QLabel; | 33 | class QLabel; |
36 | //class QSpinBox; | 34 | //class QSpinBox; |
37 | /* | 35 | /* |
38 | class CBarPrefs1 : public QWidget | 36 | class CBarPrefs1 : public QWidget |
39 | { | 37 | { |
40 | Q_OBJECT | 38 | Q_OBJECT |
41 | 39 | ||
42 | Config& config; | 40 | Config& config; |
43 | QCheckBox *open, *close, *info, *twotouch,*find,*scroll,*navigation,*page,*startend,*jump,*pageline; | 41 | QCheckBox *open, *close, *info, *twotouch,*find,*scroll,*navigation,*page,*startend,*jump,*pageline; |
44 | 42 | ||
45 | bool m_isChanged; | 43 | bool m_isChanged; |
46 | 44 | ||
47 | private slots: | 45 | private slots: |
48 | void isChanged(int _v) { m_isChanged = true; } | 46 | void isChanged(int _v) { m_isChanged = true; } |
49 | 47 | ||
50 | public: | 48 | public: |
51 | CBarPrefs1( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 49 | CBarPrefs1( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
52 | ~CBarPrefs1(); | 50 | ~CBarPrefs1(); |
53 | void saveall(); | 51 | void saveall(); |
54 | bool isChanged() { return m_isChanged; } | 52 | bool isChanged() { return m_isChanged; } |
55 | }; | 53 | }; |
56 | */ | 54 | */ |
57 | class CFileBarPrefs : public QWidget | 55 | class CFileBarPrefs : public QWidget |
58 | { | 56 | { |
59 | Q_OBJECT | 57 | Q_OBJECT |
60 | 58 | ||
61 | Config& config; | 59 | Config& config; |
62 | QCheckBox *open, *close, *info, *twotouch, *find, *scroll; | 60 | QCheckBox *open, *close, *info, *twotouch, *find, *scroll; |
63 | 61 | ||
64 | bool m_isChanged; | 62 | bool m_isChanged; |
65 | 63 | ||
66 | private slots: | 64 | private slots: |
67 | void isChanged(int _v) { m_isChanged = true; } | 65 | void isChanged(int _v) { m_isChanged = true; } |
68 | 66 | ||
69 | public: | 67 | public: |
70 | CFileBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 68 | CFileBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
71 | ~CFileBarPrefs(); | 69 | ~CFileBarPrefs(); |
72 | void saveall(); | 70 | void saveall(); |
73 | bool isChanged() { return m_isChanged; } | 71 | bool isChanged() { return m_isChanged; } |
74 | }; | 72 | }; |
75 | 73 | ||
76 | class CNavBarPrefs : public QWidget | 74 | class CNavBarPrefs : public QWidget |
77 | { | 75 | { |
78 | Q_OBJECT | 76 | Q_OBJECT |
79 | 77 | ||
80 | Config& config; | 78 | Config& config; |
81 | QCheckBox *scroll, *navback, *navhome, *navforward; | 79 | QCheckBox *scroll, *navback, *navhome, *navforward; |
82 | QCheckBox *pageup, *pagedown, *gotostart, *gotoend, *jump, *pageline; | 80 | QCheckBox *pageup, *pagedown, *gotostart, *gotoend, *jump, *pageline; |
83 | 81 | ||
84 | bool m_isChanged; | 82 | bool m_isChanged; |
85 | 83 | ||
86 | private slots: | 84 | private slots: |
87 | void isChanged(int _v) { m_isChanged = true; } | 85 | void isChanged(int _v) { m_isChanged = true; } |
88 | 86 | ||
89 | public: | 87 | public: |
90 | CNavBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 88 | CNavBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
91 | ~CNavBarPrefs(); | 89 | ~CNavBarPrefs(); |
92 | void saveall(); | 90 | void saveall(); |
93 | bool isChanged() { return m_isChanged; } | 91 | bool isChanged() { return m_isChanged; } |
94 | }; | 92 | }; |
95 | /* | 93 | /* |
96 | class CBarPrefs2 : public QWidget | 94 | class CBarPrefs2 : public QWidget |
97 | { | 95 | { |
98 | Q_OBJECT | 96 | Q_OBJECT |
99 | Config& config; | 97 | Config& config; |
100 | QCheckBox *fullscreen, *zoom, *setfont, *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *block, *indannotate, *encoding, *ideogram; | 98 | QCheckBox *fullscreen, *zoom, *setfont, *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *block, *indannotate, *encoding, *ideogram; |
101 | 99 | ||
102 | bool m_isChanged; | 100 | bool m_isChanged; |
103 | 101 | ||
104 | private slots: | 102 | private slots: |
105 | void isChanged(int _v) { m_isChanged = true; } | 103 | void isChanged(int _v) { m_isChanged = true; } |
106 | 104 | ||
107 | public: | 105 | public: |
108 | CBarPrefs2( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 106 | CBarPrefs2( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
109 | ~CBarPrefs2(); | 107 | ~CBarPrefs2(); |
110 | void saveall(); | 108 | void saveall(); |
111 | bool isChanged() { return m_isChanged; } | 109 | bool isChanged() { return m_isChanged; } |
112 | 110 | ||
113 | }; | 111 | }; |
114 | */ | 112 | */ |
115 | class CViewBarPrefs : public QWidget | 113 | class CViewBarPrefs : public QWidget |
116 | { | 114 | { |
117 | Q_OBJECT | 115 | Q_OBJECT |
118 | Config& config; | 116 | Config& config; |
119 | QCheckBox *fullscreen, *rotate, *zoomin, *zoomout, *setfont, *encoding, *ideogram, *invert; | 117 | QCheckBox *fullscreen, *rotate, *zoomin, *zoomout, *setfont, *encoding, *ideogram, *invert; |
120 | 118 | ||
121 | bool m_isChanged; | 119 | bool m_isChanged; |
122 | 120 | ||
123 | private slots: | 121 | private slots: |
124 | void isChanged(int _v) { m_isChanged = true; } | 122 | void isChanged(int _v) { m_isChanged = true; } |
125 | 123 | ||
126 | public: | 124 | public: |
127 | CViewBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 125 | CViewBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
128 | ~CViewBarPrefs(); | 126 | ~CViewBarPrefs(); |
129 | void saveall(); | 127 | void saveall(); |
130 | bool isChanged() { return m_isChanged; } | 128 | bool isChanged() { return m_isChanged; } |
131 | 129 | ||
132 | }; | 130 | }; |
133 | 131 | ||
134 | class CMarkBarPrefs : public QWidget | 132 | class CMarkBarPrefs : public QWidget |
135 | { | 133 | { |
136 | Q_OBJECT | 134 | Q_OBJECT |
137 | Config& config; | 135 | Config& config; |
138 | QCheckBox *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *startblock, *copyblock; | 136 | QCheckBox *mark, *annotate, *go_to, *Delete, *autogen, *clear, *save, *tidy, *startblock, *copyblock; |
139 | 137 | ||
140 | bool m_isChanged; | 138 | bool m_isChanged; |
141 | 139 | ||
142 | private slots: | 140 | private slots: |
143 | void isChanged(int _v) { m_isChanged = true; } | 141 | void isChanged(int _v) { m_isChanged = true; } |
144 | 142 | ||
145 | public: | 143 | public: |
146 | CMarkBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 144 | CMarkBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
147 | ~CMarkBarPrefs(); | 145 | ~CMarkBarPrefs(); |
148 | void saveall(); | 146 | void saveall(); |
149 | bool isChanged() { return m_isChanged; } | 147 | bool isChanged() { return m_isChanged; } |
150 | 148 | ||
151 | }; | 149 | }; |
152 | 150 | ||
153 | class CIndBarPrefs : public QWidget | 151 | class CIndBarPrefs : public QWidget |
154 | { | 152 | { |
155 | Q_OBJECT | 153 | Q_OBJECT |
156 | Config& config; | 154 | Config& config; |
157 | QCheckBox *indannotate; | 155 | QCheckBox *indannotate; |
158 | 156 | ||
159 | bool m_isChanged; | 157 | bool m_isChanged; |
160 | 158 | ||
161 | private slots: | 159 | private slots: |
162 | void isChanged(int _v) { m_isChanged = true; } | 160 | void isChanged(int _v) { m_isChanged = true; } |
163 | 161 | ||
164 | public: | 162 | public: |
165 | CIndBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 163 | CIndBarPrefs( Config&, QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
166 | ~CIndBarPrefs(); | 164 | ~CIndBarPrefs(); |
167 | void saveall(); | 165 | void saveall(); |
168 | bool isChanged() { return m_isChanged; } | 166 | bool isChanged() { return m_isChanged; } |
169 | 167 | ||
170 | }; | 168 | }; |
171 | 169 | ||
172 | class CMiscBarPrefs : public QWidget | 170 | class CMiscBarPrefs : public QWidget |
173 | { | 171 | { |
174 | 172 | ||
175 | public: | 173 | public: |
176 | 174 | ||
177 | CMiscBarPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 175 | CMiscBarPrefs( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
178 | ~CMiscBarPrefs(); | 176 | ~CMiscBarPrefs(); |
179 | 177 | ||
180 | #ifdef USECOMBO | 178 | #ifdef USECOMBO |
181 | QComboBox *tbpolicy, *tbposition, *qtscroll, *localscroll; | 179 | QComboBox *tbpolicy, *tbposition, *qtscroll, *localscroll; |
182 | #else | 180 | #else |
183 | MenuButton *tbpolicy, *tbposition, *qtscroll, *localscroll; | 181 | MenuButton *tbpolicy, *tbposition, *qtscroll, *localscroll; |
184 | #endif | 182 | #endif |
185 | QCheckBox *tbmovable, *floating; | 183 | QCheckBox *tbmovable, *floating; |
186 | }; | 184 | }; |
187 | 185 | ||
188 | class CBarPrefs : public QDialog | 186 | class CBarPrefs : public QDialog |
189 | { | 187 | { |
190 | Q_OBJECT | 188 | Q_OBJECT |
191 | ; | 189 | ; |
192 | CMiscBarPrefs* misc; | 190 | CMiscBarPrefs* misc; |
193 | CFileBarPrefs* filebar; | 191 | CFileBarPrefs* filebar; |
194 | CNavBarPrefs* navbar; | 192 | CNavBarPrefs* navbar; |
195 | CViewBarPrefs* viewbar; | 193 | CViewBarPrefs* viewbar; |
196 | CMarkBarPrefs* markbar; | 194 | CMarkBarPrefs* markbar; |
197 | CIndBarPrefs* indbar; | 195 | CIndBarPrefs* indbar; |
198 | Config config; | 196 | Config config; |
199 | 197 | ||
200 | void keyPressEvent(QKeyEvent* e) | 198 | void keyPressEvent(QKeyEvent* e) |
201 | { | 199 | { |
202 | switch (e->key()) | 200 | switch (e->key()) |
203 | { | 201 | { |
204 | case Key_Escape: | 202 | case Key_Escape: |
205 | e->accept(); | 203 | e->accept(); |
206 | reject(); | 204 | reject(); |
207 | break; | 205 | break; |
208 | case Key_Space: | 206 | case Key_Space: |
209 | case Key_Return: | 207 | case Key_Return: |
210 | e->accept(); | 208 | e->accept(); |
211 | accept(); | 209 | accept(); |
212 | break; | 210 | break; |
213 | default: | 211 | default: |
214 | QWidget::keyPressEvent(e); | 212 | QWidget::keyPressEvent(e); |
215 | } | 213 | } |
216 | } | 214 | } |
217 | public: | 215 | public: |
218 | CBarPrefs(const QString& appdir, bool fs = true, QWidget* parent = 0, const char* name = 0); | 216 | CBarPrefs(const QString& appdir, bool fs = true, QWidget* parent = 0, const char* name = 0); |
diff --git a/noncore/apps/opie-reader/URLDialog.h b/noncore/apps/opie-reader/URLDialog.h index 1bcc4bd..792d13a 100644 --- a/noncore/apps/opie-reader/URLDialog.h +++ b/noncore/apps/opie-reader/URLDialog.h | |||
@@ -1,65 +1,64 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Form interface generated from reading ui file 'Prefs.ui' | 2 | ** Form interface generated from reading ui file 'Prefs.ui' |
3 | ** | 3 | ** |
4 | ** Created: Tue Feb 11 23:53:32 2003 | 4 | ** Created: Tue Feb 11 23:53:32 2003 |
5 | ** by: The User Interface Compiler (uic) | 5 | ** by: The User Interface Compiler (uic) |
6 | ** | 6 | ** |
7 | ** WARNING! All changes made in this file will be lost! | 7 | ** WARNING! All changes made in this file will be lost! |
8 | ****************************************************************************/ | 8 | ****************************************************************************/ |
9 | #ifndef __URLDIALOG_H | 9 | #ifndef __URLDIALOG_H |
10 | #define __URLDIALOG_H | 10 | #define __URLDIALOG_H |
11 | 11 | ||
12 | #include "useqpe.h" | ||
13 | #include <qvariant.h> | 12 | #include <qvariant.h> |
14 | #include <qwidget.h> | 13 | #include <qwidget.h> |
15 | #include <qtabdialog.h> | 14 | #include <qtabdialog.h> |
16 | #include <qtabwidget.h> | 15 | #include <qtabwidget.h> |
17 | #include <qspinbox.h> | 16 | #include <qspinbox.h> |
18 | #include <qcheckbox.h> | 17 | #include <qcheckbox.h> |
19 | #include <qcombobox.h> | 18 | #include <qcombobox.h> |
20 | #include <qlineedit.h> | 19 | #include <qlineedit.h> |
21 | //#include <qpe/menubutton.h> | 20 | //#include <qpe/menubutton.h> |
22 | #include <qvbuttongroup.h> | 21 | #include <qvbuttongroup.h> |
23 | 22 | ||
24 | class QVBoxLayout; | 23 | class QVBoxLayout; |
25 | class QHBoxLayout; | 24 | class QHBoxLayout; |
26 | class QGridLayout; | 25 | class QGridLayout; |
27 | //class QCheckBox; | 26 | //class QCheckBox; |
28 | class QLabel; | 27 | class QLabel; |
29 | //class QSpinBox; | 28 | //class QSpinBox; |
30 | 29 | ||
31 | class CURLDialog : public QDialog | 30 | class CURLDialog : public QDialog |
32 | { | 31 | { |
33 | Q_OBJECT | 32 | Q_OBJECT |
34 | QCheckBox *m_localfile, *m_globalfile, *m_clipboard; | 33 | QCheckBox *m_localfile, *m_globalfile, *m_clipboard; |
35 | #ifndef USEQPE | 34 | #ifndef USEQPE |
36 | void keyPressEvent(QKeyEvent* e) | 35 | void keyPressEvent(QKeyEvent* e) |
37 | { | 36 | { |
38 | switch (e->key()) | 37 | switch (e->key()) |
39 | { | 38 | { |
40 | case Key_Escape: | 39 | case Key_Escape: |
41 | e->accept(); | 40 | e->accept(); |
42 | reject(); | 41 | reject(); |
43 | break; | 42 | break; |
44 | case Key_Space: | 43 | case Key_Space: |
45 | case Key_Return: | 44 | case Key_Return: |
46 | e->accept(); | 45 | e->accept(); |
47 | accept(); | 46 | accept(); |
48 | break; | 47 | break; |
49 | default: | 48 | default: |
50 | QWidget::keyPressEvent(e); | 49 | QWidget::keyPressEvent(e); |
51 | } | 50 | } |
52 | } | 51 | } |
53 | #endif | 52 | #endif |
54 | public: | 53 | public: |
55 | CURLDialog(const QString&, bool fs = true, QWidget* parent = 0, const char* name = 0); | 54 | CURLDialog(const QString&, bool fs = true, QWidget* parent = 0, const char* name = 0); |
56 | ~CURLDialog() {} | 55 | ~CURLDialog() {} |
57 | bool clipboard() { return m_clipboard->isChecked(); } | 56 | bool clipboard() { return m_clipboard->isChecked(); } |
58 | bool localfile() { return m_localfile->isChecked(); } | 57 | bool localfile() { return m_localfile->isChecked(); } |
59 | bool globalfile() { return m_globalfile->isChecked(); } | 58 | bool globalfile() { return m_globalfile->isChecked(); } |
60 | void clipboard(bool _b) { m_clipboard->setChecked(_b); } | 59 | void clipboard(bool _b) { m_clipboard->setChecked(_b); } |
61 | void localfile(bool _b) { m_localfile->setChecked(_b); } | 60 | void localfile(bool _b) { m_localfile->setChecked(_b); } |
62 | void globalfile(bool _b) { m_globalfile->setChecked(_b); } | 61 | void globalfile(bool _b) { m_globalfile->setChecked(_b); } |
63 | 62 | ||
64 | }; | 63 | }; |
65 | #endif // CPREFS_H | 64 | #endif // CPREFS_H |
diff --git a/noncore/apps/opie-reader/WeaselCodec/WeaselCodec.pro b/noncore/apps/opie-reader/WeaselCodec/WeaselCodec.pro index 61e7dc9..f20bdc6 100644 --- a/noncore/apps/opie-reader/WeaselCodec/WeaselCodec.pro +++ b/noncore/apps/opie-reader/WeaselCodec/WeaselCodec.pro | |||
@@ -1,17 +1,17 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = ztxt.h | 5 | HEADERS = ztxt.h |
6 | 6 | ||
7 | SOURCES = ztxt.cpp | 7 | SOURCES = ztxt.cpp |
8 | 8 | ||
9 | INTERFACES= | 9 | INTERFACES= |
10 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 10 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
11 | TARGET = Weasel | 11 | TARGET = Weasel |
12 | LIBS += -lreader_pdb -lreader_codec | 12 | LIBS += -lreader_pdb -lreader_codec |
13 | 13 | ||
14 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 14 | INCLUDEPATH+= $(OPIEDIR)/include |
15 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | DEPENDPATH+= $(OPIEDIR)/include |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/ZText.h b/noncore/apps/opie-reader/ZText.h index 06e3bf8..199c7da 100644 --- a/noncore/apps/opie-reader/ZText.h +++ b/noncore/apps/opie-reader/ZText.h | |||
@@ -1,116 +1,115 @@ | |||
1 | #ifndef __Text_h | 1 | #ifndef __Text_h |
2 | #define __Text_h | 2 | #define __Text_h |
3 | #include <stdio.h> | 3 | #include <stdio.h> |
4 | #include <zlib.h> | 4 | #include <zlib.h> |
5 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
6 | #include "useqpe.h" | ||
7 | #include "CExpander.h" | 6 | #include "CExpander.h" |
8 | 7 | ||
9 | class Text: public CExpander { | 8 | class Text: public CExpander { |
10 | gzFile file; | 9 | gzFile file; |
11 | unsigned long fsize; | 10 | unsigned long fsize; |
12 | public: | 11 | public: |
13 | void suspend() | 12 | void suspend() |
14 | { | 13 | { |
15 | #ifdef USEQPE | 14 | #ifdef USEQPE |
16 | if (!bSuspended) | 15 | if (!bSuspended) |
17 | { | 16 | { |
18 | bSuspended = true; | 17 | bSuspended = true; |
19 | suspos = gztell(file); | 18 | suspos = gztell(file); |
20 | gzclose(file); | 19 | gzclose(file); |
21 | file = NULL; | 20 | file = NULL; |
22 | sustime = time(NULL); | 21 | sustime = time(NULL); |
23 | } | 22 | } |
24 | #endif | 23 | #endif |
25 | } | 24 | } |
26 | void unsuspend() | 25 | void unsuspend() |
27 | { | 26 | { |
28 | #ifdef USEQPE | 27 | #ifdef USEQPE |
29 | if (bSuspended) | 28 | if (bSuspended) |
30 | { | 29 | { |
31 | bSuspended = false; | 30 | bSuspended = false; |
32 | if (sustime != ((time_t)-1)) | 31 | if (sustime != ((time_t)-1)) |
33 | { | 32 | { |
34 | int delay = time(NULL) - sustime; | 33 | int delay = time(NULL) - sustime; |
35 | if (delay < 10) sleep(10-delay); | 34 | if (delay < 10) sleep(10-delay); |
36 | } | 35 | } |
37 | file = gzopen(fname, "rb"); | 36 | file = gzopen(fname, "rb"); |
38 | for (int i = 0; file == NULL && i < 5; i++) | 37 | for (int i = 0; file == NULL && i < 5; i++) |
39 | { | 38 | { |
40 | sleep(5); | 39 | sleep(5); |
41 | file = gzopen(fname, "rb"); | 40 | file = gzopen(fname, "rb"); |
42 | } | 41 | } |
43 | if (file == NULL) | 42 | if (file == NULL) |
44 | { | 43 | { |
45 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); | 44 | QMessageBox::warning(NULL, PROGNAME, "Couldn't reopen file"); |
46 | exit(0); | 45 | exit(0); |
47 | } | 46 | } |
48 | suspos = gzseek(file, suspos, SEEK_SET); | 47 | suspos = gzseek(file, suspos, SEEK_SET); |
49 | } | 48 | } |
50 | #endif | 49 | #endif |
51 | } | 50 | } |
52 | Text() : file(NULL) {}; | 51 | Text() : file(NULL) {}; |
53 | virtual ~Text() | 52 | virtual ~Text() |
54 | { | 53 | { |
55 | if (file != NULL) | 54 | if (file != NULL) |
56 | { | 55 | { |
57 | #ifdef USEQPE | 56 | #ifdef USEQPE |
58 | unsuspend(); | 57 | unsuspend(); |
59 | #endif | 58 | #endif |
60 | gzclose(file); | 59 | gzclose(file); |
61 | } | 60 | } |
62 | } | 61 | } |
63 | int OpenFile(const char *src) | 62 | int OpenFile(const char *src) |
64 | { | 63 | { |
65 | if (file != NULL) gzclose(file); | 64 | if (file != NULL) gzclose(file); |
66 | struct stat _stat; | 65 | struct stat _stat; |
67 | stat(src,&_stat); | 66 | stat(src,&_stat); |
68 | fsize = _stat.st_size; | 67 | fsize = _stat.st_size; |
69 | return ((file = gzopen(src,"rb")) == NULL); | 68 | return ((file = gzopen(src,"rb")) == NULL); |
70 | } | 69 | } |
71 | int getch() | 70 | int getch() |
72 | { | 71 | { |
73 | #ifdef USEQPE | 72 | #ifdef USEQPE |
74 | unsuspend(); | 73 | unsuspend(); |
75 | #endif | 74 | #endif |
76 | return gzgetc(file); | 75 | return gzgetc(file); |
77 | } | 76 | } |
78 | unsigned int locate() | 77 | unsigned int locate() |
79 | { | 78 | { |
80 | #ifdef USEQPE | 79 | #ifdef USEQPE |
81 | unsuspend(); | 80 | unsuspend(); |
82 | #endif | 81 | #endif |
83 | return gztell(file); | 82 | return gztell(file); |
84 | } | 83 | } |
85 | void locate(unsigned int n) | 84 | void locate(unsigned int n) |
86 | { | 85 | { |
87 | #ifdef USEQPE | 86 | #ifdef USEQPE |
88 | unsuspend(); | 87 | unsuspend(); |
89 | #endif | 88 | #endif |
90 | gzseek(file,n,SEEK_SET); | 89 | gzseek(file,n,SEEK_SET); |
91 | } | 90 | } |
92 | bool hasrandomaccess() { return true; } | 91 | bool hasrandomaccess() { return true; } |
93 | void sizes(unsigned long& _file, unsigned long& _text) | 92 | void sizes(unsigned long& _file, unsigned long& _text) |
94 | { | 93 | { |
95 | _text = _file = fsize; | 94 | _text = _file = fsize; |
96 | FILE* f = fopen(fname, "rb"); | 95 | FILE* f = fopen(fname, "rb"); |
97 | if (f != NULL) | 96 | if (f != NULL) |
98 | { | 97 | { |
99 | unsigned char mn[2]; | 98 | unsigned char mn[2]; |
100 | fread(mn, 1, 2, f); | 99 | fread(mn, 1, 2, f); |
101 | if ((mn[0] == 31) && (mn[1] == 139)) | 100 | if ((mn[0] == 31) && (mn[1] == 139)) |
102 | { | 101 | { |
103 | int tmp = sizeof(_text); | 102 | int tmp = sizeof(_text); |
104 | fseek(f,-tmp,SEEK_END); | 103 | fseek(f,-tmp,SEEK_END); |
105 | fread(&_text, sizeof(_text), 1, f); | 104 | fread(&_text, sizeof(_text), 1, f); |
106 | } | 105 | } |
107 | fclose(f); | 106 | fclose(f); |
108 | } | 107 | } |
109 | } | 108 | } |
110 | MarkupType PreferredMarkup() | 109 | MarkupType PreferredMarkup() |
111 | { | 110 | { |
112 | return cTEXT; | 111 | return cTEXT; |
113 | } | 112 | } |
114 | QString about() { return QString("Text/gzipped text codec (c) Tim Wentford"); } | 113 | QString about() { return QString("Text/gzipped text codec (c) Tim Wentford"); } |
115 | }; | 114 | }; |
116 | #endif | 115 | #endif |
diff --git a/noncore/apps/opie-reader/codeclib/codeclib.pro b/noncore/apps/opie-reader/codeclib/codeclib.pro index 6adcda8..c24767b 100644 --- a/noncore/apps/opie-reader/codeclib/codeclib.pro +++ b/noncore/apps/opie-reader/codeclib/codeclib.pro | |||
@@ -1,17 +1,17 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = pdb.h | 5 | HEADERS = pdb.h |
6 | 6 | ||
7 | SOURCES = CExpander.cpp CBuffer.cpp StyleConsts.cpp \ | 7 | SOURCES = CExpander.cpp CBuffer.cpp StyleConsts.cpp \ |
8 | hrule.cpp Navigation.cpp Bkmks.cpp | 8 | hrule.cpp Navigation.cpp Bkmks.cpp |
9 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/lib | 11 | DESTDIR = $(OPIEDIR)/lib |
12 | TARGET = reader_codec | 12 | TARGET = reader_codec |
13 | 13 | ||
14 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 14 | INCLUDEPATH+= $(OPIEDIR)/include |
15 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | DEPENDPATH+= $(OPIEDIR)/include |
16 | 16 | ||
17 | include ( $(OPIEDIR)/include.pro ) | 17 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/ebookcodec.h b/noncore/apps/opie-reader/ebookcodec.h index b341e55..f6e2daf 100644 --- a/noncore/apps/opie-reader/ebookcodec.h +++ b/noncore/apps/opie-reader/ebookcodec.h | |||
@@ -1,120 +1,118 @@ | |||
1 | #include "CExpander.h" | 1 | #include "CExpander.h" |
2 | 2 | ||
3 | #include <qfileinfo.h> | 3 | #include <qfileinfo.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | 5 | ||
6 | #include "useqpe.h" | ||
7 | #ifdef USEQPE | 6 | #ifdef USEQPE |
8 | #include <qpe/global.h> | 7 | #include <qpe/global.h> |
9 | #endif | 8 | #endif |
10 | 9 | ||
11 | #include "util.h" | 10 | #include "util.h" |
12 | 11 | ||
13 | #include "static.h" | ||
14 | #ifndef __STATIC | 12 | #ifndef __STATIC |
15 | #include <dlfcn.h> | 13 | #include <dlfcn.h> |
16 | class ebookcodec : public CExpander_Interface | 14 | class ebookcodec : public CExpander_Interface |
17 | { | 15 | { |
18 | CExpander *codec; | 16 | CExpander *codec; |
19 | void *handle; | 17 | void *handle; |
20 | int status; | 18 | int status; |
21 | public: | 19 | public: |
22 | QString about() | 20 | QString about() |
23 | { | 21 | { |
24 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); | 22 | return QString("Plug-in ebook codec interface (c) Tim Wentford\n")+codec->about(); |
25 | } | 23 | } |
26 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) | 24 | ebookcodec(const QString& _s) : codec(NULL), handle(NULL), status(0) |
27 | { | 25 | { |
28 | QString codecpath(QTReaderUtil::getPluginPath()); | 26 | QString codecpath(QTReaderUtil::getPluginPath()); |
29 | codecpath += _s; | 27 | codecpath += _s; |
30 | if (QFile::exists(codecpath)) | 28 | if (QFile::exists(codecpath)) |
31 | { | 29 | { |
32 | qDebug("Codec:%s", (const char*)codecpath); | 30 | qDebug("Codec:%s", (const char*)codecpath); |
33 | handle = dlopen(codecpath, RTLD_LAZY); | 31 | handle = dlopen(codecpath, RTLD_LAZY); |
34 | if (handle == 0) | 32 | if (handle == 0) |
35 | { | 33 | { |
36 | /* | 34 | /* |
37 | QString wrn(dlerror()); | 35 | QString wrn(dlerror()); |
38 | QString fmt; | 36 | QString fmt; |
39 | while (wrn.length() > 10) | 37 | while (wrn.length() > 10) |
40 | { | 38 | { |
41 | fmt += wrn.left(10); | 39 | fmt += wrn.left(10); |
42 | fmt += '\n'; | 40 | fmt += '\n'; |
43 | wrn = wrn.right(wrn.length()-10); | 41 | wrn = wrn.right(wrn.length()-10); |
44 | } | 42 | } |
45 | fmt += wrn; | 43 | fmt += wrn; |
46 | QMessageBox::warning(NULL, PROGNAME, fmt); | 44 | QMessageBox::warning(NULL, PROGNAME, fmt); |
47 | */ | 45 | */ |
48 | qDebug("Can't find codec:%s", dlerror()); | 46 | qDebug("Can't find codec:%s", dlerror()); |
49 | status = -10; | 47 | status = -10; |
50 | return; | 48 | return; |
51 | } | 49 | } |
52 | CExpander* (*newcodec)(); | 50 | CExpander* (*newcodec)(); |
53 | newcodec = (CExpander* (*)())dlsym(handle, "newcodec"); | 51 | newcodec = (CExpander* (*)())dlsym(handle, "newcodec"); |
54 | if (newcodec == NULL) | 52 | if (newcodec == NULL) |
55 | { | 53 | { |
56 | qDebug("Can't find newcodec"); | 54 | qDebug("Can't find newcodec"); |
57 | status = -20; | 55 | status = -20; |
58 | return; | 56 | return; |
59 | } | 57 | } |
60 | codec = (*newcodec)(); | 58 | codec = (*newcodec)(); |
61 | } | 59 | } |
62 | else | 60 | else |
63 | { | 61 | { |
64 | qDebug("Can't find codec"); | 62 | qDebug("Can't find codec"); |
65 | } | 63 | } |
66 | if (codec == NULL) | 64 | if (codec == NULL) |
67 | { | 65 | { |
68 | qDebug("Can't do newcodec"); | 66 | qDebug("Can't do newcodec"); |
69 | status = -30; | 67 | status = -30; |
70 | return; | 68 | return; |
71 | } | 69 | } |
72 | } | 70 | } |
73 | virtual ~ebookcodec() | 71 | virtual ~ebookcodec() |
74 | { | 72 | { |
75 | if (codec != NULL) delete codec; | 73 | if (codec != NULL) delete codec; |
76 | if (handle != NULL) dlclose(handle); | 74 | if (handle != NULL) dlclose(handle); |
77 | } | 75 | } |
78 | size_t getHome() { return codec->getHome(); } | 76 | size_t getHome() { return codec->getHome(); } |
79 | #ifdef USEQPE | 77 | #ifdef USEQPE |
80 | void suspend() { codec->suspend(); } | 78 | void suspend() { codec->suspend(); } |
81 | void unsuspend() { codec->unsuspend(); } | 79 | void unsuspend() { codec->unsuspend(); } |
82 | void suspend(FILE*& fin) { codec->suspend(fin); } | 80 | void suspend(FILE*& fin) { codec->suspend(fin); } |
83 | void unsuspend(FILE*& fin) { codec->unsuspend(fin); } | 81 | void unsuspend(FILE*& fin) { codec->unsuspend(fin); } |
84 | #endif | 82 | #endif |
85 | unsigned int locate() { return codec->locate(); } | 83 | unsigned int locate() { return codec->locate(); } |
86 | void locate(unsigned int n) { codec->locate(n); } | 84 | void locate(unsigned int n) { codec->locate(n); } |
87 | bool hasrandomaccess() { return codec->hasrandomaccess(); } | 85 | bool hasrandomaccess() { return codec->hasrandomaccess(); } |
88 | void sizes(unsigned long& file, unsigned long& text) | 86 | void sizes(unsigned long& file, unsigned long& text) |
89 | { | 87 | { |
90 | codec->sizes(file, text); | 88 | codec->sizes(file, text); |
91 | //qDebug("Codec sizes:(%u, %u)", file, text); | 89 | //qDebug("Codec sizes:(%u, %u)", file, text); |
92 | } | 90 | } |
93 | CList<Bkmk>* getbkmklist() { return codec->getbkmklist(); } | 91 | CList<Bkmk>* getbkmklist() { return codec->getbkmklist(); } |
94 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) { codec->getch(ch, sty, pos); } | 92 | void getch(tchar& ch, CStyle& sty, unsigned long& pos) { codec->getch(ch, sty, pos); } |
95 | int getch() { return codec->getch(); } | 93 | int getch() { return codec->getch(); } |
96 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) { return codec->hyperlink(n, noff, wrd, nm); } | 94 | linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) { return codec->hyperlink(n, noff, wrd, nm); } |
97 | MarkupType PreferredMarkup() { return codec->PreferredMarkup(); } | 95 | MarkupType PreferredMarkup() { return codec->PreferredMarkup(); } |
98 | void saveposn(size_t posn) { codec->saveposn(posn); } | 96 | void saveposn(size_t posn) { codec->saveposn(posn); } |
99 | void writeposn(size_t posn) { codec->writeposn(posn); } | 97 | void writeposn(size_t posn) { codec->writeposn(posn); } |
100 | linkType forward(size_t& loc) { return codec->forward(loc); } | 98 | linkType forward(size_t& loc) { return codec->forward(loc); } |
101 | linkType back(size_t& loc) { return codec->back(loc); } | 99 | linkType back(size_t& loc) { return codec->back(loc); } |
102 | bool hasnavigation() { return codec->hasnavigation(); } | 100 | bool hasnavigation() { return codec->hasnavigation(); } |
103 | void start2endSection() { codec->start2endSection(); } | 101 | void start2endSection() { codec->start2endSection(); } |
104 | QImage* getPicture(unsigned long tgt) { return codec->getPicture(tgt); } | 102 | QImage* getPicture(unsigned long tgt) { return codec->getPicture(tgt); } |
105 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) { return codec->setSaveData(data, len, src, srclen); } | 103 | void setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) { return codec->setSaveData(data, len, src, srclen); } |
106 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } | 104 | void putSaveData(unsigned char*& src, unsigned short& srclen) { codec->putSaveData(src, srclen); } |
107 | void setContinuous(bool _b) { codec->setContinuous(_b); } | 105 | void setContinuous(bool _b) { codec->setContinuous(_b); } |
108 | void setwidth(int w) { codec->setwidth(w); } | 106 | void setwidth(int w) { codec->setwidth(w); } |
109 | unsigned long startSection() { return codec->startSection(); } | 107 | unsigned long startSection() { return codec->startSection(); } |
110 | unsigned long endSection() { return codec->endSection(); } | 108 | unsigned long endSection() { return codec->endSection(); } |
111 | int openfile(const char *src) | 109 | int openfile(const char *src) |
112 | { | 110 | { |
113 | //qDebug("ebook openfile:%s", src); | 111 | //qDebug("ebook openfile:%s", src); |
114 | return (status != 0) ? status : codec->openfile(src); | 112 | return (status != 0) ? status : codec->openfile(src); |
115 | } | 113 | } |
116 | int getwidth() { return codec->getwidth(); } | 114 | int getwidth() { return codec->getwidth(); } |
117 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } | 115 | QImage* getPicture(const QString& href) { return codec->getPicture(href); } |
118 | bool getFile(const QString& href) { return codec->getFile(href); } | 116 | bool getFile(const QString& href) { return codec->getFile(href); } |
119 | }; | 117 | }; |
120 | #endif | 118 | #endif |
diff --git a/noncore/apps/opie-reader/iSiloCodec/iSiloCodec.pro b/noncore/apps/opie-reader/iSiloCodec/iSiloCodec.pro index 78d5a49..5cf075e 100644 --- a/noncore/apps/opie-reader/iSiloCodec/iSiloCodec.pro +++ b/noncore/apps/opie-reader/iSiloCodec/iSiloCodec.pro | |||
@@ -1,19 +1,19 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | #HEADERS = Aportis.h | 5 | #HEADERS = Aportis.h |
6 | 6 | ||
7 | SOURCES = iSilo.cpp | 7 | SOURCES = iSilo.cpp |
8 | 8 | ||
9 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 11 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
12 | TARGET = iSilo | 12 | TARGET = iSilo |
13 | LIBS += -lreader_pdb -lreader_codec | 13 | LIBS += -lreader_pdb -lreader_codec |
14 | 14 | ||
15 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 17 | ||
18 | include ( $(OPIEDIR)/include.pro ) | 18 | include ( $(OPIEDIR)/include.pro ) |
19 | 19 | ||
diff --git a/noncore/apps/opie-reader/main.cpp b/noncore/apps/opie-reader/main.cpp index 3e1f5e7..af276da 100644 --- a/noncore/apps/opie-reader/main.cpp +++ b/noncore/apps/opie-reader/main.cpp | |||
@@ -1,50 +1,49 @@ | |||
1 | #include "useqpe.h" | ||
2 | #ifdef USEQPE | 1 | #ifdef USEQPE |
3 | #include <qpe/qpeapplication.h> | 2 | #include <qpe/qpeapplication.h> |
4 | #else | 3 | #else |
5 | #include <qapplication.h> | 4 | #include <qapplication.h> |
6 | #endif | 5 | #endif |
7 | #include "QTReaderApp.h" | 6 | #include "QTReaderApp.h" |
8 | 7 | ||
9 | #include "signal.h" | 8 | #include "signal.h" |
10 | #include "stdio.h" | 9 | #include "stdio.h" |
11 | #include "time.h" | 10 | #include "time.h" |
12 | 11 | ||
13 | 12 | ||
14 | #ifdef USEQPE | 13 | #ifdef USEQPE |
15 | QTReaderApp* app = NULL; | 14 | QTReaderApp* app = NULL; |
16 | 15 | ||
17 | void handler(int signum) | 16 | void handler(int signum) |
18 | { | 17 | { |
19 | if (app != NULL) | 18 | if (app != NULL) |
20 | { | 19 | { |
21 | app->suspend(); | 20 | app->suspend(); |
22 | app->saveprefs(); | 21 | app->saveprefs(); |
23 | } | 22 | } |
24 | signal(signum, handler); | 23 | signal(signum, handler); |
25 | } | 24 | } |
26 | #endif | 25 | #endif |
27 | 26 | ||
28 | int main( int argc, char ** argv ) | 27 | int main( int argc, char ** argv ) |
29 | { | 28 | { |
30 | 29 | ||
31 | #ifdef USEQPE | 30 | #ifdef USEQPE |
32 | signal(SIGCONT, handler); | 31 | signal(SIGCONT, handler); |
33 | QPEApplication a( argc, argv ); | 32 | QPEApplication a( argc, argv ); |
34 | QTReaderApp m; | 33 | QTReaderApp m; |
35 | a.showMainDocumentWidget( &m ); | 34 | a.showMainDocumentWidget( &m ); |
36 | app = &m; | 35 | app = &m; |
37 | #else | 36 | #else |
38 | QApplication a( argc, argv ); | 37 | QApplication a( argc, argv ); |
39 | QTReaderApp m; | 38 | QTReaderApp m; |
40 | a.setMainWidget( &m ); | 39 | a.setMainWidget( &m ); |
41 | if (argc > 1) | 40 | if (argc > 1) |
42 | { | 41 | { |
43 | m.setDocument(argv[1]); | 42 | m.setDocument(argv[1]); |
44 | } | 43 | } |
45 | #endif | 44 | #endif |
46 | 45 | ||
47 | 46 | ||
48 | return a.exec(); | 47 | return a.exec(); |
49 | } | 48 | } |
50 | 49 | ||
diff --git a/noncore/apps/opie-reader/pdb.cpp b/noncore/apps/opie-reader/pdb.cpp index 39551cc..6719af4 100644 --- a/noncore/apps/opie-reader/pdb.cpp +++ b/noncore/apps/opie-reader/pdb.cpp | |||
@@ -1,90 +1,89 @@ | |||
1 | #include "pdb.h" | 1 | #include "pdb.h" |
2 | #ifdef _WINDOWS | 2 | #ifdef _WINDOWS |
3 | #include <winsock2.h> | 3 | #include <winsock2.h> |
4 | #endif | 4 | #endif |
5 | 5 | ||
6 | #include "useqpe.h" | ||
7 | 6 | ||
8 | #ifdef USEQPE | 7 | #ifdef USEQPE |
9 | void Cpdb::suspend() | 8 | void Cpdb::suspend() |
10 | { | 9 | { |
11 | CExpander::suspend(fin); | 10 | CExpander::suspend(fin); |
12 | } | 11 | } |
13 | void Cpdb::unsuspend() | 12 | void Cpdb::unsuspend() |
14 | { | 13 | { |
15 | CExpander::unsuspend(fin); | 14 | CExpander::unsuspend(fin); |
16 | } | 15 | } |
17 | #endif | 16 | #endif |
18 | 17 | ||
19 | Cpdb::~Cpdb() | 18 | Cpdb::~Cpdb() |
20 | { | 19 | { |
21 | if (fin != NULL) | 20 | if (fin != NULL) |
22 | { | 21 | { |
23 | #ifdef USEQPE | 22 | #ifdef USEQPE |
24 | unsuspend(); | 23 | unsuspend(); |
25 | #endif | 24 | #endif |
26 | fclose(fin); | 25 | fclose(fin); |
27 | } | 26 | } |
28 | } | 27 | } |
29 | 28 | ||
30 | size_t Cpdb::recordpos(int n) | 29 | size_t Cpdb::recordpos(int n) |
31 | { | 30 | { |
32 | UInt16 mxn = ntohs(head.recordList.numRecords); | 31 | UInt16 mxn = ntohs(head.recordList.numRecords); |
33 | if (n >= mxn) | 32 | if (n >= mxn) |
34 | { | 33 | { |
35 | return file_length; | 34 | return file_length; |
36 | } | 35 | } |
37 | else | 36 | else |
38 | { | 37 | { |
39 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); | 38 | size_t dataoffset = sizeof(DatabaseHdrType) - sizeof(UInt16); |
40 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; | 39 | dataoffset += /*dataoffset%4 + */ sizeof(RecordListType) * n; |
41 | fseek(fin, dataoffset, SEEK_SET); | 40 | fseek(fin, dataoffset, SEEK_SET); |
42 | RecordListType hdr; | 41 | RecordListType hdr; |
43 | fread(&hdr, 1, sizeof(hdr), fin); | 42 | fread(&hdr, 1, sizeof(hdr), fin); |
44 | return ntohl(hdr.nextRecordListID); | 43 | return ntohl(hdr.nextRecordListID); |
45 | } | 44 | } |
46 | 45 | ||
47 | } | 46 | } |
48 | 47 | ||
49 | size_t Cpdb::recordlength(int n) | 48 | size_t Cpdb::recordlength(int n) |
50 | { | 49 | { |
51 | return recordpos(n+1)-recordpos(n); | 50 | return recordpos(n+1)-recordpos(n); |
52 | } | 51 | } |
53 | 52 | ||
54 | void Cpdb::gotorecordnumber(int n) | 53 | void Cpdb::gotorecordnumber(int n) |
55 | { | 54 | { |
56 | fseek(fin, recordpos(n), SEEK_SET); | 55 | fseek(fin, recordpos(n), SEEK_SET); |
57 | } | 56 | } |
58 | 57 | ||
59 | bool Cpdb::openpdbfile(const char *src) | 58 | bool Cpdb::openpdbfile(const char *src) |
60 | { | 59 | { |
61 | //qDebug("cpdb openfile:%s", src); | 60 | //qDebug("cpdb openfile:%s", src); |
62 | 61 | ||
63 | // printf("In openfile\n"); | 62 | // printf("In openfile\n"); |
64 | // printf("closing fin:%x\n",fin); | 63 | // printf("closing fin:%x\n",fin); |
65 | if (fin != NULL) fclose(fin); | 64 | if (fin != NULL) fclose(fin); |
66 | // printf("opening fin\n"); | 65 | // printf("opening fin\n"); |
67 | fin = fopen(src,"rb"); | 66 | fin = fopen(src,"rb"); |
68 | 67 | ||
69 | if (fin==0) | 68 | if (fin==0) |
70 | { | 69 | { |
71 | return false; | 70 | return false; |
72 | } | 71 | } |
73 | 72 | ||
74 | // just holds the first few chars of the file | 73 | // just holds the first few chars of the file |
75 | //char buf[0x100]; | 74 | //char buf[0x100]; |
76 | struct stat _stat; | 75 | struct stat _stat; |
77 | stat(src,&_stat); | 76 | stat(src,&_stat); |
78 | file_length = _stat.st_size; | 77 | file_length = _stat.st_size; |
79 | // fseek(fin,0,SEEK_END); | 78 | // fseek(fin,0,SEEK_END); |
80 | // file_length = ftell(fin); | 79 | // file_length = ftell(fin); |
81 | 80 | ||
82 | fseek(fin,0,SEEK_SET); | 81 | fseek(fin,0,SEEK_SET); |
83 | 82 | ||
84 | fread(&head, 1, sizeof(head), fin); | 83 | fread(&head, 1, sizeof(head), fin); |
85 | 84 | ||
86 | qDebug("Database name:%s", head.name); | 85 | qDebug("Database name:%s", head.name); |
87 | qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); | 86 | qDebug("Total number of records:%u", ntohs(head.recordList.numRecords)); |
88 | 87 | ||
89 | return true; | 88 | return true; |
90 | } | 89 | } |
diff --git a/noncore/apps/opie-reader/pdb.h b/noncore/apps/opie-reader/pdb.h index 7a6580d..7458919 100644 --- a/noncore/apps/opie-reader/pdb.h +++ b/noncore/apps/opie-reader/pdb.h | |||
@@ -1,101 +1,100 @@ | |||
1 | 1 | ||
2 | /* | 2 | /* |
3 | * This header file defines some structures and types normally found in the | 3 | * This header file defines some structures and types normally found in the |
4 | * Palm SDK. However, I don't want to require the presense of the SDK for a | 4 | * Palm SDK. However, I don't want to require the presense of the SDK for a |
5 | * small utility since most Palm owners won't have it. | 5 | * small utility since most Palm owners won't have it. |
6 | * | 6 | * |
7 | * $Id$ | 7 | * $Id$ |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | 10 | ||
11 | #ifndef __PDB_H__ | 11 | #ifndef __PDB_H__ |
12 | #define __PDB_H__ | 12 | #define __PDB_H__ |
13 | 13 | ||
14 | #ifndef _WINDOWS | 14 | #ifndef _WINDOWS |
15 | #include <netinet/in.h> | 15 | #include <netinet/in.h> |
16 | #endif | 16 | #endif |
17 | #include <stdio.h> | 17 | #include <stdio.h> |
18 | #include "useqpe.h" | ||
19 | #include "CExpander.h" | 18 | #include "CExpander.h" |
20 | 19 | ||
21 | /* Normal Palm typedefs */ | 20 | /* Normal Palm typedefs */ |
22 | typedef unsigned char UInt8; | 21 | typedef unsigned char UInt8; |
23 | typedef unsigned short UInt16; | 22 | typedef unsigned short UInt16; |
24 | typedef signed short Int16; | 23 | typedef signed short Int16; |
25 | typedef unsigned long UInt32; | 24 | typedef unsigned long UInt32; |
26 | typedef UInt32 LocalID; | 25 | typedef UInt32 LocalID; |
27 | 26 | ||
28 | /* Max length of DB name */ | 27 | /* Max length of DB name */ |
29 | #define dmDBNameLength 0x20 | 28 | #define dmDBNameLength 0x20 |
30 | 29 | ||
31 | 30 | ||
32 | /************************************************************ | 31 | /************************************************************ |
33 | * Structure of a Record entry | 32 | * Structure of a Record entry |
34 | *************************************************************/ | 33 | *************************************************************/ |
35 | typedef struct { | 34 | typedef struct { |
36 | LocalID localChunkID; // local chunkID of a record | 35 | LocalID localChunkID; // local chunkID of a record |
37 | UInt8 attributes; // record attributes; | 36 | UInt8 attributes; // record attributes; |
38 | UInt8 uniqueID[3]; // unique ID of record; should | 37 | UInt8 uniqueID[3]; // unique ID of record; should |
39 | // not be 0 for a legal record. | 38 | // not be 0 for a legal record. |
40 | } RecordEntryType; | 39 | } RecordEntryType; |
41 | 40 | ||
42 | 41 | ||
43 | /************************************************************ | 42 | /************************************************************ |
44 | * Structure of a record list extension. This is used if all | 43 | * Structure of a record list extension. This is used if all |
45 | * the database record/resource entries of a database can't fit into | 44 | * the database record/resource entries of a database can't fit into |
46 | * the database header. | 45 | * the database header. |
47 | *************************************************************/ | 46 | *************************************************************/ |
48 | typedef struct { | 47 | typedef struct { |
49 | LocalID nextRecordListID; // local chunkID of next list | 48 | LocalID nextRecordListID; // local chunkID of next list |
50 | UInt16 numRecords; // number of records in this list | 49 | UInt16 numRecords; // number of records in this list |
51 | UInt16 firstEntry; // array of Record/Rsrc entries | 50 | UInt16 firstEntry; // array of Record/Rsrc entries |
52 | // starts here | 51 | // starts here |
53 | } RecordListType; | 52 | } RecordListType; |
54 | 53 | ||
55 | 54 | ||
56 | /************************************************************ | 55 | /************************************************************ |
57 | * Structure of a Database Header | 56 | * Structure of a Database Header |
58 | *************************************************************/ | 57 | *************************************************************/ |
59 | typedef struct { | 58 | typedef struct { |
60 | UInt8 name[dmDBNameLength]; // name of database | 59 | UInt8 name[dmDBNameLength]; // name of database |
61 | UInt16 attributes; // database attributes | 60 | UInt16 attributes; // database attributes |
62 | UInt16 version; // version of database | 61 | UInt16 version; // version of database |
63 | UInt32 creationDate; // creation date of database | 62 | UInt32 creationDate; // creation date of database |
64 | UInt32 modificationDate; // latest modification date | 63 | UInt32 modificationDate; // latest modification date |
65 | UInt32 lastBackupDate; // latest backup date | 64 | UInt32 lastBackupDate; // latest backup date |
66 | UInt32 modificationNumber; // modification number of database | 65 | UInt32 modificationNumber; // modification number of database |
67 | LocalID appInfoID; // application specific info | 66 | LocalID appInfoID; // application specific info |
68 | LocalID sortInfoID; // app specific sorting info | 67 | LocalID sortInfoID; // app specific sorting info |
69 | UInt32 type; // database type | 68 | UInt32 type; // database type |
70 | UInt32 creator; // database creator | 69 | UInt32 creator; // database creator |
71 | UInt32 uniqueIDSeed; // used to generate unique IDs. | 70 | UInt32 uniqueIDSeed; // used to generate unique IDs. |
72 | // Note that only the low order | 71 | // Note that only the low order |
73 | // 3 bytes of this is used (in | 72 | // 3 bytes of this is used (in |
74 | // RecordEntryType.uniqueID). | 73 | // RecordEntryType.uniqueID). |
75 | // We are keeping 4 bytes for | 74 | // We are keeping 4 bytes for |
76 | // alignment purposes. | 75 | // alignment purposes. |
77 | RecordListType recordList; // first record list | 76 | RecordListType recordList; // first record list |
78 | } DatabaseHdrType; | 77 | } DatabaseHdrType; |
79 | 78 | ||
80 | 79 | ||
81 | class Cpdb : public CExpander | 80 | class Cpdb : public CExpander |
82 | { | 81 | { |
83 | protected: | 82 | protected: |
84 | size_t file_length; | 83 | size_t file_length; |
85 | FILE* fin; | 84 | FILE* fin; |
86 | size_t recordpos(int); | 85 | size_t recordpos(int); |
87 | size_t recordlength(int); | 86 | size_t recordlength(int); |
88 | void gotorecordnumber(int); | 87 | void gotorecordnumber(int); |
89 | DatabaseHdrType head; | 88 | DatabaseHdrType head; |
90 | bool openpdbfile(const char* src); | 89 | bool openpdbfile(const char* src); |
91 | Cpdb() : fin(NULL) {} | 90 | Cpdb() : fin(NULL) {} |
92 | ~Cpdb(); | 91 | ~Cpdb(); |
93 | #ifdef USEQPE | 92 | #ifdef USEQPE |
94 | void suspend(); | 93 | void suspend(); |
95 | void unsuspend(); | 94 | void unsuspend(); |
96 | #endif | 95 | #endif |
97 | public: | 96 | public: |
98 | virtual void sizes(unsigned long& _file, unsigned long& _text) = 0; | 97 | virtual void sizes(unsigned long& _file, unsigned long& _text) = 0; |
99 | }; | 98 | }; |
100 | #endif | 99 | #endif |
101 | 100 | ||
diff --git a/noncore/apps/opie-reader/pdblib/pdblib.pro b/noncore/apps/opie-reader/pdblib/pdblib.pro index cb861a8..830d988 100644 --- a/noncore/apps/opie-reader/pdblib/pdblib.pro +++ b/noncore/apps/opie-reader/pdblib/pdblib.pro | |||
@@ -1,16 +1,16 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = pdb.h | 5 | HEADERS = pdb.h |
6 | 6 | ||
7 | SOURCES = pdb.cpp | 7 | SOURCES = pdb.cpp |
8 | 8 | ||
9 | INTERFACES= | 9 | INTERFACES= |
10 | DESTDIR = $(OPIEDIR)/lib | 10 | DESTDIR = $(OPIEDIR)/lib |
11 | TARGET = reader_pdb | 11 | TARGET = reader_pdb |
12 | 12 | ||
13 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 13 | INCLUDEPATH+= $(OPIEDIR)/include |
14 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 14 | DEPENDPATH+= $(OPIEDIR)/include |
15 | 15 | ||
16 | include ( $(OPIEDIR)/include.pro ) | 16 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/plucker.cpp b/noncore/apps/opie-reader/plucker.cpp index d1ccd6f..4ea807a 100644 --- a/noncore/apps/opie-reader/plucker.cpp +++ b/noncore/apps/opie-reader/plucker.cpp | |||
@@ -1,215 +1,213 @@ | |||
1 | #include "useqpe.h" | ||
2 | #include <stdio.h> | 1 | #include <stdio.h> |
3 | #include <string.h> | 2 | #include <string.h> |
4 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
5 | #include <qpixmap.h> | 4 | #include <qpixmap.h> |
6 | #ifdef USEQPE | 5 | #ifdef USEQPE |
7 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
8 | #endif | 7 | #endif |
9 | #ifdef LOCALPICTURES | 8 | #ifdef LOCALPICTURES |
10 | #include <qscrollview.h> | 9 | #include <qscrollview.h> |
11 | #endif | 10 | #endif |
12 | #ifdef USEQPE | 11 | #ifdef USEQPE |
13 | #include <qpe/global.h> | 12 | #include <qpe/global.h> |
14 | #include <qpe/qpeapplication.h> | 13 | #include <qpe/qpeapplication.h> |
15 | #else | 14 | #else |
16 | #include <qapplication.h> | 15 | #include <qapplication.h> |
17 | #endif | 16 | #endif |
18 | #include <qclipboard.h> | 17 | #include <qclipboard.h> |
19 | 18 | ||
20 | #include "plucker.h" | 19 | #include "plucker.h" |
21 | #include "Aportis.h" | 20 | #include "Aportis.h" |
22 | #include "Palm2QImage.h" | 21 | #include "Palm2QImage.h" |
23 | #include "static.h" | ||
24 | 22 | ||
25 | 23 | ||
26 | struct CPlucker_dataRecord | 24 | struct CPlucker_dataRecord |
27 | { | 25 | { |
28 | UInt16 uid; | 26 | UInt16 uid; |
29 | UInt16 nParagraphs; | 27 | UInt16 nParagraphs; |
30 | UInt16 size; | 28 | UInt16 size; |
31 | UInt8 type; | 29 | UInt8 type; |
32 | UInt8 reserved; | 30 | UInt8 reserved; |
33 | }; | 31 | }; |
34 | 32 | ||
35 | int CPlucker::HeaderSize() | 33 | int CPlucker::HeaderSize() |
36 | { | 34 | { |
37 | return sizeof(CPlucker_dataRecord); | 35 | return sizeof(CPlucker_dataRecord); |
38 | } | 36 | } |
39 | 37 | ||
40 | void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) | 38 | void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) |
41 | { | 39 | { |
42 | CPlucker_dataRecord thishdr; | 40 | CPlucker_dataRecord thishdr; |
43 | fread(&thishdr, 1, HeaderSize(), fin); | 41 | fread(&thishdr, 1, HeaderSize(), fin); |
44 | uid = ntohs(thishdr.uid); | 42 | uid = ntohs(thishdr.uid); |
45 | nParagraphs = ntohs(thishdr.nParagraphs); | 43 | nParagraphs = ntohs(thishdr.nParagraphs); |
46 | size = ntohs(thishdr.size); | 44 | size = ntohs(thishdr.size); |
47 | type = thishdr.type; | 45 | type = thishdr.type; |
48 | reserved = thishdr.reserved; | 46 | reserved = thishdr.reserved; |
49 | } | 47 | } |
50 | 48 | ||
51 | CPlucker::CPlucker() | 49 | CPlucker::CPlucker() |
52 | { /*printf("constructing:%x\n",fin);*/ | 50 | { /*printf("constructing:%x\n",fin);*/ |
53 | EOPPhase = 0; | 51 | EOPPhase = 0; |
54 | } | 52 | } |
55 | 53 | ||
56 | bool CPlucker::CorrectDecoder() | 54 | bool CPlucker::CorrectDecoder() |
57 | { | 55 | { |
58 | return (memcmp(&head.type, "DataPlkr", 8) == 0); | 56 | return (memcmp(&head.type, "DataPlkr", 8) == 0); |
59 | } | 57 | } |
60 | 58 | ||
61 | int CPlucker::bgetch() | 59 | int CPlucker::bgetch() |
62 | { | 60 | { |
63 | int ch = EOF; | 61 | int ch = EOF; |
64 | if (bufferpos >= buffercontent) | 62 | if (bufferpos >= buffercontent) |
65 | { | 63 | { |
66 | if (isEndOfSection(bufferrec)) | 64 | if (isEndOfSection(bufferrec)) |
67 | { | 65 | { |
68 | if (!m_continuous) return EOF; | 66 | if (!m_continuous) return EOF; |
69 | } | 67 | } |
70 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) | 68 | if (bufferrec >= ntohs(head.recordList.numRecords) - 1) |
71 | { | 69 | { |
72 | return EOF; | 70 | return EOF; |
73 | } | 71 | } |
74 | if (!expand(bufferrec+1)) | 72 | if (!expand(bufferrec+1)) |
75 | { | 73 | { |
76 | return EOF; | 74 | return EOF; |
77 | } | 75 | } |
78 | mystyle.unset(); | 76 | mystyle.unset(); |
79 | if (m_ParaOffsets[m_nextParaIndex] == 0) | 77 | if (m_ParaOffsets[m_nextParaIndex] == 0) |
80 | { | 78 | { |
81 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) | 79 | while (m_ParaOffsets[m_nextParaIndex+1] == 0) |
82 | { | 80 | { |
83 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 81 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
84 | m_nextParaIndex++; | 82 | m_nextParaIndex++; |
85 | } | 83 | } |
86 | } | 84 | } |
87 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | 85 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); |
88 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 86 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
89 | ch = 10; | 87 | ch = 10; |
90 | if (m_continuous) EOPPhase = 4; | 88 | if (m_continuous) EOPPhase = 4; |
91 | } | 89 | } |
92 | else if (bufferpos == m_nextPara) | 90 | else if (bufferpos == m_nextPara) |
93 | { | 91 | { |
94 | while (bufferpos == m_nextPara) | 92 | while (bufferpos == m_nextPara) |
95 | { | 93 | { |
96 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; | 94 | UInt16 attr = m_ParaAttrs[m_nextParaIndex]; |
97 | m_nextParaIndex++; | 95 | m_nextParaIndex++; |
98 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 96 | // qDebug("Skipping extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
99 | if (m_nextParaIndex == m_nParas) | 97 | if (m_nextParaIndex == m_nParas) |
100 | { | 98 | { |
101 | m_nextPara = -1; | 99 | m_nextPara = -1; |
102 | } | 100 | } |
103 | else | 101 | else |
104 | { | 102 | { |
105 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; | 103 | m_nextPara += m_ParaOffsets[m_nextParaIndex]; |
106 | } | 104 | } |
107 | } | 105 | } |
108 | mystyle.unset(); | 106 | mystyle.unset(); |
109 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); | 107 | mystyle.setExtraSpace((m_ParaAttrs[m_nextParaIndex]&7)*2); |
110 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); | 108 | //qDebug("Using extraspace:%d", m_ParaAttrs[m_nextParaIndex]&7); |
111 | if (m_lastBreak == locate()) | 109 | if (m_lastBreak == locate()) |
112 | { | 110 | { |
113 | currentpos++; | 111 | currentpos++; |
114 | ch = expandedtextbuffer[bufferpos++]; | 112 | ch = expandedtextbuffer[bufferpos++]; |
115 | } | 113 | } |
116 | else | 114 | else |
117 | { | 115 | { |
118 | ch = 10; | 116 | ch = 10; |
119 | } | 117 | } |
120 | } | 118 | } |
121 | else | 119 | else |
122 | { | 120 | { |
123 | currentpos++; | 121 | currentpos++; |
124 | ch = expandedtextbuffer[bufferpos++]; | 122 | ch = expandedtextbuffer[bufferpos++]; |
125 | } | 123 | } |
126 | return ch; | 124 | return ch; |
127 | } | 125 | } |
128 | 126 | ||
129 | tchar CPlucker::getch(bool fast) | 127 | tchar CPlucker::getch(bool fast) |
130 | { | 128 | { |
131 | mystyle.clearPicture(); | 129 | mystyle.clearPicture(); |
132 | 130 | ||
133 | if (EOPPhase > 0) | 131 | if (EOPPhase > 0) |
134 | { | 132 | { |
135 | int ch = 10; | 133 | int ch = 10; |
136 | switch (EOPPhase) | 134 | switch (EOPPhase) |
137 | { | 135 | { |
138 | case 4: | 136 | case 4: |
139 | if (!fast) mystyle.setPicture(false, hRule(100,5)); | 137 | if (!fast) mystyle.setPicture(false, hRule(100,5)); |
140 | mystyle.setCentreJustify(); | 138 | mystyle.setCentreJustify(); |
141 | ch = '#'; | 139 | ch = '#'; |
142 | break; | 140 | break; |
143 | case 3: | 141 | case 3: |
144 | mystyle.setFontSize(3); | 142 | mystyle.setFontSize(3); |
145 | ch = 10; | 143 | ch = 10; |
146 | break; | 144 | break; |
147 | case 2: | 145 | case 2: |
148 | ch = 10; | 146 | ch = 10; |
149 | break; | 147 | break; |
150 | case 1: | 148 | case 1: |
151 | mystyle.unset(); | 149 | mystyle.unset(); |
152 | default: | 150 | default: |
153 | ch = 10; | 151 | ch = 10; |
154 | } | 152 | } |
155 | EOPPhase--; | 153 | EOPPhase--; |
156 | return ch; | 154 | return ch; |
157 | } | 155 | } |
158 | 156 | ||
159 | return getch_base(fast); | 157 | return getch_base(fast); |
160 | } | 158 | } |
161 | 159 | ||
162 | QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) | 160 | QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) |
163 | { | 161 | { |
164 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); | 162 | QImage* qimage = Palm2QImage(imgbuffer, imgsize); |
165 | delete [] imgbuffer; | 163 | delete [] imgbuffer; |
166 | return qimage; | 164 | return qimage; |
167 | } | 165 | } |
168 | 166 | ||
169 | void CPlucker::start2endSection() // to plucker base | 167 | void CPlucker::start2endSection() // to plucker base |
170 | { | 168 | { |
171 | m_currentstart = NEFstartSection(); | 169 | m_currentstart = NEFstartSection(); |
172 | m_currentend = NEFendSection(); | 170 | m_currentend = NEFendSection(); |
173 | } | 171 | } |
174 | 172 | ||
175 | unsigned long CPlucker::NEFstartSection() // virtual in plucker base - differs only in obsoleted nef so move implementation | 173 | unsigned long CPlucker::NEFstartSection() // virtual in plucker base - differs only in obsoleted nef so move implementation |
176 | { | 174 | { |
177 | //inefficient - Should calc start/end of section on entry to section? | 175 | //inefficient - Should calc start/end of section on entry to section? |
178 | UInt16 thishdr_uid, thishdr_nParagraphs; | 176 | UInt16 thishdr_uid, thishdr_nParagraphs; |
179 | UInt32 thishdr_size; | 177 | UInt32 thishdr_size; |
180 | UInt8 thishdr_type, thishdr_reserved; | 178 | UInt8 thishdr_type, thishdr_reserved; |
181 | unsigned long textlength = currentpos-bufferpos; | 179 | unsigned long textlength = currentpos-bufferpos; |
182 | for (UInt16 recptr = bufferrec-1; recptr >= 1; recptr--) | 180 | for (UInt16 recptr = bufferrec-1; recptr >= 1; recptr--) |
183 | { | 181 | { |
184 | gotorecordnumber(recptr); | 182 | gotorecordnumber(recptr); |
185 | //qDebug("recptr:%u", recptr); | 183 | //qDebug("recptr:%u", recptr); |
186 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 184 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
187 | if (thishdr_type < 2) | 185 | if (thishdr_type < 2) |
188 | { | 186 | { |
189 | if ((thishdr_reserved && continuation_bit) == 0) break; | 187 | if ((thishdr_reserved && continuation_bit) == 0) break; |
190 | textlength -= thishdr_size; | 188 | textlength -= thishdr_size; |
191 | //qDebug("Textlength:%u, reserved:%u, recptr:%u", textlength, thishdr_reserved, recptr); | 189 | //qDebug("Textlength:%u, reserved:%u, recptr:%u", textlength, thishdr_reserved, recptr); |
192 | } | 190 | } |
193 | } | 191 | } |
194 | return textlength; | 192 | return textlength; |
195 | } | 193 | } |
196 | 194 | ||
197 | unsigned long CPlucker::NEFendSection() // virtual in plucker base - differs only in obsoleted nef so move implementation | 195 | unsigned long CPlucker::NEFendSection() // virtual in plucker base - differs only in obsoleted nef so move implementation |
198 | { | 196 | { |
199 | //inefficient - Should calc start/end of section on entry to section? | 197 | //inefficient - Should calc start/end of section on entry to section? |
200 | unsigned long textlength = currentpos-bufferpos+buffercontent; | 198 | unsigned long textlength = currentpos-bufferpos+buffercontent; |
201 | gotorecordnumber(bufferrec); | 199 | gotorecordnumber(bufferrec); |
202 | UInt16 thishdr_uid, thishdr_nParagraphs; | 200 | UInt16 thishdr_uid, thishdr_nParagraphs; |
203 | UInt32 thishdr_size; | 201 | UInt32 thishdr_size; |
204 | UInt8 thishdr_type, thishdr_reserved; | 202 | UInt8 thishdr_type, thishdr_reserved; |
205 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 203 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
206 | if ((thishdr_reserved && continuation_bit) != 0) | 204 | if ((thishdr_reserved && continuation_bit) != 0) |
207 | { | 205 | { |
208 | for (UInt16 recptr = bufferrec+1; recptr < ntohs(head.recordList.numRecords); recptr++) | 206 | for (UInt16 recptr = bufferrec+1; recptr < ntohs(head.recordList.numRecords); recptr++) |
209 | { | 207 | { |
210 | gotorecordnumber(recptr); | 208 | gotorecordnumber(recptr); |
211 | UInt16 thishdr_uid, thishdr_nParagraphs; | 209 | UInt16 thishdr_uid, thishdr_nParagraphs; |
212 | UInt32 thishdr_size; | 210 | UInt32 thishdr_size; |
213 | UInt8 thishdr_type, thishdr_reserved; | 211 | UInt8 thishdr_type, thishdr_reserved; |
214 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 212 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
215 | //qDebug("recptr %u bufferrec %u type %u m_reserved %u", recptr, bufferrec, typ | 213 | //qDebug("recptr %u bufferrec %u type %u m_reserved %u", recptr, bufferrec, typ |
diff --git a/noncore/apps/opie-reader/plucker_base.cpp b/noncore/apps/opie-reader/plucker_base.cpp index 0b7fae8..d7d538f 100644 --- a/noncore/apps/opie-reader/plucker_base.cpp +++ b/noncore/apps/opie-reader/plucker_base.cpp | |||
@@ -1,216 +1,214 @@ | |||
1 | #include "useqpe.h" | ||
2 | #include "usenef.h" | 1 | #include "usenef.h" |
3 | #include <stdio.h> | 2 | #include <stdio.h> |
4 | #include <string.h> | 3 | #include <string.h> |
5 | #include <qmessagebox.h> | 4 | #include <qmessagebox.h> |
6 | #include <qpixmap.h> | 5 | #include <qpixmap.h> |
7 | #ifdef USEQPE | 6 | #ifdef USEQPE |
8 | #include <qpe/qcopenvelope_qws.h> | 7 | #include <qpe/qcopenvelope_qws.h> |
9 | #endif /* USEQPE */ | 8 | #endif /* USEQPE */ |
10 | #ifdef LOCALPICTURES | 9 | #ifdef LOCALPICTURES |
11 | #include <qscrollview.h> | 10 | #include <qscrollview.h> |
12 | #endif | 11 | #endif |
13 | #ifdef USEQPE | 12 | #ifdef USEQPE |
14 | #include <qpe/global.h> | 13 | #include <qpe/global.h> |
15 | #endif /* USEQPE */ | 14 | #endif /* USEQPE */ |
16 | #include <qclipboard.h> | 15 | #include <qclipboard.h> |
17 | #ifndef USEQPE | 16 | #ifndef USEQPE |
18 | #include <qapplication.h> | 17 | #include <qapplication.h> |
19 | #else /* USEQPE */ | 18 | #else /* USEQPE */ |
20 | #include <qpe/qpeapplication.h> | 19 | #include <qpe/qpeapplication.h> |
21 | #endif /* USEQPE */ | 20 | #endif /* USEQPE */ |
22 | #include <qimage.h> | 21 | #include <qimage.h> |
23 | 22 | ||
24 | #include "static.h" | ||
25 | #include "plucker_base.h" | 23 | #include "plucker_base.h" |
26 | #include "Aportis.h" | 24 | #include "Aportis.h" |
27 | #include "hrule.h" | 25 | #include "hrule.h" |
28 | #include "util.h" | 26 | #include "util.h" |
29 | 27 | ||
30 | const UInt8 CPlucker_base::continuation_bit = 1; | 28 | const UInt8 CPlucker_base::continuation_bit = 1; |
31 | 29 | ||
32 | CPlucker_base::CPlucker_base() : | 30 | CPlucker_base::CPlucker_base() : |
33 | #ifdef LOCALPICTURES | 31 | #ifdef LOCALPICTURES |
34 | m_viewer(NULL), | 32 | m_viewer(NULL), |
35 | m_picture(NULL), | 33 | m_picture(NULL), |
36 | #endif | 34 | #endif |
37 | expandedtextbuffer(NULL), | 35 | expandedtextbuffer(NULL), |
38 | compressedtextbuffer(NULL), | 36 | compressedtextbuffer(NULL), |
39 | bufferrec(-1), | 37 | bufferrec(-1), |
40 | m_offset(0) | 38 | m_offset(0) |
41 | //, urls(NULL) | 39 | //, urls(NULL) |
42 | { /*printf("constructing:%x\n",fin);*/ } | 40 | { /*printf("constructing:%x\n",fin);*/ } |
43 | 41 | ||
44 | 42 | ||
45 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) | 43 | void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) |
46 | { | 44 | { |
47 | if (type%2 == 0) | 45 | if (type%2 == 0) |
48 | { | 46 | { |
49 | fread(buffer, reclen, sizeof(char), fin); | 47 | fread(buffer, reclen, sizeof(char), fin); |
50 | } | 48 | } |
51 | else | 49 | else |
52 | { | 50 | { |
53 | UInt8* readbuffer = NULL; | 51 | UInt8* readbuffer = NULL; |
54 | if (reclen > compressedbuffersize) | 52 | if (reclen > compressedbuffersize) |
55 | { | 53 | { |
56 | readbuffer = new UInt8[reclen]; | 54 | readbuffer = new UInt8[reclen]; |
57 | } | 55 | } |
58 | else | 56 | else |
59 | { | 57 | { |
60 | readbuffer = compressedtextbuffer; | 58 | readbuffer = compressedtextbuffer; |
61 | } | 59 | } |
62 | if (readbuffer != NULL) | 60 | if (readbuffer != NULL) |
63 | { | 61 | { |
64 | fread(readbuffer, reclen, sizeof(char), fin); | 62 | fread(readbuffer, reclen, sizeof(char), fin); |
65 | (*m_decompress)(readbuffer, reclen, buffer, buffersize); | 63 | (*m_decompress)(readbuffer, reclen, buffer, buffersize); |
66 | if (reclen > compressedbuffersize) | 64 | if (reclen > compressedbuffersize) |
67 | { | 65 | { |
68 | delete [] readbuffer; | 66 | delete [] readbuffer; |
69 | } | 67 | } |
70 | } | 68 | } |
71 | } | 69 | } |
72 | } | 70 | } |
73 | 71 | ||
74 | void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) | 72 | void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) |
75 | { | 73 | { |
76 | _file = file_length; | 74 | _file = file_length; |
77 | if (textlength == 0) | 75 | if (textlength == 0) |
78 | { | 76 | { |
79 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) | 77 | for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) |
80 | { | 78 | { |
81 | gotorecordnumber(recptr); | 79 | gotorecordnumber(recptr); |
82 | UInt16 thishdr_uid, thishdr_nParagraphs; | 80 | UInt16 thishdr_uid, thishdr_nParagraphs; |
83 | UInt32 thishdr_size; | 81 | UInt32 thishdr_size; |
84 | UInt8 thishdr_type, thishdr_reserved; | 82 | UInt8 thishdr_type, thishdr_reserved; |
85 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 83 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
86 | if (thishdr_type < 2) textlength += thishdr_size; | 84 | if (thishdr_type < 2) textlength += thishdr_size; |
87 | } | 85 | } |
88 | } | 86 | } |
89 | _text = textlength; | 87 | _text = textlength; |
90 | //ntohl(hdr0.size); | 88 | //ntohl(hdr0.size); |
91 | } | 89 | } |
92 | 90 | ||
93 | char* CPlucker_base::geturl(UInt16 tgt) | 91 | char* CPlucker_base::geturl(UInt16 tgt) |
94 | { | 92 | { |
95 | char * pRet = NULL; | 93 | char * pRet = NULL; |
96 | gotorecordnumber(0); | 94 | gotorecordnumber(0); |
97 | fread(&hdr0, 1, 6, fin); | 95 | fread(&hdr0, 1, 6, fin); |
98 | unsigned int nrecs = ntohs(hdr0.nRecords); | 96 | unsigned int nrecs = ntohs(hdr0.nRecords); |
99 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); | 97 | //qDebug("Version %u, no. recs %u", ntohs(hdr0.version), nrecs); |
100 | UInt16 urlid = 0; | 98 | UInt16 urlid = 0; |
101 | bool urlsfound = false; | 99 | bool urlsfound = false; |
102 | char* urls = NULL; | 100 | char* urls = NULL; |
103 | size_t urlsize = 0; | 101 | size_t urlsize = 0; |
104 | for (unsigned int i = 0; i < nrecs; i++) | 102 | for (unsigned int i = 0; i < nrecs; i++) |
105 | { | 103 | { |
106 | UInt16 id, name; | 104 | UInt16 id, name; |
107 | fread(&name, 1, sizeof(name), fin); | 105 | fread(&name, 1, sizeof(name), fin); |
108 | fread(&id, 1, sizeof(id), fin); | 106 | fread(&id, 1, sizeof(id), fin); |
109 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); | 107 | //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); |
110 | if (ntohs(name) == 2) | 108 | if (ntohs(name) == 2) |
111 | { | 109 | { |
112 | urlsfound = true; | 110 | urlsfound = true; |
113 | urlid = id; | 111 | urlid = id; |
114 | //qDebug("Found url index:%d", ntohs(urlid)); | 112 | //qDebug("Found url index:%d", ntohs(urlid)); |
115 | } | 113 | } |
116 | ////qDebug("%x", id); | 114 | ////qDebug("%x", id); |
117 | } | 115 | } |
118 | if (urlsfound) | 116 | if (urlsfound) |
119 | { | 117 | { |
120 | unsigned short recptr = finduid(ntohs(urlid)); | 118 | unsigned short recptr = finduid(ntohs(urlid)); |
121 | if (recptr != 0) | 119 | if (recptr != 0) |
122 | { | 120 | { |
123 | gotorecordnumber(recptr); | 121 | gotorecordnumber(recptr); |
124 | UInt16 thishdr_uid, thishdr_nParagraphs; | 122 | UInt16 thishdr_uid, thishdr_nParagraphs; |
125 | UInt32 thishdr_size; | 123 | UInt32 thishdr_size; |
126 | UInt8 thishdr_type, thishdr_reserved; | 124 | UInt8 thishdr_type, thishdr_reserved; |
127 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 125 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
128 | UInt16 urlctr = 0; | 126 | UInt16 urlctr = 0; |
129 | while (1) | 127 | while (1) |
130 | { | 128 | { |
131 | UInt16 tctr; | 129 | UInt16 tctr; |
132 | fread(&tctr, 1, sizeof(tctr), fin); | 130 | fread(&tctr, 1, sizeof(tctr), fin); |
133 | fread(&urlid, 1, sizeof(urlid), fin); | 131 | fread(&urlid, 1, sizeof(urlid), fin); |
134 | tctr = ntohs(tctr); | 132 | tctr = ntohs(tctr); |
135 | //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); | 133 | //qDebug("tgt:%u urlctr:%u tctr:%u", tgt, urlctr, tctr); |
136 | if (tctr >= tgt) | 134 | if (tctr >= tgt) |
137 | { | 135 | { |
138 | break; | 136 | break; |
139 | } | 137 | } |
140 | urlctr = tctr; | 138 | urlctr = tctr; |
141 | } | 139 | } |
142 | //qDebug("urls are in %d", ntohs(urlid)); | 140 | //qDebug("urls are in %d", ntohs(urlid)); |
143 | recptr = finduid(ntohs(urlid)); | 141 | recptr = finduid(ntohs(urlid)); |
144 | if (recptr != 0) | 142 | if (recptr != 0) |
145 | { | 143 | { |
146 | UInt32 reclen = recordlength(recptr) - HeaderSize(); | 144 | UInt32 reclen = recordlength(recptr) - HeaderSize(); |
147 | gotorecordnumber(recptr); | 145 | gotorecordnumber(recptr); |
148 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 146 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
149 | //qDebug("Found urls:%x",thishdr_type); | 147 | //qDebug("Found urls:%x",thishdr_type); |
150 | urlsize = thishdr_size; | 148 | urlsize = thishdr_size; |
151 | urls = new char[urlsize]; | 149 | urls = new char[urlsize]; |
152 | Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); | 150 | Expand(reclen, thishdr_type, (UInt8*)urls, urlsize); |
153 | char* ptr = urls; | 151 | char* ptr = urls; |
154 | int rn = urlctr+1; | 152 | int rn = urlctr+1; |
155 | while (ptr - urls < urlsize) | 153 | while (ptr - urls < urlsize) |
156 | { | 154 | { |
157 | if (rn == tgt) | 155 | if (rn == tgt) |
158 | { | 156 | { |
159 | //qDebug("URL:%s", ptr); | 157 | //qDebug("URL:%s", ptr); |
160 | int len = strlen(ptr)+1; | 158 | int len = strlen(ptr)+1; |
161 | pRet = new char[len]; | 159 | pRet = new char[len]; |
162 | memcpy(pRet, ptr, len); | 160 | memcpy(pRet, ptr, len); |
163 | break; | 161 | break; |
164 | } | 162 | } |
165 | ptr += strlen(ptr)+1; | 163 | ptr += strlen(ptr)+1; |
166 | rn++; | 164 | rn++; |
167 | } | 165 | } |
168 | delete [] urls; | 166 | delete [] urls; |
169 | } | 167 | } |
170 | } | 168 | } |
171 | } | 169 | } |
172 | else | 170 | else |
173 | { | 171 | { |
174 | pRet = NULL; | 172 | pRet = NULL; |
175 | } | 173 | } |
176 | return pRet; | 174 | return pRet; |
177 | } | 175 | } |
178 | 176 | ||
179 | CPlucker_base::~CPlucker_base() | 177 | CPlucker_base::~CPlucker_base() |
180 | { | 178 | { |
181 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; | 179 | if (expandedtextbuffer != NULL) delete [] expandedtextbuffer; |
182 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; | 180 | if (compressedtextbuffer != NULL) delete [] compressedtextbuffer; |
183 | #ifdef LOCALPICTURES | 181 | #ifdef LOCALPICTURES |
184 | if (m_viewer != NULL) delete m_viewer; | 182 | if (m_viewer != NULL) delete m_viewer; |
185 | #endif | 183 | #endif |
186 | } | 184 | } |
187 | 185 | ||
188 | int CPlucker_base::getch() { return getch(false); } | 186 | int CPlucker_base::getch() { return getch(false); } |
189 | 187 | ||
190 | void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos) | 188 | void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos) |
191 | { | 189 | { |
192 | pos = locate(); | 190 | pos = locate(); |
193 | ch = getch(false); | 191 | ch = getch(false); |
194 | sty = mystyle; | 192 | sty = mystyle; |
195 | } | 193 | } |
196 | 194 | ||
197 | unsigned int CPlucker_base::locate() | 195 | unsigned int CPlucker_base::locate() |
198 | { | 196 | { |
199 | return currentpos; | 197 | return currentpos; |
200 | /* | 198 | /* |
201 | UInt16 thisrec = 1; | 199 | UInt16 thisrec = 1; |
202 | unsigned long locpos = 0; | 200 | unsigned long locpos = 0; |
203 | gotorecordnumber(thisrec); | 201 | gotorecordnumber(thisrec); |
204 | UInt16 thishdr_uid, thishdr_nParagraphs; | 202 | UInt16 thishdr_uid, thishdr_nParagraphs; |
205 | UInt32 thishdr_size; | 203 | UInt32 thishdr_size; |
206 | UInt8 thishdr_type, thishdr_reserved; | 204 | UInt8 thishdr_type, thishdr_reserved; |
207 | while (thisrec < bufferrec) | 205 | while (thisrec < bufferrec) |
208 | { | 206 | { |
209 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); | 207 | GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); |
210 | if (thishdr_type < 2) locpos += thishdr_size; | 208 | if (thishdr_type < 2) locpos += thishdr_size; |
211 | thisrec++; | 209 | thisrec++; |
212 | gotorecordnumber(thisrec); | 210 | gotorecordnumber(thisrec); |
213 | } | 211 | } |
214 | return locpos+bufferpos; | 212 | return locpos+bufferpos; |
215 | */ | 213 | */ |
216 | } | 214 | } |
@@ -1170,242 +1168,241 @@ tchar CPlucker_base::getch_base(bool fast) | |||
1170 | mystyle.setFontSize(1); | 1168 | mystyle.setFontSize(1); |
1171 | mystyle.setBold(); | 1169 | mystyle.setBold(); |
1172 | break; | 1170 | break; |
1173 | case 4: | 1171 | case 4: |
1174 | mystyle.setFontSize(0); | 1172 | mystyle.setFontSize(0); |
1175 | mystyle.setBold(); | 1173 | mystyle.setBold(); |
1176 | break; | 1174 | break; |
1177 | case 5: | 1175 | case 5: |
1178 | mystyle.setFontSize(0); | 1176 | mystyle.setFontSize(0); |
1179 | mystyle.setBold(); | 1177 | mystyle.setBold(); |
1180 | break; | 1178 | break; |
1181 | case 6: | 1179 | case 6: |
1182 | mystyle.setFontSize(0); | 1180 | mystyle.setFontSize(0); |
1183 | mystyle.setBold(); | 1181 | mystyle.setBold(); |
1184 | break; | 1182 | break; |
1185 | case 7: | 1183 | case 7: |
1186 | mystyle.setFontSize(0); | 1184 | mystyle.setFontSize(0); |
1187 | mystyle.setBold(); | 1185 | mystyle.setBold(); |
1188 | break; | 1186 | break; |
1189 | case 8: // should be fixed width | 1187 | case 8: // should be fixed width |
1190 | //qDebug("Trying fixed width"); | 1188 | //qDebug("Trying fixed width"); |
1191 | mystyle.setFontSize(0); | 1189 | mystyle.setFontSize(0); |
1192 | mystyle.setMono(); | 1190 | mystyle.setMono(); |
1193 | break; | 1191 | break; |
1194 | case 9: | 1192 | case 9: |
1195 | // mystyle.setFontSize(mystyle.getFontSize()); | 1193 | // mystyle.setFontSize(mystyle.getFontSize()); |
1196 | mystyle.setFontSize(-1); | 1194 | mystyle.setFontSize(-1); |
1197 | break; | 1195 | break; |
1198 | case 10: | 1196 | case 10: |
1199 | mystyle.setFontSize(-2); | 1197 | mystyle.setFontSize(-2); |
1200 | mystyle.setVOffset(1); | 1198 | mystyle.setVOffset(1); |
1201 | break; | 1199 | break; |
1202 | case 11: | 1200 | case 11: |
1203 | mystyle.setFontSize(-2); | 1201 | mystyle.setFontSize(-2); |
1204 | mystyle.setVOffset(-1); | 1202 | mystyle.setVOffset(-1); |
1205 | break; | 1203 | break; |
1206 | default: | 1204 | default: |
1207 | qDebug("Unrecognised font"); | 1205 | qDebug("Unrecognised font"); |
1208 | break; | 1206 | break; |
1209 | } | 1207 | } |
1210 | ch = bgetch(); | 1208 | ch = bgetch(); |
1211 | } | 1209 | } |
1212 | break; | 1210 | break; |
1213 | case 0x29: | 1211 | case 0x29: |
1214 | ch = bgetch(); | 1212 | ch = bgetch(); |
1215 | switch (ch) | 1213 | switch (ch) |
1216 | { | 1214 | { |
1217 | case 0: | 1215 | case 0: |
1218 | mystyle.setLeftJustify(); | 1216 | mystyle.setLeftJustify(); |
1219 | // //qDebug("left"); | 1217 | // //qDebug("left"); |
1220 | break; | 1218 | break; |
1221 | case 1: | 1219 | case 1: |
1222 | mystyle.setRightJustify(); | 1220 | mystyle.setRightJustify(); |
1223 | // //qDebug("right"); | 1221 | // //qDebug("right"); |
1224 | break; | 1222 | break; |
1225 | case 2: | 1223 | case 2: |
1226 | mystyle.setCentreJustify(); | 1224 | mystyle.setCentreJustify(); |
1227 | // //qDebug("centre"); | 1225 | // //qDebug("centre"); |
1228 | break; | 1226 | break; |
1229 | case 3: | 1227 | case 3: |
1230 | mystyle.setFullJustify(); | 1228 | mystyle.setFullJustify(); |
1231 | // //qDebug("full"); | 1229 | // //qDebug("full"); |
1232 | break; | 1230 | break; |
1233 | 1231 | ||
1234 | } | 1232 | } |
1235 | ch = bgetch(); | 1233 | ch = bgetch(); |
1236 | break; | 1234 | break; |
1237 | case 0x53: | 1235 | case 0x53: |
1238 | { | 1236 | { |
1239 | int r = bgetch(); | 1237 | int r = bgetch(); |
1240 | int g = bgetch(); | 1238 | int g = bgetch(); |
1241 | int b = bgetch(); | 1239 | int b = bgetch(); |
1242 | mystyle.setColour(r,g,b); | 1240 | mystyle.setColour(r,g,b); |
1243 | ch = bgetch(); | 1241 | ch = bgetch(); |
1244 | } | 1242 | } |
1245 | break; | 1243 | break; |
1246 | case 0x1a: | 1244 | case 0x1a: |
1247 | case 0x5c: | 1245 | case 0x5c: |
1248 | { | 1246 | { |
1249 | bool hasalternate = (ch == 0x5c); | 1247 | bool hasalternate = (ch == 0x5c); |
1250 | UInt16 ir = bgetch(); | 1248 | UInt16 ir = bgetch(); |
1251 | ir = (ir << 8) + bgetch(); | 1249 | ir = (ir << 8) + bgetch(); |
1252 | if (hasalternate) | 1250 | if (hasalternate) |
1253 | { | 1251 | { |
1254 | //qDebug("Alternate image:%x", ir); | 1252 | //qDebug("Alternate image:%x", ir); |
1255 | UInt16 ir2 = bgetch(); | 1253 | UInt16 ir2 = bgetch(); |
1256 | ir2 = (ir2 << 8) + bgetch(); | 1254 | ir2 = (ir2 << 8) + bgetch(); |
1257 | if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); | 1255 | if (!fast) mystyle.setPicture(true, expandimg(ir2, true), true, ir << 16); |
1258 | #ifdef LOCALPICTURES | 1256 | #ifdef LOCALPICTURES |
1259 | UInt32 ln = ir; | 1257 | UInt32 ln = ir; |
1260 | ln <<= 16; | 1258 | ln <<= 16; |
1261 | mystyle.setLink(true); | 1259 | mystyle.setLink(true); |
1262 | mystyle.setData(ln); | 1260 | mystyle.setData(ln); |
1263 | #endif | 1261 | #endif |
1264 | } | 1262 | } |
1265 | else | 1263 | else |
1266 | { | 1264 | { |
1267 | if (!fast) mystyle.setPicture(true, expandimg(ir)); | 1265 | if (!fast) mystyle.setPicture(true, expandimg(ir)); |
1268 | } | 1266 | } |
1269 | // if (mystyle.getLink()) qDebug("Picture link!"); | 1267 | // if (mystyle.getLink()) qDebug("Picture link!"); |
1270 | ch = '#'; | 1268 | ch = '#'; |
1271 | } | 1269 | } |
1272 | // ch = bgetch(); | 1270 | // ch = bgetch(); |
1273 | break; | 1271 | break; |
1274 | case 0x33: | 1272 | case 0x33: |
1275 | { | 1273 | { |
1276 | UInt8 h = bgetch(); | 1274 | UInt8 h = bgetch(); |
1277 | UInt8 wc = bgetch(); | 1275 | UInt8 wc = bgetch(); |
1278 | UInt8 pc = bgetch(); | 1276 | UInt8 pc = bgetch(); |
1279 | UInt16 w = wc; | 1277 | UInt16 w = wc; |
1280 | // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); | 1278 | // //qDebug("h,w,pc [%u, %u, %u]", h, w, pc); |
1281 | if (w == 0) | 1279 | if (w == 0) |
1282 | { | 1280 | { |
1283 | w = (m_scrWidth*(unsigned long)pc)/100; | 1281 | w = (m_scrWidth*(unsigned long)pc)/100; |
1284 | } | 1282 | } |
1285 | if (w == 0) w = m_scrWidth; | 1283 | if (w == 0) w = m_scrWidth; |
1286 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); | 1284 | mystyle.setPicture(false, hRule(w,h,mystyle.Red(),mystyle.Green(),mystyle.Blue())); |
1287 | // if (mystyle.getLink()) //qDebug("hRule link!"); | 1285 | // if (mystyle.getLink()) //qDebug("hRule link!"); |
1288 | ch = '#'; | 1286 | ch = '#'; |
1289 | } | 1287 | } |
1290 | break; | 1288 | break; |
1291 | case 0x60: | 1289 | case 0x60: |
1292 | mystyle.setUnderline(); | 1290 | mystyle.setUnderline(); |
1293 | ch = bgetch(); | 1291 | ch = bgetch(); |
1294 | break; | 1292 | break; |
1295 | case 0x68: | 1293 | case 0x68: |
1296 | mystyle.unsetUnderline(); | 1294 | mystyle.unsetUnderline(); |
1297 | ch = bgetch(); | 1295 | ch = bgetch(); |
1298 | break; | 1296 | break; |
1299 | case 0x22: | 1297 | case 0x22: |
1300 | ch = bgetch(); | 1298 | ch = bgetch(); |
1301 | mystyle.setLeftMargin(ch); | 1299 | mystyle.setLeftMargin(ch); |
1302 | // //qDebug("Left margin:%d", ch); | 1300 | // //qDebug("Left margin:%d", ch); |
1303 | ch = bgetch(); | 1301 | ch = bgetch(); |
1304 | mystyle.setRightMargin(ch); | 1302 | mystyle.setRightMargin(ch); |
1305 | // //qDebug("Right margin:%d", ch); | 1303 | // //qDebug("Right margin:%d", ch); |
1306 | ch = bgetch(); | 1304 | ch = bgetch(); |
1307 | break; | 1305 | break; |
1308 | case 0x70: | 1306 | case 0x70: |
1309 | mystyle.setStrikethru(); | 1307 | mystyle.setStrikethru(); |
1310 | ch = bgetch(); | 1308 | ch = bgetch(); |
1311 | break; | 1309 | break; |
1312 | case 0x78: | 1310 | case 0x78: |
1313 | mystyle.unsetStrikethru(); | 1311 | mystyle.unsetStrikethru(); |
1314 | ch = bgetch(); | 1312 | ch = bgetch(); |
1315 | break; | 1313 | break; |
1316 | case 0x83: | 1314 | case 0x83: |
1317 | { | 1315 | { |
1318 | int tlen = bgetch(); | 1316 | int tlen = bgetch(); |
1319 | ch = bgetch(); | 1317 | ch = bgetch(); |
1320 | ch <<= 8; | 1318 | ch <<= 8; |
1321 | ch |= (tchar)bgetch(); | 1319 | ch |= (tchar)bgetch(); |
1322 | for (int i = 0; i < tlen; i++) bgetch(); | 1320 | for (int i = 0; i < tlen; i++) bgetch(); |
1323 | //qDebug("Function 83"); | 1321 | //qDebug("Function 83"); |
1324 | } | 1322 | } |
1325 | break; | 1323 | break; |
1326 | case 0x9a: | 1324 | case 0x9a: |
1327 | { | 1325 | { |
1328 | m_offset = 255*bgetch(); | 1326 | m_offset = 255*bgetch(); |
1329 | m_offset += bgetch(); | 1327 | m_offset += bgetch(); |
1330 | qDebug("Found offset:%u", m_offset); | 1328 | qDebug("Found offset:%u", m_offset); |
1331 | ch = bgetch(); | 1329 | ch = bgetch(); |
1332 | } | 1330 | } |
1333 | break; | 1331 | break; |
1334 | case 0x85: | 1332 | case 0x85: |
1335 | default: | 1333 | default: |
1336 | qDebug("Function:%x NOT IMPLEMENTED", ch); | 1334 | qDebug("Function:%x NOT IMPLEMENTED", ch); |
1337 | { | 1335 | { |
1338 | int skip = ch & 7; | 1336 | int skip = ch & 7; |
1339 | for (int i = 0; i < skip; i++) | 1337 | for (int i = 0; i < skip; i++) |
1340 | { | 1338 | { |
1341 | ch = bgetch(); | 1339 | ch = bgetch(); |
1342 | //qDebug("Arg %d, %d", i, ch); | 1340 | //qDebug("Arg %d, %d", i, ch); |
1343 | } | 1341 | } |
1344 | ch = bgetch(); | 1342 | ch = bgetch(); |
1345 | } | 1343 | } |
1346 | } | 1344 | } |
1347 | } | 1345 | } |
1348 | 1346 | ||
1349 | if (m_lastIsBreak && !mystyle.isMono()) | 1347 | if (m_lastIsBreak && !mystyle.isMono()) |
1350 | { | 1348 | { |
1351 | while (ch == ' ') | 1349 | while (ch == ' ') |
1352 | { | 1350 | { |
1353 | ch = getch(false); | 1351 | ch = getch(false); |
1354 | } | 1352 | } |
1355 | } | 1353 | } |
1356 | 1354 | ||
1357 | m_lastIsBreak = (ch == 10); | 1355 | m_lastIsBreak = (ch == 10); |
1358 | 1356 | ||
1359 | return (ch == EOF) ? UEOF : ch; | 1357 | return (ch == EOF) ? UEOF : ch; |
1360 | } | 1358 | } |
1361 | 1359 | ||
1362 | #include "static.h" | ||
1363 | #if defined(__STATIC) && defined(USENEF) | 1360 | #if defined(__STATIC) && defined(USENEF) |
1364 | #include "Model.h" | 1361 | #include "Model.h" |
1365 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | 1362 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) |
1366 | { | 1363 | { |
1367 | if (_s == "PluckerDecompress3") | 1364 | if (_s == "PluckerDecompress3") |
1368 | { | 1365 | { |
1369 | return PluckerDecompress3; | 1366 | return PluckerDecompress3; |
1370 | } | 1367 | } |
1371 | if (_s == "PluckerDecompress4") | 1368 | if (_s == "PluckerDecompress4") |
1372 | { | 1369 | { |
1373 | return PluckerDecompress4; | 1370 | return PluckerDecompress4; |
1374 | } | 1371 | } |
1375 | return NULL; | 1372 | return NULL; |
1376 | } | 1373 | } |
1377 | #else | 1374 | #else |
1378 | 1375 | ||
1379 | #include "qfileinfo.h" | 1376 | #include "qfileinfo.h" |
1380 | 1377 | ||
1381 | #include <dlfcn.h> | 1378 | #include <dlfcn.h> |
1382 | 1379 | ||
1383 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) | 1380 | void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) |
1384 | { | 1381 | { |
1385 | QString codecpath(QTReaderUtil::getPluginPath("support")); | 1382 | QString codecpath(QTReaderUtil::getPluginPath("support")); |
1386 | codecpath += "/libpluckerdecompress.so"; | 1383 | codecpath += "/libpluckerdecompress.so"; |
1387 | qDebug("Codec:%s", (const char*)codecpath); | 1384 | qDebug("Codec:%s", (const char*)codecpath); |
1388 | if (QFile::exists(codecpath)) | 1385 | if (QFile::exists(codecpath)) |
1389 | { | 1386 | { |
1390 | qDebug("Codec:%s", (const char*)codecpath); | 1387 | qDebug("Codec:%s", (const char*)codecpath); |
1391 | void* handle = dlopen(codecpath, RTLD_LAZY); | 1388 | void* handle = dlopen(codecpath, RTLD_LAZY); |
1392 | if (handle == 0) | 1389 | if (handle == 0) |
1393 | { | 1390 | { |
1394 | qDebug("Can't find codec:%s", dlerror()); | 1391 | qDebug("Can't find codec:%s", dlerror()); |
1395 | return NULL; | 1392 | return NULL; |
1396 | } | 1393 | } |
1397 | return (void (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); | 1394 | return (void (*)(UInt8*, size_t, UInt8*, size_t))dlsym(handle, _s); |
1398 | } | 1395 | } |
1399 | return NULL; | 1396 | return NULL; |
1400 | } | 1397 | } |
1401 | #endif | 1398 | #endif |
1402 | 1399 | ||
1403 | QString CPlucker_base::about() | 1400 | QString CPlucker_base::about() |
1404 | { | 1401 | { |
1405 | QString abt = "Plucker base codec (c) Tim Wentford"; | 1402 | QString abt = "Plucker base codec (c) Tim Wentford"; |
1406 | if (m_decompress != UnDoc && m_decompress != UnZip) | 1403 | if (m_decompress != UnDoc && m_decompress != UnZip) |
1407 | { | 1404 | { |
1408 | abt += "\nSpecial decompression (c) Tim Wentford"; | 1405 | abt += "\nSpecial decompression (c) Tim Wentford"; |
1409 | } | 1406 | } |
1410 | return abt; | 1407 | return abt; |
1411 | } | 1408 | } |
diff --git a/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro b/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro index bee1a2d..7c2f31e 100644 --- a/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro +++ b/noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro | |||
@@ -1,18 +1,18 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = pdb.h \ | 5 | HEADERS = pdb.h \ |
6 | util.h | 6 | util.h |
7 | 7 | ||
8 | SOURCES = plucker_base.cpp | 8 | SOURCES = plucker_base.cpp |
9 | 9 | ||
10 | INTERFACES= | 10 | INTERFACES= |
11 | DESTDIR = $(OPIEDIR)/lib | 11 | DESTDIR = $(OPIEDIR)/lib |
12 | TARGET = reader_pluckerbase | 12 | TARGET = reader_pluckerbase |
13 | LIBS += -ldl | 13 | LIBS += -ldl |
14 | 14 | ||
15 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 15 | INCLUDEPATH+= $(OPIEDIR)/include |
16 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | DEPENDPATH+= $(OPIEDIR)/include |
17 | 17 | ||
18 | include ( $(OPIEDIR)/include.pro ) | 18 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/ppm_expander.cpp b/noncore/apps/opie-reader/ppm_expander.cpp index ea5b955..2a4318b 100644 --- a/noncore/apps/opie-reader/ppm_expander.cpp +++ b/noncore/apps/opie-reader/ppm_expander.cpp | |||
@@ -1,116 +1,115 @@ | |||
1 | /* | 1 | /* |
2 | * Interface pour le programme de compression | 2 | * Interface pour le programme de compression |
3 | * (c) 1995 Fabrice Bellard | 3 | * (c) 1995 Fabrice Bellard |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <stdlib.h> | 6 | #include <stdlib.h> |
7 | //#include <unistd.h> | 7 | //#include <unistd.h> |
8 | #include <stdio.h> | 8 | #include <stdio.h> |
9 | #include <string.h> | 9 | #include <string.h> |
10 | #include <time.h> | 10 | #include <time.h> |
11 | #include "static.h" | ||
12 | 11 | ||
13 | /*************************************************************************** | 12 | /*************************************************************************** |
14 | * Interface avec les routines de compression | 13 | * Interface avec les routines de compression |
15 | */ | 14 | */ |
16 | 15 | ||
17 | #define METHOD_NB 2 /* nombre total de méthodes de compression */ | 16 | #define METHOD_NB 2 /* nombre total de méthodes de compression */ |
18 | 17 | ||
19 | #define METHOD_STORE 0 | 18 | #define METHOD_STORE 0 |
20 | #define METHOD_PPM 1 | 19 | #define METHOD_PPM 1 |
21 | 20 | ||
22 | 21 | ||
23 | #define DEFAULT_SUFFIX ".st" /* extension par défault */ | 22 | #define DEFAULT_SUFFIX ".st" /* extension par défault */ |
24 | /* signature en début de fichier */ | 23 | /* signature en début de fichier */ |
25 | #define STAT_MAGIC_SIZE 4 | 24 | #define STAT_MAGIC_SIZE 4 |
26 | char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; | 25 | char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; |
27 | 26 | ||
28 | #include "ppm_expander.h" | 27 | #include "ppm_expander.h" |
29 | 28 | ||
30 | ppm_expander::~ppm_expander() { | 29 | ppm_expander::~ppm_expander() { |
31 | if (needppmend) ppm.PPM_End(); | 30 | if (needppmend) ppm.PPM_End(); |
32 | ppm.arith.Arith_DecodeEnd(); | 31 | ppm.arith.Arith_DecodeEnd(); |
33 | if (buf_in!=NULL) delete [] buf_in; | 32 | if (buf_in!=NULL) delete [] buf_in; |
34 | if (buf_out!=NULL) delete [] buf_out; | 33 | if (buf_out!=NULL) delete [] buf_out; |
35 | if (my_read_buf != NULL) delete my_read_buf; | 34 | if (my_read_buf != NULL) delete my_read_buf; |
36 | if (my_file_in != NULL) fclose(my_file_in); | 35 | if (my_file_in != NULL) fclose(my_file_in); |
37 | } | 36 | } |
38 | 37 | ||
39 | int ppm_expander::OpenFile(const char* infile) | 38 | int ppm_expander::OpenFile(const char* infile) |
40 | { | 39 | { |
41 | my_file_in=fopen(infile,"rb"); | 40 | my_file_in=fopen(infile,"rb"); |
42 | my_read_buf = new PPM_ReadBuf(my_file_in); | 41 | my_read_buf = new PPM_ReadBuf(my_file_in); |
43 | return home(); | 42 | return home(); |
44 | } | 43 | } |
45 | 44 | ||
46 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) | 45 | void ppm_expander::sizes(unsigned long& file, unsigned long& text) |
47 | { | 46 | { |
48 | struct stat _stat; | 47 | struct stat _stat; |
49 | fstat(fileno(my_file_in),&_stat); | 48 | fstat(fileno(my_file_in),&_stat); |
50 | file = _stat.st_size; | 49 | file = _stat.st_size; |
51 | text = numblocks*blocksize; | 50 | text = numblocks*blocksize; |
52 | } | 51 | } |
53 | 52 | ||
54 | int ppm_expander::home() | 53 | int ppm_expander::home() |
55 | { | 54 | { |
56 | fseek(my_file_in,0, SEEK_SET); | 55 | fseek(my_file_in,0, SEEK_SET); |
57 | unsigned char header[STAT_MAGIC_SIZE]; | 56 | unsigned char header[STAT_MAGIC_SIZE]; |
58 | size_t len=fread(header,1,STAT_MAGIC_SIZE,my_file_in); | 57 | size_t len=fread(header,1,STAT_MAGIC_SIZE,my_file_in); |
59 | if (strncmp((char*)header,stat_magic,STAT_MAGIC_SIZE)!=0) { | 58 | if (strncmp((char*)header,stat_magic,STAT_MAGIC_SIZE)!=0) { |
60 | return 1; | 59 | return 1; |
61 | } | 60 | } |
62 | if (len!=(STAT_MAGIC_SIZE)) { | 61 | if (len!=(STAT_MAGIC_SIZE)) { |
63 | return 1; | 62 | return 1; |
64 | } | 63 | } |
65 | if (fread(&maxnode,sizeof(maxnode),1,my_file_in) != 1) return 1; | 64 | if (fread(&maxnode,sizeof(maxnode),1,my_file_in) != 1) return 1; |
66 | if (fread(&blocksize,sizeof(blocksize),1,my_file_in) != 1) return 1; | 65 | if (fread(&blocksize,sizeof(blocksize),1,my_file_in) != 1) return 1; |
67 | if (fread(&numblocks,sizeof(numblocks),1,my_file_in) != 1) return 1; | 66 | if (fread(&numblocks,sizeof(numblocks),1,my_file_in) != 1) return 1; |
68 | //fprintf(stderr,"<%u,%u,%u>\n",maxnode,blocksize,numblocks); | 67 | //fprintf(stderr,"<%u,%u,%u>\n",maxnode,blocksize,numblocks); |
69 | locate(0,0); | 68 | locate(0,0); |
70 | outbytes = 0; | 69 | outbytes = 0; |
71 | return 0; | 70 | return 0; |
72 | } | 71 | } |
73 | 72 | ||
74 | void ppm_expander::locate(unsigned int n) { | 73 | void ppm_expander::locate(unsigned int n) { |
75 | locate(n/blocksize, n%blocksize); | 74 | locate(n/blocksize, n%blocksize); |
76 | outbytes = n; | 75 | outbytes = n; |
77 | } | 76 | } |
78 | 77 | ||
79 | void ppm_expander::locate(unsigned short block, unsigned int n) | 78 | void ppm_expander::locate(unsigned short block, unsigned int n) |
80 | { | 79 | { |
81 | if (needppmend) | 80 | if (needppmend) |
82 | { | 81 | { |
83 | ppm.PPM_End(); | 82 | ppm.PPM_End(); |
84 | needppmend = false; | 83 | needppmend = false; |
85 | } | 84 | } |
86 | size_t fpos; | 85 | size_t fpos; |
87 | fseek(my_file_in,STAT_MAGIC_SIZE+sizeof(maxnode)+sizeof(blocksize)+sizeof(numblocks)+block*sizeof(fpos),SEEK_SET); | 86 | fseek(my_file_in,STAT_MAGIC_SIZE+sizeof(maxnode)+sizeof(blocksize)+sizeof(numblocks)+block*sizeof(fpos),SEEK_SET); |
88 | fread(&fpos,sizeof(fpos),1,my_file_in); | 87 | fread(&fpos,sizeof(fpos),1,my_file_in); |
89 | fseek(my_file_in,fpos,SEEK_SET); | 88 | fseek(my_file_in,fpos,SEEK_SET); |
90 | 89 | ||
91 | ppm.arith.Arith_DecodeInit(my_read_buf,buf_in,bufsize); | 90 | ppm.arith.Arith_DecodeInit(my_read_buf,buf_in,bufsize); |
92 | int err=ppm.PPM_Init(maxnode); | 91 | int err=ppm.PPM_Init(maxnode); |
93 | needppmend = true; | 92 | needppmend = true; |
94 | curblock = block; | 93 | curblock = block; |
95 | for (int i = 0; i < n; i++) getch(); | 94 | for (int i = 0; i < n; i++) getch(); |
96 | } | 95 | } |
97 | 96 | ||
98 | int ppm_expander::getch() { | 97 | int ppm_expander::getch() { |
99 | if (curblock >= numblocks) return EOF; | 98 | if (curblock >= numblocks) return EOF; |
100 | int c=ppm.PPM_Decode(); | 99 | int c=ppm.PPM_Decode(); |
101 | if (c == SYM_EOF) | 100 | if (c == SYM_EOF) |
102 | { | 101 | { |
103 | if (++curblock >= numblocks) return EOF; | 102 | if (++curblock >= numblocks) return EOF; |
104 | locate(curblock,0); | 103 | locate(curblock,0); |
105 | c = ppm.PPM_Decode(); | 104 | c = ppm.PPM_Decode(); |
106 | } | 105 | } |
107 | outbytes++; | 106 | outbytes++; |
108 | return (c==SYM_EOF) ? EOF : c; | 107 | return (c==SYM_EOF) ? EOF : c; |
109 | } | 108 | } |
110 | 109 | ||
111 | #ifndef __STATIC | 110 | #ifndef __STATIC |
112 | extern "C" | 111 | extern "C" |
113 | { | 112 | { |
114 | CExpander* newcodec() { return new ppm_expander; } | 113 | CExpander* newcodec() { return new ppm_expander; } |
115 | } | 114 | } |
116 | #endif | 115 | #endif |
diff --git a/noncore/apps/opie-reader/ppm_expander.h b/noncore/apps/opie-reader/ppm_expander.h index a1a3b60..ccc89c2 100644 --- a/noncore/apps/opie-reader/ppm_expander.h +++ b/noncore/apps/opie-reader/ppm_expander.h | |||
@@ -1,62 +1,61 @@ | |||
1 | #ifndef __ppm_expander_h | 1 | #ifndef __ppm_expander_h |
2 | #define __ppm_expander_h | 2 | #define __ppm_expander_h |
3 | 3 | ||
4 | #include "useqpe.h" | ||
5 | #include "CExpander.h" | 4 | #include "CExpander.h" |
6 | #include <sys/stat.h> | 5 | #include <sys/stat.h> |
7 | 6 | ||
8 | 7 | ||
9 | #include "utypes.h" | 8 | #include "utypes.h" |
10 | #include "ppm.h" | 9 | #include "ppm.h" |
11 | #include "arith.h" | 10 | #include "arith.h" |
12 | 11 | ||
13 | 12 | ||
14 | #define SYM_EOF 256 | 13 | #define SYM_EOF 256 |
15 | 14 | ||
16 | class ppm_expander : public CExpander { | 15 | class ppm_expander : public CExpander { |
17 | UCHAR *buf_in,*buf_out; | 16 | UCHAR *buf_in,*buf_out; |
18 | unsigned int bufsize; | 17 | unsigned int bufsize; |
19 | unsigned int outbytes; | 18 | unsigned int outbytes; |
20 | unsigned long blocksize; | 19 | unsigned long blocksize; |
21 | unsigned short numblocks; | 20 | unsigned short numblocks; |
22 | unsigned short curblock; | 21 | unsigned short curblock; |
23 | unsigned short maxnode; | 22 | unsigned short maxnode; |
24 | bool needppmend; | 23 | bool needppmend; |
25 | int home(); | 24 | int home(); |
26 | FILE* my_file_in; | 25 | FILE* my_file_in; |
27 | PPM_ReadBuf* my_read_buf; | 26 | PPM_ReadBuf* my_read_buf; |
28 | ppm_worker ppm; | 27 | ppm_worker ppm; |
29 | public: | 28 | public: |
30 | QString about() { return QString("ppms Codec (c) Tim Wentford\nCompression code (c) Fabrice Bellard"); } | 29 | QString about() { return QString("ppms Codec (c) Tim Wentford\nCompression code (c) Fabrice Bellard"); } |
31 | #ifdef USEQPE | 30 | #ifdef USEQPE |
32 | void suspend() | 31 | void suspend() |
33 | { | 32 | { |
34 | CExpander::suspend(my_file_in); | 33 | CExpander::suspend(my_file_in); |
35 | } | 34 | } |
36 | void unsuspend() | 35 | void unsuspend() |
37 | { | 36 | { |
38 | CExpander::unsuspend(my_file_in); | 37 | CExpander::unsuspend(my_file_in); |
39 | } | 38 | } |
40 | #endif | 39 | #endif |
41 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) | 40 | ppm_expander() : needppmend(false), my_file_in(NULL), my_read_buf(NULL) |
42 | { | 41 | { |
43 | bufsize = 1024; | 42 | bufsize = 1024; |
44 | buf_in = new UCHAR[bufsize]; | 43 | buf_in = new UCHAR[bufsize]; |
45 | buf_out = new UCHAR[bufsize]; | 44 | buf_out = new UCHAR[bufsize]; |
46 | outbytes = 0; | 45 | outbytes = 0; |
47 | } | 46 | } |
48 | int OpenFile(const char* infile); | 47 | int OpenFile(const char* infile); |
49 | int getch(); | 48 | int getch(); |
50 | void locate(unsigned short block, unsigned int n); | 49 | void locate(unsigned short block, unsigned int n); |
51 | virtual ~ppm_expander(); | 50 | virtual ~ppm_expander(); |
52 | unsigned int locate() { return outbytes; } | 51 | unsigned int locate() { return outbytes; } |
53 | void locate(unsigned int n); | 52 | void locate(unsigned int n); |
54 | bool hasrandomaccess() { return (numblocks > 1); } | 53 | bool hasrandomaccess() { return (numblocks > 1); } |
55 | void sizes(unsigned long& file, unsigned long& text); | 54 | void sizes(unsigned long& file, unsigned long& text); |
56 | MarkupType PreferredMarkup() | 55 | MarkupType PreferredMarkup() |
57 | { | 56 | { |
58 | return cTEXT; | 57 | return cTEXT; |
59 | } | 58 | } |
60 | }; | 59 | }; |
61 | 60 | ||
62 | #endif | 61 | #endif |
diff --git a/noncore/apps/opie-reader/ppmsCodec/ppmsCodec.pro b/noncore/apps/opie-reader/ppmsCodec/ppmsCodec.pro index 8699d3b..d6ec97b 100644 --- a/noncore/apps/opie-reader/ppmsCodec/ppmsCodec.pro +++ b/noncore/apps/opie-reader/ppmsCodec/ppmsCodec.pro | |||
@@ -1,19 +1,19 @@ | |||
1 | DEFINES += OPIE USEQPE | 1 | DEFINES += OPIE USEQPE |
2 | VPATH = .. | 2 | VPATH = .. |
3 | TEMPLATE= lib | 3 | TEMPLATE= lib |
4 | CONFIG = qt warn_on release dll | 4 | CONFIG = qt warn_on release dll |
5 | HEADERS = Aportis.h | 5 | HEADERS = Aportis.h |
6 | 6 | ||
7 | SOURCES = ppm_expander.cpp \ | 7 | SOURCES = ppm_expander.cpp \ |
8 | ppm.cpp \ | 8 | ppm.cpp \ |
9 | arith_d.cpp | 9 | arith_d.cpp |
10 | 10 | ||
11 | INTERFACES= | 11 | INTERFACES= |
12 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs | 12 | DESTDIR = $(OPIEDIR)/plugins/reader/codecs |
13 | TARGET = ppms | 13 | TARGET = ppms |
14 | LIBS += -lreader_codec | 14 | LIBS += -lreader_codec |
15 | 15 | ||
16 | INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include | 16 | INCLUDEPATH+= $(OPIEDIR)/include |
17 | DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include | 17 | DEPENDPATH+= $(OPIEDIR)/include |
18 | 18 | ||
19 | include ( $(OPIEDIR)/include.pro ) | 19 | include ( $(OPIEDIR)/include.pro ) |
diff --git a/noncore/apps/opie-reader/preferences.cpp b/noncore/apps/opie-reader/preferences.cpp index b9397cf..0f59a22 100755 --- a/noncore/apps/opie-reader/preferences.cpp +++ b/noncore/apps/opie-reader/preferences.cpp | |||
@@ -1,105 +1,104 @@ | |||
1 | #include "useqpe.h" | ||
2 | #ifndef USEQPE | 1 | #ifndef USEQPE |
3 | 2 | ||
4 | #include "preferences.h" | 3 | #include "preferences.h" |
5 | 4 | ||
6 | #include <qfile.h> | 5 | #include <qfile.h> |
7 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
8 | 7 | ||
9 | Config::Config(const QString& _fn) : fname(_fn) | 8 | Config::Config(const QString& _fn) : fname(_fn) |
10 | { | 9 | { |
11 | // qDebug("Config::Config:%s", (const char*)fname); | 10 | // qDebug("Config::Config:%s", (const char*)fname); |
12 | QFile fl(fname); | 11 | QFile fl(fname); |
13 | if (fl.open(IO_ReadOnly)) | 12 | if (fl.open(IO_ReadOnly)) |
14 | { | 13 | { |
15 | QTextStream t(&fl); | 14 | QTextStream t(&fl); |
16 | QString key, value; | 15 | QString key, value; |
17 | while (!t.eof()) | 16 | while (!t.eof()) |
18 | { | 17 | { |
19 | QString data = t.readLine(); | 18 | QString data = t.readLine(); |
20 | int colon = data.find(':'); | 19 | int colon = data.find(':'); |
21 | if (colon > 0) | 20 | if (colon > 0) |
22 | { | 21 | { |
23 | QString key = data.left(colon); | 22 | QString key = data.left(colon); |
24 | QString value = data.right(data.length()-colon-1); | 23 | QString value = data.right(data.length()-colon-1); |
25 | values[key] = value; | 24 | values[key] = value; |
26 | } | 25 | } |
27 | } | 26 | } |
28 | fl.close(); | 27 | fl.close(); |
29 | } | 28 | } |
30 | // read entries into values | 29 | // read entries into values |
31 | } | 30 | } |
32 | Config::~Config() | 31 | Config::~Config() |
33 | { | 32 | { |
34 | // qDebug("Config::~Config:%s", (const char*)fname); | 33 | // qDebug("Config::~Config:%s", (const char*)fname); |
35 | QFile fl(fname); | 34 | QFile fl(fname); |
36 | if (fl.open(IO_WriteOnly)) | 35 | if (fl.open(IO_WriteOnly)) |
37 | { | 36 | { |
38 | QTextStream t(&fl); | 37 | QTextStream t(&fl); |
39 | for (QMap<QString,QString>::Iterator iter = values.begin(); | 38 | for (QMap<QString,QString>::Iterator iter = values.begin(); |
40 | iter != values.end(); | 39 | iter != values.end(); |
41 | iter++) | 40 | iter++) |
42 | { | 41 | { |
43 | t << iter.key() << ':' << iter.data() << '\n'; | 42 | t << iter.key() << ':' << iter.data() << '\n'; |
44 | } | 43 | } |
45 | fl.close(); | 44 | fl.close(); |
46 | } | 45 | } |
47 | } | 46 | } |
48 | QString Config::readEntry(const QString& key, const QString& deflt) | 47 | QString Config::readEntry(const QString& key, const QString& deflt) |
49 | { | 48 | { |
50 | QMap<QString,QString>::Iterator iter = values.find(key); | 49 | QMap<QString,QString>::Iterator iter = values.find(key); |
51 | if (iter != values.end()) | 50 | if (iter != values.end()) |
52 | { | 51 | { |
53 | return iter.data(); | 52 | return iter.data(); |
54 | } | 53 | } |
55 | else | 54 | else |
56 | { | 55 | { |
57 | return deflt; | 56 | return deflt; |
58 | } | 57 | } |
59 | } | 58 | } |
60 | bool Config::readBoolEntry(const QString& key, const bool deflt) | 59 | bool Config::readBoolEntry(const QString& key, const bool deflt) |
61 | { | 60 | { |
62 | bool ok; | 61 | bool ok; |
63 | QMap<QString,QString>::Iterator iter = values.find(key); | 62 | QMap<QString,QString>::Iterator iter = values.find(key); |
64 | if (iter != values.end()) | 63 | if (iter != values.end()) |
65 | { | 64 | { |
66 | int ret = iter.data().toInt(&ok); | 65 | int ret = iter.data().toInt(&ok); |
67 | return ((ok) ? !!ret : deflt); | 66 | return ((ok) ? !!ret : deflt); |
68 | } | 67 | } |
69 | else | 68 | else |
70 | { | 69 | { |
71 | return deflt; | 70 | return deflt; |
72 | } | 71 | } |
73 | } | 72 | } |
74 | int Config::readNumEntry(const QString& key, const int deflt) | 73 | int Config::readNumEntry(const QString& key, const int deflt) |
75 | { | 74 | { |
76 | bool ok; | 75 | bool ok; |
77 | QMap<QString,QString>::Iterator iter = values.find(key); | 76 | QMap<QString,QString>::Iterator iter = values.find(key); |
78 | if (iter != values.end()) | 77 | if (iter != values.end()) |
79 | { | 78 | { |
80 | int ret = iter.data().toInt(&ok); | 79 | int ret = iter.data().toInt(&ok); |
81 | return ((ok) ? ret : deflt); | 80 | return ((ok) ? ret : deflt); |
82 | } | 81 | } |
83 | else | 82 | else |
84 | { | 83 | { |
85 | return deflt; | 84 | return deflt; |
86 | } | 85 | } |
87 | } | 86 | } |
88 | void Config::writeEntry(const QString& key, const QString& value) | 87 | void Config::writeEntry(const QString& key, const QString& value) |
89 | { | 88 | { |
90 | values[key] = value; | 89 | values[key] = value; |
91 | } | 90 | } |
92 | 91 | ||
93 | void Config::writeEntry(const QString& key, const bool value) | 92 | void Config::writeEntry(const QString& key, const bool value) |
94 | { | 93 | { |
95 | values[key] = (value) ? "1" : "0"; | 94 | values[key] = (value) ? "1" : "0"; |
96 | } | 95 | } |
97 | 96 | ||
98 | void Config::writeEntry(const QString& key, const int value) | 97 | void Config::writeEntry(const QString& key, const int value) |
99 | { | 98 | { |
100 | QString rhs; | 99 | QString rhs; |
101 | rhs.setNum(value); | 100 | rhs.setNum(value); |
102 | values[key] = rhs; | 101 | values[key] = rhs; |
103 | } | 102 | } |
104 | 103 | ||
105 | #endif | 104 | #endif |
diff --git a/noncore/apps/opie-reader/preferences.h b/noncore/apps/opie-reader/preferences.h index 69d1774..aeb2a84 100644 --- a/noncore/apps/opie-reader/preferences.h +++ b/noncore/apps/opie-reader/preferences.h | |||
@@ -1,27 +1,26 @@ | |||
1 | #include "useqpe.h" | ||
2 | #ifndef USEQPE | 1 | #ifndef USEQPE |
3 | #ifndef __PREFERENCES_H | 2 | #ifndef __PREFERENCES_H |
4 | #define __PREFERENCES_H | 3 | #define __PREFERENCES_H |
5 | 4 | ||
6 | #include <qstring.h> | 5 | #include <qstring.h> |
7 | #include <qmap.h> | 6 | #include <qmap.h> |
8 | 7 | ||
9 | class Config | 8 | class Config |
10 | { | 9 | { |
11 | QMap<QString, QString> values; | 10 | QMap<QString, QString> values; |
12 | QString fname; | 11 | QString fname; |
13 | public: | 12 | public: |
14 | Config(const QString& fname); | 13 | Config(const QString& fname); |
15 | ~Config(); | 14 | ~Config(); |
16 | void setGroup(const QString& s) { } | 15 | void setGroup(const QString& s) { } |
17 | QString readEntry(const QString&, const QString&); | 16 | QString readEntry(const QString&, const QString&); |
18 | bool readBoolEntry(const QString&, const bool); | 17 | bool readBoolEntry(const QString&, const bool); |
19 | int readNumEntry(const QString&, const int); | 18 | int readNumEntry(const QString&, const int); |
20 | 19 | ||
21 | void writeEntry(const QString&, const QString&); | 20 | void writeEntry(const QString&, const QString&); |
22 | void writeEntry(const QString&, const bool); | 21 | void writeEntry(const QString&, const bool); |
23 | void writeEntry(const QString&, const int); | 22 | void writeEntry(const QString&, const int); |
24 | }; | 23 | }; |
25 | 24 | ||
26 | #endif // PREFERENCES | 25 | #endif // PREFERENCES |
27 | #endif | 26 | #endif |
diff --git a/noncore/apps/opie-reader/static.h b/noncore/apps/opie-reader/static.h deleted file mode 100644 index e69de29..0000000 --- a/noncore/apps/opie-reader/static.h +++ b/dev/null | |||
diff --git a/noncore/apps/opie-reader/striphtml.cpp b/noncore/apps/opie-reader/striphtml.cpp index 9cd6a0d..e86402b 100644 --- a/noncore/apps/opie-reader/striphtml.cpp +++ b/noncore/apps/opie-reader/striphtml.cpp | |||
@@ -1,197 +1,196 @@ | |||
1 | #include <qmap.h> | 1 | #include <qmap.h> |
2 | #include <qfileinfo.h> | 2 | #include <qfileinfo.h> |
3 | #include <qtextstream.h> | 3 | #include <qtextstream.h> |
4 | #include <qdir.h> | 4 | #include <qdir.h> |
5 | #include "useqpe.h" | ||
6 | #ifdef USEQPE | 5 | #ifdef USEQPE |
7 | #include <qpe/global.h> | 6 | #include <qpe/global.h> |
8 | #endif | 7 | #endif |
9 | #include "CDrawBuffer.h" | 8 | #include "CDrawBuffer.h" |
10 | #include "striphtml.h" | 9 | #include "striphtml.h" |
11 | #include "hrule.h" | 10 | #include "hrule.h" |
12 | #include "util.h" | 11 | #include "util.h" |
13 | 12 | ||
14 | #include <qregexp.h> | 13 | #include <qregexp.h> |
15 | #include <qimage.h> | 14 | #include <qimage.h> |
16 | #include <qpixmap.h> | 15 | #include <qpixmap.h> |
17 | //#include <qprogressdialog.h> | 16 | //#include <qprogressdialog.h> |
18 | //#include <qapplication.h> | 17 | //#include <qapplication.h> |
19 | 18 | ||
20 | static unsigned char h2i(unsigned char c) | 19 | static unsigned char h2i(unsigned char c) |
21 | { | 20 | { |
22 | unsigned char ret = 0; | 21 | unsigned char ret = 0; |
23 | if ('0' <= c && c <= '9') | 22 | if ('0' <= c && c <= '9') |
24 | { | 23 | { |
25 | ret = c - '0'; | 24 | ret = c - '0'; |
26 | } | 25 | } |
27 | else if ('a' <= c && c <= 'f') | 26 | else if ('a' <= c && c <= 'f') |
28 | { | 27 | { |
29 | ret = c - 'a' + 10; | 28 | ret = c - 'a' + 10; |
30 | } | 29 | } |
31 | return ret; | 30 | return ret; |
32 | } | 31 | } |
33 | 32 | ||
34 | static void parse_color(const QString& attr, unsigned char& r, unsigned char& g, unsigned char& b) | 33 | static void parse_color(const QString& attr, unsigned char& r, unsigned char& g, unsigned char& b) |
35 | { | 34 | { |
36 | r = g = b = 0; | 35 | r = g = b = 0; |
37 | if (attr.length() >= 7 && attr[0] == '#') | 36 | if (attr.length() >= 7 && attr[0] == '#') |
38 | { | 37 | { |
39 | r = h2i(attr[1].unicode()); | 38 | r = h2i(attr[1].unicode()); |
40 | r = 16*r + h2i(attr[2].unicode()); | 39 | r = 16*r + h2i(attr[2].unicode()); |
41 | g = h2i(attr[3].unicode()); | 40 | g = h2i(attr[3].unicode()); |
42 | g = 16*g + h2i(attr[4].unicode()); | 41 | g = 16*g + h2i(attr[4].unicode()); |
43 | b = h2i(attr[5].unicode()); | 42 | b = h2i(attr[5].unicode()); |
44 | b = 16*b + h2i(attr[6].unicode()); | 43 | b = 16*b + h2i(attr[6].unicode()); |
45 | } | 44 | } |
46 | else if (attr == "red") | 45 | else if (attr == "red") |
47 | { | 46 | { |
48 | r = 255; | 47 | r = 255; |
49 | } | 48 | } |
50 | else if (attr == "green") | 49 | else if (attr == "green") |
51 | { | 50 | { |
52 | g = 255; | 51 | g = 255; |
53 | } | 52 | } |
54 | else if (attr == "blue") | 53 | else if (attr == "blue") |
55 | { | 54 | { |
56 | b = 255; | 55 | b = 255; |
57 | } | 56 | } |
58 | else if (attr == "white") | 57 | else if (attr == "white") |
59 | { | 58 | { |
60 | r = g = b = 255; | 59 | r = g = b = 255; |
61 | } | 60 | } |
62 | else if (attr == "black") | 61 | else if (attr == "black") |
63 | { | 62 | { |
64 | r = g = b = 0; | 63 | r = g = b = 0; |
65 | } | 64 | } |
66 | else | 65 | else |
67 | { | 66 | { |
68 | qDebug("Don't understand colour \"%s\"", (const char*)attr); | 67 | qDebug("Don't understand colour \"%s\"", (const char*)attr); |
69 | } | 68 | } |
70 | } | 69 | } |
71 | 70 | ||
72 | CNavigation_base<htmlmark> striphtml::m_nav; | 71 | CNavigation_base<htmlmark> striphtml::m_nav; |
73 | 72 | ||
74 | void striphtml::skipblock(const QString& _ent) | 73 | void striphtml::skipblock(const QString& _ent) |
75 | { | 74 | { |
76 | tchar ch = '>'; | 75 | tchar ch = '>'; |
77 | CStyle dummy; | 76 | CStyle dummy; |
78 | QString ent; | 77 | QString ent; |
79 | unsigned long pos; | 78 | unsigned long pos; |
80 | do | 79 | do |
81 | { | 80 | { |
82 | while (ch != '<' && ch != UEOF) | 81 | while (ch != '<' && ch != UEOF) |
83 | { | 82 | { |
84 | mygetch(ch, dummy, pos); | 83 | mygetch(ch, dummy, pos); |
85 | } | 84 | } |
86 | 85 | ||
87 | ch = skip_ws(); | 86 | ch = skip_ws(); |
88 | 87 | ||
89 | ent = getname(ch, " >").lower(); | 88 | ent = getname(ch, " >").lower(); |
90 | qDebug("Skipblock:%s", (const char*)ent); | 89 | qDebug("Skipblock:%s", (const char*)ent); |
91 | } while (ent != _ent && ch != UEOF); | 90 | } while (ent != _ent && ch != UEOF); |
92 | } | 91 | } |
93 | 92 | ||
94 | void striphtml::locate(unsigned int n) | 93 | void striphtml::locate(unsigned int n) |
95 | { | 94 | { |
96 | m_inblock = false; | 95 | m_inblock = false; |
97 | text_q = ""; | 96 | text_q = ""; |
98 | forcecentre = false; | 97 | forcecentre = false; |
99 | ignorespace = false; | 98 | ignorespace = false; |
100 | while (!stylestack.isEmpty()) stylestack.pop(); | 99 | while (!stylestack.isEmpty()) stylestack.pop(); |
101 | currentstyle.unset(); | 100 | currentstyle.unset(); |
102 | qDebug("striphtml:locating:%u", n); | 101 | qDebug("striphtml:locating:%u", n); |
103 | parent->locate(n); | 102 | parent->locate(n); |
104 | } | 103 | } |
105 | 104 | ||
106 | int striphtml::getpara(CBuffer& buff, unsigned long& startpos) | 105 | int striphtml::getpara(CBuffer& buff, unsigned long& startpos) |
107 | { | 106 | { |
108 | tchar ch; | 107 | tchar ch; |
109 | CStyle sty; | 108 | CStyle sty; |
110 | unsigned long pos; | 109 | unsigned long pos; |
111 | int i = 0; | 110 | int i = 0; |
112 | parent->getch(ch, sty, startpos); | 111 | parent->getch(ch, sty, startpos); |
113 | pos = startpos; | 112 | pos = startpos; |
114 | while (1) | 113 | while (1) |
115 | { | 114 | { |
116 | if (ch == 10 && !isPre) | 115 | if (ch == 10 && !isPre) |
117 | { | 116 | { |
118 | ch = ' '; | 117 | ch = ' '; |
119 | } | 118 | } |
120 | if (ch == UEOF) | 119 | if (ch == UEOF) |
121 | { | 120 | { |
122 | // qDebug("EOF:%d:%u", i, pos); | 121 | // qDebug("EOF:%d:%u", i, pos); |
123 | buff[i] = 0; | 122 | buff[i] = 0; |
124 | if (i == 0) | 123 | if (i == 0) |
125 | { | 124 | { |
126 | i = -1; | 125 | i = -1; |
127 | } | 126 | } |
128 | return i; | 127 | return i; |
129 | } | 128 | } |
130 | else if (ch == '<') | 129 | else if (ch == '<') |
131 | { | 130 | { |
132 | tchar ch2 = skip_ws(); | 131 | tchar ch2 = skip_ws(); |
133 | QString ent = getname(ch2, " >"); | 132 | QString ent = getname(ch2, " >"); |
134 | ent = ent.lower(); | 133 | ent = ent.lower(); |
135 | // qDebug("ent:%s", (const char*)ent); | 134 | // qDebug("ent:%s", (const char*)ent); |
136 | if (ent == "a") | 135 | if (ent == "a") |
137 | { | 136 | { |
138 | buff[i++] = '<'; | 137 | buff[i++] = '<'; |
139 | buff[i++] = 'a'; | 138 | buff[i++] = 'a'; |
140 | buff[i++] = ch2; | 139 | buff[i++] = ch2; |
141 | // buff[i] = 0; qDebug("ANCHOR:%s", (const char*)toQString(buff.data())); | 140 | // buff[i] = 0; qDebug("ANCHOR:%s", (const char*)toQString(buff.data())); |
142 | } | 141 | } |
143 | else if (ent == "/a") | 142 | else if (ent == "/a") |
144 | { | 143 | { |
145 | buff[i++] = '<'; | 144 | buff[i++] = '<'; |
146 | buff[i++] = '/'; | 145 | buff[i++] = '/'; |
147 | buff[i++] = 'a'; | 146 | buff[i++] = 'a'; |
148 | buff[i++] = ch2; | 147 | buff[i++] = ch2; |
149 | // buff[i] = 0; qDebug("/ANCHOR:%s", (const char*)toQString(buff.data())); | 148 | // buff[i] = 0; qDebug("/ANCHOR:%s", (const char*)toQString(buff.data())); |
150 | } | 149 | } |
151 | else if (ent == "div") | 150 | else if (ent == "div") |
152 | { | 151 | { |
153 | // buff[i] = 0; qDebug("DIV:%s", (const char*)toQString(buff.data())); | 152 | // buff[i] = 0; qDebug("DIV:%s", (const char*)toQString(buff.data())); |
154 | if (i == 0) | 153 | if (i == 0) |
155 | { | 154 | { |
156 | buff[i++] = '<'; | 155 | buff[i++] = '<'; |
157 | buff[i++] = 'd'; | 156 | buff[i++] = 'd'; |
158 | buff[i++] = 'i'; | 157 | buff[i++] = 'i'; |
159 | buff[i++] = 'v'; | 158 | buff[i++] = 'v'; |
160 | buff[i++] = ' '; | 159 | buff[i++] = ' '; |
161 | buff[i++] = ch2; | 160 | buff[i++] = ch2; |
162 | while (ch2 != '>' && ch2 != UEOF && i < 2048) | 161 | while (ch2 != '>' && ch2 != UEOF && i < 2048) |
163 | { | 162 | { |
164 | parent->getch(ch2, sty, pos); | 163 | parent->getch(ch2, sty, pos); |
165 | buff[i++] = ch2; | 164 | buff[i++] = ch2; |
166 | } | 165 | } |
167 | } | 166 | } |
168 | else | 167 | else |
169 | { | 168 | { |
170 | locate(pos); | 169 | locate(pos); |
171 | } | 170 | } |
172 | buff[i++] = 0; | 171 | buff[i++] = 0; |
173 | // qDebug("DIV:%s", (const char*)toQString(buff.data())); | 172 | // qDebug("DIV:%s", (const char*)toQString(buff.data())); |
174 | return i; | 173 | return i; |
175 | } | 174 | } |
176 | else if (ent == "p" || (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1)) | 175 | else if (ent == "p" || (ent[0] == 'h' && ent.length() == 2 && QString("123456789").find(ent[1]) != -1)) |
177 | { | 176 | { |
178 | buff[i++] = 0; | 177 | buff[i++] = 0; |
179 | while (ch2 != '>' && ch2 != UEOF) | 178 | while (ch2 != '>' && ch2 != UEOF) |
180 | { | 179 | { |
181 | parent->getch(ch2, sty, pos); | 180 | parent->getch(ch2, sty, pos); |
182 | } | 181 | } |
183 | return i; | 182 | return i; |
184 | } | 183 | } |
185 | else | 184 | else |
186 | { | 185 | { |
187 | while (ch2 != '>' && ch2 != UEOF) | 186 | while (ch2 != '>' && ch2 != UEOF) |
188 | { | 187 | { |
189 | parent->getch(ch2, sty, pos); | 188 | parent->getch(ch2, sty, pos); |
190 | } | 189 | } |
191 | } | 190 | } |
192 | } | 191 | } |
193 | else | 192 | else |
194 | { | 193 | { |
195 | buff[i++] = ch; | 194 | buff[i++] = ch; |
196 | } | 195 | } |
197 | parent->getch(ch, sty, pos); | 196 | parent->getch(ch, sty, pos); |
diff --git a/noncore/apps/opie-reader/useqpe.h b/noncore/apps/opie-reader/useqpe.h deleted file mode 100644 index e69de29..0000000 --- a/noncore/apps/opie-reader/useqpe.h +++ b/dev/null | |||
diff --git a/noncore/apps/opie-reader/ztxt.cpp b/noncore/apps/opie-reader/ztxt.cpp index 79c5fa4..35db05e 100644 --- a/noncore/apps/opie-reader/ztxt.cpp +++ b/noncore/apps/opie-reader/ztxt.cpp | |||
@@ -1,174 +1,173 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <string.h> | 2 | #include <string.h> |
3 | #include "ztxt.h" | 3 | #include "ztxt.h" |
4 | #include "my_list.h" | 4 | #include "my_list.h" |
5 | #include "Bkmks.h" | 5 | #include "Bkmks.h" |
6 | #include "static.h" | ||
7 | 6 | ||
8 | ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } | 7 | ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } |
9 | 8 | ||
10 | 9 | ||
11 | int ztxt::OpenFile(const char *src) | 10 | int ztxt::OpenFile(const char *src) |
12 | { | 11 | { |
13 | if (!Cpdb::openpdbfile(src)) | 12 | if (!Cpdb::openpdbfile(src)) |
14 | { | 13 | { |
15 | return -1; | 14 | return -1; |
16 | } | 15 | } |
17 | 16 | ||
18 | //printf("Okay %u\n", 4); | 17 | //printf("Okay %u\n", 4); |
19 | 18 | ||
20 | if (head.type != ZTXT_ID) return -1; | 19 | if (head.type != ZTXT_ID) return -1; |
21 | 20 | ||
22 | gotorecordnumber(0); | 21 | gotorecordnumber(0); |
23 | fread(&hdr0, 1, sizeof(hdr0), fin); | 22 | fread(&hdr0, 1, sizeof(hdr0), fin); |
24 | //printf("Okay %u\n", 5); | 23 | //printf("Okay %u\n", 5); |
25 | buffersize = ntohl(hdr0.size); | 24 | buffersize = ntohl(hdr0.size); |
26 | compressedtextbuffer = new UInt8[buffersize]; | 25 | compressedtextbuffer = new UInt8[buffersize]; |
27 | expandedtextbuffer = new UInt8[buffersize]; | 26 | expandedtextbuffer = new UInt8[buffersize]; |
28 | //printf("Okay %u\n", 6); | 27 | //printf("Okay %u\n", 6); |
29 | 28 | ||
30 | home(); | 29 | home(); |
31 | //printf("Okay %u\n", 7); | 30 | //printf("Okay %u\n", 7); |
32 | 31 | ||
33 | // printf("Returning 0\n"); | 32 | // printf("Returning 0\n"); |
34 | 33 | ||
35 | return 0; | 34 | return 0; |
36 | } | 35 | } |
37 | 36 | ||
38 | int ztxt::getch() | 37 | int ztxt::getch() |
39 | { | 38 | { |
40 | if (bufferpos >= buffercontent) | 39 | if (bufferpos >= buffercontent) |
41 | { | 40 | { |
42 | size_t reclen = recordlength(++bufferrec); | 41 | size_t reclen = recordlength(++bufferrec); |
43 | if (reclen == 0) return -1; | 42 | if (reclen == 0) return -1; |
44 | gotorecordnumber(bufferrec); | 43 | gotorecordnumber(bufferrec); |
45 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 44 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
46 | 45 | ||
47 | zstream.next_in = compressedtextbuffer; | 46 | zstream.next_in = compressedtextbuffer; |
48 | zstream.next_out = expandedtextbuffer; | 47 | zstream.next_out = expandedtextbuffer; |
49 | zstream.avail_out = buffersize; | 48 | zstream.avail_out = buffersize; |
50 | zstream.avail_in = reclen; | 49 | zstream.avail_in = reclen; |
51 | 50 | ||
52 | int ret = inflate(&zstream, Z_SYNC_FLUSH); | 51 | int ret = inflate(&zstream, Z_SYNC_FLUSH); |
53 | buffercontent = buffersize - zstream.avail_out; | 52 | buffercontent = buffersize - zstream.avail_out; |
54 | bufferpos = 0; | 53 | bufferpos = 0; |
55 | 54 | ||
56 | } | 55 | } |
57 | currentpos++; | 56 | currentpos++; |
58 | return expandedtextbuffer[bufferpos++]; | 57 | return expandedtextbuffer[bufferpos++]; |
59 | } | 58 | } |
60 | 59 | ||
61 | unsigned int ztxt::locate() | 60 | unsigned int ztxt::locate() |
62 | { | 61 | { |
63 | return currentpos; | 62 | return currentpos; |
64 | } | 63 | } |
65 | 64 | ||
66 | void ztxt::locate(unsigned int n) | 65 | void ztxt::locate(unsigned int n) |
67 | { | 66 | { |
68 | 67 | ||
69 | if (hasrandomaccess()) | 68 | if (hasrandomaccess()) |
70 | { | 69 | { |
71 | bufferrec = n / ntohs(hdr0.recordSize) + 1; | 70 | bufferrec = n / ntohs(hdr0.recordSize) + 1; |
72 | if (bufferrec == 1) | 71 | if (bufferrec == 1) |
73 | { | 72 | { |
74 | inflateEnd(&zstream); | 73 | inflateEnd(&zstream); |
75 | } | 74 | } |
76 | size_t reclen = recordlength(bufferrec); | 75 | size_t reclen = recordlength(bufferrec); |
77 | if (reclen == 0) return; | 76 | if (reclen == 0) return; |
78 | gotorecordnumber(bufferrec); | 77 | gotorecordnumber(bufferrec); |
79 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 78 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
80 | 79 | ||
81 | zstream.next_in = compressedtextbuffer; | 80 | zstream.next_in = compressedtextbuffer; |
82 | zstream.next_out = expandedtextbuffer; | 81 | zstream.next_out = expandedtextbuffer; |
83 | zstream.avail_out = buffersize; | 82 | zstream.avail_out = buffersize; |
84 | zstream.avail_in = reclen; | 83 | zstream.avail_in = reclen; |
85 | 84 | ||
86 | if (bufferrec == 1) | 85 | if (bufferrec == 1) |
87 | { | 86 | { |
88 | zstream.zalloc = Z_NULL; | 87 | zstream.zalloc = Z_NULL; |
89 | zstream.zfree = Z_NULL; | 88 | zstream.zfree = Z_NULL; |
90 | zstream.opaque = Z_NULL; | 89 | zstream.opaque = Z_NULL; |
91 | 90 | ||
92 | inflateInit(&zstream); | 91 | inflateInit(&zstream); |
93 | } | 92 | } |
94 | 93 | ||
95 | 94 | ||
96 | int ret = inflate(&zstream, Z_SYNC_FLUSH); | 95 | int ret = inflate(&zstream, Z_SYNC_FLUSH); |
97 | buffercontent = buffersize - zstream.avail_out; | 96 | buffercontent = buffersize - zstream.avail_out; |
98 | bufferpos = 0; | 97 | bufferpos = 0; |
99 | currentpos = n - n % ntohs(hdr0.recordSize); | 98 | currentpos = n - n % ntohs(hdr0.recordSize); |
100 | while (currentpos < n) getch(); | 99 | while (currentpos < n) getch(); |
101 | } | 100 | } |
102 | else | 101 | else |
103 | { | 102 | { |
104 | home(); | 103 | home(); |
105 | while (currentpos < n && getch() != EOF); | 104 | while (currentpos < n && getch() != EOF); |
106 | } | 105 | } |
107 | } | 106 | } |
108 | 107 | ||
109 | void ztxt::home() | 108 | void ztxt::home() |
110 | { | 109 | { |
111 | if (bInit) | 110 | if (bInit) |
112 | { | 111 | { |
113 | inflateEnd(&zstream); | 112 | inflateEnd(&zstream); |
114 | } | 113 | } |
115 | bInit = true; | 114 | bInit = true; |
116 | size_t reclen = recordlength(1); | 115 | size_t reclen = recordlength(1); |
117 | gotorecordnumber(1); | 116 | gotorecordnumber(1); |
118 | fread(compressedtextbuffer, reclen, sizeof(char), fin); | 117 | fread(compressedtextbuffer, reclen, sizeof(char), fin); |
119 | 118 | ||
120 | zstream.next_in = compressedtextbuffer; | 119 | zstream.next_in = compressedtextbuffer; |
121 | zstream.next_out = expandedtextbuffer; | 120 | zstream.next_out = expandedtextbuffer; |
122 | zstream.avail_out = buffersize; | 121 | zstream.avail_out = buffersize; |
123 | zstream.avail_in = reclen; | 122 | zstream.avail_in = reclen; |
124 | 123 | ||
125 | zstream.zalloc = Z_NULL; | 124 | zstream.zalloc = Z_NULL; |
126 | zstream.zfree = Z_NULL; | 125 | zstream.zfree = Z_NULL; |
127 | zstream.opaque = Z_NULL; | 126 | zstream.opaque = Z_NULL; |
128 | 127 | ||
129 | // printf("Initialising\n"); | 128 | // printf("Initialising\n"); |
130 | 129 | ||
131 | inflateInit(&zstream); | 130 | inflateInit(&zstream); |
132 | 131 | ||
133 | int ret = inflate(&zstream, Z_SYNC_FLUSH); | 132 | int ret = inflate(&zstream, Z_SYNC_FLUSH); |
134 | // printf("Inflate : %d\n", ret); | 133 | // printf("Inflate : %d\n", ret); |
135 | bufferpos = 0; | 134 | bufferpos = 0; |
136 | bufferrec = 1; | 135 | bufferrec = 1; |
137 | currentpos = 0; | 136 | currentpos = 0; |
138 | buffercontent = buffersize - zstream.avail_out; | 137 | buffercontent = buffersize - zstream.avail_out; |
139 | //printf("buffercontent:%u\n", buffercontent); | 138 | //printf("buffercontent:%u\n", buffercontent); |
140 | } | 139 | } |
141 | 140 | ||
142 | CList<Bkmk>* ztxt::getbkmklist() | 141 | CList<Bkmk>* ztxt::getbkmklist() |
143 | { | 142 | { |
144 | UInt16 recno = ntohs(hdr0.bookmarkRecord); | 143 | UInt16 recno = ntohs(hdr0.bookmarkRecord); |
145 | 144 | ||
146 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); | 145 | // printf("Bookmarks - record %d contains %d\n", recno, ntohs(hdr0.numBookmarks)); |
147 | 146 | ||
148 | if (recno == 0) return NULL; | 147 | if (recno == 0) return NULL; |
149 | 148 | ||
150 | CList<Bkmk>* t = new CList<Bkmk>; | 149 | CList<Bkmk>* t = new CList<Bkmk>; |
151 | size_t cur = ftell(fin); | 150 | size_t cur = ftell(fin); |
152 | gotorecordnumber(recno); | 151 | gotorecordnumber(recno); |
153 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) | 152 | for (int i = 0; i < ntohs(hdr0.numBookmarks); i++) |
154 | { | 153 | { |
155 | zTXTbkmk bkmk; | 154 | zTXTbkmk bkmk; |
156 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; | 155 | if (fread(&bkmk, sizeof(bkmk), 1, fin) != 1) break; |
157 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); | 156 | // printf("Bookmark number:%d:%.20s\n", i, bkmk.title); |
158 | tchar title[MAX_BMRK_LENGTH]; | 157 | tchar title[MAX_BMRK_LENGTH]; |
159 | for (int j = 0; j < MAX_BMRK_LENGTH; j++) | 158 | for (int j = 0; j < MAX_BMRK_LENGTH; j++) |
160 | { | 159 | { |
161 | title[j] = bkmk.title[j]; | 160 | title[j] = bkmk.title[j]; |
162 | } | 161 | } |
163 | t->push_back(Bkmk(title, NULL, ntohl(bkmk.offset))); | 162 | t->push_back(Bkmk(title, NULL, ntohl(bkmk.offset))); |
164 | } | 163 | } |
165 | fseek(fin, cur, SEEK_SET); | 164 | fseek(fin, cur, SEEK_SET); |
166 | return t; | 165 | return t; |
167 | } | 166 | } |
168 | 167 | ||
169 | #ifndef __STATIC | 168 | #ifndef __STATIC |
170 | extern "C" | 169 | extern "C" |
171 | { | 170 | { |
172 | CExpander* newcodec() { return new ztxt; } | 171 | CExpander* newcodec() { return new ztxt; } |
173 | } | 172 | } |
174 | #endif | 173 | #endif |