summaryrefslogtreecommitdiff
authorpohly <pohly>2004-08-26 05:57:55 (UTC)
committer pohly <pohly>2004-08-26 05:57:55 (UTC)
commit3f36482d9a6c096fdf5d8ab8831eb736746c0565 (patch) (unidiff)
treefb213ba05e20c9a02bca3d805f8f5c96c1c45da0
parente00962edd9d4be58c6184e5b6c5f6ef07f449689 (diff)
downloadopie-3f36482d9a6c096fdf5d8ab8831eb736746c0565.zip
opie-3f36482d9a6c096fdf5d8ab8831eb736746c0565.tar.gz
opie-3f36482d9a6c096fdf5d8ab8831eb736746c0565.tar.bz2
removed obsolete static.h and useqpe.h
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Aportis.cpp1
-rw-r--r--noncore/apps/opie-reader/AportisCodec/AportisCodec.pro7
-rw-r--r--noncore/apps/opie-reader/BuffDoc.cpp2
-rw-r--r--noncore/apps/opie-reader/BuffDoc.h1
-rw-r--r--noncore/apps/opie-reader/CDrawBuffer.cpp1
-rw-r--r--noncore/apps/opie-reader/CExpander.h1
-rw-r--r--noncore/apps/opie-reader/CFilter.cpp1
-rw-r--r--noncore/apps/opie-reader/CFilter.h1
-rw-r--r--noncore/apps/opie-reader/CHM.cpp1
-rw-r--r--noncore/apps/opie-reader/CHM.h1
-rw-r--r--noncore/apps/opie-reader/CHM/CHM.pro4
-rw-r--r--noncore/apps/opie-reader/CloseDialog.h1
-rw-r--r--noncore/apps/opie-reader/FontControl.cpp1
-rw-r--r--noncore/apps/opie-reader/HTMLFilter/HTMLFilter.pro4
-rw-r--r--noncore/apps/opie-reader/Palm2QImage.cpp1
-rw-r--r--noncore/apps/opie-reader/PluckerCodec/PluckerCodec.pro4
-rw-r--r--noncore/apps/opie-reader/QTReader.cpp1
-rw-r--r--noncore/apps/opie-reader/QTReader.h1
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.cpp2
-rw-r--r--noncore/apps/opie-reader/QTReaderApp.h1
-rw-r--r--noncore/apps/opie-reader/ToolbarPrefs.cpp1
-rw-r--r--noncore/apps/opie-reader/ToolbarPrefs.h2
-rw-r--r--noncore/apps/opie-reader/URLDialog.h1
-rw-r--r--noncore/apps/opie-reader/WeaselCodec/WeaselCodec.pro4
-rw-r--r--noncore/apps/opie-reader/ZText.h1
-rw-r--r--noncore/apps/opie-reader/codeclib/codeclib.pro4
-rw-r--r--noncore/apps/opie-reader/ebookcodec.h2
-rw-r--r--noncore/apps/opie-reader/iSiloCodec/iSiloCodec.pro4
-rw-r--r--noncore/apps/opie-reader/main.cpp1
-rw-r--r--noncore/apps/opie-reader/pdb.cpp1
-rw-r--r--noncore/apps/opie-reader/pdb.h1
-rw-r--r--noncore/apps/opie-reader/pdblib/pdblib.pro4
-rw-r--r--noncore/apps/opie-reader/plucker.cpp2
-rw-r--r--noncore/apps/opie-reader/plucker_base.cpp3
-rw-r--r--noncore/apps/opie-reader/pluckerbaselib/pluckerbaselib.pro4
-rw-r--r--noncore/apps/opie-reader/ppm_expander.cpp1
-rw-r--r--noncore/apps/opie-reader/ppm_expander.h1
-rw-r--r--noncore/apps/opie-reader/ppmsCodec/ppmsCodec.pro4
-rwxr-xr-xnoncore/apps/opie-reader/preferences.cpp1
-rw-r--r--noncore/apps/opie-reader/preferences.h1
-rw-r--r--noncore/apps/opie-reader/static.h0
-rw-r--r--noncore/apps/opie-reader/striphtml.cpp1
-rw-r--r--noncore/apps/opie-reader/useqpe.h0
-rw-r--r--noncore/apps/opie-reader/ztxt.cpp1
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,455 +1,454 @@
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
8Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ } 7Aportis::Aportis() : peanutfile(false) { /*printf("constructing:%x\n",fin);*/ }
9 8
10void Aportis::dePeanut(int& ch) 9void 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
20CList<Bkmk>* Aportis::getbkmklist() 19CList<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
94int Aportis::OpenFile(const char *src) 93int 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
199 qDebug("Mobi image rec:%u", mobiimagerec); 198 qDebug("Mobi image rec:%u", mobiimagerec);
200 199
201 // this is the main record buffer 200 // this is the main record buffer
202 // it knows how to stretch to accomodate the decompress 201 // it knows how to stretch to accomodate the decompress
203 currentrec = 0; 202 currentrec = 0;
204 cbptr = 0; 203 cbptr = 0;
205 outptr = 0; 204 outptr = 0;
206 refreshbuffer(); 205 refreshbuffer();
207 if (!html) 206 if (!html)
208 { 207 {
209 int c; 208 int c;
210 char htmltag[] = "<HTML>"; 209 char htmltag[] = "<HTML>";
211 char *p = htmltag; 210 char *p = htmltag;
212 while (1) 211 while (1)
213 { 212 {
214 c = getch(); 213 c = getch();
215 char ch = *p++; 214 char ch = *p++;
216 if (ch == 0) 215 if (ch == 0)
217 { 216 {
218 html = true; 217 html = true;
219 break; 218 break;
220 } 219 }
221 if (c != ch) 220 if (c != ch)
222 { 221 {
223 html = false; 222 html = false;
224 break; 223 break;
225 } 224 }
226 } 225 }
227 currentrec = 0; 226 currentrec = 0;
228 cbptr = 0; 227 cbptr = 0;
229 outptr = 0; 228 outptr = 0;
230 refreshbuffer(); 229 refreshbuffer();
231 } 230 }
232 /* 231 /*
233 for (int i = 0; i < nRecs2; i++) 232 for (int i = 0; i < nRecs2; i++)
234 { 233 {
235 qDebug("Record:%u - %u bytes at position %x", i, recordlength(i), recordpos(i)); 234 qDebug("Record:%u - %u bytes at position %x", i, recordlength(i), recordpos(i));
236 } 235 }
237 */ 236 */
238 237
239 qDebug("Number of records:[%u,%u]", nRecs, nRecs2); 238 qDebug("Number of records:[%u,%u]", nRecs, nRecs2);
240 return ret; 239 return ret;
241} 240}
242 241
243int Aportis::getch() 242int Aportis::getch()
244{ 243{
245 if (bCompressed == 1) 244 if (bCompressed == 1)
246 { 245 {
247 if ((dwRecLen == 0) && !refreshbuffer()) return EOF; 246 if ((dwRecLen == 0) && !refreshbuffer()) return EOF;
248 else 247 else
249 { 248 {
250 int c = getc(fin); 249 int c = getc(fin);
251 dePeanut(c); 250 dePeanut(c);
252 dwRecLen--; 251 dwRecLen--;
253 currentpos++; 252 currentpos++;
254 return c; 253 return c;
255 } 254 }
256 } 255 }
257 if (outptr != cbptr) 256 if (outptr != cbptr)
258 { 257 {
259 currentpos++; 258 currentpos++;
260 return (circbuf[outptr = (outptr + 1) % 2048]); 259 return (circbuf[outptr = (outptr + 1) % 2048]);
261 } 260 }
262 if ((dwRecLen == 0) && !refreshbuffer()) return EOF; 261 if ((dwRecLen == 0) && !refreshbuffer()) return EOF;
263 currentpos++; 262 currentpos++;
264 int c; 263 int c;
265 264
266 // take a char from the input buffer 265 // take a char from the input buffer
267 c = getc(fin); 266 c = getc(fin);
268 dePeanut(c); 267 dePeanut(c);
269 dwRecLen--; 268 dwRecLen--;
270 // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF 269 // separate the char into zones: 0, 1...8, 9...0x7F, 0x80...0xBF, 0xC0...0xFF
271 270
272 // codes 1...8 mean copy that many chars; for accented chars & binary 271 // codes 1...8 mean copy that many chars; for accented chars & binary
273 if (c == 0) 272 if (c == 0)
274 { 273 {
275 circbuf[outptr = cbptr = (cbptr+1)%2048] = c; 274 circbuf[outptr = cbptr = (cbptr+1)%2048] = c;
276 return c; 275 return c;
277 } 276 }
278 else if (c >= 0x09 && c <= 0x7F) 277 else if (c >= 0x09 && c <= 0x7F)
279 { 278 {
280 circbuf[outptr = cbptr = (cbptr+1)%2048] = c; 279 circbuf[outptr = cbptr = (cbptr+1)%2048] = c;
281 return c; 280 return c;
282 } 281 }
283 else if (c >= 0x01 && c <= 0x08) 282 else if (c >= 0x01 && c <= 0x08)
284 { 283 {
285 dwRecLen -= c; 284 dwRecLen -= c;
286 while(c--) 285 while(c--)
287 { 286 {
288 int c = getc(fin); 287 int c = getc(fin);
289 dePeanut(c); 288 dePeanut(c);
290 circbuf[cbptr = (cbptr+1)%2048] = c; 289 circbuf[cbptr = (cbptr+1)%2048] = c;
291 } 290 }
292 return circbuf[outptr = (outptr+1)%2048]; 291 return circbuf[outptr = (outptr+1)%2048];
293 } 292 }
294 else if (c >= 0x80 && c <= 0xBF) 293 else if (c >= 0x80 && c <= 0xBF)
295 { 294 {
296 int m,n; 295 int m,n;
297 c <<= 8; 296 c <<= 8;
298 int c1 = getc(fin); 297 int c1 = getc(fin);
299 dePeanut(c1); 298 dePeanut(c1);
300 c += c1; 299 c += c1;
301 dwRecLen--; 300 dwRecLen--;
302 m = (c & 0x3FFF) >> COUNT_BITS; 301 m = (c & 0x3FFF) >> COUNT_BITS;
303 n = c & ((1<<COUNT_BITS) - 1); 302 n = c & ((1<<COUNT_BITS) - 1);
304 n += 3; 303 n += 3;
305 while (n--) 304 while (n--)
306 { 305 {
307 cbptr = (cbptr+1)%2048; 306 cbptr = (cbptr+1)%2048;
308 circbuf[cbptr] = circbuf[(cbptr+2048-m)%2048]; 307 circbuf[cbptr] = circbuf[(cbptr+2048-m)%2048];
309 } 308 }
310 return circbuf[outptr = (outptr+1)%2048]; 309 return circbuf[outptr = (outptr+1)%2048];
311 } 310 }
312 else if (c >= 0xC0 && c <= 0xFF) 311 else if (c >= 0xC0 && c <= 0xFF)
313 { 312 {
314 circbuf[cbptr = (cbptr+1)%2048] = ' '; 313 circbuf[cbptr = (cbptr+1)%2048] = ' ';
315 circbuf[cbptr = (cbptr+1)%2048] = c^0x80; 314 circbuf[cbptr = (cbptr+1)%2048] = c^0x80;
316 return circbuf[outptr = (outptr+1)%2048]; 315 return circbuf[outptr = (outptr+1)%2048];
317 } 316 }
318} 317}
319 318
320unsigned int Aportis::GetBS(unsigned int bn) 319unsigned int Aportis::GetBS(unsigned int bn)
321{ 320{
322 DWORD dwPos; 321 DWORD dwPos;
323 WORD fs; 322 WORD fs;
324 323
325 fseek(fin, 0x56 + 8*bn, SEEK_SET); 324 fseek(fin, 0x56 + 8*bn, SEEK_SET);
326 fread(&dwPos, 4, 1, fin); 325 fread(&dwPos, 4, 1, fin);
327 dwPos = SwapLong(dwPos); 326 dwPos = SwapLong(dwPos);
328 fseek(fin,dwPos,SEEK_SET); 327 fseek(fin,dwPos,SEEK_SET);
329 328
330// gotorecordnumber(bn+1); 329// gotorecordnumber(bn+1);
331 unsigned char ch; 330 unsigned char ch;
332 fread(&ch,1,1,fin); 331 fread(&ch,1,1,fin);
333 if (ch == 241) 332 if (ch == 241)
334 { 333 {
335 fread(&fs,sizeof(fs),1,fin); 334 fread(&fs,sizeof(fs),1,fin);
336 fs = SwapWord(fs); 335 fs = SwapWord(fs);
337 } 336 }
338 else 337 else
339 fs = 0; 338 fs = 0;
340 return fs; 339 return fs;
341} 340}
342 341
343unsigned int Aportis::locate() 342unsigned int Aportis::locate()
344{ 343{
345 if (bCompressed == 4) 344 if (bCompressed == 4)
346 { 345 {
347 size_t cur = ftell(fin); 346 size_t cur = ftell(fin);
348 unsigned int clen = 0; 347 unsigned int clen = 0;
349 for (unsigned int i = 0; i < currentrec-1; i++) 348 for (unsigned int i = 0; i < currentrec-1; i++)
350 { 349 {
351 unsigned int bs = GetBS(i); 350 unsigned int bs = GetBS(i);
352 if (bs == 0) break; 351 if (bs == 0) break;
353 clen += bs; 352 clen += bs;
354 } 353 }
355 fseek(fin,cur,SEEK_SET); 354 fseek(fin,cur,SEEK_SET);
356 return clen+currentpos; 355 return clen+currentpos;
357 } 356 }
358 else 357 else
359 return (currentrec-1)*BlockSize+currentpos; 358 return (currentrec-1)*BlockSize+currentpos;
360} 359}
361 360
362void Aportis::locate(unsigned int n) 361void Aportis::locate(unsigned int n)
363{ 362{
364 unsigned int offset; 363 unsigned int offset;
365 // currentrec = (n >> OFFBITS); 364 // currentrec = (n >> OFFBITS);
366 switch (bCompressed) 365 switch (bCompressed)
367 { 366 {
368 case 4: 367 case 4:
369 { 368 {
370 DWORD clen = 0; 369 DWORD clen = 0;
371 offset = n; 370 offset = n;
372 unsigned int i; 371 unsigned int i;
373 for (i = 0; i < nRecs; i++) 372 for (i = 0; i < nRecs; i++)
374 { 373 {
375 unsigned int bs = GetBS(i); 374 unsigned int bs = GetBS(i);
376 if (bs == 0) break; 375 if (bs == 0) break;
377 clen += bs; 376 clen += bs;
378 if (clen > n) break; 377 if (clen > n) break;
379 offset = n - clen; 378 offset = n - clen;
380 } 379 }
381 currentrec = i; 380 currentrec = i;
382 } 381 }
383 break; 382 break;
384 case 1: 383 case 1:
385 case 2: 384 case 2:
386 default: 385 default:
387 currentrec = n / BlockSize; 386 currentrec = n / BlockSize;
388 offset = n % BlockSize; 387 offset = n % BlockSize;
389 } 388 }
390 389
391 outptr = cbptr; 390 outptr = cbptr;
392 refreshbuffer(); 391 refreshbuffer();
393 while (currentpos < offset && getch() != EOF); 392 while (currentpos < offset && getch() != EOF);
394} 393}
395 394
396bool Aportis::refreshbuffer() 395bool Aportis::refreshbuffer()
397{ 396{
398 if (currentrec < nRecs) 397 if (currentrec < nRecs)
399 { 398 {
400 dwRecLen = recordlength(currentrec+1); 399 dwRecLen = recordlength(currentrec+1);
401 gotorecordnumber(currentrec+1); 400 gotorecordnumber(currentrec+1);
402 if (bCompressed == 4) 401 if (bCompressed == 4)
403 { 402 {
404 unsigned char t[3]; 403 unsigned char t[3];
405 fread(t,1,3,fin); 404 fread(t,1,3,fin);
406 if (t[0] != 241) 405 if (t[0] != 241)
407 { 406 {
408 printf("You shouldn't be here!\n"); 407 printf("You shouldn't be here!\n");
409 return false; 408 return false;
410 } 409 }
411 dwRecLen -= 3; 410 dwRecLen -= 3;
412 } 411 }
413 /* 412 /*
414 int n = fread(t.buf, 1, dwRecLen, fin); 413 int n = fread(t.buf, 1, dwRecLen, fin);
415 t.len = n; 414 t.len = n;
416 // if(bCompressed) 415 // if(bCompressed)
417 t.Decompress(); 416 t.Decompress();
418 417
419 t.buf[t.Len()] = '\0'; 418 t.buf[t.Len()] = '\0';
420 */ 419 */
421 currentpos = 0; 420 currentpos = 0;
422 currentrec++; 421 currentrec++;
423 return true; 422 return true;
424 } 423 }
425 else { 424 else {
426 return false; 425 return false;
427 } 426 }
428} 427}
429 428
430#include <qimage.h> 429#include <qimage.h>
431 430
432QImage* Aportis::getPicture(unsigned long tgt) 431QImage* Aportis::getPicture(unsigned long tgt)
433{ 432{
434 unsigned short tgtrec = tgt+mobiimagerec; 433 unsigned short tgtrec = tgt+mobiimagerec;
435 if (tgtrec > nRecs2) return NULL; 434 if (tgtrec > nRecs2) return NULL;
436 size_t cur = ftell(fin); 435 size_t cur = ftell(fin);
437 unsigned short reclen = recordlength(tgtrec); 436 unsigned short reclen = recordlength(tgtrec);
438 gotorecordnumber(tgtrec); 437 gotorecordnumber(tgtrec);
439 UInt8* imgbuffer = new UInt8[reclen]; 438 UInt8* imgbuffer = new UInt8[reclen];
440 fread(imgbuffer, 1, reclen, fin); 439 fread(imgbuffer, 1, reclen, fin);
441 QByteArray arr; 440 QByteArray arr;
442 arr.assign((const char*)imgbuffer, reclen); 441 arr.assign((const char*)imgbuffer, reclen);
443 442
444 QImage* qimage = new QImage(arr); 443 QImage* qimage = new QImage(arr);
445 fseek(fin, cur, SEEK_SET); 444 fseek(fin, cur, SEEK_SET);
446 445
447 return qimage; 446 return qimage;
448} 447}
449 448
450#ifndef __STATIC 449#ifndef __STATIC
451extern "C" 450extern "C"
452{ 451{
453 CExpander* newcodec() { return new Aportis; } 452 CExpander* newcodec() { return new Aportis; }
454} 453}
455#endif 454#endif
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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
25LIBS += -lreader_pdb -lreader_codec 24LIBS += -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
30include ( $(OPIEDIR)/include.pro ) \ No newline at end of file 29include ( $(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,710 +1,708 @@
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
29linkType BuffDoc::hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) 27linkType 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
50void BuffDoc::locate(unsigned int n) 48void 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
65static bool isletter(unsigned short c) 63static 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
74static bool isvowel(unsigned short c) // Only want lower case vowels 72static 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
126inline bool isconsonant(unsigned short c) 124inline 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
147bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder, bool hyphenate, int availht) 145bool 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 }
200 laststartline = exp->locate(); 198 laststartline = exp->locate();
201 break; 199 break;
202 } 200 }
203 if (ch == 10) 201 if (ch == 10)
204 { 202 {
205 buff->setendpara(cs); 203 buff->setendpara(cs);
206 lastispara = true; 204 lastispara = true;
207 laststartline = exp->locate(); 205 laststartline = exp->locate();
208 break; 206 break;
209 } 207 }
210 if (ch == 6) 208 if (ch == 6)
211 { 209 {
212 buff->setendpara(cs); 210 buff->setendpara(cs);
213 buff->setBop(); 211 buff->setBop();
214 lastispara = true; 212 lastispara = true;
215 laststartline = exp->locate(); 213 laststartline = exp->locate();
216 break; 214 break;
217 } 215 }
218 lastispara = false; 216 lastispara = false;
219 buff->addch(ch, cs); 217 buff->addch(ch, cs);
220 if (ch == ' ') 218 if (ch == ' ')
221 { 219 {
222 nospaces++; 220 nospaces++;
223 } 221 }
224 len++; 222 len++;
225 if (!margindone) 223 if (!margindone)
226 { 224 {
227 w -= buff->leftMargin() + buff->rightMargin(); 225 w -= buff->leftMargin() + buff->rightMargin();
228 margindone = true; 226 margindone = true;
229 } 227 }
230#ifdef INCREMENTALWIDTH 228#ifdef INCREMENTALWIDTH
231 if ((slen += buff->charwidth(len-1, cs)) > w) 229 if ((slen += buff->charwidth(len-1, cs)) > w)
232#else 230#else
233 if ((slen = buff->width(availht, len)) > w) 231 if ((slen = buff->width(availht, len)) > w)
234#endif 232#endif
235 { 233 {
236 if (ch == ' ' || len == 1) 234 if (ch == ' ' || len == 1)
237 { 235 {
238 if (ch == ' ') buff->truncate(len-1); 236 if (ch == ' ') buff->truncate(len-1);
239 laststartline = exp->locate(); 237 laststartline = exp->locate();
240 break; 238 break;
241 } 239 }
242 else // should do a backward search for spaces, first. 240 else // should do a backward search for spaces, first.
243 { 241 {
244 int lastk = len-4; 242 int lastk = len-4;
245 for (int i = len-2; i > 0; i--) 243 for (int i = len-2; i > 0; i--)
246 { 244 {
247 if ( 245 if (
248 (((*buff)[i] == 0x2014) && isletter((*buff)[i+1])) 246 (((*buff)[i] == 0x2014) && isletter((*buff)[i+1]))
249 || 247 ||
250 ((*buff)[i] == '-') 248 ((*buff)[i] == '-')
251 // ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-'))) 249 // ((*buff)[i] == '-' && !(((*buff)[i-1] == '-') || ((*buff)[i+1] == '-')))
252) 250)
253 { 251 {
254 (*buff)[len] = 0; 252 (*buff)[len] = 0;
255 lastword.setright(*buff, i+1); 253 lastword.setright(*buff, i+1);
256 buff->truncate(i+1); 254 buff->truncate(i+1);
257 (*buff)[i+1] = '\0'; 255 (*buff)[i+1] = '\0';
258 laststartline = lastsizes[i+1]; 256 laststartline = lastsizes[i+1];
259 // buff->resize(); 257 // buff->resize();
260 for (int j = 0; j < lastword.length(); j++) 258 for (int j = 0; j < lastword.length(); j++)
261 { 259 {
262 lastsizes[j] = lastsizes[j+i+1]; 260 lastsizes[j] = lastsizes[j+i+1];
263 } 261 }
264 return true; 262 return true;
265 } 263 }
266 264
267 //if (hyphenate && (m_hyphenthreshold+1)*i < m_hyphenthreshold*len) 265 //if (hyphenate && (m_hyphenthreshold+1)*i < m_hyphenthreshold*len)
268 // We end up with i+1 characters instead of len-1 266 // We end up with i+1 characters instead of len-1
269 // Thus we are removing len - 1 - (i + 1) = len-i-2 267 // Thus we are removing len - 1 - (i + 1) = len-i-2
270 // The space characters will be stretched to cover 268 // The space characters will be stretched to cover
271 // nospaces to nospaces + len - i - 2 269 // nospaces to nospaces + len - i - 2
272 // The stretch factor is hence 270 // The stretch factor is hence
273 // (nospaces+len-i-2)/nospaces 271 // (nospaces+len-i-2)/nospaces
274 if (hyphenate && !isCentred && ( 100*(nospaces+len-i-2) > (100+m_hyphenthreshold)*nospaces )) 272 if (hyphenate && !isCentred && ( 100*(nospaces+len-i-2) > (100+m_hyphenthreshold)*nospaces ))
275 { 273 {
276 /* 274 /*
277 if (m_customhyphen) 275 if (m_customhyphen)
278 { 276 {
279 for (int k = lastk; k >= i && k >= 2; k--) 277 for (int k = lastk; k >= i && k >= 2; k--)
280 { 278 {
281 if ( 279 if (
282 isletter((*buff)[k+3]) 280 isletter((*buff)[k+3])
283 && 281 &&
284 isletter((*buff)[k+2]) 282 isletter((*buff)[k+2])
285 && 283 &&
286 isvowel((*buff)[k+1]) 284 isvowel((*buff)[k+1])
287 && 285 &&
288 isconsonant((*buff)[k]) 286 isconsonant((*buff)[k])
289 && 287 &&
290 isletter((*buff)[k-1]) 288 isletter((*buff)[k-1])
291 && 289 &&
292 isletter((*buff)[k-2]) 290 isletter((*buff)[k-2])
293 ) 291 )
294 { 292 {
295 (*buff)[len] = 0; 293 (*buff)[len] = 0;
296 lastword.setright(*buff, k+1); 294 lastword.setright(*buff, k+1);
297 buff->truncate(k+2); 295 buff->truncate(k+2);
298 (*buff)[k+1] = '-'; 296 (*buff)[k+1] = '-';
299 (*buff)[k+2] = '\0'; 297 (*buff)[k+2] = '\0';
300 laststartline = lastsizes[k+1]; 298 laststartline = lastsizes[k+1];
301 buff->resize(); 299 buff->resize();
302 for (int j = 0; j < lastword.length(); j++) 300 for (int j = 0; j < lastword.length(); j++)
303 { 301 {
304 lastsizes[j] = lastsizes[j+k+1]; 302 lastsizes[j] = lastsizes[j+k+1];
305 } 303 }
306 return true; 304 return true;
307 } 305 }
308 } 306 }
309 } 307 }
310 else 308 else
311 */ 309 */
312 { 310 {
313 for (int k = lastk; k >= i && k >= 1; k--) 311 for (int k = lastk; k >= i && k >= 1; k--)
314 { 312 {
315 if ( 313 if (
316 /* 314 /*
317 ( 315 (
318 k < len-3 316 k < len-3
319 && 317 &&
320 k >= 1 318 k >= 1
321 && 319 &&
322 isletter((*buff)[k+3]) 320 isletter((*buff)[k+3])
323 && 321 &&
324 isletter((*buff)[k+2]) 322 isletter((*buff)[k+2])
325 && 323 &&
326 isconsonant((*buff)[k+1]) 324 isconsonant((*buff)[k+1])
327 && 325 &&
328 ((*buff)[k+1] != 'y') 326 ((*buff)[k+1] != 'y')
329 && 327 &&
330 ((*buff)[k+1] != 'h') 328 ((*buff)[k+1] != 'h')
331 && 329 &&
332 isconsonant((*buff)[k]) 330 isconsonant((*buff)[k])
333 && 331 &&
334 ((*buff)[k] != 'h') 332 ((*buff)[k] != 'h')
335 && 333 &&
336 isletter((*buff)[k-1]) 334 isletter((*buff)[k-1])
337 ) 335 )
338 || 336 ||
339 */ 337 */
340 ( 338 (
341 isletter((*buff)[k+3]) 339 isletter((*buff)[k+3])
342 && 340 &&
343 isletter((*buff)[k+2]) 341 isletter((*buff)[k+2])
344 && 342 &&
345 isconsonant((*buff)[k+1]) 343 isconsonant((*buff)[k+1])
346 && 344 &&
347 ((*buff)[k+1] != 'y') 345 ((*buff)[k+1] != 'y')
348 && 346 &&
349 isletter((*buff)[k]) 347 isletter((*buff)[k])
350 && 348 &&
351 ((*buff)[k] != 'h') 349 ((*buff)[k] != 'h')
352 && 350 &&
353 isletter((*buff)[k-1]) 351 isletter((*buff)[k-1])
354 && // Do not hyphenate when the first part ends with a vowel, 352 && // Do not hyphenate when the first part ends with a vowel,
355 // and the second starts with the two consonants. 353 // and the second starts with the two consonants.
356 // Examples: "co-nsona-nts" -> "con-sonants", 354 // Examples: "co-nsona-nts" -> "con-sonants",
357 // "hy-phenation" -> "hyp-henation" etc. 355 // "hy-phenation" -> "hyp-henation" etc.
358 !( isvowel( (*buff)[k] ) && isconsonant( (*buff)[k+2] ) ) 356 !( isvowel( (*buff)[k] ) && isconsonant( (*buff)[k+2] ) )
359 ) 357 )
360 ) 358 )
361 { 359 {
362 (*buff)[len] = 0; 360 (*buff)[len] = 0;
363 lastword.setright(*buff, k+1); 361 lastword.setright(*buff, k+1);
364 buff->truncate(k+2); 362 buff->truncate(k+2);
365 (*buff)[k+1] = '-'; 363 (*buff)[k+1] = '-';
366 (*buff)[k+2] = '\0'; 364 (*buff)[k+2] = '\0';
367 laststartline = lastsizes[k+1]; 365 laststartline = lastsizes[k+1];
368 // buff->resize(); 366 // buff->resize();
369 for (int j = 0; j < lastword.length(); j++) 367 for (int j = 0; j < lastword.length(); j++)
370 { 368 {
371 lastsizes[j] = lastsizes[j+k+1]; 369 lastsizes[j] = lastsizes[j+k+1];
372 } 370 }
373 return true; 371 return true;
374 } 372 }
375 } 373 }
376 } 374 }
377 lastk = i; 375 lastk = i;
378 } 376 }
379 if ((*buff)[i] == ' ') 377 if ((*buff)[i] == ' ')
380 { 378 {
381 (*buff)[len] = 0; 379 (*buff)[len] = 0;
382 lastword.setright(*buff, i+1); 380 lastword.setright(*buff, i+1);
383 buff->truncate(i); 381 buff->truncate(i);
384 (*buff)[i] = '\0'; 382 (*buff)[i] = '\0';
385 laststartline = lastsizes[i+1]; 383 laststartline = lastsizes[i+1];
386 // buff->resize(); 384 // buff->resize();
387 for (int j = 0; j < lastword.length(); j++) 385 for (int j = 0; j < lastword.length(); j++)
388 { 386 {
389 lastsizes[j] = lastsizes[j+i+1]; 387 lastsizes[j] = lastsizes[j+i+1];
390 } 388 }
391 return true; 389 return true;
392 } 390 }
393 } 391 }
394 laststartline = lastsizes[len-1]; 392 laststartline = lastsizes[len-1];
395 (*buff)[len] = 0; 393 (*buff)[len] = 0;
396 lastword.setright(*buff, len - 1); 394 lastword.setright(*buff, len - 1);
397 buff->truncate(len-1); 395 buff->truncate(len-1);
398 buff->addch('-', cs); 396 buff->addch('-', cs);
399 for (int j = 0; j < lastword.length(); j++) 397 for (int j = 0; j < lastword.length(); j++)
400 { 398 {
401 lastsizes[j] = lastsizes[j+len]; 399 lastsizes[j] = lastsizes[j+len];
402 } 400 }
403 break; 401 break;
404 } 402 }
405 } 403 }
406 } 404 }
407 (*buff)[len] = '\0'; 405 (*buff)[len] = '\0';
408 // buff->resize(); 406 // buff->resize();
409 return moreleft; 407 return moreleft;
410} 408}
411#else 409#else
412bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder) 410bool BuffDoc::getline(CDrawBuffer* buff, int wth, unsigned short _lborder, unsigned short _rborder)
413{ 411{
414 bool margindone = false; 412 bool margindone = false;
415 int w = wth-(_lborder+_rborder); 413 int w = wth-(_lborder+_rborder);
416 tchar ch = 32; 414 tchar ch = 32;
417 CStyle cs; 415 CStyle cs;
418 buff->empty(); 416 buff->empty();
419 if (exp == NULL) 417 if (exp == NULL)
420 { 418 {
421 //(*buff)[0] = '\0'; 419 //(*buff)[0] = '\0';
422 buff->empty(); 420 buff->empty();
423 return false; 421 return false;
424 } 422 }
425 int len = 0, lastcheck = 0; 423 int len = 0, lastcheck = 0;
426 if (lastword.length() > 0) 424 if (lastword.length() > 0)
427 { 425 {
428 *buff = lastword; 426 *buff = lastword;
429 cs = lastword.laststyle(); 427 cs = lastword.laststyle();
430 w -= buff->leftMargin() + buff->rightMargin(); 428 w -= buff->leftMargin() + buff->rightMargin();
431 margindone = true; 429 margindone = true;
432 } 430 }
433 else buff->empty(); 431 else buff->empty();
434// //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data())); 432// //qDebug("Buff:%s Lastword:%s", (const char*)toQString(buff->data()), (const char*)toQString(lastword.data()));
435 lastcheck = len = buff->length(); 433 lastcheck = len = buff->length();
436 unsigned int slen = buff->width(availht, len); 434 unsigned int slen = buff->width(availht, len);
437 if (slen > w) 435 if (slen > w)
438 { 436 {
439 for ( ; len > 1; len--) 437 for ( ; len > 1; len--)
440 { 438 {
441 if (buff->width(availht, len) < w) break; 439 if (buff->width(availht, len) < w) break;
442 } 440 }
443// lastword = buff->data() + len - 1; 441// lastword = buff->data() + len - 1;
444 laststartline = lastsizes[len-1]; 442 laststartline = lastsizes[len-1];
445 for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1]; 443 for (int i = 0; i < buff->length(); i++) lastsizes[i] = lastsizes[i+len-1];
446// (*buff)[len-1] = '-'; 444// (*buff)[len-1] = '-';
447 if (len > 2) 445 if (len > 2)
448 { 446 {
449 lastword.setright(*buff, len - 1); 447 lastword.setright(*buff, len - 1);
450 buff->truncate(len-1); 448 buff->truncate(len-1);
451 buff->addch('-', cs); 449 buff->addch('-', cs);
452 (*buff)[len] = '\0'; 450 (*buff)[len] = '\0';
453 } 451 }
454 452
455 else 453 else
456 { 454 {
457 lastword.empty(); 455 lastword.empty();
458 (*buff)[len] = '\0'; 456 (*buff)[len] = '\0';
459 } 457 }
460 // buff->resize(); 458 // buff->resize();
461 return true; 459 return true;
462 } 460 }
463 if (lastispara) 461 if (lastispara)
464 { 462 {
465 lastispara = false; 463 lastispara = false;
466// lastword[0] = '\0'; 464// lastword[0] = '\0';
467 lastword.empty(); 465 lastword.empty();
468 len = buff->length(); 466 len = buff->length();
469 while (buff->width(availht, len) > w) len--; 467 while (buff->width(availht, len) > w) len--;
470// (*buff)[len] = '\0'; 468// (*buff)[len] = '\0';
471 buff->truncate(len); 469 buff->truncate(len);
472 laststartline = exp->locate(); 470 laststartline = exp->locate();
473 // buff->resize(); 471 // buff->resize();
474 return true; 472 return true;
475 } 473 }
476 lastispara = false; 474 lastispara = false;
477 for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i]; 475 for (int i = 0; i < len; i++) allsizes[i] = lastsizes[i];
478 while (slen < w) 476 while (slen < w)
479 { 477 {
480 lastcheck = len; 478 lastcheck = len;
481 getch(ch, cs, allsizes[len]); 479 getch(ch, cs, allsizes[len]);
482 while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128) 480 while (ch != ' ' && ch != '\012' && ch != UEOF && len < 128)
483 { 481 {
484 len++; 482 len++;
485 buff->addch(ch,cs); 483 buff->addch(ch,cs);
486 getch(ch, cs, allsizes[len]); 484 getch(ch, cs, allsizes[len]);
487 } 485 }
488 (*buff)[len] = 0; 486 (*buff)[len] = 0;
489 slen = buff->width(availht, len); 487 slen = buff->width(availht, len);
490 len++; 488 len++;
491 buff->addch(' ', cs); 489 buff->addch(' ', cs);
492 if (!margindone) 490 if (!margindone)
493 { 491 {
494 w -= buff->leftMargin() + buff->rightMargin(); 492 w -= buff->leftMargin() + buff->rightMargin();
495 margindone = true; 493 margindone = true;
496 } 494 }
497 allsizes[len] = exp->locate(); 495 allsizes[len] = exp->locate();
498 if (slen < w && ch != ' ') 496 if (slen < w && ch != ' ')
499 { 497 {
500 lastcheck = len; 498 lastcheck = len;
501 break; 499 break;
502 } 500 }
503 lastispara = (ch == '\012'); 501 lastispara = (ch == '\012');
504 } 502 }
505 (*buff)[len] = '\0'; 503 (*buff)[len] = '\0';
506// lastword = buff->data()+lastcheck; 504// lastword = buff->data()+lastcheck;
507#ifdef _WINDOWS 505#ifdef _WINDOWS
508 lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); 506 lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1);
509 { 507 {
510 int i; 508 int i;
511 for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; 509 for (i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck];
512 } 510 }
513#else 511#else
514 lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1); 512 lastword.setright(*buff, (lastcheck > 0) ? lastcheck : 1);
515 for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck]; 513 for (int i = 0; i < lastword.length(); i++) lastsizes[i] = allsizes[i+lastcheck];
516#endif 514#endif
517 if (lastcheck > 0) 515 if (lastcheck > 0)
518 { 516 {
519 laststartline = allsizes[lastcheck]; 517 laststartline = allsizes[lastcheck];
520// (*buff)[lastcheck-1] = '\0'; 518// (*buff)[lastcheck-1] = '\0';
521 buff->truncate(lastcheck-1); 519 buff->truncate(lastcheck-1);
522 } 520 }
523 else 521 else
524 { 522 {
525 laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1]; 523 laststartline = (lastcheck == len) ? exp->locate() : allsizes[lastcheck+1];
526// (*buff)[lastcheck] = '\0'; 524// (*buff)[lastcheck] = '\0';
527 buff->truncate(lastcheck); 525 buff->truncate(lastcheck);
528 } 526 }
529// buff->frig(); 527// buff->frig();
530// buff->resize(); 528// buff->resize();
531 if (ch == UEOF && buff->length() == 0) 529 if (ch == UEOF && buff->length() == 0)
532 { 530 {
533 buff->setEof(); 531 buff->setEof();
534 return false; 532 return false;
535 } 533 }
536 return true; 534 return true;
537} 535}
538#endif 536#endif
539 537
540bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned short _lborder, unsigned short _rborder, int availht) 538bool BuffDoc::getline(CDrawBuffer* buff, int wth, int cw, unsigned short _lborder, unsigned short _rborder, int availht)
541{ 539{
542 int w = wth-(_lborder+_rborder); 540 int w = wth-(_lborder+_rborder);
543 buff->empty(); 541 buff->empty();
544 if (exp == NULL) 542 if (exp == NULL)
545 { 543 {
546 return false; 544 return false;
547 } 545 }
548 tchar ch; 546 tchar ch;
549 CStyle cs; 547 CStyle cs;
550 int i = 1; 548 int i = 1;
551 int offset = buff->offset(w,0,0,availht); 549 int offset = buff->offset(w,0,0,availht);
552 while (i*cw < w-offset) 550 while (i*cw < w-offset)
553 { 551 {
554 unsigned long dummy; 552 unsigned long dummy;
555 getch(ch, cs, dummy); 553 getch(ch, cs, dummy);
556 if (ch == '\12' || ch == UEOF) break; 554 if (ch == '\12' || ch == UEOF) break;
557 buff->addch(ch,cs); 555 buff->addch(ch,cs);
558 i++; 556 i++;
559 } 557 }
560 buff->truncate(i); 558 buff->truncate(i);
561 laststartline = exp->locate(); 559 laststartline = exp->locate();
562 // buff->resize(); 560 // buff->resize();
563 return (ch != UEOF); 561 return (ch != UEOF);
564} 562}
565 563
566int BuffDoc::openfile(QWidget* _parent, const char *src) 564int BuffDoc::openfile(QWidget* _parent, const char *src)
567{ 565{
568 if (exp != NULL) delete exp; 566 if (exp != NULL) delete exp;
569 exp = NULL; 567 exp = NULL;
570 568
571#ifdef __STATIC 569#ifdef __STATIC
572 exp = new Aportis; 570 exp = new Aportis;
573 int ret = exp->openfile(src); 571 int ret = exp->openfile(src);
574 if (ret == -1) 572 if (ret == -1)
575 { 573 {
576 delete exp; 574 delete exp;
577 exp = NULL; 575 exp = NULL;
578 return ret; 576 return ret;
579 } 577 }
580 if (ret == -2) 578 if (ret == -2)
581 { 579 {
582 580
583 delete exp; 581 delete exp;
584 exp = new ztxt; 582 exp = new ztxt;
585 ret = exp->openfile(src); 583 ret = exp->openfile(src);
586 } 584 }
587 /* 585 /*
588 } 586 }
589 if (ret != 0) 587 if (ret != 0)
590 { 588 {
591 delete exp; 589 delete exp;
592 exp = new ebookcodec("Aportis"); 590 exp = new ebookcodec("Aportis");
593 ret = exp->openfile(src); 591 ret = exp->openfile(src);
594 if (ret == 0) qDebug("Aportis format"); 592 if (ret == 0) qDebug("Aportis format");
595 } 593 }
596 */ 594 */
597#ifdef USENEF 595#ifdef USENEF
598 if (ret != 0) 596 if (ret != 0)
599 { 597 {
600 598
601 delete exp; 599 delete exp;
602 exp = new CArriere; 600 exp = new CArriere;
603 ret = exp->openfile(src); 601 ret = exp->openfile(src);
604 if (ret == 0) qDebug("Arriere format"); 602 if (ret == 0) qDebug("Arriere format");
605 } 603 }
606 if (ret != 0) 604 if (ret != 0)
607 { 605 {
608 606
609 delete exp; 607 delete exp;
610 exp = new CNEF; 608 exp = new CNEF;
611 ret = exp->openfile(src); 609 ret = exp->openfile(src);
612 if (ret == 0) qDebug("NEF format"); 610 if (ret == 0) qDebug("NEF format");
613 } 611 }
614#endif 612#endif
615 if (ret != 0) 613 if (ret != 0)
616 { 614 {
617 615
618 delete exp; 616 delete exp;
619 exp = new CPlucker; 617 exp = new CPlucker;
620 ret = exp->openfile(src); 618 ret = exp->openfile(src);
621 } 619 }
622 if (ret != 0) 620 if (ret != 0)
623 { 621 {
624 622
625 delete exp; 623 delete exp;
626 exp = new CHM; 624 exp = new CHM;
627 ret = exp->openfile(src); 625 ret = exp->openfile(src);
628 } 626 }
629 if (ret != 0) 627 if (ret != 0)
630 { 628 {
631 629
632 delete exp; 630 delete exp;
633 exp = new iSilo; 631 exp = new iSilo;
634 ret = exp->openfile(src); 632 ret = exp->openfile(src);
635 } 633 }
636 if (ret != 0) 634 if (ret != 0)
637 { 635 {
638 delete exp; 636 delete exp;
639 //qDebug("Trying ppms"); 637 //qDebug("Trying ppms");
640 exp = new ppm_expander; 638 exp = new ppm_expander;
641 ret = exp->openfile(src); 639 ret = exp->openfile(src);
642 } 640 }
643 if (ret != 0) 641 if (ret != 0)
644 { 642 {
645 delete exp; 643 delete exp;
646 exp = new Text; 644 exp = new Text;
647 // //qDebug("Trying text"); 645 // //qDebug("Trying text");
648 ret = exp->openfile(src); 646 ret = exp->openfile(src);
649 if (ret == 0) qDebug("Text format"); 647 if (ret == 0) qDebug("Text format");
650 } 648 }
651 649
652 if (ret != 0) 650 if (ret != 0)
653 { 651 {
654 delete exp; 652 delete exp;
655 QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file"); 653 QMessageBox::information(_parent, PROGNAME, "Unknown file compression type","Try another file");
656 return ret; 654 return ret;
657 } 655 }
658 // //qDebug("Doing final open:%x:%x",exp,filt); 656 // //qDebug("Doing final open:%x:%x",exp,filt);
659#else 657#else
660 QString codecpath(QTReaderUtil::getPluginPath()); 658 QString codecpath(QTReaderUtil::getPluginPath());
661 QDir d(codecpath, "*.so"); 659 QDir d(codecpath, "*.so");
662 660
663 if (d.exists()) 661 if (d.exists())
664 { 662 {
665 663
666 const QFileInfoList *list = d.entryInfoList(); 664 const QFileInfoList *list = d.entryInfoList();
667 QFileInfoListIterator it( *list ); // create list iterator 665 QFileInfoListIterator it( *list ); // create list iterator
668 QFileInfo *fi; // pointer for traversing 666 QFileInfo *fi; // pointer for traversing
669 667
670 int ret = -1; 668 int ret = -1;
671 while ( ret != 0 && (fi=it.current()) ) 669 while ( ret != 0 && (fi=it.current()) )
672 { // for each file... 670 { // for each file...
673 if (exp != NULL) delete exp; 671 if (exp != NULL) delete exp;
674 qDebug("Trying %s", (const char*)fi->fileName()); 672 qDebug("Trying %s", (const char*)fi->fileName());
675 exp = new ebookcodec(fi->fileName()); 673 exp = new ebookcodec(fi->fileName());
676 ret = exp->openfile(src); 674 ret = exp->openfile(src);
677 ++it; 675 ++it;
678 } 676 }
679 qDebug("Buffdoc:Finished opening"); 677 qDebug("Buffdoc:Finished opening");
680 if (ret != 0) 678 if (ret != 0)
681 { 679 {
682 if (exp != NULL) delete exp; 680 if (exp != NULL) delete exp;
683 exp = new Text; 681 exp = new Text;
684 ret = exp->openfile(src); 682 ret = exp->openfile(src);
685 } 683 }
686 } 684 }
687 else 685 else
688 { 686 {
689 if (exp != NULL) delete exp; 687 if (exp != NULL) delete exp;
690 exp = new Text; 688 exp = new Text;
691 exp->openfile(src); 689 exp->openfile(src);
692 } 690 }
693#endif 691#endif
694 lastword.empty(); 692 lastword.empty();
695 lastsizes[0] = laststartline = 0; 693 lastsizes[0] = laststartline = 0;
696#ifdef NEWLINEBREAK 694#ifdef NEWLINEBREAK
697 lastispara = false; 695 lastispara = false;
698#else 696#else
699 lastispara = false; 697 lastispara = false;
700#endif 698#endif
701 exp->locate(exp->getHome()); 699 exp->locate(exp->getHome());
702 filt->setsource(exp); 700 filt->setsource(exp);
703 qDebug("BuffDoc:file opened"); 701 qDebug("BuffDoc:file opened");
704 return 0; 702 return 0;
705} 703}
706 704
707QString BuffDoc::about() 705QString BuffDoc::about()
708{ 706{
709 return QString("Buffered Decompressor (c) Tim Wentford\nHyphenation algorithm (c) Tim Wentford\n (Cyrillic support by Konstantin Isakov\n")+filt->about(); 707 return QString("Buffered Decompressor (c) Tim Wentford\nHyphenation algorithm (c) Tim Wentford\n (Cyrillic support by Konstantin Isakov\n")+filt->about();
710} 708}
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
11class BuffDoc 10class 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,775 +1,774 @@
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
9CDrawBuffer::~CDrawBuffer() 8CDrawBuffer::~CDrawBuffer()
10{ 9{
11 while (!segs.isEmpty()) segs.erase(0); 10 while (!segs.isEmpty()) segs.erase(0);
12} 11}
13 12
14void CDrawBuffer::setright(CDrawBuffer& rhs, int f) 13void 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
42CDrawBuffer& CDrawBuffer::operator=(CDrawBuffer& rhs) 41CDrawBuffer& 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
67CDrawBuffer& CDrawBuffer::operator=(const tchar*sztmp) 66CDrawBuffer& 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
81void CDrawBuffer::empty() 80void 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
97void CDrawBuffer::setendpara(const CStyle& _style/* = ucFontBase*/) 96void 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
107void CDrawBuffer::addch(tchar ch, CStyle _style/* = ucFontBase*/) 106void 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
121void CDrawBuffer::truncate(int n) 120void CDrawBuffer::truncate(int n)
122{ 121{
123 len = n; 122 len = n;
124 (*this)[n] = 0; 123 (*this)[n] = 0;
125} 124}
126 125
127int CDrawBuffer::width(int availht, int numchars, bool onscreen, int scwidth, unsigned short _lborder, unsigned short _rborder) 126int 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())
200 { 199 {
201 int cw = (7*fc->getsize(currentstyle))/10; 200 int cw = (7*fc->getsize(currentstyle))/10;
202 currentx += cw*(end-textstart->start); 201 currentx += cw*(end-textstart->start);
203 } 202 }
204 else 203 else
205 { 204 {
206 QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 205 QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
207 // f.setUnderline(currentstyle.isUnderline()); 206 // f.setUnderline(currentstyle.isUnderline());
208 QString str = text.mid(textstart->start, end-textstart->start); 207 QString str = text.mid(textstart->start, end-textstart->start);
209 QFontMetrics fm(f); 208 QFontMetrics fm(f);
210 if (just) 209 if (just)
211 { 210 {
212 int lastspace = -1; 211 int lastspace = -1;
213 int nsp = 0; 212 int nsp = 0;
214 int cx = currentx; 213 int cx = currentx;
215 while ((nsp = str.find(" ", lastspace+1)) >= 0) 214 while ((nsp = str.find(" ", lastspace+1)) >= 0)
216 { 215 {
217 if (nsp > nonspace) 216 if (nsp > nonspace)
218 { 217 {
219 spacenumber++; 218 spacenumber++;
220 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; 219 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
221 QString nstr = str.mid(lastspace+1, nsp-lastspace); 220 QString nstr = str.mid(lastspace+1, nsp-lastspace);
222 int lw = fm.width(nstr); 221 int lw = fm.width(nstr);
223 cx += lw+nexttoadd; 222 cx += lw+nexttoadd;
224 spacesofar += nexttoadd; 223 spacesofar += nexttoadd;
225 lastspace = nsp; 224 lastspace = nsp;
226 } 225 }
227 else 226 else
228 { 227 {
229 QString nstr = str.mid(lastspace+1, nsp-lastspace); 228 QString nstr = str.mid(lastspace+1, nsp-lastspace);
230 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); 229 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
231 int lw = fm.width(nstr); 230 int lw = fm.width(nstr);
232 cx += lw; 231 cx += lw;
233 lastspace = nsp; 232 lastspace = nsp;
234 } 233 }
235 } 234 }
236 QString nstr = str.right(str.length()-1-lastspace); 235 QString nstr = str.right(str.length()-1-lastspace);
237 cx += fm.width(nstr); 236 cx += fm.width(nstr);
238 currentx = cx; 237 currentx = cx;
239 } 238 }
240 else 239 else
241 { 240 {
242 currentx += fm.width(str); 241 currentx += fm.width(str);
243 } 242 }
244 } 243 }
245 } 244 }
246 textstart = textend; 245 textstart = textend;
247 } 246 }
248 while (textend != segs.end() && end != numchars && textstart->start < len); 247 while (textend != segs.end() && end != numchars && textstart->start < len);
249 return currentx; 248 return currentx;
250} 249}
251 250
252int CDrawBuffer::charwidth(int numchars, CStyle& currentstyle) 251int CDrawBuffer::charwidth(int numchars, CStyle& currentstyle)
253{ 252{
254 if (currentstyle.isPicture()) 253 if (currentstyle.isPicture())
255 { 254 {
256 int gzoom = fc->gzoom(); 255 int gzoom = fc->gzoom();
257 if (currentstyle.canScale()) 256 if (currentstyle.canScale())
258 { 257 {
259 return (gzoom*currentstyle.getPicture()->width())/100; 258 return (gzoom*currentstyle.getPicture()->width())/100;
260 } 259 }
261 else 260 else
262 { 261 {
263 return currentstyle.getPicture()->width(); 262 return currentstyle.getPicture()->width();
264 } 263 }
265 } 264 }
266 else 265 else
267 { 266 {
268 if (currentstyle.isMono() && !fc->hasCourier()) 267 if (currentstyle.isMono() && !fc->hasCourier())
269 { 268 {
270 return (7*fc->getsize(currentstyle))/10; 269 return (7*fc->getsize(currentstyle))/10;
271 } 270 }
272 else 271 else
273 { 272 {
274 QString text = QChar((data())[numchars]); 273 QString text = QChar((data())[numchars]);
275 QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 274 QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
276 // f.setUnderline(currentstyle.isUnderline()); 275 // f.setUnderline(currentstyle.isUnderline());
277 QFontMetrics fm(f); 276 QFontMetrics fm(f);
278 return fm.width(text); 277 return fm.width(text);
279 } 278 }
280 } 279 }
281 return 0; 280 return 0;
282} 281}
283 282
284int CDrawBuffer::charwidth(int numchars) 283int CDrawBuffer::charwidth(int numchars)
285{ 284{
286 int gzoom = fc->gzoom(); 285 int gzoom = fc->gzoom();
287 int end = 0; 286 int end = 0;
288 QString text = QChar((data())[numchars]); 287 QString text = QChar((data())[numchars]);
289 CList<textsegment>::iterator textstart = segs.begin(); 288 CList<textsegment>::iterator textstart = segs.begin();
290 CList<textsegment>::iterator textend = textstart; 289 CList<textsegment>::iterator textend = textstart;
291 do 290 do
292 { 291 {
293 textend++; 292 textend++;
294 end = (textend != segs.end()) ? textend->start : len; 293 end = (textend != segs.end()) ? textend->start : len;
295 if (end <= numchars) 294 if (end <= numchars)
296 { 295 {
297 textstart = textend; 296 textstart = textend;
298 continue; 297 continue;
299 } 298 }
300 if (numchars >= 0 && end > numchars) 299 if (numchars >= 0 && end > numchars)
301 { 300 {
302 end = numchars; 301 end = numchars;
303 } 302 }
304 CStyle currentstyle = textstart->style; 303 CStyle currentstyle = textstart->style;
305 if (currentstyle.isPicture()) 304 if (currentstyle.isPicture())
306 { 305 {
307 if (currentstyle.canScale()) 306 if (currentstyle.canScale())
308 { 307 {
309 return (gzoom*currentstyle.getPicture()->width())/100; 308 return (gzoom*currentstyle.getPicture()->width())/100;
310 } 309 }
311 else 310 else
312 { 311 {
313 return currentstyle.getPicture()->width(); 312 return currentstyle.getPicture()->width();
314 } 313 }
315 } 314 }
316 else 315 else
317 { 316 {
318 if (currentstyle.isMono() && !fc->hasCourier()) 317 if (currentstyle.isMono() && !fc->hasCourier())
319 { 318 {
320 return (7*fc->getsize(currentstyle))/10; 319 return (7*fc->getsize(currentstyle))/10;
321 } 320 }
322 else 321 else
323 { 322 {
324 QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 323 QFont f(currentstyle.isMono() ? QString(fc->fixedfontname()) : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
325 // f.setUnderline(currentstyle.isUnderline()); 324 // f.setUnderline(currentstyle.isUnderline());
326 QFontMetrics fm(f); 325 QFontMetrics fm(f);
327 return fm.width(text); 326 return fm.width(text);
328 } 327 }
329 } 328 }
330 textstart = textend; 329 textstart = textend;
331 } 330 }
332 while (textend != segs.end() /* && end != numchars*/ && textstart->start < len); 331 while (textend != segs.end() /* && end != numchars*/ && textstart->start < len);
333 return 0; 332 return 0;
334} 333}
335 334
336 335
337 336
338int CDrawBuffer::leftMargin() 337int CDrawBuffer::leftMargin()
339{ 338{
340 return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style)+3)/6; 339 return (segs.begin()->style.getLeftMargin()*fc->getsize(segs.begin()->style)+3)/6;
341} 340}
342 341
343int CDrawBuffer::rightMargin() 342int CDrawBuffer::rightMargin()
344{ 343{
345 return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style)+3)/6; 344 return (segs.begin()->style.getRightMargin()*fc->getsize(segs.begin()->style)+3)/6;
346} 345}
347 346
348int CDrawBuffer::offset(int scwidth, unsigned short _lborder, unsigned short _rborder, int availht) 347int CDrawBuffer::offset(int scwidth, unsigned short _lborder, unsigned short _rborder, int availht)
349{ 348{
350 int currentx = _lborder; 349 int currentx = _lborder;
351 switch(segs.begin()->style.getJustify()) 350 switch(segs.begin()->style.getJustify())
352 { 351 {
353 case m_AlignRight: 352 case m_AlignRight:
354 { 353 {
355 currentx = scwidth - _rborder - rightMargin() - width(availht); 354 currentx = scwidth - _rborder - rightMargin() - width(availht);
356 } 355 }
357 break; 356 break;
358 case m_AlignCentre: 357 case m_AlignCentre:
359 { 358 {
360 currentx = ( 359 currentx = (
361 scwidth - _lborder -_rborder + 360 scwidth - _lborder -_rborder +
362 leftMargin() - rightMargin() 361 leftMargin() - rightMargin()
363 - width(availht))/2 + _lborder; 362 - width(availht))/2 + _lborder;
364 } 363 }
365 break; 364 break;
366 case m_AlignJustify: 365 case m_AlignJustify:
367 case m_AlignLeft: 366 case m_AlignLeft:
368 currentx = _lborder + leftMargin(); 367 currentx = _lborder + leftMargin();
369 break; 368 break;
370 } 369 }
371 return currentx; 370 return currentx;
372} 371}
373 372
374void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned short _lborder, unsigned short _rborder, const QColor& _bg, int availht) 373void CDrawBuffer::render(QPainter* _p, int _y, bool _bMono, int _charWidth, int scwidth, unsigned short _lborder, unsigned short _rborder, const QColor& _bg, int availht)
375{ 374{
376 CList<textsegment>::iterator textstart = segs.begin(); 375 CList<textsegment>::iterator textstart = segs.begin();
377 QColor paperColour = QColor(qRgb(textstart->style.pRed(), 376 QColor paperColour = QColor(qRgb(textstart->style.pRed(),
378 textstart->style.pGreen(), 377 textstart->style.pGreen(),
379 textstart->style.pBlue())); 378 textstart->style.pBlue()));
380 379
381 Highlight(_p, !(paperColour == _bg), _lborder, _y, scwidth-(_lborder+_rborder), paperColour); 380 Highlight(_p, !(paperColour == _bg), _lborder, _y, scwidth-(_lborder+_rborder), paperColour);
382 // Highlight(_p, true, _lborder, _y, scwidth-(_lborder+_rborder), paperColour); 381 // Highlight(_p, true, _lborder, _y, scwidth-(_lborder+_rborder), paperColour);
383 int gzoom = fc->gzoom(); 382 int gzoom = fc->gzoom();
384 int currentx = offset(scwidth, _lborder, _rborder, availht); 383 int currentx = offset(scwidth, _lborder, _rborder, availht);
385 if (!m_hastext) 384 if (!m_hastext)
386 { 385 {
387 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++) 386 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end(); iter++)
388 { 387 {
389 CStyle currentstyle = iter->style; 388 CStyle currentstyle = iter->style;
390 if (currentstyle.isPicture()) 389 if (currentstyle.isPicture())
391 { 390 {
392 CStyle currentstyle = segs.begin()->style; 391 CStyle currentstyle = segs.begin()->style;
393 int ht = (gzoom*currentstyle.getPicture()->height())/100; 392 int ht = (gzoom*currentstyle.getPicture()->height())/100;
394 int wt = (gzoom*currentstyle.getPicture()->width())/100; 393 int wt = (gzoom*currentstyle.getPicture()->width())/100;
395 bool willscale = false; 394 bool willscale = false;
396 if (ht > availht) 395 if (ht > availht)
397 { 396 {
398 wt = (wt*availht)/ht; 397 wt = (wt*availht)/ht;
399 ht = availht; 398 ht = availht;
400 willscale = true; 399 willscale = true;
401 } 400 }
402 401
403 QPixmap pc; 402 QPixmap pc;
404 if ((willscale || gzoom != 100) && currentstyle.canScale()) 403 if ((willscale || gzoom != 100) && currentstyle.canScale())
405 { 404 {
406 QImage im = currentstyle.getPicture()->smoothScale(wt,ht); 405 QImage im = currentstyle.getPicture()->smoothScale(wt,ht);
407 pc.convertFromImage(im); 406 pc.convertFromImage(im);
408 } 407 }
409 else 408 else
410 { 409 {
411 pc.convertFromImage(*currentstyle.getPicture()); 410 pc.convertFromImage(*currentstyle.getPicture());
412 } 411 }
413 int yoffset = pc.height()/2; 412 int yoffset = pc.height()/2;
414 _p->drawPixmap( currentx, _y-yoffset, pc ); 413 _p->drawPixmap( currentx, _y-yoffset, pc );
415 currentx += pc.width(); 414 currentx += pc.width();
416 } 415 }
417 } 416 }
418 return; 417 return;
419 } 418 }
420 QString text = toQString(data()); 419 QString text = toQString(data());
421 int extraspace = 0; 420 int extraspace = 0;
422 bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify); 421 bool just = (!m_bEop && textstart->style.getJustify() == m_AlignJustify);
423 int spaces = 0; 422 int spaces = 0;
424 int spacesofar = 0; 423 int spacesofar = 0;
425 int spacenumber = 0; 424 int spacenumber = 0;
426 int nonspace = 0; 425 int nonspace = 0;
427 if (just) 426 if (just)
428 { 427 {
429 for (int i = 0; i < len; i++) 428 for (int i = 0; i < len; i++)
430 { 429 {
431 if ((*this)[i] != ' ') 430 if ((*this)[i] != ' ')
432 { 431 {
433 nonspace = i; 432 nonspace = i;
434 break; 433 break;
435 } 434 }
436 } 435 }
437#ifdef _WINDOWS 436#ifdef _WINDOWS
438 for (i = nonspace; i < len; i++) 437 for (i = nonspace; i < len; i++)
439#else 438#else
440 for (int i = nonspace; i < len; i++) 439 for (int i = nonspace; i < len; i++)
441#endif 440#endif
442 { 441 {
443 if ((*this)[i] == ' ') 442 if ((*this)[i] == ' ')
444 { 443 {
445 spaces++; 444 spaces++;
446 } 445 }
447 } 446 }
448 if (spaces == 0) 447 if (spaces == 0)
449 { 448 {
450 just = false; 449 just = false;
451 } 450 }
452 else 451 else
453 { 452 {
454 extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht)); 453 extraspace = (scwidth - (_lborder+_rborder) - rightMargin() - leftMargin() - width(availht));
455 if (extraspace == 0) just = false; 454 if (extraspace == 0) just = false;
456 } 455 }
457 } 456 }
458 CList<textsegment>::iterator textend = textstart; 457 CList<textsegment>::iterator textend = textstart;
459 458
460 bool drawBackground = false; 459 bool drawBackground = false;
461 do 460 do
462 { 461 {
463 textend++; 462 textend++;
464 int end = (textend != segs.end()) ? textend->start : len; 463 int end = (textend != segs.end()) ? textend->start : len;
465 CStyle currentstyle = textstart->style; 464 CStyle currentstyle = textstart->style;
466 /* 465 /*
467 bool drawBackground = ( 466 bool drawBackground = (
468 currentstyle.bRed() != 255 467 currentstyle.bRed() != 255
469 || 468 ||
470 currentstyle.bGreen() != 255 469 currentstyle.bGreen() != 255
471 || 470 ||
472 currentstyle.bBlue() != 255 471 currentstyle.bBlue() != 255
473 ); 472 );
474 */ 473 */
475 QColor bgColour = QColor(qRgb(currentstyle.bRed(), 474 QColor bgColour = QColor(qRgb(currentstyle.bRed(),
476 currentstyle.bGreen(), 475 currentstyle.bGreen(),
477 currentstyle.bBlue())); 476 currentstyle.bBlue()));
478 drawBackground = !(bgColour == _bg); 477 drawBackground = !(bgColour == _bg);
479 478
480// if (drawBackground) qDebug("Drawing background"); 479// if (drawBackground) qDebug("Drawing background");
481 480
482 QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) ); 481 QFont f((currentstyle.isMono() && fc->hasCourier()) ? fc->fixedfontname() : fc->name(), fc->getsize(currentstyle), (currentstyle.isBold()) ? QFont::Bold : QFont::Normal, (currentstyle.isItalic()) );
483 //f.setUnderline(currentstyle.isUnderline()); 482 //f.setUnderline(currentstyle.isUnderline());
484 //if (currentstyle.isUnderline()) qDebug("UNDERLINE"); 483 //if (currentstyle.isUnderline()) qDebug("UNDERLINE");
485 _p->setFont(f); 484 _p->setFont(f);
486 QString str = text.mid(textstart->start, end-textstart->start); 485 QString str = text.mid(textstart->start, end-textstart->start);
487#if defined(OPIE) || !defined(USEQPE) 486#if defined(OPIE) || !defined(USEQPE)
488 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100)); 487 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/100));
489#else 488#else
490 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10)); 489 _p->setPen(QPen(QColor(currentstyle.Red(), currentstyle.Green(), currentstyle.Blue()), fc->getsize(currentstyle)/10));
491#endif 490#endif
492 int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2; 491 int voffset = currentstyle.getVOffset()*fc->getsize(currentstyle)/2;
493 492
494 if (_bMono) 493 if (_bMono)
495 { 494 {
496 495
497 Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour); 496 Highlight(_p, drawBackground, currentx, _y, str.length()*_charWidth, bgColour);
498 if (currentstyle.isUnderline()) 497 if (currentstyle.isUnderline())
499 { 498 {
500 _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset); 499 _p->drawLine( currentx, _y+voffset, currentx + str.length()*_charWidth, _y+voffset);
501 } 500 }
502 if (currentstyle.isStrikethru()) 501 if (currentstyle.isStrikethru())
503 { 502 {
504 int ascent = fc->ascent(currentstyle)/3; 503 int ascent = fc->ascent(currentstyle)/3;
505 _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset); 504 _p->drawLine( currentx, _y-ascent+voffset, currentx + str.length()*_charWidth, _y-ascent+voffset);
506 } 505 }
507 for (int i = 0; i < str.length(); i++) 506 for (int i = 0; i < str.length(); i++)
508 { 507 {
509 _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i])); 508 _p->drawText( currentx + i*_charWidth, _y+voffset, QString(str[i]));
510 } 509 }
511 currentx += str.length()*_charWidth; 510 currentx += str.length()*_charWidth;
512 } 511 }
513 else 512 else
514 { 513 {
515 if (currentstyle.isPicture()) 514 if (currentstyle.isPicture())
516 { 515 {
517 int ht = (gzoom*currentstyle.getPicture()->height())/100; 516 int ht = (gzoom*currentstyle.getPicture()->height())/100;
518 int wt = (gzoom*currentstyle.getPicture()->width())/100; 517 int wt = (gzoom*currentstyle.getPicture()->width())/100;
519 bool willscale = false; 518 bool willscale = false;
520 if (ht > availht) 519 if (ht > availht)
521 { 520 {
522 wt = (wt*availht)/ht; 521 wt = (wt*availht)/ht;
523 ht = availht; 522 ht = availht;
524 willscale = true; 523 willscale = true;
525 } 524 }
526 int ascent = fc->ascent(currentstyle)/2; 525 int ascent = fc->ascent(currentstyle)/2;
527 int yoffset = ht/2 + ascent; 526 int yoffset = ht/2 + ascent;
528 527
529 QPixmap pc; 528 QPixmap pc;
530 if ((willscale || gzoom != 100) && currentstyle.canScale()) 529 if ((willscale || gzoom != 100) && currentstyle.canScale())
531 { 530 {
532 QImage im = currentstyle.getPicture()->smoothScale(wt,ht); 531 QImage im = currentstyle.getPicture()->smoothScale(wt,ht);
533 pc.convertFromImage(im); 532 pc.convertFromImage(im);
534 } 533 }
535 else 534 else
536 { 535 {
537 pc.convertFromImage(*currentstyle.getPicture()); 536 pc.convertFromImage(*currentstyle.getPicture());
538 } 537 }
539 _p->drawPixmap( currentx, _y-yoffset, pc ); 538 _p->drawPixmap( currentx, _y-yoffset, pc );
540 currentx += wt; 539 currentx += wt;
541 } 540 }
542 else 541 else
543 { 542 {
544 if (currentstyle.isMono() && !fc->hasCourier()) 543 if (currentstyle.isMono() && !fc->hasCourier())
545 { 544 {
546 int cw = (7*fc->getsize(currentstyle))/10; 545 int cw = (7*fc->getsize(currentstyle))/10;
547 int w = cw*(end-textstart->start); 546 int w = cw*(end-textstart->start);
548 Highlight(_p, drawBackground, currentx, _y, w, bgColour); 547 Highlight(_p, drawBackground, currentx, _y, w, bgColour);
549 if (currentstyle.isUnderline()) 548 if (currentstyle.isUnderline())
550 { 549 {
551 _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); 550 _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset);
552 } 551 }
553 if (currentstyle.isStrikethru()) 552 if (currentstyle.isStrikethru())
554 { 553 {
555 int ascent = fc->ascent(currentstyle)/3; 554 int ascent = fc->ascent(currentstyle)/3;
556 _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); 555 _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset);
557 } 556 }
558 QString str = text.mid(textstart->start, end-textstart->start); 557 QString str = text.mid(textstart->start, end-textstart->start);
559 558
560 for (unsigned int i = 0; i < str.length(); i++) 559 for (unsigned int i = 0; i < str.length(); i++)
561 { 560 {
562#ifdef _WINDOWS 561#ifdef _WINDOWS
563 _p->drawText( currentx, _y+voffset, QString(str.at(i))); 562 _p->drawText( currentx, _y+voffset, QString(str.at(i)));
564#else 563#else
565 _p->drawText( currentx, _y+voffset, QString(str[i])); 564 _p->drawText( currentx, _y+voffset, QString(str[i]));
566#endif 565#endif
567 currentx += cw; 566 currentx += cw;
568 } 567 }
569 } 568 }
570 else 569 else
571 { 570 {
572 QFontMetrics fm(f); 571 QFontMetrics fm(f);
573 int w; 572 int w;
574 if (just) 573 if (just)
575 { 574 {
576 int lastspace = -1; 575 int lastspace = -1;
577 int nsp = 0; 576 int nsp = 0;
578 int cx = currentx; 577 int cx = currentx;
579 while ((nsp = str.find(" ", lastspace+1)) >= 0) 578 while ((nsp = str.find(" ", lastspace+1)) >= 0)
580 { 579 {
581 if (nsp+textstart->start >= nonspace) 580 if (nsp+textstart->start >= nonspace)
582 { 581 {
583 spacenumber++; 582 spacenumber++;
584 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar; 583 int nexttoadd = (extraspace*spacenumber+spaces/2)/spaces - spacesofar;
585 QString nstr = str.mid(lastspace+1, nsp-lastspace); 584 QString nstr = str.mid(lastspace+1, nsp-lastspace);
586 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); 585 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
587 int lw = fm.width(nstr); 586 int lw = fm.width(nstr);
588 Highlight(_p, drawBackground, cx, _y, lw, bgColour); 587 Highlight(_p, drawBackground, cx, _y, lw, bgColour);
589 _p->drawText( cx, _y+voffset, nstr); 588 _p->drawText( cx, _y+voffset, nstr);
590 Highlight(_p, drawBackground, cx+lw, _y, nexttoadd, bgColour); 589 Highlight(_p, drawBackground, cx+lw, _y, nexttoadd, bgColour);
591 cx += lw+nexttoadd; 590 cx += lw+nexttoadd;
592 spacesofar += nexttoadd; 591 spacesofar += nexttoadd;
593 lastspace = nsp; 592 lastspace = nsp;
594 } 593 }
595 else 594 else
596 { 595 {
597 QString nstr = str.mid(lastspace+1, nsp-lastspace); 596 QString nstr = str.mid(lastspace+1, nsp-lastspace);
598 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr); 597 // qDebug("str:%s: last:%d new:%d nstr:%s:", (const char*)str, lastspace, nsp, (const char*)nstr);
599 int lw = fm.width(nstr); 598 int lw = fm.width(nstr);
600 Highlight(_p, drawBackground, cx, _y, lw, bgColour); 599 Highlight(_p, drawBackground, cx, _y, lw, bgColour);
601 _p->drawText( cx, _y+voffset, nstr); 600 _p->drawText( cx, _y+voffset, nstr);
602 cx += lw; 601 cx += lw;
603 lastspace = nsp; 602 lastspace = nsp;
604 } 603 }
605 } 604 }
606 QString nstr = str.right(str.length()-1-lastspace); 605 QString nstr = str.right(str.length()-1-lastspace);
607 int lw = fm.width(nstr); 606 int lw = fm.width(nstr);
608 Highlight(_p, drawBackground, cx, _y, lw, bgColour); 607 Highlight(_p, drawBackground, cx, _y, lw, bgColour);
609 _p->drawText( cx, _y+voffset, nstr); 608 _p->drawText( cx, _y+voffset, nstr);
610 cx += lw; 609 cx += lw;
611 w = cx - currentx; 610 w = cx - currentx;
612 } 611 }
613 else 612 else
614 { 613 {
615 int lw = fm.width(str); 614 int lw = fm.width(str);
616 Highlight(_p, drawBackground, currentx, _y, lw, bgColour); 615 Highlight(_p, drawBackground, currentx, _y, lw, bgColour);
617 _p->drawText( currentx, _y+voffset, str); 616 _p->drawText( currentx, _y+voffset, str);
618 w = lw; 617 w = lw;
619 } 618 }
620 if (currentstyle.isUnderline()) 619 if (currentstyle.isUnderline())
621 { 620 {
622 _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset); 621 _p->drawLine( currentx, _y+voffset, currentx + w, _y+voffset);
623 } 622 }
624 if (currentstyle.isStrikethru()) 623 if (currentstyle.isStrikethru())
625 { 624 {
626 int ascent = fc->ascent(currentstyle)/3; 625 int ascent = fc->ascent(currentstyle)/3;
627 _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset); 626 _p->drawLine( currentx, _y-ascent+voffset, currentx + w, _y-ascent+voffset);
628 } 627 }
629 currentx += w; 628 currentx += w;
630 } 629 }
631 } 630 }
632 } 631 }
633 textstart = textend; 632 textstart = textend;
634 } 633 }
635 while (textend != segs.end() && textstart->start < len); 634 while (textend != segs.end() && textstart->start < len);
636/* 635/*
637 if (firstColour == bgColour) 636 if (firstColour == bgColour)
638 { 637 {
639 Highlight(_p, drawBackground, currentx, _y, scwidth - (currentx + _lborder + _rborder), bgColour); 638 Highlight(_p, drawBackground, currentx, _y, scwidth - (currentx + _lborder + _rborder), bgColour);
640 } 639 }
641 */ 640 */
642} 641}
643 642
644void CDrawBuffer::Highlight(QPainter* _p, bool drawBackground, int _x, int _y, int w, QColor bgColour) 643void CDrawBuffer::Highlight(QPainter* _p, bool drawBackground, int _x, int _y, int w, QColor bgColour)
645{ 644{
646 if (drawBackground) 645 if (drawBackground)
647 { 646 {
648 _p->fillRect(_x, _y-m_ascent, w, m_lineSpacing, bgColour); 647 _p->fillRect(_x, _y-m_ascent, w, m_lineSpacing, bgColour);
649 } 648 }
650} 649}
651 650
652CStyle CDrawBuffer::laststyle() 651CStyle CDrawBuffer::laststyle()
653{ 652{
654 return segs.last().style; 653 return segs.last().style;
655} 654}
656 655
657CStyle CDrawBuffer::firststyle() 656CStyle CDrawBuffer::firststyle()
658{ 657{
659 return segs.first().style; 658 return segs.first().style;
660} 659}
661 660
662linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img) 661linkType CDrawBuffer::getLinkType(int numchars, size_t& tgt, size_t& offset, size_t& pictgt, QImage*& img)
663{ 662{
664 linkType ret = eNone; 663 linkType ret = eNone;
665 int end = 0; 664 int end = 0;
666 CStyle currentstyle; 665 CStyle currentstyle;
667 CList<textsegment>::iterator textstart = segs.begin(); 666 CList<textsegment>::iterator textstart = segs.begin();
668 CList<textsegment>::iterator textend = textstart; 667 CList<textsegment>::iterator textend = textstart;
669 do 668 do
670 { 669 {
671 textend++; 670 textend++;
672 end = (textend != segs.end()) ? textend->start : len; 671 end = (textend != segs.end()) ? textend->start : len;
673 currentstyle = textstart->style; 672 currentstyle = textstart->style;
674/* 673/*
675 if (currentstyle.isPicture()) qDebug("Passed thru picture"); 674 if (currentstyle.isPicture()) qDebug("Passed thru picture");
676 if (currentstyle.getLink()) qDebug("Passed thru link"); 675 if (currentstyle.getLink()) qDebug("Passed thru link");
677 //qDebug("islink:%d - %d", numchars, end); 676 //qDebug("islink:%d - %d", numchars, end);
678*/ 677*/
679 textstart = textend; 678 textstart = textend;
680 } 679 }
681 while (textend != segs.end() && end <= numchars); 680 while (textend != segs.end() && end <= numchars);
682 img = currentstyle.getPicture(); 681 img = currentstyle.getPicture();
683 if (currentstyle.getPictureLink()) 682 if (currentstyle.getPictureLink())
684 { 683 {
685 pictgt = currentstyle.getPictureLinkData(); 684 pictgt = currentstyle.getPictureLinkData();
686 ret |= ePicture; 685 ret |= ePicture;
687 } 686 }
688 if (currentstyle.getLink()) 687 if (currentstyle.getLink())
689 { 688 {
690 tgt = currentstyle.getData(); 689 tgt = currentstyle.getData();
691 offset = currentstyle.getOffset(); 690 offset = currentstyle.getOffset();
692 ret |= eLink; 691 ret |= eLink;
693 } 692 }
694 return ret; 693 return ret;
695} 694}
696 695
697void CDrawBuffer::resize(int availht) 696void CDrawBuffer::resize(int availht)
698{ 697{
699 int gzoom = fc->gzoom(); 698 int gzoom = fc->gzoom();
700 m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0; 699 m_ascent = m_descent = m_lineSpacing = m_lineExtraSpacing = 0;
701 /* 700 /*
702 int t_ascent = 0; 701 int t_ascent = 0;
703 int t_descent = 0; 702 int t_descent = 0;
704 int t_lineExtraSpacing = 0; 703 int t_lineExtraSpacing = 0;
705 */ 704 */
706 int t_lineSpacing = 0; 705 int t_lineSpacing = 0;
707 m_hastext = false; 706 m_hastext = false;
708 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) 707 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; )
709 { 708 {
710 CStyle _style = iter->style; 709 CStyle _style = iter->style;
711 if (!_style.isPicture()) 710 if (!_style.isPicture())
712 { 711 {
713 m_hastext = true; 712 m_hastext = true;
714 break; 713 break;
715 } 714 }
716 iter++; 715 iter++;
717 } 716 }
718 if (m_hastext) 717 if (m_hastext)
719 { 718 {
720 719
721 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; ) 720 for (CList<textsegment>::iterator iter = segs.begin(); iter != segs.end() && iter->start <= len; )
722 { 721 {
723 CList<textsegment>::iterator next = iter; 722 CList<textsegment>::iterator next = iter;
724 iter++; 723 iter++;
725 int st = next->start; 724 int st = next->start;
726 if (st < 0) st = 0; 725 if (st < 0) st = 0;
727 726
728 CStyle _style = next->style; 727 CStyle _style = next->style;
729 728
730 int linespacing, ascent, descent, extra; 729 int linespacing, ascent, descent, extra;
731 730
732 ascent = fc->ascent(_style); 731 ascent = fc->ascent(_style);
733 descent = fc->descent(_style); 732 descent = fc->descent(_style);
734 linespacing = fc->lineSpacing(_style); 733 linespacing = fc->lineSpacing(_style);
735 extra = linespacing - ascent - descent; 734 extra = linespacing - ascent - descent;
736 /* 735 /*
737 if (ascent > t_ascent) t_ascent = ascent; 736 if (ascent > t_ascent) t_ascent = ascent;
738 if (descent > t_descent) t_descent = descent; 737 if (descent > t_descent) t_descent = descent;
739 if (extra > t_lineExtraSpacing) t_lineExtraSpacing = extra; 738 if (extra > t_lineExtraSpacing) t_lineExtraSpacing = extra;
740 t_lineSpacing = t_ascent+t_descent+t_lineExtraSpacing; 739 t_lineSpacing = t_ascent+t_descent+t_lineExtraSpacing;
741 */ 740 */
742 if (linespacing > t_lineSpacing) t_lineSpacing = linespacing; 741 if (linespacing > t_lineSpacing) t_lineSpacing = linespacing;
743 if (_style.isPicture()) 742 if (_style.isPicture())
744 { 743 {
745 int ht = (gzoom*_style.getPicture()->height())/100; 744 int ht = (gzoom*_style.getPicture()->height())/100;
746 int wt = (gzoom*_style.getPicture()->width())/100; 745 int wt = (gzoom*_style.getPicture()->width())/100;
747 746
748 bool willscale = false; 747 bool willscale = false;
749 if (ht > availht) 748 if (ht > availht)
750 { 749 {
751 wt = (wt*availht)/ht; 750 wt = (wt*availht)/ht;
752 ht = availht; 751 ht = availht;
753 willscale = true; 752 willscale = true;
754 } 753 }
755 if (willscale || _style.canScale()) 754 if (willscale || _style.canScale())
756 { 755 {
757 descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2; 756 descent = ((gzoom*_style.getPicture()->height())/100-ascent)/2;
758 ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2; 757 ascent = ((gzoom*_style.getPicture()->height())/100+ascent)/2;
759 } 758 }
760 } 759 }
761 760
762 /* 761 /*
763 else if (fc != NULL) 762 else if (fc != NULL)
764 { 763 {
765 ascent = fc->ascent(_style); 764 ascent = fc->ascent(_style);
766 descent = fc->descent(_style); 765 descent = fc->descent(_style);
767 linespacing = fc->lineSpacing(_style); 766 linespacing = fc->lineSpacing(_style);
768 extra = linespacing - ascent - descent; 767 extra = linespacing - ascent - descent;
769 } 768 }
770 */ 769 */
771 if (ascent > m_ascent) m_ascent = ascent; 770 if (ascent > m_ascent) m_ascent = ascent;
772 if (descent > m_descent) m_descent = descent; 771 if (descent > m_descent) m_descent = descent;
773 if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra; 772 if (extra > m_lineExtraSpacing) m_lineExtraSpacing = extra;
774 m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing; 773 m_lineSpacing = m_ascent+m_descent+m_lineExtraSpacing;
775 } 774 }
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
18class QImage; 17class QImage;
19class Bkmk; 18class Bkmk;
20class QString; 19class QString;
21 20
22template<class T> 21template<class T>
23class CList; 22class CList;
24 23
25class CCharacterSource 24class 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
44class CExpander_Interface 43class 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
90class CExpander : public CExpander_Interface 89class 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,773 +1,772 @@
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
20void textfmt::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) 19void 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
33void textfmt::getch(tchar& ch, CStyle& sty, unsigned long& pos) 32void 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
137void remap::getch(tchar& ch, CStyle& sty, unsigned long& pos) 136void 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:
198 offset = 0; 197 offset = 0;
199 q[0] = '-'; 198 q[0] = '-';
200 q[1] = 0; 199 q[1] = 0;
201 ch = '-'; // should be -- 200 ch = '-'; // should be --
202 break; 201 break;
203 case 0x02dc: 202 case 0x02dc:
204 ch = '~'; 203 ch = '~';
205 break; 204 break;
206 case 0x0161: 205 case 0x0161:
207 ch = 's'; 206 ch = 's';
208 break; 207 break;
209 case 0x203a: 208 case 0x203a:
210 ch = '>'; 209 ch = '>';
211 break; 210 break;
212 case 0x0153: 211 case 0x0153:
213 offset = 0; 212 offset = 0;
214 q[0] = 'e'; 213 q[0] = 'e';
215 q[1] = 0; 214 q[1] = 0;
216 ch = 'o';// should be oe 215 ch = 'o';// should be oe
217 break; 216 break;
218 /* 217 /*
219 case 0x0009: // tab 218 case 0x0009: // tab
220 offset = 0; 219 offset = 0;
221 q[0] = ' '; 220 q[0] = ' ';
222 q[1] = 0; 221 q[1] = 0;
223 ch = ' '; 222 ch = ' ';
224 break; 223 break;
225 */ 224 */
226 case 0x017e: 225 case 0x017e:
227 ch = 'z'; 226 ch = 'z';
228 break; 227 break;
229 case 0x0178: 228 case 0x0178:
230 ch = 'Y'; 229 ch = 'Y';
231 break; 230 break;
232 } 231 }
233 currentstyle = sty; 232 currentstyle = sty;
234} 233}
235 234
236void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos) 235void PeanutFormatter::getch(tchar& ch, CStyle& sty, unsigned long& pos)
237{ 236{
238 CStyle dummy; 237 CStyle dummy;
239 currentstyle.setColour(0,0,0); 238 currentstyle.setColour(0,0,0);
240 parent->getch(ch, dummy, pos); 239 parent->getch(ch, dummy, pos);
241 while (ch == '\\') 240 while (ch == '\\')
242 { 241 {
243 parent->getch(ch, dummy, pos); 242 parent->getch(ch, dummy, pos);
244 if (ch == '\\') break; 243 if (ch == '\\') break;
245 switch(ch) 244 switch(ch)
246 { 245 {
247 case 'a': 246 case 'a':
248 { 247 {
249 int code = 0; 248 int code = 0;
250 for (int i = 0; i < 3; i++) 249 for (int i = 0; i < 3; i++)
251 { 250 {
252 parent->getch(ch, dummy, pos); 251 parent->getch(ch, dummy, pos);
253 code = 10*code + ch - '0'; 252 code = 10*code + ch - '0';
254 } 253 }
255 ch = code; 254 ch = code;
256 } 255 }
257 break; 256 break;
258 case 'v': 257 case 'v':
259 { 258 {
260 while (1) 259 while (1)
261 { 260 {
262 parent->getch(ch, dummy, pos); 261 parent->getch(ch, dummy, pos);
263 if (ch == '\\') 262 if (ch == '\\')
264 { 263 {
265 parent->getch(ch, dummy, pos); 264 parent->getch(ch, dummy, pos);
266 if (ch == 'v') 265 if (ch == 'v')
267 { 266 {
268 parent->getch(ch, dummy, pos); 267 parent->getch(ch, dummy, pos);
269 break; 268 break;
270 } 269 }
271 } 270 }
272 } 271 }
273 } 272 }
274 break; 273 break;
275 case 's': 274 case 's':
276 case 'n': 275 case 'n':
277 currentstyle.setFontSize(0); 276 currentstyle.setFontSize(0);
278 parent->getch(ch,dummy, pos); 277 parent->getch(ch,dummy, pos);
279 break; 278 break;
280 case 'p': 279 case 'p':
281 currentstyle.unset(); 280 currentstyle.unset();
282 // parent->getch(ch,dummy); 281 // parent->getch(ch,dummy);
283 ch = 10; 282 ch = 10;
284 break; 283 break;
285 case 'l': 284 case 'l':
286 if (currentstyle.getFontSize() == 1) 285 if (currentstyle.getFontSize() == 1)
287 { 286 {
288 currentstyle.setFontSize(0); 287 currentstyle.setFontSize(0);
289 } 288 }
290 else 289 else
291 { 290 {
292 currentstyle.setFontSize(1); 291 currentstyle.setFontSize(1);
293 } 292 }
294 parent->getch(ch, dummy, pos); 293 parent->getch(ch, dummy, pos);
295 break; 294 break;
296 case 'x': 295 case 'x':
297 if (currentstyle.getFontSize() == 0) 296 if (currentstyle.getFontSize() == 0)
298 { 297 {
299 // currentstyle.unset(); 298 // currentstyle.unset();
300 // currentstyle.setBold(); 299 // currentstyle.setBold();
301 currentstyle.setFontSize(1); 300 currentstyle.setFontSize(1);
302 } 301 }
303 else 302 else
304 { 303 {
305 currentstyle.unset(); 304 currentstyle.unset();
306 } 305 }
307 // parent->getch(ch, dummy); 306 // parent->getch(ch, dummy);
308 ch = 10; 307 ch = 10;
309 break; 308 break;
310 case 'i': 309 case 'i':
311 if (currentstyle.isItalic()) 310 if (currentstyle.isItalic())
312 { 311 {
313 currentstyle.unsetItalic(); 312 currentstyle.unsetItalic();
314 } 313 }
315 else 314 else
316 { 315 {
317 currentstyle.setItalic(); 316 currentstyle.setItalic();
318 } 317 }
319 parent->getch(ch, dummy, pos); 318 parent->getch(ch, dummy, pos);
320 break; 319 break;
321 case 'b': 320 case 'b':
322 case 'B': 321 case 'B':
323 if (currentstyle.isBold()) 322 if (currentstyle.isBold())
324 { 323 {
325 currentstyle.unsetBold(); 324 currentstyle.unsetBold();
326 } 325 }
327 else 326 else
328 { 327 {
329 currentstyle.setBold(); 328 currentstyle.setBold();
330 } 329 }
331 parent->getch(ch, dummy, pos); 330 parent->getch(ch, dummy, pos);
332 break; 331 break;
333 case 'c': 332 case 'c':
334 if (currentstyle.getJustify() == m_AlignCentre) 333 if (currentstyle.getJustify() == m_AlignCentre)
335 { 334 {
336 currentstyle.setLeftJustify(); 335 currentstyle.setLeftJustify();
337 } 336 }
338 else 337 else
339 { 338 {
340 currentstyle.setCentreJustify(); 339 currentstyle.setCentreJustify();
341 } 340 }
342 parent->getch(ch, dummy, pos); 341 parent->getch(ch, dummy, pos);
343 break; 342 break;
344 case 'r': 343 case 'r':
345 if (currentstyle.getJustify() == m_AlignRight) 344 if (currentstyle.getJustify() == m_AlignRight)
346 { 345 {
347 currentstyle.setLeftJustify(); 346 currentstyle.setLeftJustify();
348 } 347 }
349 else 348 else
350 { 349 {
351 currentstyle.setRightJustify(); 350 currentstyle.setRightJustify();
352 } 351 }
353 parent->getch(ch, dummy, pos); 352 parent->getch(ch, dummy, pos);
354 break; 353 break;
355 default: 354 default:
356 currentstyle.setColour(255,0,0); 355 currentstyle.setColour(255,0,0);
357 } 356 }
358 } 357 }
359 sty = currentstyle; 358 sty = currentstyle;
360} 359}
361 360
362void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos) 361void OnePara::getch(tchar& ch, CStyle& sty, unsigned long& pos)
363{ 362{
364 parent->getch(ch, sty, pos); 363 parent->getch(ch, sty, pos);
365 if (m_lastchar == 10) 364 if (m_lastchar == 10)
366 { 365 {
367 while (ch == 10) parent->getch(ch, sty, pos); 366 while (ch == 10) parent->getch(ch, sty, pos);
368 } 367 }
369 m_lastchar = ch; 368 m_lastchar = ch;
370} 369}
371 370
372void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos) 371void repalm::getch(tchar& ch, CStyle& sty, unsigned long& pos)
373{ 372{
374 parent->getch(ch, sty, pos); 373 parent->getch(ch, sty, pos);
375 switch (ch) 374 switch (ch)
376 { 375 {
377 case 0x80: 376 case 0x80:
378 ch = 0x20ac; 377 ch = 0x20ac;
379 break; 378 break;
380 case 0x82: 379 case 0x82:
381 ch = 0x201a; 380 ch = 0x201a;
382 break; 381 break;
383 case 0x83: 382 case 0x83:
384 ch = 0x0192; 383 ch = 0x0192;
385 break; 384 break;
386 case 0x84: 385 case 0x84:
387 ch = 0x201e; 386 ch = 0x201e;
388 break; 387 break;
389 case 0x85: 388 case 0x85:
390 ch = 0x2026; 389 ch = 0x2026;
391 break; 390 break;
392 case 0x86: 391 case 0x86:
393 ch = 0x2020; 392 ch = 0x2020;
394 break; 393 break;
395 case 0x87: 394 case 0x87:
396 ch = 0x2021; 395 ch = 0x2021;
397 break; 396 break;
398 case 0x88: 397 case 0x88:
399 ch = 0x02c6; 398 ch = 0x02c6;
400 break; 399 break;
401 case 0x89: 400 case 0x89:
402 ch = 0x2030; 401 ch = 0x2030;
403 break; 402 break;
404 case 0x8a: 403 case 0x8a:
405 ch = 0x0160; 404 ch = 0x0160;
406 break; 405 break;
407 case 0x8b: 406 case 0x8b:
408 ch = 0x2039; 407 ch = 0x2039;
409 break; 408 break;
410 case 0x8c: 409 case 0x8c:
411 ch = 0x0152; 410 ch = 0x0152;
412 break; 411 break;
413/* 412/*
414 case 0x8e: 413 case 0x8e:
415 ch = 0x017d; 414 ch = 0x017d;
416 break; 415 break;
417*/ 416*/
418 case 0x91: 417 case 0x91:
419 ch = 0x2018; 418 ch = 0x2018;
420 break; 419 break;
421 case 0x92: 420 case 0x92:
422 ch = 0x2019; 421 ch = 0x2019;
423 break; 422 break;
424 case 0x93: 423 case 0x93:
425 ch = 0x201c; 424 ch = 0x201c;
426 break; 425 break;
427 case 0x94: 426 case 0x94:
428 ch = 0x201d; 427 ch = 0x201d;
429 break; 428 break;
430 case 0x95: 429 case 0x95:
431 ch = 0x2022; 430 ch = 0x2022;
432 break; 431 break;
433 case 0x96: 432 case 0x96:
434 ch = 0x2013; 433 ch = 0x2013;
435 break; 434 break;
436 case 0x97: 435 case 0x97:
437 ch = 0x2014; 436 ch = 0x2014;
438 break; 437 break;
439 case 0x98: 438 case 0x98:
440 ch = 0x02dc; 439 ch = 0x02dc;
441 break; 440 break;
442 case 0x99: 441 case 0x99:
443 ch = 0x2122; 442 ch = 0x2122;
444 break; 443 break;
445 case 0x9a: 444 case 0x9a:
446 ch = 0x0161; 445 ch = 0x0161;
447 break; 446 break;
448 case 0x9b: 447 case 0x9b:
449 ch = 0x203a; 448 ch = 0x203a;
450 break; 449 break;
451 case 0x9c: 450 case 0x9c:
452 ch = 0x0153; 451 ch = 0x0153;
453 break; 452 break;
454 case 0x9e: 453 case 0x9e:
455 ch = 0x017e; 454 ch = 0x017e;
456 break; 455 break;
457 case 0x9f: 456 case 0x9f:
458 ch = 0x0178; 457 ch = 0x0178;
459 break; 458 break;
460 case 0x18: 459 case 0x18:
461 ch = 0x2026; 460 ch = 0x2026;
462 break; 461 break;
463 case 0x19: 462 case 0x19:
464 ch = 0x2007; 463 ch = 0x2007;
465 break; 464 break;
466 case 0x8d: 465 case 0x8d:
467 ch = 0x2662; 466 ch = 0x2662;
468 break; 467 break;
469 case 0x8e: 468 case 0x8e:
470 ch = 0x2663; 469 ch = 0x2663;
471 break; 470 break;
472 case 0x8f: 471 case 0x8f:
473 ch = 0x2661; 472 ch = 0x2661;
474 break; 473 break;
475 case 0x90: 474 case 0x90:
476 ch = 0x2660; 475 ch = 0x2660;
477 break; 476 break;
478 default: 477 default:
479 break; 478 break;
480 } 479 }
481} 480}
482 481
483//static tchar nextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 }; 482//static tchar nextpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','n','e','x','t',' ','p','a','r','t',0 };
484//static tchar prevpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','a','r','t',0 }; 483//static tchar prevpart[] = { 'C','l','i','c','k',' ','h','e','r','e',' ','f','o','r',' ','t','h','e',' ','p','r','e','v','i','o','u','s',' ','p','a','r','t',0 };
485 484
486void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos) 485void DePluck::getch(tchar& ch, CStyle& sty, unsigned long& pos)
487{ 486{
488 if (m_buffed > 0) 487 if (m_buffed > 0)
489 { 488 {
490 sty = m_laststyle; 489 sty = m_laststyle;
491 ch = nextpart[m_current++]; 490 ch = nextpart[m_current++];
492 if (m_current == m_buffed) 491 if (m_current == m_buffed)
493 { 492 {
494 m_current = m_buffed = 0; 493 m_current = m_buffed = 0;
495 } 494 }
496 } 495 }
497 else 496 else
498 { 497 {
499 if (m_buffer != 0) 498 if (m_buffer != 0)
500 { 499 {
501 ch = m_buffer; 500 ch = m_buffer;
502 m_buffer = 0; 501 m_buffer = 0;
503 return; 502 return;
504 } 503 }
505 unsigned long lnk, lnkoff; 504 unsigned long lnk, lnkoff;
506 do 505 do
507 { 506 {
508 if (nextpart[m_buffed] == 0) break; 507 if (nextpart[m_buffed] == 0) break;
509 parent->getch(ch, sty, pos); 508 parent->getch(ch, sty, pos);
510 m_laststyle = sty; 509 m_laststyle = sty;
511 if (sty.getLink()) 510 if (sty.getLink())
512 { 511 {
513 lnk = sty.getData(); 512 lnk = sty.getData();
514 lnkoff = sty.getOffset(); 513 lnkoff = sty.getOffset();
515 } 514 }
516 } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed); 515 } while (ch == nextpart[m_buffed] && sty.getLink() && ++m_buffed);
517 m_current = 0; 516 m_current = 0;
518 if (nextpart[m_buffed] == 0) 517 if (nextpart[m_buffed] == 0)
519 { 518 {
520 m_buffed = 0; 519 m_buffed = 0;
521 QString dmy, dmy2; 520 QString dmy, dmy2;
522 parent->hyperlink(lnk, lnkoff, dmy, dmy2); 521 parent->hyperlink(lnk, lnkoff, dmy, dmy2);
523 do 522 do
524 { 523 {
525 parent->getch(ch, sty, pos); 524 parent->getch(ch, sty, pos);
526 } 525 }
527 while (ch != 10); 526 while (ch != 10);
528 parent->getch(ch, sty, pos); 527 parent->getch(ch, sty, pos);
529 } 528 }
530 else if (m_buffed > 0) 529 else if (m_buffed > 0)
531 { 530 {
532 m_buffer = ch; 531 m_buffer = ch;
533 ch = nextpart[0]; 532 ch = nextpart[0];
534 if (m_buffed == 1) 533 if (m_buffed == 1)
535 { 534 {
536 m_buffed = 0; 535 m_buffed = 0;
537 } 536 }
538 else m_current = 1; 537 else m_current = 1;
539 } 538 }
540 } 539 }
541 540
542 return; 541 return;
543} 542}
544 543
545HighlightFilter::HighlightFilter(QTReader* _p) : pReader(_p), lastpos(0), nextpos(0), red(255), green(255), blue(255) 544HighlightFilter::HighlightFilter(QTReader* _p) : pReader(_p), lastpos(0), nextpos(0), red(255), green(255), blue(255)
546{ 545{
547} 546}
548 547
549#include "Bkmks.h" 548#include "Bkmks.h"
550#include "QTReader.h" 549#include "QTReader.h"
551 550
552void HighlightFilter::refresh(unsigned long pos) 551void HighlightFilter::refresh(unsigned long pos)
553{ 552{
554 bkmks = pReader->Bkmklist(); 553 bkmks = pReader->Bkmklist();
555 554
556 red = green = blue = 255; 555 red = green = blue = 255;
557 556
558 if (bkmks == NULL) 557 if (bkmks == NULL)
559 { 558 {
560 lastpos = 0; 559 lastpos = 0;
561 nextpos = 0xffffffff; 560 nextpos = 0xffffffff;
562 } 561 }
563 else 562 else
564 { 563 {
565 lastpos = 0; 564 lastpos = 0;
566 nextpos = 0xffffffff; 565 nextpos = 0xffffffff;
567 for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++) 566 for (CList<Bkmk>::iterator i = bkmks->begin(); i != bkmks->end(); i++)
568 { 567 {
569 if ((*i).value() <= pos && pos < (*i).value2()) 568 if ((*i).value() <= pos && pos < (*i).value2())
570 { 569 {
571 red = i->red(); 570 red = i->red();
572 green = i->green(); 571 green = i->green();
573 blue = i->blue(); 572 blue = i->blue();
574 lastpos = (*i).value(); 573 lastpos = (*i).value();
575 nextpos = (*i).value2(); 574 nextpos = (*i).value2();
576 break; 575 break;
577 } 576 }
578 if ((*i).value() > pos) 577 if ((*i).value() > pos)
579 { 578 {
580 nextpos = (*i).value(); 579 nextpos = (*i).value();
581 break; 580 break;
582 } 581 }
583 lastpos = (*i).value(); 582 lastpos = (*i).value();
584 } 583 }
585 } 584 }
586} 585}
587 586
588void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos) 587void HighlightFilter::getch(tchar& ch, CStyle& sty, unsigned long& pos)
589{ 588{
590 parent->getch(ch, sty, pos); 589 parent->getch(ch, sty, pos);
591 if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos) 590 if (bkmks != pReader->Bkmklist() || pos <= lastpos || pos >= nextpos)
592 { 591 {
593 // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos); 592 // qDebug("Recalc <%lu, %lu, %lu>", lastpos, pos, nextpos);
594 refresh(pos); 593 refresh(pos);
595 // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos); 594 // qDebug("Recalc(2) <%lu, %lu, %lu>", lastpos, pos, nextpos);
596 } 595 }
597 int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); 596 int r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue();
598 if (r == 255 && g == 255 && b == 255) 597 if (r == 255 && g == 255 && b == 255)
599 { 598 {
600 sty.setBackground(red, green, blue); 599 sty.setBackground(red, green, blue);
601 } 600 }
602} 601}
603 602
604void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos) 603void kern::getch(tchar& ch, CStyle& sty, unsigned long& pos)
605{ 604{
606 if (uselast) 605 if (uselast)
607 { 606 {
608 ch = lastchar; 607 ch = lastchar;
609 sty = laststy; 608 sty = laststy;
610 uselast = false; 609 uselast = false;
611 return; 610 return;
612 } 611 }
613 else 612 else
614 { 613 {
615 parent->getch(ch, sty, pos); 614 parent->getch(ch, sty, pos);
616 } 615 }
617 switch (ch) 616 switch (ch)
618 { 617 {
619 case 'f': 618 case 'f':
620 { 619 {
621 tchar savedchar = 'f'; 620 tchar savedchar = 'f';
622 parent->getch(ch, sty, pos); 621 parent->getch(ch, sty, pos);
623 switch (ch) 622 switch (ch)
624 { 623 {
625 case 'i': 624 case 'i':
626 ch = (251 << 8) + 1; 625 ch = (251 << 8) + 1;
627 break; 626 break;
628 case 'l': 627 case 'l':
629 ch = (251 << 8) + 2; 628 ch = (251 << 8) + 2;
630 break; 629 break;
631 default: 630 default:
632 lastchar = ch; 631 lastchar = ch;
633 uselast = true; 632 uselast = true;
634 laststy = sty; 633 laststy = sty;
635 ch = savedchar; 634 ch = savedchar;
636 } 635 }
637 } 636 }
638 break; 637 break;
639 default: 638 default:
640 break; 639 break;
641 } 640 }
642} 641}
643 642
644class ErrorFilter : public CFilter 643class ErrorFilter : public CFilter
645{ 644{
646 QString error; 645 QString error;
647 int currentpos; 646 int currentpos;
648 public: 647 public:
649 ErrorFilter(const QString& _s) : error(_s), currentpos(0) {} 648 ErrorFilter(const QString& _s) : error(_s), currentpos(0) {}
650 ~ErrorFilter() {} 649 ~ErrorFilter() {}
651 void getch(tchar& ch, CStyle& sty, unsigned long& pos) 650 void getch(tchar& ch, CStyle& sty, unsigned long& pos)
652 { 651 {
653 if (currentpos == error.length()) 652 if (currentpos == error.length())
654 { 653 {
655 ch = UEOF; 654 ch = UEOF;
656 currentpos = 0; 655 currentpos = 0;
657 } 656 }
658 else 657 else
659 { 658 {
660 ch = error[currentpos++].unicode(); 659 ch = error[currentpos++].unicode();
661 } 660 }
662 } 661 }
663 QString about() { return parent->about(); } 662 QString about() { return parent->about(); }
664}; 663};
665 664
666#ifndef __STATIC 665#ifndef __STATIC
667ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL) 666ExternFilter::ExternFilter(const QString& nm, const QString& optional) : filt(NULL), handle(NULL)
668{ 667{
669 QString filterpath(QTReaderUtil::getPluginPath("filters/lib")); 668 QString filterpath(QTReaderUtil::getPluginPath("filters/lib"));
670 filterpath += nm; 669 filterpath += nm;
671 filterpath += ".so"; 670 filterpath += ".so";
672 if (QFile::exists(filterpath)) 671 if (QFile::exists(filterpath))
673 { 672 {
674 qDebug("Filter:%s", (const char*)filterpath); 673 qDebug("Filter:%s", (const char*)filterpath);
675 handle = dlopen(filterpath, RTLD_LAZY); 674 handle = dlopen(filterpath, RTLD_LAZY);
676 if (handle == 0) 675 if (handle == 0)
677 { 676 {
678 qDebug("Can't find filter:%s", dlerror()); 677 qDebug("Can't find filter:%s", dlerror());
679 // status = -10; 678 // status = -10;
680 filt = new ErrorFilter(QString("Can't find plugin:")+nm); 679 filt = new ErrorFilter(QString("Can't find plugin:")+nm);
681 return; 680 return;
682 } 681 }
683 CFilter* (*newfilter)(const QString&); 682 CFilter* (*newfilter)(const QString&);
684 newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter"); 683 newfilter = (CFilter* (*)(const QString&))dlsym(handle, "newfilter");
685 if (newfilter == NULL) 684 if (newfilter == NULL)
686 { 685 {
687 qDebug("Can't find newfilter"); 686 qDebug("Can't find newfilter");
688 filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm); 687 filt = new ErrorFilter(QString("Can't find entry point in plugin:")+nm);
689 return; 688 return;
690 } 689 }
691 filt = (*newfilter)(optional); 690 filt = (*newfilter)(optional);
692 } 691 }
693 else 692 else
694 { 693 {
695 qDebug("No filter path"); 694 qDebug("No filter path");
696 filt = new ErrorFilter(QString("No filter plugins installed:")+nm); 695 filt = new ErrorFilter(QString("No filter plugins installed:")+nm);
697 } 696 }
698 if (filt == NULL) 697 if (filt == NULL)
699 { 698 {
700 qDebug("Can't do newfilter"); 699 qDebug("Can't do newfilter");
701 filt = new ErrorFilter(QString("Filter creation failed:")+nm); 700 filt = new ErrorFilter(QString("Filter creation failed:")+nm);
702 return; 701 return;
703 } 702 }
704} 703}
705#endif 704#endif
706 705
707void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos) 706void makeInverse::getch(tchar& ch, CStyle& sty, unsigned long& pos)
708{ 707{
709 parent->getch(ch, sty, pos); 708 parent->getch(ch, sty, pos);
710 int r,g,b; 709 int r,g,b;
711 r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue(); 710 r = 255 - sty.Red(), g = 255 - sty.Green(), b = 255 - sty.Blue();
712 sty.setColour(r,g,b); 711 sty.setColour(r,g,b);
713 r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue(); 712 r = 255 - sty.bRed(), g = 255 - sty.bGreen(), b = 255 - sty.bBlue();
714 sty.setBackground(r,g,b); 713 sty.setBackground(r,g,b);
715 r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue(); 714 r = 255 - sty.pRed(), g = 255 - sty.pGreen(), b = 255 - sty.pBlue();
716 sty.setPaper(r,g,b); 715 sty.setPaper(r,g,b);
717} 716}
718/* 717/*
719void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos) 718void makeNegative::getch(tchar& ch, CStyle& sty, unsigned long& pos)
720{ 719{
721 parent->getch(ch, sty, pos); 720 parent->getch(ch, sty, pos);
722 QColor fg(sty.Red(), sty.Green(), sty.Blue()); 721 QColor fg(sty.Red(), sty.Green(), sty.Blue());
723 int h,s,v; 722 int h,s,v;
724 fg.hsv(&h,&s,&v); 723 fg.hsv(&h,&s,&v);
725 fg.setHsv(h,s,255-v); 724 fg.setHsv(h,s,255-v);
726 int r,g,b; 725 int r,g,b;
727 fg.rgb(&r,&g,&b); 726 fg.rgb(&r,&g,&b);
728 sty.setColour(r,g,b); 727 sty.setColour(r,g,b);
729 728
730 fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue()); 729 fg = QColor(sty.bRed(), sty.bGreen(), sty.bBlue());
731 fg.hsv(&h,&s,&v); 730 fg.hsv(&h,&s,&v);
732 fg.setHsv(h,s,255-v); 731 fg.setHsv(h,s,255-v);
733 fg.rgb(&r,&g,&b); 732 fg.rgb(&r,&g,&b);
734 sty.setBackground(r,g,b); 733 sty.setBackground(r,g,b);
735} 734}
736*/ 735*/
737void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos) 736void setbg::getch(tchar& ch, CStyle& sty, unsigned long& pos)
738{ 737{
739 parent->getch(ch, sty, pos); 738 parent->getch(ch, sty, pos);
740 int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue(); 739 int r = sty.pRed(), g = sty.pGreen(), b = sty.pBlue();
741 if (r == 255 && g == 255 && b == 255) 740 if (r == 255 && g == 255 && b == 255)
742 { 741 {
743 sty.setPaper(m_r,m_g,m_b); 742 sty.setPaper(m_r,m_g,m_b);
744 } 743 }
745 else 744 else
746 { 745 {
747 qDebug("We have background [%x%x%x]", r, g, b); 746 qDebug("We have background [%x%x%x]", r, g, b);
748 } 747 }
749 r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue(); 748 r = sty.bRed(), g = sty.bGreen(), b = sty.bBlue();
750 if (r == 255 && g == 255 && b == 255) 749 if (r == 255 && g == 255 && b == 255)
751 { 750 {
752 sty.setBackground(m_r,m_g,m_b); 751 sty.setBackground(m_r,m_g,m_b);
753 } 752 }
754 else 753 else
755 { 754 {
756 qDebug("We have background [%x%x%x]", r, g, b); 755 qDebug("We have background [%x%x%x]", r, g, b);
757 } 756 }
758} 757}
759 758
760void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos) 759void setfg::getch(tchar& ch, CStyle& sty, unsigned long& pos)
761{ 760{
762 parent->getch(ch, sty, pos); 761 parent->getch(ch, sty, pos);
763 int r = sty.Red(), g = sty.Green(), b = sty.Blue(); 762 int r = sty.Red(), g = sty.Green(), b = sty.Blue();
764 if (r == 0 && g == 0 && b == 0) 763 if (r == 0 && g == 0 && b == 0)
765 { 764 {
766 sty.setColour(m_r,m_g,m_b); 765 sty.setColour(m_r,m_g,m_b);
767 } 766 }
768} 767}
769 768
770#include "CRegExp.h" 769#include "CRegExp.h"
771 770
772repara::repara(const QString& pat) : tch(0) 771repara::repara(const QString& pat) : tch(0)
773{ 772{
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
@@ -1,475 +1,474 @@
1#ifndef __CFILTER_H 1#ifndef __CFILTER_H
2#define __CFILTER_H 2#define __CFILTER_H
3 3
4#include "CExpander.h" 4#include "CExpander.h"
5#include "CEncoding.h" 5#include "CEncoding.h"
6 6
7class CFilter_IFace : public CCharacterSource 7class CFilter_IFace : public CCharacterSource
8{ 8{
9 public: 9 public:
10 virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) = 0; 10 virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) = 0;
11 virtual void setparent(CCharacterSource* p) = 0; 11 virtual void setparent(CCharacterSource* p) = 0;
12 virtual ~CFilter_IFace() {}; 12 virtual ~CFilter_IFace() {};
13 virtual void locate(unsigned int n) = 0; 13 virtual void locate(unsigned int n) = 0;
14 virtual bool findanchor(const QString& nm) = 0; 14 virtual bool findanchor(const QString& nm) = 0;
15 virtual void saveposn(const QString& f, size_t posn) = 0; 15 virtual void saveposn(const QString& f, size_t posn) = 0;
16 virtual void writeposn(const QString& f, size_t posn) = 0; 16 virtual void writeposn(const QString& f, size_t posn) = 0;
17 virtual linkType forward(QString& f, size_t& loc) = 0; 17 virtual linkType forward(QString& f, size_t& loc) = 0;
18 virtual linkType back(QString& f, size_t& loc) = 0; 18 virtual linkType back(QString& f, size_t& loc) = 0;
19 virtual bool hasnavigation() = 0; 19 virtual bool hasnavigation() = 0;
20 virtual int getwidth() = 0; 20 virtual int getwidth() = 0;
21 virtual CCharacterSource* getparent() = 0; 21 virtual CCharacterSource* getparent() = 0;
22}; 22};
23 23
24class CFilter : public CFilter_IFace 24class CFilter : public CFilter_IFace
25{ 25{
26 protected: 26 protected:
27 CCharacterSource* parent; 27 CCharacterSource* parent;
28 public: 28 public:
29 virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm) 29 virtual linkType hyperlink(unsigned int n, unsigned int noff, QString& w, QString& nm)
30 { 30 {
31 return parent->hyperlink(n,noff,w,nm); 31 return parent->hyperlink(n,noff,w,nm);
32 } 32 }
33 CFilter() : parent(NULL) {} 33 CFilter() : parent(NULL) {}
34 void setparent(CCharacterSource* p) { parent = p; } 34 void setparent(CCharacterSource* p) { parent = p; }
35 CCharacterSource* getparent() { return parent; } 35 CCharacterSource* getparent() { return parent; }
36 virtual ~CFilter() {}; 36 virtual ~CFilter() {};
37 virtual void locate(unsigned int n) 37 virtual void locate(unsigned int n)
38 { 38 {
39 parent->locate(n); 39 parent->locate(n);
40 } 40 }
41 virtual bool findanchor(const QString& nm) 41 virtual bool findanchor(const QString& nm)
42 { 42 {
43 return parent->findanchor(nm); 43 return parent->findanchor(nm);
44 } 44 }
45 virtual void saveposn(const QString& f, size_t posn) { parent->saveposn(f, posn); } 45 virtual void saveposn(const QString& f, size_t posn) { parent->saveposn(f, posn); }
46 virtual void writeposn(const QString& f, size_t posn) { parent->writeposn(f, posn); } 46 virtual void writeposn(const QString& f, size_t posn) { parent->writeposn(f, posn); }
47 virtual linkType forward(QString& f, size_t& loc) { return parent->forward(f, loc); } 47 virtual linkType forward(QString& f, size_t& loc) { return parent->forward(f, loc); }
48 virtual linkType back(QString& f, size_t& loc) { return parent->back(f, loc); } 48 virtual linkType back(QString& f, size_t& loc) { return parent->back(f, loc); }
49 virtual bool hasnavigation() { return parent->hasnavigation(); } 49 virtual bool hasnavigation() { return parent->hasnavigation(); }
50 virtual int getwidth() { return parent->getwidth(); } 50 virtual int getwidth() { return parent->getwidth(); }
51 QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); } 51 QImage* getPicture(unsigned long tgt) { return parent->getPicture(tgt); }
52 QImage* getPicture(const QString& href) { return parent->getPicture(href); } 52 QImage* getPicture(const QString& href) { return parent->getPicture(href); }
53 bool getFile(const QString& href) { return parent->getFile(href); } 53 bool getFile(const QString& href) { return parent->getFile(href); }
54}; 54};
55 55
56class CFilterChain 56class CFilterChain
57{ 57{
58 CExpander_Interface* expander; 58 CExpander_Interface* expander;
59 CEncoding* encoder; 59 CEncoding* encoder;
60 CFilter_IFace* first; 60 CFilter_IFace* first;
61 CCharacterSource* front; 61 CCharacterSource* front;
62 public: 62 public:
63 CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {}; 63 CFilterChain(CEncoding* _e) : encoder(_e), first(NULL), front(_e) {};
64 ~CFilterChain() 64 ~CFilterChain()
65 { 65 {
66 CCharacterSource* p = front; 66 CCharacterSource* p = front;
67 while (p != encoder) 67 while (p != encoder)
68 { 68 {
69 CFilter_IFace* pnext = (CFilter_IFace*)p; 69 CFilter_IFace* pnext = (CFilter_IFace*)p;
70 p = ((CFilter_IFace*)p)->getparent(); 70 p = ((CFilter_IFace*)p)->getparent();
71 delete pnext; 71 delete pnext;
72 } 72 }
73 delete encoder; 73 delete encoder;
74 } 74 }
75 linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm) 75 linkType hyperlink(unsigned int n, unsigned int noff, QString& wrd, QString& nm)
76 { 76 {
77 return front->hyperlink(n, noff, wrd, nm); 77 return front->hyperlink(n, noff, wrd, nm);
78 } 78 }
79 void locate(unsigned int n) 79 void locate(unsigned int n)
80 { 80 {
81 front->locate(n); 81 front->locate(n);
82 } 82 }
83 void getch(tchar& ch, CStyle& sty, unsigned long& pos) 83 void getch(tchar& ch, CStyle& sty, unsigned long& pos)
84 { 84 {
85 front->getch(ch, sty, pos); 85 front->getch(ch, sty, pos);
86 } 86 }
87 void addfilter(CFilter_IFace* p) 87 void addfilter(CFilter_IFace* p)
88 { 88 {
89 if (first == NULL) 89 if (first == NULL)
90 { 90 {
91 front = first = p; 91 front = first = p;
92 p->setparent(encoder); 92 p->setparent(encoder);
93 } 93 }
94 else 94 else
95 { 95 {
96 p->setparent(front); 96 p->setparent(front);
97 front = p; 97 front = p;
98 } 98 }
99 } 99 }
100 void setsource(CExpander_Interface* p) 100 void setsource(CExpander_Interface* p)
101 { 101 {
102 expander = p; 102 expander = p;
103 encoder->setparent(p); 103 encoder->setparent(p);
104 } 104 }
105 void setencoder(CEncoding* p) 105 void setencoder(CEncoding* p)
106 { 106 {
107 delete encoder; 107 delete encoder;
108 encoder = p; 108 encoder = p;
109 first->setparent(p); 109 first->setparent(p);
110 encoder->setparent(expander); 110 encoder->setparent(expander);
111 } 111 }
112 bool findanchor(const QString& nm) 112 bool findanchor(const QString& nm)
113 { 113 {
114 return front->findanchor(nm); 114 return front->findanchor(nm);
115 } 115 }
116 void saveposn(const QString& f, size_t posn) { front->saveposn(f, posn); } 116 void saveposn(const QString& f, size_t posn) { front->saveposn(f, posn); }
117 void writeposn(const QString& f, size_t posn) { front->writeposn(f, posn); } 117 void writeposn(const QString& f, size_t posn) { front->writeposn(f, posn); }
118 linkType forward(QString& f, size_t& loc) { return front->forward(f, loc); } 118 linkType forward(QString& f, size_t& loc) { return front->forward(f, loc); }
119 linkType back(QString& f, size_t& loc) { return front->back(f, loc); } 119 linkType back(QString& f, size_t& loc) { return front->back(f, loc); }
120 bool hasnavigation() { return front->hasnavigation(); } 120 bool hasnavigation() { return front->hasnavigation(); }
121 QString about() { return QString("Filter chain (c) Tim Wentford\n")+front->about(); } 121 QString about() { return QString("Filter chain (c) Tim Wentford\n")+front->about(); }
122}; 122};
123 123
124class stripcr : public CFilter 124class stripcr : public CFilter
125{ 125{
126 public: 126 public:
127 stripcr() {} 127 stripcr() {}
128 ~stripcr() {} 128 ~stripcr() {}
129 void getch(tchar& ch, CStyle& sty, unsigned long& pos) 129 void getch(tchar& ch, CStyle& sty, unsigned long& pos)
130 { 130 {
131 do 131 do
132 { 132 {
133 parent->getch(ch, sty, pos); 133 parent->getch(ch, sty, pos);
134 } 134 }
135 while (ch == 13); 135 while (ch == 13);
136 } 136 }
137 QString about() { return QString("StripCR filter (c) Tim Wentford\n")+parent->about(); } 137 QString about() { return QString("StripCR filter (c) Tim Wentford\n")+parent->about(); }
138}; 138};
139 139
140class dehyphen : public CFilter 140class dehyphen : public CFilter
141{ 141{
142 bool m_bCharWaiting; 142 bool m_bCharWaiting;
143 tchar m_nextChar; 143 tchar m_nextChar;
144 CStyle m_nextSty; 144 CStyle m_nextSty;
145 public: 145 public:
146 dehyphen() : m_bCharWaiting(false) {} 146 dehyphen() : m_bCharWaiting(false) {}
147 ~dehyphen() {} 147 ~dehyphen() {}
148 void getch(tchar& ch, CStyle& sty, unsigned long& pos) 148 void getch(tchar& ch, CStyle& sty, unsigned long& pos)
149 { 149 {
150 if (m_bCharWaiting) 150 if (m_bCharWaiting)
151 { 151 {
152 m_bCharWaiting = false; 152 m_bCharWaiting = false;
153 ch = m_nextChar; 153 ch = m_nextChar;
154 sty = m_nextSty; 154 sty = m_nextSty;
155 return; 155 return;
156 } 156 }
157 parent->getch(ch, sty, pos); 157 parent->getch(ch, sty, pos);
158 if (ch != '-') return; 158 if (ch != '-') return;
159 parent->getch(m_nextChar, m_nextSty, pos); 159 parent->getch(m_nextChar, m_nextSty, pos);
160 if (m_nextChar != 10) 160 if (m_nextChar != 10)
161 { 161 {
162 m_bCharWaiting = true; 162 m_bCharWaiting = true;
163 ch = '-'; 163 ch = '-';
164 return; 164 return;
165 } 165 }
166 parent->getch(ch, sty, pos); 166 parent->getch(ch, sty, pos);
167 } 167 }
168 QString about() { return QString("Hyphenation filter (c) Tim Wentford\n")+parent->about(); } 168 QString about() { return QString("Hyphenation filter (c) Tim Wentford\n")+parent->about(); }
169}; 169};
170 170
171template<class A, class B>class QMap; 171template<class A, class B>class QMap;
172 172
173const int m_cmaxdepth = 8; 173const int m_cmaxdepth = 8;
174 174
175class htmlmark 175class htmlmark
176{ 176{
177 QString file; 177 QString file;
178 size_t pos; 178 size_t pos;
179 public: 179 public:
180 htmlmark() : file(), pos(0) {} 180 htmlmark() : file(), pos(0) {}
181 htmlmark(const QString& _f, size_t _p) : file(_f), pos(_p) {} 181 htmlmark(const QString& _f, size_t _p) : file(_f), pos(_p) {}
182 QString filename() { return file; } 182 QString filename() { return file; }
183 size_t posn() { return pos; } 183 size_t posn() { return pos; }
184}; 184};
185 185
186class unindent : public CFilter 186class unindent : public CFilter
187{ 187{
188 tchar lc; 188 tchar lc;
189 public: 189 public:
190 unindent() : lc(0) {} 190 unindent() : lc(0) {}
191 ~unindent() {} 191 ~unindent() {}
192 void getch(tchar& ch, CStyle& sty, unsigned long& pos) 192 void getch(tchar& ch, CStyle& sty, unsigned long& pos)
193 { 193 {
194 if (lc == 10) 194 if (lc == 10)
195 { 195 {
196 do 196 do
197 { 197 {
198 parent->getch(ch, sty, pos); 198 parent->getch(ch, sty, pos);
199 } 199 }
200 while (ch == ' '); 200 while (ch == ' ');
201 } 201 }
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
209class CRegExpFilt; 209class CRegExpFilt;
210class repara : public CFilter 210class 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
221class indenter : public CFilter 221class 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
249class dblspce : public CFilter 249class 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
275class textfmt : public CFilter 275class 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
288class embolden : public CFilter 288class 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
301class remap : public CFilter 301class 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
313class PeanutFormatter : public CFilter 313class 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
322class OnePara : public CFilter 322class 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
332class DePluck : public CFilter 332class 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
347class repalm : public CFilter 347class 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
355class FullJust : public CFilter 355class 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/*
366class AddSpace : public CFilter 366class 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
379class QTReader; 379class QTReader;
380 380
381class HighlightFilter : public CFilter 381class 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
398class ExternFilter : public CFilter_IFace 397class 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
432class kern : public CFilter 431class 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
444class makeInverse : public CFilter 443class 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/*
451class makeNegative : public CFilter 450class 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*/
457class setbg : public CFilter 456class 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
466class setfg : public CFilter 465class 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,380 +1,379 @@
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
11extern "C" 10extern "C"
12{ 11{
13 CExpander* newcodec() { return new CHM; } 12 CExpander* newcodec() { return new CHM; }
14} 13}
15#endif 14#endif
16 15
17static int _print_ui_index(struct chmFile *h, struct chmUnitInfo *ui, 16static 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
29static int _get_hhc (struct chmFile *h, struct chmUnitInfo *ui, 28static 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
40CHM::CHM() { 39CHM::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
48CHM::~CHM() { 47CHM::~CHM() {
49 if (chmFile != NULL) 48 if (chmFile != NULL)
50 chm_close(chmFile); 49 chm_close(chmFile);
51} 50}
52 51
53void CHM::suspend() { 52void 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
63void CHM::unsuspend() { 62void 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
85void CHM::addContent(QString content) { 84void CHM::addContent(QString content) {
86 chmBuffer += content; 85 chmBuffer += content;
87} 86}
88 87
89void CHM::FillHomeContent() { 88void 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
164bool CHM::FillBuffer() 163bool 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();
196 return bRetVal; 195 return bRetVal;
197} 196}
198 197
199bool CHM::FillContent() { 198bool CHM::FillContent() {
200 bool bRetVal = false; 199 bool bRetVal = false;
201 if (chmPath != "") { 200 if (chmPath != "") {
202 /* try to find the file */ 201 /* try to find the file */
203 const char *filename = (const char *)chmPath; 202 const char *filename = (const char *)chmPath;
204 if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS) 203 if (chm_resolve_object(chmFile, filename, &m_ui) != CHM_RESOLVE_SUCCESS)
205 { 204 {
206 fsize = chmBuffer.length(); 205 fsize = chmBuffer.length();
207 return bRetVal; 206 return bRetVal;
208 } 207 }
209 208
210 char buffer[65536]; 209 char buffer[65536];
211 int swath, offset; 210 int swath, offset;
212 chmBuffer = ""; 211 chmBuffer = "";
213 swath = 65536; 212 swath = 65536;
214 offset = 0; 213 offset = 0;
215 fsize = m_ui.length; 214 fsize = m_ui.length;
216 while (offset < m_ui.length) 215 while (offset < m_ui.length)
217 { 216 {
218 if ((m_ui.length - offset) < 65536) 217 if ((m_ui.length - offset) < 65536)
219 swath = m_ui.length - offset; 218 swath = m_ui.length - offset;
220 else 219 else
221 swath = 65536; 220 swath = 65536;
222 swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath); 221 swath = (int)chm_retrieve_object(chmFile, &m_ui, (unsigned char *) buffer, offset, swath);
223 chmBuffer += buffer; 222 chmBuffer += buffer;
224 offset += swath; 223 offset += swath;
225 } 224 }
226 //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it 225 //There seems to be a ton of gobbledygook at the end that is reminiscent of the hhc file - remove it
227 QString temp = chmBuffer.lower(); 226 QString temp = chmBuffer.lower();
228 int lpos = temp.find("</html"); 227 int lpos = temp.find("</html");
229 if (lpos > -1) { 228 if (lpos > -1) {
230 chmBuffer.truncate(lpos); 229 chmBuffer.truncate(lpos);
231 chmBuffer = chmBuffer+"</HTML>"; 230 chmBuffer = chmBuffer+"</HTML>";
232 } 231 }
233 fsize = chmBuffer.length(); 232 fsize = chmBuffer.length();
234 233
235 bufpos = 0; 234 bufpos = 0;
236 m_currentstart = m_ui.start; 235 m_currentstart = m_ui.start;
237 m_currentend = m_currentstart+chmBuffer.length(); 236 m_currentend = m_currentstart+chmBuffer.length();
238 bRetVal = true; 237 bRetVal = true;
239 } 238 }
240 return bRetVal; 239 return bRetVal;
241} 240}
242 241
243bool CHM::getFile(const QString& href) { 242bool CHM::getFile(const QString& href) {
244 qDebug("Got:%s", (const char*)href); 243 qDebug("Got:%s", (const char*)href);
245 bool bRetVal = false; 244 bool bRetVal = false;
246 QString temp = chmPath; 245 QString temp = chmPath;
247 chmPath = href; 246 chmPath = href;
248 if (FillContent()) { 247 if (FillContent()) {
249 qDebug("Got it"); 248 qDebug("Got it");
250 bRetVal = true; 249 bRetVal = true;
251 } else { 250 } else {
252 qDebug("Missed"); 251 qDebug("Missed");
253 chmPath = temp; 252 chmPath = temp;
254 FillContent(); 253 FillContent();
255 } 254 }
256 return bRetVal; 255 return bRetVal;
257} 256}
258 257
259QImage *CHM::getPicture(const QString& href) { 258QImage *CHM::getPicture(const QString& href) {
260 QImage *img = NULL; 259 QImage *img = NULL;
261 QString PicRef = "/"+href; 260 QString PicRef = "/"+href;
262 struct chmUnitInfo ui; 261 struct chmUnitInfo ui;
263 const char *ext; 262 const char *ext;
264 /* try to find the file */ 263 /* try to find the file */
265 const char *filename = (const char *)PicRef; 264 const char *filename = (const char *)PicRef;
266 if (chm_resolve_object(chmFile, filename, &ui) != CHM_RESOLVE_SUCCESS) 265 if (chm_resolve_object(chmFile, filename, &ui) != CHM_RESOLVE_SUCCESS)
267 { 266 {
268 qDebug ("Could not resolve image"); 267 qDebug ("Could not resolve image");
269 return img; 268 return img;
270 } 269 }
271 if (ui.length > 0) { 270 if (ui.length > 0) {
272 char *temp = new char[ui.length]; 271 char *temp = new char[ui.length];
273 char buffer[65536]; 272 char buffer[65536];
274 int swath, offset; 273 int swath, offset;
275 swath = 65536; 274 swath = 65536;
276 offset = 0; 275 offset = 0;
277 276
278 while (offset < ui.length) 277 while (offset < ui.length)
279 { 278 {
280 if ((ui.length - offset) < 65536) 279 if ((ui.length - offset) < 65536)
281 swath = ui.length - offset; 280 swath = ui.length - offset;
282 else 281 else
283 swath = 65536; 282 swath = 65536;
284 swath = (int)chm_retrieve_object(chmFile, &ui, (unsigned char *) buffer, offset, swath); 283 swath = (int)chm_retrieve_object(chmFile, &ui, (unsigned char *) buffer, offset, swath);
285 memcpy( (void *) (temp + offset), (void *)&buffer, swath ); 284 memcpy( (void *) (temp + offset), (void *)&buffer, swath );
286 offset += swath; 285 offset += swath;
287 } 286 }
288 QByteArray qba; 287 QByteArray qba;
289 qba.setRawData( (const char *)temp, ui.length); 288 qba.setRawData( (const char *)temp, ui.length);
290 QPixmap qpm(qba); 289 QPixmap qpm(qba);
291 img = new QImage(qpm.convertToImage()); 290 img = new QImage(qpm.convertToImage());
292 qba.resetRawData((const char *)temp, ui.length); 291 qba.resetRawData((const char *)temp, ui.length);
293 delete[] temp; 292 delete[] temp;
294 } 293 }
295 294
296 return img; 295 return img;
297} 296}
298 297
299int CHM::OpenFile(const char *src) { 298int CHM::OpenFile(const char *src) {
300 if (chmFile != NULL) chm_close(chmFile); 299 if (chmFile != NULL) chm_close(chmFile);
301 struct stat _stat; 300 struct stat _stat;
302 stat(src,&_stat); 301 stat(src,&_stat);
303 fsize = _stat.st_size; 302 fsize = _stat.st_size;
304 chmFile = chm_open(src); 303 chmFile = chm_open(src);
305 if (chmFile != NULL) { 304 if (chmFile != NULL) {
306 chm_enumerate(chmFile, 305 chm_enumerate(chmFile,
307 CHM_ENUMERATE_ALL, 306 CHM_ENUMERATE_ALL,
308 _get_hhc, 307 _get_hhc,
309 (void *)this); 308 (void *)this);
310 if ( chmPath != "") { 309 if ( chmPath != "") {
311 setHomePath(chmPath); 310 setHomePath(chmPath);
312 FillHomeContent(); 311 FillHomeContent();
313 } 312 }
314 } 313 }
315 m_homepos = locate(); 314 m_homepos = locate();
316 qDebug("Home:%u", m_homepos); 315 qDebug("Home:%u", m_homepos);
317 return (chmFile==NULL); 316 return (chmFile==NULL);
318} 317}
319 318
320int CHM::getch() { 319int CHM::getch() {
321 if ( (bufpos+1) >= chmBuffer.length() ) 320 if ( (bufpos+1) >= chmBuffer.length() )
322 return EOF; 321 return EOF;
323#ifdef _WINDOWS 322#ifdef _WINDOWS
324 QChar letter = chmBuffer.at(bufpos++); 323 QChar letter = chmBuffer.at(bufpos++);
325#else 324#else
326 QChar letter = chmBuffer[bufpos++]; 325 QChar letter = chmBuffer[bufpos++];
327#endif 326#endif
328 return (int)(char)letter; 327 return (int)(char)letter;
329} 328}
330 329
331void CHM::getch(tchar& ch, CStyle& sty) 330void CHM::getch(tchar& ch, CStyle& sty)
332{ 331{
333 int ich = getch(); 332 int ich = getch();
334 ch = (ich == EOF) ? UEOF : ich; 333 ch = (ich == EOF) ? UEOF : ich;
335} 334}
336 335
337void CHM::start2endSection() 336void CHM::start2endSection()
338{ 337{
339 m_currentstart = m_ui.start; 338 m_currentstart = m_ui.start;
340 m_currentend = m_currentstart+chmBuffer.length(); 339 m_currentend = m_currentstart+chmBuffer.length();
341} 340}
342 341
343unsigned int CHM::locate() { 342unsigned int CHM::locate() {
344 return m_currentstart+bufpos; 343 return m_currentstart+bufpos;
345} 344}
346 345
347void CHM::locate(unsigned int n) { 346void CHM::locate(unsigned int n) {
348 if (n == 0) n = m_homepos; 347 if (n == 0) n = m_homepos;
349 if (n >= m_homestart && n < m_homeend) 348 if (n >= m_homestart && n < m_homeend)
350 { 349 {
351 FillHomeContent(); 350 FillHomeContent();
352 bufpos = n - m_homestart; 351 bufpos = n - m_homestart;
353 start2endSection(); 352 start2endSection();
354 qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); 353 qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend);
355 } 354 }
356 else if (n >= m_currentstart && n < m_currentend) 355 else if (n >= m_currentstart && n < m_currentend)
357 { 356 {
358 bufpos = n - m_currentstart; 357 bufpos = n - m_currentstart;
359 } 358 }
360 else if (CHM_RESOLVE_FAILURE == chm_resolve_location(chmFile, n/4, &m_ui)) 359 else if (CHM_RESOLVE_FAILURE == chm_resolve_location(chmFile, n/4, &m_ui))
361 { 360 {
362 qDebug("Resolve failure"); 361 qDebug("Resolve failure");
363 FillHomeContent(); 362 FillHomeContent();
364 bufpos = 0; 363 bufpos = 0;
365 start2endSection(); 364 start2endSection();
366 qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); 365 qDebug("Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend);
367 } 366 }
368 else 367 else
369 { 368 {
370 qDebug("Resolve success"); 369 qDebug("Resolve success");
371 FillBuffer(); 370 FillBuffer();
372 start2endSection(); 371 start2endSection();
373 bufpos=n-m_currentstart; 372 bufpos=n-m_currentstart;
374 qDebug("Not Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend); 373 qDebug("Not Home:%u:<%u, %u, %u>", m_ui.start, m_currentstart, n, m_currentend);
375 } 374 }
376} 375}
377 376
378void CHM::sizes(unsigned long& _file, unsigned long& _text) { 377void CHM::sizes(unsigned long& _file, unsigned long& _text) {
379 _text = _file = fsize; 378 _text = _file = fsize;
380} 379}
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
11struct Ref { 10struct 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
18struct Pic { 17struct 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
25class CHM : public CExpander 24class 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;
39public: 38public:
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"); }
63private : 62private :
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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
13LIBS += -lreader_codec 13LIBS += -lreader_codec
14 14
15 INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include 15 INCLUDEPATH+= $(OPIEDIR)/include
16 DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include 16 DEPENDPATH+= $(OPIEDIR)/include
17 17
18include ( $(OPIEDIR)/include.pro ) \ No newline at end of file 18include ( $(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
24class QVBoxLayout; 23class QVBoxLayout;
25class QHBoxLayout; 24class QHBoxLayout;
26class QGridLayout; 25class QGridLayout;
27//class QCheckBox; 26//class QCheckBox;
28class QLabel; 27class QLabel;
29//class QSpinBox; 28//class QSpinBox;
30 29
31class CCloseDialog : public QDialog 30class CCloseDialog : public QDialog
32{ 31{
33Q_OBJECT 32Q_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
5int FontControl::gzoom() 4int 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
34bool FontControl::ChangeFont(QString& n, int tgt) 33bool 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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
11QMAKE_PRE_LINK = mkdir -p $(OPIEDIR)/plugins/reader/data && cp ../HTMLentities $(OPIEDIR)/plugins/reader/data/HTMLentities 11QMAKE_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
20include ( $(OPIEDIR)/include.pro ) 20include ( $(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,299 +1,298 @@
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
39typedef struct { 38typedef 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
45static ColorMapEntry Palm8BitColormap[] = { 44static 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
111static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }}; 110static ColorMapEntry Palm1BitColormap[] = {{ 255, 255, 255 }, { 0, 0, 0 }};
112 111
113static ColorMapEntry Palm2BitColormap[] = { 112static 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
116static ColorMapEntry Palm4BitColormap[] = { 115static 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
122QImage* Palm2QImage 121QImage* 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;
195 } 194 }
196 if (bits_per_pixel > (8 * sizeof(unsigned long))) { 195 if (bits_per_pixel > (8 * sizeof(unsigned long))) {
197// qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel); 196// qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel);
198 return NULL; 197 return NULL;
199 } 198 }
200 imagedatastart = palmimage + 24; 199 imagedatastart = palmimage + 24;
201 } else { 200 } else {
202// qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel); 201// qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel);
203 return NULL; 202 return NULL;
204 } 203 }
205 204
206#ifndef USEQPE 205#ifndef USEQPE
207 QImage* qimage = new QImage(width, height, 32); 206 QImage* qimage = new QImage(width, height, 32);
208#else 207#else
209 QImage* qimage = new QImage(width, height, 16); 208 QImage* qimage = new QImage(width, height, 16);
210#endif 209#endif
211 210
212 /* row by row, uncompress the Palm image and copy it to the JPEG buffer */ 211 /* row by row, uncompress the Palm image and copy it to the JPEG buffer */
213 rowbuf = new unsigned char[bytes_per_row * width]; 212 rowbuf = new unsigned char[bytes_per_row * width];
214 lastrow = new unsigned char[bytes_per_row * width]; 213 lastrow = new unsigned char[bytes_per_row * width];
215 214
216 for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) { 215 for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) {
217// qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row); 216// qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row);
218 217
219 /* first, uncompress the Palm image */ 218 /* first, uncompress the Palm image */
220 if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) { 219 if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) {
221 for (j = 0; j < bytes_per_row; ) { 220 for (j = 0; j < bytes_per_row; ) {
222 incount = *palm_ptr++; 221 incount = *palm_ptr++;
223 inval = *palm_ptr++; 222 inval = *palm_ptr++;
224 memset(rowbuf + j, inval, incount); 223 memset(rowbuf + j, inval, incount);
225 j += incount; 224 j += incount;
226 } 225 }
227 } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) { 226 } else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) {
228 for (j = 0; j < bytes_per_row; j += 8) { 227 for (j = 0; j < bytes_per_row; j += 8) {
229 incount = *palm_ptr++; 228 incount = *palm_ptr++;
230 inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8; 229 inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8;
231 for (inbit = 0; inbit < inval; inbit += 1) { 230 for (inbit = 0; inbit < inval; inbit += 1) {
232 if (incount & (1 << (7 - inbit))) 231 if (incount & (1 << (7 - inbit)))
233 rowbuf[j + inbit] = *palm_ptr++; 232 rowbuf[j + inbit] = *palm_ptr++;
234 else 233 else
235 rowbuf[j + inbit] = lastrow[j + inbit]; 234 rowbuf[j + inbit] = lastrow[j + inbit];
236 } 235 }
237 } 236 }
238 memcpy (lastrow, rowbuf, bytes_per_row); 237 memcpy (lastrow, rowbuf, bytes_per_row);
239 } else if (((flags & PALM_IS_COMPRESSED_FLAG) && 238 } else if (((flags & PALM_IS_COMPRESSED_FLAG) &&
240 (compression_type == PALM_COMPRESSION_NONE)) || 239 (compression_type == PALM_COMPRESSION_NONE)) ||
241 ((flags & PALM_IS_COMPRESSED_FLAG) == 0)) 240 ((flags & PALM_IS_COMPRESSED_FLAG) == 0))
242 { 241 {
243 memcpy (rowbuf, palm_ptr, bytes_per_row); 242 memcpy (rowbuf, palm_ptr, bytes_per_row);
244 palm_ptr += bytes_per_row; 243 palm_ptr += bytes_per_row;
245 } 244 }
246 else { 245 else {
247 qDebug("Case 4"); 246 qDebug("Case 4");
248 qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true"); 247 qDebug("Is compressed:%s", ((flags & PALM_IS_COMPRESSED_FLAG) == 0) ? "false" : "true");
249 qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true"); 248 qDebug("Has colourmap:%s", ((flags & PALM_HAS_COLORMAP_FLAG) == 0) ? "false" : "true");
250 qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true"); 249 qDebug("Has transparency:%s", ((flags & PALM_HAS_TRANSPARENCY_FLAG) == 0) ? "false" : "true");
251 qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true"); 250 qDebug("Direct colour:%s", ((flags & PALM_DIRECT_COLOR_FLAG) == 0) ? "false" : "true");
252 qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true"); 251 qDebug("four byte field:%s", ((flags & PALM_4_BYTE_FIELD_FLAG) == 0) ? "false" : "true");
253 memcpy (rowbuf, palm_ptr, bytes_per_row); 252 memcpy (rowbuf, palm_ptr, bytes_per_row);
254 palm_ptr += bytes_per_row; 253 palm_ptr += bytes_per_row;
255 } 254 }
256 /* next, write it to the GDK bitmap */ 255 /* next, write it to the GDK bitmap */
257 if (colormap) { 256 if (colormap) {
258 mask = (1 << bits_per_pixel) - 1; 257 mask = (1 << bits_per_pixel) - 1;
259 for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) { 258 for (inbit = 8 - bits_per_pixel, inbyte = rowbuf, j = 0; j < width; ++j) {
260 inval = ((*inbyte) & (mask << inbit)) >> inbit; 259 inval = ((*inbyte) & (mask << inbit)) >> inbit;
261 /* correct for oddity of the 8-bit color Palm pixmap... */ 260 /* correct for oddity of the 8-bit color Palm pixmap... */
262 if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231; 261 if ((bits_per_pixel == 8) && (inval == 0xFF)) inval = 231;
263 /* now lookup the correct color and set the pixel in the GTK bitmap */ 262 /* now lookup the correct color and set the pixel in the GTK bitmap */
264 QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue); 263 QRgb colour = qRgb(colormap[inval].red, colormap[inval].green, colormap[inval].blue);
265 qimage->setPixel(j, i, colour); 264 qimage->setPixel(j, i, colour);
266 if (!inbit) { 265 if (!inbit) {
267 ++inbyte; 266 ++inbyte;
268 inbit = 8 - bits_per_pixel; 267 inbit = 8 - bits_per_pixel;
269 } else { 268 } else {
270 inbit -= bits_per_pixel; 269 inbit -= bits_per_pixel;
271 } 270 }
272 } 271 }
273 } else if (!colormap && 272 } else if (!colormap &&
274 bits_per_pixel == 16) { 273 bits_per_pixel == 16) {
275 for (inbyte = rowbuf, j = 0; j < width; ++j) { 274 for (inbyte = rowbuf, j = 0; j < width; ++j) {
276 inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1]; 275 inval = ((unsigned short)inbyte[0] << (unsigned short)8) | inbyte[1];
277 276
278/* 277/*
279 qDebug ("pixel is %d,%d (%d:%d:%d)", 278 qDebug ("pixel is %d,%d (%d:%d:%d)",
280 j, i, 279 j, i,
281 ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), 280 ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits),
282 ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), 281 ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits),
283 ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); 282 ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits));
284*/ 283*/
285 QRgb colour = qRgb( 284 QRgb colour = qRgb(
286 ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits), 285 ((inval >> (bits_per_pixel - palm_red_bits)) & ((1 << palm_red_bits) - 1)) << (8-palm_red_bits),
287 ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits), 286 ((inval >> palm_blue_bits) & ((1 << palm_green_bits) - 1)) << (8-palm_green_bits),
288 ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits)); 287 ((inval >> 0) & ((1 << palm_blue_bits) - 1)) << (8-palm_blue_bits));
289 qimage->setPixel(j, i, colour); 288 qimage->setPixel(j, i, colour);
290 inbyte += 2; 289 inbyte += 2;
291 } 290 }
292 } 291 }
293 } 292 }
294 293
295 delete [] rowbuf; 294 delete [] rowbuf;
296 delete [] lastrow; 295 delete [] lastrow;
297 296
298 return qimage; 297 return qimage;
299} 298}
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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
13LIBS += -lreader_pdb -lreader_pluckerbase -lreader_codec 13LIBS += -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
18include ( $(OPIEDIR)/include.pro ) 18include ( $(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,781 +1,780 @@
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
11const int _SBARHEIGHT = 3; 11const 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
38const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 }; 37const char *QTReader::fonts[] = { "unifont", "Courier", "Times", 0 };
39#else 38#else
40const char *QTReader::fonts[] = { "Helvetica", "Courier", "Times", 0 }; 39const 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
49tchar 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 }; 48tchar 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 };
50tchar QTReader::jplucknextpart[] = { 'N','e','x','t',' ','P','a','r','t',' ','>','>',0 }; 49tchar 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
54QTReader::QTReader( QWidget *parent, const char *name, WFlags f) : 53QTReader::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/*
106QTReader::QTReader( const QString& filename, QWidget *parent=0, const tchar *name=0, WFlags f = 0) : 105QTReader::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/*
127void QTReader::mouseMoveEvent(QMouseEvent* _e) 126void 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*/
135long QTReader::real_delay() 134long 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
140void QTReader::mousePressEvent( QMouseEvent* _e ) 139void 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
182void QTReader::processmousepositionevent( QMouseEvent* _e ) 181void 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)
206 { 205 {
207 goUp(); 206 goUp();
208 } 207 }
209 else 208 else
210 { 209 {
211 if (x < wh/3) 210 if (x < wh/3)
212 { 211 {
213 goBack(); 212 goBack();
214 } 213 }
215 else if (x > (2*wh)/3) 214 else if (x > (2*wh)/3)
216 { 215 {
217 goForward(); 216 goForward();
218 } 217 }
219 else 218 else
220 { 219 {
221 goHome(); 220 goHome();
222 } 221 }
223 } 222 }
224 } 223 }
225 else 224 else
226 { 225 {
227 if (y > ht/2) 226 if (y > ht/2)
228 { 227 {
229 goDown(); 228 goDown();
230 } 229 }
231 else 230 else
232 { 231 {
233 goUp(); 232 goUp();
234 } 233 }
235 } 234 }
236} 235}
237 236
238void QTReader::goHome() 237void QTReader::goHome()
239{ 238{
240 if (buffdoc.hasnavigation()) 239 if (buffdoc.hasnavigation())
241 { 240 {
242 size_t current=pagelocate(); 241 size_t current=pagelocate();
243 size_t home=buffdoc.getHome(); 242 size_t home=buffdoc.getHome();
244 if (current!=home) 243 if (current!=home)
245 { 244 {
246 buffdoc.saveposn(m_lastfile, current); 245 buffdoc.saveposn(m_lastfile, current);
247 locate(home); 246 locate(home);
248 } 247 }
249 } 248 }
250 else 249 else
251 locate(0); 250 locate(0);
252} 251}
253 252
254void QTReader::goBack() 253void QTReader::goBack()
255{ 254{
256 if (buffdoc.hasnavigation()) 255 if (buffdoc.hasnavigation())
257 { 256 {
258 size_t target = pagelocate(); 257 size_t target = pagelocate();
259 QString nxt = m_lastfile; 258 QString nxt = m_lastfile;
260 buffdoc.writeposn(m_lastfile, target); 259 buffdoc.writeposn(m_lastfile, target);
261 linkType lt = buffdoc.back(nxt, target); 260 linkType lt = buffdoc.back(nxt, target);
262 if ((lt & eFile) != 0) 261 if ((lt & eFile) != 0)
263 { 262 {
264 if (nxt != m_lastfile) 263 if (nxt != m_lastfile)
265 { 264 {
266 emit NewFileRequest(nxt); 265 emit NewFileRequest(nxt);
267 } 266 }
268 locate(target); 267 locate(target);
269 } 268 }
270 else if ((lt & eLink) != 0) 269 else if ((lt & eLink) != 0)
271 { 270 {
272 locate(target); 271 locate(target);
273 } 272 }
274 } 273 }
275} 274}
276 275
277void QTReader::goForward() 276void QTReader::goForward()
278{ 277{
279 if (buffdoc.hasnavigation()) 278 if (buffdoc.hasnavigation())
280 { 279 {
281 size_t target = pagelocate(); 280 size_t target = pagelocate();
282 QString nxt = m_lastfile; 281 QString nxt = m_lastfile;
283 linkType lt = buffdoc.forward(nxt, target); 282 linkType lt = buffdoc.forward(nxt, target);
284 if ((lt & eFile) != 0) 283 if ((lt & eFile) != 0)
285 { 284 {
286 if (nxt != m_lastfile) 285 if (nxt != m_lastfile)
287 { 286 {
288 emit NewFileRequest(nxt); 287 emit NewFileRequest(nxt);
289 } 288 }
290 locate(target); 289 locate(target);
291 } 290 }
292 else if ((lt & eLink) != 0) 291 else if ((lt & eLink) != 0)
293 { 292 {
294 locate(target); 293 locate(target);
295 } 294 }
296 } 295 }
297} 296}
298 297
299linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img) 298linkType QTReader::getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*& img)
300{ 299{
301 int ht; 300 int ht;
302 if (m_scrolldy == m_topmargin) 301 if (m_scrolldy == m_topmargin)
303 { 302 {
304 lineno = 0; 303 lineno = 0;
305 ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin; 304 ht = textarray[0]->lineSpacing()-m_scrolldy1 + m_topmargin;
306 } 305 }
307 else 306 else
308 { 307 {
309 if (y >= m_scrolldy) 308 if (y >= m_scrolldy)
310 { 309 {
311 lineno = 0; 310 lineno = 0;
312 ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy + m_topmargin; 311 ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy + m_topmargin;
313 } 312 }
314 else 313 else
315 { 314 {
316 lineno = 0; 315 lineno = 0;
317 ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy+m_topmargin; 316 ht = textarray[0]->lineSpacing()-m_scrolldy1+m_scrolldy+m_topmargin;
318 while ((ht < h) && (lineno < numlines-1)) 317 while ((ht < h) && (lineno < numlines-1))
319 { 318 {
320 ht += textarray[++lineno]->lineSpacing(); 319 ht += textarray[++lineno]->lineSpacing();
321 } 320 }
322 ht = textarray[lineno]->lineSpacing(); 321 ht = textarray[lineno]->lineSpacing();
323 } 322 }
324 } 323 }
325 while ((ht < y) && (lineno < numlines-1)) 324 while ((ht < y) && (lineno < numlines-1))
326 { 325 {
327 ht += textarray[++lineno]->lineSpacing(); 326 ht += textarray[++lineno]->lineSpacing();
328 } 327 }
329 if (ht < y && textarray[numlines]->showPartial()) lineno = numlines; 328 if (ht < y && textarray[numlines]->showPartial()) lineno = numlines;
330 start = locnarray[lineno]; 329 start = locnarray[lineno];
331 int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; 330 int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin;
332 if (m_bMonoSpaced) 331 if (m_bMonoSpaced)
333 { 332 {
334 offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth; 333 offset = (x - textarray[lineno]->offset(w, m_left_border, m_right_border, availht))/m_charWidth;
335 } 334 }
336 else 335 else
337 { 336 {
338 int i; 337 int i;
339 CDrawBuffer* t = textarray[lineno]; 338 CDrawBuffer* t = textarray[lineno];
340 x = x - t->offset(width(), m_left_border, m_right_border, availht); 339 x = x - t->offset(width(), m_left_border, m_right_border, availht);
341 for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--); 340 for (i = t->length(); i > 0 && t->width(availht, i, true, w, m_left_border, m_right_border) > x; i--);
342 offset = i; 341 offset = i;
343 } 342 }
344 return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img); 343 return textarray[lineno]->getLinkType(offset, tgt, tgtoffset, pictgt, img);
345} 344}
346 345
347void QTReader::suspend() 346void QTReader::suspend()
348{ 347{
349 buffdoc.suspend(); 348 buffdoc.suspend();
350 /*#ifdef OPIE 349 /*#ifdef OPIE
351 if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend(); 350 if (memcmp("/mnt/", m_lastfile.latin1(), 5) == 0) buffdoc.suspend();
352#else 351#else
353 if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend(); 352 if (memcmp("/usr/mnt.rom/", m_lastfile.latin1(), 13) == 0) buffdoc.suspend();
354#endif 353#endif
355 */ 354 */
356} 355}
357 356
358void QTReader::setTwoTouch(bool _b) 357void QTReader::setTwoTouch(bool _b)
359{ 358{
360 setBackgroundColor( m_bg ); 359 setBackgroundColor( m_bg );
361 m_twotouch = m_touchone = _b; 360 m_twotouch = m_touchone = _b;
362} 361}
363 362
364void QTReader::setContinuous(bool _b) 363void QTReader::setContinuous(bool _b)
365{ 364{
366 buffdoc.unsuspend(); 365 buffdoc.unsuspend();
367 buffdoc.setContinuous(m_continuousDocument = _b); 366 buffdoc.setContinuous(m_continuousDocument = _b);
368} 367}
369 368
370void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno) 369void QTReader::processmousewordevent(size_t startpos, size_t startoffset, QMouseEvent* _e, int lineno)
371{ 370{
372 unsigned long wrdstart, wrdend; 371 unsigned long wrdstart, wrdend;
373 QString wrd; 372 QString wrd;
374 int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; 373 int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin;
375 if (m_twotouch) 374 if (m_twotouch)
376 { 375 {
377 if (m_touchone) 376 if (m_touchone)
378 { 377 {
379 m_touchone = false; 378 m_touchone = false;
380 m_startpos = startpos; 379 m_startpos = startpos;
381 m_startoffset = startoffset; 380 m_startoffset = startoffset;
382 setBackgroundColor( lightGray ); 381 setBackgroundColor( lightGray );
383 } 382 }
384 else 383 else
385 { 384 {
386 m_touchone = true; 385 m_touchone = true;
387 setBackgroundColor( m_bg ); 386 setBackgroundColor( m_bg );
388 size_t endpos, endoffset; 387 size_t endpos, endoffset;
389 endpos = startpos; 388 endpos = startpos;
390 endoffset = startoffset; 389 endoffset = startoffset;
391 size_t currentpos = locate(); 390 size_t currentpos = locate();
392 if (endpos >= m_startpos) 391 if (endpos >= m_startpos)
393 { 392 {
394 jumpto(m_startpos); 393 jumpto(m_startpos);
395 for (int i = 0; i < m_startoffset; i++) 394 for (int i = 0; i < m_startoffset; i++)
396 { 395 {
397 getch(); 396 getch();
398 } 397 }
399 wrdstart = buffdoc.explocate(); 398 wrdstart = buffdoc.explocate();
400 if (m_startpos == endpos) 399 if (m_startpos == endpos)
401 { 400 {
402 for (int i = m_startoffset; i <= endoffset; i++) 401 for (int i = m_startoffset; i <= endoffset; i++)
403 { 402 {
404 wrd += QChar(getch()); 403 wrd += QChar(getch());
405 } 404 }
406 } 405 }
407 else 406 else
408 { 407 {
409 while (buffdoc.explocate() <= endpos) 408 while (buffdoc.explocate() <= endpos)
410 { 409 {
411 wrd += QChar(getch()); 410 wrd += QChar(getch());
412 } 411 }
413 for (int i = 0; i < endoffset; i++) 412 for (int i = 0; i < endoffset; i++)
414 { 413 {
415 wrd += QChar(getch()); 414 wrd += QChar(getch());
416 } 415 }
417 } 416 }
418 wrdend = buffdoc.explocate(); 417 wrdend = buffdoc.explocate();
419 jumpto(currentpos); 418 jumpto(currentpos);
420 } 419 }
421 } 420 }
422 } 421 }
423 else if (m_bMonoSpaced) 422 else if (m_bMonoSpaced)
424 { 423 {
425 int chno = (m_rotated) ? 424 int chno = (m_rotated) ?
426 (_e->y()-textarray[lineno]->offset(height(), m_left_border, m_right_border, availht))/m_charWidth 425 (_e->y()-textarray[lineno]->offset(height(), m_left_border, m_right_border, availht))/m_charWidth
427 : 426 :
428 (_e->x()-textarray[lineno]->offset(width(), m_left_border, m_right_border, availht))/m_charWidth; 427 (_e->x()-textarray[lineno]->offset(width(), m_left_border, m_right_border, availht))/m_charWidth;
429 if (chno < ustrlen(textarray[lineno]->data())) 428 if (chno < ustrlen(textarray[lineno]->data()))
430 { 429 {
431 wrd[0] = textarray[lineno]->data()[chno]; 430 wrd[0] = textarray[lineno]->data()[chno];
432 } 431 }
433 } 432 }
434 else 433 else
435 { 434 {
436 CDrawBuffer* t = textarray[lineno]; 435 CDrawBuffer* t = textarray[lineno];
437 int first = 0; 436 int first = 0;
438 int tgt = (m_rotated) ? 437 int tgt = (m_rotated) ?
439 _e->y() - t->offset(height(), m_left_border, m_right_border, availht) : 438 _e->y() - t->offset(height(), m_left_border, m_right_border, availht) :
440 _e->x() - t->offset(width(), m_left_border, m_right_border, availht); 439 _e->x() - t->offset(width(), m_left_border, m_right_border, availht);
441 while (1) 440 while (1)
442 { 441 {
443 int i = first+1; 442 int i = first+1;
444 int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin; 443 int availht = ((m_rotated) ? width() : height()) - m_topmargin - m_bottommargin;
445 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; 444 while (QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
446 if (t->width(availht, i, true, (m_rotated) ? height() : width(), m_left_border, m_right_border) > tgt) 445 if (t->width(availht, i, true, (m_rotated) ? height() : width(), m_left_border, m_right_border) > tgt)
447 { 446 {
448 wrd = toQString(t->data()+first, i - first); 447 wrd = toQString(t->data()+first, i - first);
449 // qDebug("Got %s", (const char *)wrd); 448 // qDebug("Got %s", (const char *)wrd);
450 break; 449 break;
451 } 450 }
452 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++; 451 while (!QChar((*t)[i]).isLetter() && (*t)[i] != 0) i++;
453 if ((*t)[i] == 0) break; 452 if ((*t)[i] == 0) break;
454 first = i; 453 first = i;
455 } 454 }
456 } 455 }
457 if (!wrd.isEmpty()) 456 if (!wrd.isEmpty())
458 { 457 {
459 qDebug("Selecteed:%s", (const char*)wrd); 458 qDebug("Selecteed:%s", (const char*)wrd);
460 if (m_twotouch) 459 if (m_twotouch)
461 { 460 {
462 emit OnWordSelected(wrd, wrdstart, wrdend, wrd); 461 emit OnWordSelected(wrd, wrdstart, wrdend, wrd);
463 } 462 }
464 else 463 else
465 { 464 {
466 QString line = toQString(textarray[lineno]->data()); 465 QString line = toQString(textarray[lineno]->data());
467 emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line); 466 emit OnWordSelected(wrd, locnarray[lineno], locnarray[lineno]+line.length(), line);
468 } 467 }
469 } 468 }
470} 469}
471 470
472void QTReader::mouseReleaseEvent( QMouseEvent* _e ) 471void QTReader::mouseReleaseEvent( QMouseEvent* _e )
473{ 472{
474 buffdoc.unsuspend(); 473 buffdoc.unsuspend();
475 int x, y, ht, wh; 474 int x, y, ht, wh;
476 if (m_rotated) 475 if (m_rotated)
477 { 476 {
478 x = _e->y(); 477 x = _e->y();
479 y = width()-_e->x(); 478 y = width()-_e->x();
480 ht = width(); 479 ht = width();
481 wh = height(); 480 wh = height();
482 } 481 }
483 else 482 else
484 { 483 {
485 x = _e->x(); 484 x = _e->x();
486 y = _e->y(); 485 y = _e->y();
487 ht = height(); 486 ht = height();
488 wh = width(); 487 wh = width();
489 } 488 }
490 if (_e->button() == LeftButton) 489 if (_e->button() == LeftButton)
491 { 490 {
492 if (mouseUpOn) 491 if (mouseUpOn)
493 { 492 {
494 // qDebug("MouseRelease"); 493 // qDebug("MouseRelease");
495 switch(m_scrollpos) 494 switch(m_scrollpos)
496 { 495 {
497 case 1: // Bottom 496 case 1: // Bottom
498 if (y > ht - 5) 497 if (y > ht - 5)
499 { 498 {
500 locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh); 499 locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*x+wh/2)/wh);
501 return; 500 return;
502 } 501 }
503 break; 502 break;
504 case 2: // right 503 case 2: // right
505 if (x > wh - m_right_border) 504 if (x > wh - m_right_border)
506 { 505 {
507 locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); 506 locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht);
508 return; 507 return;
509 } 508 }
510 break; 509 break;
511 case 3: // left 510 case 3: // left
512 if (x < m_left_border) 511 if (x < m_left_border)
513 { 512 {
514 locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht); 513 locate(buffdoc.startSection()+((buffdoc.endSection()-buffdoc.startSection())*y+ht/2)/ht);
515 return; 514 return;
516 } 515 }
517 break; 516 break;
518 case 0: 517 case 0:
519 default: 518 default:
520 break; 519 break;
521 } 520 }
522 if (textarray[0] != NULL) 521 if (textarray[0] != NULL)
523 { 522 {
524 QString line; 523 QString line;
525 // int lineno = _e->y()/m_linespacing; 524 // int lineno = _e->y()/m_linespacing;
526 int lineno = 0; 525 int lineno = 0;
527 /* 526 /*
528 int ht = textarray[0]->lineSpacing(); 527 int ht = textarray[0]->lineSpacing();
529 while ((ht < y) && (lineno < numlines)) 528 while ((ht < y) && (lineno < numlines))
530 { 529 {
531 ht += textarray[++lineno]->lineSpacing(); 530 ht += textarray[++lineno]->lineSpacing();
532 } 531 }
533 */ 532 */
534 size_t startpos, startoffset, tgt, tgtoffset, pictgt; 533 size_t startpos, startoffset, tgt, tgtoffset, pictgt;
535 QImage* img; 534 QImage* img;
536 if (m_currentlinkstyle != NULL) 535 if (m_currentlinkstyle != NULL)
537 { 536 {
538 textarray[m_currentlink]->invertLink(m_currentlinkoffset); 537 textarray[m_currentlink]->invertLink(m_currentlinkoffset);
539 m_currentlinkstyle = NULL; 538 m_currentlinkstyle = NULL;
540 m_currentlink = -1; 539 m_currentlink = -1;
541 m_currentlinkoffset = -1; 540 m_currentlinkoffset = -1;
542 } 541 }
543 linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img); 542 linkType glt = getcurrentpos(x, y, wh, ht, lineno, startpos, startoffset, tgt, tgtoffset, pictgt, img);
544 if ((glt & eLink) != 0) 543 if ((glt & eLink) != 0)
545 { 544 {
546 if ((glt & ePicture) != 0) 545 if ((glt & ePicture) != 0)
547 { 546 {
548 qDebug("Big Picture:%x", pictgt); 547 qDebug("Big Picture:%x", pictgt);
549 if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) 548 if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0)
550 { 549 {
551 QImage* pm = buffdoc.getPicture(pictgt); 550 QImage* pm = buffdoc.getPicture(pictgt);
552 if (pm != NULL) 551 if (pm != NULL)
553 { 552 {
554 emit OnShowPicture(*pm); 553 emit OnShowPicture(*pm);
555 delete pm; 554 delete pm;
556 return; 555 return;
557 } 556 }
558 } 557 }
559 } 558 }
560 else if (img != NULL) 559 else if (img != NULL)
561 { 560 {
562 if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0) 561 if (QMessageBox::warning(this, PROGNAME, "Show picture or goto link?", "Show", "Goto Link") == 0)
563 { 562 {
564 emit OnShowPicture(*img); 563 emit OnShowPicture(*img);
565 return; 564 return;
566 } 565 }
567 } 566 }
568 size_t saveposn = pagelocate(); 567 size_t saveposn = pagelocate();
569 QString href, nm; 568 QString href, nm;
570 linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm); 569 linkType lt = buffdoc.hyperlink(tgt, tgtoffset, href, nm);
571 qDebug("URL(1):%s", (const char*)href); 570 qDebug("URL(1):%s", (const char*)href);
572 if ((lt & eFile) != 0) 571 if ((lt & eFile) != 0)
573 { 572 {
574 buffdoc.saveposn(m_lastfile, saveposn); 573 buffdoc.saveposn(m_lastfile, saveposn);
575#ifdef USEQPE 574#ifdef USEQPE
576 { 575 {
577 QCopEnvelope e("QPE/System", "busy()"); 576 QCopEnvelope e("QPE/System", "busy()");
578 } 577 }
579#endif 578#endif
580 ResetScroll(); 579 ResetScroll();
581 if (!href.isEmpty()) 580 if (!href.isEmpty())
582 { 581 {
583 if (!buffdoc.getFile(href)) 582 if (!buffdoc.getFile(href))
584 { 583 {
585 emit NewFileRequest(href); 584 emit NewFileRequest(href);
586 } 585 }
587 else 586 else
588 { 587 {
589 ResetScroll(); 588 ResetScroll();
590 fillbuffer(); 589 fillbuffer();
591 update(); 590 update();
592 } 591 }
593 } 592 }
594 if (!nm.isEmpty()) 593 if (!nm.isEmpty())
595 { 594 {
596 qDebug("QTReader:Finding %s", (const char*)nm); 595 qDebug("QTReader:Finding %s", (const char*)nm);
597 if (buffdoc.findanchor(nm)) 596 if (buffdoc.findanchor(nm))
598 { 597 {
599 fillbuffer(); 598 fillbuffer();
600 update(); 599 update();
601 } 600 }
602 } 601 }
603 //fillbuffer(); 602 //fillbuffer();
604 //update(); 603 //update();
605#ifdef USEQPE 604#ifdef USEQPE
606 { 605 {
607 QCopEnvelope e("QPE/System", "notBusy()"); 606 QCopEnvelope e("QPE/System", "notBusy()");
608 } 607 }
609#endif 608#endif
610 } 609 }
611 else if ((lt & eLink) != 0) 610 else if ((lt & eLink) != 0)
612 { 611 {
613 buffdoc.saveposn(m_lastfile, saveposn); 612 buffdoc.saveposn(m_lastfile, saveposn);
614 ResetScroll(); 613 ResetScroll();
615 fillbuffer(); 614 fillbuffer();
616 update(); 615 update();
617 } 616 }
618 else 617 else
619 { 618 {
620 if ((lt & ePicture) != 0) 619 if ((lt & ePicture) != 0)
621 { 620 {
622 QImage* pm = buffdoc.getPicture(tgt); 621 QImage* pm = buffdoc.getPicture(tgt);
623 if (pm != NULL) 622 if (pm != NULL)
624 { 623 {
625 emit OnShowPicture(*pm); 624 emit OnShowPicture(*pm);
626 delete pm; 625 delete pm;
627 } 626 }
628 } 627 }
629 else 628 else
630 { 629 {
631 // QString anchortext = textarray[lineno]->getanchortext(startoffset); 630 // QString anchortext = textarray[lineno]->getanchortext(startoffset);
632 if (!href.isEmpty()) 631 if (!href.isEmpty())
633 { 632 {
634 emit OnURLSelected(href, tgt); 633 emit OnURLSelected(href, tgt);
635 } 634 }
636 } 635 }
637 locate(pagelocate()); 636 locate(pagelocate());
638 } 637 }
639 return; 638 return;
640 } 639 }
641 else if ((glt & ePicture) != 0) 640 else if ((glt & ePicture) != 0)
642 { 641 {
643 qDebug("Big Picture:%x", pictgt); 642 qDebug("Big Picture:%x", pictgt);
644 QImage* pm = buffdoc.getPicture(pictgt); 643 QImage* pm = buffdoc.getPicture(pictgt);
645 if (pm != NULL) 644 if (pm != NULL)
646 { 645 {
647 emit OnShowPicture(*pm); 646 emit OnShowPicture(*pm);
648 delete pm; 647 delete pm;
649 } 648 }
650 else 649 else
651 { 650 {
652 locate(pagelocate()); 651 locate(pagelocate());
653 } 652 }
654 return; 653 return;
655 } 654 }
656 else if (img != NULL) 655 else if (img != NULL)
657 { 656 {
658 emit OnShowPicture(*img); 657 emit OnShowPicture(*img);
659 return; 658 return;
660 } 659 }
661 if (m_swapmouse) 660 if (m_swapmouse)
662 processmousepositionevent(_e); 661 processmousepositionevent(_e);
663 else 662 else
664 processmousewordevent(startpos, startoffset, _e, lineno); 663 processmousewordevent(startpos, startoffset, _e, lineno);
665 } 664 }
666 } 665 }
667 else 666 else
668 { 667 {
669 mouseUpOn = true; 668 mouseUpOn = true;
670 } 669 }
671 } 670 }
672} 671}
673 672
674void QTReader::focusInEvent(QFocusEvent* e) 673void QTReader::focusInEvent(QFocusEvent* e)
675{ 674{
676 if (m_autoScroll) timer->start(real_delay(), false); 675 if (m_autoScroll) timer->start(real_delay(), false);
677 update(); 676 update();
678} 677}
679 678
680void QTReader::focusOutEvent(QFocusEvent* e) 679void QTReader::focusOutEvent(QFocusEvent* e)
681{ 680{
682 if (m_autoScroll) 681 if (m_autoScroll)
683 { 682 {
684 timer->stop(); 683 timer->stop();
685 //m_scrolldy1 = m_scrolldy2 = 0; 684 //m_scrolldy1 = m_scrolldy2 = 0;
686 } 685 }
687} 686}
688 687
689#include <qapplication.h> 688#include <qapplication.h>
690#include <qdrawutil.h> 689#include <qdrawutil.h>
691#ifndef _WINDOWS 690#ifndef _WINDOWS
692#include <unistd.h> 691#include <unistd.h>
693#endif 692#endif
694 693
695void QTReader::goDown() 694void QTReader::goDown()
696{ 695{
697 if (m_bpagemode) 696 if (m_bpagemode)
698 { 697 {
699 dopagedn(); 698 dopagedn();
700 } 699 }
701 else 700 else
702 { 701 {
703 lineDown(); 702 lineDown();
704 } 703 }
705} 704}
706 705
707void QTReader::goUp() 706void QTReader::goUp()
708{ 707{
709 if (m_bpagemode) 708 if (m_bpagemode)
710 { 709 {
711 dopageup(); 710 dopageup();
712 } 711 }
713 else 712 else
714 { 713 {
715 lineUp(); 714 lineUp();
716 } 715 }
717} 716}
718 717
719void QTReader::NavUp() 718void QTReader::NavUp()
720{ 719{
721 buffdoc.unsuspend(); 720 buffdoc.unsuspend();
722 if (buffdoc.hasnavigation()) 721 if (buffdoc.hasnavigation())
723 { 722 {
724/* 723/*
725 size_t target = pagelocate(); 724 size_t target = pagelocate();
726 if (buffdoc.back(target)) 725 if (buffdoc.back(target))
727 { 726 {
728 locate(target); 727 locate(target);
729 } 728 }
730*/ 729*/
731 locate(buffdoc.startSection()); 730 locate(buffdoc.startSection());
732 } 731 }
733 else 732 else
734 { 733 {
735 goUp(); 734 goUp();
736 } 735 }
737} 736}
738 737
739void QTReader::NavDown() 738void QTReader::NavDown()
740{ 739{
741 buffdoc.unsuspend(); 740 buffdoc.unsuspend();
742 if (buffdoc.hasnavigation()) 741 if (buffdoc.hasnavigation())
743 { 742 {
744/* 743/*
745 size_t target = pagelocate(); 744 size_t target = pagelocate();
746 if (buffdoc.forward(target)) 745 if (buffdoc.forward(target))
747 { 746 {
748 locate(target); 747 locate(target);
749 } 748 }
750*/ 749*/
751 dopageup(buffdoc.endSection()); 750 dopageup(buffdoc.endSection());
752 } 751 }
753 else 752 else
754 { 753 {
755 goDown(); 754 goDown();
756 } 755 }
757} 756}
758 757
759void QTReader::zoomin() 758void QTReader::zoomin()
760{ 759{
761 if (m_fontControl.increasesize()) 760 if (m_fontControl.increasesize())
762 { 761 {
763 bool sc = m_autoScroll; 762 bool sc = m_autoScroll;
764 setautoscroll(false); 763 setautoscroll(false);
765 setfont(); 764 setfont();
766 locate(pagelocate()); 765 locate(pagelocate());
767 repaint(); 766 repaint();
768 setautoscroll(sc); 767 setautoscroll(sc);
769 } 768 }
770} 769}
771 770
772void QTReader::zoomout() 771void QTReader::zoomout()
773{ 772{
774 if (m_fontControl.decreasesize()) 773 if (m_fontControl.decreasesize())
775 { 774 {
776 bool sc = m_autoScroll; 775 bool sc = m_autoScroll;
777 setautoscroll(false); 776 setautoscroll(false);
778 setfont(); 777 setfont();
779 locate(pagelocate()); 778 locate(pagelocate());
780 repaint(); 779 repaint();
781 setautoscroll(sc); 780 setautoscroll(sc);
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,416 +1,415 @@
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
14class CDrawBuffer; 13class CDrawBuffer;
15//class CBuffer; 14//class CBuffer;
16#include <qpixmap.h> 15#include <qpixmap.h>
17class QPainter; 16class QPainter;
18class QTimer; 17class QTimer;
19class QImage; 18class 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
28class QPainter; 27class QPainter;
29#endif 28#endif
30 29
31class CStyle; 30class CStyle;
32 31
33class QTReader : public QWidget 32class 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
105public: 104public:
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 }
198 void setencoding(int _f) 197 void setencoding(int _f)
199 { 198 {
200 m_encd = _f; 199 m_encd = _f;
201 setfilter(getfilter()); 200 setfilter(getfilter());
202 } 201 }
203 MarkupType PreferredMarkup(); 202 MarkupType PreferredMarkup();
204 CEncoding* getencoding() 203 CEncoding* getencoding()
205 { 204 {
206 // qDebug("m_encd:%d", m_encd); 205 // qDebug("m_encd:%d", m_encd);
207 switch (m_encd) 206 switch (m_encd)
208 { 207 {
209 case 4: 208 case 4:
210 // qDebug("palm"); 209 // qDebug("palm");
211 return new CPalm; 210 return new CPalm;
212 case 1: 211 case 1:
213 // qDebug("utf8"); 212 // qDebug("utf8");
214 return new CUtf8; 213 return new CUtf8;
215 case 2: 214 case 2:
216 // qDebug("ucs16be"); 215 // qDebug("ucs16be");
217 return new CUcs16be; 216 return new CUcs16be;
218 case 3: 217 case 3:
219 // qDebug("ucs16le"); 218 // qDebug("ucs16le");
220 return new CUcs16le; 219 return new CUcs16le;
221 case 0: 220 case 0:
222 // qDebug("ascii"); 221 // qDebug("ascii");
223 return new CAscii; 222 return new CAscii;
224 default: 223 default:
225 return new CGeneral8Bit(m_encd-MAX_ENCODING+1); 224 return new CGeneral8Bit(m_encd-MAX_ENCODING+1);
226 } 225 }
227 } 226 }
228 HighlightFilter* m_highlightfilter; 227 HighlightFilter* m_highlightfilter;
229 CFilterChain* getfilter() 228 CFilterChain* getfilter()
230 { 229 {
231 CFilterChain * filt = new CFilterChain(getencoding()); 230 CFilterChain * filt = new CFilterChain(getencoding());
232 if (bstripcr) filt->addfilter(new stripcr); 231 if (bstripcr) filt->addfilter(new stripcr);
233 232
234 if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt); 233 if (btextfmt || (bautofmt && (PreferredMarkup() == cTEXT))) filt->addfilter(new textfmt);
235 if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter); 234 if (bpeanut || (bautofmt && (PreferredMarkup() == cPML))) filt->addfilter(new PeanutFormatter);
236 // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); 235 // if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile));
237 236
238#ifdef __STATIC 237#ifdef __STATIC
239 if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile)); 238 if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new striphtml(m_lastfile));
240 if (bautofmt && (PreferredMarkup() == cCHM)) 239 if (bautofmt && (PreferredMarkup() == cCHM))
241 { 240 {
242 filt->addfilter(new striphtml(m_lastfile)); 241 filt->addfilter(new striphtml(m_lastfile));
243 } 242 }
244#else 243#else
245 if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile)); 244 if (bstriphtml || (bautofmt && (PreferredMarkup() == cHTML))) filt->addfilter(new ExternFilter("HTMLfilter", m_lastfile));
246 if (bautofmt && (PreferredMarkup() == cCHM)) 245 if (bautofmt && (PreferredMarkup() == cCHM))
247 { 246 {
248 ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile); 247 ExternFilter* f = new ExternFilter("HTMLfilter",m_lastfile);
249 ((striphtml*)f->filter())->setchm(true); 248 ((striphtml*)f->filter())->setchm(true);
250 filt->addfilter(f); 249 filt->addfilter(f);
251 } 250 }
252#endif 251#endif
253 m_highlightfilter = new HighlightFilter(this); 252 m_highlightfilter = new HighlightFilter(this);
254 filt->addfilter(m_highlightfilter); 253 filt->addfilter(m_highlightfilter);
255 254
256 if (bdehyphen) filt->addfilter(new dehyphen); 255 if (bdehyphen) filt->addfilter(new dehyphen);
257 if (bunindent) filt->addfilter(new unindent); 256 if (bunindent) filt->addfilter(new unindent);
258 if (brepara) filt->addfilter(new repara(m_reparastring)); 257 if (brepara) filt->addfilter(new repara(m_reparastring));
259 if (bonespace) filt->addfilter(new OnePara); 258 if (bonespace) filt->addfilter(new OnePara);
260 if (bindenter) filt->addfilter(new indenter(bindenter)); 259 if (bindenter) filt->addfilter(new indenter(bindenter));
261 if (bdblspce) filt->addfilter(new dblspce); 260 if (bdblspce) filt->addfilter(new dblspce);
262 if (bdepluck) filt->addfilter(new DePluck(pluckernextpart)); 261 if (bdepluck) filt->addfilter(new DePluck(pluckernextpart));
263 if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart)); 262 if (bdejpluck) filt->addfilter(new DePluck(jplucknextpart));
264 if (brepalm) filt->addfilter(new repalm); 263 if (brepalm) filt->addfilter(new repalm);
265 if (bkern) filt->addfilter(new kern); 264 if (bkern) filt->addfilter(new kern);
266 if (bremap) filt->addfilter(new remap); 265 if (bremap) filt->addfilter(new remap);
267 if (bmakebold) filt->addfilter(new embolden); 266 if (bmakebold) filt->addfilter(new embolden);
268 if (bfulljust) filt->addfilter(new FullJust); 267 if (bfulljust) filt->addfilter(new FullJust);
269 int r,g,b; 268 int r,g,b;
270 m_default_bg.rgb(&r, &g, &b); 269 m_default_bg.rgb(&r, &g, &b);
271 if (r != 255 || g != 255 || b != 255) 270 if (r != 255 || g != 255 || b != 255)
272 filt->addfilter(new setbg(r,g,b)); 271 filt->addfilter(new setbg(r,g,b));
273 m_default_fg.rgb(&r, &g, &b); 272 m_default_fg.rgb(&r, &g, &b);
274 if (r != 0 || g != 0 || b != 0) 273 if (r != 0 || g != 0 || b != 0)
275 filt->addfilter(new setfg(r,g,b)); 274 filt->addfilter(new setfg(r,g,b));
276 // if (bNegative) filt->addfilter(new makeNegative); 275 // if (bNegative) filt->addfilter(new makeNegative);
277 if (bInverse) filt->addfilter(new makeInverse); 276 if (bInverse) filt->addfilter(new makeInverse);
278 return filt; 277 return filt;
279 } 278 }
280 279
281 280
282private slots: 281private slots:
283 void dopageup(); 282 void dopageup();
284 void lineDown(); 283 void lineDown();
285 void lineUp(); 284 void lineUp();
286 void dopagedn(); 285 void dopagedn();
287 void goHome(); 286 void goHome();
288 void goBack(); 287 void goBack();
289 void goForward(); 288 void goForward();
290 void doscroll(); 289 void doscroll();
291 void paintEvent( QPaintEvent * ); 290 void paintEvent( QPaintEvent * );
292#ifdef DOUBLEBUFFER 291#ifdef DOUBLEBUFFER
293 void resizeEvent( QResizeEvent * p ); 292 void resizeEvent( QResizeEvent * p );
294#endif 293#endif
295 void keyPressEvent(QKeyEvent*); 294 void keyPressEvent(QKeyEvent*);
296 private: 295 private:
297 // void drawIt( QPainter * ); 296 // void drawIt( QPainter * );
298 void redrawall(); 297 void redrawall();
299 void drawFonts(); 298 void drawFonts();
300 void DrawStraight(QPainter* p, int w, int h); 299 void DrawStraight(QPainter* p, int w, int h);
301 QColor m_scrollcolor, m_scrollbarcolor; 300 QColor m_scrollcolor, m_scrollbarcolor;
302 void setTwoTouch(bool _b); 301 void setTwoTouch(bool _b);
303 void init(); 302 void init();
304 void mousePressEvent( QMouseEvent* ); 303 void mousePressEvent( QMouseEvent* );
305 void mouseReleaseEvent( QMouseEvent* ); 304 void mouseReleaseEvent( QMouseEvent* );
306// void mouseDoubleClickEvent( QMouseEvent* ); 305// void mouseDoubleClickEvent( QMouseEvent* );
307 QString m_string, m_fontname, m_reparastring; 306 QString m_string, m_fontname, m_reparastring;
308 void setfont(); 307 void setfont();
309 //myoutput stuff 308 //myoutput stuff
310 private: 309 private:
311#ifdef SPECIALSCROLL 310#ifdef SPECIALSCROLL
312 int m_scrolldy; 311 int m_scrolldy;
313#endif 312#endif
314 bool mouseUpOn; 313 bool mouseUpOn;
315 linkType getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*&); 314 linkType getcurrentpos(int x, int y, int w, int h, int& lineno, size_t& start, size_t& offset, size_t& tgt, size_t& tgtoffset, size_t& pictgt, QImage*&);
316 bool m_twotouch, m_touchone; 315 bool m_twotouch, m_touchone;
317 size_t m_startpos, m_startoffset; 316 size_t m_startpos, m_startoffset;
318 void dopageup(unsigned int); 317 void dopageup(unsigned int);
319 long real_delay(); 318 long real_delay();
320 int m_textsize; 319 int m_textsize;
321 int m_lastwidth, m_lastheight; 320 int m_lastwidth, m_lastheight;
322 CBufferFace<CDrawBuffer*> textarray; 321 CBufferFace<CDrawBuffer*> textarray;
323 CBufferFace<size_t> locnarray; 322 CBufferFace<size_t> locnarray;
324 unsigned int numlines; 323 unsigned int numlines;
325// bool m_showlast; 324// bool m_showlast;
326 bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse; 325 bool bstripcr, btextfmt, bstriphtml, bdehyphen, bdepluck, bdejpluck, bunindent, brepara, bdblspce, btight, bmakebold, bremap, bpeanut, bautofmt, bonespace, bfulljust, /*bNegative,*/ bInverse;
327 bool bkern, brepalm; 326 bool bkern, brepalm;
328 bool m_bpagemode, m_bMonoSpaced, m_continuousDocument; 327 bool m_bpagemode, m_bMonoSpaced, m_continuousDocument;
329 unsigned char bindenter; 328 unsigned char bindenter;
330 QString m_lastfile; 329 QString m_lastfile;
331 size_t m_lastposn; 330 size_t m_lastposn;
332 bool bDoUpdates; 331 bool bDoUpdates;
333 public: 332 public:
334 void setDoUpdates(bool b) { bDoUpdates = b; } 333 void setDoUpdates(bool b) { bDoUpdates = b; }
335 void setStripCR(bool b) { bstripcr = b; } 334 void setStripCR(bool b) { bstripcr = b; }
336 void NavUp(); 335 void NavUp();
337 void NavDown(); 336 void NavDown();
338 tchar getch() { return buffdoc.getch(); } 337 tchar getch() { return buffdoc.getch(); }
339 bool synch(size_t, size_t); 338 bool synch(size_t, size_t);
340 bool tight; 339 bool tight;
341 bool load_file(const char *newfile, unsigned int lcn=0); 340 bool load_file(const char *newfile, unsigned int lcn=0);
342 BuffDoc buffdoc; 341 BuffDoc buffdoc;
343 CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); } 342 CList<Bkmk>* getbkmklist() { return buffdoc.getbkmklist(); }
344 bool locate(unsigned long n); 343 bool locate(unsigned long n);
345 void jumpto(unsigned long n) { buffdoc.locate(n); } 344 void jumpto(unsigned long n) { buffdoc.locate(n); }
346 unsigned long locate() { return buffdoc.locate(); } 345 unsigned long locate() { return buffdoc.locate(); }
347 unsigned long explocate() { return buffdoc.explocate(); } 346 unsigned long explocate() { return buffdoc.explocate(); }
348 unsigned long pagelocate() { return locnarray[0]; } 347 unsigned long pagelocate() { return locnarray[0]; }
349 unsigned long mylastpos; 348 unsigned long mylastpos;
350 void getNextLink(); 349 void getNextLink();
351 void setfilter(CFilterChain *f) { buffdoc.setfilter(f); if (bDoUpdates) locate(pagelocate()); } 350 void setfilter(CFilterChain *f) { buffdoc.setfilter(f); if (bDoUpdates) locate(pagelocate()); }
352 void restore() { jumpto(mylastpos); } 351 void restore() { jumpto(mylastpos); }
353 void goUp(); 352 void goUp();
354 void refresh(bool full = false); 353 void refresh(bool full = false);
355 void goDown(); 354 void goDown();
356 // bool bold; 355 // bool bold;
357 int textsize() { return m_textsize; } 356 int textsize() { return m_textsize; }
358 void textsize(int ts) { m_textsize = ts; } 357 void textsize(int ts) { m_textsize = ts; }
359 bool fillbuffer(int ru = 0, int ht = -1, int newht = -1); 358 bool fillbuffer(int ru = 0, int ht = -1, int newht = -1);
360 void CalculateScrollParameters(); 359 void CalculateScrollParameters();
361 unsigned int screenlines(); 360 unsigned int screenlines();
362 void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); } 361 void sizes(unsigned long& fs, unsigned long& ts) { buffdoc.sizes(fs,ts); }
363 static const char *fonts[]; 362 static const char *fonts[];
364// unsigned int *fontsizes; 363// unsigned int *fontsizes;
365 int m_ascent, m_descent, m_linespacing; 364 int m_ascent, m_descent, m_linespacing;
366 int m_topmargin, m_bottommargin; 365 int m_topmargin, m_bottommargin;
367 int m_abstopmargin, m_absbottommargin; 366 int m_abstopmargin, m_absbottommargin;
368 QFontMetrics* m_fm; 367 QFontMetrics* m_fm;
369 QString firstword(); 368 QString firstword();
370 bool hyphenate; 369 bool hyphenate;
371 void reset_bg() 370 void reset_bg()
372 { 371 {
373 int r,g,b; 372 int r,g,b;
374 m_default_bg.rgb(&r, &g, &b); 373 m_default_bg.rgb(&r, &g, &b);
375 if (bInverse) 374 if (bInverse)
376 { 375 {
377 r = 255-r; 376 r = 255-r;
378 g = 255-g; 377 g = 255-g;
379 b = 255-b; 378 b = 255-b;
380 } 379 }
381 m_bg.setRgb(r,g,b); 380 m_bg.setRgb(r,g,b);
382 /* 381 /*
383 int h,s,v; 382 int h,s,v;
384 m_bg.hsv(&h, &s, &v); 383 m_bg.hsv(&h, &s, &v);
385 if (bNegative) 384 if (bNegative)
386 { 385 {
387 v = 255-v; 386 v = 255-v;
388 m_bg.setHsv(h,s,v); 387 m_bg.setHsv(h,s,v);
389 } 388 }
390 */ 389 */
391 setBackgroundColor( m_bg ); 390 setBackgroundColor( m_bg );
392 } 391 }
393 void setInverse(bool b) 392 void setInverse(bool b)
394 { 393 {
395 bInverse = b; 394 bInverse = b;
396 reset_bg(); 395 reset_bg();
397 } 396 }
398 /* 397 /*
399 void setNegative() 398 void setNegative()
400 { 399 {
401 bNegative = !bNegative; 400 bNegative = !bNegative;
402 reset_bg(); 401 reset_bg();
403 } 402 }
404 */ 403 */
405 signals: 404 signals:
406 void OnRedraw(); 405 void OnRedraw();
407 void OnWordSelected(const QString&, size_t, size_t, const QString&); 406 void OnWordSelected(const QString&, size_t, size_t, const QString&);
408 void OnShowPicture(QImage&); 407 void OnShowPicture(QImage&);
409 void OnURLSelected(const QString&, const size_t); 408 void OnURLSelected(const QString&, const size_t);
410 void NewFileRequest(const QString&); 409 void NewFileRequest(const QString&);
411 void HandleKeyRequest(QKeyEvent*); 410 void HandleKeyRequest(QKeyEvent*);
412 void SetScrollState(bool); 411 void SetScrollState(bool);
413 void RefreshBitmap(); 412 void RefreshBitmap();
414}; 413};
415 414
416#endif 415#endif
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,854 +1,852 @@
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>
75using namespace Opie::Ui; 74using 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
93bool CheckVersion(int&, int&, char&); 91bool 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/"
103QString picdir() 101QString 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
112unsigned long QTReaderApp::m_uid = 0; 110unsigned long QTReaderApp::m_uid = 0;
113 111
114void QTReaderApp::setScrollState(bool _b) { m_scrollButton->setOn(_b); } 112void 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
134void QTReaderApp::listBkmkFiles() 132void 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
202void QTReaderApp::hidetoolbars() 200void 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
234QTReaderApp::QTReaderApp( QWidget *parent, const char *name, WFlags f ) 232QTReaderApp::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;
279 277
280 m_fBkmksChanged = false; 278 m_fBkmksChanged = false;
281 279
282 QString lang = getenv( "LANG" ); 280 QString lang = getenv( "LANG" );
283 QString rot = getenv( "QWS_DISPLAY" ); 281 QString rot = getenv( "QWS_DISPLAY" );
284 282
285/* 283/*
286 int m_rot = 0; 284 int m_rot = 0;
287 if (rot.contains("Rot90")) 285 if (rot.contains("Rot90"))
288 { 286 {
289 m_rot = 90; 287 m_rot = 90;
290 } 288 }
291 else if (rot.contains("Rot180")) 289 else if (rot.contains("Rot180"))
292 { 290 {
293 m_rot = 180; 291 m_rot = 180;
294 } 292 }
295 else if (rot.contains("Rot270")) 293 else if (rot.contains("Rot270"))
296 { 294 {
297 m_rot = 270; 295 m_rot = 270;
298 } 296 }
299 297
300// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot); 298// qDebug("Initial Rotation(%d):%s", m_rot, (const char*)rot);
301*/ 299*/
302 m_autogenstr = "^ *[A-Z].*[a-z] *$"; 300 m_autogenstr = "^ *[A-Z].*[a-z] *$";
303 301
304#ifdef USEQPE 302#ifdef USEQPE
305 setIcon( Resource::loadPixmap( PICDIR "uqtreader") ); 303 setIcon( Resource::loadPixmap( PICDIR "uqtreader") );
306#else 304#else
307 setIcon( QPixmap (PICDIR + "/uqtreader.png") ); 305 setIcon( QPixmap (PICDIR + "/uqtreader.png") );
308#endif /* USEQPE */ 306#endif /* USEQPE */
309 307
310// QPEToolBar *bar = new QPEToolBar( this ); 308// QPEToolBar *bar = new QPEToolBar( this );
311// menubar = new QPEToolBar( this ); 309// menubar = new QPEToolBar( this );
312#ifdef USEQPE 310#ifdef USEQPE
313 Config config( APPDIR ); 311 Config config( APPDIR );
314#else 312#else
315 QDir d = QDir::home(); // "/" 313 QDir d = QDir::home(); // "/"
316 if ( !d.cd(APPDIR) ) { // "/tmp" 314 if ( !d.cd(APPDIR) ) { // "/tmp"
317 qWarning( "Cannot find the \"~/" APPDIR "\" directory" ); 315 qWarning( "Cannot find the \"~/" APPDIR "\" directory" );
318 d = QDir::home(); 316 d = QDir::home();
319 d.mkdir(APPDIR); 317 d.mkdir(APPDIR);
320 d.cd(APPDIR); 318 d.cd(APPDIR);
321 } 319 }
322 QFileInfo fi(d, INIFILE); 320 QFileInfo fi(d, INIFILE);
323// qDebug("Path:%s", (const char*)fi.absFilePath()); 321// qDebug("Path:%s", (const char*)fi.absFilePath());
324 Config config(fi.absFilePath()); 322 Config config(fi.absFilePath());
325#endif 323#endif
326 config.setGroup("Toolbar"); 324 config.setGroup("Toolbar");
327 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false); 325 m_tbmovesave = m_tbmove = config.readBoolEntry("Movable", false);
328 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1); 326 m_tbpolsave = m_tbpol = (ToolbarPolicy)config.readNumEntry("Policy", 1);
329 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2); 327 m_tbposition = (ToolBarDock)config.readNumEntry("Position", 2);
330 m_qtscroll = config.readNumEntry("QTScrollBar", false); 328 m_qtscroll = config.readNumEntry("QTScrollBar", false);
331 m_localscroll = config.readNumEntry("LocalScrollBar", false); 329 m_localscroll = config.readNumEntry("LocalScrollBar", false);
332 330
333// fileBar = new QToolBar("File", this); 331// fileBar = new QToolBar("File", this);
334// QToolBar* viewBar = new QToolBar("File", this); 332// QToolBar* viewBar = new QToolBar("File", this);
335// QToolBar* navBar = new QToolBar("File", this); 333// QToolBar* navBar = new QToolBar("File", this);
336// QToolBar* markBar = new QToolBar("File", this); 334// QToolBar* markBar = new QToolBar("File", this);
337 335
338#ifdef USEQPE 336#ifdef USEQPE
339 menubar = new QToolBar("Menus", this, m_tbposition); 337 menubar = new QToolBar("Menus", this, m_tbposition);
340 mb = new QPEMenuBar( menubar ); 338 mb = new QPEMenuBar( menubar );
341#else 339#else
342 mb = new QMenuBar( this ); 340 mb = new QMenuBar( this );
343#endif 341#endif
344 342
345#ifdef USEQPE 343#ifdef USEQPE
346 QPopupMenu* tmp = new QPopupMenu(mb); 344 QPopupMenu* tmp = new QPopupMenu(mb);
347 mb->insertItem( geticon( "AppsIcon" ), tmp ); 345 mb->insertItem( geticon( "AppsIcon" ), tmp );
348#else 346#else
349 QMenuBar* tmp = mb; 347 QMenuBar* tmp = mb;
350#endif 348#endif
351 349
352 QPopupMenu *file = new QPopupMenu( mb ); 350 QPopupMenu *file = new QPopupMenu( mb );
353 tmp->insertItem( tr( "File" ), file ); 351 tmp->insertItem( tr( "File" ), file );
354 352
355 QPopupMenu *navigation = new QPopupMenu(mb); 353 QPopupMenu *navigation = new QPopupMenu(mb);
356 tmp->insertItem( tr( "Navigation" ), navigation ); 354 tmp->insertItem( tr( "Navigation" ), navigation );
357 355
358 QPopupMenu *view = new QPopupMenu( mb ); 356 QPopupMenu *view = new QPopupMenu( mb );
359 tmp->insertItem( tr( "View" ), view ); 357 tmp->insertItem( tr( "View" ), view );
360 358
361 QPopupMenu *marks = new QPopupMenu( this ); 359 QPopupMenu *marks = new QPopupMenu( this );
362 tmp->insertItem( tr( "Marks" ), marks ); 360 tmp->insertItem( tr( "Marks" ), marks );
363 361
364 QPopupMenu *settings = new QPopupMenu( this ); 362 QPopupMenu *settings = new QPopupMenu( this );
365 tmp->insertItem( tr( "Settings" ), settings ); 363 tmp->insertItem( tr( "Settings" ), settings );
366 364
367// addToolBar(menubar, "Menus",QMainWindow::Top); 365// addToolBar(menubar, "Menus",QMainWindow::Top);
368// addToolBar(fileBar, "Toolbar",QMainWindow::Top); 366// addToolBar(fileBar, "Toolbar",QMainWindow::Top);
369 367
370 // QPopupMenu *edit = new QPopupMenu( this ); 368 // QPopupMenu *edit = new QPopupMenu( this );
371 369
372 /* 370 /*
373 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 ); 371 QAction *a = new QAction( tr( "New" ), Resource::loadPixmap( "new" ), QString::null, 0, this, 0 );
374 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) ); 372 connect( a, SIGNAL( activated() ), this, SLOT( fileNew() ) );
375 a->addTo( bar ); 373 a->addTo( bar );
376 a->addTo( file ); 374 a->addTo( file );
377 */ 375 */
378 QWidget* widge = new QWidget(this); 376 QWidget* widge = new QWidget(this);
379 setCentralWidget( widge ); 377 setCentralWidget( widge );
380 QVBoxLayout* vlayout = new QVBoxLayout(widge); 378 QVBoxLayout* vlayout = new QVBoxLayout(widge);
381 m_layout = new QBoxLayout(QBoxLayout::LeftToRight); 379 m_layout = new QBoxLayout(QBoxLayout::LeftToRight);
382 m_prog = new QLabel(widge); 380 m_prog = new QLabel(widge);
383 vlayout->addLayout(m_layout, 1); 381 vlayout->addLayout(m_layout, 1);
384 vlayout->addWidget(m_prog); 382 vlayout->addWidget(m_prog);
385 383
386 editorStack = new QWidgetStack( widge ); 384 editorStack = new QWidgetStack( widge );
387 // setCentralWidget( editorStack ); 385 // setCentralWidget( editorStack );
388 386
389 searchVisible = FALSE; 387 searchVisible = FALSE;
390 regVisible = FALSE; 388 regVisible = FALSE;
391 m_fontVisible = false; 389 m_fontVisible = false;
392 390
393 m_buttonprefs = new CButtonPrefs(&kmap, this); 391 m_buttonprefs = new CButtonPrefs(&kmap, this);
394 editorStack->addWidget(m_buttonprefs, get_unique_id()); 392 editorStack->addWidget(m_buttonprefs, get_unique_id());
395 connect( m_buttonprefs, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); 393 connect( m_buttonprefs, SIGNAL( Closed() ), this, SLOT( infoClose() ) );
396 394
397 395
398 m_annoWin = new CAnnoEdit(editorStack); 396 m_annoWin = new CAnnoEdit(editorStack);
399 editorStack->addWidget(m_annoWin, get_unique_id()); 397 editorStack->addWidget(m_annoWin, get_unique_id());
400 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) ); 398 connect( m_annoWin, SIGNAL( finished(const QString&, const QString&) ), this, SLOT( addAnno(const QString&, const QString&) ) );
401 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) ); 399 connect( m_annoWin, SIGNAL( cancelled() ), this, SLOT( infoClose() ) );
402 400
403 m_infoWin = new infowin(editorStack); 401 m_infoWin = new infowin(editorStack);
404 editorStack->addWidget(m_infoWin, get_unique_id()); 402 editorStack->addWidget(m_infoWin, get_unique_id());
405 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) ); 403 connect( m_infoWin, SIGNAL( Close() ), this, SLOT( infoClose() ) );
406 404
407 m_graphicwin = new GraphicWin(editorStack); 405 m_graphicwin = new GraphicWin(editorStack);
408 editorStack->addWidget(m_graphicwin, get_unique_id()); 406 editorStack->addWidget(m_graphicwin, get_unique_id());
409 connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) ); 407 connect( m_graphicwin, SIGNAL( Closed() ), this, SLOT( infoClose() ) );
410 408
411// bkmkselector = new QListBox(editorStack, "Bookmarks"); 409// bkmkselector = new QListBox(editorStack, "Bookmarks");
412 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks"); 410 bkmkselector = new CBkmkSelector(editorStack, "Bookmarks");
413 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) ); 411 // connect(bkmkselector, SIGNAL( selected(const QString&) ), this, SLOT( gotobkmk(const QString&) ) );
414 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) ); 412 connect(bkmkselector, SIGNAL( selected(int) ), this, SLOT( gotobkmk(int) ) );
415 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) ); 413 connect(bkmkselector, SIGNAL( cancelled() ), this, SLOT( cancelbkmk() ) );
416 editorStack->addWidget( bkmkselector, get_unique_id() ); 414 editorStack->addWidget( bkmkselector, get_unique_id() );
417 415
418/* 416/*
419 importSelector = new FileSelector( "*", editorStack, "importselector", false ); 417 importSelector = new FileSelector( "*", editorStack, "importselector", false );
420 connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) ); 418 connect( importSelector, SIGNAL( fileSelected( const DocLnk &) ), this, SLOT( importFile( const DocLnk & ) ) );
421 419
422 editorStack->addWidget( importSelector, get_unique_id() ); 420 editorStack->addWidget( importSelector, get_unique_id() );
423 421
424 // don't need the close visible, it is redundant... 422 // don't need the close visible, it is redundant...
425 importSelector->setCloseVisible( FALSE ); 423 importSelector->setCloseVisible( FALSE );
426*/ 424*/
427// qDebug("Reading file list"); 425// qDebug("Reading file list");
428 readfilelist(); 426 readfilelist();
429 427
430 reader = new QTReader( editorStack ); 428 reader = new QTReader( editorStack );
431 429
432 reader->setDoUpdates(false); 430 reader->setDoUpdates(false);
433 431
434#ifdef USEQPE 432#ifdef USEQPE
435 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold); 433 ((QPEApplication*)qApp)->setStylusOperation(reader, QPEApplication::RightOnHold);
436#endif 434#endif
437 435
438// qDebug("Reading config"); 436// qDebug("Reading config");
439// Config config( APPDIR ); 437// Config config( APPDIR );
440 config.setGroup( "View" ); 438 config.setGroup( "View" );
441 m_debounce = config.readNumEntry("Debounce", 0); 439 m_debounce = config.readNumEntry("Debounce", 0);
442 m_buttonprefs->Debounce(m_debounce); 440 m_buttonprefs->Debounce(m_debounce);
443#ifdef USEQPE 441#ifdef USEQPE
444 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false); 442 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", false);
445#else 443#else
446 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true); 444 m_bFloatingDialog = config.readBoolEntry("FloatDialogs", true);
447#endif 445#endif
448 reader->setStripCR(config.readBoolEntry( "StripCr", true )); 446 reader->setStripCR(config.readBoolEntry( "StripCr", true ));
449 reader->bfulljust = config.readBoolEntry( "FullJust", false ); 447 reader->bfulljust = config.readBoolEntry( "FullJust", false );
450 /* 448 /*
451 bool btmp = config.readBoolEntry("Negative", false); 449 bool btmp = config.readBoolEntry("Negative", false);
452 if (btmp) reader->setNegative(); 450 if (btmp) reader->setNegative();
453 */ 451 */
454 reader->bInverse = config.readBoolEntry("Inverse", false); 452 reader->bInverse = config.readBoolEntry("Inverse", false);
455 reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false )); 453 reader->m_fontControl.FixGraphics(config.readBoolEntry( "FixGraphics", false ));
456 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 )); 454 reader->setextraspace(config.readNumEntry( "ExtraSpace", 0 ));
457 reader->setlead(config.readNumEntry( "ExtraLead", 0 )); 455 reader->setlead(config.readNumEntry( "ExtraLead", 0 ));
458 reader->btextfmt = config.readBoolEntry( "TextFmt", false ); 456 reader->btextfmt = config.readBoolEntry( "TextFmt", false );
459 reader->bautofmt = config.readBoolEntry( "AutoFmt", true ); 457 reader->bautofmt = config.readBoolEntry( "AutoFmt", true );
460 reader->bstriphtml = config.readBoolEntry( "StripHtml", false ); 458 reader->bstriphtml = config.readBoolEntry( "StripHtml", false );
461 reader->bpeanut = config.readBoolEntry( "Peanut", false ); 459 reader->bpeanut = config.readBoolEntry( "Peanut", false );
462 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false ); 460 reader->bdehyphen = config.readBoolEntry( "Dehyphen", false );
463 reader->bdepluck = config.readBoolEntry( "Depluck", false ); 461 reader->bdepluck = config.readBoolEntry( "Depluck", false );
464 reader->bdejpluck = config.readBoolEntry( "Dejpluck", false ); 462 reader->bdejpluck = config.readBoolEntry( "Dejpluck", false );
465 reader->bonespace = config.readBoolEntry( "OneSpace", false ); 463 reader->bonespace = config.readBoolEntry( "OneSpace", false );
466 reader->bunindent = config.readBoolEntry( "Unindent", false ); 464 reader->bunindent = config.readBoolEntry( "Unindent", false );
467 reader->brepara = config.readBoolEntry( "Repara", false ); 465 reader->brepara = config.readBoolEntry( "Repara", false );
468 reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}"); 466 reader->m_reparastring = config.readEntry( "ReparaString", "\\n{[\\n \\t]}");
469 m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 ); 467 m_bgtype = (bground)config.readNumEntry( "BackgroundType" , 0 );
470 m_themename = config.readEntry("Theme", QString::null ); 468 m_themename = config.readEntry("Theme", QString::null );
471 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false ); 469 reader->bdblspce = config.readBoolEntry( "DoubleSpace", false );
472 reader->bindenter = config.readNumEntry( "Indent", 0 ); 470 reader->bindenter = config.readNumEntry( "Indent", 0 );
473 reader->m_textsize = config.readNumEntry( "FontSize", 12 ); 471 reader->m_textsize = config.readNumEntry( "FontSize", 12 );
474 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184); 472 reader->m_delay = config.readNumEntry( "ScrollDelay", 5184);
475 reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1); 473 reader->m_scrollstep = config.readNumEntry( "ScrollStep", 1);
476 474
477 reader->m_lastfile = config.readEntry( "LastFile", QString::null ); 475 reader->m_lastfile = config.readEntry( "LastFile", QString::null );
478 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 ); 476 reader->m_lastposn = config.readNumEntry( "LastPosn", 0 );
479 reader->m_bpagemode = config.readBoolEntry( "PageMode", true ); 477 reader->m_bpagemode = config.readBoolEntry( "PageMode", true );
480 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false); 478 reader->m_bMonoSpaced = config.readBoolEntry( "MonoSpaced", false);
481 reader->m_rotated = config.readBoolEntry( "IsRotated", false ); 479 reader->m_rotated = config.readBoolEntry( "IsRotated", false );
482 reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 ); 480 reader->m_scrolltype = config.readNumEntry( "ScrollType", 0 );
483 m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%"); 481 m_statusstring = config.readEntry("StatusContent", "%P%% Doc:%d/%D %p%% %z%%");
484 m_statusishidden = config.readBoolEntry("StatusHidden", false); 482 m_statusishidden = config.readBoolEntry("StatusHidden", false);
485 m_background = config.readNumEntry( "Background", 0 ); 483 m_background = config.readNumEntry( "Background", 0 );
486 reader->setBackground(getcolour(m_background)); 484 reader->setBackground(getcolour(m_background));
487 m_foreground = config.readNumEntry( "Foreground", 1 ); 485 m_foreground = config.readNumEntry( "Foreground", 1 );
488 reader->setForeground(getcolour(m_foreground)); 486 reader->setForeground(getcolour(m_foreground));
489 m_scrollcolor = config.readNumEntry( "ScrollColour", 5 ); 487 m_scrollcolor = config.readNumEntry( "ScrollColour", 5 );
490 setscrollcolour(); 488 setscrollcolour();
491 m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", 5 ); 489 m_scrollbarcolor = config.readNumEntry( "ScrollBarColour", 5 );
492 setscrollbarcolour(); 490 setscrollbarcolour();
493 reader->hyphenate = config.readBoolEntry( "Hyphenate", false ); 491 reader->hyphenate = config.readBoolEntry( "Hyphenate", false );
494 reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false); 492 reader->m_swapmouse = config.readBoolEntry( "SwapMouse", false);
495 reader->m_fontname = config.readEntry( "Fontname", "helvetica" ); 493 reader->m_fontname = config.readEntry( "Fontname", "helvetica" );
496 reader->m_encd = config.readNumEntry( "Encoding", 0 ); 494 reader->m_encd = config.readNumEntry( "Encoding", 0 );
497 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 ); 495 reader->m_charpc = config.readNumEntry( "CharSpacing", 100 );
498 reader->m_overlap = config.readNumEntry( "Overlap", 0 ); 496 reader->m_overlap = config.readNumEntry( "Overlap", 0 );
499 reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 ); 497 reader->m_abstopmargin = config.readNumEntry( "Top Margin", 100 );
500 reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 ); 498 reader->m_absbottommargin = config.readNumEntry( "Bottom Margin", 100 );
501 reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 ); 499 reader->m_absleft_border = config.readNumEntry( "Left Margin", 100 );
502 reader->m_absright_border = config.readNumEntry( "Right Margin", 100 ); 500 reader->m_absright_border = config.readNumEntry( "Right Margin", 100 );
503 501
504 m_scrollishidden = config.readBoolEntry( "HideScrollBar", false ); 502 m_scrollishidden = config.readBoolEntry( "HideScrollBar", false );
505 503
506 reader->brepalm = config.readBoolEntry( "Repalm", false ); 504 reader->brepalm = config.readBoolEntry( "Repalm", false );
507 reader->bkern = config.readBoolEntry( "Kern", false ); 505 reader->bkern = config.readBoolEntry( "Kern", false );
508 reader->bremap = config.readBoolEntry( "Remap", true ); 506 reader->bremap = config.readBoolEntry( "Remap", true );
509 reader->bmakebold = config.readBoolEntry( "MakeBold", false ); 507 reader->bmakebold = config.readBoolEntry( "MakeBold", false );
510 reader->setContinuous(config.readBoolEntry( "Continuous", true )); 508 reader->setContinuous(config.readBoolEntry( "Continuous", true ));
511 m_targetapp = config.readEntry( "TargetApp", QString::null ); 509 m_targetapp = config.readEntry( "TargetApp", QString::null );
512 m_targetmsg = config.readEntry( "TargetMsg", QString::null ); 510 m_targetmsg = config.readEntry( "TargetMsg", QString::null );
513#ifdef _SCROLLPIPE 511#ifdef _SCROLLPIPE
514 reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null ); 512 reader->m_pipetarget = config.readEntry( "PipeTarget", QString::null );
515 reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true ); 513 reader->m_pauseAfterEachPara = config.readBoolEntry( "PauseAfterPara", true );
516#endif 514#endif
517 m_twoTouch = config.readBoolEntry( "TwoTouch", false); 515 m_twoTouch = config.readBoolEntry( "TwoTouch", false);
518 m_doAnnotation = config.readBoolEntry( "Annotation", false); 516 m_doAnnotation = config.readBoolEntry( "Annotation", false);
519 m_doDictionary = config.readBoolEntry( "Dictionary", false); 517 m_doDictionary = config.readBoolEntry( "Dictionary", false);
520 m_doClipboard = config.readBoolEntry( "Clipboard", false); 518 m_doClipboard = config.readBoolEntry( "Clipboard", false);
521 /* 519 /*
522 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll); 520 m_spaceTarget = (ActionTypes)config.readNumEntry("SpaceTarget", cesAutoScroll);
523 m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone); 521 m_escapeTarget = (ActionTypes)config.readNumEntry("EscapeTarget", cesNone);
524 m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen); 522 m_returnTarget = (ActionTypes)config.readNumEntry("ReturnTarget", cesFullScreen);
525 m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut); 523 m_leftTarget = (ActionTypes)config.readNumEntry("LeftTarget", cesZoomOut);
526 m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn); 524 m_rightTarget = (ActionTypes)config.readNumEntry("RightTarget", cesZoomIn);
527 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp); 525 m_upTarget = (ActionTypes)config.readNumEntry("UpTarget", cesPageUp);
528 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown); 526 m_downTarget = (ActionTypes)config.readNumEntry("DownTarget", cesPageDown);
529 527
530 m_leftScroll = config.readBoolEntry("LeftScroll", false); 528 m_leftScroll = config.readBoolEntry("LeftScroll", false);
531 m_rightScroll = config.readBoolEntry("RightScroll", false); 529 m_rightScroll = config.readBoolEntry("RightScroll", false);
532 m_upScroll = config.readBoolEntry("UpScroll", true); 530 m_upScroll = config.readBoolEntry("UpScroll", true);
533 m_downScroll = config.readBoolEntry("DownScroll", true); 531 m_downScroll = config.readBoolEntry("DownScroll", true);
534 */ 532 */
535 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false); 533 m_propogatefontchange = config.readBoolEntry( "RequestorFontChange", false);
536 reader->setBaseSize(config.readNumEntry( "Basesize", 10 )); 534 reader->setBaseSize(config.readNumEntry( "Basesize", 10 ));
537 reader->setHyphenThreshold(config.readNumEntry( "HyphenThreshold", 50 )); 535 reader->setHyphenThreshold(config.readNumEntry( "HyphenThreshold", 50 ));
538 // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false )); 536 // reader->buffdoc.setCustomHyphen(config.readBoolEntry( "CustomHyphen", false ));
539#ifndef USEQPE 537#ifndef USEQPE
540 config.setGroup( "Geometry" ); 538 config.setGroup( "Geometry" );
541 setGeometry(0,0, 539 setGeometry(0,0,
542 config.readNumEntry( "width", QApplication::desktop()->width()/2 ), 540 config.readNumEntry( "width", QApplication::desktop()->width()/2 ),
543 config.readNumEntry( "height", QApplication::desktop()->height()/2 )); 541 config.readNumEntry( "height", QApplication::desktop()->height()/2 ));
544 move( 542 move(
545 config.readNumEntry( "x", 20 ), 543 config.readNumEntry( "x", 20 ),
546 config.readNumEntry( "y", 20 )); 544 config.readNumEntry( "y", 20 ));
547#else 545#else
548 m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", false); 546 m_grabkeyboard = config.readBoolEntry( "GrabKeyboard", false);
549#endif 547#endif
550 548
551 549
552 550
553 setTwoTouch(m_twoTouch); 551 setTwoTouch(m_twoTouch);
554 552
555 connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) ); 553 connect( reader, SIGNAL( OnShowPicture(QImage&) ), this, SLOT( showgraphic(QImage&) ) );
556 554
557 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) ); 555 connect( reader, SIGNAL( OnRedraw() ), this, SLOT( OnRedraw() ) );
558 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, size_t, const QString&) ) ); 556 connect( reader, SIGNAL( OnWordSelected(const QString&, size_t, size_t, const QString&) ), this, SLOT( OnWordSelected(const QString&, size_t, size_t, const QString&) ) );
559 connect( reader, SIGNAL( OnURLSelected(const QString&, const size_t) ), this, SLOT( OnURLSelected(const QString&, const size_t) ) ); 557 connect( reader, SIGNAL( OnURLSelected(const QString&, const size_t) ), this, SLOT( OnURLSelected(const QString&, const size_t) ) );
560 connect( reader, SIGNAL( NewFileRequest(const QString&) ), this, SLOT( forceopen(const QString&) ) ); 558 connect( reader, SIGNAL( NewFileRequest(const QString&) ), this, SLOT( forceopen(const QString&) ) );
561 connect( reader, SIGNAL( HandleKeyRequest(QKeyEvent*) ), this, SLOT( handlekey(QKeyEvent*) ) ); 559 connect( reader, SIGNAL( HandleKeyRequest(QKeyEvent*) ), this, SLOT( handlekey(QKeyEvent*) ) );
562 connect( reader, SIGNAL( SetScrollState(bool) ), this, SLOT( setScrollState(bool) ) ); 560 connect( reader, SIGNAL( SetScrollState(bool) ), this, SLOT( setScrollState(bool) ) );
563 connect( reader, SIGNAL(RefreshBitmap()), this, SLOT(setBackgroundBitmap())); 561 connect( reader, SIGNAL(RefreshBitmap()), this, SLOT(setBackgroundBitmap()));
564 editorStack->addWidget( reader, get_unique_id() ); 562 editorStack->addWidget( reader, get_unique_id() );
565 563
566 m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL); 564 m_preferences_action = new QAction( tr( "Configuration" ), geticon( "SettingsIcon" ), QString::null, 0, this, NULL);
567 connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) ); 565 connect( m_preferences_action, SIGNAL( activated() ), this, SLOT( showprefs() ) );
568 m_preferences_action->addTo( settings ); 566 m_preferences_action->addTo( settings );
569 567
570 m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL); 568 m_saveconfig_action = new QAction( tr( "Save Config" ), QString::null, 0, this, NULL);
571 connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) ); 569 connect( m_saveconfig_action, SIGNAL( activated() ), this, SLOT( SaveConfig() ) );
572 m_saveconfig_action->addTo( settings ); 570 m_saveconfig_action->addTo( settings );
573 571
574 m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL); 572 m_loadconfig_action = new QAction( tr( "Load Config" ), QString::null, 0, this, NULL);
575 connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) ); 573 connect( m_loadconfig_action, SIGNAL( activated() ), this, SLOT( LoadConfig() ) );
576 m_loadconfig_action->addTo( settings ); 574 m_loadconfig_action->addTo( settings );
577 575
578 m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL); 576 m_tidyconfig_action = new QAction( tr( "Delete Config" ), QString::null, 0, this, NULL);
579 connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) ); 577 connect( m_tidyconfig_action, SIGNAL( activated() ), this, SLOT( TidyConfig() ) );
580 m_tidyconfig_action->addTo( settings ); 578 m_tidyconfig_action->addTo( settings );
581 579
582 settings->insertSeparator(); 580 settings->insertSeparator();
583 m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL); 581 m_toolbarprefs_action = new QAction( tr( "Toolbars" ), QString::null, 0, this, NULL);
584 connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) ); 582 connect( m_toolbarprefs_action, SIGNAL( activated() ), this, SLOT( showtoolbarprefs() ) );
585 m_toolbarprefs_action->addTo( settings ); 583 m_toolbarprefs_action->addTo( settings );
586 584
587 m_buttonprefs_action = new QAction( tr( "Buttons" ), QString::null, 0, this, NULL); 585 m_buttonprefs_action = new QAction( tr( "Buttons" ), QString::null, 0, this, NULL);
588 connect( m_buttonprefs_action, SIGNAL( activated() ), this, SLOT( showbuttonprefs() ) ); 586 connect( m_buttonprefs_action, SIGNAL( activated() ), this, SLOT( showbuttonprefs() ) );
589 m_buttonprefs_action->addTo( settings ); 587 m_buttonprefs_action->addTo( settings );
590 588
591 m_loadtheme_action = new QAction( tr( "Load Theme" ), QString::null, 0, this, NULL); 589 m_loadtheme_action = new QAction( tr( "Load Theme" ), QString::null, 0, this, NULL);
592 connect( m_loadtheme_action, SIGNAL( activated() ), this, SLOT( LoadTheme() ) ); 590 connect( m_loadtheme_action, SIGNAL( activated() ), this, SLOT( LoadTheme() ) );
593 m_loadtheme_action->addTo( settings ); 591 m_loadtheme_action->addTo( settings );
594 592
595 m_repara_action = new QAction( tr( "EOP Marker" ), QString::null, 0, this, NULL); 593 m_repara_action = new QAction( tr( "EOP Marker" ), QString::null, 0, this, NULL);
596 connect( m_repara_action, SIGNAL( activated() ), this, SLOT( reparastring() ) ); 594 connect( m_repara_action, SIGNAL( activated() ), this, SLOT( reparastring() ) );
597 m_repara_action->addTo(settings); 595 m_repara_action->addTo(settings);
598 596
599#ifdef USEQPE 597#ifdef USEQPE
600 m_grab_action = new QAction( tr( "Grab Buttons" ), QString::null, 0, this, NULL, true ); 598 m_grab_action = new QAction( tr( "Grab Buttons" ), QString::null, 0, this, NULL, true );
601 connect( m_grab_action, SIGNAL( toggled(bool) ), this, SLOT( setgrab(bool) ) ); 599 connect( m_grab_action, SIGNAL( toggled(bool) ), this, SLOT( setgrab(bool) ) );
602 m_grab_action->setOn(m_grabkeyboard); 600 m_grab_action->setOn(m_grabkeyboard);
603 m_grab_action->addTo( settings ); 601 m_grab_action->addTo( settings );
604#endif 602#endif
605 603
606 m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 ); 604 m_open_action = new QAction( tr( "Open" ), geticon( "fileopen" ), QString::null, 0, this, 0 );
607 connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) ); 605 connect( m_open_action, SIGNAL( activated() ), this, SLOT( fileOpen() ) );
608 m_open_action->addTo( file ); 606 m_open_action->addTo( file );
609 607
610 m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 ); 608 m_close_action = new QAction( tr( "Close" ), geticon( "close" ), QString::null, 0, this, 0 );
611 connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) ); 609 connect( m_close_action, SIGNAL( activated() ), this, SLOT( fileClose() ) );
612 m_close_action->addTo( file ); 610 m_close_action->addTo( file );
613 611
614#ifdef _SCRIPT 612#ifdef _SCRIPT
615 a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL); 613 a = new QAction( tr( "Run Script" ), QString::null, 0, this, NULL);
616 connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) ); 614 connect( a, SIGNAL( activated() ), this, SLOT( RunScript() ) );
617 a->addTo( file ); 615 a->addTo( file );
618#endif 616#endif
619 /* 617 /*
620 a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 ); 618 a = new QAction( tr( "Revert" ), geticon( "close" ), QString::null, 0, this, 0 );
621 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) ); 619 connect( a, SIGNAL( activated() ), this, SLOT( fileRevert() ) );
622 a->addTo( file ); 620 a->addTo( file );
623 621
624 a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 ); 622 a = new QAction( tr( "Cut" ), geticon( "cut" ), QString::null, 0, this, 0 );
625 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) ); 623 connect( a, SIGNAL( activated() ), this, SLOT( editCut() ) );
626 a->addTo( filebar() ); 624 a->addTo( filebar() );
627 a->addTo( edit ); 625 a->addTo( edit );
628 */ 626 */
629 627
630 m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL); 628 m_info_action = new QAction( tr( "Info" ), geticon( "UtilsIcon" ), QString::null, 0, this, NULL);
631 connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) ); 629 connect( m_info_action, SIGNAL( activated() ), this, SLOT( showinfo() ) );
632 m_info_action->addTo( file ); 630 m_info_action->addTo( file );
633 631
634 m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true ); 632 m_touch_action = new QAction( tr( "Two/One Touch" ), geticon( "1to1" ), QString::null, 0, this, NULL, true );
635 connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) ); 633 connect( m_touch_action, SIGNAL( toggled(bool) ), this, SLOT( setTwoTouch(bool) ) );
636 m_touch_action->setOn(m_twoTouch); 634 m_touch_action->setOn(m_twoTouch);
637 m_touch_action->addTo( file ); 635 m_touch_action->addTo( file );
638 636
639 m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL); 637 m_find_action = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, NULL);
640 connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) ); 638 connect( m_find_action, SIGNAL( activated() ), this, SLOT( editFind() ) );
641 file->insertSeparator(); 639 file->insertSeparator();
642// a->addTo( bar ); 640// a->addTo( bar );
643 m_find_action->addTo( file ); 641 m_find_action->addTo( file );
644 642
645 m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL); 643 m_exportlinks_action = new QAction( tr( "Export Links" ), QString::null, 0, this, NULL);
646 connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) ); 644 connect( m_exportlinks_action, SIGNAL( activated() ), this, SLOT( ExportLinks() ) );
647 m_exportlinks_action->addTo( file ); 645 m_exportlinks_action->addTo( file );
648 646
649 m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true ); 647 m_scrollButton = new QAction( tr( "Scroll" ), getmyicon( "panel-arrow-down" ), QString::null, 0, this, 0, true );
650 connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) ); 648 connect( m_scrollButton, SIGNAL( toggled(bool) ), this, SLOT( autoScroll(bool) ) );
651 m_scrollButton->addTo(navigation); 649 m_scrollButton->addTo(navigation);
652 m_scrollButton->setOn(false); 650 m_scrollButton->setOn(false);
653 651
654 m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL); 652 m_start_action = new QAction( tr( "Goto Start" ), geticon( "start" ), QString::null, 0, this, NULL);
655 connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) ); 653 connect( m_start_action, SIGNAL( activated() ), this, SLOT( gotoStart() ) );
656 m_start_action->addTo(navigation); 654 m_start_action->addTo(navigation);
657 655
658 m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL); 656 m_end_action = new QAction( tr( "Goto End" ), geticon( "finish" ), QString::null, 0, this, NULL);
659 connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) ); 657 connect( m_end_action, SIGNAL( activated() ), this, SLOT( gotoEnd() ) );
660 m_end_action->addTo(navigation); 658 m_end_action->addTo(navigation);
661 659
662 m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL); 660 m_jump_action = new QAction( tr( "Jump" ), geticon( "rotate" ), QString::null, 0, this, NULL);
663 connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) ); 661 connect( m_jump_action, SIGNAL( activated() ), this, SLOT( jump() ) );
664 m_jump_action->addTo(navigation); 662 m_jump_action->addTo(navigation);
665 663
666 m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true ); 664 m_pageline_action = new QAction( tr( "Page/Line Scroll" ), geticon( "pass" ), QString::null, 0, this, NULL, true );
667 connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) ); 665 connect( m_pageline_action, SIGNAL( toggled(bool) ), this, SLOT( pagemode(bool) ) );
668 m_pageline_action->addTo(navigation); 666 m_pageline_action->addTo(navigation);
669 m_pageline_action->setOn(reader->m_bpagemode); 667 m_pageline_action->setOn(reader->m_bpagemode);
670 668
671 m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 ); 669 m_pageup_action = new QAction( tr( "Up" ), geticon( "up" ), QString::null, 0, this, 0 );
672 connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) ); 670 connect( m_pageup_action, SIGNAL( activated() ), this, SLOT( pageup() ) );
673 m_pageup_action->addTo( navigation ); 671 m_pageup_action->addTo( navigation );
674 672
675 m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 ); 673 m_pagedn_action = new QAction( tr( "Down" ), geticon( "down" ), QString::null, 0, this, 0 );
676 connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 674 connect( m_pagedn_action, SIGNAL( activated() ), this, SLOT( pagedn() ) );
677 m_pagedn_action->addTo( navigation ); 675 m_pagedn_action->addTo( navigation );
678 676
679 m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 ); 677 m_back_action = new QAction( tr( "Back" ), geticon( "back" ), QString::null, 0, this, 0 );
680 connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) ); 678 connect( m_back_action, SIGNAL( activated() ), reader, SLOT( goBack() ) );
681 m_back_action->addTo( navigation ); 679 m_back_action->addTo( navigation );
682 680
683 m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 ); 681 m_home_action = new QAction( tr( "Home" ), geticon( "home" ), QString::null, 0, this, 0 );
684 connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) ); 682 connect( m_home_action, SIGNAL( activated() ), reader, SLOT( goHome() ) );
685 m_home_action->addTo( navigation ); 683 m_home_action->addTo( navigation );
686 684
687 m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 ); 685 m_forward_action = new QAction( tr( "Forward" ), geticon( "forward" ), QString::null, 0, this, 0 );
688 connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) ); 686 connect( m_forward_action, SIGNAL( activated() ), reader, SLOT( goForward() ) );
689 m_forward_action->addTo( navigation ); 687 m_forward_action->addTo( navigation );
690 688
691 /* 689 /*
692 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true ); 690 a = new QAction( tr( "Find" ), QString::null, 0, this, NULL, true );
693 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 691 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
694 a->addTo( file ); 692 a->addTo( file );
695 693
696 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true ); 694 a = new QAction( tr( "Find Again" ), QString::null, 0, this, NULL, true );
697 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) ); 695 // connect( a, SIGNAL( activated() ), this, SLOT( pagedn() ) );
698 a->addTo( file ); 696 a->addTo( file );
699 */ 697 */
700 698
701// file->insertSeparator(); 699// file->insertSeparator();
702 700
703#ifdef _SCROLLPIPE 701#ifdef _SCROLLPIPE
704 702
705 QActionGroup* ag = new QActionGroup(this); 703 QActionGroup* ag = new QActionGroup(this);
706 ag->setExclusive(false); 704 ag->setExclusive(false);
707 spacemenu = new QPopupMenu(this); 705 spacemenu = new QPopupMenu(this);
708 file->insertItem( tr( "Scrolling" ), spacemenu ); 706 file->insertItem( tr( "Scrolling" ), spacemenu );
709 707
710 a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL); 708 a = new QAction( tr( "Set Target" ), QString::null, 0, ag, NULL);
711 connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) ); 709 connect( a, SIGNAL( activated() ), this, SLOT( setpipetarget() ) );
712 710
713 a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true ); 711 a = new QAction( tr( "Pause Paras" ), QString::null, 0, ag, NULL, true );
714 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) ); 712 connect( a, SIGNAL( toggled(bool) ), this, SLOT( setpause(bool) ) );
715 a->setOn(reader->m_pauseAfterEachPara); 713 a->setOn(reader->m_pauseAfterEachPara);
716 714
717 ag->addTo(spacemenu); 715 ag->addTo(spacemenu);
718// file->insertSeparator(); 716// file->insertSeparator();
719 717
720#endif 718#endif
721 719
722/* 720/*
723 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL ); 721 a = new QAction( tr( "Import" ), QString::null, 0, this, NULL );
724 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) ); 722 connect( a, SIGNAL( activated() ), this, SLOT( importFiles() ) );
725 a->addTo( file ); 723 a->addTo( file );
726*/ 724*/
727 725
728 /* 726 /*
729 a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 ); 727 a = new QAction( tr( "Paste" ), geticon( "paste" ), QString::null, 0, this, 0 );
730 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) ); 728 connect( a, SIGNAL( activated() ), this, SLOT( editPaste() ) );
731 a->addTo( fileBar ); 729 a->addTo( fileBar );
732 a->addTo( edit ); 730 a->addTo( edit );
733 */ 731 */
734 732
735// a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 ); 733// a = new QAction( tr( "Find..." ), geticon( "find" ), QString::null, 0, this, 0 );
736 734
737 m_fullscreen = false; 735 m_fullscreen = false;
738 m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true ); 736 m_actFullscreen = new QAction( tr( "Fullscreen" ), geticon( "fullscreen" ), QString::null, 0, this, NULL, true );
739 connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) ); 737 connect( m_actFullscreen, SIGNAL( toggled(bool) ), this, SLOT( setfullscreen(bool) ) );
740 m_actFullscreen->setOn(m_fullscreen); 738 m_actFullscreen->setOn(m_fullscreen);
741 m_actFullscreen->addTo( view ); 739 m_actFullscreen->addTo( view );
742 740
743 m_rotate_action = new QAction( tr( "Rotate" ), geticon( "repeat" ), QString::null, 0, this, NULL, true ); 741 m_rotate_action = new QAction( tr( "Rotate" ), geticon( "repeat" ), QString::null, 0, this, NULL, true );
744 connect( m_rotate_action, SIGNAL( toggled(bool) ), this, SLOT( setrotated(bool) ) ); 742 connect( m_rotate_action, SIGNAL( toggled(bool) ), this, SLOT( setrotated(bool) ) );
745 m_rotate_action->setOn(reader->m_rotated); 743 m_rotate_action->setOn(reader->m_rotated);
746 m_rotate_action->addTo( view ); 744 m_rotate_action->addTo( view );
747 745
748 m_inverse_action = new QAction( tr( "Invert" ), getmyicon( "invert" ), QString::null, 0, this, NULL, true ); 746 m_inverse_action = new QAction( tr( "Invert" ), getmyicon( "invert" ), QString::null, 0, this, NULL, true );
749 connect( m_inverse_action, SIGNAL( toggled(bool) ), this, SLOT( setinverted(bool) ) ); 747 connect( m_inverse_action, SIGNAL( toggled(bool) ), this, SLOT( setinverted(bool) ) );
750 m_inverse_action->setOn(reader->bInverse); 748 m_inverse_action->setOn(reader->bInverse);
751 m_inverse_action->addTo( view ); 749 m_inverse_action->addTo( view );
752 750
753 view->insertSeparator(); 751 view->insertSeparator();
754 752
755 m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this); 753 m_zoomin_action = new QAction( tr( "Zoom In" ), geticon( "zoom" ), QString::null, 0, this);
756 connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) ); 754 connect( m_zoomin_action, SIGNAL( activated() ), this, SLOT( zoomin() ) );
757 m_zoomin_action->addTo( view ); 755 m_zoomin_action->addTo( view );
758 756
759 m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this); 757 m_zoomout_action = new QAction( tr( "Zoom Out" ), geticon( "mag" ), QString::null, 0, this);
760 connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) ); 758 connect( m_zoomout_action, SIGNAL( activated() ), this, SLOT( zoomout() ) );
761 m_zoomout_action->addTo( view ); 759 m_zoomout_action->addTo( view );
762 760
763 view->insertSeparator(); 761 view->insertSeparator();
764 m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this); 762 m_setfont_action = new QAction( tr( "Set Font" ), getmyicon( "font" ), QString::null, 0, this);
765 connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) ); 763 connect( m_setfont_action, SIGNAL( activated() ), this, SLOT( setfont() ) );
766 m_setfont_action->addTo( view ); 764 m_setfont_action->addTo( view );
767 765
768 view->insertSeparator(); 766 view->insertSeparator();
769 m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this); 767 m_setenc_action = new QAction( tr( "Set Encoding" ), getmyicon( "charset" ), QString::null, 0, this);
770 connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) ); 768 connect( m_setenc_action, SIGNAL( activated() ), this, SLOT( chooseencoding() ) );
771 m_setenc_action->addTo( view ); 769 m_setenc_action->addTo( view );
772 770
773 m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true); 771 m_setmono_action = new QAction( tr( "Ideogram" ), getmyicon( "ideogram" ), QString::null, 0, this, NULL, true);
774 connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); 772 connect( m_setmono_action, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
775 m_setmono_action->addTo( view ); 773 m_setmono_action->addTo( view );
776 m_setmono_action->setOn(reader->m_bMonoSpaced); 774 m_setmono_action->setOn(reader->m_bMonoSpaced);
777 775
778 776
779 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true ); 777 // a = new QAction( tr( "Zoom" ), QString::null, 0, this, NULL, true );
780 // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 ); 778 // a = new QAction( tr( "Zoom" ), geticon( "mag" ), QString::null, 0, this, 0 );
781 779
782 780
783 781
784 // a->addTo( filebar() ); 782 // a->addTo( filebar() );
785// view->insertSeparator(); 783// view->insertSeparator();
786 784
787/* 785/*
788 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true ); 786 a = new QAction( tr( "Ideogram/Word" ), QString::null, 0, this, NULL, true );
789 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) ); 787 connect( a, SIGNAL( toggled(bool) ), this, SLOT( monospace(bool) ) );
790 a->setOn(reader->m_bMonoSpaced); 788 a->setOn(reader->m_bMonoSpaced);
791 a->addTo( view ); 789 a->addTo( view );
792*/ 790*/
793/* 791/*
794 a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL); 792 a = new QAction( tr( "Set Width" ), QString::null, 0, this, NULL);
795 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) ); 793 connect( a, SIGNAL( activated() ), this, SLOT( setspacing() ) );
796 a->addTo( view ); 794 a->addTo( view );
797*/ 795*/
798 796
799 m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL); 797 m_mark_action = new QAction( tr( "Bookmark" ), getmyicon( "bookmark" ), QString::null, 0, this, NULL);
800 connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) ); 798 connect( m_mark_action, SIGNAL( activated() ), this, SLOT( addbkmk() ) );
801 m_mark_action->addTo( marks ); 799 m_mark_action->addTo( marks );
802 800
803 m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL); 801 m_annotate_action = new QAction( tr( "Annotate" ), getmyicon( "annotate" ), QString::null, 0, this, NULL);
804 connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) ); 802 connect( m_annotate_action, SIGNAL( activated() ), this, SLOT( addanno() ) );
805 m_annotate_action->addTo( marks ); 803 m_annotate_action->addTo( marks );
806 804
807 m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false ); 805 m_goto_action = new QAction( tr( "Goto" ), getmyicon( "bookmark_goto" ), QString::null, 0, this, NULL, false );
808 connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) ); 806 connect( m_goto_action, SIGNAL( activated() ), this, SLOT( do_gotomark() ) );
809 m_goto_action->addTo( marks ); 807 m_goto_action->addTo( marks );
810 808
811 m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL); 809 m_delete_action = new QAction( tr( "Delete" ), getmyicon( "bookmark_delete" ), QString::null, 0, this, NULL);
812 connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) ); 810 connect( m_delete_action, SIGNAL( activated() ), this, SLOT( do_delmark() ) );
813 m_delete_action->addTo( marks ); 811 m_delete_action->addTo( marks );
814 812
815 m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false ); 813 m_autogen_action = new QAction( tr( "Autogen" ), geticon( "exec" ), QString::null, 0, this, NULL, false );
816 connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) ); 814 connect( m_autogen_action, SIGNAL( activated() ), this, SLOT( do_autogen() ) );
817 marks->insertSeparator(); 815 marks->insertSeparator();
818 m_autogen_action->addTo( marks ); 816 m_autogen_action->addTo( marks );
819 817
820 m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL); 818 m_clear_action = new QAction( tr( "Clear" ), getmyicon( "bookmark_clear" ), QString::null, 0, this, NULL);
821 connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) ); 819 connect( m_clear_action, SIGNAL( activated() ), this, SLOT( clearBkmkList() ) );
822 m_clear_action->addTo( marks ); 820 m_clear_action->addTo( marks );
823 821
824 m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL ); 822 m_save_action = new QAction( tr( "Save" ), getmyicon( "bookmark_save" ), QString::null, 0, this, NULL );
825 connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) ); 823 connect( m_save_action, SIGNAL( activated() ), this, SLOT( savebkmks() ) );
826 m_save_action->addTo( marks ); 824 m_save_action->addTo( marks );
827 825
828 m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL); 826 m_tidy_action = new QAction( tr( "Tidy" ), getmyicon( "bookmark_tidy" ), QString::null, 0, this, NULL);
829 connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) ); 827 connect( m_tidy_action, SIGNAL( activated() ), this, SLOT( listBkmkFiles() ) );
830 marks->insertSeparator(); 828 marks->insertSeparator();
831 m_tidy_action->addTo( marks ); 829 m_tidy_action->addTo( marks );
832 830
833 m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL); 831 m_startBlock_action = new QAction( tr( "Start Block" ), geticon( "new" ), QString::null, 0, this, NULL);
834 connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) ); 832 connect( m_startBlock_action, SIGNAL( activated() ), this, SLOT( editMark() ) );
835 marks->insertSeparator(); 833 marks->insertSeparator();
836 m_startBlock_action->addTo( marks ); 834 m_startBlock_action->addTo( marks );
837 835
838 m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL); 836 m_endBlock_action = new QAction( tr( "Copy Block" ), geticon( "copy" ), QString::null, 0, this, NULL);
839 connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) ); 837 connect( m_endBlock_action, SIGNAL( activated() ), this, SLOT( editCopy() ) );
840 m_endBlock_action->addTo( marks ); 838 m_endBlock_action->addTo( marks );
841 839
842 m_bkmkAvail = NULL; 840 m_bkmkAvail = NULL;
843 841
844 842
845 setToolBarsMovable(m_tbmove); 843 setToolBarsMovable(m_tbmove);
846 addtoolbars(&config); 844 addtoolbars(&config);
847 845
848 pbar = new QProgressBar(this); 846 pbar = new QProgressBar(this);
849 pbar->hide(); 847 pbar->hide();
850 848
851 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE ); 849 searchBar = new QFloatBar( "Search", this, QMainWindow::Top, TRUE );
852 850
853 searchBar->setHorizontalStretchable( TRUE ); 851 searchBar->setHorizontalStretchable( TRUE );
854 852
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,485 +1,484 @@
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
47class QBoxLayout; 46class QBoxLayout;
48class QWidgetStack; 47class QWidgetStack;
49class QToolButton; 48class QToolButton;
50class QPopupMenu; 49class QPopupMenu;
51class QToolBar; 50class QToolBar;
52#ifdef USEQPE 51#ifdef USEQPE
53class QPEToolBar; 52class QPEToolBar;
54class QPEMenuBar; 53class QPEMenuBar;
55#endif 54#endif
56class QScrollBar; 55class QScrollBar;
57class CBkmkSelector; 56class CBkmkSelector;
58class QProgressBar; 57class QProgressBar;
59class QAction; 58class QAction;
60class CAnnoEdit; 59class CAnnoEdit;
61class QFloatBar; 60class QFloatBar;
62class CDrawBuffer; 61class CDrawBuffer;
63class QTReader; 62class QTReader;
64class QImage; 63class QImage;
65class Config; 64class Config;
66class CButtonPrefs; 65class CButtonPrefs;
67 66
68#ifdef USEQPE 67#ifdef USEQPE
69enum ToolbarPolicy 68enum ToolbarPolicy
70{ 69{
71 cesSingle = 0, 70 cesSingle = 0,
72 cesMenuTool, 71 cesMenuTool,
73 cesMultiple 72 cesMultiple
74}; 73};
75#else 74#else
76enum ToolbarPolicy 75enum ToolbarPolicy
77{ 76{
78 cesMenuTool = 0, 77 cesMenuTool = 0,
79 cesMultiple 78 cesMultiple
80}; 79};
81#endif 80#endif
82 81
83enum regedit_type 82enum 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
100enum bkmk_action 99enum 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
112enum fontselector_action 111enum fontselector_action
113{ 112{
114 cChooseFont, 113 cChooseFont,
115 cChooseEncoding 114 cChooseEncoding
116}; 115};
117 116
118#ifdef __ISEARCH 117#ifdef __ISEARCH
119struct searchrecord 118struct 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
127class infowin; 126class infowin;
128class GraphicWin; 127class GraphicWin;
129 128
130class QTReaderApp : public QMainWindow 129class 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();
217public slots: 216public 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);
222 void forceopen(const QString& filename); 221 void forceopen(const QString& filename);
223 void setDocument(const QString&); 222 void setDocument(const QString&);
224private slots: 223private slots:
225#ifdef _SCRIPT 224#ifdef _SCRIPT
226// void RunScript(); 225// void RunScript();
227#endif 226#endif
228 void actionscroll(int v); 227 void actionscroll(int v);
229 void SaveConfig(); 228 void SaveConfig();
230 void LoadTheme(); 229 void LoadTheme();
231 void LoadConfig(); 230 void LoadConfig();
232 void TidyConfig(); 231 void TidyConfig();
233 void ExportLinks(); 232 void ExportLinks();
234 void zoomin(); 233 void zoomin();
235 void zoomout(); 234 void zoomout();
236 void chooseencoding(); 235 void chooseencoding();
237 void setfullscreen(bool sfs); 236 void setfullscreen(bool sfs);
238 void setrotated(bool sfs); 237 void setrotated(bool sfs);
239 void setinverted(bool sfs); 238 void setinverted(bool sfs);
240 void setgrab(bool sfs); 239 void setgrab(bool sfs);
241// void setcontinuous(bool sfs); 240// void setcontinuous(bool sfs);
242 void setTwoTouch(bool _b); 241 void setTwoTouch(bool _b);
243 void restoreFocus(); 242 void restoreFocus();
244 void OnAnnotation(bool _b) 243 void OnAnnotation(bool _b)
245 { 244 {
246 m_doAnnotation = _b; 245 m_doAnnotation = _b;
247 } 246 }
248 void OnDictionary(bool _b) 247 void OnDictionary(bool _b)
249 { 248 {
250 m_doDictionary = _b; 249 m_doDictionary = _b;
251 } 250 }
252 void OnClipboard(bool _b) 251 void OnClipboard(bool _b)
253 { 252 {
254 m_doClipboard = _b; 253 m_doClipboard = _b;
255 } 254 }
256 void OnWordSelected(const QString&, size_t, size_t, const QString&); 255 void OnWordSelected(const QString&, size_t, size_t, const QString&);
257 void OnURLSelected(const QString& href, const size_t tgt); 256 void OnURLSelected(const QString& href, const size_t tgt);
258 void showgraphic(QImage&); 257 void showgraphic(QImage&);
259 void addAnno(const QString&, const QString&, size_t, size_t); 258 void addAnno(const QString&, const QString&, size_t, size_t);
260 void addAnno(const QString&, const QString&); 259 void addAnno(const QString&, const QString&);
261 void addanno(); 260 void addanno();
262 void showAnnotation(); 261 void showAnnotation();
263 void do_setencoding(int i); 262 void do_setencoding(int i);
264 void do_setfont(const QString&); 263 void do_setfont(const QString&);
265 //void buttonActionSelected(QAction*); 264 //void buttonActionSelected(QAction*);
266 void msgHandler(const QCString&, const QByteArray&); 265 void msgHandler(const QCString&, const QByteArray&);
267 void monospace(bool); 266 void monospace(bool);
268 void jump(); 267 void jump();
269 void reparastring(); 268 void reparastring();
270 void settarget(); 269 void settarget();
271#ifdef _SCROLLPIPE 270#ifdef _SCROLLPIPE
272 //void setpipetarget(); 271 //void setpipetarget();
273 //void setpause(bool); 272 //void setpause(bool);
274#endif 273#endif
275 //void setspacing(); 274 //void setspacing();
276 void setfont(); 275 void setfont();
277 void clearBkmkList(); 276 void clearBkmkList();
278 void listBkmkFiles(); 277 void listBkmkFiles();
279 void editMark(); 278 void editMark();
280 void autoScroll(bool); 279 void autoScroll(bool);
281 void addbkmk(); 280 void addbkmk();
282 void savebkmks(); 281 void savebkmks();
283 //void importFiles(); 282 //void importFiles();
284 void showprefs(); 283 void showprefs();
285 void showtoolbarprefs(); 284 void showtoolbarprefs();
286 void showbuttonprefs(); 285 void showbuttonprefs();
287 void infoClose(); 286 void infoClose();
288 // void oldFile(); 287 // void oldFile();
289 void showinfo(); 288 void showinfo();
290 289
291// void indentplus(); 290// void indentplus();
292// void indentminus(); 291// void indentminus();
293 292
294 void fileOpen(); 293 void fileOpen();
295 void fileClose(); 294 void fileClose();
296 295
297 void editCopy(); 296 void editCopy();
298 void editFind(); 297 void editFind();
299 298
300 void gotoStart(); 299 void gotoStart();
301 void gotoEnd(); 300 void gotoEnd();
302 301
303 void pageup(); 302 void pageup();
304 void pagedn(); 303 void pagedn();
305 304
306 void findNext(); 305 void findNext();
307 void findClose(); 306 void findClose();
308 307
309 void regClose(); 308 void regClose();
310 309
311#ifdef __ISEARCH 310#ifdef __ISEARCH
312// void search( const QString& ); 311// void search( const QString& );
313#else 312#else
314 void search(); 313 void search();
315#endif 314#endif
316 315
317 void showEditTools(); 316 void showEditTools();
318 317
319// void stripcr(bool); 318// void stripcr(bool);
320// void setfulljust(bool); 319// void setfulljust(bool);
321// void onespace(bool); 320// void onespace(bool);
322// void repalm(bool); 321// void repalm(bool);
323// void peanut(bool _b); 322// void peanut(bool _b);
324// void remap(bool); 323// void remap(bool);
325// void embolden(bool); 324// void embolden(bool);
326// void autofmt(bool); 325// void autofmt(bool);
327// void textfmt(bool); 326// void textfmt(bool);
328// void striphtml(bool); 327// void striphtml(bool);
329// void dehyphen(bool); 328// void dehyphen(bool);
330// void depluck(bool); 329// void depluck(bool);
331// void dejpluck(bool); 330// void dejpluck(bool);
332// void unindent(bool); 331// void unindent(bool);
333// void repara(bool); 332// void repara(bool);
334// void dblspce(bool); 333// void dblspce(bool);
335 void pagemode(bool); 334 void pagemode(bool);
336 // void gotobkmk(const QString& bm); 335 // void gotobkmk(const QString& bm);
337 void gotobkmk(int); 336 void gotobkmk(int);
338 void cancelbkmk(); 337 void cancelbkmk();
339 void do_gotomark(); 338 void do_gotomark();
340 void do_delmark(); 339 void do_delmark();
341 void do_autogen(); 340 void do_autogen();
342 void do_regaction(); 341 void do_regaction();
343 void OnRedraw(); 342 void OnRedraw();
344 343
345 private: 344 private:
346 void setscrollcolour(); 345 void setscrollcolour();
347 void setscrollbarcolour(); 346 void setscrollbarcolour();
348 void writeUrl(const QString& file, const QString& href); 347 void writeUrl(const QString& file, const QString& href);
349 QAction *m_preferences_action, *m_open_action, *m_close_action; 348 QAction *m_preferences_action, *m_open_action, *m_close_action;
350 QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action; 349 QAction *m_info_action, *m_touch_action, *m_find_action, *m_start_action;
351 QAction *m_end_action, *m_jump_action, *m_pageline_action; 350 QAction *m_end_action, *m_jump_action, *m_pageline_action;
352 QAction *m_pageup_action, *m_pagedn_action, *m_back_action; 351 QAction *m_pageup_action, *m_pagedn_action, *m_back_action;
353 QAction *m_home_action, *m_forward_action, *m_zoomin_action; 352 QAction *m_home_action, *m_forward_action, *m_zoomin_action;
354 QAction *m_zoomout_action, *m_setfont_action, *m_mark_action; 353 QAction *m_zoomout_action, *m_setfont_action, *m_mark_action;
355 QAction *m_annotate_action, *m_goto_action, *m_delete_action; 354 QAction *m_annotate_action, *m_goto_action, *m_delete_action;
356 QAction *m_autogen_action, *m_clear_action, *m_save_action; 355 QAction *m_autogen_action, *m_clear_action, *m_save_action;
357 QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action; 356 QAction *m_tidy_action, *m_startBlock_action, *m_endBlock_action;
358 QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action; 357 QAction *m_setenc_action, *m_setmono_action, *m_saveconfig_action;
359 QAction *m_loadconfig_action, *m_loadtheme_action, *m_toolbarprefs_action, *m_tidyconfig_action; 358 QAction *m_loadconfig_action, *m_loadtheme_action, *m_toolbarprefs_action, *m_tidyconfig_action;
360 QAction *m_exportlinks_action, *m_rotate_action, *m_buttonprefs_action, *m_inverse_action; 359 QAction *m_exportlinks_action, *m_rotate_action, *m_buttonprefs_action, *m_inverse_action;
361 QAction *m_repara_action; 360 QAction *m_repara_action;
362#ifdef USEQPE 361#ifdef USEQPE
363 QAction *m_grab_action; 362 QAction *m_grab_action;
364#endif 363#endif
365 void addtoolbars(Config* config); 364 void addtoolbars(Config* config);
366 ToolbarPolicy m_tbpol, m_tbpolsave; 365 ToolbarPolicy m_tbpol, m_tbpolsave;
367 ToolBarDock m_tbposition; 366 ToolBarDock m_tbposition;
368 bool m_tbmove, m_tbmovesave; 367 bool m_tbmove, m_tbmovesave;
369 QToolBar* filebar(); 368 QToolBar* filebar();
370 QToolBar* viewbar(); 369 QToolBar* viewbar();
371 QToolBar* navbar(); 370 QToolBar* navbar();
372 QToolBar* markbar(); 371 QToolBar* markbar();
373 void hidetoolbars(); 372 void hidetoolbars();
374 void addfilebar(Config* _config, const QString& key, QAction* a); 373 void addfilebar(Config* _config, const QString& key, QAction* a);
375 void addviewbar(Config* _config, const QString& key, QAction* a); 374 void addviewbar(Config* _config, const QString& key, QAction* a);
376 void addnavbar(Config* _config, const QString& key, QAction* a); 375 void addnavbar(Config* _config, const QString& key, QAction* a);
377 void addmarkbar(Config* _config, const QString& key, QAction* a); 376 void addmarkbar(Config* _config, const QString& key, QAction* a);
378 bool checkbar(Config* _config, const QString& key); 377 bool checkbar(Config* _config, const QString& key);
379#ifdef _SCRIPT 378#ifdef _SCRIPT
380 void SaveScript(const char* sname); 379 void SaveScript(const char* sname);
381#endif 380#endif
382/* 381/*
383 void setstate(unsigned char* _sd, unsigned short _sdlen); 382 void setstate(unsigned char* _sd, unsigned short _sdlen);
384 void getstate(unsigned char*& data, unsigned short& len); 383 void getstate(unsigned char*& data, unsigned short& len);
385*/ 384*/
386 void fileOpen2(); 385 void fileOpen2();
387 void readfilelist(); 386 void readfilelist();
388 void savefilelist(); 387 void savefilelist();
389 void updatefileinfo(); 388 void updatefileinfo();
390 bool openfrombkmk(Bkmk*); 389 bool openfrombkmk(Bkmk*);
391 QString m_targetapp, m_targetmsg, m_statusstring, m_themename; 390 QString m_targetapp, m_targetmsg, m_statusstring, m_themename;
392 bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null); 391 bool listbkmk(CList<Bkmk>*, const QString& _lab = QString::null);
393 QString usefilebrowser(); 392 QString usefilebrowser();
394 void do_regedit(); 393 void do_regedit();
395 void colorChanged( const QColor &c ); 394 void colorChanged( const QColor &c );
396 void clear(); 395 void clear();
397 void updateCaption(); 396 void updateCaption();
398 void do_autogen(const QString&); 397 void do_autogen(const QString&);
399 void do_addbkmk(const QString&); 398 void do_addbkmk(const QString&);
400 bool findNextBookmark(size_t start); 399 bool findNextBookmark(size_t start);
401 400
402 private: 401 private:
403 402
404 QAction* m_scrollButton; 403 QAction* m_scrollButton;
405 404
406 QAction* m_buttonAction[MAX_ACTIONS]; 405 QAction* m_buttonAction[MAX_ACTIONS];
407 406
408 CBkmkSelector* bkmkselector; 407 CBkmkSelector* bkmkselector;
409 408
410 // ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget, 409 // ActionTypes m_spaceTarget, m_escapeTarget, m_returnTarget, m_leftTarget, m_rightTarget,
411 //m_upTarget, m_downTarget; 410 //m_upTarget, m_downTarget;
412 //bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll; 411 //bool m_leftScroll, m_rightScroll, m_upScroll, m_downScroll;
413 bool m_bcloseDisabled, m_disableesckey; 412 bool m_bcloseDisabled, m_disableesckey;
414 size_t searchStart; 413 size_t searchStart;
415#ifdef __ISEARCH 414#ifdef __ISEARCH
416 QStack<searchrecord>* searchStack; 415 QStack<searchrecord>* searchStack;
417 bool dosearch(size_t start, CDrawBuffer& test, const QString& arg); 416 bool dosearch(size_t start, CDrawBuffer& test, const QString& arg);
418#else 417#else
419 bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg); 418 bool dosearch(size_t start, CDrawBuffer& test, const QRegExp& arg);
420#endif 419#endif
421 QWidgetStack *editorStack; 420 QWidgetStack *editorStack;
422 QTReader* reader; 421 QTReader* reader;
423 QComboBox* m_fontSelector; 422 QComboBox* m_fontSelector;
424// QPEToolBar /* *menu,*/ *fileBar; 423// QPEToolBar /* *menu,*/ *fileBar;
425#ifdef USEQPE 424#ifdef USEQPE
426 QToolBar *menubar; 425 QToolBar *menubar;
427#endif 426#endif
428 QToolBar *fileBar, *navBar, *viewBar, *markBar; 427 QToolBar *fileBar, *navBar, *viewBar, *markBar;
429#ifdef USEQPE 428#ifdef USEQPE
430 QPEMenuBar *mb; 429 QPEMenuBar *mb;
431#else 430#else
432 QMenuBar *mb; 431 QMenuBar *mb;
433#endif 432#endif
434 QFloatBar *searchBar, *regBar/*, *m_fontBar*/; 433 QFloatBar *searchBar, *regBar/*, *m_fontBar*/;
435 QToolBar /* *searchBar, *regBar,*/ *m_fontBar; 434 QToolBar /* *searchBar, *regBar,*/ *m_fontBar;
436 QLineEdit *searchEdit, *regEdit; 435 QLineEdit *searchEdit, *regEdit;
437 bool searchVisible; 436 bool searchVisible;
438 bool regVisible; 437 bool regVisible;
439 bool m_fontVisible, m_twoTouch; 438 bool m_fontVisible, m_twoTouch;
440 static unsigned long m_uid; 439 static unsigned long m_uid;
441 long unsigned get_unique_id() { return m_uid++; } 440 long unsigned get_unique_id() { return m_uid++; }
442 /* 441 /*
443 void resizeEvent( QResizeEvent * r) 442 void resizeEvent( QResizeEvent * r)
444 { 443 {
445// qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height()); 444// qDebug("resize:(%u,%u)", r->oldSize().width(), r->oldSize().height());
446// qDebug("resize:(%u,%u)", r->size().width(), r->size().height()); 445// qDebug("resize:(%u,%u)", r->size().width(), r->size().height());
447 // bgroup->move( width()-bgroup->width(), 0 ); 446 // bgroup->move( width()-bgroup->width(), 0 );
448 } 447 }
449 */ 448 */
450 CList<Bkmk>* pBkmklist; 449 CList<Bkmk>* pBkmklist;
451 CList<Bkmk>* pOpenlist; 450 CList<Bkmk>* pOpenlist;
452 infowin* m_infoWin; 451 infowin* m_infoWin;
453 GraphicWin* m_graphicwin; 452 GraphicWin* m_graphicwin;
454 QProgressBar* pbar; 453 QProgressBar* pbar;
455 bool m_fBkmksChanged; 454 bool m_fBkmksChanged;
456// int m_nRegAction; 455// int m_nRegAction;
457 regedit_type m_nRegAction; 456 regedit_type m_nRegAction;
458 bkmk_action m_nBkmkAction; 457 bkmk_action m_nBkmkAction;
459 QString m_autogenstr; 458 QString m_autogenstr;
460 bool m_dontSave; 459 bool m_dontSave;
461}; 460};
462 461
463//const int cAutoGen = 0; 462//const int cAutoGen = 0;
464//const int cAddBkmk = 1; 463//const int cAddBkmk = 1;
465//const int cDelBkmk = 2; 464//const int cDelBkmk = 2;
466//const int cGotoBkmk = 3; 465//const int cGotoBkmk = 3;
467//const int cRmBkmkFile = 4; 466//const int cRmBkmkFile = 4;
468//const int cJump = 5; 467//const int cJump = 5;
469//const int cMonoSpace = 6; 468//const int cMonoSpace = 6;
470//const int cOverlap = 7; 469//const int cOverlap = 7;
471//const int cSetTarget = 8; 470//const int cSetTarget = 8;
472//const int cOpenFile = 9; 471//const int cOpenFile = 9;
473//const int cSetPipeTarget = 10; 472//const int cSetPipeTarget = 10;
474//const int cSetConfigName = 11; 473//const int cSetConfigName = 11;
475//const int cMargin = 12; 474//const int cMargin = 12;
476//const int cExtraSpace = 14; 475//const int cExtraSpace = 14;
477//const int cExtraLead = 15; 476//const int cExtraLead = 15;
478//const int cGfxSize = 16; 477//const int cGfxSize = 16;
479//const int cChooseFont = 2; 478//const int cChooseFont = 2;
480//const int cChooseEncoding = 1; 479//const int cChooseEncoding = 1;
481 480
482#endif 481#endif
483 482
484 483
485 484
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,547 +1,546 @@
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
27CBarPrefs::CBarPrefs(const QString& appdir, bool fs, QWidget* parent, const char* name) : QDialog(parent, name, true), config( appdir ) 26CBarPrefs::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/*
50CBarPrefs1::CBarPrefs1( Config& _config, QWidget* parent, const char* name, WFlags fl ) 49CBarPrefs1::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
98void CBarPrefs1::saveall() 97void 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
114CBarPrefs1::~CBarPrefs1() 113CBarPrefs1::~CBarPrefs1()
115{ 114{
116} 115}
117*/ 116*/
118/* 117/*
119CBarPrefs2::CBarPrefs2( Config& _config, QWidget* parent, const char* name, WFlags fl ) 118CBarPrefs2::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
192void CBarPrefs2::saveall() 191void 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());
202 201
203 config.writeEntry( "Mark", mark->isChecked()); 202 config.writeEntry( "Mark", mark->isChecked());
204 config.writeEntry( "Annotate", annotate->isChecked()); 203 config.writeEntry( "Annotate", annotate->isChecked());
205 config.writeEntry( "Goto", go_to->isChecked()); 204 config.writeEntry( "Goto", go_to->isChecked());
206 config.writeEntry( "Delete", Delete->isChecked()); 205 config.writeEntry( "Delete", Delete->isChecked());
207 config.writeEntry( "Autogen", autogen->isChecked()); 206 config.writeEntry( "Autogen", autogen->isChecked());
208 config.writeEntry( "Clear", clear->isChecked()); 207 config.writeEntry( "Clear", clear->isChecked());
209 config.writeEntry( "Save", save->isChecked()); 208 config.writeEntry( "Save", save->isChecked());
210 config.writeEntry( "Tidy", tidy->isChecked()); 209 config.writeEntry( "Tidy", tidy->isChecked());
211 config.writeEntry( "Start/Copy Block", block->isChecked()); 210 config.writeEntry( "Start/Copy Block", block->isChecked());
212 config.writeEntry( "Annotation indicator", indannotate->isChecked()); 211 config.writeEntry( "Annotation indicator", indannotate->isChecked());
213} 212}
214 213
215CBarPrefs2::~CBarPrefs2() 214CBarPrefs2::~CBarPrefs2()
216{ 215{
217} 216}
218*/ 217*/
219 218
220CFileBarPrefs::CFileBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) 219CFileBarPrefs::CFileBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl )
221 : QWidget( parent, name, fl ), config(_config) 220 : QWidget( parent, name, fl ), config(_config)
222{ 221{
223 config.setGroup( "Toolbar" ); 222 config.setGroup( "Toolbar" );
224 QVBoxLayout* vb = new QVBoxLayout(this); 223 QVBoxLayout* vb = new QVBoxLayout(this);
225 224
226 QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "File", this); 225 QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "File", this);
227 vb->addWidget(bg); 226 vb->addWidget(bg);
228 227
229 open = new QCheckBox( tr("Open"), bg ); 228 open = new QCheckBox( tr("Open"), bg );
230 open->setChecked(config.readBoolEntry( "Open", false )); 229 open->setChecked(config.readBoolEntry( "Open", false ));
231 connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 230 connect(open, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
232 close = new QCheckBox( tr("Close"), bg ); 231 close = new QCheckBox( tr("Close"), bg );
233 close->setChecked(config.readBoolEntry( "Close", false )); 232 close->setChecked(config.readBoolEntry( "Close", false ));
234 connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 233 connect(close, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
235 info = new QCheckBox( tr("Info"), bg ); 234 info = new QCheckBox( tr("Info"), bg );
236 info->setChecked(config.readBoolEntry( "Info", false )); 235 info->setChecked(config.readBoolEntry( "Info", false ));
237 connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 236 connect(info, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
238 twotouch = new QCheckBox( tr("Two/One\nTouch"), bg ); 237 twotouch = new QCheckBox( tr("Two/One\nTouch"), bg );
239 twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false )); 238 twotouch->setChecked(config.readBoolEntry( "Two/One Touch", false ));
240 connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 239 connect(twotouch, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
241 find = new QCheckBox( tr("Find"), bg ); 240 find = new QCheckBox( tr("Find"), bg );
242 find->setChecked(config.readBoolEntry( "Find", false )); 241 find->setChecked(config.readBoolEntry( "Find", false ));
243 connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 242 connect(find, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
244 m_isChanged = false; 243 m_isChanged = false;
245} 244}
246 245
247void CFileBarPrefs::saveall() 246void CFileBarPrefs::saveall()
248{ 247{
249 config.setGroup( "Toolbar" ); 248 config.setGroup( "Toolbar" );
250 config.writeEntry( "Open", open->isChecked()); 249 config.writeEntry( "Open", open->isChecked());
251 config.writeEntry( "Close", close->isChecked()); 250 config.writeEntry( "Close", close->isChecked());
252 config.writeEntry( "Info", info->isChecked()); 251 config.writeEntry( "Info", info->isChecked());
253 config.writeEntry( "Two/One Touch", twotouch->isChecked()); 252 config.writeEntry( "Two/One Touch", twotouch->isChecked());
254 config.writeEntry( "Find", find->isChecked()); 253 config.writeEntry( "Find", find->isChecked());
255} 254}
256 255
257CFileBarPrefs::~CFileBarPrefs() 256CFileBarPrefs::~CFileBarPrefs()
258{ 257{
259} 258}
260 259
261CNavBarPrefs::CNavBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) 260CNavBarPrefs::CNavBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl )
262 : QWidget( parent, name, fl ), config(_config) 261 : QWidget( parent, name, fl ), config(_config)
263{ 262{
264 config.setGroup( "Toolbar" ); 263 config.setGroup( "Toolbar" );
265 QVBoxLayout* vb = new QVBoxLayout(this); 264 QVBoxLayout* vb = new QVBoxLayout(this);
266 265
267 QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this); 266 QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Navigation", this);
268 vb->addWidget(bg); 267 vb->addWidget(bg);
269 scroll = new QCheckBox( tr("Scroll"), bg ); 268 scroll = new QCheckBox( tr("Scroll"), bg );
270 scroll->setChecked(config.readBoolEntry( "Scroll", false )); 269 scroll->setChecked(config.readBoolEntry( "Scroll", false ));
271 connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 270 connect(scroll, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
272 271
273 navback = new QCheckBox( tr("Back"), bg ); 272 navback = new QCheckBox( tr("Back"), bg );
274 navback->setChecked(config.readBoolEntry( "Back", false )); 273 navback->setChecked(config.readBoolEntry( "Back", false ));
275 connect(navback, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 274 connect(navback, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
276 navhome = new QCheckBox( tr("Home"), bg ); 275 navhome = new QCheckBox( tr("Home"), bg );
277 navhome->setChecked(config.readBoolEntry( "Home", false )); 276 navhome->setChecked(config.readBoolEntry( "Home", false ));
278 connect(navhome, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 277 connect(navhome, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
279 navforward = new QCheckBox( tr("Forward"), bg ); 278 navforward = new QCheckBox( tr("Forward"), bg );
280 navforward->setChecked(config.readBoolEntry( "Forward", false )); 279 navforward->setChecked(config.readBoolEntry( "Forward", false ));
281 connect(navforward, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 280 connect(navforward, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
282 281
283 pageup = new QCheckBox( tr("Page Up"), bg ); 282 pageup = new QCheckBox( tr("Page Up"), bg );
284 pageup->setChecked(config.readBoolEntry( "Page Up", false )); 283 pageup->setChecked(config.readBoolEntry( "Page Up", false ));
285 connect(pageup, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 284 connect(pageup, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
286 pagedown = new QCheckBox( tr("Page Down"), bg ); 285 pagedown = new QCheckBox( tr("Page Down"), bg );
287 pagedown->setChecked(config.readBoolEntry( "Page Down", false )); 286 pagedown->setChecked(config.readBoolEntry( "Page Down", false ));
288 connect(pagedown, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 287 connect(pagedown, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
289 gotostart = new QCheckBox( tr("Goto Start"), bg ); 288 gotostart = new QCheckBox( tr("Goto Start"), bg );
290 gotostart->setChecked(config.readBoolEntry( "Goto Start", false )); 289 gotostart->setChecked(config.readBoolEntry( "Goto Start", false ));
291 connect(gotostart, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 290 connect(gotostart, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
292 gotoend = new QCheckBox( tr("Goto End"), bg ); 291 gotoend = new QCheckBox( tr("Goto End"), bg );
293 gotoend->setChecked(config.readBoolEntry( "Goto End", false )); 292 gotoend->setChecked(config.readBoolEntry( "Goto End", false ));
294 connect(gotoend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 293 connect(gotoend, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
295 jump = new QCheckBox( tr("Jump"), bg ); 294 jump = new QCheckBox( tr("Jump"), bg );
296 jump->setChecked(config.readBoolEntry( "Jump", false )); 295 jump->setChecked(config.readBoolEntry( "Jump", false ));
297 connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 296 connect(jump, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
298 pageline = new QCheckBox( tr("Page/Line Scroll"), bg ); 297 pageline = new QCheckBox( tr("Page/Line Scroll"), bg );
299 pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false )); 298 pageline->setChecked(config.readBoolEntry( "Page/Line Scroll", false ));
300 connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 299 connect(pageline, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
301 m_isChanged = false; 300 m_isChanged = false;
302} 301}
303 302
304void CNavBarPrefs::saveall() 303void CNavBarPrefs::saveall()
305{ 304{
306 config.setGroup( "Toolbar" ); 305 config.setGroup( "Toolbar" );
307 config.writeEntry( "Scroll", scroll->isChecked()); 306 config.writeEntry( "Scroll", scroll->isChecked());
308 config.writeEntry( "Back", navback->isChecked()); 307 config.writeEntry( "Back", navback->isChecked());
309 config.writeEntry( "Home", navhome->isChecked()); 308 config.writeEntry( "Home", navhome->isChecked());
310 config.writeEntry( "Forward", navforward->isChecked()); 309 config.writeEntry( "Forward", navforward->isChecked());
311 config.writeEntry( "Page Up", pageup->isChecked()); 310 config.writeEntry( "Page Up", pageup->isChecked());
312 config.writeEntry( "Page Down", pagedown->isChecked()); 311 config.writeEntry( "Page Down", pagedown->isChecked());
313 config.writeEntry( "Goto Start", gotostart->isChecked()); 312 config.writeEntry( "Goto Start", gotostart->isChecked());
314 config.writeEntry( "Goto End", gotoend->isChecked()); 313 config.writeEntry( "Goto End", gotoend->isChecked());
315 config.writeEntry( "Jump", jump->isChecked()); 314 config.writeEntry( "Jump", jump->isChecked());
316 config.writeEntry( "Page/Line Scroll", pageline->isChecked()); 315 config.writeEntry( "Page/Line Scroll", pageline->isChecked());
317} 316}
318 317
319CNavBarPrefs::~CNavBarPrefs() 318CNavBarPrefs::~CNavBarPrefs()
320{ 319{
321} 320}
322 321
323CViewBarPrefs::CViewBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) 322CViewBarPrefs::CViewBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl )
324 : QWidget( parent, name, fl ), config(_config) 323 : QWidget( parent, name, fl ), config(_config)
325{ 324{
326 QVBoxLayout* vb = new QVBoxLayout(this); 325 QVBoxLayout* vb = new QVBoxLayout(this);
327 326
328 QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "View", this); 327 QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "View", this);
329 vb->addWidget(bg); 328 vb->addWidget(bg);
330 329
331 config.setGroup( "Toolbar" ); 330 config.setGroup( "Toolbar" );
332 331
333 fullscreen = new QCheckBox( tr("Fullscreen"), bg ); 332 fullscreen = new QCheckBox( tr("Fullscreen"), bg );
334 fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false )); 333 fullscreen->setChecked(config.readBoolEntry( "Fullscreen", false ));
335 connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 334 connect(fullscreen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
336 rotate = new QCheckBox( tr("Rotate"), bg ); 335 rotate = new QCheckBox( tr("Rotate"), bg );
337 rotate->setChecked(config.readBoolEntry( "Rotate", false )); 336 rotate->setChecked(config.readBoolEntry( "Rotate", false ));
338 connect(rotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 337 connect(rotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
339 338
340 invert = new QCheckBox( tr("Invert"), bg ); 339 invert = new QCheckBox( tr("Invert"), bg );
341 invert->setChecked(config.readBoolEntry( "Invert Action", false )); 340 invert->setChecked(config.readBoolEntry( "Invert Action", false ));
342 connect(invert, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 341 connect(invert, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
343 342
344 zoomin = new QCheckBox( tr("Zoom In"), bg ); 343 zoomin = new QCheckBox( tr("Zoom In"), bg );
345 zoomin->setChecked(config.readBoolEntry( "Zoom In", false )); 344 zoomin->setChecked(config.readBoolEntry( "Zoom In", false ));
346 connect(zoomin, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 345 connect(zoomin, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
347 zoomout = new QCheckBox( tr("Zoom Out"), bg ); 346 zoomout = new QCheckBox( tr("Zoom Out"), bg );
348 zoomout->setChecked(config.readBoolEntry( "Zoom Out", false )); 347 zoomout->setChecked(config.readBoolEntry( "Zoom Out", false ));
349 connect(zoomout, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 348 connect(zoomout, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
350 setfont = new QCheckBox( tr("Set Font"), bg ); 349 setfont = new QCheckBox( tr("Set Font"), bg );
351 setfont->setChecked(config.readBoolEntry( "Set Font", false )); 350 setfont->setChecked(config.readBoolEntry( "Set Font", false ));
352 connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 351 connect(setfont, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
353 352
354 encoding = new QCheckBox( tr("Encoding"), bg ); 353 encoding = new QCheckBox( tr("Encoding"), bg );
355 encoding->setChecked(config.readBoolEntry("Encoding Select", false)); 354 encoding->setChecked(config.readBoolEntry("Encoding Select", false));
356 connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 355 connect(encoding, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
357 ideogram = new QCheckBox( tr("Ideogram"), bg ); 356 ideogram = new QCheckBox( tr("Ideogram"), bg );
358 ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false)); 357 ideogram->setChecked(config.readBoolEntry("Ideogram Mode", false));
359 connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 358 connect(ideogram, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
360 m_isChanged = false; 359 m_isChanged = false;
361} 360}
362 361
363void CViewBarPrefs::saveall() 362void CViewBarPrefs::saveall()
364{ 363{
365 config.setGroup( "Toolbar" ); 364 config.setGroup( "Toolbar" );
366 config.writeEntry( "Fullscreen", fullscreen->isChecked()); 365 config.writeEntry( "Fullscreen", fullscreen->isChecked());
367 config.writeEntry( "Rotate", rotate->isChecked()); 366 config.writeEntry( "Rotate", rotate->isChecked());
368 config.writeEntry( "Invert Action", invert->isChecked()); 367 config.writeEntry( "Invert Action", invert->isChecked());
369 config.writeEntry( "Zoom In", zoomin->isChecked()); 368 config.writeEntry( "Zoom In", zoomin->isChecked());
370 config.writeEntry( "Zoom Out", zoomout->isChecked()); 369 config.writeEntry( "Zoom Out", zoomout->isChecked());
371 config.writeEntry( "Set Font", setfont->isChecked()); 370 config.writeEntry( "Set Font", setfont->isChecked());
372 config.writeEntry("Encoding Select", encoding->isChecked()); 371 config.writeEntry("Encoding Select", encoding->isChecked());
373 config.writeEntry("Ideogram Mode", ideogram->isChecked()); 372 config.writeEntry("Ideogram Mode", ideogram->isChecked());
374} 373}
375 374
376CViewBarPrefs::~CViewBarPrefs() 375CViewBarPrefs::~CViewBarPrefs()
377{ 376{
378} 377}
379 378
380CMarkBarPrefs::CMarkBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) 379CMarkBarPrefs::CMarkBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl )
381 : QWidget( parent, name, fl ), config(_config) 380 : QWidget( parent, name, fl ), config(_config)
382{ 381{
383 QVBoxLayout* vb = new QVBoxLayout(this); 382 QVBoxLayout* vb = new QVBoxLayout(this);
384 383
385 QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Marks", this); 384 QGroupBox* bg = new QGroupBox(2, Qt::Horizontal, "Marks", this);
386 vb->addWidget(bg); 385 vb->addWidget(bg);
387 mark = new QCheckBox( tr("Bookmark"), bg ); 386 mark = new QCheckBox( tr("Bookmark"), bg );
388 mark->setChecked(config.readBoolEntry( "Mark", false )); 387 mark->setChecked(config.readBoolEntry( "Mark", false ));
389 connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 388 connect(mark, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
390 annotate = new QCheckBox( tr("Annotate"), bg ); 389 annotate = new QCheckBox( tr("Annotate"), bg );
391 annotate->setChecked(config.readBoolEntry( "Annotate", false )); 390 annotate->setChecked(config.readBoolEntry( "Annotate", false ));
392 connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 391 connect(annotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
393 go_to = new QCheckBox( tr("Goto"), bg ); 392 go_to = new QCheckBox( tr("Goto"), bg );
394 go_to->setChecked(config.readBoolEntry( "Goto", false )); 393 go_to->setChecked(config.readBoolEntry( "Goto", false ));
395 connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 394 connect(go_to, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
396 Delete = new QCheckBox( tr("Delete"), bg ); 395 Delete = new QCheckBox( tr("Delete"), bg );
397 Delete->setChecked(config.readBoolEntry( "Delete", false )); 396 Delete->setChecked(config.readBoolEntry( "Delete", false ));
398 connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 397 connect(Delete, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
399 autogen = new QCheckBox( tr("Autogen"), bg ); 398 autogen = new QCheckBox( tr("Autogen"), bg );
400 autogen->setChecked(config.readBoolEntry( "Autogen", false )); 399 autogen->setChecked(config.readBoolEntry( "Autogen", false ));
401 connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 400 connect(autogen, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
402 clear = new QCheckBox( tr("Clear"), bg ); 401 clear = new QCheckBox( tr("Clear"), bg );
403 clear->setChecked(config.readBoolEntry( "Clear", false )); 402 clear->setChecked(config.readBoolEntry( "Clear", false ));
404 connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 403 connect(clear, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
405 save = new QCheckBox( tr("Save"), bg ); 404 save = new QCheckBox( tr("Save"), bg );
406 save->setChecked(config.readBoolEntry( "Save", false )); 405 save->setChecked(config.readBoolEntry( "Save", false ));
407 connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 406 connect(save, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
408 tidy = new QCheckBox( tr("Tidy"), bg ); 407 tidy = new QCheckBox( tr("Tidy"), bg );
409 tidy->setChecked(config.readBoolEntry( "Tidy", false )); 408 tidy->setChecked(config.readBoolEntry( "Tidy", false ));
410 connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 409 connect(tidy, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
411 startblock = new QCheckBox( tr("Mark Block"), bg ); 410 startblock = new QCheckBox( tr("Mark Block"), bg );
412 startblock->setChecked(config.readBoolEntry( "Start Block", false )); 411 startblock->setChecked(config.readBoolEntry( "Start Block", false ));
413 connect(startblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 412 connect(startblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
414 copyblock = new QCheckBox( tr("Copy Block"), bg ); 413 copyblock = new QCheckBox( tr("Copy Block"), bg );
415 copyblock->setChecked(config.readBoolEntry( "Copy Block", false )); 414 copyblock->setChecked(config.readBoolEntry( "Copy Block", false ));
416 connect(copyblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 415 connect(copyblock, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
417 m_isChanged = false; 416 m_isChanged = false;
418} 417}
419 418
420void CMarkBarPrefs::saveall() 419void CMarkBarPrefs::saveall()
421{ 420{
422 config.setGroup( "Toolbar" ); 421 config.setGroup( "Toolbar" );
423 config.writeEntry( "Mark", mark->isChecked()); 422 config.writeEntry( "Mark", mark->isChecked());
424 config.writeEntry( "Annotate", annotate->isChecked()); 423 config.writeEntry( "Annotate", annotate->isChecked());
425 config.writeEntry( "Goto", go_to->isChecked()); 424 config.writeEntry( "Goto", go_to->isChecked());
426 config.writeEntry( "Delete", Delete->isChecked()); 425 config.writeEntry( "Delete", Delete->isChecked());
427 config.writeEntry( "Autogen", autogen->isChecked()); 426 config.writeEntry( "Autogen", autogen->isChecked());
428 config.writeEntry( "Clear", clear->isChecked()); 427 config.writeEntry( "Clear", clear->isChecked());
429 config.writeEntry( "Save", save->isChecked()); 428 config.writeEntry( "Save", save->isChecked());
430 config.writeEntry( "Tidy", tidy->isChecked()); 429 config.writeEntry( "Tidy", tidy->isChecked());
431 config.writeEntry( "Start Block", startblock->isChecked()); 430 config.writeEntry( "Start Block", startblock->isChecked());
432 config.writeEntry( "Copy Block", copyblock->isChecked()); 431 config.writeEntry( "Copy Block", copyblock->isChecked());
433} 432}
434 433
435CMarkBarPrefs::~CMarkBarPrefs() 434CMarkBarPrefs::~CMarkBarPrefs()
436{ 435{
437} 436}
438 437
439CMiscBarPrefs::CMiscBarPrefs( QWidget* parent, const char* name, WFlags fl ) 438CMiscBarPrefs::CMiscBarPrefs( QWidget* parent, const char* name, WFlags fl )
440 : QWidget( parent, name, fl ) 439 : QWidget( parent, name, fl )
441{ 440{
442 441
443 QGridLayout* hl = new QGridLayout(this,2,2); 442 QGridLayout* hl = new QGridLayout(this,2,2);
444 443
445 hl->setMargin( 0 ); 444 hl->setMargin( 0 );
446 445
447 QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Dialogs", this); 446 QGroupBox* gb = new QGroupBox(1, Qt::Horizontal, "Dialogs", this);
448 floating = new QCheckBox(gb); 447 floating = new QCheckBox(gb);
449 floating->setText(tr("Floating")); 448 floating->setText(tr("Floating"));
450 hl->addWidget( gb, 0, 0 ); 449 hl->addWidget( gb, 0, 0 );
451 450
452 451
453 gb = new QGroupBox(1, Qt::Horizontal, "Bars (Restart)", this); 452 gb = new QGroupBox(1, Qt::Horizontal, "Bars (Restart)", this);
454 453
455// QLabel* ql = new QLabel("Restart to apply changes", gb); 454// QLabel* ql = new QLabel("Restart to apply changes", gb);
456// TextLabel = new QLabel( gb ); 455// TextLabel = new QLabel( gb );
457// TextLabel->setText( tr( "Policy" ) ); 456// TextLabel->setText( tr( "Policy" ) );
458 457
459#ifdef USECOMBO 458#ifdef USECOMBO
460 tbpolicy = new QComboBox(gb); 459 tbpolicy = new QComboBox(gb);
461#else 460#else
462 tbpolicy = new MenuButton(gb); 461 tbpolicy = new MenuButton(gb);
463#endif 462#endif
464 tbpolicy->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); 463 tbpolicy->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
465#ifdef USEQPE 464#ifdef USEQPE
466 tbpolicy->insertItem(tr("Single bar")); 465 tbpolicy->insertItem(tr("Single bar"));
467 tbpolicy->insertItem(tr("Menu/tool bar")); 466 tbpolicy->insertItem(tr("Menu/tool bar"));
468 tbpolicy->insertItem(tr("Multiple bars")); 467 tbpolicy->insertItem(tr("Multiple bars"));
469#else 468#else
470 tbpolicy->insertItem(tr("Single bar")); 469 tbpolicy->insertItem(tr("Single bar"));
471 tbpolicy->insertItem(tr("Multiple bars")); 470 tbpolicy->insertItem(tr("Multiple bars"));
472#endif 471#endif
473 472
474#ifdef USECOMBO 473#ifdef USECOMBO
475 tbposition = new QComboBox(gb); 474 tbposition = new QComboBox(gb);
476#else 475#else
477 tbposition = new MenuButton(gb); 476 tbposition = new MenuButton(gb);
478#endif 477#endif
479 tbposition->insertItem(tr("Top")); 478 tbposition->insertItem(tr("Top"));
480 tbposition->insertItem(tr("Bottom")); 479 tbposition->insertItem(tr("Bottom"));
481 tbposition->insertItem(tr("Right")); 480 tbposition->insertItem(tr("Right"));
482 tbposition->insertItem(tr("Left")); 481 tbposition->insertItem(tr("Left"));
483 tbposition->insertItem(tr("Minimised")); 482 tbposition->insertItem(tr("Minimised"));
484 483
485 tbmovable = new QCheckBox( tr("Movable"), gb ); 484 tbmovable = new QCheckBox( tr("Movable"), gb );
486 485
487 hl->addWidget(gb, 0, 1); 486 hl->addWidget(gb, 0, 1);
488 487
489 gb = new QGroupBox(1, Qt::Horizontal, "QT Scroll Bar", this); 488 gb = new QGroupBox(1, Qt::Horizontal, "QT Scroll Bar", this);
490 489
491#ifdef USECOMBO 490#ifdef USECOMBO
492 qtscroll = new QComboBox(gb); 491 qtscroll = new QComboBox(gb);
493#else 492#else
494 qtscroll = new MenuButton(gb); 493 qtscroll = new MenuButton(gb);
495#endif 494#endif
496 qtscroll->insertItem(tr("None")); 495 qtscroll->insertItem(tr("None"));
497 qtscroll->insertItem(tr("Right")); 496 qtscroll->insertItem(tr("Right"));
498 qtscroll->insertItem(tr("Left")); 497 qtscroll->insertItem(tr("Left"));
499 498
500 hl->addWidget(gb, 1, 0); 499 hl->addWidget(gb, 1, 0);
501 gb = new QGroupBox(1, Qt::Horizontal, "Miniscroll", this); 500 gb = new QGroupBox(1, Qt::Horizontal, "Miniscroll", this);
502 501
503#ifdef USECOMBO 502#ifdef USECOMBO
504 localscroll = new QComboBox(gb); 503 localscroll = new QComboBox(gb);
505#else 504#else
506 localscroll = new MenuButton(gb); 505 localscroll = new MenuButton(gb);
507#endif 506#endif
508 localscroll->insertItem(tr("None")); 507 localscroll->insertItem(tr("None"));
509 localscroll->insertItem(tr("Bottom")); 508 localscroll->insertItem(tr("Bottom"));
510 localscroll->insertItem(tr("Right")); 509 localscroll->insertItem(tr("Right"));
511 localscroll->insertItem(tr("Left")); 510 localscroll->insertItem(tr("Left"));
512 511
513 //scrollonleft = new QCheckBox( tr("... on Left"), gb ); 512 //scrollonleft = new QCheckBox( tr("... on Left"), gb );
514 // ch->setChecked(config.readBoolEntry( "Movable", false )); 513 // ch->setChecked(config.readBoolEntry( "Movable", false ));
515 514
516 hl->addWidget(gb, 1, 1); 515 hl->addWidget(gb, 1, 1);
517 516
518} 517}
519 518
520CMiscBarPrefs::~CMiscBarPrefs() 519CMiscBarPrefs::~CMiscBarPrefs()
521{ 520{
522 // no need to delete child widgets, Qt does it all for us 521 // no need to delete child widgets, Qt does it all for us
523} 522}
524 523
525 524
526CIndBarPrefs::CIndBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl ) 525CIndBarPrefs::CIndBarPrefs( Config& _config, QWidget* parent, const char* name, WFlags fl )
527 : QWidget( parent, name, fl ), config(_config) 526 : QWidget( parent, name, fl ), config(_config)
528{ 527{
529 QVBoxLayout* vb = new QVBoxLayout(this); 528 QVBoxLayout* vb = new QVBoxLayout(this);
530 529
531 QGroupBox* bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this); 530 QGroupBox* bg = new QGroupBox(1, Qt::Horizontal, "Indicators", this);
532 vb->addWidget(bg); 531 vb->addWidget(bg);
533 indannotate = new QCheckBox( tr("Annotation"), bg ); 532 indannotate = new QCheckBox( tr("Annotation"), bg );
534 indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false )); 533 indannotate->setChecked(config.readBoolEntry( "Annotation indicator", false ));
535 connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) ); 534 connect(indannotate, SIGNAL(stateChanged(int)), this, SLOT( isChanged(int) ) );
536 m_isChanged = false; 535 m_isChanged = false;
537} 536}
538 537
539void CIndBarPrefs::saveall() 538void CIndBarPrefs::saveall()
540{ 539{
541 config.setGroup( "Toolbar" ); 540 config.setGroup( "Toolbar" );
542 config.writeEntry( "Annotation indicator", indannotate->isChecked()); 541 config.writeEntry( "Annotation indicator", indannotate->isChecked());
543} 542}
544 543
545CIndBarPrefs::~CIndBarPrefs() 544CIndBarPrefs::~CIndBarPrefs()
546{ 545{
547} 546}
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,269 +1,267 @@
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
31class QVBoxLayout; 29class QVBoxLayout;
32class QHBoxLayout; 30class QHBoxLayout;
33class QGridLayout; 31class QGridLayout;
34//class QCheckBox; 32//class QCheckBox;
35class QLabel; 33class QLabel;
36//class QSpinBox; 34//class QSpinBox;
37/* 35/*
38class CBarPrefs1 : public QWidget 36class 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*/
57class CFileBarPrefs : public QWidget 55class 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
76class CNavBarPrefs : public QWidget 74class 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/*
96class CBarPrefs2 : public QWidget 94class 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*/
115class CViewBarPrefs : public QWidget 113class 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
134class CMarkBarPrefs : public QWidget 132class 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
153class CIndBarPrefs : public QWidget 151class 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
172class CMiscBarPrefs : public QWidget 170class CMiscBarPrefs : public QWidget
173{ 171{
174 172
175public: 173public:
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
188class CBarPrefs : public QDialog 186class 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);
219 ~CBarPrefs() 217 ~CBarPrefs()
220 { 218 {
221 if (result()) 219 if (result())
222 { 220 {
223 if (navbar->isChanged()) navbar->saveall(); 221 if (navbar->isChanged()) navbar->saveall();
224 if (filebar->isChanged()) filebar->saveall(); 222 if (filebar->isChanged()) filebar->saveall();
225 if (viewbar->isChanged()) viewbar->saveall(); 223 if (viewbar->isChanged()) viewbar->saveall();
226 if (markbar->isChanged()) markbar->saveall(); 224 if (markbar->isChanged()) markbar->saveall();
227 if (indbar->isChanged()) indbar->saveall(); 225 if (indbar->isChanged()) indbar->saveall();
228 } 226 }
229 } 227 }
230 bool isChanged() 228 bool isChanged()
231 { 229 {
232 return 230 return
233 ( 231 (
234 filebar->isChanged() 232 filebar->isChanged()
235 || 233 ||
236 navbar->isChanged() 234 navbar->isChanged()
237 || 235 ||
238 viewbar->isChanged() 236 viewbar->isChanged()
239 || 237 ||
240 markbar->isChanged() 238 markbar->isChanged()
241 || 239 ||
242 indbar->isChanged() 240 indbar->isChanged()
243 ); 241 );
244 } 242 }
245 bool floating() { return misc->floating->isChecked(); } 243 bool floating() { return misc->floating->isChecked(); }
246 void floating(bool v) { misc->floating->setChecked(v); } 244 void floating(bool v) { misc->floating->setChecked(v); }
247 int tbpolicy() { return misc->tbpolicy->currentItem(); } 245 int tbpolicy() { return misc->tbpolicy->currentItem(); }
248 int qtscroll() { return misc->qtscroll->currentItem(); } 246 int qtscroll() { return misc->qtscroll->currentItem(); }
249 int localscroll() { return misc->localscroll->currentItem(); } 247 int localscroll() { return misc->localscroll->currentItem(); }
250#ifdef USECOMBO 248#ifdef USECOMBO
251 void tbpolicy(int v) { misc->tbpolicy->setCurrentItem(v); } 249 void tbpolicy(int v) { misc->tbpolicy->setCurrentItem(v); }
252 void qtscroll(int v) { misc->qtscroll->setCurrentItem(v); } 250 void qtscroll(int v) { misc->qtscroll->setCurrentItem(v); }
253 void localscroll(int v) { misc->localscroll->setCurrentItem(v); } 251 void localscroll(int v) { misc->localscroll->setCurrentItem(v); }
254#else 252#else
255 void tbpolicy(int v) { misc->tbpolicy->select(v); } 253 void tbpolicy(int v) { misc->tbpolicy->select(v); }
256 void qtscroll(int v) { misc->qtscroll->select(v); } 254 void qtscroll(int v) { misc->qtscroll->select(v); }
257 void localscroll(int v) { misc->localscroll->select(v); } 255 void localscroll(int v) { misc->localscroll->select(v); }
258#endif 256#endif
259 bool tbmovable() { return misc->tbmovable->isChecked(); } 257 bool tbmovable() { return misc->tbmovable->isChecked(); }
260 void tbmovable(bool v) { misc->tbmovable->setChecked(v); } 258 void tbmovable(bool v) { misc->tbmovable->setChecked(v); }
261 int tbposition() { return misc->tbposition->currentItem(); } 259 int tbposition() { return misc->tbposition->currentItem(); }
262#ifdef USECOMBO 260#ifdef USECOMBO
263 void tbposition(int v) { misc->tbposition->setCurrentItem(v); } 261 void tbposition(int v) { misc->tbposition->setCurrentItem(v); }
264#else 262#else
265 void tbposition(int v) { misc->tbposition->select(v); } 263 void tbposition(int v) { misc->tbposition->select(v); }
266#endif 264#endif
267 265
268}; 266};
269#endif // CPREFS_H 267#endif // CPREFS_H
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
24class QVBoxLayout; 23class QVBoxLayout;
25class QHBoxLayout; 24class QHBoxLayout;
26class QGridLayout; 25class QGridLayout;
27//class QCheckBox; 26//class QCheckBox;
28class QLabel; 27class QLabel;
29//class QSpinBox; 28//class QSpinBox;
30 29
31class CURLDialog : public QDialog 30class CURLDialog : public QDialog
32{ 31{
33Q_OBJECT 32Q_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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
12LIBS += -lreader_pdb -lreader_codec 12LIBS += -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
17include ( $(OPIEDIR)/include.pro ) 17include ( $(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
9class Text: public CExpander { 8class Text: public CExpander {
10 gzFile file; 9 gzFile file;
11 unsigned long fsize; 10 unsigned long fsize;
12public: 11public:
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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
17include ( $(OPIEDIR)/include.pro ) 17include ( $(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>
16class ebookcodec : public CExpander_Interface 14class 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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
13LIBS += -lreader_pdb -lreader_codec 13LIBS += -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
18include ( $(OPIEDIR)/include.pro ) 18include ( $(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
15QTReaderApp* app = NULL; 14QTReaderApp* app = NULL;
16 15
17void handler(int signum) 16void 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
28int main( int argc, char ** argv ) 27int 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
9void Cpdb::suspend() 8void Cpdb::suspend()
10{ 9{
11 CExpander::suspend(fin); 10 CExpander::suspend(fin);
12} 11}
13void Cpdb::unsuspend() 12void Cpdb::unsuspend()
14{ 13{
15 CExpander::unsuspend(fin); 14 CExpander::unsuspend(fin);
16} 15}
17#endif 16#endif
18 17
19Cpdb::~Cpdb() 18Cpdb::~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
30size_t Cpdb::recordpos(int n) 29size_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
49size_t Cpdb::recordlength(int n) 48size_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
54void Cpdb::gotorecordnumber(int n) 53void Cpdb::gotorecordnumber(int n)
55{ 54{
56 fseek(fin, recordpos(n), SEEK_SET); 55 fseek(fin, recordpos(n), SEEK_SET);
57} 56}
58 57
59bool Cpdb::openpdbfile(const char *src) 58bool 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 */
22typedef unsigned char UInt8; 21typedef unsigned char UInt8;
23typedef unsigned short UInt16; 22typedef unsigned short UInt16;
24typedef signed short Int16; 23typedef signed short Int16;
25typedef unsigned long UInt32; 24typedef unsigned long UInt32;
26typedef UInt32 LocalID; 25typedef 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 *************************************************************/
35typedef struct { 34typedef 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 *************************************************************/
48typedef struct { 47typedef 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 *************************************************************/
59typedef struct { 58typedef 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
81class Cpdb : public CExpander 80class 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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
16include ( $(OPIEDIR)/include.pro ) 16include ( $(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,231 +1,229 @@
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
26struct CPlucker_dataRecord 24struct 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
35int CPlucker::HeaderSize() 33int CPlucker::HeaderSize()
36{ 34{
37 return sizeof(CPlucker_dataRecord); 35 return sizeof(CPlucker_dataRecord);
38} 36}
39 37
40void CPlucker::GetHeader(UInt16& uid, UInt16& nParagraphs, UInt32& size, UInt8& type, UInt8& reserved) 38void 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
51CPlucker::CPlucker() 49CPlucker::CPlucker()
52 { /*printf("constructing:%x\n",fin);*/ 50 { /*printf("constructing:%x\n",fin);*/
53 EOPPhase = 0; 51 EOPPhase = 0;
54 } 52 }
55 53
56bool CPlucker::CorrectDecoder() 54bool CPlucker::CorrectDecoder()
57{ 55{
58 return (memcmp(&head.type, "DataPlkr", 8) == 0); 56 return (memcmp(&head.type, "DataPlkr", 8) == 0);
59} 57}
60 58
61int CPlucker::bgetch() 59int 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
129tchar CPlucker::getch(bool fast) 127tchar 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
162QImage* CPlucker::imagefromdata(UInt8* imgbuffer, UInt32 imgsize) 160QImage* 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
169void CPlucker::start2endSection() // to plucker base 167void 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
175unsigned long CPlucker::NEFstartSection() // virtual in plucker base - differs only in obsoleted nef so move implementation 173unsigned 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
197unsigned long CPlucker::NEFendSection() // virtual in plucker base - differs only in obsoleted nef so move implementation 195unsigned 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
216 if (thishdr_type < 2) 214 if (thishdr_type < 2)
217 { 215 {
218 textlength += thishdr_size; 216 textlength += thishdr_size;
219 if ((thishdr_reserved && continuation_bit) == 0) break; 217 if ((thishdr_reserved && continuation_bit) == 0) break;
220 } 218 }
221 } 219 }
222 } 220 }
223 return textlength; 221 return textlength;
224} 222}
225 223
226#ifndef __STATIC 224#ifndef __STATIC
227extern "C" 225extern "C"
228{ 226{
229 CExpander* newcodec() { return new CPlucker; } 227 CExpander* newcodec() { return new CPlucker; }
230} 228}
231#endif 229#endif
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,1411 +1,1408 @@
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
30const UInt8 CPlucker_base::continuation_bit = 1; 28const UInt8 CPlucker_base::continuation_bit = 1;
31 29
32CPlucker_base::CPlucker_base() : 30CPlucker_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
45void CPlucker_base::Expand(UInt32 reclen, UInt8 type, UInt8* buffer, UInt32 buffersize) 43void 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
74void CPlucker_base::sizes(unsigned long& _file, unsigned long& _text) 72void 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
93char* CPlucker_base::geturl(UInt16 tgt) 91char* 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
179CPlucker_base::~CPlucker_base() 177CPlucker_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
188int CPlucker_base::getch() { return getch(false); } 186int CPlucker_base::getch() { return getch(false); }
189 187
190void CPlucker_base::getch(tchar& ch, CStyle& sty, unsigned long& pos) 188void 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
197unsigned int CPlucker_base::locate() 195unsigned 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}
217 215
218void CPlucker_base::locate(unsigned int n) 216void CPlucker_base::locate(unsigned int n)
219{ 217{
220 218
221 // clock_t start = clock(); 219 // clock_t start = clock();
222 if (n >= currentpos-bufferpos && n < currentpos - bufferpos + buffercontent) 220 if (n >= currentpos-bufferpos && n < currentpos - bufferpos + buffercontent)
223 { 221 {
224 currentpos -= bufferpos; 222 currentpos -= bufferpos;
225 expand(bufferrec); 223 expand(bufferrec);
226 while (currentpos < n && bufferpos < buffercontent) getch_base(true); 224 while (currentpos < n && bufferpos < buffercontent) getch_base(true);
227 return; 225 return;
228 } 226 }
229 /* 227 /*
230 228
231 UInt32 textlength = currentpos - bufferpos; 229 UInt32 textlength = currentpos - bufferpos;
232 UInt16 recptr = bufferrec; 230 UInt16 recptr = bufferrec;
233 if (n < textlength/2) 231 if (n < textlength/2)
234 { 232 {
235 textlength = 0; 233 textlength = 0;
236 UInt16 thishdr_uid, thishdr_nParagraphs; 234 UInt16 thishdr_uid, thishdr_nParagraphs;
237 UInt32 thishdr_size = buffercontent; 235 UInt32 thishdr_size = buffercontent;
238 UInt8 thishdr_type, thishdr_reserved; 236 UInt8 thishdr_type, thishdr_reserved;
239 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 237 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
240 { 238 {
241 gotorecordnumber(recptr); 239 gotorecordnumber(recptr);
242 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 240 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
243 if (thishdr_type < 2) 241 if (thishdr_type < 2)
244 { 242 {
245 textlength += thishdr_size; 243 textlength += thishdr_size;
246 if (textlength > n) 244 if (textlength > n)
247 { 245 {
248 textlength -= thishdr_size; 246 textlength -= thishdr_size;
249 break; 247 break;
250 } 248 }
251 } 249 }
252 } 250 }
253 } 251 }
254 else if (n < textlength) 252 else if (n < textlength)
255 { 253 {
256 UInt16 thishdr_uid, thishdr_nParagraphs; 254 UInt16 thishdr_uid, thishdr_nParagraphs;
257 UInt32 thishdr_size; 255 UInt32 thishdr_size;
258 UInt8 thishdr_type, thishdr_reserved; 256 UInt8 thishdr_type, thishdr_reserved;
259 while (n < textlength && recptr > 1) 257 while (n < textlength && recptr > 1)
260 { 258 {
261 recptr--; 259 recptr--;
262 gotorecordnumber(recptr); 260 gotorecordnumber(recptr);
263 //qDebug("recptr:%u", recptr); 261 //qDebug("recptr:%u", recptr);
264 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 262 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
265 if (thishdr_type < 2) 263 if (thishdr_type < 2)
266 { 264 {
267 textlength -= thishdr_size; 265 textlength -= thishdr_size;
268 } 266 }
269 } 267 }
270 } 268 }
271 else 269 else
272 { 270 {
273 UInt16 thishdr_uid, thishdr_nParagraphs; 271 UInt16 thishdr_uid, thishdr_nParagraphs;
274 UInt32 thishdr_size = buffercontent; 272 UInt32 thishdr_size = buffercontent;
275 UInt8 thishdr_type, thishdr_reserved; 273 UInt8 thishdr_type, thishdr_reserved;
276 while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1) 274 while (n > textlength + thishdr_size && recptr < ntohs(head.recordList.numRecords)-1)
277 { 275 {
278 textlength += thishdr_size; 276 textlength += thishdr_size;
279 recptr++; 277 recptr++;
280 gotorecordnumber(recptr); 278 gotorecordnumber(recptr);
281 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 279 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
282 if (!(thishdr_type < 2)) 280 if (!(thishdr_type < 2))
283 { 281 {
284 thishdr_size = 0; 282 thishdr_size = 0;
285 } 283 }
286 } 284 }
287 } 285 }
288 286
289 */ 287 */
290 UInt16 thisrec = 0; 288 UInt16 thisrec = 0;
291 unsigned long locpos = 0; 289 unsigned long locpos = 0;
292 unsigned long bs = 0; 290 unsigned long bs = 0;
293 UInt16 thishdr_uid, thishdr_nParagraphs; 291 UInt16 thishdr_uid, thishdr_nParagraphs;
294 UInt32 thishdr_size; 292 UInt32 thishdr_size;
295 UInt8 thishdr_type, thishdr_reserved; 293 UInt8 thishdr_type, thishdr_reserved;
296 do 294 do
297 { 295 {
298 thisrec++; 296 thisrec++;
299 locpos += bs; 297 locpos += bs;
300 gotorecordnumber(thisrec); 298 gotorecordnumber(thisrec);
301 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 299 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
302 if (thishdr_type < 2) 300 if (thishdr_type < 2)
303 { 301 {
304 bs = thishdr_size; 302 bs = thishdr_size;
305 } 303 }
306 else 304 else
307 { 305 {
308 bs = 0; 306 bs = 0;
309 } 307 }
310 } while (locpos + bs <= n); 308 } while (locpos + bs <= n);
311 309
312 // qDebug("Time(2): %u", clock()-start); 310 // qDebug("Time(2): %u", clock()-start);
313 /* 311 /*
314 if (recptr != thisrec) 312 if (recptr != thisrec)
315 { 313 {
316 qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec); 314 qDebug("Disaster:recptr:%u thisrec:%u", recptr, thisrec);
317 UInt16 thishdr_uid, thishdr_nParagraphs; 315 UInt16 thishdr_uid, thishdr_nParagraphs;
318 UInt32 thishdr_size = buffercontent; 316 UInt32 thishdr_size = buffercontent;
319 UInt8 thishdr_type, thishdr_reserved; 317 UInt8 thishdr_type, thishdr_reserved;
320 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 318 for (recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
321 { 319 {
322 gotorecordnumber(recptr); 320 gotorecordnumber(recptr);
323 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 321 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
324 // qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", thishdr_uid, thishdr_nParagraphs, thishdr_size, (unsigned int)thishdr_type, (unsigned int)thishdr_reserved); 322 // qDebug("UID:%u Paras:%u Size:%u Type:%u Reserved:%u", thishdr_uid, thishdr_nParagraphs, thishdr_size, (unsigned int)thishdr_type, (unsigned int)thishdr_reserved);
325 } 323 }
326 //QApplication::exit ( 100 ); 324 //QApplication::exit ( 100 );
327 } 325 }
328 */ 326 */
329 currentpos = locpos; 327 currentpos = locpos;
330 expand(thisrec); 328 expand(thisrec);
331 while (currentpos < n && bufferpos < buffercontent) getch_base(true); 329 while (currentpos < n && bufferpos < buffercontent) getch_base(true);
332 330
333 /* // This is faster but the alignment attribute doesn't get set 8^( 331 /* // This is faster but the alignment attribute doesn't get set 8^(
334 bufferpos = n-locpos; 332 bufferpos = n-locpos;
335 currentpos = n; 333 currentpos = n;
336 while (bufferpos >= m_nextPara && m_nextPara >= 0) 334 while (bufferpos >= m_nextPara && m_nextPara >= 0)
337 { 335 {
338 UInt16 attr = m_ParaAttrs[m_nextParaIndex]; 336 UInt16 attr = m_ParaAttrs[m_nextParaIndex];
339 m_nextParaIndex++; 337 m_nextParaIndex++;
340 if (m_nextParaIndex == m_nParas) 338 if (m_nextParaIndex == m_nParas)
341 { 339 {
342 m_nextPara = -1; 340 m_nextPara = -1;
343 } 341 }
344 else 342 else
345 { 343 {
346 m_nextPara += m_ParaOffsets[m_nextParaIndex]; 344 m_nextPara += m_ParaOffsets[m_nextParaIndex];
347 } 345 }
348 } 346 }
349 */ 347 */
350} 348}
351 349
352bool CPlucker_base::expand(int thisrec) 350bool CPlucker_base::expand(int thisrec)
353{ 351{
354 mystyle.unset(); 352 mystyle.unset();
355 if (bufferrec != thisrec) 353 if (bufferrec != thisrec)
356 { 354 {
357 size_t reclen = recordlength(thisrec); 355 size_t reclen = recordlength(thisrec);
358 gotorecordnumber(thisrec); 356 gotorecordnumber(thisrec);
359 UInt16 thishdr_uid, thishdr_nParagraphs; 357 UInt16 thishdr_uid, thishdr_nParagraphs;
360 UInt32 thishdr_size; 358 UInt32 thishdr_size;
361 UInt8 thishdr_type, thishdr_reserved; 359 UInt8 thishdr_type, thishdr_reserved;
362 while (1) 360 while (1)
363 { 361 {
364 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 362 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
365 //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid); 363 //qDebug("This (%d) type is %d, uid is %u", thisrec, thishdr_type, thishdr_uid);
366 if (thishdr_type < 2) break; 364 if (thishdr_type < 2) break;
367 //qDebug("Skipping paragraph of type %d", thishdr_type); 365 //qDebug("Skipping paragraph of type %d", thishdr_type);
368 if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false; 366 if (++thisrec >= ntohs(head.recordList.numRecords) - 1) return false;
369 reclen = recordlength(thisrec); 367 reclen = recordlength(thisrec);
370 gotorecordnumber(thisrec); 368 gotorecordnumber(thisrec);
371 } 369 }
372 m_nParas = thishdr_nParagraphs; 370 m_nParas = thishdr_nParagraphs;
373 m_bufferisreserved = (thishdr_reserved != 0); 371 m_bufferisreserved = (thishdr_reserved != 0);
374 //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size); 372 //qDebug("It has %u paragraphs and is %u bytes", thishdr_nParagraphs, thishdr_size);
375 uid = thishdr_uid; 373 uid = thishdr_uid;
376 // gotorecordnumber(thisrec); 374 // gotorecordnumber(thisrec);
377 // fread(expandedtextbuffer,1,10,fin); 375 // fread(expandedtextbuffer,1,10,fin);
378 for (int i = 0; i < m_nParas; i++) 376 for (int i = 0; i < m_nParas; i++)
379 { 377 {
380 UInt16 ubytes, attrs; 378 UInt16 ubytes, attrs;
381 fread(&ubytes, 1, sizeof(ubytes), fin); 379 fread(&ubytes, 1, sizeof(ubytes), fin);
382 fread(&attrs, 1, sizeof(attrs), fin); 380 fread(&attrs, 1, sizeof(attrs), fin);
383 m_ParaOffsets[i] = ntohs(ubytes); 381 m_ParaOffsets[i] = ntohs(ubytes);
384 m_ParaAttrs[i] = ntohs(attrs); 382 m_ParaAttrs[i] = ntohs(attrs);
385 ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs)); 383 ////qDebug("Bytes %u, Attr %x", ntohs(ubytes), ntohs(attrs));
386 } 384 }
387 385
388 reclen -= HeaderSize()+4*m_nParas; 386 reclen -= HeaderSize()+4*m_nParas;
389 387
390 buffercontent = thishdr_size; 388 buffercontent = thishdr_size;
391 389
392 if (thishdr_size > buffersize) 390 if (thishdr_size > buffersize)
393 { 391 {
394 delete [] expandedtextbuffer; 392 delete [] expandedtextbuffer;
395 buffersize = thishdr_size; 393 buffersize = thishdr_size;
396 expandedtextbuffer = new UInt8[buffersize]; 394 expandedtextbuffer = new UInt8[buffersize];
397 } 395 }
398 Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent); 396 Expand(reclen, thishdr_type, expandedtextbuffer, buffercontent);
399 bufferrec = thisrec; 397 bufferrec = thisrec;
400 } 398 }
401 399
402 400
403 if (m_nParas > 0) 401 if (m_nParas > 0)
404 { 402 {
405 m_nextPara = m_ParaOffsets[0]; 403 m_nextPara = m_ParaOffsets[0];
406 //qDebug("First offset = %u", m_nextPara); 404 //qDebug("First offset = %u", m_nextPara);
407 m_nextParaIndex = 0; 405 m_nextParaIndex = 0;
408 } 406 }
409 else 407 else
410 { 408 {
411 m_nextPara = -1; 409 m_nextPara = -1;
412 } 410 }
413 bufferpos = 0; 411 bufferpos = 0;
414 //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size); 412 //qDebug("BC:%u, HS:%u", buffercontent, thishdr_size);
415 return true; 413 return true;
416} 414}
417 415
418void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) 416void CPlucker_base::UnZip(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
419{ 417{
420 z_stream zstream; 418 z_stream zstream;
421 memset(&zstream,sizeof(zstream),0); 419 memset(&zstream,sizeof(zstream),0);
422 zstream.next_in = compressedbuffer; 420 zstream.next_in = compressedbuffer;
423 zstream.next_out = tgtbuffer; 421 zstream.next_out = tgtbuffer;
424 zstream.avail_out = bsize; 422 zstream.avail_out = bsize;
425 zstream.avail_in = reclen; 423 zstream.avail_in = reclen;
426 424
427 int keylen = 0; 425 int keylen = 0;
428 426
429 zstream.zalloc = Z_NULL; 427 zstream.zalloc = Z_NULL;
430 zstream.zfree = Z_NULL; 428 zstream.zfree = Z_NULL;
431 zstream.opaque = Z_NULL; 429 zstream.opaque = Z_NULL;
432 430
433 // printf("Initialising\n"); 431 // printf("Initialising\n");
434 432
435 inflateInit(&zstream); 433 inflateInit(&zstream);
436 int err = 0; 434 int err = 0;
437 do { 435 do {
438 if ( zstream.avail_in == 0 && 0 < keylen ) { 436 if ( zstream.avail_in == 0 && 0 < keylen ) {
439 zstream.next_in = compressedbuffer + keylen; 437 zstream.next_in = compressedbuffer + keylen;
440 zstream.avail_in = reclen - keylen; 438 zstream.avail_in = reclen - keylen;
441 keylen = 0; 439 keylen = 0;
442 } 440 }
443 zstream.next_out = tgtbuffer; 441 zstream.next_out = tgtbuffer;
444 zstream.avail_out = bsize; 442 zstream.avail_out = bsize;
445 443
446 err = inflate( &zstream, Z_SYNC_FLUSH ); 444 err = inflate( &zstream, Z_SYNC_FLUSH );
447 445
448 ////qDebug("err:%d - %u", err, zstream.avail_in); 446 ////qDebug("err:%d - %u", err, zstream.avail_in);
449 447
450 } while ( err == Z_OK ); 448 } while ( err == Z_OK );
451 449
452 inflateEnd(&zstream); 450 inflateEnd(&zstream);
453} 451}
454 452
455void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize) 453void CPlucker_base::UnDoc(UInt8* compressedbuffer, size_t reclen, UInt8* tgtbuffer, size_t bsize)
456{ 454{
457 // UInt16 headerSize; 455 // UInt16 headerSize;
458 UInt16 docSize; 456 UInt16 docSize;
459 UInt16 i; 457 UInt16 i;
460 UInt16 j; 458 UInt16 j;
461 UInt16 k; 459 UInt16 k;
462 460
463 UInt8 *inBuf = compressedbuffer; 461 UInt8 *inBuf = compressedbuffer;
464 UInt8 *outBuf = tgtbuffer; 462 UInt8 *outBuf = tgtbuffer;
465 463
466 // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph ); 464 // headerSize = sizeof( Header ) + record->paragraphs * sizeof( Paragraph );
467 docSize = reclen; 465 docSize = reclen;
468 466
469 j = 0; 467 j = 0;
470 k = 0; 468 k = 0;
471 while ( j < docSize ) { 469 while ( j < docSize ) {
472 i = 0; 470 i = 0;
473 while ( i < bsize && j < docSize ) { 471 while ( i < bsize && j < docSize ) {
474 UInt16 c; 472 UInt16 c;
475 473
476 c = (UInt16) inBuf[ j++ ]; 474 c = (UInt16) inBuf[ j++ ];
477 if ( 0 < c && c < 9 ) { 475 if ( 0 < c && c < 9 ) {
478 while ( 0 < c-- ) 476 while ( 0 < c-- )
479 outBuf[ i++ ] = inBuf[ j++ ]; 477 outBuf[ i++ ] = inBuf[ j++ ];
480 } 478 }
481 else if ( c < 0x80 ) 479 else if ( c < 0x80 )
482 outBuf[ i++ ] = c; 480 outBuf[ i++ ] = c;
483 else if ( 0xc0 <= c ) { 481 else if ( 0xc0 <= c ) {
484 outBuf[ i++ ] = ' '; 482 outBuf[ i++ ] = ' ';
485 outBuf[ i++ ] = c ^ 0x80; 483 outBuf[ i++ ] = c ^ 0x80;
486 } 484 }
487 else { 485 else {
488 Int16 m; 486 Int16 m;
489 Int16 n; 487 Int16 n;
490 488
491 c <<= 8; 489 c <<= 8;
492 c += inBuf[ j++ ]; 490 c += inBuf[ j++ ];
493 491
494 m = ( c & 0x3fff ) >> COUNT_BITS; 492 m = ( c & 0x3fff ) >> COUNT_BITS;
495 n = c & ( ( 1 << COUNT_BITS ) - 1 ); 493 n = c & ( ( 1 << COUNT_BITS ) - 1 );
496 n += 2; 494 n += 2;
497 495
498 do { 496 do {
499 outBuf[ i ] = outBuf[ i - m ]; 497 outBuf[ i ] = outBuf[ i - m ];
500 i++; 498 i++;
501 } while ( 0 < n-- ); 499 } while ( 0 < n-- );
502 } 500 }
503 } 501 }
504 k += bsize; 502 k += bsize;
505 } 503 }
506} 504}
507 505
508void CPlucker_base::home() 506void CPlucker_base::home()
509{ 507{
510 currentpos = 0; 508 currentpos = 0;
511 expand(1); 509 expand(1);
512} 510}
513 511
514CList<Bkmk>* CPlucker_base::getbkmklist() 512CList<Bkmk>* CPlucker_base::getbkmklist()
515{ 513{
516 /* 514 /*
517 UInt16 thishdr_uid, thishdr_nParagraphs; 515 UInt16 thishdr_uid, thishdr_nParagraphs;
518 UInt32 thishdr_size; 516 UInt32 thishdr_size;
519 UInt8 thishdr_type, thishdr_reserved; 517 UInt8 thishdr_type, thishdr_reserved;
520 518
521 for (int i = 1; i < ntohs(head.recordList.numRecords); i++) 519 for (int i = 1; i < ntohs(head.recordList.numRecords); i++)
522 { 520 {
523 gotorecordnumber(i); 521 gotorecordnumber(i);
524 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 522 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
525 if (thishdr_type == 8) 523 if (thishdr_type == 8)
526 { 524 {
527 UInt16 n; 525 UInt16 n;
528 fread(&n, 1, sizeof(n), fin); 526 fread(&n, 1, sizeof(n), fin);
529 n = ntohs(n); 527 n = ntohs(n);
530 //qDebug("Found %u bookmarks", n); 528 //qDebug("Found %u bookmarks", n);
531 } 529 }
532 //qDebug("Found:%d, %u", i , thishdr_type); 530 //qDebug("Found:%d, %u", i , thishdr_type);
533 } 531 }
534 */ 532 */
535 return NULL; 533 return NULL;
536} 534}
537 535
538#include <qnamespace.h> 536#include <qnamespace.h>
539 537
540QImage* CPlucker_base::expandimg(UInt16 tgt, bool border) 538QImage* CPlucker_base::expandimg(UInt16 tgt, bool border)
541{ 539{
542 QImage* qimage = getimg(tgt); 540 QImage* qimage = getimg(tgt);
543 QImage* ret; 541 QImage* ret;
544 if (qimage == NULL) return NULL; 542 if (qimage == NULL) return NULL;
545 if (border) 543 if (border)
546 { 544 {
547 QPixmap* image = new QPixmap(0,0); 545 QPixmap* image = new QPixmap(0,0);
548 image->convertFromImage(*qimage); 546 image->convertFromImage(*qimage);
549 delete qimage; 547 delete qimage;
550 QPixmap* pret = new QPixmap(image->width()+4, image->height()+4); 548 QPixmap* pret = new QPixmap(image->width()+4, image->height()+4);
551 pret->fill(Qt::red); 549 pret->fill(Qt::red);
552 bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP); 550 bitBlt(pret, 2, 2, image, 0, 0, -1, -1);//, Qt::RasterOp::CopyROP);
553 delete image; 551 delete image;
554 ret = new QImage(pret->convertToImage()); 552 ret = new QImage(pret->convertToImage());
555 } 553 }
556 else 554 else
557 { 555 {
558 ret = qimage; 556 ret = qimage;
559 } 557 }
560 return ret; 558 return ret;
561} 559}
562 560
563#ifdef _BUFFERPICS 561#ifdef _BUFFERPICS
564#include <qmap.h> 562#include <qmap.h>
565#endif 563#endif
566 564
567QImage* CPlucker_base::getPicture(unsigned long tgt) 565QImage* CPlucker_base::getPicture(unsigned long tgt)
568{ 566{
569#ifdef _BUFFERPICS 567#ifdef _BUFFERPICS
570 static QMap<unsigned long, QPixmap> pix; 568 static QMap<unsigned long, QPixmap> pix;
571 QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt); 569 QMap<unsigned long, QPixmap>::Iterator t = pix.find(tgt);
572 if (t == pix.end()) 570 if (t == pix.end())
573 { 571 {
574 pix[tgt] = *expandimg(tgt); 572 pix[tgt] = *expandimg(tgt);
575 return &pix[tgt]; 573 return &pix[tgt];
576 } 574 }
577 else 575 else
578 return &(t.data()); 576 return &(t.data());
579#else 577#else
580 return expandimg(tgt >> 16); 578 return expandimg(tgt >> 16);
581#endif 579#endif
582} 580}
583 581
584#ifdef LOCALPICTURES 582#ifdef LOCALPICTURES
585#include <unistd.h> 583#include <unistd.h>
586#include <qpe/global.h> 584#include <qpe/global.h>
587void CPlucker_base::showimg(UInt16 tgt) 585void CPlucker_base::showimg(UInt16 tgt)
588{ 586{
589 //qDebug("Crassssssh!"); 587 //qDebug("Crassssssh!");
590 QPixmap* qimage = expandimg(tgt); 588 QPixmap* qimage = expandimg(tgt);
591 m_picture->setFixedSize(qimage->size()); 589 m_picture->setFixedSize(qimage->size());
592 m_picture->setBackgroundPixmap(*qimage); 590 m_picture->setBackgroundPixmap(*qimage);
593 delete qimage; 591 delete qimage;
594 m_viewer->show(); 592 m_viewer->show();
595 593
596 /* 594 /*
597 char tmp[] = "uqtreader.XXXXXX"; 595 char tmp[] = "uqtreader.XXXXXX";
598 QImage* qimage = getimg(tgt); 596 QImage* qimage = getimg(tgt);
599 QPixmap* image = new QPixmap(0,0); 597 QPixmap* image = new QPixmap(0,0);
600 // //qDebug("New image"); 598 // //qDebug("New image");
601 image->convertFromImage(*qimage); 599 image->convertFromImage(*qimage);
602 delete qimage; 600 delete qimage;
603 char tmpfile[sizeof(tmp)+1]; 601 char tmpfile[sizeof(tmp)+1];
604 strcpy(tmpfile,tmp); 602 strcpy(tmpfile,tmp);
605 int f = mkstemp(tmpfile); 603 int f = mkstemp(tmpfile);
606 close(f); 604 close(f);
607 //qDebug("TMPFILE:%s", tmpfile); 605 //qDebug("TMPFILE:%s", tmpfile);
608 if (image->save(tmpfile,"PNG")) 606 if (image->save(tmpfile,"PNG"))
609 { 607 {
610 QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)"); 608 QCopEnvelope e("QPE/Application/showimg", "setDocument(QString)");
611 e << QString(tmpfile); 609 e << QString(tmpfile);
612 } 610 }
613 Global::statusMessage("Opening image"); 611 Global::statusMessage("Opening image");
614 sleep(5); 612 sleep(5);
615 delete image; 613 delete image;
616 unlink(tmpfile); 614 unlink(tmpfile);
617 */ 615 */
618} 616}
619 617
620#endif 618#endif
621 619
622unsigned short CPlucker_base::finduid(unsigned short urlid) 620unsigned short CPlucker_base::finduid(unsigned short urlid)
623{ 621{
624 // //qDebug("Finding %u", urlid); 622 // //qDebug("Finding %u", urlid);
625 unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords); 623 unsigned short jmin = 1, jmax = ntohs(head.recordList.numRecords);
626 unsigned short jmid = (jmin+jmax) >> 1; 624 unsigned short jmid = (jmin+jmax) >> 1;
627 while (jmax - jmin > 1) 625 while (jmax - jmin > 1)
628 { 626 {
629 gotorecordnumber(jmid); 627 gotorecordnumber(jmid);
630 UInt16 thishdr_uid, thishdr_nParagraphs; 628 UInt16 thishdr_uid, thishdr_nParagraphs;
631 UInt32 thishdr_size; 629 UInt32 thishdr_size;
632 UInt8 thishdr_type, thishdr_reserved; 630 UInt8 thishdr_type, thishdr_reserved;
633 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 631 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
634 unsigned short luid = thishdr_uid; 632 unsigned short luid = thishdr_uid;
635 ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid); 633 ////qDebug("%u %u %u : %u", jmin, jmid, jmax, urlid);
636 if (luid == urlid) 634 if (luid == urlid)
637 { 635 {
638 return jmid; 636 return jmid;
639 } 637 }
640 if (luid < urlid) 638 if (luid < urlid)
641 { 639 {
642 jmin = jmid; 640 jmin = jmid;
643 } 641 }
644 else 642 else
645 { 643 {
646 jmax = jmid; 644 jmax = jmid;
647 } 645 }
648 jmid = (jmin+jmax) >> 1; 646 jmid = (jmin+jmax) >> 1;
649 } 647 }
650 gotorecordnumber(jmin); 648 gotorecordnumber(jmin);
651 UInt16 thishdr_uid, thishdr_nParagraphs; 649 UInt16 thishdr_uid, thishdr_nParagraphs;
652 UInt32 thishdr_size; 650 UInt32 thishdr_size;
653 UInt8 thishdr_type, thishdr_reserved; 651 UInt8 thishdr_type, thishdr_reserved;
654 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 652 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
655 unsigned short luid = thishdr_uid; 653 unsigned short luid = thishdr_uid;
656 //qDebug("jmin at end:%u,%u", jmin, luid); 654 //qDebug("jmin at end:%u,%u", jmin, luid);
657 if (luid == urlid) 655 if (luid == urlid)
658 { 656 {
659 return jmin; 657 return jmin;
660 } 658 }
661 gotorecordnumber(jmax); 659 gotorecordnumber(jmax);
662 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 660 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
663 luid = thishdr_uid; 661 luid = thishdr_uid;
664 //qDebug("jmax at end:%u,%u", jmax, luid); 662 //qDebug("jmax at end:%u,%u", jmax, luid);
665 if (luid == urlid) 663 if (luid == urlid)
666 { 664 {
667 return jmax; 665 return jmax;
668 } 666 }
669 //qDebug("Couldn't find %u", urlid); 667 //qDebug("Couldn't find %u", urlid);
670 return 0; // Not found! 668 return 0; // Not found!
671} 669}
672 670
673#include <qnamespace.h> 671#include <qnamespace.h>
674 672
675void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen) 673void CPlucker_base::setSaveData(unsigned char*& data, unsigned short& len, unsigned char* src, unsigned short srclen)
676{ 674{
677 unsigned short sz = 0; 675 unsigned short sz = 0;
678 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) 676 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
679 { 677 {
680 sz++; 678 sz++;
681 } 679 }
682 size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long); 680 size_t newlen = srclen+sizeof(sz)+sz*sizeof(unsigned long);
683 unsigned char* newdata = new unsigned char[newlen]; 681 unsigned char* newdata = new unsigned char[newlen];
684 unsigned char* pdata = newdata; 682 unsigned char* pdata = newdata;
685 memcpy(newdata, src, srclen); 683 memcpy(newdata, src, srclen);
686 newdata += srclen; 684 newdata += srclen;
687 memcpy(newdata, &sz, sizeof(sz)); 685 memcpy(newdata, &sz, sizeof(sz));
688 newdata += sizeof(sz); 686 newdata += sizeof(sz);
689#ifdef _WINDOWS 687#ifdef _WINDOWS
690 for (it = visited.begin(); it != visited.end(); it++) 688 for (it = visited.begin(); it != visited.end(); it++)
691#else 689#else
692 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) 690 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
693#endif 691#endif
694 { 692 {
695 unsigned long t = *it; 693 unsigned long t = *it;
696 //qDebug("[%u]", t); 694 //qDebug("[%u]", t);
697 memcpy(newdata, &t, sizeof(t)); 695 memcpy(newdata, &t, sizeof(t));
698 newdata += sizeof(t); 696 newdata += sizeof(t);
699 } 697 }
700 m_nav.setSaveData(data, len, pdata, newlen); 698 m_nav.setSaveData(data, len, pdata, newlen);
701 delete [] pdata; 699 delete [] pdata;
702} 700}
703 701
704void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen) 702void CPlucker_base::putSaveData(unsigned char*& src, unsigned short& srclen)
705{ 703{
706 unsigned short sz; 704 unsigned short sz;
707 if (srclen >= sizeof(sz)) 705 if (srclen >= sizeof(sz))
708 { 706 {
709 memcpy(&sz, src, sizeof(sz)); 707 memcpy(&sz, src, sizeof(sz));
710 src += sizeof(sz); 708 src += sizeof(sz);
711 srclen -= sizeof(sz); 709 srclen -= sizeof(sz);
712 } 710 }
713 for (int i = 0; i < sz; i++) 711 for (int i = 0; i < sz; i++)
714 { 712 {
715 unsigned long t; 713 unsigned long t;
716 if (srclen >= sizeof(t)) 714 if (srclen >= sizeof(t))
717 { 715 {
718 memcpy(&t, src, sizeof(t)); 716 memcpy(&t, src, sizeof(t));
719 // qDebug("[%u]", t); 717 // qDebug("[%u]", t);
720 visited.push_front(t); 718 visited.push_front(t);
721 src += sizeof(t); 719 src += sizeof(t);
722 srclen -= sizeof(t); 720 srclen -= sizeof(t);
723 } 721 }
724 else 722 else
725 { 723 {
726 QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself"); 724 QMessageBox::warning(NULL, PROGNAME, "File data mismatch\nMight fix itself");
727 break; 725 break;
728 } 726 }
729 } 727 }
730 m_nav.putSaveData(src, srclen); 728 m_nav.putSaveData(src, srclen);
731} 729}
732 730
733int CPlucker_base::OpenFile(const char *src) 731int CPlucker_base::OpenFile(const char *src)
734{ 732{
735 qDebug("plucker openfile:%s", src); 733 qDebug("plucker openfile:%s", src);
736 m_lastBreak = 0; 734 m_lastBreak = 0;
737 if (!Cpdb::openpdbfile(src)) 735 if (!Cpdb::openpdbfile(src))
738 { 736 {
739 return -1; 737 return -1;
740 } 738 }
741 739
742 if (!CorrectDecoder()) return -1; 740 if (!CorrectDecoder()) return -1;
743 741
744 gotorecordnumber(0); 742 gotorecordnumber(0);
745 fread(&hdr0, 1, 6, fin); 743 fread(&hdr0, 1, 6, fin);
746 qDebug("Compression type:%u", ntohs(hdr0.version)); 744 qDebug("Compression type:%u", ntohs(hdr0.version));
747 745
748 746
749 switch (ntohs(hdr0.version)) 747 switch (ntohs(hdr0.version))
750 { 748 {
751 case 2: 749 case 2:
752 m_decompress = UnZip; 750 m_decompress = UnZip;
753 break; 751 break;
754 case 1: 752 case 1:
755 m_decompress = UnDoc; 753 m_decompress = UnDoc;
756 break; 754 break;
757#ifdef USENEF 755#ifdef USENEF
758 case 3: 756 case 3:
759 m_decompress = getdecompressor("PluckerDecompress3"); 757 m_decompress = getdecompressor("PluckerDecompress3");
760 break; 758 break;
761 case 4: 759 case 4:
762 m_decompress = getdecompressor("PluckerDecompress4"); 760 m_decompress = getdecompressor("PluckerDecompress4");
763 break; 761 break;
764#endif 762#endif
765 default: 763 default:
766 m_decompress = NULL; 764 m_decompress = NULL;
767 } 765 }
768 if (m_decompress == NULL) return -1; 766 if (m_decompress == NULL) return -1;
769 767
770 setbuffersize(); 768 setbuffersize();
771 compressedtextbuffer = new UInt8[compressedbuffersize]; 769 compressedtextbuffer = new UInt8[compressedbuffersize];
772 expandedtextbuffer = new UInt8[buffersize]; 770 expandedtextbuffer = new UInt8[buffersize];
773 771
774 unsigned int nrecs = ntohs(hdr0.nRecords); 772 unsigned int nrecs = ntohs(hdr0.nRecords);
775 qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs); 773 qDebug("Version %u, no. reserved recs %u", ntohs(hdr0.version), nrecs);
776 textlength = ntohl(head.sortInfoID); 774 textlength = ntohl(head.sortInfoID);
777 qDebug("Textlength at startup:%u", textlength); 775 qDebug("Textlength at startup:%u", textlength);
778 UInt16 homerecid = 1; 776 UInt16 homerecid = 1;
779 for (unsigned int i = 0; i < nrecs; i++) 777 for (unsigned int i = 0; i < nrecs; i++)
780 { 778 {
781 UInt16 id, name; 779 UInt16 id, name;
782 fread(&name, 1, sizeof(name), fin); 780 fread(&name, 1, sizeof(name), fin);
783 fread(&id, 1, sizeof(id), fin); 781 fread(&id, 1, sizeof(id), fin);
784 //qDebug("N:%d, I:%d", ntohs(name), ntohs(id)); 782 //qDebug("N:%d, I:%d", ntohs(name), ntohs(id));
785 if (ntohs(name) == 0) homerecid = ntohs(id); 783 if (ntohs(name) == 0) homerecid = ntohs(id);
786 } 784 }
787 785
788 textlength = 0; 786 textlength = 0;
789 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++) 787 for (int recptr = 1; recptr < ntohs(head.recordList.numRecords); recptr++)
790 { 788 {
791 gotorecordnumber(recptr); 789 gotorecordnumber(recptr);
792 UInt16 thishdr_uid, thishdr_nParagraphs; 790 UInt16 thishdr_uid, thishdr_nParagraphs;
793 UInt32 thishdr_size; 791 UInt32 thishdr_size;
794 UInt8 thishdr_type, thishdr_reserved; 792 UInt8 thishdr_type, thishdr_reserved;
795 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 793 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
796 if (thishdr_uid == homerecid) 794 if (thishdr_uid == homerecid)
797 { 795 {
798 m_homepos = textlength; 796 m_homepos = textlength;
799 break; 797 break;
800 } 798 }
801 if (thishdr_type < 2) textlength += thishdr_size; 799 if (thishdr_type < 2) textlength += thishdr_size;
802 } 800 }
803 qDebug("Found home"); 801 qDebug("Found home");
804 textlength = 0; 802 textlength = 0;
805 home(); 803 home();
806 qDebug("Gone home"); 804 qDebug("Gone home");
807#ifdef LOCALPICTURES 805#ifdef LOCALPICTURES
808 if (m_viewer == NULL) 806 if (m_viewer == NULL)
809 { 807 {
810 m_viewer = new QScrollView(NULL); 808 m_viewer = new QScrollView(NULL);
811 m_picture = new QWidget(m_viewer->viewport()); 809 m_picture = new QWidget(m_viewer->viewport());
812 m_viewer->addChild(m_picture); 810 m_viewer->addChild(m_picture);
813 } 811 }
814#endif 812#endif
815 return 0; 813 return 0;
816 814
817} 815}
818 816
819QImage* CPlucker_base::getimg(UInt16 tgt) 817QImage* CPlucker_base::getimg(UInt16 tgt)
820{ 818{
821 size_t reclen; 819 size_t reclen;
822 UInt16 thisrec = finduid(tgt); 820 UInt16 thisrec = finduid(tgt);
823 qDebug("getimg:Found %u from uid:%u", thisrec, tgt); 821 qDebug("getimg:Found %u from uid:%u", thisrec, tgt);
824 reclen = recordlength(thisrec); 822 reclen = recordlength(thisrec);
825 gotorecordnumber(thisrec); 823 gotorecordnumber(thisrec);
826 UInt16 thishdr_uid, thishdr_nParagraphs; 824 UInt16 thishdr_uid, thishdr_nParagraphs;
827 UInt32 thishdr_size; 825 UInt32 thishdr_size;
828 UInt8 thishdr_type, thishdr_reserved; 826 UInt8 thishdr_type, thishdr_reserved;
829 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 827 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
830 if (thishdr_type == 15) 828 if (thishdr_type == 15)
831 { 829 {
832 char *buffer = new char[thishdr_size]; 830 char *buffer = new char[thishdr_size];
833 fread(buffer, thishdr_size, sizeof(char), fin); 831 fread(buffer, thishdr_size, sizeof(char), fin);
834 unsigned short tmp; 832 unsigned short tmp;
835 memcpy(&tmp, buffer, sizeof(tmp)); 833 memcpy(&tmp, buffer, sizeof(tmp));
836 unsigned short cols = ntohs(tmp); 834 unsigned short cols = ntohs(tmp);
837 memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp)); 835 memcpy(&tmp, buffer+sizeof(tmp), sizeof(tmp));
838 unsigned short rows = ntohs(tmp); 836 unsigned short rows = ntohs(tmp);
839 qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols); 837 qDebug("Found a picture of type:%u [%u,%u]", thishdr_type, rows, cols);
840 QImage*** images; 838 QImage*** images;
841 images = new QImage**[rows]; 839 images = new QImage**[rows];
842#ifdef _WINDOWS 840#ifdef _WINDOWS
843 int i; 841 int i;
844 for (i = 0; i < rows; i++) 842 for (i = 0; i < rows; i++)
845#else 843#else
846 for (int i = 0; i < rows; i++) 844 for (int i = 0; i < rows; i++)
847#endif 845#endif
848 { 846 {
849 images[i] = new QImage*[cols]; 847 images[i] = new QImage*[cols];
850 } 848 }
851 int height = 0; 849 int height = 0;
852 int width = 0; 850 int width = 0;
853#ifdef _WINDOWS 851#ifdef _WINDOWS
854 for (i = 0; i < rows; i++) 852 for (i = 0; i < rows; i++)
855#else 853#else
856 for (int i = 0; i < rows; i++) 854 for (int i = 0; i < rows; i++)
857#endif 855#endif
858 { 856 {
859 width = 0; 857 width = 0;
860 for (int j = 0; j < cols; j++) 858 for (int j = 0; j < cols; j++)
861 { 859 {
862 memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp)); 860 memcpy(&tmp, buffer+(i*cols+j+2)*sizeof(tmp), sizeof(tmp));
863 unsigned short uid = ntohs(tmp); 861 unsigned short uid = ntohs(tmp);
864 images[i][j] = getimg(uid); 862 images[i][j] = getimg(uid);
865 width += images[i][j]->width(); 863 width += images[i][j]->width();
866 } 864 }
867 height += images[i][0]->height(); 865 height += images[i][0]->height();
868 } 866 }
869 delete [] buffer; 867 delete [] buffer;
870 QPixmap pm(width, height); 868 QPixmap pm(width, height);
871 int hoffset = 0; 869 int hoffset = 0;
872#ifdef _WINDOWS 870#ifdef _WINDOWS
873 for (i = 0; i < rows; i++) 871 for (i = 0; i < rows; i++)
874#else 872#else
875 for (int i = 0; i < rows; i++) 873 for (int i = 0; i < rows; i++)
876#endif 874#endif
877 { 875 {
878 int woffset = 0; 876 int woffset = 0;
879 int delht = images[i][0]->height(); 877 int delht = images[i][0]->height();
880 for (int j = 0; j < cols; j++) 878 for (int j = 0; j < cols; j++)
881 { 879 {
882 QPixmap pm2; 880 QPixmap pm2;
883 pm2.convertFromImage(*(images[i][j])); 881 pm2.convertFromImage(*(images[i][j]));
884 delete images[i][j]; 882 delete images[i][j];
885 bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height()); 883 bitBlt(&pm, woffset, hoffset, &pm2, 0, 0, pm2.width(), pm2.height());
886 woffset += pm2.width(); 884 woffset += pm2.width();
887 } 885 }
888 hoffset += delht; 886 hoffset += delht;
889 } 887 }
890#ifdef _WINDOWS 888#ifdef _WINDOWS
891 for (i = 0; i < rows; i++) 889 for (i = 0; i < rows; i++)
892#else 890#else
893 for (int i = 0; i < rows; i++) 891 for (int i = 0; i < rows; i++)
894#endif 892#endif
895 { 893 {
896 delete [] images[i]; 894 delete [] images[i];
897 } 895 }
898 delete [] images; 896 delete [] images;
899 return new QImage(pm.convertToImage()); 897 return new QImage(pm.convertToImage());
900 } 898 }
901 else 899 else
902 { 900 {
903 qDebug("Found a picture of type:%u", thishdr_type); 901 qDebug("Found a picture of type:%u", thishdr_type);
904 reclen -= HeaderSize(); 902 reclen -= HeaderSize();
905 903
906 UInt32 imgsize = thishdr_size; 904 UInt32 imgsize = thishdr_size;
907 UInt8* imgbuffer = new UInt8[imgsize]; 905 UInt8* imgbuffer = new UInt8[imgsize];
908 906
909 Expand(reclen, thishdr_type, imgbuffer, imgsize); 907 Expand(reclen, thishdr_type, imgbuffer, imgsize);
910 908
911 return imagefromdata(imgbuffer, imgsize); 909 return imagefromdata(imgbuffer, imgsize);
912 } 910 }
913} 911}
914 912
915linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& wrd, QString&) 913linkType CPlucker_base::hyperlink(unsigned int n, unsigned int offset, QString& wrd, QString&)
916{ 914{
917 visited.push_front(n); 915 visited.push_front(n);
918 UInt16 tuid = (n >> 16); 916 UInt16 tuid = (n >> 16);
919 n &= 0xffff; 917 n &= 0xffff;
920 char *turl = geturl(tuid); 918 char *turl = geturl(tuid);
921 if (turl != NULL) 919 if (turl != NULL)
922 { 920 {
923 qDebug("URL in PB:%s", turl); 921 qDebug("URL in PB:%s", turl);
924 wrd = turl; 922 wrd = turl;
925 delete [] turl; 923 delete [] turl;
926 } 924 }
927 else 925 else
928 { 926 {
929 wrd.truncate(0); 927 wrd.truncate(0);
930 } 928 }
931 qDebug("Hyper: UID:%u, Para:%u, Offset:%u", tuid, n, offset); 929 qDebug("Hyper: UID:%u, Para:%u, Offset:%u", tuid, n, offset);
932 UInt16 thisrec = 1; 930 UInt16 thisrec = 1;
933 currentpos = 0; 931 currentpos = 0;
934 gotorecordnumber(thisrec); 932 gotorecordnumber(thisrec);
935 UInt16 thishdr_uid, thishdr_nParagraphs; 933 UInt16 thishdr_uid, thishdr_nParagraphs;
936 UInt32 thishdr_size; 934 UInt32 thishdr_size;
937 UInt8 thishdr_type, thishdr_reserved; 935 UInt8 thishdr_type, thishdr_reserved;
938 while (1) 936 while (1)
939 { 937 {
940 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved); 938 GetHeader(thishdr_uid, thishdr_nParagraphs, thishdr_size, thishdr_type, thishdr_reserved);
941 if (tuid == thishdr_uid) break; 939 if (tuid == thishdr_uid) break;
942 if (thishdr_type < 2) currentpos += thishdr_size; 940 if (thishdr_type < 2) currentpos += thishdr_size;
943 ////qDebug("hyper-cp:%u", currentpos); 941 ////qDebug("hyper-cp:%u", currentpos);
944 thisrec++; 942 thisrec++;
945 if (thisrec >= ntohs(head.recordList.numRecords)) 943 if (thisrec >= ntohs(head.recordList.numRecords))
946 { 944 {
947 if (wrd.isEmpty()) 945 if (wrd.isEmpty())
948 { 946 {
949 QMessageBox::information(NULL, 947 QMessageBox::information(NULL,
950 QString(PROGNAME), 948 QString(PROGNAME),
951 QString("Couldn't find link") 949 QString("Couldn't find link")
952 ); 950 );
953 } 951 }
954 else 952 else
955 { 953 {
956#ifdef USEQPE 954#ifdef USEQPE
957 if (wrd.length() > 10) 955 if (wrd.length() > 10)
958 { 956 {
959 Global::statusMessage(wrd.left(8) + ".."); 957 Global::statusMessage(wrd.left(8) + "..");
960 } 958 }
961 else 959 else
962 { 960 {
963 Global::statusMessage(wrd); 961 Global::statusMessage(wrd);
964 } 962 }
965#else 963#else
966#endif /* USEQPE */ 964#endif /* USEQPE */
967 //qDebug("Link:%s", (const char*)wrd); 965 //qDebug("Link:%s", (const char*)wrd);
968 // setlink(fn, wrd); 966 // setlink(fn, wrd);
969 } 967 }
970 return eNone; 968 return eNone;
971 } 969 }
972 gotorecordnumber(thisrec); 970 gotorecordnumber(thisrec);
973 } 971 }
974 if (thishdr_type > 1) 972 if (thishdr_type > 1)
975 { 973 {
976 if (thishdr_type == 4) 974 if (thishdr_type == 4)
977 { 975 {
978 QMessageBox::information(NULL, 976 QMessageBox::information(NULL,
979 QString(PROGNAME), 977 QString(PROGNAME),
980 QString("Mailto links\nnot yet supported (2)")); 978 QString("Mailto links\nnot yet supported (2)"));
981 } 979 }
982 else 980 else
983 { 981 {
984 if (thishdr_type > 3 && thishdr_type != 15) 982 if (thishdr_type > 3 && thishdr_type != 15)
985 { 983 {
986 QMessageBox::information(NULL, 984 QMessageBox::information(NULL,
987 QString(PROGNAME), 985 QString(PROGNAME),
988 QString("External links\nnot yet supported (2)") 986 QString("External links\nnot yet supported (2)")
989 ); 987 );
990 return eNone; 988 return eNone;
991 } 989 }
992 else 990 else
993 { 991 {
994#ifdef LOCALPICTURES 992#ifdef LOCALPICTURES
995 showimg(tuid); 993 showimg(tuid);
996#else 994#else
997 return ePicture; 995 return ePicture;
998#endif 996#endif
999 } 997 }
1000 } 998 }
1001 return eNone; 999 return eNone;
1002 } 1000 }
1003 /* 1001 /*
1004 if (thishdr_type == 2 || thishdr_type == 3) 1002 if (thishdr_type == 2 || thishdr_type == 3)
1005 { 1003 {
1006 expandimg(thisrec); 1004 expandimg(thisrec);
1007 1005
1008 } 1006 }
1009 */ 1007 */
1010 else 1008 else
1011 { 1009 {
1012 expand(thisrec); 1010 expand(thisrec);
1013 unsigned int paraoffset = offset; 1011 unsigned int paraoffset = offset;
1014 // unsigned int noff = 0; 1012 // unsigned int noff = 0;
1015 if (n != 0) 1013 if (n != 0)
1016 { 1014 {
1017 if (n >= m_nParas) 1015 if (n >= m_nParas)
1018 { 1016 {
1019 QMessageBox::information(NULL, 1017 QMessageBox::information(NULL,
1020 QString(PROGNAME), 1018 QString(PROGNAME),
1021 QString("Error in link\nPara # too big") 1019 QString("Error in link\nPara # too big")
1022 ); 1020 );
1023 return eNone; 1021 return eNone;
1024 } 1022 }
1025 unsigned int noff = 0; 1023 unsigned int noff = 0;
1026 for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i]; 1024 for (unsigned int i = 0; i < n; i++) noff += m_ParaOffsets[i];
1027 1025
1028 paraoffset += noff; 1026 paraoffset += noff;
1029 } 1027 }
1030 if (paraoffset > thishdr_size) 1028 if (paraoffset > thishdr_size)
1031 { 1029 {
1032 QMessageBox::information(NULL, 1030 QMessageBox::information(NULL,
1033 QString(PROGNAME), 1031 QString(PROGNAME),
1034 QString("Error in link\nOffset too big") 1032 QString("Error in link\nOffset too big")
1035 ); 1033 );
1036 return eNone; 1034 return eNone;
1037 } 1035 }
1038 while (bufferpos < paraoffset && bufferpos < buffercontent) getch_base(true); 1036 while (bufferpos < paraoffset && bufferpos < buffercontent) getch_base(true);
1039 //qDebug("Hyper:<%u,%u,%u>", paraoffset, bufferpos, currentpos); 1037 //qDebug("Hyper:<%u,%u,%u>", paraoffset, bufferpos, currentpos);
1040 /* // This is faster but the alignment doesn't get set 1038 /* // This is faster but the alignment doesn't get set
1041 mystyle.unset(); 1039 mystyle.unset();
1042 bufferpos = n; 1040 bufferpos = n;
1043 currentpos += n; 1041 currentpos += n;
1044 while (bufferpos >= m_nextPara && m_nextPara >= 0) 1042 while (bufferpos >= m_nextPara && m_nextPara >= 0)
1045 { 1043 {
1046 UInt16 attr = m_ParaAttrs[m_nextParaIndex]; 1044 UInt16 attr = m_ParaAttrs[m_nextParaIndex];
1047 m_nextParaIndex++; 1045 m_nextParaIndex++;
1048 if (m_nextParaIndex == m_nParas) 1046 if (m_nextParaIndex == m_nParas)
1049 { 1047 {
1050 m_nextPara = -1; 1048 m_nextPara = -1;
1051 } 1049 }
1052 else 1050 else
1053 { 1051 {
1054 m_nextPara += m_ParaOffsets[m_nextParaIndex]; 1052 m_nextPara += m_ParaOffsets[m_nextParaIndex];
1055 } 1053 }
1056 } 1054 }
1057 */ 1055 */
1058 } 1056 }
1059 return eLink; 1057 return eLink;
1060} 1058}
1061 1059
1062tchar CPlucker_base::getch_base(bool fast) 1060tchar CPlucker_base::getch_base(bool fast)
1063{ 1061{
1064 int ch = bgetch(); 1062 int ch = bgetch();
1065 while (ch == 0) 1063 while (ch == 0)
1066 { 1064 {
1067 ch = bgetch(); 1065 ch = bgetch();
1068 ////qDebug("Function:%x", ch); 1066 ////qDebug("Function:%x", ch);
1069 switch (ch) 1067 switch (ch)
1070 { 1068 {
1071 case 0x38: 1069 case 0x38:
1072 // //qDebug("Break:%u", locate()); 1070 // //qDebug("Break:%u", locate());
1073 if (m_lastBreak == locate()) 1071 if (m_lastBreak == locate())
1074 { 1072 {
1075 ch = bgetch(); 1073 ch = bgetch();
1076 } 1074 }
1077 else 1075 else
1078 { 1076 {
1079 ch = 10; 1077 ch = 10;
1080 } 1078 }
1081 m_lastBreak = locate(); 1079 m_lastBreak = locate();
1082 break; 1080 break;
1083 case 0x0a: 1081 case 0x0a:
1084 case 0x0c: 1082 case 0x0c:
1085 { 1083 {
1086 unsigned long ln = 0; 1084 unsigned long ln = 0;
1087 int skip = ch & 7; 1085 int skip = ch & 7;
1088 for (int i = 0; i < 2; i++) 1086 for (int i = 0; i < 2; i++)
1089 { 1087 {
1090 int ch = bgetch(); 1088 int ch = bgetch();
1091 ln = (ln << 8) + ch; 1089 ln = (ln << 8) + ch;
1092 // //qDebug("ch:%d, ln:%u", ch, ln); 1090 // //qDebug("ch:%d, ln:%u", ch, ln);
1093 } 1091 }
1094 if (skip == 2) 1092 if (skip == 2)
1095 { 1093 {
1096 ln <<= 16; 1094 ln <<= 16;
1097 } 1095 }
1098 else 1096 else
1099 { 1097 {
1100 for (int i = 0; i < 2; i++) 1098 for (int i = 0; i < 2; i++)
1101 { 1099 {
1102 int ch = bgetch(); 1100 int ch = bgetch();
1103 ln = (ln << 8) + ch; 1101 ln = (ln << 8) + ch;
1104 // //qDebug("ch:%d, ln:%u", ch, ln); 1102 // //qDebug("ch:%d, ln:%u", ch, ln);
1105 } 1103 }
1106 } 1104 }
1107 // //qDebug("ln:%u", ln); 1105 // //qDebug("ln:%u", ln);
1108 mystyle.setLink(true); 1106 mystyle.setLink(true);
1109 mystyle.setData(ln); 1107 mystyle.setData(ln);
1110 // mystyle.setColour(255, 0, 0); 1108 // mystyle.setColour(255, 0, 0);
1111 bool hasseen = false; 1109 bool hasseen = false;
1112 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++) 1110 for (CList<unsigned long>::iterator it = visited.begin(); it != visited.end(); it++)
1113 { 1111 {
1114 if (*it == ln) 1112 if (*it == ln)
1115 { 1113 {
1116 hasseen = true; 1114 hasseen = true;
1117 break; 1115 break;
1118 } 1116 }
1119 } 1117 }
1120 if (hasseen) 1118 if (hasseen)
1121 { 1119 {
1122 mystyle.setStrikethru(); 1120 mystyle.setStrikethru();
1123 } 1121 }
1124 else 1122 else
1125 { 1123 {
1126 mystyle.setUnderline(); 1124 mystyle.setUnderline();
1127 } 1125 }
1128 mystyle.setOffset(m_offset); 1126 mystyle.setOffset(m_offset);
1129 m_offset = 0; 1127 m_offset = 0;
1130 ch = bgetch(); 1128 ch = bgetch();
1131 } 1129 }
1132 break; 1130 break;
1133 case 0x08: 1131 case 0x08:
1134 ch = bgetch(); 1132 ch = bgetch();
1135 // mystyle.setColour(0, 0, 0); 1133 // mystyle.setColour(0, 0, 0);
1136 mystyle.unsetUnderline(); 1134 mystyle.unsetUnderline();
1137 mystyle.unsetStrikethru(); 1135 mystyle.unsetStrikethru();
1138 mystyle.setLink(false); 1136 mystyle.setLink(false);
1139 mystyle.setData(0); 1137 mystyle.setData(0);
1140 break; 1138 break;
1141 case 0x40: 1139 case 0x40:
1142 mystyle.setItalic(); 1140 mystyle.setItalic();
1143 ch = bgetch(); 1141 ch = bgetch();
1144 break; 1142 break;
1145 case 0x48: 1143 case 0x48:
1146 mystyle.unsetItalic(); 1144 mystyle.unsetItalic();
1147 ch = bgetch(); 1145 ch = bgetch();
1148 break; 1146 break;
1149 case 0x11: 1147 case 0x11:
1150 { 1148 {
1151 ch = bgetch(); 1149 ch = bgetch();
1152 // //qDebug("Font:%d",ch); 1150 // //qDebug("Font:%d",ch);
1153 mystyle.setVOffset(0); 1151 mystyle.setVOffset(0);
1154 mystyle.unsetMono(); 1152 mystyle.unsetMono();
1155 mystyle.unsetBold(); 1153 mystyle.unsetBold();
1156 switch (ch) 1154 switch (ch)
1157 { 1155 {
1158 case 0: 1156 case 0:
1159 mystyle.setFontSize(0); 1157 mystyle.setFontSize(0);
1160 break; 1158 break;
1161 case 1: 1159 case 1:
1162 mystyle.setFontSize(3); 1160 mystyle.setFontSize(3);
1163 mystyle.setBold(); 1161 mystyle.setBold();
1164 break; 1162 break;
1165 case 2: 1163 case 2:
1166 mystyle.setFontSize(2); 1164 mystyle.setFontSize(2);
1167 mystyle.setBold(); 1165 mystyle.setBold();
1168 break; 1166 break;
1169 case 3: 1167 case 3:
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"
1365void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) 1362void (*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
1383void (*CPlucker_base::getdecompressor(const QString& _s))(UInt8*, size_t, UInt8*, size_t) 1380void (*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
1403QString CPlucker_base::about() 1400QString 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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
18include ( $(OPIEDIR)/include.pro ) 18include ( $(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
26char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'}; 25char stat_magic[STAT_MAGIC_SIZE]={'P','P','M','S'};
27 26
28#include "ppm_expander.h" 27#include "ppm_expander.h"
29 28
30ppm_expander::~ppm_expander() { 29ppm_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
39int ppm_expander::OpenFile(const char* infile) 38int 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
46void ppm_expander::sizes(unsigned long& file, unsigned long& text) 45void 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
54int ppm_expander::home() 53int 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
74void ppm_expander::locate(unsigned int n) { 73void 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
79void ppm_expander::locate(unsigned short block, unsigned int n) 78void 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
98int ppm_expander::getch() { 97int 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
112extern "C" 111extern "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
16class ppm_expander : public CExpander { 15class 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;
29public: 28public:
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 @@
1DEFINES += OPIE USEQPE 1DEFINES += OPIE USEQPE
2VPATH = .. 2VPATH = ..
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
14LIBS += -lreader_codec 14LIBS += -lreader_codec
15 15
16 INCLUDEPATH+= ../OREADERINC $(OPIEDIR)/include 16 INCLUDEPATH+= $(OPIEDIR)/include
17 DEPENDPATH+= ../OREADERINC $(OPIEDIR)/include 17 DEPENDPATH+= $(OPIEDIR)/include
18 18
19include ( $(OPIEDIR)/include.pro ) 19include ( $(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
9Config::Config(const QString& _fn) : fname(_fn) 8Config::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}
32Config::~Config() 31Config::~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}
48QString Config::readEntry(const QString& key, const QString& deflt) 47QString 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}
60bool Config::readBoolEntry(const QString& key, const bool deflt) 59bool 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}
74int Config::readNumEntry(const QString& key, const int deflt) 73int 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}
88void Config::writeEntry(const QString& key, const QString& value) 87void Config::writeEntry(const QString& key, const QString& value)
89{ 88{
90 values[key] = value; 89 values[key] = value;
91} 90}
92 91
93void Config::writeEntry(const QString& key, const bool value) 92void 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
98void Config::writeEntry(const QString& key, const int value) 97void 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
9class Config 8class 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,773 +1,772 @@
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
20static unsigned char h2i(unsigned char c) 19static 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
34static void parse_color(const QString& attr, unsigned char& r, unsigned char& g, unsigned char& b) 33static 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
72CNavigation_base<htmlmark> striphtml::m_nav; 71CNavigation_base<htmlmark> striphtml::m_nav;
73 72
74void striphtml::skipblock(const QString& _ent) 73void 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
94void striphtml::locate(unsigned int n) 93void 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
106int striphtml::getpara(CBuffer& buff, unsigned long& startpos) 105int 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);
198 } 197 }
199} 198}
200 199
201QString striphtml::dehtml(const QString& _info) 200QString striphtml::dehtml(const QString& _info)
202{ 201{
203 QString info; 202 QString info;
204 for (int i = 0; i < _info.length(); i++) 203 for (int i = 0; i < _info.length(); i++)
205 { 204 {
206 tchar ch = _info[i]; 205 tchar ch = _info[i];
207 if (ch == '%') 206 if (ch == '%')
208 { 207 {
209 ch = 0; 208 ch = 0;
210 for (int j = 0; j < 2; j++) 209 for (int j = 0; j < 2; j++)
211 { 210 {
212 ch <<= 4; 211 ch <<= 4;
213 tchar ch1 = _info[++i]; 212 tchar ch1 = _info[++i];
214 if ('0' <= ch1 && ch1 <= '9') 213 if ('0' <= ch1 && ch1 <= '9')
215 { 214 {
216 ch += ch1 - '0'; 215 ch += ch1 - '0';
217 } 216 }
218 else if ('a' <= ch1 && ch1 <= 'f') 217 else if ('a' <= ch1 && ch1 <= 'f')
219 { 218 {
220 ch += ch1 - 'a' + 10; 219 ch += ch1 - 'a' + 10;
221 } 220 }
222 else if ('A' <= ch1 && ch1 <= 'F') 221 else if ('A' <= ch1 && ch1 <= 'F')
223 { 222 {
224 ch += ch1 - 'A' + 10; 223 ch += ch1 - 'A' + 10;
225 } 224 }
226 } 225 }
227 } 226 }
228 info += ch; 227 info += ch;
229 } 228 }
230 return info; 229 return info;
231} 230}
232 231
233bool striphtml::findanchor(const QString& _info) 232bool striphtml::findanchor(const QString& _info)
234{ 233{
235 // QProgressDialog dlg("Finding link...", QString::null, 0, NULL, "progress", true); 234 // QProgressDialog dlg("Finding link...", QString::null, 0, NULL, "progress", true);
236 // QProgressBar dlg(0); 235 // QProgressBar dlg(0);
237#if defined(USEQPE) || defined(_WINDOWS) 236#if defined(USEQPE) || defined(_WINDOWS)
238 QString info; 237 QString info;
239 for (int i = 0; i < _info.length(); i++) 238 for (int i = 0; i < _info.length(); i++)
240 { 239 {
241 tchar ch = _info[i]; 240 tchar ch = _info[i];
242 if (QString(".^$[]*+?").find(ch) != -1) 241 if (QString(".^$[]*+?").find(ch) != -1)
243 { 242 {
244 info += '\\'; 243 info += '\\';
245 } 244 }
246 info += ch; 245 info += ch;
247 } 246 }
248#else 247#else
249 QString info = QRegExp::escape(_info); 248 QString info = QRegExp::escape(_info);
250#endif 249#endif
251 qDebug("Adjusted searchstring:%s", (const char*)info); 250 qDebug("Adjusted searchstring:%s", (const char*)info);
252 QString sname("<[Aa][^>]*[ \t]+[Nn][Aa][Mm][Ee][ \t]*=[ \t]*\"?"); 251 QString sname("<[Aa][^>]*[ \t]+[Nn][Aa][Mm][Ee][ \t]*=[ \t]*\"?");
253 sname += info + "\"?[ \t>]"; 252 sname += info + "\"?[ \t>]";
254 QString sid("<[A-Za-z][^>]*[ \t]+[Ii][Dd][ \t]*=[ \t]*\"?"); 253 QString sid("<[A-Za-z][^>]*[ \t]+[Ii][Dd][ \t]*=[ \t]*\"?");
255 sid += info+"\"?[ \t>]"; 254 sid += info+"\"?[ \t>]";
256#ifdef USEQPE 255#ifdef USEQPE
257 QRegExp name(sname); 256 QRegExp name(sname);
258 QRegExp id(sid); 257 QRegExp id(sid);
259#else 258#else
260 QRegExp name(sname+"|"+sid); 259 QRegExp name(sname+"|"+sid);
261#endif 260#endif
262 bool ret = true; 261 bool ret = true;
263 locate(0); 262 locate(0);
264 unsigned long pos = 0; 263 unsigned long pos = 0;
265 unsigned long startpos = 0; 264 unsigned long startpos = 0;
266 int offset; 265 int offset;
267 CBuffer test; 266 CBuffer test;
268 qDebug("striphtml::findanchor"); 267 qDebug("striphtml::findanchor");
269 // dlg.show(); 268 // dlg.show();
270 if (getpara(test, pos) >= 0) 269 if (getpara(test, pos) >= 0)
271 { 270 {
272 while (1) 271 while (1)
273 { 272 {
274 // qApp->processEvents(); 273 // qApp->processEvents();
275 if ((offset = name.match(toQString(test.data()))) != -1) break; 274 if ((offset = name.match(toQString(test.data()))) != -1) break;
276#ifdef USEQPE 275#ifdef USEQPE
277 if ((offset = id.match(toQString(test.data()))) != -1) break; 276 if ((offset = id.match(toQString(test.data()))) != -1) break;
278#endif 277#endif
279 if (getpara(test, pos) < 0) 278 if (getpara(test, pos) < 0)
280 { 279 {
281 locate(startpos); 280 locate(startpos);
282 qDebug("Not found"); 281 qDebug("Not found");
283 return false; 282 return false;
284 } 283 }
285 } 284 }
286 locate(pos); 285 locate(pos);
287 qDebug("Found"); 286 qDebug("Found");
288 ret = true; 287 ret = true;
289 } 288 }
290 else 289 else
291 { 290 {
292 locate(startpos); 291 locate(startpos);
293 qDebug("Not found"); 292 qDebug("Not found");
294 ret = false; 293 ret = false;
295 } 294 }
296 return ret; 295 return ret;
297} 296}
298 297
299striphtml::striphtml(const QString& _s) : entmap(NULL), isPre(false), currentid(0), lastch(0), currentfile(_s), indent(0), forcecentre(false), m_inblock(false), m_bchm(false), ignorespace(false) 298striphtml::striphtml(const QString& _s) : entmap(NULL), isPre(false), currentid(0), lastch(0), currentfile(_s), indent(0), forcecentre(false), m_inblock(false), m_bchm(false), ignorespace(false)
300{ 299{
301 href2filepos = new QMap<QString, unsigned long>; 300 href2filepos = new QMap<QString, unsigned long>;
302 id2href = new QMap<unsigned long, QString>; 301 id2href = new QMap<unsigned long, QString>;
303} 302}
304 303
305striphtml::~striphtml() 304striphtml::~striphtml()
306{ 305{
307 if (entmap != NULL) delete entmap; 306 if (entmap != NULL) delete entmap;
308 delete href2filepos; 307 delete href2filepos;
309 delete id2href; 308 delete id2href;
310} 309}
311 310
312void striphtml::initentmap() 311void striphtml::initentmap()
313{ 312{
314 entmap = new QMap<QString, tchar>; 313 entmap = new QMap<QString, tchar>;
315 QString fname(QTReaderUtil::getPluginPath("data")); 314 QString fname(QTReaderUtil::getPluginPath("data"));
316 QFileInfo fi; 315 QFileInfo fi;
317 fi.setFile(fname, "HTMLentities"); 316 fi.setFile(fname, "HTMLentities");
318 if (fi.exists()) 317 if (fi.exists())
319 { 318 {
320 fname = fi.absFilePath(); 319 fname = fi.absFilePath();
321 320
322 QFile fl(fname); 321 QFile fl(fname);
323 if (fl.open(IO_ReadOnly)) 322 if (fl.open(IO_ReadOnly))
324 { 323 {
325 QTextStream t(&fl); 324 QTextStream t(&fl);
326 QString key, value; 325 QString key, value;
327 while (!t.eof()) 326 while (!t.eof())
328 { 327 {
329 QString data = t.readLine(); 328 QString data = t.readLine();
330 int colon = data.find(':'); 329 int colon = data.find(':');
331 if (colon > 0) 330 if (colon > 0)
332 { 331 {
333 QString key = data.left(colon); 332 QString key = data.left(colon);
334 QString value = data.right(data.length()-colon-1); 333 QString value = data.right(data.length()-colon-1);
335 bool ok; 334 bool ok;
336 int ret = value.toInt(&ok); 335 int ret = value.toInt(&ok);
337 if (ok) 336 if (ok)
338 { 337 {
339 (*entmap)[key] = ret; 338 (*entmap)[key] = ret;
340 } 339 }
341 } 340 }
342 } 341 }
343 fl.close(); 342 fl.close();
344 } 343 }
345 } 344 }
346} 345}
347 346
348unsigned short striphtml::skip_ws() 347unsigned short striphtml::skip_ws()
349{ 348{
350 tchar ch; 349 tchar ch;
351 CStyle sty; 350 CStyle sty;
352 unsigned long dummy; 351 unsigned long dummy;
353 do 352 do
354 { 353 {
355 mygetch(ch, sty, dummy); 354 mygetch(ch, sty, dummy);
356 } 355 }
357 while (ch < 33 && ch != UEOF); 356 while (ch < 33 && ch != UEOF);
358 return ch; 357 return ch;
359} 358}
360 359
361unsigned short striphtml::skip_ws_end() 360unsigned short striphtml::skip_ws_end()
362{ 361{
363 unsigned long dummy; 362 unsigned long dummy;
364 return skip_ws_end(dummy); 363 return skip_ws_end(dummy);
365} 364}
366 365
367unsigned short striphtml::skip_ws_end(unsigned long& pos) 366unsigned short striphtml::skip_ws_end(unsigned long& pos)
368{ 367{
369 tchar ch; 368 tchar ch;
370 CStyle sty; 369 CStyle sty;
371 do 370 do
372 { 371 {
373 mygetch(ch, sty, pos); 372 mygetch(ch, sty, pos);
374 } 373 }
375 while (ch != '>' && ch != UEOF); 374 while (ch != '>' && ch != UEOF);
376 return ch; 375 return ch;
377} 376}
378 377
379QString striphtml::getname(tchar& ch, const QString& nd) 378QString striphtml::getname(tchar& ch, const QString& nd)
380{ 379{
381 QString nm = ""; 380 QString nm = "";
382 // nm += ch; 381 // nm += ch;
383 CStyle sty; 382 CStyle sty;
384 unsigned long dummy; 383 unsigned long dummy;
385 while (1) 384 while (1)
386 { 385 {
387 // if ( QChar(ch).isLetterOrNumber() ) 386 // if ( QChar(ch).isLetterOrNumber() )
388 if (ch != UEOF && nd.find(ch, 0, false) == -1 && nm.length() < 2048) 387 if (ch != UEOF && nd.find(ch, 0, false) == -1 && nm.length() < 2048)
389 { 388 {
390 nm += ch; 389 nm += ch;
391 } 390 }
392 else 391 else
393 { 392 {
394 break; 393 break;
395 } 394 }
396 mygetch(ch, sty, dummy); 395 mygetch(ch, sty, dummy);
397 } 396 }
398 return nm; 397 return nm;
399} 398}
400 399
401QString striphtml::getattr(tchar& ch) 400QString striphtml::getattr(tchar& ch)
402{ 401{
403 QString ref; 402 QString ref;
404 CStyle sty; 403 CStyle sty;
405 unsigned long pos; 404 unsigned long pos;
406 if (ch == ' ') ch = skip_ws(); 405 if (ch == ' ') ch = skip_ws();
407 if (ch == '=') 406 if (ch == '=')
408 { 407 {
409 ch = skip_ws(); 408 ch = skip_ws();
410 if (ch == '"') 409 if (ch == '"')
411 { 410 {
412 mygetch(ch, sty, pos); 411 mygetch(ch, sty, pos);
413 ref = getname(ch, "\""); 412 ref = getname(ch, "\"");
414 ch = skip_ws(); 413 ch = skip_ws();
415 } 414 }
416 else 415 else
417 { 416 {
418 ref = getname(ch, " >"); 417 ref = getname(ch, " >");
419 if (ch == ' ') ch = skip_ws(); 418 if (ch == ' ') ch = skip_ws();
420 } 419 }
421 } 420 }
422 return ref; 421 return ref;
423} 422}
424 423
425linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm) 424linkType striphtml::hyperlink(unsigned int n, unsigned int, QString& w, QString& nm)
426{ 425{
427#if defined(USEQPE) || defined(_WINDOWS) 426#if defined(USEQPE) || defined(_WINDOWS)
428 QMap<unsigned long, QString>::Iterator hrefit = id2href->find(n); 427 QMap<unsigned long, QString>::Iterator hrefit = id2href->find(n);
429#else 428#else
430 QMap<unsigned long, QString>::iterator hrefit = id2href->find(n); 429 QMap<unsigned long, QString>::iterator hrefit = id2href->find(n);
431#endif 430#endif
432 if (hrefit == id2href->end()) 431 if (hrefit == id2href->end())
433 { 432 {
434 return eNone; 433 return eNone;
435 } 434 }
436 QString href = *hrefit; 435 QString href = *hrefit;
437#if defined(USEQPE) || defined(_WINDOWS) 436#if defined(USEQPE) || defined(_WINDOWS)
438 QMap<QString, unsigned long>::Iterator fpit = href2filepos->find(href); 437 QMap<QString, unsigned long>::Iterator fpit = href2filepos->find(href);
439#else 438#else
440 QMap<QString, unsigned long>::iterator fpit = href2filepos->find(href); 439 QMap<QString, unsigned long>::iterator fpit = href2filepos->find(href);
441#endif 440#endif
442 if (fpit == href2filepos->end()) 441 if (fpit == href2filepos->end())
443 { 442 {
444 if (href == "history.back()") 443 if (href == "history.back()")
445 { 444 {
446 QString fc = currentfile; 445 QString fc = currentfile;
447 unsigned long loc; 446 unsigned long loc;
448 htmlmark m(fc, loc); 447 htmlmark m(fc, loc);
449 linkType ret = (m_nav.back(m)) ? eFile : eNone; 448 linkType ret = (m_nav.back(m)) ? eFile : eNone;
450 if (fc == m.filename()) 449 if (fc == m.filename())
451 { 450 {
452 if ((ret & eFile) != 0) 451 if ((ret & eFile) != 0)
453 { 452 {
454 locate(m.posn()); 453 locate(m.posn());
455 return eLink; 454 return eLink;
456 } 455 }
457 } 456 }
458 return eNone; 457 return eNone;
459 } 458 }
460 qDebug("Searching for %s", (const char*)href); 459 qDebug("Searching for %s", (const char*)href);
461 460
462 461
463 QString file, name; 462 QString file, name;
464 463
465 int colon = href.find('#'); 464 int colon = href.find('#');
466 if (colon >= 0) 465 if (colon >= 0)
467 { 466 {
468 file = dehtml(href.left(colon)); 467 file = dehtml(href.left(colon));
469 name = dehtml(href.right(href.length()-colon-1)); 468 name = dehtml(href.right(href.length()-colon-1));
470 } 469 }
471 else 470 else
472 { 471 {
473 file = dehtml(href); 472 file = dehtml(href);
474 } 473 }
475 474
476 qDebug("File:%s", (const char*)file); 475 qDebug("File:%s", (const char*)file);
477 qDebug("Name:%s", (const char*)name); 476 qDebug("Name:%s", (const char*)name);
478 477
479 478
480 if (file.isEmpty()) 479 if (file.isEmpty())
481 { 480 {
482 fpit = href2filepos->find(name); 481 fpit = href2filepos->find(name);
483 if (fpit != href2filepos->end()) 482 if (fpit != href2filepos->end())
484 { 483 {
485 locate(*fpit); 484 locate(*fpit);
486 return eLink; 485 return eLink;
487 } 486 }
488 else 487 else
489 { 488 {
490 // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\""; 489 // nm = QString("<a[^>]*name[ \t]*=[ \t]*\"") + name + "\"";
491 qDebug("Do a search for:%s", (const char*)name); 490 qDebug("Do a search for:%s", (const char*)name);
492 parent->locate(0); 491 parent->locate(0);
493 findanchor(name); 492 findanchor(name);
494 return eLink; 493 return eLink;
495 } 494 }
496 } 495 }
497 else 496 else
498 // if (href.find('#') == -1) 497 // if (href.find('#') == -1)
499 { 498 {
500 if (m_bchm) 499 if (m_bchm)
501 { 500 {
502 w = "/"+file; 501 w = "/"+file;
503 nm = name; 502 nm = name;
504 return eFile; 503 return eFile;
505 } 504 }
506 else 505 else
507 { 506 {
508 QFileInfo f(currentfile); 507 QFileInfo f(currentfile);
509 QFileInfo f1(f.dir(true), file); 508 QFileInfo f1(f.dir(true), file);
510 if (f1.exists()) 509 if (f1.exists())
511 { 510 {
512 w = f1.absFilePath(); 511 w = f1.absFilePath();
513 nm = name; 512 nm = name;
514 } 513 }
515 else 514 else
516 { 515 {
517 w = file; 516 w = file;
518 } 517 }
519 return (f1.exists() ? eFile : eNone); 518 return (f1.exists() ? eFile : eNone);
520 } 519 }
521 } 520 }
522 return eNone; 521 return eNone;
523 } 522 }
524 locate(*fpit); 523 locate(*fpit);
525 // parent->locate((*href2filepos)[(*id2href)[n]]); 524 // parent->locate((*href2filepos)[(*id2href)[n]]);
526 return eLink; 525 return eLink;
527} 526}
528/* 527/*
529unsigned short striphtml::parse_m() 528unsigned short striphtml::parse_m()
530{ 529{
531 tchar ch; 530 tchar ch;
532 CStyle sty; 531 CStyle sty;
533 unsigned long dummy; 532 unsigned long dummy;
534 mygetch(ch, sty, dummy); 533 mygetch(ch, sty, dummy);
535 if (ch == 'm' || ch == 'M') 534 if (ch == 'm' || ch == 'M')
536 { 535 {
537 ch = skip_ws_end(); 536 ch = skip_ws_end();
538 if (ch == '>') 537 if (ch == '>')
539 { 538 {
540 return 0; 539 return 0;
541 } 540 }
542 } 541 }
543 return ch; 542 return ch;
544} 543}
545*/ 544*/
546 545
547void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos) 546void striphtml::mygetch(tchar& ch, CStyle& sty, unsigned long& pos)
548{ 547{
549 if (!text_q.isEmpty() && !m_inblock) 548 if (!text_q.isEmpty() && !m_inblock)
550 { 549 {
551 ch = text_q[0].unicode(); 550 ch = text_q[0].unicode();
552 text_q = text_q.right(text_q.length()-1); 551 text_q = text_q.right(text_q.length()-1);
553 } 552 }
554 else 553 else
555 { 554 {
556 parent->getch(ch, sty, pos); 555 parent->getch(ch, sty, pos);
557 if (ch == '<') 556 if (ch == '<')
558 { 557 {
559 m_inblock = true; 558 m_inblock = true;
560 } 559 }
561 if (ch == '>') 560 if (ch == '>')
562 { 561 {
563 m_inblock = false; 562 m_inblock = false;
564 } 563 }
565 } 564 }
566 if (ch == 10 && !isPre) 565 if (ch == 10 && !isPre)
567 { 566 {
568 ch = ' '; 567 ch = ' ';
569 } 568 }
570} 569}
571 570
572void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos) 571void striphtml::parse_paragraph(CStyle& currentstyle, tchar& ch, unsigned long pos)
573{ 572{
574/* 573/*
575 int count = 0; 574 int count = 0;
576 for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter) 575 for (CList<CStyle>::iterator iter = stylestack.begin(); iter != stylestack.end(); ++iter)
577 { 576 {
578 count++; 577 count++;
579 } 578 }
580 qDebug("Currently have %u styles", count); 579 qDebug("Currently have %u styles", count);
581*/ 580*/
582 if (stylestack.isEmpty()) 581 if (stylestack.isEmpty())
583 { 582 {
584 currentstyle.unset(); 583 currentstyle.unset();
585 } 584 }
586 else 585 else
587 { 586 {
588 qDebug("Using stack style"); 587 qDebug("Using stack style");
589 currentstyle = stylestack.first(); 588 currentstyle = stylestack.first();
590 } 589 }
591 if (forcecentre) 590 if (forcecentre)
592 { 591 {
593 currentstyle.setCentreJustify(); 592 currentstyle.setCentreJustify();
594 } 593 }
595 if (ch == ' ') ch = skip_ws(); 594 if (ch == ' ') ch = skip_ws();
596 while (ch != '>' && ch != UEOF) 595 while (ch != '>' && ch != UEOF)
597 { 596 {
598 QString ent = getname(ch, " =>").lower(); 597 QString ent = getname(ch, " =>").lower();
599 QString attr = getattr(ch).lower(); 598 QString attr = getattr(ch).lower();
600 //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr); 599 //qDebug("(Paragraph)Entity:%s Attr:%s", (const char*)ent, (const char*)attr);
601 if (ent == "align") 600 if (ent == "align")
602 { 601 {
603 if (attr == "center") 602 if (attr == "center")
604 { 603 {
605 currentstyle.setCentreJustify(); 604 currentstyle.setCentreJustify();
606 } 605 }
607 if (attr == "right") 606 if (attr == "right")
608 { 607 {
609 currentstyle.setRightJustify(); 608 currentstyle.setRightJustify();
610 } 609 }
611 } 610 }
612 if (ent == "id") 611 if (ent == "id")
613 { 612 {
614 (*href2filepos)[attr] = pos; 613 (*href2filepos)[attr] = pos;
615 } 614 }
616 if (ent == "bgcolor") 615 if (ent == "bgcolor")
617 { 616 {
618 qDebug("Got paper colour:%s", (const char*)attr); 617 qDebug("Got paper colour:%s", (const char*)attr);
619 unsigned char r,g,b; 618 unsigned char r,g,b;
620 parse_color(attr, r, g, b); 619 parse_color(attr, r, g, b);
621 currentstyle.setPaper(r, g, b); 620 currentstyle.setPaper(r, g, b);
622 } 621 }
623 if (ent == "color") 622 if (ent == "color")
624 { 623 {
625 qDebug("Got foreground colour:%s", (const char*)attr); 624 qDebug("Got foreground colour:%s", (const char*)attr);
626 unsigned char r,g,b; 625 unsigned char r,g,b;
627 parse_color(attr, r, g, b); 626 parse_color(attr, r, g, b);
628 currentstyle.setColour(r, g, b); 627 currentstyle.setColour(r, g, b);
629 } 628 }
630 if (ch == ' ') ch = skip_ws(); 629 if (ch == ' ') ch = skip_ws();
631 } 630 }
632 ch = 10; 631 ch = 10;
633} 632}
634 633
635void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos) 634void striphtml::getch(tchar& ch, CStyle& sty, unsigned long& pos)
636{ 635{
637 currentstyle.clearPicture(); 636 currentstyle.clearPicture();
638 if (!q.isEmpty()) 637 if (!q.isEmpty())
639 { 638 {
640 ch = q[0].unicode(); 639 ch = q[0].unicode();
641 if (ch == '-') 640 if (ch == '-')
642 { 641 {
643 tchar w = q[1].unicode(); 642 tchar w = q[1].unicode();
644 tchar h = q[2].unicode(); 643 tchar h = q[2].unicode();
645 unsigned char r = q[3].unicode(); 644 unsigned char r = q[3].unicode();
646 unsigned char g = q[4].unicode(); 645 unsigned char g = q[4].unicode();
647 unsigned char b = q[5].unicode(); 646 unsigned char b = q[5].unicode();
648 ch = '#'; 647 ch = '#';
649 //qDebug("html:hrule<%u, %u>", w, h); 648 //qDebug("html:hrule<%u, %u>", w, h);
650 currentstyle.setPicture(false, hRule(w,h,r,g,b)); 649 currentstyle.setPicture(false, hRule(w,h,r,g,b));
651 q = q.right(q.length()-6); 650 q = q.right(q.length()-6);
652 } 651 }
653 else 652 else
654 { 653 {
655 q = q.right(q.length()-1); 654 q = q.right(q.length()-1);
656 } 655 }
657 sty = currentstyle; 656 sty = currentstyle;
658 return; 657 return;
659 } 658 }
660 do 659 do
661 { 660 {
662 unsigned long npos; 661 unsigned long npos;
663 CStyle dummy; 662 CStyle dummy;
664 mygetch(ch, dummy, pos); 663 mygetch(ch, dummy, pos);
665 // if (ch == 10 && !isPre) ch = ' '; 664 // if (ch == 10 && !isPre) ch = ' ';
666 while (ch == '<' && ch != UEOF) 665 while (ch == '<' && ch != UEOF)
667 { 666 {
668 ch = skip_ws(); 667 ch = skip_ws();
669 668
670 QString ent = getname(ch, " >").lower(); 669 QString ent = getname(ch, " >").lower();
671 670
672 // qDebug("Entity:%s", (const char*)ent); 671 // qDebug("Entity:%s", (const char*)ent);
673 672
674 if (ent == "a"/* || ent == "reference"*/) 673 if (ent == "a"/* || ent == "reference"*/)
675 { 674 {
676 if (ch == ' ') ch = skip_ws(); 675 if (ch == ' ') ch = skip_ws();
677 bool fileposfound = false; 676 bool fileposfound = false;
678 bool ishref = false; 677 bool ishref = false;
679 unsigned int filepos = 0; 678 unsigned int filepos = 0;
680 QString ref, name; 679 QString ref, name;
681 while (ch != '>' && ch != UEOF) 680 while (ch != '>' && ch != UEOF)
682 { 681 {
683 QString ent = getname(ch, " =>").lower(); 682 QString ent = getname(ch, " =>").lower();
684 QString attr = getattr(ch); 683 QString attr = getattr(ch);
685 qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr); 684 qDebug("<A>Entity:%s Attr:%s", (const char*)ent, (const char*)attr);
686 if (ent == "name") 685 if (ent == "name")
687 { 686 {
688 name = attr; 687 name = attr;
689 } 688 }
690 if (ent == "onclick") 689 if (ent == "onclick")
691 { 690 {
692 int st = attr.find('\''); 691 int st = attr.find('\'');
693 int nd = attr.findRev('\''); 692 int nd = attr.findRev('\'');
694 ref = attr.mid(st+1, nd-st-1); 693 ref = attr.mid(st+1, nd-st-1);
695 ishref = true; 694 ishref = true;
696 qDebug("Onclick:%s", (const char*)ref); 695 qDebug("Onclick:%s", (const char*)ref);
697 } 696 }
698 if (ent == "href") 697 if (ent == "href")
699 { 698 {
700 ishref = true; 699 ishref = true;
701 ref = attr; 700 ref = attr;
702 } 701 }
703 if (ent == "filepos") 702 if (ent == "filepos")
704 { 703 {
705 filepos = attr.toUInt(&fileposfound); 704 filepos = attr.toUInt(&fileposfound);
706 if (ref.isEmpty()) 705 if (ref.isEmpty())
707 { 706 {
708 ishref = true; 707 ishref = true;
709 ref = attr; 708 ref = attr;
710 } 709 }
711 } 710 }
712 if (ent == "title") 711 if (ent == "title")
713 { 712 {
714 text_q = attr + "</a><p>"; 713 text_q = attr + "</a><p>";
715 } 714 }
716 qDebug("<a %s=%s>", (const char*)ent, (const char*)ref); 715 qDebug("<a %s=%s>", (const char*)ent, (const char*)ref);
717 } 716 }
718 if (ishref) 717 if (ishref)
719 { 718 {
720 currentstyle.setColour(0,0,255); 719 currentstyle.setColour(0,0,255);
721 currentstyle.setLink(true); 720 currentstyle.setLink(true);
722 currentstyle.setData(currentid); 721 currentstyle.setData(currentid);
723 if (!text_q.isEmpty()) 722 if (!text_q.isEmpty())
724 { 723 {
725 currentstyle.setBold(); 724 currentstyle.setBold();
726 currentstyle.setCentreJustify(); 725 currentstyle.setCentreJustify();
727 } 726 }
728 (*id2href)[currentid] = ref; 727 (*id2href)[currentid] = ref;
729 currentid++; 728 currentid++;
730 729
731 730
732 if (fileposfound) 731 if (fileposfound)
733 { 732 {
734 (*href2filepos)[ref] = filepos; 733 (*href2filepos)[ref] = filepos;
735 } 734 }
736 } 735 }
737 if (!name.isEmpty()) 736 if (!name.isEmpty())
738 { 737 {
739 (*href2filepos)[name] = pos; 738 (*href2filepos)[name] = pos;
740 } 739 }
741 } 740 }
742 else if (ent == "p") 741 else if (ent == "p")
743 { 742 {
744 parse_paragraph(currentstyle, ch, pos); 743 parse_paragraph(currentstyle, ch, pos);
745 currentstyle.setExtraSpace(3); 744 currentstyle.setExtraSpace(3);
746 continue; 745 continue;
747 } 746 }
748 else if (ent == "div") 747 else if (ent == "div")
749 { 748 {
750 parse_paragraph(currentstyle, ch, pos); 749 parse_paragraph(currentstyle, ch, pos);
751 stylestack.push_front(currentstyle); 750 stylestack.push_front(currentstyle);
752 //indent = 0; 751 //indent = 0;
753 continue; 752 continue;
754 } 753 }
755 else if (ent == "sup") 754 else if (ent == "sup")
756 { 755 {
757 currentstyle.setVOffset(-1); 756 currentstyle.setVOffset(-1);
758 } 757 }
759 else if (ent == "sup") 758 else if (ent == "sup")
760 { 759 {
761 currentstyle.setVOffset(1); 760 currentstyle.setVOffset(1);
762 } 761 }
763 else if (ent == "/sup" || ent == "/sub") 762 else if (ent == "/sup" || ent == "/sub")
764 { 763 {
765 currentstyle.setVOffset(0); 764 currentstyle.setVOffset(0);
766 } 765 }
767 else if (ent == "span") 766 else if (ent == "span")
768 { 767 {
769 if (ch == ' ') ch = skip_ws(); 768 if (ch == ' ') ch = skip_ws();
770 while (ch != '>' && ch != UEOF) 769 while (ch != '>' && ch != UEOF)
771 { 770 {
772 QString ent = getname(ch, " =>").lower(); 771 QString ent = getname(ch, " =>").lower();
773 QString attr = getattr(ch).lower(); 772 QString attr = getattr(ch).lower();
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
8ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ } 7ztxt::ztxt() : bInit(false), expandedtextbuffer(NULL), compressedtextbuffer(NULL) { /*printf("constructing:%x\n",fin);*/ }
9 8
10 9
11int ztxt::OpenFile(const char *src) 10int 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
38int ztxt::getch() 37int 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
61unsigned int ztxt::locate() 60unsigned int ztxt::locate()
62{ 61{
63 return currentpos; 62 return currentpos;
64} 63}
65 64
66void ztxt::locate(unsigned int n) 65void 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
109void ztxt::home() 108void 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
142CList<Bkmk>* ztxt::getbkmklist() 141CList<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
170extern "C" 169extern "C"
171{ 170{
172 CExpander* newcodec() { return new ztxt; } 171 CExpander* newcodec() { return new ztxt; }
173} 172}
174#endif 173#endif